refactor to make sure that we count the visual scroll column on move/delete, in normal mode
This commit is contained in:
@@ -400,6 +400,7 @@ struct
|
||||
|
||||
val cursorIdx = 0
|
||||
val startLine = 0
|
||||
val visualScrollColumn = 0
|
||||
val buffer = LineGap.goToIdx (cursorIdx, buffer)
|
||||
|
||||
val drawMsg = TextBuilder.build
|
||||
@@ -416,7 +417,16 @@ struct
|
||||
val mode = NORMAL_MODE ""
|
||||
in
|
||||
NormalModeWith.bufferAndCursorIdx
|
||||
(app, buffer, cursorIdx, mode, startLine, searchList, drawMsg, time)
|
||||
( app
|
||||
, buffer
|
||||
, cursorIdx
|
||||
, mode
|
||||
, startLine
|
||||
, searchList
|
||||
, drawMsg
|
||||
, time
|
||||
, visualScrollColumn
|
||||
)
|
||||
end
|
||||
|
||||
fun helpDeleteToMatch (app: app_type, low, high, time) =
|
||||
|
||||
@@ -16,7 +16,8 @@ struct
|
||||
|
||||
(* calculate scroll column *)
|
||||
val buffer = LineGap.goToIdx (cursorIdx, buffer)
|
||||
val visualScrollColumn = TextScroll.getScrollColumn (buffer, cursorIdx, windowWidth)
|
||||
val visualScrollColumn =
|
||||
TextScroll.getScrollColumn (buffer, cursorIdx, windowWidth)
|
||||
|
||||
(* move LineGap to first line displayed on screen *)
|
||||
val buffer = LineGap.goToLine (startLine, buffer)
|
||||
@@ -50,6 +51,7 @@ struct
|
||||
, searchList
|
||||
, msgs
|
||||
, bufferModifyTime
|
||||
, visualScrollColumn
|
||||
)
|
||||
end
|
||||
|
||||
@@ -84,7 +86,10 @@ struct
|
||||
, ...
|
||||
} = app
|
||||
|
||||
val newBuffer = LineGap.goToLine (startLine, buffer)
|
||||
val newBuffer = LineGap.goToIdx (cursorIdx, buffer)
|
||||
val visualScrollColumn =
|
||||
TextScroll.getScrollColumn (buffer, cursorIdx, windowWidth)
|
||||
val newBuffer = LineGap.goToLine (startLine, newBuffer)
|
||||
val lineIdx = TextBuilder.getLineAbsIdx (startLine, buffer)
|
||||
|
||||
val drawMsg = TextBuilder.build
|
||||
@@ -106,6 +111,7 @@ struct
|
||||
, searchList
|
||||
, drawMsg
|
||||
, bufferModifyTime
|
||||
, visualScrollColumn
|
||||
)
|
||||
end
|
||||
|
||||
@@ -119,6 +125,10 @@ struct
|
||||
let
|
||||
val {windowWidth, windowHeight, startLine, searchString, ...} = app
|
||||
|
||||
val buffer = LineGap.goToIdx (cursorIdx, buffer)
|
||||
val visualScrollColumn =
|
||||
TextScroll.getScrollColumn (buffer, cursorIdx, windowWidth)
|
||||
|
||||
(* move LineGap to first line displayed on screen *)
|
||||
val buffer = LineGap.goToLine (startLine, buffer)
|
||||
|
||||
@@ -152,6 +162,7 @@ struct
|
||||
, searchList
|
||||
, drawMsg
|
||||
, bufferModifyTime
|
||||
, visualScrollColumn
|
||||
)
|
||||
end
|
||||
|
||||
@@ -186,6 +197,9 @@ struct
|
||||
, searchString
|
||||
, []
|
||||
)
|
||||
in
|
||||
let
|
||||
val _ = raise Fail "centering to line is unimplemented\n"
|
||||
in
|
||||
NormalModeWith.bufferAndCursorIdx
|
||||
( app
|
||||
@@ -196,6 +210,8 @@ struct
|
||||
, searchList
|
||||
, drawMsg
|
||||
, bufferModifyTime
|
||||
, #visualScrollColumn app
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -10,6 +10,7 @@ struct
|
||||
, newSearchList
|
||||
, newMsgs
|
||||
, newBufferModifyTime
|
||||
, newVisualScrollColumn
|
||||
) =
|
||||
let
|
||||
val
|
||||
@@ -19,11 +20,11 @@ struct
|
||||
, windowWidth = _
|
||||
, windowHeight = _
|
||||
, searchList = _
|
||||
, visualScrollColumn = _
|
||||
, msgs = _
|
||||
, searchString
|
||||
, startLine
|
||||
, cursorIdx
|
||||
, visualScrollColumn
|
||||
} = app
|
||||
in
|
||||
{ mode = mode
|
||||
@@ -32,11 +33,11 @@ struct
|
||||
, windowWidth = newWidth
|
||||
, windowHeight = newHeight
|
||||
, searchList = newSearchList
|
||||
, visualScrollColumn = newVisualScrollColumn
|
||||
, msgs = newMsgs
|
||||
, searchString = searchString
|
||||
, startLine = startLine
|
||||
, cursorIdx = cursorIdx
|
||||
, visualScrollColumn = visualScrollColumn
|
||||
}
|
||||
end
|
||||
|
||||
@@ -49,6 +50,7 @@ struct
|
||||
, newSearchList
|
||||
, newMsgs
|
||||
, newBufferModifyTime
|
||||
, newVisualScrollColumn
|
||||
) =
|
||||
let
|
||||
val
|
||||
@@ -58,11 +60,11 @@ struct
|
||||
, cursorIdx = _
|
||||
, startLine = _
|
||||
, searchList = _
|
||||
, visualScrollColumn = _
|
||||
, msgs = _
|
||||
, searchString
|
||||
, windowWidth
|
||||
, windowHeight
|
||||
, visualScrollColumn
|
||||
} = app
|
||||
in
|
||||
{ mode = newMode
|
||||
@@ -71,11 +73,11 @@ struct
|
||||
, cursorIdx = newCursorIdx
|
||||
, startLine = newStartLine
|
||||
, searchList = newSearchList
|
||||
, visualScrollColumn = newVisualScrollColumn
|
||||
, msgs = newMsgs
|
||||
, searchString = searchString
|
||||
, windowWidth = windowWidth
|
||||
, windowHeight = windowHeight
|
||||
, visualScrollColumn = visualScrollColumn
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
@@ -40,6 +40,7 @@ struct
|
||||
, searchList
|
||||
, drawMsg
|
||||
, bufferModifyTime
|
||||
, 0
|
||||
)
|
||||
end
|
||||
|
||||
@@ -63,6 +64,8 @@ struct
|
||||
val bufferLine = bufferLine - 1
|
||||
|
||||
val buffer = LineGap.goToIdx (bufferIdx, buffer)
|
||||
val visualScrollColumn =
|
||||
TextScroll.getScrollColumn (buffer, bufferIdx, windowWidth)
|
||||
val bufferLine =
|
||||
let
|
||||
val maxHeight = windowHeight - TextConstants.ySpace
|
||||
@@ -96,6 +99,7 @@ struct
|
||||
, searchList
|
||||
, drawMsg
|
||||
, bufferModifyTime
|
||||
, visualScrollColumn
|
||||
)
|
||||
end
|
||||
|
||||
@@ -120,6 +124,8 @@ struct
|
||||
val cursorIdx = Cursor.getLineStartIdx (buffer, reqLine)
|
||||
|
||||
val buffer = LineGap.goToIdx (cursorIdx, buffer)
|
||||
val visualScrollColumn =
|
||||
TextScroll.getScrollColumn (buffer, cursorIdx, windowWidth)
|
||||
val startLine = TextWindow.getStartLineWithCursorCentered
|
||||
(buffer, cursorIdx, origLine, windowWidth, windowHeight div 2)
|
||||
|
||||
@@ -148,6 +154,7 @@ struct
|
||||
, searchList
|
||||
, drawMsg
|
||||
, bufferModifyTime
|
||||
, visualScrollColumn
|
||||
)
|
||||
end
|
||||
|
||||
@@ -172,38 +179,10 @@ struct
|
||||
val buffer = LineGap.goToLine (startLine, buffer)
|
||||
val lineIdx = TextBuilder.getLineAbsIdx (startLine, buffer)
|
||||
in
|
||||
if
|
||||
TextWindow.isCursorVisible
|
||||
(buffer, cursorIdx, startLine, windowWidth, windowHeight)
|
||||
then
|
||||
(* if visible, just need to redraw; no need to get line *)
|
||||
let
|
||||
val drawMsg = TextBuilder.build
|
||||
( startLine
|
||||
, cursorIdx
|
||||
, buffer
|
||||
, windowWidth
|
||||
, windowHeight
|
||||
, searchList
|
||||
, searchString
|
||||
, []
|
||||
)
|
||||
in
|
||||
NormalModeWith.bufferAndCursorIdx
|
||||
( app
|
||||
, buffer
|
||||
, cursorIdx
|
||||
, NORMAL_MODE ""
|
||||
, startLine
|
||||
, searchList
|
||||
, drawMsg
|
||||
, bufferModifyTime
|
||||
)
|
||||
end
|
||||
else
|
||||
(* not visible, so need to get startLine where cursor is visible *)
|
||||
let
|
||||
val buffer = LineGap.goToIdx (cursorIdx, buffer)
|
||||
val visualScrollColumn =
|
||||
TextScroll.getScrollColumn (buffer, cursorIdx, windowWidth)
|
||||
val startLine = TextWindow.getStartLineWithCursorCentered
|
||||
(buffer, cursorIdx, startLine, windowWidth, windowHeight div 2)
|
||||
|
||||
@@ -230,6 +209,7 @@ struct
|
||||
, searchList
|
||||
, drawMsg
|
||||
, bufferModifyTime
|
||||
, visualScrollColumn
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user