Skip to content

Commit

Permalink
Reset cursor position on rebuild with --clear-screen --watch (purescr…
Browse files Browse the repository at this point in the history
  • Loading branch information
jhrcek authored and Benjmhart committed Oct 27, 2019
1 parent c67e582 commit 19cb6f1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Bugfixes:
- Fix confusing warning when trying to `spago install` a package already present in project dependencies list (#436)
- Do not watch files in `.spago` folder when running `spago build --watch` (#430)
- Fix dynamic libraries compatibility problems by publishing a statically linked executable for Linux (#427, #437)
- `--clear-screen` (usable e.g. with `spago build --watch`) now also resets cursor position, so the rebuild message always appears at top left of the screen (#465)

Other improvements:
- Speed up test suite by replacing couple of end 2 end bump-version tests with unit/property tests
Expand Down
8 changes: 5 additions & 3 deletions src/Spago/Watch.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ import Control.Concurrent.STM (check)
import qualified Data.Map.Strict as Map
import qualified Data.Set as Set
import Data.Text (pack, toLower, unpack)
import Data.Time.Clock (NominalDiffTime, diffUTCTime, getCurrentTime)
import GHC.IO (FilePath)
import GHC.IO.Exception
import System.Console.ANSI (clearScreen)
import System.Console.ANSI (clearScreen, setCursorPosition)
import System.FilePath (splitDirectories)
import qualified System.FilePath.Glob as Glob
import qualified System.FSNotify as Watch
import System.IO (getLine)
import qualified UnliftIO
import UnliftIO.Async (race_)
import Data.Time.Clock (NominalDiffTime, getCurrentTime, diffUTCTime)

-- Should we clear the screen on rebuild?
data ClearScreen = DoClear | NoClear
Expand Down Expand Up @@ -65,7 +65,9 @@ fileWatchConf watchConfig shouldClear inner = withManagerConf watchConfig $ \man
watchVar <- liftIO $ newTVarIO Map.empty

let redisplay maybeMsg = do
when (shouldClear == DoClear) $ liftIO clearScreen
when (shouldClear == DoClear) $ liftIO $ do
clearScreen
setCursorPosition 0 0
mapM_ echoStr maybeMsg

let onChange event = do
Expand Down

0 comments on commit 19cb6f1

Please sign in to comment.