diff --git a/fcore/app-update.sml b/fcore/app-update.sml index b67ac23..d86d92b 100644 --- a/fcore/app-update.sml +++ b/fcore/app-update.sml @@ -25,7 +25,7 @@ struct val buffer = LineGap.goToIdx (cursorIdx, buffer) val startLine = TextWindow.getStartLineWithCursorCentered - (buffer, cursorIdx, origLine, windowWidth, windowHeight) + (buffer, cursorIdx, origLine, windowWidth, windowHeight div 2) val buffer = LineGap.goToLine (startLine, buffer) @@ -41,7 +41,7 @@ struct fun moveToStart (app: app_type) = let - val {buffer, windowWidth, windowHeight, startLine, ...} = app + val {buffer, windowWidth, windowHeight, ...} = app val cursorIdx = 0 val startLine = 0 @@ -58,6 +58,32 @@ struct (newApp, drawMsg) 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) = if count = 0 then let @@ -181,6 +207,11 @@ struct move (app, 1, Cursor.vi0) | #"$" => move (app, 1, Cursor.viDlr) | #"^" => 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 *) | #"t" => appendChr (app, chr, str) | #"T" => appendChr (app, chr, str) diff --git a/fcore/text-window.sml b/fcore/text-window.sml index 74629a1..21bafb7 100644 --- a/fcore/text-window.sml +++ b/fcore/text-window.sml @@ -252,7 +252,7 @@ struct end in getCursorStartLine - (strIdx, shd, lineNum, leftStrings, maxWidth, maxHeight div 2) + (strIdx, shd, lineNum, leftStrings, maxWidth, maxHeight) end else (* todo: strIdx is in tl *) diff --git a/lib/brolib-sml b/lib/brolib-sml index d59d0bb..446e335 160000 --- a/lib/brolib-sml +++ b/lib/brolib-sml @@ -1 +1 @@ -Subproject commit d59d0bb17f1d45c034d6ceeb711de9f53b710f4d +Subproject commit 446e335f5432512ba6993bb0e4e78454b007ffd0 diff --git a/shf b/shf index e9a82b4..bf03bda 100755 Binary files a/shf and b/shf differ