void cbStyledTextCtrl::OnKeyDown(wxKeyEvent& event) { switch (event.GetKeyCode()) { case WXK_TAB: { if (m_tabSmartJump && !(event.ControlDown() || event.ShiftDown() || event.AltDown())) { if (!AutoCompActive() && m_bracePosition != wxSCI_INVALID_POSITION) { m_lastPosition = GetCurrentPos(); GotoPos(m_bracePosition); // Need judge if it's the final brace HighlightRightBrace(); if (!m_tabSmartJump && CallTipActive()) CallTipCancel(); return; } } } break; case WXK_BACK: { if (m_tabSmartJump) { if (!(event.ControlDown() || event.ShiftDown() || event.AltDown())) { const int pos = GetCurrentPos(); const int index = s_leftBrace.Find((wxChar)GetCharAt(pos - 1)); if (index != wxNOT_FOUND && (wxChar)GetCharAt(pos) == s_rightBrace.GetChar(index)) { CharRight(); DeleteBack(); } } else if (m_lastPosition != wxSCI_INVALID_POSITION && event.ControlDown()) { GotoPos(m_lastPosition); m_lastPosition = wxSCI_INVALID_POSITION; return; } } } break; case WXK_RETURN: case WXK_ESCAPE: { if (m_tabSmartJump) m_tabSmartJump = false; } break; } event.Skip(); }
void cbStyledTextCtrl::OnKillFocus(wxFocusEvent& event) { // cancel auto-completion list when losing focus if ( AutoCompActive() ) AutoCompCancel(); if ( CallTipActive() ) CallTipCancel(); event.Skip(); }
/* TextEditor::onUpdateUI * Called when anything is modified in the text editor (cursor * position, styling, text, etc) *******************************************************************/ void TextEditor::onUpdateUI(wxStyledTextEvent& e) { // Check for brace match if (txed_brace_match) checkBraceMatch(); // If a calltip is open, update it if (CallTipActive()) updateCalltip(); e.Skip(); }
void DisassemblyTextCtrl::OnKillFocus(wxFocusEvent& event) { // cancel auto-completion list when losing focus if (AutoCompActive()) { AutoCompCancel(); } if (CallTipActive()) { CallTipCancel(); } event.Skip(); } // end of OnKillFocus
void Edit::OnKeyDown (wxKeyEvent &event) { if (CallTipActive()) CallTipCancel(); if (event.GetKeyCode() == WXK_SPACE && event.ControlDown() && event.ShiftDown()) { int pos = GetCurrentPos(); CallTipSetBackground(*wxYELLOW); CallTipShow(pos, "This is a CallTip with multiple lines.\n" "It is meant to be a context sensitive popup helper for the user."); return; } event.Skip(); }
/* 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); }
/* TextEditor::updateCalltip * Updates the current calltip, or attempts to open one if none is * currently showing *******************************************************************/ void TextEditor::updateCalltip() { // Don't bother if no language if (!language) return; if (!CallTipActive()) { // No calltip currently showing, check if we're in a function int pos = GetCurrentPos() - 1; while (pos >= 0) { // Get character int chr = GetCharAt(pos); // If we find a closing bracket, skip to matching brace if (chr == ')') { while (pos >= 0 && chr != '(') { pos--; chr = GetCharAt(pos); } pos--; continue; } // If we find an opening bracket, try to open a calltip if (chr == '(') { if (!openCalltip(pos)) return; else break; } // Go to previous character pos--; } } if (ct_function) { // Calltip currently showing, determine what arg we're at int pos = ct_start+1; int arg = 0; while (pos < GetCurrentPos() && pos < GetTextLength()) { // Get character int chr = GetCharAt(pos); // If it's an opening brace, skip until closing (ie skip a function as an arg) if (chr == '(') { while (chr != ')') { // Exit if we get to the current position or the end of the text if (pos == GetCurrentPos() || pos == GetTextLength()-1) break; // Get next character pos++; chr = GetCharAt(pos); } pos++; continue; } // If it's a comma, increment arg if (chr == ',') arg++; // If it's a closing brace, we're outside the function, so cancel the calltip if (chr == ')') { CallTipCancel(); ct_function = NULL; return; } // Go to next character pos++; } // Update calltip string with the selected arg set and the current arg highlighted CallTipShow(ct_start, ct_function->generateCallTipString(ct_argset)); point2_t arg_ext = ct_function->getArgTextExtent(arg, ct_argset); CallTipSetHighlight(arg_ext.x, arg_ext.y); } }
/* 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); }
void cbStyledTextCtrl::OnKeyDown(wxKeyEvent& event) { m_lastSelectedText = GetSelectedText(); bool emulateDwellStart = false; switch ( event.GetKeyCode() ) { case _T('I'): { if (event.GetModifiers() == wxMOD_ALT) m_braceShortcutState = true; break; } case WXK_TAB: { if (m_tabSmartJump && event.GetModifiers() == wxMOD_NONE) { if (!AutoCompActive() && m_bracePosition != wxSCI_INVALID_POSITION) { m_lastPosition = GetCurrentPos(); GotoPos(m_bracePosition); // Need judge if it's the final brace HighlightRightBrace(); if (!m_tabSmartJump && CallTipActive()) CallTipCancel(); return; } } } break; case WXK_BACK: { if (m_tabSmartJump) { if (!(event.ControlDown() || event.ShiftDown() || event.AltDown())) { const int pos = GetCurrentPos(); const int index = s_leftBrace.Find((wxChar)GetCharAt(pos - 1)); if (index != wxNOT_FOUND && (wxChar)GetCharAt(pos) == s_rightBrace.GetChar(index)) { CharRight(); DeleteBack(); } } else if (m_lastPosition != wxSCI_INVALID_POSITION && event.ControlDown()) { GotoPos(m_lastPosition); m_lastPosition = wxSCI_INVALID_POSITION; return; } } } break; case WXK_RETURN: case WXK_NUMPAD_ENTER: case WXK_ESCAPE: { if (m_tabSmartJump) m_tabSmartJump = false; } break; case WXK_CONTROL: { EmulateDwellStart(); emulateDwellStart = true; } break; default: break; } if (event.ControlDown() && !emulateDwellStart) EmulateDwellStart(); event.Skip(); }