add KEY_ESC message type, and refactor app-update.sml to use it (always calls 'clearMode' function which always sets the app to normal mode, and sets the command strnig to empty)
This commit is contained in:
@@ -430,6 +430,7 @@ struct
|
|||||||
fun handleMoveToChr (count, app, fMove, newCmd) =
|
fun handleMoveToChr (count, app, fMove, newCmd) =
|
||||||
case newCmd of
|
case newCmd of
|
||||||
CHAR_EVENT chr => moveToChr (app, count, fMove, chr)
|
CHAR_EVENT chr => moveToChr (app, count, fMove, chr)
|
||||||
|
| KEY_ESC => clearMode app
|
||||||
| RESIZE_EVENT (width, height) => resizeText (app, width, height)
|
| RESIZE_EVENT (width, height) => resizeText (app, width, height)
|
||||||
|
|
||||||
fun handleGo (count, app, newCmd) =
|
fun handleGo (count, app, newCmd) =
|
||||||
@@ -440,6 +441,7 @@ struct
|
|||||||
| #"E" => move (app, count, Cursor.endOfPrevWORD)
|
| #"E" => move (app, count, Cursor.endOfPrevWORD)
|
||||||
| #"g" => moveToStart app
|
| #"g" => moveToStart app
|
||||||
| _ => clearMode app)
|
| _ => clearMode app)
|
||||||
|
| KEY_ESC => clearMode app
|
||||||
| RESIZE_EVENT (width, height) => resizeText (app, width, height)
|
| RESIZE_EVENT (width, height) => resizeText (app, width, height)
|
||||||
|
|
||||||
(* useful reference as list of non-terminal commands *)
|
(* useful reference as list of non-terminal commands *)
|
||||||
@@ -487,15 +489,17 @@ struct
|
|||||||
fun parseNormalModeCommand (app, str, newCmd) =
|
fun parseNormalModeCommand (app, str, newCmd) =
|
||||||
if String.size str = 0 then
|
if String.size str = 0 then
|
||||||
case newCmd of
|
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
|
else if String.size str = 1 then
|
||||||
case newCmd of
|
case newCmd of
|
||||||
RESIZE_EVENT (width, height) => resizeText (app, width, height)
|
CHAR_EVENT chr =>
|
||||||
| CHAR_EVENT chr =>
|
|
||||||
(case Int.fromString str of
|
(case Int.fromString str of
|
||||||
SOME count => handleChr (app, count, chr, str)
|
SOME count => handleChr (app, count, chr, str)
|
||||||
| NONE => parseAfterCount (0, str, 1, app, newCmd))
|
| NONE => parseAfterCount (0, str, 1, app, newCmd))
|
||||||
|
| KEY_ESC => clearMode app
|
||||||
|
| RESIZE_EVENT (width, height) => resizeText (app, width, height)
|
||||||
else
|
else
|
||||||
let
|
let
|
||||||
val numLength = getNumLength (0, str)
|
val numLength = getNumLength (0, str)
|
||||||
@@ -508,8 +512,9 @@ struct
|
|||||||
if numLength = String.size str then
|
if numLength = String.size str then
|
||||||
(* reached end of str; str only contained numbers *)
|
(* reached end of str; str only contained numbers *)
|
||||||
case newCmd of
|
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
|
else if numLength + 1 < String.size str then
|
||||||
(* continue parsing. *)
|
(* continue parsing. *)
|
||||||
parseAfterCount (numLength + 1, str, count, app, newCmd)
|
parseAfterCount (numLength + 1, str, count, app, newCmd)
|
||||||
|
|||||||
@@ -1,13 +1,15 @@
|
|||||||
signature INPUT_MSG =
|
signature INPUT_MSG =
|
||||||
sig
|
sig
|
||||||
datatype t =
|
datatype t =
|
||||||
RESIZE_EVENT of int * int
|
CHAR_EVENT of char
|
||||||
| CHAR_EVENT of char
|
| KEY_ESC
|
||||||
|
| RESIZE_EVENT of int * int
|
||||||
end
|
end
|
||||||
|
|
||||||
structure InputMsg :> INPUT_MSG =
|
structure InputMsg :> INPUT_MSG =
|
||||||
struct
|
struct
|
||||||
datatype t =
|
datatype t =
|
||||||
RESIZE_EVENT of int * int
|
CHAR_EVENT of char
|
||||||
| CHAR_EVENT of char
|
| KEY_ESC
|
||||||
|
| RESIZE_EVENT of int * int
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user