-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Minimalistic console UI (getLine), arrow key support (edit, browse cmd history). -- -- The UI library provides a more modern getLine style function for -- making console based CLIs (command line interfaces). The library -- provides editing capabilities through the use of arrow keys, as well -- as browsing through the command history. It is very minimalistic, does -- only export two functions and doesn't require its own monad (only IO). @package ui @version 1.0.0 -- | The UI library provides a more modern getLine style -- function for making console based CLIs (command line interfaces). The -- library provides editing capabilities through the use of arrow keys, -- as well as browsing through the command history. -- -- It is very minimalistic, does only export two functions and doesn't -- require its own monad (only IO). module Data.UI -- | Term is the internal state of the library. data Term Term :: Bool -> Vector Line -> Int -> Int -> Line -> Int -> Int -> Line -> Term [initialized] :: Term -> Bool [log] :: Term -> Vector Line [logpos] :: Term -> Int [loglen] :: Term -> Int [buf] :: Term -> Line [len] :: Term -> Int [pos] :: Term -> Int [prompt] :: Term -> Line -- | TermRes is the result of the input. Returned whenever the user presses -- a key. data TermRes -- | Returns the numeric value on each key press (except enter). TKey :: Key -> TermRes -- | Returns the line of data when user presses enter. TLine :: Line -> TermRes -- | Line is the datatype of the returned text string when the user presses -- enter. This type can easily be changed from the default (String) to -- Text or anything else. Change it in the type alias and it will be used -- everywhere. type Line = String -- | init initial_prompt -- -- Initializes the terminal. Returns a handle which you pass on to the -- input function. init :: Line -> IO Term -- | input handle -- -- Reads one character from the keyboard. You give it the handle from the -- last function call. It returns the string when pressed enter and -- returns the key code otherwise. -- -- Example: -- --
--   > 
--   > import qualified Data.UI (init, input)
--   > import Data.UI (TermRes(..))
--   > 
--   > example :: IO ()
--   > example = do
--   >     t <- Data.UI.init "prompt> "
--   >     go t
--   >     where
--   >      go t' = do
--   >         (res,newstate) <- Data.UI.input t'
--   >         case res of
--   >             TLine x  -> do
--   >                          _ <- putStrLn $ "\nResult: '" <> x <> "'"
--   >                          go newstate
--   >             _        -> go newstate
--   > 
--   
input :: Term -> IO (TermRes, Term) instance GHC.Internal.Show.Show Data.UI.Arrow instance GHC.Internal.Show.Show Data.UI.Term instance GHC.Internal.Show.Show Data.UI.TermRes