[gnome-builder/wip/chergert/gutter] add deletes back
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/chergert/gutter] add deletes back
- Date: Mon, 18 Sep 2017 09:37:33 +0000 (UTC)
commit f2e917179b6b854e90a2024b7ecf7e0ccdbcd7a5
Author: Christian Hergert <chergert redhat com>
Date: Mon Sep 18 02:37:13 2017 -0700
add deletes back
libide/sourceview/ide-omni-gutter-renderer.c | 75 +++++++++++++++++++++----
1 files changed, 63 insertions(+), 12 deletions(-)
---
diff --git a/libide/sourceview/ide-omni-gutter-renderer.c b/libide/sourceview/ide-omni-gutter-renderer.c
index 6486888..5d388f1 100644
--- a/libide/sourceview/ide-omni-gutter-renderer.c
+++ b/libide/sourceview/ide-omni-gutter-renderer.c
@@ -54,9 +54,13 @@
#define DIAGNOSTICS_SIZE 16
#define ARROW_WIDTH 5
#define CHANGE_WIDTH 2
+#define DELETE_WIDTH 5.0
+#define DELETE_HEIGHT 8.0
-#define IS_BREAKPOINT(i) ((i)->is_breakpoint || (i)->is_countpoint || (i)->is_watchpoint)
-#define IS_DIAGNOSTIC(i) ((i)->is_error || (i)->is_warning || (i)->is_note)
+#define IS_BREAKPOINT(i) ((i)->is_breakpoint || (i)->is_countpoint || (i)->is_watchpoint)
+#define IS_DIAGNOSTIC(i) ((i)->is_error || (i)->is_warning || (i)->is_note)
+#define IS_LINE_CHANGE(i) ((i)->is_add || (i)->is_change || \
+ (i)->is_delete || (i)->is_next_delete || (i)->is_prev_delete)
struct _IdeOmniGutterRenderer
{
@@ -189,6 +193,12 @@ typedef struct
/* The line is part of a deleted range in the buffer */
guint is_delete : 1;
+ /* The previous line was a delete */
+ guint is_prev_delete : 1;
+
+ /* The next line is a delete */
+ guint is_next_delete : 1;
+
/* The line contains a diagnostic error */
guint is_error : 1;
@@ -428,6 +438,7 @@ ide_omni_gutter_renderer_load_basic (IdeOmniGutterRenderer *self,
GArray *lines)
{
GtkTextBuffer *buffer;
+ LineInfo *last = NULL;
guint line;
g_assert (IDE_IS_OMNI_GUTTER_RENDERER (self));
@@ -452,6 +463,14 @@ ide_omni_gutter_renderer_load_basic (IdeOmniGutterRenderer *self,
info->is_warning = !!(flags & IDE_BUFFER_LINE_FLAGS_WARNING);
info->is_note = !!(flags & IDE_BUFFER_LINE_FLAGS_NOTE);
info->is_error = !!(flags & IDE_BUFFER_LINE_FLAGS_ERROR);
+
+ if (last != NULL)
+ {
+ info->is_prev_delete = last->is_delete;
+ last->is_next_delete = info->is_delete;
+ }
+
+ last = info;
}
}
@@ -847,11 +866,11 @@ draw_breakpoint_bg (IdeOmniGutterRenderer *self,
}
static void
-draw_add_change (IdeOmniGutterRenderer *self,
- cairo_t *cr,
- GdkRectangle *area,
- LineInfo *info,
- GtkSourceGutterRendererState state)
+draw_line_change (IdeOmniGutterRenderer *self,
+ cairo_t *cr,
+ GdkRectangle *area,
+ LineInfo *info,
+ GtkSourceGutterRendererState state)
{
g_assert (IDE_IS_OMNI_GUTTER_RENDERER (self));
g_assert (cr != NULL);
@@ -878,9 +897,41 @@ draw_add_change (IdeOmniGutterRenderer *self,
cairo_fill (cr);
}
- /*
- * TODO: Draw a red deletion mark if necessary.
- */
+ if (info->is_next_delete && !info->is_delete)
+ {
+ cairo_move_to (cr,
+ area->x + area->width,
+ area->y + area->height);
+ cairo_line_to (cr,
+ area->x + area->width - DELETE_WIDTH,
+ area->y + area->height);
+ cairo_line_to (cr,
+ area->x + area->width - DELETE_WIDTH,
+ area->y + area->height - (DELETE_HEIGHT / 2));
+ cairo_line_to (cr,
+ area->x + area->width,
+ area->y + area->height);
+ gdk_cairo_set_source_rgba (cr, &self->changes.remove);
+ cairo_fill (cr);
+ }
+
+ if (info->is_delete && !info->is_prev_delete)
+ {
+ cairo_move_to (cr,
+ area->x + area->width,
+ area->y);
+ cairo_line_to (cr,
+ area->x + area->width - DELETE_WIDTH,
+ area->y);
+ cairo_line_to (cr,
+ area->x + area->width - DELETE_WIDTH,
+ area->y + (DELETE_HEIGHT / 2));
+ cairo_line_to (cr,
+ area->x + area->width,
+ area->y);
+ gdk_cairo_set_source_rgba (cr, &self->changes.remove);
+ cairo_fill (cr);
+ }
}
static void
@@ -995,8 +1046,8 @@ ide_omni_gutter_renderer_draw (GtkSourceGutterRenderer *renderer,
/* Draw line changes next so it will show up underneath the
* breakpoint arrows.
*/
- if (self->show_line_changes && (info->is_add || info->is_change))
- draw_add_change (self, cr, cell_area, info, state);
+ if (self->show_line_changes && IS_LINE_CHANGE (info))
+ draw_line_change (self, cr, cell_area, info, state);
/* Draw breakpoint arrows if we have any breakpoints that could
* potentially match.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]