diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c index b18fd6a2..f28610a7 100644 --- a/src/command/cmd_funcs.c +++ b/src/command/cmd_funcs.c @@ -122,7 +122,6 @@ static void _who_roster(ProfWin* window, const char* const command, gchar** args static gboolean _cmd_execute(ProfWin* window, const char* const command, const char* const inp); static gboolean _cmd_execute_default(ProfWin* window, const char* inp); static gboolean _cmd_execute_alias(ProfWin* window, const char* const inp, gboolean* ran); -gboolean _get_message_from_editor(gchar* message, gchar** returned_message); /* * Take a line of input and process it, return TRUE if profanity is to @@ -4099,7 +4098,7 @@ cmd_subject(ProfWin* window, const char* const command, gchar** args) gchar* message = NULL; char* subject = muc_subject(mucwin->roomjid); - if (_get_message_from_editor(subject, &message)) { + if (get_message_from_editor(subject, &message)) { return TRUE; } @@ -9455,7 +9454,7 @@ cmd_change_password(ProfWin* window, const char* const command, gchar** args) // Returns true if an error occurred gboolean -_get_message_from_editor(gchar* message, gchar** returned_message) +get_message_from_editor(gchar* message, gchar** returned_message) { // create editor dir if not present char* jid = connection_get_barejid(); @@ -9548,7 +9547,7 @@ cmd_editor(ProfWin* window, const char* const command, gchar** args) gchar* message = NULL; - if (_get_message_from_editor(NULL, &message)) { + if (get_message_from_editor(NULL, &message)) { return TRUE; } @@ -9571,7 +9570,7 @@ cmd_correct_editor(ProfWin* window, const char* const command, gchar** args) gchar* initial_message = win_get_last_sent_message(window); gchar* message = NULL; - if (_get_message_from_editor(initial_message, &message)) { + if (get_message_from_editor(initial_message, &message)) { return TRUE; } diff --git a/src/command/cmd_funcs.h b/src/command/cmd_funcs.h index f4cbe0bf..e1d5c4f7 100644 --- a/src/command/cmd_funcs.h +++ b/src/command/cmd_funcs.h @@ -250,5 +250,6 @@ gboolean cmd_correct_editor(ProfWin* window, const char* const command, gchar** gboolean cmd_silence(ProfWin* window, const char* const command, gchar** args); gboolean cmd_register(ProfWin* window, const char* const command, gchar** args); gboolean cmd_mood(ProfWin* window, const char* const command, gchar** args); +gboolean get_message_from_editor(gchar* message, gchar** returned_message); #endif diff --git a/src/ui/inputwin.c b/src/ui/inputwin.c index 4ea773c8..6972bc33 100644 --- a/src/ui/inputwin.c +++ b/src/ui/inputwin.c @@ -60,6 +60,7 @@ #include "log.h" #include "common.h" #include "command/cmd_ac.h" +#include "command/cmd_funcs.h" #include "config/files.h" #include "config/accounts.h" #include "config/preferences.h" @@ -133,6 +134,7 @@ static int _inp_rl_subwin_pageup_handler(int count, int key); static int _inp_rl_subwin_pagedown_handler(int count, int key); static int _inp_rl_startup_hook(void); static int _inp_rl_down_arrow_handler(int count, int key); +static int _inp_rl_send_to_editor(int count, int key); void create_input_window(void) @@ -434,6 +436,7 @@ _inp_rl_addfuncs(void) rl_add_funmap_entry("prof_subwin_pagedown", _inp_rl_subwin_pagedown_handler); rl_add_funmap_entry("prof_win_clear", _inp_rl_win_clear_handler); rl_add_funmap_entry("prof_win_close", _inp_rl_win_close_handler); + rl_add_funmap_entry("prof_send_to_editor", _inp_rl_send_to_editor); } // Readline callbacks @@ -484,6 +487,7 @@ _inp_rl_startup_hook(void) rl_bind_keyseq("\\ea", _inp_rl_win_next_unread_handler); rl_bind_keyseq("\\ev", _inp_rl_win_attention_handler); rl_bind_keyseq("\\em", _inp_rl_win_attention_next_handler); + rl_bind_keyseq("\\ed", _inp_rl_send_to_editor); rl_bind_keyseq("\\e\\e[5~", _inp_rl_subwin_pageup_handler); rl_bind_keyseq("\\e[5;3~", _inp_rl_subwin_pageup_handler); @@ -877,3 +881,25 @@ _inp_rl_down_arrow_handler(int count, int key) rl_redisplay(); return 0; } + +static int +_inp_rl_send_to_editor(int count, int key) +{ + if (rl_point != rl_end || !rl_line_buffer) { + return 0; + } + + gchar* message = NULL; + + if (get_message_from_editor(rl_line_buffer, &message)) { + return TRUE; + } + + rl_replace_line(message, 0); + ui_resize(); + rl_point = rl_end; + rl_forced_update_display(); + g_free(message); + + return 0; +}