Implement "tab" button in terminal
This commit is contained in:
+13
-4
@@ -19,6 +19,7 @@ module Dodge.Terminal (
|
||||
getCommands,
|
||||
makeColorTermPara,
|
||||
commandColor,
|
||||
tabComplete,
|
||||
) where
|
||||
|
||||
import qualified Data.ListTrie.Patricia.Map.Enum as PTE
|
||||
@@ -114,19 +115,19 @@ getCommands = foldMap getCommand . _tmCommands -- tm -- ++ _tmWriteCommands tm
|
||||
getCommand :: TCom -> PTE.TrieMap Char (PTE.TrieMap Char [TerminalLine])
|
||||
getCommand = \case
|
||||
TCInfo x z -> PTE.singleton x (PTE.singleton "" (makeTermPara z))
|
||||
TCBase -> helpCommand <> commandsCommand <> quitCommand
|
||||
TCBase -> helpCommand <> quitCommand
|
||||
|
||||
helpCommand :: PTE.TrieMap Char (PTE.TrieMap Char [TerminalLine])
|
||||
helpCommand = PTE.singleton "HELP" (fmap makeTermPara helpStrings)
|
||||
|
||||
helpStrings :: PTE.TrieMap Char String
|
||||
helpStrings = PTE.fromList
|
||||
[("", "THIS TERMINAL PROCESSES TEXT INPUT. INPUT \"COMMANDS\" TO LIST AVAILABLE FUNCTIONALITY.")
|
||||
[("", "THIS TERMINAL PROCESSES TEXT INPUT. USE TAB FOR AVAILABLE COMMANDS AND AUTOCOMPLETE.")
|
||||
,("HELP", "BASIC HELP. ACCEPTS A COMMAND AS AN ARGUMENT.")
|
||||
]
|
||||
|
||||
commandsCommand :: PTE.TrieMap Char (PTE.TrieMap Char [TerminalLine])
|
||||
commandsCommand = PTE.singleton "COMMANDS" (PTE.singleton "" [TLine 0 [] TmDisplayCommands])
|
||||
--commandsCommand :: PTE.TrieMap Char (PTE.TrieMap Char [TerminalLine])
|
||||
--commandsCommand = PTE.singleton "COMMANDS" (PTE.singleton "" [TLine 0 [] TmDisplayCommands])
|
||||
|
||||
quitCommand :: PTE.TrieMap Char (PTE.TrieMap Char [TerminalLine])
|
||||
quitCommand = PTE.singleton "QUIT" (PTE.singleton "" [TLine 0 [] TmWdWdDisconnectTerminal])
|
||||
@@ -146,6 +147,14 @@ makeColorTermLine col str = TLine 1 [TerminalLineConst str col] TmWdId
|
||||
commandColor :: Color
|
||||
commandColor = yellow
|
||||
|
||||
tabComplete :: String -> Terminal -> Terminal
|
||||
tabComplete s tm = case fmap fst $ PTE.toList $ PTE.lookupPrefix s $ getCommands tm of
|
||||
[] -> tm
|
||||
[x] -> tm & tmStatus .~ TerminalTextInput x
|
||||
xs -> tm & tmFutureLines .~
|
||||
makeColorTermPara commandColor
|
||||
(unwords xs)
|
||||
|
||||
--doTerminalCommandEffect :: TerminalCommandEffect -> Terminal -> World -> EffectArguments
|
||||
--doTerminalCommandEffect tce = case tce of
|
||||
-- TerminalCommandArguments eas -> \_ _ -> eas
|
||||
|
||||
Reference in New Issue
Block a user