Kate
katevimodebase.cpp
Go to the documentation of this file.
44 // TODO: the "previous word/WORD [end]" methods should be optimized. now they're being called in a
45 // loop and all calculations done up to finding a match are trown away when called with a count > 1
78 res = doc()->removeText( Range( r.startLine, r.startColumn, r.endLine, r.endColumn), mode == Block );
183 Range KateViModeBase::findPattern(const QString& pattern, bool backwards, bool caseSensitive, const Cursor& startFrom, int count) const
205 const KTextEditor::Range matchRange = m_view->doc()->searchText(KTextEditor::Range(Cursor(searchBegin.line(), searchBegin.column() + 1), m_view->doc()->documentEnd()), pattern, flags).first();
214 const KTextEditor::Range wrappedMatchRange = m_view->doc()->searchText(KTextEditor::Range(m_view->doc()->documentRange().start(), m_view->doc()->documentEnd()), pattern, flags).first();
232 // Unfortunately, searchText doesn't necessarily turn up all matches (just the first one, sometimes)
233 // so we must repeatedly search in such a way that the previous match isn't found, until we either
235 Cursor newSearchBegin = Cursor(searchBegin.line(), m_view->doc()->lineLength(searchBegin.line()));
239 QVector<Range> matchesUnfiltered = m_view->doc()->searchText(Range(newSearchBegin, m_view->doc()->documentRange().start()), pattern, flags);
240 kDebug(13070) << "matchesUnfiltered: " << matchesUnfiltered << " searchBegin: " << newSearchBegin;
281 const KTextEditor::Range wrappedMatchRange = m_view->doc()->searchText(KTextEditor::Range(m_view->doc()->documentEnd(), m_view->doc()->documentRange().start()), pattern, flags).first();
299 KateViRange KateViModeBase::findPatternForMotion( const QString& pattern, bool backwards, bool caseSensitive, const Cursor& startFrom, int count ) const
309 return KateViRange( match.start().line(), match.start().column(), match.end().line(), match.end().column(), ViMotion::ExclusiveMotion );
312 Cursor KateViModeBase::findNextWordStart( int fromLine, int fromColumn, bool onlyCurrentLine ) const
325 QRegExp nonWordAfterWord( "\\b(?!\\s)\\W" ); // word-boundary followed by a non-word which is not a space
374 Cursor KateViModeBase::findNextWORDStart( int fromLine, int fromColumn, bool onlyCurrentLine ) const
416 Cursor KateViModeBase::findPrevWordEnd( int fromLine, int fromColumn, bool onlyCurrentLine ) const
456 Cursor KateViModeBase::findPrevWORDEnd( int fromLine, int fromColumn, bool onlyCurrentLine ) const
493 Cursor KateViModeBase::findPrevWordStart( int fromLine, int fromColumn, bool onlyCurrentLine ) const
506 QRegExp nonWordAfterWord( "\\b(?!\\s)\\W" ); // word-boundary followed by a non-word which is not a space
557 Cursor KateViModeBase::findPrevWORDStart( int fromLine, int fromColumn, bool onlyCurrentLine ) const
877 KateViRange KateViModeBase::findSurrounding( const QRegExp &c1, const QRegExp &c2, bool inner ) const
899 int KateViModeBase::findLineStartingWitchChar( const QChar &c, unsigned int count, bool forward ) const
1124 // the continuations are also "invisibly" (i.e. without any spaces in the text itself) indented.
1125 const bool isWrappedContinuation = (m_viewInternal->cache()->textLayout(startRealLine, startVisualLine).lineLayout().lineNumber() != 0);
1126 const int numInvisibleIndentChars = isWrappedContinuation ? startLine->toVirtualColumn(m_viewInternal->cache()->line(startRealLine)->textLine()->nextNonSpaceChar(0), tabstop) : 0;
1128 const int realLineStartColumn = m_viewInternal->cache()->textLayout(startRealLine, startVisualLine).startCol();
1130 const int visualColumnNoInvisibleIndent = startLine->toVirtualColumn(c.column(), tabstop) - lineStartVirtualColumn;
1135 // The "real" (non-virtual) beginning of the current "line", which might be a wrapped continuation of a
1137 const int realLineStartColumn = m_viewInternal->cache()->textLayout(finishRealLine, finishVisualLine).startCol();
1140 // the continuations are also "invisibly" (i.e. without any spaces in the text itself) indented.
1141 const bool isWrappedContinuation = (m_viewInternal->cache()->textLayout(finishRealLine, finishVisualLine).lineLayout().lineNumber() != 0);
1142 const int numInvisibleIndentChars = isWrappedContinuation ? endLine->toVirtualColumn(m_viewInternal->cache()->line(finishRealLine)->textLine()->nextNonSpaceChar(0), tabstop) : 0;
1145 const int visualEndColumn = m_viewInternal->cache()->textLayout(finishRealLine, finishVisualLine).lineLayout().textLength() - 1;
1146 r.endColumn = endLine->fromVirtualColumn( visualEndColumn + realLineStartColumn - numInvisibleIndentChars, tabstop );
1156 const int visualColumn = endLine->toVirtualColumn( realLineStartColumn + realOffsetToVisualStickyColumn, tabstop ) - lineStartVirtualColumn + numInvisibleIndentChars;
1177 if (!( m_viInputModeManager->isAnyVisualMode() || m_viInputModeManager->isReplayingLastChange() ))
1346 for (int searchFromColumn = wordStartPos; searchFromColumn < currentLineLength; searchFromColumn++)
1401 // Create the new text string to be inserted. Prepend with “0x” if in base 16, and "0" if base 8.
1402 // For non-decimal numbers, try to keep the length of the number the same (including leading 0's).
1410 doc()->removeText( KTextEditor::Range( c.line(), numberStartPos , c.line(), numberStartPos+numberAsString.length() ) );
1413 updateCursor(Cursor(m_view->cursorPosition().line(), numberStartPos + newNumberText.length() - 1));
1429 int curr_cursor_y = m_view->mapToGlobal(m_view->cursorToCoordinate(m_view->cursorPosition())).y();
1430 int curr_cursor_x = m_view->mapToGlobal(m_view->cursorToCoordinate(m_view->cursorPosition())).x();
1433 int best_x1 = -1, best_x2 = -1, best_y1 = -1, best_y2 = -1, best_center_y = -1, best_center_x = -1;
void updateViModeBarMode()
Update vi mode statusbar according to the current mode.
Definition: kateview.cpp:1568
void viEnterNormalMode()
set normal mode to be the active vi mode and perform the needed setup work
Definition: kateviinputmodemanager.cpp:484
int indexOf(QChar ch, int from, Qt::CaseSensitivity cs) const
Cursor findWORDEnd(int fromLine, int fromColumn, bool onlyCurrentLine=false) const
Definition: katevimodebase.cpp:645
QString cap(int nth) const
QString & append(QChar ch)
QScriptValue i18n(QScriptContext *context, QScriptEngine *engine)
i18n("text", arguments [optional])
Definition: katescripthelpers.cpp:186
Cursor findPrevWORDStart(int fromLine, int fromColumn, bool onlyCurrentLine=false) const
Definition: katevimodebase.cpp:557
OperationMode getRegisterFlag(const QChar ®) const
Definition: katevimodebase.cpp:958
QPointer< KTextEditor::Message > m_infoMessage
Definition: katevimodebase.h:180
KateViRange findSurroundingQuotes(const QChar &c, bool inner=false) const
Definition: katevimodebase.cpp:697
T pop()
void append(const T &value)
void push_back(const T &value)
const QString getWordUnderCursor() const
Definition: katevimodebase.cpp:141
const QChar getCharUnderCursor() const
Definition: katevimodebase.cpp:128
const QChar getCharAtVirtualColumn(QString &line, int virtualColumn, int tabWidht) const
Definition: katevimodebase.cpp:1290
bool m_currentMotionWasVisualLineUpOrDown
Definition: katevimodebase.h:170
void changeViMode(ViMode newMode)
changes the current vi mode to the given mode
Definition: kateviinputmodemanager.cpp:445
void push(const T &t)
const T & at(int i) const
Definition: kateviinputmodemanager.h:51
T & last()
int size() const
int lineNumber() const
KateTextLayout textLayout(const KTextEditor::Cursor &realCursor)
Returns the layout describing the text line which is occupied by realCursor.
Definition: katelayoutcache.cpp:337
void copyToClipboard(const QString &text)
Copy text to clipboard an remember it in the history.
Definition: kateglobal.cpp:550
T & first()
QString join(const QString &separator) const
Kate::TextLine plainKateTextLine(uint i)
Definition: katedocument.cpp:4712
const QString getRange(KateViRange &r, OperationMode mode=LineWise) const
Definition: katevimodebase.cpp:95
int x() const
int y() const
int lastIndexOf(QChar ch, int from, Qt::CaseSensitivity cs) const
bool isNull() const
KTextEditor::Cursor getNextJump(KTextEditor::Cursor cursor)
Definition: kateviinputmodemanager.cpp:687
KateViRange goLineUpDown(int lines)
method for moving up or down one or more lines note: the sticky column is always a virtual column ...
Definition: katevimodebase.cpp:998
void addJump(KTextEditor::Cursor cursor)
Definition: kateviinputmodemanager.cpp:668
int indexIn(const QString &str, int offset, CaretMode caretMode) const
KateViRange goVisualLineUpDown(int lines)
Definition: katevimodebase.cpp:1052
Cursor findPrevWORDEnd(int fromLine, int fromColumn, bool onlyCurrentLine=false) const
Definition: katevimodebase.cpp:456
void clear()
virtual bool insertText(const KTextEditor::Cursor &position, const QString &s, bool block=false)
Definition: katedocument.cpp:530
virtual QStringList textLines(const KTextEditor::Range &range, bool block=false) const
Definition: katedocument.cpp:398
int count(const T &value) const
void fillRegister(const QChar ®, const QString &text, OperationMode flag=CharWise)
Definition: katevimodebase.cpp:963
bool isSpace() const
virtual QChar character(const KTextEditor::Cursor &position) const
Definition: katedocument.cpp:388
Definition: katevirange.h:33
Definition: katevimodebase.h:56
Definition: katevimodebase.h:58
KTextEditor::Cursor getNextJump(KTextEditor::Cursor)
Definition: katevimodebase.cpp:974
QPoint cursorToCoordinate(const KTextEditor::Cursor &cursor) const
Definition: kateview.cpp:2433
int toInt(bool *ok, int base) const
KateLineLayoutPtr line(int realLine, int virtualLine=-1)
Returns the KateLineLayout for the specified line.
Definition: katelayoutcache.cpp:280
bool isEmpty() const
QString trimmed() const
void updateCursor(const Cursor &c) const
Definition: katevimodebase.cpp:932
bool startsWith(const QString &s, Qt::CaseSensitivity cs) const
virtual KTextEditor::Cursor documentEnd() const
Definition: katedocument.cpp:4681
void viEnterVisualMode(ViMode visualMode=VisualMode)
set visual mode to be the active vi mode and make the needed setup work
Definition: kateviinputmodemanager.cpp:526
void switchView(Direction direction=Next)
Definition: katevimodebase.cpp:1416
Range findPattern(const QString &pattern, bool backwards, bool caseSensitive, const Cursor &startFrom, int count=-1) const
Definition: katevimodebase.cpp:183
Definition: katevimodebase.h:60
Cursor findWordEnd(int fromLine, int fromColumn, bool onlyCurrentLine=false) const
Definition: katevimodebase.cpp:604
KateTextLayout & viewLine(int viewLine)
Returns the layout of the corresponding line in the view.
Definition: katelayoutcache.cpp:358
Definition: kateview.h:77
Definition: kateviinputmodemanager.h:53
Cursor findNextWordStart(int fromLine, int fromColumn, bool onlyCurrentLine=false) const
Definition: katevimodebase.cpp:312
Definition: katevimodebase.h:51
void setUndoMergeAllEdits(bool merge)
Definition: katedocument.cpp:4722
Definition: katevimodebase.h:57
void setVisualModeType(ViMode mode)
Definition: katevivisualmode.cpp:213
Definition: kateviinputmodemanager.h:52
virtual QVector< KTextEditor::Range > searchText(const KTextEditor::Range &range, const QString &pattern, const KTextEditor::Search::SearchOptions options)
Definition: katedocument.cpp:1387
int findLineStartingWitchChar(const QChar &c, unsigned int count, bool forward=true) const
Definition: katevimodebase.cpp:899
Definition: katevirange.h:29
void storeLastChangeCommand()
copy the contents of the key events log to m_lastChange so that it can be repeated ...
Definition: kateviinputmodemanager.cpp:279
OperationMode getRegisterFlag(const QChar ®) const
Definition: kateviglobal.cpp:126
int lastIndexIn(const QString &str, int offset, CaretMode caretMode) const
QChar getChosenRegister(const QChar &defaultReg) const
Definition: katevimodebase.cpp:940
QString mid(int position, int n) const
void yankToClipBoard(QChar chosen_register, QString text)
Definition: katevimodebase.cpp:54
int textLength() const
bool isEmpty() const
bool deleteRange(KateViRange &r, OperationMode mode=LineWise, bool addToRegister=true)
Definition: katevimodebase.cpp:65
KTextEditor::Cursor getPrevJump(KTextEditor::Cursor)
Definition: katevimodebase.cpp:979
const QChar at(int position) const
KateViInputModeManager * m_viInputModeManager
Definition: katevimodebase.h:177
KTextEditor::Cursor getPrevJump(KTextEditor::Cursor cursor)
Definition: kateviinputmodemanager.cpp:704
bool isReplayingLastChange() const
Definition: kateviinputmodemanager.h:163
int length() const
virtual QString text(const KTextEditor::Range &range, bool blockwise=false) const
Definition: katedocument.cpp:337
bool m_lastMotionWasVisualLineUpOrDown
Definition: katevimodebase.h:169
QString getRegisterContent(const QChar ®)
Definition: katevimodebase.cpp:947
KateViRange findSurroundingBrackets(const QChar &c1, const QChar &c2, bool inner, const QChar &nested1, const QChar &nested2) const
Definition: katevimodebase.cpp:764
Cursor findPrevWordEnd(int fromLine, int fromColumn, bool onlyCurrentLine=false) const
Definition: katevimodebase.cpp:416
Definition: katevimodebase.h:52
virtual bool postMessage(KTextEditor::Message *message)
Definition: katedocument.cpp:5533
const Range getWordRangeUnderCursor() const
Definition: katevimodebase.cpp:147
KateViVisualMode * getViVisualMode()
Definition: kateviinputmodemanager.cpp:556
void editStart()
Enclose editor actions with editStart() and editEnd() to group them.
Definition: katedocument.cpp:776
Definition: katedefaultcolors.h:62
int size() const
Cursor findPrevWordStart(int fromLine, int fromColumn, bool onlyCurrentLine=false) const
Definition: katevimodebase.cpp:493
KateViRange findSurrounding(const QRegExp &c1, const QRegExp &c2, bool inner=false) const
Definition: katevimodebase.cpp:877
QString getRegisterContent(const QChar ®) const
Definition: kateviglobal.cpp:121
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
Definition: katevirange.h:29
void fillRegister(const QChar ®, const QString &text, OperationMode flag=CharWise)
Definition: kateviglobal.cpp:146
bool isAnyVisualMode() const
Definition: kateviinputmodemanager.cpp:461
virtual bool removeText(const KTextEditor::Range &range, bool block=false)
Definition: katedocument.cpp:633
Cursor findNextWORDStart(int fromLine, int fromColumn, bool onlyCurrentLine=false) const
Definition: katevimodebase.cpp:374
Definition: katevimodebase.h:59
void viEnterInsertMode()
set insert mode to be the active vi mode and perform the needed setup work
Definition: kateviinputmodemanager.cpp:511
void addToNumberUnderCursor(int count)
Definition: katevimodebase.cpp:1323
KateViRange findPatternForMotion(const QString &pattern, bool backwards, bool caseSensitive, const Cursor &startFrom, int count=1) const
Definition: katevimodebase.cpp:299
void viEnterReplaceMode()
set replace mode to be the active vi mode and make the needed setup work
Definition: kateviinputmodemanager.cpp:538
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Sat May 9 2020 03:56:59 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2020 The KDE developers.
Generated on Sat May 9 2020 03:56:59 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.