Commit cef0f70c authored by David Rabel's avatar David Rabel Committed by Kai Willadsen

Dim text ignored by filters

Filtered text that is not indicated somehow can lead to confusion,
because for example Melds comparison algorithm does not distinguish
between a blank line and a line that matches a text filter.

Now the filtered text is dimmed, that means the foreground color of
filtered text is changed to light grey to indicate that it is ignored by
Melds comparison algorithm.

https://bugzilla.gnome.org/show_bug.cgi?id=633515
parent d408a696
......@@ -13,4 +13,5 @@
<style name="meld:unknown-text" foreground="#888888"/>
<style name="meld:syncpoint-outline" foreground="#555555"/>
<style name="meld:current-chunk-highlight" background="rgba(255, 255, 255, 0.5)"/>
<style name="meld:dimmed" foreground="#999999"/>
</style-scheme>
......@@ -14,4 +14,5 @@
<style name="meld:unknown-text" background="#aaaaaa"/>
<style name="meld:syncpoint-outline" foreground="#bbbbbb"/>
<style name="meld:current-chunk-highlight" background="rgba(255, 255, 255, 0.1)"/>
<style name="meld:dimmed" foreground="#999999"/>
</style-scheme>
......@@ -762,17 +762,37 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
None, True)
self.queue_draw()
def _filter_text(self, txt):
def _filter_text(self, txt, buf, start_iter, end_iter):
dimmed_tag = buf.get_tag_table().lookup("dimmed")
buf.remove_tag(dimmed_tag, start_iter, end_iter)
start = start_iter.copy()
end = start_iter.copy()
def killit(m):
assert m.group().count("\n") == 0
if len(m.groups()):
s = m.group()
for g in m.groups():
for i in reversed(range(1, len(m.groups())+1)):
g = m.group(i)
if g:
s = s.replace(g,"")
start.forward_chars(m.start(i))
end.forward_chars(m.end(i))
buf.apply_tag(dimmed_tag, start, end)
start.forward_chars(-m.start(i))
end.forward_chars(-m.end(i))
s = s[:m.start(i)-m.start()]+s[m.end(i)-m.start():]
return s
else:
start.forward_chars(m.start())
end.forward_chars(m.end())
buf.apply_tag(dimmed_tag, start, end)
start.forward_chars(-m.start())
end.forward_chars(-m.end())
return ""
try:
for filt in self.text_filters:
if filt.active:
......
......@@ -223,7 +223,7 @@ class BufferLines(object):
end = self.buf.get_iter_at_line_or_eof(hi)
txt = text_type(self.buf.get_text(start, end, False), 'utf8')
filter_txt = self.textfilter(txt)
filter_txt = self.textfilter(txt, self.buf, start, end)
lines = filter_txt.splitlines()
ends = filter_txt.splitlines(True)
......@@ -269,7 +269,8 @@ class BufferLines(object):
if not line_end.ends_line():
line_end.forward_to_line_end()
txt = self.buf.get_text(line_start, line_end, False)
return text_type(self.textfilter(txt), 'utf8')
txt_filtered = self.textfilter(txt, self.buf, line_start, line_end)
return text_type(txt_filtered, 'utf8')
def __len__(self):
return self.buf.get_line_count()
......
......@@ -124,6 +124,7 @@ class MeldSourceView(GtkSource.View):
buf = meldbuffer.MeldBuffer()
buf.create_tag("inline")
buf.create_tag("dimmed")
self.set_buffer(buf)
meldsettings.connect('changed', self.on_setting_changed)
......@@ -162,6 +163,9 @@ class MeldSourceView(GtkSource.View):
tag = self.get_buffer().get_tag_table().lookup("inline")
tag.props.background_rgba = colour_lookup_with_fallback(
"meld:inline", "background")
tag = self.get_buffer().get_tag_table().lookup("dimmed")
tag.props.foreground_rgba = colour_lookup_with_fallback(
"meld:dimmed", "foreground")
def do_realize(self):
bind_settings(self)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment