| 1 |
#ifndef _ScriptEditor_h_ |
| 2 |
#define _ScriptEditor_h_ |
| 3 |
/* ScriptEditor.h |
| 4 |
* |
| 5 |
* Copyright (C) 1997-2011,2012,2015,2016,2018,2022-2024,2026 Paul Boersma |
| 6 |
* |
| 7 |
* This code is free software; you can redistribute it and/or modify |
| 8 |
* it under the terms of the GNU General Public License as published by |
| 9 |
* the Free Software Foundation; either version 3 of the License, or (at |
| 10 |
* your option) any later version. |
| 11 |
* |
| 12 |
* This code is distributed in the hope that it will be useful, but |
| 13 |
* WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 15 |
* See the GNU General Public License for more details. |
| 16 |
* |
| 17 |
* You should have received a copy of the GNU General Public License |
| 18 |
* along with this work. If not, see <http://www.gnu.org/licenses/>. |
| 19 |
*/ |
| 20 |
|
| 21 |
#include "Script.h" |
| 22 |
#include "TextEditor.h" |
| 23 |
#include "Interpreter.h" |
| 24 |
|
| 25 |
Thing_define (ScriptEditor, TextEditor) { |
| 26 |
/* |
| 27 |
Who owns me? |
| 28 |
*/ |
| 29 |
autostring32 optionalOwningEditorClassName; // set at creation, and never changed after that (last checked 2023-02-25) |
| 30 |
Editor optionalReferenceToOwningEditor; // set at creation, and may be set to null later on |
| 31 |
bool wasCreatedInAnEditor () const noexcept { |
| 32 |
return !! our optionalOwningEditorClassName; |
| 33 |
} |
| 34 |
|
| 35 |
autoInterpreterStack interpreterStack; |
| 36 |
autoUiForm argsDialog; |
| 37 |
|
| 38 |
void v9_destroy () noexcept |
| 39 |
override; |
| 40 |
void v_nameChanged () |
| 41 |
override; |
| 42 |
bool v_scriptable () |
| 43 |
override { return false; } |
| 44 |
void v_createMenus () |
| 45 |
override; |
| 46 |
void v_createMenuItems_help (EditorMenu menu) |
| 47 |
override; |
| 48 |
conststring32 v_extension () const |
| 49 |
override { return U".praat"; } |
| 50 |
}; |
| 51 |
|
| 52 |
void ScriptEditor_init (ScriptEditor me, |
| 53 |
Editor optionalEditor, |
| 54 |
conststring32 initialText |
| 55 |
); |
| 56 |
autoScriptEditor ScriptEditor_createFromText ( |
| 57 |
Editor optionalEditor, // the scripting environment; if null, the scripting environment consists of the global windows |
| 58 |
conststring32 initialText // may be null |
| 59 |
); |
| 60 |
|
| 61 |
autoScriptEditor ScriptEditor_createFromScript_canBeNull ( |
| 62 |
Editor optionalEditor, |
| 63 |
autoScript script // the ScriptEditor will take over ownership, and in turn hand it over to the set of known scripts |
| 64 |
); |
| 65 |
|
| 66 |
bool ScriptEditors_dirty (); // are there any modified and unsaved scripts? Ask before quitting the program. |
| 67 |
|
| 68 |
void ScriptEditor_debug_printAllOpenScriptEditors (); |
| 69 |
|
| 70 |
extern CollectionOf <structScriptEditor> theReferencesToAllOpenScriptEditors; |
| 71 |
|
| 72 |
/* End of file ScriptEditor.h */ |
| 73 |
#endif |