KTextEditor

commandmode.h
1/*
2 SPDX-FileCopyrightText: 2013-2016 Simon St James <kdedevel@etotheipiplusone.com>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#ifndef KATEVI_EMULATED_COMMAND_BAR_COMMANDMODE_H
8#define KATEVI_EMULATED_COMMAND_BAR_COMMANDMODE_H
9
10#include "activemode.h"
11
12#include <QHash>
13
14#include <KCompletion>
15
16namespace KTextEditor
17{
18class ViewPrivate;
19class Command;
20}
21
22namespace KateVi
23{
24class EmulatedCommandBar;
25class MatchHighlighter;
26class InteractiveSedReplaceMode;
27class Completer;
28class InputModeManager;
29
30class CommandMode : public ActiveMode
31{
32public:
33 CommandMode(EmulatedCommandBar *emulatedCommandBar,
34 MatchHighlighter *matchHighlighter,
35 InputModeManager *viInputModeManager,
36 KTextEditor::ViewPrivate *view,
37 QLineEdit *edit,
38 InteractiveSedReplaceMode *interactiveSedReplaceMode,
39 Completer *completer);
40 ~CommandMode() override
41 {
42 }
43 bool handleKeyPress(const QKeyEvent *keyEvent) override;
44 void editTextChanged(const QString &newText) override;
45 CompletionStartParams completionInvoked(Completer::CompletionInvocation invocationType) override;
46 void completionChosen() override;
47 void deactivate(bool wasAborted) override;
48 QString executeCommand(const QString &commandToExecute);
49
50private:
51 CompletionStartParams activateCommandCompletion();
52 CompletionStartParams activateCommandHistoryCompletion();
53 CompletionStartParams activateSedFindHistoryCompletion();
54 CompletionStartParams activateSedReplaceHistoryCompletion();
55 QString withoutRangeExpression();
56 QString rangeExpression();
57 QString withSedFindTermReplacedWith(const QString &newFindTerm);
58 QString withSedDelimiterEscaped(const QString &text);
59 bool isCursorInFindTermOfSed();
60 bool isCursorInReplaceTermOfSed();
61 QString sedFindTerm();
62 QString sedReplaceTerm();
63 /**
64 * Stuff to do with expressions of the form:
65 *
66 * s/find/replace/<sedflags>
67 */
68 struct ParsedSedExpression {
69 bool parsedSuccessfully;
70 int findBeginPos;
71 int findEndPos;
72 int replaceBeginPos;
73 int replaceEndPos;
74 QChar delimiter;
75 };
76 /**
77 * The "range expression" is the (optional) expression before the command that describes
78 * the range over which the command should be run e.g. '<,'>. @see CommandRangeExpressionParser
79 */
80 CommandMode::ParsedSedExpression parseAsSedExpression();
81 int commandBeforeCursorBegin();
82 QLineEdit *m_edit;
83 InteractiveSedReplaceMode *m_interactiveSedReplaceMode;
84 Completer *m_completer;
85 KCompletion m_cmdCompletion;
87 KTextEditor::Command *queryCommand(const QString &cmd) const;
88};
89}
90
91#endif
An Editor command line command.
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-2024 The KDE developers.
Generated on Fri Jun 14 2024 11:57:26 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.