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
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), ] }, 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
-
#initialize(buffer, options = {}) ⇒ Status
constructor
A new instance of Status.
- #register(widget, *events) ⇒ Object
- #style=(config) ⇒ Object
- #text ⇒ Object
Constructor Details
#initialize(buffer, options = {}) ⇒ Status
Returns a new instance of Status.
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/ver/status.rb', line 53 def initialize(buffer, = {}) super 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.
51 52 53 |
# File 'lib/ver/status.rb', line 51 def buffer @buffer end |
#notify ⇒ Object
Returns the value of attribute notify.
51 52 53 |
# File 'lib/ver/status.rb', line 51 def notify @notify end |
#widgets ⇒ Object
Returns the value of attribute widgets.
51 52 53 |
# File 'lib/ver/status.rb', line 51 def @widgets end |
Instance Method Details
#event(*names) ⇒ Object
73 74 75 76 77 78 79 |
# File 'lib/ver/status.rb', line 73 def event(*names) names.each do |name| notify[name].each do || .update(name) end end end |
#register(widget, *events) ⇒ Object
81 82 83 |
# File 'lib/ver/status.rb', line 81 def register(, *events) events.each{|event| notify[event] << } end |
#style=(config) ⇒ Object
89 90 91 |
# File 'lib/ver/status.rb', line 89 def style=(config) Tk::After.idle{ @widgets.each{|| .style = config } } end |
#text ⇒ Object
85 86 87 |
# File 'lib/ver/status.rb', line 85 def text buffer.text end |