From 593b95246c971bce26650141a7e3a0502c4abedb Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Sat, 19 Sep 2020 23:16:23 -0700 Subject: 6814 - tile: backspace deletes char or word --- apps/tile/environment.mu | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'apps/tile/environment.mu') diff --git a/apps/tile/environment.mu b/apps/tile/environment.mu index 275b87df..caa8c720 100644 --- a/apps/tile/environment.mu +++ b/apps/tile/environment.mu @@ -93,9 +93,36 @@ $process:body: { } break $process:body } + compare key, 0x7f # del (backspace on Macs) + { + break-if-!= + var cursor-word-ah/edi: (addr handle word) <- get self, cursor-word + var _cursor-word/eax: (addr word) <- lookup *cursor-word-ah + var cursor-word/ecx: (addr word) <- copy _cursor-word + # if not at start of some word, delete grapheme before cursor within current word + var at-start?/eax: boolean <- cursor-at-start? cursor-word + compare at-start?, 0 # false + { + break-if-= + delete-before-cursor cursor-word + break $process:body + } + # otherwise delete current word and move to end of prev word + var prev-word-ah/esi: (addr handle word) <- get cursor-word, prev + var prev-word/eax: (addr word) <- lookup *prev-word-ah + { + compare prev-word, 0 + break-if-= + copy-object prev-word-ah, cursor-word-ah + cursor-to-end prev-word + delete-next prev-word + } + break $process:body + } compare key, 0x20 # space { break-if-!= + # insert new word var cursor-word-ah/edx: (addr handle word) <- get self, cursor-word append-word cursor-word-ah var cursor-word/eax: (addr word) <- lookup *cursor-word-ah @@ -103,6 +130,7 @@ $process:body: { copy-object next-word-ah, cursor-word-ah break $process:body } + # otherwise insert key within current word var g/edx: grapheme <- copy key var print?/eax: boolean <- real-grapheme? key { -- cgit 1.4.1-2-gfad0