Remove a lot of IO/maybe cruft
This commit is contained in:
+32
-32
@@ -5,15 +5,15 @@ module Dodge.Debug.Terminal where
|
||||
import Dodge.Item.Location.Initialize
|
||||
import Control.Applicative
|
||||
import Control.Lens
|
||||
import Control.Monad
|
||||
import Data.List
|
||||
--import Control.Monad
|
||||
--import Data.List
|
||||
import Data.Maybe
|
||||
import qualified Data.Text as T
|
||||
import Dodge.Creature
|
||||
import Dodge.Data.Universe
|
||||
import Dodge.Inventory.Add
|
||||
import Dodge.Item
|
||||
import Dodge.Menu.PushPop
|
||||
--import Dodge.Menu.PushPop
|
||||
import qualified IntMapHelp as IM
|
||||
import LensHelp
|
||||
import MaybeHelp
|
||||
@@ -75,35 +75,35 @@ applySetTerminalString var = case key' of
|
||||
val' = readMaybe val :: Maybe Float
|
||||
key' = if isNothing val' then "" else key
|
||||
|
||||
autoCompleteTerminal :: String -> String -> Universe -> IO (Maybe Universe)
|
||||
autoCompleteTerminal s _ =
|
||||
return
|
||||
. (popScreen' >=> pushScreen' (InputScreen (T.pack input_str) valid_commands))
|
||||
where
|
||||
(key, val) = getSplitString $ tail s
|
||||
command_options = case val of
|
||||
"" -> filter (isInfixOf key) (validTerminalCommands "")
|
||||
_ -> filter (isInfixOf val) (validTerminalCommands key)
|
||||
-- basic autocomplete if single option available (or as far as possible)
|
||||
input_str = case (key, val) of
|
||||
(_, "") ->
|
||||
if length command_options == 1
|
||||
then ">" ++ head command_options ++ " "
|
||||
else ">" ++ longestCommonPrefix command_options
|
||||
_ ->
|
||||
if length command_options == 1
|
||||
then ">" ++ key ++ " " ++ head command_options ++ " "
|
||||
else
|
||||
if null command_options
|
||||
then s
|
||||
else ">" ++ key ++ " " ++ longestCommonPrefix command_options
|
||||
command_options' =
|
||||
if not (null command_options) && head command_options == key
|
||||
then validTerminalCommands key
|
||||
else command_options
|
||||
|
||||
--val' = Debug.Trace.trace key tail val
|
||||
valid_commands = "Options: " ++ intercalate ", " command_options'
|
||||
--autoCompleteTerminal :: String -> String -> Universe -> IO (Maybe Universe)
|
||||
--autoCompleteTerminal s _ =
|
||||
-- return
|
||||
-- . (popScreen' >=> pushScreen' (InputScreen (T.pack input_str) valid_commands))
|
||||
-- where
|
||||
-- (key, val) = getSplitString $ tail s
|
||||
-- command_options = case val of
|
||||
-- "" -> filter (isInfixOf key) (validTerminalCommands "")
|
||||
-- _ -> filter (isInfixOf val) (validTerminalCommands key)
|
||||
-- -- basic autocomplete if single option available (or as far as possible)
|
||||
-- input_str = case (key, val) of
|
||||
-- (_, "") ->
|
||||
-- if length command_options == 1
|
||||
-- then ">" ++ head command_options ++ " "
|
||||
-- else ">" ++ longestCommonPrefix command_options
|
||||
-- _ ->
|
||||
-- if length command_options == 1
|
||||
-- then ">" ++ key ++ " " ++ head command_options ++ " "
|
||||
-- else
|
||||
-- if null command_options
|
||||
-- then s
|
||||
-- else ">" ++ key ++ " " ++ longestCommonPrefix command_options
|
||||
-- command_options' =
|
||||
-- if not (null command_options) && head command_options == key
|
||||
-- then validTerminalCommands key
|
||||
-- else command_options
|
||||
--
|
||||
-- --val' = Debug.Trace.trace key tail val
|
||||
-- valid_commands = "Options: " ++ intercalate ", " command_options'
|
||||
|
||||
getSplitString :: [Char] -> ([Char], [Char])
|
||||
getSplitString str = case break (== ' ') str of
|
||||
|
||||
Reference in New Issue
Block a user