Add message to window prompt to execute arbitrary actions with the window

This commit is contained in:
Zubin Duggal
2020-04-09 01:06:20 +05:30
parent 5521b432dd
commit 5880e01ad2

View File

@@ -72,13 +72,14 @@ import XMonad.Util.NamedWindows
-- "XMonad.Doc.Extending#Editing_key_bindings".
-- Describe actions that can applied on the selected window
data WindowPrompt = Goto | Bring | BringCopy | BringToMaster
data WindowPrompt = Goto | Bring | BringCopy | BringToMaster | WithWindow String (Window -> X())
instance XPrompt WindowPrompt where
showXPrompt Goto = "Go to window: "
showXPrompt Bring = "Bring window: "
showXPrompt BringToMaster
= "Bring window to master: "
showXPrompt BringCopy = "Bring a copy: "
showXPrompt (WithWindow xs _) = xs
commandToComplete _ c = c
nextCompletion _ = getNextCompletion
@@ -96,13 +97,15 @@ instance XPrompt WindowModePrompt where
modeAction (WindowModePrompt action winmap _) buf auto = do
let name = if null auto then buf else auto
a = case action of
Goto -> gotoAction winmap
Bring -> bringAction winmap
BringCopy -> bringCopyAction winmap
BringToMaster -> bringToMaster winmap
Goto -> gotoAction
Bring -> bringAction
BringCopy -> bringCopyAction
BringToMaster -> bringToMaster
WithWindow _ f -> withWindow f
a name
where
winAction a m = flip whenJust (windows . a) . flip M.lookup m
withWindow f = flip whenJust f . flip M.lookup winmap
winAction a = withWindow (windows . a)
gotoAction = winAction W.focusWindow
bringAction = winAction bringWindow
bringCopyAction = winAction bringCopyWindow