diff options
author | Thomas White <taw@physics.org> | 2018-01-04 22:35:55 +0100 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2018-01-04 22:35:55 +0100 |
commit | 02828602d6f2f1ec2a7e718dea8d4bedc9dc300d (patch) | |
tree | 983ba5c7cdeaef546f28cec786ee3ac5e5848491 /src/sc_editor.c | |
parent | 785c8853383711e6e0bcbdbbcc806907cab391dc (diff) |
Copy and paste entire frames
Diffstat (limited to 'src/sc_editor.c')
-rw-r--r-- | src/sc_editor.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/sc_editor.c b/src/sc_editor.c index c94dcba..fa86706 100644 --- a/src/sc_editor.c +++ b/src/sc_editor.c @@ -431,6 +431,48 @@ void sc_editor_redraw(SCEditor *e) } +void paste_received(GtkClipboard *cb, const gchar *t, gpointer vp) +{ + SCEditor *e = vp; + SCBlock *nf; + nf = sc_parse(t); + sc_block_append_block(e->scblocks, nf); + full_rerender(e); +} + + +void sc_editor_paste(SCEditor *e) +{ + GtkClipboard *cb; + GdkAtom atom; + + atom = gdk_atom_intern("CLIPBOARD", FALSE); + if ( atom == GDK_NONE ) return; + cb = gtk_clipboard_get(atom); + gtk_clipboard_request_text(cb, paste_received, e); +} + + +void sc_editor_copy_selected_frame(SCEditor *e) +{ + char *t; + GtkClipboard *cb; + GdkAtom atom; + + if ( e->selection == NULL ) return; + + atom = gdk_atom_intern("CLIPBOARD", FALSE); + if ( atom == GDK_NONE ) return; + + cb = gtk_clipboard_get(atom); + + t = serialise_sc_block(e->selection->scblocks); + + gtk_clipboard_set_text(cb, t, -1); + free(t); +} + + void sc_editor_delete_selected_frame(SCEditor *e) { sc_block_delete(&e->scblocks, e->selection->scblocks); |