This commit is contained in:
2024-09-12 18:30:38 +01:00
parent e69abf1715
commit d2e1b054d0
4 changed files with 24 additions and 22 deletions
+11 -11
View File
@@ -1,30 +1,30 @@
module Dodge.Update.Input.Text (
doTextInputOverUniverse,
doTextInputOver,
doTextInputOver',
) where
import Data.Either
--import Data.Char
import Data.Char
import Dodge.Data.Universe
import LensHelp
import SDL
doTextInputOver :: ASetter' Universe String -> Universe -> Universe
doTextInputOver p u = doTextInputOver' u p u
doTextInputOverUniverse :: ASetter' Universe String -> Universe -> Universe
doTextInputOverUniverse p u = doTextInputOver (u ^. uvWorld . input) p u
doTextInputOver' :: Universe -> ASetter' a String -> a -> a
doTextInputOver' u p x =
--x & p %~ (++ map toUpper (rights str))
x & p %~ (++ rights str)
doTextInputOver :: Input -> ASetter' a String -> a -> a
doTextInputOver u p x =
x & p %~ (++ map toUpper (rights str))
--x & p %~ (++ rights str)
& checkBackspace
where
str = u ^. uvWorld . input . textInput
str = u ^. textInput
checkBackspace
| backspaceInputted u = p %~ doBackspace
| otherwise = id
backspaceInputted :: Universe -> Bool
backspaceInputted u = case u ^. uvWorld . input . pressedKeys . at ScancodeBackspace of
backspaceInputted :: Input -> Bool
backspaceInputted u = case u ^. pressedKeys . at ScancodeBackspace of
Just InitialPress -> True
Just LongPress -> True
_ -> False