add function to retrieve column that cursor is on, relative to line

This commit is contained in:
2024-10-19 07:03:32 +01:00
parent 5f4be185e8
commit 7fd59c734a
4 changed files with 116 additions and 5 deletions

View File

@@ -26,13 +26,15 @@ struct
(* move LineGap to cursorIdx, which is necessary for finding newCursorIdx *)
val buffer = LineGap.goToIdx (cursorIdx, buffer)
val cursorIdx = Cursor.viL (buffer, cursorIdx)
val preferredColumn = Cursor.getCursorColumn (buffer, cursorIdx)
(* move LineGap to first line displayed on screen, and build new text *)
val buffer = LineGap.goToLine (startLine, buffer)
val drawMsg = TextBuilder.build
(startLine, cursorIdx, buffer, windowWidth, windowHeight)
val newApp = AppWith.bufferAndCursorIdx (app, buffer, cursorIdx)
val newApp =
AppWith.bufferAndCursorIdx (app, buffer, cursorIdx, preferredColumn)
in
(newApp, drawMsg)
end
@@ -43,12 +45,14 @@ struct
val buffer = LineGap.goToIdx (cursorIdx, buffer)
val cursorIdx = Cursor.viH (buffer, cursorIdx)
val preferredColumn = Cursor.getCursorColumn (buffer, cursorIdx)
val buffer = LineGap.goToLine (startLine, buffer)
val drawMsg = TextBuilder.build
(startLine, cursorIdx, buffer, windowWidth, windowHeight)
val newApp = AppWith.bufferAndCursorIdx (app, buffer, cursorIdx)
val newApp =
AppWith.bufferAndCursorIdx (app, buffer, cursorIdx, preferredColumn)
in
(newApp, drawMsg)
end