Commit 0ff01a92 authored by David Lawrence Ramsey's avatar David Lawrence Ramsey
Browse files

put DB's old efficiency tweaks back in bottombars()

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2025 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
parent cc823ab6
Showing with 25 additions and 17 deletions
+25 -17
...@@ -258,6 +258,10 @@ CVS code - ...@@ -258,6 +258,10 @@ CVS code -
- New function to set resetstatuspos to FALSE when we don't - New function to set resetstatuspos to FALSE when we don't
properly exit the statusbar prompt, e.g. when we get a file properly exit the statusbar prompt, e.g. when we get a file
from the file browser). (DLR) from the file browser). (DLR)
bottombars()
- For efficiency, no longer dynamically allocate space for each
visible shortcut, as they're all of a constant short length.
(David Benbennick)
reset_cursor() reset_cursor()
- If this is called before any files have been opened, as it can - If this is called before any files have been opened, as it can
be by statusbar(), put the cursor at the top left corner of be by statusbar(), put the cursor at the top left corner of
......
...@@ -2450,7 +2450,6 @@ void statusbar(const char *msg, ...) ...@@ -2450,7 +2450,6 @@ void statusbar(const char *msg, ...)
void bottombars(const shortcut *s) void bottombars(const shortcut *s)
{ {
size_t i, colwidth, slen; size_t i, colwidth, slen;
char *keystr;
if (ISSET(NO_HELP)) if (ISSET(NO_HELP))
return; return;
...@@ -2469,35 +2468,40 @@ void bottombars(const shortcut *s) ...@@ -2469,35 +2468,40 @@ void bottombars(const shortcut *s)
/* There will be this many characters per column. We need at least /* There will be this many characters per column. We need at least
* 3 to display anything properly.*/ * 3 to display anything properly.*/
colwidth = COLS / ((slen / 2) + (slen % 2)); colwidth = COLS / ((slen / 2) + (slen % 2));
keystr = charalloc(colwidth);
blank_bottombars(); blank_bottombars();
for (i = 0; i < slen; i++, s = s->next) { for (i = 0; i < slen; i++, s = s->next) {
wmove(bottomwin, 1 + i % 2, (i / 2) * colwidth); const char *keystr;
/* Yucky sentinel values we can't handle a better way. */ /* Yucky sentinel values we can't handle a better way. */
#ifndef NANO_SMALL #ifndef NANO_SMALL
if (s->ctrlval == NANO_HISTORY_KEY) if (s->ctrlval == NANO_HISTORY_KEY)
strncpy(keystr, _("Up"), colwidth); keystr = _("Up");
else else {
#endif #endif
if (s->ctrlval == NANO_CONTROL_SPACE) char foo[4];
strncpy(keystr, "^ ", colwidth);
else if (s->ctrlval == NANO_CONTROL_8) if (s->ctrlval == NANO_CONTROL_SPACE)
strncpy(keystr, "^?", colwidth); strcpy(foo, "^ ");
/* Normal values. Assume that the shortcut has an equivalent else if (s->ctrlval == NANO_CONTROL_8)
* control key, meta key sequence, or both. */ strcpy(foo, "^?");
else if (s->ctrlval != NANO_NO_KEY) /* Normal values. Assume that the shortcut has an
snprintf(keystr, colwidth, "^%c", s->ctrlval + 64); * equivalent control key, meta key sequence, or both. */
else if (s->metaval != NANO_NO_KEY) else if (s->ctrlval != NANO_NO_KEY)
snprintf(keystr, colwidth, "M-%c", toupper(s->metaval)); sprintf(foo, "^%c", s->ctrlval + 64);
else if (s->metaval != NANO_NO_KEY)
sprintf(foo, "M-%c", toupper(s->metaval));
keystr = foo;
#ifndef NANO_SMALL
}
#endif
wmove(bottomwin, 1 + i % 2, (i / 2) * colwidth);
onekey(keystr, s->desc, colwidth); onekey(keystr, s->desc, colwidth);
} }
free(keystr);
wnoutrefresh(bottomwin); wnoutrefresh(bottomwin);
reset_cursor(); reset_cursor();
wrefresh(edit); wrefresh(edit);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment