summaryrefslogtreecommitdiff
path: root/nncmpp.c
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2017-06-26 04:54:56 +0200
committerPřemysl Janouch <p.janouch@gmail.com>2017-06-26 04:54:56 +0200
commit2375e0dd3e431a4f69a522af30b7813aa3b74598 (patch)
tree9ada2827b85f7a45e24bc35d6c390132d791fe52 /nncmpp.c
parent7d414c76470c55b9b517e7a990fa23121da645ad (diff)
downloadnncmpp-2375e0dd3e431a4f69a522af30b7813aa3b74598.tar.gz
nncmpp-2375e0dd3e431a4f69a522af30b7813aa3b74598.tar.xz
nncmpp-2375e0dd3e431a4f69a522af30b7813aa3b74598.zip
Make Del/Bksp eat whole graphemes
Tested on some zalgo text.
Diffstat (limited to 'nncmpp.c')
-rw-r--r--nncmpp.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/nncmpp.c b/nncmpp.c
index 10f9cdc..4f6dd31 100644
--- a/nncmpp.c
+++ b/nncmpp.c
@@ -1724,22 +1724,34 @@ app_editor_process_action (enum action action)
return true;
case ACTION_EDITOR_B_DELETE:
+ {
if (g.editor_point < 1)
return false;
- app_editor_move (g.editor_point - 1, g.editor_point,
+ int len = 1;
+ while (g.editor_point - len > 0
+ && !g.editor_w[g.editor_point - len])
+ len++;
+ app_editor_move (g.editor_point - len, g.editor_point,
g.editor_len - g.editor_point);
- g.editor_len--;
- g.editor_point--;
+ g.editor_len -= len;
+ g.editor_point -= len;
app_editor_changed ();
return true;
+ }
case ACTION_EDITOR_F_DELETE:
+ {
if (g.editor_point + 1 > (int) g.editor_len)
return false;
- g.editor_len--;
- app_editor_move (g.editor_point, g.editor_point + 1,
+ int len = 1;
+ while (g.editor_point + len < (int) g.editor_len
+ && !g.editor_w[g.editor_point + len])
+ len++;
+ g.editor_len -= len;
+ app_editor_move (g.editor_point, g.editor_point + len,
g.editor_len - g.editor_point);
app_editor_changed ();
return true;
+ }
case ACTION_EDITOR_B_KILL_WORD:
{
if (g.editor_point < 1)