ui: acc: show a better title with filename & query
This commit is contained in:
		
							parent
							
								
									d32a028a19
								
							
						
					
					
						commit
						f496ec9809
					
				| @ -11,8 +11,9 @@ import Control.Lens ((^.)) | |||||||
| import Control.Monad.IO.Class | import Control.Monad.IO.Class | ||||||
| -- import Data.Default | -- import Data.Default | ||||||
| import Data.List | import Data.List | ||||||
| -- import Data.Monoid              --  | import Data.Monoid | ||||||
| import Data.Time.Calendar (Day) | import Data.Time.Calendar (Day) | ||||||
|  | import System.FilePath (takeFileName) | ||||||
| import qualified Data.Vector as V | import qualified Data.Vector as V | ||||||
| import Graphics.Vty as Vty | import Graphics.Vty as Vty | ||||||
| import Brick | import Brick | ||||||
| @ -56,9 +57,22 @@ initAccountsScreen d args st@AppState{aopts=opts, ajournal=j, aScreen=s@Accounts | |||||||
| initAccountsScreen _ _ _ = error "init function called with wrong screen type, should not happen" | initAccountsScreen _ _ _ = error "init function called with wrong screen type, should not happen" | ||||||
| 
 | 
 | ||||||
| drawAccountsScreen :: AppState -> [Widget] | drawAccountsScreen :: AppState -> [Widget] | ||||||
| drawAccountsScreen st@AppState{aScreen=AccountsScreen{asState=is}} = [ui] | drawAccountsScreen st@AppState{aopts=uopts, ajournal=j, aScreen=AccountsScreen{asState=is}} = [ui] | ||||||
|     where |     where | ||||||
|       label = str "Account " <+> cur <+> str " of " <+> total |       label = str "Accounts in " | ||||||
|  |               <+> withAttr ("border" <> "bold") files | ||||||
|  |               <+> borderQuery querystr | ||||||
|  |               <+> str " (" | ||||||
|  |               <+> cur | ||||||
|  |               <+> str " of " | ||||||
|  |               <+> total | ||||||
|  |               <+> str ")" | ||||||
|  |       files = str $ case journalFilePaths j of | ||||||
|  |                      [] -> "" | ||||||
|  |                      [f] -> takeFileName f | ||||||
|  |                      [f,_] -> takeFileName f ++ " (& 1 included file)" | ||||||
|  |                      f:fs -> takeFileName f ++ " (& " ++ show (length fs) ++ " included files)" | ||||||
|  |       querystr = query_ $ reportopts_ $ cliopts_ uopts | ||||||
|       cur = str (case is^.listSelectedL of |       cur = str (case is^.listSelectedL of | ||||||
|                   Nothing -> "-" |                   Nothing -> "-" | ||||||
|                   Just i -> show (i + 1)) |                   Just i -> show (i + 1)) | ||||||
|  | |||||||
| @ -66,7 +66,9 @@ themesList :: [(String, AttrMap)] | |||||||
| themesList = [ | themesList = [ | ||||||
|   ("default", attrMap |   ("default", attrMap | ||||||
|             (black `on` white & bold) [ -- default style for this theme |             (black `on` white & bold) [ -- default style for this theme | ||||||
|               (borderAttr       , white `on` black), |               (borderAttr       , white `on` black & dim), | ||||||
|  |               (borderAttr <> "bold", white `on` black & bold), | ||||||
|  |               (borderAttr <> "query", yellow `on` black & bold), | ||||||
|               -- ("normal"                , black `on` white), |               -- ("normal"                , black `on` white), | ||||||
|               ("list"                  , black `on` white),      -- regular list items |               ("list"                  , black `on` white),      -- regular list items | ||||||
|               ("list" <> "selected"    , white `on` blue & bold) -- selected list items |               ("list" <> "selected"    , white `on` blue & bold) -- selected list items | ||||||
|  | |||||||
| @ -9,13 +9,14 @@ module Hledger.UI.UIUtils ( | |||||||
|  ,withBorderAttr |  ,withBorderAttr | ||||||
|  ,topBottomBorderWithLabel |  ,topBottomBorderWithLabel | ||||||
|  ,defaultLayout |  ,defaultLayout | ||||||
|  |  ,borderQuery | ||||||
|  ) where |  ) where | ||||||
| 
 | 
 | ||||||
| import Control.Lens ((^.)) | import Control.Lens ((^.)) | ||||||
| -- import Control.Monad | -- import Control.Monad | ||||||
| -- import Control.Monad.IO.Class | -- import Control.Monad.IO.Class | ||||||
| -- import Data.Default | -- import Data.Default | ||||||
| -- import Data.Monoid              --  | import Data.Monoid | ||||||
| import Data.Time.Calendar (Day) | import Data.Time.Calendar (Day) | ||||||
| import Brick | import Brick | ||||||
| -- import Brick.Widgets.List | -- import Brick.Widgets.List | ||||||
| @ -121,3 +122,7 @@ withBorderAttr attr = updateAttrMap (applyAttrMappings [(borderAttr, attr)]) | |||||||
| --                       , str " " | --                       , str " " | ||||||
| --                       , hCenter $ str "Press Esc to exit." | --                       , hCenter $ str "Press Esc to exit." | ||||||
| --                       ] | --                       ] | ||||||
|  | 
 | ||||||
|  | borderQuery :: String -> Widget | ||||||
|  | borderQuery ""  = str "" | ||||||
|  | borderQuery qry = str " filtered by: " <+> withAttr (borderAttr <> "query") (str qry) | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user