From 2076d5a98b9046f0bd095aa984c91bcd808406e0 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Wed, 17 Nov 2021 16:56:50 -1000 Subject: [PATCH] ui: enable mouse support at startup --- hledger-ui/Hledger/UI/Main.hs | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/hledger-ui/Hledger/UI/Main.hs b/hledger-ui/Hledger/UI/Main.hs index 29988b3f6..7c504fb77 100644 --- a/hledger-ui/Hledger/UI/Main.hs +++ b/hledger-ui/Hledger/UI/Main.hs @@ -17,7 +17,7 @@ import Data.List (find) import Data.List.Extra (nubSort) import Data.Maybe (fromMaybe) import qualified Data.Text as T -import Graphics.Vty (mkVty) +import Graphics.Vty (mkVty, Mode (Mouse), Vty (outputIface), Output (setMode)) import Lens.Micro ((^.)) import System.Directory (canonicalizePath) import System.FilePath (takeDirectory) @@ -168,9 +168,17 @@ runBrickUi uopts@UIOpts{uoCliOpts=copts@CliOpts{inputopts_=_iopts,reportspec_=rs -- print (length (show ui)) >> exitSuccess -- show any debug output to this point & quit + let + -- helper: make a Vty terminal controller with mouse support enabled + makevty = do + v <- mkVty mempty + setMode (outputIface v) Mouse True + return v + if not (uoWatch uopts') - then - void $ Brick.defaultMain brickapp ui + then do + vty <- makevty + void $ customMain vty makevty Nothing brickapp ui else do -- a channel for sending misc. events to the app @@ -228,7 +236,6 @@ runBrickUi uopts@UIOpts{uoCliOpts=copts@CliOpts{inputopts_=_iopts,reportspec_=rs writeChan eventChan FileChange ) - -- and start the app. Must be inside the withManager block - let vtyhandle = mkVty mempty - vty <- vtyhandle - void $ customMain vty vtyhandle (Just eventChan) brickapp ui + -- and start the app. Must be inside the withManager block. (XXX makevty too ?) + vty <- makevty + void $ customMain vty makevty (Just eventChan) brickapp ui