From 374120d3ccedb064c30b09ddd48131bc1b0a5df8 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Sun, 8 May 2016 17:57:03 +0200 Subject: Highlight paragraph only in narrative window and only during slideshow --- src/narrative_window.c | 4 ++++ src/sc_editor.c | 15 ++++++++++++--- src/sc_editor.h | 3 +++ 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/narrative_window.c b/src/narrative_window.c index e9436cc..d1aa5f0 100644 --- a/src/narrative_window.c +++ b/src/narrative_window.c @@ -171,6 +171,7 @@ static void ss_end_show(SlideShow *ss, void *vp) { NarrativeWindow *nw = vp; nw->show = NULL; + sc_editor_set_para_highlight(nw->sceditor, 0); } @@ -279,6 +280,9 @@ static void start_slideshow_sig(GSimpleAction *action, GVariant *parameter, nw->sel_slide = first_slide(nw->p); nw->show = try_start_slideshow(nw->p, ssc, nw); + if ( nw->show != NULL ) { + sc_editor_set_para_highlight(nw->sceditor, 1); + } } diff --git a/src/sc_editor.c b/src/sc_editor.c index 0c07b5b..beb1d5a 100644 --- a/src/sc_editor.c +++ b/src/sc_editor.c @@ -409,13 +409,14 @@ static void draw_editing_box(cairo_t *cr, struct frame *fr) static void draw_caret(cairo_t *cr, struct frame *fr, int cursor_para, - size_t cursor_pos, int cursor_trail) + size_t cursor_pos, int cursor_trail, int hgh) { double cx, clow, chigh, h; double cy, w; const double t = 1.8; - if ( get_para_highlight(fr, cursor_para, &cx, &cy, &w, &h) == 0 ) { + 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); @@ -483,7 +484,7 @@ static void draw_overlay(cairo_t *cr, SCEditor *e) } draw_caret(cr, e->cursor_frame, e->cursor_para, e->cursor_pos, - e->cursor_trail); + e->cursor_trail, e->para_highlight); } @@ -1591,6 +1592,13 @@ void sc_editor_set_callbacks(SCEditor *e, SCCallbackList *cbl) } +void sc_editor_set_para_highlight(SCEditor *e, int para_highlight) +{ + e->para_highlight = para_highlight; + sc_editor_redraw(e); +} + + SCEditor *sc_editor_new(SCBlock *scblocks, SCBlock **stylesheets, PangoLanguage *lang) { @@ -1614,6 +1622,7 @@ SCEditor *sc_editor_new(SCBlock *scblocks, SCBlock **stylesheets, sceditor->scroll_pos = 0; sceditor->flow = 0; sceditor->lang = lang; + sceditor->para_highlight = 0; sceditor->stylesheets = copy_ss_list(stylesheets); diff --git a/src/sc_editor.h b/src/sc_editor.h index cf0b6d6..a2a9b38 100644 --- a/src/sc_editor.h +++ b/src/sc_editor.h @@ -97,6 +97,7 @@ struct _sceditor ImageStore *is; SCCallbackList *cbl; struct frame *top; + int para_highlight; /* Redraw/scroll stuff */ GtkScrollablePolicy hpol; @@ -181,4 +182,6 @@ extern void sc_editor_delete_selected_frame(SCEditor *e); extern void sc_editor_remove_cursor(SCEditor *e); extern SCBlock *split_paragraph_at_cursor(SCEditor *e); +extern void sc_editor_set_para_highlight(SCEditor *e, int para_highlight); + #endif /* SC_EDITOR_H */ -- cgit v1.2.3