mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Remove autocomplete for /correct-editor
We decided that it was better to remove autocomplete for this command, since adding it only introduced problems and the command can still function perfectly without autocomplete.
This commit is contained in:
parent
cd16264d2b
commit
6b0f15a1c9
@ -1795,7 +1795,6 @@ _cmd_ac_complete_params(ProfWin* window, const char* const input, gboolean previ
|
|||||||
g_hash_table_insert(ac_funcs, "/avatar", _avatar_autocomplete);
|
g_hash_table_insert(ac_funcs, "/avatar", _avatar_autocomplete);
|
||||||
g_hash_table_insert(ac_funcs, "/correction", _correction_autocomplete);
|
g_hash_table_insert(ac_funcs, "/correction", _correction_autocomplete);
|
||||||
g_hash_table_insert(ac_funcs, "/correct", _correct_autocomplete);
|
g_hash_table_insert(ac_funcs, "/correct", _correct_autocomplete);
|
||||||
g_hash_table_insert(ac_funcs, "/correct-editor", _correct_autocomplete);
|
|
||||||
g_hash_table_insert(ac_funcs, "/software", _software_autocomplete);
|
g_hash_table_insert(ac_funcs, "/software", _software_autocomplete);
|
||||||
g_hash_table_insert(ac_funcs, "/url", _url_autocomplete);
|
g_hash_table_insert(ac_funcs, "/url", _url_autocomplete);
|
||||||
g_hash_table_insert(ac_funcs, "/executable", _executable_autocomplete);
|
g_hash_table_insert(ac_funcs, "/executable", _executable_autocomplete);
|
||||||
@ -4031,6 +4030,17 @@ _correction_autocomplete(ProfWin* window, const char* const input, gboolean prev
|
|||||||
|
|
||||||
static char*
|
static char*
|
||||||
_correct_autocomplete(ProfWin* window, const char* const input, gboolean previous)
|
_correct_autocomplete(ProfWin* window, const char* const input, gboolean previous)
|
||||||
|
{
|
||||||
|
GString* result_str = g_string_new("/correct ");
|
||||||
|
g_string_append(result_str, _get_last_message(window));
|
||||||
|
char* result = result_str->str;
|
||||||
|
g_string_free(result_str, FALSE);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
char*
|
||||||
|
_get_last_message(ProfWin* window)
|
||||||
{
|
{
|
||||||
char* last_message = NULL;
|
char* last_message = NULL;
|
||||||
switch (window->type) {
|
switch (window->type) {
|
||||||
@ -4055,27 +4065,7 @@ _correct_autocomplete(ProfWin* window, const char* const input, gboolean previou
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get command
|
return last_message;
|
||||||
int len = strlen(input);
|
|
||||||
char command[len + 2];
|
|
||||||
int i = 0;
|
|
||||||
while (i < len) {
|
|
||||||
if (input[i] == ' ') {
|
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
command[i] = input[i];
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
command[i] = ' ';
|
|
||||||
command[i + 1] = '\0';
|
|
||||||
|
|
||||||
GString* result_str = g_string_new(command);
|
|
||||||
g_string_append(result_str, last_message);
|
|
||||||
char* result = result_str->str;
|
|
||||||
g_string_free(result_str, FALSE);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static char*
|
static char*
|
||||||
|
@ -59,5 +59,6 @@ void cmd_ac_add_form_fields(DataForm* form);
|
|||||||
void cmd_ac_remove_form_fields(DataForm* form);
|
void cmd_ac_remove_form_fields(DataForm* form);
|
||||||
|
|
||||||
char* cmd_ac_complete_filepath(const char* const input, char* const startstr, gboolean previous);
|
char* cmd_ac_complete_filepath(const char* const input, char* const startstr, gboolean previous);
|
||||||
|
char* _get_last_message(ProfWin* window);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -2623,21 +2623,19 @@ static struct cmd_t command_defs[] = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
{ "/correct-editor",
|
{ "/correct-editor",
|
||||||
parse_args_as_one, 1, 1, NULL,
|
parse_args, 0, 0, NULL,
|
||||||
CMD_NOSUBFUNCS
|
CMD_NOSUBFUNCS
|
||||||
CMD_MAINFUNC(cmd_correct_editor)
|
CMD_MAINFUNC(cmd_correct_editor)
|
||||||
CMD_TAGS(
|
CMD_TAGS(
|
||||||
CMD_TAG_CHAT,
|
CMD_TAG_CHAT,
|
||||||
CMD_TAG_GROUPCHAT)
|
CMD_TAG_GROUPCHAT)
|
||||||
CMD_SYN(
|
CMD_SYN(
|
||||||
"/correct-editor <message>")
|
"/correct-editor")
|
||||||
CMD_DESC(
|
CMD_DESC(
|
||||||
"Spawn external editor to correct and resend the last message (XEP-0308). "
|
"Spawn external editor to correct and resend the last message (XEP-0308). "
|
||||||
"Use tab completion to get the last sent message. "
|
|
||||||
"For more information on how to configure corrections, see: /help correction. "
|
"For more information on how to configure corrections, see: /help correction. "
|
||||||
"Use /executable to set your favourite editor.")
|
"Use /executable to set your favourite editor.")
|
||||||
CMD_ARGS(
|
CMD_NOARGS
|
||||||
{ "message", "The corrected message." })
|
|
||||||
CMD_NOEXAMPLES
|
CMD_NOEXAMPLES
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -9461,7 +9461,7 @@ cmd_change_password(ProfWin* window, const char* const command, gchar** args)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns true if any error occured
|
// Returns true if an error occured
|
||||||
gboolean
|
gboolean
|
||||||
_get_message_from_editor(gchar* message, gchar** returned_message)
|
_get_message_from_editor(gchar* message, gchar** returned_message)
|
||||||
{
|
{
|
||||||
@ -9569,15 +9569,13 @@ cmd_correct_editor(ProfWin* window, const char* const command, gchar** args)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
gchar* initial_message = g_strjoinv(" ", args);
|
gchar* initial_message = _get_last_message(window);
|
||||||
|
|
||||||
gchar* message = NULL;
|
gchar* message = NULL;
|
||||||
if (_get_message_from_editor(initial_message, &message)) {
|
if (_get_message_from_editor(initial_message, &message)) {
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
free(initial_message);
|
|
||||||
|
|
||||||
if (window->type == WIN_CHAT) {
|
if (window->type == WIN_CHAT) {
|
||||||
ProfChatWin* chatwin = (ProfChatWin*)window;
|
ProfChatWin* chatwin = (ProfChatWin*)window;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user