@@ -43,7 +43,7 @@ module Reflex.Vty.Widget
4343 , doubleBoxStyle
4444 , fill
4545 , hRule
46−
46+ , TextInputConfig(..)
4747 , textInput
4848 , multilineTextInput
4949 , def
@@ -539,16 +539,17 @@ updateInputState ev i@(InputState before after) = case ev of
539539 _ -> i
540540
541541data TextInputConfig t = TextInputConfig
542− { _textInputConfig_modifyInputState :: Event t (InputState -> InputState)
542+ { _textInputConfig_initialValue :: Text
543+ , _textInputConfig_modifyInputState :: Event t (InputState -> InputState)
543544 }
544545
545546instance Reflex t => Default (TextInputConfig t) where
546− def = TextInputConfig never
547+ def = TextInputConfig "" never
547548
548549textInput :: (Reflex t, MonadHold t m, MonadFix m) => TextInputConfig t -> VtyWidget t m (Dynamic t Text)
549550textInput cfg = do
550551 i <- input
551− v <- foldDyn ($) (InputState mempty mempty) $ mergeWith (.)
552+ v <- foldDyn ($) (InputState (_textInputConfig_initialValue cfg) mempty) $ mergeWith (.)
552553 [ updateInputState <$> i
553554 , _textInputConfig_modifyInputState cfg
554555 ]
@@ -562,9 +563,11 @@ textInput cfg = do
562563multilineTextInput :: (Reflex t, MonadHold t m, MonadFix m) => TextInputConfig t -> VtyWidget t m (Dynamic t Text)
563564multilineTextInput cfg = do
564565 i <- input
565− textInput $ TextInputConfig $ mergeWith (.)
566− [ fforMaybe i $ \case
567− V.EvKey V.KEnter [] -> Just $ \(InputState before after) -> InputState (T.snoc before '\n') after
568− _ -> Nothing
569− , _textInputConfig_modifyInputState cfg
570− ]
566+ textInput $ cfg
567+ { _textInputConfig_modifyInputState = mergeWith (.)
568+ [ fforMaybe i $ \case
569+ V.EvKey V.KEnter [] -> Just $ \(InputState before after) -> InputState (T.snoc before '\n') after
570+ _ -> Nothing
571+ , _textInputConfig_modifyInputState cfg
572+ ]
573+ }