diff --git a/src/cut.c b/src/cut.c index 6d7f87e1..3c922171 100644 --- a/src/cut.c +++ b/src/cut.c @@ -138,6 +138,32 @@ void do_backspace(void) } } +/* Return FALSE when a cut command would not actually cut anything: when + * on an empty line at EOF, or when the mark covers zero characters, or + * (when test_cliff is TRUE) when the magic line would be cut. */ +bool is_cuttable(bool test_cliff) +{ + size_t from = (test_cliff) ? openfile->current_x : 0; + + if ((openfile->current->next == NULL && openfile->current->data[from] == '\0' +#ifndef NANO_TINY + && openfile->mark == NULL) || + (openfile->mark == openfile->current && + openfile->mark_x == openfile->current_x) || + (from > 0 && !ISSET(NO_NEWLINES) && + openfile->current->data[from] == '\0' && + openfile->current->next == openfile->filebot +#endif + )) { +#ifndef NANO_TINY + statusbar(_("Nothing was cut")); + openfile->mark = NULL; +#endif + return FALSE; + } else + return TRUE; +} + #ifndef NANO_TINY /* Delete text from the cursor until the first start of a word to * the left, or to the right when forward is TRUE. */ @@ -508,32 +534,6 @@ void do_snip(bool copying, bool marked, bool until_eof, bool append) refresh_needed = TRUE; } -/* Return FALSE when a cut command would not actually cut anything: when - * on an empty line at EOF, or when the mark covers zero characters, or - * (when test_cliff is TRUE) when the magic line would be cut. */ -bool is_cuttable(bool test_cliff) -{ - size_t from = (test_cliff) ? openfile->current_x : 0; - - if ((openfile->current->next == NULL && openfile->current->data[from] == '\0' -#ifndef NANO_TINY - && openfile->mark == NULL) || - (openfile->mark == openfile->current && - openfile->mark_x == openfile->current_x) || - (from > 0 && !ISSET(NO_NEWLINES) && - openfile->current->data[from] == '\0' && - openfile->current->next == openfile->filebot -#endif - )) { -#ifndef NANO_TINY - statusbar(_("Nothing was cut")); - openfile->mark = NULL; -#endif - return FALSE; - } else - return TRUE; -} - /* Move text from the current buffer into the cutbuffer. */ void cut_text(void) { diff --git a/src/proto.h b/src/proto.h index 0dc94af7..842f893a 100644 --- a/src/proto.h +++ b/src/proto.h @@ -264,7 +264,6 @@ void copy_from_buffer(linestruct *somebuffer); void cut_marked(bool *right_side_up); #endif void do_snip(bool copying, bool marked, bool until_eof, bool append); -bool is_cuttable(bool test_cliff); void cut_text(void); #ifndef NANO_TINY void copy_text(void);