diff --git a/fcore/app-update.sml b/fcore/app-update.sml index 9a260b2..c6f1f73 100644 --- a/fcore/app-update.sml +++ b/fcore/app-update.sml @@ -430,6 +430,7 @@ struct fun handleMoveToChr (count, app, fMove, newCmd) = case newCmd of CHAR_EVENT chr => moveToChr (app, count, fMove, chr) + | KEY_ESC => clearMode app | RESIZE_EVENT (width, height) => resizeText (app, width, height) fun handleGo (count, app, newCmd) = @@ -440,6 +441,7 @@ struct | #"E" => move (app, count, Cursor.endOfPrevWORD) | #"g" => moveToStart app | _ => clearMode app) + | KEY_ESC => clearMode app | RESIZE_EVENT (width, height) => resizeText (app, width, height) (* useful reference as list of non-terminal commands *) @@ -487,15 +489,17 @@ struct fun parseNormalModeCommand (app, str, newCmd) = if String.size str = 0 then case newCmd of - RESIZE_EVENT (width, height) => resizeText (app, width, height) - | CHAR_EVENT chr => handleChr (app, 1, chr, str) + CHAR_EVENT chr => handleChr (app, 1, chr, str) + | KEY_ESC => clearMode app + | RESIZE_EVENT (width, height) => resizeText (app, width, height) else if String.size str = 1 then case newCmd of - RESIZE_EVENT (width, height) => resizeText (app, width, height) - | CHAR_EVENT chr => + CHAR_EVENT chr => (case Int.fromString str of SOME count => handleChr (app, count, chr, str) | NONE => parseAfterCount (0, str, 1, app, newCmd)) + | KEY_ESC => clearMode app + | RESIZE_EVENT (width, height) => resizeText (app, width, height) else let val numLength = getNumLength (0, str) @@ -508,8 +512,9 @@ struct if numLength = String.size str then (* reached end of str; str only contained numbers *) case newCmd of - RESIZE_EVENT (width, height) => resizeText (app, width, height) - | CHAR_EVENT chr => handleChr (app, count, chr, str) + CHAR_EVENT chr => handleChr (app, count, chr, str) + | KEY_ESC => clearMode app + | RESIZE_EVENT (width, height) => resizeText (app, width, height) else if numLength + 1 < String.size str then (* continue parsing. *) parseAfterCount (numLength + 1, str, count, app, newCmd) diff --git a/message-types/input-msg.sml b/message-types/input-msg.sml index 6c2c8eb..d453f6c 100644 --- a/message-types/input-msg.sml +++ b/message-types/input-msg.sml @@ -1,13 +1,15 @@ signature INPUT_MSG = sig datatype t = - RESIZE_EVENT of int * int - | CHAR_EVENT of char + CHAR_EVENT of char + | KEY_ESC + | RESIZE_EVENT of int * int end structure InputMsg :> INPUT_MSG = struct datatype t = - RESIZE_EVENT of int * int - | CHAR_EVENT of char + CHAR_EVENT of char + | KEY_ESC + | RESIZE_EVENT of int * int end diff --git a/shf b/shf index 4de6040..e2b4549 100755 Binary files a/shf and b/shf differ