amend problem with TextWindow.getStartLineBefore, where we were not following rule mentioned in previous commits to not count (graphical-chr -> \n) as line break
This commit is contained in:
@@ -262,34 +262,34 @@ struct
|
|||||||
let
|
let
|
||||||
(* delete char at cursor and then decrement cursorIdx by 1
|
(* delete char at cursor and then decrement cursorIdx by 1
|
||||||
* if cursorIdx is not 0 *)
|
* if cursorIdx is not 0 *)
|
||||||
val newBuffer = LineGap.delete (cursorIdx, 1, buffer)
|
val buffer = LineGap.delete (cursorIdx, 1, buffer)
|
||||||
val cursorIdx =
|
val cursorIdx =
|
||||||
if Cursor.isPrevChrStartOfLine (newBuffer, cursorIdx)
|
if Cursor.isPrevChrStartOfLine (buffer, cursorIdx)
|
||||||
orelse cursorIdx = 0 then
|
orelse cursorIdx = 0 then
|
||||||
cursorIdx
|
cursorIdx
|
||||||
else cursorIdx - 1
|
else cursorIdx - 1
|
||||||
|
|
||||||
val newBuffer = LineGap.goToLine (startLine, newBuffer)
|
val buffer = LineGap.goToLine (startLine, buffer)
|
||||||
val newApp = AppWith.bufferAndCursorIdx
|
val newApp = AppWith.bufferAndCursorIdx
|
||||||
(app, newBuffer, cursorIdx, NORMAL_MODE "", startLine)
|
(app, buffer, cursorIdx, NORMAL_MODE "", startLine)
|
||||||
|
|
||||||
val drawMsg =
|
val drawMsg =
|
||||||
TextBuilder.build
|
TextBuilder.build
|
||||||
(startLine, cursorIdx, newBuffer, windowWidth, windowHeight)
|
(startLine, cursorIdx, buffer, windowWidth, windowHeight)
|
||||||
in
|
in
|
||||||
(newApp, drawMsg)
|
(newApp, drawMsg)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
let
|
let
|
||||||
val newBuffer = LineGap.delete (cursorIdx, 1, buffer)
|
val buffer = LineGap.delete (cursorIdx, 1, buffer)
|
||||||
|
|
||||||
val newBuffer = LineGap.goToLine (startLine, newBuffer)
|
val buffer = LineGap.goToLine (startLine, buffer)
|
||||||
val newApp = AppWith.bufferAndCursorIdx
|
val newApp = AppWith.bufferAndCursorIdx
|
||||||
(app, newBuffer, cursorIdx, NORMAL_MODE "", startLine)
|
(app, buffer, cursorIdx, NORMAL_MODE "", startLine)
|
||||||
|
|
||||||
val drawMsg =
|
val drawMsg =
|
||||||
TextBuilder.build
|
TextBuilder.build
|
||||||
(startLine, cursorIdx, newBuffer, windowWidth, windowHeight)
|
(startLine, cursorIdx, buffer, windowWidth, windowHeight)
|
||||||
in
|
in
|
||||||
(newApp, drawMsg)
|
(newApp, drawMsg)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -20,23 +20,24 @@ struct
|
|||||||
| [] =>
|
| [] =>
|
||||||
0
|
0
|
||||||
else
|
else
|
||||||
let
|
if absIdx <= cursorIdx then
|
||||||
val chr = String.sub (shd, sIdx)
|
lineNum
|
||||||
in
|
else
|
||||||
if chr = #"\n" then
|
let
|
||||||
if absIdx <> cursorIdx then
|
val chr = String.sub (shd, sIdx)
|
||||||
getStartLineBefore
|
in
|
||||||
(sIdx - 1, shd, lineNum - 1, absIdx - 1, cursorIdx, stl)
|
if chr = #"\n" then
|
||||||
|
if isPrevChrLn (shd, sIdx, stl) then
|
||||||
|
(* \n -> \n *)
|
||||||
|
getStartLineBefore
|
||||||
|
(sIdx - 1, shd, lineNum - 1, absIdx - 1, cursorIdx, stl)
|
||||||
|
else
|
||||||
|
(* graphical-chr -> \n *)
|
||||||
|
getStartLineBefore
|
||||||
|
(sIdx - 1, shd, lineNum, absIdx - 1, cursorIdx, stl)
|
||||||
else
|
else
|
||||||
(* we have found cursor, and it is at \n *)
|
|
||||||
lineNum - 1
|
|
||||||
else
|
|
||||||
if absIdx <> cursorIdx then
|
|
||||||
getStartLineBefore
|
getStartLineBefore
|
||||||
(sIdx - 1, shd, lineNum, absIdx - 1, cursorIdx, stl)
|
(sIdx - 1, shd, lineNum, absIdx - 1, cursorIdx, stl)
|
||||||
else
|
|
||||||
(* we have found cursor; return line *)
|
|
||||||
lineNum - 1
|
|
||||||
end
|
end
|
||||||
|
|
||||||
fun getStartLineAfter
|
fun getStartLineAfter
|
||||||
|
|||||||
Reference in New Issue
Block a user