From e3a55a72d9ac1cc4a2a71a2cdae26dfbb54aebc7 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Wed, 1 Jun 2016 12:17:32 -0700 Subject: [PATCH] ui: accounts: E key toggles --empty --- hledger-ui/Hledger/UI/AccountsScreen.hs | 2 ++ hledger-ui/Hledger/UI/UIUtils.hs | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/hledger-ui/Hledger/UI/AccountsScreen.hs b/hledger-ui/Hledger/UI/AccountsScreen.hs index 5957f0f25..76cc9c336 100644 --- a/hledger-ui/Hledger/UI/AccountsScreen.hs +++ b/hledger-ui/Hledger/UI/AccountsScreen.hs @@ -138,6 +138,7 @@ drawAccountsScreen AppState{aopts=UIOpts{cliopts_=CliOpts{reportopts_=ropts}} -- ("up/down/pgup/pgdown/home/end", "move") ("-=1234567890", "depth") ,("F", "flat?") + ,("E", "empty?") ,("C", "cleared?") ,("R", "real?") ,("right/enter", "register") @@ -255,6 +256,7 @@ handleAccountsScreen st@AppState{ Vty.EvKey (Vty.KChar '9') [] -> continue $ reload j d $ setDepth 9 st' Vty.EvKey (Vty.KChar '0') [] -> continue $ reload j d $ setDepth 0 st' Vty.EvKey (Vty.KChar 'F') [] -> continue $ reload j d $ stToggleFlat st' + Vty.EvKey (Vty.KChar 'E') [] -> continue $ reload j d $ stToggleEmpty st' Vty.EvKey (Vty.KChar 'C') [] -> continue $ reload j d $ stToggleCleared st' Vty.EvKey (Vty.KChar 'R') [] -> continue $ reload j d $ stToggleReal st' Vty.EvKey (Vty.KLeft) [] -> continue $ popScreen st' diff --git a/hledger-ui/Hledger/UI/UIUtils.hs b/hledger-ui/Hledger/UI/UIUtils.hs index 74ca5e104..0682fd526 100644 --- a/hledger-ui/Hledger/UI/UIUtils.hs +++ b/hledger-ui/Hledger/UI/UIUtils.hs @@ -16,6 +16,7 @@ module Hledger.UI.UIUtils ( ,borderKeysStr -- ,stToggleCleared + ,stToggleEmpty ,stToggleFlat ,stToggleReal ) where @@ -49,6 +50,14 @@ stToggleCleared st@AppState{aopts=uopts@UIOpts{cliopts_=copts@CliOpts{reportopts toggleCleared :: ReportOpts -> ReportOpts toggleCleared ropts = ropts{cleared_=not $ cleared_ ropts} +stToggleEmpty :: AppState -> AppState +stToggleEmpty st@AppState{aopts=uopts@UIOpts{cliopts_=copts@CliOpts{reportopts_=ropts}}} = + st{aopts=uopts{cliopts_=copts{reportopts_=toggleEmpty ropts}}} + +-- | Toggle between showing all and showing only empty items. +toggleEmpty :: ReportOpts -> ReportOpts +toggleEmpty ropts = ropts{empty_=not $ empty_ ropts} + stToggleFlat :: AppState -> AppState stToggleFlat st@AppState{aopts=uopts@UIOpts{cliopts_=copts@CliOpts{reportopts_=ropts}}} = st{aopts=uopts{cliopts_=copts{reportopts_=toggleFlatMode ropts}}}