Example #1
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();
}
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();
}
Example #3
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 wxCodeCompletionBoxManager::OnStcModified(wxStyledTextEvent& event)
{
    event.Skip();
    if(m_box && m_box->IsShown() && m_box->m_stc == event.GetEventObject()) {
        m_box->StcModified(event);
    }
}
Example #5
0
void ctlSQLBox::OnMarginClick(wxStyledTextEvent &event)
{
	if (event.GetMargin() == 2)
		ToggleFold(LineFromPosition(event.GetPosition()));

	event.Skip();
}
Example #6
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();
}
Example #7
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();
		}
	}
}
Example #8
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();
}
Example #9
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;
    }
}
Example #10
0
/* TextEditor::onCharAdded
 * Called when a character is added to the text
 *******************************************************************/
void TextEditor::onCharAdded(wxStyledTextEvent& e)
{
	// Update line numbers margin width
	string numlines = S_FMT("0%d", GetNumberOfLines());
	SetMarginWidth(0, TextWidth(wxSTC_STYLE_LINENUMBER, numlines));

	// Auto indent
	int currentLine = GetCurrentLine();
	if (txed_auto_indent && e.GetKey() == '\n')
	{
		// Get indentation amount
		int lineInd = 0;
		if (currentLine > 0)
			lineInd = GetLineIndentation(currentLine - 1);

		// Do auto-indent if needed
		if (lineInd != 0)
		{
			SetLineIndentation(currentLine, lineInd);

			// Skip to end of tabs
			while (1)
			{
				int chr = GetCharAt(GetCurrentPos());
				if (chr == '\t' || chr == ' ')
					GotoPos(GetCurrentPos()+1);
				else
					break;
			}
		}
	}

	// The following require a language to work
	if (language)
	{
		// Call tip
		if (e.GetKey() == '(' && txed_calltips_parenthesis)
		{
			openCalltip(GetCurrentPos());
		}

		// End call tip
		if (e.GetKey() == ')')
		{
			CallTipCancel();
		}

		// Comma, possibly update calltip
		if (e.GetKey() == ',' && txed_calltips_parenthesis)
		{
			//openCalltip(GetCurrentPos());
			//if (CallTipActive())
			updateCalltip();
		}
	}

	// Continue
	e.Skip();
}
Example #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);
        }
    }
}
Example #12
0
void PyConsole::OnStcEvent(wxStyledTextEvent& event)
{
    if( event.GetEventType() == wxEVT_STC_DOUBLECLICK )
    {
        wxString word = m_control->GetSelectedText();
        HighlightOccurrences(word, wxSTC_FIND_MATCHCASE | wxSTC_FIND_WORDSTART );
        event.Skip();
    }
}
Example #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();
	}
}
Example #14
0
void CodeEdit::OnCharAdded(wxStyledTextEvent& event)
{

    // Indent the line to the same indentation as the previous line.
    // Adapted from http://STCntilla.sourceforge.net/STCntillaUsage.html

    char ch = event.GetKey();

    if  (ch == '\r' || ch == '\n')
    {

        int line        = GetCurrentLine();
        int lineLength  = LineLength(line);

        if (line > 0 && lineLength <= 2)
        {

            wxString buffer = GetLine(line - 1);
                
            for (unsigned int i =  0; i < buffer.Length();  ++i)
            {
                if (buffer[i] != ' ' && buffer[i] != '\t')
                {
                    buffer.Truncate(i);
                    break;
                }
            }

            ReplaceSelection(buffer);
            
            // Remember that we just auto-indented so that the backspace
            // key will un-autoindent us.
            m_autoIndented = true;
            
        }
        
    }
    else if (m_enableAutoComplete && m_autoCompleteManager != NULL)
    {

        // Handle auto completion.

        wxString token;
        
        if (GetTokenFromPosition(GetCurrentPos() - 1, ".:", token))
        {
            StartAutoCompletion(token);
        }

    }

    event.Skip();

}
Example #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);
        }
    }
}
void t4p::PhpCodeCompletionProviderClass::OnAutoCompletionSelected(wxStyledTextEvent& event) {
    wxStyledTextCtrl* txtCtrl = wxDynamicCast(event.GetEventObject(), wxStyledTextCtrl);
    if (!txtCtrl) {
        return;
    }
    t4p::CodeControlClass* ctrl = (t4p::CodeControlClass*)txtCtrl;

    if (!AutoCompletionResourceMatches.empty()) {
        UnicodeString selected = t4p::WxToIcu(event.GetText());

        bool handled = false;
        for (size_t i = 0; i < AutoCompletionResourceMatches.size(); ++i) {
            t4p::PhpTagClass res = AutoCompletionResourceMatches[i];
            if (res.Identifier == selected) {
                // user had selected  a function /method name; let's add the
                // parenthesis and show the call tip
                ctrl->AutoCompCancel();
                wxString selected = event.GetText();
                int startPos = ctrl->WordStartPosition(ctrl->GetCurrentPos(), true);
                ctrl->SetSelection(startPos, ctrl->GetCurrentPos());
                wxString status;
                if ((t4p::PhpTagClass::FUNCTION == res.Type || t4p::PhpTagClass::METHOD == res.Type) && !res.HasParameters()) {
                    ctrl->ReplaceSelection(selected + wxT("()"));
                    ctrl->HandleCallTip(0, true);
                } else if (t4p::PhpTagClass::FUNCTION == res.Type || t4p::PhpTagClass::METHOD == res.Type) {
                    ctrl->ReplaceSelection(selected + wxT("("));
                    ctrl->HandleCallTip(0, true);
                } else {
                    ctrl->ReplaceSelection(selected);
                }
                handled = true;
                break;
            }
        }
        if (!handled) {
            // complete the PHP alternative syntax for control structures
            // ie endif endwhile endfor endforeach endswitch
            // Scintilla cannot handle semicolons in keywords; we will add the semicolon here
            if (selected.caseCompare(UNICODE_STRING_SIMPLE("endif"), 0) == 0 ||
                    selected.caseCompare(UNICODE_STRING_SIMPLE("endwhile"), 0) == 0 ||
                    selected.caseCompare(UNICODE_STRING_SIMPLE("endfor"), 0) == 0 ||
                    selected.caseCompare(UNICODE_STRING_SIMPLE("endforeach"), 0) == 0 ||
                    selected.caseCompare(UNICODE_STRING_SIMPLE("endswitch"), 0) == 0) {
                ctrl->AutoCompCancel();
                wxString selected = event.GetText();
                int startPos = ctrl->WordStartPosition(ctrl->GetCurrentPos(), true);
                ctrl->SetSelection(startPos, ctrl->GetCurrentPos());
                ctrl->ReplaceSelection(selected + wxT(";"));
            }
        }
    }
}
Example #17
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);
		}
	}
}
Example #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 );
		}
	}
}
Example #19
0
void Edit::OnCharAdded(wxStyledTextEvent &event) {
  event.Skip();
  
  const wxChar c = event.GetKey();
  if (c == wxT('\n')) {
    const int line = GetCurrentLine();
    const int indent = line < 1 ? 0 : GetLineIndentation(line - 1);

    if (indent != 0) {
      SetLineIndentation(line, indent);
      GotoPos(GetLineIndentPosition(line));
    }
  }
}
Example #20
0
void SvnConsole::OnCharAdded(wxStyledTextEvent& event)
{
    if(event.GetKey() == '\n') {
        // an enter was inserted
        // take the last inserted line and send it to the m_process
        wxString line = m_sci->GetTextRange(m_inferiorEnd, m_sci->GetLength());
        line.Trim();

        if(m_process) {
            m_process->Write(line);
        }
    }
    event.Skip();
}
Example #21
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();
	}
}
Example #22
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);
      }
    }
  }
} 
Example #23
0
void FileEditorWnd::OnCharacterAdded(wxStyledTextEvent& event)
{
	char chr = (char)event.GetKey();
	int currentLine = m_textCtrl->GetCurrentLine();
	if (chr== '\n')
	{
		int lineInd = 0;
		if (currentLine>0)
			lineInd = m_textCtrl->GetLineIndentation(currentLine-1);
		if (lineInd==0)
			return;

		m_textCtrl->SetLineIndentation(currentLine, lineInd);
		m_textCtrl->LineEnd();
		return;
	}

	char previousChr = m_textCtrl->GetCharAt(m_textCtrl->GetCurrentPos() - 2 );
	if (chr == '.' || (chr == '>' && previousChr == '-'))
		showAutoComplete();
	else if (chr == '(')
		showCallTip(true);
	else if (chr == ')')
	{
		if (m_textCtrl->CallTipActive())
			m_textCtrl->CallTipCancel();
	}
	else if (m_textCtrl->CallTipActive())
		showCallTip(false);
}
Example #24
0
void CodeFormatterDlg::OnPHPCSFixerOptionsUpdated(wxStyledTextEvent& event)
{
    m_isDirty = true;
    m_options.SetPHPCSFixerPharOptions(m_stc->GetText());
    CallAfter(&CodeFormatterDlg::UpdatePreview);
    event.Skip();
}
Example #25
0
void fbtTextFile::zoomEvent(wxStyledTextEvent& evt)
{
	evt.Skip();

	// dsiable zoom
	if (GetZoom() != 0) SetZoom(0);
}
Example #26
0
/* TextEditor::onModified
 * Called when the text is modified
 *******************************************************************/
void TextEditor::onModified(wxStyledTextEvent& e)
{
	// (Re)start update timer
	timer_update.Start(1000, true);

	e.Skip();
}
void AbbreviationsSettingsDlg::OnMarkDirty(wxStyledTextEvent& event)
{
    event.Skip();
    if(m_activeItemName.IsEmpty() == false) {
        m_dirty = true;
    }
}
Example #28
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);
}
Example #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 (wxTheApp->IsActive() && HasFocus() && !call_tip->IsShown() && txed_calltips_mouse && e.GetPosition() >= 0)
	{
		openCalltip(e.GetPosition(), -1, true);
		ct_dwell = true;
	}
}
Example #30
0
void TextFrame::onUpdateUI(wxStyledTextEvent& event)
{
    if(event.GetUpdated()==wxSTC_UPDATE_SELECTION)
    {
        onSelectionChanged();
        wxObject *obj = event.GetEventObject();
        if(obj)
        {
          wxStyledTextCtrl* txt = dynamic_cast<wxStyledTextCtrl*>(obj);
          if(txt)
            updateBraceHilight(txt);
        }
    }
    else if(event.GetUpdated()==wxSTC_UPDATE_V_SCROLL)
    {
        UpdateMarkerPages();
    }
}