mirror of
https://github.com/NorfairKing/feedback.git
synced 2024-11-23 05:23:37 +03:00
Show a 'Done.' indicator when exiting a loop to definitely reset the terminal colour
This commit is contained in:
parent
306d105111
commit
8c7f4f44af
@ -22,6 +22,9 @@ putTimedChunks terminalCapabilities chunks = do
|
||||
let timeChunk = fore yellow $ chunk $ T.pack $ formatTime defaultTimeLocale "%H:%M:%S" now
|
||||
putChunksLocaleWith terminalCapabilities $ timeChunk : " " : chunks ++ ["\n"]
|
||||
|
||||
putDone :: TerminalCapabilities -> IO ()
|
||||
putDone terminalCapabilities = putTimedChunks terminalCapabilities [indicatorChunk "Done."]
|
||||
|
||||
indicatorChunk :: String -> Chunk
|
||||
indicatorChunk = fore cyan . chunk . T.pack . printf "%-10s"
|
||||
|
||||
|
@ -39,27 +39,28 @@ runFeedbackLoop = do
|
||||
here <- getCurrentDir
|
||||
mStdinFiles <- getStdinFiles here
|
||||
terminalCapabilities <- getTermCaps
|
||||
forever $ do
|
||||
-- We show a 'preparing' chunk before we get the settings because sometimes
|
||||
-- getting the settings can take a while, for example in big repositories.
|
||||
putTimedChunks terminalCapabilities [indicatorChunk "preparing"]
|
||||
LoopSettings {..} <- getLoopSettings
|
||||
-- 0.1 second debouncing, 0.001 was too little
|
||||
let conf = FS.defaultConfig {confDebounce = Debounce 0.1}
|
||||
FS.withManagerConf conf $ \watchManager -> do
|
||||
eventFilter <- mkEventFilter here mStdinFiles loopSettingFilterSettings
|
||||
eventChan <- newChan
|
||||
outputChan <- newChan
|
||||
stopListeningAction <-
|
||||
FS.watchTree
|
||||
watchManager
|
||||
(fromAbsDir here) -- Where to watch
|
||||
eventFilter
|
||||
(writeChan eventChan)
|
||||
race_
|
||||
(processWorker loopSettingRunSettings eventChan outputChan)
|
||||
(outputWorker terminalCapabilities loopSettingOutputSettings outputChan)
|
||||
stopListeningAction
|
||||
let singleIteration = do
|
||||
-- We show a 'preparing' chunk before we get the settings because sometimes
|
||||
-- getting the settings can take a while, for example in big repositories.
|
||||
putTimedChunks terminalCapabilities [indicatorChunk "Preparing"]
|
||||
LoopSettings {..} <- getLoopSettings
|
||||
-- 0.1 second debouncing, 0.001 was too little
|
||||
let conf = FS.defaultConfig {confDebounce = Debounce 0.1}
|
||||
FS.withManagerConf conf $ \watchManager -> do
|
||||
eventFilter <- mkEventFilter here mStdinFiles loopSettingFilterSettings
|
||||
eventChan <- newChan
|
||||
outputChan <- newChan
|
||||
stopListeningAction <-
|
||||
FS.watchTree
|
||||
watchManager
|
||||
(fromAbsDir here) -- Where to watch
|
||||
eventFilter
|
||||
(writeChan eventChan)
|
||||
race_
|
||||
(processWorker loopSettingRunSettings eventChan outputChan)
|
||||
(outputWorker terminalCapabilities loopSettingOutputSettings outputChan)
|
||||
stopListeningAction
|
||||
forever singleIteration `finally` putDone terminalCapabilities
|
||||
|
||||
#ifdef MIN_VERSION_safe_coloured_text_terminfo
|
||||
getTermCaps :: IO TerminalCapabilities
|
||||
|
Loading…
Reference in New Issue
Block a user