Last fixes, add reset of cutbuffer when uncutting marked text and reset marked_cut when cutbuffer reset
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@688 35c25a1d-7b9e-4130-9fde-d3aeb78583b8master
parent
68b3dfb431
commit
40f45c8689
|
@ -69,6 +69,9 @@ Cvs code -
|
||||||
do_cut_text()
|
do_cut_text()
|
||||||
- If the line is empty when using -k and wasn't already added,
|
- If the line is empty when using -k and wasn't already added,
|
||||||
create a dummy line and add it to the cutbuffer (fixes bug #61)
|
create a dummy line and add it to the cutbuffer (fixes bug #61)
|
||||||
|
- Reset marked_cut if we blow away the cutbuffer.
|
||||||
|
do_uncut_text()
|
||||||
|
- Reset cutbuffer even if we're uncutting marked or cut to end text!
|
||||||
- faq.html:
|
- faq.html:
|
||||||
- Brought the FAQ up to date, many little changes (Jordi).
|
- Brought the FAQ up to date, many little changes (Jordi).
|
||||||
- files.c:
|
- files.c:
|
||||||
|
|
27
cut.c
27
cut.c
|
@ -58,7 +58,8 @@ void add_to_cutbuffer(filestruct * inptr)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef NANO_SMALL
|
#ifndef NANO_SMALL
|
||||||
/* Cut a marked segment instead of a whole line. Only called from do_cut_text().
|
/* Cut a marked segment instead of a whole line. Only called from
|
||||||
|
do_cut_text().
|
||||||
destructive is whether to actually modify the file structure, if not then
|
destructive is whether to actually modify the file structure, if not then
|
||||||
just copy the buffer into cutbuffer and don't pull it from the file */
|
just copy the buffer into cutbuffer and don't pull it from the file */
|
||||||
|
|
||||||
|
@ -162,6 +163,7 @@ int do_cut_text(void)
|
||||||
int newsize, cuttingtoend = 0;
|
int newsize, cuttingtoend = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
check_statblank();
|
check_statblank();
|
||||||
if (fileptr == NULL || fileptr->data == NULL)
|
if (fileptr == NULL || fileptr->data == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -172,6 +174,7 @@ int do_cut_text(void)
|
||||||
free_filestruct(cutbuffer);
|
free_filestruct(cutbuffer);
|
||||||
cutbuffer = NULL;
|
cutbuffer = NULL;
|
||||||
|
|
||||||
|
marked_cut = 0;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr, _("Blew away cutbuffer =)\n"));
|
fprintf(stderr, _("Blew away cutbuffer =)\n"));
|
||||||
#endif
|
#endif
|
||||||
|
@ -185,15 +188,22 @@ int do_cut_text(void)
|
||||||
if (ISSET(CUT_TO_END) && !ISSET(MARK_ISSET)) {
|
if (ISSET(CUT_TO_END) && !ISSET(MARK_ISSET)) {
|
||||||
if (current_x == strlen(current->data)) {
|
if (current_x == strlen(current->data)) {
|
||||||
|
|
||||||
/* If the line is empty and we didn't just cut a non-blank
|
/* If the line is empty and we didn't just cut a non-blank
|
||||||
line, create a dummy line and add it to the cutbuffer */
|
line, create a dummy line and add it to the cutbuffer */
|
||||||
if (current_x == 0 && marked_cut != 1) {
|
if (marked_cut != 1) {
|
||||||
|
|
||||||
filestruct *junk;
|
filestruct *junk;
|
||||||
|
|
||||||
junk = copy_node(current);
|
junk = NULL;
|
||||||
|
junk = make_new_node(current);
|
||||||
|
junk->data = nmalloc(1 * sizeof (char));
|
||||||
|
junk->data[0] = 0;
|
||||||
|
|
||||||
add_to_cutbuffer(junk);
|
add_to_cutbuffer(junk);
|
||||||
|
dump_buffer(cutbuffer);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
do_delete();
|
do_delete();
|
||||||
SET(KEEP_CUTBUFFER);
|
SET(KEEP_CUTBUFFER);
|
||||||
marked_cut = 2;
|
marked_cut = 2;
|
||||||
|
@ -339,6 +349,8 @@ int do_uncut_text(void)
|
||||||
current->data = tmpstr;
|
current->data = tmpstr;
|
||||||
current_x += strlen(cutbuffer->data);
|
current_x += strlen(cutbuffer->data);
|
||||||
totsize += strlen(cutbuffer->data);
|
totsize += strlen(cutbuffer->data);
|
||||||
|
if (strlen(cutbuffer->data) == 0)
|
||||||
|
totlines++;
|
||||||
|
|
||||||
placewewant = xplustabs();
|
placewewant = xplustabs();
|
||||||
update_cursor();
|
update_cursor();
|
||||||
|
@ -399,7 +411,7 @@ int do_uncut_text(void)
|
||||||
screw up all the work we just did and separate the line. There
|
screw up all the work we just did and separate the line. There
|
||||||
must be a better way to do this, but not at 1AM on a work night. */
|
must be a better way to do this, but not at 1AM on a work night. */
|
||||||
|
|
||||||
if (marked_cut == 2 && current_x != strlen(current->data)) {
|
if (marked_cut == 2) {
|
||||||
tmp = make_new_node(current);
|
tmp = make_new_node(current);
|
||||||
tmp->data = charalloc(strlen(¤t->data[current_x]) + 1);
|
tmp->data = charalloc(strlen(¤t->data[current_x]) + 1);
|
||||||
strcpy(tmp->data, ¤t->data[current_x]);
|
strcpy(tmp->data, ¤t->data[current_x]);
|
||||||
|
@ -408,6 +420,10 @@ int do_uncut_text(void)
|
||||||
current = current->next;
|
current = current->next;
|
||||||
current_x = 0;
|
current_x = 0;
|
||||||
placewewant = 0;
|
placewewant = 0;
|
||||||
|
|
||||||
|
/* Extra line added, update stuff */
|
||||||
|
totlines++;
|
||||||
|
totsize++;
|
||||||
}
|
}
|
||||||
/* Renumber from BEFORE where we pasted ;) */
|
/* Renumber from BEFORE where we pasted ;) */
|
||||||
renumber(hold);
|
renumber(hold);
|
||||||
|
@ -416,6 +432,7 @@ int do_uncut_text(void)
|
||||||
dump_buffer(cutbuffer);
|
dump_buffer(cutbuffer);
|
||||||
set_modified();
|
set_modified();
|
||||||
edit_refresh();
|
edit_refresh();
|
||||||
|
UNSET(KEEP_CUTBUFFER);
|
||||||
return 0;
|
return 0;
|
||||||
#else
|
#else
|
||||||
if (0) {
|
if (0) {
|
||||||
|
|
Loading…
Reference in New Issue