diff options
author | Eric Mertens <emertens@galois.com> | 2007-10-02 23:08:14 +0200 |
---|---|---|
committer | Eric Mertens <emertens@galois.com> | 2007-10-02 23:08:14 +0200 |
commit | 73472e541d5268d46341264bbd0ef05fd1951cac (patch) | |
tree | ac1af1e2494a8df3da6c0a9da7cb5c953c4f8cea | |
parent | 8492b4a71241d0bce32286121eba10dd42bd4b21 (diff) | |
download | XMonadContrib-73472e541d5268d46341264bbd0ef05fd1951cac.tar.gz XMonadContrib-73472e541d5268d46341264bbd0ef05fd1951cac.tar.xz XMonadContrib-73472e541d5268d46341264bbd0ef05fd1951cac.zip |
Add ^K and ^U support to XPrompt
darcs-hash:20071002210814-b49f3-044f20328be2d3a51ddb2ef0d0e7d8b755af749e.gz
-rw-r--r-- | XPrompt.hs | 23 |
1 files changed, 20 insertions, 3 deletions
@@ -265,9 +265,15 @@ data Direction = Prev | Next deriving (Eq,Show,Read) keyPressHandle :: KeyMask -> KeyStroke -> XP () -- commands: ctrl + ... todo -keyPressHandle mask _ - | mask == controlMask = eventLoop handle -- TODO -keyPressHandle _ (ks,_) +keyPressHandle mask (ks,_) + | mask == controlMask = + case () of +-- ^U + _ | ks == xK_u -> killBefore >> go +-- ^K + | ks == xK_k -> killAfter >> go +-- Unhandled control sequence + | otherwise -> eventLoop handle -- Return: exit | ks == xK_Return = do historyPush return () @@ -295,6 +301,17 @@ keyPressHandle _ (_,s) -- 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 flushString :: XP () flushString = do |