📄 indices.c
字号:
if (strcmp (index_search, index_index[i]->label) == 0) break; /* If that failed, look for the next substring match. */ if ((i < 0) || (!index_index[i])) { for (i = index_offset + dir; (i > -1) && (index_index[i]); i += dir) if (string_in_line (index_search, index_index[i]->label) != -1) break; if ((i > -1) && (index_index[i])) partial = string_in_line (index_search, index_index[i]->label); } /* If that failed, print an error. */ if ((i < 0) || (!index_index[i])) { info_error (_("No %sindex entries containing \"%s\"."), index_offset > 0 ? _("more ") : "", index_search); return; } /* Okay, we found the next one. Move the offset to the current entry. */ index_offset = i; /* Report to the user on what we have found. */ { register int j; char *name = _("CAN'T SEE THIS"); char *match; for (j = 0; index_nodenames[j]; j++) { if ((i >= index_nodenames[j]->first) && (i <= index_nodenames[j]->last)) { name = index_nodenames[j]->name; break; } } /* If we had a partial match, indicate to the user which part of the string matched. */ match = xstrdup (index_index[i]->label); if (partial && show_index_match) { int j, ls, start, upper; ls = strlen (index_search); start = partial - ls; upper = isupper (match[start]) ? 1 : 0; for (j = 0; j < ls; j++) if (upper) match[j + start] = info_tolower (match[j + start]); else match[j + start] = info_toupper (match[j + start]); } { char *format; format = replace_in_documentation (_("Found \"%s\" in %s. (`\\[next-index-match]' tries to find next.)")); window_message_in_echo_area (format, match, name); } free (match); } /* Select the node corresponding to this index entry. */ node = info_get_node (index_index[i]->filename, index_index[i]->nodename); if (!node) { info_error (CANT_FILE_NODE, index_index[i]->filename, index_index[i]->nodename); return; } set_remembered_pagetop_and_point (window); window_set_node_of_window (window, node); remember_window_and_node (window, node); /* Try to find an occurence of LABEL in this node. */ { long start, loc; start = window->line_starts[1] - window->node->contents; loc = info_target_search_node (node, index_index[i]->label, start); if (loc != -1) { window->point = loc; window_adjust_pagetop (window); } }}/* **************************************************************** *//* *//* Info APROPOS: Search every known index. *//* *//* **************************************************************** *//* For every menu item in DIR, search the indices of that file for SEARCH_STRING. */REFERENCE **apropos_in_all_indices (search_string, inform) char *search_string; int inform;{ register int i, dir_index; REFERENCE **all_indices = (REFERENCE **)NULL; REFERENCE **dir_menu = (REFERENCE **)NULL; NODE *dir_node; dir_node = info_get_node ("dir", "Top"); if (dir_node) dir_menu = info_menu_of_node (dir_node); if (!dir_menu) return NULL; /* For every menu item in DIR, get the associated node's file buffer and read the indices of that file buffer. Gather all of the indices into one large one. */ for (dir_index = 0; dir_menu[dir_index]; dir_index++) { REFERENCE **this_index, *this_item; NODE *this_node; FILE_BUFFER *this_fb; this_item = dir_menu[dir_index]; if (!this_item->filename) { if (dir_node->parent) this_item->filename = xstrdup (dir_node->parent); else this_item->filename = xstrdup (dir_node->filename); } /* Find this node. If we cannot find it, try using the label of the entry as a file (i.e., "(LABEL)Top"). */ this_node = info_get_node (this_item->filename, this_item->nodename); if (!this_node && this_item->nodename && (strcmp (this_item->label, this_item->nodename) == 0)) this_node = info_get_node (this_item->label, "Top"); if (!this_node) continue; /* Get the file buffer associated with this node. */ { char *files_name; files_name = this_node->parent; if (!files_name) files_name = this_node->filename; this_fb = info_find_file (files_name); if (this_fb && inform) message_in_echo_area (_("Scanning indices of \"%s\"..."), files_name); this_index = info_indices_of_file_buffer (this_fb); free (this_node); if (this_fb && inform) unmessage_in_echo_area (); } if (this_index) { /* Remember the filename which contains this set of references. */ for (i = 0; this_index && this_index[i]; i++) if (!this_index[i]->filename) this_index[i]->filename = xstrdup (this_fb->filename); /* Concatenate with the other indices. */ all_indices = info_concatenate_references (all_indices, this_index); } } info_free_references (dir_menu); /* Build a list of the references which contain SEARCH_STRING. */ if (all_indices) { REFERENCE *entry, **apropos_list = (REFERENCE **)NULL; int apropos_list_index = 0; int apropos_list_slots = 0; for (i = 0; (entry = all_indices[i]); i++) { if (string_in_line (search_string, entry->label) != -1) { add_pointer_to_array (entry, apropos_list_index, apropos_list, apropos_list_slots, 100, REFERENCE *); } else { maybe_free (entry->label); maybe_free (entry->filename); maybe_free (entry->nodename); free (entry); } } free (all_indices); all_indices = apropos_list; } return (all_indices);}#define APROPOS_NONE \ _("No available info files reference \"%s\" in their indices.")voidinfo_apropos (string) char *string;{ REFERENCE **apropos_list; apropos_list = apropos_in_all_indices (string, 0); if (!apropos_list) { info_error (APROPOS_NONE, string); } else { register int i; REFERENCE *entry; for (i = 0; (entry = apropos_list[i]); i++) fprintf (stderr, "\"(%s)%s\" -- %s\n", entry->filename, entry->nodename, entry->label); } info_free_references (apropos_list);}static char *apropos_list_nodename = "*Apropos*";DECLARE_INFO_COMMAND (info_index_apropos, _("Grovel all known info file's indices for a string and build a menu")){ char *line; line = info_read_in_echo_area (window, _("Index apropos: ")); window = active_window; /* User aborted? */ if (!line) { info_abort_key (window, 1, 1); return; } /* User typed something? */ if (*line) { REFERENCE **apropos_list; NODE *apropos_node; apropos_list = apropos_in_all_indices (line, 1); if (!apropos_list) { info_error (APROPOS_NONE, line); } else { register int i; char *line_buffer; initialize_message_buffer (); printf_to_message_buffer (_("\n* Menu: Nodes whoses indices contain \"%s\":\n"), line); line_buffer = (char *)xmalloc (500); for (i = 0; apropos_list[i]; i++) { int len; sprintf (line_buffer, "* (%s)%s::", apropos_list[i]->filename, apropos_list[i]->nodename); len = pad_to (36, line_buffer); sprintf (line_buffer + len, "%s", apropos_list[i]->label); printf_to_message_buffer ("%s\n", line_buffer); } free (line_buffer); } apropos_node = message_buffer_to_node (); add_gcable_pointer (apropos_node->contents); name_internal_node (apropos_node, apropos_list_nodename); /* Even though this is an internal node, we don't want the window system to treat it specially. So we turn off the internalness of it here. */ apropos_node->flags &= ~N_IsInternal; /* Find/Create a window to contain this node. */ { WINDOW *new; NODE *node; set_remembered_pagetop_and_point (window); /* If a window is visible and showing an apropos list already, re-use it. */ for (new = windows; new; new = new->next) { node = new->node; if (internal_info_node_p (node) && (strcmp (node->nodename, apropos_list_nodename) == 0)) break; } /* If we couldn't find an existing window, try to use the next window in the chain. */ if (!new && window->next) new = window->next; /* If we still don't have a window, make a new one to contain the list. */ if (!new) { WINDOW *old_active; old_active = active_window; active_window = window; new = window_make_window ((NODE *)NULL); active_window = old_active; } /* If we couldn't make a new window, use this one. */ if (!new) new = window; /* Lines do not wrap in this window. */ new->flags |= W_NoWrap; window_set_node_of_window (new, apropos_node); remember_window_and_node (new, apropos_node); active_window = new; } info_free_references (apropos_list); } free (line); if (!info_error_was_printed) window_clear_echo_area ();}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -