File indexing completed on 2025-01-05 04:26:46
0001 /**************************************************************************************** 0002 * Copyright (c) 2013 Anmol Ahuja <darthcodus@gmail.com> * 0003 * * 0004 * This program is free software; you can redistribute it and/or modify it under * 0005 * the terms of the GNU General Public License as published by the Free Software * 0006 * Foundation; either version 2 of the License, or (at your option) any later * 0007 * version. * 0008 * * 0009 * This program is distributed in the hope that it will be useful, but WITHOUT ANY * 0010 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * 0011 * PARTICULAR PURPOSE. See the GNU General Public License for more details. * 0012 * * 0013 * You should have received a copy of the GNU General Public License along with * 0014 * this program. If not, see <http://www.gnu.org/licenses/>. * 0015 ****************************************************************************************/ 0016 0017 #ifndef SCRIPT_CONSOLE_ITEM_H 0018 #define SCRIPT_CONSOLE_ITEM_H 0019 0020 #include "scripting/scriptmanager/ScriptItem.h" 0021 0022 namespace KTextEditor{ 0023 class View; 0024 } 0025 class QJSValue; 0026 class QWidget; 0027 class QPlainTextEdit; 0028 0029 namespace ScriptConsoleNS 0030 { 0031 class ScriptEditorDocument; 0032 0033 class ScriptConsoleItem : public ScriptItem 0034 { 0035 Q_OBJECT 0036 0037 public: 0038 ScriptConsoleItem( QObject *parent, const QString &name, const QString &path 0039 , const QString &category, ScriptEditorDocument *document ); 0040 ~ScriptConsoleItem() override; 0041 ScriptEditorDocument* document() { return m_viewFactory; } 0042 bool start( bool silent = false ) override; 0043 KTextEditor::View *getEditorView( QWidget *parent ); 0044 void appendToConsoleWidget( const QString &msg); 0045 QWidget *getConsoleWidget( QWidget *parent ); 0046 QWidget *getOutputWdiget( QWidget *parent ); 0047 QWidget *getErrorWidget( QWidget *parent ); 0048 0049 /** 0050 * Clear script files on disk upon object deletion 0051 */ 0052 void setClearOnDeletion( bool clearOnDelete ); 0053 void pause() override; 0054 0055 public Q_SLOTS: 0056 void updateOutputWidget( QString output ); 0057 void updateErrorWidget( QJSValue error ); 0058 0059 0060 private: 0061 bool m_clearOnDelete; 0062 ScriptEditorDocument *m_viewFactory; 0063 QPointer<KTextEditor::View> m_view; 0064 QPointer<QPlainTextEdit> m_console; 0065 QPointer<QPlainTextEdit> m_output; 0066 QPointer<QPlainTextEdit> m_error; 0067 0068 void timerEvent(QTimerEvent* event) override; 0069 void initializeScriptEngine() override; 0070 static KPluginInfo createSpecFile( const QString &name, const QString &category, const QString &path ); 0071 QString handleError( QJSValue *result ) override; 0072 0073 }; 0074 } 0075 0076 Q_DECLARE_METATYPE( ScriptConsoleNS::ScriptConsoleItem* ) 0077 0078 #endif // SCRIPT_CONSOLE_ITEM_H