Work on tab completion

This commit is contained in:
2025-12-26 21:49:39 +00:00
parent 2fd4a3d2e3
commit bb376b0a56
2 changed files with 20 additions and 2 deletions
+18
View File
@@ -149,6 +149,24 @@ tabComplete' s' w tm = case PTE.lookup s $ getCommands w tm of
<> [TLine 1 [] . TmTmSetStatus $ TerminalTextInput s'] <> [TLine 1 [] . TmTmSetStatus $ TerminalTextInput s']
) )
tComplete
:: String
-> PTE.TrieMap Char (PTE.TrieMap Char [TerminalLine])
-> Either (String,[String]) (String,[String])
tComplete s pt = fromMaybe (Left (mempty,allcommands pt)) $ do
s1 <- words s ^? ix 0
let (e1,mx,pt') = PTE.splitPrefix $ PTE.deletePrefix s1 pt
case e1 of
[] -> do
pt'' <- mx
return $ fromMaybe (Right (mempty, allcommands pt'')) $ do
s2 <- words s ^? ix 1
let (e2,_,pt3) = PTE.splitPrefix $ PTE.deletePrefix s2 pt''
Just $ Right (e2, allcommands pt3)
_ -> Just $ Left (e1, allcommands pt')
where
allcommands = fmap fst . PTE.toList
-- damageCodeCommand :: TerminalCommand -- damageCodeCommand :: TerminalCommand
-- damageCodeCommand = -- damageCodeCommand =
-- TerminalCommand -- TerminalCommand
+2 -2
View File
@@ -132,9 +132,9 @@ terminalWheelEvent :: Int -> Int -> World -> World
terminalWheelEvent yi tmid w terminalWheelEvent yi tmid w
| w & has (input . mouseButtons . ix ButtonRight) | w & has (input . mouseButtons . ix ButtonRight)
, Just TerminalTextInput{} <- w ^? cWorld . lWorld . terminals . ix tmid . tmStatus = , Just TerminalTextInput{} <- w ^? cWorld . lWorld . terminals . ix tmid . tmStatus =
w & cWorld . lWorld . terminals . ix tmid %~ g
| Just TerminalTextInput{} <- w ^? cWorld . lWorld . terminals . ix tmid . tmStatus =
w & cWorld . lWorld . terminals . ix tmid %~ f w & cWorld . lWorld . terminals . ix tmid %~ f
| Just TerminalTextInput{} <- w ^? cWorld . lWorld . terminals . ix tmid . tmStatus =
w & cWorld . lWorld . terminals . ix tmid %~ g
| otherwise = w | otherwise = w
where where
dowrap = if yi > 0 then wrapup else wrapdown dowrap = if yi > 0 then wrapup else wrapdown