aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiquel Sabaté <mikisabate@gmail.com>2014-01-20 17:09:21 (GMT)
committerMiquel Sabaté <mikisabate@gmail.com>2014-01-20 17:09:21 (GMT)
commit55186a6b94135e60cb1ccf6064f26d352b90dce1 (patch)
tree25c83cdeb12cc886043a4a4517e904d8323977df
parenta5f5290b7b8ab5a299ab85d851bd7ec8d3058d61 (diff)
Removed the KateScriptConsole.
REVIEW: 115156
-rw-r--r--part/CMakeLists.txt1
-rw-r--r--part/script/katescriptconsole.cpp155
-rw-r--r--part/script/katescriptconsole.h102
-rw-r--r--part/view/kateview.cpp26
-rw-r--r--part/view/kateview.h5
5 files changed, 0 insertions, 289 deletions
diff --git a/part/CMakeLists.txt b/part/CMakeLists.txt
index 57162d9..51af1b8 100644
--- a/part/CMakeLists.txt
+++ b/part/CMakeLists.txt
@@ -81,7 +81,6 @@ script/katecommandlinescript.cpp
script/katetemplatescript.cpp
script/katescriptmanager.cpp
script/katescriptaction.cpp
-script/katescriptconsole.cpp
# scripting wrappers
script/katescriptdocument.cpp
diff --git a/part/script/katescriptconsole.cpp b/part/script/katescriptconsole.cpp
deleted file mode 100644
index 4864535..0000000
--- a/part/script/katescriptconsole.cpp
+++ /dev/null
@@ -1,155 +0,0 @@
-/* This file is part of the KDE libraries
- Copyright (C) 2010 Miquel Sabaté <mikisabate@gmail.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-*/
-
-
-//BEGIN Includes
-// Qt
-#include <QtCore/QFile>
-#include <QtGui/QLabel>
-#include <QtGui/QVBoxLayout>
-#include <QtGui/QPushButton>
-#include <QtGui/QTextEdit>
-
-// KDE
-#include <KStandardDirs>
-#include <KLocale>
-
-// Kate
-#include "katescriptconsole.h"
-#include "katetemplatescript.h"
-//END Includes
-
-
-//BEGIN KateScriptConsoleEngine
-KateScriptConsoleEngine::KateScriptConsoleEngine(KateView * view)
- : m_view (view)
-{
- m_utilsUrl = KGlobal::dirs()->findResource("data", "katepart/script/commands/utils.js");
-}
-
-KateScriptConsoleEngine::~KateScriptConsoleEngine()
-{
- /* There's nothing to do here */
-}
-
-const QString & KateScriptConsoleEngine::execute(const QString & text)
-{
- static QString msg;
- msg = "";
- QString name = getFirstFunctionName(text, msg);
- if (name.isEmpty() && !msg.isEmpty()) // Error
- return msg;
-
- QFile file(m_utilsUrl);
- if (!file.open(QFile::ReadOnly)) {
- msg = i18n("Error: cannot open utils.js");
- return msg;
- }
- QString utilsCode = file.readAll();
- file.close();
-
- QString funcCode;
- if (name.isEmpty()) { // It's a command
- name = "foo";
- funcCode = utilsCode + "function foo() { " + text + " }";
- } else // It's a set of functions
- funcCode = utilsCode + text;
- KateTemplateScript script(funcCode);
- msg = script.invoke(m_view, name, "");
- if (msg.isEmpty())
- msg = i18n("Syntax Error: Parse error");
- return msg;
-}
-
-const QString KateScriptConsoleEngine::getFirstFunctionName(const QString & text, QString & msg)
-{
- QString name = "";
- QRegExp reg("(function)");
- int i = reg.indexIn(text);
- if (i < 0) // there's no defined functions
- return "";
- i += 8; // "function"
- for (; text[i] != '('; ++i) {
- if (text[i] == ' ') // avoid blank spaces
- continue;
- if (text[i] == '{' || text[i] == '}' || text[i] == ')') { // bad ...
- msg = i18n("Error: There are bad defined functions");
- return "";
- }
- name.append(text[i]);
- }
- return name;
-}
-//END KateScriptConsoleEngine
-
-
-//BEGIN KateScriptConsole
-KateScriptConsole::KateScriptConsole(KateView * view, QWidget * parent)
- : KateViewBarWidget (true, parent)
- , m_view (view)
-{
- Q_ASSERT(m_view != NULL);
-
- layout = new QVBoxLayout();
- centralWidget()->setLayout(layout);
- layout->setMargin(0);
- hLayout = new QHBoxLayout;
- m_result = new QLabel(this);
- m_edit = new QTextEdit(this);
- m_execute = new QPushButton(i18n("Execute"), this);
- m_execute->setIcon(KIcon("quickopen"));
- connect(m_execute, SIGNAL(clicked()), this, SLOT(executePressed()));
-
- layout->addWidget(m_edit);
- hLayout->addWidget(m_result);
- hLayout->addWidget(m_execute, 1, Qt::AlignRight);
- layout->addLayout(hLayout);
-
- m_engine = new KateScriptConsoleEngine(m_view);
-}
-
-KateScriptConsole::~KateScriptConsole()
-{
- delete m_engine;
-}
-
-void KateScriptConsole::closed()
-{
- if (viewBar())
- viewBar()->removeBarWidget(this);
-}
-
-void KateScriptConsole::executePressed()
-{
- QString text = m_edit->toPlainText();
- QString msg;
- if (!text.isEmpty()) {
- msg = m_engine->execute(text);
- m_result->setText("<b>" + msg + "</b>");
- } else
- m_result->setText("<b>" + i18n("There's no code to execute") + "</b>");
-}
-//END KateScriptConsole
-
-
-#include "katescriptconsole.moc"
-
-
-// kate: space-indent on; indent-width 2; replace-tabs on;
-
diff --git a/part/script/katescriptconsole.h b/part/script/katescriptconsole.h
deleted file mode 100644
index 1efde82..0000000
--- a/part/script/katescriptconsole.h
+++ /dev/null
@@ -1,102 +0,0 @@
-/* This file is part of the KDE libraries
- Copyright (C) 2010 Miquel Sabaté <mikisabate@gmail.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-*/
-
-
-#ifndef KATE_SCRIPT_CONSOLE_H
-#define KATE_SCRIPT_CONSOLE_H
-
-
-#include "kateviewhelpers.h"
-
-class QTextEdit;
-class QPushButton;
-class QLabel;
-class QVBoxLayout;
-class QHBoxLayout;
-
-
-/**
- * Manage JavaScript, allowing the user directly type commands as in
- * KateCommnadLineBar environment. It also allows the user to define
- * his own JavaScript functions and to redefine each one of them.
- */
-class KateScriptConsoleEngine
-{
- public:
- /** Constructor + Destructor */
- KateScriptConsoleEngine(KateView * view);
- virtual ~KateScriptConsoleEngine();
-
- /**
- * Execute a command or a set of functions
- * @param text text containing a command or a set of functions.
- * @return a printable message about the execution.
- */
- const QString & execute(const QString & text);
-
- private:
- /** Url of utils.js file */
- QString m_utilsUrl;
-
- /** Just a Kate view :) */
- KateView * m_view;
-
- private:
- /**
- * Get the name of the first defined function
- * @param text text containing a command or a set of functions.
- * @param msg an error string
- * @return the name of the first function defined or a void QString if
- * there's no functions.
- */
- const QString getFirstFunctionName(const QString & text, QString & msg);
-};
-
-
-class KateScriptConsole : public KateViewBarWidget
-{
- Q_OBJECT
-
- public:
- KateScriptConsole(KateView * view, QWidget * parent = NULL);
- virtual ~KateScriptConsole();
-
- protected:
- // overridden
- virtual void closed();
-
- private:
- QVBoxLayout * layout;
- QHBoxLayout * hLayout;
- QTextEdit * m_edit;
- QPushButton * m_execute;
- QLabel * m_result;
- KateView * m_view;
- KateScriptConsoleEngine * m_engine;
-
- public slots:
- void executePressed();
-};
-
-
-#endif /* KATE_SCRIPT_CONSOLE_H */
-
-
-// kate: space-indent on; indent-width 2; replace-tabs on;
-
diff --git a/part/view/kateview.cpp b/part/view/kateview.cpp
index 113a672..0ede409 100644
--- a/part/view/kateview.cpp
+++ b/part/view/kateview.cpp
@@ -55,7 +55,6 @@
#include "katebuffer.h"
#include "script/katescriptmanager.h"
#include "script/katescriptaction.h"
-#include "script/katescriptconsole.h"
#include "snippet/katesnippetglobal.h"
#include "snippet/snippetcompletionmodel.h"
#include "katemessagewidget.h"
@@ -126,7 +125,6 @@ KateView::KateView( KateDocument *doc, QWidget *parent )
, m_bottomViewBar (0)
, m_topViewBar (0)
, m_cmdLine (0)
- , m_console (0)
, m_searchBar (0)
, m_viModeEmulatedCommandBar(0)
, m_gotoBar (0)
@@ -605,11 +603,6 @@ void KateView::setupActions()
a->setWhatsThis(i18n("Show/hide the command line on the bottom of the view."));
connect(a, SIGNAL(triggered(bool)), SLOT(switchToCmdLine()));
- a = m_switchConsole = ac->addAction("switch_to_console");
- a->setText(i18n("Show the JavaScript Console"));
- a->setWhatsThis(i18n("Show/hide the JavaScript Console on the bottom of the view."));
- connect(a, SIGNAL(triggered(bool)), SLOT(switchToConsole()));
-
a = m_viInputModeAction = new KToggleAction(i18n("&VI Input Mode"), this);
ac->addAction("view_vi_input_mode", a);
a->setShortcut(QKeySequence(Qt::CTRL + Qt::META + Qt::Key_V));
@@ -1641,15 +1634,6 @@ void KateView::switchToCmdLine ()
cmdLineBar()->setFocus ();
}
-void KateView::switchToConsole ()
-{
- if (!m_console)
- m_console = new KateScriptConsole (this, bottomViewBar());
- bottomViewBar()->addBarWidget(m_console);
- bottomViewBar()->showBarWidget(m_console);
- m_console->setFocus ();
-}
-
KateRenderer *KateView::renderer ()
{
return m_renderer;
@@ -2956,16 +2940,6 @@ KateCommandLineBar *KateView::cmdLineBar ()
return m_cmdLine;
}
-KateScriptConsole *KateView::consoleBar ()
-{
- if (!m_console) {
- m_console = new KateScriptConsole (this, bottomViewBar());
- bottomViewBar()->addBarWidget(m_console);
- }
-
- return m_console;
-}
-
KateSearchBar *KateView::searchBar (bool initHintAsPower)
{
if (!m_searchBar) {
diff --git a/part/view/kateview.h b/part/view/kateview.h
index 476b2ae..c707298 100644
--- a/part/view/kateview.h
+++ b/part/view/kateview.h
@@ -63,7 +63,6 @@ class KateViewBar;
class KateGotoBar;
class KateDictionaryBar;
class KateSpellingMenu;
-class KateScriptConsole;
class KateMessageWidget;
class KToggleAction;
@@ -559,7 +558,6 @@ class KATEPART_TESTS_EXPORT KateView : public KTextEditor::View,
void toggleWWMarker();
void toggleWriteLock();
void switchToCmdLine ();
- void switchToConsole ();
void slotReadWriteChanged ();
void slotClipboardHistoryChanged ();
@@ -616,7 +614,6 @@ class KATEPART_TESTS_EXPORT KateView : public KTextEditor::View,
KSelectAction* m_setDynWrapIndicators;
KToggleAction* m_toggleWWMarker;
KAction* m_switchCmdLine;
- KAction* m_switchConsole;
KToggleAction* m_viInputModeAction;
KSelectAction* m_setEndOfLine;
@@ -685,7 +682,6 @@ class KATEPART_TESTS_EXPORT KateView : public KTextEditor::View,
KateViewBar *topViewBar() const;
KateViewBar *bottomViewBar() const;
KateCommandLineBar *cmdLineBar ();
- KateScriptConsole *consoleBar ();
KateDictionaryBar *dictionaryBar();
KateViEmulatedCommandBar *viModeEmulatedCommandBar();
@@ -704,7 +700,6 @@ class KATEPART_TESTS_EXPORT KateView : public KTextEditor::View,
KateViewBar *m_topViewBar;
// created on demand..., only access them through the above accessors....
KateCommandLineBar *m_cmdLine;
- KateScriptConsole *m_console;
KateSearchBar *m_searchBar;
KateViEmulatedCommandBar *m_viModeEmulatedCommandBar;
KateGotoBar *m_gotoBar;