DLR's latest bits
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1365 35c25a1d-7b9e-4130-9fde-d3aeb78583b8master
parent
2ad0f6c0ad
commit
09fc4300ec
12
ChangeLog
12
ChangeLog
|
@ -199,6 +199,9 @@ Changes
|
|||
found, display "[string] not found" instead of "Replaced 0
|
||||
occurrences". (DLR)
|
||||
- utils.c:
|
||||
is_cntrl_char()
|
||||
- Rework to fix a problem with displaying certain high-bit
|
||||
characters. (David Benbennick; reported by Andrzej Marecki)
|
||||
align()
|
||||
- Don't just assert that the string passed in isn't NULL; check
|
||||
that it isn't and only do the alignment when it isn't. (David
|
||||
|
@ -211,10 +214,13 @@ Changes
|
|||
charalloc()
|
||||
- Removed and redefined as a macro that calls nmalloc(). (David
|
||||
Benbennick)
|
||||
is_cntrl_char()
|
||||
- Rework to fix a problem with displaying certain high-bit
|
||||
characters. (David Benbennick; reported by Andrzej Marecki)
|
||||
- winio.c:
|
||||
nanogetstr()
|
||||
- Tweak to make the cursor stay in the same place if we hit a
|
||||
prompt-changing toggle while it's in the middle of the string.
|
||||
Also fix minor problem with search history where the current
|
||||
search item could be at the bottom of the history twice in a
|
||||
row under certain conditions. (DLR)
|
||||
edit_refresh()
|
||||
- Miscellaneous cleanups that fix a bug where the screen
|
||||
isn't updated after uncutting chunks of upwardly marked cut
|
||||
|
|
2
nano.c
2
nano.c
|
@ -2993,7 +2993,7 @@ int main(int argc, char *argv[])
|
|||
int optchr;
|
||||
int startline = 0; /* Line to try and start at */
|
||||
int modify_control_seq;
|
||||
int fill_flag_used = 0; /* Was the fill option used? */
|
||||
int fill_flag_used = 0; /* Was the fill option used? */
|
||||
const shortcut *s;
|
||||
#ifdef HAVE_GETOPT_LONG
|
||||
int preserveopt = 0; /* Did the cmdline include --preserve? */
|
||||
|
|
32
search.c
32
search.c
|
@ -158,8 +158,7 @@ int search_init(int replacing)
|
|||
case -2: /* Same string */
|
||||
#ifdef HAVE_REGEX_H
|
||||
if (ISSET(USE_REGEXP))
|
||||
/* If we're in Pico mode, and answer is "", use
|
||||
last_search! */
|
||||
/* If answer is "", use last_search! */
|
||||
regexp_init(last_search);
|
||||
#endif
|
||||
break;
|
||||
|
@ -405,7 +404,7 @@ int do_search(void)
|
|||
if (fileptr == current && fileptr_x == current_x && didfind != NULL)
|
||||
statusbar(_("This is the only occurrence"));
|
||||
else if (current->lineno <= edittop->lineno
|
||||
|| current->lineno >= editbot->lineno)
|
||||
|| current->lineno >= editbot->lineno)
|
||||
edit_update(current, current_x);
|
||||
|
||||
search_abort();
|
||||
|
@ -687,7 +686,7 @@ int do_replace(void)
|
|||
}
|
||||
|
||||
#ifndef NANO_SMALL
|
||||
if (strcmp(answer, ""))
|
||||
if (answer[0] != '\0')
|
||||
update_history(&search_history, answer);
|
||||
#endif /* !NANO_SMALL */
|
||||
|
||||
|
@ -712,7 +711,7 @@ int do_replace(void)
|
|||
_("Replace with"));
|
||||
|
||||
#ifndef NANO_SMALL
|
||||
if (i == 0 && strcmp(answer, ""))
|
||||
if (i == 0 && answer[0] != '\0')
|
||||
update_history(&replace_history, answer);
|
||||
#endif /* !NANO_SMALL */
|
||||
|
||||
|
@ -912,7 +911,7 @@ void history_init(void)
|
|||
/* find first node containing string *s in history list *h */
|
||||
historytype *find_node(historytype *h, char *s)
|
||||
{
|
||||
for ( ; h->next ; h = h->next)
|
||||
for (; h->next != NULL; h = h->next)
|
||||
if (strcmp(s, h->data) == 0)
|
||||
return h;
|
||||
return NULL;
|
||||
|
@ -945,10 +944,11 @@ void update_history(historyheadtype *h, char *s)
|
|||
{
|
||||
historytype *p;
|
||||
|
||||
if ((p = find_node(h->next, s))) {
|
||||
if (p == h->next) /* catch delete and re-insert of same string in 1st node */
|
||||
if ((p = find_node(h->next, s)) != NULL) {
|
||||
if (p == h->next) /* catch delete and re-insert of
|
||||
same string in 1st node */
|
||||
goto up_hs;
|
||||
remove_node(p); /* delete identical older string */
|
||||
remove_node(p); /* delete identical older string */
|
||||
h->count--;
|
||||
}
|
||||
if (h->count == MAX_SEARCH_HISTORY) { /* list 'full', delete oldest */
|
||||
|
@ -957,14 +957,14 @@ void update_history(historyheadtype *h, char *s)
|
|||
}
|
||||
insert_node((historytype *)h, s);
|
||||
h->count++;
|
||||
up_hs:
|
||||
up_hs:
|
||||
h->current = h->next;
|
||||
}
|
||||
|
||||
/* return a pointer to either the next older history or NULL if no more */
|
||||
char *get_history_older(historyheadtype *h)
|
||||
{
|
||||
if (h->current->next) { /* any older entries ? */
|
||||
if (h->current->next != NULL) { /* any older entries? */
|
||||
h->current = h->current->next; /* yes */
|
||||
return h->current->data; /* return it */
|
||||
}
|
||||
|
@ -973,9 +973,9 @@ char *get_history_older(historyheadtype *h)
|
|||
|
||||
char *get_history_newer(historyheadtype *h)
|
||||
{
|
||||
if (h->current->prev) {
|
||||
if (h->current->prev != NULL) {
|
||||
h->current = h->current->prev;
|
||||
if (h->current->prev)
|
||||
if (h->current->prev != NULL)
|
||||
return h->current->data;
|
||||
}
|
||||
return NULL;
|
||||
|
@ -986,8 +986,8 @@ char *get_history_completion(historyheadtype *h, char *s)
|
|||
{
|
||||
historytype *p;
|
||||
|
||||
for (p = h->current->next ; p->next ; p = p->next) {
|
||||
if ((strncmp(s, p->data, h->len) == 0) && (strlen(p->data) != h->len)) {
|
||||
for (p = h->current->next; p->next != NULL; p = p->next) {
|
||||
if (strncmp(s, p->data, h->len) == 0 && strlen(p->data) != h->len) {
|
||||
h->current = p;
|
||||
return p->data;
|
||||
}
|
||||
|
@ -1002,7 +1002,7 @@ void free_history(historyheadtype *h)
|
|||
{
|
||||
historytype *p, *n;
|
||||
|
||||
for (p = h->next ; (n = p->next) ; p = n)
|
||||
for (p = h->next; (n = p->next); p = n)
|
||||
remove_node(p);
|
||||
}
|
||||
|
||||
|
|
23
winio.c
23
winio.c
|
@ -197,7 +197,7 @@ int nanogetstr(int allowtabs, const char *buf, const char *def,
|
|||
)
|
||||
{
|
||||
int kbinput;
|
||||
int x;
|
||||
static int x = -1;
|
||||
/* the cursor position in 'answer' */
|
||||
int xend;
|
||||
/* length of 'answer', the status bar text */
|
||||
|
@ -213,7 +213,14 @@ int nanogetstr(int allowtabs, const char *buf, const char *def,
|
|||
int last_kbinput = 0, ret2cb = 0;
|
||||
#endif
|
||||
xend = strlen(def);
|
||||
x = xend;
|
||||
|
||||
/* Only put x at the end of the string if it's uninitialized or if
|
||||
it would be past the end of the string as it is. Otherwise,
|
||||
leave it alone. This is so the cursor position stays at the same
|
||||
place if a prompt-changing toggle is pressed. */
|
||||
if (x == -1 || x > xend)
|
||||
x = xend;
|
||||
|
||||
answer = (char *)nrealloc(answer, xend + 1);
|
||||
if (xend > 0)
|
||||
strcpy(answer, def);
|
||||
|
@ -351,7 +358,7 @@ int nanogetstr(int allowtabs, const char *buf, const char *def,
|
|||
case KEY_UP:
|
||||
case NANO_UP_KEY:
|
||||
#ifndef NANO_SMALL
|
||||
if (history_list) {
|
||||
if (history_list != NULL) {
|
||||
|
||||
/* If there's no previous temp holder, or if we already
|
||||
arrowed back down to it and (possibly edited it),
|
||||
|
@ -376,17 +383,19 @@ int nanogetstr(int allowtabs, const char *buf, const char *def,
|
|||
case KEY_DOWN:
|
||||
case NANO_DOWN_KEY:
|
||||
#ifndef NANO_SMALL
|
||||
if (history_list) {
|
||||
if (history_list != NULL) {
|
||||
/* get newer search from the history list */
|
||||
if ((history = get_history_newer(history_list)) != NULL) {
|
||||
answer = mallocstrcpy(answer, history);
|
||||
xend = strlen(history);
|
||||
|
||||
/* Else if we ran out of history, regurgitate the temporary
|
||||
buffer */
|
||||
/* else if we ran out of history, regurgitate the temporary
|
||||
buffer and blow away currentbuf */
|
||||
} else if (currentbuf != NULL) {
|
||||
answer = mallocstrcpy(answer, currentbuf);
|
||||
xend = strlen(currentbuf);
|
||||
free(currentbuf);
|
||||
currentbuf = NULL;
|
||||
xend = strlen(answer);
|
||||
ret2cb = 1;
|
||||
} else {
|
||||
answer = mallocstrcpy(answer, "");
|
||||
|
|
Loading…
Reference in New Issue