Jens Schmidt on Fri, 21 Apr 2017 19:43:33 +0200 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: PARI/GP for Windows doesn't support umlauts and diacritical signs but it's possible |
Bill Allombert schrieb: > On Fri, Apr 21, 2017 at 11:39:00AM +0200, Jens Schmidt wrote: >> There is another related? effect with readline and colors in Windows >> (not only in Wine). >> >> To test this start clean PARI/GP without any preloaded defaults in a >> windows console: >> >> gp -f >> default(prompt, "gp >") >> default(colors, brightfg) >> default(readline, 0) >> >> The white prompt switches to yellow color and brightness on. Now type: >> >> default(readline, 4) >> >> The prompt switches back to white color and brightness off. This >> should'nt happen. > > This is a know issue. The default Windows terminal does not handle > ANSI color sequences, so we use a function win32_ansi_fputs() > in src/systems/mingw/mingw.c that parses the color code and sets the > terminal color using SetConsoleTextAttribute. > > Unfortunately the prompt is printed directly by readline and we did > not find a way to have readline use win32_ansi_fputs() or set the > color correctly. > > If you have a solution for this, please tell us. > > Cheers, > Bill. > There is another problem that prevents PARI/GP from initializing properly. libreadline uses setlocale from MinGW which is forwarded to msvcrt.dll in Windows. msvcrt's setlocale doesn't support real locale - it reports only "C" or NULL. C is 7-bit ASCII. I have appended a patch (as a suggestion) that solves both problems. 1. setlocale() is replaced by an own functioning version. 2. init_readline() gets an additional call to rl_initialize(). The patch makes PARI/GP 2.9.2 working on my testing systems (Windows 7 and Wine). LG - Jens
*** gp_rl.c 2017-01-14 13:26:42.000000000 +0100 --- gp_rl.c.new 2017-04-21 19:09:02.182999912 +0200 *************** gp_completion(char *text, int START, int *** 361,366 **** --- 361,383 ---- return pari_completion(&pari_rl, text, START, END); } + #ifdef __MINGW32__ + /* + * Replacement setlocale() to enable special chars in libreadline. + * + * Get environment info from LC_CTYPE, LC_ALL or LANG in this order. + */ + char *setlocale(int category, const char *locale) + { + static char loc[64]; + char *e = getenv("LC_CTYPE")?: getenv("LC_ALL")?: getenv("LANG"); + + strncpy(loc, (e && *e)? e: "C", sizeof(loc) - 1); + + return loc; + } + #endif + void init_readline(void) { *************** init_readline(void) *** 376,381 **** --- 393,403 ---- cb_pari_init_histfile = init_histfile; cb_pari_get_line_interactive = get_line_from_readline; + #ifdef __MINGW32__ + /* Initialize readline */ + rl_initialize(); + #endif + /* Allow conditional parsing of the ~/.inputrc file. */ rl_readline_name = "Pari-GP";