11#include "katebuffer.h"
13#include "katecompletionwidget.h"
14#include "kateconfig.h"
15#include "katedocument.h"
16#include "kateglobal.h"
17#include "katepartdebug.h"
18#include "katerenderer.h"
19#include "kateundomanager.h"
20#include "kateviewhelpers.h"
21#include "kateviewinternal.h"
22#include "kateviinputmode.h"
23#include <ktexteditor/attribute.h>
24#include <vimode/emulatedcommandbar/emulatedcommandbar.h>
25#include <vimode/globalstate.h>
26#include <vimode/history.h>
27#include <vimode/inputmodemanager.h>
28#include <vimode/keymapper.h>
29#include <vimode/keyparser.h>
30#include <vimode/lastchangerecorder.h>
31#include <vimode/macrorecorder.h>
32#include <vimode/marks.h>
33#include <vimode/modes/insertvimode.h>
34#include <vimode/modes/normalvimode.h>
35#include <vimode/modes/replacevimode.h>
36#include <vimode/modes/visualvimode.h>
37#include <vimode/registers.h>
38#include <vimode/searcher.h>
40#include <KLocalizedString>
41#include <QApplication>
44using namespace KateVi;
46NormalViMode::NormalViMode(InputModeManager *viInputModeManager, KTextEditor::ViewPrivate *view, KateViewInternal *viewInternal)
50 m_viewInternal = viewInternal;
51 m_viInputModeManager = viInputModeManager;
53 m_lastMotionWasVisualLineUpOrDown =
false;
54 m_currentMotionWasVisualLineUpOrDown =
false;
57 m_extraWordCharacters =
QString();
58 m_matchingItems[QStringLiteral(
"/*")] = QStringLiteral(
"*/");
59 m_matchingItems[QStringLiteral(
"*/")] = QStringLiteral(
"-/*");
61 m_matchItemRegex = generateMatchingItemRegex();
63 m_scroll_count_limit = 1000;
65 m_pendingResetIsDueToExit =
false;
66 m_isRepeatedTFcommand =
false;
67 m_lastMotionWasLinewiseInnerBlock =
false;
68 m_motionCanChangeWholeVisualModeSelection =
false;
72 connect(doc()->undoManager(), &KateUndoManager::undoStart,
this, &NormalViMode::undoBeginning);
73 connect(doc()->undoManager(), &KateUndoManager::undoEnd,
this, &NormalViMode::undoEnded);
75 updateYankHighlightAttrib();
81NormalViMode::~NormalViMode()
83 qDeleteAll(m_highlightedYanks);
92 const int keyCode = e->
key();
103 m_viInputModeManager->inputAdapter()->setCaretStyle(KTextEditor::caretStyles::Block);
104 m_pendingResetIsDueToExit =
true;
108 m_viInputModeManager->setTemporaryNormalMode(
false);
113 const QChar key = KeyParser::self()->KeyEventToQChar(*e);
116 const bool waitingForRegisterOrCharToSearch = this->waitingForRegisterOrCharToSearch();
119 if (key ==
QLatin1Char(
'r') && !waitingForRegisterOrCharToSearch) {
120 m_viInputModeManager->inputAdapter()->setCaretStyle(KTextEditor::caretStyles::Underline);
123 m_keysVerbatim.
append(KeyParser::self()->decodeKeySequence(key));
126 && (m_countTemp != 0 || keyCode !=
Qt::Key_0)
127 && (!waitingForRegisterOrCharToSearch)
133 }
else if (m_countTemp != 0) {
134 m_count = getCount() * m_countTemp;
141 if (m_viInputModeManager->macroRecorder()->isRecording() && key ==
QLatin1Char(
'q')) {
144 m_viInputModeManager->macroRecorder()->stop();
157 m_positionWhenIncrementalSearchBegan = m_view->cursorPosition();
159 commandSearchForward();
161 commandSearchBackward();
175 : findWordEnd(currentPosition.
line(), currentPosition.
column() - 1,
true));
177 if (currentPosition == endOfWordOrWORD) {
178 m_keys = QStringLiteral(
"cl");
181 m_keys = QStringLiteral(
"cE");
183 m_keys = QStringLiteral(
"ce");
189 if (m_keys.
size() < 2) {
196 m_register = m_keys[1];
207 if (!m_matchingCommands.
isEmpty()) {
208 int n = m_matchingCommands.
size() - 1;
211 for (
int i = n; i >= 0; i--) {
212 if (!
commands().at(m_matchingCommands.
at(i)).matches(m_keys)) {
213 if (
commands().at(m_matchingCommands.
at(i)).needsMotion()) {
215 m_motionOperatorIndex = m_matchingCommands.
at(i);
217 m_matchingCommands.
remove(i);
224 for (
int i = 0; i < m_matchingCommands.
size(); i++) {
225 if (
commands().at(m_matchingCommands.
at(i)).needsMotion()) {
226 m_awaitingMotionOrTextObject.
push(m_keys.
size());
232 for (
size_t i = 0; i <
commands().size(); i++) {
233 if (
commands().at(i).matches(m_keys)) {
236 m_awaitingMotionOrTextObject.
push(m_keys.
size());
243 int checkFrom = (m_awaitingMotionOrTextObject.isEmpty() ? 0 : m_awaitingMotionOrTextObject.
top());
248 if (m_viInputModeManager->getCurrentViMode() == ViMode::NormalMode && !m_awaitingMotionOrTextObject.isEmpty()) {
249 m_viInputModeManager->inputAdapter()->setCaretStyle(KTextEditor::caretStyles::Half);
255 bool motionExecuted =
false;
256 if (checkFrom < m_keys.
size()) {
257 for (
size_t i = 0; i <
motions().size(); i++) {
259 if (
motions().at(i).matches(motion)) {
260 m_lastMotionWasLinewiseInnerBlock =
false;
264 if (
motions().at(i).matchesExact(motion)) {
265 m_currentMotionWasVisualLineUpOrDown =
false;
266 motionExecuted =
true;
267 if (checkFrom == 0) {
270 Range r =
motions().at(i).execute(
this);
271 m_motionCanChangeWholeVisualModeSelection =
motions().at(i).canChangeWholeVisualModeSelection();
273 if (!
motions().at(i).canLandInsideFoldingRange()) {
276 int currLine = m_view->cursorPosition().
line();
277 int delta = r.endLine - currLine;
282 if (r.endLine >= doc()->lines()) {
283 r.endLine = doc()->
lines() - 1;
288 if (r.valid && r.endLine >= 0 && (r.endLine == 0 || r.endLine <= doc()->lines() - 1) && r.endColumn >= 0) {
289 if (r.endColumn >= doc()->lineLength(r.endLine) && doc()->lineLength(r.endLine) > 0) {
290 r.endColumn = doc()->
lineLength(r.endLine) - 1;
296 if (!m_viInputModeManager->isAnyVisualMode()) {
297 m_viInputModeManager->clearCurrentChangeLog();
300 qCDebug(LOG_KTE) <<
"Invalid position: (" << r.endLine <<
"," << r.endColumn <<
")";
307 if (m_viInputModeManager->getTemporaryNormalMode()) {
312 m_lastMotionWasVisualLineUpOrDown = m_currentMotionWasVisualLineUpOrDown;
319 m_commandRange =
motions().at(i).execute(
this);
320 m_linewiseCommand =
motions().at(i).isLineWise();
323 if (m_commandRange.startLine == -1) {
325 m_commandRange.startLine = c.
line();
326 m_commandRange.startColumn = c.
column();
333 if (m_commandRange.endLine != m_commandRange.startLine && m_commandRange.endColumn ==
getFirstNonBlank(m_commandRange.endLine)) {
334 m_commandRange.endLine--;
335 m_commandRange.endColumn = doc()->
lineLength(m_commandRange.endLine);
339 m_commandWithMotion =
true;
341 if (m_commandRange.valid) {
342 executeCommand(&
commands().at(m_motionOperatorIndex));
344 qCDebug(LOG_KTE) <<
"Invalid range: "
345 <<
"from (" << m_commandRange.startLine <<
"," << m_commandRange.startColumn <<
")"
346 <<
"to (" << m_commandRange.endLine <<
"," << m_commandRange.endColumn <<
")";
349 if (m_viInputModeManager->getCurrentViMode() == ViMode::NormalMode) {
350 m_viInputModeManager->inputAdapter()->setCaretStyle(KTextEditor::caretStyles::Block);
352 m_commandWithMotion =
false;
361 if (this->waitingForRegisterOrCharToSearch()) {
366 m_viInputModeManager->keyMapper()->setDoNotMapNextKeypress();
369 if (motionExecuted) {
375 if (m_matchingCommands.
size() == 1) {
376 if (
commands().at(m_matchingCommands.
at(0)).matchesExact(m_keys) && !
commands().at(m_matchingCommands.
at(0)).needsMotion()) {
377 if (m_viInputModeManager->getCurrentViMode() == ViMode::NormalMode) {
378 m_viInputModeManager->inputAdapter()->setCaretStyle(KTextEditor::caretStyles::Block);
381 const Command &cmd =
commands().at(m_matchingCommands.
at(0));
382 executeCommand(&cmd);
385 if (cmd.shouldReset()) {
387 m_view->setBlockSelection(
false);
393 }
else if (m_matchingCommands.
size() == 0 && m_matchingMotions.
size() == 0) {
403 m_matchingMotions.
clear();
414 m_keysVerbatim.
clear();
416 m_oneTimeCountOverride = -1;
420 m_findWaitingForChar =
false;
421 m_matchingCommands.
clear();
422 m_matchingMotions.
clear();
423 m_awaitingMotionOrTextObject.clear();
424 m_motionOperatorIndex = 0;
426 m_commandWithMotion =
false;
427 m_linewiseCommand =
true;
428 m_deleteCommand =
false;
430 m_commandShouldKeepSelection =
false;
434 if (m_viInputModeManager->getCurrentViMode() == ViMode::NormalMode) {
435 m_viInputModeManager->inputAdapter()->setCaretStyle(KTextEditor::caretStyles::Block);
440void NormalViMode::reset()
443 m_commandRange.startLine = -1;
444 m_commandRange.startColumn = -1;
447void NormalViMode::beginMonitoringDocumentChanges()
453void NormalViMode::executeCommand(
const Command *cmd)
455 const ViMode originalViMode = m_viInputModeManager->getCurrentViMode();
461 if (m_viInputModeManager->getTemporaryNormalMode()) {
468 if (m_viInputModeManager->getCurrentViMode() != ViMode::InsertMode && m_viInputModeManager->getCurrentViMode() != ViMode::ReplaceMode) {
469 if (cmd->isChange() && !m_viInputModeManager->lastChangeRecorder()->isReplaying()) {
470 m_viInputModeManager->storeLastChangeCommand();
475 const bool commandSwitchedToVisualMode = ((originalViMode == ViMode::NormalMode) && m_viInputModeManager->isAnyVisualMode());
476 if (!commandSwitchedToVisualMode) {
477 m_viInputModeManager->clearCurrentChangeLog();
483 if (m_viInputModeManager->getCurrentViMode() == ViMode::NormalMode) {
486 if (c.column() >= lineLength) {
487 if (lineLength == 0) {
490 c.setColumn(lineLength - 1);
508 m_viInputModeManager->getViInsertMode()->setCount(getCount());
509 return startInsertMode();
522 if (doc()->lineLength(c.
line()) == 0) {
527 if (c.
column() > doc()->lineLength(c.
line())) {
534 m_viInputModeManager->getViInsertMode()->setCount(getCount());
535 return startInsertMode();
549 m_viInputModeManager->getViInsertMode()->setCount(getCount());
550 return startInsertMode();
553bool NormalViMode::commandEnterInsertModeBeforeFirstNonBlankInLine()
559 updateCursor(cursor);
562 m_viInputModeManager->getViInsertMode()->setCount(getCount());
563 return startInsertMode();
578 return startInsertMode();
581bool NormalViMode::commandEnterVisualLineMode()
583 if (m_viInputModeManager->getCurrentViMode() == VisualLineMode) {
588 return startVisualLineMode();
591bool NormalViMode::commandEnterVisualBlockMode()
593 if (m_viInputModeManager->getCurrentViMode() == VisualBlockMode) {
598 return startVisualBlockMode();
601bool NormalViMode::commandReselectVisual()
611 m_viInputModeManager->getViVisualMode()->setStart(c1);
612 bool returnValue =
false;
614 switch (m_viInputModeManager->getViVisualMode()->getLastVisualMode()) {
615 case ViMode::VisualMode:
616 returnValue = commandEnterVisualMode();
618 case ViMode::VisualLineMode:
619 returnValue = commandEnterVisualLineMode();
621 case ViMode::VisualBlockMode:
622 returnValue = commandEnterVisualBlockMode();
625 Q_ASSERT(
"invalid visual mode");
627 m_viInputModeManager->getViVisualMode()->goToPos(c2);
630 error(QStringLiteral(
"No previous visual selection"));
636bool NormalViMode::commandEnterVisualMode()
638 if (m_viInputModeManager->getCurrentViMode() == ViMode::VisualMode) {
643 return startVisualMode();
646bool NormalViMode::commandToOtherEnd()
648 if (m_viInputModeManager->isAnyVisualMode()) {
649 m_viInputModeManager->getViVisualMode()->switchStartEnd();
656bool NormalViMode::commandEnterReplaceMode()
659 m_viInputModeManager->getViReplaceMode()->setCount(getCount());
660 return startReplaceMode();
663bool NormalViMode::commandDeleteLine()
669 r.startLine = c.line();
670 r.endLine = c.line() + getCount() - 1;
672 int column = c.column();
674 bool ret = deleteRange(r, LineWise);
676 c = m_view->cursorPosition();
677 if (column > doc()->lineLength(c.line()) - 1) {
684 if (c.line() > doc()->lines() - 1) {
685 c.setLine(doc()->lines() - 1);
692 m_deleteCommand =
true;
696bool NormalViMode::commandDelete()
698 m_deleteCommand =
true;
699 return deleteRange(m_commandRange, getOperationMode());
702bool NormalViMode::commandDeleteToEOL()
705 OperationMode m = CharWise;
707 m_commandRange.endColumn = KateVi::EOL;
708 switch (m_viInputModeManager->getCurrentViMode()) {
709 case ViMode::NormalMode:
710 m_commandRange.startLine = c.line();
711 m_commandRange.startColumn = c.column();
712 m_commandRange.endLine = c.line() + getCount() - 1;
714 case ViMode::VisualMode:
715 case ViMode::VisualLineMode:
718 case ViMode::VisualBlockMode:
719 m_commandRange.normalize();
727 bool r = deleteRange(m_commandRange, m);
731 c.setColumn(doc()->lineLength(c.line()) - 1);
734 c.setLine(m_commandRange.startLine);
735 c.setColumn(
getFirstNonBlank(qMin(doc()->lastLine(), m_commandRange.startLine)));
738 c.setLine(m_commandRange.startLine);
739 c.setColumn(m_commandRange.startColumn - 1);
747 if (c.line() > doc()->lastLine()) {
748 c.setLine(doc()->lastLine());
750 if (c.column() > doc()->lineLength(c.line()) - 1) {
751 c.setColumn(doc()->lineLength(c.line()) - 1);
753 if (c.column() < 0) {
759 m_deleteCommand =
true;
763bool NormalViMode::commandMakeLowercase()
767 OperationMode m = getOperationMode();
768 QString text = getRange(m_commandRange, m);
774 m_commandRange.normalize();
779 doc()->replaceText(range, lowerCase, m == Block);
781 if (m_viInputModeManager->getCurrentViMode() == ViMode::NormalMode) {
790bool NormalViMode::commandMakeLowercaseLine()
794 if (doc()->lineLength(c.
line()) == 0) {
799 m_commandRange.startLine = c.
line();
800 m_commandRange.endLine = c.
line() + getCount() - 1;
801 m_commandRange.startColumn = 0;
804 return commandMakeLowercase();
807bool NormalViMode::commandMakeUppercase()
809 if (!m_commandRange.valid) {
813 OperationMode m = getOperationMode();
814 QString text = getRange(m_commandRange, m);
820 m_commandRange.normalize();
825 doc()->replaceText(range, upperCase, m == Block);
826 if (m_viInputModeManager->getCurrentViMode() == ViMode::NormalMode) {
835bool NormalViMode::commandMakeUppercaseLine()
839 if (doc()->lineLength(c.
line()) == 0) {
844 m_commandRange.startLine = c.
line();
845 m_commandRange.endLine = c.
line() + getCount() - 1;
846 m_commandRange.startColumn = 0;
849 return commandMakeUppercase();
852bool NormalViMode::commandChangeCase()
859 if (m_viInputModeManager->getCurrentViMode() == ViMode::VisualMode || m_viInputModeManager->getCurrentViMode() == ViMode::VisualBlockMode) {
871 }
else if (m_viInputModeManager->getCurrentViMode() == ViMode::VisualLineMode) {
889 if (c2.
column() > doc()->lineLength(c.
line())) {
896 bool block = m_viInputModeManager->getCurrentViMode() == ViMode::VisualBlockMode;
899 text = doc()->
text(range, block);
902 for (
int i = 0; i < text.
length(); i++) {
911 doc()->replaceText(range, text, block);
915 if (m_viInputModeManager->getCurrentViMode() == ViMode::NormalMode) {
916 updateCursor(range.
end());
918 updateCursor(range.
start());
924bool NormalViMode::commandChangeCaseRange()
926 OperationMode m = getOperationMode();
927 QString changedCase = getRange(m_commandRange, m);
934 for (
int i = 0; i < changedCase.
length(); i++) {
936 changedCase[i] = changedCase.
at(i).
toLower();
937 }
else if (changedCase.
at(i).
isLower()) {
938 changedCase[i] = changedCase.
at(i).
toUpper();
941 doc()->replaceText(range, changedCase, m == Block);
945bool NormalViMode::commandChangeCaseLine()
949 if (doc()->lineLength(c.
line()) == 0) {
954 m_commandRange.startLine = c.
line();
955 m_commandRange.endLine = c.
line() + getCount() - 1;
956 m_commandRange.startColumn = 0;
959 if (!commandChangeCaseRange()) {
964 if (getCount() > 1) {
972bool NormalViMode::commandOpenNewLineUnder()
974 doc()->setUndoMergeAllEdits(
true);
981 doc()->newLine(m_view);
985 m_viInputModeManager->getViInsertMode()->setCount(getCount());
986 m_viInputModeManager->getViInsertMode()->setCountedRepeatsBeginOnNewLine(
true);
991bool NormalViMode::commandOpenNewLineOver()
993 doc()->setUndoMergeAllEdits(
true);
998 doc()->insertLine(0,
QString());
1006 doc()->newLine(m_view);
1009 m_stickyColumn = -1;
1011 m_viInputModeManager->getViInsertMode()->setCount(getCount());
1012 m_viInputModeManager->getViInsertMode()->setCountedRepeatsBeginOnNewLine(
true);
1017bool NormalViMode::commandJoinLines()
1021 unsigned int from = c.
line();
1022 unsigned int to = c.
line() + ((getCount() == 1) ? 1 : getCount() - 1);
1025 if (m_commandRange.startLine != -1 && m_commandRange.endLine != -1) {
1026 m_commandRange.normalize();
1027 c.
setLine(m_commandRange.startLine);
1028 from = m_commandRange.startLine;
1029 to = m_commandRange.endLine;
1032 if (to >= (
unsigned int)doc()->lines()) {
1036 bool nonEmptyLineFound =
false;
1037 for (
unsigned int lineNum = from; lineNum <= to; lineNum++) {
1038 if (!doc()->line(lineNum).isEmpty()) {
1039 nonEmptyLineFound =
true;
1045 if (firstNonWhitespaceOnLastLine != -1) {
1046 leftTrimmedLastLine = doc()->
line(to).
mid(firstNonWhitespaceOnLastLine);
1049 joinLines(from, to);
1051 if (nonEmptyLineFound && leftTrimmedLastLine.
isEmpty()) {
1053 doc()->insertText(
KTextEditor::Cursor(from, doc()->lineLength(from)), QStringLiteral(
" "));
1057 c.
setColumn(doc()->lineLength(from) - leftTrimmedLastLine.
length() - 1);
1062 m_deleteCommand =
true;
1066bool NormalViMode::commandChange()
1070 OperationMode m = getOperationMode();
1072 doc()->setUndoMergeAllEdits(
true);
1076 if (m == LineWise) {
1078 doc()->insertLine(m_commandRange.startLine,
QString());
1079 c.
setLine(m_commandRange.startLine);
1081 }
else if (m == Block) {
1084 return commandPrependToBlock();
1086 if (m_commandRange.startLine < m_commandRange.endLine) {
1087 c.
setLine(m_commandRange.startLine);
1089 c.
setColumn(m_commandRange.startColumn);
1097 if (m == LineWise) {
1101 m_deleteCommand =
true;
1105bool NormalViMode::commandChangeToEOL()
1107 commandDeleteToEOL();
1109 if (getOperationMode() == Block) {
1110 return commandPrependToBlock();
1113 m_deleteCommand =
true;
1117bool NormalViMode::commandChangeLine()
1119 m_deleteCommand =
true;
1124 doc()->setUndoMergeAllEdits(
true);
1127 if (getCount() >= 2) {
1128 Range r(c.
line(), 0, c.
line() + getCount() - 2, 0, InclusiveMotion);
1133 Range r(c.
line(), c.
column(), c.
line(), doc()->lineLength(c.
line()) - 1, InclusiveMotion);
1134 deleteRange(r, CharWise,
true);
1137 if (getOperationMode() == Block) {
1138 return commandPrependToBlock();
1148bool NormalViMode::commandSubstituteChar()
1150 if (commandDeleteChar()) {
1156 m_deleteCommand =
true;
1160bool NormalViMode::commandSubstituteLine()
1162 m_deleteCommand =
true;
1163 return commandChangeLine();
1166bool NormalViMode::commandYank()
1171 OperationMode m = getOperationMode();
1172 yankedText = getRange(m_commandRange, m);
1174 highlightYank(m_commandRange, m);
1176 QChar chosen_register = getChosenRegister(ZeroRegister);
1177 fillRegister(chosen_register, yankedText, m);
1178 yankToClipBoard(chosen_register, yankedText);
1183bool NormalViMode::commandYankLine()
1187 int linenum = c.
line();
1189 for (
int i = 0; i < getCount(); i++) {
1193 Range yankRange(linenum, 0, linenum + getCount() - 1, getLine(linenum + getCount() - 1).length(), InclusiveMotion);
1194 highlightYank(yankRange);
1196 QChar chosen_register = getChosenRegister(ZeroRegister);
1197 fillRegister(chosen_register, lines, LineWise);
1198 yankToClipBoard(chosen_register, lines);
1203bool NormalViMode::commandYankToEOL()
1205 OperationMode m = CharWise;
1208 MotionType motion = m_commandRange.motionType;
1209 m_commandRange.endLine = c.
line() + getCount() - 1;
1210 m_commandRange.endColumn = doc()->
lineLength(m_commandRange.endLine) - 1;
1211 m_commandRange.motionType = InclusiveMotion;
1213 switch (m_viInputModeManager->getCurrentViMode()) {
1214 case ViMode::NormalMode:
1215 m_commandRange.startLine = c.
line();
1216 m_commandRange.startColumn = c.
column();
1218 case ViMode::VisualMode:
1219 case ViMode::VisualLineMode:
1222 VisualViMode *visual =
static_cast<VisualViMode *
>(
this);
1226 case ViMode::VisualBlockMode:
1234 const QString &yankedText = getRange(m_commandRange, m);
1235 m_commandRange.motionType = motion;
1236 highlightYank(m_commandRange);
1238 QChar chosen_register = getChosenRegister(ZeroRegister);
1239 fillRegister(chosen_register, yankedText, m);
1240 yankToClipBoard(chosen_register, yankedText);
1251bool NormalViMode::commandPaste()
1253 return paste(AfterCurrentPosition,
false,
false);
1257bool NormalViMode::commandPasteBefore()
1259 return paste(AtCurrentPosition,
false,
false);
1267bool NormalViMode::commandgPaste()
1269 return paste(AfterCurrentPosition,
true,
false);
1274bool NormalViMode::commandgPasteBefore()
1276 return paste(AtCurrentPosition,
true,
false);
1279bool NormalViMode::commandIndentedPaste()
1281 return paste(AfterCurrentPosition,
false,
true);
1284bool NormalViMode::commandIndentedPasteBefore()
1286 return paste(AtCurrentPosition,
false,
true);
1289bool NormalViMode::commandDeleteChar()
1294 if (m_commandRange.startLine != -1 && m_commandRange.startColumn != -1) {
1297 if (r.endColumn > doc()->lineLength(r.startLine)) {
1298 r.endColumn = doc()->
lineLength(r.startLine);
1303 OperationMode m = CharWise;
1304 if (m_viInputModeManager->getCurrentViMode() == VisualLineMode) {
1306 }
else if (m_viInputModeManager->getCurrentViMode() == VisualBlockMode) {
1310 m_deleteCommand =
true;
1311 return deleteRange(r, m);
1314bool NormalViMode::commandDeleteCharBackward()
1320 if (m_commandRange.startLine != -1 && m_commandRange.startColumn != -1) {
1323 if (r.startColumn < 0) {
1329 OperationMode m = CharWise;
1330 if (m_viInputModeManager->getCurrentViMode() == VisualLineMode) {
1332 }
else if (m_viInputModeManager->getCurrentViMode() == VisualBlockMode) {
1336 m_deleteCommand =
true;
1337 return deleteRange(r, m);
1340bool NormalViMode::commandReplaceCharacter()
1342 QString key = KeyParser::self()->decodeKeySequence(m_keys.
right(1));
1345 const int keyCode = KeyParser::self()->encoded2qt(m_keys.
right(1));
1362 key = QStringLiteral(
"\n");
1366 if (m_viInputModeManager->isAnyVisualMode()) {
1367 OperationMode m = getOperationMode();
1368 QString text = getRange(m_commandRange, m);
1370 if (m == LineWise) {
1375 text.
replace(nonNewlineRegex, key);
1377 m_commandRange.normalize();
1382 r = doc()->replaceText(range, text, m == Block);
1390 if (c2.
column() > doc()->lineLength(m_view->cursorPosition().
line())) {
1400bool NormalViMode::commandSwitchToCmdLine()
1403 if (m_viInputModeManager->isAnyVisualMode()) {
1405 m_viInputModeManager->getViVisualMode()->saveRangeMarks();
1406 initialText = QStringLiteral(
"'<,'>");
1407 }
else if (getCount() != 1) {
1413 m_viInputModeManager->inputAdapter()->showViModeEmulatedCommandBar();
1414 m_viInputModeManager->inputAdapter()->viModeEmulatedCommandBar()->init(EmulatedCommandBar::Command, initialText);
1416 m_commandShouldKeepSelection =
true;
1421bool NormalViMode::commandSearchBackward()
1423 m_viInputModeManager->inputAdapter()->showViModeEmulatedCommandBar();
1424 m_viInputModeManager->inputAdapter()->viModeEmulatedCommandBar()->init(EmulatedCommandBar::SearchBackward);
1428bool NormalViMode::commandSearchForward()
1430 m_viInputModeManager->inputAdapter()->showViModeEmulatedCommandBar();
1431 m_viInputModeManager->inputAdapter()->viModeEmulatedCommandBar()->init(EmulatedCommandBar::SearchForward);
1435bool NormalViMode::commandUndo()
1438 m_viInputModeManager->clearCurrentChangeLog();
1440 if (doc()->undoCount() > 0) {
1441 const bool mapped = m_viInputModeManager->keyMapper()->isExecutingMapping();
1450 if (m_viInputModeManager->isAnyVisualMode()) {
1452 m_view->clearSelection();
1460bool NormalViMode::commandRedo()
1462 if (doc()->redoCount() > 0) {
1463 const bool mapped = m_viInputModeManager->keyMapper()->isExecutingMapping();
1472 if (m_viInputModeManager->isAnyVisualMode()) {
1474 m_view->clearSelection();
1482bool NormalViMode::commandSetMark()
1487 m_viInputModeManager->marks()->setUserMark(mark, c);
1492bool NormalViMode::commandIndentLine()
1501bool NormalViMode::commandUnindentLine()
1510bool NormalViMode::commandIndentLines()
1512 const bool downwards = m_commandRange.startLine < m_commandRange.endLine;
1514 m_commandRange.normalize();
1516 int line1 = m_commandRange.startLine;
1517 int line2 = m_commandRange.endLine;
1518 int col = getLine(line2).
length();
1529bool NormalViMode::commandUnindentLines()
1531 const bool downwards = m_commandRange.startLine < m_commandRange.endLine;
1533 m_commandRange.normalize();
1535 int line1 = m_commandRange.startLine;
1536 int line2 = m_commandRange.endLine;
1538 doc()->indent(
KTextEditor::Range(line1, 0, line2, doc()->lineLength(line2)), -getCount());
1548bool NormalViMode::commandScrollPageDown()
1550 if (getCount() < m_scroll_count_limit) {
1551 for (
int i = 0; i < getCount(); i++) {
1558bool NormalViMode::commandScrollPageUp()
1560 if (getCount() < m_scroll_count_limit) {
1561 for (
int i = 0; i < getCount(); i++) {
1568bool NormalViMode::commandScrollHalfPageUp()
1570 if (getCount() < m_scroll_count_limit) {
1571 for (
int i = 0; i < getCount(); i++) {
1572 m_viewInternal->pageUp(
false,
true);
1578bool NormalViMode::commandScrollHalfPageDown()
1580 if (getCount() < m_scroll_count_limit) {
1581 for (
int i = 0; i < getCount(); i++) {
1582 m_viewInternal->pageDown(
false,
true);
1588bool NormalViMode::commandCenterView(
bool onFirst)
1591 const int virtualCenterLine = m_viewInternal->startLine() + linesDisplayed() / 2;
1594 scrollViewLines(virtualCursorLine - virtualCenterLine);
1602bool NormalViMode::commandCenterViewOnNonBlank()
1604 return commandCenterView(
true);
1607bool NormalViMode::commandCenterViewOnCursor()
1609 return commandCenterView(
false);
1612bool NormalViMode::commandTopView(
bool onFirst)
1615 const int virtualCenterLine = m_viewInternal->startLine();
1618 scrollViewLines(virtualCursorLine - virtualCenterLine);
1626bool NormalViMode::commandTopViewOnNonBlank()
1628 return commandTopView(
true);
1631bool NormalViMode::commandTopViewOnCursor()
1633 return commandTopView(
false);
1636bool NormalViMode::commandBottomView(
bool onFirst)
1639 const int virtualCenterLine = m_viewInternal->endLine();
1642 scrollViewLines(virtualCursorLine - virtualCenterLine);
1650bool NormalViMode::commandBottomViewOnNonBlank()
1652 return commandBottomView(
true);
1655bool NormalViMode::commandBottomViewOnCursor()
1657 return commandBottomView(
false);
1660bool NormalViMode::commandAbort()
1662 m_pendingResetIsDueToExit =
true;
1667bool NormalViMode::commandPrintCharacterCode()
1669 QChar ch = getCharUnderCursor();
1672 message(QStringLiteral(
"NUL"));
1679 if (
oct.length() < 3) {
1682 if (code > 0x80 && code < 0x1000) {
1685 message(
i18n(
"'%1' %2, Hex %3, Octal %4", ch, dec, hex, oct));
1691bool NormalViMode::commandRepeatLastChange()
1693 const int repeatCount = getCount();
1695 if (repeatCount > 1) {
1696 m_oneTimeCountOverride = repeatCount;
1699 m_viInputModeManager->repeatLastChange();
1705bool NormalViMode::commandAlignLine()
1707 const int line = m_view->cursorPosition().
line();
1710 doc()->align(m_view, alignRange);
1715bool NormalViMode::commandAlignLines()
1717 m_commandRange.normalize();
1727bool NormalViMode::commandAddToNumber()
1729 addToNumberUnderCursor(getCount());
1734bool NormalViMode::commandSubtractFromNumber()
1736 addToNumberUnderCursor(-getCount());
1741bool NormalViMode::commandPrependToBlock()
1746 m_commandRange.normalize();
1747 c.
setColumn(m_commandRange.startColumn);
1748 c.
setLine(m_commandRange.startLine);
1751 m_stickyColumn = -1;
1752 m_viInputModeManager->getViInsertMode()->setBlockPrependMode(m_commandRange);
1753 return startInsertMode();
1756bool NormalViMode::commandAppendToBlock()
1760 m_commandRange.normalize();
1761 if (m_stickyColumn == (
unsigned int)KateVi::EOL) {
1763 c.
setLine(m_commandRange.startLine);
1766 m_viInputModeManager->getViInsertMode()->setBlockAppendMode(m_commandRange, AppendEOL);
1768 m_viInputModeManager->getViInsertMode()->setBlockAppendMode(m_commandRange, Append);
1770 c.
setColumn(m_commandRange.endColumn + 1);
1771 c.
setLine(m_commandRange.startLine);
1775 m_stickyColumn = -1;
1777 return startInsertMode();
1780bool NormalViMode::commandGoToNextJump()
1788bool NormalViMode::commandGoToPrevJump()
1796bool NormalViMode::commandSwitchToLeftView()
1802bool NormalViMode::commandSwitchToDownView()
1808bool NormalViMode::commandSwitchToUpView()
1814bool NormalViMode::commandSwitchToRightView()
1820bool NormalViMode::commandSwitchToNextView()
1826bool NormalViMode::commandSplitHoriz()
1828 return executeKateCommand(QStringLiteral(
"split"));
1831bool NormalViMode::commandSplitVert()
1833 return executeKateCommand(QStringLiteral(
"vsplit"));
1836bool NormalViMode::commandCloseView()
1838 return executeKateCommand(QStringLiteral(
"close"));
1841bool NormalViMode::commandSwitchToNextTab()
1843 QString command = QStringLiteral(
"bn");
1849 return executeKateCommand(command);
1852bool NormalViMode::commandSwitchToPrevTab()
1854 QString command = QStringLiteral(
"bp");
1860 return executeKateCommand(command);
1863bool NormalViMode::commandFormatLine()
1867 reformatLines(c.
line(), c.
line() + getCount() - 1);
1872bool NormalViMode::commandFormatLines()
1874 reformatLines(m_commandRange.startLine, m_commandRange.endLine);
1878bool NormalViMode::commandCollapseToplevelNodes()
1880 m_view->slotFoldToplevelNodes();
1884bool NormalViMode::commandStartRecordingMacro()
1886 const QChar reg = m_keys[m_keys.
size() - 1];
1887 m_viInputModeManager->macroRecorder()->start(reg);
1891bool NormalViMode::commandReplayMacro()
1896 m_viInputModeManager->clearCurrentChangeLog();
1897 const QChar reg = m_keys[m_keys.
size() - 1];
1898 const unsigned int count = getCount();
1901 for (
unsigned int i = 0; i < count; i++) {
1902 m_viInputModeManager->macroRecorder()->replay(reg);
1908bool NormalViMode::commandCloseNocheck()
1910 return executeKateCommand(QStringLiteral(
"q!"));
1913bool NormalViMode::commandCloseWrite()
1915 return executeKateCommand(QStringLiteral(
"wq"));
1918bool NormalViMode::commandCollapseLocal()
1920 int line = m_view->cursorPosition().
line();
1921 bool actionDone =
false;
1922 while (!actionDone && line > -1) {
1923 actionDone = m_view->foldLine(line--).
isValid();
1928bool NormalViMode::commandExpandAll()
1931 m_view->slotExpandToplevelNodes();
1935bool NormalViMode::commandExpandLocal()
1937 int line = m_view->cursorPosition().
line();
1938 return m_view->unfoldLine(line);
1941bool NormalViMode::commandToggleRegionVisibility()
1944 m_view->slotToggleFolding();
1952Range NormalViMode::motionDown()
1954 return goLineDown();
1957Range NormalViMode::motionUp()
1962Range NormalViMode::motionLeft()
1965 m_stickyColumn = -1;
1966 Range r(cursor, ExclusiveMotion);
1967 r.endColumn -= getCount();
1969 if (r.endColumn < 0) {
1976Range NormalViMode::motionRight()
1979 m_stickyColumn = -1;
1980 Range r(cursor, ExclusiveMotion);
1981 r.endColumn += getCount();
1984 if (r.endColumn > doc()->lineLength(r.endLine)) {
1991Range NormalViMode::motionPageDown()
1994 Range r(c, InclusiveMotion);
1995 r.endLine += linesDisplayed();
1997 if (r.endLine >= doc()->lines()) {
1998 r.endLine = doc()->
lines() - 1;
2003Range NormalViMode::motionPageUp()
2006 Range r(c, InclusiveMotion);
2007 r.endLine -= linesDisplayed();
2009 if (r.endLine < 0) {
2015Range NormalViMode::motionHalfPageDown()
2017 if (commandScrollHalfPageDown()) {
2019 m_commandRange.endLine = c.
line();
2020 m_commandRange.endColumn = c.
column();
2021 return m_commandRange;
2023 return Range::invalid();
2026Range NormalViMode::motionHalfPageUp()
2028 if (commandScrollHalfPageUp()) {
2030 m_commandRange.endLine = c.
line();
2031 m_commandRange.endColumn = c.
column();
2032 return m_commandRange;
2034 return Range::invalid();
2037Range NormalViMode::motionDownToFirstNonBlank()
2039 Range r = goLineDown();
2044Range NormalViMode::motionUpToFirstNonBlank()
2046 Range r = goLineUp();
2051Range NormalViMode::motionWordForward()
2054 Range r(c, ExclusiveMotion);
2056 m_stickyColumn = -1;
2060 if (c.
line() == doc()->lines() - 1 && c.
column() == doc()->lineLength(c.
line()) - 1) {
2061 r.motionType = InclusiveMotion;
2063 for (
int i = 0; i < getCount(); i++) {
2071 if (i < getCount()) {
2072 r.motionType = InclusiveMotion;
2079 r.endColumn = c.
column();
2080 r.endLine = c.
line();
2085Range NormalViMode::motionWordBackward()
2088 Range r(c, ExclusiveMotion);
2090 m_stickyColumn = -1;
2092 for (
int i = 0; i < getCount(); i++) {
2101 r.endColumn = c.
column();
2102 r.endLine = c.
line();
2107Range NormalViMode::motionWORDForward()
2110 Range r(c, ExclusiveMotion);
2112 m_stickyColumn = -1;
2114 for (
int i = 0; i < getCount(); i++) {
2118 if (c.
line() == doc()->lines() - 1 && c.
column() == doc()->lineLength(c.
line()) - 1) {
2123 r.endColumn = c.
column();
2124 r.endLine = c.
line();
2129Range NormalViMode::motionWORDBackward()
2132 Range r(c, ExclusiveMotion);
2134 m_stickyColumn = -1;
2136 for (
int i = 0; i < getCount(); i++) {
2144 r.endColumn = c.
column();
2145 r.endLine = c.
line();
2150Range NormalViMode::motionToEndOfWord()
2153 Range r(c, InclusiveMotion);
2155 m_stickyColumn = -1;
2157 for (
int i = 0; i < getCount(); i++) {
2165 r.endColumn = c.
column();
2166 r.endLine = c.
line();
2171Range NormalViMode::motionToEndOfWORD()
2174 Range r(c, InclusiveMotion);
2176 m_stickyColumn = -1;
2178 for (
int i = 0; i < getCount(); i++) {
2186 r.endColumn = c.
column();
2187 r.endLine = c.
line();
2192Range NormalViMode::motionToEndOfPrevWord()
2195 Range r(c, InclusiveMotion);
2197 m_stickyColumn = -1;
2199 for (
int i = 0; i < getCount(); i++) {
2203 r.endColumn = c.
column();
2204 r.endLine = c.
line();
2215Range NormalViMode::motionToEndOfPrevWORD()
2218 Range r(c, InclusiveMotion);
2220 m_stickyColumn = -1;
2222 for (
int i = 0; i < getCount(); i++) {
2226 r.endColumn = c.
column();
2227 r.endLine = c.
line();
2238void NormalViMode::stickStickyColumnToEOL()
2240 if (m_keys.
size() == 1) {
2241 m_stickyColumn = KateVi::EOL;
2245Range NormalViMode::motionToEOL()
2249 stickStickyColumnToEOL();
2251 unsigned int line = c.
line() + (getCount() - 1);
2252 Range r(line, doc()->lineLength(line) - 1, InclusiveMotion);
2256Range NormalViMode::motionToLastNonBlank()
2260 stickStickyColumnToEOL();
2262 unsigned int line = c.
line() + (getCount() - 1);
2265 Range r(line, text_line.previousNonSpaceChar(text_line.length()), InclusiveMotion);
2269Range NormalViMode::motionToColumn0()
2271 m_stickyColumn = -1;
2273 Range r(cursor.line(), 0, ExclusiveMotion);
2278Range NormalViMode::motionToFirstCharacterOfLine()
2280 m_stickyColumn = -1;
2285 Range r(cursor.line(), c, ExclusiveMotion);
2290Range NormalViMode::motionFindChar()
2292 m_lastTFcommand = m_keys;
2296 m_stickyColumn = -1;
2298 int matchColumn = cursor.column();
2300 for (
int i = 0; i < getCount(); i++) {
2302 if (matchColumn == -1) {
2309 if (matchColumn != -1) {
2310 r.endColumn = matchColumn;
2311 r.endLine = cursor.line();
2313 return Range::invalid();
2319Range NormalViMode::motionFindCharBackward()
2321 m_lastTFcommand = m_keys;
2325 m_stickyColumn = -1;
2327 int matchColumn = -1;
2330 int i = cursor.column() - 1;
2332 while (hits != getCount() && i >= 0) {
2333 if (line.
at(i) == m_keys.
at(m_keys.
size() - 1)) {
2337 if (hits == getCount()) {
2344 Range r(cursor, ExclusiveMotion);
2346 if (matchColumn != -1) {
2347 r.endColumn = matchColumn;
2348 r.endLine = cursor.line();
2350 return Range::invalid();
2356Range NormalViMode::motionToChar()
2358 m_lastTFcommand = m_keys;
2362 m_stickyColumn = -1;
2367 int matchColumn = cursor.column() + (m_isRepeatedTFcommand ? 2 : 1);
2369 for (
int i = 0; i < getCount(); i++) {
2370 const int lastColumn = matchColumn;
2371 matchColumn = line.
indexOf(m_keys.
right(1), matchColumn + ((i > 0) ? 1 : 0));
2372 if (matchColumn == -1) {
2373 if (m_isRepeatedTFcommand) {
2374 matchColumn = lastColumn;
2376 return Range::invalid();
2382 r.endColumn = matchColumn - 1;
2383 r.endLine = cursor.line();
2385 m_isRepeatedTFcommand =
false;
2389Range NormalViMode::motionToCharBackward()
2391 m_lastTFcommand = m_keys;
2395 const int originalColumn = cursor.column();
2396 m_stickyColumn = -1;
2398 int matchColumn = originalColumn - 1;
2401 int i = cursor.column() - (m_isRepeatedTFcommand ? 2 : 1);
2403 Range r(cursor, ExclusiveMotion);
2405 while (hits != getCount() && i >= 0) {
2406 if (line.
at(i) == m_keys.
at(m_keys.
size() - 1)) {
2410 if (hits == getCount()) {
2417 if (hits == getCount()) {
2418 r.endColumn = matchColumn + 1;
2419 r.endLine = cursor.line();
2424 m_isRepeatedTFcommand =
false;
2429Range NormalViMode::motionRepeatlastTF()
2431 if (!m_lastTFcommand.
isEmpty()) {
2432 m_isRepeatedTFcommand =
true;
2433 m_keys = m_lastTFcommand;
2435 return motionFindChar();
2437 return motionFindCharBackward();
2439 return motionToChar();
2441 return motionToCharBackward();
2446 return Range::invalid();
2449Range NormalViMode::motionRepeatlastTFBackward()
2451 if (!m_lastTFcommand.
isEmpty()) {
2452 m_isRepeatedTFcommand =
true;
2453 m_keys = m_lastTFcommand;
2455 return motionFindCharBackward();
2457 return motionFindChar();
2459 return motionToCharBackward();
2461 return motionToChar();
2466 return Range::invalid();
2469Range NormalViMode::motionToLineFirst()
2471 Range r(getCount() - 1, 0, InclusiveMotion);
2472 m_stickyColumn = -1;
2474 if (r.endLine > doc()->lines() - 1) {
2475 r.endLine = doc()->
lines() - 1;
2482Range NormalViMode::motionToLineLast()
2484 Range r(doc()->lines() - 1, 0, InclusiveMotion);
2485 m_stickyColumn = -1;
2489 r.endLine = m_count - 1;
2492 if (r.endLine > doc()->lines() - 1) {
2493 r.endLine = doc()->
lines() - 1;
2500Range NormalViMode::motionToScreenColumn()
2502 m_stickyColumn = -1;
2506 int column = getCount() - 1;
2508 if (doc()->lineLength(c.
line()) - 1 < (
int)getCount() - 1) {
2512 return Range(c.
line(), column, ExclusiveMotion);
2515Range NormalViMode::motionToMark()
2519 m_stickyColumn = -1;
2525 r.endLine = c.
line();
2526 r.endColumn = c.
column();
2528 error(
i18n(
"Mark not set: %1", m_keys.
right(1)));
2537Range NormalViMode::motionToMarkLine()
2539 Range r = motionToMark();
2542 m_stickyColumn = -1;
2546Range NormalViMode::motionToMatchingItem()
2549 int lines = doc()->
lines();
2554 int count = getCount();
2558 r.endLine = qRound(lines * count / 100.0) - 1;
2568 m_stickyColumn = -1;
2571 return Range::invalid();
2574 const auto bracketChar = l.
at(n1);
2587 c = m_viewInternal->findMatchingBracket();
2588 if (c > m_view->cursorPosition()) {
2591 m_view->setCursorPosition(oldCursorPos);
2595 const int n2 = l.
indexOf(boundaryRegex, n1);
2597 QString matchingItem = m_matchingItems[item];
2600 int line = c.
line();
2601 int column = n2 - item.
length();
2602 bool reverse =
false;
2605 matchingItem.
remove(0, 1);
2610 if (column == 0 && reverse) {
2617 while (toFind > 0) {
2620 matchItemIdx = l.
lastIndexOf(matchingItem, column - 1);
2622 if (itemIdx != -1 && (matchItemIdx == -1 || itemIdx > matchItemIdx)) {
2626 itemIdx = l.
indexOf(item, column);
2627 matchItemIdx = l.
indexOf(matchingItem, column);
2629 if (itemIdx != -1 && (matchItemIdx == -1 || itemIdx < matchItemIdx)) {
2634 if (matchItemIdx != -1 || itemIdx != -1) {
2636 column = qMin((
unsigned int)itemIdx, (
unsigned int)matchItemIdx);
2638 column = qMax(itemIdx, matchItemIdx);
2642 if (matchItemIdx != -1) {
2643 if (matchItemIdx == column) {
2649 (reverse) ? --line : ++line;
2652 if ((!reverse && line >= lines) || (reverse && line < 0)) {
2662 r.endLine = c.
line();
2663 r.endColumn = c.
column();
2669Range NormalViMode::motionToNextBraceBlockStart()
2673 m_stickyColumn = -1;
2675 int line = findLineStartingWitchChar(
QLatin1Char(
'{'), getCount());
2678 return Range::invalid();
2685 if (motionWillBeUsedWithCommand()) {
2688 r.motionType = ExclusiveMotion;
2689 if (m_view->cursorPosition().
column() != 0) {
2698Range NormalViMode::motionToPreviousBraceBlockStart()
2702 m_stickyColumn = -1;
2704 int line = findLineStartingWitchChar(
QLatin1Char(
'{'), getCount(),
false);
2707 return Range::invalid();
2714 if (motionWillBeUsedWithCommand()) {
2716 r.motionType = ExclusiveMotion;
2722Range NormalViMode::motionToNextBraceBlockEnd()
2726 m_stickyColumn = -1;
2728 int line = findLineStartingWitchChar(
QLatin1Char(
'}'), getCount());
2731 return Range::invalid();
2738 if (motionWillBeUsedWithCommand()) {
2741 r.motionType = ExclusiveMotion;
2742 if (m_view->cursorPosition().
column() != 0) {
2751Range NormalViMode::motionToPreviousBraceBlockEnd()
2755 m_stickyColumn = -1;
2757 int line = findLineStartingWitchChar(
QLatin1Char(
'}'), getCount(),
false);
2760 return Range::invalid();
2767 if (motionWillBeUsedWithCommand()) {
2768 r.motionType = ExclusiveMotion;
2774Range NormalViMode::motionToNextOccurrence()
2776 const QString word = getWordUnderCursor();
2777 Searcher *searcher = m_viInputModeManager->searcher();
2778 const Range
match = searcher->findWordForMotion(word,
false, getWordRangeUnderCursor().
start(), getCount());
2779 if (searcher->lastSearchWrapped()) {
2780 m_view->showSearchWrappedHint(
false);
2783 return Range(
match.startLine,
match.startColumn, ExclusiveMotion);
2786Range NormalViMode::motionToPrevOccurrence()
2788 const QString word = getWordUnderCursor();
2789 Searcher *searcher = m_viInputModeManager->searcher();
2790 const Range
match = searcher->findWordForMotion(word,
true, getWordRangeUnderCursor().
start(), getCount());
2791 if (searcher->lastSearchWrapped()) {
2792 m_view->showSearchWrappedHint(
true);
2795 return Range(
match.startLine,
match.startColumn, ExclusiveMotion);
2798Range NormalViMode::motionToFirstLineOfWindow()
2801 if (linesDisplayed() <= (
unsigned int)m_viewInternal->endLine()) {
2802 lines_to_go = m_viewInternal->endLine() - linesDisplayed() - m_view->cursorPosition().
line() + 1;
2804 lines_to_go = -m_view->cursorPosition().
line();
2807 Range r = goLineUpDown(lines_to_go);
2812Range NormalViMode::motionToMiddleLineOfWindow()
2815 if (linesDisplayed() <= (
unsigned int)m_viewInternal->endLine()) {
2816 lines_to_go = m_viewInternal->endLine() - linesDisplayed() / 2 - m_view->cursorPosition().
line();
2818 lines_to_go = m_viewInternal->endLine() / 2 - m_view->cursorPosition().
line();
2821 Range r = goLineUpDown(lines_to_go);
2826Range NormalViMode::motionToLastLineOfWindow()
2829 if (linesDisplayed() <= (
unsigned int)m_viewInternal->endLine()) {
2830 lines_to_go = m_viewInternal->endLine() - m_view->cursorPosition().
line();
2832 lines_to_go = m_viewInternal->endLine() - m_view->cursorPosition().
line();
2835 Range r = goLineUpDown(lines_to_go);
2840Range NormalViMode::motionToNextVisualLine()
2842 return goVisualLineUpDown(getCount());
2845Range NormalViMode::motionToPrevVisualLine()
2847 return goVisualLineUpDown(-getCount());
2850Range NormalViMode::motionToPreviousSentence()
2853 int linenum = c.
line();
2855 const bool skipSpaces = doc()->
line(linenum).
isEmpty();
2860 column = doc()->
line(linenum).
size() - 1;
2864 for (
int i = linenum; i >= 0; i--) {
2867 if (line.
isEmpty() && !skipSpaces) {
2868 return Range(i, 0, InclusiveMotion);
2871 if (column < 0 && !line.
isEmpty()) {
2872 column = line.
size() - 1;
2875 for (
int j = column; j >= 0; j--) {
2876 if (skipSpaces || QStringLiteral(
".?!").indexOf(line.
at(j)) != -1) {
2880 c = findSentenceStart();
2881 return Range(c, InclusiveMotion);
2884 column = line.
size() - 1;
2886 return Range(0, 0, InclusiveMotion);
2889Range NormalViMode::motionToNextSentence()
2892 int linenum = c.
line();
2893 int column = c.
column() + 1;
2894 const bool skipSpaces = doc()->
line(linenum).
isEmpty();
2896 for (
int i = linenum; i < doc()->
lines(); i++) {
2899 if (line.
isEmpty() && !skipSpaces) {
2900 return Range(i, 0, InclusiveMotion);
2903 for (
int j = column; j < line.
size(); j++) {
2905 return Range(i, j, InclusiveMotion);
2912 return Range(c, InclusiveMotion);
2915Range NormalViMode::motionToBeforeParagraph()
2919 int line = c.
line();
2921 m_stickyColumn = -1;
2923 for (
int i = 0; i < getCount(); i++) {
2928 }
while (line >= 0 && getLine(line + 1).length() == 0);
2929 while (line > 0 && getLine(line).length() != 0) {
2938 Range r(line, 0, InclusiveMotion);
2943Range NormalViMode::motionToAfterParagraph()
2947 int line = c.
line();
2949 m_stickyColumn = -1;
2951 for (
int i = 0; i < getCount(); i++) {
2956 }
while (line <= doc()->lines() - 1 && getLine(line - 1).length() == 0);
2957 while (line < doc()->lines() - 1 && getLine(line).length() != 0) {
2962 if (line >= doc()->lines()) {
2963 line = doc()->
lines() - 1;
2967 int column = (line == doc()->
lines() - 1) ? qMax(getLine(line).length() - 1, 0) : 0;
2969 return Range(line, column, InclusiveMotion);
2972Range NormalViMode::motionToIncrementalSearchMatch()
2974 return Range(m_positionWhenIncrementalSearchBegan.
line(),
2975 m_positionWhenIncrementalSearchBegan.
column(),
2976 m_view->cursorPosition().
line(),
2977 m_view->cursorPosition().
column(),
2985Range NormalViMode::textObjectAWord()
2991 bool startedOnSpace =
false;
2992 if (doc()->characterAt(c).isSpace()) {
2993 startedOnSpace =
true;
2995 c1 = findPrevWordStart(c.
line(), c.
column() + 1,
true);
3001 for (
int i = 1; i <= getCount(); i++) {
3005 return Range::invalid();
3011 if (!startedOnSpace) {
3017 bool swallowCarriageReturnAtEndOfLine =
false;
3021 swallowCarriageReturnAtEndOfLine =
true;
3023 const bool swallowPrecedingSpaces =
3024 (c2.
column() == doc()->lineLength(c2.
line()) - 1 && !doc()->characterAt(c2).isSpace()) || startedOnSpace || swallowCarriageReturnAtEndOfLine;
3025 if (swallowPrecedingSpaces) {
3028 if (previousNonSpace.
isValid() && previousNonSpace.
line() == c1.
line()) {
3030 }
else if (startedOnSpace || swallowCarriageReturnAtEndOfLine) {
3036 return Range(c1, c2, !swallowCarriageReturnAtEndOfLine ? InclusiveMotion : ExclusiveMotion);
3039Range NormalViMode::textObjectInnerWord()
3050 for (
int i = 0; i < getCount(); i++) {
3051 c2 = findWordEnd(c2.
line(), c2.
column(),
true);
3060 return Range::invalid();
3062 return Range(c1, c2, InclusiveMotion);
3065Range NormalViMode::textObjectAWORD()
3071 bool startedOnSpace =
false;
3072 if (doc()->characterAt(c).isSpace()) {
3073 startedOnSpace =
true;
3075 c1 = findPrevWORDStart(c.
line(), c.
column() + 1,
true);
3081 for (
int i = 1; i <= getCount(); i++) {
3085 return Range::invalid();
3091 if (!startedOnSpace) {
3097 bool swallowCarriageReturnAtEndOfLine =
false;
3101 swallowCarriageReturnAtEndOfLine =
true;
3103 const bool swallowPrecedingSpaces =
3104 (c2.
column() == doc()->lineLength(c2.
line()) - 1 && !doc()->characterAt(c2).isSpace()) || startedOnSpace || swallowCarriageReturnAtEndOfLine;
3105 if (swallowPrecedingSpaces) {
3108 if (previousNonSpace.
isValid() && previousNonSpace.
line() == c1.
line()) {
3110 }
else if (startedOnSpace || swallowCarriageReturnAtEndOfLine) {
3116 return Range(c1, c2, !swallowCarriageReturnAtEndOfLine ? InclusiveMotion : ExclusiveMotion);
3119Range NormalViMode::textObjectInnerWORD()
3129 for (
int i = 0; i < getCount(); i++) {
3130 c2 = findWORDEnd(c2.
line(), c2.
column(),
true);
3139 return Range::invalid();
3141 return Range(c1, c2, InclusiveMotion);
3147 int linenum = c.
line();
3151 for (
int i = linenum; i >= 0; i--) {
3153 const int lineLength = line.
size();
3155 column = lineLength;
3164 for (
int j = column; j >= 0; j--) {
3165 if (j == lineLength || line.
at(j).
isSpace()) {
3166 int lastSpace = j--;
3167 for (; j >= 0 && QStringLiteral(
"\"')]").indexOf(line.
at(j)) != -1; j--) {
3171 if (j >= 0 && QStringLiteral(
".!?").indexOf(line.
at(j)) != -1) {
3172 if (lastSpace == lineLength) {
3192 int linenum = c.
line();
3197 for (
int i = linenum; i < doc()->
lines(); i++) {
3206 for (j = column; j < line.
size(); j++) {
3207 if (QStringLiteral(
".!?").indexOf(line.
at(j)) != -1) {
3210 for (; j < line.
size() && QStringLiteral(
"\"')]").indexOf(line.
at(j)) != -1; j++) {
3214 if (j >= line.
size()) {
3237 int prev = c.
line();
3239 for (
int i = prev; i >= 0; i--) {
3240 if (doc()->line(i).isEmpty()) {
3248 for (; i >= 0 && doc()->
line(i).
isEmpty(); i--, prev--) {
3261 int prev = c.
line();
3262 int lines = doc()->
lines();
3263 const bool firstBlank = doc()->
line(prev).
isEmpty();
3265 for (
int i = prev; i < lines; i++) {
3266 if (doc()->line(i).isEmpty()) {
3274 for (; i < lines && doc()->
line(i).
isEmpty(); i++, prev++) {
3285Range NormalViMode::textObjectInnerSentence()
3292 r.startLine = c1.
line();
3293 r.startColumn = c1.
column();
3294 r.endLine = c2.
line();
3295 r.endColumn = c2.
column();
3299Range NormalViMode::textObjectASentence()
3302 Range r = textObjectInnerSentence();
3306 for (i = r.endColumn + 1; i < line.
size(); i++) {
3311 r.endColumn = i - 1;
3314 if (r.startColumn != 0) {
3315 if (r.endColumn == line.
size() - 1 && !line.
at(r.endColumn).
isSpace()) {
3317 for (i = r.startColumn - 1; i >= 0; i--) {
3322 r.startColumn = i + 1;
3328Range NormalViMode::textObjectInnerParagraph()
3335 r.startLine = c1.
line();
3336 r.startColumn = c1.
column();
3337 r.endLine = c2.
line();
3338 r.endColumn = c2.
column();
3342Range NormalViMode::textObjectAParagraph()
3344 Range r = textObjectInnerParagraph();
3345 int lines = doc()->
lines();
3347 if (r.endLine + 1 < lines) {
3350 if (doc()->line(r.endLine + 1).
isEmpty()) {
3351 for (
int i = r.endLine + 1; i < lines && doc()->line(i).isEmpty(); i++) {
3359 c = findParagraphEnd();
3361 r.endLine = c.
line();
3362 r.endColumn = c.
column();
3364 }
else if (doc()->lineLength(r.startLine) > 0) {
3366 for (
int i = r.startLine - 1; i >= 0 && doc()->line(i).isEmpty(); i--) {
3373 return Range::invalid();
3378Range NormalViMode::textObjectAQuoteDouble()
3380 return findSurroundingQuotes(
QLatin1Char(
'"'),
false);
3383Range NormalViMode::textObjectInnerQuoteDouble()
3385 return findSurroundingQuotes(
QLatin1Char(
'"'),
true);
3388Range NormalViMode::textObjectAQuoteSingle()
3390 return findSurroundingQuotes(
QLatin1Char(
'\''),
false);
3393Range NormalViMode::textObjectInnerQuoteSingle()
3395 return findSurroundingQuotes(
QLatin1Char(
'\''),
true);
3398Range NormalViMode::textObjectABackQuote()
3400 return findSurroundingQuotes(
QLatin1Char(
'`'),
false);
3403Range NormalViMode::textObjectInnerBackQuote()
3405 return findSurroundingQuotes(
QLatin1Char(
'`'),
true);
3408Range NormalViMode::textObjectAParen()
3413Range NormalViMode::textObjectInnerParen()
3418Range NormalViMode::textObjectABracket()
3423Range NormalViMode::textObjectInnerBracket()
3428Range NormalViMode::textObjectACurlyBracket()
3433Range NormalViMode::textObjectInnerCurlyBracket()
3438 Range innerCurlyBracket(allBetweenCurlyBrackets);
3440 if (innerCurlyBracket.startLine != innerCurlyBracket.endLine) {
3441 const bool openingBraceIsLastCharOnLine = innerCurlyBracket.startColumn == doc()->
line(innerCurlyBracket.startLine).
length();
3442 const bool stuffToDeleteIsAllOnEndLine = openingBraceIsLastCharOnLine && innerCurlyBracket.endLine == innerCurlyBracket.startLine + 1;
3443 const QString textLeadingClosingBracket = doc()->
line(innerCurlyBracket.endLine).
mid(0, innerCurlyBracket.endColumn + 1);
3444 const bool closingBracketHasLeadingNonWhitespace = !textLeadingClosingBracket.
trimmed().
isEmpty();
3445 if (stuffToDeleteIsAllOnEndLine) {
3446 if (!closingBracketHasLeadingNonWhitespace) {
3448 return Range::invalid();
3451 innerCurlyBracket.startLine++;
3452 innerCurlyBracket.startColumn = 0;
3455 if (openingBraceIsLastCharOnLine && !closingBracketHasLeadingNonWhitespace) {
3456 innerCurlyBracket.startLine++;
3457 innerCurlyBracket.startColumn = 0;
3458 m_lastMotionWasLinewiseInnerBlock =
true;
3463 if (!closingBracketHasLeadingNonWhitespace) {
3466 innerCurlyBracket.endLine--;
3467 innerCurlyBracket.endColumn = doc()->
line(innerCurlyBracket.endLine).
length();
3472 return innerCurlyBracket;
3475Range NormalViMode::textObjectAInequalitySign()
3480Range NormalViMode::textObjectInnerInequalitySign()
3485Range NormalViMode::textObjectAComma()
3487 return textObjectComma(
false);
3490Range NormalViMode::textObjectInnerComma()
3492 return textObjectComma(
true);
3497 QString pattern(QStringLiteral(
"\\[|\\]|\\{|\\}|\\(|\\)|"));
3499 for (
QString s : std::as_const(m_matchingItems)) {
3503 s.replace(
QLatin1Char(
'*'), QStringLiteral(
"\\*"));
3504 s.replace(
QLatin1Char(
'+'), QStringLiteral(
"\\+"));
3505 s.replace(
QLatin1Char(
'['), QStringLiteral(
"\\["));
3506 s.replace(
QLatin1Char(
']'), QStringLiteral(
"\\]"));
3507 s.replace(
QLatin1Char(
'('), QStringLiteral(
"\\("));
3508 s.replace(
QLatin1Char(
')'), QStringLiteral(
"\\)"));
3509 s.replace(
QLatin1Char(
'{'), QStringLiteral(
"\\{"));
3510 s.replace(
QLatin1Char(
'}'), QStringLiteral(
"\\}"));
3526OperationMode NormalViMode::getOperationMode()
const
3528 OperationMode m = CharWise;
3530 if (m_viInputModeManager->getCurrentViMode() == ViMode::VisualBlockMode) {
3532 }
else if (m_viInputModeManager->getCurrentViMode() == ViMode::VisualLineMode
3533 || (m_commandRange.startLine != m_commandRange.endLine && m_viInputModeManager->getCurrentViMode() != ViMode::VisualMode)) {
3537 if (m_commandWithMotion && !m_linewiseCommand) {
3541 if (m_lastMotionWasLinewiseInnerBlock) {
3548bool NormalViMode::paste(PasteLocation pasteLocation,
bool isgPaste,
bool isIndentedPaste)
3552 QChar reg = getChosenRegister(UnnamedRegister);
3554 OperationMode m = getRegisterFlag(reg);
3555 QString textToInsert = getRegisterContent(reg);
3559 isgPaste |= m_viInputModeManager->getTemporaryNormalMode();
3562 error(
i18n(
"Nothing in register %1", reg.
toLower()));
3566 if (getCount() > 1) {
3567 textToInsert = textToInsert.
repeated(getCount());
3570 if (m == LineWise) {
3571 pasteAt.setColumn(0);
3572 if (isIndentedPaste) {
3576 const QString pasteLineString = doc()->
line(pasteAt.line());
3577 const QString leadingWhiteSpaceOnCurrentLine = pasteLineString.
mid(0, pasteLineString.
indexOf(nonWhitespaceRegex));
3578 const QString leadingWhiteSpaceOnFirstPastedLine = textToInsert.
mid(0, textToInsert.
indexOf(nonWhitespaceRegex));
3580 while (textToInsert[0].isSpace()) {
3581 textToInsert = textToInsert.
mid(1);
3583 textToInsert.
prepend(leadingWhiteSpaceOnCurrentLine);
3586 textToInsert.
chop(1);
3590 if (pasteLocation == AfterCurrentPosition) {
3591 textToInsert.
chop(1);
3592 pasteAt.setColumn(doc()->lineLength(pasteAt.line()));
3595 cursorAfterPaste.
setLine(cursorAfterPaste.
line() + 1);
3601 if (pasteLocation == AfterCurrentPosition) {
3604 if (getLine(pasteAt.line()).
length() > 0) {
3605 pasteAt.setColumn(pasteAt.column() + 1);
3607 cursorAfterPaste = pasteAt;
3609 const bool leaveCursorAtStartOfPaste = isTextMultiLine && !isgPaste;
3610 if (!leaveCursorAtStartOfPaste) {
3611 cursorAfterPaste = cursorPosAtEndOfPaste(pasteAt, textToInsert);
3619 if (m_view->selection()) {
3620 pasteAt = m_view->selectionRange().
start();
3621 doc()->removeText(m_view->selectionRange());
3623 doc()->insertText(pasteAt, textToInsert, m == Block);
3626 if (cursorAfterPaste.
line() >= doc()->lines()) {
3627 cursorAfterPaste.
setLine(doc()->lines() - 1);
3629 updateCursor(cursorAfterPaste);
3638 if (lineCount == 1) {
3648void NormalViMode::joinLines(
unsigned int from,
unsigned int to)
const
3651 if (to >= (
unsigned int)(doc()->lines())) {
3652 to = doc()->
lines() - 1;
3663void NormalViMode::reformatLines(
unsigned int from,
unsigned int to)
const
3668 for (
int i = 0; i < text.
length(); ++i) {
3676 for (; from < to; ++from) {
3677 if (isNonEmptyLine(document->
line(from))) {
3681 for (; to > from; --to) {
3682 if (isNonEmptyLine(document->
line(to))) {
3688 joinLines(from, to);
3696 line = m_view->cursorPosition().
line();
3702 return (c < 0) ? 0 : c;
3706void NormalViMode::shrinkRangeAroundCursor(Range &toShrink,
const Range &rangeToShrinkTo)
const
3708 if (!toShrink.valid || !rangeToShrinkTo.valid) {
3712 if (rangeToShrinkTo.startLine >= cursorPos.
line()) {
3713 if (rangeToShrinkTo.startLine > cursorPos.
line()) {
3717 Q_ASSERT(rangeToShrinkTo.startLine == cursorPos.
line());
3718 if (rangeToShrinkTo.startColumn > cursorPos.
column()) {
3723 if (rangeToShrinkTo.endLine <= cursorPos.
line()) {
3724 if (rangeToShrinkTo.endLine < cursorPos.
line()) {
3728 Q_ASSERT(rangeToShrinkTo.endLine == cursorPos.
line());
3729 if (rangeToShrinkTo.endColumn < cursorPos.
column()) {
3735 if (toShrink.startLine <= rangeToShrinkTo.startLine) {
3736 if (toShrink.startLine < rangeToShrinkTo.startLine) {
3737 toShrink.startLine = rangeToShrinkTo.startLine;
3738 toShrink.startColumn = rangeToShrinkTo.startColumn;
3740 Q_ASSERT(toShrink.startLine == rangeToShrinkTo.startLine);
3741 if (toShrink.startColumn < rangeToShrinkTo.startColumn) {
3742 toShrink.startColumn = rangeToShrinkTo.startColumn;
3745 if (toShrink.endLine >= rangeToShrinkTo.endLine) {
3746 if (toShrink.endLine > rangeToShrinkTo.endLine) {
3747 toShrink.endLine = rangeToShrinkTo.endLine;
3748 toShrink.endColumn = rangeToShrinkTo.endColumn;
3750 Q_ASSERT(toShrink.endLine == rangeToShrinkTo.endLine);
3751 if (toShrink.endColumn > rangeToShrinkTo.endColumn) {
3752 toShrink.endColumn = rangeToShrinkTo.endColumn;
3757Range NormalViMode::textObjectComma(
bool inner)
const
3762 Range r(0, 0, m_view->doc()->
lines(), m_view->doc()->
line(m_view->doc()->
lastLine()).
length(), InclusiveMotion);
3764 shrinkRangeAroundCursor(r, findSurroundingQuotes(
QLatin1Char(
','), inner));
3776void NormalViMode::updateYankHighlightAttrib()
3778 if (!m_highlightYankAttribute) {
3781 const QColor &yankedColor = m_view->rendererConfig()->savedLineColor();
3782 m_highlightYankAttribute->setBackground(yankedColor);
3784 mouseInAttribute->setFontBold(
true);
3789void NormalViMode::highlightYank(
const Range &range,
const OperationMode mode)
3791 clearYankHighlight();
3795 if (mode == Block) {
3796 for (
int i = range.startLine; i <= range.endLine; i++) {
3800 addHighlightYank(
KTextEditor::Range(range.startLine, range.startColumn, range.endLine, range.endColumn));
3807 highlightedYank->
setView(m_view);
3811 highlightedYank->
setAttribute(m_highlightYankAttribute);
3813 highlightedYankForDocument().
insert(highlightedYank);
3816void NormalViMode::clearYankHighlight()
3819 qDeleteAll(pHighlightedYanks);
3820 pHighlightedYanks.
clear();
3823void NormalViMode::aboutToDeleteMovingInterfaceContent()
3827 pHighlightedYanks.
clear();
3834 return m_viInputModeManager->getViNormalMode()->m_highlightedYanks;
3837bool NormalViMode::waitingForRegisterOrCharToSearch()
3842 const int keysSize = m_keys.
size();
3849 QChar cPrefix = m_keys[0];
3850 if (keysSize == 2) {
3856 }
else if (keysSize == 3) {
3858 QChar cNextfix = m_keys[1];
3869 QChar ch = m_keys[keysSize - 1];
3883 const bool isInsertReplaceMode =
3884 (m_viInputModeManager->getCurrentViMode() == ViMode::InsertMode || m_viInputModeManager->getCurrentViMode() == ViMode::ReplaceMode);
3885 const bool continuesInsertion = range.
start().
line() == m_currentChangeEndMarker.
line() && range.
start().
column() == m_currentChangeEndMarker.
column();
3887 if (!continuesInsertion) {
3889 if (beginsWithNewline && !isInsertReplaceMode) {
3893 m_viInputModeManager->marks()->setStartEditYanked(newBeginMarkerPos);
3895 m_viInputModeManager->marks()->setLastChange(range.
start());
3897 if (!isInsertReplaceMode) {
3900 m_viInputModeManager->marks()->setFinishEditYanked(editEndMarker);
3901 m_currentChangeEndMarker = range.
end();
3904 m_viInputModeManager->marks()->setStartEditYanked(
KTextEditor::Cursor(m_viInputModeManager->marks()->getStartEditYanked().
line(), 0));
3905 if (addsMultipleLines) {
3906 m_viInputModeManager->marks()->setFinishEditYanked(
KTextEditor::Cursor(m_viInputModeManager->marks()->getFinishEditYanked().
line() + 1, 0));
3907 m_viInputModeManager->marks()->setLastChange(
KTextEditor::Cursor(m_viInputModeManager->marks()->getLastChange().
line() + 1, 0));
3909 m_viInputModeManager->marks()->setFinishEditYanked(
KTextEditor::Cursor(m_viInputModeManager->marks()->getFinishEditYanked().
line(), 0));
3910 m_viInputModeManager->marks()->setLastChange(
KTextEditor::Cursor(m_viInputModeManager->marks()->getLastChange().
line(), 0));
3922 const bool isInsertReplaceMode =
3923 (m_viInputModeManager->getCurrentViMode() == ViMode::InsertMode || m_viInputModeManager->getCurrentViMode() == ViMode::ReplaceMode);
3924 m_viInputModeManager->marks()->setLastChange(range.
start());
3925 if (!isInsertReplaceMode) {
3927 m_viInputModeManager->marks()->setStartEditYanked(range.
start());
3930 m_currentChangeEndMarker = range.
start();
3932 m_viInputModeManager->marks()->setFinishEditYanked(range.
start());
3937 const int markerLineAdjustment = (range.
start().line() != range.
end().
line()) ? 1 : 0;
3938 m_viInputModeManager->marks()->setStartEditYanked(
3940 m_viInputModeManager->marks()->setFinishEditYanked(
3942 m_viInputModeManager->marks()->setLastChange(
KTextEditor::Cursor(m_viInputModeManager->marks()->getLastChange().
line() + markerLineAdjustment, 0));
3946void NormalViMode::undoBeginning()
3951void NormalViMode::undoEnded()
3956bool NormalViMode::executeKateCommand(
const QString &command)
3965 return p->
exec(m_view, command, msg);
3968#define ADDCMD(STR, FUNC, FLGS) Command(QStringLiteral(STR), &NormalViMode::FUNC, FLGS)
3970#define ADDMOTION(STR, FUNC, FLGS) Motion(QStringLiteral(STR), &NormalViMode::FUNC, FLGS)
3975 static const std::vector<Command> global{
3980 ADDCMD(
"I", commandEnterInsertModeBeforeFirstNonBlankInLine, IS_CHANGE),
3982 ADDCMD(
"v", commandEnterVisualMode, 0),
3983 ADDCMD(
"V", commandEnterVisualLineMode, 0),
3984 ADDCMD(
"<c-v>", commandEnterVisualBlockMode, 0),
3985 ADDCMD(
"gv", commandReselectVisual, SHOULD_NOT_RESET),
3986 ADDCMD(
"o", commandOpenNewLineUnder, IS_CHANGE),
3987 ADDCMD(
"O", commandOpenNewLineOver, IS_CHANGE),
3988 ADDCMD(
"J", commandJoinLines, IS_CHANGE),
3989 ADDCMD(
"c", commandChange, IS_CHANGE | NEEDS_MOTION),
3990 ADDCMD(
"C", commandChangeToEOL, IS_CHANGE),
3991 ADDCMD(
"cc", commandChangeLine, IS_CHANGE),
3992 ADDCMD(
"s", commandSubstituteChar, IS_CHANGE),
3993 ADDCMD(
"S", commandSubstituteLine, IS_CHANGE),
3994 ADDCMD(
"dd", commandDeleteLine, IS_CHANGE),
3995 ADDCMD(
"d", commandDelete, IS_CHANGE | NEEDS_MOTION),
3996 ADDCMD(
"D", commandDeleteToEOL, IS_CHANGE),
3997 ADDCMD(
"x", commandDeleteChar, IS_CHANGE),
3998 ADDCMD(
"<delete>", commandDeleteChar, IS_CHANGE),
3999 ADDCMD(
"X", commandDeleteCharBackward, IS_CHANGE),
4000 ADDCMD(
"gu", commandMakeLowercase, IS_CHANGE | NEEDS_MOTION),
4001 ADDCMD(
"guu", commandMakeLowercaseLine, IS_CHANGE),
4002 ADDCMD(
"gU", commandMakeUppercase, IS_CHANGE | NEEDS_MOTION),
4003 ADDCMD(
"gUU", commandMakeUppercaseLine, IS_CHANGE),
4004 ADDCMD(
"y", commandYank, NEEDS_MOTION),
4005 ADDCMD(
"yy", commandYankLine, 0),
4006 ADDCMD(
"Y", commandYankToEOL, 0),
4007 ADDCMD(
"p", commandPaste, IS_CHANGE),
4008 ADDCMD(
"P", commandPasteBefore, IS_CHANGE),
4009 ADDCMD(
"gp", commandgPaste, IS_CHANGE),
4010 ADDCMD(
"gP", commandgPasteBefore, IS_CHANGE),
4011 ADDCMD(
"]p", commandIndentedPaste, IS_CHANGE),
4012 ADDCMD(
"[p", commandIndentedPasteBefore, IS_CHANGE),
4013 ADDCMD(
"r.", commandReplaceCharacter, IS_CHANGE | REGEX_PATTERN),
4014 ADDCMD(
"R", commandEnterReplaceMode, IS_CHANGE),
4015 ADDCMD(
":", commandSwitchToCmdLine, 0),
4016 ADDCMD(
"u", commandUndo, 0),
4017 ADDCMD(
"<c-r>", commandRedo, 0),
4018 ADDCMD(
"U", commandRedo, 0),
4019 ADDCMD(
"m.", commandSetMark, REGEX_PATTERN),
4020 ADDCMD(
">>", commandIndentLine, IS_CHANGE),
4021 ADDCMD(
"<<", commandUnindentLine, IS_CHANGE),
4022 ADDCMD(
">", commandIndentLines, IS_CHANGE | NEEDS_MOTION),
4023 ADDCMD(
"<", commandUnindentLines, IS_CHANGE | NEEDS_MOTION),
4024 ADDCMD(
"<c-f>", commandScrollPageDown, 0),
4025 ADDCMD(
"<pagedown>", commandScrollPageDown, 0),
4026 ADDCMD(
"<c-b>", commandScrollPageUp, 0),
4027 ADDCMD(
"<pageup>", commandScrollPageUp, 0),
4028 ADDCMD(
"<c-u>", commandScrollHalfPageUp, 0),
4029 ADDCMD(
"<c-d>", commandScrollHalfPageDown, 0),
4030 ADDCMD(
"z.", commandCenterViewOnNonBlank, 0),
4031 ADDCMD(
"zz", commandCenterViewOnCursor, 0),
4032 ADDCMD(
"z<return>", commandTopViewOnNonBlank, 0),
4033 ADDCMD(
"zt", commandTopViewOnCursor, 0),
4034 ADDCMD(
"z-", commandBottomViewOnNonBlank, 0),
4035 ADDCMD(
"zb", commandBottomViewOnCursor, 0),
4036 ADDCMD(
"ga", commandPrintCharacterCode, SHOULD_NOT_RESET),
4037 ADDCMD(
".", commandRepeatLastChange, 0),
4038 ADDCMD(
"==", commandAlignLine, IS_CHANGE),
4039 ADDCMD(
"=", commandAlignLines, IS_CHANGE | NEEDS_MOTION),
4040 ADDCMD(
"~", commandChangeCase, IS_CHANGE),
4041 ADDCMD(
"g~", commandChangeCaseRange, IS_CHANGE | NEEDS_MOTION),
4042 ADDCMD(
"g~~", commandChangeCaseLine, IS_CHANGE),
4043 ADDCMD(
"<c-a>", commandAddToNumber, IS_CHANGE),
4044 ADDCMD(
"<c-x>", commandSubtractFromNumber, IS_CHANGE),
4045 ADDCMD(
"<c-o>", commandGoToPrevJump, CAN_LAND_INSIDE_FOLDING_RANGE),
4046 ADDCMD(
"<c-i>", commandGoToNextJump, CAN_LAND_INSIDE_FOLDING_RANGE),
4048 ADDCMD(
"<c-w>h", commandSwitchToLeftView, 0),
4049 ADDCMD(
"<c-w><c-h>", commandSwitchToLeftView, 0),
4050 ADDCMD(
"<c-w><left>", commandSwitchToLeftView, 0),
4051 ADDCMD(
"<c-w>j", commandSwitchToDownView, 0),
4052 ADDCMD(
"<c-w><c-j>", commandSwitchToDownView, 0),
4053 ADDCMD(
"<c-w><down>", commandSwitchToDownView, 0),
4054 ADDCMD(
"<c-w>k", commandSwitchToUpView, 0),
4055 ADDCMD(
"<c-w><c-k>", commandSwitchToUpView, 0),
4056 ADDCMD(
"<c-w><up>", commandSwitchToUpView, 0),
4057 ADDCMD(
"<c-w>l", commandSwitchToRightView, 0),
4058 ADDCMD(
"<c-w><c-l>", commandSwitchToRightView, 0),
4059 ADDCMD(
"<c-w><right>", commandSwitchToRightView, 0),
4060 ADDCMD(
"<c-w>w", commandSwitchToNextView, 0),
4061 ADDCMD(
"<c-w><c-w>", commandSwitchToNextView, 0),
4063 ADDCMD(
"<c-w>s", commandSplitHoriz, 0),
4064 ADDCMD(
"<c-w>S", commandSplitHoriz, 0),
4065 ADDCMD(
"<c-w><c-s>", commandSplitHoriz, 0),
4066 ADDCMD(
"<c-w>v", commandSplitVert, 0),
4067 ADDCMD(
"<c-w><c-v>", commandSplitVert, 0),
4068 ADDCMD(
"<c-w>c", commandCloseView, 0),
4070 ADDCMD(
"gt", commandSwitchToNextTab, 0),
4071 ADDCMD(
"gT", commandSwitchToPrevTab, 0),
4073 ADDCMD(
"gqq", commandFormatLine, IS_CHANGE),
4074 ADDCMD(
"gq", commandFormatLines, IS_CHANGE | NEEDS_MOTION),
4076 ADDCMD(
"zo", commandExpandLocal, 0),
4077 ADDCMD(
"zc", commandCollapseLocal, 0),
4078 ADDCMD(
"za", commandToggleRegionVisibility, 0),
4079 ADDCMD(
"zr", commandExpandAll, 0),
4080 ADDCMD(
"zm", commandCollapseToplevelNodes, 0),
4082 ADDCMD(
"q.", commandStartRecordingMacro, REGEX_PATTERN),
4083 ADDCMD(
"@.", commandReplayMacro, REGEX_PATTERN),
4085 ADDCMD(
"ZZ", commandCloseWrite, 0),
4086 ADDCMD(
"ZQ", commandCloseNocheck, 0),
4094 static const std::vector<Motion> global{
4096 ADDMOTION(
"h", motionLeft, 0),
4097 ADDMOTION(
"<left>", motionLeft, 0),
4098 ADDMOTION(
"<backspace>", motionLeft, 0),
4099 ADDMOTION(
"j", motionDown, 0),
4100 ADDMOTION(
"<down>", motionDown, 0),
4101 ADDMOTION(
"<enter>", motionDownToFirstNonBlank, 0),
4102 ADDMOTION(
"<return>", motionDownToFirstNonBlank, 0),
4103 ADDMOTION(
"k", motionUp, 0),
4104 ADDMOTION(
"<up>", motionUp, 0),
4105 ADDMOTION(
"-", motionUpToFirstNonBlank, 0),
4106 ADDMOTION(
"+", motionDownToFirstNonBlank, 0),
4107 ADDMOTION(
"l", motionRight, 0),
4108 ADDMOTION(
"<right>", motionRight, 0),
4109 ADDMOTION(
" ", motionRight, 0),
4110 ADDMOTION(
"$", motionToEOL, 0),
4111 ADDMOTION(
"g_", motionToLastNonBlank, 0),
4112 ADDMOTION(
"<end>", motionToEOL, 0),
4113 ADDMOTION(
"0", motionToColumn0, 0),
4114 ADDMOTION(
"<home>", motionToColumn0, 0),
4115 ADDMOTION(
"^", motionToFirstCharacterOfLine, 0),
4116 ADDMOTION(
"f.", motionFindChar, REGEX_PATTERN | CAN_LAND_INSIDE_FOLDING_RANGE),
4117 ADDMOTION(
"F.", motionFindCharBackward, REGEX_PATTERN | CAN_LAND_INSIDE_FOLDING_RANGE),
4118 ADDMOTION(
"t.", motionToChar, REGEX_PATTERN | CAN_LAND_INSIDE_FOLDING_RANGE),
4119 ADDMOTION(
"T.", motionToCharBackward, REGEX_PATTERN | CAN_LAND_INSIDE_FOLDING_RANGE),
4120 ADDMOTION(
";", motionRepeatlastTF, CAN_LAND_INSIDE_FOLDING_RANGE),
4121 ADDMOTION(
",", motionRepeatlastTFBackward, CAN_LAND_INSIDE_FOLDING_RANGE),
4122 ADDMOTION(
"n", motionFindNext, CAN_LAND_INSIDE_FOLDING_RANGE),
4123 ADDMOTION(
"N", motionFindPrev, CAN_LAND_INSIDE_FOLDING_RANGE),
4124 ADDMOTION(
"gg", motionToLineFirst, 0),
4125 ADDMOTION(
"G", motionToLineLast, 0),
4126 ADDMOTION(
"w", motionWordForward, IS_NOT_LINEWISE | CAN_LAND_INSIDE_FOLDING_RANGE),
4127 ADDMOTION(
"W", motionWORDForward, IS_NOT_LINEWISE | CAN_LAND_INSIDE_FOLDING_RANGE),
4128 ADDMOTION(
"<c-right>", motionWordForward, IS_NOT_LINEWISE | CAN_LAND_INSIDE_FOLDING_RANGE),
4129 ADDMOTION(
"<c-left>", motionWordBackward, IS_NOT_LINEWISE | CAN_LAND_INSIDE_FOLDING_RANGE),
4130 ADDMOTION(
"b", motionWordBackward, CAN_LAND_INSIDE_FOLDING_RANGE),
4131 ADDMOTION(
"B", motionWORDBackward, CAN_LAND_INSIDE_FOLDING_RANGE),
4132 ADDMOTION(
"e", motionToEndOfWord, CAN_LAND_INSIDE_FOLDING_RANGE),
4133 ADDMOTION(
"E", motionToEndOfWORD, CAN_LAND_INSIDE_FOLDING_RANGE),
4134 ADDMOTION(
"ge", motionToEndOfPrevWord, CAN_LAND_INSIDE_FOLDING_RANGE),
4135 ADDMOTION(
"gE", motionToEndOfPrevWORD, CAN_LAND_INSIDE_FOLDING_RANGE),
4136 ADDMOTION(
"|", motionToScreenColumn, 0),
4137 ADDMOTION(
"%", motionToMatchingItem, IS_NOT_LINEWISE | CAN_LAND_INSIDE_FOLDING_RANGE),
4138 ADDMOTION(
"`[a-zA-Z^><\\.\\[\\]]", motionToMark, REGEX_PATTERN | CAN_LAND_INSIDE_FOLDING_RANGE),
4139 ADDMOTION(
"'[a-zA-Z^><]", motionToMarkLine, REGEX_PATTERN | CAN_LAND_INSIDE_FOLDING_RANGE),
4140 ADDMOTION(
"[[", motionToPreviousBraceBlockStart, IS_NOT_LINEWISE | CAN_LAND_INSIDE_FOLDING_RANGE),
4141 ADDMOTION(
"]]", motionToNextBraceBlockStart, IS_NOT_LINEWISE | CAN_LAND_INSIDE_FOLDING_RANGE),
4142 ADDMOTION(
"[]", motionToPreviousBraceBlockEnd, IS_NOT_LINEWISE | CAN_LAND_INSIDE_FOLDING_RANGE),
4143 ADDMOTION(
"][", motionToNextBraceBlockEnd, IS_NOT_LINEWISE | CAN_LAND_INSIDE_FOLDING_RANGE),
4144 ADDMOTION(
"*", motionToNextOccurrence, CAN_LAND_INSIDE_FOLDING_RANGE),
4145 ADDMOTION(
"#", motionToPrevOccurrence, CAN_LAND_INSIDE_FOLDING_RANGE),
4146 ADDMOTION(
"H", motionToFirstLineOfWindow, 0),
4147 ADDMOTION(
"M", motionToMiddleLineOfWindow, 0),
4148 ADDMOTION(
"L", motionToLastLineOfWindow, 0),
4149 ADDMOTION(
"gj", motionToNextVisualLine, 0),
4150 ADDMOTION(
"g<down>", motionToNextVisualLine, 0),
4151 ADDMOTION(
"gk", motionToPrevVisualLine, 0),
4152 ADDMOTION(
"g<up>", motionToPrevVisualLine, 0),
4153 ADDMOTION(
"(", motionToPreviousSentence, CAN_LAND_INSIDE_FOLDING_RANGE),
4154 ADDMOTION(
")", motionToNextSentence, CAN_LAND_INSIDE_FOLDING_RANGE),
4155 ADDMOTION(
"{", motionToBeforeParagraph, CAN_LAND_INSIDE_FOLDING_RANGE),
4156 ADDMOTION(
"}", motionToAfterParagraph, CAN_LAND_INSIDE_FOLDING_RANGE),
4159 ADDMOTION(
"iw", textObjectInnerWord, 0),
4160 ADDMOTION(
"aw", textObjectAWord, IS_NOT_LINEWISE),
4161 ADDMOTION(
"iW", textObjectInnerWORD, 0),
4162 ADDMOTION(
"aW", textObjectAWORD, IS_NOT_LINEWISE),
4163 ADDMOTION(
"is", textObjectInnerSentence, IS_NOT_LINEWISE | CAN_LAND_INSIDE_FOLDING_RANGE),
4164 ADDMOTION(
"as", textObjectASentence, IS_NOT_LINEWISE | CAN_LAND_INSIDE_FOLDING_RANGE),
4165 ADDMOTION(
"ip", textObjectInnerParagraph, IS_NOT_LINEWISE | CAN_LAND_INSIDE_FOLDING_RANGE),
4166 ADDMOTION(
"ap", textObjectAParagraph, IS_NOT_LINEWISE | CAN_LAND_INSIDE_FOLDING_RANGE),
4167 ADDMOTION(
"i\"", textObjectInnerQuoteDouble, IS_NOT_LINEWISE | CAN_LAND_INSIDE_FOLDING_RANGE),
4168 ADDMOTION(
"a\"", textObjectAQuoteDouble, IS_NOT_LINEWISE | CAN_LAND_INSIDE_FOLDING_RANGE),
4169 ADDMOTION(
"i'", textObjectInnerQuoteSingle, IS_NOT_LINEWISE | CAN_LAND_INSIDE_FOLDING_RANGE),
4170 ADDMOTION(
"a'", textObjectAQuoteSingle, IS_NOT_LINEWISE | CAN_LAND_INSIDE_FOLDING_RANGE),
4171 ADDMOTION(
"i`", textObjectInnerBackQuote, IS_NOT_LINEWISE | CAN_LAND_INSIDE_FOLDING_RANGE),
4172 ADDMOTION(
"a`", textObjectABackQuote, IS_NOT_LINEWISE | CAN_LAND_INSIDE_FOLDING_RANGE),
4173 ADDMOTION(
"i[()b]", textObjectInnerParen, REGEX_PATTERN | IS_NOT_LINEWISE | CAN_LAND_INSIDE_FOLDING_RANGE),
4174 ADDMOTION(
"a[()b]", textObjectAParen, REGEX_PATTERN | IS_NOT_LINEWISE | CAN_LAND_INSIDE_FOLDING_RANGE),
4175 ADDMOTION(
"i[{}B]", textObjectInnerCurlyBracket, REGEX_PATTERN | IS_NOT_LINEWISE | CAN_LAND_INSIDE_FOLDING_RANGE),
4176 ADDMOTION(
"a[{}B]", textObjectACurlyBracket, REGEX_PATTERN | IS_NOT_LINEWISE | CAN_LAND_INSIDE_FOLDING_RANGE),
4177 ADDMOTION(
"i[><]", textObjectInnerInequalitySign, REGEX_PATTERN | IS_NOT_LINEWISE | CAN_LAND_INSIDE_FOLDING_RANGE),
4178 ADDMOTION(
"a[><]", textObjectAInequalitySign, REGEX_PATTERN | IS_NOT_LINEWISE | CAN_LAND_INSIDE_FOLDING_RANGE),
4179 ADDMOTION(
"i[\\[\\]]", textObjectInnerBracket, REGEX_PATTERN | IS_NOT_LINEWISE | CAN_LAND_INSIDE_FOLDING_RANGE),
4180 ADDMOTION(
"a[\\[\\]]", textObjectABracket, REGEX_PATTERN | IS_NOT_LINEWISE | CAN_LAND_INSIDE_FOLDING_RANGE),
4181 ADDMOTION(
"i,", textObjectInnerComma, IS_NOT_LINEWISE | CAN_LAND_INSIDE_FOLDING_RANGE),
4182 ADDMOTION(
"a,", textObjectAComma, IS_NOT_LINEWISE | CAN_LAND_INSIDE_FOLDING_RANGE),
4184 ADDMOTION(
"/<enter>", motionToIncrementalSearchMatch, IS_NOT_LINEWISE | CAN_LAND_INSIDE_FOLDING_RANGE),
4185 ADDMOTION(
"?<enter>", motionToIncrementalSearchMatch, IS_NOT_LINEWISE | CAN_LAND_INSIDE_FOLDING_RANGE),
A class which provides customized text decorations.
@ ActivateMouseIn
Activate attribute on mouse in.
An Editor command line command.
virtual bool exec(KTextEditor::View *view, const QString &cmd, QString &msg, const KTextEditor::Range &range=KTextEditor::Range::invalid())=0
Execute the command for the given view and cmd string.
The Cursor represents a position in a Document.
constexpr int column() const noexcept
Retrieve the column on which this cursor is situated.
void setColumn(int column) noexcept
Set the cursor column to column.
constexpr bool isValid() const noexcept
Returns whether the current position of this cursor is a valid position (line + column must both be >...
void setLine(int line) noexcept
Set the cursor line to line.
constexpr int line() const noexcept
Retrieve the line on which this cursor is situated.
static constexpr Cursor invalid() noexcept
Returns an invalid cursor.
Backend of KTextEditor::Document related public KTextEditor interfaces.
KTextEditor::Cursor documentEnd() const override
End position of the document.
void joinLines(uint first, uint last)
Unwrap a range of lines.
KTextEditor::MovingRange * newMovingRange(KTextEditor::Range range, KTextEditor::MovingRange::InsertBehaviors insertBehaviors=KTextEditor::MovingRange::DoNotExpand, KTextEditor::MovingRange::EmptyBehavior emptyBehavior=KTextEditor::MovingRange::AllowEmpty) override
Create a new moving range for this document.
QString text(KTextEditor::Range range, bool blockwise=false) const override
Get the document content within the given range.
QString line(int line) const override
Get a single text line.
int lastLine() const
gets the last line number (lines() - 1)
int lines() const override
Get the count of lines of the document.
void textRemoved(KTextEditor::Document *document, KTextEditor::Range range, const QString &oldText)
The document emits this signal whenever range was removed, i.e.
bool editStart()
Enclose editor actions with editStart() and editEnd() to group them.
bool wrapText(int startLine, int endLine)
Warp a line.
Kate::TextLine plainKateTextLine(int i)
Return line lineno.
void textInsertedRange(KTextEditor::Document *document, KTextEditor::Range range)
The document emits this signal whenever text was inserted.
Kate::TextLine kateTextLine(int i)
Same as plainKateTextLine(), except that it is made sure the line is highlighted.
bool editEnd()
End a editor operation.
int lineLength(int line) const override
Get the length of a given line in characters.
A KParts derived class representing a text document.
void aboutToInvalidateMovingInterfaceContent(KTextEditor::Document *document)
This signal is emitted before the ranges of a document are invalidated and the revisions are deleted ...
void aboutToDeleteMovingInterfaceContent(KTextEditor::Document *document)
This signal is emitted before the cursors/ranges/revisions of a document are destroyed as the documen...
A range that is bound to a specific Document, and maintains its position.
virtual void setAttribute(Attribute::Ptr attribute)=0
Sets the currently active attribute for this range.
virtual void setAttributeOnlyForViews(bool onlyForViews)=0
Set if this range's attribute is only visible in views, not for example prints.
virtual void setView(View *view)=0
Sets the currently active view for this range.
virtual void setZDepth(qreal zDepth)=0
Set the current Z-depth of this range.
@ DoNotExpand
Don't expand to encapsulate new characters in either direction. This is the default.
An object representing a section of text, from one Cursor to another.
constexpr Cursor end() const noexcept
Get the end position of this range.
constexpr Cursor start() const noexcept
Get the start position of this range.
void setRange(Range range) noexcept
Set the start and end cursors to range.start() and range.end() respectively.
constexpr bool isValid() const noexcept
Validity check.
void configChanged(KTextEditor::View *view)
This signal is emitted whenever the current view configuration is changed.
bool handleKeypress(const QKeyEvent *e) override
parses a key stroke to check if it's a valid (part of) a command
virtual const std::vector< Command > & commands()
Return commands available for this mode.
bool commandEnterInsertModeLast()
enter insert mode at the last insert position
void resetParser()
(re)set to start configuration.
bool commandEnterInsertModeAppendEOL()
start insert mode after the last character of the line
bool commandEnterInsertMode()
enter insert mode at the cursor position
int getFirstNonBlank(int line=-1) const
Get the index of the first non-blank character from the given line.
virtual const std::vector< Motion > & motions()
Return motions available for this mode.
bool commandEnterInsertModeAppend()
enter insert mode after the current character
int lineToVisibleLine(int line) const
Convert a text buffer line to a visible line number.
int visibleLineToLine(int visibleLine) const
Convert a visible line number to a line number in the text buffer.
Class representing a single text line.
int firstChar() const
Returns the position of the first non-whitespace character.
Q_SCRIPTABLE Q_NOREPLY void start()
QString i18n(const char *text, const TYPE &arg...)
KCOREADDONS_EXPORT Result match(QStringView pattern, QStringView str)
const QList< QKeySequence > & end()
bool isLower(char32_t ucs4)
bool isSpace(char32_t ucs4)
bool isUpper(char32_t ucs4)
char32_t toLower(char32_t ucs4)
char32_t toUpper(char32_t ucs4)
Qt::KeyboardModifiers modifiers() const const
const_reference at(qsizetype i) const const
bool isEmpty() const const
void push_back(parameter_type value)
void remove(qsizetype i, qsizetype n)
qsizetype size() const const
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
UseUnicodePropertiesOption
iterator insert(const T &value)
qsizetype count() const const
QString & append(QChar ch)
const QChar at(qsizetype position) const const
qsizetype indexOf(QChar ch, qsizetype from, Qt::CaseSensitivity cs) const const
bool isEmpty() const const
qsizetype lastIndexOf(QChar ch, Qt::CaseSensitivity cs) const const
qsizetype length() const const
QString mid(qsizetype position, qsizetype n) const const
QString number(double n, char format, int precision)
QString & prepend(QChar ch)
QString & remove(QChar ch, Qt::CaseSensitivity cs)
QString repeated(qsizetype times) const const
QString & replace(QChar before, QChar after, Qt::CaseSensitivity cs)
QString right(qsizetype n) const const
qsizetype size() const const
bool startsWith(QChar c, Qt::CaseSensitivity cs) const const
QString toLower() const const
QString toUpper() const const
QString trimmed() const const
QTextStream & dec(QTextStream &stream)
QTextStream & hex(QTextStream &stream)
QTextStream & oct(QTextStream &stream)
QTextStream & right(QTextStream &stream)
QFuture< QtPrivate::MapResultType< Iterator, MapFunctor > > mapped(Iterator begin, Iterator end, MapFunctor &&function)
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)