tweaks: rename, rewrap, and reshuffle some stuff, and frob some comments
Этот коммит содержится в:
родитель
c24e95e3d6
Коммит
d33b5f3dab
@ -216,7 +216,7 @@ void do_cut_text_void(void)
|
|||||||
void do_copy_text(void)
|
void do_copy_text(void)
|
||||||
{
|
{
|
||||||
static struct filestruct *next_contiguous_line = NULL;
|
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. */
|
/* Remember the current viewport and cursor position. */
|
||||||
ssize_t is_edittop_lineno = openfile->edittop->lineno;
|
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;
|
ssize_t is_current_lineno = openfile->current->lineno;
|
||||||
size_t is_current_x = openfile->current_x;
|
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();
|
cutbuffer_reset();
|
||||||
|
|
||||||
do_cut_text(TRUE, FALSE);
|
do_cut_text(TRUE, FALSE);
|
||||||
|
|
||||||
/* If the mark was set, blow away the cutbuffer on the next copy. */
|
/* 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 the mark was set, restore the viewport and cursor position. */
|
||||||
if (mark_set) {
|
if (mark_is_set) {
|
||||||
openfile->edittop = fsfromline(is_edittop_lineno);
|
openfile->edittop = fsfromline(is_edittop_lineno);
|
||||||
openfile->firstcolumn = is_firstcolumn;
|
openfile->firstcolumn = is_firstcolumn;
|
||||||
openfile->current = fsfromline(is_current_lineno);
|
openfile->current = fsfromline(is_current_lineno);
|
||||||
|
14
src/nano.c
14
src/nano.c
@ -307,14 +307,12 @@ void extract_buffer(filestruct **file_top, filestruct **file_bot,
|
|||||||
openfile->edittop->lineno <= openfile->filebot->lineno);
|
openfile->edittop->lineno <= openfile->filebot->lineno);
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
if (openfile->mark) {
|
if (openfile->mark) {
|
||||||
mark_inside = (openfile->mark->lineno >=
|
mark_inside = (openfile->mark->lineno >= openfile->fileage->lineno &&
|
||||||
openfile->fileage->lineno &&
|
openfile->mark->lineno <= openfile->filebot->lineno &&
|
||||||
openfile->mark->lineno <=
|
(openfile->mark != openfile->fileage ||
|
||||||
openfile->filebot->lineno &&
|
openfile->mark_x >= top_x) &&
|
||||||
(openfile->mark != openfile->fileage ||
|
(openfile->mark != openfile->filebot ||
|
||||||
openfile->mark_x >= top_x) &&
|
openfile->mark_x <= bot_x));
|
||||||
(openfile->mark != openfile->filebot ||
|
|
||||||
openfile->mark_x <= bot_x));
|
|
||||||
same_line = (openfile->mark == openfile->fileage);
|
same_line = (openfile->mark == openfile->fileage);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -383,13 +383,13 @@ typedef struct openfilestruct {
|
|||||||
/* The file's current stat information. */
|
/* The file's current stat information. */
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
filestruct *mark;
|
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;
|
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;
|
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;
|
file_format fmt;
|
||||||
/* The file's format. */
|
/* The file's format -- Unix or DOS or Mac or mixed. */
|
||||||
undo *undotop;
|
undo *undotop;
|
||||||
/* The top of the undo list. */
|
/* The top of the undo list. */
|
||||||
undo *current_undo;
|
undo *current_undo;
|
||||||
|
@ -710,7 +710,7 @@ ssize_t do_replace_loop(const char *needle, bool whole_word_only,
|
|||||||
openfile->mark = was_mark;
|
openfile->mark = was_mark;
|
||||||
#endif
|
#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. */
|
* magicline, make a new magicline. */
|
||||||
if (!ISSET(NO_NEWLINES) && openfile->filebot->data[0] != '\0')
|
if (!ISSET(NO_NEWLINES) && openfile->filebot->data[0] != '\0')
|
||||||
new_magicline();
|
new_magicline();
|
||||||
|
28
src/text.c
28
src/text.c
@ -57,14 +57,14 @@ static completion_word *list_of_completions;
|
|||||||
/* Toggle the mark. */
|
/* Toggle the mark. */
|
||||||
void do_mark(void)
|
void do_mark(void)
|
||||||
{
|
{
|
||||||
if (openfile->mark == NULL) {
|
if (!openfile->mark) {
|
||||||
statusbar(_("Mark Set"));
|
|
||||||
openfile->mark = openfile->current;
|
openfile->mark = openfile->current;
|
||||||
openfile->mark_x = openfile->current_x;
|
openfile->mark_x = openfile->current_x;
|
||||||
|
statusbar(_("Mark Set"));
|
||||||
openfile->kind_of_mark = HARDMARK;
|
openfile->kind_of_mark = HARDMARK;
|
||||||
} else {
|
} else {
|
||||||
statusbar(_("Mark Unset"));
|
|
||||||
openfile->mark = NULL;
|
openfile->mark = NULL;
|
||||||
|
statusbar(_("Mark Unset"));
|
||||||
refresh_needed = TRUE;
|
refresh_needed = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1063,8 +1063,8 @@ void do_enter(void)
|
|||||||
add_undo(ENTER);
|
add_undo(ENTER);
|
||||||
|
|
||||||
/* Adjust the mark if it was on the current line after the cursor. */
|
/* Adjust the mark if it was on the current line after the cursor. */
|
||||||
if (openfile->current == openfile->mark &&
|
if (openfile->mark == openfile->current &&
|
||||||
openfile->current_x < openfile->mark_x) {
|
openfile->mark_x > openfile->current_x) {
|
||||||
openfile->mark = newnode;
|
openfile->mark = newnode;
|
||||||
openfile->mark_x += extra - openfile->current_x;
|
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;
|
ssize_t current_lineno_save = openfile->current->lineno;
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
bool mark_is_set = (openfile->mark != NULL);
|
bool mark_is_set = (openfile->mark != NULL);
|
||||||
ssize_t mb_lineno_save = 0;
|
ssize_t was_mark_lineno = (mark_is_set ? openfile->mark->lineno : 0);
|
||||||
size_t mark_begin_x_save = 0;
|
size_t was_mark_x = openfile->mark_x;
|
||||||
|
|
||||||
if (mark_is_set) {
|
|
||||||
mb_lineno_save = openfile->mark->lineno;
|
|
||||||
mark_begin_x_save = openfile->mark_x;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Move bot down par_len lines to the line after the last line of
|
/* 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) {
|
if (openfile->current != openfile->fileage) {
|
||||||
top = openfile->current->prev;
|
top = openfile->current->prev;
|
||||||
#ifndef NANO_TINY
|
#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 = openfile->current;
|
||||||
openfile->mark_x = mark_begin_x_save;
|
openfile->mark_x = was_mark_x;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
} else
|
} else
|
||||||
@ -2062,9 +2057,9 @@ void backup_lines(filestruct *first_line, size_t par_len)
|
|||||||
if (top->lineno == current_lineno_save)
|
if (top->lineno == current_lineno_save)
|
||||||
openfile->current = top;
|
openfile->current = top;
|
||||||
#ifndef NANO_TINY
|
#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 = top;
|
||||||
openfile->mark_x = mark_begin_x_save;
|
openfile->mark_x = was_mark_x;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
top = top->prev;
|
top = top->prev;
|
||||||
@ -2927,7 +2922,6 @@ const char *do_alt_speller(char *tempfile_name)
|
|||||||
|
|
||||||
mark_order((const filestruct **)&top, &top_x,
|
mark_order((const filestruct **)&top, &top_x,
|
||||||
(const filestruct **)&bot, &bot_x, &right_side_up);
|
(const filestruct **)&bot, &bot_x, &right_side_up);
|
||||||
|
|
||||||
openfile->mark = NULL;
|
openfile->mark = NULL;
|
||||||
|
|
||||||
replace_marked_buffer(tempfile_name, top, top_x, bot, bot_x);
|
replace_marked_buffer(tempfile_name, top, top_x, bot, bot_x);
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user