add horizontal scrolling functionality to SearchBar

This commit is contained in:
2025-09-14 10:07:43 +01:00
parent f1a06f946d
commit 0632f7a969
3 changed files with 17 additions and 5 deletions

View File

@@ -46,6 +46,7 @@ struct
, floatWindowWidth
, floatWindowHeight
, searchCursorIdx
, searchScrollColumn
)
val buffer = LineGap.goToIdx (cursorIdx, buffer)
@@ -83,6 +84,7 @@ struct
, newWindowHeight
, searchCursorIdx
, tempSearchList
, searchScrollColumn
) =
let
val
@@ -107,6 +109,7 @@ struct
, floatWindowWidth
, floatWindowHeight
, searchCursorIdx
, searchScrollColumn
)
val cursor =

View File

@@ -140,7 +140,7 @@ struct
app
else
let
val searchCursorIdx = searchCursorIdx - 1
val searchCursorIdx = Int.max (0, searchCursorIdx - 1)
in
NormalSearchFinish.onSearchChanged
( app
@@ -158,7 +158,8 @@ struct
app
else
let
val searchCursorIdx = searchCursorIdx + 1
val searchCursorIdx =
Int.min (searchCursorIdx + 1, String.size searchString)
in
NormalSearchFinish.onSearchChanged
( app
@@ -209,7 +210,13 @@ struct
NormalFinish.withSearchList (app, searchList, time)
| RESIZE_EVENT (width, height) =>
NormalSearchFinish.resize
(app, width, height, searchCursorIdx, tempSearchList)
( app
, width
, height
, searchCursorIdx
, tempSearchList
, searchScrollColumn
)
(* In Vim's search mode, the up and down arrows can be used
* to scroll through the search history.

View File

@@ -58,6 +58,7 @@ struct
, floatWindowWidth
, floatWindowHeight
, searchCursorIdx
, searchScrollColumn
) =
let
val r: Real32.real = 0.67
@@ -95,7 +96,8 @@ struct
val cursor =
let
val xpos = TextConstants.xSpace * (searchCursorIdx + 1) + startX
val xpos = (searchCursorIdx + 1) - searchScrollColumn
val xpos = TextConstants.xSpace * xpos + startX
val xpos = Int.min (endX, xpos)
val x = Real32.fromInt xpos
in
@@ -115,7 +117,7 @@ struct
val posX = startX + TC.xSpace
in
loop
( 0
( searchScrollColumn
, str
, posX
, startY