Class: VER::NotebookLayout

Inherits:
Tk::Tile::LabelFrame
  • Object
show all
Defined in:
lib/ver/layout/notebook.rb

Defined Under Namespace

Classes: Notebook

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parent, options = {}) ⇒ NotebookLayout

Returns a new instance of NotebookLayout.



8
9
10
11
12
13
14
15
# File 'lib/ver/layout/notebook.rb', line 8

def initialize(parent, options = {})
  super
  pack(fill: :both, expand: true)
  @stack = []
  @options = {}
  @note = Notebook.new(self)
  @note.pack fill: :both, expand: true
end

Instance Attribute Details

#noteObject (readonly)

Returns the value of attribute note.



3
4
5
# File 'lib/ver/layout/notebook.rb', line 3

def note
  @note
end

#optionsObject (readonly)

Returns the value of attribute options.



3
4
5
# File 'lib/ver/layout/notebook.rb', line 3

def options
  @options
end

#stackObject (readonly)

Returns the value of attribute stack.



3
4
5
# File 'lib/ver/layout/notebook.rb', line 3

def stack
  @stack
end

#strategyObject (readonly)

Returns the value of attribute strategy.



3
4
5
# File 'lib/ver/layout/notebook.rb', line 3

def strategy
  @strategy
end

Instance Method Details

#close_buffer(buffer) ⇒ Object



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

def close_buffer(buffer)
  note.forget(buffer)
  buffer.destroy
end

#create_buffer(options = {}) {|buffer| ... } ⇒ Object

Yields:

  • (buffer)


17
18
19
20
21
22
23
# File 'lib/ver/layout/notebook.rb', line 17

def create_buffer(options = {})
  buffer = Buffer.new(self, options)
  yield buffer
  note.add(buffer, text: buffer.text.short_filename)
  note.select(buffer)
  buffer.focus
end

#focus_next(current) ⇒ Object



30
31
32
33
34
35
36
# File 'lib/ver/layout/notebook.rb', line 30

def focus_next(current)
  index = note.index(current)
  total = note.index('end') - 1

  note.select(index == total ? 0 : index + 1)
  Tk::Focus.focus(note.select)
end

#focus_prev(current) ⇒ Object



38
39
40
41
42
43
# File 'lib/ver/layout/notebook.rb', line 38

def focus_prev(current)
  index = note.index(current)

  note.select(index == 0 ? (note.index('end') - 1) : index - 1)
  Tk::Focus.focus(note.select)
end

#push_bottom(current) ⇒ Object



70
71
72
# File 'lib/ver/layout/notebook.rb', line 70

def push_bottom(current)
  note.insert('end', current)
end

#push_down(current) ⇒ Object



55
56
57
58
59
60
61
62
63
64
# File 'lib/ver/layout/notebook.rb', line 55

def push_down(current)
  index = note.index(current)
  total = note.index('end') - 1

  if index == total
    note.insert(0, index)
  else
    note.insert(index + 1, index)
  end
end

#push_top(current) ⇒ Object



66
67
68
# File 'lib/ver/layout/notebook.rb', line 66

def push_top(current)
  note.insert(0, current)
end

#push_up(current) ⇒ Object



45
46
47
48
49
50
51
52
53
# File 'lib/ver/layout/notebook.rb', line 45

def push_up(current)
  index = note.index(current)

  if index == 0
    note.insert('end', index)
  else
    note.insert(index - 1, index)
  end
end