Refactor text input
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
module Dodge.Update.Input
|
||||
( updateKeyInGame
|
||||
, doInputScreenInput
|
||||
) where
|
||||
|
||||
import Dodge.WorldPos
|
||||
@@ -14,6 +15,24 @@ import Dodge.Menu
|
||||
import Dodge.Data.Universe
|
||||
import SDL
|
||||
import LensHelp
|
||||
import qualified Data.Text as T
|
||||
|
||||
doInputScreenInput :: Universe -> Universe
|
||||
doInputScreenInput u = u & uvScreenLayers . _head . scInput %~ (`T.append` thetext)
|
||||
& checkBackspace
|
||||
where
|
||||
thetext = u ^. uvWorld . input . textInput
|
||||
checkBackspace = case u ^. uvWorld . input . pressedKeys . at ScancodeBackspace of
|
||||
Just InitialPress -> f
|
||||
Just LongPress -> f
|
||||
_ -> id
|
||||
f = uvScreenLayers . _head . scInput %~ doBackspace
|
||||
|
||||
doBackspace :: T.Text -> T.Text
|
||||
doBackspace t = case T.unsnoc t of
|
||||
Nothing -> t
|
||||
Just (t', _) -> t'
|
||||
|
||||
|
||||
updateKeyInGame :: Universe -> Scancode -> PressType -> Universe
|
||||
updateKeyInGame uv sc InitialPress = case sc of
|
||||
|
||||
Reference in New Issue
Block a user