KTextEditor

replacevimode.h
1/*
2 SPDX-FileCopyrightText: 2008 Erlend Hamberg <ehamberg@gmail.com>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#ifndef KATEVI_REPLACE_VI_MODE_H
8#define KATEVI_REPLACE_VI_MODE_H
9
10#include <vimode/modes/modebase.h>
11
12namespace KateVi
13{
14/**
15 * Commands for the vi replace mode
16 */
17class ReplaceViMode : public ModeBase
18{
19public:
20 explicit ReplaceViMode(InputModeManager *viInputModeManager, KTextEditor::ViewPrivate *view, KateViewInternal *viewInternal);
21
22 /// Update the track of overwritten characters with the \p s character.
23 inline void overwrittenChar(const QChar &s)
24 {
25 m_overwritten += s;
26 }
27
28 void setCount(int count)
29 {
30 m_count = count;
31 }
32
33protected:
34 /**
35 * Checks if the key is a valid command in replace mode.
36 *
37 * @returns true if a command was completed and executed, false otherwise.
38 */
39 bool handleKeypress(const QKeyEvent *e) override;
40
41private:
42 /**
43 * Replace the character at the current column with a character from
44 * the same column but in a different line.
45 *
46 * @param offset The offset of the line to be picked. This value is
47 * relative to the current line.
48 * @returns true if the character could be replaced, false otherwise.
49 */
50 bool commandInsertFromLine(int offset);
51
52 // Auxiliar methods for moving the cursor in replace mode.
53
54 bool commandMoveOneWordLeft();
55 bool commandMoveOneWordRight();
56
57 // Auxiliar methods for removing modifications.
58
59 void backspace();
60 void commandBackWord();
61 void commandBackLine();
62 void leaveReplaceMode();
63
64protected:
65 unsigned int m_count;
66
67private:
68 /// Keeps track of the characters that have been overwritten so far.
69 QString m_overwritten;
70};
71
72}
73
74#endif /* KATEVI_REPLACE_VI_MODE_H */
Commands for the vi replace mode.
bool handleKeypress(const QKeyEvent *e) override
Checks if the key is a valid command in replace mode.
void overwrittenChar(const QChar &s)
Update the track of overwritten characters with the s character.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Feb 24 2024 20:00:58 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.