implement indenting for multiple lines, using the 'count' parameter
This commit is contained in:
@@ -25,23 +25,38 @@ struct
|
|||||||
NormalModeWith.mode (app, mode, [])
|
NormalModeWith.mode (app, mode, [])
|
||||||
end
|
end
|
||||||
|
|
||||||
(* todo: use count to find number of lines to indent *)
|
local
|
||||||
fun indnetLine (app: app_type, count, time) =
|
fun loop (app: app_type, cursorIdx, buffer, count, time) =
|
||||||
|
if count = 0 then
|
||||||
let
|
let
|
||||||
open MailboxType
|
open MailboxType
|
||||||
|
|
||||||
val {cursorIdx, buffer, searchString, ...} = app
|
val {cursorIdx = origCursorIdx, searchString, ...} = app
|
||||||
val buffer = LineGap.goToIdx (cursorIdx, buffer)
|
|
||||||
val lineStart = Cursor.vi0 (buffer, cursorIdx)
|
|
||||||
|
|
||||||
val indentString = " "
|
|
||||||
val buffer = LineGap.insert (lineStart, indentString, buffer)
|
|
||||||
|
|
||||||
val buffer = LineGap.goToStart buffer
|
val buffer = LineGap.goToStart buffer
|
||||||
val initialMsg = [SEARCH (buffer, searchString, time)]
|
val initialMsg = [SEARCH (buffer, searchString, time)]
|
||||||
in
|
in
|
||||||
NormalDelete.finishAfterDeletingBuffer
|
NormalDelete.finishAfterDeletingBuffer
|
||||||
(app, cursorIdx, buffer, time, initialMsg)
|
(app, origCursorIdx, buffer, time, initialMsg)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
let
|
||||||
|
val buffer = LineGap.goToIdx (cursorIdx, buffer)
|
||||||
|
val lineStart = Cursor.vi0 (buffer, cursorIdx)
|
||||||
|
|
||||||
|
val buffer = LineGap.insert (lineStart, " ", buffer)
|
||||||
|
|
||||||
|
val buffer = LineGap.goToIdx (lineStart, buffer)
|
||||||
|
val lineEnd = Cursor.viDlr (buffer, lineStart, 1)
|
||||||
|
val buffer = LineGap.goToIdx (lineEnd, buffer)
|
||||||
|
val nextLine = Cursor.viL (buffer, lineEnd)
|
||||||
|
|
||||||
|
val count = if lineEnd = nextLine then 0 else count - 1
|
||||||
|
in
|
||||||
|
loop (app, nextLine, buffer, count, time)
|
||||||
|
end
|
||||||
|
in
|
||||||
|
fun indnetLine (app: app_type, count, time) =
|
||||||
|
loop (app, #cursorIdx app, #buffer app, count, time)
|
||||||
end
|
end
|
||||||
|
|
||||||
(* todo: use count to find number of lines to dedent *)
|
(* todo: use count to find number of lines to dedent *)
|
||||||
|
|||||||
Reference in New Issue
Block a user