mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-08-02 13:11:52 -07:00
Add ^K and ^U support to XPrompt
This commit is contained in:
23
XPrompt.hs
23
XPrompt.hs
@@ -265,9 +265,15 @@ data Direction = Prev | Next deriving (Eq,Show,Read)
|
|||||||
|
|
||||||
keyPressHandle :: KeyMask -> KeyStroke -> XP ()
|
keyPressHandle :: KeyMask -> KeyStroke -> XP ()
|
||||||
-- commands: ctrl + ... todo
|
-- commands: ctrl + ... todo
|
||||||
keyPressHandle mask _
|
keyPressHandle mask (ks,_)
|
||||||
| mask == controlMask = eventLoop handle -- TODO
|
| mask == controlMask =
|
||||||
keyPressHandle _ (ks,_)
|
case () of
|
||||||
|
-- ^U
|
||||||
|
_ | ks == xK_u -> killBefore >> go
|
||||||
|
-- ^K
|
||||||
|
| ks == xK_k -> killAfter >> go
|
||||||
|
-- Unhandled control sequence
|
||||||
|
| otherwise -> eventLoop handle
|
||||||
-- Return: exit
|
-- Return: exit
|
||||||
| ks == xK_Return = do historyPush
|
| ks == xK_Return = do historyPush
|
||||||
return ()
|
return ()
|
||||||
@@ -295,6 +301,17 @@ keyPressHandle _ (_,s)
|
|||||||
|
|
||||||
-- KeyPress and State
|
-- KeyPress and State
|
||||||
|
|
||||||
|
-- | Kill the portion of the command before the cursor
|
||||||
|
killBefore :: XP ()
|
||||||
|
killBefore =
|
||||||
|
modify $ \s -> s { command = drop (offset s) (command s)
|
||||||
|
, offset = 0 }
|
||||||
|
|
||||||
|
-- | Kill the portion of the command including and after the cursor
|
||||||
|
killAfter :: XP ()
|
||||||
|
killAfter =
|
||||||
|
modify $ \s -> s { command = take (offset s) (command s) }
|
||||||
|
|
||||||
-- | Flush the command string and reset the offest
|
-- | Flush the command string and reset the offest
|
||||||
flushString :: XP ()
|
flushString :: XP ()
|
||||||
flushString = do
|
flushString = do
|
||||||
|
Reference in New Issue
Block a user