Class: VER::Status
- Inherits:
-
Tk::Tile::Frame
- Object
- Tk::Tile::Frame
- VER::Status
- Defined in:
- lib/ver/status.rb,
lib/ver/status/mode.rb,
lib/ver/status/label.rb,
lib/ver/status/syntax.rb,
lib/ver/status/battery.rb,
lib/ver/status/percent.rb,
lib/ver/status/encoding.rb,
lib/ver/status/filename.rb,
lib/ver/status/position.rb,
lib/ver/status/nano_help.rb,
lib/ver/status/separator.rb,
lib/ver/status/nano_position.rb,
lib/ver/status/short_filename.rb,
lib/ver/status/buffer_position.rb,
lib/ver/status/diakonos_position.rb
Overview
The status bar
Defined Under Namespace
Modules: LabelToggle Classes: Battery, BufferPosition, DiakonosPosition, Encoding, Filename, Label, Mode, NanoHelp, NanoPosition, Percent, Position, Separator, ShortFilename, Syntax
Constant Summary collapse
- LINES =
{ vim: lambda{|status| [ ShortFilename.new(status, weight: 1), Position.new(status), Percent.new(status), Mode.new(status), Syntax.new(status), Encoding.new(status), ] }, emacs: lambda{|status| [ ShortFilename.new(status, weight: 1), Position.new(status), Percent.new(status), Mode.new(status), Syntax.new(status), Encoding.new(status), ] }, nano: lambda{|status| [ NanoPosition.new(status, row: 0, column: 0, weight: 1, anchor: :center), NanoHelp.new(status, row: 1, column: 0, sticky: :nwse, weight: 1), ] }, diakonos: lambda{|status| [ Separator.new(status, orient: :horizontal), Filename.new(status), Separator.new(status, orient: :horizontal), Syntax.new(status, format: "(%s)"), Separator.new(status, orient: :horizontal, weight: 1), BufferPosition.new(status, format: 'Buf %d of %d'), Separator.new(status, orient: :horizontal), DiakonosPosition.new(status, format: 'L %3d/%3d C%2d'), Separator.new(status, orient: :horizontal), ] } }
Instance Attribute Summary collapse
-
#buffer ⇒ Object
Returns the value of attribute buffer.
-
#notify ⇒ Object
Returns the value of attribute notify.
-
#widgets ⇒ Object
Returns the value of attribute widgets.
Instance Method Summary collapse
- #event(*names) ⇒ Object
- #hide ⇒ Object
-
#initialize(parent, buffer, options = {}) ⇒ Status
constructor
A new instance of Status.
- #register(widget, *events) ⇒ Object
- #show ⇒ Object
- #style=(config) ⇒ Object
Constructor Details
#initialize(parent, buffer, options = {}) ⇒ Status
Returns a new instance of Status.
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/ver/status.rb', line 82 def initialize(parent, buffer, = {}) super(parent, ) self.buffer = buffer self.notify = Hash.new{|hash, key| hash[key] = Set.new } constructor = VER..statusline || LINES.fetch(VER..keymap.to_sym) @widgets = constructor.call(self) @widgets.each.with_index do |, index| row = .row || 0 column = .column || index sticky = .sticky || :we weight = .weight || 0 .grid_configure(row: row, column: column, sticky: sticky) grid_columnconfigure(, weight: weight) end grid_rowconfigure(0, weight: 1) end |
Instance Attribute Details
#buffer ⇒ Object
Returns the value of attribute buffer.
80 81 82 |
# File 'lib/ver/status.rb', line 80 def buffer @buffer end |
#notify ⇒ Object
Returns the value of attribute notify.
80 81 82 |
# File 'lib/ver/status.rb', line 80 def notify @notify end |
#widgets ⇒ Object
Returns the value of attribute widgets.
80 81 82 |
# File 'lib/ver/status.rb', line 80 def @widgets end |
Instance Method Details
#event(*names) ⇒ Object
102 103 104 105 106 107 108 |
# File 'lib/ver/status.rb', line 102 def event(*names) names.each do |name| notify[name].each do || .update(name) end end end |
#hide ⇒ Object
124 125 126 127 128 129 |
# File 'lib/ver/status.rb', line 124 def hide return unless winfo_ismapped @last_grid_info = grid_info grid_forget true end |
#register(widget, *events) ⇒ Object
110 111 112 |
# File 'lib/ver/status.rb', line 110 def register(, *events) events.each{|event| notify[event] << } end |
#show ⇒ Object
118 119 120 121 122 |
# File 'lib/ver/status.rb', line 118 def show return if winfo_ismapped grid_configure(@last_grid_info) true end |
#style=(config) ⇒ Object
114 115 116 |
# File 'lib/ver/status.rb', line 114 def style=(config) Tk::After.idle{ @widgets.each{|| .style = config } } end |