diff --git a/src/Dodge/Terminal.hs b/src/Dodge/Terminal.hs index 8ec3dc77a..acd93848b 100644 --- a/src/Dodge/Terminal.hs +++ b/src/Dodge/Terminal.hs @@ -149,6 +149,24 @@ tabComplete' s' w tm = case PTE.lookup s $ getCommands w tm of <> [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 diff --git a/src/Dodge/Update/Scroll.hs b/src/Dodge/Update/Scroll.hs index 838bd0419..b23499fe5 100644 --- a/src/Dodge/Update/Scroll.hs +++ b/src/Dodge/Update/Scroll.hs @@ -132,9 +132,9 @@ terminalWheelEvent :: Int -> Int -> World -> World terminalWheelEvent yi tmid w | w & has (input . mouseButtons . ix ButtonRight) , 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 + | Just TerminalTextInput{} <- w ^? cWorld . lWorld . terminals . ix tmid . tmStatus = + w & cWorld . lWorld . terminals . ix tmid %~ g | otherwise = w where dowrap = if yi > 0 then wrapup else wrapdown