diff options
-rw-r--r-- | browse-slack/environment.mu | 43 |
1 files changed, 22 insertions, 21 deletions
diff --git a/browse-slack/environment.mu b/browse-slack/environment.mu index 85e1a43c..ca3d827d 100644 --- a/browse-slack/environment.mu +++ b/browse-slack/environment.mu @@ -666,28 +666,29 @@ fn render-json-escaped-unicode-grapheme screen: (addr screen), stream: (addr str fn update-environment _env: (addr environment), key: byte, users: (addr array user), channels: (addr array channel), items: (addr item-list) { var env/edi: (addr environment) <- copy _env - # back in history + # first dispatch to search mode if necessary { - compare key, 0x1b/esc - break-if-!= - { - var cursor-in-search?/eax: (addr boolean) <- get env, cursor-in-search? - compare *cursor-in-search?, 0/false - break-if-= - copy-to *cursor-in-search?, 0/false - return - } - previous-tab env + var cursor-in-search?/eax: (addr boolean) <- get env, cursor-in-search? + compare *cursor-in-search?, 0/false + break-if-= + update-search env, key, users, channels, items return } { compare key, 0x2f/slash break-if-!= - # start search mode + # enter search mode var cursor-in-search?/eax: (addr boolean) <- get env, cursor-in-search? copy-to *cursor-in-search?, 1/true return } + { + compare key, 0x1b/esc + break-if-!= + # back in history + previous-tab env + return + } var cursor-in-channels?/eax: (addr boolean) <- get env, cursor-in-channels? { compare key, 9/tab @@ -696,14 +697,6 @@ fn update-environment _env: (addr environment), key: byte, users: (addr array us not *cursor-in-channels? return } - # dispatch based on where the cursor is - { - var cursor-in-search?/eax: (addr boolean) <- get env, cursor-in-search? - compare *cursor-in-search?, 0/false - break-if-= - update-search env, key, users, channels, items - return - } { compare *cursor-in-channels?, 0/false break-if-!= @@ -773,11 +766,19 @@ fn update-channels-nav _env: (addr environment), key: byte, users: (addr array u fn update-search _env: (addr environment), key: byte, users: (addr array user), channels: (addr array channel), items: (addr item-list) { var env/edi: (addr environment) <- copy _env + var cursor-in-search?/eax: (addr boolean) <- get env, cursor-in-search? + { + compare key 0x1b/esc + break-if-!= + # get out of search mode + copy-to *cursor-in-search?, 0/false + return + } { compare key, 0xa/newline break-if-!= + # perform a search, then get out of search mode new-search-tab env, items - var cursor-in-search?/eax: (addr boolean) <- get env, cursor-in-search? copy-to *cursor-in-search?, 0/false return } |