1
1

adjust the shortcut list display and related mouse support to not waste

the last few characters of bottomwin when the screen width isn't a clean
multiple of the column width, per Benno Schulenberg's patch (with a few
tweaks by me)


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3390 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
Этот коммит содержится в:
David Lawrence Ramsey 2006-04-18 16:13:35 +00:00
родитель 172aa93f4a
Коммит e806ab8473
2 изменённых файлов: 27 добавлений и 11 удалений

Просмотреть файл

@ -39,6 +39,11 @@ CVS code -
display" refer to display, for clarity. Changes to display" refer to display, for clarity. Changes to
shortcut_init(), configure.ac, and faq.html. (DLR, suggested shortcut_init(), configure.ac, and faq.html. (DLR, suggested
by Benno Schulenberg) by Benno Schulenberg)
- Adjust the shortcut list display and related mouse support to
not waste the last few characters of bottomwin when the screen
width isn't a clean multiple of the column width. Changes to
do_mouseinput() and bottombars(). (Benno Schulenberg, minor
tweaks by DLR)
- files.c: - files.c:
open_file() open_file()
- Remove redundant wording in the error message when we try to - Remove redundant wording in the error message when we try to

Просмотреть файл

@ -1587,25 +1587,34 @@ bool get_mouseinput(int *mouse_x, int *mouse_y, bool allow_shortcuts)
currslen = MAIN_VISIBLE; currslen = MAIN_VISIBLE;
} }
/* Calculate the width of each shortcut in the list. It's the /* Calculate the width of all of the shortcuts in the list
* same for all of them. */ * except for the last two, which are longer by (COLS % i)
* columns so as to not waste space. */
if (currslen < 2) if (currslen < 2)
i = COLS / 6; i = COLS / (MAIN_VISIBLE / 2);
else else
i = COLS / ((currslen / 2) + (currslen % 2)); i = COLS / ((currslen / 2) + (currslen % 2));
/* Calculate the y-coordinate relative to the beginning of /* Calculate the y-coordinate relative to the beginning of
* the shortcut list in bottomwin, i.e, with the sizes of * the shortcut list in bottomwin, i.e, with the sizes of
* topwin, edit, and the first line of bottomwin subtracted * topwin, edit, and the first line of bottomwin subtracted
* out. */ * out, and set j to it. */
j = *mouse_y - (2 - no_more_space()) - editwinrows - 1; j = *mouse_y - (2 - no_more_space()) - editwinrows - 1;
/* If we're on the statusbar, beyond the end of the shortcut /* If we're on the statusbar, don't do anything. */
* list, or beyond the end of a shortcut on the right side of if (j < 0)
* the screen, don't do anything. */
if (j < 0 || (*mouse_x / i) >= currslen)
return FALSE; return FALSE;
/* Calculate the x-coordinate relative to the beginning of the
* shortcut list in bottomwin, and add it to j. j should now be
* the index in the shortcut list of the shortcut we clicked. */
j = (*mouse_x / i) * 2 + j; j = (*mouse_x / i) * 2 + j;
/* Adjust j if we clicked in the last two shortcuts. */
if ((j >= currslen) && (*mouse_x % i < COLS % i))
j -= 2;
/* If we're beyond the last shortcut, don't do anything. */
if (j >= currslen) if (j >= currslen)
return FALSE; return FALSE;
@ -2222,8 +2231,10 @@ void bottombars(const shortcut *s)
slen = MAIN_VISIBLE; slen = MAIN_VISIBLE;
} }
/* There will be this many characters per column. We need at least /* There will be this many characters per column, except for the
* 3 to display anything properly. */ * last two, which will be longer by (COLS % colwidth) columns so as
* to not waste space. We need at least three columns to display
* anything properly. */
colwidth = COLS / ((slen / 2) + (slen % 2)); colwidth = COLS / ((slen / 2) + (slen % 2));
blank_bottombars(); blank_bottombars();
@ -2247,7 +2258,7 @@ void bottombars(const shortcut *s)
keystr = foo; keystr = foo;
wmove(bottomwin, 1 + i % 2, (i / 2) * colwidth); wmove(bottomwin, 1 + i % 2, (i / 2) * colwidth);
onekey(keystr, s->desc, colwidth); onekey(keystr, s->desc, colwidth + (COLS % colwidth));
} }
wnoutrefresh(bottomwin); wnoutrefresh(bottomwin);