handle resize event and concurrent (permanent and full) search result in NORMAL_SEARCH_MODE
This commit is contained in:
@@ -1,12 +1,11 @@
|
|||||||
structure NormalSearchFinish =
|
structure NormalSearchFinish =
|
||||||
struct
|
struct
|
||||||
open AppType
|
open AppType
|
||||||
|
open DrawMsg
|
||||||
|
|
||||||
fun onSearchChanged
|
fun onSearchChanged
|
||||||
(app: app_type, searchString, tempSearchList, searchCursorIdx, buffer) =
|
(app: app_type, searchString, tempSearchList, searchCursorIdx, buffer) =
|
||||||
let
|
let
|
||||||
open DrawMsg
|
|
||||||
|
|
||||||
val {buffer, cursorIdx, startLine, windowWidth, windowHeight, ...} = app
|
val {buffer, cursorIdx, startLine, windowWidth, windowHeight, ...} = app
|
||||||
val mode = NORMAL_SEARCH_MODE
|
val mode = NORMAL_SEARCH_MODE
|
||||||
{ searchString = searchString
|
{ searchString = searchString
|
||||||
@@ -74,4 +73,73 @@ struct
|
|||||||
(app, buffer, startLine, mode, msgs)
|
(app, buffer, startLine, mode, msgs)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
fun resize
|
||||||
|
( app: app_type
|
||||||
|
, newWindowWidth
|
||||||
|
, newWindowHeight
|
||||||
|
, searchCursorIdx
|
||||||
|
, tempSearchList
|
||||||
|
) =
|
||||||
|
let
|
||||||
|
val {buffer, cursorIdx, startLine, searchString, ...} = app
|
||||||
|
|
||||||
|
val floatWindowWidth = Real32.fromInt newWindowWidth
|
||||||
|
val floatWindowHeight = Real32.fromInt newWindowHeight
|
||||||
|
|
||||||
|
val searchStringPosY = newWindowHeight - TextConstants.ySpace - 5
|
||||||
|
|
||||||
|
val initialTextAcc = TextBuilder.buildLineToList
|
||||||
|
( searchString
|
||||||
|
, 5
|
||||||
|
, searchStringPosY
|
||||||
|
, newWindowWidth
|
||||||
|
, floatWindowWidth
|
||||||
|
, floatWindowHeight
|
||||||
|
)
|
||||||
|
|
||||||
|
val cursor =
|
||||||
|
let
|
||||||
|
val xpos = TextConstants.xSpace * (searchCursorIdx + 1) + 5
|
||||||
|
val x = Real32.fromInt xpos
|
||||||
|
val y = Real32.fromInt searchStringPosY
|
||||||
|
val r: Real32.real = 0.67
|
||||||
|
val g: Real32.real = 0.51
|
||||||
|
val b: Real32.real = 0.83
|
||||||
|
in
|
||||||
|
PipeCursor.lerp
|
||||||
|
( x
|
||||||
|
, y
|
||||||
|
, TextConstants.scale
|
||||||
|
, floatWindowWidth
|
||||||
|
, floatWindowHeight
|
||||||
|
, r
|
||||||
|
, g
|
||||||
|
, b
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
val buffer = LineGap.goToLine (startLine, buffer)
|
||||||
|
val startLine = TextWindow.getStartLine
|
||||||
|
(buffer, startLine, cursorIdx, newWindowWidth, newWindowHeight)
|
||||||
|
|
||||||
|
val remainingWindowHeight = newWindowHeight - (TextConstants.ySpace * 2)
|
||||||
|
|
||||||
|
val msgs = TextBuilder.buildWithExisting
|
||||||
|
( startLine
|
||||||
|
, cursorIdx
|
||||||
|
, buffer
|
||||||
|
, newWindowWidth
|
||||||
|
, remainingWindowHeight
|
||||||
|
, floatWindowWidth
|
||||||
|
, floatWindowHeight
|
||||||
|
, tempSearchList
|
||||||
|
, searchString
|
||||||
|
, []
|
||||||
|
, cursor :: initialTextAcc
|
||||||
|
, []
|
||||||
|
)
|
||||||
|
in
|
||||||
|
NormalSearchModeWith.bufferAndSize
|
||||||
|
(app, buffer, newWindowWidth, newWindowHeight, msgs)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -66,4 +66,61 @@ struct
|
|||||||
, cursorIdx = cursorIdx
|
, cursorIdx = cursorIdx
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
fun searchList (app: app_type, newSearchList) =
|
||||||
|
let
|
||||||
|
val
|
||||||
|
{ mode
|
||||||
|
, buffer
|
||||||
|
, searchString
|
||||||
|
, searchList = _
|
||||||
|
, startLine
|
||||||
|
, msgs
|
||||||
|
, bufferModifyTime
|
||||||
|
, windowWidth
|
||||||
|
, windowHeight
|
||||||
|
, cursorIdx
|
||||||
|
} = app
|
||||||
|
in
|
||||||
|
{ mode = mode
|
||||||
|
, searchList = newSearchList
|
||||||
|
, buffer = buffer
|
||||||
|
, startLine = startLine
|
||||||
|
, msgs = msgs
|
||||||
|
, searchString = searchString
|
||||||
|
, bufferModifyTime = bufferModifyTime
|
||||||
|
, windowWidth = windowWidth
|
||||||
|
, windowHeight = windowHeight
|
||||||
|
, cursorIdx = cursorIdx
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
fun bufferAndSize
|
||||||
|
(app: app_type, newBuffer, newWindowWidth, newWindowHeight, newMsgs) =
|
||||||
|
let
|
||||||
|
val
|
||||||
|
{ mode
|
||||||
|
, windowWidth = _
|
||||||
|
, windowHeight = _
|
||||||
|
, msgs = _
|
||||||
|
, buffer = _
|
||||||
|
, searchString
|
||||||
|
, searchList
|
||||||
|
, startLine
|
||||||
|
, bufferModifyTime
|
||||||
|
, cursorIdx
|
||||||
|
} = app
|
||||||
|
in
|
||||||
|
{ mode = mode
|
||||||
|
, buffer = newBuffer
|
||||||
|
, windowWidth = newWindowWidth
|
||||||
|
, windowHeight = newWindowHeight
|
||||||
|
, msgs = newMsgs
|
||||||
|
, searchList = searchList
|
||||||
|
, startLine = startLine
|
||||||
|
, searchString = searchString
|
||||||
|
, bufferModifyTime = bufferModifyTime
|
||||||
|
, cursorIdx = cursorIdx
|
||||||
|
}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -131,12 +131,22 @@ struct
|
|||||||
backspace (app, searchString, tempSearchList, searchCursorIdx)
|
backspace (app, searchString, tempSearchList, searchCursorIdx)
|
||||||
| KEY_ESC => exitToNormalMode app
|
| KEY_ESC => exitToNormalMode app
|
||||||
| KEY_ENTER => saveSearch (app, searchString, tempSearchList)
|
| KEY_ENTER => saveSearch (app, searchString, tempSearchList)
|
||||||
| RESIZE_EVENT (width, height) => app
|
|
||||||
| WITH_SEARCH_LIST searchList => app
|
|
||||||
| ARROW_LEFT =>
|
| ARROW_LEFT =>
|
||||||
moveLeft (app, searchString, tempSearchList, searchCursorIdx)
|
moveLeft (app, searchString, tempSearchList, searchCursorIdx)
|
||||||
| ARROW_RIGHT =>
|
| ARROW_RIGHT =>
|
||||||
moveRight (app, searchString, tempSearchList, searchCursorIdx)
|
moveRight (app, searchString, tempSearchList, searchCursorIdx)
|
||||||
|
| WITH_SEARCH_LIST searchList =>
|
||||||
|
NormalSearchModeWith.searchList (app, searchList)
|
||||||
|
| RESIZE_EVENT (width, height) =>
|
||||||
|
NormalSearchFinish.resize
|
||||||
|
(app, width, height, searchCursorIdx, tempSearchList)
|
||||||
|
|
||||||
|
(* In Vim's search mode, the up and down arrows can be used
|
||||||
|
* to scroll through the search history.
|
||||||
|
* I don't find this feature too useful as it is often easier to type
|
||||||
|
* the whole search string again, so I'm leaving it unimplemented
|
||||||
|
* until/unless I find that I wish this functionality was there
|
||||||
|
* while using the program. *)
|
||||||
| ARROW_UP => app
|
| ARROW_UP => app
|
||||||
| ARROW_DOWN => app
|
| ARROW_DOWN => app
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user