match the config.h #includes everywhere else. (DLR)
- Change all hardcoded instances of 128 bytes to MAX_BUF_SIZE,
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:
load_open_file()
- Remove an unneeded clearok(FALSE). (DLR)
do_output()
- Properly allow wrapping when we insert a tab, for consistency.
(DLR)
-- search.c:
- get_history_newer()
- - Remove redundant check. (DLR)
- utils.c:
num_of_digits()
- Use a size_t instead of an int, and rename to digits(). (DLR)
- winio.c:
- nanogetstr()
- - Simplify one of the history checks. (DLR)
do_help()
- Don't treat NANO_CANCEL_KEY as NANO_EXIT_KEY anymore, for
consistency. (DLR)
#ifdef HAVE_REGEX_H
const char *regexp_msg = N_("Regexp");
#endif
- const char *history_msg = N_("History");
+ const char *prevhistory_msg = N_("PrevString");
+ const char *nexthistory_msg = N_("NextString");
#ifdef ENABLE_MULTIBUFFER
const char *new_buffer_msg = N_("New Buffer");
#endif
#ifdef HAVE_REGEX_H
const char *nano_regexp_msg = N_("Use regular expressions");
#endif
- const char *nano_editstr_msg =
- N_("Edit the previous search/replace strings");
+ const char *nano_prevhistory_msg =
+ N_("Edit the previous search/replace string");
+ const char *nano_nexthistory_msg =
+ N_("Edit the next search/replace string");
#endif /* !NANO_SMALL */
#ifndef DISABLE_BROWSER
#endif
/* Translators: try to keep this string under 10 characters long */
- sc_init_one(&whereis_list, NANO_HISTORY_KEY, history_msg,
- IFHELP(nano_editstr_msg, NANO_NO_KEY), NANO_NO_KEY,
+ sc_init_one(&whereis_list, NANO_PREVLINE_KEY, prevhistory_msg,
+ 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);
/* Translators: try to keep this string under 10 characters long */
NANO_NO_KEY, VIEW, NULL);
#endif
- sc_init_one(&replace_list, NANO_HISTORY_KEY, history_msg,
- IFHELP(nano_editstr_msg, NANO_NO_KEY), NANO_NO_KEY,
+ sc_init_one(&replace_list, NANO_PREVLINE_KEY, prevhistory_msg,
+ 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);
#endif /* !NANO_SMALL */
NANO_NO_KEY, VIEW, do_last_line);
#ifndef NANO_SMALL
- sc_init_one(&replace_list_2, NANO_HISTORY_KEY, history_msg,
- IFHELP(nano_editstr_msg, NANO_NO_KEY), NANO_NO_KEY,
+ sc_init_one(&replace_list_2, NANO_PREVLINE_KEY, prevhistory_msg,
+ 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);
#endif
/* Control key. */
if (s->ctrlval != NANO_NO_KEY) {
entries++;
-#ifndef NANO_SMALL
- if (s->ctrlval == NANO_HISTORY_KEY) {
- char *up_ptr = display_string(_("Up"), 0, 7, FALSE);
-
- ptr += sprintf(ptr, "%s", up_ptr);
-
- free(up_ptr);
- } else
-#endif
+ /* Yucky sentinel values that we can't handle a better
+ * way. */
if (s->ctrlval == NANO_CONTROL_SPACE) {
char *space_ptr = display_string(_("Space"), 0, 6,
FALSE);
free(space_ptr);
} else if (s->ctrlval == NANO_CONTROL_8)
ptr += sprintf(ptr, "^?");
+ /* Normal values. */
else
ptr += sprintf(ptr, "^%c", s->ctrlval + 64);
*(ptr++) = '\t';
/* No key at all. */
#define NANO_NO_KEY -2
-/* Special sentinel key used for search/replace history. */
-#define NANO_HISTORY_KEY -3
-
/* Normal keys. */
#define NANO_XON_KEY NANO_CONTROL_Q
#define NANO_XOFF_KEY NANO_CONTROL_S
{
if (h->current->prev != NULL) {
h->current = h->current->prev;
- return h->current->data;
+ if (h->current->prev != NULL)
+ return h->current->data;
}
return NULL;
}
/* If we have a shortcut with an associated function, break out
* if we're finished after running or trying to run the
* function. */
- if (finished)
+ if (ran_func && finished)
break;
assert(statusbar_x <= answer_len && answer_len == strlen(answer));
case NANO_PREVLINE_KEY:
#ifndef NANO_SMALL
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
* that we're scrolling up at the top of the search
* history, and we need to save the current answer
* in currentbuf. Do this and reset use_cb to 0. */
- if (currentbuf != NULL && use_cb == 1 &&
- strcmp(currentbuf, answer) != 0) {
+ if (currentbuf == NULL || (use_cb == 1 &&
+ strcmp(currentbuf, answer) != 0)) {
currentbuf = mallocstrcpy(currentbuf, answer);
use_cb = 0;
}
for (i = 0; i < slen; i++, s = s->next) {
const char *keystr;
-
- /* Yucky sentinel values we can't handle a better way. */
-#ifndef NANO_SMALL
- if (s->ctrlval == NANO_HISTORY_KEY)
- keystr = _("Up");
- else {
-#endif
- char foo[4] = "";
-
- if (s->ctrlval == NANO_CONTROL_SPACE)
- strcpy(foo, "^ ");
- else if (s->ctrlval == NANO_CONTROL_8)
- strcpy(foo, "^?");
- /* Normal values. Assume that the shortcut has an
- * equivalent control key, meta key sequence, or both. */
- 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
+ char foo[4] = "";
+
+ /* Yucky sentinel values that we can't handle a better way. */
+ if (s->ctrlval == NANO_CONTROL_SPACE)
+ strcpy(foo, "^ ");
+ else if (s->ctrlval == NANO_CONTROL_8)
+ strcpy(foo, "^?");
+ /* Normal values. Assume that the shortcut has an equivalent
+ * control key, meta key sequence, or both. */
+ 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;
wmove(bottomwin, 1 + i % 2, (i / 2) * colwidth);
onekey(keystr, s->desc, colwidth);