Skip to content

Commit

Permalink
Send clipboard via /paste
Browse files Browse the repository at this point in the history
New command `/paste` that sends the clipboard in MUC, Chat etc windows.

Fix #156
  • Loading branch information
jubalh committed Oct 29, 2019
1 parent 900a045 commit 291f9de
Showing 1 changed file with 34 additions and 2 deletions.
36 changes: 34 additions & 2 deletions src/command/cmd_funcs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 291f9de

Please sign in to comment.