diff options
author | Michael Vetter <jubalh@iodoru.org> | 2019-10-29 14:57:03 +0100 |
---|---|---|
committer | Michael Vetter <jubalh@iodoru.org> | 2019-10-29 15:20:57 +0100 |
commit | 291f9de1e998f3deb1fb34cb221dca9bfdbde7f1 (patch) | |
tree | d8eaee5d6ae0b5a5ed2decd45d60c3072e3c74ca /src/command | |
parent | 900a0451a7b7cab6af3826134b623560c0452fe6 (diff) | |
download | profani-tty-291f9de1e998f3deb1fb34cb221dca9bfdbde7f1.tar.gz |
Send clipboard via /paste
New command `/paste` that sends the clipboard in MUC, Chat etc windows. Fix https://github.com/profanity-im/profanity/issues/156
Diffstat (limited to 'src/command')
-rw-r--r-- | src/command/cmd_funcs.c | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c index dee1b9b5..cc26bba2 100644 --- a/src/command/cmd_funcs.c +++ b/src/command/cmd_funcs.c @@ -8581,8 +8581,40 @@ gboolean cmd_paste(ProfWin *window, const char *const command, gchar **args) { #ifdef HAVE_GTK - char *buf = clipboard_get(); - cons_show(buf); + char *clipboard_buffer = clipboard_get(); + + if (clipboard_buffer) { + switch (window->type) { + case WIN_MUC: + { + ProfMucWin *mucwin = (ProfMucWin*)window; + assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); + cl_ev_send_muc_msg(mucwin, clipboard_buffer, NULL); + break; + } + case WIN_CHAT: + { + ProfChatWin *chatwin = (ProfChatWin*)window; + assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK); + cl_ev_send_msg(chatwin, clipboard_buffer, NULL); + break; + } + case WIN_PRIVATE: + { + ProfPrivateWin *privatewin = (ProfPrivateWin*)window; + assert(privatewin->memcheck == PROFPRIVATEWIN_MEMCHECK); + cl_ev_send_priv_msg(privatewin, clipboard_buffer, NULL); + break; + } + case WIN_CONSOLE: + case WIN_XML: + default: + cons_bad_cmd_usage(command); + break; + } + + free(clipboard_buffer); + } #else cons_show("This version of Profanity has not been built with GTK support enabled. It is needed for the clipboard feature to work."); #endif |