• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • applications API Reference
  • KDE Home
  • Contact Us
 

Kate

  • sources
  • kde-4.12
  • applications
  • kate
  • part
  • vimode
katevinormalmode.cpp
Go to the documentation of this file.
1 /* This file is part of the KDE libraries and the Kate part.
2  *
3  * Copyright (C) 2008-2009 Erlend Hamberg <ehamberg@gmail.com>
4  * Copyright (C) 2008 Evgeniy Ivanov <powerfox@kde.ru>
5  * Copyright (C) 2009 Paul Gideon Dann <pdgiddie@gmail.com>
6  * Copyright (C) 2011 Svyatoslav Kuzmich <svatoslav1@gmail.com>
7  * Copyright (C) 2012 - 2013 Simon St James <kdedevel@etotheipiplusone.com>
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Library General Public
11  * License as published by the Free Software Foundation; either
12  * version 2 of the License, or (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * Library General Public License for more details.
18  *
19  * You should have received a copy of the GNU Library General Public License
20  * along with this library; see the file COPYING.LIB. If not, write to
21  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22  * Boston, MA 02110-1301, USA.
23  */
24 
25 #include "katevinormalmode.h"
26 #include "katevivisualmode.h"
27 #include "kateviinsertmode.h"
28 #include "kateviinputmodemanager.h"
29 #include "kateviglobal.h"
30 #include "katevikeymapper.h"
31 #include "kateviemulatedcommandbar.h"
32 #include "kateglobal.h"
33 #include "kateconfig.h"
34 #include "katebuffer.h"
35 #include "kateviewhelpers.h"
36 #include <kateundomanager.h>
37 #include <ktexteditor/attribute.h>
38 #include <katecompletionwidget.h>
39 #include "kateconfig.h"
40 
41 #include <QApplication>
42 #include <QList>
43 
44 using KTextEditor::Cursor;
45 using KTextEditor::Range;
46 
47 #define ADDCMD(STR, FUNC, FLGS) m_commands.push_back( \
48  new KateViCommand( this, STR, &KateViNormalMode::FUNC, FLGS ) );
49 
50 #define ADDMOTION(STR, FUNC, FLGS) m_motions.push_back( \
51  new KateViMotion( this, STR, &KateViNormalMode::FUNC, FLGS ) );
52 
53 KateViNormalMode::KateViNormalMode( KateViInputModeManager *viInputModeManager, KateView * view,
54  KateViewInternal * viewInternal ) : KateViModeBase()
55 {
56  m_view = view;
57  m_viewInternal = viewInternal;
58  m_viInputModeManager = viInputModeManager;
59  m_stickyColumn = -1;
60  m_lastMotionWasVisualLineUpOrDown = false;
61  m_currentMotionWasVisualLineUpOrDown = false;
62 
63  // FIXME: make configurable
64  m_extraWordCharacters = "";
65  m_matchingItems["/*"] = "*/";
66  m_matchingItems["*/"] = "-/*";
67 
68  m_matchItemRegex = generateMatchingItemRegex();
69 
70  m_defaultRegister = '"';
71 
72  m_scroll_count_limit = 1000; // Limit of count for scroll commands.
73 
74  initializeCommands();
75  m_pendingResetIsDueToExit = false;
76  m_isRepeatedTFcommand = false;
77  m_lastMotionWasLinewiseInnerBlock = false;
78  m_motionCanChangeWholeVisualModeSelection = false;
79  resetParser(); // initialise with start configuration
80 
81  m_isUndo = false;
82  connect(doc()->undoManager(), SIGNAL(undoStart(KTextEditor::Document*)),
83  this, SLOT(undoBeginning()));
84  connect(doc()->undoManager(), SIGNAL(undoEnd(KTextEditor::Document*)),
85  this, SLOT(undoEnded()));
86 
87  updateYankHighlightAttrib();
88  connect(view, SIGNAL(configChanged()),
89  this, SLOT(updateYankHighlightAttrib()));
90  connect(doc(), SIGNAL(aboutToInvalidateMovingInterfaceContent(KTextEditor::Document*)),
91  this, SLOT(clearYankHighlight()));
92  connect(doc(), SIGNAL(aboutToDeleteMovingInterfaceContent(KTextEditor::Document*)),
93  this, SLOT(aboutToDeleteMovingInterfaceContent()));
94  m_highlightedYank = NULL;
95 
96 }
97 
98 KateViNormalMode::~KateViNormalMode()
99 {
100  qDeleteAll( m_commands );
101  qDeleteAll( m_motions) ;
102  delete m_highlightedYank;
103 }
104 
109 bool KateViNormalMode::handleKeypress( const QKeyEvent *e )
110 {
111  const int keyCode = e->key();
112  const QString text = e->text();
113 
114  // ignore modifier keys alone
115  if ( keyCode == Qt::Key_Shift || keyCode == Qt::Key_Control
116  || keyCode == Qt::Key_Alt || keyCode == Qt::Key_Meta ) {
117  return false;
118  }
119 
120  clearYankHighlight();
121 
122  if ( keyCode == Qt::Key_Escape || (keyCode == Qt::Key_C && e->modifiers() == Qt::ControlModifier) || (keyCode == Qt::Key_BracketLeft && e->modifiers() == Qt::ControlModifier)) {
123  m_view->setCaretStyle( KateRenderer::Block, true );
124  m_pendingResetIsDueToExit = true;
125  // Vim in weird as if we e.g. i<ctrl-o><ctrl-c> it claims (in the status bar) to still be in insert mode,
126  // but behaves as if it's in normal mode. I'm treating the status bar thing as a bug and just exiting
127  // insert mode altogether.
128  m_viInputModeManager->setTemporaryNormalMode(false);
129  reset();
130  return true;
131  }
132 
133  const QChar key = KateViKeyParser::self()->KeyEventToQChar(*e);
134 
135  const QChar lastChar = m_keys.isEmpty() ? QChar::Null : m_keys.at(m_keys.size() - 1);
136  const bool waitingForRegisterOrCharToSearch = this->waitingForRegisterOrCharToSearch();
137 
138  // Use replace caret when reading a character for "r"
139  if ( key == 'r' && !waitingForRegisterOrCharToSearch) {
140  m_view->setCaretStyle( KateRenderer::Underline, true );
141  }
142 
143  m_keysVerbatim.append( KateViKeyParser::self()->decodeKeySequence( key ) );
144 
145  if ( ( keyCode >= Qt::Key_0 && keyCode <= Qt::Key_9 && lastChar != '"' ) // key 0-9
146  && ( m_countTemp != 0 || keyCode != Qt::Key_0 ) // first digit can't be 0
147  && (!waitingForRegisterOrCharToSearch) // Not in the middle of "find char" motions or replacing char.
148  && e->modifiers() == Qt::NoModifier) {
149 
150  m_countTemp *= 10;
151  m_countTemp += keyCode-Qt::Key_0;
152 
153  return true;
154  } else if ( m_countTemp != 0 ) {
155  m_count = getCount() * m_countTemp;
156  m_countTemp = 0;
157  m_iscounted = true;
158 
159  kDebug( 13070 ) << "count = " << getCount();
160  }
161 
162  m_keys.append( key );
163 
164  if (m_viInputModeManager->isRecordingMacro() && key == 'q')
165  {
166  // Need to special case this "finish macro" q, as the "begin macro" q
167  // needs a parameter whereas the finish macro does not.
168  m_viInputModeManager->finishRecordingMacro();
169  resetParser();
170  return true;
171  }
172 
173  if ((key == '/' || key == '?') && !waitingForRegisterOrCharToSearch)
174  {
175  // Special case for "/" and "?": these should be motions, but this is complicated by
176  // the fact that the user must interact with the search bar before the range of the
177  // motion can be determined.
178  // We hack around this by showing the search bar immediately, and, when the user has
179  // finished interacting with it, have the search bar send a "synthetic" keypresses
180  // that will either abort everything (if the search was aborted) or "complete" the motion
181  // otherwise.
182  m_positionWhenIncrementalSearchBegan = m_view->cursorPosition();
183  if (key == '/')
184  {
185  commandSearchForward();
186  }
187  else
188  {
189  commandSearchBackward();
190  }
191  return true;
192  }
193 
194  // Special case: "cw" and "cW" work the same as "ce" and "cE" if the cursor is
195  // on a non-blank. This is because Vim interprets "cw" as change-word, and a
196  // word does not include the following white space. (:help cw in vim)
197  if ( ( m_keys == "cw" || m_keys == "cW" ) && !getCharUnderCursor().isSpace() ) {
198  // Special case of the special case: :-)
199  // If the cursor is at the end of the current word rewrite to "cl"
200  const bool isWORD = (m_keys.at(1) == 'W');
201  const Cursor currentPosition( m_view->cursorPosition() );
202  const Cursor endOfWordOrWORD = (isWORD ? findWORDEnd(currentPosition.line(), currentPosition.column()-1, true) :
203  findWordEnd(currentPosition.line(), currentPosition.column()-1, true));
204 
205  if ( currentPosition == endOfWordOrWORD ) {
206  m_keys = "cl";
207  } else {
208  if (isWORD) {
209  m_keys = "cE";
210  } else {
211  m_keys = "ce";
212  }
213  }
214  }
215 
216  if ( m_keys[ 0 ] == Qt::Key_QuoteDbl ) {
217  if ( m_keys.size() < 2 ) {
218  return true; // waiting for a register
219  }
220  else {
221  QChar r = m_keys[ 1 ].toLower();
222 
223  if ( ( r >= '0' && r <= '9' ) || ( r >= 'a' && r <= 'z' ) ||
224  r == '_' || r == '+' || r == '*' || r == '#' || r == '^' ) {
225  m_register = r;
226  kDebug( 13070 ) << "Register set to " << r;
227  m_keys.clear();
228  return true;
229  }
230  else {
231  resetParser();
232  return true;
233  }
234  }
235  }
236 
237  // if we have any matching commands so far, check which ones still match
238  if ( m_matchingCommands.size() > 0 ) {
239  int n = m_matchingCommands.size()-1;
240 
241  // remove commands not matching anymore
242  for ( int i = n; i >= 0; i-- ) {
243  if ( !m_commands.at( m_matchingCommands.at( i ) )->matches( m_keys ) ) {
244  //kDebug( 13070 ) << "removing " << m_commands.at( m_matchingCommands.at( i ) )->pattern() << ", size before remove is " << m_matchingCommands.size();
245  if ( m_commands.at( m_matchingCommands.at( i ) )->needsMotion() ) {
246  // "cache" command needing a motion for later
247  //kDebug( 13070 ) << "m_motionOperatorIndex set to " << m_motionOperatorIndex;
248  m_motionOperatorIndex = m_matchingCommands.at( i );
249  }
250  m_matchingCommands.remove( i );
251  }
252  }
253 
254  // check if any of the matching commands need a motion/text object, if so
255  // push the current command length to m_awaitingMotionOrTextObject so one
256  // knows where to split the command between the operator and the motion
257  for ( int i = 0; i < m_matchingCommands.size(); i++ ) {
258  if ( m_commands.at( m_matchingCommands.at( i ) )->needsMotion() ) {
259  m_awaitingMotionOrTextObject.push( m_keys.size() );
260  break;
261  }
262  }
263  } else {
264  // go through all registered commands and put possible matches in m_matchingCommands
265  for ( int i = 0; i < m_commands.size(); i++ ) {
266  if ( m_commands.at( i )->matches( m_keys ) ) {
267  m_matchingCommands.push_back( i );
268  if ( m_commands.at( i )->needsMotion() && m_commands.at( i )->pattern().length() == m_keys.size() ) {
269  m_awaitingMotionOrTextObject.push( m_keys.size() );
270  }
271  }
272  }
273  }
274 
275  // this indicates where in the command string one should start looking for a motion command
276  int checkFrom = ( m_awaitingMotionOrTextObject.isEmpty() ? 0 : m_awaitingMotionOrTextObject.top() );
277 
278  // Use operator-pending caret when reading a motion for an operator
279  // in normal mode. We need to check that we are indeed in normal mode
280  // since visual mode inherits from it.
281  if( m_viInputModeManager->getCurrentViMode() == NormalMode &&
282  !m_awaitingMotionOrTextObject.isEmpty() ) {
283  m_view->setCaretStyle( KateRenderer::Half, true );
284  }
285 
286  //kDebug( 13070 ) << "checkFrom: " << checkFrom;
287 
288  // look for matching motion commands from position 'checkFrom'
289  // FIXME: if checkFrom hasn't changed, only motions whose index is in
290  // m_matchingMotions should be checked
291  bool motionExecuted = false;
292  if ( checkFrom < m_keys.size() ) {
293  for ( int i = 0; i < m_motions.size(); i++ ) {
294  //kDebug( 13070 ) << "\tchecking " << m_keys.mid( checkFrom ) << " against " << m_motions.at( i )->pattern();
295  if ( m_motions.at( i )->matches( m_keys.mid( checkFrom ) ) ) {
296  m_lastMotionWasLinewiseInnerBlock = false;
297  //kDebug( 13070 ) << m_keys.mid( checkFrom ) << " matches!";
298  m_matchingMotions.push_back( i );
299 
300  // if it matches exact, we have found the motion command to execute
301  if ( m_motions.at( i )->matchesExact( m_keys.mid( checkFrom ) ) ) {
302  m_currentMotionWasVisualLineUpOrDown = false;
303  motionExecuted = true;
304  if ( checkFrom == 0 ) {
305  // no command given before motion, just move the cursor to wherever
306  // the motion says it should go to
307  KateViRange r = m_motions.at( i )->execute();
308  m_motionCanChangeWholeVisualModeSelection = m_motions.at( i )->canChangeWholeVisualModeSelection();
309 
310  // jump over folding regions since we are just moving the cursor
311  int currLine = m_view->cursorPosition().line();
312  int delta = r.endLine - currLine;
313  int vline = m_view->textFolding().lineToVisibleLine( currLine );
314  r.endLine = m_view->textFolding().visibleLineToLine( qMax (vline+delta, 0) /* ensure we have a valid line */ );
315  if ( r.endLine >= doc()->lines() ) r.endLine = doc()->lines()-1;
316 
317  // make sure the position is valid before moving the cursor there
318  // TODO: can this be simplified? :/
319  if ( r.valid
320  && r.endLine >= 0
321  && ( r.endLine == 0 || r.endLine <= doc()->lines()-1 )
322  && r.endColumn >= 0 ) {
323  if ( r.endColumn >= doc()->lineLength( r.endLine )
324  && doc()->lineLength( r.endLine ) > 0 ) {
325  r.endColumn = doc()->lineLength( r.endLine ) - 1;
326  }
327 
328  kDebug( 13070 ) << "No command given, going to position ("
329  << r.endLine << "," << r.endColumn << ")";
330  goToPos( r );
331  m_viInputModeManager->clearCurrentChangeLog();
332  } else {
333  kDebug( 13070 ) << "Invalid position: (" << r.endLine << "," << r.endColumn << ")";
334  }
335 
336  resetParser();
337 
338  // if normal mode was started by using Ctrl-O in insert mode,
339  // it's time to go back to insert mode.
340  if (m_viInputModeManager->getTemporaryNormalMode()) {
341  startInsertMode();
342  m_viewInternal->repaint();
343  }
344 
345  m_lastMotionWasVisualLineUpOrDown = m_currentMotionWasVisualLineUpOrDown;
346 
347  break;
348  } else {
349  // execute the specified command and supply the position returned from
350  // the motion
351 
352  m_commandRange = m_motions.at( i )->execute();
353  m_linewiseCommand = m_motions.at( i )->isLineWise();
354 
355  // if we didn't get an explicit start position, use the current cursor position
356  if ( m_commandRange.startLine == -1 ) {
357  Cursor c( m_view->cursorPosition() );
358  m_commandRange.startLine = c.line();
359  m_commandRange.startColumn = c.column();
360  }
361 
362  // special case: When using the "w" motion in combination with an operator and
363  // the last word moved over is at the end of a line, the end of that word
364  // becomes the end of the operated text, not the first word in the next line.
365  if ( m_motions.at(i)->pattern() == "w" || m_motions.at(i)->pattern() == "W" ) {
366  if(m_commandRange.endLine != m_commandRange.startLine &&
367  m_commandRange.endColumn == getLine(m_commandRange.endLine).indexOf( QRegExp("\\S") )){
368  m_commandRange.endLine--;
369  m_commandRange.endColumn = doc()->lineLength(m_commandRange.endLine );
370  }
371  }
372 
373  m_commandWithMotion = true;
374 
375  if ( m_commandRange.valid ) {
376  kDebug( 13070 ) << "Run command" << m_commands.at( m_motionOperatorIndex )->pattern()
377  << "from (" << m_commandRange.startLine << "," << m_commandRange.startColumn << ")"
378  << "to (" << m_commandRange.endLine << "," << m_commandRange.endColumn << ")";
379  executeCommand( m_commands.at( m_motionOperatorIndex ) );
380  } else {
381  kDebug( 13070 ) << "Invalid range: "
382  << "from (" << m_commandRange.startLine << "," << m_commandRange.startColumn << ")"
383  << "to (" << m_commandRange.endLine << "," << m_commandRange.endColumn << ")";
384  }
385 
386  if( m_viInputModeManager->getCurrentViMode() == NormalMode ) {
387  m_view->setCaretStyle( KateRenderer::Block, true );
388  }
389  m_commandWithMotion = false;
390  reset();
391  break;
392  }
393  }
394  }
395  }
396  }
397 
398  if (this->waitingForRegisterOrCharToSearch())
399  {
400  // If we are waiting for a char to search or a new register,
401  // don't translate next character; we need the actual character so that e.g.
402  // 'ab' is translated to 'fb' if the mappings 'a' -> 'f' and 'b' -> something else
403  // exist.
404  m_viInputModeManager->keyMapper()->setDoNotMapNextKeypress();
405  }
406 
407  if (motionExecuted)
408  {
409  return true;
410  }
411 
412  //kDebug( 13070 ) << "'" << m_keys << "' MATCHING COMMANDS: " << m_matchingCommands.size();
413  //kDebug( 13070 ) << "'" << m_keys << "' MATCHING MOTIONS: " << m_matchingMotions.size();
414  //kDebug( 13070 ) << "'" << m_keys << "' AWAITING MOTION OR TO (INDEX): " << ( m_awaitingMotionOrTextObject.isEmpty() ? 0 : m_awaitingMotionOrTextObject.top() );
415 
416  // if we have only one match, check if it is a perfect match and if so, execute it
417  // if it's not waiting for a motion or a text object
418  if ( m_matchingCommands.size() == 1 ) {
419  if ( m_commands.at( m_matchingCommands.at( 0 ) )->matchesExact( m_keys )
420  && !m_commands.at( m_matchingCommands.at( 0 ) )->needsMotion() ) {
421  //kDebug( 13070 ) << "Running command at index " << m_matchingCommands.at( 0 );
422 
423  if( m_viInputModeManager->getCurrentViMode() == NormalMode ) {
424  m_view->setCaretStyle( KateRenderer::Block, true );
425  }
426 
427  KateViCommand *cmd = m_commands.at( m_matchingCommands.at( 0 ) );
428  executeCommand( cmd );
429 
430  // check if reset() should be called. some commands in visual mode should not end visual mode
431  if ( cmd->shouldReset() ) {
432  reset();
433  m_view->setBlockSelection(false);
434  }
435  resetParser();
436 
437  return true;
438  }
439  } else if ( m_matchingCommands.size() == 0 && m_matchingMotions.size() == 0 ) {
440  resetParser();
441  return false;
442  }
443 
444  m_matchingMotions.clear();
445  return false;
446 }
447 
452 void KateViNormalMode::resetParser()
453 {
454 // kDebug( 13070 ) << "***RESET***";
455  m_keys.clear();
456  m_keysVerbatim.clear();
457  m_count = 0;
458  m_oneTimeCountOverride = -1;
459  m_iscounted = false;
460  m_countTemp = 0;
461  m_register = QChar::Null;
462  m_findWaitingForChar = false;
463  m_matchingCommands.clear();
464  m_matchingMotions.clear();
465  m_awaitingMotionOrTextObject.clear();
466  m_motionOperatorIndex = 0;
467 
468  m_commandWithMotion = false;
469  m_linewiseCommand = true;
470  m_deleteCommand = false;
471 
472  m_commandShouldKeepSelection = false;
473 
474  m_currentChangeEndMarker = Cursor::invalid();
475 }
476 
477 // reset the command parser
478 void KateViNormalMode::reset()
479 {
480  resetParser();
481  m_commandRange.startLine = -1;
482  m_commandRange.startColumn = -1;
483 }
484 
485 void KateViNormalMode::beginMonitoringDocumentChanges()
486 {
487  connect(doc(), SIGNAL(textInserted(KTextEditor::Document*,KTextEditor::Range)),
488  this, SLOT(textInserted(KTextEditor::Document*,KTextEditor::Range)));
489  connect(doc(), SIGNAL(textRemoved(KTextEditor::Document*,KTextEditor::Range)),
490  this, SLOT(textRemoved(KTextEditor::Document*,KTextEditor::Range)));
491 }
492 
493 void KateViNormalMode::goToPos( const KateViRange &r )
494 {
495  Cursor c;
496  c.setLine( r.endLine );
497  c.setColumn( r.endColumn );
498 
499  if ( r.jump ) {
500  addCurrentPositionToJumpList();
501  }
502 
503  if ( c.line() >= doc()->lines() ) {
504  c.setLine( doc()->lines()-1 );
505  }
506 
507  updateCursor( c );
508 }
509 
510 void KateViNormalMode::executeCommand( const KateViCommand* cmd )
511 {
512  cmd->execute();
513 
514  // if normal mode was started by using Ctrl-O in insert mode,
515  // it's time to go back to insert mode.
516  if (m_viInputModeManager->getTemporaryNormalMode()) {
517  startInsertMode();
518  m_viewInternal->repaint();
519  }
520 
521  // if the command was a change, and it didn't enter insert mode, store the key presses so that
522  // they can be repeated with '.'
523  if ( m_viInputModeManager->getCurrentViMode() != InsertMode ) {
524  if ( cmd->isChange() && !m_viInputModeManager->isReplayingLastChange() ) {
525  m_viInputModeManager->storeLastChangeCommand();
526  }
527 
528  m_viInputModeManager->clearCurrentChangeLog();
529  }
530 
531  // make sure the cursor does not end up after the end of the line
532  Cursor c( m_view->cursorPosition() );
533  if ( m_viInputModeManager->getCurrentViMode() == NormalMode ) {
534  int lineLength = doc()->lineLength( c.line() );
535 
536  if ( c.column() >= lineLength ) {
537  if ( lineLength == 0 ) {
538  c.setColumn( 0 );
539  } else {
540  c.setColumn( lineLength-1 );
541  }
542  }
543  updateCursor( c );
544  }
545 }
546 
547 void KateViNormalMode::addCurrentPositionToJumpList() {
548  m_viInputModeManager->addJump(m_view->cursorPosition());
549 }
550 
552 // COMMANDS AND OPERATORS
554 
559 bool KateViNormalMode::commandEnterInsertMode()
560 {
561  m_stickyColumn = -1;
562  m_viInputModeManager->getViInsertMode()->setCount(getCount());
563  return startInsertMode();
564 }
565 
570 bool KateViNormalMode::commandEnterInsertModeAppend()
571 {
572  Cursor c( m_view->cursorPosition() );
573  c.setColumn( c.column()+1 );
574 
575  // if empty line, the cursor should start at column 0
576  if ( doc()->lineLength( c.line() ) == 0 ) {
577  c.setColumn( 0 );
578  }
579 
580  // cursor should never be in a column > number of columns
581  if ( c.column() > doc()->lineLength( c.line() ) ) {
582  c.setColumn( doc()->lineLength( c.line() ) );
583  }
584 
585  updateCursor( c );
586 
587  m_stickyColumn = -1;
588  m_viInputModeManager->getViInsertMode()->setCount(getCount());
589  return startInsertMode();
590 }
591 
596 bool KateViNormalMode::commandEnterInsertModeAppendEOL()
597 {
598  Cursor c( m_view->cursorPosition() );
599  c.setColumn( doc()->lineLength( c.line() ) );
600  updateCursor( c );
601 
602  m_stickyColumn = -1;
603  m_viInputModeManager->getViInsertMode()->setCount(getCount());
604  return startInsertMode();
605 }
606 
607 bool KateViNormalMode::commandEnterInsertModeBeforeFirstNonBlankInLine()
608 {
609  Cursor cursor( m_view->cursorPosition() );
610  QRegExp nonSpace( "\\S" );
611  int c = getLine().indexOf( nonSpace );
612  if ( c == -1 ) {
613  c = 0;
614  }
615  cursor.setColumn( c );
616  updateCursor( cursor );
617 
618  m_stickyColumn = -1;
619  m_viInputModeManager->getViInsertMode()->setCount(getCount());
620  return startInsertMode();
621 }
622 
627 bool KateViNormalMode::commandEnterInsertModeLast()
628 {
629  Cursor c = m_view->getViInputModeManager()->getMarkPosition( '^' );
630  if ( c.isValid() ) {
631  updateCursor( c );
632  }
633 
634  m_stickyColumn = -1;
635  return startInsertMode();
636 }
637 
638 bool KateViNormalMode::commandEnterVisualLineMode()
639 {
640  if ( m_viInputModeManager->getCurrentViMode() == VisualLineMode ) {
641  reset();
642  return true;
643  }
644 
645  return startVisualLineMode();
646 }
647 
648 bool KateViNormalMode::commandEnterVisualBlockMode()
649 {
650  if ( m_viInputModeManager->getCurrentViMode() == VisualBlockMode ) {
651  reset();
652  return true;
653  }
654 
655  return startVisualBlockMode();
656 }
657 
658 bool KateViNormalMode::commandReselectVisual()
659 {
660  // start last visual mode and set start = `< and cursor = `>
661  Cursor c1 = m_view->getViInputModeManager()->getMarkPosition( '<' );
662  Cursor c2 = m_view->getViInputModeManager()->getMarkPosition( '>' );
663 
664  // we should either get two valid cursors or two invalid cursors
665  Q_ASSERT( c1.isValid() == c2.isValid() );
666 
667  if ( c1.isValid() && c2.isValid() ) {
668  m_viInputModeManager->getViVisualMode()->setStart( c1 );
669  bool returnValue = false;
670 
671  switch ( m_viInputModeManager->getViVisualMode()->getLastVisualMode() ) {
672  case VisualMode:
673  returnValue = commandEnterVisualMode();
674  break;
675  case VisualLineMode:
676  returnValue = commandEnterVisualLineMode();
677  break;
678  case VisualBlockMode:
679  returnValue = commandEnterVisualBlockMode();
680  break;
681  default:
682  Q_ASSERT( "invalid visual mode" );
683  }
684  m_viInputModeManager->getViVisualMode()->goToPos(c2);
685  return returnValue;
686  } else {
687  error("No previous visual selection");
688  }
689 
690  return false;
691 }
692 
693 bool KateViNormalMode::commandEnterVisualMode()
694 {
695  if ( m_viInputModeManager->getCurrentViMode() == VisualMode ) {
696  reset();
697  return true;
698  }
699 
700  return startVisualMode();
701 }
702 
703 bool KateViNormalMode::commandToOtherEnd()
704 {
705  if ( m_viInputModeManager->getCurrentViMode() == VisualMode
706  || m_viInputModeManager->getCurrentViMode() == VisualLineMode
707  || m_viInputModeManager->getCurrentViMode() == VisualBlockMode ) {
708  m_viInputModeManager->getViVisualMode()->switchStartEnd();
709  return true;
710  }
711 
712  return false;
713 }
714 
715 bool KateViNormalMode::commandEnterReplaceMode()
716 {
717  return startReplaceMode();
718 }
719 
720 bool KateViNormalMode::commandDeleteLine()
721 {
722  Cursor c( m_view->cursorPosition() );
723 
724  KateViRange r;
725 
726  r.startLine = c.line();
727  r.endLine = c.line()+getCount()-1;
728 
729  int column = c.column();
730 
731  bool ret = deleteRange( r, LineWise );
732 
733  c = m_view->cursorPosition();
734  if ( column > doc()->lineLength( c.line() )-1 ) {
735  column = doc()->lineLength( c.line() )-1;
736  }
737  if ( column < 0 ) {
738  column = 0;
739  }
740 
741  if ( c.line() > doc()->lines()-1 ) {
742  c.setLine( doc()->lines()-1 );
743  }
744 
745  c.setColumn( column );
746  m_stickyColumn = -1;
747  updateCursor( c );
748 
749  m_deleteCommand = true;
750  return ret;
751 }
752 
753 bool KateViNormalMode::commandDelete()
754 {
755  m_deleteCommand = true;
756  return deleteRange( m_commandRange, getOperationMode() );
757 }
758 
759 bool KateViNormalMode::commandDeleteToEOL()
760 {
761  Cursor c(m_view->cursorPosition());
762  OperationMode m = CharWise;
763 
764  m_commandRange.endColumn = KateVi::EOL;
765  switch (m_viInputModeManager->getCurrentViMode()) {
766  case NormalMode:
767  m_commandRange.startLine = c.line();
768  m_commandRange.startColumn = c.column();
769  m_commandRange.endLine = c.line() + getCount() - 1;
770  break;
771  case VisualMode:
772  case VisualLineMode:
773  m = LineWise;
774  break;
775  case VisualBlockMode:
776  m_commandRange.normalize();
777  m = Block;
778  break;
779  default:
780  /* InsertMode and ReplaceMode will never call this method. */
781  Q_ASSERT(false);
782  }
783 
784  bool r = deleteRange(m_commandRange, m);
785 
786  switch (m) {
787  case CharWise:
788  c.setColumn(doc()->lineLength(c.line()) - 1);
789  break;
790  case LineWise:
791  c.setLine(m_commandRange.startLine);
792  c.setColumn(0); // FIXME: should be first non-blank
793  break;
794  case Block:
795  c.setLine(m_commandRange.startLine);
796  c.setColumn(m_commandRange.startColumn - 1);
797  break;
798  }
799 
800  // make sure cursor position is valid after deletion
801  if (c.line() < 0) {
802  c.setLine(0);
803  }
804  if (c.line() > doc()->lastLine()) {
805  c.setLine(doc()->lastLine());
806  }
807  if (c.column() > doc()->lineLength(c.line()) - 1) {
808  c.setColumn(doc()->lineLength(c.line()) - 1);
809  }
810  if (c.column() < 0) {
811  c.setColumn(0);
812  }
813 
814  updateCursor(c);
815 
816  m_deleteCommand = true;
817  return r;
818 }
819 
820 bool KateViNormalMode::commandMakeLowercase()
821 {
822  Cursor c = m_view->cursorPosition();
823 
824  OperationMode m = getOperationMode();
825  QString text = getRange( m_commandRange, m );
826  if (m == LineWise)
827  text = text.left(text.size() - 1); // don't need '\n' at the end;
828  QString lowerCase = text.toLower();
829 
830  m_commandRange.normalize();
831  Cursor start( m_commandRange.startLine, m_commandRange.startColumn );
832  Cursor end( m_commandRange.endLine, m_commandRange.endColumn );
833  Range range( start, end );
834 
835  doc()->replaceText( range, lowerCase, m == Block );
836 
837  if (m_viInputModeManager->getCurrentViMode() == NormalMode)
838  updateCursor( start );
839  else
840  updateCursor(c);
841 
842  return true;
843 }
844 
845 bool KateViNormalMode::commandMakeLowercaseLine()
846 {
847  Cursor c( m_view->cursorPosition() );
848 
849  if (doc()->lineLength(c.line()) == 0)
850  {
851  // Nothing to do.
852  return true;
853  }
854 
855  m_commandRange.startLine = c.line();
856  m_commandRange.endLine = c.line() + getCount() - 1;
857  m_commandRange.startColumn = 0;
858  m_commandRange.endColumn = doc()->lineLength( c.line() )-1;
859 
860  return commandMakeLowercase();
861 }
862 
863 bool KateViNormalMode::commandMakeUppercase()
864 {
865  kDebug(13070) << "Heere!";
866  if (!m_commandRange.valid)
867  {
868  kDebug(13070) << "Here2";
869  return false;
870  }
871  Cursor c = m_view->cursorPosition();
872  OperationMode m = getOperationMode();
873  QString text = getRange( m_commandRange, m );
874  if (m == LineWise)
875  text = text.left(text.size() - 1); // don't need '\n' at the end;
876  QString upperCase = text.toUpper();
877 
878  m_commandRange.normalize();
879  Cursor start( m_commandRange.startLine, m_commandRange.startColumn );
880  Cursor end( m_commandRange.endLine, m_commandRange.endColumn );
881  Range range( start, end );
882 
883  doc()->replaceText( range, upperCase, m == Block );
884  if (m_viInputModeManager->getCurrentViMode() == NormalMode)
885  updateCursor( start );
886  else
887  updateCursor(c);
888 
889  return true;
890 }
891 
892 bool KateViNormalMode::commandMakeUppercaseLine()
893 {
894  Cursor c( m_view->cursorPosition() );
895 
896  if (doc()->lineLength(c.line()) == 0)
897  {
898  // Nothing to do.
899  return true;
900  }
901 
902  m_commandRange.startLine = c.line();
903  m_commandRange.endLine = c.line() + getCount() - 1;
904  m_commandRange.startColumn = 0;
905  m_commandRange.endColumn = doc()->lineLength( c.line() )-1;
906 
907  return commandMakeUppercase();
908 }
909 
910 bool KateViNormalMode::commandChangeCase()
911 {
912  switchView();
913  QString text;
914  Range range;
915  Cursor c( m_view->cursorPosition() );
916 
917  // in visual mode, the range is from start position to end position...
918  if ( m_viInputModeManager->getCurrentViMode() == VisualMode
919  || m_viInputModeManager->getCurrentViMode() == VisualBlockMode ) {
920  Cursor c2 = m_viInputModeManager->getViVisualMode()->getStart();
921 
922  if ( c2 > c ) {
923  c2.setColumn( c2.column()+1 );
924  } else {
925  c.setColumn( c.column()+1 );
926  }
927 
928  range.setRange( c, c2 );
929  // ... in visual line mode, the range is from column 0 on the first line to
930  // the line length of the last line...
931  } else if ( m_viInputModeManager->getCurrentViMode() == VisualLineMode ) {
932  Cursor c2 = m_viInputModeManager->getViVisualMode()->getStart();
933 
934  if ( c2 > c ) {
935  c2.setColumn( doc()->lineLength( c2.line() ) );
936  c.setColumn( 0 );
937  } else {
938  c.setColumn( doc()->lineLength( c.line() ) );
939  c2.setColumn( 0 );
940  }
941 
942  range.setRange( c, c2 );
943  // ... and in normal mode the range is from the current position to the
944  // current position + count
945  } else {
946  Cursor c2 = c;
947  c2.setColumn( c.column()+getCount() );
948 
949  if ( c2.column() > doc()->lineLength( c.line() ) ) {
950  c2.setColumn( doc()->lineLength( c.line() ) );
951  }
952 
953  range.setRange( c, c2 );
954  }
955 
956  bool block = m_viInputModeManager->getCurrentViMode() == VisualBlockMode;
957 
958  // get the text the command should operate on
959  text = doc()->text ( range, block );
960 
961  // for every character, switch its case
962  for ( int i = 0; i < text.length(); i++ ) {
963  if ( text.at(i).isUpper() ) {
964  text[i] = text.at(i).toLower();
965  } else if ( text.at(i).isLower() ) {
966  text[i] = text.at(i).toUpper();
967  }
968  }
969 
970  // replace the old text with the modified text
971  doc()->replaceText( range, text, block );
972 
973  // in normal mode, move the cursor to the right, in visual mode move the
974  // cursor to the start of the selection
975  if ( m_viInputModeManager->getCurrentViMode() == NormalMode ) {
976  updateCursor( range.end() );
977  } else {
978  updateCursor( range.start() );
979  }
980 
981  return true;
982 }
983 
984 bool KateViNormalMode::commandChangeCaseRange()
985 {
986  OperationMode m = getOperationMode();
987  QString changedCase = getRange( m_commandRange, m );
988  if (m == LineWise)
989  changedCase = changedCase.left(changedCase.size() - 1); // don't need '\n' at the end;
990  Range range = Range(m_commandRange.startLine, m_commandRange.startColumn, m_commandRange.endLine, m_commandRange.endColumn);
991  // get the text the command should operate on
992  // for every character, switch its case
993  for ( int i = 0; i < changedCase.length(); i++ ) {
994  if ( changedCase.at(i).isUpper() ) {
995  changedCase[i] = changedCase.at(i).toLower();
996  } else if ( changedCase.at(i).isLower() ) {
997  changedCase[i] = changedCase.at(i).toUpper();
998  }
999  }
1000  doc()->replaceText( range, changedCase, m == Block );
1001  return true;
1002 }
1003 
1004 bool KateViNormalMode::commandOpenNewLineUnder()
1005 {
1006  doc()->setUndoMergeAllEdits(true);
1007 
1008  Cursor c( m_view->cursorPosition() );
1009 
1010  c.setColumn( doc()->lineLength( c.line() ) );
1011  updateCursor( c );
1012 
1013  doc()->newLine( m_view );
1014 
1015  m_stickyColumn = -1;
1016  startInsertMode();
1017  m_viInputModeManager->getViInsertMode()->setCount(getCount());
1018  m_viInputModeManager->getViInsertMode()->setCountedRepeatsBeginOnNewLine(true);
1019  m_viewInternal->repaint ();
1020 
1021  return true;
1022 }
1023 
1024 bool KateViNormalMode::commandOpenNewLineOver()
1025 {
1026  doc()->setUndoMergeAllEdits(true);
1027 
1028  Cursor c( m_view->cursorPosition() );
1029 
1030  if ( c.line() == 0 ) {
1031  doc()->insertLine(0, QString());
1032  c.setColumn( 0 );
1033  c.setLine( 0 );
1034  updateCursor( c );
1035  } else {
1036  c.setLine( c.line()-1 );
1037  c.setColumn( getLine( c.line() ).length() );
1038  updateCursor( c );
1039  doc()->newLine( m_view );
1040  }
1041 
1042  m_stickyColumn = -1;
1043  startInsertMode();
1044  m_viInputModeManager->getViInsertMode()->setCount(getCount());
1045  m_viInputModeManager->getViInsertMode()->setCountedRepeatsBeginOnNewLine(true);
1046  m_viewInternal->repaint ();
1047 
1048  return true;
1049 }
1050 
1051 bool KateViNormalMode::commandJoinLines()
1052 {
1053  Cursor c( m_view->cursorPosition() );
1054 
1055  unsigned int from = c.line();
1056  unsigned int to = c.line() + ((getCount() == 1) ? 1 : getCount() - 1);
1057 
1058  // if we were given a range of lines, this information overrides the previous
1059  if ( m_commandRange.startLine != -1 && m_commandRange.endLine != -1 ) {
1060  m_commandRange.normalize();
1061  c.setLine ( m_commandRange.startLine );
1062  from = m_commandRange.startLine;
1063  to = m_commandRange.endLine;
1064  }
1065 
1066  if (to >= (unsigned int)doc()->lines())
1067  {
1068  return false;
1069  }
1070 
1071  bool nonEmptyLineFound = false;
1072  for (unsigned int lineNum = from; lineNum <= to; lineNum++)
1073  {
1074  if (!doc()->line(lineNum).isEmpty())
1075  {
1076  nonEmptyLineFound = true;
1077  }
1078  }
1079 
1080  const int firstNonWhitespaceOnLastLine = doc()->kateTextLine(to)->firstChar();
1081  QString leftTrimmedLastLine;
1082  if (firstNonWhitespaceOnLastLine != -1)
1083  {
1084  leftTrimmedLastLine = doc()->line(to).mid(firstNonWhitespaceOnLastLine);
1085  }
1086 
1087  joinLines( from, to );
1088 
1089  if (nonEmptyLineFound && leftTrimmedLastLine.isEmpty())
1090  {
1091  // joinLines won't have added a trailing " ", whereas Vim does - follow suit.
1092  doc()->insertText(Cursor(from, doc()->lineLength(from)), " ");
1093  }
1094 
1095  // Position cursor just before first non-whitesspace character of what was the last line joined.
1096  c.setColumn(doc()->lineLength(from) - leftTrimmedLastLine.length() - 1);
1097  if (c.column() >= 0) {
1098  updateCursor( c );
1099  }
1100 
1101  m_deleteCommand = true;
1102  return true;
1103 }
1104 
1105 bool KateViNormalMode::commandChange()
1106 {
1107  Cursor c( m_view->cursorPosition() );
1108 
1109  OperationMode m = getOperationMode();
1110 
1111  doc()->setUndoMergeAllEdits(true);
1112 
1113  commandDelete();
1114 
1115  // if we deleted several lines, insert an empty line and put the cursor there
1116  if ( m == LineWise ) {
1117  doc()->insertLine( m_commandRange.startLine, QString() );
1118  c.setLine( m_commandRange.startLine );
1119  c.setColumn(0);
1120  }
1121 
1122  if ( m == LineWise ) {
1123  updateCursor( c );
1124  }
1125 
1126  // block substitute can be simulated by first deleting the text (done above) and then starting
1127  // block prepend
1128  if ( m == Block ) {
1129  return commandPrependToBlock();
1130  }
1131 
1132  setCount(0); // The count was for the motion, not the insertion.
1133  commandEnterInsertMode();
1134 
1135  // correct indentation level
1136  if ( m == LineWise ) {
1137  m_view->align();
1138  }
1139 
1140  m_deleteCommand = true;
1141  return true;
1142 }
1143 
1144 bool KateViNormalMode::commandChangeToEOL()
1145 {
1146  commandDeleteToEOL();
1147 
1148  if ( getOperationMode() == Block ) {
1149  return commandPrependToBlock();
1150  }
1151 
1152  m_deleteCommand = true;
1153  return commandEnterInsertModeAppend();
1154 }
1155 
1156 bool KateViNormalMode::commandChangeLine()
1157 {
1158  m_deleteCommand = true;
1159  Cursor c( m_view->cursorPosition() );
1160  c.setColumn( 0 );
1161  updateCursor( c );
1162 
1163  doc()->setUndoMergeAllEdits(true);
1164 
1165  // if count >= 2 start by deleting the whole lines
1166  if ( getCount() >= 2 ) {
1167  KateViRange r( c.line(), 0, c.line()+getCount()-2, 0, ViMotion::InclusiveMotion );
1168  deleteRange( r );
1169  }
1170 
1171  // ... then delete the _contents_ of the last line, but keep the line
1172  KateViRange r( c.line(), c.column(), c.line(), doc()->lineLength( c.line() )-1,
1173  ViMotion::InclusiveMotion );
1174  deleteRange( r, CharWise, true );
1175 
1176  // ... then enter insert mode
1177  if ( getOperationMode() == Block ) {
1178  return commandPrependToBlock();
1179  }
1180  commandEnterInsertModeAppend();
1181 
1182  // correct indentation level
1183  m_view->align();
1184 
1185  return true;
1186 }
1187 
1188 bool KateViNormalMode::commandSubstituteChar()
1189 {
1190  if ( commandDeleteChar() ) {
1191  return commandEnterInsertMode();
1192  }
1193 
1194  m_deleteCommand = true;
1195  return false;
1196 }
1197 
1198 bool KateViNormalMode::commandSubstituteLine()
1199 {
1200  m_deleteCommand = true;
1201  return commandChangeLine();
1202 }
1203 
1204 bool KateViNormalMode::commandYank()
1205 {
1206  Cursor c( m_view->cursorPosition() );
1207 
1208  bool r = false;
1209  QString yankedText;
1210 
1211  OperationMode m = getOperationMode();
1212  yankedText = getRange( m_commandRange, m );
1213 
1214  highlightYank(m_commandRange);
1215 
1216  QChar chosen_register = getChosenRegister( '0' );
1217  fillRegister(chosen_register, yankedText, m );
1218  yankToClipBoard(chosen_register, yankedText);
1219 
1220  return r;
1221 }
1222 
1223 bool KateViNormalMode::commandYankLine()
1224 {
1225  Cursor c( m_view->cursorPosition() );
1226  QString lines;
1227  int linenum = c.line();
1228 
1229  for ( unsigned int i = 0; i < getCount(); i++ ) {
1230  lines.append( getLine( linenum + i ) + '\n' );
1231  }
1232 
1233  KateViRange yankRange(linenum, 0, linenum + getCount() - 1, getLine(linenum + getCount() - 1).length(), ViMotion::InclusiveMotion);
1234  highlightYank(yankRange);
1235 
1236  QChar chosen_register = getChosenRegister( '0' );
1237  fillRegister(chosen_register, lines, LineWise );
1238  yankToClipBoard(chosen_register, lines);
1239 
1240  return true;
1241 }
1242 
1243 bool KateViNormalMode::commandYankToEOL()
1244 {
1245  Cursor c( m_view->cursorPosition() );
1246 
1247  bool r = false;
1248  QString yankedText;
1249 
1250  m_commandRange.endLine = c.line()+getCount()-1;
1251  m_commandRange.endColumn = doc()->lineLength( m_commandRange.endLine )-1;
1252 
1253  OperationMode m = CharWise;
1254 
1255  if ( m_viInputModeManager->getCurrentViMode() == VisualMode
1256  || m_viInputModeManager->getCurrentViMode() == VisualLineMode ) {
1257  m = LineWise;
1258  KateViVisualMode* visualmode = static_cast<KateViVisualMode*>(this);
1259  visualmode->setStart( Cursor(visualmode->getStart().line(),0) );
1260  } else if (m_viInputModeManager->getCurrentViMode() == VisualBlockMode ) {
1261  m = Block;;
1262  }
1263 
1264  if ( m_viInputModeManager->getCurrentViMode() == NormalMode ) {
1265  m_commandRange.startLine = c.line();
1266  m_commandRange.startColumn = c.column();
1267  }
1268 
1269  yankedText = getRange( m_commandRange, m );
1270 
1271  highlightYank(m_commandRange);
1272 
1273  QChar chosen_register = getChosenRegister( '0' );
1274  fillRegister(chosen_register, yankedText, m );
1275  yankToClipBoard(chosen_register, yankedText);
1276 
1277  return r;
1278 }
1279 
1280 // Insert the text in the given register after the cursor position.
1281 // This is the non-g version of paste, so the cursor will usually
1282 // end up on the last character of the pasted text, unless the text
1283 // was multi-line or linewise in which case it will end up
1284 // on the *first* character of the pasted text(!)
1285 // If linewise, will paste after the current line.
1286 bool KateViNormalMode::commandPaste()
1287 {
1288  return paste(AfterCurrentPosition, false, false);
1289 }
1290 
1291 // As with commandPaste, except that the text is pasted *at* the cursor position
1292 bool KateViNormalMode::commandPasteBefore()
1293 {
1294  return paste(AtCurrentPosition, false, false);
1295 }
1296 
1297 // As with commandPaste, except that the cursor will generally be placed *after* the
1298 // last pasted character (assuming the last pasted character is not at the end of the line).
1299 // If linewise, cursor will be at the beginning of the line *after* the last line of pasted text,
1300 // unless that line is the last line of the document; then it will be placed at the beginning of the
1301 // last line pasted.
1302 bool KateViNormalMode::commandgPaste()
1303 {
1304  return paste(AfterCurrentPosition, true, false);
1305 }
1306 
1307 // As with commandgPaste, except that it pastes *at* the current cursor position or, if linewise,
1308 // at the current line.
1309 bool KateViNormalMode::commandgPasteBefore()
1310 {
1311  return paste(AtCurrentPosition, true, false);
1312 }
1313 
1314 bool KateViNormalMode::commandIndentedPaste()
1315 {
1316  return paste(AfterCurrentPosition, false, true);
1317 }
1318 
1319 bool KateViNormalMode::commandIndentedPasteBefore()
1320 {
1321  return paste(AtCurrentPosition, false, true);
1322 }
1323 
1324 bool KateViNormalMode::commandDeleteChar()
1325 {
1326  Cursor c( m_view->cursorPosition() );
1327  KateViRange r( c.line(), c.column(), c.line(), c.column()+getCount(), ViMotion::ExclusiveMotion );
1328 
1329  if ( m_commandRange.startLine != -1 && m_commandRange.startColumn != -1 ) {
1330  r = m_commandRange;
1331  } else {
1332  if ( r.endColumn > doc()->lineLength( r.startLine ) ) {
1333  r.endColumn = doc()->lineLength( r.startLine );
1334  }
1335  }
1336 
1337  // should delete entire lines if in visual line mode and selection in visual block mode
1338  OperationMode m = CharWise;
1339  if ( m_viInputModeManager->getCurrentViMode() == VisualLineMode ) {
1340  m = LineWise;
1341  } else if ( m_viInputModeManager->getCurrentViMode() == VisualBlockMode ) {
1342  m = Block;
1343  }
1344 
1345  m_deleteCommand = true;
1346  return deleteRange( r, m );
1347 }
1348 
1349 bool KateViNormalMode::commandDeleteCharBackward()
1350 {
1351  Cursor c( m_view->cursorPosition() );
1352 
1353  KateViRange r( c.line(), c.column()-getCount(), c.line(), c.column(), ViMotion::ExclusiveMotion );
1354 
1355  if ( m_commandRange.startLine != -1 && m_commandRange.startColumn != -1 ) {
1356  r = m_commandRange;
1357  } else {
1358  if ( r.startColumn < 0 ) {
1359  r.startColumn = 0;
1360  }
1361  }
1362 
1363  // should delete entire lines if in visual line mode and selection in visual block mode
1364  OperationMode m = CharWise;
1365  if ( m_viInputModeManager->getCurrentViMode() == VisualLineMode ) {
1366  m = LineWise;
1367  } else if ( m_viInputModeManager->getCurrentViMode() == VisualBlockMode ) {
1368  m = Block;
1369  }
1370 
1371  m_deleteCommand = true;
1372  return deleteRange( r, m );
1373 }
1374 
1375 bool KateViNormalMode::commandReplaceCharacter()
1376 {
1377 
1378 bool r;
1379 if ( m_viInputModeManager->getCurrentViMode() == VisualMode
1380  || m_viInputModeManager->getCurrentViMode() == VisualLineMode
1381  || m_viInputModeManager->getCurrentViMode() == VisualBlockMode ) {
1382 
1383  OperationMode m = getOperationMode();
1384  QString text = getRange( m_commandRange, m );
1385 
1386  if (m == LineWise)
1387  text = text.left(text.size() - 1); // don't need '\n' at the end;
1388 
1389  text.replace( QRegExp( "[^\n]" ), m_keys.right( 1 ) );
1390 
1391  m_commandRange.normalize();
1392  Cursor start( m_commandRange.startLine, m_commandRange.startColumn );
1393  Cursor end( m_commandRange.endLine, m_commandRange.endColumn );
1394  Range range( start, end );
1395 
1396  r = doc()->replaceText( range, text, m == Block );
1397 
1398 } else {
1399  Cursor c1( m_view->cursorPosition() );
1400  Cursor c2( m_view->cursorPosition() );
1401 
1402  c2.setColumn( c2.column() + getCount() );
1403 
1404  if (c2.column() > doc()->lineLength(m_view->cursorPosition().line()))
1405  {
1406  return false;
1407  }
1408 
1409  r = doc()->replaceText( Range( c1, c2 ), m_keys.right( 1 ).repeated(getCount()) );
1410  updateCursor( c1 );
1411 
1412 }
1413  return r;
1414 }
1415 
1416 bool KateViNormalMode::commandSwitchToCmdLine()
1417 {
1418  Cursor c( m_view->cursorPosition() );
1419 
1420 
1421  QString initialText;
1422  if ( m_viInputModeManager->getCurrentViMode() == VisualMode
1423  || m_viInputModeManager->getCurrentViMode() == VisualLineMode
1424  || m_viInputModeManager->getCurrentViMode() == VisualBlockMode ) {
1425  // if in visual mode, make command range == visual selection
1426  m_viInputModeManager->getViVisualMode()->saveRangeMarks();
1427  initialText = "'<,'>";
1428  }
1429  else if ( getCount() != 1 ) {
1430  // if a count is given, the range [current line] to [current line] +
1431  // count should be prepended to the command line
1432  initialText = ".,.+" +QString::number( getCount()-1 );
1433  }
1434  if (!KateViewConfig::global()->viInputModeEmulateCommandBar())
1435  {
1436  m_view->switchToCmdLine();
1437  m_view->cmdLineBar()->setText( initialText, false );
1438  }
1439  else
1440  {
1441  m_view->showViModeEmulatedCommandBar();
1442  m_view->viModeEmulatedCommandBar()->init( KateViEmulatedCommandBar::Command, initialText );
1443  }
1444 
1445  m_commandShouldKeepSelection = true;
1446 
1447  return true;
1448 }
1449 
1450 bool KateViNormalMode::commandSearchBackward()
1451 {
1452  if (!KateViewConfig::global()->viInputModeEmulateCommandBar())
1453  {
1454  m_viInputModeManager->setLastSearchBackwards(true);
1455  m_view->find();
1456  }
1457  else
1458  {
1459  m_view->showViModeEmulatedCommandBar();
1460  m_view->viModeEmulatedCommandBar()->init(KateViEmulatedCommandBar::SearchBackward);
1461  }
1462  return true;
1463 }
1464 
1465 bool KateViNormalMode::commandSearchForward()
1466 {
1467  if (!KateViewConfig::global()->viInputModeEmulateCommandBar())
1468  {
1469  m_view->find();
1470  }
1471  else
1472  {
1473  m_view->showViModeEmulatedCommandBar();
1474  m_view->viModeEmulatedCommandBar()->init(KateViEmulatedCommandBar::SearchForward);
1475  }
1476  m_viInputModeManager->setLastSearchBackwards( false );
1477  return true;
1478 }
1479 
1480 bool KateViNormalMode::commandUndo()
1481 {
1482  doc()->undo();
1483  return true;
1484 }
1485 
1486 bool KateViNormalMode::commandRedo()
1487 {
1488  doc()->redo();
1489  return true;
1490 }
1491 
1492 bool KateViNormalMode::commandSetMark()
1493 {
1494  Cursor c( m_view->cursorPosition() );
1495 
1496  m_view->getViInputModeManager()->addMark( doc(), m_keys.at( m_keys.size()-1 ), c );
1497  kDebug( 13070 ) << "set mark at (" << c.line() << "," << c.column() << ")";
1498 
1499  return true;
1500 }
1501 
1502 bool KateViNormalMode::commandIndentLine()
1503 {
1504  Cursor c( m_view->cursorPosition() );
1505 
1506  for ( unsigned int i = 0; i < getCount(); i++ ) {
1507  doc()->indent( KTextEditor::Range( c.line()+i, 0, c.line()+i, 0), 1 );
1508  }
1509 
1510  return true;
1511 }
1512 
1513 bool KateViNormalMode::commandUnindentLine()
1514 {
1515  Cursor c( m_view->cursorPosition() );
1516 
1517  for ( unsigned int i = 0; i < getCount(); i++ ) {
1518  doc()->indent( KTextEditor::Range( c.line()+i, 0, c.line()+i, 0), -1 );
1519  }
1520 
1521  return true;
1522 }
1523 
1524 bool KateViNormalMode::commandIndentLines()
1525 {
1526  Cursor c( m_view->cursorPosition() );
1527 
1528  m_commandRange.normalize();
1529 
1530  int line1 = m_commandRange.startLine;
1531  int line2 = m_commandRange.endLine;
1532  int col = getLine( line2 ).length();
1533 
1534  doc()->indent( KTextEditor::Range( line1, 0, line2, col ), getCount() );
1535 
1536  return true;
1537 }
1538 
1539 bool KateViNormalMode::commandUnindentLines()
1540 {
1541  Cursor c( m_view->cursorPosition() );
1542 
1543  m_commandRange.normalize();
1544 
1545  int line1 = m_commandRange.startLine;
1546  int line2 = m_commandRange.endLine;
1547 
1548  doc()->indent( KTextEditor::Range( line1, 0, line2, doc()->lineLength( line2 ) ), -getCount() );
1549 
1550  return true;
1551 }
1552 
1553 bool KateViNormalMode::commandScrollPageDown()
1554 {
1555  if ( getCount() < m_scroll_count_limit ) {
1556 
1557  for(uint i = 0; i < getCount(); i++)
1558  m_view->pageDown();
1559  }
1560  return true;
1561 }
1562 
1563 bool KateViNormalMode::commandScrollPageUp()
1564 {
1565  if ( getCount() < m_scroll_count_limit ) {
1566  for(uint i=0; i < getCount(); i++)
1567  m_view->pageUp();
1568  }
1569  return true;
1570 
1571 }
1572 
1573 bool KateViNormalMode::commandScrollHalfPageUp()
1574 {
1575  if ( getCount() < m_scroll_count_limit ) {
1576 
1577  for(uint i=0; i < getCount(); i++)
1578  m_viewInternal->pageUp(false, true);
1579  }
1580  return true;
1581 }
1582 
1583 bool KateViNormalMode::commandScrollHalfPageDown()
1584 {
1585  if ( getCount() < m_scroll_count_limit ) {
1586  for(uint i=0; i < getCount(); i++)
1587  m_viewInternal->pageDown(false, true);
1588  }
1589  return true;
1590 }
1591 
1592 bool KateViNormalMode::commandCentreViewOnCursor()
1593 {
1594  Cursor c( m_view->cursorPosition() );
1595  int linesToScroll = (m_viewInternal->endLine()-linesDisplayed()/2)-c.line();
1596 
1597  scrollViewLines( -linesToScroll );
1598 
1599  return true;
1600 }
1601 
1602 bool KateViNormalMode::commandAbort()
1603 {
1604  m_pendingResetIsDueToExit = true;
1605  reset();
1606  return true;
1607 }
1608 
1609 bool KateViNormalMode::commandPrintCharacterCode()
1610 {
1611  QChar ch = getCharUnderCursor();
1612 
1613  if ( ch == QChar::Null ) {
1614  message( QString( "NUL" ) );
1615  } else {
1616 
1617  int code = ch.unicode();
1618 
1619  QString dec = QString::number( code );
1620  QString hex = QString::number( code, 16 );
1621  QString oct = QString::number( code, 8 );
1622  if ( oct.length() < 3 ) { oct.prepend( '0' ); }
1623  if ( code > 0x80 && code < 0x1000 ) { hex.prepend( ( code < 0x100 ? "00" : "0" ) ); }
1624  message( i18n("'%1' %2, Hex %3, Octal %4", ch, dec, hex, oct ) );
1625  }
1626 
1627  return true;
1628 }
1629 
1630 bool KateViNormalMode::commandRepeatLastChange()
1631 {
1632  const int repeatCount = getCount();
1633  resetParser();
1634  if (repeatCount > 1)
1635  {
1636  m_oneTimeCountOverride = repeatCount;
1637  }
1638  doc()->editStart();
1639  m_viInputModeManager->repeatLastChange();
1640  doc()->editEnd();
1641 
1642  return true;
1643 }
1644 
1645 bool KateViNormalMode::commandAlignLine()
1646 {
1647  const int line = m_view->cursorPosition().line();
1648  Range alignRange( Cursor(line, 0), Cursor(line, 0) );
1649 
1650  doc()->align( m_view, alignRange );
1651 
1652  return true;
1653 }
1654 
1655 bool KateViNormalMode::commandAlignLines()
1656 {
1657  Cursor c( m_view->cursorPosition() );
1658  m_commandRange.normalize();
1659 
1660  Cursor start(m_commandRange.startLine, 0);
1661  Cursor end(m_commandRange.endLine, 0);
1662 
1663  doc()->align( m_view, Range( start, end ) );
1664 
1665  return true;
1666 }
1667 
1668 bool KateViNormalMode::commandAddToNumber()
1669 {
1670  addToNumberUnderCursor( getCount() );
1671 
1672  return true;
1673 }
1674 
1675 bool KateViNormalMode::commandSubtractFromNumber()
1676 {
1677  addToNumberUnderCursor( -getCount() );
1678 
1679  return true;
1680 }
1681 
1682 bool KateViNormalMode::commandPrependToBlock()
1683 {
1684  Cursor c( m_view->cursorPosition() );
1685 
1686  // move cursor to top left corner of selection
1687  m_commandRange.normalize();
1688  c.setColumn( m_commandRange.startColumn );
1689  c.setLine( m_commandRange.startLine );
1690  updateCursor( c );
1691 
1692  m_stickyColumn = -1;
1693  m_viInputModeManager->getViInsertMode()->setBlockPrependMode( m_commandRange );
1694  return startInsertMode();
1695 }
1696 
1697 bool KateViNormalMode::commandAppendToBlock()
1698 {
1699  Cursor c( m_view->cursorPosition() );
1700 
1701  m_commandRange.normalize();
1702  if ( m_stickyColumn == (unsigned int)KateVi::EOL ) { // append to EOL
1703  // move cursor to end of first line
1704  c.setLine( m_commandRange.startLine );
1705  c.setColumn( doc()->lineLength( c.line() ) );
1706  updateCursor( c );
1707  m_viInputModeManager->getViInsertMode()->setBlockAppendMode( m_commandRange, AppendEOL );
1708  } else {
1709  m_viInputModeManager->getViInsertMode()->setBlockAppendMode( m_commandRange, Append );
1710  // move cursor to top right corner of selection
1711  c.setColumn( m_commandRange.endColumn+1 );
1712  c.setLine( m_commandRange.startLine );
1713  updateCursor( c );
1714  }
1715 
1716  m_stickyColumn = -1;
1717 
1718  return startInsertMode();
1719 }
1720 
1721 bool KateViNormalMode::commandGoToNextJump() {
1722  Cursor c = getNextJump(m_view->cursorPosition());
1723  updateCursor(c);
1724 
1725  return true;
1726 }
1727 
1728 bool KateViNormalMode::commandGoToPrevJump() {
1729  Cursor c = getPrevJump(m_view->cursorPosition());
1730  updateCursor(c);
1731 
1732  return true;
1733 }
1734 
1735 bool KateViNormalMode::commandSwitchToLeftView() {
1736  switchView(Left);
1737  return true;
1738 }
1739 
1740 bool KateViNormalMode::commandSwitchToDownView() {
1741  switchView(Down);
1742  return true;
1743 }
1744 
1745 bool KateViNormalMode::commandSwitchToUpView() {
1746  switchView(Up);
1747  return true;
1748 }
1749 
1750 bool KateViNormalMode::commandSwitchToRightView() {
1751  switchView(Right);
1752  return true;
1753 }
1754 
1755 bool KateViNormalMode::commandSwitchToNextView() {
1756  switchView(Next);
1757  return true;
1758 }
1759 
1760 bool KateViNormalMode::commandSplitHoriz() {
1761  m_view->cmdLineBar()->execute("split");
1762  return true;
1763 }
1764 
1765 bool KateViNormalMode::commandSplitVert() {
1766  m_view->cmdLineBar()->execute("vsplit");
1767  return true;
1768 }
1769 
1770 bool KateViNormalMode::commandSwitchToNextTab() {
1771  QString command = "bn";
1772 
1773  if ( m_iscounted )
1774  command = command + " " + QString::number(getCount());
1775 
1776  m_view->cmdLineBar()->execute(command);
1777  return true;
1778 }
1779 
1780 bool KateViNormalMode::commandSwitchToPrevTab() {
1781  QString command = "bp";
1782 
1783  if ( m_iscounted )
1784  command = command + " " + QString::number(getCount());
1785 
1786  m_view->cmdLineBar()->execute(command);
1787  return true;
1788 }
1789 
1790 bool KateViNormalMode::commandFormatLine()
1791 {
1792  Cursor c( m_view->cursorPosition() );
1793 
1794  reformatLines( c.line(), c.line()+getCount()-1 );
1795 
1796  return true;
1797 }
1798 
1799 bool KateViNormalMode::commandFormatLines()
1800 {
1801  reformatLines( m_commandRange.startLine, m_commandRange.endLine );
1802  return true;
1803 }
1804 
1805 bool KateViNormalMode::commandCollapseToplevelNodes()
1806 {
1807 #if 0
1808  //FIXME FOLDING
1809  doc()->foldingTree()->collapseToplevelNodes();
1810 #endif
1811  return true;
1812 }
1813 
1814 bool KateViNormalMode::commandStartRecordingMacro()
1815 {
1816  const QChar reg = m_keys[m_keys.size() - 1];
1817  m_viInputModeManager->startRecordingMacro(reg);
1818  return true;
1819 }
1820 
1821 bool KateViNormalMode::commandReplayMacro()
1822 {
1823  // "@<registername>" will have been added to the log; it needs to be cleared
1824  // *before* we replay the macro keypresses, else it can cause an infinite loop
1825  // if the macro contains a "."
1826  m_viInputModeManager->clearCurrentChangeLog();
1827  const QChar reg = m_keys[m_keys.size() - 1];
1828  const unsigned int count = getCount();
1829  resetParser();
1830  doc()->editBegin();
1831  for ( unsigned int i = 0; i < count; i++ )
1832  {
1833  m_viInputModeManager->replayMacro(reg);
1834  }
1835  doc()->editEnd();
1836  return true;
1837 }
1838 
1839 bool KateViNormalMode::commandCollapseLocal()
1840 {
1841 #if 0
1842  //FIXME FOLDING
1843  Cursor c( m_view->cursorPosition() );
1844  doc()->foldingTree()->collapseOne( c.line(), c.column() );
1845 #endif
1846  return true;
1847 }
1848 
1849 bool KateViNormalMode::commandExpandAll() {
1850 #if 0
1851  //FIXME FOLDING
1852  doc()->foldingTree()->expandAll();
1853 #endif
1854  return true;
1855 }
1856 
1857 bool KateViNormalMode::commandExpandLocal()
1858 {
1859 #if 0
1860  //FIXME FOLDING
1861  Cursor c( m_view->cursorPosition() );
1862  doc()->foldingTree()->expandOne( c.line() + 1, c.column() );
1863 #endif
1864  return true;
1865 }
1866 
1867 bool KateViNormalMode::commandToggleRegionVisibility()
1868 {
1869 #if 0
1870  //FIXME FOLDING
1871  Cursor c( m_view->cursorPosition() );
1872  doc()->foldingTree()->toggleRegionVisibility( c.line() );
1873 #endif
1874  return true;
1875 }
1876 
1877 
1879 // MOTIONS
1881 
1882 KateViRange KateViNormalMode::motionDown()
1883 {
1884  return goLineDown();
1885 }
1886 
1887 KateViRange KateViNormalMode::motionUp()
1888 {
1889  return goLineUp();
1890 }
1891 
1892 KateViRange KateViNormalMode::motionLeft()
1893 {
1894  Cursor cursor ( m_view->cursorPosition() );
1895  m_stickyColumn = -1;
1896  KateViRange r( cursor.line(), cursor.column(), ViMotion::ExclusiveMotion );
1897  r.endColumn -= getCount();
1898 
1899  if ( r.endColumn < 0 ) {
1900  r.endColumn = 0;
1901  }
1902 
1903  return r;
1904 }
1905 
1906 KateViRange KateViNormalMode::motionRight()
1907 {
1908  Cursor cursor ( m_view->cursorPosition() );
1909  m_stickyColumn = -1;
1910  KateViRange r( cursor.line(), cursor.column(), ViMotion::ExclusiveMotion );
1911  r.endColumn += getCount();
1912 
1913  // make sure end position isn't > line length
1914  if ( r.endColumn > doc()->lineLength( r.endLine ) ) {
1915  r.endColumn = doc()->lineLength( r.endLine );
1916  }
1917 
1918  return r;
1919 }
1920 
1921 KateViRange KateViNormalMode::motionPageDown()
1922 {
1923  Cursor c( m_view->cursorPosition() );
1924  int linesToScroll = linesDisplayed();
1925 
1926  KateViRange r( c.line()+linesToScroll, c.column(), ViMotion::InclusiveMotion );
1927 
1928  if ( r.endLine >= doc()->lines() ) {
1929  r.endLine = doc()->lines()-1;
1930  }
1931 
1932  return r;
1933 }
1934 
1935 KateViRange KateViNormalMode::motionPageUp()
1936 {
1937  Cursor c( m_view->cursorPosition() );
1938  int linesToScroll = linesDisplayed();
1939 
1940  KateViRange r( c.line()-linesToScroll, c.column(), ViMotion::InclusiveMotion );
1941 
1942  if ( r.endLine < 0 ) {
1943  r.endLine = 0;
1944  }
1945 
1946  return r;
1947 }
1948 
1949 KateViRange KateViNormalMode::motionDownToFirstNonBlank()
1950 {
1951  Cursor c( m_view->cursorPosition() );
1952  KateViRange r = goLineDown();
1953 
1954  r.endColumn = getLine( r.endLine ).indexOf( QRegExp( "\\S" ) );
1955 
1956  if ( r.endColumn < 0 ) {
1957  r.endColumn = 0;
1958  }
1959 
1960  return r;
1961 }
1962 
1963 KateViRange KateViNormalMode::motionUpToFirstNonBlank()
1964 {
1965  Cursor c( m_view->cursorPosition() );
1966  KateViRange r = goLineUp();
1967 
1968  r.endColumn = getLine( r.endLine ).indexOf( QRegExp( "\\S" ) );
1969 
1970  if ( r.endColumn < 0 ) {
1971  r.endColumn = 0;
1972  }
1973 
1974  return r;
1975 }
1976 
1977 KateViRange KateViNormalMode::motionWordForward()
1978 {
1979  Cursor c( m_view->cursorPosition() );
1980  KateViRange r( c.line(), c.column(), ViMotion::ExclusiveMotion );
1981 
1982  m_stickyColumn = -1;
1983 
1984  // Special case: If we're already on the very last character in the document, the motion should be
1985  // inclusive so the last character gets included
1986  if ( c.line() == doc()->lines()-1 && c.column() == doc()->lineLength( c.line() )-1 ) {
1987  r.motionType = ViMotion::InclusiveMotion;
1988  } else {
1989  for ( unsigned int i = 0; i < getCount(); i++ ) {
1990  c = findNextWordStart( c.line(), c.column() );
1991 
1992  // stop when at the last char in the document
1993  if (!c.isValid()) {
1994  c = doc()->documentEnd();
1995  // if we still haven't "used up the count", make the motion inclusive, so that the last char
1996  // is included
1997  if ( i < getCount() ) {
1998  r.motionType = ViMotion::InclusiveMotion;
1999  }
2000  break;
2001  }
2002  }
2003  }
2004 
2005  r.endColumn = c.column();
2006  r.endLine = c.line();
2007 
2008  return r;
2009 }
2010 
2011 KateViRange KateViNormalMode::motionWordBackward()
2012 {
2013  Cursor c( m_view->cursorPosition() );
2014  KateViRange r( c.line(), c.column(), ViMotion::ExclusiveMotion );
2015 
2016  m_stickyColumn = -1;
2017 
2018  for ( unsigned int i = 0; i < getCount(); i++ ) {
2019  c = findPrevWordStart( c.line(), c.column() );
2020 
2021  if (!c.isValid())
2022  {
2023  c = Cursor(0, 0);
2024  break;
2025  }
2026  }
2027 
2028  r.endColumn = c.column();
2029  r.endLine = c.line();
2030 
2031  return r;
2032 }
2033 
2034 KateViRange KateViNormalMode::motionWORDForward()
2035 {
2036  Cursor c( m_view->cursorPosition() );
2037  KateViRange r( c.line(), c.column(), ViMotion::ExclusiveMotion );
2038 
2039  m_stickyColumn = -1;
2040 
2041  for ( unsigned int i = 0; i < getCount(); i++ ) {
2042  c = findNextWORDStart( c.line(), c.column() );
2043 
2044  // stop when at the last char in the document
2045  if ( c.line() == doc()->lines()-1 && c.column() == doc()->lineLength( c.line() )-1 ) {
2046  break;
2047  }
2048  }
2049 
2050  r.endColumn = c.column();
2051  r.endLine = c.line();
2052 
2053  return r;
2054 }
2055 
2056 KateViRange KateViNormalMode::motionWORDBackward()
2057 {
2058  Cursor c( m_view->cursorPosition() );
2059  KateViRange r( c.line(), c.column(), ViMotion::ExclusiveMotion );
2060 
2061  m_stickyColumn = -1;
2062 
2063  for ( unsigned int i = 0; i < getCount(); i++ ) {
2064  c = findPrevWORDStart( c.line(), c.column() );
2065 
2066  if (!c.isValid())
2067  {
2068  c = Cursor(0, 0);
2069  }
2070  }
2071 
2072  r.endColumn = c.column();
2073  r.endLine = c.line();
2074 
2075  return r;
2076 }
2077 
2078 KateViRange KateViNormalMode::motionToEndOfWord()
2079 {
2080  Cursor c( m_view->cursorPosition() );
2081  KateViRange r( c.line(), c.column(), ViMotion::InclusiveMotion );
2082 
2083  m_stickyColumn = -1;
2084 
2085  for ( unsigned int i = 0; i < getCount(); i++ ) {
2086  c = findWordEnd( c.line(), c.column() );
2087  }
2088 
2089  r.endColumn = c.column();
2090  r.endLine = c.line();
2091 
2092  return r;
2093 }
2094 
2095 KateViRange KateViNormalMode::motionToEndOfWORD()
2096 {
2097  Cursor c( m_view->cursorPosition() );
2098  KateViRange r( c.line(), c.column(), ViMotion::InclusiveMotion );
2099 
2100  m_stickyColumn = -1;
2101 
2102  for ( unsigned int i = 0; i < getCount(); i++ ) {
2103  c = findWORDEnd( c.line(), c.column() );
2104  }
2105 
2106  if (!c.isValid())
2107  {
2108  c = doc()->documentEnd();
2109  }
2110 
2111  r.endColumn = c.column();
2112  r.endLine = c.line();
2113 
2114  return r;
2115 }
2116 
2117 KateViRange KateViNormalMode::motionToEndOfPrevWord()
2118 {
2119  Cursor c( m_view->cursorPosition() );
2120  KateViRange r( c.line(), c.column(), ViMotion::InclusiveMotion );
2121 
2122  m_stickyColumn = -1;
2123 
2124  for ( unsigned int i = 0; i < getCount(); i++ ) {
2125  c = findPrevWordEnd( c.line(), c.column() );
2126 
2127  if (c.isValid())
2128  {
2129  r.endColumn = c.column();
2130  r.endLine = c.line();
2131  }
2132  else
2133  {
2134  r.endColumn = 0;
2135  r.endLine = 0;
2136  break;
2137  }
2138 
2139  }
2140 
2141  return r;
2142 }
2143 
2144 KateViRange KateViNormalMode::motionToEndOfPrevWORD()
2145 {
2146  Cursor c( m_view->cursorPosition() );
2147  KateViRange r( c.line(), c.column(), ViMotion::InclusiveMotion );
2148 
2149  m_stickyColumn = -1;
2150 
2151  for ( unsigned int i = 0; i < getCount(); i++ ) {
2152  c = findPrevWORDEnd( c.line(), c.column() );
2153 
2154  if (c.isValid())
2155  {
2156  r.endColumn = c.column();
2157  r.endLine = c.line();
2158  }
2159  else
2160  {
2161  r.endColumn = 0;
2162  r.endLine = 0;
2163  break;
2164  }
2165  }
2166 
2167  return r;
2168 }
2169 
2170 KateViRange KateViNormalMode::motionToEOL()
2171 {
2172  Cursor c( m_view->cursorPosition() );
2173 
2174  // set sticky column to a ridiculously high value so that the cursor will stick to EOL,
2175  // but only if it's a regular motion
2176  if ( m_keys.size() == 1 ) {
2177  m_stickyColumn = KateVi::EOL;
2178  }
2179 
2180  unsigned int line = c.line() + ( getCount() - 1 );
2181  KateViRange r( line, doc()->lineLength(line )-1, ViMotion::InclusiveMotion );
2182 
2183  return r;
2184 }
2185 
2186 KateViRange KateViNormalMode::motionToColumn0()
2187 {
2188  m_stickyColumn = -1;
2189  Cursor cursor ( m_view->cursorPosition() );
2190  KateViRange r( cursor.line(), 0, ViMotion::ExclusiveMotion );
2191 
2192  return r;
2193 }
2194 
2195 KateViRange KateViNormalMode::motionToFirstCharacterOfLine()
2196 {
2197  m_stickyColumn = -1;
2198 
2199  Cursor cursor ( m_view->cursorPosition() );
2200  QRegExp nonSpace( "\\S" );
2201  int c = getLine().indexOf( nonSpace );
2202 
2203  KateViRange r( cursor.line(), c, ViMotion::ExclusiveMotion );
2204 
2205  return r;
2206 }
2207 
2208 KateViRange KateViNormalMode::motionFindChar()
2209 {
2210  m_lastTFcommand = m_keys;
2211  Cursor cursor ( m_view->cursorPosition() );
2212  QString line = getLine();
2213 
2214  m_stickyColumn = -1;
2215 
2216  int matchColumn = cursor.column();
2217 
2218  for ( unsigned int i = 0; i < getCount(); i++ ) {
2219  matchColumn = line.indexOf( m_keys.right( 1 ), matchColumn+1 );
2220  if ( matchColumn == -1 )
2221  break;
2222  }
2223 
2224  KateViRange r;
2225 
2226  if (matchColumn != -1)
2227  {
2228  r.endColumn = matchColumn;
2229  r.endLine = cursor.line();
2230  }
2231  else
2232  {
2233  return KateViRange::invalid();
2234  }
2235 
2236  return r;
2237 }
2238 
2239 KateViRange KateViNormalMode::motionFindCharBackward()
2240 {
2241  m_lastTFcommand = m_keys;
2242  Cursor cursor ( m_view->cursorPosition() );
2243  QString line = getLine();
2244 
2245  m_stickyColumn = -1;
2246 
2247  int matchColumn = -1;
2248 
2249  unsigned int hits = 0;
2250  int i = cursor.column()-1;
2251 
2252  while ( hits != getCount() && i >= 0 ) {
2253  if ( line.at( i ) == m_keys.at( m_keys.size()-1 ) )
2254  hits++;
2255 
2256  if ( hits == getCount() )
2257  matchColumn = i;
2258 
2259  i--;
2260  }
2261 
2262  KateViRange r;
2263 
2264  if (matchColumn != -1)
2265  {
2266  r.endColumn = matchColumn;
2267  r.endLine = cursor.line();
2268  }
2269  else
2270  {
2271  return KateViRange::invalid();
2272  }
2273 
2274  return r;
2275 }
2276 
2277 KateViRange KateViNormalMode::motionToChar()
2278 {
2279  m_lastTFcommand = m_keys;
2280  Cursor cursor ( m_view->cursorPosition() );
2281  QString line = getLine();
2282 
2283  m_stickyColumn = -1;
2284  KateViRange r;
2285  r.endColumn = -1;
2286  r.endLine = -1;
2287 
2288  int matchColumn = cursor.column()+ (m_isRepeatedTFcommand ? 2 : 1);
2289 
2290  for ( unsigned int i = 0; i < getCount(); i++ ) {
2291  const int lastColumn = matchColumn;
2292  matchColumn = line.indexOf( m_keys.right( 1 ), matchColumn + ((i > 0) ? 1 : 0));
2293  if ( matchColumn == -1 )
2294  {
2295  if (m_isRepeatedTFcommand)
2296  {
2297  matchColumn = lastColumn;
2298  }
2299  else
2300  {
2301  return KateViRange::invalid();
2302  }
2303  break;
2304  }
2305  }
2306 
2307 
2308  r.endColumn = matchColumn-1;
2309  r.endLine = cursor.line();
2310 
2311  m_isRepeatedTFcommand = false;
2312  return r;
2313 }
2314 
2315 KateViRange KateViNormalMode::motionToCharBackward()
2316 {
2317  m_lastTFcommand = m_keys;
2318  Cursor cursor ( m_view->cursorPosition() );
2319  QString line = getLine();
2320 
2321  const int originalColumn = cursor.column();
2322  m_stickyColumn = -1;
2323 
2324  int matchColumn = originalColumn - 1;
2325 
2326  unsigned int hits = 0;
2327  int i = cursor.column()- (m_isRepeatedTFcommand ? 2 : 1);
2328 
2329  KateViRange r;
2330 
2331  while ( hits != getCount() && i >= 0 ) {
2332  if ( line.at( i ) == m_keys.at( m_keys.size()-1 ) )
2333  hits++;
2334 
2335  if ( hits == getCount() )
2336  matchColumn = i;
2337 
2338  i--;
2339  }
2340 
2341  if (hits == getCount())
2342  {
2343  r.endColumn = matchColumn+1;
2344  r.endLine = cursor.line();
2345  }
2346  else
2347  {
2348  r.valid = false;
2349  }
2350 
2351  m_isRepeatedTFcommand = false;
2352 
2353  return r;
2354 }
2355 
2356 KateViRange KateViNormalMode::motionRepeatlastTF()
2357 {
2358  if ( !m_lastTFcommand.isEmpty() ) {
2359  m_isRepeatedTFcommand = true;
2360  m_keys = m_lastTFcommand;
2361  if ( m_keys.at( 0 ) == 'f' ) {
2362  return motionFindChar();
2363  }
2364  else if ( m_keys.at( 0 ) == 'F' ) {
2365  return motionFindCharBackward();
2366  }
2367  else if ( m_keys.at( 0 ) == 't' ) {
2368  return motionToChar();
2369  }
2370  else if ( m_keys.at( 0 ) == 'T' ) {
2371  return motionToCharBackward();
2372  }
2373  }
2374 
2375  // there was no previous t/f command
2376  return KateViRange::invalid();
2377 }
2378 
2379 KateViRange KateViNormalMode::motionRepeatlastTFBackward()
2380 {
2381  if ( !m_lastTFcommand.isEmpty() ) {
2382  m_isRepeatedTFcommand = true;
2383  m_keys = m_lastTFcommand;
2384  if ( m_keys.at( 0 ) == 'f' ) {
2385  return motionFindCharBackward();
2386  }
2387  else if ( m_keys.at( 0 ) == 'F' ) {
2388  return motionFindChar();
2389  }
2390  else if ( m_keys.at( 0 ) == 't' ) {
2391  return motionToCharBackward();
2392  }
2393  else if ( m_keys.at( 0 ) == 'T' ) {
2394  return motionToChar();
2395  }
2396  }
2397 
2398  // there was no previous t/f command
2399  return KateViRange::invalid();
2400 }
2401 
2402 // FIXME: should honour the provided count
2403 KateViRange KateViNormalMode::motionFindPrev()
2404 {
2405  QString pattern = m_viInputModeManager->getLastSearchPattern();
2406  bool backwards = m_viInputModeManager->lastSearchBackwards();
2407  const bool caseSensitive = m_viInputModeManager->lastSearchCaseSensitive();
2408  const bool placeCursorAtEndOfMatch = m_viInputModeManager->lastSearchPlacesCursorAtEndOfMatch();
2409 
2410  KateViRange match = findPatternForMotion( pattern, !backwards, caseSensitive, m_view->cursorPosition(), getCount() );
2411 
2412  if (!placeCursorAtEndOfMatch)
2413  {
2414  return KateViRange(match.startLine, match.startColumn, ViMotion::ExclusiveMotion);
2415  }
2416  else
2417  {
2418  return KateViRange(match.endLine, match.endColumn - 1, ViMotion::ExclusiveMotion);
2419  }
2420 }
2421 
2422 KateViRange KateViNormalMode::motionFindNext()
2423 {
2424  QString pattern = m_viInputModeManager->getLastSearchPattern();
2425  bool backwards = m_viInputModeManager->lastSearchBackwards();
2426  const bool caseSensitive = m_viInputModeManager->lastSearchCaseSensitive();
2427  const bool placeCursorAtEndOfMatch = m_viInputModeManager->lastSearchPlacesCursorAtEndOfMatch();
2428 
2429  KateViRange match = findPatternForMotion( pattern, backwards, caseSensitive, m_view->cursorPosition(), getCount() );
2430 
2431  if (!placeCursorAtEndOfMatch)
2432  {
2433  return KateViRange(match.startLine, match.startColumn, ViMotion::ExclusiveMotion);
2434  }
2435  else
2436  {
2437  return KateViRange(match.endLine, match.endColumn - 1, ViMotion::ExclusiveMotion);
2438  }
2439 }
2440 
2441 
2442 KateViRange KateViNormalMode::motionToLineFirst()
2443 {
2444  KateViRange r( getCount()-1, 0, ViMotion::InclusiveMotion );
2445  m_stickyColumn = -1;
2446 
2447  if ( r.endLine > doc()->lines() - 1 ) {
2448  r.endLine = doc()->lines() - 1;
2449  }
2450  r.jump = true;
2451 
2452  return r;
2453 }
2454 
2455 KateViRange KateViNormalMode::motionToLineLast()
2456 {
2457  KateViRange r( doc()->lines()-1, 0, ViMotion::InclusiveMotion );
2458  m_stickyColumn = -1;
2459 
2460  // don't use getCount() here, no count and a count of 1 is different here...
2461  if ( m_count != 0 ) {
2462  r.endLine = m_count-1;
2463  }
2464 
2465  if ( r.endLine > doc()->lines() - 1 ) {
2466  r.endLine = doc()->lines() - 1;
2467  }
2468  r.jump = true;
2469 
2470  return r;
2471 }
2472 
2473 KateViRange KateViNormalMode::motionToScreenColumn()
2474 {
2475  m_stickyColumn = -1;
2476 
2477  Cursor c( m_view->cursorPosition() );
2478 
2479  int column = getCount()-1;
2480 
2481  if ( doc()->lineLength( c.line() )-1 < (int)getCount()-1 ) {
2482  column = doc()->lineLength( c.line() )-1;
2483  }
2484 
2485  return KateViRange( c.line(), column, ViMotion::ExclusiveMotion );
2486 }
2487 
2488 KateViRange KateViNormalMode::motionToMark()
2489 {
2490  KateViRange r;
2491 
2492  m_stickyColumn = -1;
2493 
2494  QChar reg = m_keys.at( m_keys.size()-1 );
2495 
2496  // ` and ' is the same register (position before jump)
2497  if ( reg == '`' ) {
2498  reg = '\'';
2499  }
2500 
2501  Cursor c = m_view->getViInputModeManager()->getMarkPosition( reg );
2502  if ( c.isValid() ) {
2503  r.endLine = c.line();
2504  r.endColumn = c.column();
2505  } else {
2506  error(i18n("Mark not set: %1",m_keys.right( 1 ) ));
2507  r.valid = false;
2508  }
2509 
2510  r.jump = true;
2511 
2512  return r;
2513 }
2514 
2515 KateViRange KateViNormalMode::motionToMarkLine()
2516 {
2517  KateViRange r = motionToMark();
2518  r.endColumn = 0; // FIXME: should be first non-blank on line
2519 
2520  m_stickyColumn = -1;
2521 
2522  r.jump = true;
2523 
2524  return r;
2525 }
2526 
2527 KateViRange KateViNormalMode::motionToMatchingItem()
2528 {
2529  KateViRange r;
2530  int lines = doc()->lines();
2531 
2532  // If counted, then it's not a motion to matching item anymore,
2533  // but a motion to the N'th percentage of the document
2534  if( isCounted() ) {
2535  int count = getCount();
2536  if ( count > 100 ) {
2537  return r;
2538  }
2539  r.endLine = qRound(lines * count / 100.0) - 1;
2540  r.endColumn = 0;
2541  return r;
2542  }
2543 
2544  Cursor c( m_view->cursorPosition() );
2545 
2546  QString l = getLine();
2547  int n1 = l.indexOf( m_matchItemRegex, c.column() );
2548 
2549  m_stickyColumn = -1;
2550 
2551  if ( n1 < 0 ) {
2552  return KateViRange::invalid();
2553  }
2554 
2555  QRegExp brackets( "[(){}\\[\\]]" );
2556 
2557  // use Kate's built-in matching bracket finder for brackets
2558  if ( brackets.indexIn ( l, n1 ) == n1 ) {
2559  // findMatchingBracket requires us to move the cursor to the
2560  // first bracket, but we don't want the cursor to really move
2561  // in case this is e.g. a yank, so restore it to its original
2562  // position afterwards.
2563  c.setColumn( n1 + 1 );
2564  const Cursor oldCursorPos = m_view->cursorPosition();
2565  updateCursor(c);
2566 
2567  // find the matching one
2568  c = m_viewInternal->findMatchingBracket();
2569  if ( c > m_view->cursorPosition() ) {
2570  c.setColumn( c.column() - 1 );
2571  }
2572  m_view->setCursorPosition(oldCursorPos);
2573  } else {
2574  // text item we want to find a matching item for
2575  int n2 = l.indexOf( QRegExp( "\\b|\\s|$" ), n1 );
2576  QString item = l.mid( n1, n2 - n1 );
2577  QString matchingItem = m_matchingItems[ item ];
2578 
2579  int toFind = 1;
2580  int line = c.line();
2581  int column = n2 - item.length();
2582  bool reverse = false;
2583 
2584  if ( matchingItem.left( 1 ) == "-" ) {
2585  matchingItem.remove( 0, 1 ); // remove the '-'
2586  reverse = true;
2587  }
2588 
2589  // make sure we don't hit the text item we started the search from
2590  if ( column == 0 && reverse ) {
2591  column -= item.length();
2592  }
2593 
2594  int itemIdx;
2595  int matchItemIdx;
2596 
2597  while ( toFind > 0 ) {
2598  if ( reverse ) {
2599  itemIdx = l.lastIndexOf( item, column - 1 );
2600  matchItemIdx = l.lastIndexOf( matchingItem, column - 1 );
2601 
2602  if ( itemIdx != -1 && ( matchItemIdx == -1 || itemIdx > matchItemIdx ) ) {
2603  ++toFind;
2604  }
2605  } else {
2606  itemIdx = l.indexOf( item, column );
2607  matchItemIdx = l.indexOf( matchingItem, column );
2608 
2609  if ( itemIdx != -1 && ( matchItemIdx == -1 || itemIdx < matchItemIdx ) ) {
2610  ++toFind;
2611  }
2612  }
2613 
2614  if ( matchItemIdx != -1 || itemIdx != -1 ) {
2615  if ( !reverse ) {
2616  column = qMin( (unsigned int)itemIdx, (unsigned int)matchItemIdx );
2617  } else {
2618  column = qMax( itemIdx, matchItemIdx );
2619  }
2620  }
2621 
2622  if ( matchItemIdx != -1 ) { // match on current line
2623  if ( matchItemIdx == column ) {
2624  --toFind;
2625  c.setLine( line );
2626  c.setColumn( column );
2627  }
2628  } else { // no match, advance one line if possible
2629  ( reverse ) ? --line : ++line;
2630  column = 0;
2631 
2632  if ( ( !reverse && line >= lines ) || ( reverse && line < 0 ) ) {
2633  r.valid = false;
2634  break;
2635  } else {
2636  l = getLine( line );
2637  }
2638  }
2639  }
2640  }
2641 
2642  r.endLine = c.line();
2643  r.endColumn = c.column();
2644  r.jump = true;
2645 
2646  return r;
2647 }
2648 
2649 KateViRange KateViNormalMode::motionToNextBraceBlockStart()
2650 {
2651  KateViRange r;
2652 
2653  m_stickyColumn = -1;
2654 
2655  int line = findLineStartingWitchChar( '{', getCount() );
2656 
2657  if ( line == -1 ) {
2658  return KateViRange::invalid();
2659  }
2660 
2661  r.endLine = line;
2662  r.endColumn = 0;
2663  r.jump = true;
2664 
2665  if (motionWillBeUsedWithCommand())
2666  {
2667  // Delete from cursor (inclusive) to the '{' (exclusive).
2668  // If we are on the first column, then delete the entire current line.
2669  r.motionType = ViMotion::ExclusiveMotion;
2670  if (m_view->cursorPosition().column() != 0)
2671  {
2672  r.endLine--;
2673  r.endColumn = doc()->lineLength(r.endLine);
2674  }
2675  }
2676 
2677  return r;
2678 }
2679 
2680 KateViRange KateViNormalMode::motionToPreviousBraceBlockStart()
2681 {
2682  KateViRange r;
2683 
2684  m_stickyColumn = -1;
2685 
2686  int line = findLineStartingWitchChar( '{', getCount(), false );
2687 
2688  if ( line == -1 ) {
2689  return KateViRange::invalid();
2690  }
2691 
2692  r.endLine = line;
2693  r.endColumn = 0;
2694  r.jump = true;
2695 
2696  if (motionWillBeUsedWithCommand())
2697  {
2698  // With a command, do not include the { or the cursor position.
2699  r.motionType = ViMotion::ExclusiveMotion;
2700  }
2701 
2702  return r;
2703 }
2704 
2705 KateViRange KateViNormalMode::motionToNextBraceBlockEnd()
2706 {
2707  KateViRange r;
2708 
2709  m_stickyColumn = -1;
2710 
2711  int line = findLineStartingWitchChar( '}', getCount() );
2712 
2713  if ( line == -1 ) {
2714  return KateViRange::invalid();
2715  }
2716 
2717  r.endLine = line;
2718  r.endColumn = 0;
2719  r.jump = true;
2720 
2721  if (motionWillBeUsedWithCommand())
2722  {
2723  // Delete from cursor (inclusive) to the '}' (exclusive).
2724  // If we are on the first column, then delete the entire current line.
2725  r.motionType = ViMotion::ExclusiveMotion;
2726  if (m_view->cursorPosition().column() != 0)
2727  {
2728  r.endLine--;
2729  r.endColumn = doc()->lineLength(r.endLine);
2730  }
2731  }
2732 
2733  return r;
2734 }
2735 
2736 KateViRange KateViNormalMode::motionToPreviousBraceBlockEnd()
2737 {
2738  KateViRange r;
2739 
2740  m_stickyColumn = -1;
2741 
2742  int line = findLineStartingWitchChar( '}', getCount(), false );
2743 
2744  if ( line == -1 ) {
2745  return KateViRange::invalid();
2746  }
2747 
2748  r.endLine = line;
2749  r.endColumn = 0;
2750  r.jump = true;
2751 
2752  if (motionWillBeUsedWithCommand())
2753  {
2754  r.motionType = ViMotion::ExclusiveMotion;
2755  }
2756 
2757  return r;
2758 }
2759 
2760 KateViRange KateViNormalMode::motionToNextOccurrence()
2761 {
2762  QString word = getWordUnderCursor();
2763  KateGlobal::self()->viInputModeGlobal()->appendSearchHistoryItem("\\<" + word + "\\>");
2764  word.prepend("\\b").append("\\b");
2765 
2766  m_viInputModeManager->setLastSearchPattern( word );
2767  m_viInputModeManager->setLastSearchBackwards( false );
2768  m_viInputModeManager->setLastSearchCaseSensitive( false );
2769  m_viInputModeManager->setLastSearchPlacesCursorAtEndOfMatch( false );
2770 
2771  const KateViRange match = findPatternForMotion( word, false, false, getWordRangeUnderCursor().start(), getCount() );
2772  return KateViRange(match.startLine, match.startColumn, ViMotion::ExclusiveMotion);
2773 }
2774 
2775 KateViRange KateViNormalMode::motionToPrevOccurrence()
2776 {
2777  QString word = getWordUnderCursor();
2778  KateGlobal::self()->viInputModeGlobal()->appendSearchHistoryItem("\\<" + word + "\\>");
2779  word.prepend("\\b").append("\\b");
2780 
2781  m_viInputModeManager->setLastSearchPattern( word );
2782  m_viInputModeManager->setLastSearchBackwards( true );
2783  m_viInputModeManager->setLastSearchCaseSensitive( false );
2784  m_viInputModeManager->setLastSearchPlacesCursorAtEndOfMatch( false );
2785 
2786  // Search from the beginning of the word under the cursor, so that the current word isn't found
2787  // first.
2788  const KateViRange match = findPatternForMotion( word, true, false, getWordRangeUnderCursor().start(), getCount() );
2789  return KateViRange(match.startLine, match.startColumn, ViMotion::ExclusiveMotion);
2790 }
2791 
2792 KateViRange KateViNormalMode::motionToFirstLineOfWindow() {
2793  int lines_to_go;
2794  if (linesDisplayed() <= (unsigned int) m_viewInternal->endLine())
2795  lines_to_go = m_viewInternal->endLine() - linesDisplayed()- m_view->cursorPosition().line() + 1;
2796  else
2797  lines_to_go = - m_view->cursorPosition().line();
2798 
2799  KateViRange r = goLineUpDown(lines_to_go);
2800 
2801  // Finding first non-blank character
2802  QRegExp nonSpace( "\\S" );
2803  int c = getLine(r.endLine).indexOf( nonSpace );
2804  if ( c == -1 )
2805  c = 0;
2806 
2807  r.endColumn = c;
2808  return r;
2809 }
2810 
2811 KateViRange KateViNormalMode::motionToMiddleLineOfWindow() {
2812  int lines_to_go;
2813  if (linesDisplayed() <= (unsigned int) m_viewInternal->endLine())
2814  lines_to_go = m_viewInternal->endLine() - linesDisplayed()/2 - m_view->cursorPosition().line();
2815  else
2816  lines_to_go = m_viewInternal->endLine()/2 - m_view->cursorPosition().line();
2817  KateViRange r = goLineUpDown(lines_to_go);
2818 
2819  // Finding first non-blank character
2820  QRegExp nonSpace( "\\S" );
2821  int c = getLine(r.endLine).indexOf( nonSpace );
2822  if ( c == -1 )
2823  c = 0;
2824 
2825  r.endColumn = c;
2826  return r;
2827 }
2828 
2829 KateViRange KateViNormalMode::motionToLastLineOfWindow() {
2830  int lines_to_go;
2831  if (linesDisplayed() <= (unsigned int) m_viewInternal->endLine())
2832  lines_to_go = m_viewInternal->endLine() - m_view->cursorPosition().line();
2833  else
2834  lines_to_go = m_viewInternal->endLine() - m_view->cursorPosition().line();
2835 
2836  KateViRange r = goLineUpDown(lines_to_go);
2837 
2838  // Finding first non-blank character
2839  QRegExp nonSpace( "\\S" );
2840  int c = getLine(r.endLine).indexOf( nonSpace );
2841  if ( c == -1 )
2842  c = 0;
2843 
2844  r.endColumn = c;
2845  return r;
2846 }
2847 
2848 KateViRange KateViNormalMode::motionToNextVisualLine() {
2849  return goVisualLineUpDown( getCount() );
2850 }
2851 
2852 KateViRange KateViNormalMode::motionToPrevVisualLine() {
2853  return goVisualLineUpDown( -getCount() );
2854 }
2855 
2856 KateViRange KateViNormalMode::motionToBeforeParagraph()
2857 {
2858  Cursor c( m_view->cursorPosition() );
2859 
2860  int line = c.line();
2861 
2862  m_stickyColumn = -1;
2863 
2864  for ( unsigned int i = 0; i < getCount(); i++ ) {
2865  // advance at least one line, but if there are consecutive blank lines
2866  // skip them all
2867  do {
2868  line--;
2869  } while (line >= 0 && getLine( line+1 ).length() == 0);
2870  while ( line > 0 && getLine( line ).length() != 0 ) {
2871  line--;
2872  }
2873  }
2874 
2875  if ( line < 0 ) {
2876  line = 0;
2877  }
2878 
2879  KateViRange r( line, 0, ViMotion::InclusiveMotion );
2880 
2881  return r;
2882 }
2883 
2884 KateViRange KateViNormalMode::motionToAfterParagraph()
2885 {
2886  Cursor c( m_view->cursorPosition() );
2887 
2888  int line = c.line();
2889 
2890  m_stickyColumn = -1;
2891 
2892  for ( unsigned int i = 0; i < getCount(); i++ ) {
2893  // advance at least one line, but if there are consecutive blank lines
2894  // skip them all
2895  do {
2896  line++;
2897  } while (line <= doc()->lines()-1 && getLine( line-1 ).length() == 0);
2898  while ( line < doc()->lines()-1 && getLine( line ).length() != 0 ) {
2899  line++;
2900  }
2901  }
2902 
2903  if ( line >= doc()->lines() ) {
2904  line = doc()->lines()-1;
2905  }
2906 
2907  // if we ended up on the last line, the cursor should be placed on the last column
2908  int column = (line == doc()->lines()-1) ? qMax( getLine( line ).length()-1, 0 ) : 0;
2909 
2910  KateViRange r( line, column, ViMotion::InclusiveMotion );
2911 
2912  return r;
2913 }
2914 
2915 KateViRange KateViNormalMode::motionToIncrementalSearchMatch()
2916 {
2917  return KateViRange(m_positionWhenIncrementalSearchBegan.line(),
2918  m_positionWhenIncrementalSearchBegan.column(),
2919  m_view->cursorPosition().line(),
2920  m_view->cursorPosition().column(), ViMotion::ExclusiveMotion);
2921 }
2922 
2924 // TEXT OBJECTS
2926 
2927 KateViRange KateViNormalMode::textObjectAWord()
2928 {
2929  Cursor c( m_view->cursorPosition() );
2930 
2931  Cursor c1 = c;
2932 
2933  bool startedOnSpace = false;
2934  if (doc()->character(c).isSpace())
2935  {
2936  startedOnSpace = true;
2937  }
2938  else
2939  {
2940  c1 = findPrevWordStart( c.line(), c.column()+1, true );
2941  if (!c1.isValid())
2942  {
2943  c1 = Cursor(0, 0);
2944  }
2945  }
2946  Cursor c2 = Cursor(c.line(), c.column() - 1);
2947  for (unsigned int i = 1; i <= getCount(); i++)
2948  {
2949  c2 = findWordEnd(c2.line(), c2.column());
2950  }
2951  if (!c1.isValid() || !c2.isValid())
2952  {
2953  return KateViRange::invalid();
2954  }
2955  // Adhere to some of Vim's bizarre rules of whether to swallow ensuing spaces or not.
2956  // Don't ask ;)
2957  const Cursor nextWordStart = findNextWordStart(c2.line(), c2.column());
2958  if (nextWordStart.isValid() && nextWordStart.line() == c2.line())
2959  {
2960  if (!startedOnSpace)
2961  {
2962  c2 = Cursor(nextWordStart.line(), nextWordStart.column() - 1);
2963  }
2964  }
2965  else
2966  {
2967  c2 = Cursor(c2.line(), doc()->lineLength(c2.line()) - 1);
2968  }
2969  bool swallowCarriageReturnAtEndOfLine = false;
2970  if (c2.line() != c.line() && c2.column() == doc()->lineLength(c2.line()) - 1)
2971  {
2972  // Greedily descend to the next line, so as to swallow the carriage return on this line.
2973  c2 = Cursor(c2.line() + 1, 0);
2974  swallowCarriageReturnAtEndOfLine = true;
2975  }
2976  const bool swallowPrecedingSpaces = (c2.column() == doc()->lineLength(c2.line()) - 1 && !doc()->character(c2).isSpace() ) || startedOnSpace || swallowCarriageReturnAtEndOfLine;
2977  if (swallowPrecedingSpaces)
2978  {
2979  if (c1.column() != 0)
2980  {
2981  const Cursor previousNonSpace = findPrevWordEnd(c.line(), c.column());
2982  if (previousNonSpace.isValid() && previousNonSpace.line() == c1.line())
2983  {
2984  c1 = Cursor(previousNonSpace.line(), previousNonSpace.column() + 1);
2985  }
2986  else if (startedOnSpace || swallowCarriageReturnAtEndOfLine)
2987  {
2988  c1 = Cursor(c1.line(), 0);
2989  }
2990  }
2991  }
2992 
2993  KateViRange r( c.line(), c.column(), !swallowCarriageReturnAtEndOfLine ? ViMotion::InclusiveMotion : ViMotion::ExclusiveMotion );
2994 
2995  r.startLine = c1.line();
2996  r.endLine = c2.line();
2997  r.startColumn = c1.column();
2998  r.endColumn = c2.column();
2999 
3000  return r;
3001 }
3002 
3003 KateViRange KateViNormalMode::textObjectInnerWord()
3004 {
3005  Cursor c( m_view->cursorPosition() );
3006 
3007  Cursor c1 = findPrevWordStart( c.line(), c.column()+1, true );
3008  if (!c1.isValid())
3009  {
3010  c1 = Cursor(0, 0);
3011  }
3012  // need to start search in column-1 because it might be a one-character word
3013  Cursor c2( c.line(), c.column()-1 );
3014 
3015  for ( unsigned int i = 0; i < getCount(); i++ ) {
3016  c2 = findWordEnd( c2.line(), c2.column(), true );
3017  }
3018 
3019  if (!c2.isValid())
3020  {
3021  c2 = doc()->documentEnd();
3022  }
3023 
3024  KateViRange r;
3025 
3026  // sanity check
3027  if ( c1.line() != c2.line() || c1.column() > c2.column() ) {
3028  return KateViRange::invalid();
3029  } else {
3030  r.startLine = c1.line();
3031  r.endLine = c2.line();
3032  r.startColumn = c1.column();
3033  r.endColumn = c2.column();
3034  }
3035 
3036  return r;
3037 }
3038 
3039 KateViRange KateViNormalMode::textObjectAWORD()
3040 {
3041  Cursor c( m_view->cursorPosition() );
3042 
3043  Cursor c1 = c;
3044 
3045  bool startedOnSpace = false;
3046  if (doc()->character(c).isSpace())
3047  {
3048  startedOnSpace = true;
3049  }
3050  else
3051  {
3052  c1 = findPrevWORDStart( c.line(), c.column()+1, true );
3053  if (!c1.isValid())
3054  {
3055  c1 = Cursor(0, 0);
3056  }
3057  }
3058  Cursor c2 = Cursor(c.line(), c.column() - 1);
3059  for (unsigned int i = 1; i <= getCount(); i++)
3060  {
3061  c2 = findWORDEnd(c2.line(), c2.column());
3062  }
3063  if (!c1.isValid() || !c2.isValid())
3064  {
3065  return KateViRange::invalid();
3066  }
3067  // Adhere to some of Vim's bizarre rules of whether to swallow ensuing spaces or not.
3068  // Don't ask ;)
3069  const Cursor nextWordStart = findNextWordStart(c2.line(), c2.column());
3070  if (nextWordStart.isValid() && nextWordStart.line() == c2.line())
3071  {
3072  if (!startedOnSpace)
3073  {
3074  c2 = Cursor(nextWordStart.line(), nextWordStart.column() - 1);
3075  }
3076  }
3077  else
3078  {
3079  c2 = Cursor(c2.line(), doc()->lineLength(c2.line()) - 1);
3080  }
3081  bool swallowCarriageReturnAtEndOfLine = false;
3082  if (c2.line() != c.line() && c2.column() == doc()->lineLength(c2.line()) - 1)
3083  {
3084  // Greedily descend to the next line, so as to swallow the carriage return on this line.
3085  c2 = Cursor(c2.line() + 1, 0);
3086  swallowCarriageReturnAtEndOfLine = true;
3087  }
3088  const bool swallowPrecedingSpaces = (c2.column() == doc()->lineLength(c2.line()) - 1 && !doc()->character(c2).isSpace() ) || startedOnSpace || swallowCarriageReturnAtEndOfLine;
3089  if (swallowPrecedingSpaces)
3090  {
3091  if (c1.column() != 0)
3092  {
3093  const Cursor previousNonSpace = findPrevWORDEnd(c.line(), c.column());
3094  if (previousNonSpace.isValid() && previousNonSpace.line() == c1.line())
3095  {
3096  c1 = Cursor(previousNonSpace.line(), previousNonSpace.column() + 1);
3097  }
3098  else if (startedOnSpace || swallowCarriageReturnAtEndOfLine)
3099  {
3100  c1 = Cursor(c1.line(), 0);
3101  }
3102  }
3103  }
3104 
3105  KateViRange r( c.line(), c.column(), !swallowCarriageReturnAtEndOfLine ? ViMotion::InclusiveMotion : ViMotion::ExclusiveMotion );
3106 
3107  r.startLine = c1.line();
3108  r.endLine = c2.line();
3109  r.startColumn = c1.column();
3110  r.endColumn = c2.column();
3111 
3112  return r;
3113 }
3114 
3115 KateViRange KateViNormalMode::textObjectInnerWORD()
3116 {
3117  Cursor c( m_view->cursorPosition() );
3118 
3119  Cursor c1 = findPrevWORDStart( c.line(), c.column()+1, true );
3120  if (!c1.isValid())
3121  {
3122  c1 = Cursor(0, 0);
3123  }
3124  Cursor c2( c );
3125 
3126  for ( unsigned int i = 0; i < getCount(); i++ ) {
3127  c2 = findWORDEnd( c2.line(), c2.column(), true );
3128  }
3129 
3130  if (!c2.isValid())
3131  {
3132  c2 = doc()->documentEnd();
3133  }
3134 
3135  KateViRange r;
3136 
3137  // sanity check
3138  if ( c1.line() != c2.line() || c1.column() > c2.column() ) {
3139  return KateViRange::invalid();
3140  } else {
3141  r.startLine = c1.line();
3142  r.endLine = c2.line();
3143  r.startColumn = c1.column();
3144  r.endColumn = c2.column();
3145  }
3146 
3147  return r;
3148 }
3149 
3150 KateViRange KateViNormalMode::textObjectAQuoteDouble()
3151 {
3152  return findSurroundingQuotes( '"', false );
3153 }
3154 
3155 KateViRange KateViNormalMode::textObjectInnerQuoteDouble()
3156 {
3157  return findSurroundingQuotes( '"', true );
3158 }
3159 
3160 KateViRange KateViNormalMode::textObjectAQuoteSingle()
3161 {
3162  return findSurroundingQuotes( '\'', false );
3163 }
3164 
3165 KateViRange KateViNormalMode::textObjectInnerQuoteSingle()
3166 {
3167  return findSurroundingQuotes( '\'', true );
3168 }
3169 
3170 KateViRange KateViNormalMode::textObjectABackQuote()
3171 {
3172  return findSurroundingQuotes( '`', false );
3173 }
3174 
3175 KateViRange KateViNormalMode::textObjectInnerBackQuote()
3176 {
3177  return findSurroundingQuotes( '`', true );
3178 }
3179 
3180 
3181 KateViRange KateViNormalMode::textObjectAParen()
3182 {
3183 
3184  return findSurroundingBrackets( '(', ')', false, '(', ')' );
3185 }
3186 
3187 KateViRange KateViNormalMode::textObjectInnerParen()
3188 {
3189 
3190  return findSurroundingBrackets( '(', ')', true, '(', ')');
3191 }
3192 
3193 KateViRange KateViNormalMode::textObjectABracket()
3194 {
3195 
3196  return findSurroundingBrackets( '[', ']', false, '[', ']' );
3197 }
3198 
3199 KateViRange KateViNormalMode::textObjectInnerBracket()
3200 {
3201 
3202  return findSurroundingBrackets( '[', ']', true, '[', ']' );
3203 }
3204 
3205 KateViRange KateViNormalMode::textObjectACurlyBracket()
3206 {
3207 
3208  return findSurroundingBrackets( '{', '}', false, '{', '}' );
3209 }
3210 
3211 KateViRange KateViNormalMode::textObjectInnerCurlyBracket()
3212 {
3213  const KateViRange allBetweenCurlyBrackets = findSurroundingBrackets( '{', '}', true, '{', '}' );
3214  // Emulate the behaviour of vim, which tries to leave the closing bracket on its own line
3215  // if it was originally on a line different to that of the opening bracket.
3216  KateViRange innerCurlyBracket(allBetweenCurlyBrackets);
3217 
3218  if (innerCurlyBracket.startLine != innerCurlyBracket.endLine)
3219  {
3220  const bool openingBraceIsLastCharOnLine = innerCurlyBracket.startColumn == doc()->line(innerCurlyBracket.startLine).length();
3221  const bool stuffToDeleteIsAllOnEndLine = openingBraceIsLastCharOnLine &&
3222  innerCurlyBracket.endLine == innerCurlyBracket.startLine + 1;
3223  const QString textLeadingClosingBracket = doc()->line(innerCurlyBracket.endLine).mid(0, innerCurlyBracket.endColumn + 1);
3224  const bool closingBracketHasLeadingNonWhitespace = !textLeadingClosingBracket.trimmed().isEmpty();
3225  if (stuffToDeleteIsAllOnEndLine)
3226  {
3227  if (!closingBracketHasLeadingNonWhitespace)
3228  {
3229  // Nothing there to select - abort.
3230  return KateViRange::invalid();
3231  }
3232  else
3233  {
3234  // Shift the beginning of the range to the start of the line containing the closing bracket.
3235  innerCurlyBracket.startLine++;
3236  innerCurlyBracket.startColumn = 0;
3237  }
3238  }
3239  else
3240  {
3241  if (openingBraceIsLastCharOnLine && !closingBracketHasLeadingNonWhitespace)
3242  {
3243  innerCurlyBracket.startLine++;
3244  innerCurlyBracket.startColumn = 0;
3245  m_lastMotionWasLinewiseInnerBlock = true;
3246  }
3247  {
3248  // The line containing the end bracket is left alone if the end bracket is preceded by just whitespace,
3249  // else we need to delete everything (i.e. end up with "{}")
3250  if (!closingBracketHasLeadingNonWhitespace)
3251  {
3252  // Shrink the endpoint of the range so that it ends at the end of the line above,
3253  // leaving the closing bracket on its own line.
3254  innerCurlyBracket.endLine--;
3255  innerCurlyBracket.endColumn = doc()->line(innerCurlyBracket.endLine).length();
3256  }
3257  }
3258  }
3259 
3260  }
3261  return innerCurlyBracket;
3262 }
3263 
3264 KateViRange KateViNormalMode::textObjectAInequalitySign()
3265 {
3266 
3267  return findSurroundingBrackets( '<', '>', false, '<', '>' );
3268 }
3269 
3270 KateViRange KateViNormalMode::textObjectInnerInequalitySign()
3271 {
3272 
3273  return findSurroundingBrackets( '<', '>', true, '<', '>' );
3274 }
3275 
3276 KateViRange KateViNormalMode::textObjectAComma()
3277 {
3278  return textObjectComma(false);
3279 }
3280 
3281 KateViRange KateViNormalMode::textObjectInnerComma()
3282 {
3283  return textObjectComma(true);
3284 }
3285 
3286 // add commands
3287 // when adding commands here, remember to add them to visual mode too (if applicable)
3288 void KateViNormalMode::initializeCommands()
3289 {
3290  ADDCMD("a", commandEnterInsertModeAppend, IS_CHANGE );
3291  ADDCMD("A", commandEnterInsertModeAppendEOL, IS_CHANGE );
3292  ADDCMD("i", commandEnterInsertMode, IS_CHANGE );
3293  ADDCMD("I", commandEnterInsertModeBeforeFirstNonBlankInLine, IS_CHANGE );
3294  ADDCMD("gi", commandEnterInsertModeLast, IS_CHANGE );
3295  ADDCMD("v", commandEnterVisualMode, 0 );
3296  ADDCMD("V", commandEnterVisualLineMode, 0 );
3297  ADDCMD("<c-v>", commandEnterVisualBlockMode, 0 );
3298  ADDCMD("gv", commandReselectVisual, SHOULD_NOT_RESET );
3299  ADDCMD("o", commandOpenNewLineUnder, IS_CHANGE );
3300  ADDCMD("O", commandOpenNewLineOver, IS_CHANGE );
3301  ADDCMD("J", commandJoinLines, IS_CHANGE );
3302  ADDCMD("c", commandChange, IS_CHANGE | NEEDS_MOTION );
3303  ADDCMD("C", commandChangeToEOL, IS_CHANGE );
3304  ADDCMD("cc", commandChangeLine, IS_CHANGE );
3305  ADDCMD("s", commandSubstituteChar, IS_CHANGE );
3306  ADDCMD("S", commandSubstituteLine, IS_CHANGE );
3307  ADDCMD("dd", commandDeleteLine, IS_CHANGE );
3308  ADDCMD("d", commandDelete, IS_CHANGE | NEEDS_MOTION );
3309  ADDCMD("D", commandDeleteToEOL, IS_CHANGE );
3310  ADDCMD("x", commandDeleteChar, IS_CHANGE );
3311  ADDCMD("X", commandDeleteCharBackward, IS_CHANGE );
3312  ADDCMD("gu", commandMakeLowercase, IS_CHANGE | NEEDS_MOTION );
3313  ADDCMD("guu", commandMakeLowercaseLine, IS_CHANGE );
3314  ADDCMD("gU", commandMakeUppercase, IS_CHANGE | NEEDS_MOTION );
3315  ADDCMD("gUU", commandMakeUppercaseLine, IS_CHANGE );
3316  ADDCMD("y", commandYank, NEEDS_MOTION );
3317  ADDCMD("yy", commandYankLine, 0 );
3318  ADDCMD("Y", commandYankToEOL, 0 );
3319  ADDCMD("p", commandPaste, IS_CHANGE );
3320  ADDCMD("P", commandPasteBefore, IS_CHANGE );
3321  ADDCMD("gp", commandgPaste, IS_CHANGE );
3322  ADDCMD("gP", commandgPasteBefore, IS_CHANGE );
3323  ADDCMD("]p", commandIndentedPaste, IS_CHANGE );
3324  ADDCMD("[p", commandIndentedPasteBefore, IS_CHANGE );
3325  ADDCMD("r.", commandReplaceCharacter, IS_CHANGE | REGEX_PATTERN );
3326  ADDCMD("R", commandEnterReplaceMode, IS_CHANGE );
3327  ADDCMD(":", commandSwitchToCmdLine, 0 );
3328  ADDCMD("u", commandUndo, 0);
3329  ADDCMD("<c-r>", commandRedo, 0 );
3330  ADDCMD("U", commandRedo, 0 );
3331  ADDCMD("m.", commandSetMark, REGEX_PATTERN );
3332  ADDCMD(">>", commandIndentLine, IS_CHANGE );
3333  ADDCMD("<<", commandUnindentLine, IS_CHANGE );
3334  ADDCMD(">", commandIndentLines, IS_CHANGE | NEEDS_MOTION );
3335  ADDCMD("<", commandUnindentLines, IS_CHANGE | NEEDS_MOTION );
3336  ADDCMD("<c-f>", commandScrollPageDown, 0 );
3337  ADDCMD("<pagedown>", commandScrollPageDown, 0 );
3338  ADDCMD("<c-b>", commandScrollPageUp, 0 );
3339  ADDCMD("<pageup>", commandScrollPageUp, 0 );
3340  ADDCMD("<c-u>", commandScrollHalfPageUp, 0 );
3341  ADDCMD("<c-d>", commandScrollHalfPageDown, 0 );
3342  ADDCMD("zz", commandCentreViewOnCursor, 0 );
3343  ADDCMD("ga", commandPrintCharacterCode, SHOULD_NOT_RESET );
3344  ADDCMD(".", commandRepeatLastChange, 0 );
3345  ADDCMD("==", commandAlignLine, IS_CHANGE );
3346  ADDCMD("=", commandAlignLines, IS_CHANGE | NEEDS_MOTION);
3347  ADDCMD("~", commandChangeCase, IS_CHANGE );
3348  ADDCMD("g~", commandChangeCaseRange, IS_CHANGE | NEEDS_MOTION );
3349  ADDCMD("<c-a>", commandAddToNumber, IS_CHANGE );
3350  ADDCMD("<c-x>", commandSubtractFromNumber, IS_CHANGE );
3351  ADDCMD("<c-o>", commandGoToPrevJump, 0);
3352  ADDCMD("<c-i>", commandGoToNextJump, 0);
3353 
3354  ADDCMD("<c-w>h",commandSwitchToLeftView,0);
3355  ADDCMD("<c-w><c-h>",commandSwitchToLeftView,0);
3356  ADDCMD("<c-w><left>",commandSwitchToLeftView,0);
3357  ADDCMD("<c-w>j",commandSwitchToDownView,0);
3358  ADDCMD("<c-w><c-j>",commandSwitchToDownView,0);
3359  ADDCMD("<c-w><down>",commandSwitchToDownView,0);
3360  ADDCMD("<c-w>k",commandSwitchToUpView,0);
3361  ADDCMD("<c-w><c-k>",commandSwitchToUpView,0);
3362  ADDCMD("<c-w><up>",commandSwitchToUpView,0);
3363  ADDCMD("<c-w>l",commandSwitchToRightView,0);
3364  ADDCMD("<c-w><c-l>",commandSwitchToRightView,0);
3365  ADDCMD("<c-w><right>",commandSwitchToRightView,0);
3366  ADDCMD("<c-w>w",commandSwitchToNextView,0);
3367  ADDCMD("<c-w><c-w>",commandSwitchToNextView,0);
3368 
3369  ADDCMD("<c-w>s", commandSplitHoriz, 0);
3370  ADDCMD("<c-w>S", commandSplitHoriz, 0);
3371  ADDCMD("<c-w><c-s>", commandSplitHoriz, 0);
3372  ADDCMD("<c-w>v", commandSplitVert, 0);
3373  ADDCMD("<c-w><c-v>", commandSplitVert, 0);
3374 
3375  ADDCMD("gt", commandSwitchToNextTab,0);
3376  ADDCMD("gT", commandSwitchToPrevTab,0);
3377 
3378  ADDCMD("gqq", commandFormatLine, IS_CHANGE);
3379  ADDCMD("gq", commandFormatLines, IS_CHANGE | NEEDS_MOTION);
3380 
3381  ADDCMD("zo", commandExpandLocal, 0 );
3382  ADDCMD("zc", commandCollapseLocal, 0 );
3383  ADDCMD("za", commandToggleRegionVisibility, 0 );
3384  ADDCMD("zr", commandExpandAll, 0 );
3385  ADDCMD("zm", commandCollapseToplevelNodes, 0 );
3386 
3387  ADDCMD("q.", commandStartRecordingMacro, REGEX_PATTERN);
3388  ADDCMD("@.", commandReplayMacro, REGEX_PATTERN);
3389 
3390  // regular motions
3391  ADDMOTION("h", motionLeft, 0 );
3392  ADDMOTION("<left>", motionLeft, 0 );
3393  ADDMOTION("<backspace>", motionLeft, 0 );
3394  ADDMOTION("j", motionDown, 0 );
3395  ADDMOTION("<down>", motionDown, 0 );
3396  ADDMOTION("<enter>", motionDownToFirstNonBlank, 0 );
3397  ADDMOTION("<return>", motionDownToFirstNonBlank, 0 );
3398  ADDMOTION("k", motionUp, 0 );
3399  ADDMOTION("<up>", motionUp, 0 );
3400  ADDMOTION("-", motionUpToFirstNonBlank, 0 );
3401  ADDMOTION("l", motionRight, 0 );
3402  ADDMOTION("<right>", motionRight, 0 );
3403  ADDMOTION(" ", motionRight, 0 );
3404  ADDMOTION("$", motionToEOL, 0 );
3405  ADDMOTION("<end>", motionToEOL, 0 );
3406  ADDMOTION("0", motionToColumn0, 0 );
3407  ADDMOTION("<home>", motionToColumn0, 0 );
3408  ADDMOTION("^", motionToFirstCharacterOfLine, 0 );
3409  ADDMOTION("f.", motionFindChar, REGEX_PATTERN );
3410  ADDMOTION("F.", motionFindCharBackward, REGEX_PATTERN );
3411  ADDMOTION("t.", motionToChar, REGEX_PATTERN );
3412  ADDMOTION("T.", motionToCharBackward, REGEX_PATTERN );
3413  ADDMOTION(";", motionRepeatlastTF, 0 );
3414  ADDMOTION(",", motionRepeatlastTFBackward, 0 );
3415  ADDMOTION("n", motionFindNext, 0 );
3416  ADDMOTION("N", motionFindPrev, 0 );
3417  ADDMOTION("gg", motionToLineFirst, 0 );
3418  ADDMOTION("G", motionToLineLast, 0 );
3419  ADDMOTION("w", motionWordForward, IS_NOT_LINEWISE );
3420  ADDMOTION("W", motionWORDForward, IS_NOT_LINEWISE );
3421  ADDMOTION("<c-right>", motionWordForward, IS_NOT_LINEWISE);
3422  ADDMOTION("<c-left>", motionWordBackward, IS_NOT_LINEWISE);
3423  ADDMOTION("b", motionWordBackward, 0 );
3424  ADDMOTION("B", motionWORDBackward, 0 );
3425  ADDMOTION("e", motionToEndOfWord, 0 );
3426  ADDMOTION("E", motionToEndOfWORD, 0 );
3427  ADDMOTION("ge", motionToEndOfPrevWord, 0 );
3428  ADDMOTION("gE", motionToEndOfPrevWORD, 0 );
3429  ADDMOTION("|", motionToScreenColumn, 0 );
3430  ADDMOTION("%", motionToMatchingItem, IS_NOT_LINEWISE );
3431  ADDMOTION("`[a-zA-Z^><\\.\\[\\]]", motionToMark, REGEX_PATTERN );
3432  ADDMOTION("'[a-zA-Z^><]", motionToMarkLine, REGEX_PATTERN );
3433  ADDMOTION("[[", motionToPreviousBraceBlockStart, IS_NOT_LINEWISE );
3434  ADDMOTION("]]", motionToNextBraceBlockStart, IS_NOT_LINEWISE );
3435  ADDMOTION("[]", motionToPreviousBraceBlockEnd, IS_NOT_LINEWISE );
3436  ADDMOTION("][", motionToNextBraceBlockEnd, IS_NOT_LINEWISE );
3437  ADDMOTION("*", motionToNextOccurrence, 0 );
3438  ADDMOTION("#", motionToPrevOccurrence, 0 );
3439  ADDMOTION("H", motionToFirstLineOfWindow, 0 );
3440  ADDMOTION("M", motionToMiddleLineOfWindow, 0 );
3441  ADDMOTION("L", motionToLastLineOfWindow, 0 );
3442  ADDMOTION("gj", motionToNextVisualLine, 0 );
3443  ADDMOTION("gk", motionToPrevVisualLine, 0 );
3444  ADDMOTION("{", motionToBeforeParagraph, 0 );
3445  ADDMOTION("}", motionToAfterParagraph, 0 );
3446 
3447  // text objects
3448  ADDMOTION("iw", textObjectInnerWord, 0 );
3449  ADDMOTION("aw", textObjectAWord, IS_NOT_LINEWISE );
3450  ADDMOTION("iW", textObjectInnerWORD, 0 );
3451  ADDMOTION("aW", textObjectAWORD, IS_NOT_LINEWISE );
3452  ADDMOTION("i\"", textObjectInnerQuoteDouble, IS_NOT_LINEWISE );
3453  ADDMOTION("a\"", textObjectAQuoteDouble, IS_NOT_LINEWISE );
3454  ADDMOTION("i'", textObjectInnerQuoteSingle, IS_NOT_LINEWISE );
3455  ADDMOTION("a'", textObjectAQuoteSingle, IS_NOT_LINEWISE );
3456  ADDMOTION("i`", textObjectInnerBackQuote, IS_NOT_LINEWISE );
3457  ADDMOTION("a`", textObjectABackQuote, IS_NOT_LINEWISE );
3458  ADDMOTION("i[()b]", textObjectInnerParen, REGEX_PATTERN | IS_NOT_LINEWISE);
3459  ADDMOTION("a[()b]", textObjectAParen, REGEX_PATTERN | IS_NOT_LINEWISE);
3460  ADDMOTION("i[{}B]", textObjectInnerCurlyBracket, REGEX_PATTERN | IS_NOT_LINEWISE);
3461  ADDMOTION("a[{}B]", textObjectACurlyBracket, REGEX_PATTERN | IS_NOT_LINEWISE);
3462  ADDMOTION("i[><]", textObjectInnerInequalitySign, REGEX_PATTERN | IS_NOT_LINEWISE);
3463  ADDMOTION("a[><]", textObjectAInequalitySign, REGEX_PATTERN | IS_NOT_LINEWISE);
3464  ADDMOTION("i[\\[\\]]", textObjectInnerBracket, REGEX_PATTERN | IS_NOT_LINEWISE);
3465  ADDMOTION("a[\\[\\]]", textObjectABracket, REGEX_PATTERN | IS_NOT_LINEWISE);
3466  ADDMOTION("i,", textObjectInnerComma, IS_NOT_LINEWISE );
3467  ADDMOTION("a,", textObjectAComma, IS_NOT_LINEWISE);
3468 
3469  ADDMOTION("/<enter>", motionToIncrementalSearchMatch, IS_NOT_LINEWISE);
3470  ADDMOTION("?<enter>", motionToIncrementalSearchMatch, IS_NOT_LINEWISE);
3471 }
3472 
3473 QRegExp KateViNormalMode::generateMatchingItemRegex()
3474 {
3475  QString pattern("\\[|\\]|\\{|\\}|\\(|\\)|");
3476  QList<QString> keys = m_matchingItems.keys();
3477 
3478  for ( int i = 0; i < keys.size(); i++ ) {
3479  QString s = m_matchingItems[ keys[ i ] ];
3480  s = s.replace( QRegExp( "^-" ), QChar() );
3481  s = s.replace( QRegExp( "\\*" ), "\\*" );
3482  s = s.replace( QRegExp( "\\+" ), "\\+" );
3483  s = s.replace( QRegExp( "\\[" ), "\\[" );
3484  s = s.replace( QRegExp( "\\]" ), "\\]" );
3485  s = s.replace( QRegExp( "\\(" ), "\\(" );
3486  s = s.replace( QRegExp( "\\)" ), "\\)" );
3487  s = s.replace( QRegExp( "\\{" ), "\\{" );
3488  s = s.replace( QRegExp( "\\}" ), "\\}" );
3489 
3490  pattern.append( s );
3491 
3492  if ( i != keys.size()-1 ) {
3493  pattern.append( '|' );
3494  }
3495  }
3496 
3497  return QRegExp( pattern );
3498 }
3499 
3500 // returns the operation mode that should be used. this is decided by using the following heuristic:
3501 // 1. if we're in visual block mode, it should be Block
3502 // 2. if we're in visual line mode OR the range spans several lines, it should be LineWise
3503 // 3. if neither of these is true, CharWise is returned
3504 // 4. there are some motion that makes all operator charwise, if we have one of them mode will be CharWise
3505 OperationMode KateViNormalMode::getOperationMode() const
3506 {
3507  OperationMode m = CharWise;
3508 
3509  if ( m_viInputModeManager->getCurrentViMode() == VisualBlockMode ) {
3510  m = Block;
3511  } else if ( m_viInputModeManager->getCurrentViMode() == VisualLineMode
3512  || ( m_commandRange.startLine != m_commandRange.endLine
3513  && m_viInputModeManager->getCurrentViMode() != VisualMode )) {
3514  m = LineWise;
3515  }
3516 
3517  if ( m_commandWithMotion && !m_linewiseCommand )
3518  m = CharWise;
3519 
3520  if (m_lastMotionWasLinewiseInnerBlock)
3521  m = LineWise;
3522 
3523  return m;
3524 }
3525 
3526 bool KateViNormalMode::paste(PasteLocation pasteLocation, bool isgPaste, bool isIndentedPaste)
3527 {
3528  Cursor pasteAt( m_view->cursorPosition() );
3529  Cursor cursorAfterPaste = pasteAt;
3530  QChar reg = getChosenRegister( m_defaultRegister );
3531 
3532  OperationMode m = getRegisterFlag( reg );
3533  QString textToInsert = getRegisterContent( reg );
3534  const bool isTextMultiLine = textToInsert.split("\n").count() > 1;
3535 
3536  // In temporary normal mode, p/P act as gp/gP.
3537  isgPaste |= m_viInputModeManager->getTemporaryNormalMode();
3538 
3539  if ( textToInsert.isEmpty() ) {
3540  error(i18n("Nothing in register %1", reg ));
3541  return false;
3542  }
3543 
3544  if ( getCount() > 1 ) {
3545  textToInsert = textToInsert.repeated( getCount() ); // FIXME: does this make sense for blocks?
3546  }
3547 
3548 
3549  if ( m == LineWise ) {
3550  pasteAt.setColumn( 0 );
3551  if (isIndentedPaste)
3552  {
3553  // Note that this does indeed work if there is no non-whitespace on the current line or if
3554  // the line is empty!
3555  const QString leadingWhiteSpaceOnCurrentLine = doc()->line(pasteAt.line()).mid(0, doc()->line(pasteAt.line()).indexOf(QRegExp("[^\\s]")));
3556  const QString leadingWhiteSpaceOnFirstPastedLine = textToInsert.mid(0, textToInsert.indexOf(QRegExp("[^\\s]")));
3557  // QString has no "left trim" method, bizarrely.
3558  while (textToInsert[0].isSpace())
3559  {
3560  textToInsert = textToInsert.mid(1);
3561  }
3562  textToInsert.prepend(leadingWhiteSpaceOnCurrentLine);
3563  // Remove the last \n, temporarily: we're going to alter the indentation of each pasted line
3564  // by doing a search and replace on '\n's, but don't want to alter this one.
3565  textToInsert.chop( 1 );
3566  textToInsert.replace(QString('\n') + leadingWhiteSpaceOnFirstPastedLine, QString('\n') + leadingWhiteSpaceOnCurrentLine);
3567  textToInsert.append('\n'); // Re-add the temporarily removed last '\n'.
3568  }
3569  if (pasteLocation == AfterCurrentPosition)
3570  {
3571  textToInsert.chop( 1 ); // remove the last \n
3572  pasteAt.setColumn( doc()->lineLength( pasteAt.line() ) ); // paste after the current line and ...
3573  textToInsert.prepend( QChar( '\n' ) ); // ... prepend a \n, so the text starts on a new line
3574 
3575  cursorAfterPaste.setLine( cursorAfterPaste.line()+1 );
3576  }
3577  if (isgPaste)
3578  {
3579  cursorAfterPaste.setLine(cursorAfterPaste.line() + textToInsert.split("\n").length() - 1);
3580  }
3581  } else {
3582  if (pasteLocation == AfterCurrentPosition)
3583  {
3584  // Move cursor forward one before we paste. The position after the paste must also
3585  // be updated accordingly.
3586  if ( getLine( pasteAt.line() ).length() > 0 ) {
3587  pasteAt.setColumn( pasteAt.column()+1 );
3588  }
3589  cursorAfterPaste = pasteAt;
3590  }
3591  const bool leaveCursorAtStartOfPaste = isTextMultiLine && !isgPaste;
3592  if (!leaveCursorAtStartOfPaste)
3593  {
3594  cursorAfterPaste = cursorPosAtEndOfPaste(pasteAt, textToInsert);
3595  if (!isgPaste)
3596  {
3597  cursorAfterPaste.setColumn(cursorAfterPaste.column() - 1);
3598  }
3599  }
3600  }
3601 
3602  doc()->editBegin();
3603  if (m_view->selection())
3604  {
3605  pasteAt = m_view->selectionRange().start();
3606  doc()->removeText(m_view->selectionRange());
3607  }
3608  doc()->insertText( pasteAt, textToInsert, m == Block );
3609  doc()->editEnd();
3610 
3611  if (cursorAfterPaste.line() >= doc()->lines())
3612  {
3613  cursorAfterPaste.setLine(doc()->lines() - 1);
3614  }
3615  updateCursor( cursorAfterPaste );
3616 
3617  return true;
3618 }
3619 
3620 Cursor KateViNormalMode::cursorPosAtEndOfPaste(const Cursor& pasteLocation, const QString& pastedText)
3621 {
3622  Cursor cAfter = pasteLocation;
3623  const QStringList textLines = pastedText.split("\n");
3624  if (textLines.length() == 1)
3625  {
3626  cAfter.setColumn(cAfter.column() + pastedText.length());
3627  }
3628  else
3629  {
3630  cAfter.setColumn(textLines.last().length() - 0);
3631  cAfter.setLine(cAfter.line() + textLines.length() - 1);
3632  }
3633  return cAfter;
3634 }
3635 
3636 void KateViNormalMode::joinLines(unsigned int from, unsigned int to) const
3637 {
3638  // make sure we don't try to join lines past the document end
3639  if ( to >= (unsigned int)(doc()->lines()) ) {
3640  to = doc()->lines()-1;
3641  }
3642 
3643  // joining one line is a no-op
3644  if ( from == to ) return;
3645 
3646  doc()->joinLines( from, to );
3647 }
3648 
3649 void KateViNormalMode::reformatLines(unsigned int from, unsigned int to) const
3650 {
3651  joinLines( from, to );
3652  doc()->wrapText( from, to );
3653 }
3654 
3655 // Tries to shrinks toShrink so that it fits tightly around rangeToShrinkTo.
3656 void KateViNormalMode::shrinkRangeAroundCursor(KateViRange& toShrink, const KateViRange& rangeToShrinkTo)
3657 {
3658  if (!toShrink.valid || !rangeToShrinkTo.valid)
3659  {
3660  return;
3661  }
3662  Cursor cursorPos = m_view->cursorPosition();
3663  if (rangeToShrinkTo.startLine >= cursorPos.line())
3664  {
3665  if (rangeToShrinkTo.startLine > cursorPos.line())
3666  {
3667  // Does not surround cursor; aborting.
3668  return;
3669  }
3670  Q_ASSERT(rangeToShrinkTo.startLine == cursorPos.line());
3671  if (rangeToShrinkTo.startColumn > cursorPos.column())
3672  {
3673  // Does not surround cursor; aborting.
3674  return;
3675  }
3676  }
3677  if (rangeToShrinkTo.endLine <= cursorPos.line())
3678  {
3679  if (rangeToShrinkTo.endLine < cursorPos.line())
3680  {
3681  // Does not surround cursor; aborting.
3682  return;
3683  }
3684  Q_ASSERT(rangeToShrinkTo.endLine == cursorPos.line());
3685  if (rangeToShrinkTo.endColumn < cursorPos.column())
3686  {
3687  // Does not surround cursor; aborting.
3688  return;
3689  }
3690  }
3691 
3692  if (toShrink.startLine <= rangeToShrinkTo.startLine)
3693  {
3694  if (toShrink.startLine < rangeToShrinkTo.startLine)
3695  {
3696  toShrink.startLine = rangeToShrinkTo.startLine;
3697  toShrink.startColumn = rangeToShrinkTo.startColumn;
3698  }
3699  Q_ASSERT(toShrink.startLine == rangeToShrinkTo.startLine);
3700  if (toShrink.startColumn < rangeToShrinkTo.startColumn)
3701  {
3702  toShrink.startColumn = rangeToShrinkTo.startColumn;
3703  }
3704  }
3705  if (toShrink.endLine >= rangeToShrinkTo.endLine)
3706  {
3707  if (toShrink.endLine > rangeToShrinkTo.endLine)
3708  {
3709  toShrink.endLine = rangeToShrinkTo.endLine;
3710  toShrink.endColumn = rangeToShrinkTo.endColumn;
3711  }
3712  Q_ASSERT(toShrink.endLine == rangeToShrinkTo.endLine);
3713  if (toShrink.endColumn > rangeToShrinkTo.endColumn)
3714  {
3715  toShrink.endColumn = rangeToShrinkTo.endColumn;
3716  }
3717  }
3718 }
3719 
3720 KateViRange KateViNormalMode::textObjectComma(bool inner)
3721 {
3722  // Basic algorithm: look left and right of the cursor for all combinations
3723  // of enclosing commas and the various types of brackets, and pick the pair
3724  // closest to the cursor that surrounds the cursor.
3725  KateViRange r(0, 0, m_view->doc()->lines(), m_view->doc()->line(m_view->doc()->lastLine()).length(), ViMotion::InclusiveMotion);
3726 
3727  shrinkRangeAroundCursor(r, findSurroundingQuotes( ',', inner ));
3728  shrinkRangeAroundCursor(r, findSurroundingBrackets( '(', ')', inner, '(', ')' ));
3729  shrinkRangeAroundCursor(r, findSurroundingBrackets( '{', '}', inner, '{', '}' ));
3730  shrinkRangeAroundCursor(r, findSurroundingBrackets( ',', ')', inner, '(', ')' ));
3731  shrinkRangeAroundCursor(r, findSurroundingBrackets( ',', ']', inner, '[', ']' ));
3732  shrinkRangeAroundCursor(r, findSurroundingBrackets( ',', '}', inner, '{', '}' ));
3733  shrinkRangeAroundCursor(r, findSurroundingBrackets( '(', ',', inner, '(', ')' ));
3734  shrinkRangeAroundCursor(r, findSurroundingBrackets( '[', ',', inner, '[', ']' ));
3735  shrinkRangeAroundCursor(r, findSurroundingBrackets( '{', ',', inner, '{', '}' ));
3736  return r;
3737 }
3738 
3739 void KateViNormalMode::updateYankHighlightAttrib()
3740 {
3741  if (!m_highlightYankAttribute)
3742  {
3743  m_highlightYankAttribute = new KTextEditor::Attribute;
3744  }
3745  const QColor& yankedColor = m_view->renderer()->config()->savedLineColor();
3746  m_highlightYankAttribute->setBackground(yankedColor);
3747  KTextEditor::Attribute::Ptr mouseInAttribute(new KTextEditor::Attribute());
3748  mouseInAttribute->setFontBold(true);
3749  m_highlightYankAttribute->setDynamicAttribute (KTextEditor::Attribute::ActivateMouseIn, mouseInAttribute);
3750  m_highlightYankAttribute->dynamicAttribute (KTextEditor::Attribute::ActivateMouseIn)->setBackground(yankedColor);
3751 }
3752 
3753 void KateViNormalMode::highlightYank(const KateViRange& range)
3754 {
3755  clearYankHighlight();
3756  KTextEditor::MovingRange*& pHighlightedYank = highlightedYankForDocument();
3757  Range yankRange(range.startLine, range.startColumn, range.endLine, range.endColumn);
3758  pHighlightedYank = m_view->doc()->newMovingRange(yankRange, Kate::TextRange::DoNotExpand);
3759  pHighlightedYank->setView(m_view); // show only in this view
3760  pHighlightedYank->setAttributeOnlyForViews(true);
3761  // use z depth defined in moving ranges interface
3762  pHighlightedYank->setZDepth (-10000.0);
3763  pHighlightedYank->setAttribute(m_highlightYankAttribute);
3764 }
3765 
3766 
3767 void KateViNormalMode::clearYankHighlight()
3768 {
3769  KTextEditor::MovingRange*& pHighlightedYank = highlightedYankForDocument();
3770  delete pHighlightedYank;
3771  pHighlightedYank = 0;
3772 }
3773 
3774 void KateViNormalMode::aboutToDeleteMovingInterfaceContent()
3775 {
3776  KTextEditor::MovingRange*& pHighlightedYank = highlightedYankForDocument();
3777  // Prevent double-deletion in case this KateViNormalMode is deleted.
3778  pHighlightedYank = 0;
3779 }
3780 
3781 KTextEditor::MovingRange*& KateViNormalMode::highlightedYankForDocument()
3782 {
3783  // Work around the fact that both Normal and Visual mode will have their own m_highlightedYank -
3784  // make Normal's the canonical one.
3785  return m_viInputModeManager->getViNormalMode()->m_highlightedYank;
3786 }
3787 
3788 bool KateViNormalMode::waitingForRegisterOrCharToSearch()
3789 {
3790  const QChar lastChar = m_keys.isEmpty() ? QChar::Null : m_keys.at(m_keys.size() - 1);
3791  return m_keys.size() > 0 && (lastChar == 'f' || lastChar == 't' || lastChar == 'F' || lastChar == 'T' || lastChar == 'r');
3792 }
3793 
3794 void KateViNormalMode::textInserted(KTextEditor::Document* document, Range range)
3795 {
3796  Q_UNUSED(document);
3797  const bool isInsertMode = m_viInputModeManager->getCurrentViMode() == InsertMode;
3798  const bool continuesInsertion = range.start().line() == m_currentChangeEndMarker.line() && range.start().column() == m_currentChangeEndMarker.column();
3799  const bool beginsWithNewline = doc()->text(range)[0] == '\n';
3800  if (!continuesInsertion)
3801  {
3802  Cursor newBeginMarkerPos = range.start();
3803  if (beginsWithNewline && !isInsertMode)
3804  {
3805  // Presumably a linewise paste, in which case we ignore the leading '\n'
3806  newBeginMarkerPos = Cursor(newBeginMarkerPos.line() + 1, 0);
3807  }
3808  m_viInputModeManager->addMark(doc(), '[', newBeginMarkerPos, false);
3809  }
3810  m_viInputModeManager->addMark(doc(), '.', range.start());
3811  Cursor editEndMarker = range.end();
3812  if (!isInsertMode)
3813  {
3814  editEndMarker.setColumn(editEndMarker.column() - 1);
3815  }
3816  m_viInputModeManager->addMark(doc(), ']', editEndMarker);
3817  m_currentChangeEndMarker = range.end();
3818  if (m_isUndo)
3819  {
3820  const bool addsMultipleLines = range.start().line() != range.end().line();
3821  m_viInputModeManager->addMark(doc(), '[', Cursor(m_viInputModeManager->getMarkPosition('[').line(), 0));
3822  if (addsMultipleLines)
3823  {
3824  m_viInputModeManager->addMark(doc(), ']', Cursor(m_viInputModeManager->getMarkPosition(']').line() + 1, 0));
3825  m_viInputModeManager->addMark(doc(), '.', Cursor(m_viInputModeManager->getMarkPosition('.').line() + 1, 0));
3826  }
3827  else
3828  {
3829  m_viInputModeManager->addMark(doc(), ']', Cursor(m_viInputModeManager->getMarkPosition(']').line(), 0));
3830  m_viInputModeManager->addMark(doc(), '.', Cursor(m_viInputModeManager->getMarkPosition('.').line(), 0));
3831  }
3832  }
3833 }
3834 
3835 void KateViNormalMode::textRemoved(KTextEditor::Document* document , Range range)
3836 {
3837  Q_UNUSED(document);
3838  const bool isInsertMode = m_viInputModeManager->getCurrentViMode() == InsertMode;
3839  m_viInputModeManager->addMark(doc(), '.', range.start());
3840  if (!isInsertMode)
3841  {
3842  // Don't go resetting [ just because we did a Ctrl-h!
3843  m_viInputModeManager->addMark(doc(), '[', range.start());
3844  }
3845  else
3846  {
3847  // Don't go disrupting our continued insertion just because we did a Ctrl-h!
3848  m_currentChangeEndMarker = range.start();
3849  }
3850  m_viInputModeManager->addMark(doc(), ']', range.start());
3851  if (m_isUndo)
3852  {
3853  // Slavishly follow Vim's weird rules: if an undo removes several lines, then all markers should
3854  // be at the beginning of the line after the last line removed, else they should at the beginning
3855  // of the line above that.
3856  const int markerLineAdjustment = (range.start().line() != range.end().line()) ? 1 : 0;
3857  m_viInputModeManager->addMark(doc(), '[', Cursor(m_viInputModeManager->getMarkPosition('[').line() + markerLineAdjustment, 0));
3858  m_viInputModeManager->addMark(doc(), ']', Cursor(m_viInputModeManager->getMarkPosition(']').line() + markerLineAdjustment, 0));
3859  m_viInputModeManager->addMark(doc(), '.', Cursor(m_viInputModeManager->getMarkPosition('.').line() + markerLineAdjustment, 0));
3860  }
3861 }
3862 
3863 void KateViNormalMode::undoBeginning()
3864 {
3865  m_isUndo = true;
3866 }
3867 
3868 void KateViNormalMode::undoEnded()
3869 {
3870  m_isUndo = false;
3871 }
3872 
katevinormalmode.h
KateDocument::line
virtual QString line(int line) const
Definition: katedocument.cpp:447
KateViNormalMode::motionToLineLast
KateViRange motionToLineLast()
Definition: katevinormalmode.cpp:2455
KateDocument::align
void align(KateView *view, const KTextEditor::Range &range)
Definition: katedocument.cpp:2908
KateViRange::endLine
int endLine
Definition: katevirange.h:44
QColor
KateViNormalMode::motionLeft
KateViRange motionLeft()
Definition: katevinormalmode.cpp:1892
KateViNormalMode::commandFormatLines
bool commandFormatLines()
Definition: katevinormalmode.cpp:1799
KateDocument::insertLine
virtual bool insertLine(int line, const QString &s)
Definition: katedocument.cpp:701
InsertMode
Definition: kateviinputmodemanager.h:50
KTextEditor::Range::start
Cursor & start()
KateViInputModeManager::replayMacro
void replayMacro(QChar macroRegister)
Definition: kateviinputmodemanager.cpp:345
KateViInputModeManager::finishRecordingMacro
void finishRecordingMacro()
Definition: kateviinputmodemanager.cpp:333
KateViRange::jump
bool jump
Definition: katevirange.h:47
KSharedPtr< Attribute >
KateViNormalMode::commandEnterInsertModeAppendEOL
bool commandEnterInsertModeAppendEOL()
start insert mode after the last character of the line
Definition: katevinormalmode.cpp:596
KateViNormalMode::commandEnterInsertModeAppend
bool commandEnterInsertModeAppend()
enter insert mode after the current character
Definition: katevinormalmode.cpp:570
KateViNormalMode::commandSetMark
bool commandSetMark()
Definition: katevinormalmode.cpp:1492
KateViNormalMode::paste
bool paste(KateViNormalMode::PasteLocation pasteLocation, bool isgPaste, bool isIndentedPaste)
Definition: katevinormalmode.cpp:3526
KateViModeBase::findWORDEnd
Cursor findWORDEnd(int fromLine, int fromColumn, bool onlyCurrentLine=false) const
Definition: katevimodebase.cpp:650
kateviemulatedcommandbar.h
Kate::Script::i18n
QScriptValue i18n(QScriptContext *context, QScriptEngine *engine)
i18n("text", arguments [optional])
Definition: katescripthelpers.cpp:186
KateViInputModeManager::getTemporaryNormalMode
bool getTemporaryNormalMode()
Definition: kateviinputmodemanager.h:229
KateViModeBase::findPrevWORDStart
Cursor findPrevWORDStart(int fromLine, int fromColumn, bool onlyCurrentLine=false) const
Definition: katevimodebase.cpp:562
KateRenderer::Block
Definition: katerenderer.h:71
KateViNormalMode::PasteLocation
PasteLocation
Definition: katevinormalmode.h:287
KateViNormalMode::commandAlignLine
bool commandAlignLine()
Definition: katevinormalmode.cpp:1645
Left
KateViModeBase::getRegisterFlag
OperationMode getRegisterFlag(const QChar &reg) const
Definition: katevimodebase.cpp:963
KateDocument::newMovingRange
virtual KTextEditor::MovingRange * newMovingRange(const KTextEditor::Range &range, KTextEditor::MovingRange::InsertBehaviors insertBehaviors=KTextEditor::MovingRange::DoNotExpand, KTextEditor::MovingRange::EmptyBehavior emptyBehavior=KTextEditor::MovingRange::AllowEmpty)
Create a new moving range for this document.
Definition: katedocument.cpp:4742
KateViNormalMode::reformatLines
void reformatLines(unsigned int from, unsigned int to) const
Definition: katevinormalmode.cpp:3649
KateViRange::normalize
void normalize()
Definition: katevirange.cpp:53
KateViNormalMode::initializeCommands
void initializeCommands()
Definition: katevinormalmode.cpp:3288
CharWise
Definition: katevimodebase.h:50
KateViModeBase::findSurroundingQuotes
KateViRange findSurroundingQuotes(const QChar &c, bool inner=false) const
Definition: katevimodebase.cpp:702
KateView::renderer
KateRenderer * renderer()
Definition: kateview.cpp:1653
KateViNormalMode::m_commandShouldKeepSelection
bool m_commandShouldKeepSelection
Definition: katevinormalmode.h:318
KateViNormalMode::commandPrintCharacterCode
bool commandPrintCharacterCode()
Definition: katevinormalmode.cpp:1609
KateViNormalMode::commandAbort
bool commandAbort()
Definition: katevinormalmode.cpp:1602
KTextEditor::Attribute::ActivateMouseIn
KateViNormalMode::motionToEndOfWORD
KateViRange motionToEndOfWORD()
Definition: katevinormalmode.cpp:2095
KateViNormalMode::commandUndo
bool commandUndo()
Definition: katevinormalmode.cpp:1480
KTextEditor::Attribute
KateViNormalMode::reset
virtual void reset()
Definition: katevinormalmode.cpp:478
katevivisualmode.h
KateDocument::editBegin
void editBegin()
Alias for editStart()
Definition: katedocument.h:213
KateViNormalMode::motionToNextBraceBlockEnd
KateViRange motionToNextBraceBlockEnd()
Definition: katevinormalmode.cpp:2705
KateViModeBase::getWordUnderCursor
const QString getWordUnderCursor() const
Definition: katevimodebase.cpp:146
KateViNormalMode::motionToIncrementalSearchMatch
KateViRange motionToIncrementalSearchMatch()
Definition: katevinormalmode.cpp:2915
KateViModeBase::getCharUnderCursor
const QChar getCharUnderCursor() const
Definition: katevimodebase.cpp:133
KateViNormalMode::motionToNextBraceBlockStart
KateViRange motionToNextBraceBlockStart()
Definition: katevinormalmode.cpp:2649
KateViNormalMode::m_motionOperatorIndex
int m_motionOperatorIndex
Definition: katevinormalmode.h:306
KateViInputModeManager::addMark
void addMark(KateDocument *doc, const QChar &mark, const KTextEditor::Cursor &pos, const bool moveoninsert=true, const bool showmark=true)
Add a mark to the document.
Definition: kateviinputmodemanager.cpp:725
Right
KateDocument::redo
void redo()
Definition: katedocument.cpp:1380
KateViNormalMode::commandIndentLine
bool commandIndentLine()
Definition: katevinormalmode.cpp:1502
KateViNormalMode::m_positionWhenIncrementalSearchBegan
Cursor m_positionWhenIncrementalSearchBegan
Definition: katevinormalmode.h:347
KateViNormalMode::commandMakeUppercase
bool commandMakeUppercase()
Definition: katevinormalmode.cpp:863
KateViNormalMode::highlightedYankForDocument
KTextEditor::MovingRange *& highlightedYankForDocument()
Definition: katevinormalmode.cpp:3781
KateViModeBase::m_currentMotionWasVisualLineUpOrDown
bool m_currentMotionWasVisualLineUpOrDown
Definition: katevimodebase.h:170
KateViNormalMode::m_matchingCommands
QVector< int > m_matchingCommands
Definition: katevinormalmode.h:303
KateViModeBase::doc
KateDocument * doc() const
Definition: katevimodebase.h:172
KateViNormalMode::commandEnterVisualLineMode
bool commandEnterVisualLineMode()
Definition: katevinormalmode.cpp:638
KateView::setCaretStyle
void setCaretStyle(KateRenderer::caretStyles style, bool repaint=false)
Set the caret's style.
Definition: kateview.cpp:2388
KateDocument::lineLength
virtual int lineLength(int line) const
Definition: katedocument.cpp:758
KateViNormalMode::motionToEOL
KateViRange motionToEOL()
Definition: katevinormalmode.cpp:2170
KateViNormalMode::commandScrollHalfPageDown
bool commandScrollHalfPageDown()
Definition: katevinormalmode.cpp:1583
KateViNormalMode::commandEnterVisualMode
bool commandEnterVisualMode()
Definition: katevinormalmode.cpp:693
KateCommandLineBar::setText
void setText(const QString &text, bool selected=true)
Definition: kateviewhelpers.cpp:839
KateViNormalMode::waitingForRegisterOrCharToSearch
bool waitingForRegisterOrCharToSearch()
Definition: katevinormalmode.cpp:3788
KateViNormalMode::commandJoinLines
bool commandJoinLines()
Definition: katevinormalmode.cpp:1051
KateViNormalMode::motionWORDForward
KateViRange motionWORDForward()
Definition: katevinormalmode.cpp:2034
KateViModeBase::m_count
unsigned int m_count
Definition: katevimodebase.h:161
KateViNormalMode::generateMatchingItemRegex
QRegExp generateMatchingItemRegex()
Definition: katevinormalmode.cpp:3473
Kate::TextFolding::visibleLineToLine
int visibleLineToLine(int visibleLine) const
Convert a visible line number to a line number in the text buffer.
Definition: katetextfolding.cpp:422
KateViNormalMode::motionToMarkLine
KateViRange motionToMarkLine()
Definition: katevinormalmode.cpp:2515
KateViModeBase
Definition: katevimodebase.h:64
VisualMode
Definition: kateviinputmodemanager.h:51
KateViInputModeManager::setLastSearchBackwards
void setLastSearchBackwards(bool b)
set search direction of last search.
Definition: kateviinputmodemanager.h:219
KateViewInternal::pageUp
void pageUp(bool sel=false, bool half=false)
Definition: kateviewinternal.cpp:1513
KateViInputModeManager
Definition: kateviinputmodemanager.h:68
KateViNormalMode::textObjectAWord
KateViRange textObjectAWord()
Definition: katevinormalmode.cpp:2927
KateViNormalMode::executeCommand
void executeCommand(const KateViCommand *cmd)
Definition: katevinormalmode.cpp:510
KateViEmulatedCommandBar::Command
Definition: kateviemulatedcommandbar.h:44
KateViNormalMode::motionToBeforeParagraph
KateViRange motionToBeforeParagraph()
Definition: katevinormalmode.cpp:2856
KateView::showViModeEmulatedCommandBar
void showViModeEmulatedCommandBar()
Definition: kateview.cpp:1540
KateViNormalMode::commandEnterReplaceMode
bool commandEnterReplaceMode()
Definition: katevinormalmode.cpp:715
KateViNormalMode::textObjectAWORD
KateViRange textObjectAWORD()
Definition: katevinormalmode.cpp:3039
KateViNormalMode::textObjectAComma
KateViRange textObjectAComma()
Definition: katevinormalmode.cpp:3276
KateViInputModeManager::startRecordingMacro
void startRecordingMacro(QChar macroRegister)
Definition: kateviinputmodemanager.cpp:322
KateViNormalMode::textObjectInnerWORD
KateViRange textObjectInnerWORD()
Definition: katevinormalmode.cpp:3115
KateViRange::invalid
static KateViRange invalid()
Definition: katevirange.h:56
KateViKeyMapper::setDoNotMapNextKeypress
void setDoNotMapNextKeypress()
Definition: katevikeymapper.cpp:130
KateGlobal::self
static KateGlobal * self()
Kate Part Internal stuff ;)
Definition: kateglobal.cpp:462
KTextEditor::MovingRange
KateViNormalMode::m_pendingResetIsDueToExit
bool m_pendingResetIsDueToExit
Definition: katevinormalmode.h:335
KTextEditor::MovingRange::DoNotExpand
NormalMode
Definition: kateviinputmodemanager.h:49
QString
KateViKeyParser::KeyEventToQChar
const QChar KeyEventToQChar(const QKeyEvent &keyEvent)
Definition: katevikeyparser.cpp:661
KTextEditor::Range::setRange
virtual void setRange(const Range &range)
KateView::textFolding
Kate::TextFolding & textFolding()
Folding handler for this view.
Definition: kateview.h:574
KateView::setCursorPosition
bool setCursorPosition(KTextEditor::Cursor position)
Definition: kateview.cpp:2393
kDebug
static QDebug kDebug(bool cond, int area=KDE_DEFAULT_DEBUG_AREA)
KTextEditor::Cursor
KateViNormalMode::motionToLineFirst
KateViRange motionToLineFirst()
Definition: katevinormalmode.cpp:2442
KateViModeBase::m_commandRange
KateViRange m_commandRange
Definition: katevimodebase.h:160
KateViRange::startColumn
int startColumn
Definition: katevirange.h:41
KateViNormalMode::commandgPasteBefore
bool commandgPasteBefore()
Definition: katevinormalmode.cpp:1309
KateViNormalMode::motionToPrevVisualLine
KateViRange motionToPrevVisualLine()
Definition: katevinormalmode.cpp:2852
KateViNormalMode::commandReplayMacro
bool commandReplayMacro()
Definition: katevinormalmode.cpp:1821
KateDocument::indent
void indent(KTextEditor::Range range, int change)
Definition: katedocument.cpp:2898
KateViModeBase::getRange
const QString getRange(KateViRange &r, OperationMode mode=LineWise) const
Definition: katevimodebase.cpp:91
KateViNormalMode::m_commands
QVector< KateViCommand * > m_commands
Definition: katevinormalmode.h:301
KateViNormalMode::motionToFirstCharacterOfLine
KateViRange motionToFirstCharacterOfLine()
Definition: katevinormalmode.cpp:2195
KateViNormalMode::commandReplaceCharacter
bool commandReplaceCharacter()
Definition: katevinormalmode.cpp:1375
KateView::getViInputModeManager
KateViInputModeManager * getViInputModeManager()
Definition: kateview.cpp:1567
KateViNormalMode::commandRedo
bool commandRedo()
Definition: katevinormalmode.cpp:1486
KateViNormalMode::commandOpenNewLineOver
bool commandOpenNewLineOver()
Definition: katevinormalmode.cpp:1024
KateViNormalMode::commandCollapseLocal
bool commandCollapseLocal()
Definition: katevinormalmode.cpp:1839
KateViNormalMode::cursorPosAtEndOfPaste
Cursor cursorPosAtEndOfPaste(const Cursor &pasteLocation, const QString &pastedText)
Definition: katevinormalmode.cpp:3620
kateviewhelpers.h
KateViNormalMode::textObjectAInequalitySign
KateViRange textObjectAInequalitySign()
Definition: katevinormalmode.cpp:3264
KTextEditor::MovingRange::setAttributeOnlyForViews
virtual void setAttributeOnlyForViews(bool onlyForViews)=0
katebuffer.h
KateViModeBase::isCounted
bool isCounted()
Definition: katevimodebase.h:138
KateDocument::lastLine
int lastLine() const
gets the last line number (lines() - 1)
Definition: katedocument.h:691
KateViNormalMode::commandYankLine
bool commandYankLine()
Definition: katevinormalmode.cpp:1223
KateViNormalMode::motionPageDown
KateViRange motionPageDown()
Definition: katevinormalmode.cpp:1921
KateViNormalMode::commandToOtherEnd
bool commandToOtherEnd()
Definition: katevinormalmode.cpp:703
KateViVisualMode::goToPos
void goToPos(const Cursor &c)
Definition: katevivisualmode.cpp:249
KateViNormalMode::commandChangeToEOL
bool commandChangeToEOL()
Definition: katevinormalmode.cpp:1144
AppendEOL
Definition: kateviinsertmode.h:42
KateViModeBase::goLineUpDown
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
KateViModeBase::m_oneTimeCountOverride
int m_oneTimeCountOverride
Definition: katevimodebase.h:162
KateView::selectionRange
virtual const KTextEditor::Range & selectionRange() const
Definition: kateview.cpp:2760
kateviinputmodemanager.h
KateViNormalMode::motionPageUp
KateViRange motionPageUp()
Definition: katevinormalmode.cpp:1935
ADDCMD
#define ADDCMD(STR, FUNC, FLGS)
Definition: katevinormalmode.cpp:47
KateViNormalMode::m_keys
QString m_keys
Definition: katevinormalmode.h:297
KateViNormalMode::commandChangeCaseRange
bool commandChangeCaseRange()
Definition: katevinormalmode.cpp:984
KateViInputModeManager::addJump
void addJump(KTextEditor::Cursor cursor)
Definition: kateviinputmodemanager.cpp:656
KateViModeBase::goVisualLineUpDown
KateViRange goVisualLineUpDown(int lines)
Definition: katevimodebase.cpp:1057
KateViNormalMode::commandIndentedPaste
bool commandIndentedPaste()
Definition: katevinormalmode.cpp:1314
KateViInsertMode::setBlockPrependMode
void setBlockPrependMode(KateViRange blockRange)
Definition: kateviinsertmode.cpp:550
KateViNormalMode::commandAddToNumber
bool commandAddToNumber()
Definition: katevinormalmode.cpp:1668
KateDocument::replaceText
virtual bool replaceText(const KTextEditor::Range &range, const QString &s, bool block=false)
Definition: katedocument.cpp:4687
KateViNormalMode::commandDeleteToEOL
bool commandDeleteToEOL()
Definition: katevinormalmode.cpp:759
KateViModeBase::findPrevWORDEnd
Cursor findPrevWORDEnd(int fromLine, int fromColumn, bool onlyCurrentLine=false) const
Definition: katevimodebase.cpp:461
KateDocument::insertText
virtual bool insertText(const KTextEditor::Cursor &position, const QString &s, bool block=false)
Definition: katedocument.cpp:530
katevikeymapper.h
KateViNormalMode::motionToScreenColumn
KateViRange motionToScreenColumn()
Definition: katevinormalmode.cpp:2473
KateViNormalMode::motionDownToFirstNonBlank
KateViRange motionDownToFirstNonBlank()
Definition: katevinormalmode.cpp:1949
KateViNormalMode::motionToNextVisualLine
KateViRange motionToNextVisualLine()
Definition: katevinormalmode.cpp:2848
KateViModeBase::m_view
KateView * m_view
Definition: katevimodebase.h:172
KateViInputModeManager::getLastSearchPattern
const QString getLastSearchPattern() const
The current search pattern.
Definition: kateviinputmodemanager.cpp:421
KateViNormalMode::commandSwitchToRightView
bool commandSwitchToRightView()
Definition: katevinormalmode.cpp:1750
KateViNormalMode::commandScrollPageDown
bool commandScrollPageDown()
Definition: katevinormalmode.cpp:1553
KateViModeBase::fillRegister
void fillRegister(const QChar &reg, const QString &text, OperationMode flag=CharWise)
Definition: katevimodebase.cpp:968
KateViNormalMode::motionUp
KateViRange motionUp()
Definition: katevinormalmode.cpp:1887
KateViNormalMode::commandCollapseToplevelNodes
bool commandCollapseToplevelNodes()
Definition: katevinormalmode.cpp:1805
KateViNormalMode::commandEnterInsertModeLast
bool commandEnterInsertModeLast()
enter insert mode at the last insert position
Definition: katevinormalmode.cpp:627
KTextEditor::Cursor::isValid
virtual bool isValid() const
KateViNormalMode::commandSwitchToPrevTab
bool commandSwitchToPrevTab()
Definition: katevinormalmode.cpp:1780
KateRenderer::Underline
Definition: katerenderer.h:72
KateDocument::character
virtual QChar character(const KTextEditor::Cursor &position) const
Definition: katedocument.cpp:388
KateViRange
Definition: katevirange.h:33
KateDocument::wrapText
bool wrapText(int startLine, int endLine)
Remove a line.
Definition: katedocument.cpp:855
KateRenderer::config
KateRendererConfig * config() const
Configuration.
Definition: katerenderer.h:362
Up
Definition: katevimodebase.h:56
KateViRange::endColumn
int endColumn
Definition: katevirange.h:44
attribute.h
KateViModeBase::setCount
void setCount(unsigned int count)
Definition: katevimodebase.h:85
pattern
QString pattern(Mode mode=Reading)
KateViRange::motionType
ViMotion::MotionType motionType
Definition: katevirange.h:45
KateRenderer::Half
Definition: katerenderer.h:73
KateViNormalMode::beginMonitoringDocumentChanges
void beginMonitoringDocumentChanges()
Definition: katevinormalmode.cpp:485
KateViNormalMode::highlightYank
void highlightYank(const KateViRange &range)
Definition: katevinormalmode.cpp:3753
KateViNormalMode::motionToPreviousBraceBlockEnd
KateViRange motionToPreviousBraceBlockEnd()
Definition: katevinormalmode.cpp:2736
KateViEmulatedCommandBar::SearchBackward
Definition: kateviemulatedcommandbar.h:44
KTextEditor::Document
KateViNormalMode::textObjectInnerQuoteSingle
KateViRange textObjectInnerQuoteSingle()
Definition: katevinormalmode.cpp:3165
KateViNormalMode::textObjectComma
KateViRange textObjectComma(bool inner)
Definition: katevinormalmode.cpp:3720
KateViNormalMode::textObjectInnerQuoteDouble
KateViRange textObjectInnerQuoteDouble()
Definition: katevinormalmode.cpp:3155
KateViNormalMode::m_highlightedYank
KTextEditor::MovingRange * m_highlightedYank
Definition: katevinormalmode.h:338
kateglobal.h
KateViModeBase::getNextJump
KTextEditor::Cursor getNextJump(KTextEditor::Cursor)
Definition: katevimodebase.cpp:979
KateViModeBase::scrollViewLines
void scrollViewLines(int l)
Definition: katevimodebase.h:129
KateViNormalMode::motionToEndOfPrevWORD
KateViRange motionToEndOfPrevWORD()
Definition: katevinormalmode.cpp:2144
KateViNormalMode::commandEnterInsertModeBeforeFirstNonBlankInLine
bool commandEnterInsertModeBeforeFirstNonBlankInLine()
Definition: katevinormalmode.cpp:607
KateViNormalMode::m_lastMotionWasLinewiseInnerBlock
bool m_lastMotionWasLinewiseInnerBlock
Definition: katevinormalmode.h:315
QStringList
KateViewInternal
Definition: kateviewinternal.h:57
KateViModeBase::startReplaceMode
bool startReplaceMode()
Definition: katevimodebase.cpp:1201
KateViInputModeManager::keyMapper
KateViKeyMapper * keyMapper()
Definition: kateviinputmodemanager.cpp:893
KateViNormalMode::goToPos
virtual void goToPos(const KateViRange &r)
Definition: katevinormalmode.cpp:493
KateViModeBase::updateCursor
void updateCursor(const Cursor &c) const
Definition: katevimodebase.cpp:937
KateViInputModeManager::getMarkPosition
KTextEditor::Cursor getMarkPosition(const QChar &mark) const
Definition: kateviinputmodemanager.cpp:769
KateViInputModeManager::getViNormalMode
KateViNormalMode * getViNormalMode()
Definition: kateviinputmodemanager.cpp:534
KateDocument::lines
virtual int lines() const
Definition: katedocument.cpp:753
KateDocument::documentEnd
virtual KTextEditor::Cursor documentEnd() const
Definition: katedocument.cpp:4682
KateViNormalMode::m_isUndo
bool m_isUndo
Definition: katevinormalmode.h:345
KateView::cmdLineBar
KateCommandLineBar * cmdLineBar()
Definition: kateview.cpp:2941
KateViInputModeManager::setLastSearchPlacesCursorAtEndOfMatch
void setLastSearchPlacesCursorAtEndOfMatch(bool b)
Definition: kateviinputmodemanager.h:223
katecompletionwidget.h
KateViVisualMode
Definition: katevivisualmode.h:34
KateViModeBase::switchView
void switchView(Direction direction=Next)
Definition: katevimodebase.cpp:1426
KateViNormalMode::commandUnindentLines
bool commandUnindentLines()
Definition: katevinormalmode.cpp:1539
KateViEmulatedCommandBar::init
void init(Mode mode, const QString &initialText=QString())
Definition: kateviemulatedcommandbar.cpp:401
KTextEditor::MovingRange::setAttribute
virtual void setAttribute(Attribute::Ptr attribute)=0
KateViNormalMode::m_lastTFcommand
QString m_lastTFcommand
Definition: katevinormalmode.h:310
KateViNormalMode::commandYank
bool commandYank()
Definition: katevinormalmode.cpp:1204
KateViModeBase::goLineDown
KateViRange goLineDown()
Definition: katevimodebase.cpp:989
KateViNormalMode::commandScrollPageUp
bool commandScrollPageUp()
Definition: katevinormalmode.cpp:1563
KateViNormalMode::joinLines
void joinLines(unsigned int from, unsigned int to) const
Definition: katevinormalmode.cpp:3636
KateDocument::newLine
void newLine(KateView *view)
Definition: katedocument.cpp:2659
KateView::find
void find()
Definition: kateview.cpp:1577
KateViModeBase::linesDisplayed
unsigned int linesDisplayed()
Definition: katevimodebase.h:128
KateViNormalMode::motionToEndOfPrevWord
KateViRange motionToEndOfPrevWord()
Definition: katevinormalmode.cpp:2117
KateViNormalMode::commandPasteBefore
bool commandPasteBefore()
Definition: katevinormalmode.cpp:1292
Next
Definition: katevimodebase.h:60
KateViNormalMode::commandExpandAll
bool commandExpandAll()
Definition: katevinormalmode.cpp:1849
kateviinsertmode.h
KateViNormalMode::motionRepeatlastTFBackward
KateViRange motionRepeatlastTFBackward()
Definition: katevinormalmode.cpp:2379
KateViModeBase::startInsertMode
bool startInsertMode()
Definition: katevimodebase.cpp:1192
KateViModeBase::getLine
const QString getLine(int lineNumber=-1) const
Definition: katevimodebase.cpp:119
KateViNormalMode::AtCurrentPosition
Definition: katevinormalmode.h:287
KateViNormalMode::motionFindPrev
KateViRange motionFindPrev()
Definition: katevinormalmode.cpp:2403
KateViModeBase::m_iscounted
bool m_iscounted
Definition: katevimodebase.h:163
KateViModeBase::m_stickyColumn
int m_stickyColumn
Definition: katevimodebase.h:168
KateViNormalMode::handleKeypress
bool handleKeypress(const QKeyEvent *e)
parses a key stroke to check if it's a valid (part of) a command
Definition: katevinormalmode.cpp:109
KateView::selection
virtual bool selection() const
Definition: kateview.cpp:2008
KateViModeBase::findWordEnd
Cursor findWordEnd(int fromLine, int fromColumn, bool onlyCurrentLine=false) const
Definition: katevimodebase.cpp:609
KateViNormalMode::commandIndentedPasteBefore
bool commandIndentedPasteBefore()
Definition: katevinormalmode.cpp:1319
KateViNormalMode::motionToChar
KateViRange motionToChar()
Definition: katevinormalmode.cpp:2277
KateViVisualMode::setStart
void setStart(const Cursor &c)
Definition: katevivisualmode.h:52
KateViNormalMode::~KateViNormalMode
virtual ~KateViNormalMode()
Definition: katevinormalmode.cpp:98
KateView
Definition: kateview.h:78
KateView::align
void align()
Definition: kateview.cpp:2482
VisualBlockMode
Definition: kateviinputmodemanager.h:53
KateViModeBase::getCount
unsigned int getCount() const
Definition: katevimodebase.h:131
KTextEditor::Range
KateViModeBase::findNextWordStart
Cursor findNextWordStart(int fromLine, int fromColumn, bool onlyCurrentLine=false) const
Definition: katevimodebase.cpp:317
Kate::TextFolding::lineToVisibleLine
int lineToVisibleLine(int line) const
Convert a text buffer line to a visible line number.
Definition: katetextfolding.cpp:366
KateViModeBase::startVisualLineMode
bool startVisualLineMode()
Definition: katevimodebase.cpp:1241
KateViModeBase::message
void message(const QString &msg)
Definition: katevimodebase.cpp:1271
KateViNormalMode::commandChangeLine
bool commandChangeLine()
Definition: katevinormalmode.cpp:1156
LineWise
Definition: katevimodebase.h:51
KateViNormalMode::m_matchingMotions
QVector< int > m_matchingMotions
Definition: katevinormalmode.h:304
KateViNormalMode::motionWordForward
KateViRange motionWordForward()
Definition: katevinormalmode.cpp:1977
KateViModeBase::error
void error(const QString &errorMsg)
Definition: katevimodebase.cpp:1255
KateViNormalMode::commandSwitchToUpView
bool commandSwitchToUpView()
Definition: katevinormalmode.cpp:1745
KateViNormalMode::motionToNextOccurrence
KateViRange motionToNextOccurrence()
Definition: katevinormalmode.cpp:2760
KTextEditor::MovingRange::setView
virtual void setView(View *view)=0
KateViNormalMode::motionWORDBackward
KateViRange motionWORDBackward()
Definition: katevinormalmode.cpp:2056
KateViNormalMode::commandChangeCase
bool commandChangeCase()
Definition: katevinormalmode.cpp:910
KateDocument::setUndoMergeAllEdits
void setUndoMergeAllEdits(bool merge)
Definition: katedocument.cpp:4723
KateViewInternal::pageDown
void pageDown(bool sel=false, bool half=false)
Definition: kateviewinternal.cpp:1555
KateViNormalMode::m_isRepeatedTFcommand
bool m_isRepeatedTFcommand
Definition: katevinormalmode.h:311
KateViModeBase::startVisualBlockMode
bool startVisualBlockMode()
Definition: katevimodebase.cpp:1227
KateViewInternal::endLine
int endLine() const
Definition: kateviewinternal.cpp:301
Down
Definition: katevimodebase.h:57
KateViNormalMode::commandSwitchToCmdLine
bool commandSwitchToCmdLine()
Definition: katevinormalmode.cpp:1416
KateViNormalMode::m_motions
QVector< KateViMotion * > m_motions
Definition: katevinormalmode.h:302
KateViNormalMode::commandDeleteChar
bool commandDeleteChar()
Definition: katevinormalmode.cpp:1324
KateDocument::kateTextLine
Kate::TextLine kateTextLine(uint i)
Definition: katedocument.cpp:4707
KateViNormalMode::m_commandWithMotion
bool m_commandWithMotion
Definition: katevinormalmode.h:314
KateView::pageUp
void pageUp()
Definition: kateview.cpp:2710
VisualLineMode
Definition: kateviinputmodemanager.h:52
KateViNormalMode::motionToAfterParagraph
KateViRange motionToAfterParagraph()
Definition: katevinormalmode.cpp:2884
KateViNormalMode::motionToCharBackward
KateViRange motionToCharBackward()
Definition: katevinormalmode.cpp:2315
KateViNormalMode::motionToLastLineOfWindow
KateViRange motionToLastLineOfWindow()
Definition: katevinormalmode.cpp:2829
KateViModeBase::m_keysVerbatim
QString m_keysVerbatim
Definition: katevimodebase.h:166
KateViNormalMode::commandPrependToBlock
bool commandPrependToBlock()
Definition: katevinormalmode.cpp:1682
KateViNormalMode::motionDown
KateViRange motionDown()
Definition: katevinormalmode.cpp:1882
KateViNormalMode::KateViNormalMode
KateViNormalMode(KateViInputModeManager *viInputModeManager, KateView *view, KateViewInternal *viewInternal)
Definition: katevinormalmode.cpp:53
KateViNormalMode::commandSwitchToNextView
bool commandSwitchToNextView()
Definition: katevinormalmode.cpp:1755
KateView::cursorPosition
KTextEditor::Cursor cursorPosition() const
Definition: kateview.cpp:2398
KateViInputModeManager::lastSearchBackwards
bool lastSearchBackwards() const
get search direction of last search.
Definition: kateviinputmodemanager.h:214
KateViModeBase::findLineStartingWitchChar
int findLineStartingWitchChar(const QChar &c, unsigned int count, bool forward=true) const
Definition: katevimodebase.cpp:904
Append
Definition: kateviinsertmode.h:41
KateViNormalMode::m_awaitingMotionOrTextObject
QStack< int > m_awaitingMotionOrTextObject
Definition: katevinormalmode.h:305
ViMotion::ExclusiveMotion
Definition: katevirange.h:29
KateViNormalMode::commandReselectVisual
bool commandReselectVisual()
Definition: katevinormalmode.cpp:658
KTextEditor::Cursor::line
virtual int line() const
KateViNormalMode::commandSearchForward
bool commandSearchForward()
Definition: katevinormalmode.cpp:1465
KateViNormalMode::textObjectABracket
KateViRange textObjectABracket()
Definition: katevinormalmode.cpp:3193
KateViInputModeManager::storeLastChangeCommand
void storeLastChangeCommand()
copy the contents of the key events log to m_lastChange so that it can be repeated ...
Definition: kateviinputmodemanager.cpp:278
KateGlobal::viInputModeGlobal
KateViGlobal * viInputModeGlobal()
vi input mode global
Definition: kateglobal.h:338
KateViNormalMode::commandSwitchToNextTab
bool commandSwitchToNextTab()
Definition: katevinormalmode.cpp:1770
KateViNormalMode::motionToMiddleLineOfWindow
KateViRange motionToMiddleLineOfWindow()
Definition: katevinormalmode.cpp:2811
KateViNormalMode::motionWillBeUsedWithCommand
bool motionWillBeUsedWithCommand()
Definition: katevinormalmode.h:306
KateViNormalMode::commandExpandLocal
bool commandExpandLocal()
Definition: katevinormalmode.cpp:1857
KateViModeBase::goLineUp
KateViRange goLineUp()
Definition: katevimodebase.cpp:994
KateViNormalMode::commandMakeUppercaseLine
bool commandMakeUppercaseLine()
Definition: katevinormalmode.cpp:892
KateViModeBase::getChosenRegister
QChar getChosenRegister(const QChar &defaultReg) const
Definition: katevimodebase.cpp:945
KTextEditor::Cursor::setLine
virtual void setLine(int line)
KateViNormalMode::commandAlignLines
bool commandAlignLines()
Definition: katevinormalmode.cpp:1655
KateViCommand
KateViNormalMode::m_currentChangeEndMarker
Cursor m_currentChangeEndMarker
Definition: katevinormalmode.h:343
KateViModeBase::yankToClipBoard
void yankToClipBoard(QChar chosen_register, QString text)
Definition: katevimodebase.cpp:54
KateViNormalMode::commandScrollHalfPageUp
bool commandScrollHalfPageUp()
Definition: katevinormalmode.cpp:1573
KateViInputModeManager::lastSearchCaseSensitive
bool lastSearchCaseSensitive()
Definition: kateviinputmodemanager.h:225
KateView::viModeEmulatedCommandBar
KateViEmulatedCommandBar * viModeEmulatedCommandBar()
Definition: kateview.cpp:2989
KateViNormalMode::commandDelete
bool commandDelete()
Definition: katevinormalmode.cpp:753
KateVi::EOL
const unsigned int EOL
Definition: kateviglobal.h:41
KateViNormalMode::m_findWaitingForChar
bool m_findWaitingForChar
Definition: katevinormalmode.h:299
KateViNormalMode::commandgPaste
bool commandgPaste()
Definition: katevinormalmode.cpp:1302
KateDocument::editEnd
void editEnd()
End a editor operation.
Definition: katedocument.cpp:796
KateViModeBase::deleteRange
bool deleteRange(KateViRange &r, OperationMode mode=LineWise, bool addToRegister=true)
Definition: katevimodebase.cpp:61
KateViModeBase::getPrevJump
KTextEditor::Cursor getPrevJump(KTextEditor::Cursor)
Definition: katevimodebase.cpp:984
KTextEditor::Range::end
Cursor & end()
KateViNormalMode::commandSwitchToDownView
bool commandSwitchToDownView()
Definition: katevinormalmode.cpp:1740
KateView::switchToCmdLine
void switchToCmdLine()
Definition: kateview.cpp:1632
KateViModeBase::m_viInputModeManager
KateViInputModeManager * m_viInputModeManager
Definition: katevimodebase.h:177
KateRendererConfig::savedLineColor
const QColor & savedLineColor() const
Definition: kateconfig.cpp:2517
KateViNormalMode::textObjectInnerInequalitySign
KateViRange textObjectInnerInequalitySign()
Definition: katevinormalmode.cpp:3270
KateViEmulatedCommandBar::SearchForward
Definition: kateviemulatedcommandbar.h:44
KateViNormalMode::textObjectAQuoteDouble
KateViRange textObjectAQuoteDouble()
Definition: katevinormalmode.cpp:3150
KateViModeBase::m_extraWordCharacters
QString m_extraWordCharacters
Definition: katevimodebase.h:165
KateViInsertMode::setCountedRepeatsBeginOnNewLine
void setCountedRepeatsBeginOnNewLine(bool countedRepeatsBeginOnNewLine)
Definition: kateviinsertmode.h:80
KateViNormalMode::motionToColumn0
KateViRange motionToColumn0()
Definition: katevinormalmode.cpp:2186
KateViNormalMode::getOperationMode
OperationMode getOperationMode() const
Definition: katevinormalmode.cpp:3505
KateViNormalMode::textObjectInnerComma
KateViRange textObjectInnerComma()
Definition: katevinormalmode.cpp:3281
KateViNormalMode::textObjectAParen
KateViRange textObjectAParen()
Definition: katevinormalmode.cpp:3181
KTextEditor::MovingRange::setZDepth
virtual void setZDepth(qreal zDepth)=0
KateViNormalMode::commandSubtractFromNumber
bool commandSubtractFromNumber()
Definition: katevinormalmode.cpp:1675
OperationMode
OperationMode
Definition: katevimodebase.h:49
KateViInputModeManager::isReplayingLastChange
bool isReplayingLastChange() const
Definition: kateviinputmodemanager.h:153
KateViNormalMode::m_deleteCommand
bool m_deleteCommand
Definition: katevinormalmode.h:320
KateViInputModeManager::isRecordingMacro
bool isRecordingMacro()
Definition: kateviinputmodemanager.cpp:340
KateViNormalMode::m_motionCanChangeWholeVisualModeSelection
bool m_motionCanChangeWholeVisualModeSelection
Definition: katevinormalmode.h:316
KateViNormalMode::textObjectInnerParen
KateViRange textObjectInnerParen()
Definition: katevinormalmode.cpp:3187
KateViNormalMode::AfterCurrentPosition
Definition: katevinormalmode.h:287
KateViNormalMode::commandEnterInsertMode
bool commandEnterInsertMode()
enter insert mode at the cursor position
Definition: katevinormalmode.cpp:559
KateViInputModeManager::setLastSearchPattern
void setLastSearchPattern(const QString &p)
Set the current search pattern.
Definition: kateviinputmodemanager.cpp:433
KateViNormalMode::commandFormatLine
bool commandFormatLine()
Definition: katevinormalmode.cpp:1790
KateDocument::text
virtual QString text(const KTextEditor::Range &range, bool blockwise=false) const
Definition: katedocument.cpp:337
KateViNormalMode::m_linewiseCommand
bool m_linewiseCommand
Definition: katevinormalmode.h:313
KateViModeBase::m_lastMotionWasVisualLineUpOrDown
bool m_lastMotionWasVisualLineUpOrDown
Definition: katevimodebase.h:169
KateViNormalMode::commandGoToNextJump
bool commandGoToNextJump()
Definition: katevinormalmode.cpp:1721
KateViInputModeManager::clearCurrentChangeLog
void clearCurrentChangeLog()
clear the key event log
Definition: kateviinputmodemanager.h:163
KateViNormalMode::commandYankToEOL
bool commandYankToEOL()
Definition: katevinormalmode.cpp:1243
KateViNormalMode::motionToEndOfWord
KateViRange motionToEndOfWord()
Definition: katevinormalmode.cpp:2078
KateViVisualMode::saveRangeMarks
void saveRangeMarks()
Definition: katevivisualmode.cpp:186
KateDocument::undo
void undo()
Definition: katedocument.cpp:1375
KateViNormalMode::motionToMark
KateViRange motionToMark()
Definition: katevinormalmode.cpp:2488
KateViNormalMode::commandRepeatLastChange
bool commandRepeatLastChange()
Definition: katevinormalmode.cpp:1630
KateViNormalMode::m_countTemp
unsigned int m_countTemp
Definition: katevinormalmode.h:298
KateViVisualMode::switchStartEnd
void switchStartEnd()
Definition: katevivisualmode.cpp:239
KateViNormalMode::commandDeleteCharBackward
bool commandDeleteCharBackward()
Definition: katevinormalmode.cpp:1349
KateViNormalMode::commandGoToPrevJump
bool commandGoToPrevJump()
Definition: katevinormalmode.cpp:1728
KateViNormalMode::motionToPreviousBraceBlockStart
KateViRange motionToPreviousBraceBlockStart()
Definition: katevinormalmode.cpp:2680
KateViModeBase::getRegisterContent
QString getRegisterContent(const QChar &reg)
Definition: katevimodebase.cpp:952
KateViNormalMode::commandUnindentLine
bool commandUnindentLine()
Definition: katevinormalmode.cpp:1513
kateundomanager.h
KateViNormalMode::motionFindChar
KateViRange motionFindChar()
Definition: katevinormalmode.cpp:2208
KateViModeBase::findSurroundingBrackets
KateViRange findSurroundingBrackets(const QChar &c1, const QChar &c2, bool inner, const QChar &nested1, const QChar &nested2) const
Definition: katevimodebase.cpp:769
KateViNormalMode::motionToMatchingItem
KateViRange motionToMatchingItem()
Definition: katevinormalmode.cpp:2527
KateViNormalMode::commandOpenNewLineUnder
bool commandOpenNewLineUnder()
Definition: katevinormalmode.cpp:1004
KateView::setBlockSelection
virtual bool setBlockSelection(bool on)
Definition: kateview.cpp:2201
KateViModeBase::findPrevWordEnd
Cursor findPrevWordEnd(int fromLine, int fromColumn, bool onlyCurrentLine=false) const
Definition: katevimodebase.cpp:421
KateView::doc
KateDocument * doc()
accessor to katedocument pointer
Definition: kateview.h:552
KateViInputModeManager::getViInsertMode
KateViInsertMode * getViInsertMode()
Definition: kateviinputmodemanager.cpp:539
KateViVisualMode::getLastVisualMode
ViMode getLastVisualMode() const
Definition: katevivisualmode.h:57
KateViNormalMode::motionRight
KateViRange motionRight()
Definition: katevinormalmode.cpp:1906
KateViInputModeManager::repeatLastChange
void repeatLastChange()
repeat last change by feeding the contents of m_lastChange to feedKeys()
Definition: kateviinputmodemanager.cpp:314
KateViNormalMode::commandToggleRegionVisibility
bool commandToggleRegionVisibility()
Definition: katevinormalmode.cpp:1867
Block
Definition: katevimodebase.h:52
KateViNormalMode::textObjectInnerCurlyBracket
KateViRange textObjectInnerCurlyBracket()
Definition: katevinormalmode.cpp:3211
KateViModeBase::startVisualMode
bool startVisualMode()
Definition: katevimodebase.cpp:1210
KateViModeBase::getWordRangeUnderCursor
const Range getWordRangeUnderCursor() const
Definition: katevimodebase.cpp:152
KateViNormalMode::commandEnterVisualBlockMode
bool commandEnterVisualBlockMode()
Definition: katevinormalmode.cpp:648
KateViInputModeManager::getViVisualMode
KateViVisualMode * getViVisualMode()
Definition: kateviinputmodemanager.cpp:544
KateViNormalMode::commandSubstituteLine
bool commandSubstituteLine()
Definition: katevinormalmode.cpp:1198
KateViNormalMode::shrinkRangeAroundCursor
void shrinkRangeAroundCursor(KateViRange &toShrink, const KateViRange &rangeToShrinkTo)
Definition: katevinormalmode.cpp:3656
KateViNormalMode::textObjectInnerWord
KateViRange textObjectInnerWord()
Definition: katevinormalmode.cpp:3003
KateViVisualMode::getStart
Cursor getStart()
Definition: katevivisualmode.h:53
KateViNormalMode::commandSplitVert
bool commandSplitVert()
Definition: katevinormalmode.cpp:1765
KateViNormalMode::commandPaste
bool commandPaste()
Definition: katevinormalmode.cpp:1286
KateViNormalMode::commandCentreViewOnCursor
bool commandCentreViewOnCursor()
Definition: katevinormalmode.cpp:1592
KateDocument::editStart
void editStart()
Enclose editor actions with editStart() and editEnd() to group them.
Definition: katedocument.cpp:776
KateViNormalMode::motionFindNext
KateViRange motionFindNext()
Definition: katevinormalmode.cpp:2422
KateViNormalMode::m_matchingItems
QHash< QString, QString > m_matchingItems
Definition: katevinormalmode.h:329
KateViNormalMode::m_highlightYankAttribute
KTextEditor::Attribute::Ptr m_highlightYankAttribute
Definition: katevinormalmode.h:337
KateViInputModeManager::getCurrentViMode
ViMode getCurrentViMode() const
Definition: kateviinputmodemanager.cpp:449
KateViNormalMode::textObjectACurlyBracket
KateViRange textObjectACurlyBracket()
Definition: katevinormalmode.cpp:3205
KateViGlobal::appendSearchHistoryItem
void appendSearchHistoryItem(const QString &searchHistoryItem)
Definition: kateviglobal.cpp:257
KateViNormalMode::commandSplitHoriz
bool commandSplitHoriz()
Definition: katevinormalmode.cpp:1760
KateViNormalMode::commandDeleteLine
bool commandDeleteLine()
Definition: katevinormalmode.cpp:720
KateViNormalMode::motionUpToFirstNonBlank
KateViRange motionUpToFirstNonBlank()
Definition: katevinormalmode.cpp:1963
KateViNormalMode::commandMakeLowercaseLine
bool commandMakeLowercaseLine()
Definition: katevinormalmode.cpp:845
KateViNormalMode::textObjectInnerBracket
KateViRange textObjectInnerBracket()
Definition: katevinormalmode.cpp:3199
KateViInputModeManager::lastSearchPlacesCursorAtEndOfMatch
bool lastSearchPlacesCursorAtEndOfMatch()
Definition: kateviinputmodemanager.h:227
KateViModeBase::findPrevWordStart
Cursor findPrevWordStart(int fromLine, int fromColumn, bool onlyCurrentLine=false) const
Definition: katevimodebase.cpp:498
KateViKeyParser::self
static KateViKeyParser * self()
Definition: katevikeyparser.cpp:38
KateViNormalMode::commandStartRecordingMacro
bool commandStartRecordingMacro()
Definition: katevinormalmode.cpp:1814
kateviglobal.h
end
const KShortcut & end()
KateViNormalMode::textObjectABackQuote
KateViRange textObjectABackQuote()
Definition: katevinormalmode.cpp:3170
kateconfig.h
KateViRange::valid
bool valid
Definition: katevirange.h:46
KTextEditor::Cursor::setColumn
virtual void setColumn(int column)
KTextEditor::Cursor::column
int column() const
ViMotion::InclusiveMotion
Definition: katevirange.h:29
KateViNormalMode::commandAppendToBlock
bool commandAppendToBlock()
Definition: katevinormalmode.cpp:1697
KateDocument::joinLines
void joinLines(uint first, uint last)
Unwrap a range of lines.
Definition: katedocument.cpp:3496
KateViInputModeManager::setTemporaryNormalMode
void setTemporaryNormalMode(bool b)
Definition: kateviinputmodemanager.h:231
KateViNormalMode::motionRepeatlastTF
KateViRange motionRepeatlastTF()
Definition: katevinormalmode.cpp:2356
KateViNormalMode::commandSearchBackward
bool commandSearchBackward()
Definition: katevinormalmode.cpp:1450
KateViNormalMode::m_scroll_count_limit
uint m_scroll_count_limit
Definition: katevinormalmode.h:322
KateViNormalMode::motionWordBackward
KateViRange motionWordBackward()
Definition: katevinormalmode.cpp:2011
KateViRange::startLine
int startLine
Definition: katevirange.h:41
KateViModeBase::m_viewInternal
KateViewInternal * m_viewInternal
Definition: katevimodebase.h:176
KateDocument::removeText
virtual bool removeText(const KTextEditor::Range &range, bool block=false)
Definition: katedocument.cpp:633
KateCommandLineBar::execute
void execute(const QString &text)
Definition: kateviewhelpers.cpp:847
KateViNormalMode::commandSwitchToLeftView
bool commandSwitchToLeftView()
Definition: katevinormalmode.cpp:1735
KateViNormalMode::commandChange
bool commandChange()
Definition: katevinormalmode.cpp:1105
KateViNormalMode::commandMakeLowercase
bool commandMakeLowercase()
Definition: katevinormalmode.cpp:820
KateViNormalMode::textObjectAQuoteSingle
KateViRange textObjectAQuoteSingle()
Definition: katevinormalmode.cpp:3160
KateViNormalMode::addCurrentPositionToJumpList
void addCurrentPositionToJumpList()
Definition: katevinormalmode.cpp:547
KateViModeBase::findNextWORDStart
Cursor findNextWORDStart(int fromLine, int fromColumn, bool onlyCurrentLine=false) const
Definition: katevimodebase.cpp:379
KateViNormalMode::motionToPrevOccurrence
KateViRange motionToPrevOccurrence()
Definition: katevinormalmode.cpp:2775
ADDMOTION
#define ADDMOTION(STR, FUNC, FLGS)
Definition: katevinormalmode.cpp:50
KateViNormalMode::motionToFirstLineOfWindow
KateViRange motionToFirstLineOfWindow()
Definition: katevinormalmode.cpp:2792
KateViNormalMode::commandIndentLines
bool commandIndentLines()
Definition: katevinormalmode.cpp:1524
KateViModeBase::addToNumberUnderCursor
void addToNumberUnderCursor(int count)
Definition: katevimodebase.cpp:1325
KateView::pageDown
void pageDown()
Definition: kateview.cpp:2720
KateViModeBase::findPatternForMotion
KateViRange findPatternForMotion(const QString &pattern, bool backwards, bool caseSensitive, const Cursor &startFrom, int count=1) const
Definition: katevimodebase.cpp:304
QList
KateViInputModeManager::setLastSearchCaseSensitive
void setLastSearchCaseSensitive(bool caseSensitive)
Definition: kateviinputmodemanager.h:221
KateViewConfig::global
static KateViewConfig * global()
Definition: kateconfig.h:402
KateViNormalMode::m_matchItemRegex
QRegExp m_matchItemRegex
Definition: katevinormalmode.h:330
KateViNormalMode::textObjectInnerBackQuote
KateViRange textObjectInnerBackQuote()
Definition: katevinormalmode.cpp:3175
KateViInsertMode::setBlockAppendMode
void setBlockAppendMode(KateViRange blockRange, BlockInsert b)
Definition: kateviinsertmode.cpp:559
KateViewInternal::findMatchingBracket
KTextEditor::Cursor findMatchingBracket()
Definition: kateviewinternal.cpp:742
KateViNormalMode::motionFindCharBackward
KateViRange motionFindCharBackward()
Definition: katevinormalmode.cpp:2239
KateViNormalMode::commandSubstituteChar
bool commandSubstituteChar()
Definition: katevinormalmode.cpp:1188
KateViInsertMode::setCount
void setCount(int count)
Definition: kateviinsertmode.h:79
KateViModeBase::m_register
QChar m_register
Definition: katevimodebase.h:154
KateViNormalMode::resetParser
void resetParser()
(re)set to start configuration.
Definition: katevinormalmode.cpp:452
KateViNormalMode::m_defaultRegister
QChar m_defaultRegister
Definition: katevinormalmode.h:325
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

KDE's Doxygen guidelines are available online.

Kate

Skip menu "Kate"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

applications API Reference

Skip menu "applications API Reference"
  •   kate
  •       kate
  •   KTextEditor
  •   Kate
  • Applications
  •   Libraries
  •     libkonq
  • Konsole

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal