2 Hypertext file browser.
4 Copyright (C) 1994-2018
5 Free Software Foundation, Inc.
7 This file is part of the Midnight Commander.
9 The Midnight Commander is free software: you can redistribute it
10 and/or modify it under the terms of the GNU General Public License as
11 published by the Free Software Foundation, either version 3 of the License,
12 or (at your option) any later version.
14 The Midnight Commander is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>.
25 * \brief Source: hypertext file browser
27 * Implements the hypertext file viewer.
28 * The hypertext file is a file that may have one or more nodes. Each
29 * node ends with a ^D character and starts with a bracket, then the
30 * name of the node and then a closing bracket. Right after the closing
31 * bracket a newline is placed. This newline is not to be displayed by
32 * the help viewer and must be skipped - its sole purpose is to faciliate
33 * the work of the people managing the help file template (xnc.hlp) .
35 * Links in the hypertext file are specified like this: the text that
36 * will be highlighted should have a leading ^A, then it comes the
37 * text, then a ^B indicating that highlighting is done, then the name
38 * of the node you want to link to and then a ^C.
40 * The file must contain a ^D at the beginning and at the end of the
41 * file or the program will not be able to detect the end of file.
43 * Lazyness/widgeting attack: This file does use the dialog manager
44 * and uses mainly the dialog to achieve the help work. there is only
45 * one specialized widget and it's only used to forward the mouse messages
46 * to the appropriate routine.
53 #include <limits.h> /* MB_LEN_MAX */
55 #include <sys/types.h>
58 #include "lib/global.h"
60 #include "lib/tty/tty.h"
62 #include "lib/strutil.h"
63 #include "lib/fileloc.h"
65 #include "lib/widget.h"
66 #include "lib/event-types.h"
68 #include "keybind-defaults.h"
71 /*** global variables ****************************************************************************/
73 /*** file scope macro definitions ****************************************************************/
75 #define MAXLINKNAME 80
76 #define HISTORY_SIZE 20
77 #define HELP_WINDOW_WIDTH MIN(80, COLS - 16)
79 #define STRING_LINK_START "\01"
80 #define STRING_LINK_POINTER "\02"
81 #define STRING_LINK_END "\03"
82 #define STRING_NODE_END "\04"
84 /*** file scope type declarations ****************************************************************/
86 /* Link areas for the mouse */
87 typedef struct Link_Area
90 const char *link_name
;
93 /*** file scope variables ************************************************************************/
95 static char *fdata
= NULL
; /* Pointer to the loaded data file */
96 static int help_lines
; /* Lines in help viewer */
97 static int history_ptr
; /* For the history queue */
98 static const char *main_node
; /* The main node */
99 static const char *last_shown
= NULL
; /* Last byte shown in a screen */
100 static gboolean end_of_node
= FALSE
; /* Flag: the last character of the node shown? */
101 static const char *currentpoint
;
102 static const char *selected_item
;
104 /* The widget variables */
105 static WDialog
*whelp
;
109 const char *page
; /* Pointer to the selected page */
110 const char *link
; /* Pointer to the selected link */
111 } history
[HISTORY_SIZE
];
113 static GSList
*link_area
= NULL
;
114 static gboolean inside_link_area
= FALSE
;
116 static cb_ret_t
help_callback (Widget
* w
, Widget
* sender
, widget_msg_t msg
, int parm
, void *data
);
118 /*** file scope functions ************************************************************************/
119 /* --------------------------------------------------------------------------------------------- */
121 /** returns the position where text was found in the start buffer
125 search_string (const char *start
, const char *text
)
127 const char *result
= NULL
;
128 char *local_text
= g_strdup (text
);
129 char *d
= local_text
;
130 const char *e
= start
;
132 /* fmt sometimes replaces a space with a newline in the help file */
133 /* Replace the newlines in the link name with spaces to correct the situation */
142 for (d
= local_text
; *e
; e
++)
159 /* --------------------------------------------------------------------------------------------- */
160 /** Searches text in the buffer pointed by start. Search ends
161 * if the CHAR_NODE_END is found in the text.
162 * @return NULL on failure
166 search_string_node (const char *start
, const char *text
)
168 const char *d
= text
;
169 const char *e
= start
;
172 for (; *e
&& *e
!= CHAR_NODE_END
; e
++)
185 /* --------------------------------------------------------------------------------------------- */
186 /** Searches the_char in the buffer pointer by start and searches
187 * it can search forward (direction = 1) or backward (direction = -1)
191 search_char_node (const char *start
, char the_char
, int direction
)
195 for (e
= start
; (*e
!= '\0') && (*e
!= CHAR_NODE_END
); e
+= direction
)
202 /* --------------------------------------------------------------------------------------------- */
203 /** Returns the new current pointer when moved lines lines */
206 move_forward2 (const char *c
, int lines
)
212 for (line
= 0, p
= currentpoint
; (*p
!= '\0') && (*p
!= CHAR_NODE_END
); str_cnext_char (&p
))
215 return currentpoint
= p
;
220 return currentpoint
= c
;
223 /* --------------------------------------------------------------------------------------------- */
226 move_backward2 (const char *c
, int lines
)
232 for (line
= 0, p
= currentpoint
; (*p
!= '\0') && ((int) (p
- fdata
) >= 0); str_cprev_char (&p
))
234 if (*p
== CHAR_NODE_END
)
236 /* We reached the beginning of the node */
237 /* Skip the node headers */
240 return currentpoint
= p
+ 2; /* Skip the newline following the start of the node */
243 if (*(p
- 1) == '\n')
246 return currentpoint
= p
;
248 return currentpoint
= c
;
251 /* --------------------------------------------------------------------------------------------- */
257 currentpoint
= move_forward2 (currentpoint
, i
);
260 /* --------------------------------------------------------------------------------------------- */
263 move_backward (int i
)
265 currentpoint
= move_backward2 (currentpoint
, ++i
);
268 /* --------------------------------------------------------------------------------------------- */
273 while (((int) (currentpoint
> fdata
) > 0) && (*currentpoint
!= CHAR_NODE_END
))
276 while (*currentpoint
!= ']')
278 currentpoint
= currentpoint
+ 2; /* Skip the newline following the start of the node */
279 selected_item
= NULL
;
282 /* --------------------------------------------------------------------------------------------- */
285 move_to_bottom (void)
287 while ((*currentpoint
!= '\0') && (*currentpoint
!= CHAR_NODE_END
))
293 /* --------------------------------------------------------------------------------------------- */
296 help_follow_link (const char *start
, const char *lc_selected_item
)
300 if (lc_selected_item
== NULL
)
303 for (p
= lc_selected_item
; *p
&& *p
!= CHAR_NODE_END
&& *p
!= CHAR_LINK_POINTER
; p
++)
305 if (*p
== CHAR_LINK_POINTER
)
308 char link_name
[MAXLINKNAME
];
311 for (i
= 1; *p
!= CHAR_LINK_END
&& *p
&& *p
!= CHAR_NODE_END
&& i
< MAXLINKNAME
- 3;)
312 link_name
[i
++] = *++p
;
313 link_name
[i
- 1] = ']';
315 p
= search_string (fdata
, link_name
);
318 p
+= 1; /* Skip the newline following the start of the node */
323 /* Create a replacement page with the error message */
324 return _("Help file format error\n");
327 /* --------------------------------------------------------------------------------------------- */
330 select_next_link (const char *current_link
)
334 if (current_link
== NULL
)
337 p
= search_string_node (current_link
, STRING_LINK_END
);
340 p
= search_string_node (p
, STRING_LINK_START
);
346 /* --------------------------------------------------------------------------------------------- */
349 select_prev_link (const char *current_link
)
351 return current_link
== NULL
? NULL
: search_char_node (current_link
- 1, CHAR_LINK_START
, -1);
354 /* --------------------------------------------------------------------------------------------- */
357 start_link_area (int x
, int y
, const char *link_name
)
361 if (inside_link_area
)
362 message (D_NORMAL
, _("Warning"), "%s", _("Internal bug: Double start of link area"));
364 /* Allocate memory for a new link area */
365 la
= g_new (Link_Area
, 1);
366 /* Save the beginning coordinates of the link area */
369 /* Save the name of the destination anchor */
370 la
->link_name
= link_name
;
371 link_area
= g_slist_prepend (link_area
, la
);
373 inside_link_area
= TRUE
;
376 /* --------------------------------------------------------------------------------------------- */
379 end_link_area (int x
, int y
)
381 if (inside_link_area
)
383 Link_Area
*la
= (Link_Area
*) link_area
->data
;
384 /* Save the end coordinates of the link area */
387 inside_link_area
= FALSE
;
391 /* --------------------------------------------------------------------------------------------- */
394 clear_link_areas (void)
396 g_slist_free_full (link_area
, g_free
);
398 inside_link_area
= FALSE
;
401 /* --------------------------------------------------------------------------------------------- */
404 help_print_word (WDialog
* h
, GString
* word
, int *col
, int *line
, gboolean add_space
)
406 if (*line
>= help_lines
)
407 g_string_set_size (word
, 0);
412 w
= str_term_width1 (word
->str
);
413 if (*col
+ w
>= HELP_WINDOW_WIDTH
)
419 if (*line
>= help_lines
)
420 g_string_set_size (word
, 0);
423 widget_move (h
, *line
+ 2, *col
+ 2);
424 tty_print_string (word
->str
);
425 g_string_set_size (word
, 0);
432 if (*col
< HELP_WINDOW_WIDTH
- 1)
434 tty_print_char (' ');
445 /* --------------------------------------------------------------------------------------------- */
448 help_show (WDialog
* h
, const char *paint_start
)
452 gboolean painting
= TRUE
;
453 gboolean acs
; /* Flag: Alternate character set active? */
454 gboolean repeat_paint
;
455 int active_col
, active_line
; /* Active link position */
456 char buff
[MB_LEN_MAX
+ 1];
459 word
= g_string_sized_new (32);
461 tty_setcolor (HELP_NORMAL_COLOR
);
464 line
= col
= active_col
= active_line
= 0;
465 repeat_paint
= FALSE
;
469 if ((int) (selected_item
- paint_start
) < 0)
470 selected_item
= NULL
;
474 while ((n
[0] != '\0') && (n
[0] != CHAR_NODE_END
) && (line
< help_lines
))
477 n
= str_cget_next_char (p
);
478 memcpy (buff
, p
, n
- p
);
481 c
= (unsigned char) buff
[0];
484 case CHAR_LINK_START
:
485 if (selected_item
== NULL
)
487 if (p
!= selected_item
)
488 tty_setcolor (HELP_LINK_COLOR
);
491 tty_setcolor (HELP_SLINK_COLOR
);
493 /* Store the coordinates of the link */
494 active_col
= col
+ 2;
495 active_line
= line
+ 2;
497 start_link_area (col
, line
, p
);
499 case CHAR_LINK_POINTER
:
504 help_print_word (h
, word
, &col
, &line
, FALSE
);
505 end_link_area (col
- 1, line
);
506 tty_setcolor (HELP_NORMAL_COLOR
);
515 widget_move (h
, line
+ 2, col
+ 2);
516 tty_print_string (VERSION
);
517 col
+= str_term_width1 (VERSION
);
520 tty_setcolor (HELP_BOLD_COLOR
);
522 case CHAR_FONT_ITALIC
:
523 tty_setcolor (HELP_ITALIC_COLOR
);
525 case CHAR_FONT_NORMAL
:
526 help_print_word (h
, word
, &col
, &line
, FALSE
);
527 tty_setcolor (HELP_NORMAL_COLOR
);
531 help_print_word (h
, word
, &col
, &line
, FALSE
);
540 help_print_word (h
, word
, &col
, &line
, c
== ' ');
543 col
= (col
/ 8 + 1) * 8;
544 if (col
>= HELP_WINDOW_WIDTH
)
553 if (painting
&& (line
< help_lines
))
556 /* accumulate symbols in a word */
557 g_string_append (word
, buff
);
558 else if (col
< HELP_WINDOW_WIDTH
)
560 widget_move (h
, line
+ 2, col
+ 2);
562 if ((c
== ' ') || (c
== '.'))
566 tty_print_char (acs_map
[c
]);
568 SLsmg_draw_object (WIDGET (h
)->y
+ line
+ 2, WIDGET (h
)->x
+ col
+ 2,
577 /* print last word */
578 if (n
[0] == CHAR_NODE_END
)
579 help_print_word (h
, word
, &col
, &line
, FALSE
);
582 end_of_node
= line
< help_lines
;
583 tty_setcolor (HELP_NORMAL_COLOR
);
584 if ((int) (selected_item
- last_shown
) >= 0)
586 if ((link_area
== NULL
) || (link_area
->data
== NULL
))
587 selected_item
= NULL
;
590 selected_item
= ((Link_Area
*) link_area
->data
)->link_name
;
595 while (repeat_paint
);
597 g_string_free (word
, TRUE
);
599 /* Position the cursor over a nice link */
601 widget_move (h
, active_line
, active_col
);
604 /* --------------------------------------------------------------------------------------------- */
608 help_help (WDialog
* h
)
612 history_ptr
= (history_ptr
+ 1) % HISTORY_SIZE
;
613 history
[history_ptr
].page
= currentpoint
;
614 history
[history_ptr
].link
= selected_item
;
616 p
= search_string (fdata
, "[How to use help]");
619 currentpoint
= p
+ 1; /* Skip the newline following the start of the node */
620 selected_item
= NULL
;
621 send_message (h
, NULL
, MSG_DRAW
, 0, NULL
);
625 /* --------------------------------------------------------------------------------------------- */
628 help_index (WDialog
* h
)
630 const char *new_item
;
632 new_item
= search_string (fdata
, "[Contents]");
634 if (new_item
== NULL
)
635 message (D_ERROR
, MSG_ERROR
, _("Cannot find node %s in help file"), "[Contents]");
638 history_ptr
= (history_ptr
+ 1) % HISTORY_SIZE
;
639 history
[history_ptr
].page
= currentpoint
;
640 history
[history_ptr
].link
= selected_item
;
642 currentpoint
= new_item
+ 1; /* Skip the newline following the start of the node */
643 selected_item
= NULL
;
644 send_message (h
, NULL
, MSG_DRAW
, 0, NULL
);
648 /* --------------------------------------------------------------------------------------------- */
651 help_back (WDialog
* h
)
653 currentpoint
= history
[history_ptr
].page
;
654 selected_item
= history
[history_ptr
].link
;
657 history_ptr
= HISTORY_SIZE
- 1;
659 send_message (h
, NULL
, MSG_DRAW
, 0, NULL
); /* FIXME: unneeded? */
662 /* --------------------------------------------------------------------------------------------- */
665 help_next_link (gboolean move_down
)
667 const char *new_item
;
669 new_item
= select_next_link (selected_item
);
670 if (new_item
!= NULL
)
672 selected_item
= new_item
;
673 if ((int) (selected_item
- last_shown
) >= 0)
678 selected_item
= NULL
;
684 selected_item
= NULL
;
687 /* --------------------------------------------------------------------------------------------- */
690 help_prev_link (gboolean move_up
)
692 const char *new_item
;
694 new_item
= select_prev_link (selected_item
);
695 selected_item
= new_item
;
696 if ((selected_item
== NULL
) || (selected_item
< currentpoint
))
700 else if ((link_area
!= NULL
) && (link_area
->data
!= NULL
))
701 selected_item
= ((Link_Area
*) link_area
->data
)->link_name
;
703 selected_item
= NULL
;
707 /* --------------------------------------------------------------------------------------------- */
710 help_next_node (void)
712 const char *new_item
;
714 new_item
= currentpoint
;
715 while ((*new_item
!= '\0') && (*new_item
!= CHAR_NODE_END
))
718 if (*++new_item
== '[')
719 while (*++new_item
!= '\0')
720 if ((*new_item
== ']') && (*++new_item
!= '\0') && (*++new_item
!= '\0'))
722 currentpoint
= new_item
;
723 selected_item
= NULL
;
728 /* --------------------------------------------------------------------------------------------- */
731 help_prev_node (void)
733 const char *new_item
;
735 new_item
= currentpoint
;
736 while (((int) (new_item
- fdata
) > 1) && (*new_item
!= CHAR_NODE_END
))
739 while (((int) (new_item
- fdata
) > 0) && (*new_item
!= CHAR_NODE_END
))
741 while (*new_item
!= ']')
743 currentpoint
= new_item
+ 2;
744 selected_item
= NULL
;
747 /* --------------------------------------------------------------------------------------------- */
750 help_select_link (void)
753 if (selected_item
== NULL
)
755 #ifdef WE_WANT_TO_GO_BACKWARD_ON_KEY_RIGHT
756 /* Is there any reason why the right key would take us
757 * backward if there are no links selected?, I agree
758 * with Torben than doing nothing in this case is better
760 /* If there are no links, go backward in history */
763 history_ptr
= HISTORY_SIZE
- 1;
765 currentpoint
= history
[history_ptr
].page
;
766 selected_item
= history
[history_ptr
].link
;
771 history_ptr
= (history_ptr
+ 1) % HISTORY_SIZE
;
772 history
[history_ptr
].page
= currentpoint
;
773 history
[history_ptr
].link
= selected_item
;
774 currentpoint
= help_follow_link (currentpoint
, selected_item
);
777 selected_item
= NULL
;
780 /* --------------------------------------------------------------------------------------------- */
783 help_execute_cmd (long command
)
785 cb_ret_t ret
= MSG_HANDLED
;
799 help_prev_link (TRUE
);
802 help_next_link (TRUE
);
805 move_forward (help_lines
- 1);
808 move_backward (help_lines
- 1);
810 case CK_HalfPageDown
:
811 move_forward (help_lines
/ 2);
814 move_backward (help_lines
/ 2);
826 help_next_link (FALSE
);
829 help_prev_link (FALSE
);
841 ret
= MSG_NOT_HANDLED
;
847 /* --------------------------------------------------------------------------------------------- */
850 help_handle_key (WDialog
* h
, int c
)
854 command
= keybind_lookup_keymap_command (help_map
, c
);
855 if ((command
== CK_IgnoreKey
) || (help_execute_cmd (command
) == MSG_NOT_HANDLED
))
856 return MSG_NOT_HANDLED
;
858 send_message (h
, NULL
, MSG_DRAW
, 0, NULL
);
862 /* --------------------------------------------------------------------------------------------- */
865 help_callback (Widget
* w
, Widget
* sender
, widget_msg_t msg
, int parm
, void *data
)
867 WDialog
*h
= DIALOG (w
);
875 help_lines
= MIN (LINES
- 4, MAX (2 * LINES
/ 3, 18));
876 dlg_set_size (h
, help_lines
+ 4, HELP_WINDOW_WIDTH
+ 4);
877 bb
= find_buttonbar (h
);
878 widget_set_size (WIDGET (bb
), LINES
- 1, 0, 1, COLS
);
883 dlg_default_repaint (h
);
884 help_show (h
, currentpoint
);
888 return help_handle_key (h
, parm
);
891 /* Handle shortcuts and buttonbar. */
892 return help_execute_cmd (parm
);
895 return dlg_default_callback (w
, sender
, msg
, parm
, data
);
899 /* --------------------------------------------------------------------------------------------- */
902 interactive_display_finish (void)
907 /* --------------------------------------------------------------------------------------------- */
908 /** translate help file into terminal encoding */
911 translate_file (char *filedata
)
914 GString
*translated_data
;
916 /* initial allocation for largest whole help file */
917 translated_data
= g_string_sized_new (32 * 1024);
919 conv
= str_crt_conv_from ("UTF-8");
921 if (conv
== INVALID_CONV
)
922 g_string_free (translated_data
, TRUE
);
927 if (str_convert (conv
, filedata
, translated_data
) != ESTR_FAILURE
)
928 fdata
= g_string_free (translated_data
, FALSE
);
932 g_string_free (translated_data
, TRUE
);
934 str_close_conv (conv
);
938 /* --------------------------------------------------------------------------------------------- */
941 md_callback (Widget
* w
, Widget
* sender
, widget_msg_t msg
, int parm
, void *data
)
946 w
->lines
= help_lines
;
950 return widget_default_callback (w
, sender
, msg
, parm
, data
);
954 /* --------------------------------------------------------------------------------------------- */
957 help_mouse_callback (Widget
* w
, mouse_msg_t msg
, mouse_event_t
* event
)
960 GSList
*current_area
;
962 if (msg
!= MSG_MOUSE_CLICK
)
965 if ((event
->buttons
& GPM_B_RIGHT
) != 0)
967 /* Right button click */
972 /* Left bytton click */
974 /* The event is relative to the dialog window, adjust it: */
978 /* Test whether the mouse click is inside one of the link areas */
979 for (current_area
= link_area
; current_area
!= NULL
; current_area
= g_slist_next (current_area
))
981 Link_Area
*la
= (Link_Area
*) current_area
->data
;
983 /* Test one line link area */
984 if (y
== la
->y1
&& x
>= la
->x1
&& y
== la
->y2
&& x
<= la
->x2
)
987 /* Test two line link area */
988 if (la
->y1
+ 1 == la
->y2
)
990 /* The first line || The second line */
991 if ((y
== la
->y1
&& x
>= la
->x1
) || (y
== la
->y2
&& x
<= la
->x2
))
994 /* Mouse will not work with link areas of more than two lines */
997 /* Test whether a link area was found */
998 if (current_area
!= NULL
)
1000 Link_Area
*la
= (Link_Area
*) current_area
->data
;
1002 /* The click was inside a link area -> follow the link */
1003 history_ptr
= (history_ptr
+ 1) % HISTORY_SIZE
;
1004 history
[history_ptr
].page
= currentpoint
;
1005 history
[history_ptr
].link
= la
->link_name
;
1006 currentpoint
= help_follow_link (currentpoint
, la
->link_name
);
1007 selected_item
= NULL
;
1010 move_backward (help_lines
- 1);
1011 else if (y
>= help_lines
)
1012 move_forward (help_lines
- 1);
1013 else if (y
< help_lines
/ 2)
1018 /* Show the new node */
1019 send_message (w
->owner
, NULL
, MSG_DRAW
, 0, NULL
);
1022 /* --------------------------------------------------------------------------------------------- */
1025 mousedispatch_new (int y
, int x
, int yl
, int xl
)
1029 w
= g_new0 (Widget
, 1);
1030 widget_init (w
, y
, x
, yl
, xl
, md_callback
, help_mouse_callback
);
1031 w
->options
|= WOP_SELECTABLE
| WOP_WANT_CURSOR
;
1036 /* --------------------------------------------------------------------------------------------- */
1037 /*** public functions ****************************************************************************/
1038 /* --------------------------------------------------------------------------------------------- */
1040 /* event callback */
1042 help_interactive_display (const gchar
* event_group_name
, const gchar
* event_name
,
1043 gpointer init_data
, gpointer data
)
1045 const dlg_colors_t help_colors
= {
1046 HELP_NORMAL_COLOR
, /* common text color */
1047 0, /* unused in help */
1048 HELP_BOLD_COLOR
, /* bold text color */
1049 0, /* unused in help */
1050 HELP_TITLE_COLOR
/* title color */
1053 WButtonBar
*help_bar
;
1055 char *hlpfile
= NULL
;
1057 ev_help_t
*event_data
= (ev_help_t
*) data
;
1059 (void) event_group_name
;
1063 if (event_data
->filename
!= NULL
)
1064 g_file_get_contents (event_data
->filename
, &filedata
, NULL
, NULL
);
1066 filedata
= load_mc_home_file (mc_global
.share_data_dir
, MC_HELP
, &hlpfile
, NULL
);
1068 if (filedata
== NULL
)
1069 message (D_ERROR
, MSG_ERROR
, _("Cannot open file %s\n%s"),
1070 event_data
->filename
? event_data
->filename
: hlpfile
, unix_error_string (errno
));
1074 if (filedata
== NULL
)
1077 translate_file (filedata
);
1084 if ((event_data
->node
== NULL
) || (*event_data
->node
== '\0'))
1085 event_data
->node
= "[main]";
1087 main_node
= search_string (fdata
, event_data
->node
);
1089 if (main_node
== NULL
)
1091 message (D_ERROR
, MSG_ERROR
, _("Cannot find node %s in help file"), event_data
->node
);
1093 /* Fallback to [main], return if it also cannot be found */
1094 main_node
= search_string (fdata
, "[main]");
1095 if (main_node
== NULL
)
1097 interactive_display_finish ();
1102 help_lines
= MIN (LINES
- 4, MAX (2 * LINES
/ 3, 18));
1105 dlg_create (TRUE
, 0, 0, help_lines
+ 4, HELP_WINDOW_WIDTH
+ 4, WPOS_CENTER
| WPOS_TRYUP
,
1106 FALSE
, help_colors
, help_callback
, NULL
, "[Help]", _("Help"));
1107 widget_want_tab (WIDGET (whelp
), TRUE
);
1109 selected_item
= search_string_node (main_node
, STRING_LINK_START
) - 1;
1110 currentpoint
= main_node
+ 1; /* Skip the newline following the start of the node */
1112 for (history_ptr
= HISTORY_SIZE
; history_ptr
;)
1115 history
[history_ptr
].page
= currentpoint
;
1116 history
[history_ptr
].link
= selected_item
;
1119 help_bar
= buttonbar_new (TRUE
);
1120 WIDGET (help_bar
)->y
-= WIDGET (whelp
)->y
;
1121 WIDGET (help_bar
)->x
-= WIDGET (whelp
)->x
;
1123 md
= mousedispatch_new (1, 1, help_lines
, HELP_WINDOW_WIDTH
- 2);
1125 add_widget (whelp
, md
);
1126 add_widget (whelp
, help_bar
);
1128 buttonbar_set_label (help_bar
, 1, Q_ ("ButtonBar|Help"), help_map
, NULL
);
1129 buttonbar_set_label (help_bar
, 2, Q_ ("ButtonBar|Index"), help_map
, NULL
);
1130 buttonbar_set_label (help_bar
, 3, Q_ ("ButtonBar|Prev"), help_map
, NULL
);
1131 buttonbar_set_label (help_bar
, 4, "", help_map
, NULL
);
1132 buttonbar_set_label (help_bar
, 5, "", help_map
, NULL
);
1133 buttonbar_set_label (help_bar
, 6, "", help_map
, NULL
);
1134 buttonbar_set_label (help_bar
, 7, "", help_map
, NULL
);
1135 buttonbar_set_label (help_bar
, 8, "", help_map
, NULL
);
1136 buttonbar_set_label (help_bar
, 9, "", help_map
, NULL
);
1137 buttonbar_set_label (help_bar
, 10, Q_ ("ButtonBar|Quit"), help_map
, NULL
);
1140 interactive_display_finish ();
1141 dlg_destroy (whelp
);
1145 /* --------------------------------------------------------------------------------------------- */