diff --git a/fcore/app-type.sml b/fcore/app-type.sml index d1ea4eb..ef957c0 100644 --- a/fcore/app-type.sml +++ b/fcore/app-type.sml @@ -4,8 +4,13 @@ struct { buffer: LineGap.t , windowWidth: int , windowHeight: int + (* line to start drawing from *) , startLine: int + (* absolute index of movable cursor *) , cursorIdx: int + (* when moving cursor up or down a line, + * move to this column if possible *) + , preferredColumn: int } fun init (buffer, windowWidth, windowHeight) : app_type = @@ -14,5 +19,6 @@ struct , windowHeight = windowHeight , startLine = 0 , cursorIdx = 0 + , preferredColumn = 0 } end diff --git a/fcore/app-update.sml b/fcore/app-update.sml index fa3f36d..a34990d 100644 --- a/fcore/app-update.sml +++ b/fcore/app-update.sml @@ -8,7 +8,7 @@ struct fun resizeText (app: app_type, newWidth, newHeight) = let - val {buffer, windowWidth, windowHeight, startLine, cursorIdx} = app + val {buffer, windowWidth, windowHeight, startLine, cursorIdx, ...} = app val newBuffer = LineGap.goToLine (startLine, buffer) val drawMsg = TextBuilder.build @@ -21,7 +21,7 @@ struct fun moveRight (app: app_type) = let - val {buffer, windowWidth, windowHeight, startLine, cursorIdx} = app + val {buffer, windowWidth, windowHeight, startLine, cursorIdx, ...} = app (* move LineGap to cursorIdx, which is necessary for finding newCursorIdx *) val buffer = LineGap.goToIdx (cursorIdx, buffer) @@ -39,7 +39,7 @@ struct fun moveLeft (app: app_type) = let - val {buffer, windowWidth, windowHeight, startLine, cursorIdx} = app + val {buffer, windowWidth, windowHeight, startLine, cursorIdx, ...} = app val buffer = LineGap.goToIdx (cursorIdx, buffer) val cursorIdx = Cursor.viH (buffer, cursorIdx) diff --git a/fcore/app-with.sml b/fcore/app-with.sml index 25c6c51..14b1b5e 100644 --- a/fcore/app-with.sml +++ b/fcore/app-with.sml @@ -4,27 +4,41 @@ struct fun bufferAndSize (app: app_type, newBuffer, newWidth, newHeight) = let - val {buffer = _, windowWidth = _, windowHeight = _, startLine, cursorIdx} = - app + val + { buffer = _ + , windowWidth = _ + , windowHeight = _ + , startLine + , cursorIdx + , preferredColumn + } = app in { buffer = newBuffer , windowWidth = newWidth , windowHeight = newHeight , startLine = startLine , cursorIdx = cursorIdx + , preferredColumn = preferredColumn } end fun bufferAndCursorIdx (app: app_type, newBuffer, newCursorIdx) = let - val {buffer = _, cursorIdx = _, windowWidth, windowHeight, startLine} = - app + val + { buffer = _ + , cursorIdx = _ + , windowWidth + , windowHeight + , startLine + , preferredColumn + } = app in { buffer = newBuffer , cursorIdx = newCursorIdx , windowWidth = windowWidth , windowHeight = windowHeight , startLine = startLine + , preferredColumn = preferredColumn } end end diff --git a/shf b/shf index 75e4bf3..255b1bc 100755 Binary files a/shf and b/shf differ