refactor app-update.sml to pass additional parameters to TextBuilder.build
This commit is contained in:
@@ -16,11 +16,23 @@ struct
|
|||||||
|
|
||||||
fun resizeText (app: app_type, newWidth, newHeight) =
|
fun resizeText (app: app_type, newWidth, newHeight) =
|
||||||
let
|
let
|
||||||
val {buffer, windowWidth, windowHeight, startLine, cursorIdx, ...} = app
|
val
|
||||||
|
{ buffer
|
||||||
|
, windowWidth
|
||||||
|
, windowHeight
|
||||||
|
, startLine
|
||||||
|
, cursorIdx
|
||||||
|
, searchList
|
||||||
|
, searchString
|
||||||
|
, ...
|
||||||
|
} = app
|
||||||
|
|
||||||
val newBuffer = LineGap.goToLine (startLine, buffer)
|
val newBuffer = LineGap.goToLine (startLine, buffer)
|
||||||
val drawMsg = TextBuilder.build
|
val drawMsg = TextBuilder.build
|
||||||
(startLine, cursorIdx, newBuffer, newWidth, newHeight)
|
( startLine, cursorIdx, newBuffer
|
||||||
|
, newWidth, newHeight
|
||||||
|
, searchList, searchString
|
||||||
|
)
|
||||||
|
|
||||||
val newApp = AppWith.bufferAndSize (app, newBuffer, newWidth, newHeight)
|
val newApp = AppWith.bufferAndSize (app, newBuffer, newWidth, newHeight)
|
||||||
in
|
in
|
||||||
@@ -29,7 +41,8 @@ struct
|
|||||||
|
|
||||||
fun buildTextAndClear (app: app_type, buffer, cursorIdx) =
|
fun buildTextAndClear (app: app_type, buffer, cursorIdx) =
|
||||||
let
|
let
|
||||||
val {windowWidth, windowHeight, startLine, ...} = app
|
val {windowWidth, windowHeight, startLine, searchList, searchString, ...} =
|
||||||
|
app
|
||||||
|
|
||||||
(* move LineGap to first line displayed on screen *)
|
(* move LineGap to first line displayed on screen *)
|
||||||
val buffer = LineGap.goToLine (startLine, buffer)
|
val buffer = LineGap.goToLine (startLine, buffer)
|
||||||
@@ -41,9 +54,11 @@ struct
|
|||||||
(* move buffer to new startLine as required by TextBuilder.build *)
|
(* move buffer to new startLine as required by TextBuilder.build *)
|
||||||
val buffer = LineGap.goToLine (startLine, buffer)
|
val buffer = LineGap.goToLine (startLine, buffer)
|
||||||
|
|
||||||
val drawMsg =
|
val drawMsg = TextBuilder.build
|
||||||
TextBuilder.build
|
( startLine, cursorIdx, buffer
|
||||||
(startLine, cursorIdx, buffer, windowWidth, windowHeight)
|
, windowWidth, windowHeight
|
||||||
|
, searchList, searchString
|
||||||
|
)
|
||||||
|
|
||||||
val mode = NORMAL_MODE ""
|
val mode = NORMAL_MODE ""
|
||||||
val newApp = AppWith.bufferAndCursorIdx
|
val newApp = AppWith.bufferAndCursorIdx
|
||||||
@@ -59,7 +74,8 @@ struct
|
|||||||
* *)
|
* *)
|
||||||
fun buildTextAndClearAfterChr (app: app_type, buffer, cursorIdx) =
|
fun buildTextAndClearAfterChr (app: app_type, buffer, cursorIdx) =
|
||||||
let
|
let
|
||||||
val {windowWidth, windowHeight, startLine, ...} = app
|
val {windowWidth, windowHeight, startLine, searchList, searchString, ...} =
|
||||||
|
app
|
||||||
|
|
||||||
(* move LineGap to first line displayed on screen *)
|
(* move LineGap to first line displayed on screen *)
|
||||||
val buffer = LineGap.goToLine (startLine, buffer)
|
val buffer = LineGap.goToLine (startLine, buffer)
|
||||||
@@ -71,9 +87,11 @@ struct
|
|||||||
(* move buffer to new startLine as required by TextBuilder.build *)
|
(* move buffer to new startLine as required by TextBuilder.build *)
|
||||||
val buffer = LineGap.goToLine (startLine, buffer)
|
val buffer = LineGap.goToLine (startLine, buffer)
|
||||||
|
|
||||||
val drawMsg =
|
val drawMsg = TextBuilder.build
|
||||||
TextBuilder.build
|
( startLine, cursorIdx, buffer
|
||||||
(startLine, cursorIdx, buffer, windowWidth, windowHeight)
|
, windowWidth, windowHeight
|
||||||
|
, searchList, searchString
|
||||||
|
)
|
||||||
|
|
||||||
val mode = NORMAL_MODE ""
|
val mode = NORMAL_MODE ""
|
||||||
val newApp = AppWith.bufferAndCursorIdx
|
val newApp = AppWith.bufferAndCursorIdx
|
||||||
@@ -84,7 +102,16 @@ struct
|
|||||||
|
|
||||||
fun centreToCursor (app: app_type) =
|
fun centreToCursor (app: app_type) =
|
||||||
let
|
let
|
||||||
val {buffer, windowWidth, windowHeight, startLine = origLine, cursorIdx, ...} = app
|
val
|
||||||
|
{ buffer
|
||||||
|
, windowWidth
|
||||||
|
, windowHeight
|
||||||
|
, startLine = origLine
|
||||||
|
, cursorIdx
|
||||||
|
, searchList
|
||||||
|
, searchString
|
||||||
|
, ...
|
||||||
|
} = app
|
||||||
val buffer = LineGap.goToIdx (cursorIdx, buffer)
|
val buffer = LineGap.goToIdx (cursorIdx, buffer)
|
||||||
|
|
||||||
val startLine = TextWindow.getStartLineWithCursorCentered
|
val startLine = TextWindow.getStartLineWithCursorCentered
|
||||||
@@ -95,9 +122,11 @@ struct
|
|||||||
val newApp = AppWith.bufferAndCursorIdx
|
val newApp = AppWith.bufferAndCursorIdx
|
||||||
(app, buffer, cursorIdx, NORMAL_MODE "", startLine)
|
(app, buffer, cursorIdx, NORMAL_MODE "", startLine)
|
||||||
|
|
||||||
val drawMsg =
|
val drawMsg = TextBuilder.build
|
||||||
TextBuilder.build
|
( startLine, cursorIdx, buffer
|
||||||
(startLine, cursorIdx, buffer, windowWidth, windowHeight)
|
, windowWidth, windowHeight
|
||||||
|
, searchList, searchString
|
||||||
|
)
|
||||||
in
|
in
|
||||||
(newApp, drawMsg)
|
(newApp, drawMsg)
|
||||||
end
|
end
|
||||||
@@ -106,15 +135,18 @@ struct
|
|||||||
|
|
||||||
fun moveToStart (app: app_type) =
|
fun moveToStart (app: app_type) =
|
||||||
let
|
let
|
||||||
val {buffer, windowWidth, windowHeight, ...} = app
|
val {buffer, windowWidth, windowHeight, searchList, searchString, ...} =
|
||||||
|
app
|
||||||
|
|
||||||
val cursorIdx = 0
|
val cursorIdx = 0
|
||||||
val startLine = 0
|
val startLine = 0
|
||||||
val buffer = LineGap.goToIdx (cursorIdx, buffer)
|
val buffer = LineGap.goToIdx (cursorIdx, buffer)
|
||||||
|
|
||||||
val drawMsg =
|
val drawMsg = TextBuilder.build
|
||||||
TextBuilder.build
|
( startLine, cursorIdx, buffer
|
||||||
(startLine, cursorIdx, buffer, windowWidth, windowHeight)
|
, windowWidth, windowHeight
|
||||||
|
, searchList, searchString
|
||||||
|
)
|
||||||
|
|
||||||
val mode = NORMAL_MODE ""
|
val mode = NORMAL_MODE ""
|
||||||
val newApp = AppWith.bufferAndCursorIdx
|
val newApp = AppWith.bufferAndCursorIdx
|
||||||
@@ -125,7 +157,8 @@ struct
|
|||||||
|
|
||||||
fun moveToEnd (app: app_type) =
|
fun moveToEnd (app: app_type) =
|
||||||
let
|
let
|
||||||
val {buffer, windowWidth, windowHeight, ...} = app
|
val {buffer, windowWidth, windowHeight, searchList, searchString, ...} =
|
||||||
|
app
|
||||||
|
|
||||||
val buffer = LineGap.goToEnd buffer
|
val buffer = LineGap.goToEnd buffer
|
||||||
val {line = bufferLine, idx = bufferIdx, ...} = buffer
|
val {line = bufferLine, idx = bufferIdx, ...} = buffer
|
||||||
@@ -144,9 +177,11 @@ struct
|
|||||||
end
|
end
|
||||||
|
|
||||||
val buffer = LineGap.goToLine (bufferLine, buffer)
|
val buffer = LineGap.goToLine (bufferLine, buffer)
|
||||||
val drawMsg =
|
val drawMsg = TextBuilder.build
|
||||||
TextBuilder.build
|
( bufferLine, bufferIdx, buffer
|
||||||
(bufferLine, bufferIdx, buffer, windowWidth, windowHeight)
|
, windowWidth, windowHeight
|
||||||
|
, searchList, searchString
|
||||||
|
)
|
||||||
|
|
||||||
val mode = NORMAL_MODE ""
|
val mode = NORMAL_MODE ""
|
||||||
val newApp = AppWith.bufferAndCursorIdx
|
val newApp = AppWith.bufferAndCursorIdx
|
||||||
@@ -160,7 +195,15 @@ struct
|
|||||||
moveToStart app
|
moveToStart app
|
||||||
else
|
else
|
||||||
let
|
let
|
||||||
val {windowWidth, windowHeight, buffer, startLine = origLine, ...} = app
|
val
|
||||||
|
{ windowWidth
|
||||||
|
, windowHeight
|
||||||
|
, buffer
|
||||||
|
, startLine = origLine
|
||||||
|
, searchList
|
||||||
|
, searchString
|
||||||
|
, ...
|
||||||
|
} = app
|
||||||
val buffer = LineGap.goToLine (reqLine, buffer)
|
val buffer = LineGap.goToLine (reqLine, buffer)
|
||||||
|
|
||||||
(* get idx of first chr after linebreak *)
|
(* get idx of first chr after linebreak *)
|
||||||
@@ -175,9 +218,11 @@ struct
|
|||||||
val newApp = AppWith.bufferAndCursorIdx
|
val newApp = AppWith.bufferAndCursorIdx
|
||||||
(app, buffer, cursorIdx, NORMAL_MODE "", startLine)
|
(app, buffer, cursorIdx, NORMAL_MODE "", startLine)
|
||||||
|
|
||||||
val drawMsg =
|
val drawMsg = TextBuilder.build
|
||||||
TextBuilder.build
|
( startLine, cursorIdx, buffer
|
||||||
(startLine, cursorIdx, buffer, windowWidth, windowHeight)
|
, windowWidth, windowHeight
|
||||||
|
, searchList, searchString
|
||||||
|
)
|
||||||
in
|
in
|
||||||
(newApp, drawMsg)
|
(newApp, drawMsg)
|
||||||
end
|
end
|
||||||
@@ -197,8 +242,7 @@ struct
|
|||||||
* regardless of the data structure used.
|
* regardless of the data structure used.
|
||||||
* If this happens, and the newCursorIdx is the same as the old one,
|
* If this happens, and the newCursorIdx is the same as the old one,
|
||||||
* then skip to end of loop by going to base case. *)
|
* then skip to end of loop by going to base case. *)
|
||||||
if cursorIdx = newCursorIdx
|
if cursorIdx = newCursorIdx then 0
|
||||||
then 0
|
|
||||||
else count - 1
|
else count - 1
|
||||||
in
|
in
|
||||||
helpMove (app, buffer, newCursorIdx, newCount, fMove)
|
helpMove (app, buffer, newCursorIdx, newCount, fMove)
|
||||||
@@ -211,7 +255,16 @@ struct
|
|||||||
|
|
||||||
fun moveToMatchingPair (app: app_type) =
|
fun moveToMatchingPair (app: app_type) =
|
||||||
let
|
let
|
||||||
val {buffer, cursorIdx, windowWidth, windowHeight, startLine, ...} = app
|
val
|
||||||
|
{ buffer
|
||||||
|
, cursorIdx
|
||||||
|
, windowWidth
|
||||||
|
, windowHeight
|
||||||
|
, startLine
|
||||||
|
, searchList
|
||||||
|
, searchString
|
||||||
|
, ...
|
||||||
|
} = app
|
||||||
|
|
||||||
(* move LineGap and buffer to start of line *)
|
(* move LineGap and buffer to start of line *)
|
||||||
val buffer = LineGap.goToIdx (cursorIdx, buffer)
|
val buffer = LineGap.goToIdx (cursorIdx, buffer)
|
||||||
@@ -219,17 +272,20 @@ struct
|
|||||||
|
|
||||||
val buffer = LineGap.goToLine (startLine, buffer)
|
val buffer = LineGap.goToLine (startLine, buffer)
|
||||||
in
|
in
|
||||||
if TextWindow.isCursorVisible
|
if
|
||||||
(buffer, cursorIdx, startLine, windowWidth, windowHeight)
|
TextWindow.isCursorVisible
|
||||||
|
(buffer, cursorIdx, startLine, windowWidth, windowHeight)
|
||||||
then
|
then
|
||||||
(* if visible, just need to redraw; no need to get line *)
|
(* if visible, just need to redraw; no need to get line *)
|
||||||
let
|
let
|
||||||
val newApp = AppWith.bufferAndCursorIdx
|
val newApp = AppWith.bufferAndCursorIdx
|
||||||
(app, buffer, cursorIdx, NORMAL_MODE "", startLine)
|
(app, buffer, cursorIdx, NORMAL_MODE "", startLine)
|
||||||
|
|
||||||
val drawMsg =
|
val drawMsg = TextBuilder.build
|
||||||
TextBuilder.build
|
( startLine, cursorIdx, buffer
|
||||||
(startLine, cursorIdx, buffer, windowWidth, windowHeight)
|
, windowWidth, windowHeight
|
||||||
|
, searchList, searchString
|
||||||
|
)
|
||||||
in
|
in
|
||||||
(newApp, drawMsg)
|
(newApp, drawMsg)
|
||||||
end
|
end
|
||||||
@@ -237,8 +293,7 @@ struct
|
|||||||
(* not visible, so need to get startLine where cursor is visible *)
|
(* not visible, so need to get startLine where cursor is visible *)
|
||||||
let
|
let
|
||||||
val buffer = LineGap.goToIdx (cursorIdx, buffer)
|
val buffer = LineGap.goToIdx (cursorIdx, buffer)
|
||||||
val startLine =
|
val startLine = TextWindow.getStartLineWithCursorCentered
|
||||||
TextWindow.getStartLineWithCursorCentered
|
|
||||||
(buffer, cursorIdx, startLine, windowWidth, windowHeight div 2)
|
(buffer, cursorIdx, startLine, windowWidth, windowHeight div 2)
|
||||||
|
|
||||||
val buffer = LineGap.goToLine (startLine, buffer)
|
val buffer = LineGap.goToLine (startLine, buffer)
|
||||||
@@ -246,9 +301,11 @@ struct
|
|||||||
val newApp = AppWith.bufferAndCursorIdx
|
val newApp = AppWith.bufferAndCursorIdx
|
||||||
(app, buffer, cursorIdx, NORMAL_MODE "", startLine)
|
(app, buffer, cursorIdx, NORMAL_MODE "", startLine)
|
||||||
|
|
||||||
val drawMsg =
|
val drawMsg = TextBuilder.build
|
||||||
TextBuilder.build
|
( startLine, cursorIdx, buffer
|
||||||
(startLine, cursorIdx, buffer, windowWidth, windowHeight)
|
, windowWidth, windowHeight
|
||||||
|
, searchList, searchString
|
||||||
|
)
|
||||||
in
|
in
|
||||||
(newApp, drawMsg)
|
(newApp, drawMsg)
|
||||||
end
|
end
|
||||||
@@ -336,23 +393,22 @@ struct
|
|||||||
helpRemoveChr (app, buffer, cursorIdx, 0)
|
helpRemoveChr (app, buffer, cursorIdx, 0)
|
||||||
else if nextIsEnd then
|
else if nextIsEnd then
|
||||||
let
|
let
|
||||||
(* delete char at cursor and then decrement cursorIdx by 1
|
(* delete char at cursor and then decrement cursorIdx by 1
|
||||||
* if cursorIdx is not 0 *)
|
* if cursorIdx is not 0 *)
|
||||||
val buffer = LineGap.delete (cursorIdx, 1, buffer)
|
val buffer = LineGap.delete (cursorIdx, 1, buffer)
|
||||||
val cursorIdx =
|
val cursorIdx =
|
||||||
if Cursor.isPrevChrStartOfLine (buffer, cursorIdx)
|
if
|
||||||
orelse cursorIdx = 0 then
|
Cursor.isPrevChrStartOfLine (buffer, cursorIdx)
|
||||||
cursorIdx
|
orelse cursorIdx = 0
|
||||||
|
then cursorIdx
|
||||||
else cursorIdx - 1
|
else cursorIdx - 1
|
||||||
in
|
in
|
||||||
helpRemoveChr (app, buffer, cursorIdx, count - 1)
|
helpRemoveChr (app, buffer, cursorIdx, count - 1)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
let
|
let val buffer = LineGap.delete (cursorIdx, 1, buffer)
|
||||||
val buffer = LineGap.delete (cursorIdx, 1, buffer)
|
in helpRemoveChr (app, buffer, cursorIdx, count - 1)
|
||||||
in
|
end
|
||||||
helpRemoveChr (app, buffer, cursorIdx, count - 1)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
fun removeChr (app: app_type, count) =
|
fun removeChr (app: app_type, count) =
|
||||||
@@ -501,7 +557,8 @@ struct
|
|||||||
buildTextAndClear (app, buffer, low)
|
buildTextAndClear (app, buffer, low)
|
||||||
end
|
end
|
||||||
|
|
||||||
fun helpDeleteToChr (app: app_type, buffer, cursorIdx, otherIdx, count, fMove, fInc, chr) =
|
fun helpDeleteToChr
|
||||||
|
(app: app_type, buffer, cursorIdx, otherIdx, count, fMove, fInc, chr) =
|
||||||
if count = 0 then
|
if count = 0 then
|
||||||
let
|
let
|
||||||
val low = Int.min (cursorIdx, otherIdx)
|
val low = Int.min (cursorIdx, otherIdx)
|
||||||
@@ -518,25 +575,44 @@ struct
|
|||||||
val newCount = if newOtherIdx = otherIdx then 0 else count - 1
|
val newCount = if newOtherIdx = otherIdx then 0 else count - 1
|
||||||
val newOtherIdx = fInc (newOtherIdx, 1)
|
val newOtherIdx = fInc (newOtherIdx, 1)
|
||||||
in
|
in
|
||||||
helpDeleteToChr (app, buffer, cursorIdx, newOtherIdx, newCount, fMove, fInc, chr)
|
helpDeleteToChr
|
||||||
|
(app, buffer, cursorIdx, newOtherIdx, newCount, fMove, fInc, chr)
|
||||||
end
|
end
|
||||||
|
|
||||||
fun deleteToChr (app: app_type, count, fMove, fInc, chr) =
|
fun deleteToChr (app: app_type, count, fMove, fInc, chr) =
|
||||||
helpDeleteToChr
|
helpDeleteToChr
|
||||||
(app, #buffer app, #cursorIdx app, #cursorIdx app, count, fMove, fInc, chr)
|
( app
|
||||||
|
, #buffer app
|
||||||
|
, #cursorIdx app
|
||||||
|
, #cursorIdx app
|
||||||
|
, count
|
||||||
|
, fMove
|
||||||
|
, fInc
|
||||||
|
, chr
|
||||||
|
)
|
||||||
|
|
||||||
fun deleteToStart (app: app_type) =
|
fun deleteToStart (app: app_type) =
|
||||||
let
|
let
|
||||||
val {cursorIdx, buffer, windowWidth, windowHeight, ...} = app
|
val
|
||||||
|
{ cursorIdx
|
||||||
|
, buffer
|
||||||
|
, windowWidth
|
||||||
|
, windowHeight
|
||||||
|
, searchList
|
||||||
|
, searchString
|
||||||
|
, ...
|
||||||
|
} = app
|
||||||
|
|
||||||
val buffer = LineGap.delete(0, cursorIdx, buffer)
|
val buffer = LineGap.delete (0, cursorIdx, buffer)
|
||||||
val cursorIdx = 0
|
val cursorIdx = 0
|
||||||
val startLine = 0
|
val startLine = 0
|
||||||
val buffer = LineGap.goToIdx (cursorIdx, buffer)
|
val buffer = LineGap.goToIdx (cursorIdx, buffer)
|
||||||
|
|
||||||
val drawMsg =
|
val drawMsg = TextBuilder.build
|
||||||
TextBuilder.build
|
( startLine, cursorIdx, buffer
|
||||||
(startLine, cursorIdx, buffer, windowWidth, windowHeight)
|
, windowWidth, windowHeight
|
||||||
|
, searchList, searchString
|
||||||
|
)
|
||||||
|
|
||||||
val mode = NORMAL_MODE ""
|
val mode = NORMAL_MODE ""
|
||||||
val newApp = AppWith.bufferAndCursorIdx
|
val newApp = AppWith.bufferAndCursorIdx
|
||||||
@@ -610,10 +686,8 @@ struct
|
|||||||
(* if str has a size larger than 0,
|
(* if str has a size larger than 0,
|
||||||
* interpret as "go to line" command;
|
* interpret as "go to line" command;
|
||||||
* else, interpret as a command to move to end *)
|
* else, interpret as a command to move to end *)
|
||||||
if String.size str = 0 then
|
if String.size str = 0 then moveToEnd app
|
||||||
moveToEnd app
|
else moveToLine (app, count - 1)
|
||||||
else
|
|
||||||
moveToLine (app, count - 1)
|
|
||||||
| #"%" => moveToMatchingPair app
|
| #"%" => moveToMatchingPair app
|
||||||
| #"x" => removeChr (app, count)
|
| #"x" => removeChr (app, count)
|
||||||
(* multi-char commands which can be appended *)
|
(* multi-char commands which can be appended *)
|
||||||
@@ -643,33 +717,33 @@ struct
|
|||||||
case newCmd of
|
case newCmd of
|
||||||
CHAR_EVENT chr =>
|
CHAR_EVENT chr =>
|
||||||
(case chr of
|
(case chr of
|
||||||
(* terminal commands: require no input after *)
|
(* terminal commands: require no input after *)
|
||||||
#"h" => delete (app, count, Cursor.viH)
|
#"h" => delete (app, count, Cursor.viH)
|
||||||
| #"l" => delete (app, count, Cursor.viL)
|
| #"l" => delete (app, count, Cursor.viL)
|
||||||
(* vi's 'j' and 'k' commands move up or down a column
|
(* vi's 'j' and 'k' commands move up or down a column
|
||||||
* but 'dj' or 'dk' delete whole lines
|
* but 'dj' or 'dk' delete whole lines
|
||||||
* so their implementation differs from
|
* so their implementation differs from
|
||||||
* other cursor motions *)
|
* other cursor motions *)
|
||||||
| #"j" => deleteLine (app, count + 1)
|
| #"j" => deleteLine (app, count + 1)
|
||||||
| #"k" => deleteLineBack (app, count)
|
| #"k" => deleteLineBack (app, count)
|
||||||
| #"w" => delete (app, count, Cursor.nextWord)
|
| #"w" => delete (app, count, Cursor.nextWord)
|
||||||
| #"W" => delete (app, count, Cursor.nextWORD)
|
| #"W" => delete (app, count, Cursor.nextWORD)
|
||||||
| #"b" => delete (app, count, Cursor.prevWord)
|
| #"b" => delete (app, count, Cursor.prevWord)
|
||||||
| #"B" => delete (app, count, Cursor.prevWORD)
|
| #"B" => delete (app, count, Cursor.prevWORD)
|
||||||
| #"e" => delete (app, count, Cursor.endOfWordPlusOne)
|
| #"e" => delete (app, count, Cursor.endOfWordPlusOne)
|
||||||
| #"E" => delete (app, count, Cursor.endOfWORDPlusOne)
|
| #"E" => delete (app, count, Cursor.endOfWORDPlusOne)
|
||||||
| #"0" => delete (app, 1, Cursor.vi0)
|
| #"0" => delete (app, 1, Cursor.vi0)
|
||||||
| #"$" => deleteToEndOfLine app
|
| #"$" => deleteToEndOfLine app
|
||||||
| #"^" => deleteToFirstNonSpaceChr app
|
| #"^" => deleteToFirstNonSpaceChr app
|
||||||
| #"d" => deleteLine (app, count)
|
| #"d" => deleteLine (app, count)
|
||||||
(* non-terminal commands which require appending chr *)
|
(* non-terminal commands which require appending chr *)
|
||||||
| #"t" => appendChr (app, chr, str)
|
| #"t" => appendChr (app, chr, str)
|
||||||
| #"T" => appendChr (app, chr, str)
|
| #"T" => appendChr (app, chr, str)
|
||||||
| #"f" => appendChr (app, chr, str)
|
| #"f" => appendChr (app, chr, str)
|
||||||
| #"F" => appendChr (app, chr, str)
|
| #"F" => appendChr (app, chr, str)
|
||||||
| #"g" => appendChr (app, chr, str)
|
| #"g" => appendChr (app, chr, str)
|
||||||
(* invalid command: reset mode *)
|
(* invalid command: reset mode *)
|
||||||
| _ => clearMode app)
|
| _ => clearMode app)
|
||||||
| KEY_ESC => clearMode app
|
| KEY_ESC => clearMode app
|
||||||
| RESIZE_EVENT (width, height) => resizeText (app, width, height)
|
| RESIZE_EVENT (width, height) => resizeText (app, width, height)
|
||||||
else
|
else
|
||||||
@@ -678,37 +752,41 @@ struct
|
|||||||
#"t" =>
|
#"t" =>
|
||||||
(* delete till chr, forwards *)
|
(* delete till chr, forwards *)
|
||||||
(case newCmd of
|
(case newCmd of
|
||||||
CHAR_EVENT chr => deleteToChr (app, 1, Cursor.tillNextChr, op+, chr)
|
CHAR_EVENT chr =>
|
||||||
| KEY_ESC => clearMode app
|
deleteToChr (app, 1, Cursor.tillNextChr, op+, chr)
|
||||||
| RESIZE_EVENT (width, height) => resizeText (app, width, height))
|
| KEY_ESC => clearMode app
|
||||||
|
| RESIZE_EVENT (width, height) => resizeText (app, width, height))
|
||||||
| #"T" =>
|
| #"T" =>
|
||||||
(* delete till chr, backwards *)
|
(* delete till chr, backwards *)
|
||||||
(case newCmd of
|
(case newCmd of
|
||||||
CHAR_EVENT chr => deleteToChr (app, 1, Cursor.tillPrevChr, op-, chr)
|
CHAR_EVENT chr =>
|
||||||
| KEY_ESC => clearMode app
|
deleteToChr (app, 1, Cursor.tillPrevChr, op-, chr)
|
||||||
| RESIZE_EVENT (width, height) => resizeText (app, width, height))
|
| KEY_ESC => clearMode app
|
||||||
|
| RESIZE_EVENT (width, height) => resizeText (app, width, height))
|
||||||
| #"f" =>
|
| #"f" =>
|
||||||
(case newCmd of
|
(case newCmd of
|
||||||
CHAR_EVENT chr => deleteToChr (app, count, Cursor.toNextChr, op+, chr)
|
CHAR_EVENT chr =>
|
||||||
| KEY_ESC => clearMode app
|
deleteToChr (app, count, Cursor.toNextChr, op+, chr)
|
||||||
| RESIZE_EVENT (width, height) => resizeText (app, width, height))
|
| KEY_ESC => clearMode app
|
||||||
|
| RESIZE_EVENT (width, height) => resizeText (app, width, height))
|
||||||
| #"F" =>
|
| #"F" =>
|
||||||
(* delete to chr, backwards *)
|
(* delete to chr, backwards *)
|
||||||
(case newCmd of
|
(case newCmd of
|
||||||
CHAR_EVENT chr => deleteToChr (app, count, Cursor.toPrevChr, op-, chr)
|
CHAR_EVENT chr =>
|
||||||
| KEY_ESC => clearMode app
|
deleteToChr (app, count, Cursor.toPrevChr, op-, chr)
|
||||||
| RESIZE_EVENT (width, height) => resizeText (app, width, height))
|
| KEY_ESC => clearMode app
|
||||||
|
| RESIZE_EVENT (width, height) => resizeText (app, width, height))
|
||||||
| #"g" =>
|
| #"g" =>
|
||||||
(* same events as handleGo *)
|
(* same events as handleGo *)
|
||||||
(case newCmd of
|
(case newCmd of
|
||||||
CHAR_EVENT chr =>
|
CHAR_EVENT chr =>
|
||||||
(case chr of
|
(case chr of
|
||||||
#"e" => delete (app, count, Cursor.endOfPrevWord)
|
#"e" => delete (app, count, Cursor.endOfPrevWord)
|
||||||
| #"E" => delete (app, count, Cursor.endOfPrevWORD)
|
| #"E" => delete (app, count, Cursor.endOfPrevWORD)
|
||||||
| #"g" => deleteToStart app
|
| #"g" => deleteToStart app
|
||||||
| _ => clearMode app)
|
| _ => clearMode app)
|
||||||
| KEY_ESC => clearMode app
|
| KEY_ESC => clearMode app
|
||||||
| RESIZE_EVENT (width, height) => resizeText (app, width, height))
|
| RESIZE_EVENT (width, height) => resizeText (app, width, height))
|
||||||
| _ => clearMode app
|
| _ => clearMode app
|
||||||
|
|
||||||
(* useful reference as list of non-terminal commands *)
|
(* useful reference as list of non-terminal commands *)
|
||||||
@@ -729,24 +807,16 @@ struct
|
|||||||
| #"T" =>
|
| #"T" =>
|
||||||
(* to just before chr, backward *)
|
(* to just before chr, backward *)
|
||||||
handleMoveToChr (1, app, Cursor.tillPrevChr, newCmd)
|
handleMoveToChr (1, app, Cursor.tillPrevChr, newCmd)
|
||||||
| #"y" =>
|
| #"y" => (* yank *) clearMode app
|
||||||
(* yank *)
|
| #"d" => (* delete *) parseDelete (strPos, str, count, app, newCmd)
|
||||||
clearMode app
|
|
||||||
| #"d" =>
|
|
||||||
(* delete *)
|
|
||||||
parseDelete (strPos, str, count, app, newCmd)
|
|
||||||
| #"f" =>
|
| #"f" =>
|
||||||
(* to chr, forward *)
|
(* to chr, forward *)
|
||||||
handleMoveToChr (count, app, Cursor.toNextChr, newCmd)
|
handleMoveToChr (count, app, Cursor.toNextChr, newCmd)
|
||||||
| #"F" =>
|
| #"F" =>
|
||||||
(* to chr, backward *)
|
(* to chr, backward *)
|
||||||
handleMoveToChr (count, app, Cursor.toPrevChr, newCmd)
|
handleMoveToChr (count, app, Cursor.toPrevChr, newCmd)
|
||||||
| #"g" =>
|
| #"g" => (* go *) handleGo (count, app, newCmd)
|
||||||
(* go *)
|
| #"c" => (* change *) clearMode app
|
||||||
handleGo (count, app, newCmd)
|
|
||||||
| #"c" =>
|
|
||||||
(* change *)
|
|
||||||
clearMode app
|
|
||||||
| _ =>
|
| _ =>
|
||||||
(* isn't a non-terminal cmd
|
(* isn't a non-terminal cmd
|
||||||
* this case should never happen*)
|
* this case should never happen*)
|
||||||
|
|||||||
@@ -481,6 +481,9 @@ struct
|
|||||||
else
|
else
|
||||||
0
|
0
|
||||||
val absIdx = curIdx + startIdx
|
val absIdx = curIdx + startIdx
|
||||||
|
|
||||||
|
(* todo: make going to absIdx a prerequisite for using this
|
||||||
|
* function *)
|
||||||
val searchList = SearchList.goToNum (absIdx, searchList)
|
val searchList = SearchList.goToNum (absIdx, searchList)
|
||||||
|
|
||||||
val windowData =
|
val windowData =
|
||||||
|
|||||||
Reference in New Issue
Block a user