summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2021-08-27 17:15:09 -0400
committerMatthias Clasen <mclasen@redhat.com>2021-08-27 17:15:09 -0400
commit05f62eae063ec1cfe56cbfcc9e99b6dfa989ef90 (patch)
tree1e6a45587225e1c38369c09ac480b6b89b01080b /utils
parentc2bb4548c4864ecbf62daca65b2e833615bc1579 (diff)
downloadpango-05f62eae063ec1cfe56cbfcc9e99b6dfa989ef90.tar.gz
pango-view: Show caret slopes as well
When annotating caret positions, render the diagonal of the caret position rectangle as well.
Diffstat (limited to 'utils')
-rw-r--r--utils/viewer-pangocairo.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/utils/viewer-pangocairo.c b/utils/viewer-pangocairo.c
index 1bc9f025..b010c3f3 100644
--- a/utils/viewer-pangocairo.c
+++ b/utils/viewer-pangocairo.c
@@ -534,6 +534,25 @@ render_callback (PangoLayout *layout,
while (pango_layout_iter_next_run (iter));
pango_layout_iter_free (iter);
+ const char *text = pango_layout_get_text (layout);
+ int length = g_utf8_strlen (text, -1);
+ for (int i = 0; i <= length; i++)
+ {
+ PangoRectangle rect;
+ pango_layout_get_caret_pos (layout, i, &rect, NULL);
+
+ cairo_move_to (cr,
+ (double)rect.x / PANGO_SCALE - lw / 2
+ + (double)rect.width / PANGO_SCALE + lw,
+ (double)rect.y / PANGO_SCALE - lw / 2);
+ cairo_line_to (cr,
+ (double)rect.x / PANGO_SCALE - lw / 2,
+ (double)rect.y / PANGO_SCALE - lw / 2
+ + (double)rect.height / PANGO_SCALE + lw);
+ cairo_stroke (cr);
+
+ }
+
cairo_restore (cr);
}
}