add: make input prompts green, where supported
Because we can! Should have no effect where not supported.
This commit is contained in:
parent
5d0da63261
commit
d89367d75e
@ -115,7 +115,7 @@ confirmedTransactionWizard es@EntryState{..} = do
|
|||||||
parser ((fmap ('y' ==)) . headMay . map toLower . strip) $
|
parser ((fmap ('y' ==)) . headMay . map toLower . strip) $
|
||||||
defaultTo' def $ nonEmpty $
|
defaultTo' def $ nonEmpty $
|
||||||
maybeRestartTransaction $
|
maybeRestartTransaction $
|
||||||
line $ printf "Save this transaction to the journal ?%s: " (showDefault def)
|
line $ green $ printf "Save this transaction to the journal ?%s: " (showDefault def)
|
||||||
if y then return t else throw RestartTransactionException
|
if y then return t else throw RestartTransactionException
|
||||||
|
|
||||||
transactionWizard es@EntryState{..} = do
|
transactionWizard es@EntryState{..} = do
|
||||||
@ -157,7 +157,7 @@ dateAndCodeWizard EntryState{..} = do
|
|||||||
maybeExit $
|
maybeExit $
|
||||||
maybeRestartTransaction $
|
maybeRestartTransaction $
|
||||||
-- maybeShowHelp $
|
-- maybeShowHelp $
|
||||||
line $ printf "Date%s: " (showDefault def)
|
line $ green $ printf "Date%s: " (showDefault def)
|
||||||
where
|
where
|
||||||
parseSmartDateAndCode refdate s = either (const Nothing) (\(d,c) -> return (fixSmartDate refdate d, c)) edc
|
parseSmartDateAndCode refdate s = either (const Nothing) (\(d,c) -> return (fixSmartDate refdate d, c)) edc
|
||||||
where
|
where
|
||||||
@ -176,7 +176,7 @@ descriptionAndCommentWizard EntryState{..} = do
|
|||||||
s <- withCompletion (descriptionCompleter esJournal def) $
|
s <- withCompletion (descriptionCompleter esJournal def) $
|
||||||
defaultTo' def $ nonEmpty $
|
defaultTo' def $ nonEmpty $
|
||||||
maybeRestartTransaction $
|
maybeRestartTransaction $
|
||||||
line $ printf "Description%s: " (showDefault def)
|
line $ green $ printf "Description%s: " (showDefault def)
|
||||||
let (desc,comment) = (strip a, strip $ dropWhile (==';') b) where (a,b) = break (==';') s
|
let (desc,comment) = (strip a, strip $ dropWhile (==';') b) where (a,b) = break (==';') s
|
||||||
return (desc,comment)
|
return (desc,comment)
|
||||||
|
|
||||||
@ -215,7 +215,7 @@ accountWizard EntryState{..} = do
|
|||||||
withCompletion (accountCompleter esJournal def) $
|
withCompletion (accountCompleter esJournal def) $
|
||||||
defaultTo' def $ nonEmpty $
|
defaultTo' def $ nonEmpty $
|
||||||
maybeRestartTransaction $
|
maybeRestartTransaction $
|
||||||
line $ printf "Account %d%s%s: " pnum endmsg (showDefault def)
|
line $ green $ printf "Account %d%s%s: " pnum endmsg (showDefault def)
|
||||||
where
|
where
|
||||||
canfinish = not (null esPostings) && postingsBalanced esPostings
|
canfinish = not (null esPostings) && postingsBalanced esPostings
|
||||||
endmsg | canfinish = " (or . to finish this transaction)"
|
endmsg | canfinish = " (or . to finish this transaction)"
|
||||||
@ -242,7 +242,7 @@ amountAndCommentWizard EntryState{..} = do
|
|||||||
withCompletion (amountCompleter def) $
|
withCompletion (amountCompleter def) $
|
||||||
defaultTo' def $ nonEmpty $
|
defaultTo' def $ nonEmpty $
|
||||||
maybeRestartTransaction $
|
maybeRestartTransaction $
|
||||||
line $ printf "Amount %d%s: " pnum (showDefault def)
|
line $ green $ printf "Amount %d%s: " pnum (showDefault def)
|
||||||
where
|
where
|
||||||
parseAmountAndComment = either (const Nothing) Just . parseWithCtx (jContext esJournal) amountandcommentp
|
parseAmountAndComment = either (const Nothing) Just . parseWithCtx (jContext esJournal) amountandcommentp
|
||||||
amountandcommentp = do
|
amountandcommentp = do
|
||||||
@ -314,6 +314,8 @@ defaultTo' = flip defaultTo
|
|||||||
|
|
||||||
withCompletion f = withSettings (setComplete f defaultSettings)
|
withCompletion f = withSettings (setComplete f defaultSettings)
|
||||||
|
|
||||||
|
green s = "\ESC[1;32m\STX"++s++"\ESC[0m\STX"
|
||||||
|
|
||||||
showDefault "" = ""
|
showDefault "" = ""
|
||||||
showDefault s = " [" ++ s ++ "]"
|
showDefault s = " [" ++ s ++ "]"
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user