tweaks: relocate a function to before its callers

This commit is contained in:
Benno Schulenberg 2020-02-26 13:27:22 +01:00
parent 43754bd11d
commit 4da604be5a
2 changed files with 26 additions and 27 deletions

View File

@ -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)
{

View File

@ -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);