ensure that searchList is deleted from when calling delete functions other than 'helpRemoveChr'
This commit is contained in:
@@ -29,9 +29,13 @@ struct
|
|||||||
|
|
||||||
val newBuffer = LineGap.goToLine (startLine, buffer)
|
val newBuffer = LineGap.goToLine (startLine, buffer)
|
||||||
val drawMsg = TextBuilder.build
|
val drawMsg = TextBuilder.build
|
||||||
( startLine, cursorIdx, newBuffer
|
( startLine
|
||||||
, newWidth, newHeight
|
, cursorIdx
|
||||||
, searchList, searchString
|
, newBuffer
|
||||||
|
, newWidth
|
||||||
|
, newHeight
|
||||||
|
, searchList
|
||||||
|
, searchString
|
||||||
)
|
)
|
||||||
|
|
||||||
val newApp = AppWith.bufferAndSize (app, newBuffer, newWidth, newHeight)
|
val newApp = AppWith.bufferAndSize (app, newBuffer, newWidth, newHeight)
|
||||||
@@ -39,10 +43,9 @@ struct
|
|||||||
(newApp, drawMsg)
|
(newApp, drawMsg)
|
||||||
end
|
end
|
||||||
|
|
||||||
fun buildTextAndClear (app: app_type, buffer, cursorIdx) =
|
fun buildTextAndClear (app: app_type, buffer, cursorIdx, searchList) =
|
||||||
let
|
let
|
||||||
val {windowWidth, windowHeight, startLine, searchList, searchString, ...} =
|
val {windowWidth, windowHeight, startLine, searchString, ...} = app
|
||||||
app
|
|
||||||
|
|
||||||
(* 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)
|
||||||
@@ -55,14 +58,18 @@ struct
|
|||||||
val buffer = LineGap.goToLine (startLine, buffer)
|
val buffer = LineGap.goToLine (startLine, buffer)
|
||||||
|
|
||||||
val drawMsg = TextBuilder.build
|
val drawMsg = TextBuilder.build
|
||||||
( startLine, cursorIdx, buffer
|
( startLine
|
||||||
, windowWidth, windowHeight
|
, cursorIdx
|
||||||
, searchList, searchString
|
, buffer
|
||||||
|
, windowWidth
|
||||||
|
, windowHeight
|
||||||
|
, searchList
|
||||||
|
, searchString
|
||||||
)
|
)
|
||||||
|
|
||||||
val mode = NORMAL_MODE ""
|
val mode = NORMAL_MODE ""
|
||||||
val newApp = AppWith.bufferAndCursorIdx
|
val newApp = AppWith.bufferAndCursorIdx
|
||||||
(app, buffer, cursorIdx, mode, startLine)
|
(app, buffer, cursorIdx, mode, startLine, searchList)
|
||||||
in
|
in
|
||||||
(newApp, drawMsg)
|
(newApp, drawMsg)
|
||||||
end
|
end
|
||||||
@@ -72,10 +79,9 @@ struct
|
|||||||
* where the cursor may possibly jump off window by a wide marigin.
|
* where the cursor may possibly jump off window by a wide marigin.
|
||||||
* Since the cursor may move away a lot, it is best to recenter.
|
* Since the cursor may move away a lot, it is best to recenter.
|
||||||
* *)
|
* *)
|
||||||
fun buildTextAndClearAfterChr (app: app_type, buffer, cursorIdx) =
|
fun buildTextAndClearAfterChr (app: app_type, buffer, cursorIdx, searchList) =
|
||||||
let
|
let
|
||||||
val {windowWidth, windowHeight, startLine, searchList, searchString, ...} =
|
val {windowWidth, windowHeight, startLine, searchString, ...} = app
|
||||||
app
|
|
||||||
|
|
||||||
(* 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)
|
||||||
@@ -88,14 +94,18 @@ struct
|
|||||||
val buffer = LineGap.goToLine (startLine, buffer)
|
val buffer = LineGap.goToLine (startLine, buffer)
|
||||||
|
|
||||||
val drawMsg = TextBuilder.build
|
val drawMsg = TextBuilder.build
|
||||||
( startLine, cursorIdx, buffer
|
( startLine
|
||||||
, windowWidth, windowHeight
|
, cursorIdx
|
||||||
, searchList, searchString
|
, buffer
|
||||||
|
, windowWidth
|
||||||
|
, windowHeight
|
||||||
|
, searchList
|
||||||
|
, searchString
|
||||||
)
|
)
|
||||||
|
|
||||||
val mode = NORMAL_MODE ""
|
val mode = NORMAL_MODE ""
|
||||||
val newApp = AppWith.bufferAndCursorIdx
|
val newApp = AppWith.bufferAndCursorIdx
|
||||||
(app, buffer, cursorIdx, mode, startLine)
|
(app, buffer, cursorIdx, mode, startLine, searchList)
|
||||||
in
|
in
|
||||||
(newApp, drawMsg)
|
(newApp, drawMsg)
|
||||||
end
|
end
|
||||||
@@ -120,12 +130,16 @@ struct
|
|||||||
val buffer = LineGap.goToLine (startLine, buffer)
|
val buffer = LineGap.goToLine (startLine, buffer)
|
||||||
|
|
||||||
val newApp = AppWith.bufferAndCursorIdx
|
val newApp = AppWith.bufferAndCursorIdx
|
||||||
(app, buffer, cursorIdx, NORMAL_MODE "", startLine)
|
(app, buffer, cursorIdx, NORMAL_MODE "", startLine, searchList)
|
||||||
|
|
||||||
val drawMsg = TextBuilder.build
|
val drawMsg = TextBuilder.build
|
||||||
( startLine, cursorIdx, buffer
|
( startLine
|
||||||
, windowWidth, windowHeight
|
, cursorIdx
|
||||||
, searchList, searchString
|
, buffer
|
||||||
|
, windowWidth
|
||||||
|
, windowHeight
|
||||||
|
, searchList
|
||||||
|
, searchString
|
||||||
)
|
)
|
||||||
in
|
in
|
||||||
(newApp, drawMsg)
|
(newApp, drawMsg)
|
||||||
@@ -143,14 +157,18 @@ struct
|
|||||||
val buffer = LineGap.goToIdx (cursorIdx, buffer)
|
val buffer = LineGap.goToIdx (cursorIdx, buffer)
|
||||||
|
|
||||||
val drawMsg = TextBuilder.build
|
val drawMsg = TextBuilder.build
|
||||||
( startLine, cursorIdx, buffer
|
( startLine
|
||||||
, windowWidth, windowHeight
|
, cursorIdx
|
||||||
, searchList, searchString
|
, buffer
|
||||||
|
, windowWidth
|
||||||
|
, windowHeight
|
||||||
|
, searchList
|
||||||
|
, searchString
|
||||||
)
|
)
|
||||||
|
|
||||||
val mode = NORMAL_MODE ""
|
val mode = NORMAL_MODE ""
|
||||||
val newApp = AppWith.bufferAndCursorIdx
|
val newApp = AppWith.bufferAndCursorIdx
|
||||||
(app, buffer, cursorIdx, mode, startLine)
|
(app, buffer, cursorIdx, mode, startLine, searchList)
|
||||||
in
|
in
|
||||||
(newApp, drawMsg)
|
(newApp, drawMsg)
|
||||||
end
|
end
|
||||||
@@ -178,14 +196,18 @@ struct
|
|||||||
|
|
||||||
val buffer = LineGap.goToLine (bufferLine, buffer)
|
val buffer = LineGap.goToLine (bufferLine, buffer)
|
||||||
val drawMsg = TextBuilder.build
|
val drawMsg = TextBuilder.build
|
||||||
( bufferLine, bufferIdx, buffer
|
( bufferLine
|
||||||
, windowWidth, windowHeight
|
, bufferIdx
|
||||||
, searchList, searchString
|
, buffer
|
||||||
|
, windowWidth
|
||||||
|
, windowHeight
|
||||||
|
, searchList
|
||||||
|
, searchString
|
||||||
)
|
)
|
||||||
|
|
||||||
val mode = NORMAL_MODE ""
|
val mode = NORMAL_MODE ""
|
||||||
val newApp = AppWith.bufferAndCursorIdx
|
val newApp = AppWith.bufferAndCursorIdx
|
||||||
(app, buffer, bufferIdx, mode, bufferLine)
|
(app, buffer, bufferIdx, mode, bufferLine, searchList)
|
||||||
in
|
in
|
||||||
(newApp, drawMsg)
|
(newApp, drawMsg)
|
||||||
end
|
end
|
||||||
@@ -216,12 +238,16 @@ struct
|
|||||||
val buffer = LineGap.goToLine (startLine, buffer)
|
val buffer = LineGap.goToLine (startLine, buffer)
|
||||||
|
|
||||||
val newApp = AppWith.bufferAndCursorIdx
|
val newApp = AppWith.bufferAndCursorIdx
|
||||||
(app, buffer, cursorIdx, NORMAL_MODE "", startLine)
|
(app, buffer, cursorIdx, NORMAL_MODE "", startLine, searchList)
|
||||||
|
|
||||||
val drawMsg = TextBuilder.build
|
val drawMsg = TextBuilder.build
|
||||||
( startLine, cursorIdx, buffer
|
( startLine
|
||||||
, windowWidth, windowHeight
|
, cursorIdx
|
||||||
, searchList, searchString
|
, buffer
|
||||||
|
, windowWidth
|
||||||
|
, windowHeight
|
||||||
|
, searchList
|
||||||
|
, searchString
|
||||||
)
|
)
|
||||||
in
|
in
|
||||||
(newApp, drawMsg)
|
(newApp, drawMsg)
|
||||||
@@ -229,7 +255,7 @@ struct
|
|||||||
|
|
||||||
fun helpMove (app: app_type, buffer, cursorIdx, count, fMove) =
|
fun helpMove (app: app_type, buffer, cursorIdx, count, fMove) =
|
||||||
if count = 0 then
|
if count = 0 then
|
||||||
buildTextAndClear (app, buffer, cursorIdx)
|
buildTextAndClear (app, buffer, cursorIdx, #searchList app)
|
||||||
else
|
else
|
||||||
(* move LineGap to cursorIdx, which is necessary for finding newCursorIdx *)
|
(* move LineGap to cursorIdx, which is necessary for finding newCursorIdx *)
|
||||||
let
|
let
|
||||||
@@ -279,12 +305,16 @@ struct
|
|||||||
(* if visible, just need to redraw; no need to get line *)
|
(* if visible, just need to redraw; no need to get line *)
|
||||||
let
|
let
|
||||||
val newApp = AppWith.bufferAndCursorIdx
|
val newApp = AppWith.bufferAndCursorIdx
|
||||||
(app, buffer, cursorIdx, NORMAL_MODE "", startLine)
|
(app, buffer, cursorIdx, NORMAL_MODE "", startLine, searchList)
|
||||||
|
|
||||||
val drawMsg = TextBuilder.build
|
val drawMsg = TextBuilder.build
|
||||||
( startLine, cursorIdx, buffer
|
( startLine
|
||||||
, windowWidth, windowHeight
|
, cursorIdx
|
||||||
, searchList, searchString
|
, buffer
|
||||||
|
, windowWidth
|
||||||
|
, windowHeight
|
||||||
|
, searchList
|
||||||
|
, searchString
|
||||||
)
|
)
|
||||||
in
|
in
|
||||||
(newApp, drawMsg)
|
(newApp, drawMsg)
|
||||||
@@ -299,12 +329,16 @@ struct
|
|||||||
val buffer = LineGap.goToLine (startLine, buffer)
|
val buffer = LineGap.goToLine (startLine, buffer)
|
||||||
|
|
||||||
val newApp = AppWith.bufferAndCursorIdx
|
val newApp = AppWith.bufferAndCursorIdx
|
||||||
(app, buffer, cursorIdx, NORMAL_MODE "", startLine)
|
(app, buffer, cursorIdx, NORMAL_MODE "", startLine, searchList)
|
||||||
|
|
||||||
val drawMsg = TextBuilder.build
|
val drawMsg = TextBuilder.build
|
||||||
( startLine, cursorIdx, buffer
|
( startLine
|
||||||
, windowWidth, windowHeight
|
, cursorIdx
|
||||||
, searchList, searchString
|
, buffer
|
||||||
|
, windowWidth
|
||||||
|
, windowHeight
|
||||||
|
, searchList
|
||||||
|
, searchString
|
||||||
)
|
)
|
||||||
in
|
in
|
||||||
(newApp, drawMsg)
|
(newApp, drawMsg)
|
||||||
@@ -323,12 +357,12 @@ struct
|
|||||||
val buffer = LineGap.goToIdx (cursorIdx, buffer)
|
val buffer = LineGap.goToIdx (cursorIdx, buffer)
|
||||||
val cursorIdx = Cursor.firstNonSpaceChr (buffer, cursorIdx)
|
val cursorIdx = Cursor.firstNonSpaceChr (buffer, cursorIdx)
|
||||||
in
|
in
|
||||||
buildTextAndClear (app, buffer, cursorIdx)
|
buildTextAndClear (app, buffer, cursorIdx, #searchList app)
|
||||||
end
|
end
|
||||||
|
|
||||||
fun helpMoveToChr (app: app_type, buffer, cursorIdx, count, fMove, chr) =
|
fun helpMoveToChr (app: app_type, buffer, cursorIdx, count, fMove, chr) =
|
||||||
if count = 0 then
|
if count = 0 then
|
||||||
buildTextAndClearAfterChr (app, buffer, cursorIdx)
|
buildTextAndClearAfterChr (app, buffer, cursorIdx, #searchList app)
|
||||||
else
|
else
|
||||||
let
|
let
|
||||||
(* move LineGap to cursorIdx, which is necessary for finding newCursorIdx *)
|
(* move LineGap to cursorIdx, which is necessary for finding newCursorIdx *)
|
||||||
@@ -365,42 +399,18 @@ struct
|
|||||||
(** equivalent of vi's 'x' command **)
|
(** equivalent of vi's 'x' command **)
|
||||||
|
|
||||||
fun deleteSearchList (cursorIdx, length, searchString, searchList, buffer) =
|
fun deleteSearchList (cursorIdx, length, searchString, searchList, buffer) =
|
||||||
let
|
let
|
||||||
val searchList = SearchList.delete (cursorIdx, length, searchString, searchList)
|
val searchList =
|
||||||
val searchList = SearchList.mapFrom (cursorIdx, ~length, searchList)
|
SearchList.delete (cursorIdx, length, searchString, searchList)
|
||||||
in
|
val searchList = SearchList.mapFrom (cursorIdx, ~length, searchList)
|
||||||
BuildSearchList.fromRange
|
in
|
||||||
(cursorIdx, length, buffer, searchString, searchList)
|
BuildSearchList.fromRange
|
||||||
end
|
(cursorIdx, length, buffer, searchString, searchList)
|
||||||
|
end
|
||||||
|
|
||||||
fun helpRemoveChr (app: app_type, buffer, searchList, cursorIdx, count) =
|
fun helpRemoveChr (app: app_type, buffer, searchList, cursorIdx, count) =
|
||||||
if count = 0 then
|
if count = 0 then
|
||||||
let
|
buildTextAndClear (app, buffer, cursorIdx, searchList)
|
||||||
val {windowWidth, windowHeight, startLine, searchString, ...} =
|
|
||||||
app
|
|
||||||
|
|
||||||
(* move LineGap to first line displayed on screen *)
|
|
||||||
val buffer = LineGap.goToLine (startLine, buffer)
|
|
||||||
|
|
||||||
(* get new startLine which may move screen depending on cursor movements *)
|
|
||||||
val startLine = TextWindow.getStartLine
|
|
||||||
(buffer, startLine, cursorIdx, windowWidth, windowHeight)
|
|
||||||
|
|
||||||
(* move buffer to new startLine as required by TextBuilder.build *)
|
|
||||||
val buffer = LineGap.goToLine (startLine, buffer)
|
|
||||||
|
|
||||||
val drawMsg = TextBuilder.build
|
|
||||||
( startLine, cursorIdx, buffer
|
|
||||||
, windowWidth, windowHeight
|
|
||||||
, searchList, searchString
|
|
||||||
)
|
|
||||||
|
|
||||||
val mode = NORMAL_MODE ""
|
|
||||||
val newApp = AppWith.onDelete
|
|
||||||
(app, buffer, cursorIdx, mode, startLine, searchList)
|
|
||||||
in
|
|
||||||
(newApp, drawMsg)
|
|
||||||
end
|
|
||||||
else
|
else
|
||||||
let
|
let
|
||||||
val buffer = LineGap.goToIdx (cursorIdx, buffer)
|
val buffer = LineGap.goToIdx (cursorIdx, buffer)
|
||||||
@@ -433,8 +443,8 @@ struct
|
|||||||
val {searchString, ...} = app
|
val {searchString, ...} = app
|
||||||
val buffer = LineGap.delete (cursorIdx, 1, buffer)
|
val buffer = LineGap.delete (cursorIdx, 1, buffer)
|
||||||
|
|
||||||
val (buffer, searchList) =
|
val (buffer, searchList) = deleteSearchList
|
||||||
deleteSearchList (cursorIdx, 1, searchString, searchList, buffer)
|
(cursorIdx, 1, searchString, searchList, buffer)
|
||||||
|
|
||||||
val cursorIdx =
|
val cursorIdx =
|
||||||
if
|
if
|
||||||
@@ -450,8 +460,8 @@ struct
|
|||||||
val {searchString, ...} = app
|
val {searchString, ...} = app
|
||||||
val buffer = LineGap.delete (cursorIdx, 1, buffer)
|
val buffer = LineGap.delete (cursorIdx, 1, buffer)
|
||||||
|
|
||||||
val (buffer, searchList) =
|
val (buffer, searchList) = deleteSearchList
|
||||||
deleteSearchList (cursorIdx, 1, searchString, searchList, buffer)
|
(cursorIdx, 1, searchString, searchList, buffer)
|
||||||
in
|
in
|
||||||
helpRemoveChr (app, buffer, searchList, cursorIdx, count - 1)
|
helpRemoveChr (app, buffer, searchList, cursorIdx, count - 1)
|
||||||
end
|
end
|
||||||
@@ -474,15 +484,20 @@ struct
|
|||||||
val high = Int.max (cursorIdx, otherIdx)
|
val high = Int.max (cursorIdx, otherIdx)
|
||||||
val high = Cursor.clipIdx (buffer, high)
|
val high = Cursor.clipIdx (buffer, high)
|
||||||
val length = high - low
|
val length = high - low
|
||||||
|
|
||||||
val buffer = LineGap.delete (low, length, buffer)
|
val buffer = LineGap.delete (low, length, buffer)
|
||||||
|
|
||||||
|
val {searchList, searchString, ...} = app
|
||||||
|
val (buffer, searchList) = deleteSearchList
|
||||||
|
(low, length, searchString, searchList, buffer)
|
||||||
|
|
||||||
(* If we have deleted from the buffer so that cursorIdx
|
(* If we have deleted from the buffer so that cursorIdx
|
||||||
* is no longer a valid idx,
|
* is no longer a valid idx,
|
||||||
* clip cursorIdx to the end. *)
|
* clip cursorIdx to the end. *)
|
||||||
val buffer = LineGap.goToIdx (low, buffer)
|
val buffer = LineGap.goToIdx (low, buffer)
|
||||||
val cursorIdx = Cursor.clipIdx (buffer, low)
|
val cursorIdx = Cursor.clipIdx (buffer, low)
|
||||||
in
|
in
|
||||||
buildTextAndClear (app, buffer, cursorIdx)
|
buildTextAndClear (app, buffer, cursorIdx, searchList)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
let
|
let
|
||||||
@@ -517,9 +532,12 @@ struct
|
|||||||
val length = lastChr - cursorIdx
|
val length = lastChr - cursorIdx
|
||||||
val buffer = LineGap.delete (cursorIdx, length, buffer)
|
val buffer = LineGap.delete (cursorIdx, length, buffer)
|
||||||
|
|
||||||
(* todo: delete from searchList and map *)
|
(* delete from searchList and map *)
|
||||||
|
val {searchList, searchString, ...} = app
|
||||||
|
val (buffer, searchList) = deleteSearchList
|
||||||
|
(cursorIdx, length, searchString, searchList, buffer)
|
||||||
in
|
in
|
||||||
helpRemoveChr (app, buffer, #searchList app, cursorIdx, 1)
|
helpRemoveChr (app, buffer, searchList, cursorIdx, 1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -530,10 +548,14 @@ struct
|
|||||||
val length = otherIdx - cursorIdx
|
val length = otherIdx - cursorIdx
|
||||||
val buffer = LineGap.delete (cursorIdx, length, buffer)
|
val buffer = LineGap.delete (cursorIdx, length, buffer)
|
||||||
|
|
||||||
|
val {searchList, searchString, ...} = app
|
||||||
|
val (buffer, searchList) = deleteSearchList
|
||||||
|
(cursorIdx, length, searchString, searchList, buffer)
|
||||||
|
|
||||||
val buffer = LineGap.goToIdx (cursorIdx, buffer)
|
val buffer = LineGap.goToIdx (cursorIdx, buffer)
|
||||||
val cursorIdx = Cursor.clipIdx (buffer, cursorIdx)
|
val cursorIdx = Cursor.clipIdx (buffer, cursorIdx)
|
||||||
in
|
in
|
||||||
buildTextAndClear (app, buffer, cursorIdx)
|
buildTextAndClear (app, buffer, cursorIdx, searchList)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
let
|
let
|
||||||
@@ -560,9 +582,14 @@ struct
|
|||||||
val low = Int.max (low, 0)
|
val low = Int.max (low, 0)
|
||||||
val length = high - low
|
val length = high - low
|
||||||
val buffer = LineGap.delete (low, length, buffer)
|
val buffer = LineGap.delete (low, length, buffer)
|
||||||
|
|
||||||
|
val {searchList, searchString, ...} = app
|
||||||
|
val (buffer, searchList) = deleteSearchList
|
||||||
|
(low, length, searchString, searchList, buffer)
|
||||||
|
|
||||||
val buffer = LineGap.goToIdx (low, buffer)
|
val buffer = LineGap.goToIdx (low, buffer)
|
||||||
in
|
in
|
||||||
buildTextAndClear (app, buffer, low)
|
buildTextAndClear (app, buffer, low, searchList)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
let
|
let
|
||||||
@@ -586,7 +613,16 @@ struct
|
|||||||
|
|
||||||
fun deleteToFirstNonSpaceChr (app: app_type) =
|
fun deleteToFirstNonSpaceChr (app: app_type) =
|
||||||
let
|
let
|
||||||
val {buffer, cursorIdx, windowWidth, windowHeight, startLine, ...} = app
|
val
|
||||||
|
{ buffer
|
||||||
|
, cursorIdx
|
||||||
|
, windowWidth
|
||||||
|
, windowHeight
|
||||||
|
, startLine
|
||||||
|
, searchString
|
||||||
|
, searchList
|
||||||
|
, ...
|
||||||
|
} = app
|
||||||
|
|
||||||
(* move LineGap and buffer to start of line *)
|
(* move LineGap and buffer to start of line *)
|
||||||
val buffer = LineGap.goToIdx (cursorIdx, buffer)
|
val buffer = LineGap.goToIdx (cursorIdx, buffer)
|
||||||
@@ -601,8 +637,10 @@ struct
|
|||||||
val length = high - low
|
val length = high - low
|
||||||
|
|
||||||
val buffer = LineGap.delete (low, length, buffer)
|
val buffer = LineGap.delete (low, length, buffer)
|
||||||
|
val (buffer, searchList) = deleteSearchList
|
||||||
|
(low, length, searchString, searchList, buffer)
|
||||||
in
|
in
|
||||||
buildTextAndClear (app, buffer, low)
|
buildTextAndClear (app, buffer, low, searchList)
|
||||||
end
|
end
|
||||||
|
|
||||||
fun helpDeleteToChr
|
fun helpDeleteToChr
|
||||||
@@ -613,8 +651,12 @@ struct
|
|||||||
val high = Int.max (cursorIdx, otherIdx)
|
val high = Int.max (cursorIdx, otherIdx)
|
||||||
val length = high - low
|
val length = high - low
|
||||||
val buffer = LineGap.delete (low, length, buffer)
|
val buffer = LineGap.delete (low, length, buffer)
|
||||||
|
|
||||||
|
val {searchString, searchList, ...} = app
|
||||||
|
val (buffer, searchList) = deleteSearchList
|
||||||
|
(low, length, searchString, searchList, buffer)
|
||||||
in
|
in
|
||||||
buildTextAndClearAfterChr (app, buffer, low)
|
buildTextAndClearAfterChr (app, buffer, low, searchList)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
let
|
let
|
||||||
@@ -652,19 +694,26 @@ struct
|
|||||||
} = app
|
} = app
|
||||||
|
|
||||||
val buffer = LineGap.delete (0, cursorIdx, buffer)
|
val buffer = LineGap.delete (0, cursorIdx, buffer)
|
||||||
|
val (buffer, searchList) = deleteSearchList
|
||||||
|
(0, cursorIdx, searchString, searchList, buffer)
|
||||||
|
|
||||||
val cursorIdx = 0
|
val cursorIdx = 0
|
||||||
val startLine = 0
|
val startLine = 0
|
||||||
val buffer = LineGap.goToIdx (cursorIdx, buffer)
|
val buffer = LineGap.goToIdx (cursorIdx, buffer)
|
||||||
|
|
||||||
val drawMsg = TextBuilder.build
|
val drawMsg = TextBuilder.build
|
||||||
( startLine, cursorIdx, buffer
|
( startLine
|
||||||
, windowWidth, windowHeight
|
, cursorIdx
|
||||||
, searchList, searchString
|
, buffer
|
||||||
|
, windowWidth
|
||||||
|
, windowHeight
|
||||||
|
, searchList
|
||||||
|
, searchString
|
||||||
)
|
)
|
||||||
|
|
||||||
val mode = NORMAL_MODE ""
|
val mode = NORMAL_MODE ""
|
||||||
val newApp = AppWith.bufferAndCursorIdx
|
val newApp = AppWith.bufferAndCursorIdx
|
||||||
(app, buffer, cursorIdx, mode, startLine)
|
(app, buffer, cursorIdx, mode, startLine, searchList)
|
||||||
in
|
in
|
||||||
(newApp, drawMsg)
|
(newApp, drawMsg)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -51,32 +51,13 @@ struct
|
|||||||
end
|
end
|
||||||
|
|
||||||
fun bufferAndCursorIdx
|
fun bufferAndCursorIdx
|
||||||
(app: app_type, newBuffer, newCursorIdx, newMode, newStartLine) =
|
( app: app_type
|
||||||
let
|
, newBuffer
|
||||||
val
|
, newCursorIdx
|
||||||
{ mode = _
|
, newMode
|
||||||
, buffer = _
|
, newStartLine
|
||||||
, cursorIdx = _
|
, newSearchList
|
||||||
, startLine = _
|
) =
|
||||||
, searchList
|
|
||||||
, searchString
|
|
||||||
, windowWidth
|
|
||||||
, windowHeight
|
|
||||||
} = app
|
|
||||||
in
|
|
||||||
{ mode = newMode
|
|
||||||
, buffer = newBuffer
|
|
||||||
, cursorIdx = newCursorIdx
|
|
||||||
, startLine = newStartLine
|
|
||||||
, searchList = searchList
|
|
||||||
, searchString = searchString
|
|
||||||
, windowWidth = windowWidth
|
|
||||||
, windowHeight = windowHeight
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
fun onDelete
|
|
||||||
(app: app_type, newBuffer, newCursorIdx, newMode, newStartLine, newSearchList) =
|
|
||||||
let
|
let
|
||||||
val
|
val
|
||||||
{ mode = _
|
{ mode = _
|
||||||
|
|||||||
@@ -746,6 +746,22 @@ val wMove = describe "move motion 'w'"
|
|||||||
in
|
in
|
||||||
Expect.isTrue (startsAtExc andalso movedToH)
|
Expect.isTrue (startsAtExc andalso movedToH)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
, test "moves cursor to last char in buffer when in last word" (fn _ =>
|
||||||
|
let
|
||||||
|
(* arrange *)
|
||||||
|
val buffer = LineGap.fromString "hello world\n"
|
||||||
|
val app = AppType.init (buffer, 0, 0)
|
||||||
|
val app = withIdx (app, 6)
|
||||||
|
|
||||||
|
(* act *)
|
||||||
|
val (app, _) = AppUpdate.update (app, CHAR_EVENT #"w")
|
||||||
|
|
||||||
|
(* assert *)
|
||||||
|
val chrIsEnd = getChr app = #"d"
|
||||||
|
in
|
||||||
|
Expect.isTrue chrIsEnd
|
||||||
|
end)
|
||||||
]
|
]
|
||||||
|
|
||||||
val tests = concat [hMove, lMove, jMove, kMove, wMove]
|
val tests = concat [hMove, lMove, jMove, kMove, wMove]
|
||||||
|
|||||||
Reference in New Issue
Block a user