Skip to content

Commit ebabd39

Browse files
add force quit command, doesn't work.
1 parent e859603 commit ebabd39

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/Potato/Flow/Vty/AppKbCmd.hs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ data AppKbCmd t = AppKbCmd {
1313
, _appKbCmd_open :: Event t ()
1414
, _appKbCmd_print :: Event t ()
1515
, _appKbCmd_quit :: Event t ()
16+
, _appKbCmd_forceQuit :: Event t ()
1617
, _appKbCmd_new :: Event t ()
1718
, _appKbCmd_capturedInput :: Event t ()
1819
}
@@ -30,13 +31,21 @@ holdAppKbCmd = do
3031
printEv = captureKeyWithCtrl 'p'
3132
quitEv = captureKeyWithCtrl 'q'
3233
newEv = captureKeyWithCtrl 'n'
33-
captureEv = leftmost [saveEv, openEv, quitEv, newEv]
34+
35+
-- TODO this doesn't seem to work, prob cuz vty isn't handling shift correctly on mac
36+
forceQuitEv = fforMaybe inp $ \i -> case i of
37+
V.EvKey (V.KChar 'q') [V.MCtrl, V.MShift] -> Just ()
38+
V.EvKey (V.KChar 'q') [V.MShift, V.MCtrl] -> Just ()
39+
_ -> Nothing
40+
41+
captureEv = leftmost [saveEv, openEv, quitEv, newEv, forceQuitEv]
3442

3543
return $ AppKbCmd {
3644
_appKbCmd_save = saveEv
3745
, _appKbCmd_open = openEv
3846
, _appKbCmd_print = printEv
3947
, _appKbCmd_quit = quitEv
48+
, _appKbCmd_forceQuit = forceQuitEv
4049
, _appKbCmd_new = newEv
4150
, _appKbCmd_capturedInput = captureEv
4251
}

src/Potato/Flow/Vty/Main.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,4 +399,4 @@ mainPFWidgetWithBypass MainPFWidgetConfig {..} bypassEvent = mdo
399399

400400

401401
-- handle escape event
402-
return $ leftmost [_saveBeforeExitOutput_quit, void $ ffilter not doesNeedSaveOnExitEv]
402+
return $ leftmost [_appKbCmd_forceQuit, _saveBeforeExitOutput_quit, void $ ffilter not doesNeedSaveOnExitEv]

0 commit comments

Comments
 (0)