Class: Weechat::Bar

Inherits:
Object
  • Object
show all
Extended by:
Properties
Includes:
Pointer
Defined in:
lib/weechat/bar.rb

Defined Under Namespace

Classes: Item

Instance Attribute Summary

Attributes included from Pointer

#ptr

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Properties::ClassMethods

#all, #apply_rtransformation, #apply_transformation, #init_properties, #known_integer_properties, #known_properties, #known_string_properties, #mappings, #rtransformations, #settable_properties, #transformations, #type

Methods included from Pointer

#==, #hash, included, #inspect, #to_s

Constructor Details

#initialize(opts) ⇒ Bar

Creates a new Bar. Takes many optional arguments, but only :name, :position and :items are required

Examples:

Bar.new(:name => "BottomTimeBar", :position => :bottom, :items => ["time"])

Parameters:

  • opts (Hash)

    The options for creating the Bar object

Options Hash (opts):

  • :name (String)

    gives the name of the url bar. It has to be unique for all url bars

  • :position (:top, :bottom, :left, :right)

    The position of the bar

  • :items (Array<String>)

    Items that make up the url bar

  • :type (:root, :window)

    either :root or :window (default :root)

    • :root bar displayed once, outside windows

    • :window bar displayed in each window

  • :hidden (Boolean)

    whether the bar is hidden (default false)

  • :priority (Integer)

    not sure... (default 0) TODO find out what this does

  • :condition (:active, :inactive, :nicklist)

    if :type == :window, what windows to use them in (default :active)

    • :active if bar is displayed in active window only

    • :inactive if bar is displayed in inactive windows only

    • :nicklist if bar is displayed in windows with nicklist

  • :filling_top_bottom (:horizontal, :vertical, :columns_horizontal, :columns_vertical)

    how items are filled (default :horizontal)

    • :horizontal items are filled horizontally (space after each item)

    • :vertical items are filled vertically (new line after each item)

    • :columns_horizontal items are filled horizontally, displayed with columns

    • :columns_vertical items are filled vertically, displayed with columns

  • :filling_left_right (:horizontal, :vertical, :columns_horizontal, :columns_vertical)

    how items are filled (default :horizontal )

    • :horizontal items are filled horizontally (space after each item)

    • :vertical items are filled vertically (new line after each item)

    • :columns_horizontal items are filled horizontally, displayed with columns

    • :columns_vertical items are filled vertically, displayed with columns

  • :size (Integer)

    bar size in chars, 0 means automatic size (default 0)

  • :size_max (Integer)

    max size for bar, 0 means no max size (default 0)

  • :color_fg (String)

    color for text in bar (default "black")

  • :color_delim (String)

    color for delimiters in bar (default "blue")

  • :color_bg (String)

    background color for bar (default "white")

  • :separator (Boolean)

    whether bar has separator line with other windows/bars (default false)



209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
# File 'lib/weechat/bar.rb', line 209

def initialize(opts)
  @name = opts[:name]
  mapped_args = {}
  args_with_defaults = add_defaults_to_args(opts)
  args_with_defaults.each do |key, value|
    mapped_args[key] = self.class.apply_rtransformation(key, value)
  end

  @ptr = Weechat.bar_new(*mapped_args.values_at(:name, :hidden, :priority, :type,
                                                :condition, :position, :filling_top_bottom,
                                                :filling_left_right, :size, :size_max,
                                                :color_fg, :color_delim, :color_bg, :separator,
                                                :items))
  if @ptr.empty?
    raise "Could not create bar"
  end

end

Class Method Details

.find(name) ⇒ Bar? Also known as: from_name

Finds the Bar with the given name

Parameters:

  • name (String)

    The name of the bar to find

Returns:

  • (Bar?)

    The found Bar, or nil if none was found



163
164
165
166
167
168
169
170
# File 'lib/weechat/bar.rb', line 163

def find(name)
  ptr = Weechat.bar_search(name)
  if !ptr.empty?
    from_ptr(ptr)
  else
    nil
  end
end

Instance Method Details

#deleteObject Also known as: remove

deletes the bar.



261
262
263
264
# File 'lib/weechat/bar.rb', line 261

def delete
  # TODO mark deletion state
  Weechat.bar_remove(@ptr)
end

#updateObject

updates the bar



256
257
258
# File 'lib/weechat/bar.rb', line 256

def update
  Weechat.bar_update(self.name)
end