texinfo-commits
[Top][All Lists]
Advanced

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

[5593] character_width function removed


From: Gavin D. Smith
Subject: [5593] character_width function removed
Date: Wed, 21 May 2014 21:58:43 +0000

Revision: 5593
          http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=5593
Author:   gavin
Date:     2014-05-21 21:58:42 +0000 (Wed, 21 May 2014)
Log Message:
-----------
character_width function removed

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/info/infodoc.c
    trunk/info/session.c
    trunk/info/window.c
    trunk/info/window.h

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog     2014-05-21 01:36:21 UTC (rev 5592)
+++ trunk/ChangeLog     2014-05-21 21:58:42 UTC (rev 5593)
@@ -1,5 +1,16 @@
 2014-05-21  Gavin Smith  <address@hidden>
 
+       * info/infodoc.c (dump_map_to_message_buffer): Don't call
+       character_width or message_buffer_length_this_line.
+       * info/window.c (message_buffer_length_this_line, character_width)
+       (string_width): Removed.
+       (message_buffer): No longer static.
+
+       * info/window.c (calculate_line_starts): Merged into
+       recalculate_line_starts.
+
+2014-05-21  Gavin Smith  <address@hidden>
+
        * info/footnotes.c (info_get_or_remove_footnotes): If window
        too small to split to show footnotes window, don't crash.
 

Modified: trunk/info/infodoc.c
===================================================================
--- trunk/info/infodoc.c        2014-05-21 01:36:21 UTC (rev 5592)
+++ trunk/info/infodoc.c        2014-05-21 21:58:42 UTC (rev 5593)
@@ -190,6 +190,8 @@
 
 static char *where_is_internal (Keymap map, InfoCommand *cmd);
 
+struct text_buffer message_buffer;
+
 void
 dump_map_to_message_buffer (char *prefix, Keymap map)
 {
@@ -209,6 +211,7 @@
         }
       else if (map[i].function)
         {
+          long start_of_line = message_buffer.off;
           register int last;
           char *doc, *name;
 
@@ -235,21 +238,24 @@
             {
               printf_to_message_buffer ("%s .. ", pretty_keyseq (new_prefix));
               new_prefix[prefix_len] = last - 1;
-              printf_to_message_buffer ("%s\t", pretty_keyseq (new_prefix));
+              printf_to_message_buffer ("%s", pretty_keyseq (new_prefix));
               i = last - 1;
             }
           else
-            printf_to_message_buffer ("%s\t", pretty_keyseq (new_prefix));
+            printf_to_message_buffer ("%s", pretty_keyseq (new_prefix));
 
+          while (message_buffer.off - start_of_line < 8)
+            printf_to_message_buffer (" ");
+
 #if defined (NAMED_FUNCTIONS)
           /* Print the name of the function, and some padding before the
              documentation string is printed. */
           {
             int length_so_far;
-            int desired_doc_start = 40; /* Must be multiple of 8. */
+            int desired_doc_start = 40;
 
             printf_to_message_buffer ("(%s)", name);
-            length_so_far = message_buffer_length_this_line ();
+            length_so_far = message_buffer.off - start_of_line;
 
             if ((desired_doc_start + strlen (doc))
                 >= (unsigned int) the_screen->width)
@@ -258,8 +264,8 @@
               {
                 while (length_so_far < desired_doc_start)
                   {
-                    printf_to_message_buffer ("\t");
-                    length_so_far += character_width ('\t', length_so_far);
+                    printf_to_message_buffer (" ");
+                    length_so_far++;
                   }
               }
           }

Modified: trunk/info/session.c
===================================================================
--- trunk/info/session.c        2014-05-21 01:36:21 UTC (rev 5592)
+++ trunk/info/session.c        2014-05-21 21:58:42 UTC (rev 5593)
@@ -961,7 +961,7 @@
     {
       if (point_next_line (window))
         break; /* No next line. */
-    }   
+    }
 
   if (window->line_map.used == 0)
     return; /* This shouldn't happen. */

Modified: trunk/info/window.c
===================================================================
--- trunk/info/window.c 2014-05-21 01:36:21 UTC (rev 5592)
+++ trunk/info/window.c 2014-05-21 21:58:42 UTC (rev 5593)
@@ -591,7 +591,7 @@
       old_lines = window->line_count;
       old_pagetop = window->pagetop;
 
-      calculate_line_starts (window);
+      recalculate_line_starts (window);
 
       /* Make sure that point appears within this window. */
       window_adjust_pagetop (window);
@@ -730,69 +730,6 @@
     win->flags &= ~flag;
 }
 
-/* Return the number of characters it takes to display CHARACTER on the
-   screen at HPOS. */
-int
-character_width (int character, int hpos)
-{
-  int printable_limit = 127;
-  int width = 1;
-
-  if (ISO_Latin_p)
-    printable_limit = 255;
-
-  if (character > printable_limit)
-    width = 3;
-  else if (iscntrl (character))
-    {
-      switch (character)
-        {
-        case '\r':
-        case '\n':
-          width = the_screen->width - hpos;
-          break;
-        case '\t':
-          width = ((hpos + 8) & 0xf8) - hpos;
-          break;
-        default:
-          width = 2;
-        }
-    }
-  else if (character == DEL)
-    width = 2;
-
-  return width;
-}
-
-/* Return the number of characters it takes to display STRING on the screen
-   at HPOS. */
-int
-string_width (char *string, int hpos)
-{
-  register int i, width, this_char_width;
-
-  for (width = 0, i = 0; string[i]; i++)
-    {
-      /* Support ANSI escape sequences for -R.  */
-      if (raw_escapes_p
-         && string[i] == '\033'
-         && string[i+1] == '['
-         && isdigit (string[i+2])
-         && (string[i+3] == 'm'
-             || (isdigit (string[i+3]) && string[i+4] == 'm')))
-       {
-         while (string[i] != 'm')
-           i++;
-         this_char_width = 0;
-       }
-      else
-       this_char_width = character_width (string[i], hpos);
-      width += this_char_width;
-      hpos += this_char_width;
-    }
-  return width;
-}
-
 /* Quickly guess the approximate number of lines that NODE would
    take to display.  This really only counts carriage returns. */
 int
@@ -830,9 +767,12 @@
   return 0;
 }
 
+/* Given WINDOW, recalculate the line starts for the node it displays. */
 void
-calculate_line_starts (WINDOW *window)
+recalculate_line_starts (WINDOW *window)
 {
+  free (window->line_starts);
+  free (window->log_line_no);
   window->line_starts = NULL;
   window->log_line_no = NULL;
   window->line_count = 0;
@@ -846,15 +786,6 @@
   window_line_map_init (window);
 }
 
-/* Given WINDOW, recalculate the line starts for the node it displays. */
-void
-recalculate_line_starts (WINDOW *window)
-{
-  free (window->line_starts);
-  free (window->log_line_no);
-  calculate_line_starts (window);
-}
-
 /* Return the number of first physical line corresponding to the logical
    line LN.
 
@@ -1263,8 +1194,9 @@
   display_update_one_window (the_echo_area);
 }
 
+
 /* A place to build a message. */
-static struct text_buffer message_buffer;
+struct text_buffer message_buffer;
 
 /* Format MESSAGE_BUFFER with the results of printing FORMAT with ARG1 and
    ARG2. */
@@ -1336,25 +1268,6 @@
   va_end (ap);
 }
 
-/* Return the current horizontal position of the "cursor" on the most
-   recently output message buffer line. */
-int
-message_buffer_length_this_line (void)
-{
-  char *p;
-  
-  if (!message_buffer.base || !*message_buffer.base)
-    return 0;
-
-  p = strrchr (message_buffer.base, '\n');
-  if (p)
-    p++; /* Point at first character of line. */
-  else
-    p = message_buffer.base;
-  
-  return string_width (p, 0);
-}
-
 /* Pad STRING to COUNT characters by inserting blanks. */
 int
 pad_to (int count, char *string)

Modified: trunk/info/window.h
===================================================================
--- trunk/info/window.h 2014-05-21 01:36:21 UTC (rev 5592)
+++ trunk/info/window.h 2014-05-21 21:58:42 UTC (rev 5593)
@@ -242,20 +242,12 @@
 extern int window_physical_lines (NODE *node);
 
 /* Calculate a list of line starts for the node belonging to WINDOW.  The line
-   starts are pointers to the actual text within WINDOW->NODE. */
+   starts are offsets within WINDOW->node. */
 extern void calculate_line_starts (WINDOW *window);
 
 /* Given WINDOW, recalculate the line starts for the node it displays. */
 extern void recalculate_line_starts (WINDOW *window);
 
-/* Return the number of characters it takes to display CHARACTER on the
-   screen at HPOS. */
-extern int character_width (int character, int hpos);
-
-/* Return the number of characters it takes to display STRING on the
-   screen at HPOS. */
-extern int string_width (char *string, int hpos);
-
 /* Return the index of the line containing point. */
 extern int window_line_of_point (WINDOW *window);
 




reply via email to

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