| 1 |
/* |
| 2 |
* Copyright (c) 2004-2013 the xdvik development team |
| 3 |
* |
| 4 |
* Permission is hereby granted, free of charge, to any person obtaining a copy |
| 5 |
* of this software and associated documentation files (the "Software"), to |
| 6 |
* deal in the Software without restriction, including without limitation the |
| 7 |
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
| 8 |
* sell copies of the Software, and to permit persons to whom the Software is |
| 9 |
* furnished to do so, subject to the following conditions: |
| 10 |
* |
| 11 |
* The above copyright notice and this permission notice shall be included in |
| 12 |
* all copies or substantial portions of the Software. |
| 13 |
* |
| 14 |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 15 |
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 16 |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 17 |
* PAUL VOJTA OR ANY OTHER AUTHOR OF THIS SOFTWARE BE LIABLE FOR ANY CLAIM, |
| 18 |
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
| 19 |
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
| 20 |
* OTHER DEALINGS IN THE SOFTWARE. |
| 21 |
* |
| 22 |
*/ |
| 23 |
|
| 24 |
/* |
| 25 |
* Help window for xdvik, using the `topics' window framework. |
| 26 |
*/ |
| 27 |
|
| 28 |
#include "xdvi-config.h" |
| 29 |
#include "xdvi.h" |
| 30 |
#include "version.h" |
| 31 |
|
| 32 |
#include <X11/Xatom.h> |
| 33 |
#include <X11/Intrinsic.h> |
| 34 |
#include <X11/StringDefs.h> |
| 35 |
|
| 36 |
#if MOTIF |
| 37 |
# include <Xm/Xm.h> |
| 38 |
# include <Xm/Form.h> |
| 39 |
# include <Xm/Frame.h> |
| 40 |
# include <Xm/Text.h> |
| 41 |
# include <Xm/Protocols.h> |
| 42 |
#else /* MOTIF */ |
| 43 |
# include <X11/Xaw/Paned.h> |
| 44 |
# include <X11/Xaw/Form.h> |
| 45 |
# include <X11/Xaw/AsciiText.h> |
| 46 |
#endif /* MOTIF */ |
| 47 |
|
| 48 |
#include <sys/stat.h> |
| 49 |
#include <stdio.h> |
| 50 |
#include <unistd.h> |
| 51 |
|
| 52 |
#include "message-window.h" |
| 53 |
#include "util.h" |
| 54 |
#include "x_util.h" |
| 55 |
#include "string-utils.h" |
| 56 |
#include "topic-window.h" |
| 57 |
#include "help-window.h" |
| 58 |
|
| 59 |
#if HAVE_XKB_BELL_EXT |
| 60 |
# include <X11/XKBlib.h> |
| 61 |
# define XdviBell(display, window, percent) \ |
| 62 |
XkbBell(display, window, percent, (Atom) None) |
| 63 |
#else |
| 64 |
# define XdviBell(display, window, percent) XBell(display, percent) |
| 65 |
#endif |
| 66 |
|
| 67 |
/* missing features that will be listed in the help window */ |
| 68 |
#if !XDVI_XT_TIMER_HACK |
| 69 |
#define HAVE_MISSING_FEATURES 1 |
| 70 |
#endif |
| 71 |
|
| 72 |
#if !HAVE_REGEX_H |
| 73 |
#define HAVE_MISSING_FEATURES 1 |
| 74 |
#endif |
| 75 |
|
| 76 |
/* |
| 77 |
* The number of help topics - must larger or equal to actual number of items, |
| 78 |
* also keep in sync with elements resource.help_* !!! |
| 79 |
*/ |
| 80 |
#define NUM_HELP_TOPICS 16 |
| 81 |
|
| 82 |
/* |
| 83 |
* helper routines |
| 84 |
*/ |
| 85 |
|
| 86 |
static Widget |
| 87 |
create_help_text(Widget parent, const char *name, const char *value) |
| 88 |
{ |
| 89 |
Widget text; |
| 90 |
#if MOTIF |
| 91 |
Arg args[20]; |
| 92 |
int n = 0; |
| 93 |
|
| 94 |
XtSetArg(args[n], XmNeditable, False); n++; |
| 95 |
XtSetArg(args[n], XmNcursorPositionVisible, False); n++; |
| 96 |
XtSetArg(args[n], XmNvalue, value); n++; |
| 97 |
XtSetArg(args[n], XmNeditMode, XmMULTI_LINE_EDIT); n++; |
| 98 |
XtSetArg(args[n], XmNwordWrap, True); n++; |
| 99 |
XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++; |
| 100 |
/* XtSetArg(args[n], XmNtopWidget, top_widget); n++; */ |
| 101 |
/* XtSetArg(args[n], XmNtopOffset, 10); n++; */ |
| 102 |
XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++; |
| 103 |
XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++; |
| 104 |
XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); n++; |
| 105 |
XtSetArg(args[n], XmNscrollingPolicy, XmAUTOMATIC); n++; |
| 106 |
XtSetArg(args[n], XmNscrollBarDisplayPolicy, XmAS_NEEDED); n++; |
| 107 |
|
| 108 |
text = XmCreateScrolledText(parent, (char *)name, args, n); |
| 109 |
|
| 110 |
XtManageChild(text); |
| 111 |
#else /* MOTIF */ |
| 112 |
text = XtVaCreateManagedWidget(name, asciiTextWidgetClass, parent, |
| 113 |
/* XtNfromVert, top_widget, */ |
| 114 |
/* XtNvertDistance, 10, */ |
| 115 |
XtNstring, value, |
| 116 |
XtNheight, 400, |
| 117 |
XtNwidth, 500, |
| 118 |
/* resizing of pane by user isn't needed */ |
| 119 |
XtNshowGrip, False, |
| 120 |
XtNscrollVertical, XawtextScrollAlways, |
| 121 |
XtNscrollHorizontal, XawtextScrollNever, |
| 122 |
XtNeditType, XawtextRead, |
| 123 |
XtNleftMargin, 5, |
| 124 |
NULL); |
| 125 |
XawTextDisplayCaret(text, False); |
| 126 |
#endif /* MOTIF */ |
| 127 |
return text; |
| 128 |
} |
| 129 |
|
| 130 |
|
| 131 |
static void |
| 132 |
get_title_and_summary(const char *str, int len, char **title, char **summary) |
| 133 |
{ |
| 134 |
char *tmp = xmalloc(len + 1); |
| 135 |
char *ptr; |
| 136 |
|
| 137 |
memcpy(tmp, str, len); |
| 138 |
tmp[len] = '\0'; |
| 139 |
|
| 140 |
if ((ptr = strchr(tmp, '\t')) == NULL) { |
| 141 |
XDVI_WARNING((stderr, "Help resource label `%s' doesn't contain a tab character - ignoring it.", tmp)); |
| 142 |
*title = tmp; |
| 143 |
*summary = NULL; |
| 144 |
} |
| 145 |
else { |
| 146 |
*ptr++ = '\0'; |
| 147 |
*title = tmp; |
| 148 |
*summary = ptr; |
| 149 |
} |
| 150 |
|
| 151 |
TRACE_GUI((stderr, "Title, Summary: |%s|%s|", *title, *summary)); |
| 152 |
} |
| 153 |
|
| 154 |
static void |
| 155 |
init_item(const char *resource, const char **resource_default, |
| 156 |
struct topic_info *info, size_t idx, Dimension *width) |
| 157 |
{ |
| 158 |
const char *ptr = NULL; |
| 159 |
char *widget_text = NULL; |
| 160 |
Widget help_form; |
| 161 |
Widget text; |
| 162 |
struct topic_item *item = &(info->items[idx]); |
| 163 |
char *translation_str = get_string_va("#override \n" |
| 164 |
"<Key>q:close-topic-window(%p)\n" |
| 165 |
#ifdef MOTIF |
| 166 |
"<Key>osfCancel:close-topic-window(%p)\n" |
| 167 |
#else |
| 168 |
"<Key>Escape:close-topic-window(%p)\n" |
| 169 |
#endif |
| 170 |
"<Key>Return:close-topic-window(%p)", |
| 171 |
info, info, info); |
| 172 |
|
| 173 |
if (resource != NULL) { |
| 174 |
if ((ptr = strchr(resource, '\n')) == NULL) { |
| 175 |
XDVI_WARNING((stderr, "Help resource text `%s' doesn't contain a newline character.", resource)); |
| 176 |
ptr = resource; |
| 177 |
} |
| 178 |
else |
| 179 |
ptr++; |
| 180 |
get_title_and_summary(resource, ptr - resource - 1, |
| 181 |
&(item->topic), &(item->title)); |
| 182 |
} |
| 183 |
else { /* resource not set; copy resource_default into malloc()ed widget_text: */ |
| 184 |
size_t size = 0, alloc_len = 0, offset; |
| 185 |
const size_t alloc_step = 1024; |
| 186 |
int i; |
| 187 |
|
| 188 |
for (i = 0; resource_default[i] != NULL; i++) { |
| 189 |
if (i == 0) { /* special case */ |
| 190 |
get_title_and_summary(resource_default[i], strlen(resource_default[i]) - 1, |
| 191 |
&(item->topic), &(item->title)); |
| 192 |
} |
| 193 |
else { |
| 194 |
offset = size; |
| 195 |
size += strlen(resource_default[i]); |
| 196 |
/* |
| 197 |
* allocate chunks of `alloc_step' to avoid frequent calls to malloc. |
| 198 |
* `alloc_len' is always 1 more than `size', for the terminating NULL character. |
| 199 |
*/ |
| 200 |
while (size + 1 > alloc_len) { |
| 201 |
alloc_len += alloc_step; |
| 202 |
widget_text = xrealloc(widget_text, alloc_len); |
| 203 |
} |
| 204 |
memcpy(widget_text + offset, resource_default[i], size - offset); |
| 205 |
} |
| 206 |
} |
| 207 |
/* null-terminate string */ |
| 208 |
widget_text[size] = '\0'; |
| 209 |
} |
| 210 |
|
| 211 |
help_form = XtVaCreateManagedWidget("help_form", |
| 212 |
#if MOTIF |
| 213 |
xmFormWidgetClass, info->right_form, |
| 214 |
XmNtopAttachment, XmATTACH_FORM, |
| 215 |
XmNleftAttachment, XmATTACH_FORM, |
| 216 |
XmNrightAttachment, XmATTACH_FORM, |
| 217 |
XmNbottomAttachment, XmATTACH_FORM, |
| 218 |
#else |
| 219 |
formWidgetClass, info->right_form, |
| 220 |
XtNborderWidth, 0, |
| 221 |
XtNdefaultDistance, 0, |
| 222 |
#endif |
| 223 |
NULL); |
| 224 |
item->widget = help_form; |
| 225 |
if (ptr != NULL) { |
| 226 |
text = create_help_text(help_form, "help_text", ptr); |
| 227 |
} |
| 228 |
else { |
| 229 |
text = create_help_text(help_form, "help_text", widget_text); |
| 230 |
free(widget_text); |
| 231 |
} |
| 232 |
XtOverrideTranslations(text, XtParseTranslationTable(translation_str)); |
| 233 |
free(translation_str); |
| 234 |
#if !MOTIF |
| 235 |
{ |
| 236 |
Dimension w; |
| 237 |
XtVaGetValues(text, XtNwidth, &w, NULL); |
| 238 |
if (w > *width) |
| 239 |
*width = w; |
| 240 |
} |
| 241 |
#else |
| 242 |
UNUSED(width); |
| 243 |
#endif |
| 244 |
} |
| 245 |
|
| 246 |
static void |
| 247 |
initialize_items(struct topic_info *info) |
| 248 |
{ |
| 249 |
size_t k; |
| 250 |
Dimension width; |
| 251 |
|
| 252 |
/* |
| 253 |
* Define fallbacks: default_xyz is used as fallback text if |
| 254 |
* X resource xyz isn't specified. |
| 255 |
* |
| 256 |
* We use arrays of strings rather than simple strings because of C's |
| 257 |
* limitations on maximum string length; but since the resource needs to |
| 258 |
* be a simple `char *', these have to be copied into larger buffers |
| 259 |
* later on (which is a bit wasteful to space). OTOH, splitting the |
| 260 |
* strings into smaller pieces would make them hard to deal with as |
| 261 |
* X resources. They are defined as static so that they are initialized |
| 262 |
* only once. |
| 263 |
* |
| 264 |
* Last elem of each array is NULL for ease of looping through it. |
| 265 |
* |
| 266 |
* Advantages of this method vs. putting the help texts into a file: |
| 267 |
* - couldn't use #ifdef's as easily |
| 268 |
* - would need to invent our own file format |
| 269 |
* - file searching is more error-prone (needs to be installed etc.) |
| 270 |
*/ |
| 271 |
|
| 272 |
static const char *default_help_general[] = { |
| 273 |
"Introduction\tAbout this version of xdvi\n", |
| 274 |
"This is xdvik, version ", |
| 275 |
XDVI_TERSE_VERSION_INFO |
| 276 |
".\nThe program's homepage is located at:\n", |
| 277 |
"http://sourceforge.net/projects/xdvi\n", |
| 278 |
"where you can find updates, report bugs and submit feature requests.\n", |
| 279 |
"\n", |
| 280 |
"\n", |
| 281 |
"Xdvi has many command-line options, too numerous to be listed here;\n", |
| 282 |
"see the man page for a full description.\n", |
| 283 |
"\n", |
| 284 |
"The most important key bindings are listed in the help sections shown\n", |
| 285 |
"in the left window.\n", |
| 286 |
"\n", |
| 287 |
"Note: Unless a key binding also has an uppercase version,\n", |
| 288 |
"all bindings are case-insensitive.\n\n", |
| 289 |
"\n", |
| 290 |
"The major parts of Xdvik are licensed under the X Consortium license.\n", |
| 291 |
"Parts (encoding.c) are licensed under the GNU General Public License.\n", |
| 292 |
"Xdvik uses the following libraries:\n", |
| 293 |
"- The kpathsea library, licensed in part under the GNU General Public\n", |
| 294 |
" License, in part under the GNU Library General Public License.\n", |
| 295 |
"- freetype2, licensed under the GNU General Public License.\n", |
| 296 |
"There is NO WARRANTY of anything.\n", |
| 297 |
"\n", |
| 298 |
"Built using these configure options:\n", |
| 299 |
#if MOTIF |
| 300 |
"- Motif toolkit (", |
| 301 |
XmVERSION_STRING, |
| 302 |
")\n", |
| 303 |
#else |
| 304 |
"- Athena toolkit\n", |
| 305 |
#endif |
| 306 |
#ifdef A4 |
| 307 |
"- paper: a4, units cm\n", |
| 308 |
#else |
| 309 |
"- paper: letter, units inches\n", |
| 310 |
#endif |
| 311 |
#ifdef GREY |
| 312 |
"- anti-aliasing (grey) enabled\n", |
| 313 |
#endif |
| 314 |
#if FREETYPE |
| 315 |
"- freetype2 (direct rendering of PS fonts) enabled\n", |
| 316 |
#endif |
| 317 |
#if HAVE_ICONV_H |
| 318 |
"- Iconv support compiled in\n", |
| 319 |
#if USE_LANGINFO |
| 320 |
"- Langinfo support compiled in\n", |
| 321 |
#else |
| 322 |
"- Langinfo support not compiled in\n", |
| 323 |
#endif |
| 324 |
#else |
| 325 |
"- Iconv/langinfo support not compiled in\n", |
| 326 |
#endif |
| 327 |
#ifdef TEXXET |
| 328 |
"- left-to-right typesetting (TeXXeT) support enabled\n", |
| 329 |
#endif |
| 330 |
#ifdef USE_GF |
| 331 |
"- gf file support enabled\n", |
| 332 |
#endif |
| 333 |
#if HAVE_MISSING_FEATURES |
| 334 |
"\n", |
| 335 |
"Features not available on this platform:\n", |
| 336 |
#if !XDVI_XT_TIMER_HACK |
| 337 |
"- Could not redefine XtAppAddTimeOut(); some widgets may\n", |
| 338 |
" not be updated until the mouse is moved.\n", |
| 339 |
#endif |
| 340 |
#if !HAVE_REGEX_H |
| 341 |
"- regex.h header not available, regular expression support\n", |
| 342 |
" in string search is disabled.\n", |
| 343 |
#endif |
| 344 |
#endif /* HAVE_MISSING_FEATURES */ |
| 345 |
NULL |
| 346 |
}; |
| 347 |
|
| 348 |
static const char *default_help_hypertex[] = { |
| 349 |
"Hyperlinks\tNavigating links\n", |
| 350 |
"Whenever the mouse is positioned on a link, the cursor changes\n", |
| 351 |
"to a `hand' shape and the target of the link is displayed\n", |
| 352 |
"in the statusline at the bottom of the window.\n", |
| 353 |
"\n", |
| 354 |
"The following keybindings are pre-configured:\n", |
| 355 |
"\n", |
| 356 |
"Mouse-1\n", |
| 357 |
" Follow the link at the cursor position.\n", |
| 358 |
" If the link target is not a DVI file, try to launch\n", |
| 359 |
" an application to view the file.\n", |
| 360 |
"Mouse-2\n", |
| 361 |
" Open a new xdvi window displaying the link\n", |
| 362 |
" at the cursor position if the link is a DVI file;\n", |
| 363 |
" else, try to launch an application to view the file.\n", |
| 364 |
"B\n", |
| 365 |
" Go back to the previous hyperlink in the history.\n", |
| 366 |
"F\n", |
| 367 |
" Go forward to the next hyperlink in the history.\n", |
| 368 |
"\n", |
| 369 |
"By default, the hyperlinks are displayed in the colors \n", |
| 370 |
"`linkColor' and `visitedLinkColor' (for visited links) and \n", |
| 371 |
"underlined in the same colors. This can be customized \n", |
| 372 |
"by setting the resource or command-line option `linkstyle' \n", |
| 373 |
"to a value between 0 and 3, which have the following meaning:\n", |
| 374 |
" 0: no highlighting of links,\n", |
| 375 |
" 1: underline links,\n", |
| 376 |
" 2: color links,\n", |
| 377 |
" 3: color and underline links.\n\n", |
| 378 |
NULL |
| 379 |
}; |
| 380 |
|
| 381 |
static const char *default_help_othercommands[] = { |
| 382 |
"Other Commands\tMiscellaneous other commands\n", |
| 383 |
"Ctrl-f", |
| 384 |
#if MOTIF |
| 385 |
", toolbar button 12\n", |
| 386 |
#else |
| 387 |
"\n", |
| 388 |
#endif |
| 389 |
" Opens a dialog window to search for a text string\n", |
| 390 |
" in the DVI file.\n", |
| 391 |
"\n", |
| 392 |
"Ctrl-g\n", |
| 393 |
" Search for the next string match.\n", |
| 394 |
"\n", |
| 395 |
"Ctrl-l\n", |
| 396 |
" Toggles fullscreen mode (which may not work with your\n", |
| 397 |
" window manager/desktop).\n", |
| 398 |
"\n", |
| 399 |
"Ctrl-o", |
| 400 |
#if MOTIF |
| 401 |
", toolbar button 1\n", |
| 402 |
#else |
| 403 |
"\n", |
| 404 |
#endif |
| 405 |
" Opens a popup window to select another DVI file.\n", |
| 406 |
" With a prefix argument `n', the `n'th file from the file history\n", |
| 407 |
" is opened instead.\n", |
| 408 |
"\n", |
| 409 |
"Ctrl-p", |
| 410 |
#if MOTIF |
| 411 |
", toolbar button 11\n", |
| 412 |
#else |
| 413 |
"\n", |
| 414 |
#endif |
| 415 |
" Opens a popup window for printing the DVI file, or parts of it.\n", |
| 416 |
"\n", |
| 417 |
"Ctrl-r or Clear\n", |
| 418 |
" Redisplays the current page.\n", |
| 419 |
"\n", |
| 420 |
"Ctrl-s\n", |
| 421 |
" Opens a popup window for saving the DVI file, or parts of it.\n", |
| 422 |
"\n", |
| 423 |
"G\n", |
| 424 |
" Toggles the use of greyscale anti-aliasing for\n", |
| 425 |
" displaying shrunken bitmaps. In addition, the key\n", |
| 426 |
" sequences `0G' and `1G' clear and set this flag,\n", |
| 427 |
" respectively. See also the -nogrey option.\n", |
| 428 |
"\n", |
| 429 |
"k\n", |
| 430 |
" Normally when xdvi switches pages, it moves to the home\n", |
| 431 |
" position as well. The `k' keystroke toggles a `keep-\n", |
| 432 |
" position' flag which, when set, will keep the same\n", |
| 433 |
" position when moving between pages. Also `0k' and `1k'\n", |
| 434 |
" clear and set this flag, respectively. See also the\n", |
| 435 |
" -keep option.\n", |
| 436 |
"\n", |
| 437 |
"M\n", |
| 438 |
" Sets the margins so that the point currently under the\n", |
| 439 |
" cursor is the upper left-hand corner of the text in the\n", |
| 440 |
" page. Note that this command itself does not move the\n", |
| 441 |
" image at all. For details on how the margins are used,\n", |
| 442 |
" see the -margins option.\n", |
| 443 |
"\n", |
| 444 |
"P\n", |
| 445 |
" ``This is page number n.'' This can be used to make\n", |
| 446 |
" the `g' keystroke refer to a different page number.\n", |
| 447 |
" (See also `Options->Use TeX Page Numbers' and the\n", |
| 448 |
" `T' keystroke).\n", |
| 449 |
"\n", |
| 450 |
"R", |
| 451 |
#if MOTIF |
| 452 |
", toolbar button 2\n", |
| 453 |
#else |
| 454 |
"\n", |
| 455 |
#endif |
| 456 |
" Forces the DVI file to be reread.\n", |
| 457 |
"\n", |
| 458 |
"s\n", |
| 459 |
" Changes the shrink factor to the given number.\n", |
| 460 |
" If no number is given, the smallest factor that makes the\n", |
| 461 |
" entire page fit in the window will be used. (Margins\n", |
| 462 |
" are ignored in this computation.)\n", |
| 463 |
"\n", |
| 464 |
"S\n", |
| 465 |
" Sets the density factor to be used when shrinking\n", |
| 466 |
" bitmaps. This should be a number between 0 and 100;\n", |
| 467 |
" higher numbers produce lighter characters.\n", |
| 468 |
"\n", |
| 469 |
"t\n", |
| 470 |
" Switches to the next unit in a sorted list of TeX dimension\n", |
| 471 |
" units for the popup magnifier ruler and `Ruler mode' (see the\n", |
| 472 |
" section `Modes').\n" |
| 473 |
"\n", |
| 474 |
"V\n", |
| 475 |
" Toggles Ghostscript anti-aliasing. Also `0V' and `1V' clear\n", |
| 476 |
" and enables this mode, respectively. See also the the\n", |
| 477 |
" -gsalpha option.\n", |
| 478 |
"\n", |
| 479 |
"\n", |
| 480 |
"v\n", |
| 481 |
" Toggles between several modes of displaying postscript specials:\n", |
| 482 |
" Display specials, display specials with their bounding box\n", |
| 483 |
" (if available), and display bounding boxes only (if available).\n", |
| 484 |
" The prefix arguments 1, 2 and 0 also allow you to select one of\n" |
| 485 |
" these states directly.\n", |
| 486 |
"\n", |
| 487 |
"x\n", |
| 488 |
" Toggles expert mode (in which ", |
| 489 |
#if MOTIF |
| 490 |
"the menu bar, the toolbar\n", |
| 491 |
#else |
| 492 |
"the menu buttons,\n", |
| 493 |
#endif |
| 494 |
" the page list and the statusline do not appear).\n", |
| 495 |
" `1x' toggles the display of the statusline at the bottom of the window.\n", |
| 496 |
" `2x' toggles the scrollbars,\n", |
| 497 |
#if MOTIF |
| 498 |
" `3x' toggles the page list,\n", |
| 499 |
" `4x' toggles the toolbar,\n", |
| 500 |
" `5x' toggles the menu bar.\n", |
| 501 |
#else |
| 502 |
" `3x' toggles the page list and menu buttons.\n", |
| 503 |
#endif |
| 504 |
"\n", |
| 505 |
"Ctrl-+", |
| 506 |
#if MOTIF |
| 507 |
", toolbar button 9\n", |
| 508 |
#else |
| 509 |
"\n", |
| 510 |
#endif |
| 511 |
" Makes the display of the page larger (zooms in).\n", |
| 512 |
"\n", |
| 513 |
"Ctrl--", |
| 514 |
#if MOTIF |
| 515 |
", toolbar button 10\n", |
| 516 |
#else |
| 517 |
"\n", |
| 518 |
#endif |
| 519 |
" Makes the display of the page smaller (zooms out).\n", |
| 520 |
"\n", |
| 521 |
"Alt-Ctrl-+", |
| 522 |
#if MOTIF |
| 523 |
", toolbar button 17\n", |
| 524 |
#else |
| 525 |
"\n", |
| 526 |
#endif |
| 527 |
" Makes the fonts darker (by adding to the gamma value).\n", |
| 528 |
"\n", |
| 529 |
"Alt-Ctrl--", |
| 530 |
#if MOTIF |
| 531 |
", toolbar button 18\n", |
| 532 |
#else |
| 533 |
"\n", |
| 534 |
#endif |
| 535 |
" Makes the fonts lighter (by subtracting from the gamma\n", |
| 536 |
" value).\n", |
| 537 |
"\n", |
| 538 |
NULL |
| 539 |
}; |
| 540 |
|
| 541 |
static const char *default_help_marking[] = { |
| 542 |
"Printing and Saving\tMarking, printing and saving pages\n", |
| 543 |
"The `Save' and `Print' dialogs allow you to save or print all,\n", |
| 544 |
"pages, a range of pages, or all marked pages from a DVI file.\n", |
| 545 |
"\n", |
| 546 |
"Note that the page numbers for the `From ... to ...' range\n", |
| 547 |
"refer to physical pages, not TeX pages (compare the option\n", |
| 548 |
"`Use TeX Page Numbers' and the `T' keystroke).\n", |
| 549 |
"\n", |
| 550 |
"To mark a page or a range of pages, use one of the folllowing\n", |
| 551 |
"methods:\n", |
| 552 |
"- Click on the page in the page list with Mouse Button 2 to mark\n", |
| 553 |
" a single page, or drag the mouse while holding down Button 2\n", |
| 554 |
" to mark a range of pages.\n", |
| 555 |
"- Use one of the following key combinations:\n", |
| 556 |
" m: toggle the mark of the current page,\n", |
| 557 |
" 1m toggle the marks of all odd pages,\n", |
| 558 |
" 2m toggle the marks of all even pages,\n", |
| 559 |
" 0m: unmark all pages,\n", |
| 560 |
" Ctrl-n: toggle mark of current page, then move one page forward,\n", |
| 561 |
" Ctrl-u: move one page back, then toggle mark of that page.\n", |
| 562 |
#if MOTIF |
| 563 |
"- Use the toobar buttons 13 to 16 to toggle the marks\n", |
| 564 |
" of odd pages, toggle the marks of even pages, toggle the mark\n", |
| 565 |
" of the current page, or unmark all pages, respectively.\n", |
| 566 |
#endif |
| 567 |
"\n", |
| 568 |
"If the X resource or command line option `paper' has been used,\n", |
| 569 |
"its value is inserted into the `Dvips Options' field of the printing\n", |
| 570 |
"dialog so that the appropriate options can be passed to dvips.\n", |
| 571 |
"This doesn't happen if the paper size has been specified explicitly\n", |
| 572 |
"in the DVI file (e.g. by using the LaTeX `geometry' package).\n", |
| 573 |
"Note that not all of the paper options used by xdvi\n", |
| 574 |
"may be understood by dvips; dvips will ignore the option\n", |
| 575 |
"in that case, and will use its default paper setting.\n", |
| 576 |
NULL |
| 577 |
}; |
| 578 |
|
| 579 |
static const char *default_help_pagemotion[] = { |
| 580 |
"Page Motion\tMoving around in the document\n", |
| 581 |
"\n", |
| 582 |
"[", |
| 583 |
#if MOTIF |
| 584 |
", toolbar button 7\n", |
| 585 |
#else |
| 586 |
"\n", |
| 587 |
#endif |
| 588 |
" Moves back one item in the page history. With a prefix\n", |
| 589 |
" argument n, move back n history items.\n" |
| 590 |
"\n", |
| 591 |
"]", |
| 592 |
#if MOTIF |
| 593 |
", toolbar button 8\n", |
| 594 |
#else |
| 595 |
"\n", |
| 596 |
#endif |
| 597 |
" Moves forward one item in the page history. With a prefix\n", |
| 598 |
" argument n, move forward n history items.\n" |
| 599 |
"\n", |
| 600 |
"Ctr-[\n", |
| 601 |
" Deletes current item in the page history and move\n", |
| 602 |
" to the history item before the deleted one. With a prefix\n", |
| 603 |
" argument n, delete n previous history items.\n", |
| 604 |
"\n", |
| 605 |
"Ctr-]\n", |
| 606 |
" Deletes current item in the page history and move\n", |
| 607 |
" to the history item after the deleted one. With a prefix\n", |
| 608 |
" argument n, delete n next history items.\n", |
| 609 |
"\n", |
| 610 |
"n or f or Return or LineFeed or PgDn", |
| 611 |
#if MOTIF |
| 612 |
", toolbar button 5\n", |
| 613 |
#else |
| 614 |
"\n", |
| 615 |
#endif |
| 616 |
" Moves to the next page (or to the nth next page if a\n", |
| 617 |
" number is given).\n", |
| 618 |
"\n", |
| 619 |
"Space key\n", |
| 620 |
" Moves down or to the next page.", |
| 621 |
"\n", |
| 622 |
"p or b or Ctrl-h or BackSpace or PgUp", |
| 623 |
#if MOTIF |
| 624 |
", toolbar button 4\n", |
| 625 |
#else |
| 626 |
"\n", |
| 627 |
#endif |
| 628 |
" Moves to the previous page (or back n pages).\n", |
| 629 |
"\n", |
| 630 |
"Del key\n", |
| 631 |
" Moves up on the page or to the previous page.", |
| 632 |
"\n", |
| 633 |
"Up-arrow\n", |
| 634 |
" Scrolls page up.\n", |
| 635 |
"\n", |
| 636 |
"Down-arrow\n", |
| 637 |
" Scrolls page down.\n", |
| 638 |
"u\n", |
| 639 |
" Moves page up two thirds of a window-full.\n", |
| 640 |
"\n", |
| 641 |
"d\n", |
| 642 |
" Moves page down two thirds of a window-full.\n", |
| 643 |
"\n", |
| 644 |
"Left-arrow\n", |
| 645 |
" Scrolls page left.\n", |
| 646 |
"\n", |
| 647 |
"Right-arrow\n", |
| 648 |
" Scrolls page right.\n", |
| 649 |
"\n", |
| 650 |
"l\n", |
| 651 |
" Moves page left two thirds of a window-full.\n", |
| 652 |
"\n", |
| 653 |
"r\n", |
| 654 |
" Moves page right two thirds of a window-full.\n", |
| 655 |
"\n", |
| 656 |
"T\n", |
| 657 |
" Toggle the use of TeX page numbers instead of physical\n", |
| 658 |
" pages for the page list and the `g' command.\n", |
| 659 |
" (See also the `Options -> Use TeX Pages' menu.)\n", |
| 660 |
"\n", |
| 661 |
"g\n", |
| 662 |
" Moves to the page with the given number. Initially,\n", |
| 663 |
" the first page is assumed to be page number 1, but this\n", |
| 664 |
" can be changed with the `P' keystroke, described in the\n", |
| 665 |
" section `Other Commands'. If no page number is given,\n", |
| 666 |
" it moves to the last page.\n", |
| 667 |
"\n", |
| 668 |
"<, Ctrl-Home", |
| 669 |
#if MOTIF |
| 670 |
", toolbar button 3\n", |
| 671 |
#else |
| 672 |
"\n", |
| 673 |
#endif |
| 674 |
" Moves to first page in the document.\n", |
| 675 |
"\n", |
| 676 |
">, Ctrl-End", |
| 677 |
#if MOTIF |
| 678 |
", toolbar button 6\n", |
| 679 |
#else |
| 680 |
"\n", |
| 681 |
#endif |
| 682 |
" Moves to last page in the document.\n", |
| 683 |
"\n", |
| 684 |
"^\n", |
| 685 |
" Move to the ``home'' position of the page. This is\n", |
| 686 |
" normally the upper left-hand corner of the page,\n", |
| 687 |
" depending on the margins set via the -margins option.\n", |
| 688 |
"\n", |
| 689 |
"Home\n", |
| 690 |
" Move to the ``home'' position of the page (the upper\n", |
| 691 |
" left-hand corner), or to the top of the page if the `keep'\n", |
| 692 |
" flag is set.\n", |
| 693 |
"\n", |
| 694 |
"End\n", |
| 695 |
" Move to the end position of the page (the lower\n", |
| 696 |
" right-hand corner), or to the bottom of the page if the\n", |
| 697 |
" `keep' flag is set.\n", |
| 698 |
"\n", |
| 699 |
"c\n", |
| 700 |
" Moves the page so that the point currently beneath the\n", |
| 701 |
" cursor is moved to the middle of the window. It also\n", |
| 702 |
" warps the cursor to the same place.\n", |
| 703 |
"\n", |
| 704 |
NULL |
| 705 |
}; |
| 706 |
|
| 707 |
|
| 708 |
static const char *default_help_mousebuttons[] = { |
| 709 |
"Mouse Buttons\tActions bound to the mouse buttons\n", |
| 710 |
"The mouse buttons can be customized just like the keys;\n", |
| 711 |
"however the bindings cannot be intermixed (since\n", |
| 712 |
"a mouse event always requires the cursor location\n", |
| 713 |
"to be present, which a key event doesn't).\n", |
| 714 |
"The default bindings are as follows:\n" |
| 715 |
"\n", |
| 716 |
"Buttons 1-3\n", |
| 717 |
" Pops up magnifier windows of different sizes.\n", |
| 718 |
" When the mouse is over a hyperlink, the link overrides\n", |
| 719 |
" the magnifier. In that case, Button 1 jumps to the link\n", |
| 720 |
" in the current xdvi window, Button 2 opens the link target\n", |
| 721 |
" in a new instance of xdvi.\n", |
| 722 |
" In `Ruler Mode', Button1 shows/drags the ruler instead;\n", |
| 723 |
" in `Text Selection Mode', Button1 can be used to select\n", |
| 724 |
" a rectangular region of text from the DVI file.\n", |
| 725 |
"\n", |
| 726 |
"Shift-Button1 to Shift-Button3\n", |
| 727 |
" Drag the page in each direction (Button 1), vertically\n", |
| 728 |
" only (Button 2) or horizontally only (Button 3).\n", |
| 729 |
"\n", |
| 730 |
"Ctrl-Button1\n", |
| 731 |
" Invoke a reverse search for the text on the cursor\n", |
| 732 |
" location (see the section SOURCE SPECIALS for more\n", |
| 733 |
" information on this).\n", |
| 734 |
"\n", |
| 735 |
"The buttons 4 and 5 (wheel up and down for wheel mice)\n", |
| 736 |
"scroll the page up and down respectively, or jump to the\n", |
| 737 |
"next/previous page when the mouse is over the page list.", |
| 738 |
"\n", |
| 739 |
"In the page list, Button 2 toggles the mark a page (see\n", |
| 740 |
"section `Marking Pages'); moving the mouse while holding\n", |
| 741 |
"Button 2 lets you toggle a range of pages.\n", |
| 742 |
"\n", |
| 743 |
NULL |
| 744 |
}; |
| 745 |
|
| 746 |
static const char *default_help_sourcespecials[] = { |
| 747 |
"Source Specials\tNavigating between the TeX and the DVI file\n", |
| 748 |
"Some TeX implementations have an option to automatically\n", |
| 749 |
"include so-called `source specials' into a DVI file. These\n", |
| 750 |
"contain the line number and the filename of the TeX source\n", |
| 751 |
"and make it possible to go from a DVI file to the\n", |
| 752 |
"(roughly) corresponding place in the TeX source and back\n", |
| 753 |
"(this is also called `reverse search' and `forward search').\n", |
| 754 |
"\n", |
| 755 |
"On the TeX side, you need a TeX version that supports the `-src'\n", |
| 756 |
"option (e.g. teTeX >= 2.0) or a macro package like srcltx.sty\n", |
| 757 |
"to insert the specials into the DVI file.\n", |
| 758 |
"\n", |
| 759 |
"Source special mode can be customized for various editors\n", |
| 760 |
"by using the command line option \"-editor\" or one of the\n", |
| 761 |
"environment variables \"XEDITOR\", \"VISUAL\" or \"EDITOR\".\n", |
| 762 |
"See the xdvi man page on the \"-editor\" option for details\n", |
| 763 |
"and examples.\n", |
| 764 |
"\n", |
| 765 |
"Forward search can be performed by a program (i.e. your editor)\n", |
| 766 |
"invoking xdvi with the \"-sourceposition\" option like this:\n", |
| 767 |
"xdvi -sourceposition \"<line> <filename>\" <main file>\n", |
| 768 |
"If there is already an instance of xdvi running that displays\n", |
| 769 |
"<main file>, it will try to open the page specified by\n", |
| 770 |
"<line> and <filename> an highlight this location on the page.\n", |
| 771 |
"Else, a new instance of xdvi will be started that will try to\n", |
| 772 |
"do the same.\n", |
| 773 |
"\n", |
| 774 |
"The following keybindings are pre-configured:\n", |
| 775 |
"\n", |
| 776 |
"Ctrl-Mouse1\n", |
| 777 |
" [source-special()] Invoke the editor (the value\n", |
| 778 |
" of the \"editor\" resource ) to display the line in the\n", |
| 779 |
" TeX file corresponding to special at cursor position.\n", |
| 780 |
"\n", |
| 781 |
"Ctrl-v\n", |
| 782 |
" [show-source-specials()] Show bounding boxes for every\n", |
| 783 |
" source special on the current page, and print the strings\n", |
| 784 |
" contained in these specials to stderr. With prefix 1,\n", |
| 785 |
" show every bounding box on the page (for debugging purposes).\n", |
| 786 |
"\n", |
| 787 |
"Ctrl-x\n", |
| 788 |
" [source-what-special()] Display information about the\n", |
| 789 |
" source special next to the cursor, similar to\n", |
| 790 |
" \"source-special()\", but without actually invoking\n", |
| 791 |
" the editor (for debugging purposes).\n", |
| 792 |
"\n", |
| 793 |
NULL |
| 794 |
}; |
| 795 |
|
| 796 |
static const char *default_help_modes[] = { |
| 797 |
"Mouse Modes\tMagnifier Mode, Ruler Mode and Text Selection Mode\n", |
| 798 |
"The keystroke Ctrl-m [switch-mode()] switches between\n", |
| 799 |
"three different bindings for Mouse-1, which can also be\n", |
| 800 |
"activated via the Modes menu (in Motif, this is a submenu\n", |
| 801 |
"of the Options menu). The default mode at startup can be\n", |
| 802 |
"customized via the X resource `mouseMode' or the command-line\n", |
| 803 |
"option `-mousemode'. The default startup mode is Magnifier Mode.\n", |
| 804 |
"\n", |
| 805 |
"Note: The modes are activated by changing the magnifier()\n", |
| 806 |
"action. Switching the mode will not work if Mouse-1 has\n", |
| 807 |
"been customized to an action sequence that does not contain\n", |
| 808 |
"the magnifier() action.\n", |
| 809 |
"\n", |
| 810 |
"Magnifier Mode\n", |
| 811 |
"\n", |
| 812 |
" In this mode, the mouse buttons 1 to 5 will pop up a\n", |
| 813 |
" ``magnifying glass'' that shows an unshrunken image of\n", |
| 814 |
" the page (i.e. an image at the resolution determined by\n", |
| 815 |
" the option/X resource pixels or mfmode) at varying sizes.\n", |
| 816 |
" When the magnifier is moved, small ruler-like tick marks\n", |
| 817 |
" are displayed at the edges of the magnifier (unless\n", |
| 818 |
" the X resource delayRulers is set to false, in which case\n", |
| 819 |
" the tick marks are always displayed).\n", |
| 820 |
"\n", |
| 821 |
" The unit of the marks is determined by the X resource\n", |
| 822 |
" `tickUnits' (mm by default). This unit can be changed at\n", |
| 823 |
" runtime via the action `switch-magnifier-units()', by\n", |
| 824 |
" default bound to the keystroke `t' (see the description\n", |
| 825 |
" of that key, and of `switch-magnifier-units()' for more\n", |
| 826 |
" details on the units available). The length of the tick\n", |
| 827 |
" marks can be changed via the X resource `tickLength'\n", |
| 828 |
" (4 by default). A zero or negative value suppresses the\n", |
| 829 |
" tick marks.\n", |
| 830 |
"\n", |
| 831 |
"\n", |
| 832 |
"Text Selection Mode\n", |
| 833 |
"\n", |
| 834 |
" This mode allows you to select a rectangular region of\n", |
| 835 |
" text in the DVI file by holding down Mouse-1 and moving\n", |
| 836 |
" the mouse. The text is put into the X primary selection\n", |
| 837 |
" so that it can be pasted into other X applications with\n", |
| 838 |
" Mouse-2.\n", |
| 839 |
"\n", |
| 840 |
" If xdvi has been compiled with locale, nl_langinfo() and\n", |
| 841 |
" iconv support, the selected text is converted into the\n", |
| 842 |
" character set of the current locale (see the output of\n", |
| 843 |
" `locale -a' for a list of locale settings available on\n", |
| 844 |
" your system). If nl_langinfo() is not available, but\n", |
| 845 |
" iconv is, you can specify the input encoding for iconv\n", |
| 846 |
" via the X resource `textEncoding' (see the output of\n", |
| 847 |
" `iconv -l' for a list of valid encodings). If iconv support\n", |
| 848 |
" is not available, only the encodings ISO-8859-1 and UTF-8\n", |
| 849 |
" are supported (these names are case-insensitive).\n", |
| 850 |
"\n", |
| 851 |
" Note that UTF-8 is the only encoding that can render all\n", |
| 852 |
" characters (e.g. mathematical symbols). If ISO-8859-1 is\n", |
| 853 |
" active, characters that cannot be displayed are replaced\n", |
| 854 |
" by `\' followed by the hexadecimal character code. If a\n", |
| 855 |
" character is not recognized at all, it is replaced by\n", |
| 856 |
" `?'. For other encodings, such characters may trigger\n", |
| 857 |
" iconv error messages.\n", |
| 858 |
"\n", |
| 859 |
" If you want to extract larger portions of text, you\n", |
| 860 |
" can also save selected pages or the entire file in\n", |
| 861 |
" text format from the `File > Save as ...' menu.\n", |
| 862 |
"\n", |
| 863 |
"\n", |
| 864 |
"Ruler Mode\n", |
| 865 |
"\n", |
| 866 |
" This mode provides a simple way of measuring distances\n", |
| 867 |
" on the page. When this mode is activated, the mouse\n", |
| 868 |
" cursor changes into a thin cross, and a larger, cross-\n", |
| 869 |
" shaped ruler is drawn in the highlight color at the\n", |
| 870 |
" mouse location. The ruler doesn't have units attached\n", |
| 871 |
" to it; instead, the current distance between the ruler\n", |
| 872 |
" and the mouse cursor is continously printed to the\n", |
| 873 |
" statusline.\n", |
| 874 |
"\n", |
| 875 |
" When activating Ruler Mode, the ruler is at first\n", |
| 876 |
" attached to the mouse and can be moved around. It can\n", |
| 877 |
" then be positioned at a fixed place by clicking Mouse-1.\n", |
| 878 |
" After that, the mouse cursor can be moved to measure the\n", |
| 879 |
" horizontal (dx), vertical (dy) and direct (shortest)\n", |
| 880 |
" (dr) distance between the ruler center point and the\n", |
| 881 |
" mouse.\n", |
| 882 |
"\n", |
| 883 |
" Clicking Mouse-1 again will move the ruler to the\n", |
| 884 |
" current mouse position, and holding down Mouse-1 will\n", |
| 885 |
" drag the ruler around.\n", |
| 886 |
"\n", |
| 887 |
" In Ruler Mode, the following special keybindings extend\n", |
| 888 |
" or replace the default bindings:\n", |
| 889 |
"\n", |
| 890 |
" o [ruler-snap-origin()] Snap the ruler back to\n", |
| 891 |
" the origin coordinate (0,0).\n", |
| 892 |
"\n", |
| 893 |
" t [overrides switch-magnifier-units()] Toggle\n", |
| 894 |
" between various ruler units, which can be\n", |
| 895 |
" specified by the X resource tickUnits (`mm'\n", |
| 896 |
" by default).\n", |
| 897 |
"\n", |
| 898 |
" P [overrides declare-page-number()] Print the\n", |
| 899 |
" distances shown in the statusline to standard\n", |
| 900 |
" output.\n", |
| 901 |
NULL |
| 902 |
}; |
| 903 |
|
| 904 |
static const char *default_help_search[] = { |
| 905 |
"String Search\tSearching for strings in the DVI file\n", |
| 906 |
"The keystroke Ctrl-f or the menu entry File->Find ...\n", |
| 907 |
"opens a dialog window to search for a text string or a\n", |
| 908 |
"regular expression in the DVI file. The keystroke Ctrl-g\n", |
| 909 |
"jumps to the next match.\n", |
| 910 |
#ifdef MOTIF |
| 911 |
"(With Motif, you can also click on the `Binoculars' symbol\n", |
| 912 |
"in the toolbar.)\n", |
| 913 |
#endif |
| 914 |
"\n", |
| 915 |
#if HAVE_ICONV_H |
| 916 |
#if USE_LANGINFO |
| 917 |
"The search term is converted from the character set specified\n", |
| 918 |
"by the current locale into UTF-8. (See the output of `locale -a'\n", |
| 919 |
"for a list of locale settings available on your system).\n", |
| 920 |
#else /* USE_LANGINFO */ |
| 921 |
"Since langinfo() support is not available on this platform,\n", |
| 922 |
"the character set of the search string should be specified\n", |
| 923 |
"via the X resource/command-line option textEncoding if the\n", |
| 924 |
"encoding is different from iso_8859-1.\n", |
| 925 |
#endif /* USE_LANGINFO */ |
| 926 |
#else /* HAVE_ICONV_H */ |
| 927 |
"Since iconv() support is not available on this platform,\n", |
| 928 |
"the search term should be a string in the encoding specified\n", |
| 929 |
"by the X resource/command-line option textEncoding;\n", |
| 930 |
"currently, only the values iso_8859-1 and utf-8 are suported.\n", |
| 931 |
#endif |
| 932 |
"Internally, the text in the DVI file is represented in\n", |
| 933 |
"UTF-8 encoding (you can view the text by saving the DVI\n", |
| 934 |
"file to a text file in UTF-8 encoding via the `File -> Save As ...'\n", |
| 935 |
"dialog).\n", |
| 936 |
"\n", |
| 937 |
"Ideographic characters from CJKV fonts are treated specially:\n", |
| 938 |
"All white space (spaces and newlines) before and after such\n", |
| 939 |
"characters is ignored in the search string and in the DVI file.\n", |
| 940 |
"\n", |
| 941 |
"To match a newline character, use `\\n' in the search string;\n", |
| 942 |
"to match the string `\\n', use `\\\\n'.\n", |
| 943 |
"\n", |
| 944 |
"If the checkbox Regular Expression is activated, the\n", |
| 945 |
"string is teated as a regular expression in extended POSIX\n", |
| 946 |
"format, with the following properties:\n", |
| 947 |
"\n", |
| 948 |
" a? matches a zero or one times\n", |
| 949 |
"\n", |
| 950 |
" a* matches a zero or more times\n", |
| 951 |
"\n", |
| 952 |
" a+ matches a one or more times. Note that * and + are\n", |
| 953 |
" greedy, i.e. they match the longest possible\n", |
| 954 |
" sub string.\n", |
| 955 |
"\n", |
| 956 |
" a{n} matches a exactly n times\n", |
| 957 |
"\n", |
| 958 |
" a{n,m} matches a at least n and no more than m times\n", |
| 959 |
"\n", |
| 960 |
" a|b matches a or b. Brackets can be used for grouping,\n", |
| 961 |
" e.g.: (a|b)|c.\n", |
| 962 |
"\n", |
| 963 |
" The string matched by the nth group can be referenced\n", |
| 964 |
" by \\n, e.g. \\1 refers to the first match.\n", |
| 965 |
"\n", |
| 966 |
" The characters ^ and $ match the beginning and the end\n", |
| 967 |
" of a line, respectively.\n", |
| 968 |
"\n", |
| 969 |
" [abc] matches any of the letters a, b, c, and [a-z]\n", |
| 970 |
" matches all characters from a to z.\n", |
| 971 |
"\n", |
| 972 |
" The patterns . and [...] without an explicit newline\n", |
| 973 |
" don't match a newline character.\n", |
| 974 |
"\n", |
| 975 |
" Each item in a regular expression can also be one of\n", |
| 976 |
" the following POSIX character classes:\n", |
| 977 |
" [[:alnum:]] [[:alpha:]] [[:blank:]] [[:cntrl:]] [[:digit:]]\n", |
| 978 |
" [[:graph:]] [[:lower:]] [[:print:]] [[:space:]] [[:upper:]]\n", |
| 979 |
"\n", |
| 980 |
" These can be negated by inserting a ^ symbol after the\n", |
| 981 |
" first bracket: [^[:alpha:]]\n", |
| 982 |
"\n", |
| 983 |
" For more details on POSIX regular expressions, see\n", |
| 984 |
" e.g. the IEEE Std 1003.1 available online from:\n", |
| 985 |
"\n", |
| 986 |
" http://www.opengroup.org/onlinepubs/007904975/basedefs/xbd_chap09.html\n", |
| 987 |
"\n", |
| 988 |
" As a non-standard extension, the following Perl-like\n", |
| 989 |
" abbreviations can be used instead of the POSIX classes:\n", |
| 990 |
"\n", |
| 991 |
"\n", |
| 992 |
" Symbol Meaning POSIX Class\n", |
| 993 |
"\n", |
| 994 |
" \\w an alphanumeric character [[:alnum:]]\n", |
| 995 |
" \\W a non-alphanumeric character [^[:alnum:]]\n", |
| 996 |
" \\d a digit character [[:digit:]]\n", |
| 997 |
" \\D a non-digit character [^[:digit:]]\n", |
| 998 |
" \\s a whitespace character [[:space:]]\n", |
| 999 |
" \\S a non-whitespace character [^[:space:]]\n", |
| 1000 |
"\n", |
| 1001 |
" The following characters are special symbols; they\n", |
| 1002 |
" need to be escaped with \\ in order to match them\n", |
| 1003 |
" literally: ( ) [ ] . * ? + ^ $ \\.\n", |
| 1004 |
"\n", |
| 1005 |
"The dialog also provides checkboxes to search backwards,\n", |
| 1006 |
"to match in a case-sensitive manner (the default is to\n", |
| 1007 |
"ignore case, i.e. a search string Test will match both\n", |
| 1008 |
"the strings test and TEST in the DVI file) and to ignore\n", |
| 1009 |
"newlines and hyphens in the DVI file.\n", |
| 1010 |
"\n", |
| 1011 |
NULL |
| 1012 |
}; |
| 1013 |
|
| 1014 |
k = width = 0; |
| 1015 |
|
| 1016 |
init_item(resource.help_general, default_help_general, info, k++, &width); |
| 1017 |
init_item(resource.help_pagemotion, default_help_pagemotion, info, k++, &width); |
| 1018 |
init_item(resource.help_othercommands, default_help_othercommands, info, k++, &width); |
| 1019 |
init_item(resource.help_hypertex, default_help_hypertex, info, k++, &width); |
| 1020 |
init_item(resource.help_mousebuttons, default_help_mousebuttons, info, k++, &width); |
| 1021 |
init_item(resource.help_modes, default_help_modes, info, k++, &width); |
| 1022 |
init_item(resource.help_search, default_help_search, info, k++, &width); |
| 1023 |
init_item(resource.help_pagemotion, default_help_marking, info, k++, &width); |
| 1024 |
init_item(resource.help_sourcespecials, default_help_sourcespecials, info, k++, &width); |
| 1025 |
|
| 1026 |
ASSERT(k < NUM_HELP_TOPICS, "Too many elements in help topics!"); |
| 1027 |
|
| 1028 |
/* NULL-terminate items info */ |
| 1029 |
info->items[k].widget = 0; |
| 1030 |
info->items[k].topic = info->items[k].title = NULL; |
| 1031 |
|
| 1032 |
/* adjust width of topics label to longest text */ |
| 1033 |
#if !MOTIF |
| 1034 |
XtVaSetValues(info->topic_label, XtNwidth, width, NULL); |
| 1035 |
#endif |
| 1036 |
} |
| 1037 |
|
| 1038 |
|
| 1039 |
|
| 1040 |
/* |
| 1041 |
* Pops up the help window. If topic != NULL, also selects the topic. |
| 1042 |
*/ |
| 1043 |
void |
| 1044 |
show_help(Widget toplevel, const char *topic) |
| 1045 |
{ |
| 1046 |
size_t i; |
| 1047 |
static Widget help_shell = 0; |
| 1048 |
static struct topic_info info; |
| 1049 |
static struct topic_item items[NUM_HELP_TOPICS]; |
| 1050 |
static Boolean first_time = True; |
| 1051 |
|
| 1052 |
if (help_shell == 0) { /* called 1st time; create widget */ |
| 1053 |
|
| 1054 |
/* no special callbacks for OK/Cancel buttons */ |
| 1055 |
info.ok_callback = NULL; |
| 1056 |
info.cancel_callback = NULL; |
| 1057 |
info.items = items; |
| 1058 |
/* info.items_size = NUM_HELP_TOPICS; */ |
| 1059 |
|
| 1060 |
help_shell = create_topic_window(toplevel, |
| 1061 |
"xdvik: Help", |
| 1062 |
"help_window", |
| 1063 |
&info, |
| 1064 |
initialize_items, |
| 1065 |
"Close", |
| 1066 |
/* no Cancel button needed */ |
| 1067 |
NULL); |
| 1068 |
info.shell = help_shell; |
| 1069 |
|
| 1070 |
center_window(help_shell, globals.widgets.top_level); |
| 1071 |
} |
| 1072 |
|
| 1073 |
#if MOTIF |
| 1074 |
{ /* check if resources are set properly */ |
| 1075 |
Dimension w, h; |
| 1076 |
XtVaGetValues(help_shell, XtNwidth, &w, XtNheight, &h, NULL); |
| 1077 |
if (h < 200 || w < 400) { |
| 1078 |
XDVI_WARNING((stderr, "Initial help window size too small (%dx%d); overriding size.\n" |
| 1079 |
"Please check/update your application defaults file, and set both of\n" |
| 1080 |
"`XDvi*help_text.rows' and `XDvi*help_text.columns' to a realistic value.", |
| 1081 |
h, w)); |
| 1082 |
XtVaSetValues(help_shell, XtNwidth, 620, XtNheight, 520, NULL); |
| 1083 |
} |
| 1084 |
} |
| 1085 |
#endif |
| 1086 |
XtPopup(help_shell, XtGrabNone); |
| 1087 |
|
| 1088 |
if (topic != NULL) { |
| 1089 |
Boolean matched = False; |
| 1090 |
for (i = 0; info.items[i].topic != NULL; i++) { |
| 1091 |
if (strcmp(info.items[i].topic, topic) == 0) { /* match */ |
| 1092 |
select_topic(&info, i); |
| 1093 |
matched = True; |
| 1094 |
} |
| 1095 |
} |
| 1096 |
if (!matched) { |
| 1097 |
XdviBell(DISP, XtWindow(help_shell), 0); |
| 1098 |
popup_message(help_shell, |
| 1099 |
MSG_WARN, |
| 1100 |
NULL, |
| 1101 |
"Shouldn't happen: Could not find topic `%s' in help list!\n" |
| 1102 |
REPORT_XDVI_BUG_TEMPLATE, |
| 1103 |
topic); |
| 1104 |
} |
| 1105 |
} |
| 1106 |
else if (first_time) { |
| 1107 |
first_time = False; |
| 1108 |
select_topic(&info, 0); |
| 1109 |
} |
| 1110 |
} |