From 3346c5395ebe0e462fedf68fb7e07b91cf8a3767 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Thu, 2 May 2019 10:14:08 +0200 Subject: [PATCH] tweaks: place a function better, and reduce some comments to a single one --- src/cut.c | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/src/cut.c b/src/cut.c index ad9c24c1..339fdc6a 100644 --- a/src/cut.c +++ b/src/cut.c @@ -218,23 +218,11 @@ void cut_line(void) else extract(openfile->current, 0, openfile->current, strlen(openfile->current->data)); + openfile->placewewant = 0; } #ifndef NANO_TINY -/* Move all marked text from the current buffer into the cutbuffer. */ -void cut_marked(bool *right_side_up) -{ - linestruct *top, *bot; - size_t top_x, bot_x; - - get_region((const linestruct **)&top, &top_x, - (const linestruct **)&bot, &bot_x, right_side_up); - - extract(top, top_x, bot, bot_x); - openfile->placewewant = xplustabs(); -} - /* Move all text from the cursor position until the end of this line into * the cutbuffer. But when already at the end of a line, then move this * "newline" to the cutbuffer. */ @@ -255,6 +243,20 @@ void cut_to_eol(void) } } +/* Move all marked text from the current buffer into the cutbuffer. */ +void cut_marked(bool *right_side_up) +{ + linestruct *top, *bot; + size_t top_x, bot_x; + + get_region((const linestruct **)&top, &top_x, + (const linestruct **)&bot, &bot_x, right_side_up); + + extract(top, top_x, bot, bot_x); + + openfile->placewewant = xplustabs(); +} + /* Move all text from the cursor position to end-of-file into the cutbuffer. */ void cut_to_eof(void) { @@ -306,19 +308,16 @@ void do_cut_text(bool copying, bool marked, bool until_eof, bool append) SET(NO_NEWLINES); } - if (until_eof) { - /* Move all text up to the end of the file into the cutbuffer. */ + /* Now move the relevant piece of text into the cutbuffer. */ + if (until_eof) cut_to_eof(); - } else if (openfile->mark) { - /* Move the marked text to the cutbuffer, and turn the mark off. */ + else if (openfile->mark) { cut_marked(&right_side_up); openfile->mark = NULL; } else if (ISSET(CUT_FROM_CURSOR)) - /* Move all text up to the end of the line into the cutbuffer. */ cut_to_eol(); else #endif - /* Move the entire line into the cutbuffer. */ cut_line(); #ifndef NANO_TINY