Mostly use String instead of Text
This commit is contained in:
+12
-16
@@ -6,7 +6,7 @@ module Dodge.Update.Input (
|
||||
) where
|
||||
|
||||
import qualified Data.Map.Strict as M
|
||||
import qualified Data.Text as T
|
||||
import Data.Char
|
||||
import Dodge.Base.You
|
||||
import Dodge.Button.Event
|
||||
import Dodge.Combine
|
||||
@@ -23,8 +23,8 @@ import Dodge.WorldPos
|
||||
import LensHelp
|
||||
import SDL
|
||||
|
||||
doTextInputOver :: ASetter' Universe T.Text -> Universe -> Universe
|
||||
doTextInputOver p u = u & p %~ (`T.append` T.toUpper thetext)
|
||||
doTextInputOver :: ASetter' Universe String -> Universe -> Universe
|
||||
doTextInputOver p u = u & p %~ (++ map toUpper thetext)
|
||||
& checkBackspace
|
||||
where
|
||||
thetext = u ^. uvWorld . input . textInput
|
||||
@@ -32,10 +32,9 @@ doTextInputOver p u = u & p %~ (`T.append` T.toUpper thetext)
|
||||
| backspaceInputted u = p %~ doBackspace
|
||||
| otherwise = id
|
||||
|
||||
doBackspace :: T.Text -> T.Text
|
||||
doBackspace t = case T.unsnoc t of
|
||||
Nothing -> t
|
||||
Just (t', _) -> t'
|
||||
doBackspace :: String -> String
|
||||
doBackspace [] = []
|
||||
doBackspace s = init s
|
||||
|
||||
backspaceInputted :: Universe -> Bool
|
||||
backspaceInputted u = case u ^. uvWorld . input . pressedKeys . at ScancodeBackspace of
|
||||
@@ -44,17 +43,14 @@ backspaceInputted u = case u ^. uvWorld . input . pressedKeys . at ScancodeBacks
|
||||
_ -> False
|
||||
|
||||
doSubInvRegexInput :: Universe -> Universe
|
||||
doSubInvRegexInput u = u
|
||||
& doTextInputOver (uvWorld . hud . hudElement . subInventory . subInvRegex)
|
||||
& checkEndStatus
|
||||
doSubInvRegexInput u
|
||||
| any ( (== Just InitialPress) . (`M.lookup` pkeys)) [ScancodeReturn,ScancodeEscape,ScancodeSlash]
|
||||
= u & uvWorld . hud . hudElement . subInventory . subInvRegexInput .~ False
|
||||
| otherwise = u & doTextInputOver (uvWorld . hud . hudElement . subInventory . subInvRegex)
|
||||
where
|
||||
pkeys = u ^. uvWorld . input . pressedKeys
|
||||
checkEndStatus
|
||||
| any ( (== Just InitialPress) . (`M.lookup` pkeys)) [ScancodeReturn,ScancodeEscape,ScancodeSlash]
|
||||
= uvWorld . hud . hudElement . subInventory . subInvRegexInput .~ False
|
||||
| otherwise = id
|
||||
|
||||
doInputScreenInput :: T.Text -> Universe -> Universe
|
||||
doInputScreenInput :: String -> Universe -> Universe
|
||||
doInputScreenInput s u =
|
||||
u & doTextInputOver (uvScreenLayers . _head . scInput)
|
||||
& checkEndStatus
|
||||
@@ -62,7 +58,7 @@ doInputScreenInput s u =
|
||||
pkeys = u ^. uvWorld . input . pressedKeys
|
||||
checkEndStatus
|
||||
| ScancodeReturn `M.member` pkeys = (uvScreenLayers %~ tail)
|
||||
. applyTerminalString (words $ T.unpack s)
|
||||
. applyTerminalString (words s)
|
||||
| ScancodeEscape `M.member` pkeys = uvScreenLayers %~ tail
|
||||
| otherwise = id
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@ module Dodge.Update.Scroll (
|
||||
|
||||
import qualified Data.Map.Strict as M
|
||||
import Data.Maybe
|
||||
import qualified Data.Text as T
|
||||
import Dodge.Base
|
||||
import Dodge.Combine
|
||||
import Dodge.Data.Universe
|
||||
@@ -87,7 +86,7 @@ terminalWheelEvent yi tmid w
|
||||
setInput i j w' tm =
|
||||
tm
|
||||
& tmInput . tiSel .~ (i, j)
|
||||
& tmInput . tiText .~ T.pack (_tcString tc ++ " " ++ arg)
|
||||
& tmInput . tiText .~ (_tcString tc ++ " " ++ arg)
|
||||
where
|
||||
tc = scrollCommands tm !! i
|
||||
arg = getArguments' tc tm w' !! j
|
||||
|
||||
Reference in New Issue
Block a user