Philipp Hörist pushed to branch gajim_0.16 at gajim / gajim
Commits: 7d39b384 by Markus Böhme at 2017-01-25T10:46:31+01:00 Highlight all paragraphs of a search result in the history window
A single message may span multiple paragraphs. Highlight all lines belonging to the paragraph containing the search keyword.
When filling the history textbuffer, tag each newline character that is ending a message with an invisible tag. Then at search time highlight all lines up to that tag.
- - - - - b2e41e93 by Markus Böhme at 2017-01-25T10:48:33+01:00 Remove unnecessary code in message highlighting in the history window
The message to be highlighted is searched via an already formatted timestamp, and the match contains the whole timestamp with any preceding characters (like "["). Therefore, calling backward_char on the start iterator of the match just goes back to the previous line and is not needed.
- - - - - 27618b2d by Philipp Hörist at 2017-01-26T19:17:06+01:00 Merge branch 'gajim_0.16' into 'gajim_0.16'
History window: Highlight all paragraphs of a search result
See merge request !31 - - - - -
1 changed file:
- src/history_window.py
Changes:
===================================== src/history_window.py ===================================== --- a/src/history_window.py +++ b/src/history_window.py @@ -75,6 +75,8 @@ class HistoryWindow: self.history_buffer = self.history_textview.tv.get_buffer() self.history_buffer.create_tag('highlight', background = 'yellow') self.history_buffer.create_tag('invisible', invisible=True) + self.eom_tag = self.history_buffer.create_tag('endofmessage', + invisible=True) self.checkbutton = xml.get_object('log_history_checkbutton') self.checkbutton.connect('toggled', self.on_log_history_checkbutton_toggled) @@ -515,7 +517,7 @@ class HistoryWindow: else: self.history_textview.print_real_text(message, name=contact_name, xhtml=xhtml) - self.history_textview.print_real_text('\n') + self.history_textview.print_real_text('\n', ['endofmessage'])
def on_query_entry_activate(self, widget): text = self.query_entry.get_text() @@ -624,13 +626,10 @@ class HistoryWindow: self.calendar.select_day(day) unix_time = model[path][C_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)) @@ -641,9 +640,9 @@ class HistoryWindow: None) if result is not None: match_start_iter, match_end_iter = result - # include '[' or other character before time - match_start_iter.backward_char() - match_end_iter.forward_line() # highlight all message not just time + while not match_end_iter.has_tag(self.eom_tag): + if not match_end_iter.forward_to_line_end(): + break self.history_buffer.apply_tag_by_name('highlight', match_start_iter, match_end_iter)
View it on GitLab: https://dev.gajim.org/gajim/gajim/compare/32085e8bd7b92d37b5cab52d59b77e54f4...