1
1

properly handle more cases of inserting a file/uncutting text with the

mark on


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4158 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
Этот коммит содержится в:
David Lawrence Ramsey 2007-08-16 14:45:17 +00:00
родитель 1b2e77e4ff
Коммит 64b8f423b2
3 изменённых файлов: 65 добавлений и 30 удалений

Просмотреть файл

@ -1,3 +1,10 @@
2007-08-16 David Lawrence Ramsey <pooka109@gmail.com>
* files.c (do_insertfile): Properly handle more cases of
inserting a file with the mark on.
* nano.c (copy_from_file): Properly handle more cases of
uncutting text with the mark on.
2007-08-15 David Lawrence Ramsey <pooka109@gmail.com> 2007-08-15 David Lawrence Ramsey <pooka109@gmail.com>
* Makefile.am: Remove erroneous backslash after * Makefile.am: Remove erroneous backslash after

Просмотреть файл

@ -697,7 +697,7 @@ void do_insertfile(
ssize_t current_y_save = openfile->current_y; ssize_t current_y_save = openfile->current_y;
bool edittop_inside = FALSE; bool edittop_inside = FALSE;
#ifndef NANO_TINY #ifndef NANO_TINY
bool do_mark_shift = FALSE; bool right_side_up = FALSE, single_line = FALSE;
#endif #endif
while (TRUE) { while (TRUE) {
@ -797,28 +797,34 @@ void do_insertfile(
) )
continue; continue;
#ifndef NANO_TINY
/* Keep track of whether the mark begins inside the
* partition and will need adjustment. */
if (openfile->mark_set) {
filestruct *top, *bot;
size_t top_x, bot_x;
mark_order((const filestruct **)&top, &top_x,
(const filestruct **)&bot, &bot_x,
&right_side_up);
single_line = (top == bot);
}
#endif
#ifdef ENABLE_MULTIBUFFER #ifdef ENABLE_MULTIBUFFER
if (!ISSET(MULTIBUFFER)) { if (!ISSET(MULTIBUFFER)) {
#endif #endif
/* If we're not inserting into a new buffer, partition /* If we're not inserting into a new buffer, partition
* the filestruct so that it contains no text and hence * the filestruct so that it contains no text and hence
* looks like a new buffer, keep track of whether the * looks like a new buffer, and keep track of whether
* top of the edit window is inside the partition, and * the top of the edit window is inside the
* keep track of whether the mark begins inside the * partition. */
* partition and will need adjustment. */
filepart = partition_filestruct(openfile->current, filepart = partition_filestruct(openfile->current,
openfile->current_x, openfile->current, openfile->current_x, openfile->current,
openfile->current_x); openfile->current_x);
edittop_inside = edittop_inside =
(openfile->edittop == openfile->fileage); (openfile->edittop == openfile->fileage);
#ifndef NANO_TINY
if (openfile->mark_set)
do_mark_shift = (openfile->current_x <=
openfile->mark_begin_x ||
openfile->current->lineno <=
openfile->mark_begin->lineno);
#endif
#ifdef ENABLE_MULTIBUFFER #ifdef ENABLE_MULTIBUFFER
} }
#endif #endif
@ -888,7 +894,7 @@ void do_insertfile(
#ifndef NANO_TINY #ifndef NANO_TINY
if (openfile->mark_set) { if (openfile->mark_set) {
openfile->mark_begin = openfile->current; openfile->mark_begin = openfile->current;
if (do_mark_shift) if (!right_side_up)
openfile->mark_begin_x += openfile->mark_begin_x +=
openfile->current_x; openfile->current_x;
} }
@ -896,8 +902,16 @@ void do_insertfile(
openfile->current_x += current_x_save; openfile->current_x += current_x_save;
} }
#ifndef NANO_TINY #ifndef NANO_TINY
else if (openfile->mark_set && do_mark_shift) else if (openfile->mark_set) {
openfile->mark_begin_x -= openfile->current_x; if (!right_side_up) {
if (single_line) {
openfile->mark_begin = openfile->current;
openfile->mark_begin_x -= current_x_save;
} else
openfile->mark_begin_x -=
openfile->current_x;
}
}
#endif #endif
/* Update the current y-coordinate to account for the /* Update the current y-coordinate to account for the

Просмотреть файл

@ -396,24 +396,31 @@ void copy_from_filestruct(filestruct *file_top, filestruct *file_bot)
size_t current_x_save = openfile->current_x; 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 right_side_up = FALSE, single_line = FALSE;
#endif #endif
assert(file_top != NULL && file_bot != NULL); assert(file_top != NULL && file_bot != NULL);
/* Partition the filestruct so that it contains no text, keep track #ifndef NANO_TINY
* of whether the top of the edit window is inside the partition, /* Keep track of whether the mark begins inside the partition and
* and keep track of whether the mark begins inside the partition * will need adjustment. */
* and will need adjustment. */ if (openfile->mark_set) {
filestruct *top, *bot;
size_t top_x, bot_x;
mark_order((const filestruct **)&top, &top_x,
(const filestruct **)&bot, &bot_x, &right_side_up);
single_line = (top == bot);
}
#endif
/* Partition the filestruct so that it contains no text, and keep
* track of whether the top of the edit window is inside the
* partition. */
filepart = partition_filestruct(openfile->current, filepart = partition_filestruct(openfile->current,
openfile->current_x, openfile->current, openfile->current_x); openfile->current_x, openfile->current, openfile->current_x);
edittop_inside = (openfile->edittop == openfile->fileage); edittop_inside = (openfile->edittop == openfile->fileage);
#ifndef NANO_TINY
if (openfile->mark_set)
do_mark_shift = (openfile->current_x <=
openfile->mark_begin_x || openfile->current->lineno <=
openfile->mark_begin->lineno);
#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
* and file_bot. */ * and file_bot. */
@ -431,15 +438,22 @@ void copy_from_filestruct(filestruct *file_top, filestruct *file_bot)
#ifndef NANO_TINY #ifndef NANO_TINY
if (openfile->mark_set) { if (openfile->mark_set) {
openfile->mark_begin = openfile->current; openfile->mark_begin = openfile->current;
if (do_mark_shift) if (!right_side_up)
openfile->mark_begin_x += openfile->current_x; openfile->mark_begin_x += openfile->current_x;
} }
#endif #endif
openfile->current_x += current_x_save; openfile->current_x += current_x_save;
} }
#ifndef NANO_TINY #ifndef NANO_TINY
else if (openfile->mark_set && do_mark_shift) else if (openfile->mark_set) {
openfile->mark_begin_x -= openfile->current_x; if (!right_side_up) {
if (single_line) {
openfile->mark_begin = openfile->current;
openfile->mark_begin_x -= current_x_save;
} else
openfile->mark_begin_x -= openfile->current_x;
}
}
#endif #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