dev!: ui: Rename fields of UIOpts for consistency.
In code, either replace the name with the new name, or use the lenses instead. watch_ -> uoWatch cliopts_ -> uoCliOpts
This commit is contained in:
		
							parent
							
								
									7f7f1a2cdf
								
							
						
					
					
						commit
						765466c392
					
				| @ -49,7 +49,7 @@ accountsScreen = AccountsScreen{ | ||||
| 
 | ||||
| asInit :: Day -> Bool -> UIState -> UIState | ||||
| asInit d reset ui@UIState{ | ||||
|   aopts=UIOpts{cliopts_=copts@CliOpts{reportspec_=rspec@ReportSpec{_rsReportOpts=ropts}}}, | ||||
|   aopts=UIOpts{uoCliOpts=copts@CliOpts{reportspec_=rspec@ReportSpec{_rsReportOpts=ropts}}}, | ||||
|   ajournal=j, | ||||
|   aScreen=s@AccountsScreen{} | ||||
|   } = | ||||
| @ -103,7 +103,7 @@ asInit d reset ui@UIState{ | ||||
| asInit _ _ _ = error "init function called with wrong screen type, should not happen"  -- PARTIAL: | ||||
| 
 | ||||
| asDraw :: UIState -> [Widget Name] | ||||
| asDraw UIState{aopts=_uopts@UIOpts{cliopts_=copts@CliOpts{reportspec_=rspec}} | ||||
| asDraw UIState{aopts=_uopts@UIOpts{uoCliOpts=copts@CliOpts{reportspec_=rspec}} | ||||
|               ,ajournal=j | ||||
|               ,aScreen=s@AccountsScreen{} | ||||
|               ,aMode=mode | ||||
| @ -223,7 +223,7 @@ asDrawItem (acctwidth, balwidth) selected AccountsScreenItem{..} = | ||||
| asHandle :: UIState -> BrickEvent Name AppEvent -> EventM Name (Next UIState) | ||||
| asHandle ui0@UIState{ | ||||
|    aScreen=scr@AccountsScreen{..} | ||||
|   ,aopts=UIOpts{cliopts_=copts} | ||||
|   ,aopts=UIOpts{uoCliOpts=copts} | ||||
|   ,ajournal=j | ||||
|   ,aMode=mode | ||||
|   } ev = do | ||||
|  | ||||
| @ -21,6 +21,7 @@ import Data.Void (Void) | ||||
| import Graphics.Vty (Event(..),Key(..),Modifier(..)) | ||||
| import Text.Megaparsec | ||||
| import Text.Megaparsec.Char | ||||
| import Lens.Micro ((^.)) | ||||
| 
 | ||||
| import Hledger.Cli hiding (progname,prognameandversion) | ||||
| import Hledger.UI.UIOptions | ||||
| @ -42,7 +43,7 @@ esInit _ _ ui@UIState{aScreen=ErrorScreen{}} = ui | ||||
| esInit _ _ _ = error "init function called with wrong screen type, should not happen"  -- PARTIAL: | ||||
| 
 | ||||
| esDraw :: UIState -> [Widget Name] | ||||
| esDraw UIState{aopts=UIOpts{cliopts_=copts@CliOpts{}} | ||||
| esDraw UIState{aopts=UIOpts{uoCliOpts=copts} | ||||
|               ,aScreen=ErrorScreen{..} | ||||
|               ,aMode=mode | ||||
|               } = | ||||
| @ -75,7 +76,7 @@ esDraw _ = error "draw function called with wrong screen type, should not happen | ||||
| 
 | ||||
| esHandle :: UIState -> BrickEvent Name AppEvent -> EventM Name (Next UIState) | ||||
| esHandle ui@UIState{aScreen=ErrorScreen{..} | ||||
|                    ,aopts=UIOpts{cliopts_=copts} | ||||
|                    ,aopts=UIOpts{uoCliOpts=copts} | ||||
|                    ,ajournal=j | ||||
|                    ,aMode=mode | ||||
|                    } | ||||
| @ -181,8 +182,8 @@ uiReloadJournalIfChanged copts d j ui = do | ||||
| -- fail, enter (or update) the error screen. Or if balance assertions | ||||
| -- are disabled, do nothing. | ||||
| uiCheckBalanceAssertions :: Day -> UIState -> UIState | ||||
| uiCheckBalanceAssertions d ui@UIState{aopts=UIOpts{cliopts_=copts}, ajournal=j} | ||||
|   | ignore_assertions_ . balancingopts_ $ inputopts_ copts = ui | ||||
| uiCheckBalanceAssertions d ui@UIState{ajournal=j} | ||||
|   | ui^.ignore_assertions = ui | ||||
|   | otherwise = | ||||
|     case journalCheckBalanceAssertions j of | ||||
|       Nothing  -> ui | ||||
|  | ||||
| @ -44,7 +44,7 @@ writeChan = BC.writeBChan | ||||
| 
 | ||||
| main :: IO () | ||||
| main = do | ||||
|   opts@UIOpts{cliopts_=copts@CliOpts{inputopts_=iopts,rawopts_=rawopts}} <- getHledgerUIOpts | ||||
|   opts@UIOpts{uoCliOpts=copts@CliOpts{inputopts_=iopts,rawopts_=rawopts}} <- getHledgerUIOpts | ||||
|   -- when (debug_ $ cliopts_ opts) $ printf "%s\n" prognameandversion >> printf "opts: %s\n" (show opts) | ||||
| 
 | ||||
|   -- always generate forecasted periodic transactions; their visibility will be toggled by the UI. | ||||
| @ -59,7 +59,7 @@ main = do | ||||
|     _                                         -> withJournalDo copts' (runBrickUi opts) | ||||
| 
 | ||||
| runBrickUi :: UIOpts -> Journal -> IO () | ||||
| runBrickUi uopts@UIOpts{cliopts_=copts@CliOpts{inputopts_=_iopts,reportspec_=rspec@ReportSpec{_rsReportOpts=ropts}}} j = do | ||||
| runBrickUi uopts@UIOpts{uoCliOpts=copts@CliOpts{inputopts_=_iopts,reportspec_=rspec@ReportSpec{_rsReportOpts=ropts}}} j = do | ||||
|   d <- getCurrentDay | ||||
| 
 | ||||
|   let | ||||
| @ -102,7 +102,7 @@ runBrickUi uopts@UIOpts{cliopts_=copts@CliOpts{inputopts_=_iopts,reportspec_=rsp | ||||
|     -- It's cleaner and less conflicting to keep the former out of the latter. | ||||
| 
 | ||||
|     uopts' = uopts{ | ||||
|       cliopts_=copts{ | ||||
|       uoCliOpts=copts{ | ||||
|          reportspec_=rspec{ | ||||
|             _rsQuery=filteredQuery $ _rsQuery rspec,  -- query with depth/date parts removed | ||||
|             _rsReportOpts=ropts{ | ||||
| @ -168,7 +168,7 @@ runBrickUi uopts@UIOpts{cliopts_=copts@CliOpts{inputopts_=_iopts,reportspec_=rsp | ||||
| 
 | ||||
|   -- print (length (show ui)) >> exitSuccess  -- show any debug output to this point & quit | ||||
| 
 | ||||
|   if not (watch_ uopts') | ||||
|   if not (uoWatch uopts') | ||||
|   then | ||||
|     void $ Brick.defaultMain brickapp ui | ||||
| 
 | ||||
|  | ||||
| @ -56,7 +56,7 @@ rsSetAccount a forceinclusive scr@RegisterScreen{} = | ||||
| rsSetAccount _ _ scr = scr | ||||
| 
 | ||||
| rsInit :: Day -> Bool -> UIState -> UIState | ||||
| rsInit d reset ui@UIState{aopts=_uopts@UIOpts{cliopts_=copts@CliOpts{reportspec_=rspec@ReportSpec{_rsReportOpts=ropts}}}, ajournal=j, aScreen=s@RegisterScreen{..}} = | ||||
| rsInit d reset ui@UIState{aopts=_uopts@UIOpts{uoCliOpts=copts@CliOpts{reportspec_=rspec@ReportSpec{_rsReportOpts=ropts}}}, ajournal=j, aScreen=s@RegisterScreen{..}} = | ||||
|   ui{aScreen=s{rsList=newitems'}} | ||||
|   where | ||||
|     -- gather arguments and queries | ||||
| @ -134,7 +134,7 @@ rsInit d reset ui@UIState{aopts=_uopts@UIOpts{cliopts_=copts@CliOpts{reportspec_ | ||||
| rsInit _ _ _ = error "init function called with wrong screen type, should not happen"  -- PARTIAL: | ||||
| 
 | ||||
| rsDraw :: UIState -> [Widget Name] | ||||
| rsDraw UIState{aopts=_uopts@UIOpts{cliopts_=copts@CliOpts{reportspec_=rspec}} | ||||
| rsDraw UIState{aopts=_uopts@UIOpts{uoCliOpts=copts@CliOpts{reportspec_=rspec}} | ||||
|               ,aScreen=RegisterScreen{..} | ||||
|               ,aMode=mode | ||||
|               } = | ||||
| @ -275,7 +275,7 @@ rsDrawItem (datewidth,descwidth,acctswidth,changewidth,balwidth) selected Regist | ||||
| rsHandle :: UIState -> BrickEvent Name AppEvent -> EventM Name (Next UIState) | ||||
| rsHandle ui@UIState{ | ||||
|    aScreen=s@RegisterScreen{..} | ||||
|   ,aopts=UIOpts{cliopts_=copts} | ||||
|   ,aopts=UIOpts{uoCliOpts=copts} | ||||
|   ,ajournal=j | ||||
|   ,aMode=mode | ||||
|   } ev = do | ||||
|  | ||||
| @ -41,7 +41,7 @@ transactionScreen = TransactionScreen{ | ||||
|   } | ||||
| 
 | ||||
| tsInit :: Day -> Bool -> UIState -> UIState | ||||
| tsInit _d _reset ui@UIState{aopts=UIOpts{cliopts_=CliOpts{reportspec_=_rspec}} | ||||
| tsInit _d _reset ui@UIState{aopts=UIOpts{} | ||||
|                            ,ajournal=_j | ||||
|                            ,aScreen=s@TransactionScreen{tsTransaction=(_,t),tsTransactions=nts} | ||||
|                            ,aPrevScreens=prevscreens | ||||
| @ -60,7 +60,7 @@ tsInit _d _reset ui@UIState{aopts=UIOpts{cliopts_=CliOpts{reportspec_=_rspec}} | ||||
| tsInit _ _ _ = error "init function called with wrong screen type, should not happen"  -- PARTIAL: | ||||
| 
 | ||||
| tsDraw :: UIState -> [Widget Name] | ||||
| tsDraw UIState{aopts=UIOpts{cliopts_=copts@CliOpts{reportspec_=rspec@ReportSpec{_rsReportOpts=ropts}}} | ||||
| tsDraw UIState{aopts=UIOpts{uoCliOpts=copts@CliOpts{reportspec_=rspec@ReportSpec{_rsReportOpts=ropts}}} | ||||
|               ,ajournal=j | ||||
|               ,aScreen=TransactionScreen{tsTransaction=(i,t') | ||||
|                                         ,tsTransactions=nts | ||||
| @ -133,7 +133,7 @@ tsDraw _ = error "draw function called with wrong screen type, should not happen | ||||
| 
 | ||||
| tsHandle :: UIState -> BrickEvent Name AppEvent -> EventM Name (Next UIState) | ||||
| tsHandle ui@UIState{aScreen=TransactionScreen{tsTransaction=(i,t), tsTransactions=nts} | ||||
|                    ,aopts=UIOpts{cliopts_=copts} | ||||
|                    ,aopts=UIOpts{uoCliOpts=copts} | ||||
|                    ,ajournal=j | ||||
|                    ,aMode=mode | ||||
|                    } | ||||
|  | ||||
| @ -66,17 +66,17 @@ uimode =  (mode "hledger-ui" (setopt "command" "ui" def) | ||||
| 
 | ||||
| -- hledger-ui options, used in hledger-ui and above | ||||
| data UIOpts = UIOpts | ||||
|   { watch_     :: Bool | ||||
|   { uoWatch    :: Bool | ||||
|   , uoTheme    :: Maybe String | ||||
|   , uoRegister :: Maybe String | ||||
|   , cliopts_   :: CliOpts | ||||
|   , uoCliOpts  :: CliOpts | ||||
|   } deriving (Show) | ||||
| 
 | ||||
| defuiopts = UIOpts | ||||
|   { watch_     = False | ||||
|   { uoWatch    = False | ||||
|   , uoTheme    = Nothing | ||||
|   , uoRegister = Nothing | ||||
|   , cliopts_   = defcliopts | ||||
|   , uoCliOpts  = defcliopts | ||||
|   } | ||||
| 
 | ||||
| -- | Process a RawOpts into a UIOpts. | ||||
| @ -85,10 +85,10 @@ rawOptsToUIOpts :: RawOpts -> IO UIOpts | ||||
| rawOptsToUIOpts rawopts = do | ||||
|     cliopts <- set balanceaccum accum <$> rawOptsToCliOpts rawopts | ||||
|     return defuiopts { | ||||
|                 watch_     = boolopt "watch" rawopts | ||||
|                 uoWatch    = boolopt "watch" rawopts | ||||
|                ,uoTheme    = checkTheme <$> maybestringopt "theme" rawopts | ||||
|                ,uoRegister = maybestringopt "register" rawopts | ||||
|                ,cliopts_   = cliopts | ||||
|                ,uoCliOpts  = cliopts | ||||
|                } | ||||
|   where | ||||
|     -- show historical balance by default (unlike hledger) | ||||
| @ -105,7 +105,7 @@ getHledgerUIOpts = do | ||||
|   rawOptsToUIOpts cmdargopts | ||||
| 
 | ||||
| instance HasCliOpts UIOpts where | ||||
|     cliOpts f uiopts = (\x -> uiopts{cliopts_=x}) <$> f (cliopts_ uiopts) | ||||
|     cliOpts f uiopts = (\x -> uiopts{uoCliOpts=x}) <$> f (uoCliOpts uiopts) | ||||
| 
 | ||||
| instance HasInputOpts UIOpts where | ||||
|     inputOpts = cliOpts.inputOpts | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user