texinfo-commits
[Top][All Lists]
Advanced

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

[5913] cursor motion in echo area across multi-byte characters


From: Gavin D. Smith
Subject: [5913] cursor motion in echo area across multi-byte characters
Date: Fri, 07 Nov 2014 11:29:32 +0000

Revision: 5913
          http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=5913
Author:   gavin
Date:     2014-11-07 11:29:29 +0000 (Fri, 07 Nov 2014)
Log Message:
-----------
cursor motion in echo area across multi-byte characters

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/info/echo-area.c

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog     2014-11-07 10:49:13 UTC (rev 5912)
+++ trunk/ChangeLog     2014-11-07 11:29:29 UTC (rev 5913)
@@ -1,5 +1,10 @@
 2014-11-07  Gavin Smith  <address@hidden>
 
+       * info/echo-area.c (ea_forward, ea_backward): Go forward and 
+       backward over multi-byte characters correctly.
+
+2014-11-07  Gavin Smith  <address@hidden>
+
        * info/session.c (info_dispatch_on_key, read_key_sequence):
        Renamed.  Call initialize_keyseq.  Read initial key of key 
        sequence.  Merge in functionality of info_numeric_arg_digit_loop 

Modified: trunk/info/echo-area.c
===================================================================
--- trunk/info/echo-area.c      2014-11-07 10:49:13 UTC (rev 5912)
+++ trunk/info/echo-area.c      2014-11-07 11:29:29 UTC (rev 5913)
@@ -300,9 +300,16 @@
     ea_backward (window, -count);
   else
     {
-      input_line_point += count;
-      if (input_line_point > input_line_end)
-        input_line_point = input_line_end;
+      mbi_iterator_t iter;
+      mbi_init (iter, input_line + input_line_point,
+                input_line_end - input_line_point);
+      while (mbi_avail (iter) && count--)
+        {
+          mbi_advance (iter);
+          input_line_point = mbi_cur_ptr (iter) - input_line;
+          if (input_line_point > input_line_end)
+            input_line_point = input_line_end;
+        }
     }
 }
 
@@ -312,9 +319,23 @@
     ea_forward (window, -count);
   else
     {
-      input_line_point -= count;
-      if (input_line_point < input_line_beg)
-        input_line_point = input_line_beg;
+      char *ptr = input_line + input_line_point;
+      while (count--)
+        {
+          /* Go back one character.  Go back by bytes until we look at a valid
+             multi-byte sequence. */
+          ptr = input_line + input_line_point;
+          while (ptr > input_line)
+            {
+              ptr--;
+              if ((long) mbrlen (ptr,
+                                 input_line + input_line_point - ptr, 0) > 0)
+                break;
+            }
+          input_line_point = ptr - input_line;
+          if (input_line_point < input_line_beg)
+            input_line_point = input_line_beg;
+        }
     }
 }
 




reply via email to

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