diff --git a/examples/keybindings.js b/examples/keybindings.js index 46dd5f0..0f2b12b 100644 --- a/examples/keybindings.js +++ b/examples/keybindings.js @@ -205,3 +205,33 @@ function adjustWidth(incBinding="plus", decBinding="minus", increm Keybindings.bindkey(incBinding, "inc-width", adjuster(increment)); Keybindings.bindkey(decBinding, "dec-width", adjuster(-increment)); } + +function tileInto(leftBinding="less", rightBinding="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); +}