use Editor istead of String
This commit is contained in:
+16
-15
@@ -53,7 +53,7 @@ module Mtlstats.Types (
|
||||
database,
|
||||
progMode,
|
||||
dbName,
|
||||
inputBuffer,
|
||||
editorW,
|
||||
scroller,
|
||||
-- ** ProgMode Lenses
|
||||
gameStateL,
|
||||
@@ -199,6 +199,7 @@ module Mtlstats.Types (
|
||||
|
||||
import Brick.Main (ViewportScroll, viewportScroll)
|
||||
import Brick.Types (BrickEvent, EventM, Widget)
|
||||
import Brick.Widgets.Edit (Editor, editor)
|
||||
import Data.Aeson
|
||||
( FromJSON
|
||||
, ToJSON
|
||||
@@ -241,15 +242,15 @@ type Handler a = BrickEvent () () -> Action a
|
||||
|
||||
-- | Represents the program state
|
||||
data ProgState = ProgState
|
||||
{ _database :: Database
|
||||
{ _database :: Database
|
||||
-- ^ The data to be saved
|
||||
, _progMode :: ProgMode
|
||||
, _progMode :: ProgMode
|
||||
-- ^ The program's mode
|
||||
, _dbName :: String
|
||||
, _dbName :: String
|
||||
-- ^ The name of the database file
|
||||
, _inputBuffer :: String
|
||||
-- ^ Buffer for user input
|
||||
, _scroller :: ViewportScroll ()
|
||||
, _editorW :: Editor String ()
|
||||
-- ^ Editor widget
|
||||
, _scroller :: ViewportScroll ()
|
||||
-- ^ Scroller for the reports
|
||||
}
|
||||
|
||||
@@ -543,8 +544,8 @@ data GameStats = GameStats
|
||||
data Prompt = Prompt
|
||||
{ drawPrompt :: ProgState -> Widget ()
|
||||
-- ^ Draws the prompt to the screen
|
||||
, promptProcessChar :: Char -> String -> String
|
||||
-- ^ Modifies the string based on the character entered
|
||||
, promptProcessChar :: Char -> Editor String () -> Editor String ()
|
||||
-- ^ Modifies an editor based on the character entered
|
||||
, promptAction :: String -> Action ()
|
||||
-- ^ Action to perform when the value is entered
|
||||
, promptSpecialKey :: Key -> [Modifier] -> Action ()
|
||||
@@ -563,7 +564,7 @@ data SelectParams a = SelectParams
|
||||
-- ^ Search function looking for an exact match
|
||||
, spElemDesc :: a -> String
|
||||
-- ^ Provides a string description of an element
|
||||
, spProcessChar :: Char -> String -> String
|
||||
, spProcessChar :: Char -> Editor String () -> Editor String ()
|
||||
-- ^ Processes a character entered by the user
|
||||
, spCallback :: Maybe Int -> Action ()
|
||||
-- ^ The function when the selection is made
|
||||
@@ -795,11 +796,11 @@ esmSubModeL = lens
|
||||
-- | Constructor for a 'ProgState'
|
||||
newProgState :: ProgState
|
||||
newProgState = ProgState
|
||||
{ _database = newDatabase
|
||||
, _progMode = TitleScreen
|
||||
, _dbName = ""
|
||||
, _inputBuffer = ""
|
||||
, _scroller = viewportScroll ()
|
||||
{ _database = newDatabase
|
||||
, _progMode = TitleScreen
|
||||
, _dbName = ""
|
||||
, _editorW = editor () (Just 1) ""
|
||||
, _scroller = viewportScroll ()
|
||||
}
|
||||
|
||||
-- | Constructor for a 'GameState'
|
||||
|
||||
Reference in New Issue
Block a user