| 1 | /* NotebookEditor.cpp |
| 2 | * |
| 3 | * Copyright (C) 2023,2024,2026 Paul Boersma |
| 4 | * |
| 5 | * This code is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; either version 3 of the License, or (at |
| 8 | * your option) any later version. |
| 9 | * |
| 10 | * This code is distributed in the hope that it will be useful, but |
| 11 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 13 | * See the GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this work. If not, see <http://www.gnu.org/licenses/>. |
| 17 | */ |
| 18 | |
| 19 | #include "NotebookEditor.h"cxx . . $ `<file>/sys/NotebookEditor.h`/ |
| 20 | #include "../kar/longchar.h"cxx . . $ `<file>/kar/longchar.h`/ |
| 21 | #include "praatP.h"cxx . . $ `<file>/sys/praatP.h`/ |
| 22 | #include "EditorM.h"cxx . . $ `<file>/sys/EditorM.h`/ |
| 23 | |
| 24 | Thing_implementcxx . . $ `sys/Thing.h:65:9`! (NotebookEditor, TextEditor, 0); |
| 25 | |
| 26 | CollectionOfcxx . . $ CollectionOf# <structNotebookEditorcxx . . $ structNotebookEditor#> theReferencesToAllOpenNotebookEditorscxx . . $ theReferencesToAllOpenNotebookEditors.; |
| 27 | |
| 28 | bool NotebookEditors_dirtycxx . . $ NotebookEditors_dirty(c9857a73d68e59ba). () { |
| 29 | for (integercxx . . $ integer# i = 1; i <= theReferencesToAllOpenNotebookEditorscxx . . $ theReferencesToAllOpenNotebookEditors..sizecxx . . $ CollectionOf#size.; i ++) { |
| 30 | const NotebookEditorcxx . . $ NotebookEditor# me = theReferencesToAllOpenNotebookEditorscxx . . $ theReferencesToAllOpenNotebookEditors..atcxx . . $ CollectionOf#at. [cxx . . $ ArrayOf#`operator[]`(a7f36fee1ae21897).i]; |
| 31 | if (mycxx . . $ `melder/melder.h:44:9`! dirtycxx . . $ structTextEditor#dirty.) |
| 32 | return true; |
| 33 | } |
| 34 | return false; |
| 35 | } |
| 36 | |
| 37 | void structNotebookEditorcxx . . $ structNotebookEditor# :: v9_destroycxx . . $ structNotebookEditor#v9_destroy(ced63f7c635d850d). () noexcept { |
| 38 | ourcxx . . $ `melder/melder.h:42:9`! argsDialogcxx . . $ structNotebookEditor#argsDialog.. resetcxx . . $ autoSomeThing#reset(ced63f7c635d850d).(); // don't delay till delete |
| 39 | theReferencesToAllOpenNotebookEditorscxx . . $ theReferencesToAllOpenNotebookEditors.. undangleItemcxx . . $ CollectionOf#undangleItem(97cddd01752945f6). (this); |
| 40 | NotebookEditor_Parentcxx . . $ NotebookEditor_Parent# :: v9_destroycxx . . $ structTextEditor#v9_destroy(ced63f7c635d850d). (); |
| 41 | } |
| 42 | |
| 43 | void structNotebookEditorcxx . . $ structNotebookEditor# :: v_nameChangedcxx . . $ structNotebookEditor#v_nameChanged(49f6e7a06ebc5aa8). () { |
| 44 | /* |
| 45 | As TextEditor does, we totally ignore the name that our boss wants to give us. |
| 46 | Instead, we compose the window title from three ingredients: |
| 47 | |
| 48 | (1) whether we are already associated with a file or not; |
| 49 | (2) if so, the full file path; |
| 50 | (3) whether our text has been modified (i.e. whether we are "dirty"); |
| 51 | |
| 52 | (last checked 2023-03-25) |
| 53 | */ |
| 54 | const bool dirtinessAlreadyShown = GuiWindow_setDirtycxx . . $ GuiWindow_setDirty(aed7644c12df6ab). (ourcxx . . $ `melder/melder.h:42:9`! windowFormcxx . . $ structEditor#windowForm., ourcxx . . $ `melder/melder.h:42:9`! dirtycxx . . $ structTextEditor#dirty.); // (3) on the Mac (last checked 2023-03-25) |
| 55 | static MelderStringcxx . . $ MelderString# buffer; |
| 56 | MelderString_copycxx . . $ MelderString_copy(65be51a793e0ff96). (& buffer, MelderFile_isNullcxx . . $ MelderFile_isNull(8f92cdf95b27d908). (& ourcxx . . $ `melder/melder.h:42:9`! filecxx . . $ structTextEditor#file.) ? U"untitled notebook" : U"Notebook"); // (1) |
| 57 | if (! MelderFile_isNullcxx . . $ MelderFile_isNull(8f92cdf95b27d908). (& ourcxx . . $ `melder/melder.h:42:9`! filecxx . . $ structTextEditor#file.)) |
| 58 | MelderString_appendcxx . . $ MelderString_append(65be51a793e0ff96). (& buffer, U" ", MelderFile_messageNamecxx . . $ MelderFile_messageName(d9f043369fa9b55b). (& ourcxx . . $ `melder/melder.h:42:9`! filecxx . . $ structTextEditor#file.)); // (2) |
| 59 | if (ourcxx . . $ `melder/melder.h:42:9`! dirtycxx . . $ structTextEditor#dirty. && ! dirtinessAlreadyShown) |
| 60 | MelderString_appendcxx . . $ MelderString_append(65be51a793e0ff96). (& buffer, U" (modified)"); // (3) on Windows and Linux (last checked 2023-02-25) |
| 61 | GuiShell_setTitlecxx . . $ GuiShell_setTitle(3a9df304850abc11). (windowFormcxx . . $ structEditor#windowForm., buffer.stringcxx . . $ MelderString#string.); |
| 62 | } |
| 63 | |
| 64 | void structNotebookEditorcxx . . $ structNotebookEditor# :: v_goAwaycxx . . $ structNotebookEditor#v_goAway(49f6e7a06ebc5aa8). () { |
| 65 | if (ourcxx . . $ `melder/melder.h:42:9`! interpreterStackcxx . . $ structNotebookEditor#interpreterStack. ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). interpreterscxx . . $ structInterpreterStack#interpreters. [1] && ourcxx . . $ `melder/melder.h:42:9`! interpreterStackcxx . . $ structNotebookEditor#interpreterStack. ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). interpreterscxx . . $ structInterpreterStack#interpreters. [1] ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). runningcxx . . $ structInterpreter#running.) |
| 66 | Melder_flushErrorcxx . . $ Melder_flushError(6298c93241566110). (U"Cannot close the NotebookEditor while the notebook is running or paused.\n" |
| 67 | "Please close or continue the pause, trust or demo window."); |
| 68 | else |
| 69 | NotebookEditor_Parentcxx . . $ NotebookEditor_Parent# :: v_goAwaycxx . . $ structTextEditor#v_goAway(49f6e7a06ebc5aa8). (); |
| 70 | } |
| 71 | |
| 72 | static void args_okcxx . . $ args_ok(744a0abd3c8513c). (UiFormcxx . . $ UiForm# sendingForm, integercxx . . $ integer# /* narg */, Stackelcxx . . $ Stackel# /* args */, conststring32cxx . . $ conststring32# /* sendingString */, |
| 73 | Interpretercxx . . $ Interpreter# /* interpreter */, conststring32cxx . . $ conststring32# /* invokingButtonTitle */, bool /* modified */, void *void_me, Editorcxx . . $ Editor# optionalEditor) |
| 74 | { |
| 75 | iamcxx . . $ `melder/melder.h:50:9`! (NotebookEditor); |
| 76 | autostring32cxx . . $ autostring32# text = GuiText_getStringcxx . . $ GuiText_getString(9a61f82c13ba8ebc). (mycxx . . $ `melder/melder.h:44:9`! textWidgetcxx . . $ structTextEditor#textWidget.); |
| 77 | if (! MelderFile_isNullcxx . . $ MelderFile_isNull(8f92cdf95b27d908). (& mycxx . . $ `melder/melder.h:44:9`! filecxx . . $ structTextEditor#file.)) |
| 78 | MelderFile_setDefaultDircxx . . $ MelderFile_setDefaultDir(1145552d769d7b5d). (& mycxx . . $ `melder/melder.h:44:9`! filecxx . . $ structTextEditor#file.); |
| 79 | Melder_includeIncludeFilescxx . . $ Melder_includeIncludeFiles(2d5e149ff849c92b). (& text, true); |
| 80 | |
| 81 | Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (mycxx . . $ `melder/melder.h:44:9`! interpreterStack -> interpreters [1]); |
| 82 | Interpreter_getArgumentsFromDialogcxx . . $ Interpreter_getArgumentsFromDialog(d4b141834b28b228). (mycxx . . $ `melder/melder.h:44:9`! interpreterStackcxx . . $ structNotebookEditor#interpreterStack. ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). interpreterscxx . . $ structInterpreterStack#interpreters. [1].getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), sendingForm); |
| 83 | |
| 84 | autoPraatBackgroundcxx . . $ autoPraatBackground# backgroundcxx . . $ autoPraatBackground#autoPraatBackground(49f6e7a06ebc5aa8).; |
| 85 | if (! MelderFile_isNullcxx . . $ MelderFile_isNull(8f92cdf95b27d908). (& mycxx . . $ `melder/melder.h:44:9`! filecxx . . $ structTextEditor#file.)) |
| 86 | MelderFile_setDefaultDircxx . . $ MelderFile_setDefaultDir(1145552d769d7b5d). (& mycxx . . $ `melder/melder.h:44:9`! filecxx . . $ structTextEditor#file.); |
| 87 | |
| 88 | autoMelderReadTextcxx . . $ autoMelderReadText# readText = MelderReadText_createFromTextcxx . . $ MelderReadText_createFromText(ec22451ee8ecfd96). (textcxx . . $ _autostring#_autostring(39021ecceedcc7d2)..movecxx . . $ _autostring#move(bd43c759570f178f).()); |
| 89 | autoManPagescxx . . $ autoManPages# manPages = ManPages_createFromTextcxx . . $ ManPages_createFromText(c494f626560144be). (readText.getcxx . . $ std/unique_ptr#get(ea7391e9eeeaf20e).(), & mycxx . . $ `melder/melder.h:44:9`! filecxx . . $ structTextEditor#file.); // readText can release, because manPages duplicates (last checked 2023-03-25) |
| 90 | ManPagecxx . . $ ManPage# firstPage = manPages ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). pagescxx . . $ structManPages#pages..atcxx . . $ CollectionOf#at. [cxx . . $ ArrayOf#`operator[]`(a7f36fee1ae21897).1]; |
| 91 | autoManualcxx . . $ autoManual# manual = Manual_createcxx . . $ Manual_create(639647387c88cb04). (firstPage -> titlecxx . . $ structManPage#title..getcxx . . $ _autostring#get(5a2a78a048fb49a8).(), mycxx . . $ `melder/melder.h:44:9`! interpreterStackcxx . . $ structNotebookEditor#interpreterStack. ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). interpreterscxx . . $ structInterpreterStack#interpreters. [1].getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), manPages.releaseToAmbiguousOwnercxx . . $ autoSomeThing#releaseToAmbiguousOwner(258ee1c9e0a18a5c).(), true, true); |
| 92 | manual.releaseToUsercxx . . $ autoSomeThing#releaseToUser(ced63f7c635d850d). (); |
| 93 | } |
| 94 | |
| 95 | static void menu_cb_runcxx . . $ menu_cb_run(526483db6c8139bc). (NotebookEditorcxx . . $ NotebookEditor# me, EDITOR_ARGScxx . . $ `sys/EditorM.h:25:9`!) { |
| 96 | if (mycxx . . $ `melder/melder.h:44:9`! interpreterStackcxx . . $ structNotebookEditor#interpreterStack. ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). interpreterscxx . . $ structInterpreterStack#interpreters. [1] && mycxx . . $ `melder/melder.h:44:9`! interpreterStackcxx . . $ structNotebookEditor#interpreterStack. ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). interpreterscxx . . $ structInterpreterStack#interpreters. [1] ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). runningcxx . . $ structInterpreter#running.) |
| 97 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"The notebook is already running (paused). Please close or continue the pause, trust or demo window."); |
| 98 | //Melder_assert (! my interpreterStack -> interpreters [1]); // TRICKY |
| 99 | mycxx . . $ `melder/melder.h:44:9`! interpreterStackcxx . . $ structNotebookEditor#interpreterStack. ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). interpreterscxx . . $ structInterpreterStack#interpreters. [1] =cxx . . $ autoSomeThing#`operator=`(80cc59814f7161e8). Interpreter_createFromEnvironmentcxx . . $ Interpreter_createFromEnvironment(2a446a9b6f15a803). ( |
| 100 | mycxx . . $ `melder/melder.h:44:9`! interpreterStackcxx . . $ structNotebookEditor#interpreterStack..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), |
| 101 | Editorcxx . . $ Editor# (nullptr), |
| 102 | & mycxx . . $ `melder/melder.h:44:9`! filecxx . . $ structTextEditor#file. |
| 103 | ); |
| 104 | TRACEcxx . . $ `melder/melder_debug.h:54:9`! |
| 105 | tracecxx . . $ `melder/melder_debug.h:60:10`! (U"File: ", & mycxx . . $ `melder/melder.h:44:9`! file); |
| 106 | integercxx . . $ integer# startOfSelection, endOfSelection; |
| 107 | autostring32cxx . . $ autostring32# text = GuiText_getStringAndSelectionPositioncxx . . $ GuiText_getStringAndSelectionPosition(2d4f5aac9640119d). (mycxx . . $ `melder/melder.h:44:9`! textWidgetcxx . . $ structTextEditor#textWidget., & startOfSelection, & endOfSelection); |
| 108 | if (Melder_startsWithcxx . . $ Melder_startsWith(1652f10ed0f82783). (text.getcxx . . $ _autostring#get(5a2a78a048fb49a8).(), U"\"")) { |
| 109 | if (! MelderFile_isNullcxx . . $ MelderFile_isNull(8f92cdf95b27d908). (& mycxx . . $ `melder/melder.h:44:9`! filecxx . . $ structTextEditor#file.)) |
| 110 | MelderFile_setDefaultDircxx . . $ MelderFile_setDefaultDir(1145552d769d7b5d). (& mycxx . . $ `melder/melder.h:44:9`! filecxx . . $ structTextEditor#file.); |
| 111 | Melder_includeIncludeFilescxx . . $ Melder_includeIncludeFiles(2d5e149ff849c92b). (& text, true); |
| 112 | const integercxx . . $ integer# npar = Interpreter_readParameterscxx . . $ Interpreter_readParameters(9dd4ed1655057857). (mycxx . . $ `melder/melder.h:44:9`! interpreterStackcxx . . $ structNotebookEditor#interpreterStack. ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). interpreterscxx . . $ structInterpreterStack#interpreters. [1].getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), text.getcxx . . $ _autostring#get(5a2a78a048fb49a8).()); |
| 113 | if (npar != 0) { |
| 114 | /* |
| 115 | Pop up a dialog box for querying the arguments. |
| 116 | */ |
| 117 | mycxx . . $ `melder/melder.h:44:9`! argsDialogcxx . . $ structNotebookEditor#argsDialog. =cxx . . $ autoSomeThing#`operator=`(80cc59814f7161e8). Interpreter_createFormcxx . . $ Interpreter_createForm(cb75ceafc4a9bd55). (mycxx . . $ `melder/melder.h:44:9`! interpreterStackcxx . . $ structNotebookEditor#interpreterStack. ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). interpreterscxx . . $ structInterpreterStack#interpreters. [1].getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), mycxx . . $ `melder/melder.h:44:9`! windowFormcxx . . $ structEditor#windowForm., nullptr, nullptr, args_okcxx . . $ args_ok(744a0abd3c8513c)., me, false); |
| 118 | UiForm_docxx . . $ UiForm_do(c04b2c306b4dc6f4). (mycxx . . $ `melder/melder.h:44:9`! argsDialogcxx . . $ structNotebookEditor#argsDialog..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), false); |
| 119 | } else { |
| 120 | autoPraatBackgroundcxx . . $ autoPraatBackground# backgroundcxx . . $ autoPraatBackground#autoPraatBackground(49f6e7a06ebc5aa8).; |
| 121 | if (! MelderFile_isNullcxx . . $ MelderFile_isNull(8f92cdf95b27d908). (& mycxx . . $ `melder/melder.h:44:9`! filecxx . . $ structTextEditor#file.)) |
| 122 | MelderFile_setDefaultDircxx . . $ MelderFile_setDefaultDir(1145552d769d7b5d). (& mycxx . . $ `melder/melder.h:44:9`! filecxx . . $ structTextEditor#file.); |
| 123 | |
| 124 | autoMelderReadTextcxx . . $ autoMelderReadText# readText = MelderReadText_createFromTextcxx . . $ MelderReadText_createFromText(ec22451ee8ecfd96). (textcxx . . $ _autostring#_autostring(39021ecceedcc7d2)..movecxx . . $ _autostring#move(bd43c759570f178f).()); |
| 125 | autoManPagescxx . . $ autoManPages# manPages = ManPages_createFromTextcxx . . $ ManPages_createFromText(c494f626560144be). (readText.getcxx . . $ std/unique_ptr#get(ea7391e9eeeaf20e).(), & mycxx . . $ `melder/melder.h:44:9`! filecxx . . $ structTextEditor#file.); // readText can release, because manPages duplicates (last checked 2023-03-25) |
| 126 | ManPagecxx . . $ ManPage# firstPage = manPages ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). pagescxx . . $ structManPages#pages..atcxx . . $ CollectionOf#at. [cxx . . $ ArrayOf#`operator[]`(a7f36fee1ae21897).1]; |
| 127 | Interpreter_rememberNotebookcxx . . $ Interpreter_rememberNotebook(a0c4c87353b136f2). (mycxx . . $ `melder/melder.h:44:9`! interpreterStackcxx . . $ structNotebookEditor#interpreterStack. ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). interpreterscxx . . $ structInterpreterStack#interpreters. [1].getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), & mycxx . . $ `melder/melder.h:44:9`! filecxx . . $ structTextEditor#file., false); |
| 128 | autoManualcxx . . $ autoManual# manual = Manual_createcxx . . $ Manual_create(639647387c88cb04). (firstPage -> titlecxx . . $ structManPage#title..getcxx . . $ _autostring#get(5a2a78a048fb49a8).(), mycxx . . $ `melder/melder.h:44:9`! interpreterStackcxx . . $ structNotebookEditor#interpreterStack. ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). interpreterscxx . . $ structInterpreterStack#interpreters. [1].getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), manPages.releaseToAmbiguousOwnercxx . . $ autoSomeThing#releaseToAmbiguousOwner(258ee1c9e0a18a5c).(), true, true); |
| 129 | manual.releaseToUsercxx . . $ autoSomeThing#releaseToUser(ced63f7c635d850d). (); |
| 130 | } |
| 131 | } else if (str32strcxx . . $ str32str(2de17cd8f7c584a6). (text.getcxx . . $ _autostring#get(5a2a78a048fb49a8).(), U"\n####################")) { |
| 132 | autoMelderReadTextcxx . . $ autoMelderReadText# readText = MelderReadText_createFromTextcxx . . $ MelderReadText_createFromText(ec22451ee8ecfd96). (textcxx . . $ _autostring#_autostring(39021ecceedcc7d2)..movecxx . . $ _autostring#move(bd43c759570f178f).()); |
| 133 | autoManPagescxx . . $ autoManPages# you = Thing_newcxx . . $ `sys/Thing.h:514:9`! (ManPages); |
| 134 | yourcxx . . $ `melder/melder.h:46:9`! dynamiccxx . . $ structManPages#dynamic. = false; |
| 135 | integercxx . . $ integer# startingPage = ManPages_addPagesFromNotebookReadercxx . . $ ManPages_addPagesFromNotebookReader(5b6bfa485e908324). (you.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), readText.getcxx . . $ std/unique_ptr#get(ea7391e9eeeaf20e).(), startOfSelection, endOfSelection); |
| 136 | Melder_clipcxx . . $ Melder_clip(971c667ea412f82c). (1_integercxx . . $ `operator""_integer`(85240eb457c3721a)., & startingPage, yourcxx . . $ `melder/melder.h:46:9`! pagescxx . . $ structManPages#pages..sizecxx . . $ CollectionOf#size.); |
| 137 | ManPagecxx . . $ ManPage# firstPage = yourcxx . . $ `melder/melder.h:46:9`! pagescxx . . $ structManPages#pages..atcxx . . $ CollectionOf#at. [cxx . . $ ArrayOf#`operator[]`(a7f36fee1ae21897).startingPage]; |
| 138 | autoManualcxx . . $ autoManual# manual = Manual_createcxx . . $ Manual_create(639647387c88cb04). (firstPage -> titlecxx . . $ structManPage#title..getcxx . . $ _autostring#get(5a2a78a048fb49a8).(), mycxx . . $ `melder/melder.h:44:9`! interpreterStackcxx . . $ structNotebookEditor#interpreterStack. ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). interpreterscxx . . $ structInterpreterStack#interpreters. [1].getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), you.releaseToAmbiguousOwnercxx . . $ autoSomeThing#releaseToAmbiguousOwner(258ee1c9e0a18a5c).(), true, true); |
| 139 | manual.releaseToUsercxx . . $ autoSomeThing#releaseToUser(ced63f7c635d850d). (); |
| 140 | } else |
| 141 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"A Praat notebook should either start with a title between straight double quotes (\"\"), " |
| 142 | "or contain multiple such pieces separated by \"####################\" (or longer) lines on all sides."); |
| 143 | } |
| 144 | |
| 145 | static void menu_cb_runChunkcxx . . $ menu_cb_runChunk(526483db6c8139bc). (NotebookEditorcxx . . $ NotebookEditor# me, EDITOR_ARGScxx . . $ `sys/EditorM.h:25:9`!) { |
| 146 | if (mycxx . . $ `melder/melder.h:44:9`! interpreterStackcxx . . $ structNotebookEditor#interpreterStack. ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). interpreterscxx . . $ structInterpreterStack#interpreters. [1] && mycxx . . $ `melder/melder.h:44:9`! interpreterStackcxx . . $ structNotebookEditor#interpreterStack. ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). interpreterscxx . . $ structInterpreterStack#interpreters. [1] ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). runningcxx . . $ structInterpreter#running.) |
| 147 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"The notebook is already running (paused). Please close or continue the pause, trust or demo window."); |
| 148 | autostring32cxx . . $ autostring32# text = GuiText_getSelectioncxx . . $ GuiText_getSelection(9a61f82c13ba8ebc). (mycxx . . $ `melder/melder.h:44:9`! textWidgetcxx . . $ structTextEditor#textWidget.); // TODO: replace with chunk |
| 149 | if (! text) |
| 150 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"No text selected."); |
| 151 | if (! MelderFile_isNullcxx . . $ MelderFile_isNull(8f92cdf95b27d908). (& mycxx . . $ `melder/melder.h:44:9`! filecxx . . $ structTextEditor#file.)) |
| 152 | MelderFile_setDefaultDircxx . . $ MelderFile_setDefaultDir(1145552d769d7b5d). (& mycxx . . $ `melder/melder.h:44:9`! filecxx . . $ structTextEditor#file.); |
| 153 | Melder_includeIncludeFilescxx . . $ Melder_includeIncludeFiles(2d5e149ff849c92b). (& text); |
| 154 | autoPraatBackgroundcxx . . $ autoPraatBackground# backgroundcxx . . $ autoPraatBackground#autoPraatBackground(49f6e7a06ebc5aa8).; |
| 155 | if (! MelderFile_isNullcxx . . $ MelderFile_isNull(8f92cdf95b27d908). (& mycxx . . $ `melder/melder.h:44:9`! filecxx . . $ structTextEditor#file.)) |
| 156 | MelderFile_setDefaultDircxx . . $ MelderFile_setDefaultDir(1145552d769d7b5d). (& mycxx . . $ `melder/melder.h:44:9`! filecxx . . $ structTextEditor#file.); // TODO: probably wrong |
| 157 | autoInterpretercxx . . $ autoInterpreter# interpreter = Interpreter_createFromEnvironmentcxx . . $ Interpreter_createFromEnvironment(2a446a9b6f15a803). ( |
| 158 | mycxx . . $ `melder/melder.h:44:9`! interpreterStackcxx . . $ structNotebookEditor#interpreterStack..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), |
| 159 | Editorcxx . . $ Editor# (nullptr), |
| 160 | MelderFilecxx . . $ MelderFile# (nullptr) // TODO: probably wrong |
| 161 | ); |
| 162 | Interpreter_rememberNotebookcxx . . $ Interpreter_rememberNotebook(a0c4c87353b136f2). (interpreter.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), & mycxx . . $ `melder/melder.h:44:9`! filecxx . . $ structTextEditor#file., false); |
| 163 | mycxx . . $ `melder/melder.h:44:9`! interpreterStackcxx . . $ structNotebookEditor#interpreterStack. ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). emptyAllcxx . . $ structInterpreterStack#emptyAll(49f6e7a06ebc5aa8). (); |
| 164 | mycxx . . $ `melder/melder.h:44:9`! interpreterStackcxx . . $ structNotebookEditor#interpreterStack. ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). runDowncxx . . $ structInterpreterStack#runDown(f108da249e59f621). (interpretercxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f)..movecxx . . $ autoSomeThing#move(25acc3554b7d1642).(), textcxx . . $ _autostring#_autostring(39021ecceedcc7d2)..movecxx . . $ _autostring#move(bd43c759570f178f).(), true); |
| 165 | } |
| 166 | |
| 167 | static void menu_cb_expandIncludeFilescxx . . $ menu_cb_expandIncludeFiles(526483db6c8139bc). (NotebookEditorcxx . . $ NotebookEditor# me, EDITOR_ARGScxx . . $ `sys/EditorM.h:25:9`!) { |
| 168 | autostring32cxx . . $ autostring32# text = GuiText_getStringcxx . . $ GuiText_getString(9a61f82c13ba8ebc). (mycxx . . $ `melder/melder.h:44:9`! textWidgetcxx . . $ structTextEditor#textWidget.); |
| 169 | if (! MelderFile_isNullcxx . . $ MelderFile_isNull(8f92cdf95b27d908). (& mycxx . . $ `melder/melder.h:44:9`! filecxx . . $ structTextEditor#file.)) |
| 170 | MelderFile_setDefaultDircxx . . $ MelderFile_setDefaultDir(1145552d769d7b5d). (& mycxx . . $ `melder/melder.h:44:9`! filecxx . . $ structTextEditor#file.); |
| 171 | Melder_includeIncludeFilescxx . . $ Melder_includeIncludeFiles(2d5e149ff849c92b). (& text, true); |
| 172 | GuiText_setStringcxx . . $ GuiText_setString(d44acbd60ea2b9be). (mycxx . . $ `melder/melder.h:44:9`! textWidgetcxx . . $ structTextEditor#textWidget., text.getcxx . . $ _autostring#get(5a2a78a048fb49a8).()); |
| 173 | } |
| 174 | |
| 175 | static void menu_cb_AboutNotebookEditorcxx . . $ menu_cb_AboutNotebookEditor(526483db6c8139bc). (NotebookEditorcxx . . $ NotebookEditor#, EDITOR_ARGScxx . . $ `sys/EditorM.h:25:9`!) { Melder_helpcxx . . $ Melder_help(ff00d524ab0355ec). (U"NotebookEditor"); } |
| 176 | static void menu_cb_ScriptingTutorialcxx . . $ menu_cb_ScriptingTutorial(526483db6c8139bc). (NotebookEditorcxx . . $ NotebookEditor#, EDITOR_ARGScxx . . $ `sys/EditorM.h:25:9`!) { Melder_helpcxx . . $ Melder_help(ff00d524ab0355ec). (U"Scripting"); } |
| 177 | static void menu_cb_ScriptingExamplescxx . . $ menu_cb_ScriptingExamples(526483db6c8139bc). (NotebookEditorcxx . . $ NotebookEditor#, EDITOR_ARGScxx . . $ `sys/EditorM.h:25:9`!) { Melder_helpcxx . . $ Melder_help(ff00d524ab0355ec). (U"Scripting examples"); } |
| 178 | static void menu_cb_PraatScriptcxx . . $ menu_cb_PraatScript(526483db6c8139bc). (NotebookEditorcxx . . $ NotebookEditor#, EDITOR_ARGScxx . . $ `sys/EditorM.h:25:9`!) { Melder_helpcxx . . $ Melder_help(ff00d524ab0355ec). (U"Praat script"); } |
| 179 | static void menu_cb_FormulasTutorialcxx . . $ menu_cb_FormulasTutorial(526483db6c8139bc). (NotebookEditorcxx . . $ NotebookEditor#, EDITOR_ARGScxx . . $ `sys/EditorM.h:25:9`!) { Melder_helpcxx . . $ Melder_help(ff00d524ab0355ec). (U"Formulas"); } |
| 180 | static void menu_cb_Functionscxx . . $ menu_cb_Functions(526483db6c8139bc). (NotebookEditorcxx . . $ NotebookEditor#, EDITOR_ARGScxx . . $ `sys/EditorM.h:25:9`!) { Melder_helpcxx . . $ Melder_help(ff00d524ab0355ec). (U"Functions"); } |
| 181 | |
| 182 | void structNotebookEditorcxx . . $ structNotebookEditor# :: v_createMenuscxx . . $ structNotebookEditor#v_createMenus(49f6e7a06ebc5aa8). () { |
| 183 | NotebookEditor_Parentcxx . . $ NotebookEditor_Parent# :: v_createMenuscxx . . $ structTextEditor#v_createMenus(49f6e7a06ebc5aa8). (); |
| 184 | Editor_addCommandcxx . . $ Editor_addCommand(d7f2c642863274c0). (this, U"File", U"-- close --", 0, nullptrcxx . . $ MelderCallback#MelderCallback(fc624d2cd197112).); |
| 185 | Editor_addCommandcxx . . $ Editor_addCommand(d7f2c642863274c0). (this, U"Convert", U"-- expand --", 0, nullptrcxx . . $ MelderCallback#MelderCallback(fc624d2cd197112).); |
| 186 | Editor_addCommandcxx . . $ Editor_addCommand(d7f2c642863274c0). (this, U"Convert", U"Expand include files", 0, menu_cb_expandIncludeFilescxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97).); |
| 187 | Editor_addMenucxx . . $ Editor_addMenu(8b39ac34ca8e016f). (this, U"Run", 0); |
| 188 | Editor_addCommandcxx . . $ Editor_addCommand(d7f2c642863274c0). (this, U"Run", U"Run", 'R', menu_cb_runcxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97).); |
| 189 | Editor_addCommandcxx . . $ Editor_addCommand(d7f2c642863274c0). (this, U"Run", U"Run chunk", 'T', menu_cb_runChunkcxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97).); |
| 190 | } |
| 191 | |
| 192 | void structNotebookEditorcxx . . $ structNotebookEditor# :: v_createMenuItems_helpcxx . . $ structNotebookEditor#v_createMenuItems_help(6ea9c8c6ea2f58a9). (EditorMenucxx . . $ EditorMenu# menu) { |
| 193 | NotebookEditor_Parentcxx . . $ NotebookEditor_Parent# :: v_createMenuItems_helpcxx . . $ structDataGui#v_createMenuItems_help(6ea9c8c6ea2f58a9). (menu); |
| 194 | EditorMenu_addCommandcxx . . $ EditorMenu_addCommand(b3c50ad5ffa1d58a). (menu, U"About NotebookEditor", '?', menu_cb_AboutNotebookEditorcxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97).); |
| 195 | EditorMenu_addCommandcxx . . $ EditorMenu_addCommand(b3c50ad5ffa1d58a). (menu, U"Scripting tutorial", 0, menu_cb_ScriptingTutorialcxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97).); |
| 196 | EditorMenu_addCommandcxx . . $ EditorMenu_addCommand(b3c50ad5ffa1d58a). (menu, U"Scripting examples", 0, menu_cb_ScriptingExamplescxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97).); |
| 197 | EditorMenu_addCommandcxx . . $ EditorMenu_addCommand(b3c50ad5ffa1d58a). (menu, U"Praat script", 0, menu_cb_PraatScriptcxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97).); |
| 198 | EditorMenu_addCommandcxx . . $ EditorMenu_addCommand(b3c50ad5ffa1d58a). (menu, U"Formulas tutorial", 0, menu_cb_FormulasTutorialcxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97).); |
| 199 | EditorMenu_addCommandcxx . . $ EditorMenu_addCommand(b3c50ad5ffa1d58a). (menu, U"Functions", 0, menu_cb_Functionscxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97).); |
| 200 | } |
| 201 | |
| 202 | void NotebookEditor_initcxx . . $ NotebookEditor_init(edd84ce69971f6a0). (NotebookEditorcxx . . $ NotebookEditor# me, conststring32cxx . . $ conststring32# initialText) { |
| 203 | TextEditor_initcxx . . $ TextEditor_init(9ba39b4797eb5880). (me, initialText); |
| 204 | mycxx . . $ `melder/melder.h:44:9`! interpreterStackcxx . . $ structNotebookEditor#interpreterStack. =cxx . . $ autoSomeThing#`operator=`(80cc59814f7161e8). InterpreterStack_createcxx . . $ InterpreterStack_create(91aa183261e4fa82). (Editorcxx . . $ Editor# (nullptr)); |
| 205 | theReferencesToAllOpenNotebookEditorscxx . . $ theReferencesToAllOpenNotebookEditors.. addItem_refcxx . . $ CollectionOf#addItem_ref(ebd0a1552f8ce24f). (me); |
| 206 | } |
| 207 | |
| 208 | autoNotebookEditorcxx . . $ autoNotebookEditor# NotebookEditor_createFromTextcxx . . $ NotebookEditor_createFromText(2ab91d38f0848c38). (conststring32cxx . . $ conststring32# initialText) { |
| 209 | try { |
| 210 | autoNotebookEditorcxx . . $ autoNotebookEditor# me = Thing_newcxx . . $ `sys/Thing.h:514:9`! (NotebookEditor); |
| 211 | NotebookEditor_initcxx . . $ NotebookEditor_init(edd84ce69971f6a0). (me.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), initialText); |
| 212 | return mecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 213 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 214 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Notebook window not created."); |
| 215 | } |
| 216 | } |
| 217 | |
| 218 | autoNotebookEditorcxx . . $ autoNotebookEditor# NotebookEditor_createFromNotebook_canBeNullcxx . . $ NotebookEditor_createFromNotebook_canBeNull(57835e04bf6cce63). (Notebookcxx . . $ Notebook# notebook) { |
| 219 | try { |
| 220 | structMelderFilecxx . . $ structMelderFile# notebookFile { }; |
| 221 | for (integercxx . . $ integer# ieditor = 1; ieditor <= theReferencesToAllOpenNotebookEditorscxx . . $ theReferencesToAllOpenNotebookEditors..sizecxx . . $ CollectionOf#size.; ieditor ++) { |
| 222 | NotebookEditorcxx . . $ NotebookEditor# editor = theReferencesToAllOpenNotebookEditorscxx . . $ theReferencesToAllOpenNotebookEditors..atcxx . . $ CollectionOf#at. [cxx . . $ ArrayOf#`operator[]`(a7f36fee1ae21897).ieditor]; |
| 223 | if (Melder_equcxx . . $ `melder/melder_str32.h:124:9`! (notebook -> stringcxx . . $ structSimpleString#string..getcxx . . $ _autostring#get(5a2a78a048fb49a8).(), MelderFile_peekPathcxx . . $ MelderFile_peekPath(d9f043369fa9b55b). (& editor -> filecxx . . $ structTextEditor#file.))) { |
| 224 | Editor_raisecxx . . $ Editor_raise(c0154a85f79216c7). (editor); |
| 225 | Melder_pathToFilecxx . . $ Melder_pathToFile(82691f2ee21fbb13). (notebook -> stringcxx . . $ structSimpleString#string..getcxx . . $ _autostring#get(5a2a78a048fb49a8).(), & notebookFile); |
| 226 | Melder_appendErrorcxx . . $ Melder_appendError(6298c93241566110). (U"The notebook ", & notebookFile, U" is already open and has been moved to the front."); |
| 227 | if (editor -> dirtycxx . . $ structTextEditor#dirty.) |
| 228 | Melder_appendErrorcxx . . $ Melder_appendError(6298c93241566110). (U"Choose “Reopen from disk” if you want to revert to the old version."); |
| 229 | Melder_flushErrorcxx . . $ Melder_flushError(49f6e7a06ebc5aa8). (); |
| 230 | return autoNotebookEditorcxx . . $ autoSomeThing#autoSomeThing(49f6e7a06ebc5aa8).(); // safe null |
| 231 | } |
| 232 | } |
| 233 | Melder_pathToFilecxx . . $ Melder_pathToFile(82691f2ee21fbb13). (notebook -> stringcxx . . $ structSimpleString#string..getcxx . . $ _autostring#get(5a2a78a048fb49a8).(), & notebookFile); |
| 234 | autostring32cxx . . $ autostring32# text = MelderFile_readTextcxx . . $ MelderFile_readText(2312d39ae70aea26). (& notebookFile); |
| 235 | autoNotebookEditorcxx . . $ autoNotebookEditor# me = NotebookEditor_createFromTextcxx . . $ NotebookEditor_createFromText(2ab91d38f0848c38). (text.getcxx . . $ _autostring#get(5a2a78a048fb49a8).()); |
| 236 | MelderFile_copycxx . . $ MelderFile_copy(b298201f6d539a65). (& notebookFile, & mycxx . . $ `melder/melder.h:44:9`! filecxx . . $ structTextEditor#file.); |
| 237 | Thing_setNamecxx . . $ Thing_setName(b5a42e5e01c267b5). (me.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), nullptr); |
| 238 | return mecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 239 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 240 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Notebook window not created."); |
| 241 | } |
| 242 | } |
| 243 | |
| 244 | void NotebookEditor_debug_printAllOpenNotebookEditorscxx . . $ NotebookEditor_debug_printAllOpenNotebookEditors(49f6e7a06ebc5aa8). () { |
| 245 | for (integercxx . . $ integer# ieditor = 1; ieditor <= theReferencesToAllOpenNotebookEditorscxx . . $ theReferencesToAllOpenNotebookEditors..sizecxx . . $ CollectionOf#size.; ieditor ++) { |
| 246 | NotebookEditorcxx . . $ NotebookEditor# editor = theReferencesToAllOpenNotebookEditorscxx . . $ theReferencesToAllOpenNotebookEditors..atcxx . . $ CollectionOf#at. [cxx . . $ ArrayOf#`operator[]`(a7f36fee1ae21897).ieditor]; |
| 247 | Melder_casualcxx . . $ Melder_casual(6298c93241566110). (U"Open notebook editor #", ieditor, U": <<", & editor -> filecxx . . $ structTextEditor#file., U">>"); |
| 248 | } |
| 249 | } |
| 250 | |
| 251 | /* End of file NotebookEditor.cpp */ |