changeset 15627:c5c4d478c78d

(IT_menu_display): Display control characters as ^X. (XMenuAddPane, XMenuAddSelection): Adjust menu width for control characters (displayed as ^X).
author Karl Heuer <kwzh@gnu.org>
date Sun, 07 Jul 1996 22:40:53 +0000
parents a973e9f3f6d1
children f74c79dcaf8d
files src/msdos.c
diffstat 1 files changed, 31 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/msdos.c	Sun Jul 07 22:37:17 1996 +0000
+++ b/src/msdos.c	Sun Jul 07 22:40:53 1996 +0000
@@ -1854,7 +1854,17 @@
       p = text;
       *p++ = FAST_MAKE_GLYPH (' ', face);
       for (j = 0, q = menu->text[i]; *q; j++)
-	*p++ = FAST_MAKE_GLYPH (*q++, face);
+	{
+	  if (*q > 26)
+	    *p++ = FAST_MAKE_GLYPH (*q++, face);
+	  else	/* make '^x' */
+	    {
+	      *p++ = FAST_MAKE_GLYPH ('^', face);
+	      j++;
+	      *p++ = FAST_MAKE_GLYPH (*q++ + 64, face);
+	    }
+	}
+	    
       for (; j < width; j++)
 	*p++ = FAST_MAKE_GLYPH (' ', face);
       *p++ = FAST_MAKE_GLYPH (menu->submenu[i] ? 16 : ' ', face);
@@ -1891,6 +1901,7 @@
 XMenuAddPane (Display *foo, XMenu *menu, char *txt, int enable)
 {
   int len;
+  char *p;
 
   if (!enable)
     abort ();
@@ -1900,8 +1911,16 @@
   menu->text[menu->count] = txt;
   menu->panenumber[menu->count] = ++menu->panecount;
   menu->count++;
-  if ((len = strlen (txt)) > menu->width)
+
+  /* Adjust length for possible control characters (which will
+     be written as ^x).  */
+  for (len = strlen (txt), p = txt; *p; p++)
+    if (*p < 27)
+      len++;
+
+  if (len > menu->width)
     menu->width = len;
+
   return menu->panecount;
 }
 
@@ -1912,6 +1931,7 @@
 		   int foo, char *txt, int enable)
 {
   int len;
+  char *p;
 
   if (pane)
     if (!(menu = IT_menu_search_pane (menu, pane)))
@@ -1921,8 +1941,16 @@
   menu->text[menu->count] = txt;
   menu->panenumber[menu->count] = enable;
   menu->count++;
-  if ((len = strlen (txt)) > menu->width)
+
+  /* Adjust length for possible control characters (which will
+     be written as ^x).  */
+  for (len = strlen (txt), p = txt; *p; p++)
+    if (*p < 27)
+      len++;
+
+  if (len > menu->width)
     menu->width = len;
+
   return XM_SUCCESS;
 }