ref: ui: lens: Use lenses in UIState, saving a lot of boilerplate.
This commit is contained in:
parent
f471258a48
commit
7f7f1a2cdf
@ -14,26 +14,23 @@ import Data.Semigroup (Max(..))
|
|||||||
import qualified Data.Text as T
|
import qualified Data.Text as T
|
||||||
import Data.Text.Zipper (gotoEOL)
|
import Data.Text.Zipper (gotoEOL)
|
||||||
import Data.Time.Calendar (Day)
|
import Data.Time.Calendar (Day)
|
||||||
|
import Lens.Micro ((^.), over, set)
|
||||||
|
|
||||||
import Hledger
|
import Hledger
|
||||||
import Hledger.Cli.CliOptions
|
import Hledger.Cli.CliOptions
|
||||||
import Hledger.UI.UITypes
|
import Hledger.UI.UITypes
|
||||||
import Hledger.UI.UIOptions
|
|
||||||
|
|
||||||
-- | Toggle between showing only unmarked items or all items.
|
-- | Toggle between showing only unmarked items or all items.
|
||||||
toggleUnmarked :: UIState -> UIState
|
toggleUnmarked :: UIState -> UIState
|
||||||
toggleUnmarked ui@UIState{aopts=uopts@UIOpts{cliopts_=copts@CliOpts{reportspec_=rspec}}} =
|
toggleUnmarked = over statuses (toggleStatus1 Unmarked)
|
||||||
ui{aopts=uopts{cliopts_=copts{reportspec_=reportSpecToggleStatus Unmarked copts rspec}}}
|
|
||||||
|
|
||||||
-- | Toggle between showing only pending items or all items.
|
-- | Toggle between showing only pending items or all items.
|
||||||
togglePending :: UIState -> UIState
|
togglePending :: UIState -> UIState
|
||||||
togglePending ui@UIState{aopts=uopts@UIOpts{cliopts_=copts@CliOpts{reportspec_=rspec}}} =
|
togglePending = over statuses (toggleStatus1 Pending)
|
||||||
ui{aopts=uopts{cliopts_=copts{reportspec_=reportSpecToggleStatus Pending copts rspec}}}
|
|
||||||
|
|
||||||
-- | Toggle between showing only cleared items or all items.
|
-- | Toggle between showing only cleared items or all items.
|
||||||
toggleCleared :: UIState -> UIState
|
toggleCleared :: UIState -> UIState
|
||||||
toggleCleared ui@UIState{aopts=uopts@UIOpts{cliopts_=copts@CliOpts{reportspec_=rspec}}} =
|
toggleCleared = over statuses (toggleStatus1 Cleared)
|
||||||
ui{aopts=uopts{cliopts_=copts{reportspec_=reportSpecToggleStatus Cleared copts rspec}}}
|
|
||||||
|
|
||||||
-- TODO testing different status toggle styles
|
-- TODO testing different status toggle styles
|
||||||
|
|
||||||
@ -53,17 +50,11 @@ uiShowStatus copts ss =
|
|||||||
showstatus Pending = "pending"
|
showstatus Pending = "pending"
|
||||||
showstatus Unmarked = "unmarked"
|
showstatus Unmarked = "unmarked"
|
||||||
|
|
||||||
reportSpecToggleStatus :: Status -> CliOpts -> ReportSpec -> ReportSpec
|
|
||||||
reportSpecToggleStatus s _copts =
|
|
||||||
either (error "reportSpecToggleStatus: changing status should not have caused this error") id -- PARTIAL:
|
|
||||||
. updateReportSpecWith (reportOptsToggleStatus1 s)
|
|
||||||
|
|
||||||
-- various toggle behaviours:
|
-- various toggle behaviours:
|
||||||
|
|
||||||
-- 1 UPC toggles only X/all
|
-- 1 UPC toggles only X/all
|
||||||
reportOptsToggleStatus1 s ropts@ReportOpts{statuses_=ss}
|
toggleStatus1 :: Status -> [Status] -> [Status]
|
||||||
| ss == [s] = ropts{statuses_=[]}
|
toggleStatus1 s ss = if ss == [s] then [] else [s]
|
||||||
| otherwise = ropts{statuses_=[s]}
|
|
||||||
|
|
||||||
-- 2 UPC cycles X/not-X/all
|
-- 2 UPC cycles X/not-X/all
|
||||||
-- repeatedly pressing X cycles:
|
-- repeatedly pressing X cycles:
|
||||||
@ -73,25 +64,25 @@ reportOptsToggleStatus1 s ropts@ReportOpts{statuses_=ss}
|
|||||||
-- pressing Y after first or second step starts new cycle:
|
-- pressing Y after first or second step starts new cycle:
|
||||||
-- [u] P [p]
|
-- [u] P [p]
|
||||||
-- [pc] P [p]
|
-- [pc] P [p]
|
||||||
-- reportOptsToggleStatus2 s ropts@ReportOpts{statuses_=ss}
|
-- toggleStatus2 s ss
|
||||||
-- | ss == [s] = ropts{statuses_=complement [s]}
|
-- | ss == [s] = complement [s]
|
||||||
-- | ss == complement [s] = ropts{statuses_=[]}
|
-- | ss == complement [s] = []
|
||||||
-- | otherwise = ropts{statuses_=[s]} -- XXX assume only three values
|
-- | otherwise = [s] -- XXX assume only three values
|
||||||
|
|
||||||
-- 3 UPC toggles each X
|
-- 3 UPC toggles each X
|
||||||
-- reportOptsToggleStatus3 s ropts@ReportOpts{statuses_=ss}
|
-- toggleStatus3 s ss
|
||||||
-- | s `elem` ss = ropts{statuses_=filter (/= s) ss}
|
-- | s `elem` ss = filter (/= s) ss
|
||||||
-- | otherwise = ropts{statuses_=simplifyStatuses (s:ss)}
|
-- | otherwise = simplifyStatuses (s:ss)
|
||||||
|
|
||||||
-- 4 upc sets X, UPC sets not-X
|
-- 4 upc sets X, UPC sets not-X
|
||||||
--reportOptsToggleStatus4 s ropts@ReportOpts{statuses_=ss}
|
-- toggleStatus4 s ss
|
||||||
-- | s `elem` ss = ropts{statuses_=filter (/= s) ss}
|
-- | s `elem` ss = filter (/= s) ss
|
||||||
-- | otherwise = ropts{statuses_=simplifyStatuses (s:ss)}
|
-- | otherwise = simplifyStatuses (s:ss)
|
||||||
|
|
||||||
-- 5 upc toggles X, UPC toggles not-X
|
-- 5 upc toggles X, UPC toggles not-X
|
||||||
--reportOptsToggleStatus5 s ropts@ReportOpts{statuses_=ss}
|
-- toggleStatus5 s ss
|
||||||
-- | s `elem` ss = ropts{statuses_=filter (/= s) ss}
|
-- | s `elem` ss = filter (/= s) ss
|
||||||
-- | otherwise = ropts{statuses_=simplifyStatuses (s:ss)}
|
-- | otherwise = simplifyStatuses (s:ss)
|
||||||
|
|
||||||
-- | Given a list of unique enum values, list the other possible values of that enum.
|
-- | Given a list of unique enum values, list the other possible values of that enum.
|
||||||
complement :: (Bounded a, Enum a, Eq a) => [a] -> [a]
|
complement :: (Bounded a, Enum a, Eq a) => [a] -> [a]
|
||||||
@ -101,56 +92,44 @@ complement = ([minBound..maxBound] \\)
|
|||||||
|
|
||||||
-- | Toggle between showing all and showing only nonempty (more precisely, nonzero) items.
|
-- | Toggle between showing all and showing only nonempty (more precisely, nonzero) items.
|
||||||
toggleEmpty :: UIState -> UIState
|
toggleEmpty :: UIState -> UIState
|
||||||
toggleEmpty ui@UIState{aopts=uopts@UIOpts{cliopts_=copts@CliOpts{reportspec_=rspec@ReportSpec{_rsReportOpts=ropts}}}} =
|
toggleEmpty = over empty__ not
|
||||||
ui{aopts=uopts{cliopts_=copts{reportspec_=rspec{_rsReportOpts=toggleEmpty ropts}}}}
|
|
||||||
where
|
|
||||||
toggleEmpty ropts = ropts{empty_=not $ empty_ ropts}
|
|
||||||
|
|
||||||
-- | Toggle between showing the primary amounts or costs.
|
-- | Toggle between showing the primary amounts or costs.
|
||||||
toggleCost :: UIState -> UIState
|
toggleCost :: UIState -> UIState
|
||||||
toggleCost ui@UIState{aopts=uopts@UIOpts{cliopts_=copts@CliOpts{reportspec_=rspec@ReportSpec{_rsReportOpts=ropts}}}} =
|
toggleCost = over cost toggleCostMode
|
||||||
ui{aopts=uopts{cliopts_=copts{reportspec_=rspec{_rsReportOpts=ropts{cost_ = toggle $ cost_ ropts}}}}}
|
|
||||||
where
|
where
|
||||||
toggle Cost = NoCost
|
toggleCostMode Cost = NoCost
|
||||||
toggle NoCost = Cost
|
toggleCostMode NoCost = Cost
|
||||||
|
|
||||||
-- | Toggle between showing primary amounts or default valuation.
|
-- | Toggle between showing primary amounts or default valuation.
|
||||||
toggleValue :: UIState -> UIState
|
toggleValue :: UIState -> UIState
|
||||||
toggleValue ui@UIState{aopts=uopts@UIOpts{cliopts_=copts@CliOpts{reportspec_=rspec@ReportSpec{_rsReportOpts=ropts}}}} =
|
toggleValue = over value valuationToggleValue
|
||||||
ui{aopts=uopts{cliopts_=copts{reportspec_=rspec{_rsReportOpts=ropts{
|
where
|
||||||
value_ = valuationToggleValue $ value_ ropts}}}}}
|
-- | Basic toggling of -V, for hledger-ui.
|
||||||
|
valuationToggleValue (Just (AtEnd _)) = Nothing
|
||||||
-- | Basic toggling of -V, for hledger-ui.
|
valuationToggleValue _ = Just $ AtEnd Nothing
|
||||||
valuationToggleValue :: Maybe ValuationType -> Maybe ValuationType
|
|
||||||
valuationToggleValue (Just (AtEnd _)) = Nothing
|
|
||||||
valuationToggleValue _ = Just $ AtEnd Nothing
|
|
||||||
|
|
||||||
-- | Set hierarchic account tree mode.
|
-- | Set hierarchic account tree mode.
|
||||||
setTree :: UIState -> UIState
|
setTree :: UIState -> UIState
|
||||||
setTree ui@UIState{aopts=uopts@UIOpts{cliopts_=copts@CliOpts{reportspec_=rspec@ReportSpec{_rsReportOpts=ropts}}}} =
|
setTree = set accountlistmode ALTree
|
||||||
ui{aopts=uopts{cliopts_=copts{reportspec_=rspec{_rsReportOpts=ropts{accountlistmode_=ALTree}}}}}
|
|
||||||
|
|
||||||
-- | Set flat account list mode.
|
-- | Set flat account list mode.
|
||||||
setList :: UIState -> UIState
|
setList :: UIState -> UIState
|
||||||
setList ui@UIState{aopts=uopts@UIOpts{cliopts_=copts@CliOpts{reportspec_=rspec@ReportSpec{_rsReportOpts=ropts}}}} =
|
setList = set accountlistmode ALFlat
|
||||||
ui{aopts=uopts{cliopts_=copts{reportspec_=rspec{_rsReportOpts=ropts{accountlistmode_=ALFlat}}}}}
|
|
||||||
|
|
||||||
-- | Toggle between flat and tree mode. If current mode is unspecified/default, assume it's flat.
|
-- | Toggle between flat and tree mode. If current mode is unspecified/default, assume it's flat.
|
||||||
toggleTree :: UIState -> UIState
|
toggleTree :: UIState -> UIState
|
||||||
toggleTree ui@UIState{aopts=uopts@UIOpts{cliopts_=copts@CliOpts{reportspec_=rspec@ReportSpec{_rsReportOpts=ropts}}}} =
|
toggleTree = over accountlistmode toggleTreeMode
|
||||||
ui{aopts=uopts{cliopts_=copts{reportspec_=rspec{_rsReportOpts=toggleTreeMode ropts}}}}
|
|
||||||
where
|
where
|
||||||
toggleTreeMode ropts
|
toggleTreeMode ALTree = ALFlat
|
||||||
| accountlistmode_ ropts == ALTree = ropts{accountlistmode_=ALFlat}
|
toggleTreeMode ALFlat = ALTree
|
||||||
| otherwise = ropts{accountlistmode_=ALTree}
|
|
||||||
|
|
||||||
-- | Toggle between historical balances and period balances.
|
-- | Toggle between historical balances and period balances.
|
||||||
toggleHistorical :: UIState -> UIState
|
toggleHistorical :: UIState -> UIState
|
||||||
toggleHistorical ui@UIState{aopts=uopts@UIOpts{cliopts_=copts@CliOpts{reportspec_=rspec@ReportSpec{_rsReportOpts=ropts}}}} =
|
toggleHistorical = over balanceaccum toggleBalanceAccum
|
||||||
ui{aopts=uopts{cliopts_=copts{reportspec_=rspec{_rsReportOpts=ropts{balanceaccum_=b}}}}}
|
|
||||||
where
|
where
|
||||||
b | balanceaccum_ ropts == Historical = PerPeriod
|
toggleBalanceAccum Historical = PerPeriod
|
||||||
| otherwise = Historical
|
toggleBalanceAccum _ = Historical
|
||||||
|
|
||||||
-- | Toggle hledger-ui's "forecast/future mode". When this mode is enabled,
|
-- | Toggle hledger-ui's "forecast/future mode". When this mode is enabled,
|
||||||
-- hledger-shows regular transactions which have future dates, and
|
-- hledger-shows regular transactions which have future dates, and
|
||||||
@ -158,46 +137,33 @@ toggleHistorical ui@UIState{aopts=uopts@UIOpts{cliopts_=copts@CliOpts{reportspec
|
|||||||
-- (which are usually but not necessarily future-dated).
|
-- (which are usually but not necessarily future-dated).
|
||||||
-- In normal mode, both of these are hidden.
|
-- In normal mode, both of these are hidden.
|
||||||
toggleForecast :: Day -> UIState -> UIState
|
toggleForecast :: Day -> UIState -> UIState
|
||||||
toggleForecast _d ui@UIState{aopts=UIOpts{cliopts_=copts}} =
|
toggleForecast _d ui = set forecast newForecast ui
|
||||||
uiSetForecast ui $
|
where
|
||||||
case forecast_ $ inputopts_ copts of
|
newForecast = case ui^.forecast of
|
||||||
Just _ -> Nothing
|
Just _ -> Nothing
|
||||||
Nothing -> forecast_ . inputopts_ $ enableForecastPreservingPeriod ui copts
|
Nothing -> enableForecastPreservingPeriod ui (ui^.cliOpts) ^. forecast
|
||||||
|
|
||||||
-- | Ensure this CliOpts enables forecasted transactions.
|
-- | Ensure this CliOpts enables forecasted transactions.
|
||||||
-- If a forecast period was specified in the old CliOpts,
|
-- If a forecast period was specified in the old CliOpts,
|
||||||
-- or in the provided UIState's startup options,
|
-- or in the provided UIState's startup options,
|
||||||
-- it is preserved.
|
-- it is preserved.
|
||||||
enableForecastPreservingPeriod :: UIState -> CliOpts -> CliOpts
|
enableForecastPreservingPeriod :: UIState -> CliOpts -> CliOpts
|
||||||
enableForecastPreservingPeriod ui copts@CliOpts{inputopts_=iopts} =
|
enableForecastPreservingPeriod ui copts = set forecast mforecast copts
|
||||||
copts{inputopts_=iopts{forecast_=mforecast}}
|
|
||||||
where
|
where
|
||||||
mforecast = asum [mprovidedforecastperiod, mstartupforecastperiod, mdefaultforecastperiod]
|
mforecast = asum [mprovidedforecastperiod, mstartupforecastperiod, mdefaultforecastperiod]
|
||||||
where
|
where
|
||||||
mprovidedforecastperiod = forecast_ $ inputopts_ copts
|
mprovidedforecastperiod = copts ^. forecast
|
||||||
mstartupforecastperiod = forecast_ $ inputopts_ $ cliopts_ $ astartupopts ui
|
mstartupforecastperiod = astartupopts ui ^. forecast
|
||||||
mdefaultforecastperiod = Just nulldatespan
|
mdefaultforecastperiod = Just nulldatespan
|
||||||
|
|
||||||
-- | Helper: set forecast mode (with the given forecast period) on or off in the UI state.
|
|
||||||
uiSetForecast :: UIState -> Maybe DateSpan -> UIState
|
|
||||||
uiSetForecast
|
|
||||||
ui@UIState{aopts=uopts@UIOpts{cliopts_=copts@CliOpts{inputopts_=iopts}}}
|
|
||||||
mforecast =
|
|
||||||
-- we assume forecast mode has no effect on ReportSpec's derived fields
|
|
||||||
ui{aopts=uopts{cliopts_=copts{inputopts_=iopts{forecast_=mforecast}}}}
|
|
||||||
|
|
||||||
-- | Toggle between showing all and showing only real (non-virtual) items.
|
-- | Toggle between showing all and showing only real (non-virtual) items.
|
||||||
toggleReal :: UIState -> UIState
|
toggleReal :: UIState -> UIState
|
||||||
toggleReal ui@UIState{aopts=uopts@UIOpts{cliopts_=copts@CliOpts{reportspec_=rspec}}} =
|
toggleReal = fromRight err . overEither real not -- PARTIAL:
|
||||||
ui{aopts=uopts{cliopts_=copts{reportspec_=update rspec}}}
|
where err = error "toggleReal: updating Real should not result in an error"
|
||||||
where
|
|
||||||
update = either (error "toggleReal: updating Real should not result in an error") id -- PARTIAL:
|
|
||||||
. updateReportSpecWith (\ropts -> ropts{real_=not $ real_ ropts})
|
|
||||||
|
|
||||||
-- | Toggle the ignoring of balance assertions.
|
-- | Toggle the ignoring of balance assertions.
|
||||||
toggleIgnoreBalanceAssertions :: UIState -> UIState
|
toggleIgnoreBalanceAssertions :: UIState -> UIState
|
||||||
toggleIgnoreBalanceAssertions ui@UIState{aopts=uopts@UIOpts{cliopts_=copts@CliOpts{inputopts_=iopts@InputOpts{balancingopts_=bopts}}}} =
|
toggleIgnoreBalanceAssertions = over ignore_assertions not
|
||||||
ui{aopts=uopts{cliopts_=copts{inputopts_=iopts{balancingopts_=bopts{ignore_assertions_=not $ ignore_assertions_ bopts}}}}}
|
|
||||||
|
|
||||||
-- | Step through larger report periods, up to all.
|
-- | Step through larger report periods, up to all.
|
||||||
growReportPeriod :: Day -> UIState -> UIState
|
growReportPeriod :: Day -> UIState -> UIState
|
||||||
@ -222,47 +188,34 @@ previousReportPeriod enclosingspan = updateReportPeriod (periodPreviousIn enclos
|
|||||||
moveReportPeriodToDate :: Day -> UIState -> UIState
|
moveReportPeriodToDate :: Day -> UIState -> UIState
|
||||||
moveReportPeriodToDate d = updateReportPeriod (periodMoveTo d)
|
moveReportPeriodToDate d = updateReportPeriod (periodMoveTo d)
|
||||||
|
|
||||||
|
-- | Clear any report period limits.
|
||||||
|
resetReportPeriod :: UIState -> UIState
|
||||||
|
resetReportPeriod = setReportPeriod PeriodAll
|
||||||
|
|
||||||
-- | Get the report period.
|
-- | Get the report period.
|
||||||
reportPeriod :: UIState -> Period
|
reportPeriod :: UIState -> Period
|
||||||
reportPeriod = period_ . _rsReportOpts . reportspec_ . cliopts_ . aopts
|
reportPeriod = (^.period)
|
||||||
|
|
||||||
-- | Set the report period.
|
-- | Set the report period.
|
||||||
setReportPeriod :: Period -> UIState -> UIState
|
setReportPeriod :: Period -> UIState -> UIState
|
||||||
setReportPeriod p = updateReportPeriod (const p)
|
setReportPeriod p = updateReportPeriod (const p)
|
||||||
|
|
||||||
-- | Clear any report period limits.
|
|
||||||
resetReportPeriod :: UIState -> UIState
|
|
||||||
resetReportPeriod = setReportPeriod PeriodAll
|
|
||||||
|
|
||||||
-- | Update report period by a applying a function.
|
-- | Update report period by a applying a function.
|
||||||
updateReportPeriod :: (Period -> Period) -> UIState -> UIState
|
updateReportPeriod :: (Period -> Period) -> UIState -> UIState
|
||||||
updateReportPeriod updatePeriod ui@UIState{aopts=uopts@UIOpts{cliopts_=copts@CliOpts{reportspec_=rspec}}} =
|
updateReportPeriod updatePeriod = fromRight err . overEither period updatePeriod -- PARTIAL:
|
||||||
ui{aopts=uopts{cliopts_=copts{reportspec_=update rspec}}}
|
where err = error "updateReportPeriod: updating period should not result in an error"
|
||||||
where
|
|
||||||
update = either (error "updateReportPeriod: updating period should not result in an error") id -- PARTIAL:
|
|
||||||
. updateReportSpecWith (\ropts -> ropts{period_=updatePeriod $ period_ ropts})
|
|
||||||
|
|
||||||
-- | Apply a new filter query.
|
-- | Apply a new filter query.
|
||||||
setFilter :: String -> UIState -> UIState
|
setFilter :: String -> UIState -> UIState
|
||||||
setFilter s ui@UIState{aopts=uopts@UIOpts{cliopts_=copts@CliOpts{reportspec_=rspec}}} =
|
setFilter s = over reportSpec update
|
||||||
ui{aopts=uopts{cliopts_=copts{reportspec_=update rspec}}}
|
|
||||||
where
|
where
|
||||||
update = fromRight rspec . updateReportSpecWith (\ropts -> ropts{querystring_=querystring}) -- XXX silently ignores an error
|
update rspec = fromRight rspec $ setEither querystring (words'' prefixes $ T.pack s) rspec -- XXX silently ignores an error
|
||||||
querystring = words'' prefixes $ T.pack s
|
|
||||||
|
|
||||||
-- | Reset some filters & toggles.
|
-- | Reset some filters & toggles.
|
||||||
resetFilter :: UIState -> UIState
|
resetFilter :: UIState -> UIState
|
||||||
resetFilter ui@UIState{aopts=uopts@UIOpts{cliopts_=copts@CliOpts{reportspec_=rspec@ReportSpec{_rsReportOpts=ropts}}}} =
|
resetFilter = set querystringNoUpdate [] . set realNoUpdate False . set statusesNoUpdate []
|
||||||
ui{aopts=uopts{cliopts_=copts{reportspec_=rspec{
|
. set empty__ True -- set period PeriodAll
|
||||||
_rsQuery=Any
|
. set rsQuery Any . set rsQueryOpts []
|
||||||
,_rsQueryOpts=[]
|
|
||||||
,_rsReportOpts=ropts{
|
|
||||||
empty_=True
|
|
||||||
,statuses_=[]
|
|
||||||
,real_=False
|
|
||||||
,querystring_=[]
|
|
||||||
--,period_=PeriodAll
|
|
||||||
}}}}}
|
|
||||||
|
|
||||||
-- | Reset all options state to exactly what it was at startup
|
-- | Reset all options state to exactly what it was at startup
|
||||||
-- (preserving any command-line options/arguments).
|
-- (preserving any command-line options/arguments).
|
||||||
@ -297,15 +250,14 @@ setDepth :: Maybe Int -> UIState -> UIState
|
|||||||
setDepth mdepth = updateReportDepth (const mdepth)
|
setDepth mdepth = updateReportDepth (const mdepth)
|
||||||
|
|
||||||
getDepth :: UIState -> Maybe Int
|
getDepth :: UIState -> Maybe Int
|
||||||
getDepth = depth_ . _rsReportOpts . reportspec_ . cliopts_ . aopts
|
getDepth = (^.depth)
|
||||||
|
|
||||||
-- | Update report depth by a applying a function. If asked to set a depth less
|
-- | Update report depth by a applying a function. If asked to set a depth less
|
||||||
-- than zero, it will leave it unchanged.
|
-- than zero, it will leave it unchanged.
|
||||||
updateReportDepth :: (Maybe Int -> Maybe Int) -> UIState -> UIState
|
updateReportDepth :: (Maybe Int -> Maybe Int) -> UIState -> UIState
|
||||||
updateReportDepth updateDepth ui@UIState{aopts=uopts@UIOpts{cliopts_=copts@CliOpts{reportspec_=rspec}}} =
|
updateReportDepth updateDepth ui = over reportSpec update ui
|
||||||
ui{aopts=uopts{cliopts_=copts{reportspec_=update rspec}}}
|
|
||||||
where
|
where
|
||||||
update = either (error "updateReportDepth: updating depth should not result in an error") id -- PARTIAL:
|
update = fromRight (error "updateReportDepth: updating depth should not result in an error") -- PARTIAL:
|
||||||
. updateReportSpecWith (\ropts -> ropts{depth_=updateDepth (depth_ ropts) >>= clipDepth ropts})
|
. updateReportSpecWith (\ropts -> ropts{depth_=updateDepth (depth_ ropts) >>= clipDepth ropts})
|
||||||
clipDepth ropts d | d < 0 = depth_ ropts
|
clipDepth ropts d | d < 0 = depth_ ropts
|
||||||
| d >= maxDepth ui = Nothing
|
| d >= maxDepth ui = Nothing
|
||||||
@ -316,8 +268,7 @@ showMinibuffer :: UIState -> UIState
|
|||||||
showMinibuffer ui = setMode (Minibuffer e) ui
|
showMinibuffer ui = setMode (Minibuffer e) ui
|
||||||
where
|
where
|
||||||
e = applyEdit gotoEOL $ editor MinibufferEditor (Just 1) oldq
|
e = applyEdit gotoEOL $ editor MinibufferEditor (Just 1) oldq
|
||||||
oldq = T.unpack . T.unwords . map textQuoteIfNeeded
|
oldq = T.unpack . T.unwords . map textQuoteIfNeeded $ ui^.querystring
|
||||||
. querystring_ . _rsReportOpts . reportspec_ . cliopts_ $ aopts ui
|
|
||||||
|
|
||||||
-- | Close the minibuffer, discarding any edit in progress.
|
-- | Close the minibuffer, discarding any edit in progress.
|
||||||
closeMinibuffer :: UIState -> UIState
|
closeMinibuffer :: UIState -> UIState
|
||||||
@ -366,4 +317,3 @@ screenEnter :: Day -> Screen -> UIState -> UIState
|
|||||||
screenEnter d scr ui = (sInit scr) d True $
|
screenEnter d scr ui = (sInit scr) d True $
|
||||||
pushScreen scr
|
pushScreen scr
|
||||||
ui
|
ui
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user