Move towards inputs in terminal
This commit is contained in:
+18
-15
@@ -1,6 +1,6 @@
|
||||
module Dodge.Event.Menu
|
||||
( handlePressedKeyInMenu
|
||||
, handleTextInMenu
|
||||
-- , handleTextInMenu
|
||||
) where
|
||||
import Dodge.Data
|
||||
import Dodge.Debug.Terminal
|
||||
@@ -9,17 +9,20 @@ import Dodge.Menu.PushPop
|
||||
|
||||
import Data.Maybe
|
||||
--import Control.Monad
|
||||
import Control.Lens
|
||||
--import Control.Lens
|
||||
import SDL
|
||||
--import qualified Debug.Trace
|
||||
import qualified Data.Text as T
|
||||
|
||||
handleTextInMenu :: ScreenLayer -> [Char] -> Universe -> IO (Maybe Universe)
|
||||
handleTextInMenu mState text = return . Just . case mState of
|
||||
InputScreen {} -> menuLayers . ix 0 . scInput %~ updateText
|
||||
_ -> id
|
||||
where
|
||||
updateText "" = ">"
|
||||
updateText s = s ++ text
|
||||
--handleTextInMenu :: ScreenLayer -> T.Text -> Universe -> IO (Maybe Universe)
|
||||
--handleTextInMenu mState text = return . Just . -- case mState of
|
||||
---- InputScreen {} ->
|
||||
-- (menuLayers . ix 0 . scInput %~ updateText)
|
||||
---- _ -> id
|
||||
-- where
|
||||
-- updateText s = case T.unpack text of
|
||||
-- "\b" -> undefined
|
||||
-- _ -> s `T.append` text
|
||||
|
||||
handlePressedKeyInMenu :: ScreenLayer -> Scancode -> Universe -> IO (Maybe Universe)
|
||||
handlePressedKeyInMenu mState scode = case mState of
|
||||
@@ -30,15 +33,15 @@ handlePressedKeyInMenu mState scode = case mState of
|
||||
WaitScreen {} -> return . Just
|
||||
InputScreen s help -> case scode of
|
||||
ScancodeEscape -> popScreen
|
||||
ScancodeReturn -> popScreen . applyTerminalString (tail s)
|
||||
ScancodeTab -> autoCompleteTerminal s help
|
||||
ScancodeBackspace -> return . Just . (menuLayers . ix 0 . scInput %~ doBackspace)
|
||||
ScancodeReturn -> popScreen . applyTerminalString (T.unpack s)
|
||||
ScancodeTab -> autoCompleteTerminal (T.unpack s) help
|
||||
-- ScancodeBackspace -> return . Just . (menuLayers . ix 0 . scInput %~ doBackspace)
|
||||
-- text input handled by handleText
|
||||
_ -> return . Just
|
||||
where
|
||||
doBackspace [_] = ['>']
|
||||
doBackspace (x:xs) = init (x:xs)
|
||||
doBackspace _ = ['>']
|
||||
-- doBackspace [_] = ['>']
|
||||
-- doBackspace (x:xs) = init (x:xs)
|
||||
-- doBackspace _ = ['>']
|
||||
|
||||
optionListToEffects
|
||||
:: (Universe -> IO (Maybe Universe))
|
||||
|
||||
Reference in New Issue
Block a user