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 cursorIdx = 0
|
||||||
val startLine = 0
|
val startLine = 0
|
||||||
|
val visualScrollColumn = 0
|
||||||
val buffer = LineGap.goToIdx (cursorIdx, buffer)
|
val buffer = LineGap.goToIdx (cursorIdx, buffer)
|
||||||
|
|
||||||
val drawMsg = TextBuilder.build
|
val drawMsg = TextBuilder.build
|
||||||
@@ -416,7 +417,16 @@ struct
|
|||||||
val mode = NORMAL_MODE ""
|
val mode = NORMAL_MODE ""
|
||||||
in
|
in
|
||||||
NormalModeWith.bufferAndCursorIdx
|
NormalModeWith.bufferAndCursorIdx
|
||||||
(app, buffer, cursorIdx, mode, startLine, searchList, drawMsg, time)
|
( app
|
||||||
|
, buffer
|
||||||
|
, cursorIdx
|
||||||
|
, mode
|
||||||
|
, startLine
|
||||||
|
, searchList
|
||||||
|
, drawMsg
|
||||||
|
, time
|
||||||
|
, visualScrollColumn
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
fun helpDeleteToMatch (app: app_type, low, high, time) =
|
fun helpDeleteToMatch (app: app_type, low, high, time) =
|
||||||
|
|||||||
@@ -16,7 +16,8 @@ struct
|
|||||||
|
|
||||||
(* calculate scroll column *)
|
(* calculate scroll column *)
|
||||||
val buffer = LineGap.goToIdx (cursorIdx, buffer)
|
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 *)
|
(* move LineGap to first line displayed on screen *)
|
||||||
val buffer = LineGap.goToLine (startLine, buffer)
|
val buffer = LineGap.goToLine (startLine, buffer)
|
||||||
@@ -50,6 +51,7 @@ struct
|
|||||||
, searchList
|
, searchList
|
||||||
, msgs
|
, msgs
|
||||||
, bufferModifyTime
|
, bufferModifyTime
|
||||||
|
, visualScrollColumn
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -84,7 +86,10 @@ struct
|
|||||||
, ...
|
, ...
|
||||||
} = app
|
} = 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 lineIdx = TextBuilder.getLineAbsIdx (startLine, buffer)
|
||||||
|
|
||||||
val drawMsg = TextBuilder.build
|
val drawMsg = TextBuilder.build
|
||||||
@@ -106,6 +111,7 @@ struct
|
|||||||
, searchList
|
, searchList
|
||||||
, drawMsg
|
, drawMsg
|
||||||
, bufferModifyTime
|
, bufferModifyTime
|
||||||
|
, visualScrollColumn
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -119,6 +125,10 @@ struct
|
|||||||
let
|
let
|
||||||
val {windowWidth, windowHeight, startLine, searchString, ...} = app
|
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 *)
|
(* move LineGap to first line displayed on screen *)
|
||||||
val buffer = LineGap.goToLine (startLine, buffer)
|
val buffer = LineGap.goToLine (startLine, buffer)
|
||||||
|
|
||||||
@@ -152,6 +162,7 @@ struct
|
|||||||
, searchList
|
, searchList
|
||||||
, drawMsg
|
, drawMsg
|
||||||
, bufferModifyTime
|
, bufferModifyTime
|
||||||
|
, visualScrollColumn
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -187,15 +198,20 @@ struct
|
|||||||
, []
|
, []
|
||||||
)
|
)
|
||||||
in
|
in
|
||||||
NormalModeWith.bufferAndCursorIdx
|
let
|
||||||
( app
|
val _ = raise Fail "centering to line is unimplemented\n"
|
||||||
, buffer
|
in
|
||||||
, cursorIdx
|
NormalModeWith.bufferAndCursorIdx
|
||||||
, NORMAL_MODE ""
|
( app
|
||||||
, startLine
|
, buffer
|
||||||
, searchList
|
, cursorIdx
|
||||||
, drawMsg
|
, NORMAL_MODE ""
|
||||||
, bufferModifyTime
|
, startLine
|
||||||
)
|
, searchList
|
||||||
|
, drawMsg
|
||||||
|
, bufferModifyTime
|
||||||
|
, #visualScrollColumn app
|
||||||
|
)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ struct
|
|||||||
, newSearchList
|
, newSearchList
|
||||||
, newMsgs
|
, newMsgs
|
||||||
, newBufferModifyTime
|
, newBufferModifyTime
|
||||||
|
, newVisualScrollColumn
|
||||||
) =
|
) =
|
||||||
let
|
let
|
||||||
val
|
val
|
||||||
@@ -19,11 +20,11 @@ struct
|
|||||||
, windowWidth = _
|
, windowWidth = _
|
||||||
, windowHeight = _
|
, windowHeight = _
|
||||||
, searchList = _
|
, searchList = _
|
||||||
|
, visualScrollColumn = _
|
||||||
, msgs = _
|
, msgs = _
|
||||||
, searchString
|
, searchString
|
||||||
, startLine
|
, startLine
|
||||||
, cursorIdx
|
, cursorIdx
|
||||||
, visualScrollColumn
|
|
||||||
} = app
|
} = app
|
||||||
in
|
in
|
||||||
{ mode = mode
|
{ mode = mode
|
||||||
@@ -32,11 +33,11 @@ struct
|
|||||||
, windowWidth = newWidth
|
, windowWidth = newWidth
|
||||||
, windowHeight = newHeight
|
, windowHeight = newHeight
|
||||||
, searchList = newSearchList
|
, searchList = newSearchList
|
||||||
|
, visualScrollColumn = newVisualScrollColumn
|
||||||
, msgs = newMsgs
|
, msgs = newMsgs
|
||||||
, searchString = searchString
|
, searchString = searchString
|
||||||
, startLine = startLine
|
, startLine = startLine
|
||||||
, cursorIdx = cursorIdx
|
, cursorIdx = cursorIdx
|
||||||
, visualScrollColumn = visualScrollColumn
|
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -49,6 +50,7 @@ struct
|
|||||||
, newSearchList
|
, newSearchList
|
||||||
, newMsgs
|
, newMsgs
|
||||||
, newBufferModifyTime
|
, newBufferModifyTime
|
||||||
|
, newVisualScrollColumn
|
||||||
) =
|
) =
|
||||||
let
|
let
|
||||||
val
|
val
|
||||||
@@ -58,11 +60,11 @@ struct
|
|||||||
, cursorIdx = _
|
, cursorIdx = _
|
||||||
, startLine = _
|
, startLine = _
|
||||||
, searchList = _
|
, searchList = _
|
||||||
|
, visualScrollColumn = _
|
||||||
, msgs = _
|
, msgs = _
|
||||||
, searchString
|
, searchString
|
||||||
, windowWidth
|
, windowWidth
|
||||||
, windowHeight
|
, windowHeight
|
||||||
, visualScrollColumn
|
|
||||||
} = app
|
} = app
|
||||||
in
|
in
|
||||||
{ mode = newMode
|
{ mode = newMode
|
||||||
@@ -71,11 +73,11 @@ struct
|
|||||||
, cursorIdx = newCursorIdx
|
, cursorIdx = newCursorIdx
|
||||||
, startLine = newStartLine
|
, startLine = newStartLine
|
||||||
, searchList = newSearchList
|
, searchList = newSearchList
|
||||||
|
, visualScrollColumn = newVisualScrollColumn
|
||||||
, msgs = newMsgs
|
, msgs = newMsgs
|
||||||
, searchString = searchString
|
, searchString = searchString
|
||||||
, windowWidth = windowWidth
|
, windowWidth = windowWidth
|
||||||
, windowHeight = windowHeight
|
, windowHeight = windowHeight
|
||||||
, visualScrollColumn = visualScrollColumn
|
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ struct
|
|||||||
, searchList
|
, searchList
|
||||||
, drawMsg
|
, drawMsg
|
||||||
, bufferModifyTime
|
, bufferModifyTime
|
||||||
|
, 0
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -63,6 +64,8 @@ struct
|
|||||||
val bufferLine = bufferLine - 1
|
val bufferLine = bufferLine - 1
|
||||||
|
|
||||||
val buffer = LineGap.goToIdx (bufferIdx, buffer)
|
val buffer = LineGap.goToIdx (bufferIdx, buffer)
|
||||||
|
val visualScrollColumn =
|
||||||
|
TextScroll.getScrollColumn (buffer, bufferIdx, windowWidth)
|
||||||
val bufferLine =
|
val bufferLine =
|
||||||
let
|
let
|
||||||
val maxHeight = windowHeight - TextConstants.ySpace
|
val maxHeight = windowHeight - TextConstants.ySpace
|
||||||
@@ -96,6 +99,7 @@ struct
|
|||||||
, searchList
|
, searchList
|
||||||
, drawMsg
|
, drawMsg
|
||||||
, bufferModifyTime
|
, bufferModifyTime
|
||||||
|
, visualScrollColumn
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -120,6 +124,8 @@ struct
|
|||||||
val cursorIdx = Cursor.getLineStartIdx (buffer, reqLine)
|
val cursorIdx = Cursor.getLineStartIdx (buffer, reqLine)
|
||||||
|
|
||||||
val buffer = LineGap.goToIdx (cursorIdx, buffer)
|
val buffer = LineGap.goToIdx (cursorIdx, buffer)
|
||||||
|
val visualScrollColumn =
|
||||||
|
TextScroll.getScrollColumn (buffer, cursorIdx, windowWidth)
|
||||||
val startLine = TextWindow.getStartLineWithCursorCentered
|
val startLine = TextWindow.getStartLineWithCursorCentered
|
||||||
(buffer, cursorIdx, origLine, windowWidth, windowHeight div 2)
|
(buffer, cursorIdx, origLine, windowWidth, windowHeight div 2)
|
||||||
|
|
||||||
@@ -148,6 +154,7 @@ struct
|
|||||||
, searchList
|
, searchList
|
||||||
, drawMsg
|
, drawMsg
|
||||||
, bufferModifyTime
|
, bufferModifyTime
|
||||||
|
, visualScrollColumn
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -172,66 +179,39 @@ struct
|
|||||||
val buffer = LineGap.goToLine (startLine, buffer)
|
val buffer = LineGap.goToLine (startLine, buffer)
|
||||||
val lineIdx = TextBuilder.getLineAbsIdx (startLine, buffer)
|
val lineIdx = TextBuilder.getLineAbsIdx (startLine, buffer)
|
||||||
in
|
in
|
||||||
if
|
let
|
||||||
TextWindow.isCursorVisible
|
val buffer = LineGap.goToIdx (cursorIdx, buffer)
|
||||||
(buffer, cursorIdx, startLine, windowWidth, windowHeight)
|
val visualScrollColumn =
|
||||||
then
|
TextScroll.getScrollColumn (buffer, cursorIdx, windowWidth)
|
||||||
(* if visible, just need to redraw; no need to get line *)
|
val startLine = TextWindow.getStartLineWithCursorCentered
|
||||||
let
|
(buffer, cursorIdx, startLine, windowWidth, windowHeight div 2)
|
||||||
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 startLine = TextWindow.getStartLineWithCursorCentered
|
|
||||||
(buffer, cursorIdx, startLine, windowWidth, windowHeight div 2)
|
|
||||||
|
|
||||||
val buffer = LineGap.goToLine (startLine, buffer)
|
val buffer = LineGap.goToLine (startLine, buffer)
|
||||||
val lineIdx = TextBuilder.getLineAbsIdx (startLine, buffer)
|
val lineIdx = TextBuilder.getLineAbsIdx (startLine, buffer)
|
||||||
|
|
||||||
val drawMsg = TextBuilder.build
|
val drawMsg = TextBuilder.build
|
||||||
( startLine
|
( startLine
|
||||||
, cursorIdx
|
, cursorIdx
|
||||||
, buffer
|
, buffer
|
||||||
, windowWidth
|
, windowWidth
|
||||||
, windowHeight
|
, windowHeight
|
||||||
, searchList
|
, searchList
|
||||||
, searchString
|
, searchString
|
||||||
, []
|
, []
|
||||||
)
|
)
|
||||||
in
|
in
|
||||||
NormalModeWith.bufferAndCursorIdx
|
NormalModeWith.bufferAndCursorIdx
|
||||||
( app
|
( app
|
||||||
, buffer
|
, buffer
|
||||||
, cursorIdx
|
, cursorIdx
|
||||||
, NORMAL_MODE ""
|
, NORMAL_MODE ""
|
||||||
, startLine
|
, startLine
|
||||||
, searchList
|
, searchList
|
||||||
, drawMsg
|
, drawMsg
|
||||||
, bufferModifyTime
|
, bufferModifyTime
|
||||||
)
|
, visualScrollColumn
|
||||||
end
|
)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
fun firstNonSpaceChr (app: app_type) =
|
fun firstNonSpaceChr (app: app_type) =
|
||||||
|
|||||||
Reference in New Issue
Block a user