commit d9943120edb08bfdce32f140ab9f2d64e09594e0
parent a1907d77f8fb3d79175c723a6494f1af9f48bf22
Author: Benno Schulenberg <bensberg@telfort.nl>
Date: Mon, 30 Mar 2020 19:20:18 +0200
tweaks: move two functions, to have them in a more logical order
The logical order being: cut, copy, paste.
Diffstat:
M | src/cut.c | | | 84 | ++++++++++++++++++++++++++++++++++++++++---------------------------------------- |
M | src/proto.h | | | 4 | ++-- |
2 files changed, 44 insertions(+), 44 deletions(-)
diff --git a/src/cut.c b/src/cut.c
@@ -485,6 +485,48 @@ void cut_text(void)
}
#ifndef NANO_TINY
+/* Cut from the current cursor position to the end of the file. */
+void cut_till_eof(void)
+{
+ if (openfile->current->data[openfile->current_x] == '\0' &&
+ (openfile->current->next == NULL ||
+ (!ISSET(NO_NEWLINES) && openfile->current_x > 0 &&
+ openfile->current->next == openfile->filebot))) {
+ statusbar(_("Nothing was cut"));
+ return;
+ }
+
+ add_undo(CUT_TO_EOF, NULL);
+ do_snip(FALSE, TRUE, FALSE);
+ update_undo(CUT_TO_EOF);
+ wipe_statusbar();
+}
+
+/* Erase text (current line or marked region), sending it into oblivion. */
+void zap_text(void)
+{
+ /* Remember the current cutbuffer so it can be restored after the zap. */
+ linestruct *was_cutbuffer = cutbuffer;
+
+ if (!is_cuttable(ISSET(CUT_FROM_CURSOR) && openfile->mark == NULL))
+ return;
+
+ /* Add a new undo item only when the current item is not a ZAP or when
+ * the current zap is not contiguous with the previous zapping. */
+ if (openfile->last_action != ZAP || !keep_cutbuffer)
+ add_undo(ZAP, NULL);
+
+ /* Use the cutbuffer from the ZAP undo item, so the cut can be undone. */
+ cutbuffer = openfile->current_undo->cutbuffer;
+
+ do_snip(openfile->mark != NULL, FALSE, TRUE);
+
+ update_undo(ZAP);
+ wipe_statusbar();
+
+ cutbuffer = was_cutbuffer;
+}
+
/* Make a copy of the marked region, putting it in the cutbuffer. */
void copy_marked_region(void)
{
@@ -586,48 +628,6 @@ void copy_text(void)
openfile->last_action = COPY;
keep_cutbuffer = TRUE;
}
-
-/* Cut from the current cursor position to the end of the file. */
-void cut_till_eof(void)
-{
- if (openfile->current->data[openfile->current_x] == '\0' &&
- (openfile->current->next == NULL ||
- (!ISSET(NO_NEWLINES) && openfile->current_x > 0 &&
- openfile->current->next == openfile->filebot))) {
- statusbar(_("Nothing was cut"));
- return;
- }
-
- add_undo(CUT_TO_EOF, NULL);
- do_snip(FALSE, TRUE, FALSE);
- update_undo(CUT_TO_EOF);
- wipe_statusbar();
-}
-
-/* Erase text (current line or marked region), sending it into oblivion. */
-void zap_text(void)
-{
- /* Remember the current cutbuffer so it can be restored after the zap. */
- linestruct *was_cutbuffer = cutbuffer;
-
- if (!is_cuttable(ISSET(CUT_FROM_CURSOR) && openfile->mark == NULL))
- return;
-
- /* Add a new undo item only when the current item is not a ZAP or when
- * the current zap is not contiguous with the previous zapping. */
- if (openfile->last_action != ZAP || !keep_cutbuffer)
- add_undo(ZAP, NULL);
-
- /* Use the cutbuffer from the ZAP undo item, so the cut can be undone. */
- cutbuffer = openfile->current_undo->cutbuffer;
-
- do_snip(openfile->mark != NULL, FALSE, TRUE);
-
- update_undo(ZAP);
- wipe_statusbar();
-
- cutbuffer = was_cutbuffer;
-}
#endif /* !NANO_TINY */
/* Copy text from the cutbuffer into the current buffer. */
diff --git a/src/proto.h b/src/proto.h
@@ -266,10 +266,10 @@ void cut_marked_region(void);
void do_snip(bool marked, bool until_eof, bool append);
void cut_text(void);
#ifndef NANO_TINY
-void copy_marked_region(void);
-void copy_text(void);
void cut_till_eof(void);
void zap_text(void);
+void copy_marked_region(void);
+void copy_text(void);
#endif
void paste_text(void);