tweaks: rename a function, for contrast, and update antiquated comments

This commit is contained in:
Benno Schulenberg 2024-04-25 10:32:11 +02:00
parent d53521a631
commit 1327e296c2
1 changed files with 11 additions and 8 deletions

View File

@ -24,8 +24,9 @@
#include <string.h> #include <string.h>
/* Delete the character under the cursor. */ /* Delete the character at the current position, and
void do_deletion(undo_type action) * add or update an undo item for the given action. */
void expunge(undo_type action)
{ {
openfile->placewewant = xplustabs(); openfile->placewewant = xplustabs();
@ -112,7 +113,8 @@ void do_deletion(undo_type action)
set_modified(); 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) void do_delete(void)
{ {
#ifndef NANO_TINY #ifndef NANO_TINY
@ -121,17 +123,18 @@ void do_delete(void)
else else
#endif #endif
{ {
do_deletion(DEL); expunge(DEL);
#ifdef ENABLE_UTF8 #ifdef ENABLE_UTF8
while (openfile->current->data[openfile->current_x] != '\0' && while (openfile->current->data[openfile->current_x] != '\0' &&
is_zerowidth(openfile->current->data + openfile->current_x)) is_zerowidth(openfile->current->data + openfile->current_x))
do_deletion(DEL); expunge(DEL);
#endif #endif
} }
} }
/* Backspace over one character. That is, move the cursor left one /* 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) void do_backspace(void)
{ {
#ifndef NANO_TINY #ifndef NANO_TINY
@ -141,10 +144,10 @@ void do_backspace(void)
#endif #endif
if (openfile->current_x > 0) { if (openfile->current_x > 0) {
openfile->current_x = step_left(openfile->current->data, openfile->current_x); openfile->current_x = step_left(openfile->current->data, openfile->current_x);
do_deletion(BACK); expunge(BACK);
} else if (openfile->current != openfile->filetop) { } else if (openfile->current != openfile->filetop) {
do_left(); do_left();
do_deletion(BACK); expunge(BACK);
} }
} }