bug-bash
[Top][All Lists]
Advanced

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

Re: Cursor positioning in prompt is sometimes wrong, depending on locale


From: Chet Ramey
Subject: Re: Cursor positioning in prompt is sometimes wrong, depending on locale and PS1
Date: Fri, 12 Jun 2009 12:02:58 -0400
User-agent: Thunderbird 2.0.0.21 (Macintosh/20090302)

Jim Paris wrote:
> Configuration Information [Automatically generated, do not change]:
> Machine: x86_64
> OS: linux-gnu
> Compiler: gcc
> Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64' 
> -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-pc-linux-gnu' 
> -DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL 
> -DHAVE_CONFIG_H   -I.  -I../bash -I../bash/include -I../bash/lib   -g -O2 
> -Wall
> uname output: Linux pilot 2.6.26-2-amd64 #1 SMP Fri Mar 27 04:02:59 UTC 2009 
> x86_64 GNU/Linux
> Machine Type: x86_64-pc-linux-gnu
> 
> Bash Version: 4.0
> Patch Level: 24
> Release Status: release
> 
> Description:
> 
>       The cursor positioning in the prompt is sometimes wrong,
>       depending on the contents of PS1 and the locale.
> 
> Repeat-By:
> 
>       With this command, the cursor is positioned after the '5', as expected:
> 
> env -i LC_CTYPE=en_US PS1='\[\e[0m\]12345' INPUTRC=/dev/null bash --norc 
> --noprofile
> 
> 
>         With this command, the cursor is incorrectly positioned after the '1':
> 
> env -i LC_CTYPE=en_US.UTF-8 PS1='\[\e[0m\]12345' INPUTRC=/dev/null bash 
> --norc --noprofile

It's not really the locale per se, but the horizontal scroll mode that
needs attention.  (I didn't really think anybody used it anymore, but
you forced it when you started bash without TERM defined.)  Try the
attached patch.

Chet
-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer

Chet Ramey, ITS, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/
*** ../bash-4.0-patched/lib/readline/display.c  2009-05-22 12:32:25.000000000 
-0400
--- lib/readline/display.c      2009-05-29 23:32:20.000000000 -0400
***************
*** 1190,1196 ****
        line[t - 1] = '>';
  
!       if (!rl_display_fixed || forced_display || lmargin != last_lmargin)
        {
          forced_display = 0;
          update_line (&visible_line[last_lmargin],
                       &invisible_line[lmargin],
--- 1192,1200 ----
        line[t - 1] = '>';
  
!       if (rl_display_fixed == 0 || forced_display || lmargin != last_lmargin)
        {
          forced_display = 0;
+         o_cpos = _rl_last_c_pos;
+         cpos_adjusted = 0;
          update_line (&visible_line[last_lmargin],
                       &invisible_line[lmargin],
***************
*** 1200,1203 ****
--- 1204,1214 ----
                       0);
  
+         if ((MB_CUR_MAX > 1 && rl_byte_oriented == 0) &&
+             cpos_adjusted == 0 &&
+             _rl_last_c_pos != o_cpos &&
+             _rl_last_c_pos > wrap_offset &&
+             o_cpos < prompt_last_invisible)
+               _rl_last_c_pos -= prompt_invis_chars_first_line;        /* XXX 
- was wrap_offset */
+ 
          /* If the visible new line is shorter than the old, but the number
             of invisible characters is greater, and we are at the end of

reply via email to

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