[meld] gutterrendererchunk: Improve escape checks for chunk drawing
- From: Kai Willadsen <kaiw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [meld] gutterrendererchunk: Improve escape checks for chunk drawing
- Date: Sun, 2 Oct 2016 00:12:35 +0000 (UTC)
commit d7aca32d40352e029cd6ee9af2acd3e2397a818f
Author: Kai Willadsen <kai willadsen gmail com>
Date: Sun Sep 25 11:11:24 2016 +1000
gutterrendererchunk: Improve escape checks for chunk drawing
meld/gutterrendererchunk.py | 60 +++++++++++++++++++++++--------------------
1 files changed, 32 insertions(+), 28 deletions(-)
---
diff --git a/meld/gutterrendererchunk.py b/meld/gutterrendererchunk.py
index 4ba672b..11c2ecb 100644
--- a/meld/gutterrendererchunk.py
+++ b/meld/gutterrendererchunk.py
@@ -48,37 +48,41 @@ class MeldGutterRenderer(object):
line = start.get_line()
chunk_index = self.linediffer.locate_chunk(self.from_pane, line)[0]
+ if chunk_index is None:
+ return
+
+ chunk = self.linediffer.get_chunk(
+ chunk_index, self.from_pane, self.to_pane)
+ if not chunk:
+ return
+
+ x = background_area.x - 1
+ y = background_area.y
+ width = background_area.width + 2
+ height = 1 if chunk[1] == chunk[2] else background_area.height
+
context.save()
context.set_line_width(1.0)
- if chunk_index is not None:
- chunk = self.linediffer.get_chunk(
- chunk_index, self.from_pane, self.to_pane)
+ context.rectangle(x, y, width, height)
+ context.set_source_rgba(*self.fill_colors[chunk[0]])
+
+ if self.props.view.current_chunk_check(chunk):
+ context.fill_preserve()
+ highlight = self.fill_colors['current-chunk-highlight']
+ context.set_source_rgba(*highlight)
+ context.fill()
+
+ if line == chunk[1] or line == chunk[2] - 1:
+ context.set_source_rgba(*self.line_colors[chunk[0]])
+ if line == chunk[1]:
+ context.move_to(x, y + 0.5)
+ context.rel_line_to(width, 0)
+ if line == chunk[2] - 1:
+ context.move_to(x, y - 0.5 + height)
+ context.rel_line_to(width, 0)
+ context.stroke()
- if chunk:
- x = background_area.x - 1
- width = background_area.width + 2
-
- height = 1 if chunk[1] == chunk[2] else background_area.height
- y = background_area.y
- context.rectangle(x, y, width, height)
- context.set_source_rgba(*self.fill_colors[chunk[0]])
-
- if self.props.view.current_chunk_check(chunk):
- context.fill_preserve()
- highlight = self.fill_colors['current-chunk-highlight']
- context.set_source_rgba(*highlight)
- context.fill()
-
- if line == chunk[1] or line == chunk[2] - 1:
- context.set_source_rgba(*self.line_colors[chunk[0]])
- if line == chunk[1]:
- context.move_to(x, y + 0.5)
- context.rel_line_to(width, 0)
- if line == chunk[2] - 1:
- context.move_to(x, y - 0.5 + height)
- context.rel_line_to(width, 0)
- context.stroke()
context.restore()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]