diff options
author | Thomas White <taw@bitwiz.me.uk> | 2018-03-31 11:19:47 +0200 |
---|---|---|
committer | Thomas White <taw@bitwiz.me.uk> | 2018-03-31 11:19:47 +0200 |
commit | 3c52f56e0dfe71f108d0837abb8f96b2568eff40 (patch) | |
tree | d9f6c13b461e91d08becf1566445eb0a2ef05e0d /src | |
parent | 518be303d916d16f4816e3b9ae41cd42b0d5e7fd (diff) |
Ensure cursor is somewhere before adding slide
Diffstat (limited to 'src')
-rw-r--r-- | src/narrative_window.c | 2 | ||||
-rw-r--r-- | src/sc_editor.c | 11 | ||||
-rw-r--r-- | src/sc_editor.h | 1 |
3 files changed, 14 insertions, 0 deletions
diff --git a/src/narrative_window.c b/src/narrative_window.c index 913d8da..6bed315 100644 --- a/src/narrative_window.c +++ b/src/narrative_window.c @@ -324,6 +324,8 @@ static void add_slide_sig(GSimpleAction *action, GVariant *parameter, SCBlock *templ; NarrativeWindow *nw = vp; + sc_editor_ensure_cursor(nw->sceditor); + /* Split the current paragraph */ nsblock = split_paragraph_at_cursor(nw->sceditor); diff --git a/src/sc_editor.c b/src/sc_editor.c index 897bdad..e087b55 100644 --- a/src/sc_editor.c +++ b/src/sc_editor.c @@ -374,6 +374,17 @@ void sc_editor_set_background(SCEditor *e, double r, double g, double b) } +void sc_editor_ensure_cursor(SCEditor *e) +{ + if ( e->cursor_frame != NULL ) return; + e->cursor_frame = e->top; + e->cpos.para = 0; + e->cpos.pos = 0; + e->cpos.trail = 0; + e->selection = NULL; +} + + void sc_editor_remove_cursor(SCEditor *e) { e->cursor_frame = NULL; diff --git a/src/sc_editor.h b/src/sc_editor.h index 6584aef..5fea0e1 100644 --- a/src/sc_editor.h +++ b/src/sc_editor.h @@ -189,6 +189,7 @@ extern void sc_editor_add_storycode(SCEditor *e, const char *sc); extern void sc_editor_copy_selected_frame(SCEditor *e); extern void sc_editor_delete_selected_frame(SCEditor *e); extern void sc_editor_remove_cursor(SCEditor *e); +extern void sc_editor_ensure_cursor(SCEditor *e); extern SCBlock *split_paragraph_at_cursor(SCEditor *e); extern void sc_editor_set_imagestore(SCEditor *e, ImageStore *is); |