void OutputCtrl::ShowLine( int line ) { // First make sure the line is not folded. EnsureVisible( line ); line = VisibleFromDocLine( line ); int firstVisible = GetFirstVisibleLine(); int lastVisible = firstVisible + ( LinesOnScreen() - 1 ); if ( line <= firstVisible ) { int lines = line - firstVisible; if ( lines < -1 ) { lines -= LinesOnScreen() / 2; } LineScroll( 0, lines ); } else if ( line >= lastVisible ) { int lines = line - lastVisible; if ( lines > 1 ) { lines += LinesOnScreen() / 2; } LineScroll( 0, lines ); } }
void cbStyledTextCtrl::MakeNearbyLinesVisible(int line) { const int dist = VisibleFromDocLine(line) - GetFirstVisibleLine(); if (dist >= 0 && dist < 2) LineScroll(0, dist - 2); else if (dist >= LinesOnScreen() - 2) LineScroll(0, 3 + dist - LinesOnScreen()); }
void MiniStyledTextCtrl::MakeVisible(int from, int length) { ConfigManager* cfg = Manager::Get()->GetConfigManager(_T("editor")); bool doscroll = cfg->ReadBool(_T("/mini_doc/sync_to_main_doc"), true); if (doscroll) ScrollToLine(from - (LinesOnScreen()-length)/2); }
void MiniStyledTextCtrl::MakePositionVisible(int from, int length) { if (doScrollToPosition_) ScrollToLine(from - (LinesOnScreen()-length)/2); }
/** * 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; } }