| 1 | #cxx . . $ `<file>/melder/melder_info.h`/ifndef _melder_info_h_ |
| 2 | #define _melder_info_h_cxx . . $ `melder/melder_info.h:2:9`! |
| 3 | /* melder_info.h |
| 4 | * |
| 5 | * Copyright (C) 1992-2018,2020,2023,2025 Paul Boersma |
| 6 | * |
| 7 | * This code is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; either version 3 of the License, or (at |
| 10 | * your option) any later version. |
| 11 | * |
| 12 | * This code is distributed in the hope that it will be useful, but |
| 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 15 | * See the GNU General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with this work. If not, see <http://www.gnu.org/licenses/>. |
| 19 | */ |
| 20 | |
| 21 | /* |
| 22 | Give information to stdout (batch), or to an "Info" window (interactive), or to a diverted string, or to a notebook. |
| 23 | */ |
| 24 | |
| 25 | namespace MelderInfocxx . . $ MelderInfo/ { |
| 26 | using Proccxx . . $ MelderInfo/Proc# = void (*) (conststring32cxx . . $ conststring32# message); |
| 27 | void _defaultProccxx . . $ MelderInfo/_defaultProc(ff00d524ab0355ec). (conststring32cxx . . $ conststring32# message); |
| 28 | extern Proccxx . . $ MelderInfo/Proc# _p_currentProccxx . . $ MelderInfo/_p_currentProc.; |
| 29 | extern MelderStringcxx . . $ MelderString# _foregroundBuffercxx . . $ MelderInfo/_foregroundBuffer., *_p_currentBuffercxx . . $ MelderInfo/_p_currentBuffer.; |
| 30 | } |
| 31 | |
| 32 | void MelderInfo_opencxx . . $ MelderInfo_open(49f6e7a06ebc5aa8). (); // clear the Info window in the background |
| 33 | void MelderInfo_closecxx . . $ MelderInfo_close(49f6e7a06ebc5aa8). (); // drain the background info to the Info window, making sure there is a line break |
| 34 | void MelderInfo_draincxx . . $ MelderInfo_drain(49f6e7a06ebc5aa8). (); // drain the background info to the Info window, without adding any extra line break |
| 35 | |
| 36 | template <typename... Args> |
| 37 | void MelderInfo_writecxx . . $ MelderInfo_write(3eb398314feba58b). (const Args&... args) { |
| 38 | MelderString_appendcxx . . $ MelderString_append(65be51a793e0ff96). (MelderInfocxx . . $ MelderInfo/::_p_currentBuffercxx . . $ MelderInfo/_p_currentBuffer., args...); |
| 39 | if (MelderInfocxx . . $ MelderInfo/::_p_currentProccxx . . $ MelderInfo/_p_currentProc. == & MelderInfocxx . . $ MelderInfo/::_defaultProccxx . . $ MelderInfo/_defaultProc(ff00d524ab0355ec). && MelderInfocxx . . $ MelderInfo/::_p_currentBuffercxx . . $ MelderInfo/_p_currentBuffer. == & MelderInfocxx . . $ MelderInfo/::_foregroundBuffercxx . . $ MelderInfo/_foregroundBuffer.) |
| 40 | ( MelderConsolecxx . . $ MelderConsole/::writecxx . . $ MelderConsole/write(7004b68cc6c23ea2). (MelderArgcxx . . $ MelderArg# {args}._argcxx . . $ MelderArg#_arg., false), ... ); |
| 41 | } |
| 42 | |
| 43 | template <typename... Args> |
| 44 | void MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (const Args&... args) { |
| 45 | MelderString_appendcxx . . $ MelderString_append(65be51a793e0ff96). (MelderInfocxx . . $ MelderInfo/::_p_currentBuffercxx . . $ MelderInfo/_p_currentBuffer., args...); |
| 46 | MelderString_appendCharactercxx . . $ MelderString_appendCharacter(f4ab64866cffe712). (MelderInfocxx . . $ MelderInfo/::_p_currentBuffercxx . . $ MelderInfo/_p_currentBuffer., U'\n'); |
| 47 | if (MelderInfocxx . . $ MelderInfo/::_p_currentProccxx . . $ MelderInfo/_p_currentProc. == & MelderInfocxx . . $ MelderInfo/::_defaultProccxx . . $ MelderInfo/_defaultProc(ff00d524ab0355ec). && MelderInfocxx . . $ MelderInfo/::_p_currentBuffercxx . . $ MelderInfo/_p_currentBuffer. == & MelderInfocxx . . $ MelderInfo/::_foregroundBuffercxx . . $ MelderInfo/_foregroundBuffer.) { |
| 48 | ( MelderConsolecxx . . $ MelderConsole/::writecxx . . $ MelderConsole/write(7004b68cc6c23ea2). (MelderArgcxx . . $ MelderArg# {args}._argcxx . . $ MelderArg#_arg., false), ... ); |
| 49 | MelderConsolecxx . . $ MelderConsole/::writecxx . . $ MelderConsole/write(7004b68cc6c23ea2). (U"\n", false); |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | template <typename... Args> |
| 54 | void Melder_informationcxx . . $ Melder_information(3eb398314feba58b). (const Args&... args) { |
| 55 | MelderString_copycxx . . $ MelderString_copy(65be51a793e0ff96). (MelderInfocxx . . $ MelderInfo/::_p_currentBuffercxx . . $ MelderInfo/_p_currentBuffer., args...); |
| 56 | if (MelderInfocxx . . $ MelderInfo/::_p_currentProccxx . . $ MelderInfo/_p_currentProc. == & MelderInfocxx . . $ MelderInfo/::_defaultProccxx . . $ MelderInfo/_defaultProc(ff00d524ab0355ec). && MelderInfocxx . . $ MelderInfo/::_p_currentBuffercxx . . $ MelderInfo/_p_currentBuffer. == & MelderInfocxx . . $ MelderInfo/::_foregroundBuffercxx . . $ MelderInfo/_foregroundBuffer.) |
| 57 | ( MelderConsolecxx . . $ MelderConsole/::writecxx . . $ MelderConsole/write(7004b68cc6c23ea2). (MelderArgcxx . . $ MelderArg# {args}._argcxx . . $ MelderArg#_arg., false), ... ); |
| 58 | MelderInfo_closecxx . . $ MelderInfo_close(49f6e7a06ebc5aa8). (); |
| 59 | } |
| 60 | |
| 61 | void Melder_informationRealcxx . . $ Melder_informationReal(cd1f800970345287). (double value, conststring32cxx . . $ conststring32# units); // %.17g or --undefined--; units may be null |
| 62 | |
| 63 | void Melder_divertInfocxx . . $ Melder_divertInfo(93db1090f27e5462). (MelderStringcxx . . $ MelderString# *p_buffer); // nullptr = back to normal |
| 64 | |
| 65 | class autoMelderDivertInfocxx . . $ autoMelderDivertInfo# { |
| 66 | public: |
| 67 | autoMelderDivertInfocxx . . $ autoMelderDivertInfo#autoMelderDivertInfo(93db1090f27e5462). (MelderStringcxx . . $ MelderString# *p_buffer) { Melder_divertInfocxx . . $ Melder_divertInfo(93db1090f27e5462). (p_buffer); } |
| 68 | ~cxx . . $ autoMelderDivertInfo#`~autoMelderDivertInfo`(ced63f7c635d850d).autoMelderDivertInfocxx . . $ autoMelderDivertInfo# () { Melder_divertInfocxx . . $ Melder_divertInfo(93db1090f27e5462). (nullptr); } |
| 69 | }; |
| 70 | |
| 71 | void Melder_clearInfocxx . . $ Melder_clearInfo(49f6e7a06ebc5aa8). (); // clear the Info window |
| 72 | conststring32cxx . . $ conststring32# Melder_getInfocxx . . $ Melder_getInfo(1912f6684645c851). (); |
| 73 | |
| 74 | void Melder_setInformationProccxx . . $ Melder_setInformationProc(f441b548652834d9). (MelderInfocxx . . $ MelderInfo/::Proccxx . . $ MelderInfo/Proc# proc); |
| 75 | |
| 76 | class autoMelderSetInformationProccxx . . $ autoMelderSetInformationProc# { |
| 77 | public: |
| 78 | autoMelderSetInformationProccxx . . $ autoMelderSetInformationProc#autoMelderSetInformationProc(f441b548652834d9). (MelderInfocxx . . $ MelderInfo/::Proccxx . . $ MelderInfo/Proc# temporaryNewProc) { |
| 79 | ourcxx . . $ `melder/melder.h:42:9`! saveProccxx . . $ autoMelderSetInformationProc#saveProc. = MelderInfocxx . . $ MelderInfo/::_p_currentProccxx . . $ MelderInfo/_p_currentProc.; |
| 80 | Melder_setInformationProccxx . . $ Melder_setInformationProc(f441b548652834d9). (temporaryNewProc); |
| 81 | } |
| 82 | ~cxx . . $ autoMelderSetInformationProc#`~autoMelderSetInformationProc`(ced63f7c635d850d).autoMelderSetInformationProccxx . . $ autoMelderSetInformationProc# () { |
| 83 | Melder_setInformationProccxx . . $ Melder_setInformationProc(f441b548652834d9). (ourcxx . . $ `melder/melder.h:42:9`! saveProccxx . . $ autoMelderSetInformationProc#saveProc.); |
| 84 | } |
| 85 | private: |
| 86 | MelderInfocxx . . $ MelderInfo/::Proccxx . . $ MelderInfo/Proc# saveProccxx . . $ autoMelderSetInformationProc#saveProc.; |
| 87 | }; |
| 88 | |
| 89 | /* End of file melder_info.h */ |
| 90 | #endif |