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

Kate

  • kde-4.14
  • applications
  • kate
  • part
  • vimode
kateviinsertmode.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-2011 Erlend Hamberg <ehamberg@gmail.com>
4  * Copyright (C) 2011 Svyatoslav Kuzmich <svatoslav1@gmail.com>
5  * Copyright (C) 2012 - 2013 Simon St James <kdedevel@etotheipiplusone.com>
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Library General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Library General Public License for more details.
16  *
17  * You should have received a copy of the GNU Library General Public License
18  * along with this library; see the file COPYING.LIB. If not, write to
19  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20  * Boston, MA 02110-1301, USA.
21  */
22 
23 #include "kateviinsertmode.h"
24 #include "kateviinputmodemanager.h"
25 #include "kateview.h"
26 #include "kateviewinternal.h"
27 #include "kateconfig.h"
28 #include "katecompletionwidget.h"
29 #include <katecompletiontree.h>
30 #include "kateglobal.h"
31 #include "katevikeyparser.h"
32 
33 using KTextEditor::Cursor;
34 
35 KateViInsertMode::KateViInsertMode( KateViInputModeManager *viInputModeManager,
36  KateView * view, KateViewInternal * viewInternal ) : KateViModeBase()
37 {
38  m_view = view;
39  m_viewInternal = viewInternal;
40  m_viInputModeManager = viInputModeManager;
41 
42  m_blockInsert = None;
43  m_eolPos = 0;
44  m_count = 1;
45  m_countedRepeatsBeginOnNewLine = false;
46 
47  m_isExecutingCompletion = false;
48 
49  connect(doc(), SIGNAL(textInserted(KTextEditor::Document*,KTextEditor::Range)),
50  this, SLOT(textInserted(KTextEditor::Document*,KTextEditor::Range)));
51 }
52 
53 KateViInsertMode::~KateViInsertMode()
54 {
55 }
56 
57 
58 bool KateViInsertMode::commandInsertFromAbove()
59 {
60  Cursor c( m_view->cursorPosition() );
61 
62  if ( c.line() <= 0 ) {
63  return false;
64  }
65 
66  QString line = doc()->line( c.line()-1 );
67  int tabWidth = doc()->config()->tabWidth();
68  QChar ch = getCharAtVirtualColumn( line, m_view->virtualCursorColumn(), tabWidth );
69 
70  if ( ch == QChar::Null ) {
71  return false;
72  }
73 
74  return doc()->insertText( c, ch );
75 }
76 
77 bool KateViInsertMode::commandInsertFromBelow()
78 {
79  Cursor c( m_view->cursorPosition() );
80 
81  if ( c.line() >= doc()->lines()-1 ) {
82  return false;
83  }
84 
85  QString line = doc()->line( c.line()+1 );
86  int tabWidth = doc()->config()->tabWidth();
87  QChar ch = getCharAtVirtualColumn( line, m_view->virtualCursorColumn(), tabWidth );
88 
89  if ( ch == QChar::Null ) {
90  return false;
91  }
92 
93  return doc()->insertText( c, ch );
94 }
95 
96 bool KateViInsertMode::commandDeleteWord()
97 {
98  Cursor c1( m_view->cursorPosition() );
99  Cursor c2;
100 
101  c2 = findPrevWordStart( c1.line(), c1.column() );
102 
103  if ( c2.line() != c1.line() ) {
104  if ( c1.column() == 0 ) {
105  c2.setColumn( doc()->line( c2.line() ).length() );
106  } else {
107  c2.setColumn( 0 );
108  c2.setLine( c2.line()+1 );
109  }
110  }
111 
112  KateViRange r( c2.line(), c2.column(), c1.line(), c1.column(), ViMotion::ExclusiveMotion );
113 
114  return deleteRange( r, CharWise, false );
115 }
116 
117 bool KateViInsertMode::commandDeleteLine()
118 {
119  Cursor c(m_view->cursorPosition());
120  KateViRange r(c.line(), 0, c.line(), c.column(), ViMotion::ExclusiveMotion);
121 
122  if (c.column() == 0) {
123  // Try to move the current line to the end of the previous line.
124  if (c.line() == 0)
125  return true;
126  else {
127  r.startColumn = doc()->line(c.line() - 1).length();
128  r.startLine--;
129  }
130  } else {
131  /*
132  * Remove backwards until the first non-space character. If no
133  * non-space was found, remove backwards to the first column.
134  */
135  QRegExp nonSpace("\\S");
136  r.startColumn = getLine().indexOf(nonSpace);
137  if (r.startColumn == -1 || r.startColumn >= c.column())
138  r.startColumn = 0;
139  }
140  return deleteRange(r, CharWise, false);
141 }
142 
143 bool KateViInsertMode::commandDeleteCharBackward()
144 {
145  kDebug( 13070 ) << "Char backward!\n";
146  Cursor c( m_view->cursorPosition() );
147 
148  KateViRange r( c.line(), c.column()-getCount(), c.line(), c.column(), ViMotion::ExclusiveMotion );
149 
150  if (c.column() == 0) {
151  if (c.line() == 0) {
152  return true;
153  } else {
154  r.startColumn = doc()->line(c.line()-1).length();
155  r.startLine--;
156  }
157  }
158 
159  return deleteRange( r, CharWise );
160 }
161 
162 bool KateViInsertMode::commandNewLine()
163 {
164  doc()->newLine( m_view );
165  return true;
166 }
167 
168 bool KateViInsertMode::commandIndent()
169 {
170  Cursor c( m_view->cursorPosition() );
171  doc()->indent( KTextEditor::Range( c.line(), 0, c.line(), 0), 1 );
172  return true;
173 }
174 
175 bool KateViInsertMode::commandUnindent()
176 {
177  Cursor c( m_view->cursorPosition() );
178  doc()->indent( KTextEditor::Range( c.line(), 0, c.line(), 0), -1 );
179  return true;
180 }
181 
182 bool KateViInsertMode::commandToFirstCharacterInFile()
183 {
184  Cursor c;
185 
186  c.setLine( 0 );
187  c.setColumn( 0 );
188 
189  updateCursor( c );
190 
191  return true;
192 }
193 
194 bool KateViInsertMode::commandToLastCharacterInFile()
195 {
196  Cursor c;
197 
198  int lines = doc()->lines()-1;
199  c.setLine( lines );
200  c.setColumn( doc()->line( lines ).length() );
201 
202  updateCursor( c );
203 
204  return true;
205 }
206 
207 bool KateViInsertMode::commandMoveOneWordLeft()
208 {
209  Cursor c( m_view->cursorPosition() );
210  c = findPrevWordStart( c.line(), c.column() );
211 
212  if (!c.isValid()) {
213  c = Cursor(0,0);
214  }
215 
216  updateCursor( c );
217  return true;
218 }
219 
220 bool KateViInsertMode::commandMoveOneWordRight()
221 {
222  Cursor c( m_view->cursorPosition() );
223  c = findNextWordStart( c.line(), c.column() );
224 
225  if (!c.isValid())
226  {
227  c = doc()->documentEnd();
228  }
229 
230  updateCursor( c );
231  return true;
232 }
233 
234 bool KateViInsertMode::commandCompleteNext()
235 {
236  if(m_view->completionWidget()->isCompletionActive()) {
237  const QModelIndex oldCompletionItem = m_view->completionWidget()->treeView()->selectionModel()->currentIndex();
238  m_view->completionWidget()->cursorDown();
239  const QModelIndex newCompletionItem = m_view->completionWidget()->treeView()->selectionModel()->currentIndex();
240  if (newCompletionItem == oldCompletionItem)
241  {
242  // Wrap to top.
243  m_view->completionWidget()->top();
244  }
245  } else {
246  m_view->userInvokedCompletion();
247  }
248  return true;
249 }
250 
251 bool KateViInsertMode::commandCompletePrevious()
252 {
253  if(m_view->completionWidget()->isCompletionActive()) {
254  const QModelIndex oldCompletionItem = m_view->completionWidget()->treeView()->selectionModel()->currentIndex();
255  m_view->completionWidget()->cursorUp();
256  const QModelIndex newCompletionItem = m_view->completionWidget()->treeView()->selectionModel()->currentIndex();
257  if (newCompletionItem == oldCompletionItem)
258  {
259  // Wrap to bottom.
260  m_view->completionWidget()->bottom();
261  }
262  } else {
263  m_view->userInvokedCompletion();
264  m_view->completionWidget()->bottom();
265  }
266  return true;
267 }
268 
269 bool KateViInsertMode::commandInsertContentOfRegister(){
270  Cursor c( m_view->cursorPosition() );
271  Cursor cAfter = c;
272  QChar reg = getChosenRegister( m_register );
273 
274  OperationMode m = getRegisterFlag( reg );
275  QString textToInsert = getRegisterContent( reg );
276 
277  if ( textToInsert.isNull() ) {
278  error(i18n("Nothing in register %1", reg ));
279  return false;
280  }
281 
282  if ( m == LineWise ) {
283  textToInsert.chop( 1 ); // remove the last \n
284  c.setColumn( doc()->lineLength( c.line() ) ); // paste after the current line and ...
285  textToInsert.prepend( QChar( '\n' ) ); // ... prepend a \n, so the text starts on a new line
286 
287  cAfter.setLine( cAfter.line()+1 );
288  cAfter.setColumn( 0 );
289  }
290  else
291  {
292  cAfter.setColumn(cAfter.column() + textToInsert.length());
293  }
294 
295  doc()->insertText( c, textToInsert, m == Block );
296 
297  updateCursor( cAfter );
298 
299  return true;
300 }
301 
302 // Start Normal mode just for one command and return to Insert mode
303 bool KateViInsertMode::commandSwitchToNormalModeForJustOneCommand(){
304  m_viInputModeManager->setTemporaryNormalMode(true);
305  m_viInputModeManager->changeViMode(NormalMode);
306  const Cursor cursorPos = m_view->cursorPosition();
307  // If we're at end of the line, move the cursor back one step, as in Vim.
308  if (doc()->line(cursorPos.line()).length() == cursorPos.column())
309  {
310  m_view->setCursorPosition(Cursor(cursorPos.line(), cursorPos.column() - 1));
311  }
312  m_view->setCaretStyle( KateRenderer::Block, true );
313  m_view->updateViModeBarMode();
314  m_viewInternal->repaint();
315  return true;
316 }
317 
322 bool KateViInsertMode::handleKeypress( const QKeyEvent *e )
323 {
324  // backspace should work even if the shift key is down
325  if (e->modifiers() != Qt::ControlModifier && e->key() == Qt::Key_Backspace ) {
326  m_view->backspace();
327  return true;
328  }
329 
330  if(m_keys.isEmpty()){
331  if ( e->modifiers() == Qt::NoModifier ) {
332  switch ( e->key() ) {
333  case Qt::Key_Escape:
334  leaveInsertMode();
335  return true;
336  break;
337  case Qt::Key_Left:
338  m_view->cursorLeft();
339  return true;
340  case Qt::Key_Right:
341  m_view->cursorRight();
342  return true;
343  case Qt::Key_Up:
344  m_view->up();
345  return true;
346  case Qt::Key_Down:
347  m_view->down();
348  return true;
349  case Qt::Key_Insert:
350  startReplaceMode();
351  return true;
352  case Qt::Key_Delete:
353  m_view->keyDelete();
354  return true;
355  case Qt::Key_Home:
356  m_view->home();
357  return true;
358  case Qt::Key_End:
359  m_view->end();
360  return true;
361  case Qt::Key_PageUp:
362  m_view->pageUp();
363  return true;
364  case Qt::Key_PageDown:
365  m_view->pageDown();
366  return true;
367  case Qt::Key_Enter:
368  case Qt::Key_Return:
369  if (m_view->completionWidget()->isCompletionActive() && !m_viInputModeManager->isReplayingMacro() && !m_viInputModeManager->isReplayingLastChange())
370  {
371  // Filter out Enter/ Return's that trigger a completion when recording macros/ last change stuff; they
372  // will be replaced with the special code "ctrl-space".
373  // (This is why there is a "!m_viInputModeManager->isReplayingMacro()" above.)
374  m_viInputModeManager->doNotLogCurrentKeypress();
375 
376  m_isExecutingCompletion = true;
377  m_textInsertedByCompletion.clear();
378  m_view->completionWidget()->execute();
379  completionFinished();
380  m_isExecutingCompletion = false;
381  return true;
382  }
383  default:
384  return false;
385  break;
386  }
387  } else if ( e->modifiers() == Qt::ControlModifier ) {
388  switch( e->key() ) {
389  case Qt::Key_BracketLeft:
390  case Qt::Key_3:
391  leaveInsertMode();
392  return true;
393  break;
394  case Qt::Key_Space:
395  // We use Ctrl-space as a special code in macros/ last change, which means: if replaying
396  // a macro/ last change, fetch and execute the next completion for this macro/ last change ...
397  if (!m_viInputModeManager->isReplayingMacro() && !m_viInputModeManager->isReplayingLastChange())
398  {
399  commandCompleteNext();
400  // ... therefore, we should not record ctrl-space indiscriminately.
401  m_viInputModeManager->doNotLogCurrentKeypress();
402  }
403  else
404  {
405  replayCompletion();
406  }
407  return true;
408  break;
409  case Qt::Key_C:
410  leaveInsertMode( true );
411  return true;
412  break;
413  case Qt::Key_D:
414  commandUnindent();
415  return true;
416  break;
417  case Qt::Key_E:
418  commandInsertFromBelow();
419  return true;
420  break;
421  case Qt::Key_N:
422  if (!m_viInputModeManager->isReplayingMacro())
423  {
424  commandCompleteNext();
425  }
426  return true;
427  break;
428  case Qt::Key_P:
429  if (!m_viInputModeManager->isReplayingMacro())
430  {
431  commandCompletePrevious();
432  }
433  return true;
434  break;
435  case Qt::Key_T:
436  commandIndent();
437  return true;
438  break;
439  case Qt::Key_W:
440  commandDeleteWord();
441  return true;
442  break;
443  case Qt::Key_U:
444  return commandDeleteLine();
445  case Qt::Key_J:
446  commandNewLine();
447  return true;
448  break;
449  case Qt::Key_H:
450  commandDeleteCharBackward();
451  return true;
452  break;
453  case Qt::Key_Y:
454  commandInsertFromAbove();
455  return true;
456  break;
457  case Qt::Key_O:
458  commandSwitchToNormalModeForJustOneCommand();
459  return true;
460  break;
461  case Qt::Key_Home:
462  commandToFirstCharacterInFile();
463  return true;
464  break;
465  case Qt::Key_R:
466  m_keys = "cR";
467  // Waiting for register
468  return true;
469  break;
470  case Qt::Key_End:
471  commandToLastCharacterInFile();
472  return true;
473  break;
474  case Qt::Key_Left:
475  commandMoveOneWordLeft();
476  return true;
477  break;
478  case Qt::Key_Right:
479  commandMoveOneWordRight();
480  return true;
481  break;
482  default:
483  return false;
484  }
485  }
486 
487  return false;
488 } else {
489 
490  // Was waiting for register for Ctrl-R
491  if (m_keys == "cR"){
492  QChar key = KateViKeyParser::self()->KeyEventToQChar(*e);
493  key = key.toLower();
494 
495  // is it register ?
496  if ( ( key >= '0' && key <= '9' ) || ( key >= 'a' && key <= 'z' ) ||
497  key == '_' || key == '+' || key == '*' ) {
498  m_register = key;
499  } else {
500  m_keys = "";
501  return false;
502  }
503  commandInsertContentOfRegister();
504  m_keys = "";
505  return true;
506  }
507  }
508  return false;
509 }
510 
511 // leave insert mode when esc, etc, is pressed. if leaving block
512 // prepend/append, the inserted text will be added to all block lines. if
513 // ctrl-c is used to exit insert mode this is not done.
514 void KateViInsertMode::leaveInsertMode( bool force )
515 {
516  m_view->abortCompletion();
517  if ( !force )
518  {
519  if ( m_blockInsert != None ) { // block append/prepend
520 
521  // make sure cursor haven't been moved
522  if ( m_blockRange.startLine == m_view->cursorPosition().line() ) {
523  int start, len;
524  QString added;
525  Cursor c;
526 
527  switch ( m_blockInsert ) {
528  case Append:
529  case Prepend:
530  if ( m_blockInsert == Append ) {
531  start = m_blockRange.endColumn+1;
532  } else {
533  start = m_blockRange.startColumn;
534  }
535 
536  len = m_view->cursorPosition().column()-start;
537  added = getLine().mid( start, len );
538 
539  c = Cursor( m_blockRange.startLine, start );
540  for ( int i = m_blockRange.startLine+1; i <= m_blockRange.endLine; i++ ) {
541  c.setLine( i );
542  doc()->insertText( c, added );
543  }
544  break;
545  case AppendEOL:
546  start = m_eolPos;
547  len = m_view->cursorPosition().column()-start;
548  added = getLine().mid( start, len );
549 
550  c = Cursor( m_blockRange.startLine, start );
551  for ( int i = m_blockRange.startLine+1; i <= m_blockRange.endLine; i++ ) {
552  c.setLine( i );
553  c.setColumn( doc()->lineLength( i ) );
554  doc()->insertText( c, added );
555  }
556  break;
557  default:
558  error("not supported");
559  }
560  }
561 
562  m_blockInsert = None;
563  }
564  else
565  {
566  const QString added = doc()->text(Range(m_viInputModeManager->getMarkPosition('^'), m_view->cursorPosition()));
567 
568  if (m_count > 1)
569  {
570  for (unsigned int i = 0; i < m_count - 1; i++)
571  {
572  if (m_countedRepeatsBeginOnNewLine)
573  {
574  doc()->newLine(m_view);
575  }
576  doc()->insertText( m_view->cursorPosition(), added );
577  }
578  }
579  }
580  }
581  m_countedRepeatsBeginOnNewLine = false;
582  startNormalMode();
583 }
584 
585 void KateViInsertMode::setBlockPrependMode( KateViRange blockRange )
586 {
587  // ignore if not more than one line is selected
588  if ( blockRange.startLine != blockRange.endLine ) {
589  m_blockInsert = Prepend;
590  m_blockRange = blockRange;
591  }
592 }
593 
594 void KateViInsertMode::setBlockAppendMode( KateViRange blockRange, BlockInsert b )
595 {
596  Q_ASSERT( b == Append || b == AppendEOL );
597 
598  // ignore if not more than one line is selected
599  if ( blockRange.startLine != blockRange.endLine ) {
600  m_blockRange = blockRange;
601  m_blockInsert = b;
602  if ( b == AppendEOL ) {
603  m_eolPos = doc()->lineLength( m_blockRange.startLine );
604  }
605  } else {
606  kDebug( 13070 ) << "cursor moved. ignoring block append/prepend";
607  }
608 }
609 
610 void KateViInsertMode::completionFinished()
611 {
612  KateViInputModeManager::Completion::CompletionType completionType = KateViInputModeManager::Completion::PlainText;
613  if (m_view->cursorPosition() != m_textInsertedByCompletionEndPos)
614  {
615  completionType = KateViInputModeManager::Completion::FunctionWithArgs;
616  }
617  else if (m_textInsertedByCompletion.endsWith("()") || m_textInsertedByCompletion.endsWith("();"))
618  {
619  completionType = KateViInputModeManager::Completion::FunctionWithoutArgs;
620  }
621  m_viInputModeManager->logCompletionEvent(KateViInputModeManager::Completion(m_textInsertedByCompletion, KateViewConfig::global()->wordCompletionRemoveTail(), completionType));
622 }
623 
624 void KateViInsertMode::replayCompletion()
625 {
626  const KateViInputModeManager::Completion completion = m_viInputModeManager->nextLoggedCompletion();
627  // Find beginning of the word.
628  Cursor cursorPos = m_view->cursorPosition();
629  Cursor wordStart = Cursor::invalid();
630  if (!doc()->character(cursorPos).isLetterOrNumber() && doc()->character(cursorPos) != '_')
631  {
632  cursorPos.setColumn(cursorPos.column() - 1);
633  }
634  while (cursorPos.column() >= 0 && (doc()->character(cursorPos).isLetterOrNumber() || doc()->character(cursorPos) == '_'))
635  {
636  wordStart = cursorPos;
637  cursorPos.setColumn(cursorPos.column() - 1);
638  }
639  // Find end of current word.
640  cursorPos = m_view->cursorPosition();
641  Cursor wordEnd = Cursor(cursorPos.line(), cursorPos.column() - 1);
642  while (cursorPos.column() < doc()->lineLength(cursorPos.line()) && (doc()->character(cursorPos).isLetterOrNumber() || doc()->character(cursorPos) == '_'))
643  {
644  wordEnd = cursorPos;
645  cursorPos.setColumn(cursorPos.column() + 1);
646  }
647  QString completionText = completion.completedText();
648  const Range currentWord = Range(wordStart, Cursor(wordEnd.line(), wordEnd.column() + 1));
649  // Should we merge opening brackets? Yes, if completion is a function with arguments and after the cursor
650  // there is (optional whitespace) followed by an open bracket.
651  int offsetFinalCursorPosBy = 0;
652  if (completion.completionType() == KateViInputModeManager::Completion::FunctionWithArgs)
653  {
654  const int nextMergableBracketAfterCursorPos = findNextMergeableBracketPos(currentWord.end());
655  if (nextMergableBracketAfterCursorPos != -1)
656  {
657  if (completionText.endsWith("()"))
658  {
659  // Strip "()".
660  completionText = completionText.left(completionText.length() - 2);
661  }
662  else if (completionText.endsWith("();"))
663  {
664  // Strip "();".
665  completionText = completionText.left(completionText.length() - 3);
666  }
667  // Ensure cursor ends up after the merged open bracket.
668  offsetFinalCursorPosBy = nextMergableBracketAfterCursorPos + 1;
669  }
670  else
671  {
672  if (!completionText.endsWith("()") && !completionText.endsWith("();"))
673  {
674  // Original completion merged with an opening bracket; we'll have to add our own brackets.
675  completionText.append("()");
676  }
677  // Position cursor correctly i.e. we'll have added "functionname()" or "functionname();"; need to step back by
678  // one or two to be after the opening bracket.
679  offsetFinalCursorPosBy = completionText.endsWith(';') ? -2 : -1;
680  }
681  }
682  Cursor deleteEnd = completion.removeTail() ? currentWord.end() :
683  Cursor(m_view->cursorPosition().line(), m_view->cursorPosition().column() + 0);
684 
685  if (currentWord.isValid())
686  {
687  doc()->removeText(Range(currentWord.start(), deleteEnd));
688  doc()->insertText(currentWord.start(), completionText);
689  }
690  else
691  {
692  doc()->insertText(m_view->cursorPosition(), completionText);
693  }
694 
695  if (offsetFinalCursorPosBy != 0)
696  {
697  m_view->setCursorPosition(Cursor(m_view->cursorPosition().line(), m_view->cursorPosition().column() + offsetFinalCursorPosBy));
698  }
699 
700  if (!m_viInputModeManager->isReplayingLastChange())
701  {
702  Q_ASSERT(m_viInputModeManager->isReplayingMacro());
703  // Post the completion back: it needs to be added to the "last change" list ...
704  m_viInputModeManager->logCompletionEvent(completion);
705  // ... but don't log the ctrl-space that led to this call to replayCompletion(), as
706  // a synthetic ctrl-space was just added to the last change keypresses by logCompletionEvent(), and we don't
707  // want to duplicate them!
708  m_viInputModeManager->doNotLogCurrentKeypress();
709  }
710 }
711 
712 
713 int KateViInsertMode::findNextMergeableBracketPos(const Cursor& startPos)
714 {
715  const QString lineAfterCursor = doc()->text(Range(startPos, Cursor(startPos.line(), doc()->lineLength(startPos.line()))));
716  QRegExp whitespaceThenOpeningBracket("^\\s*(\\()");
717  int nextMergableBracketAfterCursorPos = -1;
718  if (lineAfterCursor.contains(whitespaceThenOpeningBracket))
719  {
720  nextMergableBracketAfterCursorPos = whitespaceThenOpeningBracket.pos(1);
721  }
722  return nextMergableBracketAfterCursorPos;
723 }
724 
725 void KateViInsertMode::textInserted(KTextEditor::Document* document, KTextEditor::Range range)
726 {
727  if (m_isExecutingCompletion)
728  {
729  m_textInsertedByCompletion += document->text(range);
730  m_textInsertedByCompletionEndPos = range.end();
731  }
732 }
733 
KateDocument::line
virtual QString line(int line) const
Definition: katedocument.cpp:447
QRegExp::pos
int pos(int nth) const
KateViRange::endLine
int endLine
Definition: katevirange.h:44
KateView::updateViModeBarMode
void updateViModeBarMode()
Update vi mode statusbar according to the current mode.
Definition: kateview.cpp:1568
KateViInsertMode::handleKeypress
bool handleKeypress(const QKeyEvent *e)
checks if the key is a valid command
Definition: kateviinsertmode.cpp:322
KateDocument::config
KateDocumentConfig * config()
Configuration.
Definition: katedocument.h:1009
QModelIndex
KateView::userInvokedCompletion
void userInvokedCompletion()
Definition: kateview.cpp:2998
QString::indexOf
int indexOf(QChar ch, int from, Qt::CaseSensitivity cs) const
KateViInsertMode::replayCompletion
void replayCompletion()
Definition: kateviinsertmode.cpp:624
QKeyEvent::modifiers
Qt::KeyboardModifiers modifiers() const
kateview.h
QString::append
QString & append(QChar ch)
Kate::Script::i18n
QScriptValue i18n(QScriptContext *context, QScriptEngine *engine)
i18n("text", arguments [optional])
Definition: katescripthelpers.cpp:186
KateRenderer::Block
Definition: katerenderer.h:71
KateViModeBase::getRegisterFlag
OperationMode getRegisterFlag(const QChar &reg) const
Definition: katevimodebase.cpp:958
KateView::end
void end()
Definition: kateview.cpp:2683
CharWise
Definition: katevimodebase.h:50
QItemSelectionModel::currentIndex
QModelIndex currentIndex() const
QAbstractItemView::selectionModel
QItemSelectionModel * selectionModel() const
BlockInsert
BlockInsert
Commands for the vi insert mode.
Definition: kateviinsertmode.h:38
KateViModeBase::getCharAtVirtualColumn
const QChar getCharAtVirtualColumn(QString &line, int virtualColumn, int tabWidht) const
Definition: katevimodebase.cpp:1290
QChar
KateView::backspace
void backspace()
Definition: kateview.cpp:2579
KateViModeBase::doc
KateDocument * doc() const
Definition: katevimodebase.h:172
KateView::setCaretStyle
void setCaretStyle(KateRenderer::caretStyles style, bool repaint=false)
Set the caret's style.
Definition: kateview.cpp:2413
KateViInputModeManager::changeViMode
void changeViMode(ViMode newMode)
changes the current vi mode to the given mode
Definition: kateviinputmodemanager.cpp:445
katecompletiontree.h
QString::prepend
QString & prepend(QChar ch)
KateDocument::lineLength
virtual int lineLength(int line) const
Definition: katedocument.cpp:758
KateViInsertMode::commandInsertContentOfRegister
bool commandInsertContentOfRegister()
Definition: kateviinsertmode.cpp:269
KateCompletionWidget::cursorDown
void cursorDown()
Definition: katecompletionwidget.cpp:1065
KateViModeBase
Definition: katevimodebase.h:64
KateViInsertMode::commandNewLine
bool commandNewLine()
Definition: kateviinsertmode.cpp:162
KateViInputModeManager
Definition: kateviinputmodemanager.h:68
KateViInsertMode::commandCompleteNext
bool commandCompleteNext()
Definition: kateviinsertmode.cpp:234
NormalMode
Definition: kateviinputmodemanager.h:49
KateViKeyParser::KeyEventToQChar
const QChar KeyEventToQChar(const QKeyEvent &keyEvent)
Definition: katevikeyparser.cpp:674
KateViInputModeManager::doNotLogCurrentKeypress
void doNotLogCurrentKeypress()
Definition: kateviinputmodemanager.cpp:411
KateView::setCursorPosition
bool setCursorPosition(KTextEditor::Cursor position)
Definition: kateview.cpp:2418
QString::chop
void chop(int n)
KateViRange::startColumn
int startColumn
Definition: katevirange.h:41
KateView::home
void home()
Definition: kateview.cpp:2673
KateViInsertMode::m_textInsertedByCompletionEndPos
Cursor m_textInsertedByCompletionEndPos
Definition: kateviinsertmode.h:96
KateDocument::indent
void indent(KTextEditor::Range range, int change)
Definition: katedocument.cpp:2899
KateViInsertMode::commandInsertFromAbove
bool commandInsertFromAbove()
Definition: kateviinsertmode.cpp:58
KateViInsertMode::m_keys
QString m_keys
Definition: kateviinsertmode.h:89
KateViInsertMode::commandDeleteWord
bool commandDeleteWord()
Definition: kateviinsertmode.cpp:96
QString::isNull
bool isNull() const
KateViInputModeManager::Completion::completedText
QString completedText() const
Definition: kateviinputmodemanager.cpp:929
QString::clear
void clear()
AppendEOL
Definition: kateviinsertmode.h:42
kateviinputmodemanager.h
KateViInsertMode::~KateViInsertMode
~KateViInsertMode()
Definition: kateviinsertmode.cpp:53
KateViInsertMode::setBlockPrependMode
void setBlockPrependMode(KateViRange blockRange)
Definition: kateviinsertmode.cpp:585
QRegExp
KateViModeBase::getLine
const QString getLine(int line=-1) const
Definition: katevimodebase.cpp:123
KateView::completionWidget
KateCompletionWidget * completionWidget() const
Definition: kateview.cpp:2346
KateDocument::insertText
virtual bool insertText(const KTextEditor::Cursor &position, const QString &s, bool block=false)
Definition: katedocument.cpp:530
KateViInsertMode::commandIndent
bool commandIndent()
Definition: kateviinsertmode.cpp:168
KateViInsertMode::commandCompletePrevious
bool commandCompletePrevious()
Definition: kateviinsertmode.cpp:251
KateViInsertMode::commandMoveOneWordLeft
bool commandMoveOneWordLeft()
Definition: kateviinsertmode.cpp:207
KateViModeBase::m_view
KateView * m_view
Definition: katevimodebase.h:172
KateView::up
void up()
Definition: kateview.cpp:2693
KateViInputModeManager::Completion::completionType
CompletionType completionType() const
Definition: kateviinputmodemanager.cpp:937
KateView::keyDelete
void keyDelete()
Definition: kateview.cpp:2594
KateViInsertMode::commandInsertFromBelow
bool commandInsertFromBelow()
Definition: kateviinsertmode.cpp:77
KateDocument::character
virtual QChar character(const KTextEditor::Cursor &position) const
Definition: katedocument.cpp:388
KateViInsertMode::commandUnindent
bool commandUnindent()
Definition: kateviinsertmode.cpp:175
KateViRange
Definition: katevirange.h:33
KateViRange::endColumn
int endColumn
Definition: katevirange.h:44
KateViModeBase::startNormalMode
bool startNormalMode()
Definition: katevimodebase.cpp:1171
KateViInputModeManager::Completion::PlainText
Definition: kateviinputmodemanager.h:188
KateViInsertMode::commandSwitchToNormalModeForJustOneCommand
bool commandSwitchToNormalModeForJustOneCommand()
Definition: kateviinsertmode.cpp:303
kateglobal.h
KateCompletionWidget::bottom
void bottom()
Definition: katecompletionwidget.cpp:1138
KateViewInternal
Definition: kateviewinternal.h:58
KateViModeBase::startReplaceMode
bool startReplaceMode()
Definition: katevimodebase.cpp:1199
QString::isEmpty
bool isEmpty() const
KateViInsertMode::m_blockRange
KateViRange m_blockRange
Definition: kateviinsertmode.h:86
KateViModeBase::updateCursor
void updateCursor(const Cursor &c) const
Definition: katevimodebase.cpp:932
KateViInputModeManager::getMarkPosition
KTextEditor::Cursor getMarkPosition(const QChar &mark) const
Definition: kateviinputmodemanager.cpp:781
KateDocument::lines
virtual int lines() const
Definition: katedocument.cpp:753
KateCompletionWidget::top
void top()
Definition: katecompletionwidget.cpp:1125
KateCompletionWidget::cursorUp
void cursorUp()
Definition: katecompletionwidget.cpp:1080
KateDocument::documentEnd
virtual KTextEditor::Cursor documentEnd() const
Definition: katedocument.cpp:4681
QString::endsWith
bool endsWith(const QString &s, Qt::CaseSensitivity cs) const
katecompletionwidget.h
kateviewinternal.h
KateViInputModeManager::Completion::removeTail
bool removeTail() const
Definition: kateviinputmodemanager.cpp:933
KateDocument::newLine
void newLine(KateView *view)
Definition: katedocument.cpp:2660
QString
KateViInsertMode::m_count
unsigned int m_count
Definition: kateviinsertmode.h:91
kateviinsertmode.h
KateViInsertMode::m_countedRepeatsBeginOnNewLine
bool m_countedRepeatsBeginOnNewLine
Definition: kateviinsertmode.h:92
KateViInsertMode::commandToFirstCharacterInFile
bool commandToFirstCharacterInFile()
Definition: kateviinsertmode.cpp:182
Prepend
Definition: kateviinsertmode.h:40
KateView
Definition: kateview.h:77
KateViModeBase::getCount
unsigned int getCount() const
Definition: katevimodebase.h:131
KateViModeBase::findNextWordStart
Cursor findNextWordStart(int fromLine, int fromColumn, bool onlyCurrentLine=false) const
Definition: katevimodebase.cpp:312
KateViInsertMode::m_textInsertedByCompletion
QString m_textInsertedByCompletion
Definition: kateviinsertmode.h:95
QKeyEvent::key
int key() const
LineWise
Definition: katevimodebase.h:51
KateView::cursorRight
void cursorRight()
Definition: kateview.cpp:2625
KateViModeBase::error
void error(const QString &errorMsg)
Definition: katevimodebase.cpp:1253
QString::contains
bool contains(QChar ch, Qt::CaseSensitivity cs) const
KateViInsertMode::m_eolPos
unsigned int m_eolPos
Definition: kateviinsertmode.h:85
KateViInputModeManager::Completion::CompletionType
CompletionType
Definition: kateviinputmodemanager.h:188
KateView::cursorLeft
void cursorLeft()
Definition: kateview.cpp:2609
KateViInputModeManager::Completion
Definition: kateviinputmodemanager.h:185
KateView::down
void down()
Definition: kateview.cpp:2703
KateViInsertMode::m_blockInsert
BlockInsert m_blockInsert
Definition: kateviinsertmode.h:81
QChar::toLower
QChar toLower() const
katevikeyparser.h
KateViInsertMode::commandDeleteCharBackward
bool commandDeleteCharBackward()
Definition: kateviinsertmode.cpp:143
KateView::pageUp
void pageUp()
Definition: kateview.cpp:2743
QWidget::repaint
void repaint()
KateView::cursorPosition
KTextEditor::Cursor cursorPosition() const
Definition: kateview.cpp:2423
Append
Definition: kateviinsertmode.h:41
ViMotion::ExclusiveMotion
Definition: katevirange.h:29
QKeyEvent
KateCompletionWidget::isCompletionActive
bool isCompletionActive() const
Definition: katecompletionwidget.cpp:748
KateViInsertMode::commandMoveOneWordRight
bool commandMoveOneWordRight()
Definition: kateviinsertmode.cpp:220
KateViInsertMode::commandToLastCharacterInFile
bool commandToLastCharacterInFile()
Definition: kateviinsertmode.cpp:194
KateViInsertMode::completionFinished
void completionFinished()
Definition: kateviinsertmode.cpp:610
KateViModeBase::getChosenRegister
QChar getChosenRegister(const QChar &defaultReg) const
Definition: katevimodebase.cpp:940
QString::mid
QString mid(int position, int n) const
KateViInputModeManager::isReplayingMacro
bool isReplayingMacro()
Definition: kateviinputmodemanager.cpp:369
KateViInsertMode::m_isExecutingCompletion
bool m_isExecutingCompletion
Definition: kateviinsertmode.h:94
KateViInsertMode::findNextMergeableBracketPos
int findNextMergeableBracketPos(const Cursor &startPos)
Definition: kateviinsertmode.cpp:713
KateViModeBase::deleteRange
bool deleteRange(KateViRange &r, OperationMode mode=LineWise, bool addToRegister=true)
Definition: katevimodebase.cpp:65
KateViModeBase::m_viInputModeManager
KateViInputModeManager * m_viInputModeManager
Definition: katevimodebase.h:177
OperationMode
OperationMode
Definition: katevimodebase.h:49
KateViInputModeManager::isReplayingLastChange
bool isReplayingLastChange() const
Definition: kateviinputmodemanager.h:163
QString::length
int length() const
KateViInputModeManager::logCompletionEvent
void logCompletionEvent(const Completion &completion)
Definition: kateviinputmodemanager.cpp:374
KateDocument::text
virtual QString text(const KTextEditor::Range &range, bool blockwise=false) const
Definition: katedocument.cpp:337
None
Definition: kateviinsertmode.h:39
QString::left
QString left(int n) const
KateViModeBase::getRegisterContent
QString getRegisterContent(const QChar &reg)
Definition: katevimodebase.cpp:947
KateView::virtualCursorColumn
int virtualCursorColumn() const
Return the virtual cursor column, each tab is expanded into the document's tabWidth characters...
Definition: kateview.cpp:1944
KateViInsertMode::leaveInsertMode
void leaveInsertMode(bool force=false)
Definition: kateviinsertmode.cpp:514
KateView::abortCompletion
virtual void abortCompletion()
Definition: kateview.cpp:2359
Block
Definition: katevimodebase.h:52
KateViInputModeManager::nextLoggedCompletion
Completion nextLoggedCompletion()
Definition: kateviinputmodemanager.cpp:388
QObject::connect
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
KateCompletionWidget::treeView
KateCompletionTree * treeView() const
Definition: katecompletionwidget.cpp:923
KateDocumentConfig::tabWidth
int tabWidth() const
Definition: kateconfig.cpp:444
KateViModeBase::findPrevWordStart
Cursor findPrevWordStart(int fromLine, int fromColumn, bool onlyCurrentLine=false) const
Definition: katevimodebase.cpp:493
KateViKeyParser::self
static KateViKeyParser * self()
Definition: katevikeyparser.cpp:38
kateconfig.h
KateViInputModeManager::setTemporaryNormalMode
void setTemporaryNormalMode(bool b)
Definition: kateviinputmodemanager.h:241
KateViInputModeManager::Completion::FunctionWithArgs
Definition: kateviinputmodemanager.h:188
KateViInsertMode::commandDeleteLine
bool commandDeleteLine()
Definition: kateviinsertmode.cpp:117
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
KateCompletionWidget::execute
void execute()
Definition: katecompletionwidget.cpp:797
KateViInputModeManager::Completion::FunctionWithoutArgs
Definition: kateviinputmodemanager.h:188
KateViInsertMode::KateViInsertMode
KateViInsertMode(KateViInputModeManager *viInputModeManager, KateView *view, KateViewInternal *viewInternal)
Definition: kateviinsertmode.cpp:35
KateView::pageDown
void pageDown()
Definition: kateview.cpp:2753
QChar::isLetterOrNumber
bool isLetterOrNumber() const
KateViewConfig::global
static KateViewConfig * global()
Definition: kateconfig.h:402
KateViInsertMode::setBlockAppendMode
void setBlockAppendMode(KateViRange blockRange, BlockInsert b)
Definition: kateviinsertmode.cpp:594
KateViModeBase::m_register
QChar m_register
Definition: katevimodebase.h:154
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Sat May 9 2020 03:56:59 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

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
  • 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