handle navigating to a non-existent function

We need a place to show error messages. Maybe on the top row?
This commit is contained in:
Kartik K. Agaram 2021-06-06 21:46:42 -07:00
parent ee1d9e8598
commit 9922e558a3
1 changed files with 23 additions and 14 deletions

View File

@ -170,29 +170,38 @@ fn edit-environment _self: (addr environment), key: grapheme, data-disk: (addr d
{
compare key, 0xa/newline
break-if-!=
var cursor-in-globals-a/edx: (addr boolean) <- get self, cursor-in-globals?
copy-to *cursor-in-globals-a, 1/true
# done with function modal
var cursor-in-function-modal-a/eax: (addr boolean) <- get self, cursor-in-function-modal?
copy-to *cursor-in-function-modal-a, 0/false
# if no function name typed in, switch to sandbox
var partial-function-name-ah/eax: (addr handle gap-buffer) <- get self, partial-function-name
var partial-function-name/eax: (addr gap-buffer) <- lookup *partial-function-name-ah
{
{
var empty?/eax: boolean <- gap-buffer-empty? partial-function-name
compare empty?, 0/false
}
break-if-!=
set-global-cursor-index globals, partial-function-name
}
var cursor-in-globals-a/ecx: (addr boolean) <- get self, cursor-in-globals?
copy-to *cursor-in-globals-a, 1/true
{
var empty?/eax: boolean <- gap-buffer-empty? partial-function-name
compare empty?, 0/false
break-if-=
var cursor-in-globals-a/eax: (addr boolean) <- get self, cursor-in-globals?
copy-to *cursor-in-globals-a, 0/false
return
}
# turn function name into a stream
var name-storage: (stream byte 0x40)
var name/ecx: (addr stream byte) <- address name-storage
emit-gap-buffer partial-function-name, name
clear-gap-buffer partial-function-name
var cursor-in-function-modal-a/eax: (addr boolean) <- get self, cursor-in-function-modal?
copy-to *cursor-in-function-modal-a, 0/false
# compute function index
var index/ecx: int <- find-symbol-in-globals globals, name
# if function not found, return
{
compare index, 0
break-if->=
return
}
# otherwise switch focus to function at index
var globals-cursor-index/eax: (addr int) <- get globals, cursor-index
copy-to *globals-cursor-index, index
var cursor-in-globals-a/ecx: (addr boolean) <- get self, cursor-in-globals?
copy-to *cursor-in-globals-a, 1/true
return
}
# otherwise process like a regular gap-buffer