texinfo-commits
[Top][All Lists]
Advanced

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

[5817] use terminal scrolling region if available


From: Gavin D. Smith
Subject: [5817] use terminal scrolling region if available
Date: Wed, 10 Sep 2014 19:46:12 +0000

Revision: 5817
          http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=5817
Author:   gavin
Date:     2014-09-10 19:46:09 +0000 (Wed, 10 Sep 2014)
Log Message:
-----------
use terminal scrolling region if available

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

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog     2014-09-09 16:00:18 UTC (rev 5816)
+++ trunk/ChangeLog     2014-09-10 19:46:09 UTC (rev 5817)
@@ -1,3 +1,20 @@
+2014-09-10  Gavin Smith  <address@hidden>
+
+       * info/display.c (display_scroll_region): New function.
+       (display_scroll_display): Call it if the terminal supports setting a
+       scrolling region.
+
+       * info/terminal.c (terminal_scroll_region): New function.
+       (terminal_can_scroll_region): New variable.
+       (term_cs, term_SF, term_SR): New variables.
+       (terminal_initialize_terminal): Set them.
+       
+       * info/window.c (set_window_pagetop): Pass top and bottom of
+       window being scrolled to display_scroll_display.
+
+       * info/display.c (display_update_window_1): Correct length argument
+       passed to display_node_text.
+
 2014-09-09  Gavin Smith  <address@hidden>
 
        * info/session.c (forward_move_node_structure)

Modified: trunk/info/display.c
===================================================================
--- trunk/info/display.c        2014-09-09 16:00:18 UTC (rev 5816)
+++ trunk/info/display.c        2014-09-10 19:46:09 UTC (rev 5817)
@@ -362,7 +362,7 @@
             {
               finish = display_node_text (win->first_row + pl_num,
                           text_buffer_base (&tb_printed_line),
-                          text_buffer_off (&tb_printed_line),
+                          text_buffer_off (&tb_printed_line) - 1,
                           pl_chars);
             }
           else
@@ -545,6 +545,57 @@
   signal_unblock_winch ();
 }
 
+/* Scroll screen lines from START inclusive to END exclusive down
+   by AMOUNT lines.  Negative AMOUNT means move them up. */
+static void
+display_scroll_region (int start, int end, int amount)
+{
+  int i;
+  DISPLAY_LINE *temp;
+
+  /* Do it on the screen. */
+  terminal_scroll_region (start, end, amount);
+
+  /* Now do it in the display buffer so our contents match the screen. */
+  if (amount > 0)
+    {
+      for (i = end - 1; i >= start + amount; i--)
+        {
+          /* Swap rows i and (i - amount). */
+          temp = the_display[i];
+          the_display[i] = the_display[i - amount];
+          the_display[i - amount] = temp;
+        }
+
+      /* Clear vacated lines */
+      for (i = start; i < start + amount && i < end; i++)
+        {
+          the_display[i]->text[0] = '\0';
+          the_display[i]->textlen = 0;
+          the_display[i]->inverse = 0;
+        }
+    }
+  else
+    {
+      amount *= -1;
+      for (i = start; i <= end - 1 - amount; i++)
+        {
+          /* Swap rows i and (i + amount). */
+          temp = the_display[i];
+          the_display[i] = the_display[i + amount];
+          the_display[i + amount] = temp;
+        }
+
+      /* Clear vacated lines */
+      for (i = end - 1; i >= end - amount && i >= start; i--)
+        {
+          the_display[i]->text[0] = '\0';
+          the_display[i]->textlen = 0;
+          the_display[i]->inverse = 0;
+        }
+    }
+}
+
 /* Scroll the region of the_display starting at START, ending at END, and
    moving the lines AMOUNT lines.  If AMOUNT is less than zero, the lines
    are moved up in the screen, otherwise down.  Actually, it is possible
@@ -557,7 +608,7 @@
   DISPLAY_LINE *temp;
 
   /* If this terminal cannot do scrolling, give up now. */
-  if (!terminal_can_scroll)
+  if (!terminal_can_scroll && !terminal_can_scroll_region)
     return;
 
   /* If there isn't anything displayed on the screen because it is too
@@ -569,6 +620,21 @@
   if (info_any_buffered_input_p ())
     return;
 
+  /* Use scrolling region if we can because it doesn't affect the area
+     below the area we want to scroll. */
+  if (terminal_can_scroll_region)
+    {
+      display_scroll_region (start, end, amount);
+      return;
+    }
+
+  /* Otherwise scroll by deleting and inserting lines. */
+
+  if (amount < 0)
+    start -= amount;
+  else
+    end -= amount;
+
   /* Do it on the screen. */
   terminal_scroll_terminal (start, end, amount);
 

Modified: trunk/info/terminal.c
===================================================================
--- trunk/info/terminal.c       2014-09-09 16:00:18 UTC (rev 5816)
+++ trunk/info/terminal.c       2014-09-10 19:46:09 UTC (rev 5817)
@@ -92,6 +92,9 @@
 static char *term_begin_use, *term_end_use;
 static char *term_AL, *term_DL, *term_al, *term_dl;
 
+static char *term_cs; /* Set scrolling region. */
+static char *term_SF, *term_SR; /* Scroll forward and in reverse. */
+
 static char *term_keypad_on, *term_keypad_off;
 
 /* How to go up a line. */
@@ -237,6 +240,10 @@
 /* Non-zero means that the terminal can do scrolling. */
 int terminal_can_scroll = 0;
 
+/* Non-zero means that the terminal scroll within a restricted region
+   of lines. */
+int terminal_can_scroll_region = 0;
+
 /* The key sequences output by the arrow keys, if this terminal has any. */
 char *term_ku = NULL;
 char *term_kd = NULL;
@@ -448,6 +455,36 @@
   fflush (stdout);
 }
 
+void
+terminal_scroll_region (int start, int end, int amount)
+{
+  /* Any scrolling at all? */
+  if (amount == 0)
+    return;
+
+  if (terminal_scroll_terminal_hook)
+    {
+      (*terminal_scroll_terminal_hook) (start, end, amount);
+      return;
+    }
+
+  if (terminal_can_scroll_region)
+    {
+      /* Set scrolling region. */
+      tputs (tgoto (term_cs, end - 1, start), 0, output_character_function);
+
+      /* Scroll. */
+      if (amount > 0)
+        tputs (tgoto (term_SR, 0, amount), 0, output_character_function);
+      else
+        tputs (tgoto (term_SF, 0, -amount), 0, output_character_function);
+
+      /* Reset scrolling region. */
+      tputs (tgoto (term_cs, screenheight - 1, 0), 0, 
output_character_function);
+      return;
+    }
+}
+
 /* 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
@@ -730,7 +767,12 @@
   term_al = tgetstr ("al", &buffer);
   term_dl = tgetstr ("dl", &buffer);
 
+  term_cs = tgetstr ("cs", &buffer);
+  term_SF = tgetstr ("SF", &buffer);
+  term_SR = tgetstr ("SR", &buffer);
+
   terminal_can_scroll = ((term_AL || term_al) && (term_DL || term_dl));
+  terminal_can_scroll_region = term_cs && term_SF && term_SR;
 
   term_invbeg = tgetstr ("mr", &buffer);
   if (term_invbeg)

Modified: trunk/info/terminal.h
===================================================================
--- trunk/info/terminal.h       2014-09-09 16:00:18 UTC (rev 5816)
+++ trunk/info/terminal.h       2014-09-10 19:46:09 UTC (rev 5817)
@@ -47,6 +47,9 @@
 /* Non-zero means that this terminal can scroll lines up and down. */
 extern int terminal_can_scroll;
 
+/* Non-zero means that this terminal can scroll within a restricted region. */
+extern int terminal_can_scroll_region;
+
 /* Initialize the terminal which is known as TERMINAL_NAME.  If this terminal
    doesn't have cursor addressability, TERMINAL_IS_DUMB_P becomes non-zero.
    The variables SCREENHEIGHT and SCREENWIDTH are set to the dimensions that
@@ -122,6 +125,8 @@
 extern void terminal_scroll_terminal (int start, int end, int amount);
 extern VFunction *terminal_scroll_terminal_hook;
 
+extern void terminal_scroll_region (int start, int end, int amount);
+
 /* Ring the terminal bell.  The bell is run visibly if it both has one and
    terminal_use_visible_bell_p is non-zero. */
 extern void terminal_ring_bell (void);

Modified: trunk/info/window.c
===================================================================
--- trunk/info/window.c 2014-09-09 16:00:18 UTC (rev 5816)
+++ trunk/info/window.c 2014-09-10 19:46:09 UTC (rev 5817)
@@ -810,7 +810,7 @@
           (((window->height - amount) * 10) < window->height))
         return;
 
-      start = amount + window->first_row;
+      start = window->first_row;
       end = window->height + window->first_row;
 
       display_scroll_display (start, end, -amount);
@@ -827,7 +827,7 @@
         return;
 
       start = window->first_row;
-      end = (window->first_row + window->height) - amount;
+      end = window->first_row + window->height;
       display_scroll_display (start, end, amount);
     }
 }




reply via email to

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