tweaks: rename, rewrap, and reshuffle some stuff, and frob some comments

master
Benno Schulenberg 2017-05-12 21:30:51 +02:00 committed by Benno Schulenberg
parent c24e95e3d6
commit d33b5f3dab
5 changed files with 26 additions and 34 deletions

View File

@ -216,7 +216,7 @@ void do_cut_text_void(void)
void do_copy_text(void)
{
static struct filestruct *next_contiguous_line = NULL;
bool mark_set = (openfile->mark != NULL);
bool mark_is_set = (openfile->mark != NULL);
/* Remember the current viewport and cursor position. */
ssize_t is_edittop_lineno = openfile->edittop->lineno;
@ -224,16 +224,16 @@ void do_copy_text(void)
ssize_t is_current_lineno = openfile->current->lineno;
size_t is_current_x = openfile->current_x;
if (mark_set || openfile->current != next_contiguous_line)
if (mark_is_set || openfile->current != next_contiguous_line)
cutbuffer_reset();
do_cut_text(TRUE, FALSE);
/* If the mark was set, blow away the cutbuffer on the next copy. */
next_contiguous_line = (mark_set ? NULL : openfile->current);
next_contiguous_line = (mark_is_set ? NULL : openfile->current);
/* If the mark was set, restore the viewport and cursor position. */
if (mark_set) {
if (mark_is_set) {
openfile->edittop = fsfromline(is_edittop_lineno);
openfile->firstcolumn = is_firstcolumn;
openfile->current = fsfromline(is_current_lineno);

View File

@ -307,14 +307,12 @@ void extract_buffer(filestruct **file_top, filestruct **file_bot,
openfile->edittop->lineno <= openfile->filebot->lineno);
#ifndef NANO_TINY
if (openfile->mark) {
mark_inside = (openfile->mark->lineno >=
openfile->fileage->lineno &&
openfile->mark->lineno <=
openfile->filebot->lineno &&
(openfile->mark != openfile->fileage ||
openfile->mark_x >= top_x) &&
(openfile->mark != openfile->filebot ||
openfile->mark_x <= bot_x));
mark_inside = (openfile->mark->lineno >= openfile->fileage->lineno &&
openfile->mark->lineno <= openfile->filebot->lineno &&
(openfile->mark != openfile->fileage ||
openfile->mark_x >= top_x) &&
(openfile->mark != openfile->filebot ||
openfile->mark_x <= bot_x));
same_line = (openfile->mark == openfile->fileage);
}
#endif

View File

@ -383,13 +383,13 @@ typedef struct openfilestruct {
/* The file's current stat information. */
#ifndef NANO_TINY
filestruct *mark;
/* The file's line where the mark is, if any. */
/* The line in the file where the mark is set; NULL if not set. */
size_t mark_x;
/* The file's mark's x-coordinate position, if any. */
/* The mark's x position in the above line. */
mark_type kind_of_mark;
/* Whether this is a soft or a hard mark. */
/* Whether it is a soft (with Shift) or a hard mark. */
file_format fmt;
/* The file's format. */
/* The file's format -- Unix or DOS or Mac or mixed. */
undo *undotop;
/* The top of the undo list. */
undo *current_undo;

View File

@ -710,7 +710,7 @@ ssize_t do_replace_loop(const char *needle, bool whole_word_only,
openfile->mark = was_mark;
#endif
/* If the NO_NEWLINES flag isn't set, and text has been added to the
/* If "automatic newline" is enabled, and text has been added to the
* magicline, make a new magicline. */
if (!ISSET(NO_NEWLINES) && openfile->filebot->data[0] != '\0')
new_magicline();

View File

@ -57,14 +57,14 @@ static completion_word *list_of_completions;
/* Toggle the mark. */
void do_mark(void)
{
if (openfile->mark == NULL) {
statusbar(_("Mark Set"));
if (!openfile->mark) {
openfile->mark = openfile->current;
openfile->mark_x = openfile->current_x;
statusbar(_("Mark Set"));
openfile->kind_of_mark = HARDMARK;
} else {
statusbar(_("Mark Unset"));
openfile->mark = NULL;
statusbar(_("Mark Unset"));
refresh_needed = TRUE;
}
}
@ -1063,8 +1063,8 @@ void do_enter(void)
add_undo(ENTER);
/* Adjust the mark if it was on the current line after the cursor. */
if (openfile->current == openfile->mark &&
openfile->current_x < openfile->mark_x) {
if (openfile->mark == openfile->current &&
openfile->mark_x > openfile->current_x) {
openfile->mark = newnode;
openfile->mark_x += extra - openfile->current_x;
}
@ -2019,13 +2019,8 @@ void backup_lines(filestruct *first_line, size_t par_len)
ssize_t current_lineno_save = openfile->current->lineno;
#ifndef NANO_TINY
bool mark_is_set = (openfile->mark != NULL);
ssize_t mb_lineno_save = 0;
size_t mark_begin_x_save = 0;
if (mark_is_set) {
mb_lineno_save = openfile->mark->lineno;
mark_begin_x_save = openfile->mark_x;
}
ssize_t was_mark_lineno = (mark_is_set ? openfile->mark->lineno : 0);
size_t was_mark_x = openfile->mark_x;
#endif
/* Move bot down par_len lines to the line after the last line of
@ -2047,9 +2042,9 @@ void backup_lines(filestruct *first_line, size_t par_len)
if (openfile->current != openfile->fileage) {
top = openfile->current->prev;
#ifndef NANO_TINY
if (mark_is_set && openfile->current->lineno == mb_lineno_save) {
if (mark_is_set && openfile->current->lineno == was_mark_lineno) {
openfile->mark = openfile->current;
openfile->mark_x = mark_begin_x_save;
openfile->mark_x = was_mark_x;
}
#endif
} else
@ -2062,9 +2057,9 @@ void backup_lines(filestruct *first_line, size_t par_len)
if (top->lineno == current_lineno_save)
openfile->current = top;
#ifndef NANO_TINY
if (mark_is_set && top->lineno == mb_lineno_save) {
if (mark_is_set && top->lineno == was_mark_lineno) {
openfile->mark = top;
openfile->mark_x = mark_begin_x_save;
openfile->mark_x = was_mark_x;
}
#endif
top = top->prev;
@ -2927,7 +2922,6 @@ const char *do_alt_speller(char *tempfile_name)
mark_order((const filestruct **)&top, &top_x,
(const filestruct **)&bot, &bot_x, &right_side_up);
openfile->mark = NULL;
replace_marked_buffer(tempfile_name, top, top_x, bot, bot_x);