mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Add /subject editor
command
Allow editing the MUC subject using external editor. Use `/subject editor`. Fix https://github.com/profanity-im/profanity/issues/1638
This commit is contained in:
parent
0b8b851bd6
commit
b8711d5627
@ -780,6 +780,7 @@ cmd_ac_init(void)
|
|||||||
subject_ac = autocomplete_new();
|
subject_ac = autocomplete_new();
|
||||||
autocomplete_add(subject_ac, "set");
|
autocomplete_add(subject_ac, "set");
|
||||||
autocomplete_add(subject_ac, "edit");
|
autocomplete_add(subject_ac, "edit");
|
||||||
|
autocomplete_add(subject_ac, "editor");
|
||||||
autocomplete_add(subject_ac, "prepend");
|
autocomplete_add(subject_ac, "prepend");
|
||||||
autocomplete_add(subject_ac, "append");
|
autocomplete_add(subject_ac, "append");
|
||||||
autocomplete_add(subject_ac, "clear");
|
autocomplete_add(subject_ac, "clear");
|
||||||
@ -3656,11 +3657,7 @@ _subject_autocomplete(ProfWin* window, const char* const input, gboolean previou
|
|||||||
char* result = NULL;
|
char* result = NULL;
|
||||||
|
|
||||||
if (window->type == WIN_MUC) {
|
if (window->type == WIN_MUC) {
|
||||||
if ((g_strcmp0(input, "/subject e") == 0)
|
if ((g_strcmp0(input, "/subject edit ") == 0)
|
||||||
|| (g_strcmp0(input, "/subject ed") == 0)
|
|
||||||
|| (g_strcmp0(input, "/subject edi") == 0)
|
|
||||||
|| (g_strcmp0(input, "/subject edit") == 0)
|
|
||||||
|| (g_strcmp0(input, "/subject edit ") == 0)
|
|
||||||
|| (g_strcmp0(input, "/subject edit \"") == 0)) {
|
|| (g_strcmp0(input, "/subject edit \"") == 0)) {
|
||||||
ProfMucWin* mucwin = (ProfMucWin*)window;
|
ProfMucWin* mucwin = (ProfMucWin*)window;
|
||||||
assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK);
|
assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK);
|
||||||
|
@ -676,6 +676,7 @@ static struct cmd_t command_defs[] = {
|
|||||||
CMD_SYN(
|
CMD_SYN(
|
||||||
"/subject set <subject>",
|
"/subject set <subject>",
|
||||||
"/subject edit <subject>",
|
"/subject edit <subject>",
|
||||||
|
"/subject editor",
|
||||||
"/subject prepend <text>",
|
"/subject prepend <text>",
|
||||||
"/subject append <text>",
|
"/subject append <text>",
|
||||||
"/subject clear")
|
"/subject clear")
|
||||||
@ -684,6 +685,7 @@ static struct cmd_t command_defs[] = {
|
|||||||
CMD_ARGS(
|
CMD_ARGS(
|
||||||
{ "set <subject>", "Set the room subject." },
|
{ "set <subject>", "Set the room subject." },
|
||||||
{ "edit <subject>", "Edit the current room subject, tab autocompletion will display the subject to edit." },
|
{ "edit <subject>", "Edit the current room subject, tab autocompletion will display the subject to edit." },
|
||||||
|
{ "editor", "Edit the current room subject in external editor." },
|
||||||
{ "prepend <text>", "Prepend text to the current room subject, use double quotes if a trailing space is needed." },
|
{ "prepend <text>", "Prepend text to the current room subject, use double quotes if a trailing space is needed." },
|
||||||
{ "append <text>", "Append text to the current room subject, use double quotes if a preceding space is needed." },
|
{ "append <text>", "Append text to the current room subject, use double quotes if a preceding space is needed." },
|
||||||
{ "clear", "Clear the room subject." })
|
{ "clear", "Clear the room subject." })
|
||||||
|
@ -122,6 +122,7 @@ 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(ProfWin* window, const char* const command, const char* const inp);
|
||||||
static gboolean _cmd_execute_default(ProfWin* window, const char* inp);
|
static gboolean _cmd_execute_default(ProfWin* window, const char* inp);
|
||||||
static gboolean _cmd_execute_alias(ProfWin* window, const char* const inp, gboolean* ran);
|
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
|
* Take a line of input and process it, return TRUE if profanity is to
|
||||||
@ -4094,6 +4095,22 @@ cmd_subject(ProfWin* window, const char* const command, gchar** args)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (g_strcmp0(args[0], "editor") == 0) {
|
||||||
|
gchar* message = NULL;
|
||||||
|
char* subject = muc_subject(mucwin->roomjid);
|
||||||
|
|
||||||
|
if (_get_message_from_editor(subject, &message)) {
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (message) {
|
||||||
|
message_send_groupchat_subject(mucwin->roomjid, message);
|
||||||
|
} else {
|
||||||
|
cons_bad_cmd_usage(command);
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
if (g_strcmp0(args[0], "prepend") == 0) {
|
if (g_strcmp0(args[0], "prepend") == 0) {
|
||||||
if (args[1]) {
|
if (args[1]) {
|
||||||
char* old_subject = muc_subject(mucwin->roomjid);
|
char* old_subject = muc_subject(mucwin->roomjid);
|
||||||
|
Loading…
Reference in New Issue
Block a user