aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.org.uk>2016-05-26 22:24:58 +0200
committerThomas White <taw@bitwiz.org.uk>2016-05-26 22:24:58 +0200
commit36c253390094aa278372eee02ad630e6225a334a (patch)
treeb67f2266c78cba6a4153ba3c3b5aa60199855af6
parent97a6c04947e30df81e898d5aef79c16fde5999ad (diff)
Highlight paragraph if caret can't be drawn
-rw-r--r--src/sc_editor.c27
1 files changed, 19 insertions, 8 deletions
diff --git a/src/sc_editor.c b/src/sc_editor.c
index 748089e..9c5443d 100644
--- a/src/sc_editor.c
+++ b/src/sc_editor.c
@@ -412,26 +412,37 @@ static void draw_editing_box(cairo_t *cr, struct frame *fr)
}
+static void draw_para_highlight(cairo_t *cr, struct frame *fr, int cursor_para)
+{
+ double cx, cy, w, h;
+
+ if ( get_para_highlight(fr, cursor_para, &cx, &cy, &w, &h) != 0 ) {
+ return;
+ }
+
+ cairo_new_path(cr);
+ cairo_rectangle(cr, cx+fr->x, cy+fr->y, w, h);
+ cairo_set_source_rgba(cr, 0.7, 0.7, 1.0, 0.5);
+ cairo_set_line_width(cr, 5.0);
+ cairo_stroke(cr);
+}
+
+
static void draw_caret(cairo_t *cr, struct frame *fr, int cursor_para,
size_t cursor_pos, int cursor_trail, int hgh)
{
double cx, clow, chigh, h;
- double cy, w;
const double t = 1.8;
- if ( hgh && get_para_highlight(fr, cursor_para, &cx, &cy, &w, &h) == 0 )
- {
- cairo_new_path(cr);
- cairo_rectangle(cr, cx+fr->x, cy+fr->y, w, h);
- cairo_set_source_rgba(cr, 0.7, 0.7, 1.0, 0.5);
- cairo_set_line_width(cr, 5.0);
- cairo_stroke(cr);
+ if ( hgh ) {
+ draw_para_highlight(cr, fr, cursor_para);
return;
}
if ( get_cursor_pos(fr, cursor_para, cursor_pos+cursor_trail,
&cx, &clow, &h) )
{
+ draw_para_highlight(cr, fr, cursor_para);
return;
}