| 1 |
/* manual_Manual.cpp |
| 2 |
* |
| 3 |
* Copyright (C) 1992-2007,2010,2011,2014-2017,2019,2020,2022-2025 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 "ManPagesM.h" |
| 20 |
|
| 21 |
void manual_Manual_init (ManPages me); |
| 22 |
void manual_Manual_init (ManPages me) { |
| 23 |
|
| 24 |
MAN_BEGIN (U"Manual", U"ppgb", 20110101) |
| 25 |
INTRO (U"The documentation system for the Praat program.") |
| 26 |
NORMAL (U"You will get a manual window every time you choose anything from a #Help menu or press a #Help button.") |
| 27 |
ENTRY (U"How to find what you are looking for") |
| 28 |
NORMAL (U"You can navigate the manual in several ways:") |
| 29 |
LIST_ITEM (U"\\bu To go to the Intro, use the #Home button.") |
| 30 |
LIST_ITEM (U"\\bu To go to the information behind a %link (a piece of blue text), just click on it.") |
| 31 |
LIST_ITEM (U"\\bu To go forward and backward through a tutorial with numbered pages, use “##1 >#” and “##< 1#”.") |
| 32 |
LIST_ITEM (U"\\bu To %revisit previous pages, use the #< and #> buttons.") |
| 33 |
LIST_ITEM (U"\\bu To browse %alphabetically, use the horizontal scroll bar and the buttons " |
| 34 |
"named “##< 1#” and “##1 >#”, or the ##Search for page (list)...# command in the “Go to” menu.") |
| 35 |
LIST_ITEM (U"\\bu To find a page with a %%known title%, use the ##Search for page...# command.") |
| 36 |
NORMAL (U"The fastest way to find what you want is usually the #Search button.") |
| 37 |
ENTRY (U"Search") |
| 38 |
NORMAL (U"In the text field after the Search button, you can type strings, separated by spaces. " |
| 39 |
"When you press the Return (or Enter) key, or click the #Search button, " |
| 40 |
"all manual pages are searched for the combination of strings that you typed. " |
| 41 |
"The titles of the 20 best matching pages are displayed as links.") |
| 42 |
NORMAL (U"##Example:# to know how to create a pitch contour from a sound, type") |
| 43 |
CODE (U"sou pit") |
| 44 |
NORMAL (U"and press Return. The best matches should appear on top. These should include " |
| 45 |
"##Sound: To Pitch (ac)...# and ##Sound: To Pitch (cc)...#.") |
| 46 |
NORMAL (U"The search is case-insensitive. For instance, the search string “$script” will give you all " |
| 47 |
"the pages that contain the words %script, %Script, %description, %PostScript, or %SCRIPT, and so on.") |
| 48 |
NORMAL (U"#Background. The search algorithm uses the following heuristics:") |
| 49 |
LIST_ITEM (U"\\bu A match in the page title is better than one in the rest of the text.") |
| 50 |
LIST_ITEM (U"\\bu Pages with many matches are better than those with few.") |
| 51 |
ENTRY (U"Your own manual pages") |
| 52 |
NORMAL (U"To create your own manual pages, create @ManPages text files.") |
| 53 |
MAN_END |
| 54 |
|
| 55 |
MAN_PAGES_BEGIN R"~~~( |
| 56 |
################################################################################ |
| 57 |
"ManPages" |
| 58 |
© Paul Boersma 2023-04-20 |
| 59 |
|
| 60 |
You can create a documentation or education system with files that you and others |
| 61 |
can read into Praat (with the @@Read from file...@ command). |
| 62 |
Your files will become a hypertext system very similar to the usual @Manual. |
| 63 |
|
| 64 |
Example 1: a single document |
| 65 |
============================ |
| 66 |
|
| 67 |
If you create a single ManPages text file, it will look like a manual with a single page. |
| 68 |
Here is an example: |
| 69 |
` |
| 70 |
ManPagesTextFile |
| 71 |
"Welkom" "miep" 19970820 0 |
| 72 |
<intro> "Hallo allemaal!" |
| 73 |
<entry> "Belangrijk..." |
| 74 |
<normal> "Hoogge\e""erd publiek!" |
| 75 |
<normal> "Einde." |
| 76 |
` |
| 77 |
A ManPages text file should start with the following information: |
| 78 |
|
| 79 |
1. The word “ManPagesTextFile” on the first line. |
| 80 |
2. The title of the manual page, between double quotes. |
| 81 |
This will be drawn at the top of the page. |
| 82 |
The name of the ManPages text file should be derived from this title (see below). |
| 83 |
3. The author of the manual page, between double quotes. |
| 84 |
This will be drawn at the bottom of the page. |
| 85 |
4. The date you created or modified the page, |
| 86 |
in the format year \-- month (two digits) \-- day (two digits), without spaces. |
| 87 |
5. The recording time. If this is not zero, |
| 88 |
three sound buttons (see below) will appear at the top of the page. |
| 89 |
6. A sequence of paragraph types and texts. |
| 90 |
You put the types between < and >, and the texts between double quotes |
| 91 |
(if your text contains a double quote, you should write two double quotes). |
| 92 |
|
| 93 |
The format of a ManPages text file is rather free, as long as the first line is correct, |
| 94 |
the four required pieces of information are there in the correct order, |
| 95 |
and there is a correct alternation between paragraph texts and types. |
| 96 |
If you put multiple elements on a line, there should be at least one space between them. |
| 97 |
You may distribute texts across multiple lines, as long as you do not add any spaces: |
| 98 |
` |
| 99 |
<normal> "Hoogge\e""erd |
| 100 |
publiek!" |
| 101 |
` |
| 102 |
This will have exactly the same effect as above. |
| 103 |
|
| 104 |
Example 2: multiple documents |
| 105 |
============================= |
| 106 |
|
| 107 |
The above example with a single document is not very useful. |
| 108 |
You will usually want to refer to other documents: |
| 109 |
` |
| 110 |
ManPagesTextFile |
| 111 |
"Welcome" "Paul Boersma" 19970820 1.0 |
| 112 |
<intro> "Welcome to Paul's transcription course." |
| 113 |
<entry> "Groups of speech sounds" |
| 114 |
<normal> "You can listen to the following sounds |
| 115 |
from the languages of the world, |
| 116 |
pronounced by a %single speaker (#me):" |
| 117 |
<list_item> "@Vowels, quite problematic for Dutch students!" |
| 118 |
<list_item> "@@Dorsal fricatives@, equally problematic!" |
| 119 |
` |
| 120 |
With the symbol “`@`”, you create a %link to another ManPages text file. |
| 121 |
A link will be drawn in blue on your screen. |
| 122 |
In this example, you have created links to the files `Vowels.man` |
| 123 |
and `Dorsal_fricatives.man` in the same folder as the current file |
| 124 |
(all `.man` files have to be in the same folder; this makes it likely |
| 125 |
that their names are unique). |
| 126 |
If the link contains spaces or other non-alphanumeric symbols, |
| 127 |
you have to use three “`@`” symbols, as shown; |
| 128 |
with a single word, you may use a single “`@`”. |
| 129 |
|
| 130 |
In resolving the file name, the ManPages system replaces spaces |
| 131 |
and other special symbols with underscores, |
| 132 |
and converts any initial lower-case character by its upper-case variant. |
| 133 |
For instance, if your link is “`@@back vowels@`”, |
| 134 |
the file name will be `Back_vowels.man`. |
| 135 |
|
| 136 |
The title in the second line of `Back_vowels.man` must be equal to the link name, |
| 137 |
though capitalization of the first letter is allowed. |
| 138 |
Thus, the title of `Back_vowels.man` will probably be “Back vowels”. |
| 139 |
Likewise, the starting file with the title “Welcome” should have the name `Welcome.man` |
| 140 |
if any other files refer to it. |
| 141 |
|
| 142 |
Paragraph types |
| 143 |
=============== |
| 144 |
|
| 145 |
A normal paragraph will have type `<normal>`. The hypertext system will |
| 146 |
leave a blank space between paragraphs with this type. |
| 147 |
The first paragraph of a manual page will normally have the type `<intro>`. |
| 148 |
Though this may look the same as `<normal>`, the search system of the @Manual |
| 149 |
may take account of the distinction. |
| 150 |
|
| 151 |
Headings (like the title “Paragraph types” of this subsection) |
| 152 |
have type `<entry>`. This will be drawn in a larger character size. |
| 153 |
|
| 154 |
For lists, you use the type `<list_item>`. You will often combine this with %button symbols, |
| 155 |
like in the following: |
| 156 |
` |
| 157 |
<normal> "Choose a colour:" |
| 158 |
<list_item> "\bu @Red." |
| 159 |
<list_item> "\bu @Green." |
| 160 |
<list_item> "\bu @Blue." |
| 161 |
` |
| 162 |
For text that should appear with a fixed character width, you use the type `<code>`. |
| 163 |
|
| 164 |
For a paragraph that should be connected with the following paragraph |
| 165 |
without leaving a blank space (probably a definition), you use the type `<term>`. |
| 166 |
|
| 167 |
For a paragraph with a blank left margin, you use the type `<definition>`. |
| 168 |
|
| 169 |
For a paragraph with an embedded script (a picture), you use the type `<script>` (see below). |
| 170 |
|
| 171 |
Special symbols and styles |
| 172 |
========================== |
| 173 |
|
| 174 |
You can use all of Praat’s @@special symbols@ and @@text styles@, |
| 175 |
except that some %single text-style symbols have different meanings: |
| 176 |
|
| 177 |
- A single percent sign introduces a word in italic: `%pot` gives %pot. |
| 178 |
- A single number sign introduces a word in bold: `#pot` gives #pot. |
| 179 |
- A single dollar sign introduces a word in monospace: `$pot` gives `pot`. |
| 180 |
- A single underscore is rendered as an underscore: `a_b` gives a\_ b. |
| 181 |
|
| 182 |
To create a single italic, bold, or subscripted letter, |
| 183 |
you revert to the usual technique for stretches of italic, bold, or subscripted text. |
| 184 |
So, to get %F_1, you type `%F__1_`. |
| 185 |
|
| 186 |
Sound links |
| 187 |
=========== |
| 188 |
|
| 189 |
Your text may contain links to sound files. They are drawn in blue. |
| 190 |
The format is: |
| 191 |
` |
| 192 |
<normal> "You should know that @@\FIct.aifc|\ct@ is more open than |
| 193 |
@@\FIo.aifc|o@." |
| 194 |
` |
| 195 |
On your screen, you will see an #\ct and an #o symbol, both drawn in blue. |
| 196 |
If you click on one of these sound links, one of the sound files `ct.aifc` |
| 197 |
or `o.aifc` will be played. |
| 198 |
|
| 199 |
The format of the sound link “`@@\FIo.aifc|o@`” is to be understood |
| 200 |
as follows. The pipe symbol separates the link information (`\FIo.aifc`) from the viewable |
| 201 |
link text (`o`). The link information is introduced with a symbol (`\FI`) that |
| 202 |
tells the manual system that a sound file name follows. The manual system reads |
| 203 |
this file, sees that it contains a sound, and plays that sound. |
| 204 |
|
| 205 |
You can use relative path names, e.g., `\FIsounds/o.aifc` refers to the file |
| 206 |
`o.aifc` in the subfolder `sounds`, which must be contained in the same folder |
| 207 |
as the `.man` files. To make sure that your manual pages run on all platforms |
| 208 |
(Windows, Macintosh, Unix), you will want to use the forward slash (/) to separate |
| 209 |
the folder name(s) from the file name, as in this example |
| 210 |
(i.e. you avoid the backslash (\bs) that is usual on Windows computers). |
| 211 |
|
| 212 |
Pictures as embedded scripts |
| 213 |
============================ |
| 214 |
|
| 215 |
Your text may contain Praat scripts. They typically draw a picture in your manual page, |
| 216 |
with the font and font size of the manual until you specify otherwise in the script. The format is: |
| 217 |
` |
| 218 |
<script> 4.5 4 " |
| 219 |
Draw inner box |
| 220 |
Axes: 0, 100, 0, 100 |
| 221 |
Text: 50, "Centre", 50, "Half", "Hello!!" |
| 222 |
" |
| 223 |
` |
| 224 |
The two numbers after `<script>` are the width and the height of the picture |
| 225 |
(the “outer viewport”) in inches, if the font size of the manual is 12. |
| 226 |
If the font size is larger, the viewport will be scaled up accordingly. |
| 227 |
|
| 228 |
Please note that the script is enclosed within double quotes. |
| 229 |
Therefore, you will have to double any double quotes that occur in the script. |
| 230 |
|
| 231 |
If needed, a script like this can create objects in the object list of the manual. |
| 232 |
However, you have to make sure that you remove them after use: |
| 233 |
` |
| 234 |
<script> 6 3 " |
| 235 |
Create Sound from formula: "sineWithNoise", 1, 0.0, 1.0, 44100, |
| 236 |
... ~1/2 * sin (2 * pi * 377 * x) + randomGauss (0, 0.1) |
| 237 |
To Spectrogram: 0.005, 5000, 0.002, 20, "Gaussian" |
| 238 |
Paint: 0, 0, 0, 0, 100.0, "yes", 50.0, 6.0, 0.0, "yes" |
| 239 |
plusObject: "Sound sineWithNoise" |
| 240 |
Remove |
| 241 |
" |
| 242 |
` |
| 243 |
Note that this script does not set the font and font size. |
| 244 |
This means that the drawing will use the font and font size of the manual page, |
| 245 |
which is usually what you want. |
| 246 |
|
| 247 |
For obvious safety reasons, embedded scripts cannot contain commands that change the contents of any disk |
| 248 |
or send messages. Thus, commands like ##Save as WAV file...#, |
| 249 |
#`deleteFile: "out.txt"`, `writeFile: "out.txt", string$`, |
| 250 |
or #`runSystem` are forbidden. Several other commands, such as #`pauseScript` and #`editor`, |
| 251 |
are irrelevant inside pictures and are therefore forbidden as well. |
| 252 |
Note that commands like #`writeInfoLine`, ##Read from file...#, and #`runScript` are still available |
| 253 |
(with the last two, you can use relative paths; |
| 254 |
with `runScript`, you can only run scripts that do not call any of the forbidden commands directly or indirectly). |
| 255 |
|
| 256 |
The commands ##Set outer viewport...# and ##Set inner viewport...# are available; |
| 257 |
they count in inches (if the font size of the manual is 12). The (0, 0) point is in the upper left corner, |
| 258 |
as in the Picture window, so that you can test your picture with a normal Praat script; |
| 259 |
for instance, the following script draws a cross in the upper half of the picture and a rectangle in the lower half: |
| 260 |
` |
| 261 |
<script> 4.5 4 " |
| 262 |
Axes: 0, 100, 0, 100 |
| 263 |
Select inner viewport: 0, 4.5, 0, 2 |
| 264 |
Draw line: 0, 0, 100, 100 |
| 265 |
Draw line: 0, 100, 100, 0 |
| 266 |
Select inner viewport: 0, 4.5, 2, 4 |
| 267 |
Draw rectangle: 0, 100, 0, 100 |
| 268 |
" |
| 269 |
` |
| 270 |
{- 4.5x4 |
| 271 |
Font size: 12 ; BUG |
| 272 |
Axes: 0, 100, 0, 100 |
| 273 |
Select inner viewport: 0, 4.5, 0, 2 |
| 274 |
Draw line: 0, 0, 100, 100 |
| 275 |
Draw line: 0, 100, 100, 0 |
| 276 |
Select inner viewport: 0, 4.5, 2, 4 |
| 277 |
Draw rectangle: 0, 100, 0, 100 |
| 278 |
} |
| 279 |
|
| 280 |
Script links |
| 281 |
============ |
| 282 |
|
| 283 |
Your text may contain links to Praat scripts. They are drawn in blue. |
| 284 |
The format is: |
| 285 |
` |
| 286 |
<normal> "Here is a script that @@\SCdraw.praat|draws@ what you have selected." |
| 287 |
` |
| 288 |
On your screen, you will see the word #draws, drawn in blue. |
| 289 |
If you click on it, the script `draw.praat` will be executed. The string “`\SC`” indicates |
| 290 |
that a script file name follows. As with sounds, you can use relative file paths. The script can take |
| 291 |
arguments: |
| 292 |
` |
| 293 |
<normal> "This script @@\SCload2files.praat hello.wav hello.TextGrid|loads@ some files." |
| 294 |
` |
| 295 |
If the script file name or any arguments except the last contain spaces, they have to be enclosed |
| 296 |
within double quotes, which have to be doubled again in the ManPage code: |
| 297 |
` |
| 298 |
<normal> "Here is a script that @@\SC""my scripts/draw.praat""|draws@ what you have selected." |
| 299 |
<normal> "This script @@\SC""my scripts/load2files.praat"" ""my sounds/hello.wav"" my textgrids/hello.TextGrid|loads@ some files." |
| 300 |
` |
| 301 |
For safety reasons, the user will see a warning about |
| 302 |
"trusting the author of the manual pages" if you include script links in your manual. |
| 303 |
|
| 304 |
How to separate link information and link text |
| 305 |
============================================== |
| 306 |
|
| 307 |
The separation between link information and viewable link text, as seen |
| 308 |
in the above description of sound and script links, is actually a general mechanism |
| 309 |
in the hypertext system. For instance, if you want to see the text "x" |
| 310 |
in blue on your screen, and create a link from it to the page "Dorsal fricatives", |
| 311 |
you specify the link as `@@Dorsal fricatives|x@`. |
| 312 |
|
| 313 |
Sound buttons |
| 314 |
============= |
| 315 |
|
| 316 |
If the %%recording time% in the second line is not 0, |
| 317 |
three buttons will appear near the top of the page: |
| 318 |
|
| 319 |
1. The #Record button allows you to record a sound from the microphone. |
| 320 |
|
| 321 |
2. The #Play button allows you to play this recorded sound. |
| 322 |
In this way, you can compare your own utterances with the sounds |
| 323 |
behind the sound links, for example. |
| 324 |
|
| 325 |
3. The ##Copy last played to list# button copies the latest sound to the list of objects, |
| 326 |
allowing you to perform analyses on it, save it to disk, et cetera. |
| 327 |
The latest sound may be a sound that you recorded with the #Record button, |
| 328 |
a sound that you played with the #Play button, |
| 329 |
or a sound that you played by clicking on a sound link, |
| 330 |
whichever occurred most recently. |
| 331 |
|
| 332 |
And beyond |
| 333 |
========== |
| 334 |
|
| 335 |
If you need even more flexibility than ManPages offer you, consider using the @@Demo window@ instead. |
| 336 |
################################################################################ |
| 337 |
)~~~" MAN_PAGES_END |
| 338 |
|
| 339 |
|
| 340 |
} |
| 341 |
|
| 342 |
/* End of file manual_Manual.cpp */ |