diff options
author | Thomas White <taw@bitwiz.org.uk> | 2016-04-26 23:12:45 +0200 |
---|---|---|
committer | Thomas White <taw@bitwiz.org.uk> | 2016-04-26 23:12:45 +0200 |
commit | 9cf3a70f71dbcebf76597880c0b998a49c95bf7c (patch) | |
tree | 31dcd0925e86cb6c03880d767ed381c6de05d553 /src/sc_editor.c | |
parent | 1d2e905763d2c403e54850d61044065b238e16bc (diff) |
Paste slide
Diffstat (limited to 'src/sc_editor.c')
-rw-r--r-- | src/sc_editor.c | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/src/sc_editor.c b/src/sc_editor.c index 4dfec35..941c822 100644 --- a/src/sc_editor.c +++ b/src/sc_editor.c @@ -1125,7 +1125,6 @@ static void copy_selection(SCEditor *e) if ( bl == NULL ) return; storycode = serialise_sc_block(bl); - printf("Got '%s'\n", storycode); cb = gtk_clipboard_get(GDK_NONE); gtk_clipboard_set_text(cb, storycode, -1); @@ -1133,6 +1132,30 @@ static void copy_selection(SCEditor *e) } +static void paste_callback(GtkClipboard *cb, const gchar *text, void *vp) +{ + SCEditor *e = vp; + SCBlock *bl = sc_parse(text); + SCBlock *cur_bl; + size_t cur_sc_pos; + + get_sc_pos(e->cursor_frame, e->cursor_para, + e->cursor_pos+e->cursor_trail, + &cur_bl, &cur_sc_pos); + sc_insert_block(cur_bl, cur_sc_pos, bl); + full_rerender(e); +} + + +static void paste_selection(SCEditor *e) +{ + GtkClipboard *cb; + + cb = gtk_clipboard_get(GDK_NONE); + gtk_clipboard_request_text(cb, paste_callback, e); +} + + static gboolean key_press_sig(GtkWidget *da, GdkEventKey *event, SCEditor *e) { @@ -1212,6 +1235,14 @@ static gboolean key_press_sig(GtkWidget *da, GdkEventKey *event, } break; + case GDK_KEY_V : + case GDK_KEY_v : + if ( event->state == GDK_CONTROL_MASK ) { + paste_selection(e); + } + break; + + } if ( claim ) return TRUE; |