texinfo-commits
[Top][All Lists]
Advanced

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

[5716] allow interrupting redisplay in another place, centralize session


From: Gavin D. Smith
Subject: [5716] allow interrupting redisplay in another place, centralize session cleanup
Date: Thu, 24 Jul 2014 12:13:42 +0000

Revision: 5716
          http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=5716
Author:   gavin
Date:     2014-07-24 12:13:41 +0000 (Thu, 24 Jul 2014)
Log Message:
-----------
allow interrupting redisplay in another place, centralize session cleanup

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/info/display.c
    trunk/info/display.h
    trunk/info/echo-area.c
    trunk/info/info.c
    trunk/info/m-x.c
    trunk/info/nodes.h
    trunk/info/session.c
    trunk/info/session.h
    trunk/info/signals.c
    trunk/info/window.c
    trunk/info/window.h

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog     2014-07-22 09:59:19 UTC (rev 5715)
+++ trunk/ChangeLog     2014-07-24 12:13:41 UTC (rev 5716)
@@ -1,3 +1,32 @@
+2014-07-24  Gavin Smith  <address@hidden>
+
+       * info/window.c (collect_line_starts, _calc_line_starts): Renamed.
+       * info/window.h (WINDOW): Change type of pagetop field to long.
+       Remove declaration of removed function.
+       * info/nodes.h (NODE): Change type of line_number field to long.
+       * info/window.c (window_log_to_phys_line): Type of arguments and
+       return value changed.
+
+       * info/display.c (display_update_display): Arguments changed.  All
+       callers updated.
+       (display_update_one_window): Allow interrupting redisplay when
+       clearing empty screen lines after the end of a node.
+
+       * info/info.c, info/session.c (allfiles_create_node): Moved betweeen
+       files.
+       * info/session.c (begin_multiple_window_info_session): Never call
+       info_session; rely on caller to do it.
+       (display_startup_message): Declared static.
+
+       * info/session.c (info_session): Arguments changed.
+       (info_session, close_info_session): Function split out.
+       * info/info.c (main): Call to info_session updated.
+       (main) <--index-search>: Call info_read_and_dispatch
+       and close_info_session instead of info_session.
+       * info/session.c (fill_input_buffer): Call close_info_session if
+       reading input failed.
+       
+
 2014-07-22  Gavin Smith  <address@hidden>
 
        * info/session.c (forward_move_node_structure): Get first menu

Modified: trunk/info/display.c
===================================================================
--- trunk/info/display.c        2014-07-22 09:59:19 UTC (rev 5715)
+++ trunk/info/display.c        2014-07-24 12:13:41 UTC (rev 5716)
@@ -64,10 +64,9 @@
 /* Non-zero if we didn't completely redisplay a window. */
 int display_was_interrupted_p = 0;
 
-/* Update the windows pointed to by WINDOW in the_display.  This actually
-   writes the text on the screen. */
+/* Update the windows on the display. */
 void
-display_update_display (WINDOW *window)
+display_update_display (void)
 {
   register WINDOW *win;
 
@@ -78,7 +77,7 @@
   display_was_interrupted_p = 0;
 
   /* For every window in the list, check contents against the display. */
-  for (win = window; win; win = win->next)
+  for (win = windows; win; win = win->next)
     {
       /* Only re-display visible windows which need updating. */
       if (((win->flags & W_WindowVisible) == 0) ||
@@ -220,15 +219,17 @@
 
   /* If display is inhibited, that counts as an interrupted display. */
   if (display_inhibited)
-    display_was_interrupted_p = 1;
+    {
+      display_was_interrupted_p = 1;
+      goto funexit;
+    }
 
-  /* If the window has no height, or display is inhibited, quit now.
-     Strictly speaking, it should only be necessary to test if the
-     values are equal to zero, since window_new_screen_size should
-     ensure that the window height/width never becomes negative, but
-     since historically this has often been the culprit for crashes, do
-     our best to be doubly safe.  */
-  if (win->height <= 0 || win->width <= 0 || display_inhibited)
+  /* If the window has no height, quit now.  Strictly speaking, it
+     should only be necessary to test if the values are equal to zero, since
+     window_new_screen_size should ensure that the window height/width never
+     becomes negative, but since historically this has often been the culprit
+     for crashes, do our best to be doubly safe.  */
+  if (win->height <= 0 || win->width <= 0)
     goto funexit;
 
   /* If the window's first row doesn't appear in the_screen, then it
@@ -263,6 +264,13 @@
 
           terminal_goto_xy (0, win->first_row + line_index);
           terminal_clear_to_eol ();
+          fflush (stdout);
+
+          if (info_any_buffered_input_p ())
+            {
+              display_was_interrupted_p = 1;
+              goto funexit;
+            }
         }
     }
 

Modified: trunk/info/display.h
===================================================================
--- trunk/info/display.h        2014-07-22 09:59:19 UTC (rev 5715)
+++ trunk/info/display.h        2014-07-24 12:13:41 UTC (rev 5716)
@@ -47,9 +47,8 @@
 /* Clear all of the lines in DISPLAY making the screen blank. */
 extern void display_clear_display (DISPLAY_LINE **display);
 
-/* Update the windows pointed to by WINDOWS in THE_DISPLAY.  This actually
-   writes the text on the screen. */
-extern void display_update_display (WINDOW *window);
+/* Update the windows on the display. */
+extern void display_update_display (void);
 
 /* Display WIN on THE_DISPLAY.  Unlike display_update_display (), this
    function only does one window. */

Modified: trunk/info/echo-area.c
===================================================================
--- trunk/info/echo-area.c      2014-07-22 09:59:19 UTC (rev 5715)
+++ trunk/info/echo-area.c      2014-07-24 12:13:41 UTC (rev 5716)
@@ -173,7 +173,7 @@
       echo_area_prep_read ();
 
       if (!info_any_buffered_input_p ())
-        display_update_display (windows);
+        display_update_display ();
 
       display_cursor_at_point (active_window);
       info_initialize_numeric_arg ();
@@ -1073,7 +1073,7 @@
         if (compwin->node != possible_completions_output_node)
           info_set_node_of_window (compwin, possible_completions_output_node);
 
-        display_update_display (windows);
+        display_update_display ();
       }
     }
 }

Modified: trunk/info/info.c
===================================================================
--- trunk/info/info.c   2014-07-22 09:59:19 UTC (rev 5715)
+++ trunk/info/info.c   2014-07-24 12:13:41 UTC (rev 5716)
@@ -450,50 +450,8 @@
 
   return;
 }
-
 
-/* Defined in indices.c */
-extern NODE *allfiles_node;
-
 static void
-allfiles_create_node (char *term, REFERENCE **fref)
-{
-  int i;
-  struct text_buffer text;
-  
-  text_buffer_init (&text);
-
-  text_buffer_printf (&text,
-                     "%s File names matching `%s'\n\n"
-                     "Info File Index\n"
-                     "***************\n\n"
-                     "File names that match `%s':\n",
-                      INFO_NODE_LABEL,
-                     term, term);
-
-  /* Mark as an index so that destinations are never hidden. */
-  text_buffer_add_string (&text, "\000\010[index\000\010]", 11);
-  text_buffer_printf (&text, "\n* Menu:\n\n");
-
-  for (i = 0; fref[i]; i++)
-    {
-      text_buffer_printf (&text, "* %4i: (%s)", i+1, fref[i]->filename);
-      if (fref[i]->nodename)
-       text_buffer_printf (&text, "%s", fref[i]->nodename);
-      text_buffer_printf (&text, ".\n");
-    }
-
-  allfiles_node = info_create_node ();
-  allfiles_node->fullpath = xstrdup ("");
-  allfiles_node->nodename = xstrdup ("*Info File Index*");
-  allfiles_node->contents = text_buffer_base (&text);
-  allfiles_node->nodelen = text_buffer_off (&text);
-  allfiles_node->body_start = strcspn (allfiles_node->contents, "\n");
-
-  scan_node_contents (0, &allfiles_node);
-}
-
-static void
 info_find_matching_files (char *filename)
 {
   int i;
@@ -859,6 +817,9 @@
               initialize_info_session ();
               do_info_index_search (windows, initial_fb, 0,
                                     index_search_string);
+              info_read_and_dispatch ();
+              close_info_session ();
+              return 0;
             }
           else
             {
@@ -867,9 +828,6 @@
               close_dribble_file ();
               return 1;
             }
-          
-          info_session ();
-          return 0;
         }
 
       /* Add nodes to start with (unless we fell back to the man page). */
@@ -913,23 +871,8 @@
       return 1;
     }
     
-  /* Initialize the Info session. */
-  initialize_info_session ();
-
-  if (!error)
-    display_startup_message ();
-  else
-    show_error_node (error);
-
-  if (!all_matches_p)
-    begin_multiple_window_info_session (ref_list, error);
-  else
-    {
-      allfiles_create_node (user_filename, ref_list);
-      info_set_node_of_window (active_window, allfiles_node);
-    }
-
-  info_session ();
+  info_session (ref_list, all_matches_p ? user_filename : 0, error);
+  close_info_session ();
   return 0;
 }
 

Modified: trunk/info/m-x.c
===================================================================
--- trunk/info/m-x.c    2014-07-22 09:59:19 UTC (rev 5715)
+++ trunk/info/m-x.c    2014-07-24 12:13:41 UTC (rev 5716)
@@ -193,7 +193,7 @@
         window_new_screen_size won't do anything, but we've
         already cleared the display above.  Undo the damage.  */
       window_mark_chain (windows, W_UpdateWindow);
-      display_update_display (windows);
+      display_update_display ();
     }
   else
     {

Modified: trunk/info/nodes.h
===================================================================
--- trunk/info/nodes.h  2014-07-22 09:59:19 UTC (rev 5715)
+++ trunk/info/nodes.h  2014-07-24 12:13:41 UTC (rev 5716)
@@ -32,7 +32,7 @@
   char *filename;       /* File where this node can be found. */
   char *nodename;       /* Name of the node. */
   int start, end;       /* Offsets within the containing node of LABEL. */
-  int line_number;      /* Specific line number a menu item points to.  */
+  long line_number;     /* Specific line number a menu item points to.  */
   int type;             /* Whether reference is a xref or a menu item */
 } REFERENCE;
 

Modified: trunk/info/session.c
===================================================================
--- trunk/info/session.c        2014-07-22 09:59:19 UTC (rev 5715)
+++ trunk/info/session.c        2014-07-24 12:13:41 UTC (rev 5716)
@@ -50,7 +50,6 @@
 /*                                                                  */
 /* **************************************************************** */
 
-static void info_read_and_dispatch (void);
 static void mouse_event_handler (void);
 
 /* The place that we are reading input from. */
@@ -62,10 +61,54 @@
 /* Minimal length of a search string */
 int min_search_length = 1;
 
+
+/* Defined in indices.c */
+extern NODE *allfiles_node;
+
+static void
+allfiles_create_node (char *term, REFERENCE **fref)
+{
+  int i;
+  struct text_buffer text;
+  
+  text_buffer_init (&text);
+
+  text_buffer_printf (&text,
+                      "%s File names matching `%s'\n\n"
+                      "Info File Index\n"
+                      "***************\n\n"
+                      "File names that match `%s':\n",
+                      INFO_NODE_LABEL,
+                      term, term);
+
+  /* Mark as an index so that destinations are never hidden. */
+  text_buffer_add_string (&text, "\000\010[index\000\010]", 11);
+  text_buffer_printf (&text, "\n* Menu:\n\n");
+
+  for (i = 0; fref[i]; i++)
+    {
+      text_buffer_printf (&text, "* %4i: (%s)", i+1, fref[i]->filename);
+      if (fref[i]->nodename)
+        text_buffer_printf (&text, "%s", fref[i]->nodename);
+      text_buffer_printf (&text, ".\n");
+    }
+
+  allfiles_node = info_create_node ();
+  allfiles_node->fullpath = xstrdup ("");
+  allfiles_node->nodename = xstrdup ("*Info File Index*");
+  allfiles_node->contents = text_buffer_base (&text);
+  allfiles_node->nodelen = text_buffer_off (&text);
+  allfiles_node->body_start = strcspn (allfiles_node->contents, "\n");
+
+  scan_node_contents (0, &allfiles_node);
+}
+
+
+
 /* Begin an info session finding the nodes specified by REFERENCES.  For
    each loaded node, create a new window.  Always split the largest of the
    available windows.  Display ERROR in echo area if non-null. */
-void
+static void
 begin_multiple_window_info_session (REFERENCE **references, char *error)
 {
   register int i;
@@ -97,10 +140,9 @@
 
           if (!largest)
             {
-              display_update_display (windows);
+              display_update_display ();
               info_error ("%s", msg_cant_find_window);
-              info_session ();
-              exit (EXIT_SUCCESS);
+              return;
             }
 
           active_window = largest;
@@ -115,15 +157,12 @@
             }
 
           if (window)
-            {
-              window_tile_windows (TILE_INTERNALS);
-            }
+            window_tile_windows (TILE_INTERNALS);
           else
             {
-              display_update_display (windows);
+              display_update_display ();
               info_error ("%s", msg_win_too_small);
-              info_session ();
-              exit (EXIT_SUCCESS);
+              return;
             }
         }
     }
@@ -137,7 +176,7 @@
     }
 }
 
-void
+static void
 display_startup_message (void)
 {
   char *format;
@@ -149,25 +188,37 @@
   window_message_in_echo_area (format, VERSION, NULL);
 }
 
-/* Run an info session with an already initialized window and node. */
+/* Run an Info session.  If USER_FILENAME is null, create a window for each
+   node referenced in REF_LIST.  If USER_FILENAME is not null, "--all" was
+   used on the command line, and display a file index with entries in
+   REF_LIST.  ERROR is an optional error message to display at start-up. */
 void
-info_session (void)
+info_session (REFERENCE **ref_list, char *user_filename, char *error)
 {
-  display_update_display (windows);
+  /* Initialize the Info session. */
+  initialize_info_session ();
+
+  if (!error)
+    display_startup_message ();
+  else
+    show_error_node (error);
+
+  if (!user_filename)
+    begin_multiple_window_info_session (ref_list, error);
+  else
+    {
+      allfiles_create_node (user_filename, ref_list);
+      info_set_node_of_window (active_window, allfiles_node);
+    }
+
   info_read_and_dispatch ();
-  /* On program exit, leave the cursor at the bottom of the window, and
-     restore the terminal I/O. */
-  terminal_goto_xy (0, screenheight - 1);
-  terminal_clear_to_eol ();
-  fflush (stdout);
-  terminal_unprep_terminal ();
-  close_dribble_file ();
+  close_info_session ();
 }
 
 void mouse_reporting_on (void);
 void mouse_reporting_off (void);
 
-static void
+void
 info_read_and_dispatch (void)
 {
   int key;
@@ -175,7 +226,7 @@
   for (quit_info_immediately = 0; !quit_info_immediately; )
     {
       if (!info_any_buffered_input_p ())
-        display_update_display (windows);
+        display_update_display ();
 
       display_cursor_at_point (active_window);
       info_initialize_numeric_arg ();
@@ -240,6 +291,18 @@
   info_windows_initialized_p = 1;
 }
 
+/* On program exit, leave the cursor at the bottom of the window, and
+   restore the terminal I/O. */
+void
+close_info_session (void)
+{
+  terminal_goto_xy (0, screenheight - 1);
+  terminal_clear_to_eol ();
+  fflush (stdout);
+  terminal_unprep_terminal ();
+  close_dribble_file ();
+}
+
 /* Tell Info that input is coming from the file FILENAME. */
 void
 info_set_input_from_file (char *filename)
@@ -320,6 +383,8 @@
       if (success || !wait)
         return;
 
+      /* Reading failed.  If we were reading from a dribble file with
+         --restore, switch to standard input.  Otherwise quit. */
       if (info_input_stream != stdin)
         {
           int tty;
@@ -327,13 +392,12 @@
           info_input_stream = stdin;
           tty = fileno (info_input_stream);
           display_inhibited = 0;
-          display_update_display (windows);
+          display_update_display ();
           display_cursor_at_point (active_window);
         }
       else
         {
-          terminal_unprep_terminal ();
-          close_dribble_file ();
+          close_info_session ();
           exit (EXIT_SUCCESS);
         }
     }
@@ -4462,7 +4526,7 @@
       terminal_clear_screen ();
       display_clear_display (the_display);
       window_mark_chain (windows, W_UpdateWindow);
-      display_update_display (windows);
+      display_update_display ();
     }
   else
     {
@@ -4797,7 +4861,7 @@
       else
         {
           if (display_was_interrupted_p && !info_any_buffered_input_p ())
-            display_update_display (windows);
+            display_update_display ();
 
           if (active_window != the_echo_area)
             display_cursor_at_point (active_window);

Modified: trunk/info/session.h
===================================================================
--- trunk/info/session.h        2014-07-22 09:59:19 UTC (rev 5715)
+++ trunk/info/session.h        2014-07-24 12:13:41 UTC (rev 5716)
@@ -108,12 +108,11 @@
 /* The names of the functions that run an info session. */
 
 /* Starting an info session. */
-extern void begin_multiple_window_info_session (REFERENCE **references,
-    char *error_msg);
-extern void display_startup_message (void);
-extern void info_session (void);
+void initialize_info_session (void);
+void info_read_and_dispatch (void);
+void close_info_session (void);
+void info_session (REFERENCE **ref_list, char *user_filename, char *error);
 extern void initialize_terminal_and_keymaps (char *init_file);
-extern void initialize_info_session (void);
 extern REFERENCE *info_intuit_options_node (NODE *initial_node, char *program);
 
 /* Moving the point within a node. */

Modified: trunk/info/signals.c
===================================================================
--- trunk/info/signals.c        2014-07-22 09:59:19 UTC (rev 5715)
+++ trunk/info/signals.c        2014-07-24 12:13:41 UTC (rev 5716)
@@ -159,7 +159,7 @@
   if (auto_footnotes_p)
     info_get_or_remove_footnotes (active_window);
   window_mark_chain (windows, W_UpdateWindow);
-  display_update_display (windows);
+  display_update_display ();
   display_cursor_at_point (active_window);
   fflush (stdout);
 }

Modified: trunk/info/window.c
===================================================================
--- trunk/info/window.c 2014-07-22 09:59:19 UTC (rev 5715)
+++ trunk/info/window.c 2014-07-24 12:13:41 UTC (rev 5716)
@@ -28,6 +28,8 @@
 #include "tag.h"
 #include "variables.h"
 
+static void recalculate_line_starts (WINDOW *window);
+
 /* The window which describes the screen. */
 WINDOW *the_screen = NULL;
 
@@ -672,11 +674,11 @@
 }
 
 
-/* Called by process_node_text. */
+/* Used by recalculate_line_starts via process_node_text. */
 static int
-_calc_line_starts (WINDOW *win, size_t pl_num, size_t ll_num,
-                   size_t pl_start, char *printed_line,
-                   size_t pl_bytes, size_t pl_chars)
+collect_line_starts (WINDOW *win, size_t pl_num, size_t ll_num,
+                     size_t pl_start, char *printed_line,
+                     size_t pl_bytes, size_t pl_chars)
 {
   add_element_to_array (pl_start, win->line_count,
                         win->line_starts, win->line_slots, 2);
@@ -689,8 +691,9 @@
   return 0;
 }
 
-/* Given WINDOW, recalculate the line starts for the node it displays. */
-void
+/* Calculate a list of line starts for the node belonging to WINDOW.  The line
+   starts are offsets within WINDOW->node->contents. */
+static void
 recalculate_line_starts (WINDOW *window)
 {
   free (window->line_starts);
@@ -703,7 +706,7 @@
   if (!window->node)
     return;
   
-  process_node_text (window, window->node->contents, _calc_line_starts);
+  process_node_text (window, window->node->contents, collect_line_starts);
 
   window_line_map_init (window);
 }
@@ -715,8 +718,8 @@
    occupies more than one physical line if its width is greater than the
    window width and the flag W_NoWrap is not set for that window.
  */
-size_t
-window_log_to_phys_line (WINDOW *window, size_t ln)
+long
+window_log_to_phys_line (WINDOW *window, long ln)
 {
   size_t i;
   

Modified: trunk/info/window.h
===================================================================
--- trunk/info/window.h 2014-07-22 09:59:19 UTC (rev 5715)
+++ trunk/info/window.h 2014-07-24 12:13:41 UTC (rev 5716)
@@ -55,7 +55,7 @@
    do it.  NB> The last element does NOT end with a semi-colon. */
 #define WINDOW_STATE_DECL \
    NODE *node;          /* The node displayed in this window. */ \
-   int pagetop;         /* LINE_STARTS[PAGETOP] is first line in WINDOW. */ \
+   long pagetop;        /* LINE_STARTS[PAGETOP] is first line in WINDOW. */ \
    long point           /* Offset within NODE of the cursor position. */
 
 typedef struct {
@@ -185,11 +185,6 @@
 extern NODE *format_message_node (const char *format, ...)
   TEXINFO_PRINTFLIKE(1,2);
 
-/* Build a new node with the given CONTENTS.
-   Note: CONTENTS is "stolen", i.e. the pointer to it is saved in the
-   new node. */
-extern NODE *string_to_node (char *contents);
-
 struct text_buffer;
 extern NODE *text_buffer_to_node (struct text_buffer *tb);
 
@@ -220,10 +215,6 @@
    The echo area is cleared immediately. */
 extern void window_clear_echo_area (void);
 
-/* Calculate a list of line starts for the node belonging to WINDOW.  The line
-   starts are offsets within WINDOW->node. */
-extern void recalculate_line_starts (WINDOW *window);
-
 /* Return the index of the line containing point. */
 extern int window_line_of_point (WINDOW *window);
 
@@ -253,6 +244,6 @@
 
 extern long window_end_of_line (WINDOW *win);
 
-extern size_t window_log_to_phys_line (WINDOW *window, size_t ln);
+extern long window_log_to_phys_line (WINDOW *window, long ln);
 
 #endif /* not INFO_WINDOW_H */




reply via email to

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