KTextEditor

katescriptmanager.h
1 /*
2  SPDX-FileCopyrightText: 2008 Paul Giannaros <[email protected]>
3  SPDX-FileCopyrightText: 2009-2018 Dominik Haumann <[email protected]>
4  SPDX-FileCopyrightText: 2010 Joseph Wenninger <[email protected]>
5 
6  SPDX-License-Identifier: LGPL-2.0-or-later
7 */
8 
9 #ifndef KATE_SCRIPT_MANAGER_H
10 #define KATE_SCRIPT_MANAGER_H
11 
12 #include <KTextEditor/Command>
13 #include <ktexteditor/cursor.h>
14 
15 #include <QVector>
16 
17 #include "katecommandlinescript.h"
18 #include "kateindentscript.h"
19 #include "katescript.h"
20 
21 class QString;
22 
28 {
29  Q_OBJECT
30 
32  static KateScriptManager *m_instance;
33 
34 public:
35  ~KateScriptManager() override;
36 
39  {
40  return m_commandLineScripts;
41  }
42 
49  KateIndentScript *indenter(const QString &language);
50 
51  //
52  // KTextEditor::Command
53  //
54 public:
62  bool exec(KTextEditor::View *view, const QString &cmd, QString &errorMsg, const KTextEditor::Range &) override;
63 
71  bool help(KTextEditor::View *view, const QString &cmd, QString &msg) override;
72 
73  static KateScriptManager *self()
74  {
75  if (m_instance == nullptr) {
76  m_instance = new KateScriptManager();
77  }
78  return m_instance;
79  }
80 
81  //
82  // Helper methods
83  //
84 public:
88  void collect();
89 
90 public:
91  KateIndentScript *indentationScript(const QString &scriptname)
92  {
93  return m_indentationScriptMap.value(scriptname);
94  }
95 
96  int indentationScriptCount()
97  {
98  return m_indentationScripts.size();
99  }
100  KateIndentScript *indentationScriptByIndex(int index)
101  {
102  return m_indentationScripts[index];
103  }
104 
105 public:
107  void reload();
108 
109 Q_SIGNALS:
111  void reloaded();
112 
113 private:
115  QVector<KateCommandLineScript *> m_commandLineScripts;
116 
118  QList<KateIndentScript *> m_indentationScripts;
119 
121  QHash<QString, KateIndentScript *> m_indentationScriptMap;
122 
124  QHash<QString, QVector<KateIndentScript *>> m_languageToIndenters;
125 };
126 
127 #endif
Manage the scripts on disks – find them and query them.
bool exec(KTextEditor::View *view, const QString &cmd, QString &errorMsg, const KTextEditor::Range &) override
execute command
Q_SIGNALSQ_SIGNALS
int size() const const
const QVector< KateCommandLineScript * > & commandLineScripts()
Get all scripts available in the command line.
void collect()
Collect all scripts.
Q_OBJECTQ_OBJECT
void reload()
explicitly reload all scripts
A specialized class for scripts that are of type ScriptType::Indentation.
An object representing a section of text, from one Cursor to another.
An Editor command line command.
const T value(const Key &key) const const
bool help(KTextEditor::View *view, const QString &cmd, QString &msg) override
get help for a command
A text widget with KXMLGUIClient that represents a Document.
Definition: view.h:143
void reloaded()
this signal is emitted when all scripts are deleted and reloaded again.
KateIndentScript * indenter(const QString &language)
Get an indentation script for the given language – if there is more than one result, this will return the script with the highest priority.
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Sat Sep 19 2020 22:57:20 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.