Add analysing machine
This commit is contained in:
@@ -10,7 +10,7 @@ import Control.Monad
|
||||
import Control.Lens
|
||||
import Text.Read (readMaybe)
|
||||
import Data.List --(isPrefixOf, isInfixOf, intercalate)
|
||||
import Data.Maybe (fromJust)
|
||||
import Data.Maybe
|
||||
import LensHelp
|
||||
--import qualified Debug.Trace
|
||||
--import Graphics.Rendering.OpenGL.GL.Shaders (validateProgram)
|
||||
@@ -28,11 +28,11 @@ applyTerminalString "LOADTEST" = (uvWorld . creatures . ix 0 . crInv .~ testInve
|
||||
applyTerminalString "LM" = applyTerminalString "LOADME"
|
||||
applyTerminalString "LT" = applyTerminalString "LOADTEST"
|
||||
applyTerminalString ('s': 'e': 't': '_': 'h': 'p': ' ': hp)
|
||||
| (readMaybe hp :: Maybe Int) == Nothing = id
|
||||
| isNothing (readMaybe hp :: Maybe Int) = id
|
||||
| otherwise = uvWorld . creatures . ix 0 . crHP .~ read hp
|
||||
applyTerminalString ('s': 'e': 't': '_': 'i': 'n': 'v': 'c': 'a': 'p': ' ': n)
|
||||
| (readMaybe n :: Maybe Int) == Nothing = id
|
||||
| otherwise = (uvWorld . creatures . ix 0 . crInvCapacity .~ read n)
|
||||
| isNothing (readMaybe n :: Maybe Int) = id
|
||||
| otherwise = uvWorld . creatures . ix 0 . crInvCapacity .~ read n
|
||||
applyTerminalString ('s': 'e': 't': ' ': var)
|
||||
| var /= [] = applySetTerminalString var
|
||||
| otherwise = id
|
||||
@@ -61,7 +61,7 @@ applySetTerminalString var = case key' of
|
||||
where
|
||||
(key, val) = getSplitString var
|
||||
val' = readMaybe val :: Maybe Float
|
||||
key' = if val' == Nothing then "" else key
|
||||
key' = if isNothing val' then "" else key
|
||||
|
||||
autoCompleteTerminal :: String -> String -> Universe -> IO (Maybe Universe)
|
||||
autoCompleteTerminal s _ = return .
|
||||
@@ -73,10 +73,17 @@ autoCompleteTerminal s _ = return .
|
||||
_ -> 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 length command_options > 0 && head command_options == key then validTerminalCommands key else command_options
|
||||
(_, "") -> 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'
|
||||
|
||||
Reference in New Issue
Block a user