KTextEditor

visualvimode.h
1/*
2 SPDX-FileCopyrightText: 2008-2009 Erlend Hamberg <ehamberg@gmail.com>
3 SPDX-FileCopyrightText: 2009 Paul Gideon Dann <pdgiddie@gmail.com>
4 SPDX-FileCopyrightText: 2011 Svyatoslav Kuzmich <svatoslav1@gmail.com>
5 SPDX-FileCopyrightText: 2012-2013 Simon St James <kdedevel@etotheipiplusone.com>
6
7 SPDX-License-Identifier: LGPL-2.0-or-later
8*/
9
10#ifndef KATEVI_VISUAL_VI_MODE_H
11#define KATEVI_VISUAL_VI_MODE_H
12
13#include <ktexteditor/range.h>
14#include <vimode/modes/normalvimode.h>
15
16namespace KateVi
17{
18class InputModeManager;
19
20class VisualViMode : public NormalViMode
21{
22public:
23 explicit VisualViMode(InputModeManager *viInputModeManager, KTextEditor::ViewPrivate *view, KateViewInternal *viewInternal);
24
25 void init();
26
27 bool isVisualLine() const
28 {
29 return m_mode == VisualLineMode;
30 }
31
32 bool isVisualBlock() const
33 {
34 return m_mode == VisualBlockMode;
35 }
36
37 void switchStartEnd();
38 void reset() override;
39 void setVisualModeType(const ViMode mode);
40 void saveRangeMarks();
41
42 void setStart(const KTextEditor::Cursor c)
43 {
44 m_start = c;
45 }
46
47 KTextEditor::Cursor getStart()
48 {
49 return m_start;
50 }
51
52 void goToPos(const KTextEditor::Cursor c);
53
54 ViMode getLastVisualMode() const
55 {
56 return m_lastVisualMode;
57 }
58
59 const KTextEditor::Cursor getStart() const
60 {
61 return m_start;
62 }
63
64 // Selects all lines in range;
65 void selectLines(KTextEditor::Range range);
66
67 // Selects range between c1 and c2, but includes the end cursor position.
68 void selectInclusive(const KTextEditor::Cursor c1, const KTextEditor::Cursor c2);
69
70 // Select block between c1 and c2.
71 void selectBlockInclusive(const KTextEditor::Cursor c1, const KTextEditor::Cursor c2);
72
73protected:
74 /**
75 * Called when a motion/text object is used. Updates the cursor position
76 * and modifies the range. A motion will only modify the end of the range
77 * (i.e. move the cursor) while a text object may modify both the start and
78 * the end. Overridden from the ModeBase class.
79 */
80 void goToPos(const Range &r) override;
81
82 /**
83 * Return commands available for this mode.
84 * Overwritten in sub classes to replace them, must be a stable reference!
85 */
86 const std::vector<Command> &commands() override;
87
88 /**
89 * Return motions available for this mode.
90 * Overwritten in sub classes to replace them, must be a stable reference!
91 */
92 const std::vector<Motion> &motions() override;
93
94public:
95 /**
96 * Updates the visual mode's range to reflect a new cursor position. This
97 * needs to be called if modifying the range from outside the vi mode, e.g.
98 * via mouse selection.
99 */
100 void updateSelection();
101
102private:
103 KTextEditor::Cursor m_start;
104 ViMode m_mode, m_lastVisualMode;
105};
106}
107
108#endif /* KATEVI_VISUAL_VI_MODE_H */
The Cursor represents a position in a Document.
Definition cursor.h:75
An object representing a section of text, from one Cursor to another.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:11:27 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.