mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-07-31 20:21:51 -07:00
Merge pull request #333 from wz1000/master
Allow WindowPrompt to execute arbitrary actions with the window
This commit is contained in:
@@ -77,6 +77,11 @@
|
|||||||
- Added `recentWS` function which allows the recency list to be filtered with
|
- Added `recentWS` function which allows the recency list to be filtered with
|
||||||
a user-provided predicate.
|
a user-provided predicate.
|
||||||
|
|
||||||
|
* `XMonad.Prompt.Window`
|
||||||
|
|
||||||
|
- Added a `WithWindow` constructor to `WindowPrompt` to allow executing
|
||||||
|
actions of type `Window -> X ()` on the chosen window.
|
||||||
|
|
||||||
## 0.16
|
## 0.16
|
||||||
|
|
||||||
### Breaking Changes
|
### Breaking Changes
|
||||||
|
@@ -72,13 +72,14 @@ import XMonad.Util.NamedWindows
|
|||||||
-- "XMonad.Doc.Extending#Editing_key_bindings".
|
-- "XMonad.Doc.Extending#Editing_key_bindings".
|
||||||
|
|
||||||
-- Describe actions that can applied on the selected window
|
-- 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
|
instance XPrompt WindowPrompt where
|
||||||
showXPrompt Goto = "Go to window: "
|
showXPrompt Goto = "Go to window: "
|
||||||
showXPrompt Bring = "Bring window: "
|
showXPrompt Bring = "Bring window: "
|
||||||
showXPrompt BringToMaster
|
showXPrompt BringToMaster
|
||||||
= "Bring window to master: "
|
= "Bring window to master: "
|
||||||
showXPrompt BringCopy = "Bring a copy: "
|
showXPrompt BringCopy = "Bring a copy: "
|
||||||
|
showXPrompt (WithWindow xs _) = xs
|
||||||
commandToComplete _ c = c
|
commandToComplete _ c = c
|
||||||
nextCompletion _ = getNextCompletion
|
nextCompletion _ = getNextCompletion
|
||||||
|
|
||||||
@@ -96,13 +97,15 @@ instance XPrompt WindowModePrompt where
|
|||||||
modeAction (WindowModePrompt action winmap _) buf auto = do
|
modeAction (WindowModePrompt action winmap _) buf auto = do
|
||||||
let name = if null auto then buf else auto
|
let name = if null auto then buf else auto
|
||||||
a = case action of
|
a = case action of
|
||||||
Goto -> gotoAction winmap
|
Goto -> gotoAction
|
||||||
Bring -> bringAction winmap
|
Bring -> bringAction
|
||||||
BringCopy -> bringCopyAction winmap
|
BringCopy -> bringCopyAction
|
||||||
BringToMaster -> bringToMaster winmap
|
BringToMaster -> bringToMaster
|
||||||
|
WithWindow _ f -> withWindow f
|
||||||
a name
|
a name
|
||||||
where
|
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
|
gotoAction = winAction W.focusWindow
|
||||||
bringAction = winAction bringWindow
|
bringAction = winAction bringWindow
|
||||||
bringCopyAction = winAction bringCopyWindow
|
bringCopyAction = winAction bringCopyWindow
|
||||||
|
Reference in New Issue
Block a user