diff options
-rw-r--r-- | .local/share/weechat/python/go.py | 47 |
1 files changed, 33 insertions, 14 deletions
diff --git a/.local/share/weechat/python/go.py b/.local/share/weechat/python/go.py index 77c5774..c4f7f8e 100644 --- a/.local/share/weechat/python/go.py +++ b/.local/share/weechat/python/go.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# Copyright (C) 2009-2014 Sébastien Helleu <flashcode@flashtux.org> +# Copyright (C) 2009-2023 Sébastien Helleu <flashcode@flashtux.org> # Copyright (C) 2010 m4v <lambdae2@gmail.com> # Copyright (C) 2011 stfn <stfnmd@googlemail.com> # @@ -21,6 +21,15 @@ # # History: # +# 2024-05-30, Sébastien Helleu <flashcode@flashtux.org>: +# version 3.0.1: refresh buffer input at the end of search +# 2024-05-30, Sébastien Helleu <flashcode@flashtux.org>: +# version 3.0: refresh immediately buffer input when /go command is executed +# (needed for WeeChat >= 4.3.0) +# 2023-06-21, Sébastien Helleu <flashcode@flashtux.org>: +# version 2.9: add option "min_chars" +# 2023-01-08, Sébastien Helleu <flashcode@flashtux.org>: +# version 2.8: send buffer pointer with signal "input_text_changed" # 2021-05-25, Tomáš Janoušek <tomi@nomi.cz>: # version 2.7: add new option to prefix short names with server names # 2019-07-11, Simmo Saan <simmo.saan@gmail.com> @@ -96,7 +105,7 @@ from __future__ import print_function SCRIPT_NAME = 'go' SCRIPT_AUTHOR = 'Sébastien Helleu <flashcode@flashtux.org>' -SCRIPT_VERSION = '2.7' +SCRIPT_VERSION = '3.0.1' SCRIPT_LICENSE = 'GPL3' SCRIPT_DESC = 'Quick jump to buffers' @@ -108,13 +117,19 @@ try: import weechat except ImportError: print('This script must be run under WeeChat.') - print('Get WeeChat now at: http://www.weechat.org/') + print('Get WeeChat now at: https://weechat.org/') IMPORT_OK = False import re # script options SETTINGS = { + 'auto_jump': ( + 'off', + 'automatically jump to buffer when it is uniquely selected'), + 'buffer_number': ( + 'on', + 'display buffer number'), 'color_number': ( 'yellow,magenta', 'color for buffer number (not selected)'), @@ -133,9 +148,15 @@ SETTINGS = { 'color_name_highlight_selected': ( 'red,brown', 'color for highlight in a selected buffer name'), + 'fuzzy_search': ( + 'off', + 'search buffer matches using approximation'), 'message': ( 'Go to: ', 'message to display before list of buffers'), + 'min_chars': ( + '0', + 'Minimum chars to search and display list of matching buffers'), 'short_name': ( 'off', 'display and search in short names instead of buffer name'), @@ -154,15 +175,6 @@ SETTINGS = { 'use_core_instead_weechat': ( 'off', 'use name "core" instead of "weechat" for core buffer'), - 'auto_jump': ( - 'off', - 'automatically jump to buffer when it is uniquely selected'), - 'fuzzy_search': ( - 'off', - 'search buffer matches using approximation'), - 'buffer_number': ( - 'on', - 'display buffer number'), } # hooks management @@ -208,6 +220,7 @@ def go_unhook_all(): go_unhook_one('modifier') for hook in HOOK_COMMAND_RUN: go_unhook_one(hook) + weechat.bar_item_update('input_text') def go_hook_all(): @@ -227,6 +240,7 @@ def go_hook_all(): if 'modifier' not in hooks: hooks['modifier'] = weechat.hook_modifier( 'input_text_display_with_cursor', 'go_input_modifier', '') + weechat.bar_item_update('input_text') def go_start(buf): @@ -410,6 +424,11 @@ def go_matching_buffers(strinput): def go_buffers_to_string(listbuf, pos, strinput): """Return string built with list of buffers found (matching user input).""" + try: + if len(strinput) < int(weechat.config_get_plugin('min_chars')): + return '' + except: + pass string = '' strinput = strinput.lower() for i in range(len(listbuf)): @@ -500,7 +519,7 @@ def go_command_run_input(data, buf, command): if buffers_pos >= len(buffers): buffers_pos = 0 weechat.hook_signal_send('input_text_changed', - weechat.WEECHAT_HOOK_SIGNAL_STRING, '') + weechat.WEECHAT_HOOK_SIGNAL_POINTER, buf) return weechat.WEECHAT_RC_OK_EAT elif command == '/input complete_previous': # choose previous buffer in list @@ -508,7 +527,7 @@ def go_command_run_input(data, buf, command): if buffers_pos < 0: buffers_pos = len(buffers) - 1 weechat.hook_signal_send('input_text_changed', - weechat.WEECHAT_HOOK_SIGNAL_STRING, '') + weechat.WEECHAT_HOOK_SIGNAL_POINTER, buf) return weechat.WEECHAT_RC_OK_EAT elif command == '/input return': # switch to selected buffer (if any) |