Module: VER::Methods::Layout

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

Class Method Summary collapse

Class Method Details

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



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

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

.close(text) ⇒ Object



30
31
32
# File 'lib/ver/methods/layout.rb', line 30

def close(text)
  text.buffer.close
end

.create(text) ⇒ Object



26
27
28
# File 'lib/ver/methods/layout.rb', line 26

def create(text)
  VER::Buffer.create
end

.cycle_next(text) ⇒ Object



113
114
115
# File 'lib/ver/methods/layout.rb', line 113

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

.cycle_prev(text) ⇒ Object



117
118
119
# File 'lib/ver/methods/layout.rb', line 117

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

.find_or_create(text, file, &block) ⇒ Object



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

def find_or_create(text, file, &block)
  VER::Buffer.find_or_create(file, &block)
end

.focus(text, index = 0) ⇒ Object



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

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

.focus_next(text) ⇒ Object



34
35
36
# File 'lib/ver/methods/layout.rb', line 34

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

.focus_prev(text) ⇒ Object



38
39
40
# File 'lib/ver/methods/layout.rb', line 38

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

.master_dec(text) ⇒ Object



87
88
89
90
91
# File 'lib/ver/methods/layout.rb', line 87

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

.master_equal(text) ⇒ Object

Center the split between masters and slaves



108
109
110
111
# File 'lib/ver/methods/layout.rb', line 108

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

.master_grow(text) ⇒ Object

Grow the master pane by 10%



101
102
103
104
105
# File 'lib/ver/methods/layout.rb', line 101

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

.master_inc(text) ⇒ Object



82
83
84
85
# File 'lib/ver/methods/layout.rb', line 82

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

.master_shrink(text) ⇒ Object

Shrink the master pane by 10%



94
95
96
97
98
# File 'lib/ver/methods/layout.rb', line 94

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

.one(text) ⇒ Object



58
59
60
61
# File 'lib/ver/methods/layout.rb', line 58

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

.peer(text) ⇒ Object



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

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

.push_bottom(text) ⇒ Object



54
55
56
# File 'lib/ver/methods/layout.rb', line 54

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

.push_down(text) ⇒ Object



46
47
48
# File 'lib/ver/methods/layout.rb', line 46

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

.push_top(text) ⇒ Object



50
51
52
# File 'lib/ver/methods/layout.rb', line 50

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

.push_up(text) ⇒ Object



42
43
44
# File 'lib/ver/methods/layout.rb', line 42

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

.slave_dec(text) ⇒ Object



76
77
78
79
80
# File 'lib/ver/methods/layout.rb', line 76

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

.slave_inc(text) ⇒ Object



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

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

.two(text) ⇒ Object



63
64
65
66
# File 'lib/ver/methods/layout.rb', line 63

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