Commit 6bc26a9a authored by David Lawrence Ramsey's avatar David Lawrence Ramsey
Browse files

revert some attempts at simplifying the search/replace history code that

were causing breakage; make "previous history" and "next history" use
separate keys; and display them as "^P" and "^N" instead of using one
sentinel value for both, so that clicking on them with the mouse works
again


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2497 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
No related merge requests found
Showing with 53 additions and 55 deletions
+53 -55
...@@ -7,6 +7,10 @@ CVS code - ...@@ -7,6 +7,10 @@ CVS code -
match the config.h #includes everywhere else. (DLR) match the config.h #includes everywhere else. (DLR)
- Change all hardcoded instances of 128 bytes to MAX_BUF_SIZE, - Change all hardcoded instances of 128 bytes to MAX_BUF_SIZE,
and #define MAX_BUF_SIZE as 128 in nano.h. (DLR) and #define MAX_BUF_SIZE as 128 in nano.h. (DLR)
- Use separate keys to go to the previous and next strings in
the search/replace history, and display them as "^P" and "^N".
This makes mouse clicks work properly on them. Changes to
shortcut_init(), help_init(), and do_statusbar_input(). (DLR)
- files.c: - files.c:
load_open_file() load_open_file()
- Remove an unneeded clearok(FALSE). (DLR) - Remove an unneeded clearok(FALSE). (DLR)
...@@ -35,15 +39,10 @@ CVS code - ...@@ -35,15 +39,10 @@ CVS code -
do_output() do_output()
- Properly allow wrapping when we insert a tab, for consistency. - Properly allow wrapping when we insert a tab, for consistency.
(DLR) (DLR)
- search.c:
get_history_newer()
- Remove redundant check. (DLR)
- utils.c: - utils.c:
num_of_digits() num_of_digits()
- Use a size_t instead of an int, and rename to digits(). (DLR) - Use a size_t instead of an int, and rename to digits(). (DLR)
- winio.c: - winio.c:
nanogetstr()
- Simplify one of the history checks. (DLR)
do_help() do_help()
- Don't treat NANO_CANCEL_KEY as NANO_EXIT_KEY anymore, for - Don't treat NANO_CANCEL_KEY as NANO_EXIT_KEY anymore, for
consistency. (DLR) consistency. (DLR)
......
...@@ -252,7 +252,8 @@ void shortcut_init(bool unjustify) ...@@ -252,7 +252,8 @@ void shortcut_init(bool unjustify)
#ifdef HAVE_REGEX_H #ifdef HAVE_REGEX_H
const char *regexp_msg = N_("Regexp"); const char *regexp_msg = N_("Regexp");
#endif #endif
const char *history_msg = N_("History"); const char *prevhistory_msg = N_("PrevString");
const char *nexthistory_msg = N_("NextString");
#ifdef ENABLE_MULTIBUFFER #ifdef ENABLE_MULTIBUFFER
const char *new_buffer_msg = N_("New Buffer"); const char *new_buffer_msg = N_("New Buffer");
#endif #endif
...@@ -339,8 +340,10 @@ void shortcut_init(bool unjustify) ...@@ -339,8 +340,10 @@ void shortcut_init(bool unjustify)
#ifdef HAVE_REGEX_H #ifdef HAVE_REGEX_H
const char *nano_regexp_msg = N_("Use regular expressions"); const char *nano_regexp_msg = N_("Use regular expressions");
#endif #endif
const char *nano_editstr_msg = const char *nano_prevhistory_msg =
N_("Edit the previous search/replace strings"); N_("Edit the previous search/replace string");
const char *nano_nexthistory_msg =
N_("Edit the next search/replace string");
#endif /* !NANO_SMALL */ #endif /* !NANO_SMALL */
#ifndef DISABLE_BROWSER #ifndef DISABLE_BROWSER
...@@ -663,8 +666,13 @@ void shortcut_init(bool unjustify) ...@@ -663,8 +666,13 @@ void shortcut_init(bool unjustify)
#endif #endif
/* Translators: try to keep this string under 10 characters long */ /* Translators: try to keep this string under 10 characters long */
sc_init_one(&whereis_list, NANO_HISTORY_KEY, history_msg, sc_init_one(&whereis_list, NANO_PREVLINE_KEY, prevhistory_msg,
IFHELP(nano_editstr_msg, NANO_NO_KEY), NANO_NO_KEY, IFHELP(nano_prevhistory_msg, NANO_NO_KEY), NANO_NO_KEY,
NANO_NO_KEY, VIEW, NULL);
/* Translators: try to keep this string under 10 characters long */
sc_init_one(&whereis_list, NANO_NEXTLINE_KEY, nexthistory_msg,
IFHELP(nano_nexthistory_msg, NANO_NO_KEY), NANO_NO_KEY,
NANO_NO_KEY, VIEW, NULL); NANO_NO_KEY, VIEW, NULL);
/* Translators: try to keep this string under 10 characters long */ /* Translators: try to keep this string under 10 characters long */
...@@ -728,8 +736,12 @@ void shortcut_init(bool unjustify) ...@@ -728,8 +736,12 @@ void shortcut_init(bool unjustify)
NANO_NO_KEY, VIEW, NULL); NANO_NO_KEY, VIEW, NULL);
#endif #endif
sc_init_one(&replace_list, NANO_HISTORY_KEY, history_msg, sc_init_one(&replace_list, NANO_PREVLINE_KEY, prevhistory_msg,
IFHELP(nano_editstr_msg, NANO_NO_KEY), NANO_NO_KEY, IFHELP(nano_prevhistory_msg, NANO_NO_KEY), NANO_NO_KEY,
NANO_NO_KEY, VIEW, NULL);
sc_init_one(&replace_list, NANO_NEXTLINE_KEY, nexthistory_msg,
IFHELP(nano_nexthistory_msg, NANO_NO_KEY), NANO_NO_KEY,
NANO_NO_KEY, VIEW, NULL); NANO_NO_KEY, VIEW, NULL);
#endif /* !NANO_SMALL */ #endif /* !NANO_SMALL */
...@@ -758,8 +770,12 @@ void shortcut_init(bool unjustify) ...@@ -758,8 +770,12 @@ void shortcut_init(bool unjustify)
NANO_NO_KEY, VIEW, do_last_line); NANO_NO_KEY, VIEW, do_last_line);
#ifndef NANO_SMALL #ifndef NANO_SMALL
sc_init_one(&replace_list_2, NANO_HISTORY_KEY, history_msg, sc_init_one(&replace_list_2, NANO_PREVLINE_KEY, prevhistory_msg,
IFHELP(nano_editstr_msg, NANO_NO_KEY), NANO_NO_KEY, IFHELP(nano_prevhistory_msg, NANO_NO_KEY), NANO_NO_KEY,
NANO_NO_KEY, VIEW, NULL);
sc_init_one(&replace_list_2, NANO_NEXTLINE_KEY, nexthistory_msg,
IFHELP(nano_nexthistory_msg, NANO_NO_KEY), NANO_NO_KEY,
NANO_NO_KEY, VIEW, NULL); NANO_NO_KEY, VIEW, NULL);
#endif #endif
......
...@@ -472,15 +472,8 @@ void help_init(void) ...@@ -472,15 +472,8 @@ void help_init(void)
/* Control key. */ /* Control key. */
if (s->ctrlval != NANO_NO_KEY) { if (s->ctrlval != NANO_NO_KEY) {
entries++; entries++;
#ifndef NANO_SMALL /* Yucky sentinel values that we can't handle a better
if (s->ctrlval == NANO_HISTORY_KEY) { * way. */
char *up_ptr = display_string(_("Up"), 0, 7, FALSE);
ptr += sprintf(ptr, "%s", up_ptr);
free(up_ptr);
} else
#endif
if (s->ctrlval == NANO_CONTROL_SPACE) { if (s->ctrlval == NANO_CONTROL_SPACE) {
char *space_ptr = display_string(_("Space"), 0, 6, char *space_ptr = display_string(_("Space"), 0, 6,
FALSE); FALSE);
...@@ -490,6 +483,7 @@ void help_init(void) ...@@ -490,6 +483,7 @@ void help_init(void)
free(space_ptr); free(space_ptr);
} else if (s->ctrlval == NANO_CONTROL_8) } else if (s->ctrlval == NANO_CONTROL_8)
ptr += sprintf(ptr, "^?"); ptr += sprintf(ptr, "^?");
/* Normal values. */
else else
ptr += sprintf(ptr, "^%c", s->ctrlval + 64); ptr += sprintf(ptr, "^%c", s->ctrlval + 64);
*(ptr++) = '\t'; *(ptr++) = '\t';
......
...@@ -395,9 +395,6 @@ typedef struct historyheadtype { ...@@ -395,9 +395,6 @@ typedef struct historyheadtype {
/* No key at all. */ /* No key at all. */
#define NANO_NO_KEY -2 #define NANO_NO_KEY -2
/* Special sentinel key used for search/replace history. */
#define NANO_HISTORY_KEY -3
/* Normal keys. */ /* Normal keys. */
#define NANO_XON_KEY NANO_CONTROL_Q #define NANO_XON_KEY NANO_CONTROL_Q
#define NANO_XOFF_KEY NANO_CONTROL_S #define NANO_XOFF_KEY NANO_CONTROL_S
......
...@@ -1215,7 +1215,8 @@ char *get_history_newer(historyheadtype *h) ...@@ -1215,7 +1215,8 @@ char *get_history_newer(historyheadtype *h)
{ {
if (h->current->prev != NULL) { if (h->current->prev != NULL) {
h->current = h->current->prev; h->current = h->current->prev;
return h->current->data; if (h->current->prev != NULL)
return h->current->data;
} }
return NULL; return NULL;
} }
......
...@@ -2495,7 +2495,7 @@ int nanogetstr(bool allow_tabs, const char *buf, const char *def, ...@@ -2495,7 +2495,7 @@ int nanogetstr(bool allow_tabs, const char *buf, const char *def,
/* If we have a shortcut with an associated function, break out /* If we have a shortcut with an associated function, break out
* if we're finished after running or trying to run the * if we're finished after running or trying to run the
* function. */ * function. */
if (finished) if (ran_func && finished)
break; break;
assert(statusbar_x <= answer_len && answer_len == strlen(answer)); assert(statusbar_x <= answer_len && answer_len == strlen(answer));
...@@ -2537,13 +2537,13 @@ int nanogetstr(bool allow_tabs, const char *buf, const char *def, ...@@ -2537,13 +2537,13 @@ int nanogetstr(bool allow_tabs, const char *buf, const char *def,
case NANO_PREVLINE_KEY: case NANO_PREVLINE_KEY:
#ifndef NANO_SMALL #ifndef NANO_SMALL
if (history_list != NULL) { if (history_list != NULL) {
/* If currentbuf is NULL, use_cb is 1, and /* If currentbuf is NULL, or if use_cb is 1 and
* currentbuf is different from answer, it means * currentbuf is different from answer, it means
* that we're scrolling up at the top of the search * that we're scrolling up at the top of the search
* history, and we need to save the current answer * history, and we need to save the current answer
* in currentbuf. Do this and reset use_cb to 0. */ * in currentbuf. Do this and reset use_cb to 0. */
if (currentbuf != NULL && use_cb == 1 && if (currentbuf == NULL || (use_cb == 1 &&
strcmp(currentbuf, answer) != 0) { strcmp(currentbuf, answer) != 0)) {
currentbuf = mallocstrcpy(currentbuf, answer); currentbuf = mallocstrcpy(currentbuf, answer);
use_cb = 0; use_cb = 0;
} }
...@@ -2949,30 +2949,21 @@ void bottombars(const shortcut *s) ...@@ -2949,30 +2949,21 @@ void bottombars(const shortcut *s)
for (i = 0; i < slen; i++, s = s->next) { for (i = 0; i < slen; i++, s = s->next) {
const char *keystr; const char *keystr;
char foo[4] = "";
/* Yucky sentinel values we can't handle a better way. */
#ifndef NANO_SMALL /* Yucky sentinel values that we can't handle a better way. */
if (s->ctrlval == NANO_HISTORY_KEY) if (s->ctrlval == NANO_CONTROL_SPACE)
keystr = _("Up"); strcpy(foo, "^ ");
else { else if (s->ctrlval == NANO_CONTROL_8)
#endif strcpy(foo, "^?");
char foo[4] = ""; /* Normal values. Assume that the shortcut has an equivalent
* control key, meta key sequence, or both. */
if (s->ctrlval == NANO_CONTROL_SPACE) else if (s->ctrlval != NANO_NO_KEY)
strcpy(foo, "^ "); sprintf(foo, "^%c", s->ctrlval + 64);
else if (s->ctrlval == NANO_CONTROL_8) else if (s->metaval != NANO_NO_KEY)
strcpy(foo, "^?"); sprintf(foo, "M-%c", toupper(s->metaval));
/* Normal values. Assume that the shortcut has an
* equivalent control key, meta key sequence, or both. */ keystr = foo;
else if (s->ctrlval != NANO_NO_KEY)
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); wmove(bottomwin, 1 + i % 2, (i / 2) * colwidth);
onekey(keystr, s->desc, colwidth); onekey(keystr, s->desc, colwidth);
......
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