fix marking breakage

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2850 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
master
David Lawrence Ramsey 2005-07-12 17:40:16 +00:00
parent 16349c992a
commit 5128de8308
7 changed files with 116 additions and 117 deletions

View File

@ -134,8 +134,8 @@ void initialize_buffer(void)
openfile->placewewant = 0; openfile->placewewant = 0;
#ifndef NANO_SMALL #ifndef NANO_SMALL
openfile->mark_beginbuf = NULL; openfile->mark_begin = NULL;
openfile->mark_beginx = 0; openfile->mark_begin_x = 0;
#endif #endif
openfile->totlines = 1; openfile->totlines = 1;

View File

@ -320,14 +320,14 @@ void move_to_filestruct(filestruct **file_top, filestruct **file_bot,
at_edittop = (openfile->fileage == openfile->edittop); at_edittop = (openfile->fileage == openfile->edittop);
#ifndef NANO_SMALL #ifndef NANO_SMALL
if (openfile->mark_set) if (openfile->mark_set)
mark_inside = (openfile->mark_beginbuf->lineno >= mark_inside = (openfile->mark_begin->lineno >=
openfile->fileage->lineno && openfile->fileage->lineno &&
openfile->mark_beginbuf->lineno <= openfile->mark_begin->lineno <=
openfile->filebot->lineno && openfile->filebot->lineno &&
(openfile->mark_beginbuf != openfile->fileage || (openfile->mark_begin != openfile->fileage ||
openfile->mark_beginx >= top_x) && openfile->mark_begin_x >= top_x) &&
(openfile->mark_beginbuf != openfile->filebot || (openfile->mark_begin != openfile->filebot ||
openfile->mark_beginx <= bot_x)); openfile->mark_begin_x <= bot_x));
#endif #endif
/* Get the number of characters in the text, and subtract it from /* Get the number of characters in the text, and subtract it from
@ -371,8 +371,8 @@ void move_to_filestruct(filestruct **file_top, filestruct **file_bot,
openfile->edittop = openfile->fileage; openfile->edittop = openfile->fileage;
#ifndef NANO_SMALL #ifndef NANO_SMALL
if (mark_inside) { if (mark_inside) {
openfile->mark_beginbuf = openfile->fileage; openfile->mark_begin = openfile->fileage;
openfile->mark_beginx = top_x; openfile->mark_begin_x = top_x;
} }
#endif #endif
@ -1311,10 +1311,10 @@ void do_delete(void)
null_at(&openfile->current->data, openfile->current_x + null_at(&openfile->current->data, openfile->current_x +
line_len - char_buf_len); line_len - char_buf_len);
#ifndef NANO_SMALL #ifndef NANO_SMALL
if (openfile->mark_set && openfile->current_x < if (openfile->mark_set && openfile->mark_begin ==
openfile->mark_beginx && openfile->mark_beginbuf == openfile->current && openfile->current_x <
openfile->current) openfile->mark_begin_x)
openfile->mark_beginx -= char_buf_len; openfile->mark_begin_x -= char_buf_len;
#endif #endif
openfile->totsize--; openfile->totsize--;
} else if (openfile->current != openfile->filebot && } else if (openfile->current != openfile->filebot &&
@ -1336,10 +1336,10 @@ void do_delete(void)
strcpy(openfile->current->data + openfile->current_x, strcpy(openfile->current->data + openfile->current_x,
foo->data); foo->data);
#ifndef NANO_SMALL #ifndef NANO_SMALL
if (openfile->mark_set && openfile->mark_beginbuf == if (openfile->mark_set && openfile->mark_begin ==
openfile->current->next) { openfile->current->next) {
openfile->mark_beginx += openfile->current_x; openfile->mark_begin = openfile->current;
openfile->mark_beginbuf = openfile->current; openfile->mark_begin_x += openfile->current_x;
} }
#endif #endif
if (openfile->filebot == foo) if (openfile->filebot == foo)
@ -1431,10 +1431,10 @@ void do_enter(void)
null_at(&openfile->current->data, openfile->current_x); null_at(&openfile->current->data, openfile->current_x);
#ifndef NANO_SMALL #ifndef NANO_SMALL
if (openfile->mark_set && openfile->current == if (openfile->mark_set && openfile->current ==
openfile->mark_beginbuf && openfile->current_x < openfile->mark_begin && openfile->current_x <
openfile->mark_beginx) { openfile->mark_begin_x) {
openfile->mark_beginbuf = newnode; openfile->mark_begin = newnode;
openfile->mark_beginx += extra - openfile->current_x; openfile->mark_begin_x += extra - openfile->current_x;
} }
#endif #endif
openfile->current_x = extra; openfile->current_x = extra;
@ -1747,15 +1747,15 @@ void do_word_count(void)
void do_mark(void) void do_mark(void)
{ {
openfile->mark_set = openfile->mark_set ? FALSE : TRUE; openfile->mark_set = !openfile->mark_set;
if (openfile->mark_set) { if (openfile->mark_set) {
statusbar(_("Mark Set")); statusbar(_("Mark Set"));
openfile->mark_beginbuf = openfile->current; openfile->mark_begin = openfile->current;
openfile->mark_beginx = openfile->current_x; openfile->mark_begin_x = openfile->current_x;
} else { } else {
statusbar(_("Mark UNset")); statusbar(_("Mark UNset"));
openfile->mark_beginbuf = NULL; openfile->mark_begin = NULL;
openfile->mark_beginx = 0; openfile->mark_begin_x = 0;
edit_refresh(); edit_refresh();
} }
} }
@ -1969,12 +1969,14 @@ bool do_wrap(filestruct *line)
/* If the mark was on this line after the wrap point, we move it /* If the mark was on this line after the wrap point, we move it
* down. If it was on the next line and we wrapped onto that line, * down. If it was on the next line and we wrapped onto that line,
* we move it right. */ * we move it right. */
if (openfile->mark_set && openfile->mark_beginbuf == line && if (openfile->mark_set) {
openfile->mark_beginx > wrap_loc) { if (openfile->mark_begin == line && openfile->mark_begin_x >
openfile->mark_beginbuf = line->next; wrap_loc) {
openfile->mark_beginx -= wrap_loc - indent_len + 1; openfile->mark_begin = line->next;
} else if (wrapping && openfile->mark_beginbuf == line->next) openfile->mark_begin_x -= wrap_loc - indent_len + 1;
openfile->mark_beginx += after_break_len; } else if (wrapping && openfile->mark_begin == line->next)
openfile->mark_begin_x += after_break_len;
}
#endif #endif
return TRUE; return TRUE;
@ -2006,7 +2008,7 @@ bool do_int_spell_fix(const char *word)
bool added_magicline = FALSE; bool added_magicline = FALSE;
/* Whether we added a magicline after filebot. */ /* Whether we added a magicline after filebot. */
bool right_side_up = FALSE; bool right_side_up = FALSE;
/* TRUE if (mark_beginbuf, mark_beginx) is the top of the mark, /* TRUE if (mark_begin, mark_begin_x) is the top of the mark,
* FALSE if (current, current_x) is. */ * FALSE if (current, current_x) is. */
filestruct *top, *bot; filestruct *top, *bot;
size_t top_x, bot_x; size_t top_x, bot_x;
@ -2101,11 +2103,11 @@ bool do_int_spell_fix(const char *word)
if (openfile->fileage == openfile->filebot) if (openfile->fileage == openfile->filebot)
bot_x += top_x; bot_x += top_x;
if (right_side_up) { if (right_side_up) {
openfile->mark_beginx = top_x; openfile->mark_begin_x = top_x;
current_x_save = bot_x; current_x_save = bot_x;
} else { } else {
current_x_save = top_x; current_x_save = top_x;
openfile->mark_beginx = bot_x; openfile->mark_begin_x = bot_x;
} }
/* Unpartition the filestruct so that it contains all the text /* Unpartition the filestruct so that it contains all the text
@ -2347,15 +2349,15 @@ const char *do_alt_speller(char *tempfile_name)
bool added_magicline = FALSE; bool added_magicline = FALSE;
/* Whether we added a magicline after filebot. */ /* Whether we added a magicline after filebot. */
bool right_side_up = FALSE; bool right_side_up = FALSE;
/* TRUE if (mark_beginbuf, mark_beginx) is the top of the mark, /* TRUE if (mark_begin, mark_begin_x) is the top of the mark,
* FALSE if (current, current_x) is. */ * FALSE if (current, current_x) is. */
filestruct *top, *bot; filestruct *top, *bot;
size_t top_x, bot_x; size_t top_x, bot_x;
ssize_t mbb_lineno_save = 0; ssize_t mb_lineno_save = 0;
/* We're going to close the current file, and open the output of /* We're going to close the current file, and open the output of
* the alternate spell command. The line that mark_beginbuf * the alternate spell command. The line that mark_begin points
* points to will be freed, so we save the line number and * to will be freed, so we save the line number and restore it
* restore afterwards. */ * afterwards. */
size_t totsize_save = openfile->totsize; size_t totsize_save = openfile->totsize;
/* Our saved value of totsize, used when we spell-check a marked /* Our saved value of totsize, used when we spell-check a marked
* selection. */ * selection. */
@ -2363,7 +2365,7 @@ const char *do_alt_speller(char *tempfile_name)
if (old_mark_set) { if (old_mark_set) {
/* If the mark is on, save the number of the line it starts on, /* If the mark is on, save the number of the line it starts on,
* and then turn the mark off. */ * and then turn the mark off. */
mbb_lineno_save = openfile->mark_beginbuf->lineno; mb_lineno_save = openfile->mark_begin->lineno;
openfile->mark_set = FALSE; openfile->mark_set = FALSE;
} }
#endif #endif
@ -2479,11 +2481,11 @@ const char *do_alt_speller(char *tempfile_name)
if (openfile->fileage == openfile->filebot) if (openfile->fileage == openfile->filebot)
bot_x += top_x; bot_x += top_x;
if (right_side_up) { if (right_side_up) {
openfile->mark_beginx = top_x; openfile->mark_begin_x = top_x;
current_x_save = bot_x; current_x_save = bot_x;
} else { } else {
current_x_save = top_x; current_x_save = top_x;
openfile->mark_beginx = bot_x; openfile->mark_begin_x = bot_x;
} }
/* Unpartition the filestruct so that it contains all the text /* Unpartition the filestruct so that it contains all the text
@ -2502,16 +2504,15 @@ const char *do_alt_speller(char *tempfile_name)
totsize_save += openfile->totsize; totsize_save += openfile->totsize;
openfile->totsize = totsize_save; openfile->totsize = totsize_save;
/* Assign mark_beginbuf to the line where the mark began /* Assign mark_begin to the line where the mark began before. */
* before. */ do_gotopos(mb_lineno_save, openfile->mark_begin_x,
do_gotopos(mbb_lineno_save, openfile->mark_beginx,
current_y_save, 0); current_y_save, 0);
openfile->mark_beginbuf = openfile->current; openfile->mark_begin = openfile->current;
/* Assign mark_beginx to the location in mark_beginbuf where the /* Assign mark_begin_x to the location in mark_begin where the
* mark began before, adjusted for any shortening of the * mark began before, adjusted for any shortening of the
* line. */ * line. */
openfile->mark_beginx = openfile->current_x; openfile->mark_begin_x = openfile->current_x;
/* Turn the mark back on. */ /* Turn the mark back on. */
openfile->mark_set = TRUE; openfile->mark_set = TRUE;
@ -2722,8 +2723,8 @@ void justify_format(filestruct *paragraph, size_t skip)
#ifndef NANO_SMALL #ifndef NANO_SMALL
/* Keep track of the change in the current line. */ /* Keep track of the change in the current line. */
if (openfile->mark_set && openfile->mark_beginbuf == if (openfile->mark_set && openfile->mark_begin ==
paragraph && openfile->mark_beginx >= end - paragraph && openfile->mark_begin_x >= end -
paragraph->data) paragraph->data)
mark_shift += end_len; mark_shift += end_len;
#endif #endif
@ -2777,8 +2778,8 @@ void justify_format(filestruct *paragraph, size_t skip)
#ifndef NANO_SMALL #ifndef NANO_SMALL
/* Keep track of the change in the current line. */ /* Keep track of the change in the current line. */
if (openfile->mark_set && openfile->mark_beginbuf == if (openfile->mark_set && openfile->mark_begin ==
paragraph && openfile->mark_beginx >= end - paragraph && openfile->mark_begin_x >= end -
paragraph->data) paragraph->data)
mark_shift += end_len; mark_shift += end_len;
#endif #endif
@ -2817,11 +2818,10 @@ void justify_format(filestruct *paragraph, size_t skip)
#ifndef NANO_SMALL #ifndef NANO_SMALL
/* Adjust the mark coordinates to compensate for the change in /* Adjust the mark coordinates to compensate for the change in
* the current line. */ * the current line. */
if (openfile->mark_set && openfile->mark_beginbuf == if (openfile->mark_set && openfile->mark_begin == paragraph) {
paragraph) { openfile->mark_begin_x -= mark_shift;
openfile->mark_beginx -= mark_shift; if (openfile->mark_begin_x > new_end - new_paragraph_data)
if (openfile->mark_beginx > new_end - new_paragraph_data) openfile->mark_begin_x = new_end - new_paragraph_data;
openfile->mark_beginx = new_end - new_paragraph_data;
} }
#endif #endif
} else } else
@ -3031,12 +3031,12 @@ filestruct *backup_lines(filestruct *first_line, size_t par_len, size_t
ssize_t current_lineno_save = openfile->current->lineno; ssize_t current_lineno_save = openfile->current->lineno;
#ifndef NANO_SMALL #ifndef NANO_SMALL
bool old_mark_set = openfile->mark_set; bool old_mark_set = openfile->mark_set;
ssize_t mbb_lineno_save = 0; ssize_t mb_lineno_save = 0;
size_t mark_beginx_save = 0; size_t mark_begin_x_save = 0;
if (old_mark_set) { if (old_mark_set) {
mbb_lineno_save = openfile->mark_beginbuf->lineno; mb_lineno_save = openfile->mark_begin->lineno;
mark_beginx_save = openfile->mark_beginx; mark_begin_x_save = openfile->mark_begin_x;
} }
#endif #endif
@ -3054,9 +3054,9 @@ filestruct *backup_lines(filestruct *first_line, size_t par_len, size_t
copy_from_filestruct(jusbuffer, jusbottom); copy_from_filestruct(jusbuffer, jusbottom);
/* Move upward from the last line of the paragraph to the first /* Move upward from the last line of the paragraph to the first
* line, putting first_line, edittop, current, and mark_beginbuf at * line, putting first_line, edittop, current, and mark_begin at the
* the same lines in the copied paragraph that they had in the * same lines in the copied paragraph that they had in the original
* original paragraph. */ * paragraph. */
top = openfile->current->prev; top = openfile->current->prev;
for (i = par_len; i > 0; i--) { for (i = par_len; i > 0; i--) {
if (top->lineno == fl_lineno_save) if (top->lineno == fl_lineno_save)
@ -3066,9 +3066,9 @@ filestruct *backup_lines(filestruct *first_line, size_t par_len, size_t
if (top->lineno == current_lineno_save) if (top->lineno == current_lineno_save)
openfile->current = top; openfile->current = top;
#ifndef NANO_SMALL #ifndef NANO_SMALL
if (old_mark_set && top->lineno == mbb_lineno_save) { if (old_mark_set && top->lineno == mb_lineno_save) {
openfile->mark_beginbuf = top; openfile->mark_begin = top;
openfile->mark_beginx = mark_beginx_save; openfile->mark_begin_x = mark_begin_x_save;
} }
#endif #endif
top = top->prev; top = top->prev;
@ -3179,8 +3179,8 @@ void do_justify(bool full_justify)
filestruct *edittop_save = openfile->edittop; filestruct *edittop_save = openfile->edittop;
filestruct *current_save = openfile->current; filestruct *current_save = openfile->current;
#ifndef NANO_SMALL #ifndef NANO_SMALL
filestruct *mark_beginbuf_save = openfile->mark_beginbuf; filestruct *mark_begin_save = openfile->mark_begin;
size_t mark_beginx_save = openfile->mark_beginx; size_t mark_begin_x_save = openfile->mark_begin_x;
#endif #endif
int kbinput; int kbinput;
bool meta_key, func_key, s_or_t, ran_func, finished; bool meta_key, func_key, s_or_t, ran_func, finished;
@ -3318,10 +3318,10 @@ void do_justify(bool full_justify)
#ifndef NANO_SMALL #ifndef NANO_SMALL
/* Adjust the mark coordinates to compensate for the change /* Adjust the mark coordinates to compensate for the change
* in the next line. */ * in the next line. */
if (openfile->mark_set && openfile->mark_beginbuf == if (openfile->mark_set && openfile->mark_begin ==
next_line) { next_line) {
openfile->mark_beginbuf = openfile->current; openfile->mark_begin = openfile->current;
openfile->mark_beginx += line_len - indent_len; openfile->mark_begin_x += line_len - indent_len;
} }
#endif #endif
@ -3398,11 +3398,11 @@ void do_justify(bool full_justify)
#ifndef NANO_SMALL #ifndef NANO_SMALL
/* Adjust the mark coordinates to compensate for the change /* Adjust the mark coordinates to compensate for the change
* in the current line. */ * in the current line. */
if (openfile->mark_set && openfile->mark_beginbuf == if (openfile->mark_set && openfile->mark_begin ==
openfile->current && openfile->mark_beginx > openfile->current && openfile->mark_begin_x >
break_pos) { break_pos) {
openfile->mark_beginbuf = openfile->current->next; openfile->mark_begin = openfile->current->next;
openfile->mark_beginx -= break_pos - indent_len; openfile->mark_begin_x -= break_pos - indent_len;
} }
#endif #endif
@ -3504,8 +3504,8 @@ void do_justify(bool full_justify)
openfile->totlines = openfile->filebot->lineno; openfile->totlines = openfile->filebot->lineno;
#ifndef NANO_SMALL #ifndef NANO_SMALL
if (openfile->mark_set) { if (openfile->mark_set) {
openfile->mark_beginbuf = mark_beginbuf_save; openfile->mark_begin = mark_begin_save;
openfile->mark_beginx = mark_beginx_save; openfile->mark_begin_x = mark_begin_x_save;
} }
#endif #endif
openfile->modified = modified_save; openfile->modified = modified_save;
@ -4137,9 +4137,9 @@ void do_output(char *output, size_t output_len, bool allow_cntrls)
#ifndef NANO_SMALL #ifndef NANO_SMALL
/* Note that current_x has not yet been incremented. */ /* Note that current_x has not yet been incremented. */
if (openfile->mark_set && openfile->current == if (openfile->mark_set && openfile->current ==
openfile->mark_beginbuf && openfile->current_x < openfile->mark_begin && openfile->current_x <
openfile->mark_beginx) openfile->mark_begin_x)
openfile->mark_beginx += char_buf_len; openfile->mark_begin_x += char_buf_len;
#endif #endif
do_right(FALSE); do_right(FALSE);

View File

@ -172,10 +172,9 @@ typedef struct openfilestruct {
* position. */ * position. */
size_t placewewant; /* Current file's place we want. */ size_t placewewant; /* Current file's place we want. */
#ifndef NANO_SMALL #ifndef NANO_SMALL
filestruct *mark_beginbuf; filestruct *mark_begin; /* Current file's beginning marked
/* Current file's beginning marked
* line. */ * line. */
size_t mark_beginx; /* Current file's beginning marked size_t mark_begin_x; /* Current file's beginning marked
* line's x-coordinate position. */ * line's x-coordinate position. */
#endif #endif
size_t totlines; /* Current file's total number of size_t totlines; /* Current file's total number of

View File

@ -486,7 +486,7 @@ void search_init_globals(void);
int search_init(bool replacing, bool use_answer); int search_init(bool replacing, bool use_answer);
bool is_whole_word(size_t pos, const char *buf, const char *word); bool is_whole_word(size_t pos, const char *buf, const char *word);
bool findnextstr(bool can_display_wrap, bool wholeword, bool bool findnextstr(bool can_display_wrap, bool wholeword, bool
no_sameline, const filestruct *begin, size_t beginx, const char no_sameline, const filestruct *begin, size_t begin_x, const char
*needle, size_t *needle_len); *needle, size_t *needle_len);
void findnextstr_wrap_reset(void); void findnextstr_wrap_reset(void);
void do_search(void); void do_search(void);

View File

@ -281,13 +281,13 @@ bool is_whole_word(size_t pos, const char *buf, const char *word)
/* Look for needle, starting at (current, current_x). If no_sameline is /* Look for needle, starting at (current, current_x). If no_sameline is
* TRUE, skip over begin when looking for needle. begin is the line * TRUE, skip over begin when looking for needle. begin is the line
* where we first started searching, at column beginx. If * where we first started searching, at column begin_x. If
* can_display_wrap is TRUE, we put messages on the statusbar, wrap * can_display_wrap is TRUE, we put messages on the statusbar, wrap
* around the file boundaries. The return value specifies whether we * around the file boundaries. The return value specifies whether we
* found anything. If we did, set needle_len to the length of the * found anything. If we did, set needle_len to the length of the
* string we found if it isn't NULL. */ * string we found if it isn't NULL. */
bool findnextstr(bool can_display_wrap, bool wholeword, bool bool findnextstr(bool can_display_wrap, bool wholeword, bool
no_sameline, const filestruct *begin, size_t beginx, const char no_sameline, const filestruct *begin, size_t begin_x, const char
*needle, size_t *needle_len) *needle, size_t *needle_len)
{ {
filestruct *fileptr = openfile->current; filestruct *fileptr = openfile->current;
@ -404,10 +404,10 @@ bool findnextstr(bool can_display_wrap, bool wholeword, bool
/* Ensure we haven't wrapped around again! */ /* Ensure we haven't wrapped around again! */
if (search_last_line && if (search_last_line &&
#ifndef NANO_SMALL #ifndef NANO_SMALL
((!ISSET(BACKWARDS_SEARCH) && current_x_find > beginx) || ((!ISSET(BACKWARDS_SEARCH) && current_x_find > begin_x) ||
(ISSET(BACKWARDS_SEARCH) && current_x_find < beginx)) (ISSET(BACKWARDS_SEARCH) && current_x_find < begin_x))
#else #else
current_x_find > beginx current_x_find > begin_x
#endif #endif
) { ) {
if (can_display_wrap) if (can_display_wrap)
@ -691,7 +691,7 @@ ssize_t do_replace_loop(const char *needle, const filestruct
filestruct *edittop_save = openfile->edittop, *top, *bot; filestruct *edittop_save = openfile->edittop, *top, *bot;
size_t top_x, bot_x; size_t top_x, bot_x;
bool right_side_up = FALSE; bool right_side_up = FALSE;
/* TRUE if (mark_beginbuf, mark_beginx) is the top of the mark, /* TRUE if (mark_begin, mark_begin_x) is the top of the mark,
* FALSE if (current, current_x) is. */ * FALSE if (current, current_x) is. */
if (old_mark_set) { if (old_mark_set) {
@ -795,17 +795,17 @@ ssize_t do_replace_loop(const char *needle, const filestruct
strlen(openfile->current->data); strlen(openfile->current->data);
#ifndef NANO_SMALL #ifndef NANO_SMALL
/* If the mark was on and (mark_beginbuf, mark_begin_x) was /* If the mark was on and (mark_begin, mark_begin_x) was the
* the top of it, don't change mark_beginx. */ * top of it, don't change mark_begin_x. */
if (!old_mark_set || !right_side_up) { if (!old_mark_set || !right_side_up) {
/* Keep mark_beginx in sync with the text changes. */ /* Keep mark_begin_x in sync with the text changes. */
if (openfile->current == openfile->mark_beginbuf && if (openfile->current == openfile->mark_begin &&
openfile->mark_beginx > openfile->current_x) { openfile->mark_begin_x > openfile->current_x) {
if (openfile->mark_beginx < openfile->current_x + if (openfile->mark_begin_x < openfile->current_x +
match_len) match_len)
openfile->mark_beginx = openfile->current_x; openfile->mark_begin_x = openfile->current_x;
else else
openfile->mark_beginx += length_change; openfile->mark_begin_x += length_change;
} }
} }
@ -878,7 +878,7 @@ void do_replace(void)
{ {
int i; int i;
filestruct *edittop_save, *begin; filestruct *edittop_save, *begin;
size_t beginx, pww_save; size_t begin_x, pww_save;
ssize_t numreplaced; ssize_t numreplaced;
if (ISSET(VIEW_MODE)) { if (ISSET(VIEW_MODE)) {
@ -941,16 +941,16 @@ void do_replace(void)
/* Save where we are. */ /* Save where we are. */
edittop_save = openfile->edittop; edittop_save = openfile->edittop;
begin = openfile->current; begin = openfile->current;
beginx = openfile->current_x; begin_x = openfile->current_x;
pww_save = openfile->placewewant; pww_save = openfile->placewewant;
numreplaced = do_replace_loop(last_search, begin, &beginx, FALSE, numreplaced = do_replace_loop(last_search, begin, &begin_x, FALSE,
NULL); NULL);
/* Restore where we were. */ /* Restore where we were. */
openfile->edittop = edittop_save; openfile->edittop = edittop_save;
openfile->current = begin; openfile->current = begin;
openfile->current_x = beginx; openfile->current_x = begin_x;
openfile->placewewant = pww_save; openfile->placewewant = pww_save;
renumber(openfile->fileage); renumber(openfile->fileage);

View File

@ -403,25 +403,25 @@ void remove_magicline(void)
/* Set top_x and bot_x to the top and bottom x-coordinates of the mark, /* Set top_x and bot_x to the top and bottom x-coordinates of the mark,
* respectively, based on the locations of top and bot. If * respectively, based on the locations of top and bot. If
* right_side_up isn't NULL, set it to TRUE If the mark begins with * right_side_up isn't NULL, set it to TRUE If the mark begins with
* (mark_beginbuf, mark_beginx) and ends with (current, current_x), or * (mark_begin, mark_begin_x) and ends with (current, current_x), or
* FALSE otherwise. */ * FALSE otherwise. */
void mark_order(const filestruct **top, size_t *top_x, const filestruct void mark_order(const filestruct **top, size_t *top_x, const filestruct
**bot, size_t *bot_x, bool *right_side_up) **bot, size_t *bot_x, bool *right_side_up)
{ {
assert(top != NULL && top_x != NULL && bot != NULL && bot_x != NULL); assert(top != NULL && top_x != NULL && bot != NULL && bot_x != NULL);
if ((openfile->current->lineno == openfile->mark_beginbuf->lineno && if ((openfile->current->lineno == openfile->mark_begin->lineno &&
openfile->current_x > openfile->mark_beginx) || openfile->current_x > openfile->mark_begin_x) ||
openfile->current->lineno > openfile->mark_beginbuf->lineno) { openfile->current->lineno > openfile->mark_begin->lineno) {
*top = openfile->mark_beginbuf; *top = openfile->mark_begin;
*top_x = openfile->mark_beginx; *top_x = openfile->mark_begin_x;
*bot = openfile->current; *bot = openfile->current;
*bot_x = openfile->current_x; *bot_x = openfile->current_x;
if (right_side_up != NULL) if (right_side_up != NULL)
*right_side_up = TRUE; *right_side_up = TRUE;
} else { } else {
*bot = openfile->mark_beginbuf; *bot = openfile->mark_begin;
*bot_x = openfile->mark_beginx; *bot_x = openfile->mark_begin_x;
*top = openfile->current; *top = openfile->current;
*top_x = openfile->current_x; *top_x = openfile->current_x;
if (right_side_up != NULL) if (right_side_up != NULL)

View File

@ -3354,19 +3354,19 @@ void edit_add(const filestruct *fileptr, const char *converted, int
#ifndef NANO_SMALL #ifndef NANO_SMALL
if (openfile->mark_set && (fileptr->lineno <= if (openfile->mark_set && (fileptr->lineno <=
openfile->mark_beginbuf->lineno || fileptr->lineno <= openfile->mark_begin->lineno || fileptr->lineno <=
openfile->current->lineno) && (fileptr->lineno >= openfile->current->lineno) && (fileptr->lineno >=
openfile->mark_beginbuf->lineno || fileptr->lineno >= openfile->mark_begin->lineno || fileptr->lineno >=
openfile->current->lineno)) { openfile->current->lineno)) {
/* fileptr is at least partially selected. */ /* fileptr is at least partially selected. */
const filestruct *top; const filestruct *top;
/* Either current or mark_beginbuf, whichever is first. */ /* Either current or mark_begin, whichever is first. */
size_t top_x; size_t top_x;
/* current_x or mark_beginx, corresponding to top. */ /* current_x or mark_begin_x, corresponding to top. */
const filestruct *bot; const filestruct *bot;
size_t bot_x; size_t bot_x;
int x_start; int x_start;
/* Starting column for mvwaddnstr. Zero-based. */ /* Starting column for mvwaddnstr(). Zero-based. */
int paintlen; int paintlen;
/* Number of chars to paint on this line. There are COLS /* Number of chars to paint on this line. There are COLS
* characters on a whole line. */ * characters on a whole line. */