mirror of
https://github.com/gosticks/PaperWM.git
synced 2026-12-04 04:11:38 +00:00
examples/keybindings: tile into left/right column
Takes the selected window and tile it into the left/right neighbour column.
This commit is contained in:
@@ -205,3 +205,33 @@ function adjustWidth(incBinding="<Super>plus", decBinding="<Super>minus", increm
|
||||
Keybindings.bindkey(incBinding, "inc-width", adjuster(increment));
|
||||
Keybindings.bindkey(decBinding, "dec-width", adjuster(-increment));
|
||||
}
|
||||
|
||||
function tileInto(leftBinding="<Super>less", rightBinding="<Super><Shift>less") {
|
||||
// less: '<'
|
||||
let Tiling = Extension.imports.tiling;
|
||||
|
||||
const tileIntoDirection = (dir=-1) => (metaWindow) => {
|
||||
let space = Tiling.spaces.spaceOfWindow(metaWindow);
|
||||
let jFrom = space.indexOf(metaWindow);
|
||||
let jTo = jFrom + dir;
|
||||
if (jTo < 0 || jTo >= space.length)
|
||||
return;
|
||||
|
||||
space[jFrom].splice(space.rowOf(metaWindow), 1);
|
||||
space[jTo].push(metaWindow);
|
||||
|
||||
if (space[jFrom].length === 0) {
|
||||
space.splice(jFrom, 1);
|
||||
}
|
||||
space.layout(true, {
|
||||
customAllocators: { [space.indexOf(metaWindow)]: Tiling.allocateEqualHeight }
|
||||
});
|
||||
space.emit("full-layout");
|
||||
}
|
||||
|
||||
let options = { activeInNavigator: true };
|
||||
if (leftBinding)
|
||||
Keybindings.bindkey(leftBinding, "tile-into-left-column", tileIntoDirection(-1), options);
|
||||
if (rightBinding)
|
||||
Keybindings.bindkey(rightBinding, "tile-into-right-column", tileIntoDirection(1), options);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user