New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] Copy-paste patch objects using system clipboard text buffer #2086
base: master
Are you sure you want to change the base?
[WIP] Copy-paste patch objects using system clipboard text buffer #2086
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pdgui_vmess
already takes care of escaping.
just use it.
7060e56
to
f41f9e2
Compare
f41f9e2
to
6b1c7f8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
better but not there yet
tcl/pd_bindings.tcl
Outdated
bind_capslock all $::modifier-Key a {menu_send %W selectall} | ||
bind_capslock all $::modifier-Key b {menu_helpbrowser} | ||
bind_capslock all $::modifier-Key c {menu_send %W copy} | ||
bind_capslock all $::modifier-$alt-Key c {menu_send %W copy-to-clipboard-as-text} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the Alt/Option is also handled in ::pd_bindings::global_bindings
, i think it should be handled only once (like with $::modifier
)
tcl/pd_menus.tcl
Outdated
} else { | ||
set accelerator "Ctrl" | ||
set alt "Alt" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
like this.
Also still need to properly escape brackets, commas, etc when sending back from Tcl. Im looking at pure-data/tcl/wheredoesthisgo.tcl Line 153 in c0a7c16
|
canvas_copy_to_clipboard_as_text() performs canvas_docopy and gets the binary object buffer as text, and passes it to TCL to copy to system clipboard canvas_paste_from_clipboard_text() calls TCL to send system clipboard text, tcl then calls canvas_got_clipboard_content() which transforms the text back to binary buffer and performs canvas_dopaste TODO: split clipboard append to chunks
2d3492a
to
de783d1
Compare
src/g_editor.c
Outdated
{ | ||
pdgui_vmess("pdtk_get_clipboard_text", "^", x); | ||
} | ||
static t_binbuf *clipboard_patch_bb = NULL; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should go into (t_glist*)->gl_privatedata
i think i discovered a bug in this needs to be fixed before this PR can properly handle appendicles ( |
Ok, I was wondering about this before.
Copying (pdgui_vmess()):
|
Even if I have the |
src/g_editor.c
Outdated
case CLIPBOARD_PATCH_TEXT_LINE_PARTIAL: | ||
case CLIPBOARD_PATCH_TEXT_LINE_END: | ||
if (clipboard_patch_bb) { | ||
case CLIPBOARD_PATCH_TEXT_LINE_END_APPENDIX: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'm not exactly sure about this.
since a Pd-file can be properly parsed by binbuf_text()
, even if it contains message delimiting commas ([foo, bar(
) and gobj attributes (, f 10
), I do not see why need special handling here.
ideally, the canvas_got_clipboard_contents()
should get the raw text (as in the clipboard), and that's it (and all the necessary escaping happens in the GUI)
#X msg 78 108 foo \, bar, f 30;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(and sorry for not saying that before you started to implement it)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Heh no worries. I'm just having trouble transmitting the comma with pdsend, i.e. something, f32
gets interpreted as 2 messages. So perhaps a special escape sequence for the comma would suffice? So \, gets transmitted as-is, but , gets handled somehow differently (tcl->pd)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
void canvas_got_clipboard_contents(t_canvas *x, t_floatarg flagf, t_symbol *s) {
const char *debug_str = "#X msg 78 108 foo \\, bar\, f 30;";
t_binbuf *temp_bb = binbuf_new();
binbuf_text(temp_bb, debug_str, strlen(debug_str));
canvas_dopaste(x, temp_bb);
binbuf_free(temp_bb);
}
Works just fine, but I can't get it transmitted via pdsend properly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's because a plain comma in a message is a message separator in Pd lingo.
also, a line in a patch file might not be terminated by a semicolon, in which case it is continued on the next line:
#X obj 79 136 print hello;
is really equivalent to
#X
obj
79
136
print
hello;
i think this is currently not handled correctly (but haven't actually checked)
this is currently not handled correctly, and i get:
bad arguments for message 'got-clipboard-contents' to object 'canvas'
bad arguments for message 'got-clipboard-contents' to object 'canvas'
#: no such object
ob: no such object
prin: no such object
hello: no such object
iirc, miller's suggestion was:
- send a start-message to initiate the binbuf build (aka
got-clipboard-contents 0
) - send the text string
- send an end-message to stop the binbuf build (aka
got-clipboard-contents 2
) - after that, the text buffer is complete, and can be converted into a binbuf and copied into the patch
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here's a super stupid (and simple idea):
do not attempt to send the data as a symbol (it's going to pollute the symbol table anyhow), but as a list of numbers (UTF-8-encoded).
This is trivial to reconstruct on the receiving side.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it's stupid :-) it's like, stream of pure data... (eh) will try. Would love this to take as few lines as possible and maximize utilizing existing functionality.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see eeropic-forks#1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great stuff!! Just need to implement the chunking, so it doesn't cut off the data in pdsend
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. It's just a poc.
I'm pretty sure there is some memory overallocation and what not.
On rethinking, I also would prefer "reset" and "submit" instead of "begin" and "end".
easier to read than numbers (or looooong defines). also easier to understand when watching the core<->gui communication.
Improvement/text clipboard
really hoping this gets done :) |
Opening wip PR for discussion
Related issue #635
Todo
,f 16
in the end of each patch line (atom width in chars)Maybe
Testing
Other