Ilya Zakharevich on Tue, 6 Mar 2001 09:24:06 -0500


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

[PATCH] bold fg and online help


a) This improves on my old patch, which made bold colors when dark
   background was indicated with default(colors, 'darkbg').  This
   conflicted with some misconfigured xterms, so was replaced by
   non-bold colors.

   Since non-bold colors may be quite pale, this patch provides a
   third choice: in addition to lightbg/darkbg, boldfg.

b) Online help (Esc h/H or F1/Shift-F1) was not giving very intuitive
   results when on \ps 5 line or default(colors, 'darkbg') line.  This
   patch teaches readline to skip back to the meaningful element, and
   teaches gp how to ask for help on such elements.

   Before it only worked for "\ps" and "default/colors".  As side
   effects, ??\ps 5 and ??default(colors, 'darkbg') now work too.

c) hit_return() was too strict on which kind of input it accepted.
   Given that it might be called from Esc H handler, thus in a raw
   mode, accepting only Control-J for input does not look too
   intuitive.  ;-)

   [In addition, since Control-C and Control-Break are also catched by
    PARI, pressing Control-J was the *only* way to terminate
    hit_return on a PC.]

Enjoy,
Ilya

--- ./src/gp/gp.c-pre	Thu Feb  8 23:55:08 2001
+++ ./src/gp/gp.c	Sun Mar  4 21:42:52 2001
@@ -556,6 +556,8 @@ sd_colors(char *v, int flag)
       v = "1, 5, 3, 7, 6, 2, 3";	/* Assume recent ReadLine. */
     if (l <= 7 && strncmp(v, "lightbg", l) == 0)
       v = "1, 6, 3, 4, 5, 2, 3";	/* Assume recent ReadLine. */
+    if (l <= 6 && strncmp(v, "boldfg", l) == 0)	/* Good for darkbg consoles */
+      v = "[1,,1], [5,,1], [3,,1], [7,,1], [6,,1], [2,,1], [3,,1]";
     v = filtre(v,NULL, f_INIT|f_REG);
     for (c=c_ERR; c < c_LAST; c++)
       gp_colors[c] = gp_get_color(&v);
@@ -1374,6 +1376,7 @@ aide0(char *s, int flag)
 {
   long n, long_help = flag & h_LONG;
   entree *ep,*ep1;
+  char *s1;
 
   s = get_sep(s);
   if (isdigit((int)*s))
@@ -1385,6 +1388,12 @@ aide0(char *s, int flag)
     if (long_help) external_help(s,3); else commands(n);
     return;
   }
+  if (*s == '\\') {
+    s1 = s+1;
+    while (isalpha((int)*s1))
+      s1++;
+    *s1 = '\0';			/* Get meaningful entry on \ps 5 */
+  }
   if (flag & h_APROPOS) { external_help(s,-1); return; }
   if (long_help && (n = ok_external_help(s))) { external_help(s,n); return; }
   switch (*s)
@@ -1399,11 +1408,22 @@ aide0(char *s, int flag)
   {
     if (!strcmp(ep->name, "default"))
     {
-      char *t = s+7;
-      if (*t == '/' && is_default(t+1))
-      {
-        external_help(t+1, 2);
-        return;
+      char *t = s+7, *e;
+
+      while (*t == ' ' || *t == '\t')
+	t++;
+      if (*t == '/' || *t == '(') {
+	t++;
+	while (*t == ' ' || *t == '\t')
+	  t++;
+	e = t;
+	while (isalpha((int)*e))
+	  e++;
+	*e = '\0';			/* get_sep() made it a copy... */
+	if (is_default(t)) {
+	  external_help(t, 2);
+          return;
+	}
       }
     }
   }
--- ./src/gp/gp_rl.c-pre	Fri Nov  3 16:00:22 2000
+++ ./src/gp/gp_rl.c	Sun Mar  4 22:31:58 2001
@@ -553,6 +553,23 @@ rl_short_help(int count, int key)
   long flag = h_RL;
 
   while (off && is_keyword_char(rl_line_buffer[off-1])) off--;
+
+  /* Check for \c type situation.  Could check for leading whitespace too... */
+  if (off == 1 && rl_line_buffer[off-1] == '\\') off--;
+  if (off >= 8) {		/* Check for default(whatever) */
+    int t = off - 1;
+
+    while (t >= 7 && (rl_line_buffer[t] == ' ' || rl_line_buffer[t] == '\t'))
+      t--;
+    if (rl_line_buffer[t--] == '(') {
+      while (t >= 6 && (rl_line_buffer[t] == ' ' || rl_line_buffer[t] == '\t'))
+	t--;
+      if (t >= 6 && rl_line_buffer[t] == 't'
+	  && strncmp(rl_line_buffer + t - 6, "default", 7) == 0
+	  && (t == 6 || !is_keyword_char(rl_line_buffer[t-7])))
+	off = t - 6;		/* All this for that assignment */
+    }
+  }
   rl_point = 0; rl_end = 0; pari_outfile = rl_outstream;
   if (count < 0) flag |= h_LONG; /* long help */
   SAVE_PROMPT();
--- ./src/language/es.c-pre	Thu Feb  8 23:58:42 2001
+++ ./src/language/es.c	Sun Mar  4 21:40:24 2001
@@ -35,10 +35,11 @@ static void (*sp)();
 void
 hit_return()
 {
-  char tmp[16];
+  int c;
   if (under_texmacs || under_emacs) return;
-  pariputs("---- (type return to continue) ----");
-  do fgets(tmp,16,stdin); while (tmp[strlen(tmp)-1] != '\n');
+  pariputs("---- (type RETURN to continue) ----");
+  /* if called from a readline callback, may be in a funny TTY mode,  */
+  do c = fgetc(stdin); while (c >= 0 && c != '\n' && c != '\r' && c != ' ');
   pariputc('\n');
 }