]> git.rmz.io Git - dotfiles.git/commitdiff
weechat: update plugins
authorSamir Benmendil <me@rmz.io>
Sat, 23 Sep 2017 12:04:31 +0000 (12:04 +0000)
committerSamir Benmendil <me@rmz.io>
Sat, 23 Sep 2017 12:04:31 +0000 (12:04 +0000)
weechat/iset.conf
weechat/perl/iset.pl
weechat/python/buffer_autoset.py
weechat/python/grep.py
weechat/python/text_item.py

index 35e1653af1cf658450cf35c7d7f4b4cb2dbd5313..8508e97d63f395acd58e51aa6f7b30ca3c8375d5 100644 (file)
@@ -33,5 +33,6 @@ show_plugin_description = off
 [look]
 scroll_horiz = 10
 show_current_line = on
+use_color = off
 use_mute = off
 value_search_char = "="
index 163dfb5e37b3b0f97ad14018169df8ca9498834a..d6c93642b78f98edd86631d566c5644eaf0ed6cc 100644 (file)
@@ -1,6 +1,6 @@
 #
-# Copyright (C) 2008-2014 Sebastien Helleu <flashcode@flashtux.org>
-# Copyright (C) 2010-2015 Nils Görs <weechatter@arcor.de>
+# Copyright (C) 2008-2017 Sebastien Helleu <flashcode@flashtux.org>
+# Copyright (C) 2010-2017 Nils Görs <weechatter@arcor.de>
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -19,6 +19,8 @@
 #
 # History:
 #
+# 2017-04-14, nils_2 <freenode.#weechat>
+#     version 4.3: add option "use_color" (https://github.com/weechat/scripts/issues/93)
 # 2016-07-08, nils_2 <weechatter@arcor.de>
 #     version 4.2: add diff function
 # 2016-02-06, Sebastien Helleu <flashcode@flashtux.org>:
 use strict;
 
 my $PRGNAME = "iset";
-my $VERSION = "4.2";
+my $VERSION = "4.3";
 my $DESCR   = "Interactive Set for configuration options";
 my $AUTHOR  = "Sebastien Helleu <flashcode\@flashtux.org>";
 my $LICENSE = "GPL3";
@@ -619,6 +621,10 @@ sub iset_refresh_line
                 }
             }
             my $value = $options_values[$y];
+            if (weechat::config_boolean($options_iset{"use_color"}) == 1 and $options_types[$y] eq "color")
+            {
+                $value = weechat::color($options_values[$y]) . $options_values[$y];
+            }
             if ($options_is_null[$y])
             {
                 $value = "null";
@@ -1509,6 +1515,10 @@ sub iset_config_init
         $iset_config_file, $section_look,
         "use_mute", "boolean", "/mute command will be used in input bar", "", 0, 0,
         "off", "off", 0, "", "", "", "", "", "");
+    $options_iset{"use_color"} = weechat::config_new_option(
+        $iset_config_file, $section_look,
+        "use_color", "boolean", "display the color value in the corresponding color", "", 0, 0,
+        "off", "off", 0, "", "", "full_refresh_cb", "", "", "");
 }
 
 sub iset_config_reload_cb
index 305bd6b2d24268c1ff17afdf8b791a1008603af7..c33d3ad9d1757207830b44cb133d2a61afe95ab7 100644 (file)
@@ -1,6 +1,6 @@
 # -*- coding: utf-8 -*-
 #
-# Copyright (C) 2010-2015 Sébastien Helleu <flashcode@flashtux.org>
+# Copyright (C) 2010-2017 Sébastien Helleu <flashcode@flashtux.org>
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -22,6 +22,8 @@
 #
 # History:
 #
+# 2017-06-21, Sébastien Helleu <flashcode@flashtux.org>:
+#     version 1.0: rename command /autosetbuffer to /buffer_autoset
 # 2015-09-28, Simmo Saan <simmo.saan@gmail.com>:
 #     version 0.9: instantly apply properties
 # 2015-07-12, Sébastien Helleu <flashcode@flashtux.org>:
 
 SCRIPT_NAME = "buffer_autoset"
 SCRIPT_AUTHOR = "Sébastien Helleu <flashcode@flashtux.org>"
-SCRIPT_VERSION = "0.9"
+SCRIPT_VERSION = "1.0"
 SCRIPT_LICENSE = "GPL3"
 SCRIPT_DESC = "Auto-set buffer properties when a buffer is opened"
 
-SCRIPT_COMMAND = "autosetbuffer"
+SCRIPT_COMMAND = SCRIPT_NAME
 
 import_ok = True
 
@@ -143,7 +145,7 @@ def bas_config_write():
 # ================================[ command ]=================================
 
 def bas_cmd(data, buffer, args):
-    """Callback for /autosetbuffer command."""
+    """Callback for /buffer_autoset command."""
     args = args.strip()
     if args == "":
         weechat.command("", "/set %s.buffer.*" % CONFIG_FILE_NAME)
@@ -172,7 +174,7 @@ def bas_completion_current_buffer_cb(data, completion_item, buffer,
                                      completion):
     """
     Complete with current buffer name (plugin.name),
-    for command '/autosetbuffer'.
+    for command '/buffer_autoset'.
     """
     name = "%s.%s" % (weechat.buffer_get_string(buffer, "plugin"),
                       weechat.buffer_get_string(buffer, "name"))
@@ -182,7 +184,7 @@ def bas_completion_current_buffer_cb(data, completion_item, buffer,
 
 
 def bas_completion_options_cb(data, completion_item, buffer, completion):
-    """Complete with config options, for command '/autosetbuffer'."""
+    """Complete with config options, for command '/buffer_autoset'."""
     options = weechat.infolist_get("option", "",
                                    "%s.buffer.*" % CONFIG_FILE_NAME)
     if options:
@@ -240,11 +242,12 @@ def bas_signal_buffer_opened_cb(data, signal, signal_data):
                            weechat.buffer_get_string(buffer, "full_name"))
     return weechat.WEECHAT_RC_OK
 
+
 def bas_config_option_cb(data, option, value):
     if not weechat.config_boolean(bas_options["look_instant"]):
         return weechat.WEECHAT_RC_OK
 
-    if not weechat.config_get(option): # option was deleted
+    if not weechat.config_get(option):  # option was deleted
         return weechat.WEECHAT_RC_OK
 
     option = option[len("%s.buffer." % CONFIG_FILE_NAME):]
@@ -267,6 +270,7 @@ def bas_config_option_cb(data, option, value):
 
     return weechat.WEECHAT_RC_OK
 
+
 # ==================================[ main ]==================================
 
 if __name__ == "__main__" and import_ok:
index 30bf2a6c2f0adfdd06d8cf734346f74056e51be7..24ab0c4b7cbf8df9e692dc44781296538463c0e6 100644 (file)
@@ -66,6 +66,9 @@
 #
 #   History:
 #
+#   2017-07-23, Sébastien Helleu <flashcode@flashtux.org>
+#   version 0.7.8: fix modulo by zero when nick is empty string
+#
 #   2016-06-23, mickael9
 #   version 0.7.7: fix get_home function
 #
@@ -206,7 +209,7 @@ except ImportError:
 
 SCRIPT_NAME    = "grep"
 SCRIPT_AUTHOR  = "Elián Hanisch <lambdae2@gmail.com>"
-SCRIPT_VERSION = "0.7.7"
+SCRIPT_VERSION = "0.7.8"
 SCRIPT_LICENSE = "GPL3"
 SCRIPT_DESC    = "Search in buffers and logs"
 SCRIPT_COMMAND = "grep"
@@ -378,13 +381,15 @@ def color_nick(nick):
     else:
         mode = mode_color = ''
     # nick color
-    nick_color = weechat.info_get('irc_nick_color', nick)
-    if not nick_color:
-        # probably we're in WeeChat 0.3.0
-        #debug('no irc_nick_color')
-        color_nicks_number = config_int('weechat.look.color_nicks_number')
-        idx = (sum(map(ord, nick))%color_nicks_number) + 1
-        nick_color = wcolor(config_string('weechat.color.chat_nick_color%02d' %idx))
+    nick_color = ''
+    if nick:
+        nick_color = weechat.info_get('irc_nick_color', nick)
+        if not nick_color:
+            # probably we're in WeeChat 0.3.0
+            #debug('no irc_nick_color')
+            color_nicks_number = config_int('weechat.look.color_nicks_number')
+            idx = (sum(map(ord, nick))%color_nicks_number) + 1
+            nick_color = wcolor(config_string('weechat.color.chat_nick_color%02d' %idx))
     return ''.join((prefix_c, prefix, mode_color, mode, nick_color, nick, suffix_c, suffix))
 
 ### Config and value validation ###
index 4b63a8158a626241cc581b9801a8dfe348f709cf..47b284fb16a69ce5519bb1e11ba9c3770f74140f 100644 (file)
@@ -1,6 +1,6 @@
 # -*- coding: utf-8 -*-
 #
-# Copyright (c) 2012-2016 by nils_2 <weechatter@arcor.de>
+# Copyright (c) 2012-2017 by nils_2 <weechatter@arcor.de>
 #
 # add a plain text or evaluated content to item bar
 #
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
+# 2017-08-23: nils_2, (freenode.#weechat)
+#     0.7.1 : improve /help text
+#
+# 2017-08-19: nils_2, (freenode.#weechat)
+#       0.7 : add type "!all", internal changes
+#
 # 2016-12-12: nils_2, (freenode.#weechat)
 #       0.6 : fix problem with multiple windows (reported by Ram-Z)
 #
@@ -50,7 +56,7 @@ except Exception:
 
 SCRIPT_NAME     = "text_item"
 SCRIPT_AUTHOR   = "nils_2 <weechatter@arcor.de>"
-SCRIPT_VERSION  = "0.6"
+SCRIPT_VERSION  = "0.7.1"
 SCRIPT_LICENSE  = "GPL"
 SCRIPT_DESC     = "add a plain text or evaluated content to item bar"
 
@@ -76,19 +82,15 @@ def unhook(hook):
 def toggle_refresh(pointer, name, value):
     option_name = name[len('plugins.var.python.' + SCRIPT_NAME + '.'):]      # get optionname
 
-    # option was removed? remove bar_item from struct!
+    # option was removed? remove bar_item from struct
     if not weechat.config_get_plugin(option_name):
         ptr_bar = weechat.bar_item_search(option_name)
         if ptr_bar:
             weechat.bar_item_remove(ptr_bar)
-            return weechat.WEECHAT_RC_OK
-        else:
-            return weechat.WEECHAT_RC_OK
+        return weechat.WEECHAT_RC_OK
 
-    # check if option is new or simply changed
-    if weechat.bar_item_search(option_name):
-        weechat.bar_item_update(option_name)
-    else:
+    # check if option is new or changed
+    if not weechat.bar_item_search(option_name):
         weechat.bar_item_new(option_name,'update_item',option_name)
 
     weechat.bar_item_update(option_name)
@@ -122,18 +124,14 @@ def update_item (data, item, window):
         window = weechat.current_window()
 
     value = weechat.config_get_plugin(data)
-
-    if value:
-        value = check_buffer_type(window, data, value)
-    else:
-        return ""
-
     if not value:
         return ""
 
+    value = check_buffer_type(window, data, value)
+
     return substitute_colors(value,window)
 
-# update item
+# update item from weechat.hook_signal()
 def bar_item_update(signal, callback, callback_data):
     ptr_infolist_option = weechat.infolist_get('option','','plugins.var.python.' + SCRIPT_NAME + '.*')
 
@@ -184,6 +182,10 @@ def check_buffer_type(window, data, value):
 
     if channel_type == 'all' or weechat.buffer_get_string(bufpointer,'localvar_type') == channel_type:
         return value
+    if channel_type == '!all':
+        a = ["channel","server","private"]
+        if weechat.buffer_get_string(bufpointer,'localvar_type') in a:
+            return value
     return ""
 
 # ================================[ main ]===============================
@@ -195,19 +197,20 @@ if __name__ == "__main__":
                         '===========\n'
                         'Template:\n'
                         '/set plugins.var.python.text_item.<item_name> <type>|<signal> <${color:name/number}><text>\n\n'
-                        '   type : all, channel, server, private\n'
-                        '   (you can use: /buffer localvar)\n\n'
-                        '   signal (eg.): buffer_switch, buffer_closing, print, \n'
+                        '   type : channel, server, private, all (all kind of buffers e.g. /color, /fset...) and !all (channel, server and private buffer)\n'
+                        '   (see: /buffer localvar)\n\n'
+                        '   signal (eg.): buffer_switch, buffer_closing, print, mouse_enabled\n'
                         '   (for a list of all possible signals, see API doc weechat_hook_signal())\n\n'
-                        'Example:\n'
-                        '=======\n'
+                        'Examples:\n'
                         'creates an option for a text item named "nick_text". The item will be created for "channel" buffers. '
                         'The text displayed in the status-bar is "Nicks:" (yellow colored!):\n'
                         '   /set plugins.var.python.text_item.nick_text "channel ${color:yellow}Nicks:"\n\n'
                         'now you have to add the item "nick_text" to the bar.items (use auto-completion or iset.pl!)\n'
                         '   /set weechat.bar.status.items nick_text\n\n'
-                        'creates an option to display the terminal width and height in an item bar. item will be updated on signal "signal_sigwinch"\n'
-                        '   /set plugins.var.python.text_item.dimension "all|signal_sigwinch width: ${info:term_width} height: ${info:term_height}"\n',
+                        'creates an option to display the terminal width and height in an item bar. item will be updated on signal "signal_sigwinch":\n'
+                        '   /set plugins.var.python.text_item.dimension "all|signal_sigwinch width: ${info:term_width} height: ${info:term_height}"\n'
+                        'creates an option to display the status from "/filter toggle" and "/filter toggle @" command, item name is "filter_item":\n'
+                        '   /set plugins.var.python.text_item.filter_item "!all|*filters* ${if:${info:filters_enabled}==1?${color:yellow}F:${color:243}F}${if:${buffer.filter}==1?${color:yellow}@:${color:243}@}"\n',
                         '',
                         '',
                         '')