From fb38380f9a6db7b4bb46422fba2edfc44935d8a3 Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Thu, 7 Dec 2023 05:18:52 +0000 Subject: [PATCH] Don't show @mentions in Ego Log post summaries. That way we get in as much as possible of the message _content_, which should help disambiguate posts that are part of a long conversation with the same user(s). --- text.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/text.py b/text.py index 307a422..dbaebe5 100644 --- a/text.py +++ b/text.py @@ -105,6 +105,9 @@ class ColouredString: line += c yield line + def is_colour(self, c): + return self.c == c * len(self.c) + class BlankLine: def render(self, width): yield ColouredString("") @@ -272,6 +275,14 @@ class Paragraph: self.words.extend(para.words) self.space_colours.extend(para.space_colours) + def delete_mention_words_from(self, pos): + while pos < len(self.words) and self.words[pos].is_colour('@'): + self.words[pos:pos+1] = [] + self.space_colours[pos:pos+1] = [] + + def __len__(self): + return len(self.words) + def __repr__(self): return f"Paragraph({self.words!r}, unfinished={self.unfinished_word!r})" @@ -299,8 +310,10 @@ class NotificationLog: self.para.end_word() if want_content: + currlen = len(self.para) for cpara in cparas: self.para.add_para(cpara) + self.para.delete_mention_words_from(currlen) def render(self, width): it = self.para.render(width, max(0, width-2)) -- 2.30.2