diff options
author | Trygve Aaberge <trygveaa@gmail.com> | 2023-05-30 20:37:20 +0200 |
---|---|---|
committer | Trygve Aaberge <trygveaa@gmail.com> | 2023-06-03 13:12:28 +0200 |
commit | 5445cb30171a01a247e5c59a572b5ba2f355eb7c (patch) | |
tree | 9e6b8a32aaea1367a5cfd44e503e06bf750963a1 /wee_slack.py | |
parent | 4c569bed30416646866ca57bb385a00352a26cdf (diff) | |
download | wee-slack-5445cb30171a01a247e5c59a572b5ba2f355eb7c.tar.gz |
Support multiline rendering in WeeChat 4.0.0
Don't insert a prefix at the start of each line of a message so it
renders normally in WeeChat 4.0.0 which supports chat lines with
multiple lines.
Diffstat (limited to 'wee_slack.py')
-rw-r--r-- | wee_slack.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/wee_slack.py b/wee_slack.py index c2e3aa0..c3d2a73 100644 --- a/wee_slack.py +++ b/wee_slack.py @@ -263,10 +263,11 @@ class WeechatWrapper(object): # first, we want to disable the prefix, which we do by specifying the same # number of spaces, so it aligns correctly. def prnt_date_tags(self, buffer, date, tags, message): - prefix, _, _ = message.partition("\t") - prefix = weechat.string_remove_color(encode_to_utf8(prefix), "") - prefix_spaces = " " * weechat.strlen_screen(prefix) - message = message.replace("\n", "\n{}\t".format(prefix_spaces)) + if weechat_version < 0x04000000: + prefix, _, _ = message.partition("\t") + prefix = weechat.string_remove_color(encode_to_utf8(prefix), "") + prefix_spaces = " " * weechat.strlen_screen(prefix) + message = message.replace("\n", "\n{}\t".format(prefix_spaces)) return self.wrap_for_utf8(self.wrapped_class.prnt_date_tags)( buffer, date, tags, message ) |