]> git.rmz.io Git - dotfiles.git/blobdiff - weechat/ruby/colorizer.rb
nvim: don't quit nvim from dashboard
[dotfiles.git] / weechat / ruby / colorizer.rb
index 21c15bbe5154dc70dad660cf8559a07fdb60e3b5..14d1729eef6b429276a74e9081e7d8ac2a20a02e 100644 (file)
 # Changelog:
 #
 # 0.1: Initial release.
 # Changelog:
 #
 # 0.1: Initial release.
-#
+# 0.2: Add compatibility with new weechat_print modifier data (WeeChat >= 2.9).
+# 0.3: Fix the compatibility checker
 
 SCRIPT_NAME    = 'colorizer'
 SCRIPT_AUTHOR  = 'Michael B. Hix'
 SCRIPT_DESC    = 'Colorize text in buffers based on rules.'
 
 SCRIPT_NAME    = 'colorizer'
 SCRIPT_AUTHOR  = 'Michael B. Hix'
 SCRIPT_DESC    = 'Colorize text in buffers based on rules.'
-SCRIPT_VERSION = '0.1'
+SCRIPT_VERSION = '0.3'
 SCRIPT_LICENSE = 'BSD'
 
 # A default coloring rule.
 SCRIPT_LICENSE = 'BSD'
 
 # A default coloring rule.
@@ -157,8 +158,16 @@ end
 # Handle message printing.
 #
 def colorize_cb( data, modifier, modifier_data, message )
 # Handle message printing.
 #
 def colorize_cb( data, modifier, modifier_data, message )
-       _,buffer,_ = modifier_data.split( ';' )
-       return message unless @buffer_regex =~ buffer
+       if modifier_data.start_with?('0x')
+               # WeeChat >= 2.9
+               buffer, tags = modifier_data.split( ';' )
+               buffer_name = Weechat.buffer_get_string(buffer, 'name')
+       else
+               # WeeChat <= 2.8
+               plugin, buffer_name, tags = modifier_data.split( ';' )
+       end
+
+       return message unless @buffer_regex =~ buffer_name
 
        reset = Weechat.color( 'reset' )
        @rules.each do |reg, color_str|
 
        reset = Weechat.color( 'reset' )
        @rules.each do |reg, color_str|