texinfo-commits
[Top][All Lists]
Advanced

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

[5796] output sequences entering and exiting standout mode with tputs


From: Gavin D. Smith
Subject: [5796] output sequences entering and exiting standout mode with tputs
Date: Mon, 01 Sep 2014 18:04:48 +0000

Revision: 5796
          http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=5796
Author:   gavin
Date:     2014-09-01 18:04:46 +0000 (Mon, 01 Sep 2014)
Log Message:
-----------
output sequences entering and exiting standout mode with tputs

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/info/display.c
    trunk/info/display.h
    trunk/info/terminal.c
    trunk/info/terminal.h

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog     2014-09-01 15:21:44 UTC (rev 5795)
+++ trunk/ChangeLog     2014-09-01 18:04:46 UTC (rev 5796)
@@ -10,6 +10,14 @@
        pressed return without typing anything.
        * info/t/search-empty.sh: New test.
 
+       * info/terminal.c: (terminal_begin_standout, terminal_end_standout)
+       (terminal_begin_standout_hook, terminal_end_standout_hook): New
+       functions and function pointers.
+       * info/display.c (display_update_window_1): For each line which
+       contains part of a search match, display it using
+       terminal_begin_standout and terminal_end_standout in this function and
+       mark it as invalid in 'the_display'.  Remove unused argument.
+
 2014-08-30  Gavin Smith  <address@hidden>
 
        * info/session.c (incremental_search): Update an automatic footnotes

Modified: trunk/info/display.c
===================================================================
--- trunk/info/display.c        2014-09-01 15:21:44 UTC (rev 5795)
+++ trunk/info/display.c        2014-09-01 18:04:46 UTC (rev 5796)
@@ -163,10 +163,8 @@
     {
       int i, off;
              
-      /* If the screen line is inversed, then we have to clear
-        the line from the screen first.  Why, I don't know.
-        (But don't do this if we have no visible entries, as can
-        happen if the window is shrunk very small.)  */
+      /* If the screen line is inversed, or if the entry is marked as
+         invalid, then clear the line from the screen first. */
       if (entry->inverse)
        {
          terminal_goto_xy (0, pl_num);
@@ -262,7 +260,7 @@
    differ, update the display.
    Return value: number of lines processed.  */
 long
-display_update_window_1 (WINDOW *win, long pagetop)
+display_update_window_1 (WINDOW *win)
 {
   char *start = win->node->contents + win->line_starts[win->pagetop];
 
@@ -271,6 +269,11 @@
   long pl_num = 0;       /* Number of physical lines done so far. */
   mbi_iterator_t iter;
 
+  /* If there are no highlighted regions in a line, we output the line with
+     display_node_text, which does some optimization of the redisplay.
+     Otherwise, the entire line is output in this function. */
+  int match_seen_in_line = 0;
+
   regmatch_t *matches = 0;
   size_t match_index = 0;
   int in_match = 0; /* If we have highlighting on for a match. */
@@ -290,9 +293,11 @@
   text_buffer_init (&tb_printed_line);
 
   if (in_match)
-    text_buffer_add_string (&tb_printed_line, term_so, strlen (term_so));
-  else
-    text_buffer_add_string (&tb_printed_line, term_se, strlen (term_se));
+    {
+      terminal_begin_standout ();
+      match_seen_in_line = 1;
+      terminal_goto_xy (0, win->first_row);
+    }
 
   for (mbi_init (iter, start, 
                  win->node->contents + win->node->nodelen - start);
@@ -305,7 +310,7 @@
       size_t pchars = 0; /* Printed chars */
       size_t pbytes = 0; /* Bytes to output. */
       int delim = 0;
-      int finish;
+      int finish = 0;
 
       /* Check if we have processed all the lines in the window. */
       if (pl_num == win->height)
@@ -329,13 +334,20 @@
 
           if (was_in_match && !in_match)
             {
-              text_buffer_add_string (&tb_printed_line, term_se,
-                                      strlen (term_se));
+              terminal_end_standout ();
             }
           else if (!was_in_match && in_match)
             {
-              text_buffer_add_string (&tb_printed_line, term_so,
-                                      strlen (term_so));
+              if (!match_seen_in_line)
+                {
+                  match_seen_in_line = 1;
+
+                  /* Output the line so far. */
+                  terminal_goto_xy (0, win->first_row + pl_num);
+                  terminal_write_chars (text_buffer_base (&tb_printed_line),
+                                      text_buffer_off (&tb_printed_line));
+                }
+              terminal_begin_standout ();
             }
         }
 
@@ -346,11 +358,21 @@
 
           text_buffer_add_char (&tb_printed_line, '\0');
 
-          finish = display_node_text (win->first_row + pl_num,
-                      text_buffer_base (&tb_printed_line),
-                      text_buffer_off (&tb_printed_line),
-                      pl_chars);
+          if (!match_seen_in_line)
+            {
+              finish = display_node_text (win->first_row + pl_num,
+                          text_buffer_base (&tb_printed_line),
+                          text_buffer_off (&tb_printed_line),
+                          pl_chars);
+            }
+          else
+            {
+              terminal_clear_to_eol ();
+              /* Let display_node_text know to clear this entire line. */
+              the_display[win->first_row + pl_num]->inverse = 1;
+            }
 
+          /* Check if a line continuation character should be displayed. */
           if (!delim)
             {
               terminal_goto_xy (win->width - 1, win->first_row + pl_num);
@@ -368,10 +390,22 @@
                     if (mb_len (mbi_cur (iter)) == 1
                         && *mbi_cur_ptr (iter) == '\n')
                       break;
+
+                  if (matches)
+                    {
+                      /* Check if the next line starts in a match. */
+                      decide_if_in_match (mbi_cur_ptr (iter) - 
win->node->contents,
+                                          &in_match, matches, win->match_count,
+                                          &match_index);
+                      if (!in_match)
+                        terminal_end_standout ();
+                    }
                 }
               fflush (stdout);
             }
 
+          /* Set for next line. */
+          match_seen_in_line = in_match ? 1 : 0;
           ++pl_num;
 
           pl_chars = 0;
@@ -383,14 +417,18 @@
 
       if (*cur_ptr != '\n' && rep) 
         {
-          text_buffer_add_string (&tb_printed_line, rep, pbytes);
+          if (!match_seen_in_line)
+            text_buffer_add_string (&tb_printed_line, rep, pbytes);
+          else
+            terminal_write_chars (rep, pbytes);
+
           pl_chars += pchars;
           continue;
         }
     }
 
   /* This would be the very last line of the node. */
-  if (pl_chars)
+  if (pl_chars && !match_seen_in_line)
     {
       text_buffer_add_char (&tb_printed_line, '\0');
       display_node_text (win->first_row + pl_num,
@@ -437,7 +475,7 @@
 
   if (win->node && win->line_starts)
     {
-      line_index = display_update_window_1 (win, win->pagetop);
+      line_index = display_update_window_1 (win);
 
       if (display_was_interrupted_p)
        goto funexit;

Modified: trunk/info/display.h
===================================================================
--- trunk/info/display.h        2014-09-01 15:21:44 UTC (rev 5795)
+++ trunk/info/display.h        2014-09-01 18:04:46 UTC (rev 5796)
@@ -1,7 +1,7 @@
 /* display.h -- How the display in Info is done.
    $Id$
 
-   Copyright 1993, 1997, 2004, 2007, 2008, 2011, 2012, 2013
+   Copyright 1993, 1997, 2004, 2007, 2008, 2011, 2012, 2013, 2014
    Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
@@ -26,9 +26,10 @@
 #include "terminal.h"
 
 typedef struct {
-  char *text;                  /* Text of the line as it appears. */
-  int textlen;                 /* Printable Length of TEXT. */
-  int inverse;                 /* Non-zero means this line is inverse. */
+  char *text;          /* Text of the line as it appears. */
+  int textlen;         /* Printable Length of TEXT. */
+  int inverse;         /* Screen line is either in inverse video, or
+                           'text' does not represent what is on the screen. */
 } DISPLAY_LINE;
 
 /* An array of display lines which tell us what is currently visible on

Modified: trunk/info/terminal.c
===================================================================
--- trunk/info/terminal.c       2014-09-01 15:21:44 UTC (rev 5795)
+++ trunk/info/terminal.c       2014-09-01 18:04:46 UTC (rev 5796)
@@ -55,6 +55,8 @@
    to the namesake function. */
 VFunction *terminal_begin_inverse_hook = NULL;
 VFunction *terminal_end_inverse_hook = NULL;
+VFunction *terminal_begin_standout_hook = NULL;
+VFunction *terminal_end_standout_hook = NULL;
 VFunction *terminal_prep_terminal_hook = NULL;
 VFunction *terminal_unprep_terminal_hook = NULL;
 VFunction *terminal_up_line_hook = NULL;
@@ -358,6 +360,31 @@
     }
 }
 
+/* Turn on "standout mode" if possible.  Likely the same
+   as reverse video. */
+void
+terminal_begin_standout (void)
+{
+  if (terminal_begin_standout_hook)
+    (*terminal_begin_standout_hook) ();
+  else
+    {
+      send_to_terminal (term_so);
+    }
+}
+
+/* Turn off "standout mode" if possible. */
+void
+terminal_end_standout (void)
+{
+  if (terminal_end_standout_hook)
+    (*terminal_end_standout_hook) ();
+  else
+    {
+      send_to_terminal (term_se);
+    }
+}
+
 /* Ring the terminal bell.  The bell is run visibly if it both has one and
    terminal_use_visible_bell_p is non-zero. */
 void

Modified: trunk/info/terminal.h
===================================================================
--- trunk/info/terminal.h       2014-09-01 15:21:44 UTC (rev 5795)
+++ trunk/info/terminal.h       2014-09-01 18:04:46 UTC (rev 5796)
@@ -107,6 +107,14 @@
 extern void terminal_end_inverse (void);
 extern VFunction *terminal_end_inverse_hook;
 
+/* Turn on standout mode if possible. */
+extern void terminal_begin_standout (void);
+extern VFunction *terminal_begin_standout_hook;
+
+/* Turn off standout mode if possible. */
+extern void terminal_end_standout (void);
+extern VFunction *terminal_end_standout_hook;
+
 /* Scroll an area of the terminal, starting with the region from START
    to END, AMOUNT lines.  If AMOUNT is negative, the lines are scrolled
    towards the top of the screen, else they are scrolled towards the




reply via email to

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