From fcdf04ee78bc26a2b8336f2d36c83decbb2e120f Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Sun, 11 Oct 2020 22:37:18 -0700 Subject: 7005 - tile: move to start/end of line --- apps/tile/environment.mu | 38 ++++++++++++++++++++++++++++++++++++++ apps/tile/main.mu | 14 +------------- 2 files changed, 39 insertions(+), 13 deletions(-) (limited to 'apps/tile') diff --git a/apps/tile/environment.mu b/apps/tile/environment.mu index e2a9f454..44a93eff 100644 --- a/apps/tile/environment.mu +++ b/apps/tile/environment.mu @@ -287,6 +287,44 @@ $process:body: { copy-object caller-cursor-element-ah, cursor-call-path-ah break $process:body } + # line-based motions + compare key, 1 # ctrl-a + $process:start-of-line: { + break-if-!= + # move cursor to initial word of sandbox + var cursor-call-path-ah/eax: (addr handle call-path-element) <- get sandbox, cursor-call-path + allocate cursor-call-path-ah + # move cursor to start of initial word + var functions/ecx: (addr handle function) <- get self, functions + get-cursor-word sandbox, functions, cursor-word-ah + var cursor-word/eax: (addr word) <- lookup *cursor-word-ah + cursor-to-start cursor-word + # this works as long as the first word isn't expanded + # but we don't expect to see zero-arg functions first-up + break $process:body + } + compare key, 5 # ctrl-e + $process:end-of-line: { + break-if-!= + # move cursor to final word of sandbox + var cursor-call-path-ah/eax: (addr handle call-path-element) <- get sandbox, cursor-call-path + allocate cursor-call-path-ah + var cursor-call-path/eax: (addr call-path-element) <- lookup *cursor-call-path-ah + var dest/edx: (addr int) <- get cursor-call-path, index-in-body + var line-ah/eax: (addr handle line) <- get sandbox, data + var line/eax: (addr line) <- lookup *line-ah + var n/eax: int <- line-length line + n <- decrement + copy-to *dest, n + # move cursor to end of final word + var functions/ecx: (addr handle function) <- get self, functions + get-cursor-word sandbox, functions, cursor-word-ah + var cursor-word/eax: (addr word) <- lookup *cursor-word-ah + cursor-to-end cursor-word + # this works because expanded words lie to the right of their bodies + # so the final word is always guaranteed to be at the top-level + break $process:body + } # if cursor is within a call, disable editing hotkeys below var cursor-call-path-ah/eax: (addr handle call-path-element) <- get sandbox, cursor-call-path var cursor-call-path/eax: (addr call-path-element) <- lookup *cursor-call-path-ah diff --git a/apps/tile/main.mu b/apps/tile/main.mu index 157adc48..457fef83 100644 --- a/apps/tile/main.mu +++ b/apps/tile/main.mu @@ -81,25 +81,13 @@ fn test { process env, g g <- copy 0x32 # '2' process env, g - g <- copy 0x2b # '+' - process env, g - g <- copy 0xa # - process env, g g <- copy 0x445b1b # left-arrow process env, g g <- copy 0x445b1b # left-arrow process env, g g <- copy 0x445b1b # left-arrow process env, g - g <- copy 0x10 # - process env, g - g <- copy 0x10 # - process env, g - g <- copy 0xe # - process env, g - g <- copy 0xe # - process env, g - g <- copy 0xe # + g <- copy 5 # process env, g } -- cgit 1.4.1-2-gfad0