Пример #1
0
/* TextEditor::onCalltipClicked
 * Called when the current calltip is clicked on
 *******************************************************************/
void TextEditor::onCalltipClicked(wxStyledTextEvent& e)
{
	// Can't do anything without function
	if (!ct_function)
		return;

	// Argset up
	if (e.GetPosition() == 1)
	{
		if (ct_argset > 0)
		{
			ct_argset--;
			updateCalltip();
		}
	}

	// Argset down
	if (e.GetPosition() == 2)
	{
		if ((unsigned)ct_argset < ct_function->nArgSets() - 1)
		{
			ct_argset++;
			updateCalltip();
		}
	}
}
Пример #2
0
void SubsTextEditCtrl::OnDoubleClick(wxStyledTextEvent &evt) {
	int pos = evt.GetPosition();
	if (pos == -1 && !tokenized_line.empty()) {
		auto tok = tokenized_line.back();
		SetSelection(line_text.size() - tok.length, line_text.size());
	}
	else {
		auto bounds = GetBoundsOfWordAtPosition(evt.GetPosition());
		if (bounds.second != 0)
			SetSelection(bounds.first, bounds.first + bounds.second);
		else
			evt.Skip();
	}
}
Пример #3
0
void SubsTextEditCtrl::OnDoubleClick(wxStyledTextEvent &evt) {
	auto bounds = GetBoundsOfWordAtPosition(evt.GetPosition());
	if (bounds.second != 0)
		SetSelection(bounds.first, bounds.first + bounds.second);
	else
		evt.Skip();
}
Пример #4
0
void wxSTEditorFindReplacePanel::OnMarginClick( wxStyledTextEvent &event )
{
    if (!m_resultEditor) return; // set after editor is fully created

    if (event.GetEventType() == wxEVT_STE_MARGINDCLICK)
        return;

    wxSTEditor *editor = (wxSTEditor*)event.GetEventObject();
    int pos = event.GetPosition();

    if (event.GetEventType() == wxEVT_STC_DOUBLECLICK) // event pos not set correctly
        pos = editor->GetCurrentPos();

    int line = editor->LineFromPosition(pos);

    if (editor->GetLine(line).Strip(wxString::both).IsEmpty())
        return;

    wxArrayString* findAllStrings = m_findReplaceData->GetFindAllStrings();

    if ((line < 0) || (line >= (int)findAllStrings->GetCount()))
        return;

    editor->MarkerDeleteAll(STE_MARKER_BOOKMARK);
    editor->MarkerAdd(line, STE_MARKER_BOOKMARK);

    wxFindDialogEvent fEvent(wxEVT_COMMAND_FIND_NEXT, GetId());
    fEvent.SetEventObject(this);
    fEvent.SetFindString(m_findCombo->GetValue());
    fEvent.SetFlags(GetFindFlags());
    fEvent.SetExtraLong(line);
    Send(fEvent);
}
void t4p::PhpCallTipProviderClass::OnCallTipClick(wxStyledTextEvent& evt) {
    wxStyledTextCtrl* ctrl = wxDynamicCast(evt.GetEventObject(), wxStyledTextCtrl);

    if (!CurrentCallTipResources.empty()) {
        size_t resourcesSize = CurrentCallTipResources.size();
        int position = evt.GetPosition();
        wxString callTip;

        // up arrow. if already at the first choice, then loop around
        // looping around looks better than hiding arrows; because hiding arrows changes the
        // rendering position and make the call tip jump around when clicking up/down
        if (1 == position) {
            CurrentCallTipIndex = ((CurrentCallTipIndex >= 1) && (CurrentCallTipIndex - 1) < resourcesSize) ? CurrentCallTipIndex - 1 : resourcesSize - 1;
            callTip =  PhpCallTipSignature(CurrentCallTipIndex, CurrentCallTipResources);
        } else if (2 == position) {
            // down arrow
            CurrentCallTipIndex = ((CurrentCallTipIndex + 1) < resourcesSize) ? CurrentCallTipIndex + 1 : 0;
            callTip = PhpCallTipSignature(CurrentCallTipIndex, CurrentCallTipResources);
        }
        if (!callTip.IsEmpty()) {
            ctrl->CallTipCancel();
            ctrl->CallTipShow(ctrl->GetCurrentPos(), callTip);
        }
    }
    evt.Skip();
}
Пример #6
0
void ctlSQLBox::OnMarginClick(wxStyledTextEvent &event)
{
	if (event.GetMargin() == 2)
		ToggleFold(LineFromPosition(event.GetPosition()));

	event.Skip();
}
Пример #7
0
void TextFrame::OnTextModified(wxStyledTextEvent& event)
{
    wxStyledTextCtrl* txt = getCurrentTextCtrl();
    if(txt)
    {
        int line  = txt->LineFromPosition(event.GetPosition()),
            lines = event.GetLinesAdded(),
            linecount = txt->GetLineCount();

        getDocument()->setModified(txt->IsModified());

        if(lines!=0)
        {
            // Add or remove lines
            updateLineNbMargin();
            _fastFindLine->SetRange(1, linecount);

            // Bookmarks
            if(getDocument()->getBookmarks().addLines(line, lines))
                UpdateBookmarkPanel();

            // Markers
            _markbar->SetMax(linecount);
            _markbar->MoveMarkers(line, lines);
        }
    }

    event.Skip();
}
Пример #8
0
void StyledTextCtrl::OnMarginClick(wxStyledTextEvent& event)
{
    int lineClick = LineFromPosition(event.GetPosition());
    int levelClick = GetFoldLevel(lineClick);
    switch (event.GetMargin())
    {
        case MARGIN_FOLD:
            if ((levelClick & wxSTC_FOLDLEVELHEADERFLAG) > 0)
            {
                ToggleFold(lineClick);
            }
            break;
        case MARGIN_LINE_BREAKS:
            if (MarkerGet(lineClick) == 0)
            {
                MarkerAdd(lineClick, 0);
            }
            else
            {
                MarkerDelete(lineClick, 0);
            }
            break;
        case MARGIN_LINE_EDITS:
            break;
        case MARGIN_LINE_NUMBERS:
            break;
        default:
            break;
    }
}
Пример #9
0
////////////////////////////////////////////////////////////////////////////////
// OnMarginClick()
//
//     This function handles the user clicks in the margin to the left of a
//     line of source code. We use the margin to display breakpoint indicators
//     so it makes sense that if you click on an breakpoint indicator, we will
//     clear that breakpoint.  If you click on a spot that does not contain a
//     breakpoint indicator (but it's still in the margin), we create a new
//     breakpoint at that line
//
// Parametes:
//     Selection Event Object
//
void frmDebugger::OnMarginClick(wxStyledTextEvent &event)
{
	int lineNo;

	// Check that the user clicked on the line number or breakpoint margin
	// We don't want to set a breakpoint when the user folds/unfolds code
	if (!(event.GetMargin() == 0 || event.GetMargin() == 1))
		return;

	lineNo = m_codeViewer->LineFromPosition(event.GetPosition());

	if (lineNo <= 0)
		return;

	// If we already have a breakpoint at the clickpoint, disable it, otherwise
	// create a new breakpoint
	if(m_codeViewer->MarkerGet(lineNo) &
	        MARKERINDEX_TO_MARKERMASK(MARKER_BREAKPOINT))
	{
		m_controller->ClearBreakpoint(lineNo);
	}
	else
	{
		m_controller->SetBreakpoint(lineNo);
	}
	m_controller->UpdateBreakpoints();
}
Пример #10
0
/* TextEditor::onMouseDwellStart
 * Called when the mouse pointer has 'dwelt' in one position for a
 * certain amount of time
 *******************************************************************/
void TextEditor::onMouseDwellStart(wxStyledTextEvent& e)
{
	if (wxTheApp->IsActive() && HasFocus() && !call_tip->IsShown() && txed_calltips_mouse && e.GetPosition() >= 0)
	{
		openCalltip(e.GetPosition(), -1, true);
		ct_dwell = true;
	}
}
Пример #11
0
//! misc
void Edit::OnMarginClick (wxStyledTextEvent &event) {
    if (event.GetMargin() == 2) {
        int lineClick = LineFromPosition (event.GetPosition());
        int levelClick = GetFoldLevel (lineClick);
        if ((levelClick & wxSTC_FOLDLEVELHEADERFLAG) > 0) {
            ToggleFold (lineClick);
        }
    }
}
Пример #12
0
void FindUsageTab::OnMouseDClick(wxStyledTextEvent& e)
{
    long pos = e.GetPosition();
    int line = m_sci->LineFromPosition(pos);
    UsageResultsMap::const_iterator iter = m_matches.find(line);
    if(iter != m_matches.end()) {
        DoOpenResult(iter->second);
    }

    m_sci->SetSelection(wxNOT_FOUND, pos);
}
Пример #13
0
/* TextEditor::onMarginClick
 * Called when a margin is clicked
 *******************************************************************/
void TextEditor::onMarginClick(wxStyledTextEvent& e)
{
	if (e.GetMargin() == 1)
	{
		int line = LineFromPosition(e.GetPosition());
		int level = GetFoldLevel(line);
		if ((level & wxSTC_FOLDLEVELHEADERFLAG) > 0)
			ToggleFold(line);
		updateFolding();
	}
}
Пример #14
0
void ReplaceInFilesPanel::OnMarginClick(wxStyledTextEvent& e)
{
    int line = m_sci->LineFromPosition(e.GetPosition());
    if(m_matchInfo.find(line) == m_matchInfo.end()) {
        FindResultsTab::OnMarginClick(e);

    } else if(m_sci->MarkerGet(line) & 7 << 0x7) {
        m_sci->MarkerDelete(line, 0x7);
    } else {
        m_sci->MarkerAdd(line, 0x7);
    }
}
Пример #15
0
void IWnd_stc::OnMarginClick (wxStyledTextEvent &evt)
{
	if (evt.GetMargin() == StcManager::FOLDING_ID) 
	{
        int lineClick = LineFromPosition (evt.GetPosition());
        int levelClick = GetFoldLevel (lineClick);
        if ((levelClick & wxSTC_FOLDLEVELHEADERFLAG) > 0) 
		{
            ToggleFold (lineClick);
        }
    }
}
Пример #16
0
// Event callback when a margin is clicked, used here for code folding
void SavvyEditor::AppFrame::OnMarginClick(wxStyledTextEvent& a_Event)
{
	if (a_Event.GetMargin() == MARGIN_FOLD)
	{
		int lineClick = m_LastSelectedTextCtrl->LineFromPosition(a_Event.GetPosition());
		int levelClick = m_LastSelectedTextCtrl->GetFoldLevel(lineClick);

		if ((levelClick & wxSTC_FOLDLEVELHEADERFLAG) > 0)
		{
			m_LastSelectedTextCtrl->ToggleFold(lineClick);
		}
	}
}
Пример #17
0
void FileEditorWnd::OnMarginClick(wxStyledTextEvent& event)
{
	switch(event.GetMargin())
	{
		case MARGIN_BREAKPOINTS:
		{
			doBreakpoint(m_textCtrl->LineFromPosition(event.GetPosition()));
		}
		break;
		case MARGIN_FOLD:
		{
			int txtline = m_textCtrl->LineFromPosition(event.GetPosition());
			int levelClick = m_textCtrl->GetFoldLevel(txtline);

			if ((levelClick & wxSTC_FOLDLEVELHEADERFLAG) > 0)
			{
				m_textCtrl->ToggleFold(txtline);
			}
		}
		break;
	}
}
Пример #18
0
void udCodeEditorPanel::OnMarginClick ( wxStyledTextEvent &event )
{
	if ( event.GetMargin() == 1 )
	{
		int lineClick = m_scintillaEditor->LineFromPosition ( event.GetPosition() );
		int levelClick = m_scintillaEditor->GetFoldLevel ( lineClick );

		if ( ( levelClick & wxSTC_FOLDLEVELHEADERFLAG ) > 0 )
		{
			m_scintillaEditor->ToggleFold ( lineClick );
		}
	}
}
Пример #19
0
void TextFrame::OnMarginClick(wxStyledTextEvent& event)
{
  if (event.GetMargin() == MARGIN_FOLD) {
    wxStyledTextCtrl* txt = getCurrentTextCtrl();
    if(txt)
    {
      int line  = txt->LineFromPosition(event.GetPosition());
      int levelClick = txt->GetFoldLevel (line);
      if ((levelClick & wxSTC_FOLDLEVELHEADERFLAG) > 0) {
        txt->ToggleFold (line);
      }
    }
  }
} 
Пример #20
0
void FindResultsTab::OnMouseDClick(wxStyledTextEvent& e)
{
    long pos = e.GetPosition();
    int line = m_sci->LineFromPosition(pos);
    int style = m_sci->GetStyleAt(pos);

    if(style == LEX_FIF_FILE || style == LEX_FIF_HEADER) {
        m_sci->ToggleFold(line);

    } else {
        MatchInfo_t::const_iterator m = m_matchInfo.find(line);
        if(m != m_matchInfo.end()) {
            DoOpenSearchResult(m->second, m_sci, m->first);
        }
    }
}
Пример #21
0
void NewBuildTab::OnStyleNeeded(wxStyledTextEvent& event)
{
    int startPos = m_view->GetEndStyled();
    int endPos = event.GetPosition();
    wxString text = m_view->GetTextRange(startPos, endPos);
#if wxCHECK_VERSION(3, 1, 1) && !defined(__WXOSX__)
    // The scintilla syntax in e.g. wx3.1.1 changed
    m_view->StartStyling(startPos);
#else
    m_view->StartStyling(startPos, 0x1f);
#endif

    int curline = m_view->GetLineCount();
    curline -= 1; // The view always ends with a "\n", we don't count it as a line
    wxArrayString lines = ::wxStringTokenize(text, wxT("\n"), wxTOKEN_RET_DELIMS);

    // the last line that we coloured
    curline -= lines.size();

    for(size_t i = 0; i < lines.size(); ++i) {
        const wxString& strLine = lines.Item(i);
        if(m_viewData.count(curline)) {
            BuildLineInfo* b = m_viewData.find(curline)->second;
            switch(b->GetSeverity()) {
            case SV_WARNING:
                m_view->SetStyling(strLine.length(), LEX_GCC_WARNING);
                break;
            case SV_ERROR:
                m_view->SetStyling(strLine.length(), LEX_GCC_ERROR);
                break;
            case SV_SUCCESS:
                m_view->SetStyling(strLine.length(), LEX_GCC_DEFAULT);
                break;
            case SV_DIR_CHANGE:
                m_view->SetStyling(strLine.length(), LEX_GCC_INFO);
                break;
            case SV_NONE:
            default:
                m_view->SetStyling(strLine.length(), LEX_GCC_DEFAULT);
                break;
            }
        } else {
            m_view->SetStyling(strLine.length(), LEX_GCC_DEFAULT);
        }
        ++curline;
    }
}
Пример #22
0
/**
 * source is modified
 */
void FbEditor::onModified(wxStyledTextEvent & event)
{
    // not directly modifying text?
    auto flags = event.GetModificationType();
    if ((flags & (wxSTC_MOD_INSERTTEXT | wxSTC_MOD_DELETETEXT)) == 0) return;

    // set input buffer
    m_srcCtx->setBuffer(GetCharacterPointer());

    // get modified line & line length
    int line     = LineFromPosition(event.GetPosition());
    int pos      = PositionFromLine(line);
    int length   = this->GetLineLength(line);

    // analyze the source
    m_srcCtx->analyze(line, pos, length);
}
Пример #23
0
void mxGdbCommandsPanel::OnMarginClick (wxStyledTextEvent & e) {
	int l = output->LineFromPosition (e.GetPosition());
	int m = output->MarkerGet(l);
	if (m) {
		int n=output->GetLineCount();
		int l2=l+1; while (l2<n && (!output->GetLine(l2).Len() || !output->GetLine(l2).StartsWith("> "))) l2++; l2--;
		if (m==1) {
			output->MarkerDelete(l,0);
			output->MarkerAdd(l,1);
			output->HideLines(l+1,l2);
		} else {
			output->MarkerDelete(l,1);
			output->MarkerAdd(l,0);
			output->ShowLines(l+1,l2);
		}
	}
	input->SetFocus();
}
Пример #24
0
void DebuggerDisassemblyTab::OnMarginClicked(wxStyledTextEvent& event)
{
    /// get the address of the line
    int nLine = m_stc->LineFromPosition(event.GetPosition());
    wxString line = m_stc->GetLine(nLine);
    wxString address = line.BeforeFirst(' ').Trim(true).Trim(false);
    ;

    if(m_stc->MarkerGet(nLine) & BREAKPOINT_MARKER_MASK) {

        // we already got a marker there
        m_stc->MarkerDelete(nLine, BREAKPOINT_MARKER);
        ManagerST::Get()->GetBreakpointsMgr()->DelBreakpointByAddress(address);

    } else {
        m_stc->MarkerAdd(nLine, BREAKPOINT_MARKER);
        ManagerST::Get()->GetBreakpointsMgr()->AddBreakpointByAddress(address);
    }
    clMainFrame::Get()->GetDebuggerPane()->GetBreakpointView()->Initialize();
}
Пример #25
0
void FindResultsTab::OnMouseDClick(wxStyledTextEvent& e)
{
    long pos = e.GetPosition();
    int line = m_sci->LineFromPosition(pos);
    int style = m_sci->GetStyleAt(pos);

    if(style == LEX_FIF_FILE || style == LEX_FIF_HEADER) {
        m_sci->ToggleFold(line);

    } else {
        int n = m_book ? m_book->GetSelection() : 0;
        const MatchInfo& matchInfo = GetMatchInfo(n);
        MatchInfo::const_iterator m = matchInfo.find(line);
        if(m != matchInfo.end()) {
            DoOpenSearchResult(m->second, m_sci, m->first);
        }
    }

    m_sci->SetSelection(wxNOT_FOUND, pos);
}
Пример #26
0
// Lexing function
// int CppCheckReportPage::ColorLine ( int, const char *text, size_t &start, size_t &len )
//{
//    wxString txt(text, wxConvUTF8);
//
//    if(txt.StartsWith(wxT("Checking "))) {
//        return wxSTC_LEX_GCC_MAKE_ENTER;
//    }
//
//    static wxRegEx gccPattern(wxT("^([^ ][a-zA-Z:]{0,2}[ a-zA-Z\\.0-9_/\\+\\-]+ *)(:)([0-9]*)(:)([a-zA-Z ]*)"));
//
//    static int fileIndex     = 1;
////	static int lineIndex     = 3;
//    static int severityIndex = 4;
//
//    if(gccPattern.Matches(txt)) {
//        wxString severity = gccPattern.GetMatch(txt, severityIndex);
//        gccPattern.GetMatch(&start, &len, fileIndex);
//
//        sErrorCount ++;
//
//        if(severity == wxT("error")) {
//            return wxSTC_LEX_GCC_ERROR;
//        } else {
//            return wxSTC_LEX_GCC_WARNING;
//        }
//    }
//
//    // file: line: severity
//    return wxSTC_LEX_GCC_DEFAULT;
//}
//
void CppCheckReportPage::OnOpenFile(wxStyledTextEvent& e)
{
    static wxRegEx gccPattern(wxT("^([^ ][a-zA-Z:]{0,2}[ a-zA-Z\\.0-9_/\\+\\-]+ *)(:)([0-9]*)(:)([a-zA-Z ]*)"));
    static int fileIndex = 1;
    static int lineIndex = 3;

    wxString txt = m_stc->GetLine(m_stc->LineFromPosition(e.GetPosition()));

    if(gccPattern.Matches(txt)) {
        wxString file = gccPattern.GetMatch(txt, fileIndex);
        wxString lineNumber = gccPattern.GetMatch(txt, lineIndex);

        if(file.IsEmpty() == false) {
            long n(0);
            lineNumber.ToLong(&n);

            // Zero based line number
            if(n)
                n--;
            m_mgr->OpenFile(file, wxEmptyString, n);
        }
    }
}
Пример #27
0
void CodeEdit::OnModified(wxStyledTextEvent& event)
{
    
    event.Skip();    

    int linesAdded = event.GetLinesAdded();
        
    // If we're inserting new lines before a line, so we need to move the
    // markers down. STCntilla doesn't do this automatically for the current line.

    if (linesAdded > 0)
    {
    
        unsigned int position = event.GetPosition();
    
        unsigned int line = LineFromPosition(position);
        unsigned int lineStartPosition = PositionFromLine(line);

        if (position == lineStartPosition)
        {
            
            int markers = MarkerGet(line);

            // Delete all of the markers from the line.
            for (int i = 0; i < 32; ++i)
            {
                MarkerDelete(line, i);
            }

            // Add the markers back on the new line.
            MarkerAddSet(line + linesAdded, markers);

        }

    }    

}
Пример #28
0
/* TextEditor::onStyleNeeded
 * Called when text styling is needed
 *******************************************************************/
void TextEditor::onStyleNeeded(wxStyledTextEvent& e)
{
	// Get range of lines to be updated
	int line_start = LineFromPosition(GetEndStyled());
	int line_end = LineFromPosition(e.GetPosition());

	// Lex until done (end of lines, end of file or end of block comment)
	int l = line_start;
	bool force_next = false;
	while (l <= GetNumberOfLines() && (l <= line_end || force_next))
	{
		int end = GetLineEndPosition(l) - 1;
		int start = end - GetLineLength(l) + 1;

		if (start > end)
			end = start;

		force_next = lexer.doStyling(this, start, end);
		l++;
	}

	if (txed_fold_enable)
		lexer.updateFolding(this, line_start);
}
Пример #29
0
/* TextEditor::onMouseDwellStart
 * Called when the mouse pointer has 'dwelt' in one position for a
 * certain amount of time
 *******************************************************************/
void TextEditor::onMouseDwellStart(wxStyledTextEvent& e)
{
	if (!CallTipActive() && txed_calltips_mouse)
		openCalltip(e.GetPosition(), -1);
}
Пример #30
0
/* TextEditor::onMouseDwellStart
 * Called when the mouse pointer has 'dwelt' in one position for a
 * certain amount of time
 *******************************************************************/
void TextEditor::onMouseDwellStart(wxStyledTextEvent& e)
{
	if (wxTheApp->IsActive() && HasFocus() && !CallTipActive() && txed_calltips_mouse && e.GetPosition() >= 0)
		openCalltip(e.GetPosition(), -1);
}