File: alt_resize.lua

package info (click to toggle)
notion 4.0.3%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 4,656 kB
  • sloc: ansic: 47,365; sh: 2,093; makefile: 594; perl: 270
file content (68 lines) | stat: -rw-r--r-- 1,880 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
-- Authors: Per Olofsson <pelle@dsv.su.se>
-- License: Public domain
-- Last Changed: Unknown
--
-- Alternative resizing for ion-devel
--
-- By Per Olofsson <pelle@dsv.su.se> (public domain)
--
--
-- More intuitive resizing keys for Ion:
--
-- key      function
-- --------------------------
-- left     shrink leftwards
-- right    grow rightwards
-- up       shrink upwards
-- down     grow downwards
--
-- The meaning of the corresponding keys are reversed when the window
-- is at the right or bottom edge of the workspace.
--
-- Add the code to ionws.lua to make use of it. You probably shouldn't
-- delete any bindings for keys that are not redefined here.
--

alt_resize={}

function alt_resize.resize(m, f, dir)
    local ws = f:manager()

    if dir == "left" then
        if ws:right_of(f) then
            m:resize( 0,-1, 0, 0)
        else
            m:resize( 1, 0, 0, 0)
        end
    elseif dir == "right" then
        if ws:right_of(f) then
            m:resize( 0, 1, 0, 0)
        else
            m:resize(-1, 0, 0, 0)
        end
    elseif dir == "up" then
        if ws:below(f) then
            m:resize( 0, 0, 0,-1)
        else
            m:resize( 0, 0, 1, 0)
        end
    elseif dir == "down" then
        if ws:below(f) then
            m:resize( 0, 0, 0, 1)
        else
            m:resize( 0, 0,-1, 0)
        end
    end
end

defbindings("WMoveresMode", {
    kpress("Left",  "alt_resize.resize(_, _sub, 'left' )"),
    kpress("Right", "alt_resize.resize(_, _sub, 'right')"),
    kpress("Up",    "alt_resize.resize(_, _sub, 'up'   )"),
    kpress("Down",  "alt_resize.resize(_, _sub, 'down' )"),
    kpress("F",     "alt_resize.resize(_, _sub, 'left' )"),
    kpress("B",     "alt_resize.resize(_, _sub, 'right')"),
    kpress("P",     "alt_resize.resize(_, _sub, 'up'   )"),
    kpress("N",     "alt_resize.resize(_, _sub, 'down' )"),
})