Ilya Zakharevich on Thu, 02 May 2019 10:47:43 +0200


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

Re: Please test pari-2.11.2 prerelease 1


On Wed, May 01, 2019 at 06:01:21PM -0700, Ilya Zakharevich wrote:
> > OK, I have rebuild with readline 8:
> > <https://pari.math.u-bordeaux.fr/pub/pari/windows/snapshots/gp64-readline8-2-11-2-pre1.exe>
> > Is it better ?

BTW, I attach a patch which makes it possible to have a colored prompt
and a colored input line without a terminal supporting ANSI sequences.
Unfortunately, this is not complete: e.g., pressing the ArrowUp key
rewrites the prompt in the color of the input line.

But anyway, this allows to make the input to stand out from the
output???

Ilya
--- pari-2.11.1/src/headers/paripriv.h-pre	2018-07-25 11:00:21.000000000 -0700
+++ pari-2.11.1/src/headers/paripriv.h	2019-05-02 01:26:12.818629100 -0700
@@ -414,6 +414,9 @@ int get_line_from_file(const char *promp
 void pari_skip_space(char **s);
 void pari_skip_alpha(char **s);
 char *pari_translate_string(const char *src, char *s, char *entry);
+#ifdef _WIN32
+int pari_rl_pre_input_hook(void);
+#endif /* defined(_WIN32) */
 
 gp_data *default_gp_data(void);
 
--- pari-2.11.1/src/gp/gp_rl.c-pre	2019-05-02 01:23:07.112007300 -0700
+++ pari-2.11.1/src/gp/gp_rl.c	2019-05-02 01:27:55.394496100 -0700
@@ -386,6 +386,11 @@ init_readline(void)
   /* custom completer */
   rl_attempted_completion_function = (rl_completion_func_t*) gp_completion;
 
+#ifdef _WIN32
+  /* Poor man color-switcher for the input */
+  rl_pre_input_hook = pari_rl_pre_input_hook;
+#endif /* defined(_WIN32) */
+
   /* we always want the whole list of completions under emacs */
   if (GP_DATA->flags & gpd_EMACS) rl_completion_query_items = 0x8fff;
 
--- pari-2.11.1/src/language/gplib.c-pre	2019-05-02 01:12:29.823556500 -0700
+++ pari-2.11.1/src/language/gplib.c	2019-05-02 01:28:25.723230800 -0700
@@ -1174,6 +1174,15 @@ get_line_from_file(const char *prompt, f
   return 1;
 }
 
+#ifdef _WIN32
+int 
+pari_rl_pre_input_hook(void)
+{
+  term_color(c_INPUT); pari_flush();
+  return 0;
+}
+#endif
+
 /* return 0 if no line could be read (EOF). If PROMPT = NULL, expand and
  * color default prompt; otherwise, use PROMPT as-is. */
 int
@@ -1192,6 +1201,10 @@ gp_read_line(filtre_t *F, const char *PR
       p = F->in_comment? GP_DATA->prompt_comment: GP_DATA->prompt;
       p = gp_format_prompt(p);
     }
+#ifdef _WIN32
+    if (GP_DATA->use_readline)	/* Duplicates color change, but this is the best we can do on Win 7 */
+      term_color(c_PROMPT), pari_flush();
+#endif
   }
   else
     p = DFT_PROMPT;