On 08.10.2015 22:53, Kai Willadsen wrote:
> On 7 October 2015 at 06:00, David Rabel <[email protected]> wrote:
>> ...
>
> Awesome! Could you please just make a note on that page that you're
> looking at it so that no one else tries to pick it up at the same
> time?
>
I wasn't sure what to write. Is it okay as I did?
>> ...
>
> Sure. Pretty much any of our options *might* conflict with something
> applied by a style scheme, so we just have to live with that. The vast
> majority of style schemes set no background colours, so that's a
> fairly reliable fallback if we want it. I'm also not too worried about
> overwriting the style scheme's foreground colours, since what we're
> indicating in code is unlikely to be overwriting important syntax
> highlighting annotations (i.e., you're probably not writing a regex to
> ignore function definitions or language keywords).
>
> So for now, I'd ignore the issue of conflicting with style schemes and
> make the drawing something that will definitely work, e.g., a light
> grey foreground text colour.
You are right. Attached you find my grey-proposal. :-)
> I'm not sure if you were done with it, but that patch doesn't quite do
> the right thing when you get multiple ignored regions. I think the
> problem is that the _filter_text changes assume that it's only called
> with the whole file, but we actually call it whenever we request a
> slice from meldbuffer.BufferLines (which is quite a bit). I think
> you'll have to change the _filter_text call to take buffer offsets
> from the slice call and do offset calculations from there.
I tried to fix this issue. I think it is correct, but maybe you could
have a closer look at it, because I was not able to reproduce the
problem reliably. Therefore I'm not sure, if I am lucky or it is fixed. ;-)
I have one more problem:
I don't really understand how the groups()-thing in killit() is supposed
to work. At the moment for each subgroup which did contribute to the
match, it filters all occurrences of the last match of this subgroup.
For example I used the pattern (\d)*(\d). If I filter the string
"12341234" it matches the whole string, but the last occurrences of the
subgroups are "3" and "4", so all "3"s and "4"s are filtered off and
after that it remains "1212". That does not seem to make a lot of sense.
At least I don't understand it. :-D
I did write some not-so-beautiful lines that dim exactly what is
filtered out thou, because it was easier to see what is going on, when I
could really visually see it.
Regards,
David
diff --git a/meld/filediff.py b/meld/filediff.py
index 0aabdba..66e9bed 100644
--- a/meld/filediff.py
+++ b/meld/filediff.py
@@ -762,16 +762,29 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
None, True)
self.queue_draw()
- def _filter_text(self, txt):
+ def _filter_text(self, txt, buf, start_offset, end_offset):
+ dimmed_tag = buf.get_tag_table().lookup("dimmed")
+ buf.remove_tag(dimmed_tag, buf.get_iter_at_offset(start_offset),
buf.get_iter_at_offset(end_offset))
def killit(m):
assert m.group().count("\n") == 0
if len(m.groups()):
s = m.group()
+ s2 = s
for g in m.groups():
if g:
+ i = 0
+ while s2.find(g, i) is not -1:
+ start_iter =
buf.get_iter_at_offset(m.start()+s2.find(g, i) +start_offset)
+ end_iter =
buf.get_iter_at_offset(m.start()+s2.find(g, i)+len(g)+start_offset)
+ buf.apply_tag(dimmed_tag, start_iter, end_iter)
+ i = s2.find(g, i)+len(g)
s = s.replace(g,"")
+
return s
else:
+ start_iter = buf.get_iter_at_offset(m.start()+start_offset)
+ end_iter = buf.get_iter_at_offset(m.end() +start_offset)
+ buf.apply_tag(dimmed_tag, start_iter, end_iter)
return ""
try:
for filt in self.text_filters:
diff --git a/meld/meldbuffer.py b/meld/meldbuffer.py
index 9c89999..a718182 100644
--- a/meld/meldbuffer.py
+++ b/meld/meldbuffer.py
@@ -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.get_offset(),
end.get_offset())
lines = filter_txt.splitlines()
ends = filter_txt.splitlines(True)
@@ -269,7 +269,7 @@ 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')
+ return text_type(self.textfilter(txt, self.buf,
line_start.get_offset(), line_end.get_offset()), 'utf8')
def __len__(self):
return self.buf.get_line_count()
diff --git a/meld/sourceview.py b/meld/sourceview.py
index 0d142f3..f0c01a1 100644
--- a/meld/sourceview.py
+++ b/meld/sourceview.py
@@ -124,6 +124,10 @@ class MeldSourceView(GtkSource.View):
buf = meldbuffer.MeldBuffer()
buf.create_tag("inline")
+ buf.create_tag("dimmed")
+ dimmed_tag = buf.get_tag_table().lookup("dimmed")
+ dimmed_tag.set_property("foreground", "#999999")
+ dimmed_tag.set_property("foreground-set", True)
self.set_buffer(buf)
meldsettings.connect('changed', self.on_setting_changed)
_______________________________________________
meld-list mailing list
[email protected]
https://mail.gnome.org/mailman/listinfo/meld-list