Skip to content

Commit

Permalink
text_item.py 0.9: fix eval_expression() for split windows
Browse files Browse the repository at this point in the history
  • Loading branch information
weechatter authored and flashcode committed May 25, 2019
1 parent f6f0fd4 commit a3eccda
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions python/text_item.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
#
# Copyright (c) 2012-2018 by nils_2 <[email protected]>
# Copyright (c) 2012-2019 by nils_2 <[email protected]>
#
# add a plain text or evaluated content to item bar
#
Expand All @@ -17,6 +17,9 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# 2019-05-23: FlashCode, (freenode.#weechat)
# 0.9 : fix eval_expression() for split windows
#
# 2018-08-18: nils_2, (freenode.#weechat)
# 0.8 : add new option "interval"
#
Expand Down Expand Up @@ -49,6 +52,13 @@
# Development is currently hosted at
# https://github.com/weechatter/weechat-scripts

# TODO
# plugins.var.python.text_item.<item_name>.enabled
# plugins.var.python.text_item.<item_name>.type
# plugins.var.python.text_item.<item_name>.signal
# plugins.var.python.text_item.<item_name>.text
# plugins.var.python.text_item.<item_name>.interval

try:
import weechat,re

Expand All @@ -59,7 +69,7 @@

SCRIPT_NAME = "text_item"
SCRIPT_AUTHOR = "nils_2 <[email protected]>"
SCRIPT_VERSION = "0.8"
SCRIPT_VERSION = "0.9"
SCRIPT_LICENSE = "GPL"
SCRIPT_DESC = "add a plain text or evaluated content to item bar"

Expand All @@ -72,7 +82,6 @@
settings = {
'interval': ('0', 'How often (in seconds) to force an update of all items. 0 means deactivated'),
}

# ================================[ hooks ]===============================
def add_hook(signal, item):
global hooks
Expand Down Expand Up @@ -183,8 +192,7 @@ def bar_item_update_cb(signal, callback, callback_data):
def substitute_colors(text,window):
if int(version) >= 0x00040200:
bufpointer = weechat.window_get_pointer(window,"buffer")
return weechat.string_eval_expression(text, {"buffer": bufpointer}, {}, {})
# return weechat.string_eval_expression(text,{},{},{})
return weechat.string_eval_expression(text, {"window": window, "buffer": bufpointer}, {}, {})
# substitute colors in output
return re.sub(regex_color, lambda match: weechat.color(match.group(1)), text)

Expand Down

0 comments on commit a3eccda

Please sign in to comment.