mirror of
git://git.sv.gnu.org/nano.git
synced 2024-11-30 00:23:28 +03:00
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
This commit is contained in:
parent
198bd592ff
commit
6bc26a9a8b
@ -7,6 +7,10 @@ CVS code -
|
||||
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)
|
||||
@ -35,15 +39,10 @@ CVS code -
|
||||
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)
|
||||
|
34
src/global.c
34
src/global.c
@ -252,7 +252,8 @@ void shortcut_init(bool unjustify)
|
||||
#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
|
||||
@ -339,8 +340,10 @@ void shortcut_init(bool unjustify)
|
||||
#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
|
||||
@ -663,8 +666,13 @@ void shortcut_init(bool unjustify)
|
||||
#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 */
|
||||
@ -728,8 +736,12 @@ void shortcut_init(bool unjustify)
|
||||
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 */
|
||||
|
||||
@ -758,8 +770,12 @@ void shortcut_init(bool unjustify)
|
||||
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
|
||||
|
||||
|
12
src/nano.c
12
src/nano.c
@ -472,15 +472,8 @@ void help_init(void)
|
||||
/* 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);
|
||||
@ -490,6 +483,7 @@ void help_init(void)
|
||||
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';
|
||||
|
@ -395,9 +395,6 @@ typedef struct historyheadtype {
|
||||
/* 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
|
||||
|
@ -1215,6 +1215,7 @@ char *get_history_newer(historyheadtype *h)
|
||||
{
|
||||
if (h->current->prev != NULL) {
|
||||
h->current = h->current->prev;
|
||||
if (h->current->prev != NULL)
|
||||
return h->current->data;
|
||||
}
|
||||
return NULL;
|
||||
|
23
src/winio.c
23
src/winio.c
@ -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'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));
|
||||
@ -2537,13 +2537,13 @@ int nanogetstr(bool allow_tabs, const char *buf, const char *def,
|
||||
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;
|
||||
}
|
||||
@ -2949,30 +2949,21 @@ void bottombars(const shortcut *s)
|
||||
|
||||
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] = "";
|
||||
|
||||
/* 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. */
|
||||
/* 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
|
||||
|
||||
wmove(bottomwin, 1 + i % 2, (i / 2) * colwidth);
|
||||
onekey(keystr, s->desc, colwidth);
|
||||
|
Loading…
Reference in New Issue
Block a user