From 9cf3a70f71dbcebf76597880c0b998a49c95bf7c Mon Sep 17 00:00:00 2001 From: Thomas White Date: Tue, 26 Apr 2016 23:12:45 +0200 Subject: Paste slide --- src/sc_editor.c | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) (limited to 'src/sc_editor.c') 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; -- cgit v1.2.3