diff --git a/hledger/Hledger/Cli/Commands/Add.hs b/hledger/Hledger/Cli/Commands/Add.hs index 9d1f2f6aa..32cfe9f2a 100644 --- a/hledger/Hledger/Cli/Commands/Add.hs +++ b/hledger/Hledger/Cli/Commands/Add.hs @@ -284,7 +284,7 @@ transactionWizard previnput state@AddState{..} stack@(currentStage : _) = case c retryMsg "Please enter y or n." $ parser ((fmap (\c -> if c == '<' then Nothing else Just c)) . headMay . map toLower . strip) $ defaultTo' def $ nonEmpty $ - line' $ green' $ printf "Save this transaction to the journal ?%s: " (showDefault def) + line $ green' $ printf "Save this transaction to the journal ?%s: " (showDefault def) case y of Just 'y' -> return t Just _ -> throw RestartTransactionException @@ -303,7 +303,7 @@ dateWizard PrevInput{..} AddState{..} = do defaultTo' def $ nonEmpty $ maybeExit $ -- maybeShowHelp $ - linePrewritten' (green' $ printf "Date%s: " (showDefault def)) (fromMaybe "" prevDateAndCode) "" + linePrewritten (green' $ printf "Date%s: " (showDefault def)) (fromMaybe "" prevDateAndCode) "" where parseSmartDateAndCode refdate s = if s == "<" then return Nothing else either (const Nothing) (\(d,c) -> return $ Just (fixSmartDate refdate d, c)) edc where @@ -325,7 +325,7 @@ descriptionWizard PrevInput{..} AddState{..} = do let def = headDef "" asArgs s <- withCompletion (descriptionCompleter asJournal def) $ defaultTo' def $ nonEmpty $ - linePrewritten' (green' $ printf "Description%s: " (showDefault def)) (fromMaybe "" prevDescAndCmnt) "" + linePrewritten (green' $ printf "Description%s: " (showDefault def)) (fromMaybe "" prevDescAndCmnt) "" if s == "<" then return Nothing else do @@ -348,7 +348,7 @@ accountWizard PrevInput{..} AddState{..} = do parser (parseAccountOrDotOrNull def canfinish) $ withCompletion (accountCompleter asJournal def) $ defaultTo' def $ -- nonEmpty $ - linePrewritten' (green' $ printf "Account %d%s%s: " pnum (endmsg::String) (showDefault def)) (fromMaybe "" $ prevAccount `atMay` length asPostings) "" + linePrewritten (green' $ printf "Account %d%s%s: " pnum (endmsg::String) (showDefault def)) (fromMaybe "" $ prevAccount `atMay` length asPostings) "" where canfinish = not (null asPostings) && postingsAreBalanced asPostings parseAccountOrDotOrNull :: String -> Bool -> String -> Maybe (Maybe String) @@ -388,7 +388,7 @@ amountWizard previnput@PrevInput{..} state@AddState{..} = do withCompletion (amountCompleter def) $ defaultTo' def $ nonEmpty $ - linePrewritten' (green' $ printf "Amount %d%s: " pnum (showDefault def)) (fromMaybe "" $ prevAmountAndCmnt `atMay` length asPostings) "" + linePrewritten (green' $ printf "Amount %d%s: " pnum (showDefault def)) (fromMaybe "" $ prevAmountAndCmnt `atMay` length asPostings) "" where -- Custom parser that combines with Wizard to use IO via outputLn parser' f a = a >>= \input -> @@ -475,11 +475,6 @@ maybeExit = parser (\s -> if s == "." then throw UnexpectedEOF else Just s) -- maybeShowHelp wizard = maybe (liftIO showHelp >> wizard) return $ -- parser (\s -> if s=="?" then Nothing else Just s) wizard --- | A workaround we seem to need for #2410 right now: wizards' input-reading functions disrupt ANSI codes --- somehow, so these variants first print the ANSI coded prompt as ordinary output, then do the input with no prompt. -line' prompt = output prompt >> line "" -linePrewritten' prompt beforetxt aftertxt = output prompt >> linePrewritten "" beforetxt aftertxt - defaultTo' = flip defaultTo withCompletion f = withSettings (setComplete f defaultSettings) diff --git a/hledger/package.yaml b/hledger/package.yaml index dca353cd8..8e1f00d6d 100644 --- a/hledger/package.yaml +++ b/hledger/package.yaml @@ -114,7 +114,7 @@ dependencies: - extra >=1.7.11 - filepath - githash >=0.1.6.2 -- haskeline >=0.6 +- haskeline >=0.8.4.0 - http-client - http-types - megaparsec >=7.0.0 && <9.8 diff --git a/stack.yaml b/stack.yaml index 730dca55c..795a11b7a 100644 --- a/stack.yaml +++ b/stack.yaml @@ -15,6 +15,8 @@ notify-if-ghc-untested: false notify-if-cabal-untested: false extra-deps: +# for #2410, #2512: +- haskeline-0.8.4.1 # currently out of stackage: - yesod-static-1.6.1.0 - yesod-test-1.6.19 diff --git a/stack910.yaml b/stack910.yaml index 514e45614..cf63f4ab3 100644 --- a/stack910.yaml +++ b/stack910.yaml @@ -10,6 +10,10 @@ packages: - hledger-ui - hledger-web +extra-deps: +# for #2410, #2512: +- haskeline-0.8.4.1 + nix: pure: false packages: [perl gmp ncurses zlib] diff --git a/stack914.yaml b/stack914.yaml index e74033f05..970b3c833 100644 --- a/stack914.yaml +++ b/stack914.yaml @@ -14,6 +14,8 @@ packages: - hledger-web extra-deps: +# for #2410, #2512: +- haskeline-0.8.4.1 # currently out of stackage: - yesod-static-1.6.1.0 - yesod-test-1.6.19 diff --git a/stack96.yaml b/stack96.yaml index 7b35e1ccf..4745f7669 100644 --- a/stack96.yaml +++ b/stack96.yaml @@ -12,6 +12,8 @@ extra-deps: - encoding-0.10 - hashtables-1.4.2 - vty-windows-0.2.0.1 +# for #2410, #2512: +- haskeline-0.8.4.1 nix: pure: false diff --git a/stack98.yaml b/stack98.yaml index c15bf0193..3c7fbed56 100644 --- a/stack98.yaml +++ b/stack98.yaml @@ -11,6 +11,8 @@ packages: extra-deps: - encoding-0.10 - hashtables-1.4.2 +# for #2410, #2512: +- haskeline-0.8.4.1 nix: pure: false