• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • applications API Reference
  • KDE Home
  • Contact Us
 

Kate

  • kde-4.14
  • applications
  • kate
  • part
  • script
katescriptmanager.h
Go to the documentation of this file.
1 // This file is part of the KDE libraries
2 // Copyright (C) 2008 Paul Giannaros <paul@giannaros.org>
3 // Copyright (C) 2009 Dominik Haumann <dhaumann kde org>
4 // Copyright (C) 2010 Joseph Wenninger <jowenn@kde.org>
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Library General Public
8 // License as published by the Free Software Foundation; either
9 // version 2 of the License, or (at your option) version 3.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Library General Public License for more details.
15 //
16 // You should have received a copy of the GNU Library General Public License
17 // along with this library; see the file COPYING.LIB. If not, write to
18 // the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 // Boston, MA 02110-1301, USA.
20 
21 #ifndef KATE_SCRIPT_MANAGER_H
22 #define KATE_SCRIPT_MANAGER_H
23 
24 #include <ktexteditor/commandinterface.h>
25 #include <ktexteditor/cursor.h>
26 
27 #include <kdebug.h>
28 
29 #include <QVector>
30 
31 #include "katescript.h"
32 #include "kateindentscript.h"
33 #include "katecommandlinescript.h"
34 #include "katetemplatescript.h"
35 
36 class QString;
37 
38 
43 class KateScriptManager : public QObject, public KTextEditor::Command
44 {
45  Q_OBJECT
46 
47  KateScriptManager();
48  static KateScriptManager* m_instance;
49 
50  public:
51  virtual ~KateScriptManager();
52 
54  const QVector<KateCommandLineScript*> &commandLineScripts() { return m_commandLineScripts; }
55 
62  KateIndentScript *indenter(const QString &language);
63 
64  //
65  // KTextEditor::Command
66  //
67  public:
75  bool exec(KTextEditor::View *view, const QString &cmd, QString &errorMsg);
76 
84  bool help(KTextEditor::View *view, const QString &cmd, QString &msg);
85 
90  const QStringList &cmds();
91 
92  static KateScriptManager* self() {
93  if (m_instance == 0) {
94  m_instance = new KateScriptManager();
95  }
96  return m_instance;
97  }
98 
99  //
100  // Helper methods
101  //
102  public:
110  void collect(bool force = false);
111 
116  static bool parseMetaInformation(const QString& url, QHash<QString, QString> &pairs);
117 
118  public:
119  KateIndentScript *indentationScript (const QString &scriptname) { return m_indentationScriptMap.value(scriptname); }
120 
121  int indentationScriptCount () { return m_indentationScripts.size(); }
122  KateIndentScript *indentationScriptByIndex (int index) { return m_indentationScripts[index]; }
123 
124  public:
126  void reload();
127 
128  Q_SIGNALS:
130  void reloaded();
131 
132  private:
134  QVector<KateCommandLineScript*> m_commandLineScripts;
135 
137  QList<KateIndentScript*> m_indentationScripts;
138 
140  QHash<QString, KateIndentScript*> m_indentationScriptMap;
141 
143  QHash<QString, QVector<KateIndentScript*> > m_languageToIndenters;
144 
145 
146  //
147  // Template handling
148  //
149  public:
151  KTextEditor::TemplateScript* registerTemplateScript (QObject* owner, const QString& script);
153  void unregisterTemplateScript(KTextEditor::TemplateScript* templateScript);
154 
155  KateTemplateScript* templateScript(KTextEditor::TemplateScript* templateScript);
156 
157  public Q_SLOTS:
158  void slotTemplateScriptOwnerDestroyed(QObject* owner);
159 
160  private:
161  QMultiMap<QObject*, KTextEditor::TemplateScript*> m_ownerScript;
162  QList<KTextEditor::TemplateScript*> m_templateScripts;
163 };
164 
165 
166 
167 #endif
168 
169 // kate: space-indent on; indent-width 2; replace-tabs on;
KateScriptManager
Manage the scripts on disks – find them and query them.
Definition: katescriptmanager.h:43
KateScriptManager::help
bool help(KTextEditor::View *view, const QString &cmd, QString &msg)
get help for a command
Definition: katescriptmanager.cpp:353
KateScriptManager::parseMetaInformation
static bool parseMetaInformation(const QString &url, QHash< QString, QString > &pairs)
Extract the meta data from the script at url and put in pairs.
Definition: katescriptmanager.cpp:275
KateScriptManager::indentationScriptCount
int indentationScriptCount()
Definition: katescriptmanager.h:121
KateScriptManager::exec
bool exec(KTextEditor::View *view, const QString &cmd, QString &errorMsg)
execute command
Definition: katescriptmanager.cpp:333
katetemplatescript.h
katescript.h
kateindentscript.h
QList::size
int size() const
QHash< QString, QString >
QObject
katecommandlinescript.h
KateScriptManager::indentationScript
KateIndentScript * indentationScript(const QString &scriptname)
Definition: katescriptmanager.h:119
KateScriptManager::indentationScriptByIndex
KateIndentScript * indentationScriptByIndex(int index)
Definition: katescriptmanager.h:122
KateScriptManager::reload
void reload()
explicitly reload all scripts
Definition: katescriptmanager.cpp:325
QString
QList< KateIndentScript * >
KateIndentScript
A specialized class for scripts that are of type KateScriptInformation::IndentationScript.
Definition: kateindentscript.h:94
QStringList
KateScriptManager::collect
void collect(bool force=false)
Find all of the scripts matching the wildcard directory.
Definition: katescriptmanager.cpp:89
QHash::value
const T value(const Key &key) const
KateScriptManager::~KateScriptManager
virtual ~KateScriptManager()
Definition: katescriptmanager.cpp:52
KateScriptManager::unregisterTemplateScript
void unregisterTemplateScript(KTextEditor::TemplateScript *templateScript)
unregister a given script
Definition: katescriptmanager.cpp:389
KateScriptManager::cmds
const QStringList & cmds()
supported commands as prefixes
Definition: katescriptmanager.cpp:366
KateScriptManager::registerTemplateScript
KTextEditor::TemplateScript * registerTemplateScript(QObject *owner, const QString &script)
managing of scripts for the template handler.
Definition: katescriptmanager.cpp:378
QVector< KateCommandLineScript * >
KateScriptManager::commandLineScripts
const QVector< KateCommandLineScript * > & commandLineScripts()
Get all scripts available in the command line.
Definition: katescriptmanager.h:54
QMultiMap< QObject *, KTextEditor::TemplateScript * >
KateTemplateScript
Definition: katetemplatescript.h:28
KateScriptManager::slotTemplateScriptOwnerDestroyed
void slotTemplateScriptOwnerDestroyed(QObject *owner)
Definition: katescriptmanager.cpp:400
KateScriptManager::reloaded
void reloaded()
this signal is emitted when all scripts are deleted and reloaded again.
KateScriptManager::indenter
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.
Definition: katescriptmanager.cpp:60
KateScriptManager::templateScript
KateTemplateScript * templateScript(KTextEditor::TemplateScript *templateScript)
Definition: katescriptmanager.cpp:410
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Sat May 9 2020 03:56:58 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

Kate

Skip menu "Kate"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

applications API Reference

Skip menu "applications API Reference"
  •   kate
  •       kate
  •   KTextEditor
  •   Kate
  • Konsole

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal