File: alt_resize.lua

package info (click to toggle)
ion3-scripts 20050418-3
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 300 kB
  • ctags: 153
  • sloc: makefile: 18
file content (62 lines) | stat: -rw-r--r-- 1,817 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
--
-- 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.
--

function ionws_alt_resize(f, dir)
    local ws = f:manager()

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

ionframe_moveres_bindings{
    kpress("Left",  function(f) ionws_alt_resize(f, "left" ) end),
    kpress("Right", function(f) ionws_alt_resize(f, "right") end),
    kpress("Up",    function(f) ionws_alt_resize(f, "up"   ) end),
    kpress("Down",  function(f) ionws_alt_resize(f, "down" ) end),
    kpress("F",     function(f) ionws_alt_resize(f, "left" ) end),
    kpress("B",     function(f) ionws_alt_resize(f, "right") end),
    kpress("P",     function(f) ionws_alt_resize(f, "up"   ) end),
    kpress("N",     function(f) ionws_alt_resize(f, "down" ) end),
}