scaffolding for backspace functionality

This commit is contained in:
2025-09-01 02:52:05 +01:00
parent 3f7009bf09
commit f4a4dd9161
7 changed files with 13 additions and 0 deletions

Binary file not shown.

View File

@@ -272,4 +272,5 @@ struct
| WITH_SEARCH_LIST searchList =>
NormalFinish.withSearchList (app, searchList)
| KEY_ENTER => app
| KEY_BACKSPACE => app
end

View File

@@ -110,9 +110,14 @@ struct
(app, buffer, searchString, tempSearchList, startLine, mode, msgs)
end
(* todo: implement *)
fun backspace (app: app_type, searchString, tempSearchList) =
raise Fail "normal-search-mode: KEY_BACKSPACE unimplemented"
fun update (app, {searchString, tempSearchList}, msg, time) =
case msg of
CHAR_EVENT chr => addChr (app, searchString, chr)
| KEY_BACKSPACE => backspace (app, searchString, tempSearchList)
| KEY_ESC => exitToNormalMode app
| KEY_ENTER => saveSearch (app, searchString, tempSearchList)
| RESIZE_EVENT (width, height) => app

View File

@@ -8,6 +8,7 @@ int REPEAT = GLFW_REPEAT;
int RELEASE = GLFW_RELEASE;
int KEY_ESC = GLFW_KEY_ESCAPE;
int KEY_ENTER = GLFW_KEY_ENTER;
int KEY_BACKSPACE = GLFW_KEY_BACKSPACE;
void framebufferSizeCallback(GLFWwindow* window, int width, int height) {
glViewport(0, 0, width, height);

View File

@@ -36,4 +36,7 @@ struct
val (KEY_ENTER, _) =
_symbol "KEY_ENTER" public : ( unit -> int ) * ( int -> unit );
val KEY_ENTER = KEY_ENTER ()
val (KEY_BACKSPACE, _) =
_symbol "KEY_BACKSPACE" public : ( unit -> int ) * ( int -> unit );
val KEY_BACKSPACE = KEY_BACKSPACE ()
end

View File

@@ -4,6 +4,7 @@ struct
CHAR_EVENT of char
| KEY_ESC
| KEY_ENTER
| KEY_BACKSPACE
| RESIZE_EVENT of int * int
| WITH_SEARCH_LIST of int vector
end

View File

@@ -27,6 +27,8 @@ struct
Mailbox.send (inputMailbox, InputMsg.KEY_ESC)
else if key = KEY_ENTER andalso action = PRESS andalso mods = 0 then
Mailbox.send (inputMailbox, InputMsg.KEY_ENTER)
else if key = KEY_BACKSPACE andalso action <> RELEASE andalso mods = 0 then
Mailbox.send (inputMailbox, InputMsg.KEY_BACKSPACE)
else
()
end