texinfo-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[5624] info/session.c reordering


From: Gavin D. Smith
Subject: [5624] info/session.c reordering
Date: Sun, 01 Jun 2014 14:48:30 +0000

Revision: 5624
          http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=5624
Author:   gavin
Date:     2014-06-01 14:48:28 +0000 (Sun, 01 Jun 2014)
Log Message:
-----------
info/session.c reordering

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/info/session.c

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog     2014-05-31 22:37:02 UTC (rev 5623)
+++ trunk/ChangeLog     2014-06-01 14:48:28 UTC (rev 5624)
@@ -1,3 +1,8 @@
+2014-06-01  Gavin Smith  <address@hidden>
+
+       * info/session.c: Some reordering of definitions and section comments.
+       No functional changes intended.
+
 2014-05-31  Gavin Smith  <address@hidden>
 
        * info/infodoc.c (dump_map_to_text_buffer): Hide "echo-area-insert"

Modified: trunk/info/session.c
===================================================================
--- trunk/info/session.c        2014-05-31 22:37:02 UTC (rev 5623)
+++ trunk/info/session.c        2014-06-01 14:48:28 UTC (rev 5624)
@@ -67,9 +67,6 @@
 /* Becomes non-zero when 'q' is typed to an Info window. */
 static int quit_info_immediately = 0;
 
-/* Whether to use regexps or not for search.  */
-static int use_regex = 1;
-
 /* Minimal length of a search string */
 int min_search_length = 1;
 
@@ -303,6 +300,13 @@
     display_inhibited = 1;
 }
 
+
+/* **************************************************************** */
+/*                                                                  */
+/*                       Window node history                        */
+/*                                                                  */
+/* **************************************************************** */
+
 /* Reset the remembered pagetop and point of WINDOW to WINDOW's current
    values if the window and node are the same as the current one being
    displayed. */
@@ -391,7 +395,7 @@
 
 /* **************************************************************** */
 /*                                                                  */
-/*                     Movement within a node                       */
+/*                   Cursor movement within a node                  */
 /*                                                                  */
 /* **************************************************************** */
 
@@ -513,6 +517,38 @@
       }
 }
 
+/* Move the cursor to the desired line of the window. */
+DECLARE_INFO_COMMAND (info_move_to_window_line,
+   _("Move the cursor to a specific line of the window"))
+{
+  int line;
+
+  /* With no numeric argument of any kind, default to the center line. */
+  if (!info_explicit_arg && count == 1)
+    line = (window->height / 2) + window->pagetop;
+  else
+    {
+      if (count < 0)
+        line = (window->height + count) + window->pagetop;
+      else
+        line = window->pagetop + count;
+    }
+
+  /* If the line doesn't appear in this window, make it do so. */
+  if ((line - window->pagetop) >= window->height)
+    line = window->pagetop + (window->height - 1);
+
+  /* If the line is too small, make it fit. */
+  if (line < window->pagetop)
+    line = window->pagetop;
+
+  /* If the selected line is past the bottom of the node, force it back. */
+  if (line >= window->line_count)
+    line = window->line_count - 1;
+
+  window->point = window->line_starts[line];
+}
+
 /* Return true if POINT sits on a newline character. */
 static int
 looking_at_newline (WINDOW *win, long point)
@@ -1122,6 +1158,34 @@
   info_scroll_half_screen_down (window, -count, key);
 }
 
+/* Scroll the "other" window of WINDOW. */
+DECLARE_INFO_COMMAND (info_scroll_other_window, _("Scroll the other window"))
+{
+  WINDOW *other;
+
+  /* If only one window, give up. */
+  if (!windows->next)
+    {
+      info_error ("%s", msg_one_window);
+      return;
+    }
+
+  other = window->next;
+
+  if (!other)
+    other = window->prev;
+
+  info_scroll_forward (other, count, key);
+}
+
+/* Scroll the "other" window of WINDOW. */
+DECLARE_INFO_COMMAND (info_scroll_other_window_backward,
+                      _("Scroll the other window backward"))
+{
+  info_scroll_other_window (window, -count, key);
+}
+
+
 
 /* **************************************************************** */
 /*                                                                  */
@@ -1361,33 +1425,6 @@
   window->flags |= W_UpdateWindow;
 }
 
-/* Scroll the "other" window of WINDOW. */
-DECLARE_INFO_COMMAND (info_scroll_other_window, _("Scroll the other window"))
-{
-  WINDOW *other;
-
-  /* If only one window, give up. */
-  if (!windows->next)
-    {
-      info_error ("%s", msg_one_window);
-      return;
-    }
-
-  other = window->next;
-
-  if (!other)
-    other = window->prev;
-
-  info_scroll_forward (other, count, key);
-}
-
-/* Scroll the "other" window of WINDOW. */
-DECLARE_INFO_COMMAND (info_scroll_other_window_backward,
-                      _("Scroll the other window backward"))
-{
-  info_scroll_other_window (window, -count, key);
-}
-
 /* Change the size of WINDOW by AMOUNT. */
 DECLARE_INFO_COMMAND (info_grow_window, _("Grow (or shrink) this window"))
 {
@@ -1411,136 +1448,9 @@
 {
   window_toggle_wrap (window);
 }
-
-/* Toggle the usage of regular expressions in searches. */
-DECLARE_INFO_COMMAND (info_toggle_regexp,
-              _("Toggle the usage of regular expressions in searches"))
-{
-  use_regex = !use_regex;
-  window_message_in_echo_area (use_regex
-                               ? _("Using regular expressions for searches.")
-                               : _("Using literal strings for searches."));
-}
 
 /* **************************************************************** */
 /*                                                                  */
-/*                      Info Node Commands                          */
-/*                                                                  */
-/* **************************************************************** */
-
-/* Return (FILENAME)NODENAME for NODE, or just NODENAME if NODE's
-   filename is not set. */
-char *
-node_printed_rep (NODE *node)
-{
-  char *rep;
-
-  if (node->filename)
-    {
-      char *filename
-       = filename_non_directory (node->parent ? node->parent : node->filename);
-      rep = xmalloc (1 + strlen (filename) + 1 + strlen (node->nodename) + 1);
-      sprintf (rep, "(%s)%s", filename, node->nodename);
-    }
-  else
-    rep = node->nodename;
-
-  return rep;
-}
-
-
-/* Using WINDOW for various defaults, select the node referenced by ENTRY
-   in it.  If the node is selected, the window and node are remembered. */
-void
-info_select_reference (WINDOW *window, REFERENCE *entry)
-{
-  NODE *node;
-  char *file_system_error;
-
-  file_system_error = NULL;
-
-  node = info_get_node_with_defaults (entry->filename, entry->nodename,
-             PARSE_NODE_VERBATIM, window);
-
-  /* Try something a little weird.  If the node couldn't be found, and the
-     reference was of the form "foo::", see if the entry->label can be found
-     as a file, with a node of "Top". */
-  if (!node)
-    {
-      if (info_recent_file_error)
-        file_system_error = xstrdup (info_recent_file_error);
-
-      if (entry->nodename
-          && entry->label && (strcmp (entry->nodename, entry->label) == 0))
-        {
-          node = info_get_node (entry->label, "Top", PARSE_NODE_DFLT);
-          if (!node && info_recent_file_error)
-            {
-              free (file_system_error);
-              file_system_error = xstrdup (info_recent_file_error);
-            }
-        }
-    }
-
-  if (!node)
-    {
-      if (file_system_error)
-        info_error ("%s", file_system_error);
-      else
-        info_error (msg_cant_find_node, entry->nodename);
-    }
-
-  free (file_system_error);
-
-  if (node)
-    {
-      long loc, line;
-
-      info_set_node_of_window (window, node);
-
-      if (entry->line_number > 0)
-        {
-          /* Go to the line given by entry->line_number. */
-          line = window_log_to_phys_line (window, entry->line_number - 1);
-
-          if (line >= 0 && line < window->line_count)
-            loc = window->line_starts[line];
-          else
-            {
-              /* Try to find an occurence of LABEL in this node.  This
-                 could be useful for following index entries. */
-              long start = window->line_starts[1];
-              loc = info_target_search_node (node, entry->label, start, 1);
-            }
-
-          if (loc != -1)
-            {
-              window->point = loc;
-              window_adjust_pagetop (window);
-            }
-        }
-    }
-}
-
-/* Parse the node specification in LINE using WINDOW to default the filename.
-   Select the parsed node in WINDOW and remember it, or error if the node
-   couldn't be found. */
-static void
-info_parse_and_select (char *line, WINDOW *window)
-{
-  REFERENCE entry;
-
-  /* info_parse_node will be called on 'line' in subsequent functions. */
-  entry.nodename = line;
-  entry.filename = 0;
-  entry.label = "*info-parse-and-select*";
-
-  info_select_reference (window, &entry);
-}
-
-
-/* **************************************************************** */
-/*                                                                  */
 /*                 Navigation of document structure                 */
 /*                                                                  */
 /* **************************************************************** */
@@ -1955,10 +1865,99 @@
 
 /* **************************************************************** */
 /*                                                                  */
-/*              Selection of cross-references and menus             */
+/*                    Cross-references and menus                    */
 /*                                                                  */
 /* **************************************************************** */
 
+/* Using WINDOW for various defaults, select the node referenced by ENTRY
+   in it.  If the node is selected, the window and node are remembered. */
+void
+info_select_reference (WINDOW *window, REFERENCE *entry)
+{
+  NODE *node;
+  char *file_system_error;
+
+  file_system_error = NULL;
+
+  node = info_get_node_with_defaults (entry->filename, entry->nodename,
+             PARSE_NODE_VERBATIM, window);
+
+  /* Try something a little weird.  If the node couldn't be found, and the
+     reference was of the form "foo::", see if the entry->label can be found
+     as a file, with a node of "Top". */
+  if (!node)
+    {
+      if (info_recent_file_error)
+        file_system_error = xstrdup (info_recent_file_error);
+
+      if (entry->nodename
+          && entry->label && (strcmp (entry->nodename, entry->label) == 0))
+        {
+          node = info_get_node (entry->label, "Top", PARSE_NODE_DFLT);
+          if (!node && info_recent_file_error)
+            {
+              free (file_system_error);
+              file_system_error = xstrdup (info_recent_file_error);
+            }
+        }
+    }
+
+  if (!node)
+    {
+      if (file_system_error)
+        info_error ("%s", file_system_error);
+      else
+        info_error (msg_cant_find_node, entry->nodename);
+    }
+
+  free (file_system_error);
+
+  if (node)
+    {
+      long loc, line;
+
+      info_set_node_of_window (window, node);
+
+      if (entry->line_number > 0)
+        {
+          /* Go to the line given by entry->line_number. */
+          line = window_log_to_phys_line (window, entry->line_number - 1);
+
+          if (line >= 0 && line < window->line_count)
+            loc = window->line_starts[line];
+          else
+            {
+              /* Try to find an occurence of LABEL in this node.  This
+                 could be useful for following index entries. */
+              long start = window->line_starts[1];
+              loc = info_target_search_node (node, entry->label, start, 1);
+            }
+
+          if (loc != -1)
+            {
+              window->point = loc;
+              window_adjust_pagetop (window);
+            }
+        }
+    }
+}
+
+/* Parse the node specification in LINE using WINDOW to default the filename.
+   Select the parsed node in WINDOW and remember it, or error if the node
+   couldn't be found. */
+static void
+info_parse_and_select (char *line, WINDOW *window)
+{
+  REFERENCE entry;
+
+  /* info_parse_node will be called on 'line' in subsequent functions. */
+  entry.nodename = line;
+  entry.filename = 0;
+  entry.label = "*info-parse-and-select*";
+
+  info_select_reference (window, &entry);
+}
+
 /* Select the last menu item in WINDOW->node. */
 DECLARE_INFO_COMMAND (info_last_menu_item,
    _("Select the last item in this node's menu"))
@@ -2413,87 +2412,6 @@
   info_menu_or_ref_item (window, key, 1, 1, 0);
 }
 
-
-/* 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"))
-{
-  char *line;
-
-#define GOTO_COMPLETES
-#if defined (GOTO_COMPLETES)
-  /* Build a completion list of all of the known nodes. */
-  {
-    register int fbi, i;
-    FILE_BUFFER *current;
-    REFERENCE **items = NULL;
-    size_t items_index = 0;
-    size_t items_slots = 0;
-
-    current = file_buffer_of_window (window);
-
-    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 = xmalloc (sizeof (REFERENCE));
-        entry->filename = entry->nodename = NULL;
-        entry->label = xmalloc (4 + strlen (fb->filename));
-        sprintf (entry->label, "(%s)*", fb->filename);
-
-        add_pointer_to_array (entry, items_index, items, items_slots, 10);
-
-        if (fb->tags)
-          {
-            for (i = 0; fb->tags[i]; i++)
-              {
-                entry = xmalloc (sizeof (REFERENCE));
-                entry->filename = entry->nodename = NULL;
-                if (this_is_the_current_fb)
-                  entry->label = xstrdup (fb->tags[i]->nodename);
-                else
-                  {
-                    entry->label = 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);
-              }
-          }
-      }
-    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: "));
-#endif /* !GOTO_COMPLETES */
-
-  /* If the user aborted, quit now. */
-  if (!line)
-    {
-      info_abort_key (window, 0, 0);
-      return;
-    }
-
-  canonicalize_whitespace (line);
-
-  if (*line)
-    info_parse_and_select (line, window);
-
-  free (line);
-  if (!info_error_was_printed)
-    window_clear_echo_area ();
-}
-
 /* Follow the menu list in MENUS (list of strings terminated by a NULL
    entry) from INITIAL_NODE.  If there is an error, place a message
    in ERROR.  STRICT says whether to accept incomplete strings as
@@ -2661,6 +2579,113 @@
     window_clear_echo_area ();
 }
 
+
+/* **************************************************************** */
+/*                                                                  */
+/*                      Info Node Commands                          */
+/*                                                                  */
+/* **************************************************************** */
+
+/* Return (FILENAME)NODENAME for NODE, or just NODENAME if NODE's
+   filename is not set. */
+char *
+node_printed_rep (NODE *node)
+{
+  char *rep;
+
+  if (node->filename)
+    {
+      char *filename
+       = filename_non_directory (node->parent ? node->parent : node->filename);
+      rep = xmalloc (1 + strlen (filename) + 1 + strlen (node->nodename) + 1);
+      sprintf (rep, "(%s)%s", filename, node->nodename);
+    }
+  else
+    rep = node->nodename;
+
+  return rep;
+}
+
+/* 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"))
+{
+  char *line;
+
+#define GOTO_COMPLETES
+#if defined (GOTO_COMPLETES)
+  /* Build a completion list of all of the known nodes. */
+  {
+    register int fbi, i;
+    FILE_BUFFER *current;
+    REFERENCE **items = NULL;
+    size_t items_index = 0;
+    size_t items_slots = 0;
+
+    current = file_buffer_of_window (window);
+
+    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 = xmalloc (sizeof (REFERENCE));
+        entry->filename = entry->nodename = NULL;
+        entry->label = xmalloc (4 + strlen (fb->filename));
+        sprintf (entry->label, "(%s)*", fb->filename);
+
+        add_pointer_to_array (entry, items_index, items, items_slots, 10);
+
+        if (fb->tags)
+          {
+            for (i = 0; fb->tags[i]; i++)
+              {
+                entry = xmalloc (sizeof (REFERENCE));
+                entry->filename = entry->nodename = NULL;
+                if (this_is_the_current_fb)
+                  entry->label = xstrdup (fb->tags[i]->nodename);
+                else
+                  {
+                    entry->label = 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);
+              }
+          }
+      }
+    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: "));
+#endif /* !GOTO_COMPLETES */
+
+  /* If the user aborted, quit now. */
+  if (!line)
+    {
+      info_abort_key (window, 0, 0);
+      return;
+    }
+
+  canonicalize_whitespace (line);
+
+  if (*line)
+    info_parse_and_select (line, window);
+
+  free (line);
+  if (!info_error_was_printed)
+    window_clear_echo_area ();
+}
+
 /* Find the node that is the best candidate to list the PROGRAM's
    invocation info and its command-line options, by looking for menu
    items and chains of menu items with characteristic names.  Return
@@ -2815,7 +2840,7 @@
   free (line);
   free (default_program_name);
 }
-
+
 DECLARE_INFO_COMMAND (info_man, _("Read a manpage reference and select it"))
 {
   char *line;
@@ -2854,7 +2879,23 @@
   info_parse_and_select ("(dir)Top", window);
 }
 
-
+DECLARE_INFO_COMMAND (info_display_file_info,
+                     _("Show full file name of node being displayed"))
+{
+  char *fname = info_find_fullpath (window->node->filename, 0);
+  if (fname)
+    {
+      int line = window_line_of_point (window);
+      window_message_in_echo_area ("File name: %s, line %d of %ld (%ld%%)",
+                                  fname, line,
+                                  window->line_count,
+                                  line * 100 / window->line_count);
+      free (fname);
+    }
+  else
+    window_message_in_echo_area ("Internal 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 *
@@ -2967,7 +3008,6 @@
   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"))
 {
@@ -3157,7 +3197,7 @@
 DECLARE_INFO_COMMAND (info_print_node,
  _("Pipe the contents of this node through INFO_PRINT_COMMAND"))
 {
-  print_node (window->node);
+    print_node (window->node);
 }
 
 /* Print NODE on a printer piping it into INFO_PRINT_COMMAND. */
@@ -3239,6 +3279,19 @@
 static int last_search_direction = 0;
 static int last_search_case_sensitive = 0;
 
+/* Whether to use regexps or not for search.  */
+static int use_regex = 1;
+
+/* Toggle the usage of regular expressions in searches. */
+DECLARE_INFO_COMMAND (info_toggle_regexp,
+              _("Toggle the usage of regular expressions in searches"))
+{
+  use_regex = !use_regex;
+  window_message_in_echo_area (use_regex
+                               ? _("Using regular expressions for searches.")
+                               : _("Using literal strings for searches."));
+}
+
 /* Return the file buffer which belongs to WINDOW's node. */
 FILE_BUFFER *
 file_buffer_of_window (WINDOW *window)
@@ -4281,6 +4334,7 @@
         }
     }
 }
+
 
 /* **************************************************************** */
 /*                                                                  */
@@ -4308,38 +4362,6 @@
   window_message_in_echo_area (_("GNU Info version %s"), VERSION);
 }
 
-/* Move the cursor to the desired line of the window. */
-DECLARE_INFO_COMMAND (info_move_to_window_line,
-   _("Move the cursor to a specific line of the window"))
-{
-  int line;
-
-  /* With no numeric argument of any kind, default to the center line. */
-  if (!info_explicit_arg && count == 1)
-    line = (window->height / 2) + window->pagetop;
-  else
-    {
-      if (count < 0)
-        line = (window->height + count) + window->pagetop;
-      else
-        line = window->pagetop + count;
-    }
-
-  /* If the line doesn't appear in this window, make it do so. */
-  if ((line - window->pagetop) >= window->height)
-    line = window->pagetop + (window->height - 1);
-
-  /* If the line is too small, make it fit. */
-  if (line < window->pagetop)
-    line = window->pagetop;
-
-  /* If the selected line is past the bottom of the node, force it back. */
-  if (line >= window->line_count)
-    line = window->line_count - 1;
-
-  window->point = window->line_starts[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"))
@@ -4764,23 +4786,6 @@
       key = 0;
     }
 }
-
-DECLARE_INFO_COMMAND (info_display_file_info,
-                     _("Show full file name of node being displayed"))
-{
-  char *fname = info_find_fullpath (window->node->filename, 0);
-  if (fname)
-    {
-      int line = window_line_of_point (window);
-      window_message_in_echo_area ("File name: %s, line %d of %ld (%ld%%)",
-                                  fname, line,
-                                  window->line_count,
-                                  line * 100 / window->line_count);
-      free (fname);
-    }
-  else
-    window_message_in_echo_area ("Internal node");
-}
 
 /* **************************************************************** */
 /*                                                                  */




reply via email to

[Prev in Thread] Current Thread [Next in Thread]