summaryrefslogtreecommitdiffstats
path: root/src/popupmnu.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2007-08-08 20:49:37 +0000
committerBram Moolenaar <Bram@vim.org>2007-08-08 20:49:37 +0000
commitabc9773580f74a0767da91af5f342de4ee12936f (patch)
treef7a5707f236c6af7fd0c738a6621e3ad5808ce2a /src/popupmnu.c
parentc2f5abcf152b0bf25cc25c364ec6d0d0bfe58066 (diff)
updated for version 7.1-058v7.1.058
Diffstat (limited to 'src/popupmnu.c')
-rw-r--r--src/popupmnu.c146
1 files changed, 126 insertions, 20 deletions
diff --git a/src/popupmnu.c b/src/popupmnu.c
index eb4631a4ce..4dd3a94882 100644
--- a/src/popupmnu.c
+++ b/src/popupmnu.c
@@ -75,7 +75,6 @@ redo:
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;
@@ -167,6 +166,15 @@ redo:
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,11 +187,23 @@ redo:
if (def_width < max_width)
def_width = max_width;
- if (col < Columns - PUM_DEF_WIDTH || col < Columns - 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;
- pum_width = Columns - pum_col - pum_scrollbar;
+
+#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,14 +215,24 @@ redo:
else if (Columns < def_width)
{
/* not enough room, will use what we have */
- pum_col = 0;
+#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 */
- pum_col = Columns - max_width;
+#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,8 +285,16 @@ pum_redraw()
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);
+#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,26 +320,67 @@ pum_redraw()
{
/* Display the text that fits or comes before a Tab.
* First convert it to printable characters. */
- char_u *st;
- int saved = *p;
+ char_u *st;
+ int saved = *p;
*p = NUL;
st = transstr(s);
*p = saved;
- if (st != NULL)
+#ifdef FEAT_RIGHTLEFT
+ if (curwin->w_p_rl)
{
- screen_puts_len(st, (int)STRLEN(st), row, col,
+ 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);
+ vim_free(st);
+ }
+ col += width;
}
- col += width;
if (*p != TAB)
break;
/* Display two spaces for a Tab. */
- screen_puts_len((char_u *)" ", 2, row, col, attr);
- col += 2;
+#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,17 +401,44 @@ pum_redraw()
&& 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,
+#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;
+ col = pum_col + pum_base_width + n;
+ }
totwidth = pum_base_width + n;
}
- screen_fill(row, row + 1, col, pum_col + pum_width, ' ', ' ', attr);
+#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)
- screen_putchar(' ', row, pum_col + pum_width,
- i >= thumb_pos && i < thumb_pos + thumb_heigth
+ {
+#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;
}