From d9a2251582b99136f9a262abbf6d93d226398ae9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20B=C3=B6hme?= Date: Wed, 25 Jan 2017 11:07:53 +0100 Subject: [PATCH] Highlight all paragraphs of a search result in the history window A single message may span multiple paragraphs. Highlight all paragraphs of a search result because a keyword could be in any of them. Every message already has the 'eol' tag on its newline character. Highlight from the start of a search match up to the next 'eol' tag. --- src/history_window.py | 7 ++----- src/htmltextview.py | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/history_window.py b/src/history_window.py index df37a787f..654c4fe0b 100644 --- a/src/history_window.py +++ b/src/history_window.py @@ -596,13 +596,10 @@ class HistoryWindow: self.calendar.select_day(day) unix_time = model[path][Column.TIME] self._scroll_to_result(unix_time) - #FIXME: one day do not search just for unix_time but the whole and user - # specific format of the textbuffer line [time] nick: message - # and highlight all that def _scroll_to_result(self, unix_time): """ - Scroll to the result using unix_time and highlight line + Scroll to the result using unix_time and highlight message """ start_iter = self.history_buffer.get_start_iter() local_time = time.localtime(float(unix_time)) @@ -614,7 +611,7 @@ class HistoryWindow: if result is not None: match_start_iter, match_end_iter = result match_start_iter.backward_char() # include '[' or other character before time - match_end_iter.forward_line() # highlight all message not just time + match_end_iter.forward_to_tag_toggle(self.history_buffer.eol_tag) self.history_buffer.apply_tag_by_name('highlight', match_start_iter, match_end_iter) mark = self.history_buffer.create_mark('match', match_start_iter, True) diff --git a/src/htmltextview.py b/src/htmltextview.py index a6f6a6270..4fe90c6a6 100644 --- a/src/htmltextview.py +++ b/src/htmltextview.py @@ -850,7 +850,7 @@ class HtmlTextView(Gtk.TextView): self.connect('copy-clipboard', self.on_html_text_view_copy_clipboard) self.id_ = self.connect('button-release-event', self.on_left_mouse_button_release) - self.get_buffer().create_tag('eol') + self.get_buffer().eol_tag = self.get_buffer().create_tag('eol') self.tooltip = tooltips.BaseTooltip() self.config = gajim.config self.interface = gajim.interface