Class: VER::Executor

Inherits:
Object
  • Object
show all
Defined in:
lib/ver/executor.rb,
lib/ver/executor/grep.rb,
lib/ver/executor/path.rb,
lib/ver/executor/entry.rb,
lib/ver/executor/label.rb,
lib/ver/executor/theme.rb,
lib/ver/executor/buffer.rb,
lib/ver/executor/locate.rb,
lib/ver/executor/method.rb,
lib/ver/executor/syntax.rb,
lib/ver/executor/encoding.rb,
lib/ver/executor/fuzzy_file_finder.rb

Defined Under Namespace

Classes: Entry, ExBuffer, ExEncoding, ExFuzzyFileFinder, ExGrep, ExGrepBuffers, ExLabel, ExLocate, ExMethod, ExPath, ExSyntax, ExTheme, ExWrite, Frame

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(caller, options = {}) ⇒ Executor

Returns a new instance of Executor.



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/ver/executor.rb', line 19

def initialize(caller, options = {})
  @caller = caller
  @tab_count = 0

  setup_widgets
  setup_layout

  @label.setup

  if action = options.delete(:action)
    @label.action(action.to_s)
  else
    @label.focus
  end
end

Instance Attribute Details

#callerObject (readonly)

Returns the value of attribute caller.



16
17
18
# File 'lib/ver/executor.rb', line 16

def caller
  @caller
end

#entryObject (readonly)

Returns the value of attribute entry.



16
17
18
# File 'lib/ver/executor.rb', line 16

def entry
  @entry
end

#frameObject (readonly)

Returns the value of attribute frame.



16
17
18
# File 'lib/ver/executor.rb', line 16

def frame
  @frame
end

#labelObject (readonly)

Returns the value of attribute label.



16
17
18
# File 'lib/ver/executor.rb', line 16

def label
  @label
end

#treeObject (readonly)

Returns the value of attribute tree.



16
17
18
# File 'lib/ver/executor.rb', line 16

def tree
  @tree
end

#update_on_changeObject

Returns the value of attribute update_on_change.



17
18
19
# File 'lib/ver/executor.rb', line 17

def update_on_change
  @update_on_change
end

#ybarObject (readonly)

Returns the value of attribute ybar.



16
17
18
# File 'lib/ver/executor.rb', line 16

def ybar
  @ybar
end

Instance Method Details

#destroy(caller_focus = true) ⇒ Object



75
76
77
78
79
80
81
# File 'lib/ver/executor.rb', line 75

def destroy(caller_focus = true)
  [@entry, @label, @tree, @ybar, @top, @bottom].compact.each(&:destroy)

  # caller.layout.close_buffer(self)
  @frame.destroy
  @caller.focus if caller_focus
end

#setup_layoutObject



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/ver/executor.rb', line 49

def setup_layout
  @frame.place anchor: :n, relx: 0.5, relwidth: 0.95, relheight: 0.95
  # VER.defer{ caller.layout.add_buffer(@frame) }

  @top.grid_configure(row: 0, column: 0, sticky: :nswe)
  @tree.grid_configure(row: 0, column: 0, sticky: :nswe)
  @ybar.grid_configure(row: 0, column: 1, sticky: :ns)
  @top.grid_rowconfigure(@tree, weight: 1)
  @top.grid_columnconfigure(@tree, weight: 1)

  @frame.grid_rowconfigure(@top, weight: 1)
  @frame.grid_columnconfigure(@top, weight: 1)

  @bottom.grid_configure(row: 1, column: 0, sticky: :we)
  @label.grid_configure(row: 0, column: 0, sticky: :w)
end

#setup_widgetsObject



35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/ver/executor.rb', line 35

def setup_widgets
  layout = caller.layout

  @frame  = Frame.new(layout)
  @top    = Frame.new(@frame)
  @bottom = Frame.new(@frame)

  @tree  = Treeview.new(@top)
  @ybar  = Tk::Tile::YScrollbar.new(@top)
  @tree.yscrollbar(@ybar)

  @label = ExLabel.new(@bottom, callback: self)
end

#use_entry(klass) ⇒ Object



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

def use_entry(klass)
  @entry = klass.new(@bottom, callback: self, mode: :executor_entry)
  @entry.grid_configure(row: 0, column: 1, sticky: :we)
  @bottom.grid_columnconfigure(@entry, weight: 1)

  @entry.setup
  @entry
end