KTextEditor

katecmd.h
1/*
2 SPDX-FileCopyrightText: 2001-2010 Christoph Cullmann <cullmann@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#ifndef _KATE_CMD_H
8#define _KATE_CMD_H
9
10#include <KCompletion>
11
12#include <QHash>
13#include <QStringList>
14
15namespace KTextEditor
16{
17class Command;
18}
19
20class KateCmd
21{
22public:
23 KateCmd();
24 ~KateCmd();
25
26 static KateCmd *self();
27
28 bool registerCommand(KTextEditor::Command *cmd);
29 bool unregisterCommand(KTextEditor::Command *cmd);
30 KTextEditor::Command *queryCommand(const QString &cmd) const;
31 QList<KTextEditor::Command *> commands() const;
32 QStringList commandList() const;
33
34 QStringList cmds();
35 void appendHistory(const QString &cmd);
36 const QString fromHistory(int i) const;
37 uint historyLength() const
38 {
39 return m_history.count();
40 }
41
42 KCompletion *commandCompletionObject();
43
44private:
46 QStringList m_cmds;
47 QStringList m_history;
48 KCompletion m_cmdCompletion; // shared completion object for all KateCmdLineEdits in each KTE::View
49};
50
51/**
52 * A KCompletion object that completes last ?unquoted? word in the string
53 * passed. Do not mistake "shell" for anything related to quoting, this
54 * simply mimics shell tab completion by completing the last word in the
55 * provided text.
56 */
58{
59public:
61
62 /**
63 * Finds completions to the given text.
64 * The first match is returned and emitted in the signal match().
65 * @param text the text to complete
66 * @return the first match, or QString() if not found
67 */
68 QString makeCompletion(const QString &text) override;
69
70protected:
71 // Called by KCompletion
72 void postProcessMatch(QString *match) const override;
73 void postProcessMatches(QStringList *matches) const override;
74 void postProcessMatches(KCompletionMatches *matches) const override;
75
76private:
77 /**
78 * Split text at the last unquoted space
79 *
80 * @param text_start will be set to the text at the left, including the space
81 * @param text_compl Will be set to the text at the right. This is the text to complete.
82 */
83 void splitText(const QString &text, QString &text_start, QString &text_compl) const;
84
85 QChar m_word_break_char;
86 QChar m_quote_char1;
87 QChar m_quote_char2;
88 QChar m_escape_char;
89
90 QString m_text_start;
91 QString m_text_compl;
92};
93
94#endif
void matches(const QStringList &matchlist)
void match(const QString &item)
An Editor command line command.
A KCompletion object that completes last ?unquoted? word in the string passed.
Definition katecmd.h:58
QString makeCompletion(const QString &text) override
Finds completions to the given text.
Definition katecmd.cpp:153
The KTextEditor namespace contains all the public API that is required to use the KTextEditor compone...
qsizetype count() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Sep 27 2024 11:56:36 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.