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
56 if ((chosen_register == '0' || chosen_register == '-') && text.length() > 1) { //only yank to the clipboard if no register was specified and textlength > 1
74 res = doc()->removeText( Range( r.startLine, r.startColumn, r.endLine, r.endColumn), mode == Block );
188 Range KateViModeBase::findPattern(const QString& pattern, bool backwards, bool caseSensitive, const Cursor& startFrom, int count) const
210 const KTextEditor::Range matchRange = m_view->doc()->searchText(KTextEditor::Range(Cursor(searchBegin.line(), searchBegin.column() + 1), m_view->doc()->documentEnd()), pattern, flags).first();
219 const KTextEditor::Range wrappedMatchRange = m_view->doc()->searchText(KTextEditor::Range(m_view->doc()->documentRange().start(), m_view->doc()->documentEnd()), pattern, flags).first();
237 // Unfortunately, searchText doesn't necessarily turn up all matches (just the first one, sometimes)
238 // so we must repeatedly search in such a way that the previous match isn't found, until we either
240 Cursor newSearchBegin = Cursor(searchBegin.line(), m_view->doc()->lineLength(searchBegin.line()));
244 QVector<Range> matchesUnfiltered = m_view->doc()->searchText(Range(newSearchBegin, m_view->doc()->documentRange().start()), pattern, flags);
245 kDebug(13070) << "matchesUnfiltered: " << matchesUnfiltered << " searchBegin: " << newSearchBegin;
286 const KTextEditor::Range wrappedMatchRange = m_view->doc()->searchText(KTextEditor::Range(m_view->doc()->documentEnd(), m_view->doc()->documentRange().start()), pattern, flags).first();
304 KateViRange KateViModeBase::findPatternForMotion( const QString& pattern, bool backwards, bool caseSensitive, const Cursor& startFrom, int count ) const
314 return KateViRange( match.start().line(), match.start().column(), match.end().line(), match.end().column(), ViMotion::ExclusiveMotion );
317 Cursor KateViModeBase::findNextWordStart( int fromLine, int fromColumn, bool onlyCurrentLine ) const
330 QRegExp nonWordAfterWord( "\\b(?!\\s)\\W" ); // word-boundary followed by a non-word which is not a space
379 Cursor KateViModeBase::findNextWORDStart( int fromLine, int fromColumn, bool onlyCurrentLine ) const
421 Cursor KateViModeBase::findPrevWordEnd( int fromLine, int fromColumn, bool onlyCurrentLine ) const
461 Cursor KateViModeBase::findPrevWORDEnd( int fromLine, int fromColumn, bool onlyCurrentLine ) const
498 Cursor KateViModeBase::findPrevWordStart( int fromLine, int fromColumn, bool onlyCurrentLine ) const
511 QRegExp nonWordAfterWord( "\\b(?!\\s)\\W" ); // word-boundary followed by a non-word which is not a space
562 Cursor KateViModeBase::findPrevWORDStart( int fromLine, int fromColumn, bool onlyCurrentLine ) const
882 KateViRange KateViModeBase::findSurrounding( const QRegExp &c1, const QRegExp &c2, bool inner ) const
904 int KateViModeBase::findLineStartingWitchChar( const QChar &c, unsigned int count, bool forward ) const
1129 // the continuations are also "invisibly" (i.e. without any spaces in the text itself) indented.
1130 const bool isWrappedContinuation = (m_viewInternal->cache()->textLayout(startRealLine, startVisualLine).lineLayout().lineNumber() != 0);
1131 const int numInvisibleIndentChars = isWrappedContinuation ? startLine->toVirtualColumn(m_viewInternal->cache()->line(startRealLine)->textLine()->nextNonSpaceChar(0), tabstop) : 0;
1133 const int realLineStartColumn = m_viewInternal->cache()->textLayout(startRealLine, startVisualLine).startCol();
1135 const int visualColumnNoInvisibleIndent = startLine->toVirtualColumn(c.column(), tabstop) - lineStartVirtualColumn;
1140 // The "real" (non-virtual) beginning of the current "line", which might be a wrapped continuation of a
1142 const int realLineStartColumn = m_viewInternal->cache()->textLayout(finishRealLine, finishVisualLine).startCol();
1145 // the continuations are also "invisibly" (i.e. without any spaces in the text itself) indented.
1146 const bool isWrappedContinuation = (m_viewInternal->cache()->textLayout(finishRealLine, finishVisualLine).lineLayout().lineNumber() != 0);
1147 const int numInvisibleIndentChars = isWrappedContinuation ? endLine->toVirtualColumn(m_viewInternal->cache()->line(finishRealLine)->textLine()->nextNonSpaceChar(0), tabstop) : 0;
1150 const int visualEndColumn = m_viewInternal->cache()->textLayout(finishRealLine, finishVisualLine).lineLayout().textLength() - 1;
1151 r.endColumn = endLine->fromVirtualColumn( visualEndColumn + realLineStartColumn - numInvisibleIndentChars, tabstop );
1161 const int visualColumn = endLine->toVirtualColumn( realLineStartColumn + realOffsetToVisualStickyColumn, tabstop ) - lineStartVirtualColumn + numInvisibleIndentChars;
1348 for (int searchFromColumn = wordStartPos; searchFromColumn < currentLineLength; searchFromColumn++)
1405 // Create the new text string to be inserted. Prepend with “0x” if in base 16, and "0" if base 8.
1406 // For non-decimal numbers, try to keep the length of the number the same (including leading 0's).
1407 QString newNumberPadded = (base == 16 || base == 8) ? QString("%1").arg(newNumber, withoutBase.length(), base, QChar('0')) : QString("%1").arg(newNumber, 0, base);
1420 doc()->removeText( KTextEditor::Range( c.line(), numberStartPos , c.line(), numberStartPos+numberAsString.length() ) );
1423 updateCursor(Cursor(m_view->cursorPosition().line(), numberStartPos + newNumberText.length() - 1));
1439 int curr_cursor_y = m_view->mapToGlobal(m_view->cursorToCoordinate(m_view->cursorPosition())).y();
1440 int curr_cursor_x = m_view->mapToGlobal(m_view->cursorToCoordinate(m_view->cursorPosition())).x();
1443 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:1548
Cursor & start()
void viEnterNormalMode()
set normal mode to be the active vi mode and perform the needed setup work
Definition: kateviinputmodemanager.cpp:472
Cursor findWORDEnd(int fromLine, int fromColumn, bool onlyCurrentLine=false) const
Definition: katevimodebase.cpp:650
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:562
OperationMode getRegisterFlag(const QChar ®) const
Definition: katevimodebase.cpp:963
QPointer< KTextEditor::Message > m_infoMessage
Definition: katevimodebase.h:180
KateViRange findSurroundingQuotes(const QChar &c, bool inner=false) const
Definition: katevimodebase.cpp:702
const QString getWordUnderCursor() const
Definition: katevimodebase.cpp:146
virtual bool isValid() const
const QChar getCharUnderCursor() const
Definition: katevimodebase.cpp:133
const QChar getCharAtVirtualColumn(QString &line, int virtualColumn, int tabWidht) const
Definition: katevimodebase.cpp:1292
bool m_currentMotionWasVisualLineUpOrDown
Definition: katevimodebase.h:170
void changeViMode(ViMode newMode)
changes the current vi mode to the given mode
Definition: kateviinputmodemanager.cpp:444
Definition: kateviinputmodemanager.h:51
const Kate::TextLine & textLine(bool forceReload=false) const
Definition: katelinelayout.cpp:65
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:547
static QDebug kDebug(bool cond, int area=KDE_DEFAULT_DEBUG_AREA)
Kate::TextLine plainKateTextLine(uint i)
Definition: katedocument.cpp:4713
const QString getRange(KateViRange &r, OperationMode mode=LineWise) const
Definition: katevimodebase.cpp:91
KTextEditor::Cursor getNextJump(KTextEditor::Cursor cursor)
Definition: kateviinputmodemanager.cpp:675
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:1003
void addJump(KTextEditor::Cursor cursor)
Definition: kateviinputmodemanager.cpp:656
KateViRange goVisualLineUpDown(int lines)
Definition: katevimodebase.cpp:1057
Cursor findPrevWORDEnd(int fromLine, int fromColumn, bool onlyCurrentLine=false) const
Definition: katevimodebase.cpp:461
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
void fillRegister(const QChar ®, const QString &text, OperationMode flag=CharWise)
Definition: katevimodebase.cpp:968
virtual QChar character(const KTextEditor::Cursor &position) const
Definition: katedocument.cpp:388
Definition: katevirange.h:33
Definition: katevimodebase.h:56
KTextEditor::Cursor getNextJump(KTextEditor::Cursor)
Definition: katevimodebase.cpp:979
QPoint cursorToCoordinate(const KTextEditor::Cursor &cursor) const
Definition: kateview.cpp:2408
KateLineLayoutPtr line(int realLine, int virtualLine=-1)
Returns the KateLineLayout for the specified line.
Definition: katelayoutcache.cpp:280
void updateCursor(const Cursor &c) const
Definition: katevimodebase.cpp:937
virtual KTextEditor::Cursor documentEnd() const
Definition: katedocument.cpp:4682
void viEnterVisualMode(ViMode visualMode=VisualMode)
set visual mode to be the active vi mode and make the needed setup work
Definition: kateviinputmodemanager.cpp:514
void switchView(Direction direction=Next)
Definition: katevimodebase.cpp:1426
Range findPattern(const QString &pattern, bool backwards, bool caseSensitive, const Cursor &startFrom, int count=-1) const
Definition: katevimodebase.cpp:188
Definition: katevimodebase.h:60
const QString getLine(int lineNumber=-1) const
Definition: katevimodebase.cpp:119
Range documentRange() const
Cursor findWordEnd(int fromLine, int fromColumn, bool onlyCurrentLine=false) const
Definition: katevimodebase.cpp:609
KateTextLayout & viewLine(int viewLine)
Returns the layout of the corresponding line in the view.
Definition: katelayoutcache.cpp:358
Definition: kateview.h:78
Definition: kateviinputmodemanager.h:53
Cursor findNextWordStart(int fromLine, int fromColumn, bool onlyCurrentLine=false) const
Definition: katevimodebase.cpp:317
Definition: katevimodebase.h:51
void setUndoMergeAllEdits(bool merge)
Definition: katedocument.cpp:4723
Definition: katevimodebase.h:57
KGuiItem ok()
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:904
Definition: katevirange.h:29
virtual int line() const
void storeLastChangeCommand()
copy the contents of the key events log to m_lastChange so that it can be repeated ...
Definition: kateviinputmodemanager.cpp:278
OperationMode getRegisterFlag(const QChar ®) const
Definition: kateviglobal.cpp:126
QChar getChosenRegister(const QChar &defaultReg) const
Definition: katevimodebase.cpp:945
void yankToClipBoard(QChar chosen_register, QString text)
Definition: katevimodebase.cpp:54
bool deleteRange(KateViRange &r, OperationMode mode=LineWise, bool addToRegister=true)
Definition: katevimodebase.cpp:61
KTextEditor::Cursor getPrevJump(KTextEditor::Cursor)
Definition: katevimodebase.cpp:984
Cursor & end()
KateViInputModeManager * m_viInputModeManager
Definition: katevimodebase.h:177
KTextEditor::Cursor getPrevJump(KTextEditor::Cursor cursor)
Definition: kateviinputmodemanager.cpp:692
QSharedPointer< TextLineData > TextLine
The normal world only accesses the text lines with shared pointers.
Definition: katetextline.h:443
bool isReplayingLastChange() const
Definition: kateviinputmodemanager.h:153
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:952
KateViRange findSurroundingBrackets(const QChar &c1, const QChar &c2, bool inner, const QChar &nested1, const QChar &nested2) const
Definition: katevimodebase.cpp:769
Cursor findPrevWordEnd(int fromLine, int fromColumn, bool onlyCurrentLine=false) const
Definition: katevimodebase.cpp:421
Definition: katevimodebase.h:52
virtual bool postMessage(KTextEditor::Message *message)
Definition: katedocument.cpp:5498
const Range getWordRangeUnderCursor() const
Definition: katevimodebase.cpp:152
KateViVisualMode * getViVisualMode()
Definition: kateviinputmodemanager.cpp:544
void editStart()
Enclose editor actions with editStart() and editEnd() to group them.
Definition: katedocument.cpp:776
Cursor findPrevWordStart(int fromLine, int fromColumn, bool onlyCurrentLine=false) const
Definition: katevimodebase.cpp:498
KateViRange findSurrounding(const QRegExp &c1, const QRegExp &c2, bool inner=false) const
Definition: katevimodebase.cpp:882
QString getRegisterContent(const QChar ®) const
Definition: kateviglobal.cpp:121
virtual void setColumn(int column)
int column() const
Definition: katevirange.h:29
void fillRegister(const QChar ®, const QString &text, OperationMode flag=CharWise)
Definition: kateviglobal.cpp:146
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:379
void viEnterInsertMode()
set insert mode to be the active vi mode and perform the needed setup work
Definition: kateviinputmodemanager.cpp:499
void addToNumberUnderCursor(int count)
Definition: katevimodebase.cpp:1325
KateViRange findPatternForMotion(const QString &pattern, bool backwards, bool caseSensitive, const Cursor &startFrom, int count=1) const
Definition: katevimodebase.cpp:304
void viEnterReplaceMode()
set replace mode to be the active vi mode and make the needed setup work
Definition: kateviinputmodemanager.cpp:526
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:31:53 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:31:53 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.