Module: VER::Methods::Layout

Defined in:
lib/ver/methods/layout.rb

Class Method Summary collapse

Class Method Details

.change(buffer, action, *count) ⇒ Object



6
7
8
# File 'lib/ver/methods/layout.rb', line 6

def change(buffer, action, *count)
  action.call(buffer, *count)
end

.close(buffer) ⇒ Object

Close the given buffer



23
24
25
# File 'lib/ver/methods/layout.rb', line 23

def close(buffer)
  buffer.close
end

.cycle_next(buffer) ⇒ Object



111
112
113
# File 'lib/ver/methods/layout.rb', line 111

def cycle_next(buffer)
  buffer.layout.cycle_next(buffer)
end

.cycle_prev(buffer) ⇒ Object



115
116
117
# File 'lib/ver/methods/layout.rb', line 115

def cycle_prev(buffer)
  buffer.layout.cycle_prev(buffer)
end

.focus(buffer, index = 0) ⇒ Object



16
17
18
19
20
# File 'lib/ver/methods/layout.rb', line 16

def focus(buffer, index = 0)
  return unless found = VER.buffers.to_a[index - 1]
  buffer.layout.push_top(found)
  found.focus
end

.focus_next(buffer) ⇒ Object



32
33
34
# File 'lib/ver/methods/layout.rb', line 32

def focus_next(buffer)
  buffer.layout.focus_next(buffer)
end

.focus_prev(buffer) ⇒ Object



36
37
38
# File 'lib/ver/methods/layout.rb', line 36

def focus_prev(buffer)
  buffer.layout.focus_prev(buffer)
end

.hide(buffer) ⇒ Object

Hide the given buffer



28
29
30
# File 'lib/ver/methods/layout.rb', line 28

def hide(buffer)
  buffer.layout.hide_buffer(buffer)
end

.master_dec(buffer) ⇒ Object



85
86
87
88
89
# File 'lib/ver/methods/layout.rb', line 85

def master_dec(buffer)
  master = buffer.layout.options[:master]
  buffer.layout.options[:master] -= 1 if master > 0
  buffer.layout.apply
end

.master_equal(buffer) ⇒ Object

Center the split between masters and slaves



106
107
108
109
# File 'lib/ver/methods/layout.rb', line 106

def master_equal(buffer)
  buffer.layout.options[:center] = 0.5
  buffer.layout.apply
end

.master_grow(buffer) ⇒ Object

Grow the master pane by 10%



99
100
101
102
103
# File 'lib/ver/methods/layout.rb', line 99

def master_grow(buffer)
  center = buffer.layout.options[:center]
  buffer.layout.options[:center] += 0.1 if center < 0.9
  buffer.layout.apply
end

.master_inc(buffer) ⇒ Object



80
81
82
83
# File 'lib/ver/methods/layout.rb', line 80

def master_inc(buffer)
  buffer.layout.options[:master] += 1
  buffer.layout.apply
end

.master_shrink(buffer) ⇒ Object

Shrink the master pane by 10%



92
93
94
95
96
# File 'lib/ver/methods/layout.rb', line 92

def master_shrink(buffer)
  center = buffer.layout.options[:center]
  buffer.layout.options[:center] -= 0.1 if center > 0.1
  buffer.layout.apply
end

.one(buffer) ⇒ Object



56
57
58
59
# File 'lib/ver/methods/layout.rb', line 56

def one(buffer)
  buffer.layout.options.merge! master: 1, slaves: 0
  push_top(buffer)
end

.peer(buffer) ⇒ Object



10
11
12
13
14
# File 'lib/ver/methods/layout.rb', line 10

def peer(buffer)
  buffer.layout.create_buffer(peer: buffer) do |buffer|
    yield(buffer) if block_given?
  end
end

.push_bottom(buffer) ⇒ Object



52
53
54
# File 'lib/ver/methods/layout.rb', line 52

def push_bottom(buffer)
  buffer.layout.push_bottom(buffer)
end

.push_down(buffer) ⇒ Object



44
45
46
# File 'lib/ver/methods/layout.rb', line 44

def push_down(buffer)
  buffer.layout.push_down(buffer)
end

.push_top(buffer) ⇒ Object



48
49
50
# File 'lib/ver/methods/layout.rb', line 48

def push_top(buffer)
  buffer.layout.push_top(buffer)
end

.push_up(buffer) ⇒ Object



40
41
42
# File 'lib/ver/methods/layout.rb', line 40

def push_up(buffer)
  buffer.layout.push_up(buffer)
end

.slave_dec(buffer) ⇒ Object



74
75
76
77
78
# File 'lib/ver/methods/layout.rb', line 74

def slave_dec(buffer)
  slaves = buffer.layout.options[:slaves]
  buffer.layout.options[:slaves] -= 1 if slaves > 0
  buffer.layout.apply
end

.slave_inc(buffer) ⇒ Object



66
67
68
69
70
71
72
# File 'lib/ver/methods/layout.rb', line 66

def slave_inc(buffer)
  slaves = buffer.layout.options[:slaves]
  unless slaves >= buffer.layout.frames.size
    buffer.layout.options[:slaves] += 1
    buffer.layout.apply
  end
end

.two(buffer) ⇒ Object



61
62
63
64
# File 'lib/ver/methods/layout.rb', line 61

def two(buffer)
  buffer.layout.options.merge! master: 1, slaves: 1
  push_top(buffer)
end