1 /* Hypertext file browser.
2 Copyright (C) 1994, 1995, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
3 2005, 2006, 2007 Free Software Foundation, Inc.
5 This program 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 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 * \brief Source: hypertext file browser
24 * Implements the hypertext file viewer.
25 * The hypertext file is a file that may have one or more nodes. Each
26 * node ends with a ^D character and starts with a bracket, then the
27 * name of the node and then a closing bracket. Right after the closing
28 * bracket a newline is placed. This newline is not to be displayed by
29 * the help viewer and must be skipped - its sole purpose is to faciliate
30 * the work of the people managing the help file template (xnc.hlp) .
32 * Links in the hypertext file are specified like this: the text that
33 * will be highlighted should have a leading ^A, then it comes the
34 * text, then a ^B indicating that highlighting is done, then the name
35 * of the node you want to link to and then a ^C.
37 * The file must contain a ^D at the beginning and at the end of the
38 * file or the program will not be able to detect the end of file.
40 * Lazyness/widgeting attack: This file does use the dialog manager
41 * and uses mainly the dialog to achieve the help work. there is only
42 * one specialized widget and it's only used to forward the mouse messages
43 * to the appropiate routine.
51 #include <sys/types.h>
54 #include "lib/global.h"
56 #include "lib/tty/tty.h"
57 #include "lib/tty/mouse.h"
59 #include "lib/strutil.h"
60 #include "lib/fileloc.h"
62 #include "lib/widget.h"
64 #include "keybind-defaults.h"
65 #include "keybind-defaults.h"
69 /*** global variables ****************************************************************************/
71 /*** file scope macro definitions ****************************************************************/
73 #define MAXLINKNAME 80
74 #define HISTORY_SIZE 20
75 #define HELP_WINDOW_WIDTH min(80, COLS - 16)
77 #define STRING_LINK_START "\01"
78 #define STRING_LINK_POINTER "\02"
79 #define STRING_LINK_END "\03"
80 #define STRING_NODE_END "\04"
82 /*** file scope type declarations ****************************************************************/
84 /* Link areas for the mouse */
85 typedef struct Link_Area
88 const char *link_name
;
91 /*** file scope variables ************************************************************************/
93 static char *fdata
= NULL
; /* Pointer to the loaded data file */
94 static int help_lines
; /* Lines in help viewer */
95 static int history_ptr
; /* For the history queue */
96 static const char *main_node
; /* The main node */
97 static const char *last_shown
= NULL
; /* Last byte shown in a screen */
98 static gboolean end_of_node
= FALSE
; /* Flag: the last character of the node shown? */
99 static const char *currentpoint
;
100 static const char *selected_item
;
102 /* The widget variables */
103 static Dlg_head
*whelp
;
107 const char *page
; /* Pointer to the selected page */
108 const char *link
; /* Pointer to the selected link */
109 } history
[HISTORY_SIZE
];
111 static GSList
*link_area
= NULL
;
112 static gboolean inside_link_area
= FALSE
;
114 static cb_ret_t
help_callback (Dlg_head
* h
, Widget
* sender
, dlg_msg_t msg
, int parm
, void *data
);
116 /*** file scope functions ************************************************************************/
117 /* --------------------------------------------------------------------------------------------- */
119 /** returns the position where text was found in the start buffer
123 search_string (const char *start
, const char *text
)
125 const char *result
= NULL
;
126 char *local_text
= g_strdup (text
);
127 char *d
= local_text
;
128 const char *e
= start
;
130 /* fmt sometimes replaces a space with a newline in the help file */
131 /* Replace the newlines in the link name with spaces to correct the situation */
140 for (d
= local_text
; *e
; e
++)
157 /* --------------------------------------------------------------------------------------------- */
158 /** Searches text in the buffer pointed by start. Search ends
159 * if the CHAR_NODE_END is found in the text.
160 * @returns 0 on failure
164 search_string_node (const char *start
, const char *text
)
166 const char *d
= text
;
167 const char *e
= start
;
170 for (; *e
&& *e
!= CHAR_NODE_END
; e
++)
183 /* --------------------------------------------------------------------------------------------- */
184 /** Searches the_char in the buffer pointer by start and searches
185 * it can search forward (direction = 1) or backward (direction = -1)
189 search_char_node (const char *start
, char the_char
, int direction
)
193 for (e
= start
; (*e
!= '\0') && (*e
!= CHAR_NODE_END
); e
+= direction
)
200 /* --------------------------------------------------------------------------------------------- */
201 /** Returns the new current pointer when moved lines lines */
204 move_forward2 (const char *c
, int lines
)
210 for (line
= 0, p
= currentpoint
; (*p
!= '\0') && (*p
!= CHAR_NODE_END
); str_cnext_char (&p
))
213 return currentpoint
= p
;
218 return currentpoint
= c
;
221 /* --------------------------------------------------------------------------------------------- */
224 move_backward2 (const char *c
, int lines
)
230 for (line
= 0, p
= currentpoint
; (*p
!= '\0') && ((int) (p
- fdata
) >= 0); str_cprev_char (&p
))
232 if (*p
== CHAR_NODE_END
)
234 /* We reached the beginning of the node */
235 /* Skip the node headers */
238 return currentpoint
= p
+ 2; /* Skip the newline following the start of the node */
241 if (*(p
- 1) == '\n')
244 return currentpoint
= p
;
246 return currentpoint
= c
;
249 /* --------------------------------------------------------------------------------------------- */
255 currentpoint
= move_forward2 (currentpoint
, i
);
258 /* --------------------------------------------------------------------------------------------- */
261 move_backward (int i
)
263 currentpoint
= move_backward2 (currentpoint
, ++i
);
266 /* --------------------------------------------------------------------------------------------- */
271 while (((int) (currentpoint
> fdata
) > 0) && (*currentpoint
!= CHAR_NODE_END
))
274 while (*currentpoint
!= ']')
276 currentpoint
= currentpoint
+ 2; /* Skip the newline following the start of the node */
277 selected_item
= NULL
;
280 /* --------------------------------------------------------------------------------------------- */
283 move_to_bottom (void)
285 while ((*currentpoint
!= '\0') && (*currentpoint
!= CHAR_NODE_END
))
291 /* --------------------------------------------------------------------------------------------- */
294 help_follow_link (const char *start
, const char *lc_selected_item
)
296 char link_name
[MAXLINKNAME
];
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 for (i
= 1; *p
!= CHAR_LINK_END
&& *p
&& *p
!= CHAR_NODE_END
&& i
< MAXLINKNAME
- 3;)
309 link_name
[i
++] = *++p
;
310 link_name
[i
- 1] = ']';
312 p
= search_string (fdata
, link_name
);
315 p
+= 1; /* Skip the newline following the start of the node */
320 /* Create a replacement page with the error message */
321 return _("Help file format error\n");
324 /* --------------------------------------------------------------------------------------------- */
327 select_next_link (const char *current_link
)
331 if (current_link
== NULL
)
334 p
= search_string_node (current_link
, STRING_LINK_END
);
337 p
= search_string_node (p
, STRING_LINK_START
);
343 /* --------------------------------------------------------------------------------------------- */
346 select_prev_link (const char *current_link
)
348 return current_link
== NULL
? NULL
: search_char_node (current_link
- 1, CHAR_LINK_START
, -1);
351 /* --------------------------------------------------------------------------------------------- */
354 start_link_area (int x
, int y
, const char *link_name
)
358 if (inside_link_area
)
359 message (D_NORMAL
, _("Warning"), _("Internal bug: Double start of link area"));
361 /* Allocate memory for a new link area */
362 la
= g_new (Link_Area
, 1);
363 /* Save the beginning coordinates of the link area */
366 /* Save the name of the destination anchor */
367 la
->link_name
= link_name
;
368 link_area
= g_slist_prepend (link_area
, la
);
370 inside_link_area
= TRUE
;
373 /* --------------------------------------------------------------------------------------------- */
376 end_link_area (int x
, int y
)
378 if (inside_link_area
)
380 Link_Area
*la
= (Link_Area
*) link_area
->data
;
381 /* Save the end coordinates of the link area */
384 inside_link_area
= FALSE
;
388 /* --------------------------------------------------------------------------------------------- */
391 clear_link_areas (void)
393 g_slist_foreach (link_area
, (GFunc
) g_free
, NULL
);
394 g_slist_free (link_area
);
396 inside_link_area
= FALSE
;
399 /* --------------------------------------------------------------------------------------------- */
402 help_print_word (Dlg_head
* h
, GString
* word
, int *col
, int *line
, gboolean add_space
)
404 if (*line
>= help_lines
)
405 g_string_set_size (word
, 0);
410 w
= str_term_width1 (word
->str
);
411 if (*col
+ w
>= HELP_WINDOW_WIDTH
)
417 if (*line
>= help_lines
)
418 g_string_set_size (word
, 0);
421 dlg_move (h
, *line
+ 2, *col
+ 2);
422 tty_print_string (word
->str
);
423 g_string_set_size (word
, 0);
430 if (*col
< HELP_WINDOW_WIDTH
- 1)
432 tty_print_char (' ');
443 /* --------------------------------------------------------------------------------------------- */
446 help_show (Dlg_head
* h
, const char *paint_start
)
450 gboolean painting
= TRUE
;
451 gboolean acs
; /* Flag: Alternate character set active? */
452 gboolean repeat_paint
;
453 int active_col
, active_line
; /* Active link position */
454 char buff
[MB_LEN_MAX
+ 1];
457 word
= g_string_sized_new (32);
459 tty_setcolor (HELP_NORMAL_COLOR
);
462 line
= col
= active_col
= active_line
= 0;
463 repeat_paint
= FALSE
;
467 if ((int) (selected_item
- paint_start
) < 0)
468 selected_item
= NULL
;
472 while ((n
[0] != '\0') && (n
[0] != CHAR_NODE_END
) && (line
< help_lines
))
475 n
= str_cget_next_char (p
);
476 memcpy (buff
, p
, n
- p
);
479 c
= (unsigned char) buff
[0];
482 case CHAR_LINK_START
:
483 if (selected_item
== NULL
)
485 if (p
!= selected_item
)
486 tty_setcolor (HELP_LINK_COLOR
);
489 tty_setcolor (HELP_SLINK_COLOR
);
491 /* Store the coordinates of the link */
492 active_col
= col
+ 2;
493 active_line
= line
+ 2;
495 start_link_area (col
, line
, p
);
497 case CHAR_LINK_POINTER
:
499 end_link_area (col
- 1, line
);
503 help_print_word (h
, word
, &col
, &line
, FALSE
);
504 tty_setcolor (HELP_NORMAL_COLOR
);
513 dlg_move (h
, line
+ 2, col
+ 2);
514 tty_print_string (VERSION
);
515 col
+= str_term_width1 (VERSION
);
518 tty_setcolor (HELP_BOLD_COLOR
);
520 case CHAR_FONT_ITALIC
:
521 tty_setcolor (HELP_ITALIC_COLOR
);
523 case CHAR_FONT_NORMAL
:
524 help_print_word (h
, word
, &col
, &line
, FALSE
);
525 tty_setcolor (HELP_NORMAL_COLOR
);
529 help_print_word (h
, word
, &col
, &line
, FALSE
);
534 col
= (col
/ 8 + 1) * 8;
535 if (col
>= HELP_WINDOW_WIDTH
)
544 help_print_word (h
, word
, &col
, &line
, TRUE
);
547 if (painting
&& (line
< help_lines
))
550 /* accumulate symbols in a word */
551 g_string_append (word
, buff
);
552 else if (col
< HELP_WINDOW_WIDTH
)
554 dlg_move (h
, line
+ 2, col
+ 2);
556 if ((c
== ' ') || (c
== '.'))
560 tty_print_char (acs_map
[c
]);
562 SLsmg_draw_object (h
->y
+ line
+ 2, h
->x
+ col
+ 2, c
);
570 /* print last word */
571 if (n
[0] == CHAR_NODE_END
)
572 help_print_word (h
, word
, &col
, &line
, FALSE
);
575 end_of_node
= line
< help_lines
;
576 tty_setcolor (HELP_NORMAL_COLOR
);
577 if ((int) (selected_item
- last_shown
) >= 0)
579 if ((link_area
== NULL
) || (link_area
->data
== NULL
))
580 selected_item
= NULL
;
583 selected_item
= ((Link_Area
*) link_area
->data
)->link_name
;
588 while (repeat_paint
);
590 g_string_free (word
, TRUE
);
592 /* Position the cursor over a nice link */
594 dlg_move (h
, active_line
, active_col
);
597 /* --------------------------------------------------------------------------------------------- */
600 help_event (Gpm_Event
* event
, void *vp
)
603 GSList
*current_area
;
605 if ((event
->type
& GPM_UP
) == 0)
608 /* The event is relative to the dialog window, adjust it: */
612 if (event
->buttons
& GPM_B_RIGHT
)
614 currentpoint
= history
[history_ptr
].page
;
615 selected_item
= history
[history_ptr
].link
;
618 history_ptr
= HISTORY_SIZE
- 1;
620 help_callback (w
->owner
, NULL
, DLG_DRAW
, 0, NULL
);
624 /* Test whether the mouse click is inside one of the link areas */
625 for (current_area
= link_area
; current_area
!= NULL
; current_area
= g_slist_next (current_area
))
627 Link_Area
*la
= (Link_Area
*) current_area
->data
;
628 /* Test one line link area */
629 if (event
->y
== la
->y1
&& event
->x
>= la
->x1
&& event
->y
== la
->y2
&& event
->x
<= la
->x2
)
631 /* Test two line link area */
632 if (la
->y1
+ 1 == la
->y2
)
635 if (event
->y
== la
->y1
&& event
->x
>= la
->x1
)
637 /* The second line */
638 if (event
->y
== la
->y2
&& event
->x
<= la
->x2
)
641 /* Mouse will not work with link areas of more than two lines */
644 /* Test whether a link area was found */
645 if (current_area
!= NULL
)
647 Link_Area
*la
= (Link_Area
*) current_area
->data
;
649 /* The click was inside a link area -> follow the link */
650 history_ptr
= (history_ptr
+ 1) % HISTORY_SIZE
;
651 history
[history_ptr
].page
= currentpoint
;
652 history
[history_ptr
].link
= la
->link_name
;
653 currentpoint
= help_follow_link (currentpoint
, la
->link_name
);
654 selected_item
= NULL
;
656 else if (event
->y
< 0)
657 move_backward (help_lines
- 1);
658 else if (event
->y
>= help_lines
)
659 move_forward (help_lines
- 1);
660 else if (event
->y
< help_lines
/ 2)
665 /* Show the new node */
666 help_callback (w
->owner
, NULL
, DLG_DRAW
, 0, NULL
);
671 /* --------------------------------------------------------------------------------------------- */
675 help_help (Dlg_head
* h
)
679 history_ptr
= (history_ptr
+ 1) % HISTORY_SIZE
;
680 history
[history_ptr
].page
= currentpoint
;
681 history
[history_ptr
].link
= selected_item
;
683 p
= search_string (fdata
, "[How to use help]");
686 currentpoint
= p
+ 1; /* Skip the newline following the start of the node */
687 selected_item
= NULL
;
688 help_callback (h
, NULL
, DLG_DRAW
, 0, NULL
);
692 /* --------------------------------------------------------------------------------------------- */
695 help_index (Dlg_head
* h
)
697 const char *new_item
;
699 new_item
= search_string (fdata
, "[Contents]");
701 if (new_item
== NULL
)
702 message (D_ERROR
, MSG_ERROR
, _("Cannot find node %s in help file"), "[Contents]");
705 history_ptr
= (history_ptr
+ 1) % HISTORY_SIZE
;
706 history
[history_ptr
].page
= currentpoint
;
707 history
[history_ptr
].link
= selected_item
;
709 currentpoint
= new_item
+ 1; /* Skip the newline following the start of the node */
710 selected_item
= NULL
;
711 help_callback (h
, NULL
, DLG_DRAW
, 0, NULL
);
715 /* --------------------------------------------------------------------------------------------- */
718 help_back (Dlg_head
* h
)
720 currentpoint
= history
[history_ptr
].page
;
721 selected_item
= history
[history_ptr
].link
;
724 history_ptr
= HISTORY_SIZE
- 1;
726 help_callback (h
, NULL
, DLG_DRAW
, 0, NULL
); /* FIXME: unneeded? */
729 /* --------------------------------------------------------------------------------------------- */
732 help_next_link (gboolean move_down
)
734 const char *new_item
;
736 new_item
= select_next_link (selected_item
);
737 if (new_item
!= NULL
)
739 selected_item
= new_item
;
740 if ((int) (selected_item
- last_shown
) >= 0)
745 selected_item
= NULL
;
751 selected_item
= NULL
;
754 /* --------------------------------------------------------------------------------------------- */
757 help_prev_link (gboolean move_up
)
759 const char *new_item
;
761 new_item
= select_prev_link (selected_item
);
762 selected_item
= new_item
;
763 if ((selected_item
== NULL
) || (selected_item
< currentpoint
))
767 else if ((link_area
!= NULL
) && (link_area
->data
!= NULL
))
768 selected_item
= ((Link_Area
*) link_area
->data
)->link_name
;
770 selected_item
= NULL
;
774 /* --------------------------------------------------------------------------------------------- */
777 help_next_node (void)
779 const char *new_item
;
781 new_item
= currentpoint
;
782 while ((*new_item
!= '\0') && (*new_item
!= CHAR_NODE_END
))
785 if (*++new_item
== '[')
786 while (*++new_item
!= '\0')
787 if ((*new_item
== ']') && (*++new_item
!= '\0') && (*++new_item
!= '\0'))
789 currentpoint
= new_item
;
790 selected_item
= NULL
;
795 /* --------------------------------------------------------------------------------------------- */
798 help_prev_node (void)
800 const char *new_item
;
802 new_item
= currentpoint
;
803 while (((int) (new_item
- fdata
) > 1) && (*new_item
!= CHAR_NODE_END
))
806 while (((int) (new_item
- fdata
) > 0) && (*new_item
!= CHAR_NODE_END
))
808 while (*new_item
!= ']')
810 currentpoint
= new_item
+ 2;
811 selected_item
= NULL
;
814 /* --------------------------------------------------------------------------------------------- */
817 help_select_link (void)
820 if (selected_item
== NULL
)
822 #ifdef WE_WANT_TO_GO_BACKWARD_ON_KEY_RIGHT
823 /* Is there any reason why the right key would take us
824 * backward if there are no links selected?, I agree
825 * with Torben than doing nothing in this case is better
827 /* If there are no links, go backward in history */
830 history_ptr
= HISTORY_SIZE
- 1;
832 currentpoint
= history
[history_ptr
].page
;
833 selected_item
= history
[history_ptr
].link
;
838 history_ptr
= (history_ptr
+ 1) % HISTORY_SIZE
;
839 history
[history_ptr
].page
= currentpoint
;
840 history
[history_ptr
].link
= selected_item
;
841 currentpoint
= help_follow_link (currentpoint
, selected_item
);
844 selected_item
= NULL
;
847 /* --------------------------------------------------------------------------------------------- */
850 help_execute_cmd (unsigned long command
)
852 cb_ret_t ret
= MSG_HANDLED
;
866 help_prev_link (TRUE
);
868 case CK_HelpMoveDown
:
869 help_next_link (TRUE
);
871 case CK_HelpMovePgDn
:
872 move_forward (help_lines
- 1);
874 case CK_HelpMovePgUp
:
875 move_backward (help_lines
- 1);
877 case CK_HelpMoveHalfPgDn
:
878 move_forward (help_lines
/ 2);
880 case CK_HelpMoveHalfPgUp
:
881 move_backward (help_lines
/ 2);
886 case CK_HelpMoveBottom
:
889 case CK_HelpSelectLink
:
892 case CK_HelpNextLink
:
893 help_next_link (FALSE
);
895 case CK_HelpPrevLink
:
896 help_prev_link (FALSE
);
898 case CK_HelpNextNode
:
901 case CK_HelpPrevNode
:
908 ret
= MSG_NOT_HANDLED
;
914 /* --------------------------------------------------------------------------------------------- */
917 help_handle_key (Dlg_head
* h
, int c
)
919 unsigned long command
;
921 command
= keybind_lookup_keymap_command (help_map
, c
);
922 if ((command
== CK_Ignore_Key
) || (help_execute_cmd (command
) == MSG_NOT_HANDLED
))
923 return MSG_NOT_HANDLED
;
925 help_callback (h
, NULL
, DLG_DRAW
, 0, NULL
);
929 /* --------------------------------------------------------------------------------------------- */
932 help_callback (Dlg_head
* h
, Widget
* sender
, dlg_msg_t msg
, int parm
, void *data
)
939 help_lines
= min (LINES
- 4, max (2 * LINES
/ 3, 18));
940 dlg_set_size (h
, help_lines
+ 4, HELP_WINDOW_WIDTH
+ 4);
941 bb
= find_buttonbar (h
);
942 widget_set_size (&bb
->widget
, LINES
- 1, 0, 1, COLS
);
946 common_dialog_repaint (h
);
947 help_show (h
, currentpoint
);
951 return help_handle_key (h
, parm
);
954 /* command from buttonbar */
955 return help_execute_cmd (parm
);
958 return default_dlg_callback (h
, sender
, msg
, parm
, data
);
962 /* --------------------------------------------------------------------------------------------- */
965 interactive_display_finish (void)
970 /* --------------------------------------------------------------------------------------------- */
971 /** translate help file into terminal encoding */
974 translate_file (char *filedata
)
977 GString
*translated_data
;
979 /* initial allocation for largest whole help file */
980 translated_data
= g_string_sized_new (32 * 1024);
982 conv
= str_crt_conv_from ("UTF-8");
984 if (conv
== INVALID_CONV
)
985 g_string_free (translated_data
, TRUE
);
990 if (str_convert (conv
, filedata
, translated_data
) != ESTR_FAILURE
)
991 fdata
= g_string_free (translated_data
, FALSE
);
995 g_string_free (translated_data
, TRUE
);
997 str_close_conv (conv
);
1001 /* --------------------------------------------------------------------------------------------- */
1004 md_callback (Widget
* w
, widget_msg_t msg
, int parm
)
1008 case WIDGET_RESIZED
:
1009 w
->lines
= help_lines
;
1013 return default_proc (msg
, parm
);
1017 /* --------------------------------------------------------------------------------------------- */
1020 mousedispatch_new (int y
, int x
, int yl
, int xl
)
1022 Widget
*w
= g_new (Widget
, 1);
1023 init_widget (w
, y
, x
, yl
, xl
, md_callback
, help_event
);
1027 /* --------------------------------------------------------------------------------------------- */
1028 /*** public functions ****************************************************************************/
1029 /* --------------------------------------------------------------------------------------------- */
1032 interactive_display (const char *filename
, const char *node
)
1034 const dlg_colors_t help_colors
= {
1035 HELP_NORMAL_COLOR
, /* common text color */
1036 0, /* unused in help */
1037 HELP_BOLD_COLOR
, /* bold text color */
1038 0, /* unused in help */
1039 HELP_TITLE_COLOR
/* title color */
1042 WButtonBar
*help_bar
;
1044 char *hlpfile
= NULL
;
1047 if (filename
!= NULL
)
1048 g_file_get_contents (filename
, &filedata
, NULL
, NULL
);
1050 filedata
= load_mc_home_file (mc_share_data_dir
, MC_HELP
, &hlpfile
);
1052 if (filedata
== NULL
)
1053 message (D_ERROR
, MSG_ERROR
, _("Cannot open file %s\n%s"),
1054 filename
? filename
: hlpfile
, unix_error_string (errno
));
1058 if (filedata
== NULL
)
1061 translate_file (filedata
);
1068 if ((node
== NULL
) || (*node
== '\0'))
1071 main_node
= search_string (fdata
, node
);
1073 if (main_node
== NULL
)
1075 message (D_ERROR
, MSG_ERROR
, _("Cannot find node %s in help file"), node
);
1077 /* Fallback to [main], return if it also cannot be found */
1078 main_node
= search_string (fdata
, "[main]");
1079 if (main_node
== NULL
)
1081 interactive_display_finish ();
1086 help_lines
= min (LINES
- 4, max (2 * LINES
/ 3, 18));
1089 create_dlg (TRUE
, 0, 0, help_lines
+ 4, HELP_WINDOW_WIDTH
+ 4,
1090 help_colors
, help_callback
, "[Help]", _("Help"),
1091 DLG_TRYUP
| DLG_CENTER
| DLG_WANT_TAB
);
1093 selected_item
= search_string_node (main_node
, STRING_LINK_START
) - 1;
1094 currentpoint
= main_node
+ 1; /* Skip the newline following the start of the node */
1096 for (history_ptr
= HISTORY_SIZE
; history_ptr
;)
1099 history
[history_ptr
].page
= currentpoint
;
1100 history
[history_ptr
].link
= selected_item
;
1103 help_bar
= buttonbar_new (TRUE
);
1104 help_bar
->widget
.y
-= whelp
->y
;
1105 help_bar
->widget
.x
-= whelp
->x
;
1107 md
= mousedispatch_new (1, 1, help_lines
, HELP_WINDOW_WIDTH
- 2);
1109 add_widget (whelp
, md
);
1110 add_widget (whelp
, help_bar
);
1112 buttonbar_set_label (help_bar
, 1, Q_ ("ButtonBar|Help"), help_map
, NULL
);
1113 buttonbar_set_label (help_bar
, 2, Q_ ("ButtonBar|Index"), help_map
, NULL
);
1114 buttonbar_set_label (help_bar
, 3, Q_ ("ButtonBar|Prev"), help_map
, NULL
);
1115 buttonbar_set_label (help_bar
, 4, "", help_map
, NULL
);
1116 buttonbar_set_label (help_bar
, 5, "", help_map
, NULL
);
1117 buttonbar_set_label (help_bar
, 6, "", help_map
, NULL
);
1118 buttonbar_set_label (help_bar
, 7, "", help_map
, NULL
);
1119 buttonbar_set_label (help_bar
, 8, "", help_map
, NULL
);
1120 buttonbar_set_label (help_bar
, 9, "", help_map
, NULL
);
1121 buttonbar_set_label (help_bar
, 10, Q_ ("ButtonBar|Quit"), help_map
, NULL
);
1124 interactive_display_finish ();
1125 destroy_dlg (whelp
);
1128 /* --------------------------------------------------------------------------------------------- */