add preferredColumn field to app type
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user