Mirror of the Vim source from https://github.com/vim/vim
Revisão | 843bfffb04c739ec456e5c5f612c6d025f2a6188 (tree) |
---|---|
Hora | 2007-08-09 05:49:37 |
Autor | vimboss |
Commiter | vimboss |
updated for version 7.1-058
@@ -75,7 +75,6 @@ | ||
75 | 75 | |
76 | 76 | row = curwin->w_cline_row + W_WINROW(curwin); |
77 | 77 | height = curwin->w_cline_height; |
78 | - col = curwin->w_wcol + W_WINCOL(curwin) - curwin->w_leftcol; | |
79 | 78 | |
80 | 79 | if (firstwin->w_p_pvw) |
81 | 80 | top_clear = firstwin->w_height; |
@@ -167,6 +166,15 @@ | ||
167 | 166 | pum_base_width = max_width; |
168 | 167 | pum_kind_width = kind_width; |
169 | 168 | |
169 | + /* Calculate column */ | |
170 | +#ifdef FEAT_RIGHTLEFT | |
171 | + if (curwin->w_p_rl) | |
172 | + col = W_WINCOL(curwin) + W_WIDTH(curwin) - curwin->w_wcol - | |
173 | + curwin->w_leftcol - 1; | |
174 | + else | |
175 | +#endif | |
176 | + col = W_WINCOL(curwin) + curwin->w_wcol - curwin->w_leftcol; | |
177 | + | |
170 | 178 | /* if there are more items than room we need a scrollbar */ |
171 | 179 | if (pum_height < size) |
172 | 180 | { |
@@ -179,11 +187,23 @@ | ||
179 | 187 | if (def_width < max_width) |
180 | 188 | def_width = max_width; |
181 | 189 | |
182 | - if (col < Columns - PUM_DEF_WIDTH || col < Columns - max_width) | |
190 | + if (((col < Columns - PUM_DEF_WIDTH || col < Columns - max_width) | |
191 | +#ifdef FEAT_RIGHTLEFT | |
192 | + && !curwin->w_p_rl) | |
193 | + || (curwin->w_p_rl && (col > PUM_DEF_WIDTH || col > max_width) | |
194 | +#endif | |
195 | + )) | |
183 | 196 | { |
184 | 197 | /* align pum column with "col" */ |
185 | 198 | pum_col = col; |
186 | - pum_width = Columns - pum_col - pum_scrollbar; | |
199 | + | |
200 | +#ifdef FEAT_RIGHTLEFT | |
201 | + if (curwin->w_p_rl) | |
202 | + pum_width = pum_col - pum_scrollbar + 1; | |
203 | + else | |
204 | +#endif | |
205 | + pum_width = Columns - pum_col - pum_scrollbar; | |
206 | + | |
187 | 207 | if (pum_width > max_width + kind_width + extra_width + 1 |
188 | 208 | && pum_width > PUM_DEF_WIDTH) |
189 | 209 | { |
@@ -195,14 +215,24 @@ | ||
195 | 215 | else if (Columns < def_width) |
196 | 216 | { |
197 | 217 | /* not enough room, will use what we have */ |
198 | - pum_col = 0; | |
218 | +#ifdef FEAT_RIGHTLEFT | |
219 | + if (curwin->w_p_rl) | |
220 | + pum_col = Columns - 1; | |
221 | + else | |
222 | +#endif | |
223 | + pum_col = 0; | |
199 | 224 | pum_width = Columns - 1; |
200 | 225 | } |
201 | 226 | else |
202 | 227 | { |
203 | 228 | if (max_width > PUM_DEF_WIDTH) |
204 | 229 | max_width = PUM_DEF_WIDTH; /* truncate */ |
205 | - pum_col = Columns - max_width; | |
230 | +#ifdef FEAT_RIGHTLEFT | |
231 | + if (curwin->w_p_rl) | |
232 | + pum_col = max_width - 1; | |
233 | + else | |
234 | +#endif | |
235 | + pum_col = Columns - max_width; | |
206 | 236 | pum_width = max_width - pum_scrollbar; |
207 | 237 | } |
208 | 238 |
@@ -255,8 +285,16 @@ | ||
255 | 285 | attr = (idx == pum_selected) ? attr_select : attr_norm; |
256 | 286 | |
257 | 287 | /* prepend a space if there is room */ |
258 | - if (pum_col > 0) | |
259 | - screen_putchar(' ', row, pum_col - 1, attr); | |
288 | +#ifdef FEAT_RIGHTLEFT | |
289 | + if (curwin->w_p_rl) | |
290 | + { | |
291 | + if (pum_col < W_WINCOL(curwin) + W_WIDTH(curwin) - 1) | |
292 | + screen_putchar(' ', row, pum_col + 1, attr); | |
293 | + } | |
294 | + else | |
295 | +#endif | |
296 | + if (pum_col > 0) | |
297 | + screen_putchar(' ', row, pum_col - 1, attr); | |
260 | 298 | |
261 | 299 | /* Display each entry, use two spaces for a Tab. |
262 | 300 | * Do this 3 times: For the main text, kind and extra info */ |
@@ -282,26 +320,67 @@ | ||
282 | 320 | { |
283 | 321 | /* Display the text that fits or comes before a Tab. |
284 | 322 | * First convert it to printable characters. */ |
285 | - char_u *st; | |
286 | - int saved = *p; | |
323 | + char_u *st; | |
324 | + int saved = *p; | |
287 | 325 | |
288 | 326 | *p = NUL; |
289 | 327 | st = transstr(s); |
290 | 328 | *p = saved; |
291 | - if (st != NULL) | |
329 | +#ifdef FEAT_RIGHTLEFT | |
330 | + if (curwin->w_p_rl) | |
292 | 331 | { |
293 | - screen_puts_len(st, (int)STRLEN(st), row, col, | |
332 | + if (st != NULL) | |
333 | + { | |
334 | + char_u *rt = reverse_text(st); | |
335 | + char_u *rt_saved = rt; | |
336 | + int len, j; | |
337 | + | |
338 | + if (rt != NULL) | |
339 | + { | |
340 | + len = STRLEN(rt); | |
341 | + if (len > pum_width) | |
342 | + { | |
343 | + for (j = pum_width; j < len; ++j) | |
344 | + mb_ptr_adv(rt); | |
345 | + len = pum_width; | |
346 | + } | |
347 | + screen_puts_len(rt, len, row, | |
348 | + col - len + 1, attr); | |
349 | + vim_free(rt_saved); | |
350 | + } | |
351 | + vim_free(st); | |
352 | + } | |
353 | + col -= width; | |
354 | + } | |
355 | + else | |
356 | +#endif | |
357 | + { | |
358 | + if (st != NULL) | |
359 | + { | |
360 | + screen_puts_len(st, (int)STRLEN(st), row, col, | |
294 | 361 | attr); |
295 | - vim_free(st); | |
362 | + vim_free(st); | |
363 | + } | |
364 | + col += width; | |
296 | 365 | } |
297 | - col += width; | |
298 | 366 | |
299 | 367 | if (*p != TAB) |
300 | 368 | break; |
301 | 369 | |
302 | 370 | /* Display two spaces for a Tab. */ |
303 | - screen_puts_len((char_u *)" ", 2, row, col, attr); | |
304 | - col += 2; | |
371 | +#ifdef FEAT_RIGHTLEFT | |
372 | + if (curwin->w_p_rl) | |
373 | + { | |
374 | + screen_puts_len((char_u *)" ", 2, row, col - 1, | |
375 | + attr); | |
376 | + col -= 2; | |
377 | + } | |
378 | + else | |
379 | +#endif | |
380 | + { | |
381 | + screen_puts_len((char_u *)" ", 2, row, col, attr); | |
382 | + col += 2; | |
383 | + } | |
305 | 384 | totwidth += 2; |
306 | 385 | s = NULL; /* start text at next char */ |
307 | 386 | width = 0; |
@@ -322,17 +401,44 @@ | ||
322 | 401 | && pum_array[idx].pum_extra == NULL) |
323 | 402 | || pum_base_width + n >= pum_width) |
324 | 403 | break; |
325 | - screen_fill(row, row + 1, col, pum_col + pum_base_width + n, | |
404 | +#ifdef FEAT_RIGHTLEFT | |
405 | + if (curwin->w_p_rl) | |
406 | + { | |
407 | + screen_fill(row, row + 1, pum_col - pum_base_width - n + 1, | |
408 | + col + 1, ' ', ' ', attr); | |
409 | + col = pum_col - pum_base_width - n + 1; | |
410 | + } | |
411 | + else | |
412 | +#endif | |
413 | + { | |
414 | + screen_fill(row, row + 1, col, pum_col + pum_base_width + n, | |
326 | 415 | ' ', ' ', attr); |
327 | - col = pum_col + pum_base_width + n; | |
416 | + col = pum_col + pum_base_width + n; | |
417 | + } | |
328 | 418 | totwidth = pum_base_width + n; |
329 | 419 | } |
330 | 420 | |
331 | - screen_fill(row, row + 1, col, pum_col + pum_width, ' ', ' ', attr); | |
421 | +#ifdef FEAT_RIGHTLEFT | |
422 | + if (curwin->w_p_rl) | |
423 | + screen_fill(row, row + 1, pum_col - pum_width + 1, col + 1, ' ', | |
424 | + ' ', attr); | |
425 | + else | |
426 | +#endif | |
427 | + screen_fill(row, row + 1, col, pum_col + pum_width, ' ', ' ', | |
428 | + attr); | |
332 | 429 | if (pum_scrollbar > 0) |
333 | - screen_putchar(' ', row, pum_col + pum_width, | |
334 | - i >= thumb_pos && i < thumb_pos + thumb_heigth | |
430 | + { | |
431 | +#ifdef FEAT_RIGHTLEFT | |
432 | + if (curwin->w_p_rl) | |
433 | + screen_putchar(' ', row, pum_col - pum_width, | |
434 | + i >= thumb_pos && i < thumb_pos + thumb_heigth | |
335 | 435 | ? attr_thumb : attr_scroll); |
436 | + else | |
437 | +#endif | |
438 | + screen_putchar(' ', row, pum_col + pum_width, | |
439 | + i >= thumb_pos && i < thumb_pos + thumb_heigth | |
440 | + ? attr_thumb : attr_scroll); | |
441 | + } | |
336 | 442 | |
337 | 443 | ++row; |
338 | 444 | } |
@@ -1,6 +1,7 @@ | ||
1 | 1 | /* search.c */ |
2 | 2 | int search_regcomp __ARGS((char_u *pat, int pat_save, int pat_use, int options, regmmatch_T *regmatch)); |
3 | 3 | char_u *get_search_pat __ARGS((void)); |
4 | +char_u *reverse_text __ARGS((char_u *s)); | |
4 | 5 | void save_search_patterns __ARGS((void)); |
5 | 6 | void restore_search_patterns __ARGS((void)); |
6 | 7 | void free_search_patterns __ARGS((void)); |
@@ -101,7 +101,6 @@ | ||
101 | 101 | static char_u *mr_pattern = NULL; /* pattern used by search_regcomp() */ |
102 | 102 | #ifdef FEAT_RIGHTLEFT |
103 | 103 | static int mr_pattern_alloced = FALSE; /* mr_pattern was allocated */ |
104 | -static char_u *reverse_text __ARGS((char_u *s)); | |
105 | 104 | #endif |
106 | 105 | |
107 | 106 | #ifdef FEAT_FIND_ID |
@@ -228,12 +227,12 @@ | ||
228 | 227 | return mr_pattern; |
229 | 228 | } |
230 | 229 | |
231 | -#ifdef FEAT_RIGHTLEFT | |
230 | +#if defined(FEAT_RIGHTLEFT) || defined(PROTO) | |
232 | 231 | /* |
233 | 232 | * Reverse text into allocated memory. |
234 | 233 | * Returns the allocated string, NULL when out of memory. |
235 | 234 | */ |
236 | - static char_u * | |
235 | + char_u * | |
237 | 236 | reverse_text(s) |
238 | 237 | char_u *s; |
239 | 238 | { |
@@ -1898,7 +1897,7 @@ | ||
1898 | 1897 | } |
1899 | 1898 | |
1900 | 1899 | #ifdef FEAT_RIGHTLEFT |
1901 | - /* This is just guessing: when 'rightleft' is set, search for a maching | |
1900 | + /* This is just guessing: when 'rightleft' is set, search for a matching | |
1902 | 1901 | * paren/brace in the other direction. */ |
1903 | 1902 | if (curwin->w_p_rl && vim_strchr((char_u *)"()[]{}<>", initc) != NULL) |
1904 | 1903 | backwards = !backwards; |
@@ -667,6 +667,8 @@ | ||
667 | 667 | static int included_patches[] = |
668 | 668 | { /* Add new patch number below this line */ |
669 | 669 | /**/ |
670 | + 58, | |
671 | +/**/ | |
670 | 672 | 57, |
671 | 673 | /**/ |
672 | 674 | 56, |