void CodeEdit::CommentSelection(const wxString& comment) { if (GetSelectionStart() < GetSelectionEnd()) { int startLine = LineFromPosition(GetSelectionStart()); int endLine = LineFromPosition(GetSelectionEnd()); // Find the minimum indentation level for all of the selected lines. int minIndentation = INT_MAX; for (int i = startLine; i <= endLine; ++i) { wxString lineText = GetLine(i); int firstNonWhitespace = GetFirstNonWhitespace(lineText); if (firstNonWhitespace != -1) { minIndentation = wxMin(firstNonWhitespace, minIndentation); } } // Insert the comment string on each non-blank line. wxString result; for (int i = startLine; i <= endLine; ++i) { wxString lineText = GetLine(i); if (GetFirstNonWhitespace(lineText) != -1) { lineText.insert(minIndentation, comment); } result += lineText; } SetTargetStart(PositionFromLine(startLine)); SetTargetEnd(PositionFromLine(endLine + 1)); ReplaceTarget(result); // Select the replaced text. SetSelectionStart(GetTargetStart()); SetSelectionEnd(GetTargetEnd() - 1); } }
void Edit::OnGoto (wxCommandEvent &WXUNUSED(event)) { const int lastLine = LineFromPosition(GetLastPosition()); long line = wxGetNumberFromUser(wxT(""), wxT("Goto line:"), wxT("Goto Line"), 1, 1, 1000000, this); if(line <= lastLine) { GotoLine(line - 1); } }
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; } }
void ctlSQLBox::OnMarginClick(wxStyledTextEvent &event) { if (event.GetMargin() == 2) ToggleFold(LineFromPosition(event.GetPosition())); event.Skip(); }
boost::python::tuple ScintillaWrapper::getUserLineSelection() { int start = GetSelectionStart(); int end = GetSelectionEnd(); if (start == end) { start = 0; end = GetLineCount() - 1; } else { start = LineFromPosition(start); end = LineFromPosition(end); } return boost::python::make_tuple(start, end); }
bool wxSTEditorShell::CheckReadOnly(bool set) { bool make_ro = !CaretOnPromptLine(STE_CARET_MOVE_NONE); if (!make_ro) { // also check selection and make ro so they can't cut text not on last line int prompt_line = GetPromptLine(); make_ro |= ((LineFromPosition(GetSelectionStart()) < prompt_line) || (LineFromPosition(GetSelectionEnd()) < prompt_line)); } if (set && (make_ro != GetReadOnly())) SetReadOnly(make_ro); return make_ro; }
//! 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); } } }
/* 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 (call_tip->IsShown()) updateCalltip(); // Do word matching if appropriate if (txed_match_cursor_word && language) { int word_start = WordStartPosition(GetCurrentPos(), true); int word_end = WordEndPosition(GetCurrentPos(), true); string current_word = GetTextRange(word_start, word_end); if (!current_word.IsEmpty() && HasFocus()) { if (current_word != prev_word_match) { prev_word_match = current_word; SetIndicatorCurrent(8); IndicatorClearRange(0, GetTextLength()); SetTargetStart(0); SetTargetEnd(GetTextLength()); SetSearchFlags(0); while (SearchInTarget(current_word) != -1) { IndicatorFillRange(GetTargetStart(), GetTargetEnd() - GetTargetStart()); SetTargetStart(GetTargetEnd()); SetTargetEnd(GetTextLength()); } } } else { SetIndicatorCurrent(8); IndicatorClearRange(0, GetTextLength()); prev_word_match = ""; } } // Hilight current line MarkerDeleteAll(1); MarkerDeleteAll(2); if (txed_hilight_current_line > 0 && HasFocus()) { int line = LineFromPosition(GetCurrentPos()); MarkerAdd(line, 1); if (txed_hilight_current_line > 1) MarkerAdd(line, 2); } e.Skip(); }
void CodeEditor::OnCharAdded(wxScintillaEvent &event) { char ch = event.GetKey(); int currentLine = GetCurrentLine(); int pos = GetCurrentPos(); if (ch == wxT('\n') && currentLine > 0) { BeginUndoAction(); wxString indent = GetLineIndentString(currentLine - 1); wxChar b = GetLastNonWhitespaceChar(); if(b == wxT('{')) { if(GetUseTabs()) indent << wxT("\t"); else indent << wxT(" "); } InsertText(pos, indent); GotoPos((int)(pos + indent.Length())); ChooseCaretX(); EndUndoAction(); } else if(ch == wxT('}')) { BeginUndoAction(); wxString line = GetLine(currentLine); line.Trim(false); line.Trim(true); if(line.Matches(wxT("}"))) { pos = GetCurrentPos() - 2; pos = FindBlockStart(pos, wxT('{'), wxT('}')); if(pos != -1) { wxString indent = GetLineIndentString(LineFromPosition(pos)); indent << wxT('}'); DelLineLeft(); DelLineRight(); pos = GetCurrentPos(); InsertText(pos, indent); GotoPos((int)(pos + indent.Length())); ChooseCaretX(); } } EndUndoAction(); } }
/* 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(); } }
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 CodeEditor::OnMarginClick(wxScintillaEvent &event) { if (event.GetMargin() == 1) { int lineClick = LineFromPosition(event.GetPosition()); int levelClick = GetFoldLevel(lineClick); if ((levelClick & wxSCI_FOLDLEVELHEADERFLAG) > 0) { ToggleFold (lineClick); } } }
void CodeEdit::UncommentSelection(const wxString& commentString) { if (GetSelectionStart() < GetSelectionEnd()) { int startLine = LineFromPosition(GetSelectionStart()); int endLine = LineFromPosition(GetSelectionEnd()); wxString result; for (int i = startLine; i <= endLine; ++i) { wxString lineText = GetLine(i); unsigned int c = GetFirstNonWhitespace(lineText); if (c != -1 && lineText.compare(c, commentString.Length(), commentString) == 0) { lineText.erase(c, commentString.Length()); } result += lineText; } SetTargetStart(PositionFromLine(startLine)); SetTargetEnd(PositionFromLine(endLine + 1)); ReplaceTarget(result); // Select the replaced text. SetSelectionStart(GetTargetStart()); SetSelectionEnd(GetTargetEnd() - 1); } }
void ZoomText::HighlightLines(int start, int end) { int nLineCount = end - start; int lastLine = LineFromPosition(GetLength()); if(lastLine < end) { end = lastLine; start = end - nLineCount; if(start < 0) start = 0; } MarkerDeleteAll(1); for(int i = start; i <= end; ++i) { MarkerAdd(i, 1); } }
void OnHotSpotClick(wxScintillaEvent &event) { AutoCompCancel(); CallTipCancel(); wxPoint clientPos = PointFromPosition(event.GetPosition()); wxPoint screenPos = ClientToScreen(clientPos); int lineHeight = TextHeight(LineFromPosition(event.GetPosition())); CloseWatch(); m_watch = new OneVariableWatchView( this, event.GetText(), wxPoint(screenPos.x - 50, screenPos.y + lineHeight), wxSize(100, 400)); m_watch->Show(); }
/** * CHaracter added */ void FbEditor::onCharAdded(wxStyledTextEvent & event) { int p = GetCurrentPos(); auto w = GetTextRange(WordStartPosition(p, true), p); if (w.length() < 2) return; w.UpperCase(); wxString words = ""; int count = 0; for (auto id : m_srcCtx->getIdentifiers(LineFromPosition(p), p - LineFromPosition(p))) { wxString ID(id); ID.UpperCase(); if (ID.compare(0, w.length(), w) == 0) { if (ID.length() == w.length()) continue; words += id + " "; count++; } } if (count > 0) { AutoCompShow((int)w.Length(), words); } }
/* 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); }
wxString CodeEditor::GetLineIndentString(int line) { int currLine = (line == -1) ? LineFromPosition(GetCurrentPos()) : line; wxString text = GetLine(currLine); int length = (int)text.Length(); wxString indent; for (int i = 0; i < length; ++i) { if (text[i] == wxT(' ') || text[i] == wxT('\t')) indent << text[i]; else break; } return indent; }
/** * 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); }
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 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); } } }
void ScintillaWrapper::pymlsearch(boost::python::object searchExp, boost::python::object callback, boost::python::object flags, boost::python::object startPosition, boost::python::object endPosition) { boost::python::object re_module( (boost::python::handle<>(PyImport_ImportModule("re"))) ); if (!re_module.is_none()) { boost::python::str contents; contents = GetText(); int iFlags = 0; if (!flags.is_none()) { iFlags = boost::python::extract<int>(flags); } iFlags |= boost::python::extract<int>(re_module.attr("MULTILINE")); boost::python::object re = re_module.attr("compile")(searchExp, iFlags); boost::python::object match; int pos = 0; if (!startPosition.is_none()) { pos = boost::python::extract<int>(startPosition); } int endPos = 0; if (!endPosition.is_none()) { endPos = boost::python::extract<int>(endPosition); } bool endPosFixed = true; if (endPos == 0) { endPos = GetLength(); endPosFixed = false; } int line; do { match = re.attr("search")(contents, pos, endPos); // If nothing found, then skip if (!match.is_none()) { pos = boost::python::extract<int>(match.attr("start")()); line = LineFromPosition(pos); boost::python::object result = callback(line, match); // If return value was false, then stop the search if (!result.is_none() && !boost::python::extract<bool>(result)) { return; } if (!endPosFixed) { endPos = GetLength(); } pos = boost::python::extract<int>(match.attr("end")()); } } while (!match.is_none()); } // end re_module check }
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(); } }
bool CodeEdit::GetTokenFromPosition(int position, const wxString& joiners, wxString& token) { if (position != -1) { // Search the text. int line = LineFromPosition(position); int seek = position - PositionFromLine(line); wxString text = GetLine(LineFromPosition(position)); if (!isalnum(text[seek]) && joiners.Find(text[seek]) == wxNOT_FOUND) { return false; } // Search from the seek point to the left until we hit a non-alphanumeric which isn't a "." // "." must be handled specially so that expressions like player.health are easy to evaluate. int start = seek; while (start > 0 && (GetIsIdentifierChar(text[start - 1]) || joiners.Find(text[start - 1]) != wxNOT_FOUND || text[start - 1] == ')')) { if (text[start - 1] == ')') { while (start > 0 && text[start - 1] != '(') start--; start--; } else --start; } // Search from the seek point to the right until we hit a non-alphanumeric unsigned int end = seek; while (end + 1 < text.Length() && (GetIsIdentifierChar(text[end + 1]) || text[end + 1] == '(')) { if (text[end + 1] == '(') { while (end + 1 < text.Length() && text[end + 1] != ')') ++end; ++end; } ++end; } token = text.SubString(start, end); return true; } return false; }
/** * 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 OutputCtrl::AppendText( const wxString& text ) { SetReadOnly( false ); bool scrollEnd = false; int pos = GetLength(); if ( GetCurrentPos() == pos && GetAnchor() == pos ) scrollEnd = true; // For each line... const wxChar* ptr = text.c_str(); const wxChar* const end = ptr + text.Length(); const wxChar* next; wxString line; bool isError = false; bool isWarn = false; //wxTextAttr errorStyle( *wxRED, *wxWHITE ); //wxTextAttr warnStyle( *wxRED, *wxWHITE ); //wxColour( 255, 128, 0 ), *wxWHITE ); long lnumb; while( ptr != end ) { wxASSERT( ptr < end ); next = std::find( ptr, end, '\n' ); if ( next != end ) ++next; line.assign( ptr, next ); ptr = next; // Look for error lines and highlight them... // // TODO: I need to optimize the regex here... maybe i // shouldn't use a regex, but use my own logic to spot // errors... could be much faster. // if ( m_ErrorExpr.Matches( line ) && m_ErrorExpr.GetMatchCount() > 3 ) isError = true; else if ( m_WarnExpr.Matches( line ) && m_ErrorExpr.GetMatchCount() > 3 ) isWarn = true; pos = GetLength(); SetTargetStart( pos ); SetTargetEnd( pos ); ReplaceTarget( line ); if ( isError ) { StartStyling( pos, 0xFF ); SetStyling( line.Len(), 2 ); // TODO: SetStyle will screw with the current scroll position. The // trick is to disable ECO_AUTOVSCROLL and ECO_AUTOHSCROLL before // changing the selection to change the style. We need to submit this // fix back to wxWindows. //::SendMessage( GetHwnd(), EM_SETOPTIONS, ECOOP_XOR, ECO_AUTOVSCROLL | ECO_AUTOHSCROLL ); //SetStyle( start, last, errorStyle ); //::SendMessage( GetHwnd(), EM_SETOPTIONS, ECOOP_OR, ECO_AUTOVSCROLL | ECO_AUTOHSCROLL ); // Add the error to the debugger state. m_ErrorExpr.GetMatch( line, 2 ).ToLong( &lnumb ); ScriptError* error = new ScriptError; error->file = m_ErrorExpr.GetMatch( line, 1 ); error->line = lnumb; error->start = pos; error->end = pos + line.Len(); error->row = LineFromPosition( pos ); error->error = m_ErrorExpr.GetMatch( line, 3 ); error->error.Trim(); error->warning = false; AddError( error ); isError = false; } else if ( isWarn ) { StartStyling( pos, 0xFF ); SetStyling( line.Len(), 2 ); // TODO: SetStyle will screw with the current scroll position. The // trick is to disable ECO_AUTOVSCROLL and ECO_AUTOHSCROLL before // changing the selection to change the style. We need to submit this // fix back to wxWindows. //::SendMessage( GetHwnd(), EM_SETOPTIONS, ECOOP_XOR, ECO_AUTOVSCROLL | ECO_AUTOHSCROLL ); //SetStyle( start, last, warnStyle ); //::SendMessage( GetHwnd(), EM_SETOPTIONS, ECOOP_OR, ECO_AUTOVSCROLL | ECO_AUTOHSCROLL ); // Add the error to the debugger state. m_WarnExpr.GetMatch( line, 2 ).ToLong( &lnumb ); ScriptError* error = new ScriptError; error->file = m_WarnExpr.GetMatch( line, 1 ); error->line = lnumb; error->start = pos; error->end = pos + line.Len(); error->row = LineFromPosition( pos ); error->error = m_WarnExpr.GetMatch( line, 3 ); error->error.Trim(); error->warning = true; AddError( error ); isWarn = false; } } if ( scrollEnd ) { const int endPos = GetLength(); SetAnchor( endPos ); SetCurrentPos( endPos ); ShowLine( LineFromPosition( endPos ) ); } EmptyUndoBuffer(); SetReadOnly( true ); }
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); }
int CSyntaxCtrl::GetCurrentLine() { int line = LineFromPosition (GetCurrentPos()); return line; }
int NppInterface::GetCurrentLineNumber(ViewType view) const { return LineFromPosition(view, GetCurrentPos(view)); }
void OutputCtrl::OnDblClick( wxMouseEvent& event ) { int pos = PositionFromPoint( event.GetPosition() ); int line = LineFromPosition( pos ); ActivateLine( line, true ); }