commit 1327e296c2bfb947778c882e6132d0b572eb921e
parent d53521a631166ba67cc2c4e039a2ffaefc10ae2d
Author: Benno Schulenberg <bensberg@telfort.nl>
Date: Thu, 25 Apr 2024 10:32:11 +0200
tweaks: rename a function, for contrast, and update antiquated comments
Diffstat:
1 file changed, 11 insertions(+), 8 deletions(-)
diff --git a/src/cut.c b/src/cut.c
@@ -24,8 +24,9 @@
#include <string.h>
-/* Delete the character under the cursor. */
-void do_deletion(undo_type action)
+/* Delete the character at the current position, and
+ * add or update an undo item for the given action. */
+void expunge(undo_type action)
{
openfile->placewewant = xplustabs();
@@ -112,7 +113,8 @@ void do_deletion(undo_type action)
set_modified();
}
-/* Delete the character under the cursor. */
+/* Delete the character under the cursor plus any succeeding zero-widths,
+ * or, when the mark is on and --zap is active, delete the marked region. */
void do_delete(void)
{
#ifndef NANO_TINY
@@ -121,17 +123,18 @@ void do_delete(void)
else
#endif
{
- do_deletion(DEL);
+ expunge(DEL);
#ifdef ENABLE_UTF8
while (openfile->current->data[openfile->current_x] != '\0' &&
is_zerowidth(openfile->current->data + openfile->current_x))
- do_deletion(DEL);
+ expunge(DEL);
#endif
}
}
/* Backspace over one character. That is, move the cursor left one
- * character, and then delete the character under the cursor. */
+ * character, and then delete the character under the cursor. Or,
+ * when mark is on and --zap is active, delete the marked region. */
void do_backspace(void)
{
#ifndef NANO_TINY
@@ -141,10 +144,10 @@ void do_backspace(void)
#endif
if (openfile->current_x > 0) {
openfile->current_x = step_left(openfile->current->data, openfile->current_x);
- do_deletion(BACK);
+ expunge(BACK);
} else if (openfile->current != openfile->filetop) {
do_left();
- do_deletion(BACK);
+ expunge(BACK);
}
}