void OutputCtrl::ActivateLine( int line, bool openFile ) { // Get the file name and line. bool isError = false; wxString File; long Line; if ( line != -1 ) { wxString Text = GetLine( line ); if ( m_ErrorExpr.Matches( Text ) && m_ErrorExpr.GetMatchCount() > 3 ) { isError = true; File = m_ErrorExpr.GetMatch( Text, 1 ); m_ErrorExpr.GetMatch( Text, 2 ).ToLong( &Line ); } else if ( m_WarnExpr.Matches( Text ) && m_WarnExpr.GetMatchCount() > 3 ) { isError = true; File = m_WarnExpr.GetMatch( Text, 1 ); m_WarnExpr.GetMatch( Text, 2 ).ToLong( &Line ); } } if ( m_Selected != -1 ) { int start = PositionFromLine( m_Selected ); int len = GetLineEndPosition( m_Selected ) - start; // Reverse the style! StartStyling( start, 0xFF ); SetStyling( len, 2 ); } m_Selected = line; if ( !isError ) m_Selected = -1; if ( m_Selected != -1 ) { int start = PositionFromLine( m_Selected ); int len = GetLineEndPosition( m_Selected ) - start; // Reverse the style! StartStyling( start, 0xFF ); SetStyling( len, 1 ); } if ( m_Selected != -1 ) ShowLine( m_Selected ); // Ok read the file name from the list. if ( openFile && !File.IsEmpty() ) { // TODO: Should we launch 3rd party apps here or allow the // file to be opened as text? wxASSERT( tsGetMainFrame() ); tsGetMainFrame()->OpenFile( File, Line-1 ); } }
void ScintillaWrapper::deleteLine(int lineNumber) { int start = 0; int lineCount = GetLineCount(); if (0 != lineNumber && lineCount != 1) { start = GetLineEndPosition(lineNumber - 1); } int end = GetLineEndPosition(lineNumber); setTarget(start, end); this->ReplaceTarget(boost::python::str("")); }
/* TextEditor::trimWhitespace * Removes any unneeded whitespace from the ends of lines *******************************************************************/ void TextEditor::trimWhitespace() { // Go through lines for (int a = 0; a < GetLineCount(); a++) { // Get line start and end positions int pos = GetLineEndPosition(a) - 1; int start = pos - GetLineLength(a); while (pos > start) { int chr = GetCharAt(pos); // Check for whitespace character if (chr == ' ' || chr == '\t') { // Remove character if whitespace Remove(pos, pos+1); pos--; } else break; // Not whitespace, stop } } }
void ScintillaWrapper::replaceLine(int lineNumber, boost::python::object newContents) { int start = PositionFromLine(lineNumber); int end = GetLineEndPosition(lineNumber); setTarget(start, end); ReplaceTarget(newContents); }
/* TextEditor::onJumpToChoiceSelected * Called when the 'Jump To' dropdown is changed *******************************************************************/ void TextEditor::onJumpToChoiceSelected(wxCommandEvent& e) { // Move to line int line = jump_to_lines[choice_jump_to->GetSelection()]; int pos = GetLineEndPosition(line); SetCurrentPos(pos); SetSelection(pos, pos); SetFirstVisibleLine(line); SetFocus(); choice_jump_to->SetSelection(-1); }
void PythonCodeCtrl::OnCharAdded(wxScintillaEvent& ke) { //User has pressed enter //if the cursor is at the end of a completed statement, submit the statement to the interpreter //otherwise, do auto-indentation if (ke.GetKey() == _T('\n')) { //int pos = GetCurrentPos(); int line = LineFromPosition(GetCurrentPos()); if(line>0) { wxString prevlinetext = GetLine(line-1).Trim(); int indentation = GetLineIndentation(line-1); if((indentation==0) //submit a return pressed on an unindented line || (indentation>0 && prevlinetext==wxEmptyString)) // or an indented block where the previous line was empty { long rs,re; GetSelection(&rs,&re); //if(rs==re && GetLastPosition()==rs) if(rs==re && GetLength()==rs) // only submit if the cursor is at the end of the control (and there is no selection) { m_pyctrl->DispatchCode(GetValue()); ke.Skip(); } } // Otherwise indent the code if necessary if (GetLine(line-1).Trim().EndsWith(_T(":"))) { if(GetStyleAt(GetLineEndPosition(line-1)-1) == wxSCI_P_OPERATOR) indentation+=GetIndent(); } if (indentation>0) { SetLineIndentation(line,indentation); SetCurrentPos(PositionFromLine(line)+indentation); SetAnchor(PositionFromLine(line)+indentation); } } } ke.Skip(); }
void LuaScriptEditorView::CheckSyntax() { CStringA text; GetText(text); int indicatorNumber = INDIC_CONTAINER; AnnotationClearAll(); Lua::State state; std::vector<CString> errorMessages; if (state.CheckSyntax(CString(text), errorMessages)) { IndicSetStyle(indicatorNumber, INDIC_HIDDEN); AnnotationSetVisible(ANNOTATION_HIDDEN); return; } IndicSetStyle(indicatorNumber, INDIC_SQUIGGLE); IndicSetFore(indicatorNumber, RGB(255, 0, 0)); // red SetIndicatorCurrent(indicatorNumber); for (size_t index = 0, maxIndex = errorMessages.size(); index < maxIndex; index++) { CString errorMessage = errorMessages[0]; int pos = errorMessage.Find(_T("]:")); int pos2 = errorMessage.Find(_T(':'), pos + 2); int lineNumber = _ttoi(errorMessage.Mid(pos + 2, pos2 - (pos + 2))); CString error = errorMessage.Mid(pos2 + 1).Trim(); SetIndicatorValue(index); int textStart = static_cast<int>(PositionFromLine(lineNumber - 1)); int textEnd = GetLineEndPosition(lineNumber - 1); IndicatorFillRange(textStart, textEnd - textStart); AnnotationSetText(lineNumber - 1, CStringA(error).GetString()); AnnotationSetVisible(ANNOTATION_BOXED); } }
/* 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); }
/* TextEditor::jumpToLine * Prompts the user for a line number and moves the cursor to the end * of the entered line *******************************************************************/ void TextEditor::jumpToLine() { int numlines = GetNumberOfLines(); // Prompt for line number long line = wxGetNumberFromUser( "Enter a line number to jump to", S_FMT("Line number (1-%d):", numlines), "Jump To Line", GetCurrentLine() + 1, 1, numlines, this); if (line >= 1) { // Move to line int pos = GetLineEndPosition(line - 1); SetCurrentPos(pos); SetSelection(pos, pos); EnsureCaretVisible(); SetFocus(); } }
/* TextEditor::onKeyDown * Called when a key is pressed *******************************************************************/ void TextEditor::onKeyDown(wxKeyEvent& e) { // Check if keypress matches any keybinds wxArrayString binds = KeyBind::getBinds(KeyBind::asKeyPress(e.GetKeyCode(), e.GetModifiers())); // Go through matching binds bool handled = false; for (unsigned a = 0; a < binds.size(); a++) { string name = binds[a]; // Open/update calltip if (name == "ted_calltip") { updateCalltip(); handled = true; } // Autocomplete else if (name == "ted_autocomplete") { // Get word before cursor string word = GetTextRange(WordStartPosition(GetCurrentPos(), true), GetCurrentPos()); // If a language is loaded, bring up autocompletion list if (language) { autocomp_list = language->getAutocompletionList(word); AutoCompShow(word.size(), autocomp_list); } handled = true; } // Find/replace else if (name == "ted_findreplace") { showFindReplaceDialog(); handled = true; } // Find next else if (name == "ted_findnext") { wxCommandEvent e; onFRDBtnFindNext(e); handled = true; } // Jump to else if (name == "ted_jumpto") { openJumpToDialog(); handled = true; } } #ifdef __WXMSW__ Colourise(GetCurrentPos(), GetLineEndPosition(GetCurrentLine())); #endif if (!handled) e.Skip(); }
/* TextEditor::openJumpToDialog * Initialises and opens the 'Jump To' dialog *******************************************************************/ void TextEditor::openJumpToDialog() { // Can't do this without a language definition or defined blocks if (!language || language->nJumpBlocks() == 0) return; // --- Scan for functions/scripts --- Tokenizer tz; vector<jp_t> jump_points; tz.openString(GetText()); string token = tz.getToken(); while (!token.IsEmpty()) { if (token == "{") { // Skip block while (!token.IsEmpty() && token != "}") token = tz.getToken(); } for (unsigned a = 0; a < language->nJumpBlocks(); a++) { // Get jump block keyword string block = language->jumpBlock(a); long skip = 0; if (block.Contains(":")) { wxArrayString sp = wxSplit(block, ':'); sp.back().ToLong(&skip); block = sp[0]; } if (S_CMPNOCASE(token, block)) { string name = tz.getToken(); for (int s = 0; s < skip; s++) name = tz.getToken(); for (unsigned i = 0; i < language->nJBIgnore(); ++i) if (S_CMPNOCASE(name, language->jBIgnore(i))) name = tz.getToken(); // Numbered block, add block name if (name.IsNumber()) name = S_FMT("%s %s", language->jumpBlock(a), name); // Unnamed block, use block name if (name == "{" || name == ";") name = language->jumpBlock(a); // Create jump point jp_t jp; jp.name = name; jp.line = tz.lineNo() - 1; jump_points.push_back(jp); } } token = tz.getToken(); } // Do nothing if no jump points if (jump_points.size() == 0) return; // --- Setup/show dialog --- wxDialog dlg(this, -1, "Jump To..."); wxBoxSizer* sizer = new wxBoxSizer(wxVERTICAL); dlg.SetSizer(sizer); // Add Jump to dropdown wxChoice* choice_jump_to = new wxChoice(&dlg, -1); sizer->Add(choice_jump_to, 0, wxEXPAND|wxALL, 4); for (unsigned a = 0; a < jump_points.size(); a++) choice_jump_to->Append(jump_points[a].name); choice_jump_to->SetSelection(0); // Add dialog buttons sizer->Add(dlg.CreateButtonSizer(wxOK|wxCANCEL), 0, wxEXPAND|wxLEFT|wxRIGHT|wxBOTTOM, 4); // Show dialog dlg.SetInitialSize(wxSize(250, -1)); dlg.CenterOnParent(); if (dlg.ShowModal() == wxID_OK) { int selection = choice_jump_to->GetSelection(); if (selection >= 0 && selection < (int)jump_points.size()) { // Get line number int line = jump_points[selection].line; // Move to line int pos = GetLineEndPosition(line); SetCurrentPos(pos); SetSelection(pos, pos); SetFirstVisibleLine(line); SetFocus(); } } }
/* TextEditor::onKeyDown * Called when a key is pressed *******************************************************************/ void TextEditor::onKeyDown(wxKeyEvent& e) { // Check if keypress matches any keybinds wxArrayString binds = KeyBind::getBinds(KeyBind::asKeyPress(e.GetKeyCode(), e.GetModifiers())); // Go through matching binds bool handled = false; for (unsigned a = 0; a < binds.size(); a++) { string name = binds[a]; // Open/update calltip if (name == "ted_calltip") { updateCalltip(); handled = true; } // Autocomplete else if (name == "ted_autocomplete") { // Get word before cursor string word = GetTextRange(WordStartPosition(GetCurrentPos(), true), GetCurrentPos()); // If a language is loaded, bring up autocompletion list if (language) { autocomp_list = language->getAutocompletionList(word); AutoCompShow(word.size(), autocomp_list); } handled = true; } // Find/replace else if (name == "ted_findreplace") { showFindReplaceDialog(); handled = true; } // Find next else if (name == "ted_findnext") { wxCommandEvent e; onFRDBtnFindNext(e); handled = true; } // Jump to else if (name == "ted_jumpto") { openJumpToDialog(); handled = true; } } #ifdef __WXMSW__ Colourise(GetCurrentPos(), GetLineEndPosition(GetCurrentLine())); #endif #ifdef __APPLE__ if (!handled) { const int keyCode = e.GetKeyCode(); const bool shiftDown = e.ShiftDown(); if (e.ControlDown()) { if (WXK_LEFT == keyCode) { if (shiftDown) { HomeExtend(); } else { Home(); } handled = true; } else if (WXK_RIGHT == keyCode) { if (shiftDown) { LineEndExtend(); } else { LineEnd(); } handled = true; } else if (WXK_UP == keyCode) { if (shiftDown) { DocumentStartExtend(); } else { DocumentStart(); } handled = true; } else if (WXK_DOWN == keyCode) { if (shiftDown) { DocumentEndExtend(); } else { DocumentEnd(); } handled = true; } } else if (e.RawControlDown()) { if (WXK_LEFT == keyCode) { if (shiftDown) { WordLeftExtend(); } else { WordLeft(); } handled = true; } else if (WXK_RIGHT == keyCode) { if (shiftDown) { WordRightExtend(); } else { WordRight(); } handled = true; } } } #endif // __APPLE__ if (!handled) e.Skip(); }
void ctlSQLBox::OnKeyDown(wxKeyEvent &event) { #ifdef __WXGTK__ event.m_metaDown = false; #endif // Get the line ending type wxString lineEnd; switch (GetEOLMode()) { case wxSTC_EOL_LF: lineEnd = wxT("\n"); break; case wxSTC_EOL_CRLF: lineEnd = wxT("\r\n"); break; case wxSTC_EOL_CR: lineEnd = wxT("\r"); break; } // Block comment/uncomment if (event.GetKeyCode() == 'K') { // Comment (Ctrl+k) if (event.GetModifiers() == wxMOD_CONTROL) { if (BlockComment(false)) return; } // Uncomment (Ctrl+Shift+K) else if (event.GetModifiers() == (wxMOD_CONTROL | wxMOD_SHIFT)) { if (BlockComment(true)) return; } } // Autoindent if (m_autoIndent && event.GetKeyCode() == WXK_RETURN) { wxString indent, line; line = GetLine(GetCurrentLine()); // Get the offset for the current line - basically, whether // or not it ends with a \r\n, \n or \r, and if so, the length int offset = 0; if (line.EndsWith(wxT("\r\n"))) offset = 2; else if (line.EndsWith(wxT("\n"))) offset = 1; else if (line.EndsWith(wxT("\r"))) offset = 1; // Get the indent. This is every leading space or tab on the // line, up until the current cursor position. int x = 0; int max = line.Length() - (GetLineEndPosition(GetCurrentLine()) - GetCurrentPos()) - offset; if(line != wxEmptyString) { while ((line[x] == '\t' || line[x] == ' ') && x < max) indent += line[x++]; } // Select any indent in front of the cursor to be removed. If // the cursor is positioned after any non-indent characters, // we don't remove anything. If there is already some selected, // don't select anything new at all. if (indent.Length() != 0 && (unsigned int)GetCurrentPos() <= ((GetLineEndPosition(GetCurrentLine()) - line.Length()) + indent.Length() + offset) && GetSelectedText() == wxEmptyString) SetSelection(GetLineEndPosition(GetCurrentLine()) - line.Length() + offset, GetLineEndPosition(GetCurrentLine()) - line.Length() + indent.Length() + offset); // Lose any selected text. ReplaceSelection(wxEmptyString); // Insert a replacement \n (or whatever), and the indent at the insertion point. InsertText(GetCurrentPos(), lineEnd + indent); // Now, reset the position, and clear the selection SetCurrentPos(GetCurrentPos() + indent.Length() + lineEnd.Length()); SetSelection(GetCurrentPos(), GetCurrentPos()); } else if (m_dlgFindReplace && event.GetKeyCode() == WXK_F3) { m_dlgFindReplace->FindNext(); } else event.Skip(); }
void ScintillaWrapper::pyreplace(boost::python::object searchExp, boost::python::object replaceStr, boost::python::object count, boost::python::object flags, boost::python::object startLine, boost::python::object endLine) { boost::python::object re_module( (boost::python::handle<>(PyImport_ImportModule("re"))) ); if (!re_module.is_none()) { BeginUndoAction(); const char *strCount = boost::python::extract<const char *>(count.attr("__str__")()); int iCount; int iFlags = 0; if (!flags.is_none()) { iFlags = boost::python::extract<int>(flags); } int start = 0; if (!startLine.is_none()) { start = boost::python::extract<int>(startLine); } int end = -1; if (!startLine.is_none()) { end = boost::python::extract<int>(endLine); } iCount = atoi(strCount); bool ignoreCount = (iCount == 0); bool includeLineEndings = (iFlags & RE_INCLUDELINEENDINGS) == RE_INCLUDELINEENDINGS; long lineCount = GetLineCount(); boost::python::object re = re_module.attr("compile")(searchExp, flags); size_t bufferLength = 0; Sci_TextRange range; range.chrg.cpMin = 0; range.lpstrText = NULL; boost::python::tuple result; idx_t currentStartPosition; int infiniteLoopCheck = 0; int previousLine = -1; for(int line = start; line < lineCount && (ignoreCount || iCount > 0) && (-1 == end || line <= end); ++line) { if (line == previousLine) { if (++infiniteLoopCheck >= 1000) { EndUndoAction(); PyErr_SetString(PyExc_SystemError, "Infinite loop detected in pyreplace"); if (range.lpstrText) { delete[] range.lpstrText; } throw boost::python::error_already_set(); } } previousLine = line; if (includeLineEndings) { result = boost::python::extract<boost::python::tuple>(re.attr("subn")(replaceStr, GetLine(line), ignoreCount ? 0 : iCount)); } else { range.chrg.cpMin = PositionFromLine(line); range.chrg.cpMax = GetLineEndPosition(line); if (bufferLength < (size_t)((range.chrg.cpMax - range.chrg.cpMin) + 1)) { if (range.lpstrText) delete [] range.lpstrText; bufferLength = (size_t)((range.chrg.cpMax - range.chrg.cpMin) + 1); range.lpstrText = new char[bufferLength + 1]; } callScintilla(SCI_GETTEXTRANGE, 0, reinterpret_cast<LPARAM>(&range)); result = boost::python::extract<boost::python::tuple>(re.attr("subn")(replaceStr, const_cast<const char *>(range.lpstrText), ignoreCount ? 0 : iCount)); } int numSubs = boost::python::extract<int>(result[1]); if (numSubs != 0) { size_t resultLength = _len(result[0]); if (includeLineEndings) { currentStartPosition = (idx_t)PositionFromLine(line); replaceWholeLine(line, result[0]); } else { currentStartPosition = (idx_t)range.chrg.cpMin; replaceLine(line, result[0]); } int newLine = LineFromPosition((int)(currentStartPosition + resultLength)); // If the line number has moved on more than one // there must have been one or more new lines in the // replacement, or no newline, hence the lines have become less if ((newLine - line) != (includeLineEndings ? 1 : 0)) { line = newLine - (includeLineEndings ? 1 : 0); lineCount = GetLineCount(); } iCount -= numSubs; } } if (range.lpstrText) delete[] range.lpstrText; EndUndoAction(); } }
/** * Style needed */ void FbEditor::onStyleNeeded(wxStyledTextEvent & event) { // startint position auto startPos = GetEndStyled(); auto startLine = LineFromPosition(startPos); startPos = PositionFromLine(startLine); // end position int lastPos = event.GetPosition(); int lastLine = std::max(LineFromPosition(lastPos), std::min(GetLineCount(), GetFirstVisibleLine() + LinesOnScreen())); lastPos = GetLineEndPosition(lastLine); // get token auto token = m_srcCtx->getLine(startLine, lastLine); // set stylling position StartStyling(startPos, INT_MAX); // clear indicatirs SetIndicatorCurrent(ErrorIndicator); IndicatorClearRange(startPos, lastPos - startPos); // no token? just colour to default if (!token) { style(lastPos - startPos, TokenStyle::Default); return; } // style the tokens int line = startLine; int col = 0; while (token && line <= lastLine) { // end of the line? if (token->getKind() == TokenKind::EndOfLine) { token = token->getNext(); continue; } // token line int tline = token->getLine(); // token started before current line if (line > tline) { int start = PositionFromLine(line); int end = PositionFromLine(token->getEndLine()) + token->getEndCol(); style(end - start, token); // end on line and column col = token->getEndCol(); line = token->getEndLine(); // get next token and continue token = token->getNext(); continue; } // empty lines before next token? if (line < tline) { int start = PositionFromLine(line) + col; int end = PositionFromLine(tline) + token->getCol(); style(end - start, TokenStyle::Default); // end on line and column line = token->getLine(); col = token->getCol(); continue; } // started on the current line if (line == tline) { // empty space ? if (token->getCol() > col) { style(token->getCol() - col, TokenStyle::Default); } // style the token style(token->getLength(), token); col = token->getEndCol(); line = token->getEndLine(); // advance to the next one token = token->getNext(); continue; } // some empty space till end of the line int length = GetLineLength(line); if (col < length) { style(length - col, TokenStyle::Default); } // incement line line++; col = 0; } }
void cbStyledTextCtrl::HighlightRightBrace() { if (m_bracePosition == wxSCI_INVALID_POSITION) return; int pos = GetCurrentPos(); if (pos == wxSCI_INVALID_POSITION) return; const static wxColour caretForeground = GetCaretForeground(); const static int caretWidth = GetCaretWidth(); const int curLine = GetCurrentLine(); const int len = GetLength(); if (m_tabSmartJump && (curLine == LineFromPosition(m_bracePosition))) { SetIndicatorCurrent(s_indicHighlight); const int indPos = GetLineIndentPosition(curLine); IndicatorClearRange(indPos, GetLineEndPosition(curLine)-indPos); do { if (pos >= len) break; wxString cur((wxChar)GetCharAt(pos)); if (cur == _T("\n")) break; int style = GetStyleAt(pos); if (IsComment(style)) continue; if (IsString(style) || IsCharacter(style)) { const int nextOne = (pos == len) ? GetStyleAt(pos) : GetStyleAt(pos + 1); if (IsCharacter(nextOne) || IsString(nextOne)) continue; } if (s_rightBrace.Contains(cur)) { SetCaretForeground(wxColour(255, 0, 0)); SetCaretWidth(caretWidth + 1); IndicatorSetForeground(s_indicHighlight, wxColour(80, 236, 120)); IndicatorSetStyle(s_indicHighlight, wxSCI_INDIC_HIGHLIGHT); #ifndef wxHAVE_RAW_BITMAP IndicatorSetUnder(s_indicHighlight, true); #endif SetIndicatorCurrent(s_indicHighlight); IndicatorFillRange(pos, 1); m_bracePosition = pos + 1; return; } } while (++pos); } m_bracePosition = wxSCI_INVALID_POSITION; m_lastPosition = wxSCI_INVALID_POSITION; m_tabSmartJump = false; SetIndicatorCurrent(s_indicHighlight); IndicatorClearRange(0, len); SetCaretForeground(caretForeground); SetCaretWidth(caretWidth); }
/* TextEditor::onKeyDown * Called when a key is pressed *******************************************************************/ void TextEditor::onKeyDown(wxKeyEvent& e) { // Check if keypress matches any keybinds wxArrayString binds = KeyBind::getBinds(KeyBind::asKeyPress(e.GetKeyCode(), e.GetModifiers())); // Go through matching binds bool handled = false; for (unsigned a = 0; a < binds.size(); a++) { string name = binds[a]; // Open/update calltip if (name == "ted_calltip") { updateCalltip(); handled = true; } // Autocomplete else if (name == "ted_autocomplete") { // Get word before cursor string word = GetTextRange(WordStartPosition(GetCurrentPos(), true), GetCurrentPos()); // If a language is loaded, bring up autocompletion list if (language) { autocomp_list = language->getAutocompletionList(word); AutoCompShow(word.size(), autocomp_list); } handled = true; } // Find/replace else if (name == "ted_findreplace") { showFindReplacePanel(); handled = true; } // Find next else if (name == "ted_findnext") { if (panel_fr && panel_fr->IsShown()) findNext(panel_fr->getFindText(), panel_fr->getFindFlags()); handled = true; } // Find previous else if (name == "ted_findprev") { if (panel_fr && panel_fr->IsShown()) findPrev(panel_fr->getFindText(), panel_fr->getFindFlags()); handled = true; } // Replace next else if (name == "ted_replacenext") { if (panel_fr && panel_fr->IsShown()) replaceCurrent(panel_fr->getFindText(), panel_fr->getReplaceText(), panel_fr->getFindFlags()); handled = true; } // Replace all else if (name == "ted_replaceall") { if (panel_fr && panel_fr->IsShown()) replaceAll(panel_fr->getFindText(), panel_fr->getReplaceText(), panel_fr->getFindFlags()); handled = true; } // Fold all else if (name == "ted_fold_foldall") { foldAll(true); handled = true; } // Unfold all else if (name == "ted_fold_unfoldall") { foldAll(false); handled = true; } // Jump to line else if (name == "ted_jumptoline") { jumpToLine(); handled = true; } } // Check for esc key if (!handled && e.GetKeyCode() == WXK_ESCAPE) { // Hide call tip if showing if (call_tip->IsShown()) call_tip->Show(false); // Hide F+R panel if showing else if (panel_fr && panel_fr->IsShown()) showFindReplacePanel(false); } // Check for up/down keys while calltip with multiple arg sets is open if (call_tip->IsShown() && ct_function && ct_function->nArgSets() > 1 && !ct_dwell) { if (e.GetKeyCode() == WXK_UP) { call_tip->prevArgSet(); handled = true; } else if (e.GetKeyCode() == WXK_DOWN) { call_tip->nextArgSet(); handled = true; } } #ifdef __WXMSW__ Colourise(GetCurrentPos(), GetLineEndPosition(GetCurrentLine())); #endif #ifdef __APPLE__ if (!handled) { const int keyCode = e.GetKeyCode(); const bool shiftDown = e.ShiftDown(); if (e.ControlDown()) { if (WXK_LEFT == keyCode) { if (shiftDown) { HomeExtend(); } else { Home(); } handled = true; } else if (WXK_RIGHT == keyCode) { if (shiftDown) { LineEndExtend(); } else { LineEnd(); } handled = true; } else if (WXK_UP == keyCode) { if (shiftDown) { DocumentStartExtend(); } else { DocumentStart(); } handled = true; } else if (WXK_DOWN == keyCode) { if (shiftDown) { DocumentEndExtend(); } else { DocumentEnd(); } handled = true; } } else if (e.RawControlDown()) { if (WXK_LEFT == keyCode) { if (shiftDown) { WordLeftExtend(); } else { WordLeft(); } handled = true; } else if (WXK_RIGHT == keyCode) { if (shiftDown) { WordRightExtend(); } else { WordRight(); } handled = true; } } } #endif // __APPLE__ if (!handled) e.Skip(); }