DB's changes to do_delete(), and a few more minor bits
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1713 35c25a1d-7b9e-4130-9fde-d3aeb78583b8master
parent
07d3febe1b
commit
604caf3d6c
|
@ -1,6 +1,8 @@
|
||||||
CVS code -
|
CVS code -
|
||||||
- General:
|
- General:
|
||||||
- Minor comment cleanups. (DLR)
|
- Minor comment cleanups. (DLR)
|
||||||
|
- Convert more ints used as boolean values to use TRUE and
|
||||||
|
FALSE. (David Benbennick)
|
||||||
- Make sure the special control keys are handled the same way
|
- Make sure the special control keys are handled the same way
|
||||||
after the window is resized or we come out of suspend mode.
|
after the window is resized or we come out of suspend mode.
|
||||||
Changes to do_cont() and handle_sigwinch(). (DLR)
|
Changes to do_cont() and handle_sigwinch(). (DLR)
|
||||||
|
@ -9,14 +11,14 @@ CVS code -
|
||||||
- Rearrange the NANO_SMALL #ifdef so that the code to set the
|
- Rearrange the NANO_SMALL #ifdef so that the code to set the
|
||||||
MODIFIED flag in open_files->flags is included only once.
|
MODIFIED flag in open_files->flags is included only once.
|
||||||
(DLR)
|
(DLR)
|
||||||
|
- nano.c:
|
||||||
|
do_delete()
|
||||||
|
- Tweak for efficiency. (David Benbennick)
|
||||||
- search.c:
|
- search.c:
|
||||||
not_found_msg()
|
not_found_msg()
|
||||||
- Convert to properly handle strings generated by
|
- Convert to properly handle strings generated by
|
||||||
display_string() that have been used in the search prompt
|
display_string() that have been used in the search prompt
|
||||||
since 1.3.0. (David Benbennick)
|
since 1.3.0. (David Benbennick)
|
||||||
do_replace_loop()
|
|
||||||
- Convert more ints used as boolean values to use TRUE and
|
|
||||||
FALSE. (David Benbennick)
|
|
||||||
- utils.c:
|
- utils.c:
|
||||||
nstricmp(), nstrnicmp()
|
nstricmp(), nstrnicmp()
|
||||||
- Add extra blank lines for greater readability, and remove
|
- Add extra blank lines for greater readability, and remove
|
||||||
|
|
61
src/nano.c
61
src/nano.c
|
@ -943,7 +943,7 @@ void do_char(char ch)
|
||||||
{
|
{
|
||||||
size_t current_len = strlen(current->data);
|
size_t current_len = strlen(current->data);
|
||||||
#if !defined(DISABLE_WRAPPING) || defined(ENABLE_COLOR)
|
#if !defined(DISABLE_WRAPPING) || defined(ENABLE_COLOR)
|
||||||
int refresh = 0;
|
int refresh = FALSE;
|
||||||
/* Do we have to run edit_refresh(), or can we get away with
|
/* Do we have to run edit_refresh(), or can we get away with
|
||||||
* update_line()? */
|
* update_line()? */
|
||||||
#endif
|
#endif
|
||||||
|
@ -986,7 +986,7 @@ void do_char(char ch)
|
||||||
|
|
||||||
#ifdef ENABLE_COLOR
|
#ifdef ENABLE_COLOR
|
||||||
if (ISSET(COLOR_SYNTAX))
|
if (ISSET(COLOR_SYNTAX))
|
||||||
refresh = 1;
|
refresh = TRUE;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(DISABLE_WRAPPING) || defined(ENABLE_COLOR)
|
#if !defined(DISABLE_WRAPPING) || defined(ENABLE_COLOR)
|
||||||
|
@ -1028,38 +1028,41 @@ int do_backspace(void)
|
||||||
|
|
||||||
int do_delete(void)
|
int do_delete(void)
|
||||||
{
|
{
|
||||||
int refresh = 0;
|
assert(current != NULL && current->data != NULL && current_x <=
|
||||||
|
strlen(current->data));
|
||||||
/* blbf -> blank line before filebot (see below) */
|
|
||||||
int blbf = 0;
|
|
||||||
|
|
||||||
if (current->next == filebot && current->data[0] == '\0')
|
|
||||||
blbf = 1;
|
|
||||||
|
|
||||||
placewewant = xplustabs();
|
placewewant = xplustabs();
|
||||||
|
|
||||||
if (current_x != strlen(current->data)) {
|
if (current->data[current_x] != '\0') {
|
||||||
/* Let's get dangerous */
|
size_t linelen = strlen(current->data + current_x);
|
||||||
|
|
||||||
|
assert(current_x < strlen(current->data));
|
||||||
|
|
||||||
|
/* Let's get dangerous. */
|
||||||
charmove(¤t->data[current_x], ¤t->data[current_x + 1],
|
charmove(¤t->data[current_x], ¤t->data[current_x + 1],
|
||||||
strlen(current->data) - current_x);
|
linelen);
|
||||||
|
|
||||||
align(¤t->data);
|
null_at(¤t->data, linelen + current_x - 1);
|
||||||
#ifdef ENABLE_COLOR
|
#ifndef NANO_SMALL
|
||||||
if (ISSET(COLOR_SYNTAX))
|
if (current_x < mark_beginx && mark_beginbuf == current)
|
||||||
refresh = 1;
|
mark_beginx--;
|
||||||
#endif
|
#endif
|
||||||
} else if (current->next != NULL && (current->next != filebot || blbf)) {
|
} else if (current != filebot && (current->next != filebot ||
|
||||||
|
current->data[0] == '\0')) {
|
||||||
/* We can delete the line before filebot only if it is blank: it
|
/* We can delete the line before filebot only if it is blank: it
|
||||||
becomes the new magic line then. */
|
* becomes the new magic line then. */
|
||||||
|
filestruct *foo = current->next;
|
||||||
|
|
||||||
filestruct *foo;
|
assert(current_x == strlen(current->data));
|
||||||
|
current->data = charealloc(current->data, current_x +
|
||||||
current->data = charealloc(current->data,
|
strlen(foo->data) + 1);
|
||||||
strlen(current->data) +
|
strcpy(current->data + current_x, foo->data);
|
||||||
strlen(current->next->data) + 1);
|
#ifndef NANO_SMALL
|
||||||
strcat(current->data, current->next->data);
|
if (mark_beginbuf == current->next) {
|
||||||
|
mark_beginx += current_x;
|
||||||
foo = current->next;
|
mark_beginbuf = current;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
if (filebot == foo)
|
if (filebot == foo)
|
||||||
filebot = current;
|
filebot = current;
|
||||||
|
|
||||||
|
@ -1067,15 +1070,13 @@ int do_delete(void)
|
||||||
delete_node(foo);
|
delete_node(foo);
|
||||||
renumber(current);
|
renumber(current);
|
||||||
totlines--;
|
totlines--;
|
||||||
refresh = 1;
|
wrap_reset();
|
||||||
} else
|
} else
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
totsize--;
|
totsize--;
|
||||||
set_modified();
|
set_modified();
|
||||||
update_line(current, current_x);
|
edit_refresh();
|
||||||
if (refresh)
|
|
||||||
edit_refresh();
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue