refactor some code to use looping in DFA (which is faster than looping outside of the data structure)
This commit is contained in:
@@ -42,19 +42,42 @@ structure MoveViJ = MakeMove (struct val fMove = Cursor.viJ end)
|
||||
structure MoveViK = MakeMove (struct val fMove = Cursor.viK end)
|
||||
structure MoveViL = MakeMove (struct val fMove = Cursor.viL end)
|
||||
|
||||
structure MoveToNextWord = MakeMove (struct val fMove = Cursor.nextWord end)
|
||||
structure MoveToNextWORD = MakeMove (struct val fMove = Cursor.nextWORD end)
|
||||
|
||||
structure MoveToEndOfWord = MakeMove (struct val fMove = Cursor.endOfWord end)
|
||||
structure MoveToEndOfWORD = MakeMove (struct val fMove = Cursor.endOfWORD end)
|
||||
|
||||
structure MoveToPrevWord = MakeMove (struct val fMove = Cursor.prevWord end)
|
||||
structure MoveToPrevWORD = MakeMove (struct val fMove = Cursor.prevWORD end)
|
||||
|
||||
structure MoveToEndOfPrevWord =
|
||||
MakeMove (struct val fMove = Cursor.endOfPrevWord end)
|
||||
structure MoveToEndOfPrevWORD =
|
||||
MakeMove (struct val fMove = Cursor.endOfPrevWORD end)
|
||||
|
||||
structure MoveToStartOfLine = MakeMove (struct val fMove = Cursor.vi0 end)
|
||||
structure MoveToEndOfLine = MakeMove (struct val fMove = Cursor.viDlr end)
|
||||
|
||||
signature DFA_MOVE =
|
||||
sig
|
||||
val fMove: LineGap.t * int * int -> int
|
||||
end
|
||||
|
||||
signature MAKE_DFA_MOVE =
|
||||
sig
|
||||
val move: AppType.app_type * int -> AppType.app_type
|
||||
end
|
||||
|
||||
functor MakeDfaMove(Fn: DFA_MOVE): MAKE_DFA_MOVE =
|
||||
struct
|
||||
fun move (app: AppType.app_type, count) =
|
||||
let
|
||||
val {buffer, cursorIdx, ...} = app
|
||||
val buffer = LineGap.goToIdx (cursorIdx, buffer)
|
||||
val cursorIdx = Fn.fMove (buffer, cursorIdx, count)
|
||||
in
|
||||
Finish.buildTextAndClear (app, buffer, cursorIdx, #searchList app)
|
||||
end
|
||||
end
|
||||
|
||||
structure MoveToNextWord = MakeDfaMove (struct val fMove = Cursor.nextWord end)
|
||||
structure MoveToNextWORD = MakeDfaMove (struct val fMove = Cursor.nextWORD end)
|
||||
|
||||
structure MoveToEndOfWord = MakeDfaMove (struct val fMove = Cursor.endOfWord end)
|
||||
structure MoveToEndOfWORD = MakeDfaMove (struct val fMove = Cursor.endOfWORD end)
|
||||
|
||||
structure MoveToPrevWord = MakeDfaMove (struct val fMove = Cursor.prevWord end)
|
||||
structure MoveToPrevWORD = MakeDfaMove (struct val fMove = Cursor.prevWORD end)
|
||||
|
||||
structure MoveToEndOfPrevWord =
|
||||
MakeDfaMove (struct val fMove = Cursor.endOfPrevWord end)
|
||||
structure MoveToEndOfPrevWORD =
|
||||
MakeDfaMove (struct val fMove = Cursor.endOfPrevWORD end)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user