To: vim-dev@vim.org
Subject: patch 7.1.058
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
------------
Patch 7.1.058
Problem: When 'rightleft' is set the completion menu is positioned wrong.
(Baha-Eddine MOKADEM)
Solution: Fix the completion menu. (Martin Toft)
Files: src/popupmnu.c, src/proto/search.pro, src/search.c
*** ../vim-7.1.057/src/popupmnu.c Thu Jun 28 21:23:52 2007
--- src/popupmnu.c Wed Aug 1 15:43:06 2007
***************
*** 75,81 ****
row = curwin->w_cline_row + W_WINROW(curwin);
height = curwin->w_cline_height;
- col = curwin->w_wcol + W_WINCOL(curwin) - curwin->w_leftcol;
if (firstwin->w_p_pvw)
top_clear = firstwin->w_height;
--- 75,80 ----
***************
*** 167,172 ****
--- 166,180 ----
pum_base_width = max_width;
pum_kind_width = kind_width;
+ /* Calculate column */
+ #ifdef FEAT_RIGHTLEFT
+ if (curwin->w_p_rl)
+ col = W_WINCOL(curwin) + W_WIDTH(curwin) - curwin->w_wcol -
+ curwin->w_leftcol - 1;
+ else
+ #endif
+ col = W_WINCOL(curwin) + curwin->w_wcol - curwin->w_leftcol;
+
/* if there are more items than room we need a scrollbar */
if (pum_height < size)
{
***************
*** 179,189 ****
if (def_width < max_width)
def_width = max_width;
! if (col < Columns - PUM_DEF_WIDTH || col < Columns - max_width)
{
/* align pum column with "col" */
pum_col = col;
! pum_width = Columns - pum_col - pum_scrollbar;
if (pum_width > max_width + kind_width + extra_width + 1
&& pum_width > PUM_DEF_WIDTH)
{
--- 187,209 ----
if (def_width < max_width)
def_width = max_width;
! if (((col < Columns - PUM_DEF_WIDTH || col < Columns - max_width)
! #ifdef FEAT_RIGHTLEFT
! && !curwin->w_p_rl)
! || (curwin->w_p_rl && (col > PUM_DEF_WIDTH || col > max_width)
! #endif
! ))
{
/* align pum column with "col" */
pum_col = col;
!
! #ifdef FEAT_RIGHTLEFT
! if (curwin->w_p_rl)
! pum_width = pum_col - pum_scrollbar + 1;
! else
! #endif
! pum_width = Columns - pum_col - pum_scrollbar;
!
if (pum_width > max_width + kind_width + extra_width + 1
&& pum_width > PUM_DEF_WIDTH)
{
***************
*** 195,208 ****
else if (Columns < def_width)
{
/* not enough room, will use what we have */
! pum_col = 0;
pum_width = Columns - 1;
}
else
{
if (max_width > PUM_DEF_WIDTH)
max_width = PUM_DEF_WIDTH; /* truncate */
! pum_col = Columns - max_width;
pum_width = max_width - pum_scrollbar;
}
--- 215,238 ----
else if (Columns < def_width)
{
/* not enough room, will use what we have */
! #ifdef FEAT_RIGHTLEFT
! if (curwin->w_p_rl)
! pum_col = Columns - 1;
! else
! #endif
! pum_col = 0;
pum_width = Columns - 1;
}
else
{
if (max_width > PUM_DEF_WIDTH)
max_width = PUM_DEF_WIDTH; /* truncate */
! #ifdef FEAT_RIGHTLEFT
! if (curwin->w_p_rl)
! pum_col = max_width - 1;
! else
! #endif
! pum_col = Columns - max_width;
pum_width = max_width - pum_scrollbar;
}
***************
*** 255,262 ****
attr = (idx == pum_selected) ? attr_select : attr_norm;
/* prepend a space if there is room */
! if (pum_col > 0)
! screen_putchar(' ', row, pum_col - 1, attr);
/* Display each entry, use two spaces for a Tab.
* Do this 3 times: For the main text, kind and extra info */
--- 285,300 ----
attr = (idx == pum_selected) ? attr_select : attr_norm;
/* prepend a space if there is room */
! #ifdef FEAT_RIGHTLEFT
! if (curwin->w_p_rl)
! {
! if (pum_col < W_WINCOL(curwin) + W_WIDTH(curwin) - 1)
! screen_putchar(' ', row, pum_col + 1, attr);
! }
! else
! #endif
! if (pum_col > 0)
! screen_putchar(' ', row, pum_col - 1, attr);
/* Display each entry, use two spaces for a Tab.
* Do this 3 times: For the main text, kind and extra info */
***************
*** 282,307 ****
{
/* Display the text that fits or comes before a Tab.
* First convert it to printable characters. */
! char_u *st;
! int saved = *p;
*p = NUL;
st = transstr(s);
*p = saved;
! if (st != NULL)
{
! screen_puts_len(st, (int)STRLEN(st), row, col,
attr);
! vim_free(st);
}
- col += width;
if (*p != TAB)
break;
/* Display two spaces for a Tab. */
! screen_puts_len((char_u *)" ", 2, row, col, attr);
! col += 2;
totwidth += 2;
s = NULL; /* start text at next char */
width = 0;
--- 320,386 ----
{
/* Display the text that fits or comes before a Tab.
* First convert it to printable characters. */
! char_u *st;
! int saved = *p;
*p = NUL;
st = transstr(s);
*p = saved;
! #ifdef FEAT_RIGHTLEFT
! if (curwin->w_p_rl)
{
! if (st != NULL)
! {
! char_u *rt = reverse_text(st);
! char_u *rt_saved = rt;
! int len, j;
!
! if (rt != NULL)
! {
! len = STRLEN(rt);
! if (len > pum_width)
! {
! for (j = pum_width; j < len; ++j)
! mb_ptr_adv(rt);
! len = pum_width;
! }
! screen_puts_len(rt, len, row,
! col - len + 1, attr);
! vim_free(rt_saved);
! }
! vim_free(st);
! }
! col -= width;
! }
! else
! #endif
! {
! if (st != NULL)
! {
! screen_puts_len(st, (int)STRLEN(st), row, col,
attr);
! vim_free(st);
! }
! col += width;
}
if (*p != TAB)
break;
/* Display two spaces for a Tab. */
! #ifdef FEAT_RIGHTLEFT
! if (curwin->w_p_rl)
! {
! screen_puts_len((char_u *)" ", 2, row, col - 1,
! attr);
! col -= 2;
! }
! else
! #endif
! {
! screen_puts_len((char_u *)" ", 2, row, col, attr);
! col += 2;
! }
totwidth += 2;
s = NULL; /* start text at next char */
width = 0;
***************
*** 322,338 ****
&& pum_array[idx].pum_extra == NULL)
|| pum_base_width + n >= pum_width)
break;
! screen_fill(row, row + 1, col, pum_col + pum_base_width + n,
' ', ' ', attr);
! col = pum_col + pum_base_width + n;
totwidth = pum_base_width + n;
}
! screen_fill(row, row + 1, col, pum_col + pum_width, ' ', ' ', attr);
if (pum_scrollbar > 0)
! screen_putchar(' ', row, pum_col + pum_width,
! i >= thumb_pos && i < thumb_pos + thumb_heigth
? attr_thumb : attr_scroll);
++row;
}
--- 401,444 ----
&& pum_array[idx].pum_extra == NULL)
|| pum_base_width + n >= pum_width)
break;
! #ifdef FEAT_RIGHTLEFT
! if (curwin->w_p_rl)
! {
! screen_fill(row, row + 1, pum_col - pum_base_width - n + 1,
! col + 1, ' ', ' ', attr);
! col = pum_col - pum_base_width - n + 1;
! }
! else
! #endif
! {
! screen_fill(row, row + 1, col, pum_col + pum_base_width + n,
' ', ' ', attr);
! col = pum_col + pum_base_width + n;
! }
totwidth = pum_base_width + n;
}
! #ifdef FEAT_RIGHTLEFT
! if (curwin->w_p_rl)
! screen_fill(row, row + 1, pum_col - pum_width + 1, col + 1, ' ',
! ' ', attr);
! else
! #endif
! screen_fill(row, row + 1, col, pum_col + pum_width, ' ', ' ',
! attr);
if (pum_scrollbar > 0)
! {
! #ifdef FEAT_RIGHTLEFT
! if (curwin->w_p_rl)
! screen_putchar(' ', row, pum_col - pum_width,
! i >= thumb_pos && i < thumb_pos + thumb_heigth
? attr_thumb : attr_scroll);
+ else
+ #endif
+ screen_putchar(' ', row, pum_col + pum_width,
+ i >= thumb_pos && i < thumb_pos + thumb_heigth
+ ? attr_thumb : attr_scroll);
+ }
++row;
}
*** ../vim-7.1.057/src/proto/search.pro Sat May 5 20:20:36 2007
--- src/proto/search.pro Wed Aug 1 12:41:25 2007
***************
*** 1,6 ****
--- 1,7 ----
/* search.c */
int search_regcomp __ARGS((char_u *pat, int pat_save, int pat_use, int options, regmmatch_T *regmatch));
char_u *get_search_pat __ARGS((void));
+ char_u *reverse_text __ARGS((char_u *s));
void save_search_patterns __ARGS((void));
void restore_search_patterns __ARGS((void));
void free_search_patterns __ARGS((void));
*** ../vim-7.1.057/src/search.c Tue Jul 10 13:27:46 2007
--- src/search.c Wed Aug 1 12:39:22 2007
***************
*** 101,107 ****
static char_u *mr_pattern = NULL; /* pattern used by search_regcomp() */
#ifdef FEAT_RIGHTLEFT
static int mr_pattern_alloced = FALSE; /* mr_pattern was allocated */
- static char_u *reverse_text __ARGS((char_u *s));
#endif
#ifdef FEAT_FIND_ID
--- 101,106 ----
***************
*** 228,239 ****
return mr_pattern;
}
! #ifdef FEAT_RIGHTLEFT
/*
* Reverse text into allocated memory.
* Returns the allocated string, NULL when out of memory.
*/
! static char_u *
reverse_text(s)
char_u *s;
{
--- 227,238 ----
return mr_pattern;
}
! #if defined(FEAT_RIGHTLEFT) || defined(PROTO)
/*
* Reverse text into allocated memory.
* Returns the allocated string, NULL when out of memory.
*/
! char_u *
reverse_text(s)
char_u *s;
{
***************
*** 1898,1904 ****
}
#ifdef FEAT_RIGHTLEFT
! /* This is just guessing: when 'rightleft' is set, search for a maching
* paren/brace in the other direction. */
if (curwin->w_p_rl && vim_strchr((char_u *)"()[]{}<>", initc) != NULL)
backwards = !backwards;
--- 1897,1903 ----
}
#ifdef FEAT_RIGHTLEFT
! /* This is just guessing: when 'rightleft' is set, search for a matching
* paren/brace in the other direction. */
if (curwin->w_p_rl && vim_strchr((char_u *)"()[]{}<>", initc) != NULL)
backwards = !backwards;
*** ../vim-7.1.057/src/version.c Wed Aug 8 21:41:19 2007
--- src/version.c Wed Aug 8 22:44:49 2007
***************
*** 668,669 ****
--- 668,671 ----
{ /* Add new patch number below this line */
+ /**/
+ 58,
/**/
--
hundred-and-one symptoms of being an internet addict:
99. The hum of a cooling fan and the click of keys is comforting to you.
/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ download, build and distribute -- http://www.A-A-P.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///