File: alt_resize.lua

package info (click to toggle)
notion 3%2B2012042300-1
  • links: PTS, VCS
  • area: non-free
  • in suites: wheezy
  • size: 4,724 kB
  • sloc: ansic: 45,614; makefile: 544; sh: 409; perl: 113
file content (65 lines) | stat: -rw-r--r-- 1,790 bytes parent folder | download
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
--
-- 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' )"),
})