KTextEditor

insertvimode.h
1/*
2 SPDX-FileCopyrightText: 2008-2011 Erlend Hamberg <ehamberg@gmail.com>
3 SPDX-FileCopyrightText: 2011 Svyatoslav Kuzmich <svatoslav1@gmail.com>
4 SPDX-FileCopyrightText: 2012-2013 Simon St James <kdedevel@etotheipiplusone.com>
5
6 SPDX-License-Identifier: LGPL-2.0-or-later
7*/
8
9#ifndef KATEVI_INSERT_VI_MODE_H
10#define KATEVI_INSERT_VI_MODE_H
11
12#include <vimode/modes/modebase.h>
13
14namespace KTextEditor
15{
16class ViewPrivate;
17}
18class KateViewInternal;
19
20class QKeyEvent;
21
22namespace KateVi
23{
24class Motion;
25
26/**
27 * Commands for the vi insert mode
28 */
29enum BlockInsert {
30 None,
31 Prepend,
32 Append,
33 AppendEOL
34};
35
36class InsertViMode : public ModeBase
37{
38public:
39 explicit InsertViMode(InputModeManager *viInputModeManager, KTextEditor::ViewPrivate *view, KateViewInternal *viewInternal);
40 ~InsertViMode() override;
41
42 bool handleKeypress(const QKeyEvent *e) override;
43
44 bool commandInsertFromAbove();
45 bool commandInsertFromBelow();
46
47 bool commandDeleteWord();
48 bool commandDeleteLine();
49 bool commandNewLine();
50 bool commandDeleteCharBackward();
51
52 bool commandIndent();
53 bool commandUnindent();
54
55 bool commandToFirstCharacterInFile();
56 bool commandToLastCharacterInFile();
57
58 bool commandMoveOneWordLeft();
59 bool commandMoveOneWordRight();
60
61 bool commandCompleteNext();
62 bool commandCompletePrevious();
63
64 bool commandInsertContentOfRegister();
65 bool commandSwitchToNormalModeForJustOneCommand();
66
67 void setBlockPrependMode(Range blockRange);
68 void setBlockAppendMode(Range blockRange, BlockInsert b);
69
70 void setCount(int count)
71 {
72 m_count = count;
73 }
74 void setCountedRepeatsBeginOnNewLine(bool countedRepeatsBeginOnNewLine)
75 {
76 m_countedRepeatsBeginOnNewLine = countedRepeatsBeginOnNewLine;
77 }
78
79protected:
80 void leaveInsertMode(bool force = false);
81 void completionFinished();
82
83protected:
84 BlockInsert m_blockInsert;
85 unsigned int m_eolPos; // length of first line in eol mode before text is appended
86 Range m_blockRange;
87
88 QString m_keys;
89 bool m_waitingRegister;
90
91 unsigned int m_count;
92 bool m_countedRepeatsBeginOnNewLine;
93
94 bool m_isExecutingCompletion;
95 QString m_textInsertedByCompletion;
96 KTextEditor::Cursor m_textInsertedByCompletionEndPos;
97
98private:
99 KTEXTEDITOR_NO_EXPORT
100 void textInserted(KTextEditor::Document *document, KTextEditor::Range range);
101};
102}
103
104#endif /* KATEVI_INSERT_VI_MODE_H */
combined class for motions and text objects.
Definition motion.h:23
The KTextEditor namespace contains all the public API that is required to use the KTextEditor compone...
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Jan 24 2025 11:55:25 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.