summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathanDaugherty <>2020-07-09 22:23:00 (GMT)
committerhdiff <hdiff@hdiff.luite.com>2020-07-09 22:23:00 (GMT)
commitd99ae923666495e2f74b1d93ead90b044f8e30b1 (patch)
tree6089fa70e9b845590dcbc997715d47d6727299a0
parent7502408c17ea24e691b0c0bb33e16c928c611391 (diff)
version 0.55HEAD0.55master
-rw-r--r--CHANGELOG.md13
-rw-r--r--README.md1
-rw-r--r--brick.cabal4
-rw-r--r--src/Brick/Main.hs16
4 files changed, 32 insertions, 2 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4b0bf93..a30ecb6 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,19 @@
Brick changelog
---------------
+0.55
+----
+
+Package changes:
+ * Increased lower bound on `vty` dependency to 5.29.
+
+Bug fixes:
+ * `customMain` now restores the initial terminal input state on
+ shutdown. This means that changes to the input state flags in the last
+ `suspendAndResume` before program exit are no longer propagated to the
+ end user's terminal environment (which could lead to broken or garbled
+ terminal I/O).
+
0.54
----
diff --git a/README.md b/README.md
index dd872ce..85ac910 100644
--- a/README.md
+++ b/README.md
@@ -62,6 +62,7 @@ at these projects:
* [`sudoku-tui`](https://github.com/evanrelf/sudoku-tui), a Sudoku implementation
* [`summoner-tui`](https://github.com/kowainik/summoner/tree/master/summoner-tui), an interactive frontend to the Summoner tool
* [`wrapping-editor`](https://github.com/ta0kira/wrapping-editor), an embeddable editor with support for Brick
+ * [`git-brunch`](https://github.com/andys8/git-brunch), a git branch checkout utility
These third-party packages also extend `brick`:
diff --git a/brick.cabal b/brick.cabal
index 916c911..3be36a9 100644
--- a/brick.cabal
+++ b/brick.cabal
@@ -1,5 +1,5 @@
name: brick
-version: 0.54
+version: 0.55
synopsis: A declarative terminal user interface library
description:
Write terminal user interfaces (TUIs) painlessly with 'brick'! You
@@ -114,7 +114,7 @@ library
Brick.Widgets.Internal
build-depends: base <= 4.14.0.0,
- vty >= 5.24,
+ vty >= 5.29,
transformers,
data-clist >= 0.1,
directory >= 1.2.5.0,
diff --git a/src/Brick/Main.hs b/src/Brick/Main.hs
index b5e975d..05b1907 100644
--- a/src/Brick/Main.hs
+++ b/src/Brick/Main.hs
@@ -75,6 +75,8 @@ import Graphics.Vty
, nextEvent
, mkVty
, defaultConfig
+ , restoreInputState
+ , inputIface
)
import Graphics.Vty.Attributes (defAttr)
@@ -202,6 +204,10 @@ runWithVty vty brickChan mUserChan app initialRS initialSt = do
-- | The custom event loop entry point to use when the simpler ones
-- don't permit enough control. Returns the final application state
-- after the application halts.
+--
+-- Note that this function guarantees that the terminal input state
+-- prior to the first Vty initialization is the terminal input state
+-- that is restored on shutdown (regardless of exceptions).
customMain :: (Ord n)
=> Vty
-- ^ The initial Vty handle to use.
@@ -221,8 +227,13 @@ customMain :: (Ord n)
-- ^ The initial application state.
-> IO s
customMain initialVty buildVty mUserChan app initialAppState = do
+ let restoreInitialState = restoreInputState $ inputIface initialVty
+
(s, vty) <- customMainWithVty initialVty buildVty mUserChan app initialAppState
+ `E.catch` (\(e::E.SomeException) -> restoreInitialState >> E.throw e)
+
shutdown vty
+ restoreInitialState
return s
-- | Like 'customMain', except the last 'Vty' handle used by the
@@ -526,5 +537,10 @@ halt = return . Halt
-- specified action. When it returns an application state value, restore
-- the terminal state, empty the rendering cache, redraw the application
-- from the new state, and resume the event loop.
+--
+-- Note that any changes made to the terminal's input state are ignored
+-- when Brick resumes execution and are not preserved in the final
+-- terminal input state after the Brick application returns the terminal
+-- to the user.
suspendAndResume :: IO s -> EventM n (Next s)
suspendAndResume = return . SuspendAndResume