add functionality to move to end of line
This commit is contained in:
@@ -25,7 +25,7 @@ struct
|
|||||||
val buffer = LineGap.goToIdx (cursorIdx, buffer)
|
val buffer = LineGap.goToIdx (cursorIdx, buffer)
|
||||||
|
|
||||||
val startLine = TextWindow.getStartLineWithCursorCentered
|
val startLine = TextWindow.getStartLineWithCursorCentered
|
||||||
(buffer, cursorIdx, origLine, windowWidth, windowHeight)
|
(buffer, cursorIdx, origLine, windowWidth, windowHeight div 2)
|
||||||
|
|
||||||
val buffer = LineGap.goToLine (startLine, buffer)
|
val buffer = LineGap.goToLine (startLine, buffer)
|
||||||
|
|
||||||
@@ -41,7 +41,7 @@ struct
|
|||||||
|
|
||||||
fun moveToStart (app: app_type) =
|
fun moveToStart (app: app_type) =
|
||||||
let
|
let
|
||||||
val {buffer, windowWidth, windowHeight, startLine, ...} = app
|
val {buffer, windowWidth, windowHeight, ...} = app
|
||||||
|
|
||||||
val cursorIdx = 0
|
val cursorIdx = 0
|
||||||
val startLine = 0
|
val startLine = 0
|
||||||
@@ -58,6 +58,32 @@ struct
|
|||||||
(newApp, drawMsg)
|
(newApp, drawMsg)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
fun moveToEnd (app: app_type) =
|
||||||
|
let
|
||||||
|
val {buffer, windowWidth, windowHeight, ...} = app
|
||||||
|
|
||||||
|
val buffer = LineGap.goToEnd buffer
|
||||||
|
val {line = bufferLine, idx = bufferIdx, ...} = buffer
|
||||||
|
|
||||||
|
val bufferIdx = bufferIdx - 1
|
||||||
|
val bufferLine = bufferLine - 1
|
||||||
|
|
||||||
|
val buffer = LineGap.goToIdx (bufferIdx, buffer)
|
||||||
|
val bufferLine = TextWindow.getStartLineWithCursorCentered
|
||||||
|
(buffer, bufferIdx, bufferLine, windowWidth, windowHeight)
|
||||||
|
|
||||||
|
val buffer = LineGap.goToLine (bufferLine, buffer)
|
||||||
|
val drawMsg =
|
||||||
|
TextBuilder.build
|
||||||
|
(bufferLine, bufferIdx, buffer, windowWidth, windowHeight)
|
||||||
|
|
||||||
|
val mode = NORMAL_MODE ""
|
||||||
|
val newApp = AppWith.bufferAndCursorIdx
|
||||||
|
(app, buffer, bufferIdx, mode, bufferLine)
|
||||||
|
in
|
||||||
|
(newApp, drawMsg)
|
||||||
|
end
|
||||||
|
|
||||||
fun helpMove (app: app_type, buffer, cursorIdx, count, fMove) =
|
fun helpMove (app: app_type, buffer, cursorIdx, count, fMove) =
|
||||||
if count = 0 then
|
if count = 0 then
|
||||||
let
|
let
|
||||||
@@ -181,6 +207,11 @@ struct
|
|||||||
move (app, 1, Cursor.vi0)
|
move (app, 1, Cursor.vi0)
|
||||||
| #"$" => move (app, 1, Cursor.viDlr)
|
| #"$" => move (app, 1, Cursor.viDlr)
|
||||||
| #"^" => firstNonSpaceChr app
|
| #"^" => firstNonSpaceChr app
|
||||||
|
| #"G" =>
|
||||||
|
(* if str has a size larger than 0,
|
||||||
|
* interpret as "go to line" command;
|
||||||
|
* else, interpret as a command to move to end *)
|
||||||
|
moveToEnd app
|
||||||
(* multi-char commands which can be appended *)
|
(* multi-char commands which can be appended *)
|
||||||
| #"t" => appendChr (app, chr, str)
|
| #"t" => appendChr (app, chr, str)
|
||||||
| #"T" => appendChr (app, chr, str)
|
| #"T" => appendChr (app, chr, str)
|
||||||
|
|||||||
@@ -252,7 +252,7 @@ struct
|
|||||||
end
|
end
|
||||||
in
|
in
|
||||||
getCursorStartLine
|
getCursorStartLine
|
||||||
(strIdx, shd, lineNum, leftStrings, maxWidth, maxHeight div 2)
|
(strIdx, shd, lineNum, leftStrings, maxWidth, maxHeight)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
(* todo: strIdx is in tl *)
|
(* todo: strIdx is in tl *)
|
||||||
|
|||||||
Submodule lib/brolib-sml updated: d59d0bb17f...446e335f54
Reference in New Issue
Block a user