5 Patch-ID: readline52-013
7 Bug-Reported-by: slinkp <stuff@slinkp.com>
8 Bug-Reference-ID: <da52a26a-9f38-4861-a918-14d3482b539d@c65g2000hsa.googlegroups.com>
9 Bug-Reference-URL: http://lists.gnu.org/archive/html/bug-bash/2008-05/msg00085.html
13 The presence of invisible characters in a prompt longer than the screenwidth
14 with invisible characters on the first and last prompt lines caused readline
15 to place the cursor in the wrong physical location.
19 *** ../readline-5.2-patched/display.c 2007-12-14 21:12:40.000000000 -0500
20 --- display.c 2008-10-23 09:39:46.000000000 -0400
24 OFFSET (which has already been calculated above). */
26 + #define INVIS_FIRST() (prompt_physical_chars > _rl_screenwidth ? prompt_invis_chars_first_line : wrap_offset)
27 + #define WRAP_OFFSET(line, offset) ((line == 0) \
28 + ? (offset ? INVIS_FIRST() : 0) \
29 + : ((line == prompt_last_screen_line) ? wrap_offset-prompt_invis_chars_first_line : 0))
30 #define W_OFFSET(line, offset) ((line) == 0 ? offset : 0)
31 #define VIS_LLEN(l) ((l) > _rl_vis_botlin ? 0 : (vis_lbreaks[l+1] - vis_lbreaks[l]))
34 _rl_last_c_pos > wrap_offset &&
35 o_cpos < prompt_last_invisible)
36 ! _rl_last_c_pos -= wrap_offset;
38 /* If this is the line with the prompt, we might need to
40 _rl_last_c_pos > wrap_offset &&
41 o_cpos < prompt_last_invisible)
42 ! _rl_last_c_pos -= prompt_invis_chars_first_line; /* XXX - was wrap_offset */
43 ! else if (linenum == prompt_last_screen_line && prompt_physical_chars > _rl_screenwidth &&
44 ! (MB_CUR_MAX > 1 && rl_byte_oriented == 0) &&
45 ! cpos_adjusted == 0 &&
46 ! _rl_last_c_pos != o_cpos &&
47 ! _rl_last_c_pos > (prompt_last_invisible - _rl_screenwidth - prompt_invis_chars_first_line))
48 ! _rl_last_c_pos -= (wrap_offset-prompt_invis_chars_first_line);
50 /* If this is the line with the prompt, we might need to
54 register char *ofd, *ols, *oe, *nfd, *nls, *ne;
55 ! int temp, lendiff, wsatend, od, nd, o_cpos;
56 int current_invis_chars;
57 int col_lendiff, col_temp;
60 register char *ofd, *ols, *oe, *nfd, *nls, *ne;
61 ! int temp, lendiff, wsatend, od, nd, twidth, o_cpos;
62 int current_invis_chars;
63 int col_lendiff, col_temp;
66 temp = _rl_last_c_pos;
68 ! temp = _rl_last_c_pos - W_OFFSET(_rl_last_v_pos, visible_wrap_offset);
69 if (temp == _rl_screenwidth && _rl_term_autowrap && !_rl_horizontal_scroll_mode
70 && _rl_last_v_pos == current_line - 1)
72 temp = _rl_last_c_pos;
74 ! temp = _rl_last_c_pos - WRAP_OFFSET (_rl_last_v_pos, visible_wrap_offset);
75 if (temp == _rl_screenwidth && _rl_term_autowrap && !_rl_horizontal_scroll_mode
76 && _rl_last_v_pos == current_line - 1)
80 _rl_output_some_chars (nfd + lendiff, temp - lendiff);
82 /* XXX -- this bears closer inspection. Fixes a redisplay bug
83 reported against bash-3.0-alpha by Andreas Schwab involving
84 multibyte characters and prompt strings with invisible
85 characters, but was previously disabled. */
86 ! _rl_last_c_pos += _rl_col_width (nfd+lendiff, 0, temp-col_lendiff);
88 ! _rl_last_c_pos += _rl_col_width (nfd+lendiff, 0, temp-lendiff);
94 _rl_output_some_chars (nfd + lendiff, temp - lendiff);
95 /* XXX -- this bears closer inspection. Fixes a redisplay bug
96 reported against bash-3.0-alpha by Andreas Schwab involving
97 multibyte characters and prompt strings with invisible
98 characters, but was previously disabled. */
99 ! if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
100 ! twidth = _rl_col_width (nfd+lendiff, 0, temp-col_lendiff);
102 ! twidth = temp - lendiff;
103 ! _rl_last_c_pos += twidth;
108 int cpos, dpos; /* current and desired cursor positions */
110 ! woff = W_OFFSET (_rl_last_v_pos, wrap_offset);
111 cpos = _rl_last_c_pos;
112 #if defined (HANDLE_MULTIBYTE)
114 int cpos, dpos; /* current and desired cursor positions */
116 ! woff = WRAP_OFFSET (_rl_last_v_pos, wrap_offset);
117 cpos = _rl_last_c_pos;
118 #if defined (HANDLE_MULTIBYTE)
121 prompt string, since they're both buffer indices and DPOS is a
122 desired display position. */
123 ! if (new > prompt_last_invisible) /* XXX - don't use woff here */
127 prompt string, since they're both buffer indices and DPOS is a
128 desired display position. */
129 ! if ((new > prompt_last_invisible) || /* XXX - don't use woff here */
130 ! (prompt_physical_chars > _rl_screenwidth &&
131 ! _rl_last_v_pos == prompt_last_screen_line &&
132 ! wrap_offset != woff &&
133 ! new > (prompt_last_invisible-_rl_screenwidth-wrap_offset)))