more fixes for uncutting text/inserting files with the mark on

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4156 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
master
David Lawrence Ramsey 2007-08-16 03:23:30 +00:00
parent b4e5fc100b
commit ee89418102
3 changed files with 21 additions and 5 deletions

View File

@ -4,7 +4,9 @@
ChangeLog.pre-2.1 in EXTRA_DIST, so that "make dist" works ChangeLog.pre-2.1 in EXTRA_DIST, so that "make dist" works
again. again.
* files.c (do_insertfile): Make sure the mark is always properly * files.c (do_insertfile): Make sure the mark is always properly
positioned after inserting a one-line file with the mark on. positioned after inserting a file with the mark on.
* nano.c (copy_from_file): Make sure the mark is always properly
positioned after uncutting multiple lines with the mark on.
2007-08-11 David Lawrence Ramsey <pooka109@gmail.com> 2007-08-11 David Lawrence Ramsey <pooka109@gmail.com>

View File

@ -814,7 +814,10 @@ void do_insertfile(
#ifndef NANO_TINY #ifndef NANO_TINY
if (openfile->mark_set) if (openfile->mark_set)
do_mark_shift = (openfile->current_x <= do_mark_shift = (openfile->current_x <=
openfile->mark_begin_x); openfile->mark_begin_x ||
openfile->current->lineno <=
openfile->mark_begin->lineno);
#endif #endif
#ifdef ENABLE_MULTIBUFFER #ifdef ENABLE_MULTIBUFFER
} }
@ -890,8 +893,12 @@ void do_insertfile(
openfile->current_x; openfile->current_x;
} }
#endif #endif
openfile->current_x += strlen(filepart->top_data); openfile->current_x += current_x_save;
} }
#ifndef NANO_TINY
else if (openfile->mark_set && do_mark_shift)
openfile->mark_begin_x -= current_x_save;
#endif
/* Update the current y-coordinate to account for the /* Update the current y-coordinate to account for the
* number of lines inserted. */ * number of lines inserted. */

View File

@ -393,6 +393,7 @@ void move_to_filestruct(filestruct **file_top, filestruct **file_bot,
void copy_from_filestruct(filestruct *file_top, filestruct *file_bot) void copy_from_filestruct(filestruct *file_top, filestruct *file_bot)
{ {
filestruct *top_save; filestruct *top_save;
size_t current_x_save = openfile->current_x;
bool edittop_inside; bool edittop_inside;
#ifndef NANO_TINY #ifndef NANO_TINY
bool do_mark_shift = FALSE; bool do_mark_shift = FALSE;
@ -409,7 +410,9 @@ void copy_from_filestruct(filestruct *file_top, filestruct *file_bot)
edittop_inside = (openfile->edittop == openfile->fileage); edittop_inside = (openfile->edittop == openfile->fileage);
#ifndef NANO_TINY #ifndef NANO_TINY
if (openfile->mark_set) if (openfile->mark_set)
do_mark_shift = (openfile->current_x <= openfile->mark_begin_x); do_mark_shift = (openfile->current_x <=
openfile->mark_begin_x || openfile->current->lineno <=
openfile->mark_begin->lineno);
#endif #endif
/* Put the top and bottom of the filestruct at copies of file_top /* Put the top and bottom of the filestruct at copies of file_top
@ -432,8 +435,12 @@ void copy_from_filestruct(filestruct *file_top, filestruct *file_bot)
openfile->mark_begin_x += openfile->current_x; openfile->mark_begin_x += openfile->current_x;
} }
#endif #endif
openfile->current_x += strlen(filepart->top_data); openfile->current_x += current_x_save;
} }
#ifndef NANO_TINY
else if (openfile->mark_set && do_mark_shift)
openfile->mark_begin_x -= current_x_save;
#endif
/* Get the number of characters in the copied text, and add it to /* Get the number of characters in the copied text, and add it to
* totsize. */ * totsize. */