| 1 | /* TextEditor.cpp |
| 2 | * |
| 3 | * Copyright (C) 1997-2026 Paul Boersma, 2010 Franz Brausse |
| 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 "ScriptEditor.h"cxx . . $ `<file>/sys/ScriptEditor.h`/ |
| 20 | #include "machine.h"cxx . . $ `<file>/sys/machine.h`/ |
| 21 | #include "../kar/longchar.h"cxx . . $ `<file>/kar/longchar.h`/ |
| 22 | #include "EditorM.h"cxx . . $ `<file>/sys/EditorM.h`/ |
| 23 | #include "../kar/UnicodeData.h"cxx . . $ `<file>/kar/UnicodeData.h`/ |
| 24 | |
| 25 | Thing_implementcxx . . $ `sys/Thing.h:65:9`! (TextEditor, Editor, 0); |
| 26 | |
| 27 | #include "Prefs_define.h"cxx . . $ `<file>/sys/Prefs_define.h`/ |
| 28 | #include "TextEditor_prefs.h"cxx . . $ `<file>/sys/TextEditor_prefs.h`/ |
| 29 | #include "Prefs_install.h"cxx . . $ `<file>/sys/Prefs_install.h`/ |
| 30 | #include "TextEditor_prefs.h"cxx . . $ `<file>/sys/TextEditor_prefs.h`/ |
| 31 | #include "Prefs_copyToInstance.h"cxx . . $ `<file>/sys/Prefs_copyToInstance.h`/ |
| 32 | #include "TextEditor_prefs.h"cxx . . $ `<file>/sys/TextEditor_prefs.h`/ |
| 33 | |
| 34 | static CollectionOfcxx . . $ CollectionOf# <structTextEditorcxx . . $ structTextEditor#> theReferencesToAllOpenTextEditorscxx . . $ theReferencesToAllOpenTextEditors.; |
| 35 | |
| 36 | /***** TextEditor methods *****/ |
| 37 | |
| 38 | void structTextEditorcxx . . $ structTextEditor# :: v9_destroycxx . . $ structTextEditor#v9_destroy(ced63f7c635d850d). () noexcept { |
| 39 | ourcxx . . $ `melder/melder.h:42:9`! openDialogcxx . . $ structTextEditor#openDialog.. resetcxx . . $ autoSomeThing#reset(ced63f7c635d850d).(); // don't delay till delete |
| 40 | ourcxx . . $ `melder/melder.h:42:9`! saveDialogcxx . . $ structTextEditor#saveDialog.. resetcxx . . $ autoSomeThing#reset(ced63f7c635d850d).(); // don't delay till delete |
| 41 | theReferencesToAllOpenTextEditorscxx . . $ theReferencesToAllOpenTextEditors.. undangleItemcxx . . $ CollectionOf#undangleItem(97cddd01752945f6). (this); |
| 42 | TextEditor_Parentcxx . . $ TextEditor_Parent# :: v9_destroycxx . . $ structEditor#v9_destroy(ced63f7c635d850d). (); |
| 43 | } |
| 44 | |
| 45 | void structTextEditorcxx . . $ structTextEditor# :: v_nameChangedcxx . . $ structTextEditor#v_nameChanged(49f6e7a06ebc5aa8). () { |
| 46 | if (ourcxx . . $ `melder/melder.h:42:9`! v_fileBasedcxx . . $ structTextEditor#v_fileBased(50ce9a9e25b4a850). ()) { |
| 47 | /* |
| 48 | We totally ignore the name that our boss wants to give us. |
| 49 | Instead, we compose the window title from three ingredients: |
| 50 | |
| 51 | (1) whether we are already associated with a file or not; |
| 52 | (2) if so, the full file path; |
| 53 | (3) whether our text has been modified (i.e. whether we are "dirty"). |
| 54 | |
| 55 | (last checked 2023-02-25) |
| 56 | */ |
| 57 | 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.); |
| 58 | static MelderStringcxx . . $ MelderString# windowTitle; |
| 59 | if (MelderFile_isNullcxx . . $ MelderFile_isNull(8f92cdf95b27d908). (& ourcxx . . $ `melder/melder.h:42:9`! filecxx . . $ structTextEditor#file.)) { |
| 60 | MelderString_copycxx . . $ MelderString_copy(65be51a793e0ff96). (& windowTitle, U"(untitled"); |
| 61 | if (ourcxx . . $ `melder/melder.h:42:9`! dirtycxx . . $ structTextEditor#dirty. && ! dirtinessAlreadyShown) |
| 62 | MelderString_appendcxx . . $ MelderString_append(65be51a793e0ff96). (& windowTitle, U", modified"); |
| 63 | MelderString_appendcxx . . $ MelderString_append(65be51a793e0ff96). (& windowTitle, U")"); |
| 64 | } else { |
| 65 | MelderString_copycxx . . $ MelderString_copy(65be51a793e0ff96). (& windowTitle, U"File ", MelderFile_messageNamecxx . . $ MelderFile_messageName(d9f043369fa9b55b). (& ourcxx . . $ `melder/melder.h:42:9`! filecxx . . $ structTextEditor#file.)); |
| 66 | if (ourcxx . . $ `melder/melder.h:42:9`! dirtycxx . . $ structTextEditor#dirty. && ! dirtinessAlreadyShown) |
| 67 | MelderString_appendcxx . . $ MelderString_append(65be51a793e0ff96). (& windowTitle, U" (modified)"); |
| 68 | } |
| 69 | GuiShell_setTitlecxx . . $ GuiShell_setTitle(3a9df304850abc11). (ourcxx . . $ `melder/melder.h:42:9`! windowFormcxx . . $ structEditor#windowForm., windowTitle.stringcxx . . $ MelderString#string.); |
| 70 | } else { |
| 71 | /* |
| 72 | We will set our window title to the name that our boss wants. |
| 73 | This occurs e.g. in the Info window. |
| 74 | (last checked 2023-02-25) |
| 75 | */ |
| 76 | TextEditor_Parentcxx . . $ TextEditor_Parent# :: v_nameChangedcxx . . $ structEditor#v_nameChanged(49f6e7a06ebc5aa8). (); |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | #pragma mark - File menu |
| 81 | |
| 82 | static void openDocumentcxx . . $ openDocument(49f816b8be034823). (TextEditorcxx . . $ TextEditor# me, MelderFilecxx . . $ MelderFile# file) { |
| 83 | for (integercxx . . $ integer# ieditor = 1; ieditor <= theReferencesToAllOpenTextEditorscxx . . $ theReferencesToAllOpenTextEditors..sizecxx . . $ CollectionOf#size.; ieditor ++) { |
| 84 | TextEditorcxx . . $ TextEditor# editor = theReferencesToAllOpenTextEditorscxx . . $ theReferencesToAllOpenTextEditors..atcxx . . $ CollectionOf#at. [cxx . . $ ArrayOf#`operator[]`(a7f36fee1ae21897).ieditor]; |
| 85 | if (editor != me && MelderFile_equalcxx . . $ MelderFile_equal(570c9229a9b16092). (file, & editor -> filecxx . . $ structTextEditor#file.)) { |
| 86 | Editor_raisecxx . . $ Editor_raise(c0154a85f79216c7). (editor); |
| 87 | /* |
| 88 | Destruction alarm! |
| 89 | When we combine the destruction of an object with the presentation of a message, |
| 90 | we shall always follow the "build message -- destroy -- show message" paradigm. |
| 91 | Actually, in this case this is not only safe, but also crucial, |
| 92 | because at the time of writing (2019-04-28) the owner of `file` is owned by `me`, |
| 93 | so that destroying `me` would dangle `file`. |
| 94 | */ |
| 95 | Melder_appendErrorcxx . . $ Melder_appendError(6298c93241566110). (U"Text file ", file, U" is already open."); |
| 96 | forgetcxx . . $ `sys/Thing.h:158:9`! (me); |
| 97 | Melder_flushErrorcxx . . $ Melder_flushError(49f6e7a06ebc5aa8). (); |
| 98 | return; |
| 99 | } |
| 100 | } |
| 101 | autostring32cxx . . $ autostring32# text = MelderFile_readTextcxx . . $ MelderFile_readText(2312d39ae70aea26). (file); |
| 102 | GuiText_setStringcxx . . $ GuiText_setString(d44acbd60ea2b9be). (mycxx . . $ `melder/melder.h:44:9`! textWidgetcxx . . $ structTextEditor#textWidget., text.getcxx . . $ _autostring#get(5a2a78a048fb49a8).()); |
| 103 | /* |
| 104 | GuiText_setString has invoked the changeCallback, |
| 105 | which has set `my dirty` to `true`. Fix this. |
| 106 | */ |
| 107 | mycxx . . $ `melder/melder.h:44:9`! dirtycxx . . $ structTextEditor#dirty. = false; |
| 108 | MelderFile_copycxx . . $ MelderFile_copy(b298201f6d539a65). (file, & mycxx . . $ `melder/melder.h:44:9`! filecxx . . $ structTextEditor#file.); // not until the file has been safely read |
| 109 | Thing_setNamecxx . . $ Thing_setName(b5a42e5e01c267b5). (me, nullptr); |
| 110 | } |
| 111 | |
| 112 | static void newDocumentcxx . . $ newDocument(22283699a15c80c8). (TextEditorcxx . . $ TextEditor# me) { |
| 113 | GuiText_setStringcxx . . $ GuiText_setString(d44acbd60ea2b9be). (mycxx . . $ `melder/melder.h:44:9`! textWidgetcxx . . $ structTextEditor#textWidget., U""); // implicitly sets my dirty to `true` |
| 114 | mycxx . . $ `melder/melder.h:44:9`! dirtycxx . . $ structTextEditor#dirty. = false; |
| 115 | MelderFile_setToNullcxx . . $ MelderFile_setToNull(1145552d769d7b5d). (& mycxx . . $ `melder/melder.h:44:9`! filecxx . . $ structTextEditor#file.); |
| 116 | if (mycxx . . $ `melder/melder.h:44:9`! v_fileBasedcxx . . $ structTextEditor#v_fileBased(50ce9a9e25b4a850). ()) |
| 117 | Thing_setNamecxx . . $ Thing_setName(b5a42e5e01c267b5). (me, nullptr); |
| 118 | } |
| 119 | |
| 120 | static void saveDocumentcxx . . $ saveDocument(49f816b8be034823). (TextEditorcxx . . $ TextEditor# me, MelderFilecxx . . $ MelderFile# file) { |
| 121 | autostring32cxx . . $ autostring32# text = GuiText_getStringcxx . . $ GuiText_getString(9a61f82c13ba8ebc). (mycxx . . $ `melder/melder.h:44:9`! textWidgetcxx . . $ structTextEditor#textWidget.); |
| 122 | MelderFile_writeText_ecxx . . $ MelderFile_writeText_e(4f26204211a3b413). (file, text.getcxx . . $ _autostring#get(5a2a78a048fb49a8).(), Melder_getOutputEncodingcxx . . $ Melder_getOutputEncoding(581d0d572cba43d7). ()); |
| 123 | mycxx . . $ `melder/melder.h:44:9`! dirtycxx . . $ structTextEditor#dirty. = false; |
| 124 | MelderFile_copycxx . . $ MelderFile_copy(b298201f6d539a65). (file, & mycxx . . $ `melder/melder.h:44:9`! filecxx . . $ structTextEditor#file.); // not until the file has been safely written |
| 125 | if (mycxx . . $ `melder/melder.h:44:9`! v_fileBasedcxx . . $ structTextEditor#v_fileBased(50ce9a9e25b4a850). ()) |
| 126 | Thing_setNamecxx . . $ Thing_setName(b5a42e5e01c267b5). (me, nullptr); |
| 127 | } |
| 128 | |
| 129 | static void closeDocumentcxx . . $ closeDocument(22283699a15c80c8). (TextEditorcxx . . $ TextEditor# me) { |
| 130 | forgetcxx . . $ `sys/Thing.h:158:9`! (me); |
| 131 | } |
| 132 | |
| 133 | static void cb_open_okcxx . . $ cb_open_ok(744a0abd3c8513c). (UiFormcxx . . $ UiForm# sendingForm, integercxx . . $ integer# /* narg */, Stackelcxx . . $ Stackel# /* args */, conststring32cxx . . $ conststring32# /* sendingString */, |
| 134 | Interpretercxx . . $ Interpreter# /* interpreter */, conststring32cxx . . $ conststring32# /* invokingButtonTitle */, bool /* modified */, void *void_me, Editorcxx . . $ Editor# /* optionalEditor */) |
| 135 | { |
| 136 | iamcxx . . $ `melder/melder.h:50:9`! (TextEditor); |
| 137 | MelderFilecxx . . $ MelderFile# file = UiFile_getFilecxx . . $ UiFile_getFile(fbc6b61177245f1d). (sendingForm); |
| 138 | openDocumentcxx . . $ openDocument(49f816b8be034823). (me, file); |
| 139 | } |
| 140 | |
| 141 | static void cb_showOpencxx . . $ cb_showOpen(2b98fae8e13abb61). (EditorCommandcxx . . $ EditorCommand# cmd) { |
| 142 | TextEditorcxx . . $ TextEditor# me = (TextEditorcxx . . $ TextEditor#) cmd -> d_editorcxx . . $ structEditorCommand#d_editor.; |
| 143 | if (! mycxx . . $ `melder/melder.h:44:9`! openDialogcxx . . $ structTextEditor#openDialog.) |
| 144 | mycxx . . $ `melder/melder.h:44:9`! openDialogcxx . . $ structTextEditor#openDialog. =cxx . . $ autoSomeThing#`operator=`(80cc59814f7161e8). UiInfile_createcxx . . $ UiInfile_create(50b46b1e7e1cbcb). (mycxx . . $ `melder/melder.h:44:9`! windowFormcxx . . $ structEditor#windowForm., nullptr, U"Open", cb_open_okcxx . . $ cb_open_ok(744a0abd3c8513c)., me, nullptr, nullptr, false); |
| 145 | UiInfile_docxx . . $ UiInfile_do(b4388889c5fb10c0). (mycxx . . $ `melder/melder.h:44:9`! openDialogcxx . . $ structTextEditor#openDialog..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).()); |
| 146 | } |
| 147 | |
| 148 | static void cb_saveAs_okcxx . . $ cb_saveAs_ok(744a0abd3c8513c). (UiFormcxx . . $ UiForm# sendingForm, integercxx . . $ integer# /* narg */, Stackelcxx . . $ Stackel# /* args */, conststring32cxx . . $ conststring32# /* sendingString */, |
| 149 | Interpretercxx . . $ Interpreter# /* interpreter */, conststring32cxx . . $ conststring32# /* invokingButtonTitle */, bool /* modified */, void *void_me, Editorcxx . . $ Editor# /* optionalEditor */) |
| 150 | { |
| 151 | iamcxx . . $ `melder/melder.h:50:9`! (TextEditor); |
| 152 | MelderFilecxx . . $ MelderFile# file = UiFile_getFilecxx . . $ UiFile_getFile(fbc6b61177245f1d). (sendingForm); |
| 153 | saveDocumentcxx . . $ saveDocument(49f816b8be034823). (me, file); |
| 154 | } |
| 155 | |
| 156 | static void menu_cb_saveAscxx . . $ menu_cb_saveAs(10954be9f18e7411). (TextEditorcxx . . $ TextEditor# me, EDITOR_ARGScxx . . $ `sys/EditorM.h:25:9`!) { |
| 157 | if (! mycxx . . $ `melder/melder.h:44:9`! saveDialogcxx . . $ structTextEditor#saveDialog.) |
| 158 | mycxx . . $ `melder/melder.h:44:9`! saveDialogcxx . . $ structTextEditor#saveDialog. =cxx . . $ autoSomeThing#`operator=`(80cc59814f7161e8). UiOutfile_createcxx . . $ UiOutfile_create(b3c832b012a1002d). (mycxx . . $ `melder/melder.h:44:9`! windowFormcxx . . $ structEditor#windowForm., nullptr, U"Save", cb_saveAs_okcxx . . $ cb_saveAs_ok(744a0abd3c8513c)., me, nullptr, nullptr); |
| 159 | char32cxx . . $ char32# defaultName [300]; |
| 160 | Melder_sprintcxx . . $ Melder_sprint(2b992b0fb5123bdf). (defaultName,300, |
| 161 | mycxx . . $ `melder/melder.h:44:9`! v_fileBasedcxx . . $ structTextEditor#v_fileBased(50ce9a9e25b4a850). () ? |
| 162 | MelderFile_isNullcxx . . $ MelderFile_isNull(8f92cdf95b27d908). (& mycxx . . $ `melder/melder.h:44:9`! filecxx . . $ structTextEditor#file.) ? |
| 163 | Melder_catcxx . . $ Melder_cat(7fbf27f4d367f442). (U"untitled", mycxx . . $ `melder/melder.h:44:9`! v_extensioncxx . . $ structTextEditor#v_extension(d608cbfe2b610d03). ()) |
| 164 | : |
| 165 | MelderFile_namecxx . . $ MelderFile_name(d9f043369fa9b55b). (& mycxx . . $ `melder/melder.h:44:9`! filecxx . . $ structTextEditor#file.) |
| 166 | : |
| 167 | U"info.txt" |
| 168 | ); |
| 169 | UiOutfile_docxx . . $ UiOutfile_do(dd78e4d327935865). (mycxx . . $ `melder/melder.h:44:9`! saveDialogcxx . . $ structTextEditor#saveDialog..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), defaultName); |
| 170 | } |
| 171 | |
| 172 | static void gui_button_cb_saveAndOpencxx . . $ gui_button_cb_saveAndOpen(55165f8e6beb845e). (EditorCommandcxx . . $ EditorCommand# cmd, GuiButtonEventcxx . . $ GuiButtonEvent# /* event */) { |
| 173 | TextEditorcxx . . $ TextEditor# me = (TextEditorcxx . . $ TextEditor#) cmd -> d_editorcxx . . $ structEditorCommand#d_editor.; |
| 174 | GuiThing_hidecxx . . $ GuiThing_hide(20e88c25f0ba841). (mycxx . . $ `melder/melder.h:44:9`! dirtyOpenDialogcxx . . $ structTextEditor#dirtyOpenDialog.); |
| 175 | if (MelderFile_isNullcxx . . $ MelderFile_isNull(8f92cdf95b27d908). (& mycxx . . $ `melder/melder.h:44:9`! filecxx . . $ structTextEditor#file.)) { |
| 176 | menu_cb_saveAscxx . . $ menu_cb_saveAs(10954be9f18e7411). (me, cmd, nullptr, 0, nullptr, nullptr, nullptr); |
| 177 | } else { |
| 178 | try { |
| 179 | saveDocumentcxx . . $ saveDocument(49f816b8be034823). (me, & mycxx . . $ `melder/melder.h:44:9`! filecxx . . $ structTextEditor#file.); |
| 180 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 181 | Melder_flushErrorcxx . . $ Melder_flushError(49f6e7a06ebc5aa8). (); |
| 182 | return; |
| 183 | } |
| 184 | cb_showOpencxx . . $ cb_showOpen(2b98fae8e13abb61). (cmd); |
| 185 | } |
| 186 | } |
| 187 | |
| 188 | static void gui_button_cb_cancelOpencxx . . $ gui_button_cb_cancelOpen(55165f8e6beb845e). (EditorCommandcxx . . $ EditorCommand# cmd, GuiButtonEventcxx . . $ GuiButtonEvent# /* event */) { |
| 189 | TextEditorcxx . . $ TextEditor# me = (TextEditorcxx . . $ TextEditor#) cmd -> d_editorcxx . . $ structEditorCommand#d_editor.; |
| 190 | GuiThing_hidecxx . . $ GuiThing_hide(20e88c25f0ba841). (mycxx . . $ `melder/melder.h:44:9`! dirtyOpenDialogcxx . . $ structTextEditor#dirtyOpenDialog.); |
| 191 | } |
| 192 | |
| 193 | static void gui_button_cb_discardAndOpencxx . . $ gui_button_cb_discardAndOpen(55165f8e6beb845e). (EditorCommandcxx . . $ EditorCommand# cmd, GuiButtonEventcxx . . $ GuiButtonEvent# /* event */) { |
| 194 | TextEditorcxx . . $ TextEditor# me = (TextEditorcxx . . $ TextEditor#) cmd -> d_editorcxx . . $ structEditorCommand#d_editor.; |
| 195 | GuiThing_hidecxx . . $ GuiThing_hide(20e88c25f0ba841). (mycxx . . $ `melder/melder.h:44:9`! dirtyOpenDialogcxx . . $ structTextEditor#dirtyOpenDialog.); |
| 196 | cb_showOpencxx . . $ cb_showOpen(2b98fae8e13abb61). (cmd); |
| 197 | } |
| 198 | |
| 199 | static void menu_cb_opencxx . . $ menu_cb_open(10954be9f18e7411). (TextEditorcxx . . $ TextEditor# me, EDITOR_ARGScxx . . $ `sys/EditorM.h:25:9`!) { |
| 200 | if (mycxx . . $ `melder/melder.h:44:9`! dirtycxx . . $ structTextEditor#dirty.) { |
| 201 | if (! mycxx . . $ `melder/melder.h:44:9`! dirtyOpenDialogcxx . . $ structTextEditor#dirtyOpenDialog.) { |
| 202 | int buttonWidth = 120, buttonSpacing = 20; |
| 203 | mycxx . . $ `melder/melder.h:44:9`! dirtyOpenDialogcxx . . $ structTextEditor#dirtyOpenDialog. = GuiDialog_createcxx . . $ GuiDialog_create(9df51e4563bc0c17). (mycxx . . $ `melder/melder.h:44:9`! windowFormcxx . . $ structEditor#windowForm., |
| 204 | 150, 70, |
| 205 | Gui_LEFT_DIALOG_SPACINGcxx . . $ `sys/Gui.h:85:9`! + 3 * buttonWidth + 2 * buttonSpacing + Gui_RIGHT_DIALOG_SPACINGcxx . . $ `sys/Gui.h:86:9`!, |
| 206 | Gui_TOP_DIALOG_SPACINGcxx . . $ `sys/Gui.h:90:10`! + Gui_TEXTFIELD_HEIGHTcxx . . $ `sys/Gui.h:96:9`! + Gui_VERTICAL_DIALOG_SPACING_SAMEcxx . . $ `sys/Gui.h:94:9`! + 2 * Gui_BOTTOM_DIALOG_SPACINGcxx . . $ `sys/Gui.h:92:9`! + Gui_PUSHBUTTON_HEIGHTcxx . . $ `sys/Gui.h:103:9`!, |
| 207 | U"Text changed", nullptrcxx . . $ MelderCallback#MelderCallback(fc624d2cd197112)., nullptr, GuiDialog_Modalitycxx . . $ GuiDialog_Modality#::MODALcxx . . $ GuiDialog_Modality#MODAL. |
| 208 | ); |
| 209 | GuiLabel_createShowncxx . . $ GuiLabel_createShown(39026c9008a6a07). (mycxx . . $ `melder/melder.h:44:9`! dirtyOpenDialogcxx . . $ structTextEditor#dirtyOpenDialog., |
| 210 | Gui_LEFT_DIALOG_SPACINGcxx . . $ `sys/Gui.h:85:9`!, - Gui_RIGHT_DIALOG_SPACINGcxx . . $ `sys/Gui.h:86:9`!, |
| 211 | Gui_TOP_DIALOG_SPACINGcxx . . $ `sys/Gui.h:90:10`!, Gui_TOP_DIALOG_SPACINGcxx . . $ `sys/Gui.h:90:10`! + Gui_LABEL_HEIGHTcxx . . $ `sys/Gui.h:97:9`!, |
| 212 | U"The text has changed! Save changes?", 0 |
| 213 | ); |
| 214 | int x = Gui_LEFT_DIALOG_SPACINGcxx . . $ `sys/Gui.h:85:9`!, y = - Gui_BOTTOM_DIALOG_SPACINGcxx . . $ `sys/Gui.h:92:9`!; |
| 215 | GuiButton_createShowncxx . . $ GuiButton_createShown(653ed9987c16d9c1). (mycxx . . $ `melder/melder.h:44:9`! dirtyOpenDialogcxx . . $ structTextEditor#dirtyOpenDialog., |
| 216 | x, x + buttonWidth, y - Gui_PUSHBUTTON_HEIGHTcxx . . $ `sys/Gui.h:103:9`!, y, |
| 217 | U"Discard & Open", gui_button_cb_discardAndOpencxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97)., cmd, 0 |
| 218 | ); |
| 219 | x += buttonWidth + buttonSpacing; |
| 220 | GuiButton_createShowncxx . . $ GuiButton_createShown(653ed9987c16d9c1). (mycxx . . $ `melder/melder.h:44:9`! dirtyOpenDialogcxx . . $ structTextEditor#dirtyOpenDialog., |
| 221 | x, x + buttonWidth, y - Gui_PUSHBUTTON_HEIGHTcxx . . $ `sys/Gui.h:103:9`!, y, |
| 222 | U"Cancel", gui_button_cb_cancelOpencxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97)., cmd, 0 |
| 223 | ); |
| 224 | x += buttonWidth + buttonSpacing; |
| 225 | GuiButton_createShowncxx . . $ GuiButton_createShown(653ed9987c16d9c1). (mycxx . . $ `melder/melder.h:44:9`! dirtyOpenDialogcxx . . $ structTextEditor#dirtyOpenDialog., |
| 226 | x, x + buttonWidth, y - Gui_PUSHBUTTON_HEIGHTcxx . . $ `sys/Gui.h:103:9`!, y, |
| 227 | U"Save & Open", gui_button_cb_saveAndOpencxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97)., cmd, 0 |
| 228 | ); |
| 229 | } |
| 230 | GuiThing_showcxx . . $ GuiThing_show(20e88c25f0ba841). (mycxx . . $ `melder/melder.h:44:9`! dirtyOpenDialogcxx . . $ structTextEditor#dirtyOpenDialog.); |
| 231 | } else { |
| 232 | cb_showOpencxx . . $ cb_showOpen(2b98fae8e13abb61). (cmd); |
| 233 | } |
| 234 | } |
| 235 | |
| 236 | static void gui_button_cb_saveAndNewcxx . . $ gui_button_cb_saveAndNew(55165f8e6beb845e). (EditorCommandcxx . . $ EditorCommand# cmd, GuiButtonEventcxx . . $ GuiButtonEvent# /* event */) { |
| 237 | TextEditorcxx . . $ TextEditor# me = (TextEditorcxx . . $ TextEditor#) cmd -> d_editorcxx . . $ structEditorCommand#d_editor.; |
| 238 | GuiThing_hidecxx . . $ GuiThing_hide(20e88c25f0ba841). (mycxx . . $ `melder/melder.h:44:9`! dirtyNewDialogcxx . . $ structTextEditor#dirtyNewDialog.); |
| 239 | if (MelderFile_isNullcxx . . $ MelderFile_isNull(8f92cdf95b27d908). (& mycxx . . $ `melder/melder.h:44:9`! filecxx . . $ structTextEditor#file.)) { |
| 240 | menu_cb_saveAscxx . . $ menu_cb_saveAs(10954be9f18e7411). (me, cmd, nullptr, 0, nullptr, nullptr, nullptr); |
| 241 | } else { |
| 242 | try { |
| 243 | saveDocumentcxx . . $ saveDocument(49f816b8be034823). (me, & mycxx . . $ `melder/melder.h:44:9`! filecxx . . $ structTextEditor#file.); |
| 244 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 245 | Melder_flushErrorcxx . . $ Melder_flushError(49f6e7a06ebc5aa8). (); |
| 246 | return; |
| 247 | } |
| 248 | newDocumentcxx . . $ newDocument(22283699a15c80c8). (me); |
| 249 | } |
| 250 | } |
| 251 | |
| 252 | static void gui_button_cb_cancelNewcxx . . $ gui_button_cb_cancelNew(55165f8e6beb845e). (EditorCommandcxx . . $ EditorCommand# cmd, GuiButtonEventcxx . . $ GuiButtonEvent# /* event */) { |
| 253 | TextEditorcxx . . $ TextEditor# me = (TextEditorcxx . . $ TextEditor#) cmd -> d_editorcxx . . $ structEditorCommand#d_editor.; |
| 254 | GuiThing_hidecxx . . $ GuiThing_hide(20e88c25f0ba841). (mycxx . . $ `melder/melder.h:44:9`! dirtyNewDialogcxx . . $ structTextEditor#dirtyNewDialog.); |
| 255 | } |
| 256 | |
| 257 | static void gui_button_cb_discardAndNewcxx . . $ gui_button_cb_discardAndNew(55165f8e6beb845e). (EditorCommandcxx . . $ EditorCommand# cmd, GuiButtonEventcxx . . $ GuiButtonEvent# /* event */) { |
| 258 | TextEditorcxx . . $ TextEditor# me = (TextEditorcxx . . $ TextEditor#) cmd -> d_editorcxx . . $ structEditorCommand#d_editor.; |
| 259 | GuiThing_hidecxx . . $ GuiThing_hide(20e88c25f0ba841). (mycxx . . $ `melder/melder.h:44:9`! dirtyNewDialogcxx . . $ structTextEditor#dirtyNewDialog.); |
| 260 | newDocumentcxx . . $ newDocument(22283699a15c80c8). (me); |
| 261 | } |
| 262 | |
| 263 | static void menu_cb_newcxx . . $ menu_cb_new(10954be9f18e7411). (TextEditorcxx . . $ TextEditor# me, EDITOR_ARGScxx . . $ `sys/EditorM.h:25:9`!) { |
| 264 | if (mycxx . . $ `melder/melder.h:44:9`! v_fileBasedcxx . . $ structTextEditor#v_fileBased(50ce9a9e25b4a850). () && mycxx . . $ `melder/melder.h:44:9`! dirtycxx . . $ structTextEditor#dirty.) { |
| 265 | if (! mycxx . . $ `melder/melder.h:44:9`! dirtyNewDialogcxx . . $ structTextEditor#dirtyNewDialog.) { |
| 266 | int buttonWidth = 120, buttonSpacing = 20; |
| 267 | mycxx . . $ `melder/melder.h:44:9`! dirtyNewDialogcxx . . $ structTextEditor#dirtyNewDialog. = GuiDialog_createcxx . . $ GuiDialog_create(9df51e4563bc0c17). (mycxx . . $ `melder/melder.h:44:9`! windowFormcxx . . $ structEditor#windowForm., |
| 268 | 150, 70, Gui_LEFT_DIALOG_SPACINGcxx . . $ `sys/Gui.h:85:9`! + 3 * buttonWidth + 2 * buttonSpacing + Gui_RIGHT_DIALOG_SPACINGcxx . . $ `sys/Gui.h:86:9`!, |
| 269 | Gui_TOP_DIALOG_SPACINGcxx . . $ `sys/Gui.h:90:10`! + Gui_TEXTFIELD_HEIGHTcxx . . $ `sys/Gui.h:96:9`! + Gui_VERTICAL_DIALOG_SPACING_SAMEcxx . . $ `sys/Gui.h:94:9`! + 2 * Gui_BOTTOM_DIALOG_SPACINGcxx . . $ `sys/Gui.h:92:9`! + Gui_PUSHBUTTON_HEIGHTcxx . . $ `sys/Gui.h:103:9`!, |
| 270 | U"Text changed", nullptrcxx . . $ MelderCallback#MelderCallback(fc624d2cd197112)., nullptr, GuiDialog_Modalitycxx . . $ GuiDialog_Modality#::MODALcxx . . $ GuiDialog_Modality#MODAL. |
| 271 | ); |
| 272 | GuiLabel_createShowncxx . . $ GuiLabel_createShown(39026c9008a6a07). (mycxx . . $ `melder/melder.h:44:9`! dirtyNewDialogcxx . . $ structTextEditor#dirtyNewDialog., |
| 273 | Gui_LEFT_DIALOG_SPACINGcxx . . $ `sys/Gui.h:85:9`!, - Gui_RIGHT_DIALOG_SPACINGcxx . . $ `sys/Gui.h:86:9`!, |
| 274 | Gui_TOP_DIALOG_SPACINGcxx . . $ `sys/Gui.h:90:10`!, Gui_TOP_DIALOG_SPACINGcxx . . $ `sys/Gui.h:90:10`! + Gui_LABEL_HEIGHTcxx . . $ `sys/Gui.h:97:9`!, |
| 275 | U"The text has changed! Save changes?", 0 |
| 276 | ); |
| 277 | int x = Gui_LEFT_DIALOG_SPACINGcxx . . $ `sys/Gui.h:85:9`!, y = - Gui_BOTTOM_DIALOG_SPACINGcxx . . $ `sys/Gui.h:92:9`!; |
| 278 | GuiButton_createShowncxx . . $ GuiButton_createShown(653ed9987c16d9c1). (mycxx . . $ `melder/melder.h:44:9`! dirtyNewDialogcxx . . $ structTextEditor#dirtyNewDialog., |
| 279 | x, x + buttonWidth, y - Gui_PUSHBUTTON_HEIGHTcxx . . $ `sys/Gui.h:103:9`!, y, |
| 280 | U"Discard & New", gui_button_cb_discardAndNewcxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97)., cmd, 0 |
| 281 | ); |
| 282 | x += buttonWidth + buttonSpacing; |
| 283 | GuiButton_createShowncxx . . $ GuiButton_createShown(653ed9987c16d9c1). (mycxx . . $ `melder/melder.h:44:9`! dirtyNewDialogcxx . . $ structTextEditor#dirtyNewDialog., |
| 284 | x, x + buttonWidth, y - Gui_PUSHBUTTON_HEIGHTcxx . . $ `sys/Gui.h:103:9`!, y, |
| 285 | U"Cancel", gui_button_cb_cancelNewcxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97)., cmd, 0 |
| 286 | ); |
| 287 | x += buttonWidth + buttonSpacing; |
| 288 | GuiButton_createShowncxx . . $ GuiButton_createShown(653ed9987c16d9c1). (mycxx . . $ `melder/melder.h:44:9`! dirtyNewDialogcxx . . $ structTextEditor#dirtyNewDialog., |
| 289 | x, x + buttonWidth, y - Gui_PUSHBUTTON_HEIGHTcxx . . $ `sys/Gui.h:103:9`!, y, |
| 290 | U"Save & New", gui_button_cb_saveAndNewcxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97)., cmd, 0 |
| 291 | ); |
| 292 | } |
| 293 | GuiThing_showcxx . . $ GuiThing_show(20e88c25f0ba841). (mycxx . . $ `melder/melder.h:44:9`! dirtyNewDialogcxx . . $ structTextEditor#dirtyNewDialog.); |
| 294 | } else { |
| 295 | newDocumentcxx . . $ newDocument(22283699a15c80c8). (me); |
| 296 | } |
| 297 | } |
| 298 | |
| 299 | static void gui_button_cb_cancelReopencxx . . $ gui_button_cb_cancelReopen(55165f8e6beb845e). (EditorCommandcxx . . $ EditorCommand# cmd, GuiButtonEventcxx . . $ GuiButtonEvent# /* event */) { |
| 300 | TextEditorcxx . . $ TextEditor# me = (TextEditorcxx . . $ TextEditor#) cmd -> d_editorcxx . . $ structEditorCommand#d_editor.; |
| 301 | GuiThing_hidecxx . . $ GuiThing_hide(20e88c25f0ba841). (mycxx . . $ `melder/melder.h:44:9`! dirtyReopenDialogcxx . . $ structTextEditor#dirtyReopenDialog.); |
| 302 | } |
| 303 | |
| 304 | static void gui_button_cb_discardAndReopencxx . . $ gui_button_cb_discardAndReopen(55165f8e6beb845e). (EditorCommandcxx . . $ EditorCommand# cmd, GuiButtonEventcxx . . $ GuiButtonEvent# /* event */) { |
| 305 | TextEditorcxx . . $ TextEditor# me = (TextEditorcxx . . $ TextEditor#) cmd -> d_editorcxx . . $ structEditorCommand#d_editor.; |
| 306 | GuiThing_hidecxx . . $ GuiThing_hide(20e88c25f0ba841). (mycxx . . $ `melder/melder.h:44:9`! dirtyReopenDialogcxx . . $ structTextEditor#dirtyReopenDialog.); |
| 307 | openDocumentcxx . . $ openDocument(49f816b8be034823). (me, & mycxx . . $ `melder/melder.h:44:9`! filecxx . . $ structTextEditor#file.); |
| 308 | } |
| 309 | |
| 310 | static void menu_cb_reopencxx . . $ menu_cb_reopen(10954be9f18e7411). (TextEditorcxx . . $ TextEditor# me, EDITOR_ARGScxx . . $ `sys/EditorM.h:25:9`!) { |
| 311 | Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (mycxx . . $ `melder/melder.h:44:9`! v_fileBased()); |
| 312 | if (MelderFile_isNullcxx . . $ MelderFile_isNull(8f92cdf95b27d908). (& mycxx . . $ `melder/melder.h:44:9`! filecxx . . $ structTextEditor#file.)) |
| 313 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Cannot reopen from disk, because the text has never been saved yet."); |
| 314 | if (mycxx . . $ `melder/melder.h:44:9`! dirtycxx . . $ structTextEditor#dirty.) { |
| 315 | if (! mycxx . . $ `melder/melder.h:44:9`! dirtyReopenDialogcxx . . $ structTextEditor#dirtyReopenDialog.) { |
| 316 | int buttonWidth = 250, buttonSpacing = 20; |
| 317 | mycxx . . $ `melder/melder.h:44:9`! dirtyReopenDialogcxx . . $ structTextEditor#dirtyReopenDialog. = GuiDialog_createcxx . . $ GuiDialog_create(9df51e4563bc0c17). (mycxx . . $ `melder/melder.h:44:9`! windowFormcxx . . $ structEditor#windowForm., |
| 318 | 150, 70, Gui_LEFT_DIALOG_SPACINGcxx . . $ `sys/Gui.h:85:9`! + 2 * buttonWidth + 1 * buttonSpacing + Gui_RIGHT_DIALOG_SPACINGcxx . . $ `sys/Gui.h:86:9`!, |
| 319 | Gui_TOP_DIALOG_SPACINGcxx . . $ `sys/Gui.h:90:10`! + Gui_TEXTFIELD_HEIGHTcxx . . $ `sys/Gui.h:96:9`! + Gui_VERTICAL_DIALOG_SPACING_SAMEcxx . . $ `sys/Gui.h:94:9`! + 2 * Gui_BOTTOM_DIALOG_SPACINGcxx . . $ `sys/Gui.h:92:9`! + Gui_PUSHBUTTON_HEIGHTcxx . . $ `sys/Gui.h:103:9`!, |
| 320 | U"Text changed", nullptrcxx . . $ MelderCallback#MelderCallback(fc624d2cd197112)., nullptr, GuiDialog_Modalitycxx . . $ GuiDialog_Modality#::MODALcxx . . $ GuiDialog_Modality#MODAL. |
| 321 | ); |
| 322 | GuiLabel_createShowncxx . . $ GuiLabel_createShown(39026c9008a6a07). (mycxx . . $ `melder/melder.h:44:9`! dirtyReopenDialogcxx . . $ structTextEditor#dirtyReopenDialog., |
| 323 | Gui_LEFT_DIALOG_SPACINGcxx . . $ `sys/Gui.h:85:9`!, - Gui_RIGHT_DIALOG_SPACINGcxx . . $ `sys/Gui.h:86:9`!, |
| 324 | Gui_TOP_DIALOG_SPACINGcxx . . $ `sys/Gui.h:90:10`!, Gui_TOP_DIALOG_SPACINGcxx . . $ `sys/Gui.h:90:10`! + Gui_LABEL_HEIGHTcxx . . $ `sys/Gui.h:97:9`!, |
| 325 | U"The text in the editor contains changes! Reopen nevertheless?", 0 |
| 326 | ); |
| 327 | int x = Gui_LEFT_DIALOG_SPACINGcxx . . $ `sys/Gui.h:85:9`!, y = - Gui_BOTTOM_DIALOG_SPACINGcxx . . $ `sys/Gui.h:92:9`!; |
| 328 | GuiButton_createShowncxx . . $ GuiButton_createShown(653ed9987c16d9c1). (mycxx . . $ `melder/melder.h:44:9`! dirtyReopenDialogcxx . . $ structTextEditor#dirtyReopenDialog., |
| 329 | x, x + buttonWidth, y - Gui_PUSHBUTTON_HEIGHTcxx . . $ `sys/Gui.h:103:9`!, y, |
| 330 | U"Keep visible version", gui_button_cb_cancelReopencxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97)., cmd, GuiButton_CANCELcxx . . $ `sys/Gui.h:468:9`! |
| 331 | ); |
| 332 | x += buttonWidth + buttonSpacing; |
| 333 | GuiButton_createShowncxx . . $ GuiButton_createShown(653ed9987c16d9c1). (mycxx . . $ `melder/melder.h:44:9`! dirtyReopenDialogcxx . . $ structTextEditor#dirtyReopenDialog., |
| 334 | x, x + buttonWidth, y - Gui_PUSHBUTTON_HEIGHTcxx . . $ `sys/Gui.h:103:9`!, y, |
| 335 | U"Replace with version from disk", gui_button_cb_discardAndReopencxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97)., cmd, GuiButton_DEFAULTcxx . . $ `sys/Gui.h:467:9`! |
| 336 | ); |
| 337 | } |
| 338 | GuiThing_showcxx . . $ GuiThing_show(20e88c25f0ba841). (mycxx . . $ `melder/melder.h:44:9`! dirtyReopenDialogcxx . . $ structTextEditor#dirtyReopenDialog.); |
| 339 | } else { |
| 340 | try { |
| 341 | openDocumentcxx . . $ openDocument(49f816b8be034823). (me, & mycxx . . $ `melder/melder.h:44:9`! filecxx . . $ structTextEditor#file.); |
| 342 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 343 | Melder_flushErrorcxx . . $ Melder_flushError(49f6e7a06ebc5aa8). (); |
| 344 | return; |
| 345 | } |
| 346 | } |
| 347 | } |
| 348 | |
| 349 | static void menu_cb_clearcxx . . $ menu_cb_clear(10954be9f18e7411). (TextEditorcxx . . $ TextEditor# me, EDITOR_ARGScxx . . $ `sys/EditorM.h:25:9`!) { |
| 350 | mycxx . . $ `melder/melder.h:44:9`! v_clearcxx . . $ structTextEditor#v_clear(49f6e7a06ebc5aa8). (); |
| 351 | } |
| 352 | |
| 353 | static void menu_cb_savecxx . . $ menu_cb_save(10954be9f18e7411). (TextEditorcxx . . $ TextEditor# me, EDITOR_ARGScxx . . $ `sys/EditorM.h:25:9`!) { |
| 354 | if (MelderFile_isNullcxx . . $ MelderFile_isNull(8f92cdf95b27d908). (& mycxx . . $ `melder/melder.h:44:9`! filecxx . . $ structTextEditor#file.)) { |
| 355 | menu_cb_saveAscxx . . $ menu_cb_saveAs(10954be9f18e7411). (me, cmd, nullptr, 0, nullptr, nullptr, nullptr); |
| 356 | } else { |
| 357 | try { |
| 358 | saveDocumentcxx . . $ saveDocument(49f816b8be034823). (me, & mycxx . . $ `melder/melder.h:44:9`! filecxx . . $ structTextEditor#file.); |
| 359 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 360 | Melder_flushErrorcxx . . $ Melder_flushError(49f6e7a06ebc5aa8). (); |
| 361 | return; |
| 362 | } |
| 363 | } |
| 364 | } |
| 365 | |
| 366 | static void gui_button_cb_saveAndClosecxx . . $ gui_button_cb_saveAndClose(f4a790d9b7d3ada8). (TextEditorcxx . . $ TextEditor# me, GuiButtonEventcxx . . $ GuiButtonEvent# /* event */) { |
| 367 | GuiThing_hidecxx . . $ GuiThing_hide(20e88c25f0ba841). (mycxx . . $ `melder/melder.h:44:9`! dirtyCloseDialogcxx . . $ structTextEditor#dirtyCloseDialog.); |
| 368 | if (MelderFile_isNullcxx . . $ MelderFile_isNull(8f92cdf95b27d908). (& mycxx . . $ `melder/melder.h:44:9`! filecxx . . $ structTextEditor#file.)) { |
| 369 | menu_cb_saveAscxx . . $ menu_cb_saveAs(10954be9f18e7411). (me, Editor_getMenuCommandcxx . . $ Editor_getMenuCommand(6b867f4f43663f0). (me, U"File", U"Save as..."), nullptr, 0, nullptr, nullptr, nullptr); |
| 370 | } else { |
| 371 | try { |
| 372 | saveDocumentcxx . . $ saveDocument(49f816b8be034823). (me, & mycxx . . $ `melder/melder.h:44:9`! filecxx . . $ structTextEditor#file.); |
| 373 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 374 | Melder_flushErrorcxx . . $ Melder_flushError(49f6e7a06ebc5aa8). (); |
| 375 | return; |
| 376 | } |
| 377 | closeDocumentcxx . . $ closeDocument(22283699a15c80c8). (me); |
| 378 | } |
| 379 | } |
| 380 | |
| 381 | static void gui_button_cb_cancelClosecxx . . $ gui_button_cb_cancelClose(f4a790d9b7d3ada8). (TextEditorcxx . . $ TextEditor# me, GuiButtonEventcxx . . $ GuiButtonEvent# /* event */) { |
| 382 | GuiThing_hidecxx . . $ GuiThing_hide(20e88c25f0ba841). (mycxx . . $ `melder/melder.h:44:9`! dirtyCloseDialogcxx . . $ structTextEditor#dirtyCloseDialog.); |
| 383 | } |
| 384 | |
| 385 | static void gui_button_cb_discardAndClosecxx . . $ gui_button_cb_discardAndClose(f4a790d9b7d3ada8). (TextEditorcxx . . $ TextEditor# me, GuiButtonEventcxx . . $ GuiButtonEvent# /* event */) { |
| 386 | GuiThing_hidecxx . . $ GuiThing_hide(20e88c25f0ba841). (mycxx . . $ `melder/melder.h:44:9`! dirtyCloseDialogcxx . . $ structTextEditor#dirtyCloseDialog.); |
| 387 | closeDocumentcxx . . $ closeDocument(22283699a15c80c8). (me); |
| 388 | } |
| 389 | |
| 390 | void structTextEditorcxx . . $ structTextEditor# :: v_goAwaycxx . . $ structTextEditor#v_goAway(49f6e7a06ebc5aa8). () { |
| 391 | if (ourcxx . . $ `melder/melder.h:42:9`! v_fileBasedcxx . . $ structTextEditor#v_fileBased(50ce9a9e25b4a850). () && ourcxx . . $ `melder/melder.h:42:9`! dirtycxx . . $ structTextEditor#dirty.) { |
| 392 | if (! ourcxx . . $ `melder/melder.h:42:9`! dirtyCloseDialogcxx . . $ structTextEditor#dirtyCloseDialog.) { |
| 393 | int buttonWidth = 120, buttonSpacing = 20; |
| 394 | ourcxx . . $ `melder/melder.h:42:9`! dirtyCloseDialogcxx . . $ structTextEditor#dirtyCloseDialog. = GuiDialog_createcxx . . $ GuiDialog_create(9df51e4563bc0c17). (ourcxx . . $ `melder/melder.h:42:9`! windowFormcxx . . $ structEditor#windowForm., |
| 395 | 150, 70, Gui_LEFT_DIALOG_SPACINGcxx . . $ `sys/Gui.h:85:9`! + 3 * buttonWidth + 2 * buttonSpacing + Gui_RIGHT_DIALOG_SPACINGcxx . . $ `sys/Gui.h:86:9`!, |
| 396 | Gui_TOP_DIALOG_SPACINGcxx . . $ `sys/Gui.h:90:10`! + Gui_TEXTFIELD_HEIGHTcxx . . $ `sys/Gui.h:96:9`! + Gui_VERTICAL_DIALOG_SPACING_SAMEcxx . . $ `sys/Gui.h:94:9`! + 2 * Gui_BOTTOM_DIALOG_SPACINGcxx . . $ `sys/Gui.h:92:9`! + Gui_PUSHBUTTON_HEIGHTcxx . . $ `sys/Gui.h:103:9`!, |
| 397 | U"Text changed", nullptrcxx . . $ MelderCallback#MelderCallback(fc624d2cd197112)., nullptr, GuiDialog_Modalitycxx . . $ GuiDialog_Modality#::MODALcxx . . $ GuiDialog_Modality#MODAL. |
| 398 | ); |
| 399 | GuiLabel_createShowncxx . . $ GuiLabel_createShown(39026c9008a6a07). (ourcxx . . $ `melder/melder.h:42:9`! dirtyCloseDialogcxx . . $ structTextEditor#dirtyCloseDialog., |
| 400 | Gui_LEFT_DIALOG_SPACINGcxx . . $ `sys/Gui.h:85:9`!, - Gui_RIGHT_DIALOG_SPACINGcxx . . $ `sys/Gui.h:86:9`!, |
| 401 | Gui_TOP_DIALOG_SPACINGcxx . . $ `sys/Gui.h:90:10`!, Gui_TOP_DIALOG_SPACINGcxx . . $ `sys/Gui.h:90:10`! + Gui_LABEL_HEIGHTcxx . . $ `sys/Gui.h:97:9`!, |
| 402 | U"The text has changed! Save changes?", 0 |
| 403 | ); |
| 404 | int x = Gui_LEFT_DIALOG_SPACINGcxx . . $ `sys/Gui.h:85:9`!, y = - Gui_BOTTOM_DIALOG_SPACINGcxx . . $ `sys/Gui.h:92:9`!; |
| 405 | GuiButton_createShowncxx . . $ GuiButton_createShown(653ed9987c16d9c1). (ourcxx . . $ `melder/melder.h:42:9`! dirtyCloseDialogcxx . . $ structTextEditor#dirtyCloseDialog., |
| 406 | x, x + buttonWidth, y - Gui_PUSHBUTTON_HEIGHTcxx . . $ `sys/Gui.h:103:9`!, y, |
| 407 | U"Discard & Close", gui_button_cb_discardAndClosecxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97)., this, 0 |
| 408 | ); |
| 409 | x += buttonWidth + buttonSpacing; |
| 410 | GuiButton_createShowncxx . . $ GuiButton_createShown(653ed9987c16d9c1). (ourcxx . . $ `melder/melder.h:42:9`! dirtyCloseDialogcxx . . $ structTextEditor#dirtyCloseDialog., |
| 411 | x, x + buttonWidth, y - Gui_PUSHBUTTON_HEIGHTcxx . . $ `sys/Gui.h:103:9`!, y, |
| 412 | U"Cancel", gui_button_cb_cancelClosecxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97)., this, 0 |
| 413 | ); |
| 414 | x += buttonWidth + buttonSpacing; |
| 415 | GuiButton_createShowncxx . . $ GuiButton_createShown(653ed9987c16d9c1). (ourcxx . . $ `melder/melder.h:42:9`! dirtyCloseDialogcxx . . $ structTextEditor#dirtyCloseDialog., |
| 416 | x, x + buttonWidth, y - Gui_PUSHBUTTON_HEIGHTcxx . . $ `sys/Gui.h:103:9`!, y, |
| 417 | U"Save & Close", gui_button_cb_saveAndClosecxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97)., this, 0 |
| 418 | ); |
| 419 | } |
| 420 | if (ourcxx . . $ `melder/melder.h:42:9`! dirtyNewDialogcxx . . $ structTextEditor#dirtyNewDialog.) |
| 421 | GuiThing_hidecxx . . $ GuiThing_hide(20e88c25f0ba841). (ourcxx . . $ `melder/melder.h:42:9`! dirtyNewDialogcxx . . $ structTextEditor#dirtyNewDialog.); |
| 422 | if (ourcxx . . $ `melder/melder.h:42:9`! dirtyOpenDialogcxx . . $ structTextEditor#dirtyOpenDialog.) |
| 423 | GuiThing_hidecxx . . $ GuiThing_hide(20e88c25f0ba841). (ourcxx . . $ `melder/melder.h:42:9`! dirtyOpenDialogcxx . . $ structTextEditor#dirtyOpenDialog.); |
| 424 | if (ourcxx . . $ `melder/melder.h:42:9`! dirtyReopenDialogcxx . . $ structTextEditor#dirtyReopenDialog.) |
| 425 | GuiThing_hidecxx . . $ GuiThing_hide(20e88c25f0ba841). (ourcxx . . $ `melder/melder.h:42:9`! dirtyReopenDialogcxx . . $ structTextEditor#dirtyReopenDialog.); |
| 426 | GuiThing_showcxx . . $ GuiThing_show(20e88c25f0ba841). (ourcxx . . $ `melder/melder.h:42:9`! dirtyCloseDialogcxx . . $ structTextEditor#dirtyCloseDialog.); |
| 427 | } else { |
| 428 | closeDocumentcxx . . $ closeDocument(22283699a15c80c8). (this); |
| 429 | } |
| 430 | } |
| 431 | |
| 432 | #pragma mark - Edit menu |
| 433 | |
| 434 | static void menu_cb_undocxx . . $ menu_cb_undo(10954be9f18e7411). (TextEditorcxx . . $ TextEditor# me, EDITOR_ARGScxx . . $ `sys/EditorM.h:25:9`!) { |
| 435 | GuiText_undocxx . . $ GuiText_undo(9d8ddf5c89937cf2). (mycxx . . $ `melder/melder.h:44:9`! textWidgetcxx . . $ structTextEditor#textWidget.); |
| 436 | } |
| 437 | |
| 438 | static void menu_cb_redocxx . . $ menu_cb_redo(10954be9f18e7411). (TextEditorcxx . . $ TextEditor# me, EDITOR_ARGScxx . . $ `sys/EditorM.h:25:9`!) { |
| 439 | GuiText_redocxx . . $ GuiText_redo(9d8ddf5c89937cf2). (mycxx . . $ `melder/melder.h:44:9`! textWidgetcxx . . $ structTextEditor#textWidget.); |
| 440 | } |
| 441 | |
| 442 | static void menu_cb_cutcxx . . $ menu_cb_cut(10954be9f18e7411). (TextEditorcxx . . $ TextEditor# me, EDITOR_ARGScxx . . $ `sys/EditorM.h:25:9`!) { |
| 443 | GuiText_cutcxx . . $ GuiText_cut(9d8ddf5c89937cf2). (mycxx . . $ `melder/melder.h:44:9`! textWidgetcxx . . $ structTextEditor#textWidget.); // use ((XmAnyCallbackStruct *) call) -> event -> xbutton. time |
| 444 | } |
| 445 | |
| 446 | static void menu_cb_copycxx . . $ menu_cb_copy(10954be9f18e7411). (TextEditorcxx . . $ TextEditor# me, EDITOR_ARGScxx . . $ `sys/EditorM.h:25:9`!) { |
| 447 | GuiText_copycxx . . $ GuiText_copy(9d8ddf5c89937cf2). (mycxx . . $ `melder/melder.h:44:9`! textWidgetcxx . . $ structTextEditor#textWidget.); |
| 448 | } |
| 449 | |
| 450 | static void menu_cb_pastecxx . . $ menu_cb_paste(10954be9f18e7411). (TextEditorcxx . . $ TextEditor# me, EDITOR_ARGScxx . . $ `sys/EditorM.h:25:9`!) { |
| 451 | GuiText_pastecxx . . $ GuiText_paste(9d8ddf5c89937cf2). (mycxx . . $ `melder/melder.h:44:9`! textWidgetcxx . . $ structTextEditor#textWidget.); |
| 452 | } |
| 453 | |
| 454 | static void menu_cb_erasecxx . . $ menu_cb_erase(10954be9f18e7411). (TextEditorcxx . . $ TextEditor# me, EDITOR_ARGScxx . . $ `sys/EditorM.h:25:9`!) { |
| 455 | GuiText_removecxx . . $ GuiText_remove(9d8ddf5c89937cf2). (mycxx . . $ `melder/melder.h:44:9`! textWidgetcxx . . $ structTextEditor#textWidget.); |
| 456 | } |
| 457 | |
| 458 | static bool getSelectedLinescxx . . $ getSelectedLines(38798e5d50d832b0). (TextEditorcxx . . $ TextEditor# me, integercxx . . $ integer# *firstLine, integercxx . . $ integer# *lastLine) { |
| 459 | integercxx . . $ integer# left, right; |
| 460 | autostring32cxx . . $ autostring32# text = GuiText_getStringAndSelectionPositioncxx . . $ GuiText_getStringAndSelectionPosition(2d4f5aac9640119d). (mycxx . . $ `melder/melder.h:44:9`! textWidgetcxx . . $ structTextEditor#textWidget., & left, & right); |
| 461 | const integercxx . . $ integer# textLength = Melder_lengthcxx . . $ Melder_length(3fae411214b133ad). (text.getcxx . . $ _autostring#get(5a2a78a048fb49a8).()); |
| 462 | Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (left >= 0); |
| 463 | Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (left <= right); |
| 464 | if (right > textLength) |
| 465 | Melder_crashcxx . . $ `melder/melder_error.h:98:9`! (U"The end of the selection is at position ", right, |
| 466 | U", which is beyond the end of the text, which is at position ", textLength, U"."); |
| 467 | integercxx . . $ integer# i = 0; |
| 468 | *firstLine = 1; |
| 469 | /* |
| 470 | Cycle through the text in order to see how many linefeeds we pass. |
| 471 | */ |
| 472 | for (; i < left; i ++) |
| 473 | if (text [cxx . . $ _autostring#`operator[]`(b190d49faf30c5be).i] == U'\n') |
| 474 | (*firstLine) ++; |
| 475 | if (left == right) |
| 476 | return false; |
| 477 | *lastLine = *firstLine; |
| 478 | for (; i < right - 1; i ++) // a newline at the end of a line is ignored (it belongs to the previous line) |
| 479 | if (text [cxx . . $ _autostring#`operator[]`(b190d49faf30c5be).i] == U'\n') |
| 480 | (*lastLine) ++; |
| 481 | return true; |
| 482 | } |
| 483 | |
| 484 | static integercxx . . $ integer# getPositionToInsertTabBeforeSelectioncxx . . $ getPositionToInsertTabBeforeSelection(1135d938fb1a3a9a). (conststring32cxx . . $ conststring32# text, const integercxx . . $ integer# startingPosition) { |
| 485 | if (startingPosition == 0) |
| 486 | return 0; // we will insert a tab at the start of the text |
| 487 | for (integercxx . . $ integer# position = startingPosition - 1; position >= 0; position --) |
| 488 | if (text [position] == U'\n') |
| 489 | return position + 1; // we will insert a tab after the last newline |
| 490 | return 0; // we were on line 1 and will therefore insert a tab at the start of the text |
| 491 | } |
| 492 | static void menu_cb_shiftRightcxx . . $ menu_cb_shiftRight(10954be9f18e7411). (TextEditorcxx . . $ TextEditor# me, EDITOR_ARGScxx . . $ `sys/EditorM.h:25:9`!) { |
| 493 | /* |
| 494 | Get the old text from the GuiText. |
| 495 | */ |
| 496 | integercxx . . $ integer# leftPosition, rightPosition; // based between characters |
| 497 | autostring32cxx . . $ autostring32# oldText = GuiText_getStringAndSelectionPositioncxx . . $ GuiText_getStringAndSelectionPosition(2d4f5aac9640119d). (mycxx . . $ `melder/melder.h:44:9`! textWidgetcxx . . $ structTextEditor#textWidget., & leftPosition, & rightPosition); |
| 498 | |
| 499 | /* |
| 500 | Convert the old text to the new text. |
| 501 | */ |
| 502 | autoMelderStringcxx . . $ autoMelderString# newTextcxx . . $ autoMelderString#autoMelderString(49f6e7a06ebc5aa8).; |
| 503 | const integercxx . . $ integer# positionToInsertTabBeforeSelection = getPositionToInsertTabBeforeSelectioncxx . . $ getPositionToInsertTabBeforeSelection(1135d938fb1a3a9a). (oldText.getcxx . . $ _autostring#get(5a2a78a048fb49a8).(), leftPosition); |
| 504 | MelderString_ncopycxx . . $ MelderString_ncopy(b76236fd155635ca). (& newText, oldText.getcxx . . $ _autostring#get(5a2a78a048fb49a8).(), positionToInsertTabBeforeSelection); |
| 505 | MelderString_appendCharactercxx . . $ MelderString_appendCharacter(f4ab64866cffe712). (& newText, U'\t'); |
| 506 | MelderString_nappendcxx . . $ MelderString_nappend(b76236fd155635ca). (& newText, & oldText [cxx . . $ _autostring#`operator[]`(b190d49faf30c5be).positionToInsertTabBeforeSelection], |
| 507 | leftPosition - positionToInsertTabBeforeSelection); |
| 508 | for (integercxx . . $ integer# position = leftPosition; position < rightPosition; position ++) { |
| 509 | MelderString_appendCharactercxx . . $ MelderString_appendCharacter(f4ab64866cffe712). (& newText, oldText [cxx . . $ _autostring#`operator[]`(b190d49faf30c5be).position]); |
| 510 | if (position < rightPosition - 1 && oldText [cxx . . $ _autostring#`operator[]`(b190d49faf30c5be).position] == U'\n') // a newline at the end of the selection is ignored (it belongs to the previous line) |
| 511 | MelderString_appendCharactercxx . . $ MelderString_appendCharacter(f4ab64866cffe712). (& newText, U'\t'); |
| 512 | } |
| 513 | const integercxx . . $ integer# newEndOfSelection = newText.lengthcxx . . $ MelderString#length.; |
| 514 | MelderString_appendcxx . . $ MelderString_append(65be51a793e0ff96). (& newText, & oldText [cxx . . $ _autostring#`operator[]`(b190d49faf30c5be).rightPosition]); |
| 515 | |
| 516 | /* |
| 517 | Put the new text into the GuiText. |
| 518 | */ |
| 519 | GuiText_setStringcxx . . $ GuiText_setString(d44acbd60ea2b9be). (mycxx . . $ `melder/melder.h:44:9`! textWidgetcxx . . $ structTextEditor#textWidget., newText.stringcxx . . $ MelderString#string.); |
| 520 | GuiText_setSelectioncxx . . $ GuiText_setSelection(e06f404191ddd8ec). (mycxx . . $ `melder/melder.h:44:9`! textWidgetcxx . . $ structTextEditor#textWidget., leftPosition + 1, newEndOfSelection); |
| 521 | GuiText_scrollToSelectioncxx . . $ GuiText_scrollToSelection(9d8ddf5c89937cf2). (mycxx . . $ `melder/melder.h:44:9`! textWidgetcxx . . $ structTextEditor#textWidget.); |
| 522 | #ifdef _WIN32 |
| 523 | GuiThing_show (my windowForm); |
| 524 | #endif |
| 525 | } |
| 526 | |
| 527 | static integercxx . . $ integer# getPositionToDeleteTabBeforeSelectioncxx . . $ getPositionToDeleteTabBeforeSelection(1135d938fb1a3a9a). (conststring32cxx . . $ conststring32# text, const integercxx . . $ integer# startingPosition) { |
| 528 | if (startingPosition == 0) { |
| 529 | if (text [startingPosition] == U'\t') |
| 530 | return 0; // we can delete a tab from the start of the text |
| 531 | else |
| 532 | return -1; // we cannot delete a tab before the start of the text |
| 533 | } |
| 534 | for (integercxx . . $ integer# position = startingPosition - 1; position >= 0; position --) |
| 535 | if (text [position] == U'\n') { |
| 536 | if (text [position + 1] == U'\t') |
| 537 | return position + 1; // we will delete a tab after the last newline |
| 538 | else |
| 539 | return -1; // we will not look past the last newline |
| 540 | } |
| 541 | return text [0] == U'\t' ? 0 : -1; // we were on line 1 and may therefore delete a tab at the start of the text |
| 542 | } |
| 543 | static void menu_cb_shiftLeftcxx . . $ menu_cb_shiftLeft(10954be9f18e7411). (TextEditorcxx . . $ TextEditor# me, EDITOR_ARGScxx . . $ `sys/EditorM.h:25:9`!) { |
| 544 | /* |
| 545 | Get the old text from the GuiText. |
| 546 | */ |
| 547 | integercxx . . $ integer# leftPosition, rightPosition; // based between characters |
| 548 | autostring32cxx . . $ autostring32# oldText = GuiText_getStringAndSelectionPositioncxx . . $ GuiText_getStringAndSelectionPosition(2d4f5aac9640119d). (mycxx . . $ `melder/melder.h:44:9`! textWidgetcxx . . $ structTextEditor#textWidget., & leftPosition, & rightPosition); |
| 549 | |
| 550 | /* |
| 551 | Convert the old text to the new text. |
| 552 | First the part before the selection. |
| 553 | */ |
| 554 | autoMelderStringcxx . . $ autoMelderString# newTextcxx . . $ autoMelderString#autoMelderString(49f6e7a06ebc5aa8).; |
| 555 | const integercxx . . $ integer# positionToDeleteTabBeforeSelection = getPositionToDeleteTabBeforeSelectioncxx . . $ getPositionToDeleteTabBeforeSelection(1135d938fb1a3a9a). (oldText.getcxx . . $ _autostring#get(5a2a78a048fb49a8).(), leftPosition); |
| 556 | const bool haveToDeleteTabBeforeSelection = ( positionToDeleteTabBeforeSelection >= 0 ); |
| 557 | if (positionToDeleteTabBeforeSelection == leftPosition) { |
| 558 | MelderString_ncopycxx . . $ MelderString_ncopy(b76236fd155635ca). (& newText, oldText.getcxx . . $ _autostring#get(5a2a78a048fb49a8).(), positionToDeleteTabBeforeSelection); |
| 559 | // skip the tab |
| 560 | constexpr integercxx . . $ integer# numberOfDeletedTabsInThisPart = 0; |
| 561 | MelderString_nappendcxx . . $ MelderString_nappend(b76236fd155635ca). (& newText, & oldText [cxx . . $ _autostring#`operator[]`(b190d49faf30c5be).positionToDeleteTabBeforeSelection + numberOfDeletedTabsInThisPart], |
| 562 | leftPosition - (positionToDeleteTabBeforeSelection + numberOfDeletedTabsInThisPart)); |
| 563 | } else if (haveToDeleteTabBeforeSelection) { |
| 564 | MelderString_ncopycxx . . $ MelderString_ncopy(b76236fd155635ca). (& newText, oldText.getcxx . . $ _autostring#get(5a2a78a048fb49a8).(), positionToDeleteTabBeforeSelection); |
| 565 | // skip the tab |
| 566 | constexpr integercxx . . $ integer# numberOfDeletedTabsInThisPart = 1; |
| 567 | MelderString_nappendcxx . . $ MelderString_nappend(b76236fd155635ca). (& newText, & oldText [cxx . . $ _autostring#`operator[]`(b190d49faf30c5be).positionToDeleteTabBeforeSelection + numberOfDeletedTabsInThisPart], |
| 568 | leftPosition - (positionToDeleteTabBeforeSelection + numberOfDeletedTabsInThisPart)); |
| 569 | } else { |
| 570 | MelderString_ncopycxx . . $ MelderString_ncopy(b76236fd155635ca). (& newText, oldText.getcxx . . $ _autostring#get(5a2a78a048fb49a8).(), leftPosition); |
| 571 | } |
| 572 | /* |
| 573 | Then the part inside the selection. |
| 574 | */ |
| 575 | if (positionToDeleteTabBeforeSelection == leftPosition) { |
| 576 | constexpr integercxx . . $ integer# numberOfDeletedTabsInThisPart = 1; |
| 577 | for (integercxx . . $ integer# position = leftPosition + numberOfDeletedTabsInThisPart; position < rightPosition; position ++) |
| 578 | if (oldText [cxx . . $ _autostring#`operator[]`(b190d49faf30c5be).position] != U'\t' || position > leftPosition && oldText [cxx . . $ _autostring#`operator[]`(b190d49faf30c5be).position - 1] != U'\n') |
| 579 | MelderString_appendCharactercxx . . $ MelderString_appendCharacter(f4ab64866cffe712). (& newText, oldText [cxx . . $ _autostring#`operator[]`(b190d49faf30c5be).position]); |
| 580 | } else { |
| 581 | constexpr integercxx . . $ integer# numberOfDeletedTabsInThisPart = 0; |
| 582 | for (integercxx . . $ integer# position = leftPosition + numberOfDeletedTabsInThisPart; position < rightPosition; position ++) |
| 583 | if (oldText [cxx . . $ _autostring#`operator[]`(b190d49faf30c5be).position] != U'\t' || position > leftPosition && oldText [cxx . . $ _autostring#`operator[]`(b190d49faf30c5be).position - 1] != U'\n') |
| 584 | MelderString_appendCharactercxx . . $ MelderString_appendCharacter(f4ab64866cffe712). (& newText, oldText [cxx . . $ _autostring#`operator[]`(b190d49faf30c5be).position]); |
| 585 | } |
| 586 | /* |
| 587 | And finally the part after the selection. |
| 588 | */ |
| 589 | const integercxx . . $ integer# newEndOfSelection = newText.lengthcxx . . $ MelderString#length.; |
| 590 | if (positionToDeleteTabBeforeSelection == rightPosition) |
| 591 | MelderString_appendcxx . . $ MelderString_append(65be51a793e0ff96). (& newText, & oldText [cxx . . $ _autostring#`operator[]`(b190d49faf30c5be).rightPosition + 1]); |
| 592 | else |
| 593 | MelderString_appendcxx . . $ MelderString_append(65be51a793e0ff96). (& newText, & oldText [cxx . . $ _autostring#`operator[]`(b190d49faf30c5be).rightPosition]); |
| 594 | |
| 595 | /* |
| 596 | Put the new text into the GuiText. |
| 597 | */ |
| 598 | GuiText_setStringcxx . . $ GuiText_setString(d44acbd60ea2b9be). (mycxx . . $ `melder/melder.h:44:9`! textWidgetcxx . . $ structTextEditor#textWidget., newText.stringcxx . . $ MelderString#string.); |
| 599 | GuiText_setSelectioncxx . . $ GuiText_setSelection(e06f404191ddd8ec). (mycxx . . $ `melder/melder.h:44:9`! textWidgetcxx . . $ structTextEditor#textWidget., leftPosition - |
| 600 | ( haveToDeleteTabBeforeSelection && positionToDeleteTabBeforeSelection != leftPosition ? 1 : 0 ), newEndOfSelection); |
| 601 | GuiText_scrollToSelectioncxx . . $ GuiText_scrollToSelection(9d8ddf5c89937cf2). (mycxx . . $ `melder/melder.h:44:9`! textWidgetcxx . . $ structTextEditor#textWidget.); |
| 602 | #ifdef _WIN32 |
| 603 | GuiThing_show (my windowForm); |
| 604 | #endif |
| 605 | } |
| 606 | |
| 607 | #pragma mark - Search menu |
| 608 | |
| 609 | static autostring32cxx . . $ autostring32# theFindStringcxx . . $ theFindString., theReplaceStringcxx . . $ theReplaceString.; |
| 610 | static void do_findcxx . . $ do_find(22283699a15c80c8). (TextEditorcxx . . $ TextEditor# me) { |
| 611 | if (! theFindStringcxx . . $ theFindString.) // e.g. when the user does "Find again" before having done any "Find" |
| 612 | return; |
| 613 | integercxx . . $ integer# left, right; |
| 614 | autostring32cxx . . $ autostring32# text = GuiText_getStringAndSelectionPositioncxx . . $ GuiText_getStringAndSelectionPosition(2d4f5aac9640119d). (mycxx . . $ `melder/melder.h:44:9`! textWidgetcxx . . $ structTextEditor#textWidget., & left, & right); |
| 615 | char32cxx . . $ char32# *location = str32strcxx . . $ str32str(2de17cd8f7c584a6). (& text [cxx . . $ _autostring#`operator[]`(b190d49faf30c5be).right], theFindStringcxx . . $ theFindString..getcxx . . $ _autostring#get(5a2a78a048fb49a8).()); |
| 616 | if (location) { |
| 617 | const integercxx . . $ integer# index = location - text.getcxx . . $ _autostring#get(5a2a78a048fb49a8).(); |
| 618 | GuiText_setSelectioncxx . . $ GuiText_setSelection(e06f404191ddd8ec). (mycxx . . $ `melder/melder.h:44:9`! textWidgetcxx . . $ structTextEditor#textWidget., index, index + Melder_lengthcxx . . $ Melder_length(3fae411214b133ad). (theFindStringcxx . . $ theFindString..getcxx . . $ _autostring#get(5a2a78a048fb49a8).())); |
| 619 | GuiText_scrollToSelectioncxx . . $ GuiText_scrollToSelection(9d8ddf5c89937cf2). (mycxx . . $ `melder/melder.h:44:9`! textWidgetcxx . . $ structTextEditor#textWidget.); |
| 620 | #ifdef _WIN32 |
| 621 | GuiThing_show (my windowForm); |
| 622 | #endif |
| 623 | } else { |
| 624 | /* |
| 625 | Try from the start of the document. |
| 626 | */ |
| 627 | location = str32strcxx . . $ str32str(2de17cd8f7c584a6). (text.getcxx . . $ _autostring#get(5a2a78a048fb49a8).(), theFindStringcxx . . $ theFindString..getcxx . . $ _autostring#get(5a2a78a048fb49a8).()); |
| 628 | if (location) { |
| 629 | const integercxx . . $ integer# index = location - text.getcxx . . $ _autostring#get(5a2a78a048fb49a8).(); |
| 630 | GuiText_setSelectioncxx . . $ GuiText_setSelection(e06f404191ddd8ec). (mycxx . . $ `melder/melder.h:44:9`! textWidgetcxx . . $ structTextEditor#textWidget., index, index + Melder_lengthcxx . . $ Melder_length(3fae411214b133ad). (theFindStringcxx . . $ theFindString..getcxx . . $ _autostring#get(5a2a78a048fb49a8).())); |
| 631 | GuiText_scrollToSelectioncxx . . $ GuiText_scrollToSelection(9d8ddf5c89937cf2). (mycxx . . $ `melder/melder.h:44:9`! textWidgetcxx . . $ structTextEditor#textWidget.); |
| 632 | #ifdef _WIN32 |
| 633 | GuiThing_show (my windowForm); |
| 634 | #endif |
| 635 | } else { |
| 636 | Melder_beepcxx . . $ Melder_beep(49f6e7a06ebc5aa8). (); |
| 637 | } |
| 638 | } |
| 639 | } |
| 640 | |
| 641 | static void do_replacecxx . . $ do_replace(22283699a15c80c8). (TextEditorcxx . . $ TextEditor# me) { |
| 642 | if (! theReplaceStringcxx . . $ theReplaceString.) // e.g. when the user does "Replace again" before having done any "Replace" |
| 643 | return; |
| 644 | autostring32cxx . . $ autostring32# selection = GuiText_getSelectioncxx . . $ GuiText_getSelection(9a61f82c13ba8ebc). (mycxx . . $ `melder/melder.h:44:9`! textWidgetcxx . . $ structTextEditor#textWidget.); |
| 645 | if (! Melder_equcxx . . $ `melder/melder_str32.h:124:9`! (selection.getcxx . . $ _autostring#get(5a2a78a048fb49a8).(), theFindStringcxx . . $ theFindString..getcxx . . $ _autostring#get(5a2a78a048fb49a8).())) { |
| 646 | do_findcxx . . $ do_find(22283699a15c80c8). (me); |
| 647 | return; |
| 648 | } |
| 649 | integercxx . . $ integer# left, right; |
| 650 | autostring32cxx . . $ autostring32# text = GuiText_getStringAndSelectionPositioncxx . . $ GuiText_getStringAndSelectionPosition(2d4f5aac9640119d). (mycxx . . $ `melder/melder.h:44:9`! textWidgetcxx . . $ structTextEditor#textWidget., & left, & right); |
| 651 | GuiText_replacecxx . . $ GuiText_replace(27ef96c8abc2c4e2). (mycxx . . $ `melder/melder.h:44:9`! textWidgetcxx . . $ structTextEditor#textWidget., left, right, theReplaceStringcxx . . $ theReplaceString..getcxx . . $ _autostring#get(5a2a78a048fb49a8).()); |
| 652 | GuiText_setSelectioncxx . . $ GuiText_setSelection(e06f404191ddd8ec). (mycxx . . $ `melder/melder.h:44:9`! textWidgetcxx . . $ structTextEditor#textWidget., left, left + Melder_lengthcxx . . $ Melder_length(3fae411214b133ad). (theReplaceStringcxx . . $ theReplaceString..getcxx . . $ _autostring#get(5a2a78a048fb49a8).())); |
| 653 | GuiText_scrollToSelectioncxx . . $ GuiText_scrollToSelection(9d8ddf5c89937cf2). (mycxx . . $ `melder/melder.h:44:9`! textWidgetcxx . . $ structTextEditor#textWidget.); |
| 654 | #ifdef _WIN32 |
| 655 | GuiThing_show (my windowForm); |
| 656 | #endif |
| 657 | } |
| 658 | |
| 659 | static void menu_cb_findcxx . . $ menu_cb_find(10954be9f18e7411). (TextEditorcxx . . $ TextEditor# me, EDITOR_ARGScxx . . $ `sys/EditorM.h:25:9`!) { |
| 660 | EDITOR_FORMcxx . . $ `sys/EditorM.h:33:9`! (U"Find", nullptr) |
| 661 | TEXTFIELDcxx . . $ `sys/EditorM.h:273:9`! (findString, U"Find", U"", 5) |
| 662 | EDITOR_OKcxx . . $ `sys/EditorM.h:38:9`! |
| 663 | if (theFindStringcxx . . $ theFindString.) SET_STRINGcxx . . $ `sys/EditorM.h:477:9`! (findString, theFindString.get()); |
| 664 | EDITOR_DOcxx . . $ `sys/EditorM.h:43:9`! |
| 665 | theFindStringcxx . . $ theFindString. =cxx . . $ _autostring#`operator=`(f562943cbc4bcf37). Melder_dupcxx . . $ Melder_dup(87bf156b1f548402). (findString); |
| 666 | #ifdef macintosh |
| 667 | /* |
| 668 | Perhaps don't use the system-wide Find pasteboard, |
| 669 | by which other applications can see what you are searching for in Praat's text windows. |
| 670 | Remember ever showing your app in Xcode to somebody, |
| 671 | revealing to your onlooker the name of the person you last looked up in your email? |
| 672 | */ |
| 673 | // NSPasteboard * theFindPasteBoard = [NSPasteboard pasteboardWithName: NSPasteboardNameFind create: NO]; |
| 674 | // [theFindPasteBoard ...] |
| 675 | #endif |
| 676 | do_findcxx . . $ do_find(22283699a15c80c8). (me); |
| 677 | EDITOR_ENDcxx . . $ `sys/EditorM.h:80:9`! |
| 678 | } |
| 679 | |
| 680 | static void menu_cb_findAgaincxx . . $ menu_cb_findAgain(10954be9f18e7411). (TextEditorcxx . . $ TextEditor# me, EDITOR_ARGScxx . . $ `sys/EditorM.h:25:9`!) { |
| 681 | do_findcxx . . $ do_find(22283699a15c80c8). (me); |
| 682 | } |
| 683 | |
| 684 | static void menu_cb_useSelectionForFindcxx . . $ menu_cb_useSelectionForFind(10954be9f18e7411). (TextEditorcxx . . $ TextEditor# me, EDITOR_ARGScxx . . $ `sys/EditorM.h:25:9`!) { |
| 685 | theFindStringcxx . . $ theFindString. =cxx . . $ _autostring#`operator=`(f562943cbc4bcf37). GuiText_getSelectioncxx . . $ GuiText_getSelection(9a61f82c13ba8ebc). (mycxx . . $ `melder/melder.h:44:9`! textWidgetcxx . . $ structTextEditor#textWidget.); |
| 686 | } |
| 687 | |
| 688 | static void menu_cb_replacecxx . . $ menu_cb_replace(10954be9f18e7411). (TextEditorcxx . . $ TextEditor# me, EDITOR_ARGScxx . . $ `sys/EditorM.h:25:9`!) { |
| 689 | EDITOR_FORMcxx . . $ `sys/EditorM.h:33:9`! (U"Find", nullptr) |
| 690 | COMMENTcxx . . $ `sys/EditorM.h:237:9`! (U"This is a \"slow\" find-and-replace method;") |
| 691 | COMMENTcxx . . $ `sys/EditorM.h:237:9`! (U"if the selected text is identical to the Find string,") |
| 692 | COMMENTcxx . . $ `sys/EditorM.h:237:9`! (U"the selected text will be replaced by the Replace string;") |
| 693 | COMMENTcxx . . $ `sys/EditorM.h:237:9`! (U"otherwise, the next occurrence of the Find string will be selected.") |
| 694 | COMMENTcxx . . $ `sys/EditorM.h:237:9`! (U"So you typically need two clicks on Apply to get a text replaced.") |
| 695 | TEXTFIELDcxx . . $ `sys/EditorM.h:273:9`! (findString, U"Find", U"", 5) |
| 696 | TEXTFIELDcxx . . $ `sys/EditorM.h:273:9`! (replaceString, U"Replace with", U"", 5) |
| 697 | EDITOR_OKcxx . . $ `sys/EditorM.h:38:9`! |
| 698 | if (theFindStringcxx . . $ theFindString.) |
| 699 | SET_STRINGcxx . . $ `sys/EditorM.h:477:9`! (findString, theFindString.get()); |
| 700 | if (theReplaceStringcxx . . $ theReplaceString.) |
| 701 | SET_STRINGcxx . . $ `sys/EditorM.h:477:9`! (replaceString, theReplaceString.get()); |
| 702 | EDITOR_DOcxx . . $ `sys/EditorM.h:43:9`! |
| 703 | theFindStringcxx . . $ theFindString. =cxx . . $ _autostring#`operator=`(f562943cbc4bcf37). Melder_dupcxx . . $ Melder_dup(87bf156b1f548402). (findString); |
| 704 | theReplaceStringcxx . . $ theReplaceString. =cxx . . $ _autostring#`operator=`(f562943cbc4bcf37). Melder_dupcxx . . $ Melder_dup(87bf156b1f548402). (replaceString); |
| 705 | do_replacecxx . . $ do_replace(22283699a15c80c8). (me); |
| 706 | EDITOR_ENDcxx . . $ `sys/EditorM.h:80:9`! |
| 707 | } |
| 708 | |
| 709 | static void menu_cb_replaceAgaincxx . . $ menu_cb_replaceAgain(10954be9f18e7411). (TextEditorcxx . . $ TextEditor# me, EDITOR_ARGScxx . . $ `sys/EditorM.h:25:9`!) { |
| 710 | do_replacecxx . . $ do_replace(22283699a15c80c8). (me); |
| 711 | } |
| 712 | |
| 713 | static void menu_cb_whereAmIcxx . . $ menu_cb_whereAmI(10954be9f18e7411). (TextEditorcxx . . $ TextEditor# me, EDITOR_ARGScxx . . $ `sys/EditorM.h:25:9`!) { |
| 714 | integercxx . . $ integer# numberOfLinesLeft, numberOfLinesRight; |
| 715 | if (! getSelectedLinescxx . . $ getSelectedLines(38798e5d50d832b0). (me, & numberOfLinesLeft, & numberOfLinesRight)) { |
| 716 | Melder_informationcxx . . $ Melder_information(3eb398314feba58b). (U"The cursor is on line ", numberOfLinesLeft, U"."); |
| 717 | } else if (numberOfLinesLeft == numberOfLinesRight) { |
| 718 | Melder_informationcxx . . $ Melder_information(3eb398314feba58b). (U"The selection is on line ", numberOfLinesLeft, U"."); |
| 719 | } else { |
| 720 | Melder_informationcxx . . $ Melder_information(3eb398314feba58b). (U"The selection runs from line ", numberOfLinesLeft, U" to line ", numberOfLinesRight, U"."); |
| 721 | } |
| 722 | } |
| 723 | |
| 724 | static void menu_cb_goToLinecxx . . $ menu_cb_goToLine(10954be9f18e7411). (TextEditorcxx . . $ TextEditor# me, EDITOR_ARGScxx . . $ `sys/EditorM.h:25:9`!) { |
| 725 | EDITOR_FORMcxx . . $ `sys/EditorM.h:33:9`! (U"Go to line", nullptr) |
| 726 | NATURALcxx . . $ `sys/EditorM.h:173:9`! (lineToGo, U"Line", U"1") |
| 727 | EDITOR_OKcxx . . $ `sys/EditorM.h:38:9`! |
| 728 | integercxx . . $ integer# firstLine, lastLine; |
| 729 | getSelectedLinescxx . . $ getSelectedLines(38798e5d50d832b0). (me, & firstLine, & lastLine); |
| 730 | SET_INTEGERcxx . . $ `sys/EditorM.h:465:9`! (lineToGo, firstLine) |
| 731 | EDITOR_DOcxx . . $ `sys/EditorM.h:43:9`! |
| 732 | autostring32cxx . . $ autostring32# text = GuiText_getStringcxx . . $ GuiText_getString(9a61f82c13ba8ebc). (mycxx . . $ `melder/melder.h:44:9`! textWidgetcxx . . $ structTextEditor#textWidget.); |
| 733 | integercxx . . $ integer# currentLine = 1; |
| 734 | integercxx . . $ integer# left = 0, right = 0; |
| 735 | if (lineToGo == 1) { |
| 736 | for (; text [cxx . . $ _autostring#`operator[]`(b190d49faf30c5be).right] != U'\n' && text [cxx . . $ _autostring#`operator[]`(b190d49faf30c5be).right] != U'\0'; right ++) { } |
| 737 | } else { |
| 738 | for (; text [cxx . . $ _autostring#`operator[]`(b190d49faf30c5be).left] != U'\0'; left ++) { |
| 739 | if (text [cxx . . $ _autostring#`operator[]`(b190d49faf30c5be).left] == U'\n') { |
| 740 | currentLine ++; |
| 741 | if (currentLine == lineToGo) { |
| 742 | left ++; |
| 743 | for (right = left; text [cxx . . $ _autostring#`operator[]`(b190d49faf30c5be).right] != U'\n' && text [cxx . . $ _autostring#`operator[]`(b190d49faf30c5be).right] != U'\0'; right ++) { } |
| 744 | break; |
| 745 | } |
| 746 | } |
| 747 | } |
| 748 | } |
| 749 | if (left == Melder_lengthcxx . . $ Melder_length(3fae411214b133ad). (text.getcxx . . $ _autostring#get(5a2a78a048fb49a8).())) |
| 750 | right = left; |
| 751 | else if (text [cxx . . $ _autostring#`operator[]`(b190d49faf30c5be).right] == U'\n') |
| 752 | right ++; |
| 753 | GuiText_setSelectioncxx . . $ GuiText_setSelection(e06f404191ddd8ec). (mycxx . . $ `melder/melder.h:44:9`! textWidgetcxx . . $ structTextEditor#textWidget., left, right); |
| 754 | GuiText_scrollToSelectioncxx . . $ GuiText_scrollToSelection(9d8ddf5c89937cf2). (mycxx . . $ `melder/melder.h:44:9`! textWidgetcxx . . $ structTextEditor#textWidget.); |
| 755 | EDITOR_ENDcxx . . $ `sys/EditorM.h:80:9`! |
| 756 | } |
| 757 | |
| 758 | #pragma mark - Convert menu |
| 759 | |
| 760 | static void menu_cb_convertToCStringcxx . . $ menu_cb_convertToCString(10954be9f18e7411). (TextEditorcxx . . $ TextEditor# me, EDITOR_ARGScxx . . $ `sys/EditorM.h:25:9`!) { |
| 761 | autostring32cxx . . $ autostring32# text = GuiText_getStringcxx . . $ GuiText_getString(9a61f82c13ba8ebc). (mycxx . . $ `melder/melder.h:44:9`! textWidgetcxx . . $ structTextEditor#textWidget.); |
| 762 | char32cxx . . $ char32# buffer [2] = U" "; |
| 763 | const conststring32cxx . . $ conststring32# hex [16] = { U"0", U"1", U"2", U"3", U"4", U"5", U"6", U"7", U"8", U"9", U"A", U"B", U"C", U"D", U"E", U"F" }; |
| 764 | MelderInfo_opencxx . . $ MelderInfo_open(49f6e7a06ebc5aa8). (); |
| 765 | MelderInfo_writecxx . . $ MelderInfo_write(3eb398314feba58b). (U"\""); |
| 766 | for (char32cxx . . $ char32# *p = & text [cxx . . $ _autostring#`operator[]`(b190d49faf30c5be).0]; *p != U'\0'; p ++) { |
| 767 | char32cxx . . $ char32# kar = *p; |
| 768 | if (kar == U'\n') { |
| 769 | MelderInfo_writecxx . . $ MelderInfo_write(3eb398314feba58b). (U"\\n\"\n\""); |
| 770 | } else if (kar == U'\t') { |
| 771 | MelderInfo_writecxx . . $ MelderInfo_write(3eb398314feba58b). (U" "); |
| 772 | } else if (kar == U'\"') { |
| 773 | MelderInfo_writecxx . . $ MelderInfo_write(3eb398314feba58b). (U"\\\""); |
| 774 | } else if (kar == U'\\') { |
| 775 | MelderInfo_writecxx . . $ MelderInfo_write(3eb398314feba58b). (U"\\\\"); |
| 776 | } else if (kar > 127) { |
| 777 | if (kar <= 0x00FFFF) |
| 778 | MelderInfo_writecxx . . $ MelderInfo_write(3eb398314feba58b). (U"\\u", hex [kar >> 12], hex [(kar >> 8) & 0x00'000F], hex [(kar >> 4) & 0x00'000F], hex [kar & 0x00'000F]); |
| 779 | else |
| 780 | MelderInfo_writecxx . . $ MelderInfo_write(3eb398314feba58b). (U"\\U", |
| 781 | hex [kar >> 28], hex [(kar >> 24) & 0x00'000F], |
| 782 | hex [(kar >> 20) & 0x00'000F], hex [(kar >> 16) & 0x00'000F], |
| 783 | hex [(kar >> 12) & 0x00'000F], hex [(kar >> 8) & 0x00'000F], |
| 784 | hex [(kar >> 4) & 0x00'000F], hex [kar & 0x00'000F] |
| 785 | ); |
| 786 | } else { |
| 787 | buffer [0] = *p; |
| 788 | MelderInfo_writecxx . . $ MelderInfo_write(3eb398314feba58b). (& buffer [0]); |
| 789 | } |
| 790 | } |
| 791 | MelderInfo_writecxx . . $ MelderInfo_write(3eb398314feba58b). (U"\""); |
| 792 | MelderInfo_closecxx . . $ MelderInfo_close(49f6e7a06ebc5aa8). (); |
| 793 | } |
| 794 | |
| 795 | #pragma mark - Font menu |
| 796 | |
| 797 | static void updateSizeMenucxx . . $ updateSizeMenu(22283699a15c80c8). (TextEditorcxx . . $ TextEditor# me) { |
| 798 | if (mycxx . . $ `melder/melder.h:44:9`! fontSizeButton_10cxx . . $ structTextEditor#fontSizeButton_10.) |
| 799 | GuiMenuItem_checkcxx . . $ GuiMenuItem_check(9c76b7451f460a69). (mycxx . . $ `melder/melder.h:44:9`! fontSizeButton_10cxx . . $ structTextEditor#fontSizeButton_10., mycxx . . $ `melder/melder.h:44:9`! instancePref_fontSizecxx . . $ structTextEditor#instancePref_fontSize(21b6c25e127938e2).() == 10.0); |
| 800 | if (mycxx . . $ `melder/melder.h:44:9`! fontSizeButton_12cxx . . $ structTextEditor#fontSizeButton_12.) |
| 801 | GuiMenuItem_checkcxx . . $ GuiMenuItem_check(9c76b7451f460a69). (mycxx . . $ `melder/melder.h:44:9`! fontSizeButton_12cxx . . $ structTextEditor#fontSizeButton_12., mycxx . . $ `melder/melder.h:44:9`! instancePref_fontSizecxx . . $ structTextEditor#instancePref_fontSize(21b6c25e127938e2).() == 12.0); |
| 802 | if (mycxx . . $ `melder/melder.h:44:9`! fontSizeButton_14cxx . . $ structTextEditor#fontSizeButton_14.) |
| 803 | GuiMenuItem_checkcxx . . $ GuiMenuItem_check(9c76b7451f460a69). (mycxx . . $ `melder/melder.h:44:9`! fontSizeButton_14cxx . . $ structTextEditor#fontSizeButton_14., mycxx . . $ `melder/melder.h:44:9`! instancePref_fontSizecxx . . $ structTextEditor#instancePref_fontSize(21b6c25e127938e2).() == 14.0); |
| 804 | if (mycxx . . $ `melder/melder.h:44:9`! fontSizeButton_18cxx . . $ structTextEditor#fontSizeButton_18.) |
| 805 | GuiMenuItem_checkcxx . . $ GuiMenuItem_check(9c76b7451f460a69). (mycxx . . $ `melder/melder.h:44:9`! fontSizeButton_18cxx . . $ structTextEditor#fontSizeButton_18., mycxx . . $ `melder/melder.h:44:9`! instancePref_fontSizecxx . . $ structTextEditor#instancePref_fontSize(21b6c25e127938e2).() == 18.0); |
| 806 | if (mycxx . . $ `melder/melder.h:44:9`! fontSizeButton_24cxx . . $ structTextEditor#fontSizeButton_24.) |
| 807 | GuiMenuItem_checkcxx . . $ GuiMenuItem_check(9c76b7451f460a69). (mycxx . . $ `melder/melder.h:44:9`! fontSizeButton_24cxx . . $ structTextEditor#fontSizeButton_24., mycxx . . $ `melder/melder.h:44:9`! instancePref_fontSizecxx . . $ structTextEditor#instancePref_fontSize(21b6c25e127938e2).() == 24.0); |
| 808 | } |
| 809 | static void setFontSizecxx . . $ setFontSize(935b16da88229807). (TextEditorcxx . . $ TextEditor# me, double fontSize) { |
| 810 | GuiText_setFontSizecxx . . $ GuiText_setFontSize(c15d57e615da0df1). (mycxx . . $ `melder/melder.h:44:9`! textWidgetcxx . . $ structTextEditor#textWidget., fontSize); |
| 811 | mycxx . . $ `melder/melder.h:44:9`! setInstancePref_fontSizecxx . . $ structTextEditor#setInstancePref_fontSize(ba8836b59fb42830). (fontSize); |
| 812 | updateSizeMenucxx . . $ updateSizeMenu(22283699a15c80c8). (me); |
| 813 | } |
| 814 | |
| 815 | static void menu_cb_10cxx . . $ menu_cb_10(10954be9f18e7411). (TextEditorcxx . . $ TextEditor# me, EDITOR_ARGScxx . . $ `sys/EditorM.h:25:9`!) { setFontSizecxx . . $ setFontSize(935b16da88229807). (me, 10.0); } |
| 816 | static void menu_cb_12cxx . . $ menu_cb_12(10954be9f18e7411). (TextEditorcxx . . $ TextEditor# me, EDITOR_ARGScxx . . $ `sys/EditorM.h:25:9`!) { setFontSizecxx . . $ setFontSize(935b16da88229807). (me, 12.0); } |
| 817 | static void menu_cb_14cxx . . $ menu_cb_14(10954be9f18e7411). (TextEditorcxx . . $ TextEditor# me, EDITOR_ARGScxx . . $ `sys/EditorM.h:25:9`!) { setFontSizecxx . . $ setFontSize(935b16da88229807). (me, 14.0); } |
| 818 | static void menu_cb_18cxx . . $ menu_cb_18(10954be9f18e7411). (TextEditorcxx . . $ TextEditor# me, EDITOR_ARGScxx . . $ `sys/EditorM.h:25:9`!) { setFontSizecxx . . $ setFontSize(935b16da88229807). (me, 18.0); } |
| 819 | static void menu_cb_24cxx . . $ menu_cb_24(10954be9f18e7411). (TextEditorcxx . . $ TextEditor# me, EDITOR_ARGScxx . . $ `sys/EditorM.h:25:9`!) { setFontSizecxx . . $ setFontSize(935b16da88229807). (me, 24.0); } |
| 820 | static void menu_cb_fontSizecxx . . $ menu_cb_fontSize(10954be9f18e7411). (TextEditorcxx . . $ TextEditor# me, EDITOR_ARGScxx . . $ `sys/EditorM.h:25:9`!) { |
| 821 | EDITOR_FORMcxx . . $ `sys/EditorM.h:33:9`! (U"Text window: Font size", nullptr) |
| 822 | POSITIVEcxx . . $ `sys/EditorM.h:117:9`! (fontSize, U"Font size (points)", U"12") |
| 823 | EDITOR_OKcxx . . $ `sys/EditorM.h:38:9`! |
| 824 | SET_REALcxx . . $ `sys/EditorM.h:462:9`! (fontSize, mycxx . . $ `melder/melder.h:44:9`! instancePref_fontSize()); |
| 825 | EDITOR_DOcxx . . $ `sys/EditorM.h:43:9`! |
| 826 | setFontSizecxx . . $ setFontSize(935b16da88229807). (me, fontSize); |
| 827 | EDITOR_ENDcxx . . $ `sys/EditorM.h:80:9`! |
| 828 | } |
| 829 | |
| 830 | static void gui_text_cb_changedcxx . . $ gui_text_cb_changed(83cbe1eef6e4a758). (TextEditorcxx . . $ TextEditor# me, GuiTextEventcxx . . $ GuiTextEvent# /* event */) { |
| 831 | if (! mycxx . . $ `melder/melder.h:44:9`! dirtycxx . . $ structTextEditor#dirty.) { |
| 832 | mycxx . . $ `melder/melder.h:44:9`! dirtycxx . . $ structTextEditor#dirty. = true; |
| 833 | mycxx . . $ `melder/melder.h:44:9`! v_nameChangedcxx . . $ structTextEditor#v_nameChanged(49f6e7a06ebc5aa8). (); |
| 834 | } |
| 835 | } |
| 836 | |
| 837 | void structTextEditorcxx . . $ structTextEditor# :: v_createChildrencxx . . $ structTextEditor#v_createChildren(49f6e7a06ebc5aa8). () { |
| 838 | textWidgetcxx . . $ structTextEditor#textWidget. = GuiText_createShowncxx . . $ GuiText_createShown(8bcb1f2be7fc31ee). (ourcxx . . $ `melder/melder.h:42:9`! windowFormcxx . . $ structEditor#windowForm., 0, 0, Machine_getMenuBarBottomcxx . . $ Machine_getMenuBarBottom(b126dc7c1de90089). (), 0, GuiText_SCROLLEDcxx . . $ `sys/Gui.h:1123:9`!); |
| 839 | GuiText_setChangedCallbackcxx . . $ GuiText_setChangedCallback(1197bbfc2caa0b9d). (textWidgetcxx . . $ structTextEditor#textWidget., gui_text_cb_changedcxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97)., this); |
| 840 | } |
| 841 | |
| 842 | void structTextEditorcxx . . $ structTextEditor# :: v_createMenuscxx . . $ structTextEditor#v_createMenus(49f6e7a06ebc5aa8). () { |
| 843 | TextEditor_Parentcxx . . $ TextEditor_Parent# :: v_createMenuscxx . . $ structEditor#v_createMenus(49f6e7a06ebc5aa8). (); |
| 844 | |
| 845 | if (v_fileBasedcxx . . $ structTextEditor#v_fileBased(50ce9a9e25b4a850). ()) { |
| 846 | Editor_addCommandcxx . . $ Editor_addCommand(d7f2c642863274c0). (this, U"File", U"New", 'N', menu_cb_newcxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97).); |
| 847 | Editor_addCommandcxx . . $ Editor_addCommand(d7f2c642863274c0). (this, U"File", U"Open...", 'O', menu_cb_opencxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97).); |
| 848 | Editor_addCommandcxx . . $ Editor_addCommand(d7f2c642863274c0). (this, U"File", U"Reopen from disk", GuiMenu_COMMAND_EXTRAcxx . . $ `sys/Gui.h:816:10`! | 'O', menu_cb_reopencxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97).); |
| 849 | } else { |
| 850 | Editor_addCommandcxx . . $ Editor_addCommand(d7f2c642863274c0). (this, U"File", U"Clear", 'N', menu_cb_clearcxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97).); |
| 851 | } |
| 852 | Editor_addCommandcxx . . $ Editor_addCommand(d7f2c642863274c0). (this, U"File", U"-- save --", 0, nullptrcxx . . $ MelderCallback#MelderCallback(fc624d2cd197112).); |
| 853 | if (v_fileBasedcxx . . $ structTextEditor#v_fileBased(50ce9a9e25b4a850). ()) { |
| 854 | Editor_addCommandcxx . . $ Editor_addCommand(d7f2c642863274c0). (this, U"File", U"Save", 'S', menu_cb_savecxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97).); |
| 855 | Editor_addCommandcxx . . $ Editor_addCommand(d7f2c642863274c0). (this, U"File", U"Save as...", 0, menu_cb_saveAscxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97).); |
| 856 | } else { |
| 857 | Editor_addCommandcxx . . $ Editor_addCommand(d7f2c642863274c0). (this, U"File", U"Save as...", 'S', menu_cb_saveAscxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97).); |
| 858 | } |
| 859 | Editor_addCommandcxx . . $ Editor_addCommand(d7f2c642863274c0). (this, U"File", U"-- close --", 0, nullptrcxx . . $ MelderCallback#MelderCallback(fc624d2cd197112).); |
| 860 | GuiText_setUndoItemcxx . . $ GuiText_setUndoItem(fe305b70bc020e42). (textWidgetcxx . . $ structTextEditor#textWidget., Editor_addCommandcxx . . $ Editor_addCommand(d7f2c642863274c0). (this, U"Edit", U"Undo", 'Z', menu_cb_undocxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97).)); |
| 861 | GuiText_setRedoItemcxx . . $ GuiText_setRedoItem(fe305b70bc020e42). (textWidgetcxx . . $ structTextEditor#textWidget., Editor_addCommandcxx . . $ Editor_addCommand(d7f2c642863274c0). (this, U"Edit", U"Redo", 'Y', menu_cb_redocxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97).)); |
| 862 | Editor_addCommandcxx . . $ Editor_addCommand(d7f2c642863274c0). (this, U"Edit", U"-- cut copy paste --", 0, nullptrcxx . . $ MelderCallback#MelderCallback(fc624d2cd197112).); |
| 863 | Editor_addCommandcxx . . $ Editor_addCommand(d7f2c642863274c0). (this, U"Edit", U"Cut", 'X', menu_cb_cutcxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97).); |
| 864 | Editor_addCommandcxx . . $ Editor_addCommand(d7f2c642863274c0). (this, U"Edit", U"Copy", 'C', menu_cb_copycxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97).); |
| 865 | Editor_addCommandcxx . . $ Editor_addCommand(d7f2c642863274c0). (this, U"Edit", U"Paste", 'V', menu_cb_pastecxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97).); |
| 866 | Editor_addCommandcxx . . $ Editor_addCommand(d7f2c642863274c0). (this, U"Edit", U"Erase", 0, menu_cb_erasecxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97).); |
| 867 | Editor_addCommandcxx . . $ Editor_addCommand(d7f2c642863274c0). (this, U"Edit", U"-- layout --", 0, nullptrcxx . . $ MelderCallback#MelderCallback(fc624d2cd197112).); |
| 868 | Editor_addCommandcxx . . $ Editor_addCommand(d7f2c642863274c0). (this, U"Edit", U"Shift right", ']', menu_cb_shiftRightcxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97).); |
| 869 | Editor_addCommandcxx . . $ Editor_addCommand(d7f2c642863274c0). (this, U"Edit", U"Shift left", '[', menu_cb_shiftLeftcxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97).); |
| 870 | |
| 871 | Editor_addMenucxx . . $ Editor_addMenu(8b39ac34ca8e016f). (this, U"Search", 0); |
| 872 | Editor_addCommandcxx . . $ Editor_addCommand(d7f2c642863274c0). (this, U"Search", U"Find...", 'F', menu_cb_findcxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97).); |
| 873 | Editor_addCommandcxx . . $ Editor_addCommand(d7f2c642863274c0). (this, U"Search", U"Find again", 'G', menu_cb_findAgaincxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97).); |
| 874 | Editor_addCommandcxx . . $ Editor_addCommand(d7f2c642863274c0). (this, U"Search", U"Replace...", GuiMenu_COMMAND_EXTRAcxx . . $ `sys/Gui.h:816:10`! | 'F', menu_cb_replacecxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97).); |
| 875 | Editor_addCommandcxx . . $ Editor_addCommand(d7f2c642863274c0). (this, U"Search", U"Replace again", GuiMenu_COMMAND_EXTRAcxx . . $ `sys/Gui.h:816:10`! | 'G', menu_cb_replaceAgaincxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97).); |
| 876 | Editor_addCommandcxx . . $ Editor_addCommand(d7f2c642863274c0). (this, U"Search", U"Use selection for find", 'E', menu_cb_useSelectionForFindcxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97).); |
| 877 | Editor_addCommandcxx . . $ Editor_addCommand(d7f2c642863274c0). (this, U"Search", U"-- line --", 0, nullptrcxx . . $ MelderCallback#MelderCallback(fc624d2cd197112).); |
| 878 | Editor_addCommandcxx . . $ Editor_addCommand(d7f2c642863274c0). (this, U"Search", U"Where am I?", 0, menu_cb_whereAmIcxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97).); |
| 879 | Editor_addCommandcxx . . $ Editor_addCommand(d7f2c642863274c0). (this, U"Search", U"Go to line...", 'L', menu_cb_goToLinecxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97).); |
| 880 | |
| 881 | Editor_addMenucxx . . $ Editor_addMenu(8b39ac34ca8e016f). (this, U"Convert", 0); |
| 882 | Editor_addCommandcxx . . $ Editor_addCommand(d7f2c642863274c0). (this, U"Convert", U"Convert to C string", 0, menu_cb_convertToCStringcxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97).); |
| 883 | |
| 884 | Editor_addMenucxx . . $ Editor_addMenu(8b39ac34ca8e016f). (this, U"Font", 0); |
| 885 | Editor_addCommandcxx . . $ Editor_addCommand(d7f2c642863274c0). (this, U"Font", U"Font size...", 0, menu_cb_fontSizecxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97).); |
| 886 | fontSizeButton_10cxx . . $ structTextEditor#fontSizeButton_10. = Editor_addCommandcxx . . $ Editor_addCommand(d7f2c642863274c0). (this, U"Font", U"10", GuiMenu_CHECKBUTTONcxx . . $ `sys/Gui.h:853:9`!, menu_cb_10cxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97).); |
| 887 | fontSizeButton_12cxx . . $ structTextEditor#fontSizeButton_12. = Editor_addCommandcxx . . $ Editor_addCommand(d7f2c642863274c0). (this, U"Font", U"12", GuiMenu_CHECKBUTTONcxx . . $ `sys/Gui.h:853:9`!, menu_cb_12cxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97).); |
| 888 | fontSizeButton_14cxx . . $ structTextEditor#fontSizeButton_14. = Editor_addCommandcxx . . $ Editor_addCommand(d7f2c642863274c0). (this, U"Font", U"14", GuiMenu_CHECKBUTTONcxx . . $ `sys/Gui.h:853:9`!, menu_cb_14cxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97).); |
| 889 | fontSizeButton_18cxx . . $ structTextEditor#fontSizeButton_18. = Editor_addCommandcxx . . $ Editor_addCommand(d7f2c642863274c0). (this, U"Font", U"18", GuiMenu_CHECKBUTTONcxx . . $ `sys/Gui.h:853:9`!, menu_cb_18cxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97).); |
| 890 | fontSizeButton_24cxx . . $ structTextEditor#fontSizeButton_24. = Editor_addCommandcxx . . $ Editor_addCommand(d7f2c642863274c0). (this, U"Font", U"24", GuiMenu_CHECKBUTTONcxx . . $ `sys/Gui.h:853:9`!, menu_cb_24cxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97).); |
| 891 | } |
| 892 | |
| 893 | void TextEditor_initcxx . . $ TextEditor_init(9ba39b4797eb5880). (TextEditorcxx . . $ TextEditor# me, conststring32cxx . . $ conststring32# initialText) { |
| 894 | /* |
| 895 | The width of a text window should be at least one tab plus 84 single-width characters, |
| 896 | if the font size is 12. |
| 897 | */ |
| 898 | constexpr double characterWidth = |
| 899 | #if defined (macintosh) |
| 900 | 0.625 * 12; // TODO: make a bit bigger |
| 901 | #elif defined (_WIN32) |
| 902 | 0.689 * 12; |
| 903 | #else |
| 904 | 0.584 * 12; // TODO: make much bigger (e.g. as size 14 is now, as in what Terminal calls size 12) |
| 905 | #endif |
| 906 | constexpr double tabWidth = |
| 907 | #if defined (_WIN32) |
| 908 | 8.0 * characterWidth; |
| 909 | #elif defined (macintosh) |
| 910 | 4.0 * characterWidth; |
| 911 | #else |
| 912 | 4.0 * characterWidth; |
| 913 | #endif |
| 914 | constexpr double numberOfFittingCharacters = 84.0; |
| 915 | constexpr double overlapWithNextCharacter = |
| 916 | #ifdef macintosh |
| 917 | 0.5 * characterWidth - 1; |
| 918 | #else |
| 919 | 0.5 * characterWidth; |
| 920 | #endif |
| 921 | constexpr int width = int (tabWidth + numberOfFittingCharacters * characterWidth + overlapWithNextCharacter); |
| 922 | Editor_initcxx . . $ Editor_init(13f379e38ac41ed6). (me, 0, 0, width, 400, U"", nullptr); |
| 923 | setFontSizecxx . . $ setFontSize(935b16da88229807). (me, mycxx . . $ `melder/melder.h:44:9`! instancePref_fontSizecxx . . $ structTextEditor#instancePref_fontSize(21b6c25e127938e2).()); |
| 924 | if (initialText) { |
| 925 | GuiText_setStringcxx . . $ GuiText_setString(d44acbd60ea2b9be). (mycxx . . $ `melder/melder.h:44:9`! textWidgetcxx . . $ structTextEditor#textWidget., initialText); |
| 926 | mycxx . . $ `melder/melder.h:44:9`! dirtycxx . . $ structTextEditor#dirty. = false; // was set to true in valueChanged callback |
| 927 | if (mycxx . . $ `melder/melder.h:44:9`! v_fileBasedcxx . . $ structTextEditor#v_fileBased(50ce9a9e25b4a850). ()) |
| 928 | Thing_setNamecxx . . $ Thing_setName(b5a42e5e01c267b5). (me, nullptr); |
| 929 | } |
| 930 | theReferencesToAllOpenTextEditorscxx . . $ theReferencesToAllOpenTextEditors.. addItem_refcxx . . $ CollectionOf#addItem_ref(ebd0a1552f8ce24f). (me); |
| 931 | } |
| 932 | |
| 933 | autoTextEditorcxx . . $ autoTextEditor# TextEditor_createcxx . . $ TextEditor_create(7d6280c58e2fee76). (conststring32cxx . . $ conststring32# initialText) { |
| 934 | try { |
| 935 | autoTextEditorcxx . . $ autoTextEditor# me = Thing_newcxx . . $ `sys/Thing.h:514:9`! (TextEditor); |
| 936 | TextEditor_initcxx . . $ TextEditor_init(9ba39b4797eb5880). (me.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), initialText); |
| 937 | return mecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 938 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 939 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Text window not created."); |
| 940 | } |
| 941 | } |
| 942 | |
| 943 | #pragma mark - Export |
| 944 | |
| 945 | void TextEditor_showOpencxx . . $ TextEditor_showOpen(22283699a15c80c8). (TextEditorcxx . . $ TextEditor# me) { |
| 946 | cb_showOpencxx . . $ cb_showOpen(2b98fae8e13abb61). (Editor_getMenuCommandcxx . . $ Editor_getMenuCommand(6b867f4f43663f0). (me, U"File", U"Open...")); |
| 947 | } |
| 948 | |
| 949 | /* End of file TextEditor.cpp */ |