Class: Weechat::Hooks::Print

Inherits:
Weechat::Hook show all
Defined in:
lib/weechat/hooks/print.rb

Overview

Hooks for adding behaviour when a line is printed out on a buffer

Instance Attribute Summary

Attributes inherited from Weechat::Hook

#callback, #id

Attributes included from Pointer

#ptr

Instance Method Summary collapse

Methods inherited from Weechat::Hook

all, #call, compute_free_id, find_by_id, #hooked?, inherited, init, register, unhook, #unhook, unhook_all, unregister

Methods included from Pointer

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

Constructor Details

#initialize(opts = {}) {|line| ... } ⇒ Print

Creates a new Print hook. By default it will be called for every printed line in every buffer. Set the :buffer, :tags and :message options to only respond to a subset of messages

Options Hash (opts):

  • :buffer (Buffer)

    If supplied, only printed lines from this Buffer will be printed. Default nil

  • :tags (Array<String>)

    Tags for the message TODO how does this filter

  • :message (String)

    TODO how does this filter

  • :strip_colors (Boolean)

    whether color chars should be filtered before being sent to the hook

Yields:

  • (line)

    The callback that should handle the line

Yield Parameters:



18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/weechat/hooks/print.rb', line 18

def initialize(opts = {}, &callback)
  super
  buffer = opts[:buffer] || "*"
  tags = opts[:tags] || []
  message = opts[:message] || ''
  strip_colors = opts[:strip_colors] || false

  buffer = buffer.ptr if buffer.respond_to?(:ptr)
  tags = tags.join(",")
  strip_colors = Weechat.bool_to_integer(strip_colors)
  @callback = EvaluatedCallback.new(callback)
  @ptr      = Weechat.hook_print(buffer, tags, message, strip_colors, "print_callback", id.to_s)
end