ui: use brick 0.12, bump version to 1.0.3
This commit is contained in:
parent
56a4d84b59
commit
c6e2784eeb
@ -2,6 +2,11 @@ User-visible changes in hledger-ui.
|
|||||||
See also the hledger and project change logs.
|
See also the hledger and project change logs.
|
||||||
|
|
||||||
|
|
||||||
|
# 1.0.3 (2016/10/31)
|
||||||
|
|
||||||
|
- use brick 0.12
|
||||||
|
|
||||||
|
|
||||||
# 1.0.2 (2016/10/27)
|
# 1.0.2 (2016/10/27)
|
||||||
|
|
||||||
- use latest brick 0.11
|
- use latest brick 0.11
|
||||||
|
|||||||
@ -247,7 +247,7 @@ asDrawItem (acctwidth, balwidth) selected AccountsScreenItem{..} =
|
|||||||
sel | selected = (<> "selected")
|
sel | selected = (<> "selected")
|
||||||
| otherwise = id
|
| otherwise = id
|
||||||
|
|
||||||
asHandle :: UIState -> Event -> EventM Name (Next UIState)
|
asHandle :: UIState -> BrickEvent Name Event -> EventM Name (Next UIState)
|
||||||
asHandle ui0@UIState{
|
asHandle ui0@UIState{
|
||||||
aScreen=scr@AccountsScreen{..}
|
aScreen=scr@AccountsScreen{..}
|
||||||
,aopts=UIOpts{cliopts_=copts}
|
,aopts=UIOpts{cliopts_=copts}
|
||||||
@ -269,55 +269,58 @@ asHandle ui0@UIState{
|
|||||||
case mode of
|
case mode of
|
||||||
Minibuffer ed ->
|
Minibuffer ed ->
|
||||||
case ev of
|
case ev of
|
||||||
EvKey KEsc [] -> continue $ closeMinibuffer ui
|
VtyEvent (EvKey KEsc []) -> continue $ closeMinibuffer ui
|
||||||
EvKey KEnter [] -> continue $ regenerateScreens j d $ setFilter s $ closeMinibuffer ui
|
VtyEvent (EvKey KEnter []) -> continue $ regenerateScreens j d $ setFilter s $ closeMinibuffer ui
|
||||||
where s = chomp $ unlines $ map strip $ getEditContents ed
|
where s = chomp $ unlines $ map strip $ getEditContents ed
|
||||||
ev -> do ed' <- handleEditorEvent ev ed
|
VtyEvent ev -> do ed' <- handleEditorEvent ev ed
|
||||||
continue $ ui{aMode=Minibuffer ed'}
|
continue $ ui{aMode=Minibuffer ed'}
|
||||||
|
AppEvent _ -> continue ui
|
||||||
|
MouseDown _ _ _ _ -> continue ui
|
||||||
|
MouseUp _ _ _ -> continue ui
|
||||||
|
|
||||||
Help ->
|
Help ->
|
||||||
case ev of
|
case ev of
|
||||||
EvKey (KChar 'q') [] -> halt ui
|
VtyEvent (EvKey (KChar 'q') []) -> halt ui
|
||||||
_ -> helpHandle ui ev
|
_ -> helpHandle ui ev
|
||||||
|
|
||||||
Normal ->
|
Normal ->
|
||||||
case ev of
|
case ev of
|
||||||
EvKey (KChar 'q') [] -> halt ui
|
VtyEvent (EvKey (KChar 'q') []) -> halt ui
|
||||||
-- EvKey (KChar 'l') [MCtrl] -> do
|
-- EvKey (KChar 'l') [MCtrl] -> do
|
||||||
EvKey KEsc [] -> continue $ resetScreens d ui
|
VtyEvent (EvKey KEsc []) -> continue $ resetScreens d ui
|
||||||
EvKey (KChar c) [] | c `elem` ['?'] -> continue $ setMode Help ui
|
VtyEvent (EvKey (KChar c) []) | c `elem` ['?'] -> continue $ setMode Help ui
|
||||||
EvKey (KChar 'g') [] -> liftIO (uiReloadJournalIfChanged copts d j ui) >>= continue
|
VtyEvent (EvKey (KChar 'g') []) -> liftIO (uiReloadJournalIfChanged copts d j ui) >>= continue
|
||||||
EvKey (KChar 'I') [] -> continue $ uiCheckBalanceAssertions d (toggleIgnoreBalanceAssertions ui)
|
VtyEvent (EvKey (KChar 'I') []) -> continue $ uiCheckBalanceAssertions d (toggleIgnoreBalanceAssertions ui)
|
||||||
EvKey (KChar 'a') [] -> suspendAndResume $ clearScreen >> setCursorPosition 0 0 >> add copts j >> uiReloadJournalIfChanged copts d j ui
|
VtyEvent (EvKey (KChar 'a') []) -> suspendAndResume $ clearScreen >> setCursorPosition 0 0 >> add copts j >> uiReloadJournalIfChanged copts d j ui
|
||||||
EvKey (KChar 'E') [] -> suspendAndResume $ void (runEditor endPos (journalFilePath j)) >> uiReloadJournalIfChanged copts d j ui
|
VtyEvent (EvKey (KChar 'E') []) -> suspendAndResume $ void (runEditor endPos (journalFilePath j)) >> uiReloadJournalIfChanged copts d j ui
|
||||||
EvKey (KChar '0') [] -> continue $ regenerateScreens j d $ setDepth (Just 0) ui
|
VtyEvent (EvKey (KChar '0') []) -> continue $ regenerateScreens j d $ setDepth (Just 0) ui
|
||||||
EvKey (KChar '1') [] -> continue $ regenerateScreens j d $ setDepth (Just 1) ui
|
VtyEvent (EvKey (KChar '1') []) -> continue $ regenerateScreens j d $ setDepth (Just 1) ui
|
||||||
EvKey (KChar '2') [] -> continue $ regenerateScreens j d $ setDepth (Just 2) ui
|
VtyEvent (EvKey (KChar '2') []) -> continue $ regenerateScreens j d $ setDepth (Just 2) ui
|
||||||
EvKey (KChar '3') [] -> continue $ regenerateScreens j d $ setDepth (Just 3) ui
|
VtyEvent (EvKey (KChar '3') []) -> continue $ regenerateScreens j d $ setDepth (Just 3) ui
|
||||||
EvKey (KChar '4') [] -> continue $ regenerateScreens j d $ setDepth (Just 4) ui
|
VtyEvent (EvKey (KChar '4') []) -> continue $ regenerateScreens j d $ setDepth (Just 4) ui
|
||||||
EvKey (KChar '5') [] -> continue $ regenerateScreens j d $ setDepth (Just 5) ui
|
VtyEvent (EvKey (KChar '5') []) -> continue $ regenerateScreens j d $ setDepth (Just 5) ui
|
||||||
EvKey (KChar '6') [] -> continue $ regenerateScreens j d $ setDepth (Just 6) ui
|
VtyEvent (EvKey (KChar '6') []) -> continue $ regenerateScreens j d $ setDepth (Just 6) ui
|
||||||
EvKey (KChar '7') [] -> continue $ regenerateScreens j d $ setDepth (Just 7) ui
|
VtyEvent (EvKey (KChar '7') []) -> continue $ regenerateScreens j d $ setDepth (Just 7) ui
|
||||||
EvKey (KChar '8') [] -> continue $ regenerateScreens j d $ setDepth (Just 8) ui
|
VtyEvent (EvKey (KChar '8') []) -> continue $ regenerateScreens j d $ setDepth (Just 8) ui
|
||||||
EvKey (KChar '9') [] -> continue $ regenerateScreens j d $ setDepth (Just 9) ui
|
VtyEvent (EvKey (KChar '9') []) -> continue $ regenerateScreens j d $ setDepth (Just 9) ui
|
||||||
EvKey (KChar '-') [] -> continue $ regenerateScreens j d $ decDepth ui
|
VtyEvent (EvKey (KChar '-') []) -> continue $ regenerateScreens j d $ decDepth ui
|
||||||
EvKey (KChar '_') [] -> continue $ regenerateScreens j d $ decDepth ui
|
VtyEvent (EvKey (KChar '_') []) -> continue $ regenerateScreens j d $ decDepth ui
|
||||||
EvKey (KChar c) [] | c `elem` ['+','='] -> continue $ regenerateScreens j d $ incDepth ui
|
VtyEvent (EvKey (KChar c) []) | c `elem` ['+','='] -> continue $ regenerateScreens j d $ incDepth ui
|
||||||
EvKey (KChar 't') [] -> continue $ regenerateScreens j d $ setReportPeriod (DayPeriod d) ui
|
VtyEvent (EvKey (KChar 't') []) -> continue $ regenerateScreens j d $ setReportPeriod (DayPeriod d) ui
|
||||||
EvKey (KChar 'H') [] -> continue $ regenerateScreens j d $ toggleHistorical ui
|
VtyEvent (EvKey (KChar 'H') []) -> continue $ regenerateScreens j d $ toggleHistorical ui
|
||||||
EvKey (KChar 'F') [] -> continue $ regenerateScreens j d $ toggleFlat ui
|
VtyEvent (EvKey (KChar 'F') []) -> continue $ regenerateScreens j d $ toggleFlat ui
|
||||||
EvKey (KChar 'Z') [] -> scrollTop >> (continue $ regenerateScreens j d $ toggleEmpty ui)
|
VtyEvent (EvKey (KChar 'Z') []) -> scrollTop >> (continue $ regenerateScreens j d $ toggleEmpty ui)
|
||||||
EvKey (KChar 'C') [] -> scrollTop >> (continue $ regenerateScreens j d $ toggleCleared ui)
|
VtyEvent (EvKey (KChar 'C') []) -> scrollTop >> (continue $ regenerateScreens j d $ toggleCleared ui)
|
||||||
EvKey (KChar 'U') [] -> scrollTop >> (continue $ regenerateScreens j d $ toggleUncleared ui)
|
VtyEvent (EvKey (KChar 'U') []) -> scrollTop >> (continue $ regenerateScreens j d $ toggleUncleared ui)
|
||||||
EvKey (KChar 'R') [] -> scrollTop >> (continue $ regenerateScreens j d $ toggleReal ui)
|
VtyEvent (EvKey (KChar 'R') []) -> scrollTop >> (continue $ regenerateScreens j d $ toggleReal ui)
|
||||||
EvKey (KDown) [MShift] -> continue $ regenerateScreens j d $ shrinkReportPeriod d ui
|
VtyEvent (EvKey (KDown) [MShift]) -> continue $ regenerateScreens j d $ shrinkReportPeriod d ui
|
||||||
EvKey (KUp) [MShift] -> continue $ regenerateScreens j d $ growReportPeriod d ui
|
VtyEvent (EvKey (KUp) [MShift]) -> continue $ regenerateScreens j d $ growReportPeriod d ui
|
||||||
EvKey (KRight) [MShift] -> continue $ regenerateScreens j d $ nextReportPeriod journalspan ui
|
VtyEvent (EvKey (KRight) [MShift]) -> continue $ regenerateScreens j d $ nextReportPeriod journalspan ui
|
||||||
EvKey (KLeft) [MShift] -> continue $ regenerateScreens j d $ previousReportPeriod journalspan ui
|
VtyEvent (EvKey (KLeft) [MShift]) -> continue $ regenerateScreens j d $ previousReportPeriod journalspan ui
|
||||||
EvKey (KChar '/') [] -> continue $ regenerateScreens j d $ showMinibuffer ui
|
VtyEvent (EvKey (KChar '/') []) -> continue $ regenerateScreens j d $ showMinibuffer ui
|
||||||
EvKey k [] | k `elem` [KBS, KDel] -> (continue $ regenerateScreens j d $ resetFilter ui)
|
VtyEvent (EvKey k []) | k `elem` [KBS, KDel] -> (continue $ regenerateScreens j d $ resetFilter ui)
|
||||||
EvKey k [] | k `elem` [KLeft, KChar 'h'] -> continue $ popScreen ui
|
VtyEvent (EvKey k []) | k `elem` [KLeft, KChar 'h'] -> continue $ popScreen ui
|
||||||
EvKey k [] | k `elem` [KRight, KChar 'l'] -> scrollTopRegister >> continue (screenEnter d scr ui)
|
VtyEvent (EvKey k []) | k `elem` [KRight, KChar 'l'] -> scrollTopRegister >> continue (screenEnter d scr ui)
|
||||||
where
|
where
|
||||||
scr = rsSetAccount selacct isdepthclipped registerScreen
|
scr = rsSetAccount selacct isdepthclipped registerScreen
|
||||||
isdepthclipped = case getDepth ui of
|
isdepthclipped = case getDepth ui of
|
||||||
@ -325,7 +328,8 @@ asHandle ui0@UIState{
|
|||||||
Nothing -> False
|
Nothing -> False
|
||||||
|
|
||||||
-- fall through to the list's event handler (handles up/down)
|
-- fall through to the list's event handler (handles up/down)
|
||||||
ev -> do
|
VtyEvent ev ->
|
||||||
|
do
|
||||||
let ev' = case ev of
|
let ev' = case ev of
|
||||||
EvKey (KChar 'k') [] -> EvKey (KUp) []
|
EvKey (KChar 'k') [] -> EvKey (KUp) []
|
||||||
EvKey (KChar 'j') [] -> EvKey (KDown) []
|
EvKey (KChar 'j') [] -> EvKey (KDown) []
|
||||||
@ -335,6 +339,9 @@ asHandle ui0@UIState{
|
|||||||
& asSelectedAccount .~ selacct
|
& asSelectedAccount .~ selacct
|
||||||
}
|
}
|
||||||
-- continue =<< handleEventLensed ui someLens ev
|
-- continue =<< handleEventLensed ui someLens ev
|
||||||
|
AppEvent _ -> continue ui
|
||||||
|
MouseDown _ _ _ _ -> continue ui
|
||||||
|
MouseUp _ _ _ -> continue ui
|
||||||
|
|
||||||
where
|
where
|
||||||
-- Encourage a more stable scroll position when toggling list items.
|
-- Encourage a more stable scroll position when toggling list items.
|
||||||
|
|||||||
@ -68,7 +68,7 @@ esDraw UIState{ --aopts=UIOpts{cliopts_=copts@CliOpts{}}
|
|||||||
|
|
||||||
esDraw _ = error "draw function called with wrong screen type, should not happen"
|
esDraw _ = error "draw function called with wrong screen type, should not happen"
|
||||||
|
|
||||||
esHandle :: UIState -> Event -> EventM Name (Next UIState)
|
esHandle :: UIState -> BrickEvent Name Event -> EventM Name (Next UIState)
|
||||||
esHandle ui@UIState{
|
esHandle ui@UIState{
|
||||||
aScreen=ErrorScreen{..}
|
aScreen=ErrorScreen{..}
|
||||||
,aopts=UIOpts{cliopts_=copts}
|
,aopts=UIOpts{cliopts_=copts}
|
||||||
@ -78,26 +78,26 @@ esHandle ui@UIState{
|
|||||||
case mode of
|
case mode of
|
||||||
Help ->
|
Help ->
|
||||||
case ev of
|
case ev of
|
||||||
EvKey (KChar 'q') [] -> halt ui
|
VtyEvent (EvKey (KChar 'q') []) -> halt ui
|
||||||
_ -> helpHandle ui ev
|
_ -> helpHandle ui ev
|
||||||
|
|
||||||
_ -> do
|
_ -> do
|
||||||
d <- liftIO getCurrentDay
|
d <- liftIO getCurrentDay
|
||||||
case ev of
|
case ev of
|
||||||
EvKey (KChar 'q') [] -> halt ui
|
VtyEvent (EvKey (KChar 'q') []) -> halt ui
|
||||||
EvKey KEsc [] -> continue $ uiCheckBalanceAssertions d $ resetScreens d ui
|
VtyEvent (EvKey KEsc []) -> continue $ uiCheckBalanceAssertions d $ resetScreens d ui
|
||||||
EvKey (KChar c) [] | c `elem` ['h','?'] -> continue $ setMode Help ui
|
VtyEvent (EvKey (KChar c) []) | c `elem` ['h','?'] -> continue $ setMode Help ui
|
||||||
EvKey (KChar 'E') [] -> suspendAndResume $ void (runEditor pos f) >> uiReloadJournalIfChanged copts d j (popScreen ui)
|
VtyEvent (EvKey (KChar 'E') []) -> suspendAndResume $ void (runEditor pos f) >> uiReloadJournalIfChanged copts d j (popScreen ui)
|
||||||
where
|
where
|
||||||
(pos,f) = case parsewithString hledgerparseerrorpositionp esError of
|
(pos,f) = case parsewithString hledgerparseerrorpositionp esError of
|
||||||
Right (f,l,c) -> (Just (l, Just c),f)
|
Right (f,l,c) -> (Just (l, Just c),f)
|
||||||
Left _ -> (endPos, journalFilePath j)
|
Left _ -> (endPos, journalFilePath j)
|
||||||
EvKey (KChar 'g') [] -> liftIO (uiReloadJournalIfChanged copts d j (popScreen ui)) >>= continue . uiCheckBalanceAssertions d
|
VtyEvent (EvKey (KChar 'g') []) -> liftIO (uiReloadJournalIfChanged copts d j (popScreen ui)) >>= continue . uiCheckBalanceAssertions d
|
||||||
-- (ej, _) <- liftIO $ journalReloadIfChanged copts d j
|
-- (ej, _) <- liftIO $ journalReloadIfChanged copts d j
|
||||||
-- case ej of
|
-- case ej of
|
||||||
-- Left err -> continue ui{aScreen=s{esError=err}} -- show latest parse error
|
-- Left err -> continue ui{aScreen=s{esError=err}} -- show latest parse error
|
||||||
-- Right j' -> continue $ regenerateScreens j' d $ popScreen ui -- return to previous screen, and reload it
|
-- Right j' -> continue $ regenerateScreens j' d $ popScreen ui -- return to previous screen, and reload it
|
||||||
EvKey (KChar 'I') [] -> continue $ uiCheckBalanceAssertions d (popScreen $ toggleIgnoreBalanceAssertions ui)
|
VtyEvent (EvKey (KChar 'I') []) -> continue $ uiCheckBalanceAssertions d (popScreen $ toggleIgnoreBalanceAssertions ui)
|
||||||
_ -> continue ui
|
_ -> continue ui
|
||||||
|
|
||||||
esHandle _ _ = error "event handler called with wrong screen type, should not happen"
|
esHandle _ _ = error "event handler called with wrong screen type, should not happen"
|
||||||
|
|||||||
@ -137,8 +137,7 @@ runBrickUi uopts@UIOpts{cliopts_=copts@CliOpts{reportopts_=ropts}} j = do
|
|||||||
|
|
||||||
brickapp :: App (UIState) V.Event Name
|
brickapp :: App (UIState) V.Event Name
|
||||||
brickapp = App {
|
brickapp = App {
|
||||||
appLiftVtyEvent = id
|
appStartEvent = return
|
||||||
, appStartEvent = return
|
|
||||||
, appAttrMap = const theme
|
, appAttrMap = const theme
|
||||||
, appChooseCursor = showFirstCursor
|
, appChooseCursor = showFirstCursor
|
||||||
, appHandleEvent = \ui ev -> sHandle (aScreen ui) ui ev
|
, appHandleEvent = \ui ev -> sHandle (aScreen ui) ui ev
|
||||||
|
|||||||
@ -236,7 +236,7 @@ rsDrawItem (datewidth,descwidth,acctswidth,changewidth,balwidth) selected Regist
|
|||||||
sel | selected = (<> "selected")
|
sel | selected = (<> "selected")
|
||||||
| otherwise = id
|
| otherwise = id
|
||||||
|
|
||||||
rsHandle :: UIState -> Event -> EventM Name (Next UIState)
|
rsHandle :: UIState -> BrickEvent Name Event -> EventM Name (Next UIState)
|
||||||
rsHandle ui@UIState{
|
rsHandle ui@UIState{
|
||||||
aScreen=s@RegisterScreen{..}
|
aScreen=s@RegisterScreen{..}
|
||||||
,aopts=UIOpts{cliopts_=copts}
|
,aopts=UIOpts{cliopts_=copts}
|
||||||
@ -248,45 +248,48 @@ rsHandle ui@UIState{
|
|||||||
case mode of
|
case mode of
|
||||||
Minibuffer ed ->
|
Minibuffer ed ->
|
||||||
case ev of
|
case ev of
|
||||||
EvKey KEsc [] -> continue $ closeMinibuffer ui
|
VtyEvent (EvKey KEsc []) -> continue $ closeMinibuffer ui
|
||||||
EvKey KEnter [] -> continue $ regenerateScreens j d $ setFilter s $ closeMinibuffer ui
|
VtyEvent (EvKey KEnter []) -> continue $ regenerateScreens j d $ setFilter s $ closeMinibuffer ui
|
||||||
where s = chomp $ unlines $ map strip $ getEditContents ed
|
where s = chomp $ unlines $ map strip $ getEditContents ed
|
||||||
ev -> do ed' <- handleEditorEvent ev ed
|
VtyEvent ev -> do ed' <- handleEditorEvent ev ed
|
||||||
continue $ ui{aMode=Minibuffer ed'}
|
continue $ ui{aMode=Minibuffer ed'}
|
||||||
|
AppEvent _ -> continue ui
|
||||||
|
MouseDown _ _ _ _ -> continue ui
|
||||||
|
MouseUp _ _ _ -> continue ui
|
||||||
|
|
||||||
Help ->
|
Help ->
|
||||||
case ev of
|
case ev of
|
||||||
EvKey (KChar 'q') [] -> halt ui
|
VtyEvent (EvKey (KChar 'q') []) -> halt ui
|
||||||
_ -> helpHandle ui ev
|
_ -> helpHandle ui ev
|
||||||
|
|
||||||
Normal ->
|
Normal ->
|
||||||
case ev of
|
case ev of
|
||||||
EvKey (KChar 'q') [] -> halt ui
|
VtyEvent (EvKey (KChar 'q') []) -> halt ui
|
||||||
EvKey KEsc [] -> continue $ resetScreens d ui
|
VtyEvent (EvKey KEsc []) -> continue $ resetScreens d ui
|
||||||
EvKey (KChar c) [] | c `elem` ['?'] -> continue $ setMode Help ui
|
VtyEvent (EvKey (KChar c) []) | c `elem` ['?'] -> continue $ setMode Help ui
|
||||||
EvKey (KChar 'g') [] -> liftIO (uiReloadJournalIfChanged copts d j ui) >>= continue
|
VtyEvent (EvKey (KChar 'g') []) -> liftIO (uiReloadJournalIfChanged copts d j ui) >>= continue
|
||||||
EvKey (KChar 'I') [] -> continue $ uiCheckBalanceAssertions d (toggleIgnoreBalanceAssertions ui)
|
VtyEvent (EvKey (KChar 'I') []) -> continue $ uiCheckBalanceAssertions d (toggleIgnoreBalanceAssertions ui)
|
||||||
EvKey (KChar 'a') [] -> suspendAndResume $ clearScreen >> setCursorPosition 0 0 >> add copts j >> uiReloadJournalIfChanged copts d j ui
|
VtyEvent (EvKey (KChar 'a') []) -> suspendAndResume $ clearScreen >> setCursorPosition 0 0 >> add copts j >> uiReloadJournalIfChanged copts d j ui
|
||||||
EvKey (KChar 't') [] -> continue $ regenerateScreens j d $ setReportPeriod (DayPeriod d) ui
|
VtyEvent (EvKey (KChar 't') []) -> continue $ regenerateScreens j d $ setReportPeriod (DayPeriod d) ui
|
||||||
EvKey (KChar 'E') [] -> suspendAndResume $ void (runEditor pos f) >> uiReloadJournalIfChanged copts d j ui
|
VtyEvent (EvKey (KChar 'E') []) -> suspendAndResume $ void (runEditor pos f) >> uiReloadJournalIfChanged copts d j ui
|
||||||
where
|
where
|
||||||
(pos,f) = case listSelectedElement rsList of
|
(pos,f) = case listSelectedElement rsList of
|
||||||
Nothing -> (endPos, journalFilePath j)
|
Nothing -> (endPos, journalFilePath j)
|
||||||
Just (_, RegisterScreenItem{rsItemTransaction=Transaction{tsourcepos=GenericSourcePos f l c}}) -> (Just (l, Just c),f)
|
Just (_, RegisterScreenItem{rsItemTransaction=Transaction{tsourcepos=GenericSourcePos f l c}}) -> (Just (l, Just c),f)
|
||||||
EvKey (KChar 'H') [] -> continue $ regenerateScreens j d $ toggleHistorical ui
|
VtyEvent (EvKey (KChar 'H') []) -> continue $ regenerateScreens j d $ toggleHistorical ui
|
||||||
EvKey (KChar 'F') [] -> scrollTop >> (continue $ regenerateScreens j d $ toggleFlat ui)
|
VtyEvent (EvKey (KChar 'F') []) -> scrollTop >> (continue $ regenerateScreens j d $ toggleFlat ui)
|
||||||
EvKey (KChar 'Z') [] -> scrollTop >> (continue $ regenerateScreens j d $ toggleEmpty ui)
|
VtyEvent (EvKey (KChar 'Z') []) -> scrollTop >> (continue $ regenerateScreens j d $ toggleEmpty ui)
|
||||||
EvKey (KChar 'C') [] -> scrollTop >> (continue $ regenerateScreens j d $ toggleCleared ui)
|
VtyEvent (EvKey (KChar 'C') []) -> scrollTop >> (continue $ regenerateScreens j d $ toggleCleared ui)
|
||||||
EvKey (KChar 'U') [] -> scrollTop >> (continue $ regenerateScreens j d $ toggleUncleared ui)
|
VtyEvent (EvKey (KChar 'U') []) -> scrollTop >> (continue $ regenerateScreens j d $ toggleUncleared ui)
|
||||||
EvKey (KChar 'R') [] -> scrollTop >> (continue $ regenerateScreens j d $ toggleReal ui)
|
VtyEvent (EvKey (KChar 'R') []) -> scrollTop >> (continue $ regenerateScreens j d $ toggleReal ui)
|
||||||
EvKey (KChar '/') [] -> (continue $ regenerateScreens j d $ showMinibuffer ui)
|
VtyEvent (EvKey (KChar '/') []) -> (continue $ regenerateScreens j d $ showMinibuffer ui)
|
||||||
EvKey (KDown) [MShift] -> continue $ regenerateScreens j d $ shrinkReportPeriod d ui
|
VtyEvent (EvKey (KDown) [MShift]) -> continue $ regenerateScreens j d $ shrinkReportPeriod d ui
|
||||||
EvKey (KUp) [MShift] -> continue $ regenerateScreens j d $ growReportPeriod d ui
|
VtyEvent (EvKey (KUp) [MShift]) -> continue $ regenerateScreens j d $ growReportPeriod d ui
|
||||||
EvKey (KRight) [MShift] -> continue $ regenerateScreens j d $ nextReportPeriod journalspan ui
|
VtyEvent (EvKey (KRight) [MShift]) -> continue $ regenerateScreens j d $ nextReportPeriod journalspan ui
|
||||||
EvKey (KLeft) [MShift] -> continue $ regenerateScreens j d $ previousReportPeriod journalspan ui
|
VtyEvent (EvKey (KLeft) [MShift]) -> continue $ regenerateScreens j d $ previousReportPeriod journalspan ui
|
||||||
EvKey k [] | k `elem` [KBS, KDel] -> (continue $ regenerateScreens j d $ resetFilter ui)
|
VtyEvent (EvKey k []) | k `elem` [KBS, KDel] -> (continue $ regenerateScreens j d $ resetFilter ui)
|
||||||
EvKey k [] | k `elem` [KLeft, KChar 'h'] -> continue $ popScreen ui
|
VtyEvent (EvKey k []) | k `elem` [KLeft, KChar 'h'] -> continue $ popScreen ui
|
||||||
EvKey k [] | k `elem` [KRight, KChar 'l'] -> do
|
VtyEvent (EvKey k []) | k `elem` [KRight, KChar 'l'] -> do
|
||||||
case listSelectedElement rsList of
|
case listSelectedElement rsList of
|
||||||
Just (_, RegisterScreenItem{rsItemTransaction=t}) ->
|
Just (_, RegisterScreenItem{rsItemTransaction=t}) ->
|
||||||
let
|
let
|
||||||
@ -299,7 +302,7 @@ rsHandle ui@UIState{
|
|||||||
,tsAccount=rsAccount} ui
|
,tsAccount=rsAccount} ui
|
||||||
Nothing -> continue ui
|
Nothing -> continue ui
|
||||||
-- fall through to the list's event handler (handles [pg]up/down)
|
-- fall through to the list's event handler (handles [pg]up/down)
|
||||||
ev -> do
|
VtyEvent ev -> do
|
||||||
let ev' = case ev of
|
let ev' = case ev of
|
||||||
EvKey (KChar 'k') [] -> EvKey (KUp) []
|
EvKey (KChar 'k') [] -> EvKey (KUp) []
|
||||||
EvKey (KChar 'j') [] -> EvKey (KDown) []
|
EvKey (KChar 'j') [] -> EvKey (KDown) []
|
||||||
@ -307,6 +310,9 @@ rsHandle ui@UIState{
|
|||||||
newitems <- handleListEvent ev' rsList
|
newitems <- handleListEvent ev' rsList
|
||||||
continue ui{aScreen=s{rsList=newitems}}
|
continue ui{aScreen=s{rsList=newitems}}
|
||||||
-- continue =<< handleEventLensed ui someLens ev
|
-- continue =<< handleEventLensed ui someLens ev
|
||||||
|
AppEvent _ -> continue ui
|
||||||
|
MouseDown _ _ _ _ -> continue ui
|
||||||
|
MouseUp _ _ _ -> continue ui
|
||||||
where
|
where
|
||||||
-- Encourage a more stable scroll position when toggling list items (cf AccountsScreen.hs)
|
-- Encourage a more stable scroll position when toggling list items (cf AccountsScreen.hs)
|
||||||
scrollTop = vScrollToBeginning $ viewportScroll RegisterViewport
|
scrollTop = vScrollToBeginning $ viewportScroll RegisterViewport
|
||||||
|
|||||||
@ -102,7 +102,7 @@ tsDraw UIState{aopts=UIOpts{cliopts_=copts@CliOpts{reportopts_=ropts}}
|
|||||||
|
|
||||||
tsDraw _ = error "draw function called with wrong screen type, should not happen"
|
tsDraw _ = error "draw function called with wrong screen type, should not happen"
|
||||||
|
|
||||||
tsHandle :: UIState -> Event -> EventM Name (Next UIState)
|
tsHandle :: UIState -> BrickEvent Name Event -> EventM Name (Next UIState)
|
||||||
tsHandle ui@UIState{aScreen=s@TransactionScreen{tsTransaction=(i,t)
|
tsHandle ui@UIState{aScreen=s@TransactionScreen{tsTransaction=(i,t)
|
||||||
,tsTransactions=nts
|
,tsTransactions=nts
|
||||||
,tsAccount=acct}
|
,tsAccount=acct}
|
||||||
@ -114,7 +114,7 @@ tsHandle ui@UIState{aScreen=s@TransactionScreen{tsTransaction=(i,t)
|
|||||||
case mode of
|
case mode of
|
||||||
Help ->
|
Help ->
|
||||||
case ev of
|
case ev of
|
||||||
EvKey (KChar 'q') [] -> halt ui
|
VtyEvent (EvKey (KChar 'q') []) -> halt ui
|
||||||
_ -> helpHandle ui ev
|
_ -> helpHandle ui ev
|
||||||
|
|
||||||
_ -> do
|
_ -> do
|
||||||
@ -123,13 +123,13 @@ tsHandle ui@UIState{aScreen=s@TransactionScreen{tsTransaction=(i,t)
|
|||||||
(iprev,tprev) = maybe (i,t) ((i-1),) $ lookup (i-1) nts
|
(iprev,tprev) = maybe (i,t) ((i-1),) $ lookup (i-1) nts
|
||||||
(inext,tnext) = maybe (i,t) ((i+1),) $ lookup (i+1) nts
|
(inext,tnext) = maybe (i,t) ((i+1),) $ lookup (i+1) nts
|
||||||
case ev of
|
case ev of
|
||||||
EvKey (KChar 'q') [] -> halt ui
|
VtyEvent (EvKey (KChar 'q') []) -> halt ui
|
||||||
EvKey KEsc [] -> continue $ resetScreens d ui
|
VtyEvent (EvKey KEsc []) -> continue $ resetScreens d ui
|
||||||
EvKey (KChar c) [] | c `elem` ['?'] -> continue $ setMode Help ui
|
VtyEvent (EvKey (KChar c) []) | c `elem` ['?'] -> continue $ setMode Help ui
|
||||||
EvKey (KChar 'E') [] -> suspendAndResume $ void (runEditor pos f) >> uiReloadJournalIfChanged copts d j ui
|
VtyEvent (EvKey (KChar 'E') []) -> suspendAndResume $ void (runEditor pos f) >> uiReloadJournalIfChanged copts d j ui
|
||||||
where
|
where
|
||||||
(pos,f) = let GenericSourcePos f l c = tsourcepos t in (Just (l, Just c),f)
|
(pos,f) = let GenericSourcePos f l c = tsourcepos t in (Just (l, Just c),f)
|
||||||
EvKey (KChar 'g') [] -> do
|
VtyEvent (EvKey (KChar 'g') []) -> do
|
||||||
d <- liftIO getCurrentDay
|
d <- liftIO getCurrentDay
|
||||||
(ej, _) <- liftIO $ journalReloadIfChanged copts d j
|
(ej, _) <- liftIO $ journalReloadIfChanged copts d j
|
||||||
case ej of
|
case ej of
|
||||||
@ -157,14 +157,14 @@ tsHandle ui@UIState{aScreen=s@TransactionScreen{tsTransaction=(i,t)
|
|||||||
,tsTransactions=numberedts
|
,tsTransactions=numberedts
|
||||||
,tsAccount=acct}}
|
,tsAccount=acct}}
|
||||||
continue $ regenerateScreens j' d ui'
|
continue $ regenerateScreens j' d ui'
|
||||||
EvKey (KChar 'I') [] -> continue $ uiCheckBalanceAssertions d (toggleIgnoreBalanceAssertions ui)
|
VtyEvent (EvKey (KChar 'I') []) -> continue $ uiCheckBalanceAssertions d (toggleIgnoreBalanceAssertions ui)
|
||||||
-- if allowing toggling here, we should refresh the txn list from the parent register screen
|
-- if allowing toggling here, we should refresh the txn list from the parent register screen
|
||||||
-- EvKey (KChar 'E') [] -> continue $ regenerateScreens j d $ stToggleEmpty ui
|
-- EvKey (KChar 'E') [] -> continue $ regenerateScreens j d $ stToggleEmpty ui
|
||||||
-- EvKey (KChar 'C') [] -> continue $ regenerateScreens j d $ stToggleCleared ui
|
-- EvKey (KChar 'C') [] -> continue $ regenerateScreens j d $ stToggleCleared ui
|
||||||
-- EvKey (KChar 'R') [] -> continue $ regenerateScreens j d $ stToggleReal ui
|
-- EvKey (KChar 'R') [] -> continue $ regenerateScreens j d $ stToggleReal ui
|
||||||
EvKey k [] | k `elem` [KUp, KChar 'k'] -> continue $ regenerateScreens j d ui{aScreen=s{tsTransaction=(iprev,tprev)}}
|
VtyEvent (EvKey k []) | k `elem` [KUp, KChar 'k'] -> continue $ regenerateScreens j d ui{aScreen=s{tsTransaction=(iprev,tprev)}}
|
||||||
EvKey k [] | k `elem` [KDown, KChar 'j'] -> continue $ regenerateScreens j d ui{aScreen=s{tsTransaction=(inext,tnext)}}
|
VtyEvent (EvKey k []) | k `elem` [KDown, KChar 'j'] -> continue $ regenerateScreens j d ui{aScreen=s{tsTransaction=(inext,tnext)}}
|
||||||
EvKey k [] | k `elem` [KLeft, KChar 'h'] -> continue ui''
|
VtyEvent (EvKey k []) | k `elem` [KLeft, KChar 'h'] -> continue ui''
|
||||||
where
|
where
|
||||||
ui'@UIState{aScreen=scr} = popScreen ui
|
ui'@UIState{aScreen=scr} = popScreen ui
|
||||||
ui'' = ui'{aScreen=rsSelect (fromIntegral i) scr}
|
ui'' = ui'{aScreen=rsSelect (fromIntegral i) scr}
|
||||||
|
|||||||
@ -50,9 +50,6 @@ import Text.Show.Functions ()
|
|||||||
import Hledger
|
import Hledger
|
||||||
import Hledger.UI.UIOptions
|
import Hledger.UI.UIOptions
|
||||||
|
|
||||||
instance Show (List n e) where show _ = "<List>"
|
|
||||||
instance Show (Editor l n) where show _ = "<Editor>"
|
|
||||||
|
|
||||||
-- | hledger-ui's application state. This holds one or more stateful screens.
|
-- | hledger-ui's application state. This holds one or more stateful screens.
|
||||||
-- As you navigate through screens, the old ones are saved in a stack.
|
-- As you navigate through screens, the old ones are saved in a stack.
|
||||||
-- The app can be in one of several modes: normal screen operation,
|
-- The app can be in one of several modes: normal screen operation,
|
||||||
@ -95,7 +92,7 @@ data Screen =
|
|||||||
AccountsScreen {
|
AccountsScreen {
|
||||||
sInit :: Day -> Bool -> UIState -> UIState -- ^ function to initialise or update this screen's state
|
sInit :: Day -> Bool -> UIState -> UIState -- ^ function to initialise or update this screen's state
|
||||||
,sDraw :: UIState -> [Widget Name] -- ^ brick renderer for this screen
|
,sDraw :: UIState -> [Widget Name] -- ^ brick renderer for this screen
|
||||||
,sHandle :: UIState -> Event -> EventM Name (Next UIState) -- ^ brick event handler for this screen
|
,sHandle :: UIState -> BrickEvent Name Event -> EventM Name (Next UIState) -- ^ brick event handler for this screen
|
||||||
-- state fields.These ones have lenses:
|
-- state fields.These ones have lenses:
|
||||||
,_asList :: List Name AccountsScreenItem -- ^ list widget showing account names & balances
|
,_asList :: List Name AccountsScreenItem -- ^ list widget showing account names & balances
|
||||||
,_asSelectedAccount :: AccountName -- ^ a backup of the account name from the list widget's selected item (or "")
|
,_asSelectedAccount :: AccountName -- ^ a backup of the account name from the list widget's selected item (or "")
|
||||||
@ -103,7 +100,7 @@ data Screen =
|
|||||||
| RegisterScreen {
|
| RegisterScreen {
|
||||||
sInit :: Day -> Bool -> UIState -> UIState
|
sInit :: Day -> Bool -> UIState -> UIState
|
||||||
,sDraw :: UIState -> [Widget Name]
|
,sDraw :: UIState -> [Widget Name]
|
||||||
,sHandle :: UIState -> Event -> EventM Name (Next UIState)
|
,sHandle :: UIState -> BrickEvent Name Event -> EventM Name (Next UIState)
|
||||||
--
|
--
|
||||||
,rsList :: List Name RegisterScreenItem -- ^ list widget showing transactions affecting this account
|
,rsList :: List Name RegisterScreenItem -- ^ list widget showing transactions affecting this account
|
||||||
,rsAccount :: AccountName -- ^ the account this register is for
|
,rsAccount :: AccountName -- ^ the account this register is for
|
||||||
@ -114,7 +111,7 @@ data Screen =
|
|||||||
| TransactionScreen {
|
| TransactionScreen {
|
||||||
sInit :: Day -> Bool -> UIState -> UIState
|
sInit :: Day -> Bool -> UIState -> UIState
|
||||||
,sDraw :: UIState -> [Widget Name]
|
,sDraw :: UIState -> [Widget Name]
|
||||||
,sHandle :: UIState -> Event -> EventM Name (Next UIState)
|
,sHandle :: UIState -> BrickEvent Name Event -> EventM Name (Next UIState)
|
||||||
--
|
--
|
||||||
,tsTransaction :: NumberedTransaction -- ^ the transaction we are currently viewing, and its position in the list
|
,tsTransaction :: NumberedTransaction -- ^ the transaction we are currently viewing, and its position in the list
|
||||||
,tsTransactions :: [NumberedTransaction] -- ^ list of transactions we can step through
|
,tsTransactions :: [NumberedTransaction] -- ^ list of transactions we can step through
|
||||||
@ -123,7 +120,7 @@ data Screen =
|
|||||||
| ErrorScreen {
|
| ErrorScreen {
|
||||||
sInit :: Day -> Bool -> UIState -> UIState
|
sInit :: Day -> Bool -> UIState -> UIState
|
||||||
,sDraw :: UIState -> [Widget Name]
|
,sDraw :: UIState -> [Widget Name]
|
||||||
,sHandle :: UIState -> Event -> EventM Name (Next UIState)
|
,sHandle :: UIState -> BrickEvent Name Event -> EventM Name (Next UIState)
|
||||||
--
|
--
|
||||||
,esError :: String -- ^ error message to show
|
,esError :: String -- ^ error message to show
|
||||||
}
|
}
|
||||||
@ -136,6 +133,7 @@ data AccountsScreenItem = AccountsScreenItem {
|
|||||||
,asItemDisplayAccountName :: AccountName -- ^ full or short account name to display
|
,asItemDisplayAccountName :: AccountName -- ^ full or short account name to display
|
||||||
,asItemRenderedAmounts :: [String] -- ^ rendered amounts
|
,asItemRenderedAmounts :: [String] -- ^ rendered amounts
|
||||||
}
|
}
|
||||||
|
deriving (Show)
|
||||||
|
|
||||||
-- | An item in the register screen's list of transactions in the current account.
|
-- | An item in the register screen's list of transactions in the current account.
|
||||||
data RegisterScreenItem = RegisterScreenItem {
|
data RegisterScreenItem = RegisterScreenItem {
|
||||||
@ -146,6 +144,7 @@ data RegisterScreenItem = RegisterScreenItem {
|
|||||||
,rsItemBalanceAmount :: String -- ^ the balance or running total after this transaction
|
,rsItemBalanceAmount :: String -- ^ the balance or running total after this transaction
|
||||||
,rsItemTransaction :: Transaction -- ^ the full transaction
|
,rsItemTransaction :: Transaction -- ^ the full transaction
|
||||||
}
|
}
|
||||||
|
deriving (Show)
|
||||||
|
|
||||||
type NumberedTransaction = (Integer, Transaction)
|
type NumberedTransaction = (Integer, Transaction)
|
||||||
|
|
||||||
|
|||||||
@ -110,13 +110,13 @@ helpDialog =
|
|||||||
renderKey (key,desc) = withAttr (borderAttr <> "keys") (str key) <+> str " " <+> str desc
|
renderKey (key,desc) = withAttr (borderAttr <> "keys") (str key) <+> str " " <+> str desc
|
||||||
|
|
||||||
-- | Event handler used when help mode is active.
|
-- | Event handler used when help mode is active.
|
||||||
helpHandle :: UIState -> Event -> EventM Name (Next UIState)
|
helpHandle :: UIState -> BrickEvent Name Event -> EventM Name (Next UIState)
|
||||||
helpHandle ui ev =
|
helpHandle ui ev =
|
||||||
case ev of
|
case ev of
|
||||||
EvKey k [] | k `elem` [KEsc, KLeft, KChar 'h', KChar '?'] -> continue $ setMode Normal ui
|
VtyEvent (EvKey k []) | k `elem` [KEsc, KLeft, KChar 'h', KChar '?'] -> continue $ setMode Normal ui
|
||||||
EvKey (KChar 't') [] -> suspendAndResume $ runHelp >> return ui'
|
VtyEvent (EvKey (KChar 't') []) -> suspendAndResume $ runHelp >> return ui'
|
||||||
EvKey (KChar 'm') [] -> suspendAndResume $ runMan >> return ui'
|
VtyEvent (EvKey (KChar 'm') []) -> suspendAndResume $ runMan >> return ui'
|
||||||
EvKey (KChar 'i') [] -> suspendAndResume $ runInfo >> return ui'
|
VtyEvent (EvKey (KChar 'i') []) -> suspendAndResume $ runInfo >> return ui'
|
||||||
_ -> continue ui
|
_ -> continue ui
|
||||||
where
|
where
|
||||||
ui' = setMode Normal ui
|
ui' = setMode Normal ui
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
-- see: https://github.com/sol/hpack
|
-- see: https://github.com/sol/hpack
|
||||||
|
|
||||||
name: hledger-ui
|
name: hledger-ui
|
||||||
version: 1.0.2
|
version: 1.0.3
|
||||||
stability: beta
|
stability: beta
|
||||||
category: Finance, Console
|
category: Finance, Console
|
||||||
synopsis: Curses-style user interface for the hledger accounting tool
|
synopsis: Curses-style user interface for the hledger accounting tool
|
||||||
@ -55,7 +55,7 @@ executable hledger-ui
|
|||||||
hs-source-dirs:
|
hs-source-dirs:
|
||||||
.
|
.
|
||||||
ghc-options: -Wall -fno-warn-unused-do-bind -fno-warn-name-shadowing -fno-warn-missing-signatures -fno-warn-type-defaults -fno-warn-orphans
|
ghc-options: -Wall -fno-warn-unused-do-bind -fno-warn-name-shadowing -fno-warn-missing-signatures -fno-warn-type-defaults -fno-warn-orphans
|
||||||
cpp-options: -DVERSION="1.0.2"
|
cpp-options: -DVERSION="1.0.3"
|
||||||
build-depends:
|
build-depends:
|
||||||
hledger >= 1.0.1 && < 1.1
|
hledger >= 1.0.1 && < 1.1
|
||||||
, hledger-lib >= 1.0.1 && < 1.1
|
, hledger-lib >= 1.0.1 && < 1.1
|
||||||
@ -82,7 +82,7 @@ executable hledger-ui
|
|||||||
buildable: False
|
buildable: False
|
||||||
else
|
else
|
||||||
build-depends:
|
build-depends:
|
||||||
brick >= 0.11 && < 0.12
|
brick >= 0.12 && < 0.13
|
||||||
, vty >= 5.5 && < 5.12
|
, vty >= 5.5 && < 5.12
|
||||||
if flag(threaded)
|
if flag(threaded)
|
||||||
ghc-options: -threaded
|
ghc-options: -threaded
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
name : hledger-ui
|
name : hledger-ui
|
||||||
version : '1.0.2'
|
version : '1.0.3'
|
||||||
synopsis : Curses-style user interface for the hledger accounting tool
|
synopsis : Curses-style user interface for the hledger accounting tool
|
||||||
description : |
|
description : |
|
||||||
This is hledger's curses-style interface.
|
This is hledger's curses-style interface.
|
||||||
@ -35,7 +35,7 @@ flags:
|
|||||||
description: If building with time < 1.5, also depend on old-locale. Set automatically by cabal.
|
description: If building with time < 1.5, also depend on old-locale. Set automatically by cabal.
|
||||||
manual: false
|
manual: false
|
||||||
default: false
|
default: false
|
||||||
cpp-options: -DVERSION="1.0.2"
|
cpp-options: -DVERSION="1.0.3"
|
||||||
executables:
|
executables:
|
||||||
hledger-ui:
|
hledger-ui:
|
||||||
source-dirs: .
|
source-dirs: .
|
||||||
@ -85,7 +85,7 @@ executables:
|
|||||||
buildable: false
|
buildable: false
|
||||||
else:
|
else:
|
||||||
dependencies:
|
dependencies:
|
||||||
- brick >= 0.11 && < 0.12
|
- brick >= 0.12 && < 0.13
|
||||||
- vty >= 5.5 && < 5.12
|
- vty >= 5.5 && < 5.12
|
||||||
- condition: flag(threaded)
|
- condition: flag(threaded)
|
||||||
ghc-options: -threaded
|
ghc-options: -threaded
|
||||||
|
|||||||
@ -11,6 +11,6 @@ packages:
|
|||||||
- hledger-api
|
- hledger-api
|
||||||
|
|
||||||
extra-deps:
|
extra-deps:
|
||||||
- brick-0.11
|
- brick-0.12
|
||||||
- text-zipper-0.8.1
|
- text-zipper-0.8.1
|
||||||
- megaparsec-5.1.2
|
- megaparsec-5.1.2
|
||||||
|
|||||||
@ -12,7 +12,7 @@ packages:
|
|||||||
|
|
||||||
extra-deps:
|
extra-deps:
|
||||||
# for hledger-ui:
|
# for hledger-ui:
|
||||||
- brick-0.11
|
- brick-0.12
|
||||||
- text-zipper-0.8.1
|
- text-zipper-0.8.1
|
||||||
- vty-5.11.3
|
- vty-5.11.3
|
||||||
# for hledger-web:
|
# for hledger-web:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user