diff options
author | Trygve Aaberge <trygveaa@gmail.com> | 2021-05-26 02:58:18 +0200 |
---|---|---|
committer | Trygve Aaberge <trygveaa@gmail.com> | 2021-05-26 03:04:35 +0200 |
commit | adb1029977169ac665041e2e95613c531808875e (patch) | |
tree | d428b7872b36034b6f7e6c46b5368d66e29dc740 | |
parent | 50d78c539141e42d689205477a4c646a936afafd (diff) | |
download | wee-slack-adb1029977169ac665041e2e95613c531808875e.tar.gz |
Fix alignment of multiline messages
When `weechat.look.prefix_align` is set to `none`, lines after the first
in a message would not align with the first. Use the same number of
spaces as the prefix for those lines, so they align with the first.
-rw-r--r-- | wee_slack.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/wee_slack.py b/wee_slack.py index cec821c..e4716b4 100644 --- a/wee_slack.py +++ b/wee_slack.py @@ -259,9 +259,12 @@ class WeechatWrapper(object): return decode_from_utf8(orig_attr) # Ensure all lines sent to weechat specifies a prefix. For lines after the - # first, we want to disable the prefix, which is done by specifying a space. + # 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): - message = message.replace("\n", "\n \t") + prefix, _, _ = message.partition("\t") + prefix_spaces = " " * len(weechat.string_remove_color(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 ) |