From 1327e296c2bfb947778c882e6132d0b572eb921e Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Thu, 25 Apr 2024 10:32:11 +0200 Subject: [PATCH] tweaks: rename a function, for contrast, and update antiquated comments --- src/cut.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/cut.c b/src/cut.c index 4e2e8381..7b39777a 100644 --- a/src/cut.c +++ b/src/cut.c @@ -24,8 +24,9 @@ #include -/* 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); } }