| 1 |
/* praat_objectMenus.cpp |
| 2 |
* |
| 3 |
* Copyright (C) 1992-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 "praatP.h" |
| 20 |
#include "praatM.h" |
| 21 |
#include "praat_script.h" |
| 22 |
#include "ScriptEditor.h" |
| 23 |
#include "NotebookEditor.h" |
| 24 |
#include "ButtonEditor.h" |
| 25 |
#include "DataEditor.h" |
| 26 |
#include "site.h" |
| 27 |
#include "GraphicsP.h" |
| 28 |
#include "DemoEditor.h" |
| 29 |
|
| 30 |
#define EDITOR theCurrentPraatObjects -> list [IOBJECT]. editors |
| 31 |
|
| 32 |
/********** Callbacks of the fixed buttons. **********/ |
| 33 |
|
| 34 |
DIRECT (PRAAT_Remove) { |
| 35 |
WHERE_DOWN (SELECTED) |
| 36 |
praat_removeObject (IOBJECT); |
| 37 |
praat_show (); |
| 38 |
END_NO_NEW_DATA |
| 39 |
} |
| 40 |
|
| 41 |
FORM (MODIFY_Rename, U"Rename object", U"Rename...") { |
| 42 |
TEXTFIELD (newName, U"New name", U"", 3) |
| 43 |
OK |
| 44 |
WHERE (SELECTED) |
| 45 |
SET_STRING (newName, NAME) |
| 46 |
DO |
| 47 |
if (theCurrentPraatObjects -> totalSelection == 0) |
| 48 |
Melder_throw (U"Selection changed!\nNo object selected. Cannot rename."); |
| 49 |
if (theCurrentPraatObjects -> totalSelection > 1) |
| 50 |
Melder_throw (U"Selection changed!\nCannot rename more than one object at a time."); |
| 51 |
WHERE (SELECTED) |
| 52 |
break; |
| 53 |
static MelderString string; |
| 54 |
MelderString_copy (& string, newName); |
| 55 |
praat_cleanUpName (string.string); |
| 56 |
static MelderString fullName; |
| 57 |
MelderString_copy (& fullName, Thing_className (OBJECT), U" ", string.string); |
| 58 |
if (! str32equ (fullName.string, FULL_NAME)) { |
| 59 |
theCurrentPraatObjects -> list [IOBJECT]. name = Melder_dup_f (fullName.string); |
| 60 |
autoMelderString listName; |
| 61 |
MelderString_append (& listName, ID, U". ", fullName.string); |
| 62 |
praat_list_renameAndSelect (IOBJECT, listName.string); |
| 63 |
for (int ieditor = 0; ieditor < praat_MAXNUM_EDITORS; ieditor ++) |
| 64 |
if (EDITOR [ieditor]) |
| 65 |
Thing_setName (EDITOR [ieditor], listName.string); |
| 66 |
Thing_setName (OBJECT, string.string); |
| 67 |
} |
| 68 |
END_NO_NEW_DATA |
| 69 |
} |
| 70 |
|
| 71 |
FORM (NEW1_Copy, U"Copy object", U"Copy...") { |
| 72 |
TEXTFIELD (newName, U"Name of new object", U"", 3) |
| 73 |
OK |
| 74 |
WHERE (SELECTED) |
| 75 |
SET_STRING (newName, NAME) |
| 76 |
DO |
| 77 |
if (theCurrentPraatObjects -> totalSelection == 0) |
| 78 |
Melder_throw (U"Selection changed!\nNo object selected. Cannot copy."); |
| 79 |
if (theCurrentPraatObjects -> totalSelection > 1) |
| 80 |
Melder_throw (U"Selection changed!\nCannot copy more than one object at a time."); |
| 81 |
if (interpreter) |
| 82 |
interpreter -> returnType = kInterpreter_ReturnType::OBJECT_; |
| 83 |
WHERE (SELECTED) |
| 84 |
praat_new (Data_copy ((Daata) OBJECT), newName); |
| 85 |
END_WITH_NEW_DATA |
| 86 |
} |
| 87 |
|
| 88 |
DIRECT (INFO_Info) { |
| 89 |
INFO_NONE |
| 90 |
if (theCurrentPraatObjects -> totalSelection == 0) |
| 91 |
Melder_throw (U"Selection changed!\nNo object selected. Cannot query."); |
| 92 |
if (theCurrentPraatObjects -> totalSelection > 1) |
| 93 |
Melder_throw (U"Selection changed!\nCannot query more than one object at a time."); |
| 94 |
WHERE (SELECTED) Thing_infoWithIdAndFile (OBJECT, ID, & theCurrentPraatObjects -> list [IOBJECT]. file); |
| 95 |
INFO_NONE_END |
| 96 |
} |
| 97 |
|
| 98 |
DIRECT (PRAAT__Inspect) { |
| 99 |
PRAAT |
| 100 |
if (theCurrentPraatObjects -> totalSelection == 0) |
| 101 |
Melder_throw (U"Selection changed!\nNo object selected. Cannot inspect."); |
| 102 |
if (theCurrentPraatApplication -> batch) { |
| 103 |
Melder_throw (U"Cannot inspect data from batch."); |
| 104 |
} else { |
| 105 |
WHERE (SELECTED) { |
| 106 |
autoDataEditor editor = DataEditor_create (ID_AND_FULL_NAME, OBJECT); |
| 107 |
praat_installEditor (editor.get(), IOBJECT); |
| 108 |
editor.releaseToUser(); |
| 109 |
} |
| 110 |
} |
| 111 |
PRAAT_END |
| 112 |
} |
| 113 |
|
| 114 |
/********** The fixed menus. **********/ |
| 115 |
|
| 116 |
static GuiMenu praatMenu, editMenu, windowMenu, newMenu, readMenu, goodiesMenu, preferencesMenu, technicalMenu, applicationHelpMenu, helpMenu; |
| 117 |
|
| 118 |
GuiMenu praat_objects_resolveMenu (conststring32 menu) { |
| 119 |
return |
| 120 |
str32equ (menu, U"Praat") || str32equ (menu, U"Control") ? praatMenu : |
| 121 |
#if cocoa |
| 122 |
str32equ (menu, U"Edit") ? editMenu : |
| 123 |
str32equ (menu, U"Window") ? windowMenu : |
| 124 |
#endif |
| 125 |
str32equ (menu, U"New") || str32equ (menu, U"Create") ? newMenu : |
| 126 |
str32equ (menu, U"Open") || str32equ (menu, U"Read") ? readMenu : |
| 127 |
str32equ (menu, U"Help") ? helpMenu : |
| 128 |
str32equ (menu, U"Goodies") ? goodiesMenu : |
| 129 |
str32equ (menu, U"Settings") || str32equ (menu, U"Preferences") ? preferencesMenu : |
| 130 |
str32equ (menu, U"Technical") ? technicalMenu : |
| 131 |
#ifdef macintosh |
| 132 |
str32equ (menu, U"ApplicationHelp") ? applicationHelpMenu : |
| 133 |
#else |
| 134 |
str32equ (menu, U"ApplicationHelp") ? helpMenu : |
| 135 |
#endif |
| 136 |
newMenu; // default |
| 137 |
} |
| 138 |
|
| 139 |
/********** Callbacks of the Praat menu. **********/ |
| 140 |
|
| 141 |
DIRECT (PRAAT__About) { |
| 142 |
PRAAT |
| 143 |
praat_showLogo (); |
| 144 |
PRAAT_END |
| 145 |
} |
| 146 |
|
| 147 |
DIRECT (PRAAT__newScript) { |
| 148 |
PRAAT |
| 149 |
autoScriptEditor scriptEditor = ScriptEditor_createFromText (nullptr, nullptr); |
| 150 |
scriptEditor.releaseToUser(); |
| 151 |
PRAAT_END |
| 152 |
} |
| 153 |
|
| 154 |
DIRECT (PRAAT__newNotebook) { |
| 155 |
PRAAT |
| 156 |
autoNotebookEditor notebookEditor = NotebookEditor_createFromText (nullptr); |
| 157 |
notebookEditor.releaseToUser(); |
| 158 |
PRAAT_END |
| 159 |
} |
| 160 |
|
| 161 |
DIRECT (PRAAT__openScript) { |
| 162 |
PRAAT |
| 163 |
autoScriptEditor scriptEditor = ScriptEditor_createFromText (nullptr, nullptr); |
| 164 |
TextEditor_showOpen (scriptEditor.get()); |
| 165 |
scriptEditor.releaseToUser(); |
| 166 |
PRAAT_END |
| 167 |
} |
| 168 |
|
| 169 |
DIRECT (PRAAT__openNotebook) { |
| 170 |
PRAAT |
| 171 |
autoNotebookEditor notebookEditor = NotebookEditor_createFromText (nullptr); |
| 172 |
TextEditor_showOpen (notebookEditor.get()); |
| 173 |
notebookEditor.releaseToUser(); |
| 174 |
PRAAT_END |
| 175 |
} |
| 176 |
|
| 177 |
static ButtonEditor theReferenceToTheOnlyButtonEditor; |
| 178 |
|
| 179 |
static void cb_ButtonEditor_destruction (Editor /* editor */) { |
| 180 |
theReferenceToTheOnlyButtonEditor = nullptr; |
| 181 |
} |
| 182 |
|
| 183 |
DIRECT (PRAAT__editButtons) { |
| 184 |
PRAAT |
| 185 |
if (theReferenceToTheOnlyButtonEditor) { |
| 186 |
Editor_raise (theReferenceToTheOnlyButtonEditor); |
| 187 |
} else { |
| 188 |
autoButtonEditor editor = ButtonEditor_create (); |
| 189 |
Editor_setDestructionCallback (editor.get(), cb_ButtonEditor_destruction); |
| 190 |
theReferenceToTheOnlyButtonEditor = editor.get(); |
| 191 |
editor.releaseToUser(); |
| 192 |
} |
| 193 |
PRAAT_END |
| 194 |
} |
| 195 |
|
| 196 |
FORM (PRAAT__addMenuCommand, U"Add menu command", U"Add menu command...") { |
| 197 |
WORD (window, U"Window", U"Objects") |
| 198 |
WORD (menu, U"Menu", U"New") |
| 199 |
SENTENCE (command, U"Command", U"Hallo...") |
| 200 |
SENTENCE (afterCommand, U"After command", U"") |
| 201 |
INTEGER (depth, U"Depth", U"0") |
| 202 |
INFILE (script, U"Script file", U"/u/miep/hallo.praat") |
| 203 |
OK |
| 204 |
DO |
| 205 |
PRAAT |
| 206 |
praat_addMenuCommandScript (window, menu, command, afterCommand, depth, script); |
| 207 |
PRAAT_END |
| 208 |
} |
| 209 |
|
| 210 |
FORM (PRAAT__hideMenuCommand, U"Hide menu command", U"Hide menu command...") { |
| 211 |
WORD (window, U"Window", U"Objects") |
| 212 |
WORD (menu, U"Menu", U"New") |
| 213 |
SENTENCE (command, U"Command", U"Hallo...") |
| 214 |
OK |
| 215 |
DO |
| 216 |
PRAAT |
| 217 |
praat_hideMenuCommand (window, menu, command); |
| 218 |
PRAAT_END |
| 219 |
} |
| 220 |
|
| 221 |
FORM (PRAAT__showMenuCommand, U"Show menu command", U"Show menu command...") { |
| 222 |
WORD (window, U"Window", U"Objects") |
| 223 |
WORD (menu, U"Menu", U"New") |
| 224 |
SENTENCE (command, U"Command", U"Hallo...") |
| 225 |
OK |
| 226 |
DO |
| 227 |
PRAAT |
| 228 |
praat_showMenuCommand (window, menu, command); |
| 229 |
PRAAT_END |
| 230 |
} |
| 231 |
|
| 232 |
FORM (PRAAT__addAction, U"Add action command", U"Add action command...") { |
| 233 |
WORD (class1, U"Class 1", U"Sound") |
| 234 |
INTEGER (number1, U"Number 1", U"0") |
| 235 |
WORD (class2, U"Class 2", U"") |
| 236 |
INTEGER (number2, U"Number 2", U"0") |
| 237 |
WORD (class3, U"Class 3", U"") |
| 238 |
INTEGER (number3, U"Number 3", U"0") |
| 239 |
SENTENCE (command, U"Command", U"Play reverse") |
| 240 |
SENTENCE (afterCommand, U"After command", U"Play") |
| 241 |
INTEGER (depth, U"Depth", U"0") |
| 242 |
INFILE (script, U"Script file", U"/u/miep/playReverse.praat") |
| 243 |
OK |
| 244 |
DO |
| 245 |
PRAAT |
| 246 |
praat_addActionScript (class1, number1, class2, number2, class3, number3, command, afterCommand, depth, script); |
| 247 |
PRAAT_END |
| 248 |
} |
| 249 |
|
| 250 |
FORM (PRAAT__hideAction, U"Hide action command", U"Hide action command...") { |
| 251 |
WORD (class1, U"Class 1", U"Sound") |
| 252 |
WORD (class2, U"Class 2", U"") |
| 253 |
WORD (class3, U"Class 3", U"") |
| 254 |
SENTENCE (command, U"Command", U"Play") |
| 255 |
OK |
| 256 |
DO |
| 257 |
PRAAT |
| 258 |
praat_hideAction_classNames (class1, class2, class3, command); |
| 259 |
PRAAT_END |
| 260 |
} |
| 261 |
|
| 262 |
FORM (PRAAT__showAction, U"Show action command", U"Show action command...") { |
| 263 |
WORD (class1, U"Class 1", U"Sound") |
| 264 |
WORD (class2, U"Class 2", U"") |
| 265 |
WORD (class3, U"Class 3", U"") |
| 266 |
SENTENCE (command, U"Command", U"Play") |
| 267 |
OK |
| 268 |
DO |
| 269 |
PRAAT |
| 270 |
praat_showAction_classNames (class1, class2, class3, command); |
| 271 |
PRAAT_END |
| 272 |
} |
| 273 |
|
| 274 |
/********** Callbacks of the Settings menu. **********/ |
| 275 |
|
| 276 |
FORM (SETTINGS__TextReadingSettings, U"Text reading settings", U"Unicode") { |
| 277 |
CHOICE_ENUM (kMelder_textInputEncoding, encodingOf8BitTextFiles, |
| 278 |
U"Encoding of 8-bit text files", kMelder_textInputEncoding::DEFAULT) |
| 279 |
OK |
| 280 |
SET_ENUM (encodingOf8BitTextFiles, kMelder_textInputEncoding, Melder_getInputEncoding ()) |
| 281 |
DO |
| 282 |
PREFS |
| 283 |
Melder_setInputEncoding (encodingOf8BitTextFiles); |
| 284 |
PREFS_END |
| 285 |
} |
| 286 |
|
| 287 |
FORM (SETTINGS__TextWritingSettings, U"Text writing settings", U"Unicode") { |
| 288 |
CHOICE_ENUM (kMelder_textOutputEncoding, outputEncoding, |
| 289 |
U"Output encoding", kMelder_textOutputEncoding::DEFAULT) |
| 290 |
OK |
| 291 |
SET_ENUM (outputEncoding, kMelder_textOutputEncoding, Melder_getOutputEncoding ()) |
| 292 |
DO |
| 293 |
PREFS |
| 294 |
Melder_setOutputEncoding (outputEncoding); |
| 295 |
PREFS_END |
| 296 |
} |
| 297 |
|
| 298 |
FORM (SETTINGS__CjkFontStyleSettings, U"CJK font style settings", nullptr) { |
| 299 |
OPTIONMENU_ENUM (kGraphics_cjkFontStyle, cjkFontStyle, |
| 300 |
U"CJK font style", kGraphics_cjkFontStyle::DEFAULT) |
| 301 |
OK |
| 302 |
SET_ENUM (cjkFontStyle, kGraphics_cjkFontStyle, theGraphicsCjkFontStyle) |
| 303 |
DO |
| 304 |
PREFS |
| 305 |
theGraphicsCjkFontStyle = cjkFontStyle; |
| 306 |
PREFS_END |
| 307 |
} |
| 308 |
|
| 309 |
/********** Callbacks of the Goodies menu. **********/ |
| 310 |
|
| 311 |
FORM (INFO_NONE__praat_calculator, U"Calculator", U"Calculator") { |
| 312 |
TEXTFIELD (expression, U"Type any numeric formula or string formula", U"5*5", 5) |
| 313 |
COMMENT (U"Note that you can include many special functions in your formula,") |
| 314 |
COMMENT (U"including statistical functions and acoustics-auditory conversions.") |
| 315 |
COMMENT (U"For details, click Help.") |
| 316 |
OK |
| 317 |
DO |
| 318 |
INFO_NONE |
| 319 |
Formula_Result result; |
| 320 |
//TRACE |
| 321 |
if (! interpreter) { |
| 322 |
trace (U"no interpreter"); |
| 323 |
static autoInterpreterStack theCalculatorInterpreterStack; |
| 324 |
if (! theCalculatorInterpreterStack) { |
| 325 |
theCalculatorInterpreterStack = InterpreterStack_create (Editor (nullptr)); // object-window command, so no editor |
| 326 |
theCalculatorInterpreterStack -> interpreters [1] = Interpreter_createFromEnvironment ( // TODO: too exposed |
| 327 |
theCalculatorInterpreterStack.get(), |
| 328 |
Editor (nullptr), |
| 329 |
MelderFile (nullptr) |
| 330 |
); |
| 331 |
} |
| 332 |
Melder_assert (theCalculatorInterpreterStack -> interpreters [1]); // TODO: should fire after exception |
| 333 |
Melder_assert (theCalculatorInterpreterStack -> interpreters [1] -> owningInterpreterStack); |
| 334 |
Interpreter_anyExpression (theCalculatorInterpreterStack -> interpreters [1].get(), expression, & result); |
| 335 |
} else { |
| 336 |
trace (U"yes interpreter"); |
| 337 |
Interpreter_anyExpression (interpreter, expression, & result); |
| 338 |
} |
| 339 |
switch (result. expressionType) { |
| 340 |
case kFormula_EXPRESSION_TYPE_NUMERIC: |
| 341 |
Melder_information (result. numericResult); |
| 342 |
break; case kFormula_EXPRESSION_TYPE_STRING: |
| 343 |
Melder_information (result. stringResult.get()); |
| 344 |
break; case kFormula_EXPRESSION_TYPE_NUMERIC_VECTOR: |
| 345 |
Melder_information (constVECVU (result. numericVectorResult)); |
| 346 |
break; case kFormula_EXPRESSION_TYPE_NUMERIC_MATRIX: |
| 347 |
Melder_information (constMATVU (result. numericMatrixResult)); |
| 348 |
break; case kFormula_EXPRESSION_TYPE_STRING_ARRAY: |
| 349 |
Melder_information (result. stringArrayResult); |
| 350 |
} |
| 351 |
INFO_NONE_END |
| 352 |
} |
| 353 |
|
| 354 |
FORM (INFO_reportDifferenceOfTwoProportions, U"Report difference of two proportions", U"Difference of two proportions") { |
| 355 |
INTEGER (a_int, U"left Row 1", U"71") |
| 356 |
INTEGER (b_int, U"right Row 1", U"39") |
| 357 |
INTEGER (c_int, U"left Row 2", U"93") |
| 358 |
INTEGER (d_int, U"right Row 2", U"27") |
| 359 |
OK |
| 360 |
DO |
| 361 |
INFO_NONE |
| 362 |
double a = a_int, b = b_int, c = c_int, d = d_int; |
| 363 |
double n = a + b + c + d; |
| 364 |
if (a < 0 || b < 0 || c < 0 || d < 0) |
| 365 |
Melder_throw (U"The numbers should not be negative."); |
| 366 |
if (a + b <= 0 || c + d <= 0) |
| 367 |
Melder_throw (U"The row totals should be positive."); |
| 368 |
if (a + c <= 0 || b + d <= 0) |
| 369 |
Melder_throw (U"The column totals should be positive."); |
| 370 |
MelderInfo_open (); |
| 371 |
MelderInfo_writeLine (U"Observed row 1 = ", Melder_iround (a), U" ", Melder_iround (b)); |
| 372 |
MelderInfo_writeLine (U"Observed row 2 = ", Melder_iround (c), U" ", Melder_iround (d)); |
| 373 |
double aexp = (a + b) * (a + c) / n; |
| 374 |
double bexp = (a + b) * (b + d) / n; |
| 375 |
double cexp = (a + c) * (c + d) / n; |
| 376 |
double dexp = (b + d) * (c + d) / n; |
| 377 |
MelderInfo_writeLine (U""); |
| 378 |
MelderInfo_writeLine (U"Expected row 1 = ", aexp, U" ", bexp); |
| 379 |
MelderInfo_writeLine (U"Expected row 2 = ", cexp, U" ", dexp); |
| 380 |
/* |
| 381 |
Continuity correction: |
| 382 |
bring the observed numbers closer to the expected numbers by 0.5 (if possible). |
| 383 |
*/ |
| 384 |
Melder_moveCloserToBy (& a, aexp, 0.5); |
| 385 |
Melder_moveCloserToBy (& b, bexp, 0.5); |
| 386 |
Melder_moveCloserToBy (& c, cexp, 0.5); |
| 387 |
Melder_moveCloserToBy (& d, dexp, 0.5); |
| 388 |
MelderInfo_writeLine (U""); |
| 389 |
MelderInfo_writeLine (U"Corrected observed row 1 = ", a, U" ", b); |
| 390 |
MelderInfo_writeLine (U"Corrected observed row 2 = ", c, U" ", d); |
| 391 |
|
| 392 |
n = a + b + c + d; |
| 393 |
double crossDifference = a * d - b * c; |
| 394 |
double x2 = n * crossDifference * crossDifference / (a + b) / (c + d) / (a + c) / (b + d); |
| 395 |
MelderInfo_writeLine (U""); |
| 396 |
MelderInfo_writeLine (U"Chi-square = ", x2); |
| 397 |
MelderInfo_writeLine (U"Two-tailed p = ", NUMchiSquareQ (x2, 1)); |
| 398 |
MelderInfo_close (); |
| 399 |
INFO_NONE_END |
| 400 |
} |
| 401 |
|
| 402 |
FORM_SAVE (GRAPHICS_saveDemoWindowAsPdfFile, U"Save Demo window as PDF file", nullptr, U"praatDemoWindow.pdf") { |
| 403 |
Demo_saveToPdfFile (file); |
| 404 |
END_NO_NEW_DATA |
| 405 |
} |
| 406 |
|
| 407 |
/********** Callbacks of the Technical menu. **********/ |
| 408 |
|
| 409 |
FORM (SETTINGS__debug, U"Set debugging options", nullptr) { |
| 410 |
COMMENT (U"If you switch Tracing on, Praat will write lots of detailed ") |
| 411 |
COMMENT (U"information about what goes on in Praat") |
| 412 |
{// scope |
| 413 |
structMelderFile file { }; |
| 414 |
#ifdef UNIX |
| 415 |
MelderFolder_getFile (Melder_preferencesFolder(), U"tracing", & file); |
| 416 |
#else |
| 417 |
MelderFolder_getFile (Melder_preferencesFolder(), U"Tracing.txt", & file); |
| 418 |
#endif |
| 419 |
COMMENT (Melder_cat (U"to ", MelderFile_peekPath (& file), U".")) |
| 420 |
} |
| 421 |
BOOLEAN (tracing, U"Tracing", false) |
| 422 |
COMMENT (U"Setting the following to anything other than zero") |
| 423 |
COMMENT (U"will alter the behaviour of Praat") |
| 424 |
COMMENT (U"in unpredictable ways.") |
| 425 |
INTEGER (debugOption, U"Debug option", U"0") |
| 426 |
OK |
| 427 |
SET_BOOLEAN (tracing, Melder_isTracingGlobally) |
| 428 |
SET_INTEGER (debugOption, Melder_debug) |
| 429 |
DO |
| 430 |
PREFS |
| 431 |
Melder_setTracing (tracing); |
| 432 |
Melder_debug = debugOption; |
| 433 |
PREFS_END |
| 434 |
} |
| 435 |
|
| 436 |
FORM (SETTINGS__DebugMultithreading, U"Debug multi-threading", U"Debug multi-threading...") { |
| 437 |
COMMENT (U"These settings determine how fast parallelized") |
| 438 |
COMMENT (U"procedures are performed on your computer.") |
| 439 |
BOOLEAN (useMultithreading, U"Use multi-threading", true) |
| 440 |
INTEGER (maximumNumberOfConcurrentThreads, U"Maximum number of threads", U"0 (= automatic)") |
| 441 |
INTEGER (minimumNumberOfElementsPerThread, U"Minimum number of frames per thread", U"0 (= automatic)") |
| 442 |
BOOLEAN (traceThreads, U"Trace threads", false) |
| 443 |
OK |
| 444 |
DO |
| 445 |
PREFS |
| 446 |
MelderThread_debugMultithreading (useMultithreading, maximumNumberOfConcurrentThreads, |
| 447 |
minimumNumberOfElementsPerThread, traceThreads); |
| 448 |
PREFS_END |
| 449 |
} |
| 450 |
|
| 451 |
DIRECT (INFO_NONE__listReadableTypesOfObjects) { |
| 452 |
INFO_NONE |
| 453 |
Thing_listReadableClasses (); |
| 454 |
INFO_NONE_END |
| 455 |
} |
| 456 |
|
| 457 |
FORM (INFO_praat_library_createC, U"PraatLib: Create C header or file", nullptr) { |
| 458 |
BOOLEAN (isInHeader, U"Is in header", true) |
| 459 |
BOOLEAN (includeCreateAPI, U"Include \"Create\" API", true) |
| 460 |
BOOLEAN (includeReadAPI, U"Include \"Read\" API", true) |
| 461 |
BOOLEAN (includeSaveAPI, U"Include \"Save\" API", true) |
| 462 |
BOOLEAN (includeQueryAPI, U"Include \"Query\" API", true) |
| 463 |
BOOLEAN (includeModifyAPI, U"Include \"Modify\" API", true) |
| 464 |
BOOLEAN (includeToAPI, U"Include \"To\" API", true) |
| 465 |
BOOLEAN (includeRecordAPI, U"Include \"Record\" API", true) |
| 466 |
BOOLEAN (includePlayAPI, U"Include \"Play\" API", true) |
| 467 |
BOOLEAN (includeDrawAPI, U"Include \"Draw\" API", true) |
| 468 |
BOOLEAN (includeHelpAPI, U"Include \"Help\" API", false) |
| 469 |
BOOLEAN (includeWindowAPI, U"Include \"Window\" API", false) |
| 470 |
BOOLEAN (includeDemoAPI, U"Include \"Demo\" API", false) |
| 471 |
OK |
| 472 |
DO |
| 473 |
praat_library_createC (isInHeader, includeCreateAPI, includeReadAPI, includeSaveAPI, |
| 474 |
includeQueryAPI, includeModifyAPI, includeToAPI, includeRecordAPI, includePlayAPI, |
| 475 |
includeDrawAPI, includeHelpAPI, includeWindowAPI, includeDemoAPI); |
| 476 |
END_NO_NEW_DATA |
| 477 |
} |
| 478 |
|
| 479 |
DIRECT (INFO_NONE__reportSystemProperties) { |
| 480 |
INFO_NONE |
| 481 |
praat_reportSystemProperties (); |
| 482 |
INFO_NONE_END |
| 483 |
} |
| 484 |
|
| 485 |
DIRECT (INFO_NONE__reportAppProperties) { |
| 486 |
INFO_NONE |
| 487 |
praat_reportAppProperties (); |
| 488 |
INFO_NONE_END |
| 489 |
} |
| 490 |
|
| 491 |
DIRECT (INFO_NONE__reportGraphicalProperties) { |
| 492 |
INFO_NONE |
| 493 |
praat_reportGraphicalProperties (); |
| 494 |
INFO_NONE_END |
| 495 |
} |
| 496 |
|
| 497 |
DIRECT (INFO_NONE__reportIntegerProperties) { |
| 498 |
INFO_NONE |
| 499 |
praat_reportIntegerProperties (); |
| 500 |
INFO_NONE_END |
| 501 |
} |
| 502 |
|
| 503 |
DIRECT (INFO_NONE__reportFloatingPointProperties) { |
| 504 |
INFO_NONE |
| 505 |
praat_reportFloatingPointProperties (); |
| 506 |
INFO_NONE_END |
| 507 |
} |
| 508 |
|
| 509 |
DIRECT (INFO_NONE__reportMemoryUse) { |
| 510 |
INFO_NONE |
| 511 |
praat_reportMemoryUse (); |
| 512 |
INFO_NONE_END |
| 513 |
} |
| 514 |
|
| 515 |
DIRECT (INFO_NONE__reportTextProperties) { |
| 516 |
INFO_NONE |
| 517 |
praat_reportTextProperties (); |
| 518 |
INFO_NONE_END |
| 519 |
} |
| 520 |
|
| 521 |
DIRECT (INFO_NONE__reportFontProperties) { |
| 522 |
INFO_NONE |
| 523 |
praat_reportFontProperties (); |
| 524 |
INFO_NONE_END |
| 525 |
} |
| 526 |
|
| 527 |
/********** Callbacks of the Open menu. **********/ |
| 528 |
|
| 529 |
/* |
| 530 |
Note: readFromFile should not call praat_updateSelection(), |
| 531 |
because praat_updateSelection() should be called after all files have been read, |
| 532 |
not just the current one. |
| 533 |
*/ |
| 534 |
static void readFromFile (MelderFile file) { |
| 535 |
autoDaata object = Data_readFromFile (file); |
| 536 |
if (! object) |
| 537 |
return; // this can happen with Picture_readFromPraatPictureFile (file recognized, but no data) |
| 538 |
if (Thing_isa (object.get(), classManPages) && ! Melder_batch) { |
| 539 |
ManPages manPages = (ManPages) object.get(); |
| 540 |
manPages -> commandsWithExternalSideEffectsAreAllowed = false; |
| 541 |
ManPage firstPage = manPages -> pages.at [1]; |
| 542 |
autoManual manual = Manual_create (firstPage -> title.get(), nullptr, |
| 543 |
(ManPages) object.releaseToAmbiguousOwner(), true, false); |
| 544 |
if (manPages -> executable) |
| 545 |
Melder_warning (U"These manual pages contain links to executable scripts.\n" |
| 546 |
"Only navigate these pages if you trust their author!"); |
| 547 |
manual.releaseToUser(); |
| 548 |
return; |
| 549 |
} |
| 550 |
if (Thing_isa (object.get(), classScript) && ! Melder_batch) { |
| 551 |
autoScriptEditor editor = ScriptEditor_createFromScript_canBeNull (nullptr, object.static_cast_move <structScript>()); |
| 552 |
if (! editor) { |
| 553 |
(void) 0; // the script was already open, and the user has been notified of that |
| 554 |
} else { |
| 555 |
editor.releaseToUser(); |
| 556 |
} |
| 557 |
return; |
| 558 |
} |
| 559 |
if (Thing_isa (object.get(), classNotebook) && ! Melder_batch) { |
| 560 |
autoNotebookEditor editor = NotebookEditor_createFromNotebook_canBeNull ((Notebook) object.get()); |
| 561 |
if (! editor) { |
| 562 |
(void) 0; // the script was already open, and the user has been notified of that |
| 563 |
} else { |
| 564 |
editor.releaseToUser(); |
| 565 |
} |
| 566 |
return; |
| 567 |
} |
| 568 |
praat_newWithFile (object.move(), file, MelderFile_name (file)); |
| 569 |
} |
| 570 |
|
| 571 |
FORM_READ (READMANY_Data_readFromFile, U"Read Object(s) from file", 0, true) { |
| 572 |
readFromFile (file); |
| 573 |
if (interpreter) |
| 574 |
interpreter -> returnType = kInterpreter_ReturnType::OBJECT_; |
| 575 |
END_WITH_NEW_DATA // this calls praat_updateSelection(), after reading a single file; see also cb_openDocument |
| 576 |
} |
| 577 |
|
| 578 |
/********** Callbacks of the Save menu. **********/ |
| 579 |
|
| 580 |
FORM_SAVE (SAVE_Data_writeToTextFile, U"Save Object(s) as one text file", nullptr, nullptr) { |
| 581 |
if (theCurrentPraatObjects -> totalSelection == 1) { |
| 582 |
LOOP { |
| 583 |
iam_LOOP (Daata); |
| 584 |
Data_writeToTextFile (me, file); |
| 585 |
} |
| 586 |
} else { |
| 587 |
autoCollection set = praat_getSelectedObjects (); |
| 588 |
Data_writeToTextFile (set.get(), file); |
| 589 |
} |
| 590 |
END_NO_NEW_DATA |
| 591 |
} |
| 592 |
|
| 593 |
FORM_SAVE (SAVE_Data_writeToShortTextFile, U"Save Object(s) as one short text file", nullptr, nullptr) { |
| 594 |
if (theCurrentPraatObjects -> totalSelection == 1) { |
| 595 |
LOOP { |
| 596 |
iam_LOOP (Daata); |
| 597 |
Data_writeToShortTextFile (me, file); |
| 598 |
} |
| 599 |
} else { |
| 600 |
autoCollection set = praat_getSelectedObjects (); |
| 601 |
Data_writeToShortTextFile (set.get(), file); |
| 602 |
} |
| 603 |
END_NO_NEW_DATA |
| 604 |
} |
| 605 |
|
| 606 |
FORM_SAVE (SAVE_Data_writeToBinaryFile, U"Save Object(s) as one binary file", nullptr, nullptr) { |
| 607 |
if (theCurrentPraatObjects -> totalSelection == 1) { |
| 608 |
LOOP { |
| 609 |
iam_LOOP (Daata); |
| 610 |
Data_writeToBinaryFile (me, file); |
| 611 |
} |
| 612 |
} else { |
| 613 |
autoCollection set = praat_getSelectedObjects (); |
| 614 |
Data_writeToBinaryFile (set.get(), file); |
| 615 |
} |
| 616 |
END_NO_NEW_DATA |
| 617 |
} |
| 618 |
|
| 619 |
FORM (PRAAT_ManPages_saveToHtmlFolder, U"Save all pages as HTML files", nullptr) { |
| 620 |
FOLDER (folder, U"Folder", U"") |
| 621 |
OK |
| 622 |
LOOP { |
| 623 |
iam_LOOP (ManPages); |
| 624 |
SET_STRING (folder, MelderFolder_peekPath (& my rootDirectory)) |
| 625 |
} |
| 626 |
DO |
| 627 |
LOOP { |
| 628 |
iam_LOOP (ManPages); |
| 629 |
ManPages_writeAllToHtmlDir (me, nullptr, folder); |
| 630 |
} |
| 631 |
END_NO_NEW_DATA |
| 632 |
} |
| 633 |
|
| 634 |
DIRECT (WINDOW_ManPages_view) { |
| 635 |
LOOP { |
| 636 |
iam_LOOP (ManPages); |
| 637 |
ManPage firstPage = my pages.at [1]; |
| 638 |
autoManual manual = Manual_create (firstPage -> title.get(), nullptr, me, false, false); |
| 639 |
if (my executable) |
| 640 |
Melder_warning (U"These manual pages contain links to executable scripts.\n" |
| 641 |
"Only navigate these pages if you trust their author!"); |
| 642 |
praat_installEditor (manual.get(), IOBJECT); |
| 643 |
manual.releaseToUser(); |
| 644 |
} |
| 645 |
END_NO_NEW_DATA |
| 646 |
} |
| 647 |
|
| 648 |
/********** Callbacks of the Help menu. **********/ |
| 649 |
|
| 650 |
FORM (PRAAT__SearchManual, U"Search manual", U"Manual") { |
| 651 |
TEXTFIELD (query, U"Search for strings (separate with spaces)", U"", 3) |
| 652 |
OK |
| 653 |
DO |
| 654 |
PRAAT |
| 655 |
if (theCurrentPraatApplication -> batch) |
| 656 |
Melder_throw (U"Cannot view a manual from batch."); |
| 657 |
autoManual manual = Manual_create (U"Intro", nullptr, theCurrentPraatApplication -> manPages, false, true); |
| 658 |
Manual_search (manual.get(), query); |
| 659 |
manual.releaseToUser(); |
| 660 |
PRAAT_END |
| 661 |
} |
| 662 |
|
| 663 |
FORM (PRAAT__GoToManualPage, U"Go to manual page", nullptr) { |
| 664 |
LIST (goToPageNumber, U"Page", ManPages_getTitles (theCurrentPraatApplication -> manPages), 1) |
| 665 |
OK |
| 666 |
DO |
| 667 |
PRAAT |
| 668 |
if (theCurrentPraatApplication -> batch) |
| 669 |
Melder_throw (U"Cannot view a manual from batch."); |
| 670 |
autoManual manual = Manual_create (U"Intro", nullptr, theCurrentPraatApplication -> manPages, false, true); |
| 671 |
HyperPage_goToPage_number (manual.get(), goToPageNumber); |
| 672 |
manual.releaseToUser(); |
| 673 |
PRAAT_END |
| 674 |
} |
| 675 |
|
| 676 |
FORM (HELP_SaveManualToHtmlFolder, U"Save all pages as HTML files", nullptr) { |
| 677 |
FOLDER (folder, U"Folder", U"") |
| 678 |
OK |
| 679 |
structMelderFolder currentFolder { }; |
| 680 |
Melder_getCurrentFolder (& currentFolder); |
| 681 |
SET_STRING (folder, MelderFolder_peekPath (& currentFolder)) |
| 682 |
DO |
| 683 |
ManPages_writeAllToHtmlDir (theCurrentPraatApplication -> manPages, nullptr, folder); |
| 684 |
END_NO_NEW_DATA |
| 685 |
} |
| 686 |
|
| 687 |
/********** Menu descriptions. **********/ |
| 688 |
|
| 689 |
void praat_show () { |
| 690 |
/* |
| 691 |
(De)sensitivize the fixed buttons as appropriate for the current selection. |
| 692 |
*/ |
| 693 |
praat_sensitivizeFixedButtonCommand (U"Remove", theCurrentPraatObjects -> totalSelection != 0); |
| 694 |
praat_sensitivizeFixedButtonCommand (U"Rename...", theCurrentPraatObjects -> totalSelection == 1); |
| 695 |
praat_sensitivizeFixedButtonCommand (U"Copy...", theCurrentPraatObjects -> totalSelection == 1); |
| 696 |
praat_sensitivizeFixedButtonCommand (U"Info", theCurrentPraatObjects -> totalSelection == 1); |
| 697 |
praat_sensitivizeFixedButtonCommand (U"Inspect", theCurrentPraatObjects -> totalSelection != 0); |
| 698 |
praat_actions_show (); |
| 699 |
if (theCurrentPraatApplication == & theForegroundPraatApplication && theReferenceToTheOnlyButtonEditor) |
| 700 |
Editor_dataChanged (theReferenceToTheOnlyButtonEditor, nullptr); |
| 701 |
} |
| 702 |
|
| 703 |
/********** Menu descriptions. **********/ |
| 704 |
|
| 705 |
void praat_addFixedButtons (GuiWindow window) { |
| 706 |
praat_addFixedButtonCommand (window, U"Rename...", MODIFY_Rename, 8, 70); |
| 707 |
praat_addFixedButtonCommand (window, U"Copy...", NEW1_Copy, 98, 70); |
| 708 |
praat_addFixedButtonCommand (window, U"Inspect", |
| 709 |
PRAAT__Inspect, 8, 40); |
| 710 |
praat_addFixedButtonCommand (window, U"Info", INFO_Info, 98, 40); |
| 711 |
praat_addFixedButtonCommand (window, U"Remove", PRAAT_Remove, 8, 10); |
| 712 |
} |
| 713 |
|
| 714 |
static void searchProc () { |
| 715 |
PRAAT__SearchManual (nullptr, 0, nullptr, nullptr, nullptr, nullptr, false, nullptr, nullptr); |
| 716 |
} |
| 717 |
|
| 718 |
static MelderString itemTitle_about; |
| 719 |
|
| 720 |
static autoDaata scriptRecognizer (integer nread, const char *header, MelderFile file) { |
| 721 |
conststring32 name = MelderFile_name (file); |
| 722 |
if (nread < 2) |
| 723 |
return autoDaata (); |
| 724 |
if ((header [0] == '#' && header [1] == '!') |
| 725 |
|| Melder_endsWith_caseAware (name, U".praat") |
| 726 |
|| Melder_endsWith_caseAware (name, U".html") |
| 727 |
) { |
| 728 |
return Script_createFromFile (file); |
| 729 |
} |
| 730 |
return autoDaata (); |
| 731 |
} |
| 732 |
|
| 733 |
static autoDaata notebookRecognizer (integer nread, const char * /* header */, MelderFile file) { |
| 734 |
conststring32 name = MelderFile_name (file); |
| 735 |
if (nread < 2) |
| 736 |
return autoDaata (); |
| 737 |
if (Melder_endsWith_caseAware (name, U".praatnb") || Melder_endsWith_caseAware (name, U".cpp")) |
| 738 |
return Notebook_createFromFile (file); |
| 739 |
return autoDaata (); |
| 740 |
} |
| 741 |
|
| 742 |
static void cb_openDocument (MelderFile file) { |
| 743 |
try { |
| 744 |
readFromFile (file); // read a single file without calling praat_updateSelection() |
| 745 |
} catch (MelderError) { |
| 746 |
Melder_flushError (); |
| 747 |
} |
| 748 |
} |
| 749 |
static void cb_finishedOpeningDocuments () { |
| 750 |
try { |
| 751 |
praat_updateSelection (); // this finally calls praat_updateSelection(), after each separate file has been read |
| 752 |
} catch (MelderError) { |
| 753 |
Melder_flushError (); |
| 754 |
} |
| 755 |
} |
| 756 |
|
| 757 |
#if cocoa |
| 758 |
DIRECT (PRAAT__cut) { |
| 759 |
PRAAT |
| 760 |
NSWindow *window = [NSApp keyWindow]; |
| 761 |
NSResponder *firstResponder = [window firstResponder]; |
| 762 |
if ([firstResponder isKindOfClass: [NSTextView class]]) |
| 763 |
[(NSTextView *) firstResponder cut: nil]; |
| 764 |
PRAAT_END |
| 765 |
} |
| 766 |
DIRECT (PRAAT__copy) { |
| 767 |
PRAAT |
| 768 |
NSWindow *window = [NSApp keyWindow]; |
| 769 |
NSResponder *firstResponder = [window firstResponder]; |
| 770 |
if ([firstResponder isKindOfClass: [NSTextView class]]) |
| 771 |
[(NSTextView *) firstResponder copy: nil]; |
| 772 |
PRAAT_END |
| 773 |
} |
| 774 |
DIRECT (PRAAT__paste) { |
| 775 |
PRAAT |
| 776 |
trace (U"Pasting to app."); |
| 777 |
NSWindow *window = [NSApp keyWindow]; |
| 778 |
NSResponder *firstResponder = [window firstResponder]; |
| 779 |
if ([firstResponder isKindOfClass: [NSTextView class]]) |
| 780 |
[(NSTextView *) firstResponder pasteAsPlainText: nil]; |
| 781 |
PRAAT_END |
| 782 |
} |
| 783 |
DIRECT (PRAAT__minimize) { |
| 784 |
PRAAT |
| 785 |
[[NSApp keyWindow] performMiniaturize: nil]; |
| 786 |
PRAAT_END |
| 787 |
} |
| 788 |
DIRECT (PRAAT__zoom) { |
| 789 |
PRAAT |
| 790 |
[[NSApp keyWindow] performZoom: nil]; |
| 791 |
PRAAT_END |
| 792 |
} |
| 793 |
DIRECT (PRAAT__close) { |
| 794 |
PRAAT |
| 795 |
[[NSApp keyWindow] performClose: nil]; |
| 796 |
PRAAT_END |
| 797 |
} |
| 798 |
#endif |
| 799 |
|
| 800 |
void praat_addMenus (GuiWindow window) { |
| 801 |
Melder_setSearchProc (searchProc); |
| 802 |
|
| 803 |
Data_recognizeFileType (scriptRecognizer); |
| 804 |
Data_recognizeFileType (notebookRecognizer); |
| 805 |
|
| 806 |
/* |
| 807 |
Create the menu titles in the bar. |
| 808 |
*/ |
| 809 |
if (! theCurrentPraatApplication -> batch) { |
| 810 |
#ifdef macintosh |
| 811 |
praatMenu = GuiMenu_createInWindow (nullptr, U"\024", 0); |
| 812 |
#if cocoa |
| 813 |
editMenu = GuiMenu_createInWindow (nullptr, U"Edit", 0); |
| 814 |
windowMenu = GuiMenu_createInWindow (nullptr, U"Window", 0); |
| 815 |
#endif |
| 816 |
#else |
| 817 |
praatMenu = GuiMenu_createInWindow (window, U"Praat", 0); |
| 818 |
#endif |
| 819 |
newMenu = GuiMenu_createInWindow (window, U"New", 0); |
| 820 |
readMenu = GuiMenu_createInWindow (window, U"Open", 0); |
| 821 |
praat_actions_createWriteMenu (window); |
| 822 |
#ifdef macintosh |
| 823 |
applicationHelpMenu = GuiMenu_createInWindow (nullptr, U"Help", 0); |
| 824 |
#endif |
| 825 |
helpMenu = GuiMenu_createInWindow (window, U"Help", 0); |
| 826 |
} |
| 827 |
|
| 828 |
MelderString_append (& itemTitle_about, U"About ", Melder_upperCaseAppName()); |
| 829 |
praat_addMenuCommand (U"Objects", U"Praat", itemTitle_about.string, nullptr, GuiMenu_UNHIDABLE, |
| 830 |
PRAAT__About); |
| 831 |
#ifdef macintosh |
| 832 |
#if cocoa |
| 833 |
/* |
| 834 |
HACK: give the following commands weird names, |
| 835 |
because otherwise they may be called from a script. |
| 836 |
(we add three alt-spaces) |
| 837 |
*/ |
| 838 |
praat_addMenuCommand (U"Objects", U"Edit", U"Cut ", nullptr, GuiMenu_UNHIDABLE | 'X' | GuiMenu_NO_API, |
| 839 |
PRAAT__cut); |
| 840 |
praat_addMenuCommand (U"Objects", U"Edit", U"Copy ", nullptr, GuiMenu_UNHIDABLE | 'C' | GuiMenu_NO_API, |
| 841 |
PRAAT__copy); |
| 842 |
praat_addMenuCommand (U"Objects", U"Edit", U"Paste ", nullptr, GuiMenu_UNHIDABLE | 'V' | GuiMenu_NO_API, |
| 843 |
PRAAT__paste); |
| 844 |
praat_addMenuCommand (U"Objects", U"Window", U"Minimize ", nullptr, GuiMenu_UNHIDABLE | GuiMenu_NO_API, |
| 845 |
PRAAT__minimize); |
| 846 |
praat_addMenuCommand (U"Objects", U"Window", U"Zoom ", nullptr, GuiMenu_UNHIDABLE | GuiMenu_NO_API, |
| 847 |
PRAAT__zoom); |
| 848 |
praat_addMenuCommand (U"Objects", U"Window", U"Close ", nullptr, 'W' | GuiMenu_NO_API, |
| 849 |
PRAAT__close); |
| 850 |
#endif |
| 851 |
#endif |
| 852 |
praat_addMenuCommand (U"Objects", U"Praat", U"-- script --", nullptr, 0, nullptr); |
| 853 |
praat_addMenuCommand (U"Objects", U"Praat", U"New Praat script", nullptr, GuiMenu_NO_API, |
| 854 |
PRAAT__newScript); |
| 855 |
praat_addMenuCommand (U"Objects", U"Praat", U"New Praat notebook", nullptr, GuiMenu_NO_API, |
| 856 |
PRAAT__newNotebook); |
| 857 |
praat_addMenuCommand (U"Objects", U"Praat", U"Open Praat script...", nullptr, GuiMenu_NO_API, |
| 858 |
PRAAT__openScript); |
| 859 |
praat_addMenuCommand (U"Objects", U"Praat", U"Open Praat notebook...", nullptr, GuiMenu_NO_API, |
| 860 |
PRAAT__openNotebook); |
| 861 |
praat_addMenuCommand (U"Objects", U"Praat", U"-- buttons --", nullptr, 0, nullptr); |
| 862 |
praat_addMenuCommand (U"Objects", U"Praat", U"Add menu command...", nullptr, GuiMenu_HIDDEN | GuiMenu_NO_API, |
| 863 |
PRAAT__addMenuCommand); |
| 864 |
praat_addMenuCommand (U"Objects", U"Praat", U"Hide menu command...", nullptr, GuiMenu_HIDDEN | GuiMenu_NO_API, |
| 865 |
PRAAT__hideMenuCommand); |
| 866 |
praat_addMenuCommand (U"Objects", U"Praat", U"Show menu command...", nullptr, GuiMenu_HIDDEN | GuiMenu_NO_API, |
| 867 |
PRAAT__showMenuCommand); |
| 868 |
praat_addMenuCommand (U"Objects", U"Praat", U"Add action command...", nullptr, GuiMenu_HIDDEN | GuiMenu_NO_API, |
| 869 |
PRAAT__addAction); |
| 870 |
praat_addMenuCommand (U"Objects", U"Praat", U"Hide action command...", nullptr, GuiMenu_HIDDEN | GuiMenu_NO_API, |
| 871 |
PRAAT__hideAction); |
| 872 |
praat_addMenuCommand (U"Objects", U"Praat", U"Show action command...", nullptr, GuiMenu_HIDDEN | GuiMenu_NO_API, |
| 873 |
PRAAT__showAction); |
| 874 |
|
| 875 |
GuiMenuItem menuItem = praat_addMenuCommand (U"Objects", U"Praat", U"Goodies", nullptr, GuiMenu_UNHIDABLE, nullptr); |
| 876 |
goodiesMenu = menuItem ? menuItem -> d_menu : nullptr; |
| 877 |
praat_addMenuCommand (U"Objects", U"Goodies", U"Calculator...", |
| 878 |
nullptr, 'U', INFO_NONE__praat_calculator); |
| 879 |
praat_addMenuCommand (U"Objects", U"Goodies", U"Report difference of two proportions...", |
| 880 |
nullptr, 0, INFO_reportDifferenceOfTwoProportions); |
| 881 |
praat_addMenuCommand (U"Objects", U"Goodies", U"-- demo window --", nullptr, 0, nullptr); |
| 882 |
praat_addMenuCommand (U"Objects", U"Goodies", U"Save Demo window as PDF file...", nullptr, 0, GRAPHICS_saveDemoWindowAsPdfFile); |
| 883 |
|
| 884 |
menuItem = praat_addMenuCommand (U"Objects", U"Praat", U"Settings", nullptr, GuiMenu_UNHIDABLE, nullptr); |
| 885 |
preferencesMenu = menuItem ? menuItem -> d_menu : nullptr; |
| 886 |
praat_addMenuCommand (U"Objects", U"Settings", U"Buttons...", |
| 887 |
nullptr, GuiMenu_UNHIDABLE, PRAAT__editButtons); |
| 888 |
praat_addMenuCommand (U"Objects", U"Settings", U"-- encoding prefs --", nullptr, 0, nullptr); |
| 889 |
praat_addMenuCommand (U"Objects", U"Settings", U"Text reading settings... || Text reading preferences...", |
| 890 |
nullptr, 0, SETTINGS__TextReadingSettings); // alternative GuiMenu_DEPRECATED_2023 |
| 891 |
praat_addMenuCommand (U"Objects", U"Settings", U"Text writing settings... || Text writing preferences...", |
| 892 |
nullptr, 0, SETTINGS__TextWritingSettings); // alternative GuiMenu_DEPRECATED_2023 |
| 893 |
praat_addMenuCommand (U"Objects", U"Settings", U"CJK font style settings... || CJK font style preferences...", |
| 894 |
nullptr, 0, SETTINGS__CjkFontStyleSettings); // alternative GuiMenu_DEPRECATED_2023 |
| 895 |
|
| 896 |
menuItem = praat_addMenuCommand (U"Objects", U"Praat", U"Technical", nullptr, GuiMenu_UNHIDABLE, nullptr); |
| 897 |
technicalMenu = menuItem ? menuItem -> d_menu : nullptr; |
| 898 |
praat_addMenuCommand (U"Objects", U"Technical", U"Report memory use", |
| 899 |
nullptr, 0, INFO_NONE__reportMemoryUse); |
| 900 |
praat_addMenuCommand (U"Objects", U"Technical", U"Report integer properties", |
| 901 |
nullptr, 0, INFO_NONE__reportIntegerProperties); |
| 902 |
praat_addMenuCommand (U"Objects", U"Technical", U"Report floating point properties", |
| 903 |
nullptr, 0, INFO_NONE__reportFloatingPointProperties); |
| 904 |
praat_addMenuCommand (U"Objects", U"Technical", U"Report system properties", |
| 905 |
nullptr, 0, INFO_NONE__reportSystemProperties); |
| 906 |
praat_addMenuCommand (U"Objects", U"Technical", U"Report app properties", |
| 907 |
nullptr, 0, INFO_NONE__reportAppProperties); |
| 908 |
praat_addMenuCommand (U"Objects", U"Technical", U"Report graphical properties", |
| 909 |
nullptr, 0, INFO_NONE__reportGraphicalProperties); |
| 910 |
praat_addMenuCommand (U"Objects", U"Technical", U"Report text properties", |
| 911 |
nullptr, 0, INFO_NONE__reportTextProperties); |
| 912 |
praat_addMenuCommand (U"Objects", U"Technical", U"Report font properties", |
| 913 |
nullptr, 0, INFO_NONE__reportFontProperties); |
| 914 |
praat_addMenuCommand (U"Objects", U"Technical", U"Debug...", |
| 915 |
nullptr, 0, SETTINGS__debug); |
| 916 |
praat_addMenuCommand (U"Objects", U"Technical", U"Debug multi-threading...", |
| 917 |
nullptr, 0, SETTINGS__DebugMultithreading); |
| 918 |
|
| 919 |
praat_addMenuCommand (U"Objects", U"Technical", U"-- api --", nullptr, 0, nullptr); |
| 920 |
praat_addMenuCommand (U"Objects", U"Technical", U"List readable types of objects", |
| 921 |
nullptr, 0, INFO_NONE__listReadableTypesOfObjects); |
| 922 |
praat_addMenuCommand (U"Objects", U"Technical", U"Create C interface...", |
| 923 |
nullptr, 0, INFO_praat_library_createC); |
| 924 |
|
| 925 |
praat_addMenuCommand (U"Objects", U"Open", U"Read from file...", nullptr, GuiMenu_ATTRACTIVE | 'O', READMANY_Data_readFromFile); |
| 926 |
|
| 927 |
praat_addAction1 (classDaata, 0, U"Save as text file... || Write to text file...", |
| 928 |
nullptr, 0, SAVE_Data_writeToTextFile); // alternative GuiMenu_DEPRECATED_2011 |
| 929 |
praat_addAction1 (classDaata, 0, U"Save as short text file... || Write to short text file...", |
| 930 |
nullptr, 0, SAVE_Data_writeToShortTextFile); // alternative GuiMenu_DEPRECATED_2011 |
| 931 |
praat_addAction1 (classDaata, 0, U"Save as binary file... || Write to binary file...", |
| 932 |
nullptr, 0, SAVE_Data_writeToBinaryFile); // alternative GuiMenu_DEPRECATED_2011 |
| 933 |
|
| 934 |
praat_addAction1 (classManPages, 1, U"Save to HTML folder... || Save to HTML directory...", |
| 935 |
nullptr, 0, PRAAT_ManPages_saveToHtmlFolder); // alternative GuiMenu_DEPRECATED_2020 |
| 936 |
praat_addAction1 (classManPages, 1, U"View", |
| 937 |
nullptr, 0, WINDOW_ManPages_view); |
| 938 |
} |
| 939 |
|
| 940 |
void praat_addMenus2 () { |
| 941 |
praat_addMenuCommand (U"Objects", U"ApplicationHelp", U"-- manual --", nullptr, 0, nullptr); |
| 942 |
praat_addMenuCommand (U"Objects", U"ApplicationHelp", U"Go to manual page...", |
| 943 |
nullptr, 0, PRAAT__GoToManualPage); |
| 944 |
praat_addMenuCommand (U"Objects", U"ApplicationHelp", U"Save manual to HTML folder...", |
| 945 |
nullptr, GuiMenu_HIDDEN, HELP_SaveManualToHtmlFolder); |
| 946 |
praat_addMenuCommand (U"Objects", U"ApplicationHelp", Melder_cat (U"Search ", Melder_upperCaseAppName(), U" manual..."), |
| 947 |
nullptr, 'M' | GuiMenu_NO_API, PRAAT__SearchManual); |
| 948 |
praat_addMenuCommand (U"Objects", U"ApplicationHelp", itemTitle_about.string, |
| 949 |
nullptr, GuiMenu_UNHIDABLE, PRAAT__About); |
| 950 |
|
| 951 |
#if defined (macintosh) |
| 952 |
Gui_setOpenDocumentCallback (cb_openDocument, cb_finishedOpeningDocuments); |
| 953 |
#endif |
| 954 |
} |
| 955 |
|
| 956 |
/* End of file praat_objectMenus.cpp */ |