commit bash-20051123 snapshot
[platform/upstream/bash.git] / display.c.diff
1 *** ../bash-3.0/lib/readline/display.c  Thu May 27 22:57:51 2004
2 --- lib/readline/display.c      Mon Aug 30 11:55:02 2004
3 ***************
4 *** 202,206 ****
5   {
6     char *r, *ret, *p;
7 !   int l, rl, last, ignoring, ninvis, invfl, ind, pind, physchars;
8   
9     /* Short-circuit if we can. */
10 --- 202,206 ----
11   {
12     char *r, *ret, *p;
13 !   int l, rl, last, ignoring, ninvis, invfl, invflset, ind, pind, physchars;
14   
15     /* Short-circuit if we can. */
16 ***************
17 *** 223,226 ****
18 --- 223,227 ----
19   
20     invfl = 0;  /* invisible chars in first line of prompt */
21 +   invflset = 0;       /* we only want to set invfl once */
22   
23     for (rl = ignoring = last = ninvis = physchars = 0, p = pmt; p && *p; p++)
24 ***************
25 *** 250,254 ****
26                 *r++ = *p++;
27               if (!ignoring)
28 !               rl += ind - pind;
29               else
30                 ninvis += ind - pind;
31 --- 251,258 ----
32                 *r++ = *p++;
33               if (!ignoring)
34 !               {
35 !                 rl += ind - pind;
36 !                 physchars += _rl_col_width (pmt, pind, ind);
37 !               }
38               else
39                 ninvis += ind - pind;
40 ***************
41 *** 260,273 ****
42               *r++ = *p;
43               if (!ignoring)
44 !               rl++;                   /* visible length byte counter */
45               else
46                 ninvis++;               /* invisible chars byte counter */
47             }
48   
49 !         if (rl >= _rl_screenwidth)
50 !           invfl = ninvis;
51
52 !         if (ignoring == 0)
53 !           physchars++;
54         }
55       }
56 --- 264,280 ----
57               *r++ = *p;
58               if (!ignoring)
59 !               {
60 !                 rl++;                 /* visible length byte counter */
61 !                 physchars++;
62 !               }
63               else
64                 ninvis++;               /* invisible chars byte counter */
65             }
66   
67 !         if (invflset == 0 && rl >= _rl_screenwidth)
68 !           {
69 !             invfl = ninvis;
70 !             invflset = 1;
71 !           }
72         }
73       }
74 ***************
75 *** 352,356 ****
76                                        &prompt_last_invisible,
77                                        (int *)NULL,
78 !                                      (int *)NULL);
79         c = *t; *t = '\0';
80         /* The portion of the prompt string up to and including the
81 --- 359,363 ----
82                                        &prompt_last_invisible,
83                                        (int *)NULL,
84 !                                      &prompt_physical_chars);
85         c = *t; *t = '\0';
86         /* The portion of the prompt string up to and including the
87 ***************
88 *** 359,363 ****
89                                                    (int *)NULL,
90                                                    &prompt_invis_chars_first_line,
91 !                                                  &prompt_physical_chars);
92         *t = c;
93         return (prompt_prefix_length);
94 --- 366,370 ----
95                                                    (int *)NULL,
96                                                    &prompt_invis_chars_first_line,
97 !                                                  (int *)NULL);
98         *t = c;
99         return (prompt_prefix_length);
100 ***************
101 *** 418,422 ****
102     register char *line;
103     int c_pos, inv_botlin, lb_botlin, lb_linenum;
104 !   int newlines, lpos, temp, modmark;
105     char *prompt_this_line;
106   #if defined (HANDLE_MULTIBYTE)
107 --- 425,429 ----
108     register char *line;
109     int c_pos, inv_botlin, lb_botlin, lb_linenum;
110 !   int newlines, lpos, temp, modmark, n0, num;
111     char *prompt_this_line;
112   #if defined (HANDLE_MULTIBYTE)
113 ***************
114 *** 574,577 ****
115 --- 581,585 ----
116   #if defined (HANDLE_MULTIBYTE)
117     memset (_rl_wrapped_line, 0, vis_lbsize);
118 +   num = 0;
119   #endif
120   
121 ***************
122 *** 592,596 ****
123 --- 600,619 ----
124            prompts that exceed two physical lines?
125            Additional logic fix from Edward Catmur <ed@catmur.co.uk> */
126 + #if defined (HANDLE_MULTIBYTE)
127 +       n0 = num;
128 +       temp = local_prompt ? strlen (local_prompt) : 0;
129 +       while (num < temp)
130 +       {
131 +         if (_rl_col_width  (local_prompt, n0, num) > _rl_screenwidth)
132 +           {
133 +             num = _rl_find_prev_mbchar (local_prompt, num, MB_FIND_ANY);
134 +             break;
135 +           }
136 +         num++;
137 +       }
138 +       temp = num +
139 + #else
140         temp = ((newlines + 1) * _rl_screenwidth) +
141 + #endif /* !HANDLE_MULTIBYTE */
142                ((local_prompt_prefix == 0) ? ((newlines == 0) ? prompt_invis_chars_first_line
143                                                             : ((newlines == 1) ? wrap_offset : 0))
144 ***************
145 *** 598,602 ****
146 --- 621,629 ----
147                
148         inv_lbreaks[++newlines] = temp;
149 + #if defined (HANDLE_MULTIBYTE)
150 +       lpos -= _rl_col_width (local_prompt, n0, num);
151 + #else
152         lpos -= _rl_screenwidth;
153 + #endif
154       }
155