diff options
Diffstat (limited to 'contrib/texinfo/info/session.c')
-rw-r--r-- | contrib/texinfo/info/session.c | 2900 |
1 files changed, 1444 insertions, 1456 deletions
diff --git a/contrib/texinfo/info/session.c b/contrib/texinfo/info/session.c index 494c4a1..63a6ecd 100644 --- a/contrib/texinfo/info/session.c +++ b/contrib/texinfo/info/session.c @@ -1,9 +1,7 @@ -/* session.c -- The user windowing interface to Info. */ +/* session.c -- The user windowing interface to Info. + $Id: session.c,v 1.13 1998/02/22 22:38:30 karl Exp $ -/* This file is part of GNU Info, a program for reading online documentation - stored in Info format. - - Copyright (C) 1993, 96 Free Software Foundation, Inc. + Copyright (C) 1993, 96, 97 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -22,12 +20,7 @@ Written by Brian Fox (bfox@ai.mit.edu). */ #include "info.h" -#if defined (HAVE_SYS_FILE_H) -#include <sys/file.h> -#endif /* HAVE_SYS_FILE_H */ #include <sys/ioctl.h> -#include <fcntl.h> -#include <stdlib.h> #if defined (HAVE_SYS_TIME_H) # include <sys/time.h> @@ -42,28 +35,28 @@ static void info_clear_pending_input (), info_set_pending_input (); static void info_handle_pointer (); /* **************************************************************** */ -/* */ -/* Running an Info Session */ -/* */ +/* */ +/* Running an Info Session */ +/* */ /* **************************************************************** */ /* The place that we are reading input from. */ -static FILE *info_input_stream = (FILE *)NULL; +static FILE *info_input_stream = NULL; /* The last executed command. */ -VFunction *info_last_executed_command = (VFunction *)NULL; +VFunction *info_last_executed_command = NULL; /* Becomes non-zero when 'q' is typed to an Info window. */ int quit_info_immediately = 0; /* Array of structures describing for each window which nodes have been visited in that window. */ -INFO_WINDOW **info_windows = (INFO_WINDOW **)NULL; +INFO_WINDOW **info_windows = NULL; /* Where to add the next window, if we need to add one. */ static int info_windows_index = 0; -/* Number of slots allocated to INFO_WINDOWS. */ +/* Number of slots allocated to `info_windows'. */ static int info_windows_slots = 0; void remember_window_and_node (), forget_window_and_nodes (); @@ -88,52 +81,52 @@ begin_multiple_window_info_session (filename, nodenames) node = info_get_node (filename, nodenames[i]); if (!node) - break; + break; /* If this is the first node, initialize the info session. */ if (!window) - { - initialize_info_session (node); - window = active_window; - } + { + initialize_info_session (node, 1); + window = active_window; + } else - { - /* Find the largest window in WINDOWS, and make that be the active - one. Then split it and add our window and node to the list - of remembered windows and nodes. Then tile the windows. */ - register WINDOW *win, *largest = (WINDOW *)NULL; - int max_height = 0; - - for (win = windows; win; win = win->next) - if (win->height > max_height) - { - max_height = win->height; - largest = win; - } - - if (!largest) - { - display_update_display (windows); - info_error (CANT_FIND_WIND); - info_session (); - exit (0); - } - - active_window = largest; - window = window_make_window (node); - if (window) - { - window_tile_windows (TILE_INTERNALS); - remember_window_and_node (window, node); - } - else - { - display_update_display (windows); - info_error (WIN_TOO_SMALL); - info_session (); - exit (0); - } - } + { + /* Find the largest window in WINDOWS, and make that be the active + one. Then split it and add our window and node to the list + of remembered windows and nodes. Then tile the windows. */ + register WINDOW *win, *largest = (WINDOW *)NULL; + int max_height = 0; + + for (win = windows; win; win = win->next) + if (win->height > max_height) + { + max_height = win->height; + largest = win; + } + + if (!largest) + { + display_update_display (windows); + info_error (CANT_FIND_WIND); + info_session (); + exit (0); + } + + active_window = largest; + window = window_make_window (node); + if (window) + { + window_tile_windows (TILE_INTERNALS); + remember_window_and_node (window, node); + } + else + { + display_update_display (windows); + info_error (WIN_TOO_SMALL); + info_session (); + exit (0); + } + } } display_startup_message_and_start (); } @@ -146,7 +139,7 @@ begin_info_session_with_error (initial_node, format, arg) char *format; void *arg; { - initialize_info_session (initial_node); + initialize_info_session (initial_node, 1); info_error (format, arg, (void *)NULL); info_session (); } @@ -156,7 +149,7 @@ void begin_info_session (initial_node) NODE *initial_node; { - initialize_info_session (initial_node); + initialize_info_session (initial_node, 1); display_startup_message_and_start (); } @@ -166,7 +159,7 @@ display_startup_message_and_start () char *format; format = replace_in_documentation - ("Welcome to Info version %s. \"\\[get-help-window]\" for help, \"\\[menu-item]\" for menu item."); + (_("Welcome to Info version %s. \"\\[get-help-window]\" for help, \"\\[menu-item]\" for menu item.")); window_message_in_echo_area (format, version_string ()); info_session (); @@ -176,9 +169,8 @@ display_startup_message_and_start () void info_session () { - terminal_prep_terminal (); display_update_display (windows); - info_last_executed_command = (VFunction *)NULL; + info_last_executed_command = NULL; info_read_and_dispatch (); /* On program exit, leave the cursor at the bottom of the window, and restore the terminal I/O. */ @@ -203,19 +195,19 @@ info_read_and_dispatch () int lk; /* If we haven't just gone up or down a line, there is no - goal column for this window. */ + goal column for this window. */ if ((info_last_executed_command != info_next_line) && - (info_last_executed_command != info_prev_line)) - active_window->goal_column = -1; + (info_last_executed_command != info_prev_line)) + active_window->goal_column = -1; if (echo_area_is_active) - { - lk = echo_area_last_command_was_kill; - echo_area_prep_read (); - } + { + lk = echo_area_last_command_was_kill; + echo_area_prep_read (); + } if (!info_any_buffered_input_p ()) - display_update_display (windows); + display_update_display (windows); display_cursor_at_point (active_window); info_initialize_numeric_arg (); @@ -224,9 +216,9 @@ info_read_and_dispatch () key = info_get_input_char (); /* No errors yet. We just read a character, that's all. Only clear - the echo_area if it is not currently active. */ + the echo_area if it is not currently active. */ if (!echo_area_is_active) - window_clear_echo_area (); + window_clear_echo_area (); info_error_was_printed = 0; @@ -234,26 +226,26 @@ info_read_and_dispatch () info_dispatch_on_key (key, active_window->keymap); if (echo_area_is_active) - { - /* Echo area commands that do killing increment the value of - ECHO_AREA_LAST_COMMAND_WAS_KILL. Thus, if there is no - change in the value of this variable, the last command - executed was not a kill command. */ - if (lk == echo_area_last_command_was_kill) - echo_area_last_command_was_kill = 0; - - if (ea_last_executed_command == ea_newline || - info_aborted_echo_area) - { - ea_last_executed_command = (VFunction *)NULL; - done = 1; - } - - if (info_last_executed_command == info_quit) - quit_info_immediately = 1; - } + { + /* Echo area commands that do killing increment the value of + ECHO_AREA_LAST_COMMAND_WAS_KILL. Thus, if there is no + change in the value of this variable, the last command + executed was not a kill command. */ + if (lk == echo_area_last_command_was_kill) + echo_area_last_command_was_kill = 0; + + if (ea_last_executed_command == ea_newline || + info_aborted_echo_area) + { + ea_last_executed_command = (VFunction *)NULL; + done = 1; + } + + if (info_last_executed_command == info_quit) + quit_info_immediately = 1; + } else if (info_last_executed_command == info_quit) - done = 1; + done = 1; } } @@ -261,26 +253,30 @@ info_read_and_dispatch () extern void initialize_info_signal_handler (); /* Initialize the first info session by starting the terminal, window, - and display systems. */ + and display systems. If CLEAR_SCREEN is 0, don't clear the screen. */ void -initialize_info_session (node) +initialize_info_session (node, clear_screen) NODE *node; + int clear_screen; { - char *getenv (), *term_name; - - term_name = getenv ("TERM"); + char *term_name = getenv ("TERM"); terminal_initialize_terminal (term_name); if (terminal_is_dumb_p) { if (!term_name) - term_name = "dumb"; + term_name = "dumb"; info_error (TERM_TOO_DUMB, term_name); exit (1); } - terminal_clear_screen (); + if (clear_screen) + { + terminal_prep_terminal (); + terminal_clear_screen (); + } + initialize_info_keymaps (); window_initialize_windows (screenwidth, screenheight); initialize_info_signal_handler (); @@ -291,9 +287,13 @@ initialize_info_session (node) asynchronously deleted (e.g., user resizes window very small). */ window_deletion_notifier = forget_window_and_nodes; - /* If input has not been redirected yet, make it come from STDIN. */ + /* If input has not been redirected yet, make it come from unbuffered + standard input. */ if (!info_input_stream) - info_input_stream = stdin; + { + setbuf(stdin, NULL); + info_input_stream = stdin; + } info_windows_initialized_p = 1; } @@ -362,10 +362,8 @@ remember_window_and_node (window, node) WINDOW *window; NODE *node; { - INFO_WINDOW *info_win; - /* See if we already have this window in our list. */ - info_win = get_info_window_of_window (window); + INFO_WINDOW *info_win = get_info_window_of_window (window); /* If the window wasn't already on our list, then make a new entry. */ if (!info_win) @@ -380,21 +378,19 @@ remember_window_and_node (window, node) info_win->nodes_slots = 0; add_pointer_to_array (info_win, info_windows_index, info_windows, - info_windows_slots, 10, INFO_WINDOW *); + info_windows_slots, 10, INFO_WINDOW *); } /* If this node, the current pagetop, and the current point are the - same as the last saved node and pagetop, don't really add this to - the list of history nodes. */ - { - int ni = info_win->nodes_index - 1; - - if ((ni != -1) && - (info_win->nodes[ni]->contents == node->contents) && - (info_win->pagetops[ni] == window->pagetop) && - (info_win->points[ni] == window->point)) - return; - } + same as the current saved node and pagetop, don't really add this to + the list of history nodes. This may happen only at the very + beginning of the program, I'm not sure. --karl */ + if (info_win->nodes + && info_win->current >= 0 + && info_win->nodes[info_win->current]->contents == node->contents + && info_win->pagetops[info_win->current] == window->pagetop + && info_win->points[info_win->current] == window->point) + return; /* Remember this node, the currently displayed pagetop, and the current location of point in this window. Because we are updating pagetops @@ -402,22 +398,20 @@ remember_window_and_node (window, node) add_pointer_to_array macro here. */ if (info_win->nodes_index + 2 >= info_win->nodes_slots) { - info_win->nodes = (NODE **) - xrealloc (info_win->nodes, - (info_win->nodes_slots += 20) * sizeof (NODE *)); - - info_win->pagetops = (int *) - xrealloc (info_win->pagetops, info_win->nodes_slots * sizeof (int)); - - info_win->points = (long *) - xrealloc (info_win->points, info_win->nodes_slots * sizeof (long)); + info_win->nodes_slots += 20; + info_win->nodes = (NODE **) xrealloc (info_win->nodes, + info_win->nodes_slots * sizeof (NODE *)); + info_win->pagetops = (int *) xrealloc (info_win->pagetops, + info_win->nodes_slots * sizeof (int)); + info_win->points = (long *) xrealloc (info_win->points, + info_win->nodes_slots * sizeof (long)); } info_win->nodes[info_win->nodes_index] = node; info_win->pagetops[info_win->nodes_index] = window->pagetop; info_win->points[info_win->nodes_index] = window->point; info_win->current = info_win->nodes_index++; - info_win->nodes[info_win->nodes_index] = (NODE *)NULL; + info_win->nodes[info_win->nodes_index] = NULL; info_win->pagetops[info_win->nodes_index] = 0; info_win->points[info_win->nodes_index] = 0; } @@ -428,18 +422,17 @@ static void consistency_check_info_windows () { register int i; - INFO_WINDOW *info_win; for (i = 0; i < info_windows_index; i++) { WINDOW *win; for (win = windows; win; win = win->next) - if (win == info_windows[i]->window) - break; + if (win == info_windows[i]->window) + break; if (!win) - abort (); + abort (); } } #endif /* DEBUG_FORGET_WINDOW_AND_NODES */ @@ -460,27 +453,27 @@ forget_window_and_nodes (window) if (info_win) { while (i < info_windows_index) - { - info_windows[i] = info_windows[i + 1]; - i++; - } + { + info_windows[i] = info_windows[i + 1]; + i++; + } info_windows_index--; info_windows[info_windows_index] = (INFO_WINDOW *)NULL; if (info_win->nodes) - { - /* Free the node structures which held onto internal node contents - here. This doesn't free the contents; we have a garbage collector - which does that. */ - for (i = 0; info_win->nodes[i]; i++) - if (internal_info_node_p (info_win->nodes[i])) - free (info_win->nodes[i]); - free (info_win->nodes); - - maybe_free (info_win->pagetops); - maybe_free (info_win->points); - } + { + /* Free the node structures which held onto internal node contents + here. This doesn't free the contents; we have a garbage collector + which does that. */ + for (i = 0; info_win->nodes[i]; i++) + if (internal_info_node_p (info_win->nodes[i])) + free (info_win->nodes[i]); + free (info_win->nodes); + + maybe_free (info_win->pagetops); + maybe_free (info_win->points); + } free (info_win); } @@ -511,9 +504,9 @@ info_set_node_of_window (window, node) /* **************************************************************** */ -/* */ -/* Info Movement Commands */ -/* */ +/* */ +/* Info Movement Commands */ +/* */ /* **************************************************************** */ /* Change the pagetop of WINDOW to DESIRED_TOP, perhaps scrolling the screen @@ -557,8 +550,8 @@ set_window_pagetop (window, desired_top) amount = desired_top - old_pagetop; if ((amount >= window->height) || - (((window->height - amount) * 10) < window->height)) - return; + (((window->height - amount) * 10) < window->height)) + return; start = amount + window->first_row; end = window->height + window->first_row; @@ -572,8 +565,8 @@ set_window_pagetop (window, desired_top) amount = old_pagetop - desired_top; if ((amount >= window->height) || - (((window->height - amount) * 10) < window->height)) - return; + (((window->height - amount) * 10) < window->height)) + return; start = window->first_row; end = (window->first_row + window->height) - amount; @@ -621,7 +614,7 @@ move_to_new_line (old, new, window) int goal; if (new >= window->line_count || new < 0) - return; + return; goal = window_get_goal_column (window); window->goal_column = goal; @@ -633,7 +626,7 @@ move_to_new_line (old, new, window) } /* Move WINDOW's point down to the next line if possible. */ -DECLARE_INFO_COMMAND (info_next_line, "Move down to the next line") +DECLARE_INFO_COMMAND (info_next_line, _("Move down to the next line")) { int old_line, new_line; @@ -648,7 +641,7 @@ DECLARE_INFO_COMMAND (info_next_line, "Move down to the next line") } /* Move WINDOW's point up to the previous line if possible. */ -DECLARE_INFO_COMMAND (info_prev_line, "Move up to the previous line") +DECLARE_INFO_COMMAND (info_prev_line, _("Move up to the previous line")) { int old_line, new_line; @@ -663,7 +656,7 @@ DECLARE_INFO_COMMAND (info_prev_line, "Move up to the previous line") } /* Move WINDOW's point to the end of the true line. */ -DECLARE_INFO_COMMAND (info_end_of_line, "Move to the end of the line") +DECLARE_INFO_COMMAND (info_end_of_line, _("Move to the end of the line")) { register int point, len; register char *buffer; @@ -683,7 +676,7 @@ DECLARE_INFO_COMMAND (info_end_of_line, "Move to the end of the line") } /* Move WINDOW's point to the beginning of the true line. */ -DECLARE_INFO_COMMAND (info_beginning_of_line, "Move to the start of the line") +DECLARE_INFO_COMMAND (info_beginning_of_line, _("Move to the start of the line")) { register int point; register char *buffer; @@ -702,7 +695,7 @@ DECLARE_INFO_COMMAND (info_beginning_of_line, "Move to the start of the line") } /* Move point forward in the node. */ -DECLARE_INFO_COMMAND (info_forward_char, "Move forward a character") +DECLARE_INFO_COMMAND (info_forward_char, _("Move forward a character")) { if (count < 0) info_backward_char (window, -count, key); @@ -711,14 +704,14 @@ DECLARE_INFO_COMMAND (info_forward_char, "Move forward a character") window->point += count; if (window->point >= window->node->nodelen) - window->point = window->node->nodelen - 1; + window->point = window->node->nodelen - 1; info_show_point (window); } } /* Move point backward in the node. */ -DECLARE_INFO_COMMAND (info_backward_char, "Move backward a character") +DECLARE_INFO_COMMAND (info_backward_char, _("Move backward a character")) { if (count < 0) info_forward_char (window, -count, key); @@ -727,7 +720,7 @@ DECLARE_INFO_COMMAND (info_backward_char, "Move backward a character") window->point -= count; if (window->point < 0) - window->point = 0; + window->point = 0; info_show_point (window); } @@ -736,7 +729,7 @@ DECLARE_INFO_COMMAND (info_backward_char, "Move backward a character") #define alphabetic(c) (islower (c) || isupper (c) || isdigit (c)) /* Move forward a word in this node. */ -DECLARE_INFO_COMMAND (info_forward_word, "Move forward a word") +DECLARE_INFO_COMMAND (info_forward_word, _("Move forward a word")) { long point; char *buffer; @@ -755,37 +748,37 @@ DECLARE_INFO_COMMAND (info_forward_word, "Move forward a word") while (count) { if (point + 1 >= end) - return; + return; /* If we are not in a word, move forward until we are in one. - Then, move forward until we hit a non-alphabetic character. */ + Then, move forward until we hit a non-alphabetic character. */ c = buffer[point]; if (!alphabetic (c)) - { - while (++point < end) - { - c = buffer[point]; - if (alphabetic (c)) - break; - } - } + { + while (++point < end) + { + c = buffer[point]; + if (alphabetic (c)) + break; + } + } if (point >= end) return; while (++point < end) - { - c = buffer[point]; - if (!alphabetic (c)) - break; - } + { + c = buffer[point]; + if (!alphabetic (c)) + break; + } --count; } window->point = point; info_show_point (window); } -DECLARE_INFO_COMMAND (info_backward_word, "Move backward a word") +DECLARE_INFO_COMMAND (info_backward_word, _("Move backward a word")) { long point; char *buffer; @@ -803,31 +796,31 @@ DECLARE_INFO_COMMAND (info_backward_word, "Move backward a word") while (count) { if (point == 0) - break; + break; /* Like info_forward_word (), except that we look at the - characters just before point. */ + characters just before point. */ c = buffer[point - 1]; if (!alphabetic (c)) - { - while (--point) - { - c = buffer[point - 1]; - if (alphabetic (c)) - break; - } - } + { + while (--point) + { + c = buffer[point - 1]; + if (alphabetic (c)) + break; + } + } while (point) - { - c = buffer[point - 1]; - if (!alphabetic (c)) - break; - else - --point; - } + { + c = buffer[point - 1]; + if (!alphabetic (c)) + break; + else + --point; + } --count; } window->point = point; @@ -859,9 +852,9 @@ times_description (count) break; if (counter_names[i]) - sprintf (td_buffer, "%s%s", counter_names[i], count > 2 ? " times" : ""); + sprintf (td_buffer, "%s%s", counter_names[i], count > 2 ? _(" times") : ""); else - sprintf (td_buffer, "%d times", count); + sprintf (td_buffer, _("%d times"), count); return (td_buffer); } @@ -870,11 +863,11 @@ times_description (count) already at the bottom of a node. Possible values are defined in session.h. The meanings are: - IS_Continuous Try to get first menu item, or failing that, the - "Next:" pointer, or failing that, the "Up:" and - "Next:" of the up. - IS_NextOnly Try to get "Next:" menu item. - IS_PageOnly Simply give up at the bottom of a node. */ + IS_Continuous Try to get first menu item, or failing that, the + "Next:" pointer, or failing that, the "Up:" and + "Next:" of the up. + IS_NextOnly Try to get "Next:" menu item. + IS_PageOnly Simply give up at the bottom of a node. */ int info_scroll_behaviour = IS_Continuous; @@ -899,136 +892,136 @@ forward_move_node_structure (window, behaviour) case IS_NextOnly: info_next_label_of_node (window->node); if (!info_parsed_nodename && !info_parsed_filename) - info_error ("No \"Next\" pointer for this node."); + info_error (_("No \"Next\" pointer for this node.")); else - { - window_message_in_echo_area ("Following \"Next\" node..."); - info_handle_pointer ("Next", window); - } + { + window_message_in_echo_area (_("Following \"Next\" node...")); + info_handle_pointer (_("Next"), window); + } break; case IS_Continuous: { - /* First things first. If this node contains a menu, move down - into the menu. */ - { - REFERENCE **menu; - - menu = info_menu_of_node (window->node); - - if (menu) - { - info_free_references (menu); - window_message_in_echo_area ("Selecting first menu item..."); - info_menu_digit (window, 1, '1'); - return; - } - } - - /* Okay, this node does not contain a menu. If it contains a - "Next:" pointer, use that. */ - info_next_label_of_node (window->node); - if (info_label_was_found) - { - window_message_in_echo_area ("Selecting \"Next\" node..."); - info_handle_pointer ("Next", window); - return; - } - - /* Okay, there wasn't a "Next:" for this node. Move "Up:" until we - can move "Next:". If that isn't possible, complain that there - are no more nodes. */ - { - int up_counter, old_current; - INFO_WINDOW *info_win; - - /* Remember the current node and location. */ - info_win = get_info_window_of_window (window); - old_current = info_win->current; - - /* Back up through the "Up:" pointers until we have found a "Next:" - that isn't the same as the first menu item found in that node. */ - up_counter = 0; - while (!info_error_was_printed) - { - info_up_label_of_node (window->node); - if (info_label_was_found) - { - info_handle_pointer ("Up", window); - if (info_error_was_printed) - continue; - - up_counter++; - - info_next_label_of_node (window->node); - - /* If no "Next" pointer, keep backing up. */ - if (!info_label_was_found) - continue; - - /* If this node's first menu item is the same as this node's - Next pointer, keep backing up. */ - if (!info_parsed_filename) - { - REFERENCE **menu; - char *next_nodename; - - /* Remember the name of the Next node, since reading - the menu can overwrite the contents of the - info_parsed_xxx strings. */ - next_nodename = strdup (info_parsed_nodename); - - menu = info_menu_of_node (window->node); - if (menu && - (strcmp - (menu[0]->nodename, next_nodename) == 0)) - { - info_free_references (menu); - free (next_nodename); - continue; - } - else - { - /* Restore the world to where it was before - reading the menu contents. */ - info_free_references (menu); - free (next_nodename); - info_next_label_of_node (window->node); - } - } - - /* This node has a "Next" pointer, and it is not the - same as the first menu item found in this node. */ - window_message_in_echo_area - ("Moving \"Up\" %s, then \"Next\".", - times_description (up_counter)); - - info_handle_pointer ("Next", window); - return; - } - else - { - /* No more "Up" pointers. Print an error, and call it - quits. */ - register int i; - - for (i = 0; i < up_counter; i++) - { - info_win->nodes_index--; - free (info_win->nodes[info_win->nodes_index]); - info_win->nodes[info_win->nodes_index] = (NODE *)NULL; - } - info_win->current = old_current; - window->node = info_win->nodes[old_current]; - window->pagetop = info_win->pagetops[old_current]; - window->point = info_win->points[old_current]; - recalculate_line_starts (window); - window->flags |= W_UpdateWindow; - info_error ("No more nodes."); - } - } - } - break; + /* First things first. If this node contains a menu, move down + into the menu. */ + { + REFERENCE **menu; + + menu = info_menu_of_node (window->node); + + if (menu) + { + info_free_references (menu); + window_message_in_echo_area (_("Selecting first menu item...")); + info_menu_digit (window, 1, '1'); + return; + } + } + + /* Okay, this node does not contain a menu. If it contains a + "Next:" pointer, use that. */ + info_next_label_of_node (window->node); + if (info_label_was_found) + { + window_message_in_echo_area (_("Selecting \"Next\" node...")); + info_handle_pointer (_("Next"), window); + return; + } + + /* Okay, there wasn't a "Next:" for this node. Move "Up:" until we + can move "Next:". If that isn't possible, complain that there + are no more nodes. */ + { + int up_counter, old_current; + INFO_WINDOW *info_win; + + /* Remember the current node and location. */ + info_win = get_info_window_of_window (window); + old_current = info_win->current; + + /* Back up through the "Up:" pointers until we have found a "Next:" + that isn't the same as the first menu item found in that node. */ + up_counter = 0; + while (!info_error_was_printed) + { + info_up_label_of_node (window->node); + if (info_label_was_found) + { + info_handle_pointer (_("Up"), window); + if (info_error_was_printed) + continue; + + up_counter++; + + info_next_label_of_node (window->node); + + /* If no "Next" pointer, keep backing up. */ + if (!info_label_was_found) + continue; + + /* If this node's first menu item is the same as this node's + Next pointer, keep backing up. */ + if (!info_parsed_filename) + { + REFERENCE **menu; + char *next_nodename; + + /* Remember the name of the Next node, since reading + the menu can overwrite the contents of the + info_parsed_xxx strings. */ + next_nodename = xstrdup (info_parsed_nodename); + + menu = info_menu_of_node (window->node); + if (menu && + (strcmp + (menu[0]->nodename, next_nodename) == 0)) + { + info_free_references (menu); + free (next_nodename); + continue; + } + else + { + /* Restore the world to where it was before + reading the menu contents. */ + info_free_references (menu); + free (next_nodename); + info_next_label_of_node (window->node); + } + } + + /* This node has a "Next" pointer, and it is not the + same as the first menu item found in this node. */ + window_message_in_echo_area + ("Moving \"Up\" %s, then \"Next\".", + times_description (up_counter)); + + info_handle_pointer (_("Next"), window); + return; + } + else + { + /* No more "Up" pointers. Print an error, and call it + quits. */ + register int i; + + for (i = 0; i < up_counter; i++) + { + info_win->nodes_index--; + free (info_win->nodes[info_win->nodes_index]); + info_win->nodes[info_win->nodes_index] = (NODE *)NULL; + } + info_win->current = old_current; + window->node = info_win->nodes[old_current]; + window->pagetop = info_win->pagetops[old_current]; + window->point = info_win->points[old_current]; + recalculate_line_starts (window); + window->flags |= W_UpdateWindow; + info_error (_("No more nodes.")); + } + } + } + break; } } } @@ -1048,115 +1041,115 @@ backward_move_node_structure (window, behaviour) case IS_NextOnly: info_prev_label_of_node (window->node); if (!info_parsed_nodename && !info_parsed_filename) - info_error ("No \"Prev\" for this node."); + info_error (_("No \"Prev\" for this node.")); else - { - window_message_in_echo_area ("Moving \"Prev\" in this window."); - info_handle_pointer ("Prev", window); - } + { + window_message_in_echo_area (_("Moving \"Prev\" in this window.")); + info_handle_pointer (_("Prev"), window); + } break; case IS_Continuous: info_prev_label_of_node (window->node); if (!info_parsed_nodename && !info_parsed_filename) - { - info_up_label_of_node (window->node); - if (!info_parsed_nodename && !info_parsed_filename) - info_error ("No \"Prev\" or \"Up\" for this node."); - else - { - window_message_in_echo_area ("Moving \"Up\" in this window."); - info_handle_pointer ("Up", window); - } - } + { + info_up_label_of_node (window->node); + if (!info_parsed_nodename && !info_parsed_filename) + info_error (_("No \"Prev\" or \"Up\" for this node.")); + else + { + window_message_in_echo_area (_("Moving \"Up\" in this window.")); + info_handle_pointer (_("Up"), window); + } + } else - { - REFERENCE **menu; - int inhibit_menu_traversing = 0; - - /* Watch out! If this node's Prev is the same as the Up, then - move Up. Otherwise, we could move Prev, and then to the last - menu item in the Prev. This would cause the user to loop - through a subsection of the info file. */ - if (!info_parsed_filename && info_parsed_nodename) - { - char *pnode; - - pnode = strdup (info_parsed_nodename); - info_up_label_of_node (window->node); - - if (!info_parsed_filename && info_parsed_nodename && - strcmp (info_parsed_nodename, pnode) == 0) - { - /* The nodes are the same. Inhibit moving to the last - menu item. */ - free (pnode); - inhibit_menu_traversing = 1; - } - else - { - free (pnode); - info_prev_label_of_node (window->node); - } - } - - /* Move to the previous node. If this node now contains a menu, - and we have not inhibited movement to it, move to the node - corresponding to the last menu item. */ - window_message_in_echo_area ("Moving \"Prev\" in this window."); - info_handle_pointer ("Prev", window); - - if (!inhibit_menu_traversing) - { - while (!info_error_was_printed && - (menu = info_menu_of_node (window->node))) - { - info_free_references (menu); - window_message_in_echo_area - ("Moving to \"Prev\"'s last menu item."); - info_menu_digit (window, 1, '0'); - } - } - } + { + REFERENCE **menu; + int inhibit_menu_traversing = 0; + + /* Watch out! If this node's Prev is the same as the Up, then + move Up. Otherwise, we could move Prev, and then to the last + menu item in the Prev. This would cause the user to loop + through a subsection of the info file. */ + if (!info_parsed_filename && info_parsed_nodename) + { + char *pnode; + + pnode = xstrdup (info_parsed_nodename); + info_up_label_of_node (window->node); + + if (!info_parsed_filename && info_parsed_nodename && + strcmp (info_parsed_nodename, pnode) == 0) + { + /* The nodes are the same. Inhibit moving to the last + menu item. */ + free (pnode); + inhibit_menu_traversing = 1; + } + else + { + free (pnode); + info_prev_label_of_node (window->node); + } + } + + /* Move to the previous node. If this node now contains a menu, + and we have not inhibited movement to it, move to the node + corresponding to the last menu item. */ + window_message_in_echo_area (_("Moving \"Prev\" in this window.")); + info_handle_pointer (_("Prev"), window); + + if (!inhibit_menu_traversing) + { + while (!info_error_was_printed && + (menu = info_menu_of_node (window->node))) + { + info_free_references (menu); + window_message_in_echo_area + (_("Moving to \"Prev\"'s last menu item.")); + info_menu_digit (window, 1, '0'); + } + } + } break; } } /* Move continuously forward through the node structure of this info file. */ DECLARE_INFO_COMMAND (info_global_next_node, - "Move forwards or down through node structure") + _("Move forwards or down through node structure")) { if (count < 0) info_global_prev_node (window, -count, key); else { while (count && !info_error_was_printed) - { - forward_move_node_structure (window, IS_Continuous); - count--; - } + { + forward_move_node_structure (window, IS_Continuous); + count--; + } } } /* Move continuously backward through the node structure of this info file. */ DECLARE_INFO_COMMAND (info_global_prev_node, - "Move backwards or up through node structure") + _("Move backwards or up through node structure")) { if (count < 0) info_global_next_node (window, -count, key); else { while (count && !info_error_was_printed) - { - backward_move_node_structure (window, IS_Continuous); - count--; - } + { + backward_move_node_structure (window, IS_Continuous); + count--; + } } } /* Show the next screen of WINDOW's node. */ -DECLARE_INFO_COMMAND (info_scroll_forward, "Scroll forward in this window") +DECLARE_INFO_COMMAND (info_scroll_forward, _("Scroll forward in this window")) { if (count < 0) info_scroll_backward (window, -count, key); @@ -1165,43 +1158,43 @@ DECLARE_INFO_COMMAND (info_scroll_forward, "Scroll forward in this window") int desired_top; /* Without an explicit numeric argument, scroll the bottom two - lines to the top of this window, Or, if at bottom of window, - and the user wishes to scroll through nodes get the "Next" node - for this window. */ + lines to the top of this window, Or, if at bottom of window, + and the user wishes to scroll through nodes get the "Next" node + for this window. */ if (!info_explicit_arg && count == 1) - { - desired_top = window->pagetop + (window->height - 2); - - /* If there are no more lines to scroll here, error, or get - another node, depending on INFO_SCROLL_BEHAVIOUR. */ - if (desired_top > window->line_count) - { - int behaviour = info_scroll_behaviour; - - /* Here is a hack. If the key being used is not SPC, do the - PageOnly behaviour. */ - if (key != SPC && key != DEL) - behaviour = IS_PageOnly; - - forward_move_node_structure (window, behaviour); - return; - } - } + { + desired_top = window->pagetop + (window->height - 2); + + /* If there are no more lines to scroll here, error, or get + another node, depending on INFO_SCROLL_BEHAVIOUR. */ + if (desired_top > window->line_count) + { + int behaviour = info_scroll_behaviour; + + /* Here is a hack. If the key being used is not SPC, do the + PageOnly behaviour. */ + if (key != SPC && key != DEL) + behaviour = IS_PageOnly; + + forward_move_node_structure (window, behaviour); + return; + } + } else - desired_top = window->pagetop + count; + desired_top = window->pagetop + count; if (desired_top >= window->line_count) - desired_top = window->line_count - 2; + desired_top = window->line_count - 2; if (window->pagetop > desired_top) - return; + return; else - set_window_pagetop (window, desired_top); + set_window_pagetop (window, desired_top); } } /* Show the previous screen of WINDOW's node. */ -DECLARE_INFO_COMMAND (info_scroll_backward, "Scroll backward in this window") +DECLARE_INFO_COMMAND (info_scroll_backward, _("Scroll backward in this window")) { if (count < 0) info_scroll_forward (window, -count, key); @@ -1210,58 +1203,58 @@ DECLARE_INFO_COMMAND (info_scroll_backward, "Scroll backward in this window") int desired_top; /* Without an explicit numeric argument, scroll the top two lines - to the bottom of this window, or move to the previous, or Up'th - node. */ + to the bottom of this window, or move to the previous, or Up'th + node. */ if (!info_explicit_arg && count == 1) - { - desired_top = window->pagetop - (window->height - 2); - - if ((desired_top < 0) && (window->pagetop == 0)) - { - int behaviour = info_scroll_behaviour; - - /* Same kind of hack as in info_scroll_forward. If the key - used to invoke this command is not DEL, do only the PageOnly - behaviour. */ - if (key != DEL && key != SPC) - behaviour = IS_PageOnly; - - backward_move_node_structure (window, behaviour); - return; - } - } + { + desired_top = window->pagetop - (window->height - 2); + + if ((desired_top < 0) && (window->pagetop == 0)) + { + int behaviour = info_scroll_behaviour; + + /* Same kind of hack as in info_scroll_forward. If the key + used to invoke this command is not DEL, do only the PageOnly + behaviour. */ + if (key != DEL && key != SPC) + behaviour = IS_PageOnly; + + backward_move_node_structure (window, behaviour); + return; + } + } else - desired_top = window->pagetop - count; + desired_top = window->pagetop - count; if (desired_top < 0) - desired_top = 0; + desired_top = 0; set_window_pagetop (window, desired_top); } } /* Move to the beginning of the node. */ -DECLARE_INFO_COMMAND (info_beginning_of_node, "Move to the start of this node") +DECLARE_INFO_COMMAND (info_beginning_of_node, _("Move to the start of this node")) { window->pagetop = window->point = 0; window->flags |= W_UpdateWindow; } /* Move to the end of the node. */ -DECLARE_INFO_COMMAND (info_end_of_node, "Move to the end of this node") +DECLARE_INFO_COMMAND (info_end_of_node, _("Move to the end of this node")) { window->point = window->node->nodelen - 1; info_show_point (window); } /* **************************************************************** */ -/* */ -/* Commands for Manipulating Windows */ -/* */ +/* */ +/* Commands for Manipulating Windows */ +/* */ /* **************************************************************** */ /* Make the next window in the chain be the active window. */ -DECLARE_INFO_COMMAND (info_next_window, "Select the next window") +DECLARE_INFO_COMMAND (info_next_window, _("Select the next window")) { if (count < 0) { @@ -1279,20 +1272,20 @@ DECLARE_INFO_COMMAND (info_next_window, "Select the next window") while (count--) { if (window->next) - window = window->next; + window = window->next; else - { - if (window == the_echo_area || !echo_area_is_active) - window = windows; - else - window = the_echo_area; - } + { + if (window == the_echo_area || !echo_area_is_active) + window = windows; + else + window = the_echo_area; + } } if (active_window != window) { if (auto_footnotes_p) - info_get_or_remove_footnotes (window); + info_get_or_remove_footnotes (window); window->flags |= W_UpdateWindow; active_window = window; @@ -1300,7 +1293,7 @@ DECLARE_INFO_COMMAND (info_next_window, "Select the next window") } /* Make the previous window in the chain be the active window. */ -DECLARE_INFO_COMMAND (info_prev_window, "Select the previous window") +DECLARE_INFO_COMMAND (info_prev_window, _("Select the previous window")) { if (count < 0) { @@ -1319,30 +1312,30 @@ DECLARE_INFO_COMMAND (info_prev_window, "Select the previous window") while (count--) { /* If we are in the echo area, or if the echo area isn't active and we - are in the first window, find the last window in the chain. */ + are in the first window, find the last window in the chain. */ if (window == the_echo_area || - (window == windows && !echo_area_is_active)) - { - register WINDOW *win, *last; + (window == windows && !echo_area_is_active)) + { + register WINDOW *win, *last; - for (win = windows; win; win = win->next) - last = win; + for (win = windows; win; win = win->next) + last = win; - window = last; - } + window = last; + } else - { - if (window == windows) - window = the_echo_area; - else - window = window->prev; - } + { + if (window == windows) + window = the_echo_area; + else + window = window->prev; + } } if (active_window != window) { if (auto_footnotes_p) - info_get_or_remove_footnotes (window); + info_get_or_remove_footnotes (window); window->flags |= W_UpdateWindow; active_window = window; @@ -1351,7 +1344,7 @@ DECLARE_INFO_COMMAND (info_prev_window, "Select the previous window") /* Split WINDOW into two windows, both showing the same node. If we are automatically tiling windows, re-tile after the split. */ -DECLARE_INFO_COMMAND (info_split_window, "Split the current window") +DECLARE_INFO_COMMAND (info_split_window, _("Split the current window")) { WINDOW *split, *old_active; int pagetop; @@ -1375,54 +1368,54 @@ DECLARE_INFO_COMMAND (info_split_window, "Split the current window") #if defined (SPLIT_BEFORE_ACTIVE) /* Try to scroll the old window into its new postion. */ if (pagetop == window->pagetop) - { - int start, end, amount; - - start = split->first_row; - end = start + window->height; - amount = split->height + 1; - display_scroll_display (start, end, amount); - } + { + int start, end, amount; + + start = split->first_row; + end = start + window->height; + amount = split->height + 1; + display_scroll_display (start, end, amount); + } #else /* !SPLIT_BEFORE_ACTIVE */ /* Make sure point still appears in the active window. */ info_show_point (window); #endif /* !SPLIT_BEFORE_ACTIVE */ /* If the window just split was one internal to Info, try to display - something else in it. */ + something else in it. */ if (internal_info_node_p (split->node)) - { - register int i, j; - INFO_WINDOW *iw; - NODE *node = (NODE *)NULL; - char *filename; - - for (i = 0; iw = info_windows[i]; i++) - { - for (j = 0; j < iw->nodes_index; j++) - if (!internal_info_node_p (iw->nodes[j])) - { - if (iw->nodes[j]->parent) - filename = iw->nodes[j]->parent; - else - filename = iw->nodes[j]->filename; - - node = info_get_node (filename, iw->nodes[j]->nodename); - if (node) - { - window_set_node_of_window (split, node); - i = info_windows_index - 1; - break; - } - } - } - } + { + register int i, j; + INFO_WINDOW *iw; + NODE *node = (NODE *)NULL; + char *filename; + + for (i = 0; (iw = info_windows[i]); i++) + { + for (j = 0; j < iw->nodes_index; j++) + if (!internal_info_node_p (iw->nodes[j])) + { + if (iw->nodes[j]->parent) + filename = iw->nodes[j]->parent; + else + filename = iw->nodes[j]->filename; + + node = info_get_node (filename, iw->nodes[j]->nodename); + if (node) + { + window_set_node_of_window (split, node); + i = info_windows_index - 1; + break; + } + } + } + } split->pagetop = window->pagetop; if (auto_tiling_p) - window_tile_windows (DONT_TILE_INTERNALS); + window_tile_windows (DONT_TILE_INTERNALS); else - window_adjust_pagetop (split); + window_adjust_pagetop (split); remember_window_and_node (split, split->node); } @@ -1432,7 +1425,7 @@ DECLARE_INFO_COMMAND (info_split_window, "Split the current window") automatically displaying footnotes, show or remove the footnotes window. If we are automatically tiling windows, re-tile after the deletion. */ -DECLARE_INFO_COMMAND (info_delete_window, "Delete the current window") +DECLARE_INFO_COMMAND (info_delete_window, _("Delete the current window")) { if (!windows->next) { @@ -1440,17 +1433,17 @@ DECLARE_INFO_COMMAND (info_delete_window, "Delete the current window") } else if (window->flags & W_WindowIsPerm) { - info_error ("Cannot delete a permanent window"); + info_error (_("Cannot delete a permanent window")); } else { info_delete_window_internal (window); if (auto_footnotes_p) - info_get_or_remove_footnotes (active_window); + info_get_or_remove_footnotes (active_window); if (auto_tiling_p) - window_tile_windows (DONT_TILE_INTERNALS); + window_tile_windows (DONT_TILE_INTERNALS); } } @@ -1463,19 +1456,19 @@ info_delete_window_internal (window) if (windows->next && ((window->flags & W_WindowIsPerm) == 0)) { /* We not only delete the window from the display, we forget it from - our list of remembered windows. */ + our list of remembered windows. */ forget_window_and_nodes (window); window_delete_window (window); if (echo_area_is_active) - echo_area_inform_of_deleted_window (window); + echo_area_inform_of_deleted_window (window); } } /* Just keep WINDOW, deleting all others. */ -DECLARE_INFO_COMMAND (info_keep_one_window, "Delete all other windows") +DECLARE_INFO_COMMAND (info_keep_one_window, _("Delete all other windows")) { - int num_deleted; /* The number of windows we deleted. */ + int num_deleted; /* The number of windows we deleted. */ int pagetop, start, end; /* Remember a few things about this window. We may be able to speed up @@ -1491,14 +1484,14 @@ DECLARE_INFO_COMMAND (info_keep_one_window, "Delete all other windows") WINDOW *win; /* Find an eligible window and delete it. If no eligible windows - are found, we are done. A window is eligible for deletion if - is it not permanent, and it is not WINDOW. */ + are found, we are done. A window is eligible for deletion if + is it not permanent, and it is not WINDOW. */ for (win = windows; win; win = win->next) - if (win != window && ((win->flags & W_WindowIsPerm) == 0)) - break; + if (win != window && ((win->flags & W_WindowIsPerm) == 0)) + break; if (!win) - break; + break; info_delete_window_internal (win); num_deleted++; @@ -1519,7 +1512,7 @@ DECLARE_INFO_COMMAND (info_keep_one_window, "Delete all other windows") } /* Scroll the "other" window of WINDOW. */ -DECLARE_INFO_COMMAND (info_scroll_other_window, "Scroll the other window") +DECLARE_INFO_COMMAND (info_scroll_other_window, _("Scroll the other window")) { WINDOW *other; @@ -1539,7 +1532,7 @@ DECLARE_INFO_COMMAND (info_scroll_other_window, "Scroll the other window") } /* Change the size of WINDOW by AMOUNT. */ -DECLARE_INFO_COMMAND (info_grow_window, "Grow (or shrink) this window") +DECLARE_INFO_COMMAND (info_grow_window, _("Grow (or shrink) this window")) { window_change_window_height (window, count); } @@ -1550,22 +1543,22 @@ int auto_tiling_p = 0; /* Tile all of the visible windows. */ DECLARE_INFO_COMMAND (info_tile_windows, - "Divide the available screen space among the visible windows") + _("Divide the available screen space among the visible windows")) { window_tile_windows (TILE_INTERNALS); } /* Toggle the state of this window's wrapping of lines. */ DECLARE_INFO_COMMAND (info_toggle_wrap, - "Toggle the state of line wrapping in the current window") + _("Toggle the state of line wrapping in the current window")) { window_toggle_wrap (window); } /* **************************************************************** */ -/* */ -/* Info Node Commands */ -/* */ +/* */ +/* Info Node Commands */ +/* */ /* **************************************************************** */ /* Using WINDOW for various defaults, select the node referenced by ENTRY @@ -1587,12 +1580,12 @@ info_select_reference (window, entry) filename = window->node->filename; if (filename) - filename = strdup (filename); + filename = xstrdup (filename); if (entry->nodename) - nodename = strdup (entry->nodename); + nodename = xstrdup (entry->nodename); else - nodename = strdup ("Top"); + nodename = xstrdup ("Top"); node = info_get_node (filename, nodename); @@ -1602,25 +1595,25 @@ info_select_reference (window, entry) if (!node) { if (info_recent_file_error) - file_system_error = strdup (info_recent_file_error); + file_system_error = xstrdup (info_recent_file_error); if (entry->nodename && (strcmp (entry->nodename, entry->label) == 0)) - { - node = info_get_node (entry->label, "Top"); - if (!node && info_recent_file_error) - { - maybe_free (file_system_error); - file_system_error = strdup (info_recent_file_error); - } - } + { + node = info_get_node (entry->label, "Top"); + if (!node && info_recent_file_error) + { + maybe_free (file_system_error); + file_system_error = xstrdup (info_recent_file_error); + } + } } if (!node) { if (file_system_error) - info_error (file_system_error); + info_error (file_system_error); else - info_error (CANT_FIND_NODE, nodename); + info_error (CANT_FIND_NODE, nodename); } maybe_free (file_system_error); @@ -1670,42 +1663,42 @@ info_handle_pointer (label, window) filename = nodename = (char *)NULL; if (info_parsed_filename) - filename = strdup (info_parsed_filename); + filename = xstrdup (info_parsed_filename); else - { - if (window->node->parent) - filename = strdup (window->node->parent); - else if (window->node->filename) - filename = strdup (window->node->filename); - } + { + if (window->node->parent) + filename = xstrdup (window->node->parent); + else if (window->node->filename) + filename = xstrdup (window->node->filename); + } if (info_parsed_nodename) - nodename = strdup (info_parsed_nodename); + nodename = xstrdup (info_parsed_nodename); else - nodename = strdup ("Top"); + nodename = xstrdup ("Top"); node = info_get_node (filename, nodename); if (node) - { - INFO_WINDOW *info_win; - - info_win = get_info_window_of_window (window); - if (info_win) - { - info_win->pagetops[info_win->current] = window->pagetop; - info_win->points[info_win->current] = window->point; - } - set_remembered_pagetop_and_point (window); - info_set_node_of_window (window, node); - } + { + INFO_WINDOW *info_win; + + info_win = get_info_window_of_window (window); + if (info_win) + { + info_win->pagetops[info_win->current] = window->pagetop; + info_win->points[info_win->current] = window->point; + } + set_remembered_pagetop_and_point (window); + info_set_node_of_window (window, node); + } else - { - if (info_recent_file_error) - info_error (info_recent_file_error); - else - info_error (CANT_FILE_NODE, filename, nodename); - } + { + if (info_recent_file_error) + info_error (info_recent_file_error); + else + info_error (CANT_FILE_NODE, filename, nodename); + } free (filename); free (nodename); @@ -1718,30 +1711,30 @@ info_handle_pointer (label, window) /* Make WINDOW display the "Next:" node of the node currently being displayed. */ -DECLARE_INFO_COMMAND (info_next_node, "Select the `Next' node") +DECLARE_INFO_COMMAND (info_next_node, _("Select the `Next' node")) { info_next_label_of_node (window->node); - info_handle_pointer ("Next", window); + info_handle_pointer (_("Next"), window); } /* Make WINDOW display the "Prev:" node of the node currently being displayed. */ -DECLARE_INFO_COMMAND (info_prev_node, "Select the `Prev' node") +DECLARE_INFO_COMMAND (info_prev_node, _("Select the `Prev' node")) { info_prev_label_of_node (window->node); - info_handle_pointer ("Prev", window); + info_handle_pointer (_("Prev"), window); } /* Make WINDOW display the "Up:" node of the node currently being displayed. */ -DECLARE_INFO_COMMAND (info_up_node, "Select the `Up' node") +DECLARE_INFO_COMMAND (info_up_node, _("Select the `Up' node")) { info_up_label_of_node (window->node); - info_handle_pointer ("Up", window); + info_handle_pointer (_("Up"), window); } /* Make WINDOW display the last node of this info file. */ -DECLARE_INFO_COMMAND (info_last_node, "Select the last node in this file") +DECLARE_INFO_COMMAND (info_last_node, _("Select the last node in this file")) { register int i; FILE_BUFFER *fb = file_buffer_of_window (window); @@ -1754,7 +1747,7 @@ DECLARE_INFO_COMMAND (info_last_node, "Select the last node in this file") } if (!node) - info_error ("This window has no additional nodes"); + info_error (_("This window has no additional nodes")); else { set_remembered_pagetop_and_point (window); @@ -1763,7 +1756,7 @@ DECLARE_INFO_COMMAND (info_last_node, "Select the last node in this file") } /* Make WINDOW display the first node of this info file. */ -DECLARE_INFO_COMMAND (info_first_node, "Select the first node in this file") +DECLARE_INFO_COMMAND (info_first_node, _("Select the first node in this file")) { FILE_BUFFER *fb = file_buffer_of_window (window); NODE *node = (NODE *)NULL; @@ -1772,7 +1765,7 @@ DECLARE_INFO_COMMAND (info_first_node, "Select the first node in this file") node = info_get_node (fb->filename, fb->tags[0]->nodename); if (!node) - info_error ("This window has no additional nodes"); + info_error (_("This window has no additional nodes")); else { set_remembered_pagetop_and_point (window); @@ -1780,55 +1773,15 @@ DECLARE_INFO_COMMAND (info_first_node, "Select the first node in this file") } } -/* Make WINDOW display the previous node displayed in this window. */ -DECLARE_INFO_COMMAND (info_history_node, - "Select the most recently selected node") -{ - INFO_WINDOW *info_win; - - /* Find the INFO_WINDOW which contains WINDOW. */ - info_win = get_info_window_of_window (window); - - if (!info_win) - { - info_error ("Requested window is not present!"); - return; - } - - set_remembered_pagetop_and_point (window); - if (!info_win->current) - { - if (info_win->nodes_index > 1) - { - window_message_in_echo_area - ("Now wrapped around to beginning of history."); - info_win->current = info_win->nodes_index; - } - else - { - info_error ("No earlier nodes in this window."); - return; - } - } - - info_win->current--; - window_set_node_of_window (window, info_win->nodes[info_win->current]); - window->pagetop = info_win->pagetops[info_win->current]; - window->point = info_win->points[info_win->current]; - window->flags |= W_UpdateWindow; - if (auto_footnotes_p) - info_get_or_remove_footnotes (window); -} - /* Select the last menu item in WINDOW->node. */ DECLARE_INFO_COMMAND (info_last_menu_item, - "Select the last item in this node's menu") + _("Select the last item in this node's menu")) { info_menu_digit (window, 1, '0'); } /* Use KEY (a digit) to select the Nth menu item in WINDOW->node. */ -DECLARE_INFO_COMMAND (info_menu_digit, "Select this menu item") +DECLARE_INFO_COMMAND (info_menu_digit, _("Select this menu item")) { register int i, item; register REFERENCE *entry, **menu; @@ -1849,15 +1802,15 @@ DECLARE_INFO_COMMAND (info_menu_digit, "Select this menu item") for (i = 0; menu[i + 1]; i++); else { - for (i = 0; entry = menu[i]; i++) - if (i == item - 1) - break; + for (i = 0; (entry = menu[i]); i++) + if (i == item - 1) + break; } if (menu[i]) info_select_reference (window, menu[i]); else - info_error ("There aren't %d items in this menu.", item); + info_error (_("There aren't %d items in this menu."), item); info_free_references (menu); return; @@ -1884,9 +1837,9 @@ info_menu_or_ref_item (window, count, key, builder, ask_p) if (!menu) { if (builder == info_menu_of_node) - info_error (NO_MENU_NODE); + info_error (NO_MENU_NODE); else - info_error (NO_XREF_NODE); + info_error (NO_XREF_NODE); return; } @@ -1900,77 +1853,77 @@ info_menu_or_ref_item (window, count, key, builder, ask_p) if (point_line != -1) { - SEARCH_BINDING binding; - - binding.buffer = window->node->contents; - binding.start = window->line_starts[point_line] - binding.buffer; - if (window->line_starts[point_line + 1]) - binding.end = window->line_starts[point_line + 1] - binding.buffer; - else - binding.end = window->node->nodelen; - binding.flags = 0; - - if (builder == info_menu_of_node) - { - if (point_line) - { - binding.start--; - refs = info_menu_items (&binding); - } - } - else - { + SEARCH_BINDING binding; + + binding.buffer = window->node->contents; + binding.start = window->line_starts[point_line] - binding.buffer; + if (window->line_starts[point_line + 1]) + binding.end = window->line_starts[point_line + 1] - binding.buffer; + else + binding.end = window->node->nodelen; + binding.flags = 0; + + if (builder == info_menu_of_node) + { + if (point_line) + { + binding.start--; + refs = info_menu_items (&binding); + } + } + else + { #if defined (HANDLE_MAN_PAGES) - if (window->node->flags & N_IsManPage) - refs = manpage_xrefs_in_binding (window->node, &binding); - else + if (window->node->flags & N_IsManPage) + refs = manpage_xrefs_in_binding (window->node, &binding); + else #endif /* HANDLE_MAN_PAGES */ - refs = info_xrefs (&binding); - } - - if (refs) - { - if ((strcmp (refs[0]->label, "Menu") != 0) || - (builder == info_xrefs_of_node)) - { - int which = 0; - - /* Find the closest reference to point. */ - if (builder == info_xrefs_of_node) - { - int closest = -1; - - for (; refs[which]; which++) - { - if ((window->point >= refs[which]->start) && - (window->point <= refs[which]->end)) - { - closest = which; - break; - } - else if (window->point < refs[which]->start) - { - break; - } - } - if (closest == -1) - which--; - else - which = closest; - } - - defentry = (REFERENCE *)xmalloc (sizeof (REFERENCE)); - defentry->label = strdup (refs[which]->label); - defentry->filename = refs[which]->filename; - defentry->nodename = refs[which]->nodename; - - if (defentry->filename) - defentry->filename = strdup (defentry->filename); - if (defentry->nodename) - defentry->nodename = strdup (defentry->nodename); - } - info_free_references (refs); - } + refs = info_xrefs (&binding); + } + + if (refs) + { + if ((strcmp (refs[0]->label, "Menu") != 0) || + (builder == info_xrefs_of_node)) + { + int which = 0; + + /* Find the closest reference to point. */ + if (builder == info_xrefs_of_node) + { + int closest = -1; + + for (; refs[which]; which++) + { + if ((window->point >= refs[which]->start) && + (window->point <= refs[which]->end)) + { + closest = which; + break; + } + else if (window->point < refs[which]->start) + { + break; + } + } + if (closest == -1) + which--; + else + which = closest; + } + + defentry = (REFERENCE *)xmalloc (sizeof (REFERENCE)); + defentry->label = xstrdup (refs[which]->label); + defentry->filename = refs[which]->filename; + defentry->nodename = refs[which]->nodename; + + if (defentry->filename) + defentry->filename = xstrdup (defentry->filename); + if (defentry->nodename) + defentry->nodename = xstrdup (defentry->nodename); + } + info_free_references (refs); + } } } @@ -1981,24 +1934,24 @@ info_menu_or_ref_item (window, count, key, builder, ask_p) /* Build the prompt string. */ if (defentry) - prompt = (char *)xmalloc (20 + strlen (defentry->label)); + prompt = (char *)xmalloc (20 + strlen (defentry->label)); else - prompt = (char *)xmalloc (20); + prompt = (char *)xmalloc (20); if (builder == info_menu_of_node) - { - if (defentry) - sprintf (prompt, "Menu item (%s): ", defentry->label); - else - sprintf (prompt, "Menu item: "); - } + { + if (defentry) + sprintf (prompt, _("Menu item (%s): "), defentry->label); + else + sprintf (prompt, _("Menu item: ")); + } else - { - if (defentry) - sprintf (prompt, "Follow xref (%s): ", defentry->label); - else - sprintf (prompt, "Follow xref: "); - } + { + if (defentry) + sprintf (prompt, _("Follow xref (%s): "), defentry->label); + else + sprintf (prompt, _("Follow xref: ")); + } line = info_read_completing_in_echo_area (window, prompt, menu); free (prompt); @@ -2007,31 +1960,31 @@ info_menu_or_ref_item (window, count, key, builder, ask_p) /* User aborts, just quit. */ if (!line) - { - maybe_free (defentry); - info_free_references (menu); - info_abort_key (window, 0, 0); - return; - } + { + maybe_free (defentry); + info_free_references (menu); + info_abort_key (window, 0, 0); + return; + } /* If we had a default and the user accepted it, use that. */ if (!*line) - { - free (line); - if (defentry) - line = strdup (defentry->label); - else - line = (char *)NULL; - } + { + free (line); + if (defentry) + line = xstrdup (defentry->label); + else + line = (char *)NULL; + } } else { /* Not going to ask any questions. If we have a default entry, use - that, otherwise return. */ + that, otherwise return. */ if (!defentry) - return; + return; else - line = strdup (defentry->label); + line = xstrdup (defentry->label); } if (line) @@ -2040,42 +1993,42 @@ info_menu_or_ref_item (window, count, key, builder, ask_p) entry = info_get_labeled_reference (line, menu); if (!entry && defentry) - info_error ("The reference disappeared! (%s).", line); + info_error (_("The reference disappeared! (%s)."), line); else - { - NODE *orig; - - orig = window->node; - info_select_reference (window, entry); - if ((builder == info_xrefs_of_node) && (window->node != orig)) - { - long offset; - long start; - - if (window->line_count > 0) - start = window->line_starts[1] - window->node->contents; - else - start = 0; - - offset = - info_target_search_node (window->node, entry->label, start); - - if (offset != -1) - { - window->point = offset; - window_adjust_pagetop (window); - } - } - } + { + NODE *orig; + + orig = window->node; + info_select_reference (window, entry); + if ((builder == info_xrefs_of_node) && (window->node != orig)) + { + long offset; + long start; + + if (window->line_count > 0) + start = window->line_starts[1] - window->node->contents; + else + start = 0; + + offset = + info_target_search_node (window->node, entry->label, start); + + if (offset != -1) + { + window->point = offset; + window_adjust_pagetop (window); + } + } + } free (line); if (defentry) - { - free (defentry->label); - maybe_free (defentry->filename); - maybe_free (defentry->nodename); - free (defentry); - } + { + free (defentry->label); + maybe_free (defentry->filename); + maybe_free (defentry->nodename); + free (defentry); + } } info_free_references (menu); @@ -2086,7 +2039,7 @@ info_menu_or_ref_item (window, count, key, builder, ask_p) /* Read a line (with completion) which is the name of a menu item, and select that item. */ -DECLARE_INFO_COMMAND (info_menu_item, "Read a menu item and select its node") +DECLARE_INFO_COMMAND (info_menu_item, _("Read a menu item and select its node")) { info_menu_or_ref_item (window, count, key, info_menu_of_node, 1); } @@ -2094,13 +2047,13 @@ DECLARE_INFO_COMMAND (info_menu_item, "Read a menu item and select its node") /* Read a line (with completion) which is the name of a reference to follow, and select the node. */ DECLARE_INFO_COMMAND - (info_xref_item, "Read a footnote or cross reference and select its node") + (info_xref_item, _("Read a footnote or cross reference and select its node")) { info_menu_or_ref_item (window, count, key, info_xrefs_of_node, 1); } /* Position the cursor at the start of this node's menu. */ -DECLARE_INFO_COMMAND (info_find_menu, "Move to the start of this node's menu") +DECLARE_INFO_COMMAND (info_find_menu, _("Move to the start of this node's menu")) { SEARCH_BINDING binding; long position; @@ -2124,7 +2077,7 @@ DECLARE_INFO_COMMAND (info_find_menu, "Move to the start of this node's menu") /* Visit as many menu items as is possible, each in a separate window. */ DECLARE_INFO_COMMAND (info_visit_menu, - "Visit as many menu items at once as possible") + _("Visit as many menu items at once as possible")) { register int i; REFERENCE *entry, **menu; @@ -2142,20 +2095,19 @@ DECLARE_INFO_COMMAND (info_visit_menu, window_tile_windows (TILE_INTERNALS); if (!new) - info_error (WIN_TOO_SMALL); + info_error (WIN_TOO_SMALL); else - { - active_window = new; - info_select_reference (new, entry); - } + { + active_window = new; + info_select_reference (new, entry); + } } } /* Read a line of input which is a node name, and go to that node. */ -DECLARE_INFO_COMMAND (info_goto_node, "Read a node name and select it") +DECLARE_INFO_COMMAND (info_goto_node, _("Read a node name and select it")) { char *line; - NODE *node; #define GOTO_COMPLETES #if defined (GOTO_COMPLETES) @@ -2171,54 +2123,54 @@ DECLARE_INFO_COMMAND (info_goto_node, "Read a node name and select it") for (fbi = 0; info_loaded_files && info_loaded_files[fbi]; fbi++) { - FILE_BUFFER *fb; - REFERENCE *entry; - int this_is_the_current_fb; - - fb = info_loaded_files[fbi]; - this_is_the_current_fb = (current == fb); - - entry = (REFERENCE *)xmalloc (sizeof (REFERENCE)); - entry->filename = entry->nodename = (char *)NULL; - entry->label = (char *)xmalloc (4 + strlen (fb->filename)); - sprintf (entry->label, "(%s)*", fb->filename); - - add_pointer_to_array - (entry, items_index, items, items_slots, 10, REFERENCE *); - - if (fb->tags) - { - for (i = 0; fb->tags[i]; i++) - { - entry = (REFERENCE *)xmalloc (sizeof (REFERENCE)); - entry->filename = entry->nodename = (char *)NULL; - entry->label = (char *) xmalloc - (4 + strlen (fb->filename) + strlen (fb->tags[i]->nodename)); - sprintf (entry->label, "(%s)%s", - fb->filename, fb->tags[i]->nodename); - - add_pointer_to_array - (entry, items_index, items, items_slots, 100, REFERENCE *); - } - - if (this_is_the_current_fb) - { - for (i = 0; fb->tags[i]; i++) - { - entry = (REFERENCE *)xmalloc (sizeof (REFERENCE)); - entry->filename = entry->nodename = (char *)NULL; - entry->label = strdup (fb->tags[i]->nodename); - add_pointer_to_array (entry, items_index, items, - items_slots, 100, REFERENCE *); - } - } - } + FILE_BUFFER *fb; + REFERENCE *entry; + int this_is_the_current_fb; + + fb = info_loaded_files[fbi]; + this_is_the_current_fb = (current == fb); + + entry = (REFERENCE *)xmalloc (sizeof (REFERENCE)); + entry->filename = entry->nodename = (char *)NULL; + entry->label = (char *)xmalloc (4 + strlen (fb->filename)); + sprintf (entry->label, "(%s)*", fb->filename); + + add_pointer_to_array + (entry, items_index, items, items_slots, 10, REFERENCE *); + + if (fb->tags) + { + for (i = 0; fb->tags[i]; i++) + { + entry = (REFERENCE *)xmalloc (sizeof (REFERENCE)); + entry->filename = entry->nodename = (char *)NULL; + entry->label = (char *) xmalloc + (4 + strlen (fb->filename) + strlen (fb->tags[i]->nodename)); + sprintf (entry->label, "(%s)%s", + fb->filename, fb->tags[i]->nodename); + + add_pointer_to_array + (entry, items_index, items, items_slots, 100, REFERENCE *); + } + + if (this_is_the_current_fb) + { + for (i = 0; fb->tags[i]; i++) + { + entry = (REFERENCE *)xmalloc (sizeof (REFERENCE)); + entry->filename = entry->nodename = (char *)NULL; + entry->label = xstrdup (fb->tags[i]->nodename); + add_pointer_to_array (entry, items_index, items, + items_slots, 100, REFERENCE *); + } + } + } } - line = info_read_maybe_completing (window, "Goto Node: ", items); + line = info_read_maybe_completing (window, _("Goto Node: "), items); info_free_references (items); } #else /* !GOTO_COMPLETES */ - line = info_read_in_echo_area (window, "Goto Node: "); + line = info_read_in_echo_area (window, _("Goto Node: ")); #endif /* !GOTO_COMPLETES */ /* If the user aborted, quit now. */ @@ -2239,12 +2191,11 @@ DECLARE_INFO_COMMAND (info_goto_node, "Read a node name and select it") } #if defined (HANDLE_MAN_PAGES) -DECLARE_INFO_COMMAND (info_man, "Read a manpage reference and select it") +DECLARE_INFO_COMMAND (info_man, _("Read a manpage reference and select it")) { char *line; - NODE *node; - line = info_read_in_echo_area (window, "Get Manpage: "); + line = info_read_in_echo_area (window, _("Get Manpage: ")); if (!line) { @@ -2259,7 +2210,7 @@ DECLARE_INFO_COMMAND (info_man, "Read a manpage reference and select it") char *goto_command; goto_command = (char *)xmalloc - (4 + strlen (MANPAGE_FILE_BUFFER_NAME) + strlen (line)); + (4 + strlen (MANPAGE_FILE_BUFFER_NAME) + strlen (line)); sprintf (goto_command, "(%s)%s", MANPAGE_FILE_BUFFER_NAME, line); @@ -2274,61 +2225,70 @@ DECLARE_INFO_COMMAND (info_man, "Read a manpage reference and select it") #endif /* HANDLE_MAN_PAGES */ /* Move to the "Top" node in this file. */ -DECLARE_INFO_COMMAND (info_top_node, "Select the node `Top' in this file") +DECLARE_INFO_COMMAND (info_top_node, _("Select the node `Top' in this file")) { - info_parse_and_select ("Top", window); + info_parse_and_select (_("Top"), window); } /* Move to the node "(dir)Top". */ -DECLARE_INFO_COMMAND (info_dir_node, "Select the node `(dir)'") +DECLARE_INFO_COMMAND (info_dir_node, _("Select the node `(dir)'")) { info_parse_and_select ("(dir)Top", window); } -/* Try to delete the current node appearing in this window, showing the most - recently selected node in this window. */ -DECLARE_INFO_COMMAND (info_kill_node, "Kill this node") + +/* Read the name of a node to kill. The list of available nodes comes + from the nodes appearing in the current window configuration. */ +static char * +read_nodename_to_kill (window) + WINDOW *window; { - register int iw, i; - register INFO_WINDOW *info_win; - char *nodename = (char *)NULL; - NODE *temp = (NODE *)NULL; + int iw; + char *nodename; + INFO_WINDOW *info_win; + REFERENCE **menu = NULL; + int menu_index = 0, menu_slots = 0; + char *default_nodename = xstrdup (active_window->node->nodename); + char *prompt = xmalloc (40 + strlen (default_nodename)); - /* Read the name of a node to kill. The list of available nodes comes - from the nodes appearing in the current window configuration. */ - { - REFERENCE **menu = (REFERENCE **)NULL; - int menu_index = 0, menu_slots = 0; - char *default_nodename, *prompt; + sprintf (prompt, _("Kill node (%s): "), default_nodename); - for (iw = 0; info_win = info_windows[iw]; iw++) - { - REFERENCE *entry; + for (iw = 0; (info_win = info_windows[iw]); iw++) + { + REFERENCE *entry = (REFERENCE *)xmalloc (sizeof (REFERENCE)); + entry->label = xstrdup (info_win->window->node->nodename); + entry->filename = entry->nodename = (char *)NULL; - entry = (REFERENCE *)xmalloc (sizeof (REFERENCE)); - entry->label = strdup (info_win->window->node->nodename); - entry->filename = entry->nodename = (char *)NULL; + add_pointer_to_array (entry, menu_index, menu, menu_slots, 10, + REFERENCE *); + } - add_pointer_to_array - (entry, menu_index, menu, menu_slots, 10, REFERENCE *); - } + nodename = info_read_completing_in_echo_area (window, prompt, menu); + free (prompt); + info_free_references (menu); + if (nodename && !*nodename) + { + free (nodename); + nodename = default_nodename; + } + else + free (default_nodename); - default_nodename = strdup (active_window->node->nodename); - prompt = (char *)xmalloc (40 + strlen (default_nodename)); - sprintf (prompt, "Kill node (%s): ", default_nodename); + return nodename; +} - nodename = info_read_completing_in_echo_area (window, prompt, menu); - free (prompt); - info_free_references (menu); - if (nodename && !*nodename) - { - free (nodename); - nodename = default_nodename; - } - else - free (default_nodename); - } +/* Delete NODENAME from this window, showing the most + recently selected node in this window. */ +static void +kill_node (window, nodename) + WINDOW *window; + char *nodename; +{ + int iw, i; + INFO_WINDOW *info_win; + NODE *temp; + /* If there is no nodename to kill, quit now. */ if (!nodename) { @@ -2337,16 +2297,16 @@ DECLARE_INFO_COMMAND (info_kill_node, "Kill this node") } /* If there is a nodename, find it in our window list. */ - for (iw = 0; info_win = info_windows[iw]; iw++) + for (iw = 0; (info_win = info_windows[iw]); iw++) if (strcmp (nodename, info_win->nodes[info_win->current]->nodename) == 0) break; if (!info_win) { if (*nodename) - info_error ("Cannot kill the node `%s'", nodename); + info_error (_("Cannot kill node `%s'"), nodename); else - window_clear_echo_area (); + window_clear_echo_area (); return; } @@ -2354,13 +2314,12 @@ DECLARE_INFO_COMMAND (info_kill_node, "Kill this node") /* If there are no more nodes left anywhere to view, complain and exit. */ if (info_windows_index == 1 && info_windows[0]->nodes_index == 1) { - info_error ("Cannot kill the last node"); + info_error (_("Cannot kill the last node")); return; } - /* INFO_WIN contains the node that the user wants to stop viewing. - Delete this node from the list of nodes previously shown in this - window. */ + /* INFO_WIN contains the node that the user wants to stop viewing. Delete + this node from the list of nodes previously shown in this window. */ for (i = info_win->current; i < info_win->nodes_index; i++) info_win->nodes[i] = info_win->nodes[i++]; @@ -2379,41 +2338,40 @@ DECLARE_INFO_COMMAND (info_kill_node, "Kill this node") long point; if (info_windows[iw + 1]) - stealer = info_windows[iw + 1]; + stealer = info_windows[iw + 1]; else - stealer = info_windows[0]; + stealer = info_windows[0]; /* If the node being displayed in the next window is not the most - recently loaded one, get the most recently loaded one. */ + recently loaded one, get the most recently loaded one. */ if ((stealer->nodes_index - 1) != stealer->current) - which = stealer->nodes_index - 1; + which = stealer->nodes_index - 1; /* Else, if there is another node behind the stealers current node, - use that one. */ + use that one. */ else if (stealer->current > 0) - which = stealer->current - 1; + which = stealer->current - 1; /* Else, just use the node appearing in STEALER's window. */ else - which = stealer->current; + which = stealer->current; /* Copy this node. */ { - NODE *copy; - - temp = stealer->nodes[which]; - point = stealer->points[which]; - pagetop = stealer->pagetops[which]; - - copy = (NODE *)xmalloc (sizeof (NODE)); - copy->filename = temp->filename; - copy->parent = temp->parent; - copy->nodename = temp->nodename; - copy->contents = temp->contents; - copy->nodelen = temp->nodelen; - copy->flags = temp->flags; - - temp = copy; + NODE *copy = xmalloc (sizeof (NODE)); + + temp = stealer->nodes[which]; + point = stealer->points[which]; + pagetop = stealer->pagetops[which]; + + copy->filename = temp->filename; + copy->parent = temp->parent; + copy->nodename = temp->nodename; + copy->contents = temp->contents; + copy->nodelen = temp->nodelen; + copy->flags = temp->flags; + + temp = copy; } window_set_node_of_window (info_win->window, temp); @@ -2426,16 +2384,39 @@ DECLARE_INFO_COMMAND (info_kill_node, "Kill this node") temp = info_win->nodes[info_win->current]; window_set_node_of_window (info_win->window, temp); } + if (!info_error_was_printed) window_clear_echo_area (); + + if (auto_footnotes_p) + info_get_or_remove_footnotes (window); +} + +/* Kill current node, thus going back one in the node history. I (karl) + do not think this is completely correct yet, because of the + window-changing stuff in kill_node, but it's a lot better than the + previous implementation, which did not account for nodes being + visited twice at all. */ +DECLARE_INFO_COMMAND (info_history_node, + _("Select the most recently selected node")) +{ + kill_node (window, active_window->node->nodename); +} + +/* Kill named node. */ +DECLARE_INFO_COMMAND (info_kill_node, _("Kill this node")) +{ + char *nodename = read_nodename_to_kill (window); + kill_node (window, nodename); } + /* Read the name of a file and select the entire file. */ -DECLARE_INFO_COMMAND (info_view_file, "Read the name of a file and select it") +DECLARE_INFO_COMMAND (info_view_file, _("Read the name of a file and select it")) { char *line; - line = info_read_in_echo_area (window, "Find file: "); + line = info_read_in_echo_area (window, _("Find file: ")); if (!line) { info_abort_key (active_window, 1, 0); @@ -2448,17 +2429,17 @@ DECLARE_INFO_COMMAND (info_view_file, "Read the name of a file and select it") node = info_get_node (line, "*"); if (!node) - { - if (info_recent_file_error) - info_error (info_recent_file_error); - else - info_error ("Cannot find \"%s\".", line); - } + { + if (info_recent_file_error) + info_error (info_recent_file_error); + else + info_error (_("Cannot find \"%s\"."), line); + } else - { - set_remembered_pagetop_and_point (active_window); - info_set_node_of_window (window, node); - } + { + set_remembered_pagetop_and_point (active_window); + info_set_node_of_window (window, node); + } free (line); } @@ -2467,9 +2448,9 @@ DECLARE_INFO_COMMAND (info_view_file, "Read the name of a file and select it") } /* **************************************************************** */ -/* */ -/* Dumping and Printing Nodes */ -/* */ +/* */ +/* Dumping and Printing Nodes */ +/* */ /* **************************************************************** */ #define VERBOSE_NODE_DUMPING @@ -2499,7 +2480,7 @@ dump_nodes_to_file (filename, nodenames, output_filename, dump_subnodes) if (!output_stream) { - info_error ("Could not create output file \"%s\".", output_filename); + info_error (_("Could not create output file \"%s\"."), output_filename); return; } @@ -2512,7 +2493,7 @@ dump_nodes_to_file (filename, nodenames, output_filename, dump_subnodes) fclose (output_stream); #if defined (VERBOSE_NODE_DUMPING) - info_error ("Done."); + info_error (_("Done.")); #endif /* VERBOSE_NODE_DUMPING */ } @@ -2544,15 +2525,15 @@ dump_node_to_stream (filename, nodename, stream, dump_subnodes) if (!node) { if (info_recent_file_error) - info_error (info_recent_file_error); + info_error (info_recent_file_error); else - { - if (filename && *nodename != '(') - info_error - (CANT_FILE_NODE, filename_non_directory (filename), nodename); - else - info_error (CANT_FIND_NODE, nodename); - } + { + if (filename && *nodename != '(') + info_error + (CANT_FILE_NODE, filename_non_directory (filename), nodename); + else + info_error (CANT_FIND_NODE, nodename); + } return; } @@ -2560,19 +2541,19 @@ dump_node_to_stream (filename, nodename, stream, dump_subnodes) for (i = 0; i < dumped_already_index; i++) if (strcmp (node->nodename, dumped_already[i]) == 0) { - free (node); - return; + free (node); + return; } add_pointer_to_array (node->nodename, dumped_already_index, dumped_already, - dumped_already_slots, 50, char *); + dumped_already_slots, 50, char *); #if defined (VERBOSE_NODE_DUMPING) /* Maybe we should print some information about the node being output. */ if (node->filename) - info_error ("Writing node \"(%s)%s\"...", - filename_non_directory (node->filename), node->nodename); + info_error (_("Writing node \"(%s)%s\"..."), + filename_non_directory (node->filename), node->nodename); else - info_error ("Writing node \"%s\"...", node->nodename); + info_error (_("Writing node \"%s\"..."), node->nodename); #endif /* VERBOSE_NODE_DUMPING */ write_node_to_stream (node, stream); @@ -2585,20 +2566,20 @@ dump_node_to_stream (filename, nodename, stream, dump_subnodes) /* If this node is an Index, do not dump the menu references. */ if (string_in_line ("Index", node->nodename) == -1) - menu = info_menu_of_node (node); + menu = info_menu_of_node (node); if (menu) - { - for (i = 0; menu[i]; i++) - { - /* We don't dump Info files which are different than the - current one. */ - if (!menu[i]->filename) - dump_node_to_stream - (filename, menu[i]->nodename, stream, dump_subnodes); - } - info_free_references (menu); - } + { + for (i = 0; menu[i]; i++) + { + /* We don't dump Info files which are different than the + current one. */ + if (!menu[i]->filename) + dump_node_to_stream + (filename, menu[i]->nodename, stream, dump_subnodes); + } + info_free_references (menu); + } } free (node); @@ -2624,7 +2605,7 @@ dump_node_to_file (node, filename, dump_subnodes) if (!output_stream) { - info_error ("Could not create output file \"%s\".", filename); + info_error (_("Could not create output file \"%s\"."), filename); return; } @@ -2641,7 +2622,7 @@ dump_node_to_file (node, filename, dump_subnodes) fclose (output_stream); #if defined (VERBOSE_NODE_DUMPING) - info_error ("Done."); + info_error (_("Done.")); #endif /* VERBOSE_NODE_DUMPING */ } @@ -2650,7 +2631,7 @@ dump_node_to_file (node, filename, dump_subnodes) #endif /* !DEFAULT_INFO_PRINT_COMMAND */ DECLARE_INFO_COMMAND (info_print_node, - "Pipe the contents of this node through INFO_PRINT_COMMAND") + _("Pipe the contents of this node through INFO_PRINT_COMMAND")) { print_node (window->node); } @@ -2660,10 +2641,8 @@ void print_node (node) NODE *node; { - char *print_command, *getenv (); FILE *printer_pipe; - - print_command = getenv ("INFO_PRINT_COMMAND"); + char *print_command = getenv ("INFO_PRINT_COMMAND"); if (!print_command || !*print_command) print_command = DEFAULT_INFO_PRINT_COMMAND; @@ -2672,24 +2651,24 @@ print_node (node) if (!printer_pipe) { - info_error ("Cannot open pipe to \"%s\".", print_command); + info_error (_("Cannot open pipe to \"%s\"."), print_command); return; } #if defined (VERBOSE_NODE_DUMPING) /* Maybe we should print some information about the node being output. */ if (node->filename) - info_error ("Printing node \"(%s)%s\"...", - filename_non_directory (node->filename), node->nodename); + info_error (_("Printing node \"(%s)%s\"..."), + filename_non_directory (node->filename), node->nodename); else - info_error ("Printing node \"%s\"...", node->nodename); + info_error (_("Printing node \"%s\"..."), node->nodename); #endif /* VERBOSE_NODE_DUMPING */ write_node_to_stream (node, printer_pipe); pclose (printer_pipe); #if defined (VERBOSE_NODE_DUMPING) - info_error ("Done."); + info_error (_("Done.")); #endif /* VERBOSE_NODE_DUMPING */ } @@ -2702,9 +2681,9 @@ write_node_to_stream (node, stream) } /* **************************************************************** */ -/* */ -/* Info Searching Commands */ -/* */ +/* */ +/* Info Searching Commands */ +/* */ /* **************************************************************** */ /* Variable controlling the garbage collection of files briefly visited @@ -2779,7 +2758,7 @@ info_search_in_node (string, node, start, window, dir) { set_remembered_pagetop_and_point (window); if (window->node != node) - window_set_node_of_window (window, node); + window_set_node_of_window (window, node); window->point = offset; window_adjust_pagetop (window); } @@ -2799,7 +2778,7 @@ info_target_search_node (node, string, start) long offset; char *target; - target = strdup (string); + target = xstrdup (string); i = strlen (target); /* Try repeatedly searching for this string while removing words from @@ -2810,7 +2789,7 @@ info_target_search_node (node, string, start) offset = info_search_in_node (target, node, start, (WINDOW *)NULL, 1); if (offset != -1) - break; + break; /* Delete the last word from TARGET. */ for (; i && (!whitespace (target[i]) && (target[i] != ',')); i--); @@ -2844,22 +2823,22 @@ info_search_internal (string, window, dir) (strcmp (last_searched_for_string, string) == 0)) { ret = info_search_in_node - (string, window->node, window->point + dir, window, dir); + (string, window->node, window->point + dir, window, dir); } else { ret = info_search_in_node - (string, window->node, window->point, window, dir); + (string, window->node, window->point, window, dir); } maybe_free (last_searched_for_string); - last_searched_for_string = strdup (string); + last_searched_for_string = xstrdup (string); if (ret != -1) { /* We won! */ if (!echo_area_is_active && !isearch_is_active) - window_clear_echo_area (); + window_clear_echo_area (); return (0); } @@ -2880,91 +2859,91 @@ info_search_internal (string, window, dir) /* Find number of tags and current tag. */ last_subfile = (char *)NULL; for (i = 0; file_buffer->tags[i]; i++) - if (strcmp (initial_nodename, file_buffer->tags[i]->nodename) == 0) - { - current_tag = i; - last_subfile = file_buffer->tags[i]->filename; - } + if (strcmp (initial_nodename, file_buffer->tags[i]->nodename) == 0) + { + current_tag = i; + last_subfile = file_buffer->tags[i]->filename; + } number_of_tags = i; /* If there is no last_subfile, our tag wasn't found. */ if (!last_subfile) - return (-1); + return (-1); /* Search through subsequent nodes, wrapping around to the top - of the info file until we find the string or return to this - window's node and point. */ + of the info file until we find the string or return to this + window's node and point. */ while (1) - { - NODE *node; - - /* Allow C-g to quit the search, failing it if pressed. */ - return_if_control_g (-1); - - current_tag += dir; - - if (current_tag < 0) - current_tag = number_of_tags - 1; - else if (current_tag == number_of_tags) - current_tag = 0; - - tag = file_buffer->tags[current_tag]; - - if (!echo_area_is_active && (last_subfile != tag->filename)) - { - window_message_in_echo_area - ("Searching subfile \"%s\"...", - filename_non_directory (tag->filename)); - - last_subfile = tag->filename; - } - - node = info_get_node (file_buffer->filename, tag->nodename); - - if (!node) - { - /* If not doing i-search... */ - if (!echo_area_is_active) - { - if (info_recent_file_error) - info_error (info_recent_file_error); - else - info_error (CANT_FILE_NODE, - filename_non_directory (file_buffer->filename), - tag->nodename); - } - return (-1); - } - - if (dir < 0) - start = tag->nodelen; - - ret = - info_search_in_node (string, node, start, window, dir); - - /* Did we find the string in this node? */ - if (ret != -1) - { - /* Yes! We win. */ - remember_window_and_node (window, node); - if (!echo_area_is_active) - window_clear_echo_area (); - return (0); - } - - /* No. Free this node, and make sure that we haven't passed - our starting point. */ - free (node); - - if (strcmp (initial_nodename, tag->nodename) == 0) - return (-1); - } + { + NODE *node; + + /* Allow C-g to quit the search, failing it if pressed. */ + return_if_control_g (-1); + + current_tag += dir; + + if (current_tag < 0) + current_tag = number_of_tags - 1; + else if (current_tag == number_of_tags) + current_tag = 0; + + tag = file_buffer->tags[current_tag]; + + if (!echo_area_is_active && (last_subfile != tag->filename)) + { + window_message_in_echo_area + (_("Searching subfile \"%s\"..."), + filename_non_directory (tag->filename)); + + last_subfile = tag->filename; + } + + node = info_get_node (file_buffer->filename, tag->nodename); + + if (!node) + { + /* If not doing i-search... */ + if (!echo_area_is_active) + { + if (info_recent_file_error) + info_error (info_recent_file_error); + else + info_error (CANT_FILE_NODE, + filename_non_directory (file_buffer->filename), + tag->nodename); + } + return (-1); + } + + if (dir < 0) + start = tag->nodelen; + + ret = + info_search_in_node (string, node, start, window, dir); + + /* Did we find the string in this node? */ + if (ret != -1) + { + /* Yes! We win. */ + remember_window_and_node (window, node); + if (!echo_area_is_active) + window_clear_echo_area (); + return (0); + } + + /* No. Free this node, and make sure that we haven't passed + our starting point. */ + free (node); + + if (strcmp (initial_nodename, tag->nodename) == 0) + return (-1); + } } return (-1); } -DECLARE_INFO_COMMAND (info_search, "Read a string and search for it") +DECLARE_INFO_COMMAND (info_search, _("Read a string and search for it")) { char *line, *prompt; int result, old_pagetop; @@ -2984,9 +2963,9 @@ DECLARE_INFO_COMMAND (info_search, "Read a string and search for it") prompt = (char *)xmalloc (50 + strlen (search_string)); - sprintf (prompt, "%s for string [%s]: ", - direction < 0 ? "Search backward" : "Search", - search_string); + sprintf (prompt, _("%s for string [%s]: "), + direction < 0 ? _("Search backward") : _("Search"), + search_string); line = info_read_in_echo_area (window, prompt); free (prompt); @@ -3000,8 +2979,8 @@ DECLARE_INFO_COMMAND (info_search, "Read a string and search for it") if (*line) { if (strlen (line) + 1 > search_string_size) - search_string = (char *) - xrealloc (search_string, (search_string_size += 50 + strlen (line))); + search_string = (char *) + xrealloc (search_string, (search_string_size += 50 + strlen (line))); strcpy (search_string, line); search_string_index = strlen (line); @@ -3012,7 +2991,7 @@ DECLARE_INFO_COMMAND (info_search, "Read a string and search for it") result = info_search_internal (search_string, active_window, direction); if (result != 0 && !info_error_was_printed) - info_error ("Search failed."); + info_error (_("Search failed.")); else if (old_pagetop != active_window->pagetop) { int new_pagetop; @@ -3021,7 +3000,7 @@ DECLARE_INFO_COMMAND (info_search, "Read a string and search for it") active_window->pagetop = old_pagetop; set_window_pagetop (active_window, new_pagetop); if (auto_footnotes_p) - info_get_or_remove_footnotes (active_window); + info_get_or_remove_footnotes (active_window); } /* Perhaps free the unreferenced file buffers that were searched, but @@ -3030,21 +3009,21 @@ DECLARE_INFO_COMMAND (info_search, "Read a string and search for it") } /* **************************************************************** */ -/* */ -/* Incremental Searching */ -/* */ +/* */ +/* Incremental Searching */ +/* */ /* **************************************************************** */ static void incremental_search (); DECLARE_INFO_COMMAND (isearch_forward, - "Search interactively for a string as you type it") + _("Search interactively for a string as you type it")) { incremental_search (window, count, key); } DECLARE_INFO_COMMAND (isearch_backward, - "Search interactively for a string as you type it") + _("Search interactively for a string as you type it")) { incremental_search (window, -count, key); } @@ -3061,10 +3040,10 @@ static unsigned char isearch_terminate_search_key = ESC; /* Structure defining the current state of an incremental search. */ typedef struct { - WINDOW_STATE_DECL; /* The node, pagetop and point. */ - int search_index; /* Offset of the last char in the search string. */ - int direction; /* The direction that this search is heading in. */ - int failing; /* Whether or not this search failed. */ + WINDOW_STATE_DECL; /* The node, pagetop and point. */ + int search_index; /* Offset of the last char in the search string. */ + int direction; /* The direction that this search is heading in. */ + int failing; /* Whether or not this search failed. */ } SEARCH_STATE; /* Array of search states. */ @@ -3087,7 +3066,7 @@ push_isearch (window, search_index, direction, failing) state->failing = failing; add_pointer_to_array (state, isearch_states_index, isearch_states, - isearch_states_slots, 20, SEARCH_STATE *); + isearch_states_slots, 20, SEARCH_STATE *); } /* Pop the state of this search to WINDOW, SEARCH_INDEX, and DIRECTION. */ @@ -3138,9 +3117,9 @@ show_isearch_prompt (dir, string, failing_p) int prompt_len, p_rep_index, p_rep_size; if (dir < 0) - prefix = "I-search backward: "; + prefix = _("I-search backward: "); else - prefix = "I-search: "; + prefix = _("I-search: "); p_rep_index = p_rep_size = 0; p_rep = (char *)NULL; @@ -3149,15 +3128,15 @@ show_isearch_prompt (dir, string, failing_p) char *rep; switch (string[i]) - { - case ' ': rep = " "; break; - case LFD: rep = "\\n"; break; - case TAB: rep = "\\t"; break; - default: - rep = pretty_keyname (string[i]); - } + { + case ' ': rep = " "; break; + case LFD: rep = "\\n"; break; + case TAB: rep = "\\t"; break; + default: + rep = pretty_keyname (string[i]); + } if ((p_rep_index + strlen (rep) + 1) >= p_rep_size) - p_rep = (char *)xrealloc (p_rep, p_rep_size += 100); + p_rep = (char *)xrealloc (p_rep, p_rep_size += 100); strcpy (p_rep + p_rep_index, rep); p_rep_index += strlen (rep); @@ -3165,8 +3144,8 @@ show_isearch_prompt (dir, string, failing_p) prompt_len = strlen (prefix) + p_rep_index + 20; prompt = (char *)xmalloc (prompt_len); - sprintf (prompt, "%s%s%s", failing_p ? "Failing " : "", prefix, - p_rep ? p_rep : ""); + sprintf (prompt, "%s%s%s", failing_p ? _("Failing ") : "", prefix, + p_rep ? p_rep : ""); window_message_in_echo_area ("%s", prompt); maybe_free (p_rep); @@ -3209,202 +3188,202 @@ incremental_search (window, count, ignore) int quoted = 0; /* If a recent display was interrupted, then do the redisplay now if - it is convenient. */ + it is convenient. */ if (!info_any_buffered_input_p () && display_was_interrupted_p) - { - display_update_one_window (window); - display_cursor_at_point (active_window); - } + { + display_update_one_window (window); + display_cursor_at_point (active_window); + } /* Read a character and dispatch on it. */ key = info_get_input_char (); window_get_state (window, &mystate); if (key == DEL) - { - /* User wants to delete one level of search? */ - if (!isearch_states_index) - { - terminal_ring_bell (); - continue; - } - else - { - pop_isearch - (window, &isearch_string_index, &dir, &search_result); - isearch_string[isearch_string_index] = '\0'; - show_isearch_prompt (dir, isearch_string, search_result); - goto after_search; - } - } + { + /* User wants to delete one level of search? */ + if (!isearch_states_index) + { + terminal_ring_bell (); + continue; + } + else + { + pop_isearch + (window, &isearch_string_index, &dir, &search_result); + isearch_string[isearch_string_index] = '\0'; + show_isearch_prompt (dir, isearch_string, search_result); + goto after_search; + } + } else if (key == Control ('q')) - { - key = info_get_input_char (); - quoted = 1; - } + { + key = info_get_input_char (); + quoted = 1; + } /* We are about to search again, or quit. Save the current search. */ push_isearch (window, isearch_string_index, dir, search_result); if (quoted) - goto insert_and_search; + goto insert_and_search; if (!Meta_p (key) || (ISO_Latin_p && key < 160)) - { - func = window->keymap[key].function; - - /* If this key invokes an incremental search, then this means that - we will either search again in the same direction, search - again in the reverse direction, or insert the last search - string that was accepted through incremental searching. */ - if (func == isearch_forward || func == isearch_backward) - { - if ((func == isearch_forward && dir > 0) || - (func == isearch_backward && dir < 0)) - { - /* If the user has typed no characters, then insert the - last successful search into the current search string. */ - if (isearch_string_index == 0) - { - /* Of course, there must be something to insert. */ - if (last_isearch_accepted) - { - if (strlen (last_isearch_accepted) + 1 >= - isearch_string_size) - isearch_string = (char *) - xrealloc (isearch_string, - isearch_string_size += 10 + - strlen (last_isearch_accepted)); - strcpy (isearch_string, last_isearch_accepted); - isearch_string_index = strlen (isearch_string); - goto search_now; - } - else - continue; - } - else - { - /* Search again in the same direction. This means start - from a new place if the last search was successful. */ - if (search_result == 0) - window->point += dir; - } - } - else - { - /* Reverse the direction of the search. */ - dir = -dir; - } - } - else if (isprint (key) || func == (VFunction *)NULL) - { - insert_and_search: - - if (isearch_string_index + 2 >= isearch_string_size) - isearch_string = (char *)xrealloc - (isearch_string, isearch_string_size += 100); - - isearch_string[isearch_string_index++] = key; - isearch_string[isearch_string_index] = '\0'; - goto search_now; - } - else if (func == info_abort_key) - { - /* If C-g pressed, and the search is failing, pop the search - stack back to the last unfailed search. */ - if (isearch_states_index && (search_result != 0)) - { - terminal_ring_bell (); - while (isearch_states_index && (search_result != 0)) - pop_isearch - (window, &isearch_string_index, &dir, &search_result); - isearch_string[isearch_string_index] = '\0'; - show_isearch_prompt (dir, isearch_string, search_result); - continue; - } - else - goto exit_search; - } - else - goto exit_search; - } + { + func = window->keymap[key].function; + + /* If this key invokes an incremental search, then this means that + we will either search again in the same direction, search + again in the reverse direction, or insert the last search + string that was accepted through incremental searching. */ + if (func == isearch_forward || func == isearch_backward) + { + if ((func == isearch_forward && dir > 0) || + (func == isearch_backward && dir < 0)) + { + /* If the user has typed no characters, then insert the + last successful search into the current search string. */ + if (isearch_string_index == 0) + { + /* Of course, there must be something to insert. */ + if (last_isearch_accepted) + { + if (strlen (last_isearch_accepted) + 1 >= + isearch_string_size) + isearch_string = (char *) + xrealloc (isearch_string, + isearch_string_size += 10 + + strlen (last_isearch_accepted)); + strcpy (isearch_string, last_isearch_accepted); + isearch_string_index = strlen (isearch_string); + goto search_now; + } + else + continue; + } + else + { + /* Search again in the same direction. This means start + from a new place if the last search was successful. */ + if (search_result == 0) + window->point += dir; + } + } + else + { + /* Reverse the direction of the search. */ + dir = -dir; + } + } + else if (isprint (key) || func == (VFunction *)NULL) + { + insert_and_search: + + if (isearch_string_index + 2 >= isearch_string_size) + isearch_string = (char *)xrealloc + (isearch_string, isearch_string_size += 100); + + isearch_string[isearch_string_index++] = key; + isearch_string[isearch_string_index] = '\0'; + goto search_now; + } + else if (func == info_abort_key) + { + /* If C-g pressed, and the search is failing, pop the search + stack back to the last unfailed search. */ + if (isearch_states_index && (search_result != 0)) + { + terminal_ring_bell (); + while (isearch_states_index && (search_result != 0)) + pop_isearch + (window, &isearch_string_index, &dir, &search_result); + isearch_string[isearch_string_index] = '\0'; + show_isearch_prompt (dir, isearch_string, search_result); + continue; + } + else + goto exit_search; + } + else + goto exit_search; + } else - { - exit_search: - /* The character is not printable, or it has a function which is - non-null. Exit the search, remembering the search string. If - the key is not the same as the isearch_terminate_search_key, - then push it into pending input. */ - if (isearch_string_index && func != info_abort_key) - { - maybe_free (last_isearch_accepted); - last_isearch_accepted = strdup (isearch_string); - } - - if (key != isearch_terminate_search_key) - info_set_pending_input (key); - - if (func == info_abort_key) - { - if (isearch_states_index) - window_set_state (window, &orig_state); - } - - if (!echo_area_is_active) - window_clear_echo_area (); - - if (auto_footnotes_p) - info_get_or_remove_footnotes (active_window); - - isearch_is_active = 0; - continue; - } + { + exit_search: + /* The character is not printable, or it has a function which is + non-null. Exit the search, remembering the search string. If + the key is not the same as the isearch_terminate_search_key, + then push it into pending input. */ + if (isearch_string_index && func != info_abort_key) + { + maybe_free (last_isearch_accepted); + last_isearch_accepted = xstrdup (isearch_string); + } + + if (key != isearch_terminate_search_key) + info_set_pending_input (key); + + if (func == info_abort_key) + { + if (isearch_states_index) + window_set_state (window, &orig_state); + } + + if (!echo_area_is_active) + window_clear_echo_area (); + + if (auto_footnotes_p) + info_get_or_remove_footnotes (active_window); + + isearch_is_active = 0; + continue; + } /* Search for the contents of isearch_string. */ search_now: show_isearch_prompt (dir, isearch_string, search_result); if (search_result == 0) - { - /* Check to see if the current search string is right here. If - we are looking at it, then don't bother calling the search - function. */ - if (((dir < 0) && - (strncasecmp (window->node->contents + window->point, - isearch_string, isearch_string_index) == 0)) || - ((dir > 0) && - ((window->point - isearch_string_index) >= 0) && - (strncasecmp (window->node->contents + - (window->point - (isearch_string_index - 1)), - isearch_string, isearch_string_index) == 0))) - { - if (dir > 0) - window->point++; - } - else - search_result = info_search_internal (isearch_string, window, dir); - } + { + /* Check to see if the current search string is right here. If + we are looking at it, then don't bother calling the search + function. */ + if (((dir < 0) && + (strncasecmp (window->node->contents + window->point, + isearch_string, isearch_string_index) == 0)) || + ((dir > 0) && + ((window->point - isearch_string_index) >= 0) && + (strncasecmp (window->node->contents + + (window->point - (isearch_string_index - 1)), + isearch_string, isearch_string_index) == 0))) + { + if (dir > 0) + window->point++; + } + else + search_result = info_search_internal (isearch_string, window, dir); + } /* If this search failed, and we didn't already have a failed search, - then ring the terminal bell. */ + then ring the terminal bell. */ if (search_result != 0 && last_search_result == 0) - terminal_ring_bell (); + terminal_ring_bell (); after_search: show_isearch_prompt (dir, isearch_string, search_result); if (search_result == 0) - { - if ((mystate.node == window->node) && - (mystate.pagetop != window->pagetop)) - { - int newtop = window->pagetop; - window->pagetop = mystate.pagetop; - set_window_pagetop (window, newtop); - } - display_update_one_window (window); - display_cursor_at_point (window); - } + { + if ((mystate.node == window->node) && + (mystate.pagetop != window->pagetop)) + { + int newtop = window->pagetop; + window->pagetop = mystate.pagetop; + set_window_pagetop (window, newtop); + } + display_update_one_window (window); + display_cursor_at_point (window); + } last_search_result = search_result; } @@ -3434,52 +3413,52 @@ info_gc_file_buffers () if (!info_loaded_files) return; - for (fb_index = 0; fb = info_loaded_files[fb_index]; fb_index++) + for (fb_index = 0; (fb = info_loaded_files[fb_index]); fb_index++) { int fb_referenced_p = 0; /* If already gc-ed, do nothing. */ if (!fb->contents) - continue; + continue; /* If this file had to be uncompressed, check to see if we should - gc it. This means that the user-variable "gc-compressed-files" - is non-zero. */ + gc it. This means that the user-variable "gc-compressed-files" + is non-zero. */ if ((fb->flags & N_IsCompressed) && !gc_compressed_files) - continue; + continue; /* If this file's contents are not gc-able, move on. */ if (fb->flags & N_CannotGC) - continue; + continue; /* Check each INFO_WINDOW to see if it has any nodes which reference - this file. */ - for (iw_index = 0; iw = info_windows[iw_index]; iw_index++) - { - for (i = 0; iw->nodes && iw->nodes[i]; i++) - { - if ((strcmp (fb->fullpath, iw->nodes[i]->filename) == 0) || - (strcmp (fb->filename, iw->nodes[i]->filename) == 0)) - { - fb_referenced_p = 1; - break; - } - } - } + this file. */ + for (iw_index = 0; (iw = info_windows[iw_index]); iw_index++) + { + for (i = 0; iw->nodes && iw->nodes[i]; i++) + { + if ((strcmp (fb->fullpath, iw->nodes[i]->filename) == 0) || + (strcmp (fb->filename, iw->nodes[i]->filename) == 0)) + { + fb_referenced_p = 1; + break; + } + } + } /* If this file buffer wasn't referenced, free its contents. */ if (!fb_referenced_p) - { - free (fb->contents); - fb->contents = (char *)NULL; - } + { + free (fb->contents); + fb->contents = (char *)NULL; + } } } /* **************************************************************** */ -/* */ -/* Traversing and Selecting References */ -/* */ +/* */ +/* Traversing and Selecting References */ +/* */ /* **************************************************************** */ /* Move to the next or previous cross reference in this node. */ @@ -3514,8 +3493,8 @@ info_move_to_xref (window, count, key, dir) char *text = node->contents + firstmenu; if (strncmp (text, INFO_MENU_LABEL, strlen (INFO_MENU_LABEL)) == 0) - firstmenu = info_search_in_node - (INFO_MENU_ENTRY_LABEL, node, firstmenu + dir, (WINDOW *)NULL, dir); + firstmenu = info_search_in_node + (INFO_MENU_ENTRY_LABEL, node, firstmenu + dir, (WINDOW *)NULL, dir); } firstxref = @@ -3530,7 +3509,7 @@ info_move_to_xref (window, count, key, dir) if (firstmenu == -1 && firstxref == -1) { - info_error ("No cross references in this node."); + info_error (_("No cross references in this node.")); return; } @@ -3554,8 +3533,8 @@ info_move_to_xref (window, count, key, dir) char *text = node->contents + nextmenu; if (strncmp (text, INFO_MENU_LABEL, strlen (INFO_MENU_LABEL)) == 0) - nextmenu = info_search_in_node - (INFO_MENU_ENTRY_LABEL, node, nextmenu + dir, (WINDOW *)NULL, dir); + nextmenu = info_search_in_node + (INFO_MENU_ENTRY_LABEL, node, nextmenu + dir, (WINDOW *)NULL, dir); } /* If there is both a next menu entry, and a next xref entry, choose the @@ -3564,10 +3543,10 @@ info_move_to_xref (window, count, key, dir) if (nextmenu != -1 && nextxref != -1) { if (((dir == 1) && (nextmenu < nextxref)) || - ((dir == -1) && (nextmenu > nextxref))) - placement = nextmenu + 1; + ((dir == -1) && (nextmenu > nextxref))) + placement = nextmenu + 1; else - placement = nextxref; + placement = nextxref; } else if (nextmenu != -1) placement = nextmenu + 1; @@ -3579,17 +3558,17 @@ info_move_to_xref (window, count, key, dir) if (placement == -1) { if (firstmenu != -1 && firstxref != -1) - { - if (((dir == 1) && (firstmenu < firstxref)) || - ((dir == -1) && (firstmenu > firstxref))) - placement = firstmenu + 1; - else - placement = firstxref; - } + { + if (((dir == 1) && (firstmenu < firstxref)) || + ((dir == -1) && (firstmenu > firstxref))) + placement = firstmenu + 1; + else + placement = firstxref; + } else if (firstmenu != -1) - placement = firstmenu + 1; + placement = firstmenu + 1; else - placement = firstxref; + placement = firstxref; } window->point = placement; window_adjust_pagetop (window); @@ -3597,7 +3576,7 @@ info_move_to_xref (window, count, key, dir) } DECLARE_INFO_COMMAND (info_move_to_prev_xref, - "Move to the previous cross reference") + _("Move to the previous cross reference")) { if (count < 0) info_move_to_prev_xref (window, -count, key); @@ -3606,7 +3585,7 @@ DECLARE_INFO_COMMAND (info_move_to_prev_xref, } DECLARE_INFO_COMMAND (info_move_to_next_xref, - "Move to the next cross reference") + _("Move to the next cross reference")) { if (count < 0) info_move_to_next_xref (window, -count, key); @@ -3616,7 +3595,7 @@ DECLARE_INFO_COMMAND (info_move_to_next_xref, /* Select the menu item or reference that appears on this line. */ DECLARE_INFO_COMMAND (info_select_reference_this_line, - "Select reference or menu item appearing on this line") + _("Select reference or menu item appearing on this line")) { char *line; NODE *orig; @@ -3632,20 +3611,20 @@ DECLARE_INFO_COMMAND (info_select_reference_this_line, } /* **************************************************************** */ -/* */ -/* Miscellaneous Info Commands */ -/* */ +/* */ +/* Miscellaneous Info Commands */ +/* */ /* **************************************************************** */ /* What to do when C-g is pressed in a window. */ -DECLARE_INFO_COMMAND (info_abort_key, "Cancel current operation") +DECLARE_INFO_COMMAND (info_abort_key, _("Cancel current operation")) { /* If error printing doesn't oridinarily ring the bell, do it now, since C-g always rings the bell. Otherwise, let the error printer do it. */ if (!info_error_rings_bell_p) terminal_ring_bell (); - info_error ("Quit"); + info_error (_("Quit")); info_initialize_numeric_arg (); info_clear_pending_input (); @@ -3654,7 +3633,7 @@ DECLARE_INFO_COMMAND (info_abort_key, "Cancel current operation") /* Move the cursor to the desired line of the window. */ DECLARE_INFO_COMMAND (info_move_to_window_line, - "Move to the cursor to a specific line of the window") + _("Move to the cursor to a specific line of the window")) { int line; @@ -3664,9 +3643,9 @@ DECLARE_INFO_COMMAND (info_move_to_window_line, else { if (count < 0) - line = (window->height + count) + window->pagetop; + line = (window->height + count) + window->pagetop; else - line = window->pagetop + count; + line = window->pagetop + count; } /* If the line doesn't appear in this window, make it do so. */ @@ -3686,7 +3665,7 @@ DECLARE_INFO_COMMAND (info_move_to_window_line, /* Clear the screen and redraw its contents. Given a numeric argument, move the line the cursor is on to the COUNT'th line of the window. */ -DECLARE_INFO_COMMAND (info_redraw_display, "Redraw the display") +DECLARE_INFO_COMMAND (info_redraw_display, _("Redraw the display")) { if ((!info_explicit_arg && count == 1) || echo_area_is_active) { @@ -3703,18 +3682,18 @@ DECLARE_INFO_COMMAND (info_redraw_display, "Redraw the display") point_line = window_line_of_point (window) - window->pagetop; if (count < 0) - desired_line = window->height + count; + desired_line = window->height + count; else - desired_line = count; + desired_line = count; if (desired_line < 0) - desired_line = 0; + desired_line = 0; if (desired_line >= window->height) - desired_line = window->height - 1; + desired_line = window->height - 1; if (desired_line == point_line) - return; + return; new_pagetop = window->pagetop + (point_line - desired_line); @@ -3723,14 +3702,14 @@ DECLARE_INFO_COMMAND (info_redraw_display, "Redraw the display") } /* This command does nothing. It is the fact that a key is bound to it that has meaning. See the code at the top of info_session (). */ -DECLARE_INFO_COMMAND (info_quit, "Quit using Info") +DECLARE_INFO_COMMAND (info_quit, _("Quit using Info")) {} /* **************************************************************** */ -/* */ -/* Reading Keys and Dispatching on Them */ -/* */ +/* */ +/* Reading Keys and Dispatching on Them */ +/* */ /* **************************************************************** */ /* Declaration only. Special cased in info_dispatch_on_key (). */ @@ -3746,14 +3725,14 @@ dispatch_error (keyseq) rep = pretty_keyseq (keyseq); if (!echo_area_is_active) - info_error ("Unknown command (%s).", rep); + info_error (_("Unknown command (%s)."), rep); else { char *temp; - temp = (char *)xmalloc (1 + strlen (rep) + strlen ("\"\" is invalid")); + temp = (char *)xmalloc (1 + strlen (rep) + strlen (_("\"\" is invalid"))); - sprintf (temp, "\"%s\" is invalid", rep); + sprintf (temp, _("\"%s\" is invalid"), rep); terminal_ring_bell (); inform_in_echo_area (temp); free (temp); @@ -3799,8 +3778,8 @@ pretty_keyseq (keyseq) for (i = 0; keyseq[i]; i++) { sprintf (keyseq_rep + strlen (keyseq_rep), "%s%s", - strlen (keyseq_rep) ? " " : "", - pretty_keyname (keyseq[i])); + strlen (keyseq_rep) ? " " : "", + pretty_keyname (keyseq[i])); } return (keyseq_rep); @@ -3833,25 +3812,30 @@ display_info_keyseq (expecting_future_input) unsigned char info_get_another_input_char () { - int ready = 0; + int ready = !info_keyseq_displayed_p; /* ready if new and pending key */ /* If there isn't any input currently available, then wait a moment looking for input. If we don't get it fast enough, prompt a little bit with the current key sequence. */ - if (!info_keyseq_displayed_p && - !info_any_buffered_input_p () && - !info_input_pending_p ()) + if (!info_keyseq_displayed_p) { + ready = 1; + if (!info_any_buffered_input_p () && + !info_input_pending_p ()) + { #if defined (FD_SET) - struct timeval timer; - fd_set readfds; - - FD_ZERO (&readfds); - FD_SET (fileno (info_input_stream), &readfds); - timer.tv_sec = 0; - timer.tv_usec = 0; - ready = select (1, &readfds, (fd_set *)NULL, (fd_set *)NULL, &timer); + struct timeval timer; + fd_set readfds; + + FD_ZERO (&readfds); + FD_SET (fileno (info_input_stream), &readfds); + timer.tv_sec = 1; + timer.tv_usec = 750; + ready = select (fileno(info_input_stream)+1, &readfds, (fd_set *)NULL, (fd_set *)NULL, &timer); +#else + ready = 0; #endif /* FD_SET */ + } } if (!ready) @@ -3870,16 +3854,16 @@ info_dispatch_on_key (key, map) if (Meta_p (key) && (!ISO_Latin_p || map[key].function != ea_insert)) { if (map[ESC].type == ISKMAP) - { - map = (Keymap)map[ESC].function; - add_char_to_keyseq (ESC); - key = UnMeta (key); - info_dispatch_on_key (key, map); - } + { + map = (Keymap)map[ESC].function; + add_char_to_keyseq (ESC); + key = UnMeta (key); + info_dispatch_on_key (key, map); + } else - { - dispatch_error (info_keyseq); - } + { + dispatch_error (info_keyseq); + } return; } @@ -3887,74 +3871,74 @@ info_dispatch_on_key (key, map) { case ISFUNC: { - VFunction *func; - - func = map[key].function; - if (func != (VFunction *)NULL) - { - /* Special case info_do_lowercase_version (). */ - if (func == info_do_lowercase_version) - { - info_dispatch_on_key (tolower (key), map); - return; - } - - add_char_to_keyseq (key); - - if (info_keyseq_displayed_p) - display_info_keyseq (0); - - { - WINDOW *where; - - where = active_window; - (*map[key].function) - (active_window, info_numeric_arg * info_numeric_arg_sign, key); - - /* If we have input pending, then the last command was a prefix - command. Don't change the value of the last function vars. - Otherwise, remember the last command executed in the var - appropriate to the window in which it was executed. */ - if (!info_input_pending_p ()) - { - if (where == the_echo_area) - ea_last_executed_command = map[key].function; - else - info_last_executed_command = map[key].function; - } - } - } - else - { - add_char_to_keyseq (key); - dispatch_error (info_keyseq); - return; - } + VFunction *func; + + func = map[key].function; + if (func != (VFunction *)NULL) + { + /* Special case info_do_lowercase_version (). */ + if (func == info_do_lowercase_version) + { + info_dispatch_on_key (tolower (key), map); + return; + } + + add_char_to_keyseq (key); + + if (info_keyseq_displayed_p) + display_info_keyseq (0); + + { + WINDOW *where; + + where = active_window; + (*map[key].function) + (active_window, info_numeric_arg * info_numeric_arg_sign, key); + + /* If we have input pending, then the last command was a prefix + command. Don't change the value of the last function vars. + Otherwise, remember the last command executed in the var + appropriate to the window in which it was executed. */ + if (!info_input_pending_p ()) + { + if (where == the_echo_area) + ea_last_executed_command = map[key].function; + else + info_last_executed_command = map[key].function; + } + } + } + else + { + add_char_to_keyseq (key); + dispatch_error (info_keyseq); + return; + } } break; case ISKMAP: add_char_to_keyseq (key); if (map[key].function != (VFunction *)NULL) - { - unsigned char newkey; + { + unsigned char newkey; - newkey = info_get_another_input_char (); - info_dispatch_on_key (newkey, (Keymap)map[key].function); - } + newkey = info_get_another_input_char (); + info_dispatch_on_key (newkey, (Keymap)map[key].function); + } else - { - dispatch_error (info_keyseq); - return; - } + { + dispatch_error (info_keyseq); + return; + } break; } } /* **************************************************************** */ -/* */ -/* Numeric Arguments */ -/* */ +/* */ +/* Numeric Arguments */ +/* */ /* **************************************************************** */ /* Handle C-u style numeric args, as well as M--, and M-digits. */ @@ -3971,7 +3955,7 @@ int info_numeric_arg = 1; /* Add the current digit to the argument in progress. */ DECLARE_INFO_COMMAND (info_add_digit_to_numeric_arg, - "Add this digit to the current numeric argument") + _("Add this digit to the current numeric argument")) { info_numeric_arg_digit_loop (window, 0, key); } @@ -3980,7 +3964,7 @@ DECLARE_INFO_COMMAND (info_add_digit_to_numeric_arg, Read a key. If the key has nothing to do with arguments, then dispatch on it. If the key is the abort character then abort. */ DECLARE_INFO_COMMAND (info_universal_argument, - "Start (or multiply by 4) the current numeric argument") + _("Start (or multiply by 4) the current numeric argument")) { info_numeric_arg *= 4; info_numeric_arg_digit_loop (window, 0, 0); @@ -3995,7 +3979,7 @@ info_initialize_numeric_arg () } DECLARE_INFO_COMMAND (info_numeric_arg_digit_loop, - "Internally used by \\[universal-argument]") + _("Internally used by \\[universal-argument]")) { unsigned char pure_key; Keymap keymap = window->keymap; @@ -4003,64 +3987,64 @@ DECLARE_INFO_COMMAND (info_numeric_arg_digit_loop, while (1) { if (key) - pure_key = key; + pure_key = key; else - { - if (display_was_interrupted_p && !info_any_buffered_input_p ()) - display_update_display (windows); + { + if (display_was_interrupted_p && !info_any_buffered_input_p ()) + display_update_display (windows); - if (active_window != the_echo_area) - display_cursor_at_point (active_window); + if (active_window != the_echo_area) + display_cursor_at_point (active_window); - pure_key = key = info_get_another_input_char (); + pure_key = key = info_get_another_input_char (); - if (Meta_p (key)) - add_char_to_keyseq (ESC); + if (Meta_p (key)) + add_char_to_keyseq (ESC); - add_char_to_keyseq (UnMeta (key)); - } + add_char_to_keyseq (UnMeta (key)); + } if (Meta_p (key)) - key = UnMeta (key); + key = UnMeta (key); if (keymap[key].type == ISFUNC && - keymap[key].function == info_universal_argument) - { - info_numeric_arg *= 4; - key = 0; - continue; - } + keymap[key].function == info_universal_argument) + { + info_numeric_arg *= 4; + key = 0; + continue; + } if (isdigit (key)) - { - if (info_explicit_arg) - info_numeric_arg = (info_numeric_arg * 10) + (key - '0'); - else - info_numeric_arg = (key - '0'); - info_explicit_arg = 1; - } + { + if (info_explicit_arg) + info_numeric_arg = (info_numeric_arg * 10) + (key - '0'); + else + info_numeric_arg = (key - '0'); + info_explicit_arg = 1; + } else - { - if (key == '-' && !info_explicit_arg) - { - info_numeric_arg_sign = -1; - info_numeric_arg = 1; - } - else - { - info_keyseq_index--; - info_dispatch_on_key (pure_key, keymap); - return; - } - } + { + if (key == '-' && !info_explicit_arg) + { + info_numeric_arg_sign = -1; + info_numeric_arg = 1; + } + else + { + info_keyseq_index--; + info_dispatch_on_key (pure_key, keymap); + return; + } + } key = 0; } } /* **************************************************************** */ -/* */ -/* Input Character Buffering */ -/* */ +/* */ +/* Input Character Buffering */ +/* */ /* **************************************************************** */ /* Character waiting to be read next. */ @@ -4109,7 +4093,7 @@ info_push_typeahead (key) { info_input_buffer[push_index++] = key; if (push_index >= sizeof (info_input_buffer)) - push_index = 0; + push_index = 0; } } @@ -4148,23 +4132,6 @@ info_any_buffered_input_p () return (push_index != pop_index); } -/* Push KEY into the *front* of the input buffer. Returns non-zero if - successful, zero if there is no space left in the buffer. */ -static int -info_replace_key_to_typeahead (key) - unsigned char key; -{ - if (info_input_buffer_space_available ()) - { - pop_index--; - if (pop_index < 0) - pop_index = sizeof (info_input_buffer) - 1; - info_input_buffer[pop_index] = key; - return (1); - } - return (0); -} - /* If characters are available to be read, then read them and stuff them into info_input_buffer. Otherwise, do nothing. */ void @@ -4189,7 +4156,7 @@ info_gather_typeahead () chars_avail = space_avail; if (chars_avail) - read (tty, &input[0], chars_avail); + chars_avail = read (tty, &input[0], chars_avail); } #else /* !FIONREAD */ # if defined (O_NDELAY) @@ -4231,34 +4198,55 @@ info_get_input_char () else if (info_get_key_from_typeahead (&keystroke) == 0) { int rawkey; + unsigned char c; + int tty = fileno (info_input_stream); + + /* Using stream I/O causes FIONREAD etc to fail to work + so unless someone can find a portable way of finding + out how many characters are currently buffered, we + should stay with away from stream I/O. + --Egil Kvaleberg <egilk@sn.no>, January 1997. */ +#ifdef EINTR + /* Keep reading if we got EINTR, so that we don't just exit. + --Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>, + 22 Dec 1997. */ + { + int n; + do + n = read (tty, &c, 1); + while (n == -1 && errno == EINTR); + rawkey = n == 1 ? c : EOF; + } +#else + rawkey = (read (tty, &c, 1) == 1) ? c : EOF; +#endif - rawkey = getc (info_input_stream); keystroke = rawkey; if (rawkey == EOF) - { - if (info_input_stream != stdin) - { - fclose (info_input_stream); - info_input_stream = stdin; - display_inhibited = 0; - display_update_display (windows); - display_cursor_at_point (active_window); - rawkey = getc (info_input_stream); - keystroke = rawkey; - } - - if (rawkey == EOF) - { - terminal_unprep_terminal (); - close_dribble_file (); - exit (0); - } - } + { + if (info_input_stream != stdin) + { + fclose (info_input_stream); + info_input_stream = stdin; + display_inhibited = 0; + display_update_display (windows); + display_cursor_at_point (active_window); + rawkey = (read (tty, &c, 1) == 1) ? c : EOF; + keystroke = rawkey; + } + + if (rawkey == EOF) + { + terminal_unprep_terminal (); + close_dribble_file (); + exit (0); + } + } } if (info_dribble_file) dribble (keystroke); - return (keystroke); + return keystroke; } |