mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
xep-0308: add correction
autocompletion
This commit is contained in:
parent
f16d56a15e
commit
039bf5d04d
@ -113,6 +113,7 @@ static char* _status_autocomplete(ProfWin *window, const char *const input, gboo
|
||||
static char* _logging_autocomplete(ProfWin *window, const char *const input, gboolean previous);
|
||||
static char* _color_autocomplete(ProfWin *window, const char *const input, gboolean previous);
|
||||
static char* _avatar_autocomplete(ProfWin *window, const char *const input, gboolean previous);
|
||||
static char* _correction_autocomplete(ProfWin *window, const char *const input, gboolean previous);
|
||||
|
||||
static char* _script_autocomplete_func(const char *const prefix, gboolean previous, void *context);
|
||||
|
||||
@ -234,6 +235,7 @@ static Autocomplete status_ac;
|
||||
static Autocomplete status_state_ac;
|
||||
static Autocomplete logging_ac;
|
||||
static Autocomplete color_ac;
|
||||
static Autocomplete correction_ac;
|
||||
|
||||
void
|
||||
cmd_ac_init(void)
|
||||
@ -928,6 +930,11 @@ cmd_ac_init(void)
|
||||
autocomplete_add(color_ac, "off");
|
||||
autocomplete_add(color_ac, "redgreen");
|
||||
autocomplete_add(color_ac, "blue");
|
||||
|
||||
correction_ac = autocomplete_new();
|
||||
autocomplete_add(correction_ac, "on");
|
||||
autocomplete_add(correction_ac, "off");
|
||||
autocomplete_add(correction_ac, "char");
|
||||
}
|
||||
|
||||
void
|
||||
@ -1233,6 +1240,7 @@ cmd_ac_reset(ProfWin *window)
|
||||
autocomplete_reset(status_state_ac);
|
||||
autocomplete_reset(logging_ac);
|
||||
autocomplete_reset(color_ac);
|
||||
autocomplete_reset(correction_ac);
|
||||
|
||||
autocomplete_reset(script_ac);
|
||||
if (script_show_ac) {
|
||||
@ -1380,6 +1388,7 @@ cmd_ac_uninit(void)
|
||||
autocomplete_free(status_state_ac);
|
||||
autocomplete_free(logging_ac);
|
||||
autocomplete_free(color_ac);
|
||||
autocomplete_free(correction_ac);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1630,6 +1639,7 @@ _cmd_ac_complete_params(ProfWin *window, const char *const input, gboolean previ
|
||||
g_hash_table_insert(ac_funcs, "/logging", _logging_autocomplete);
|
||||
g_hash_table_insert(ac_funcs, "/color", _color_autocomplete);
|
||||
g_hash_table_insert(ac_funcs, "/avatar", _avatar_autocomplete);
|
||||
g_hash_table_insert(ac_funcs, "/correction", _correction_autocomplete);
|
||||
|
||||
int len = strlen(input);
|
||||
char parsed[len+1];
|
||||
@ -3713,3 +3723,16 @@ _avatar_autocomplete(ProfWin *window, const char *const input, gboolean previous
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static char*
|
||||
_correction_autocomplete(ProfWin *window, const char *const input, gboolean previous)
|
||||
{
|
||||
char *result = NULL;
|
||||
|
||||
result = autocomplete_param_with_ac(input, "/correction", correction_ac, TRUE, previous);
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
@ -2361,6 +2361,24 @@ static struct cmd_t command_defs[] =
|
||||
{ "on|off", ""})
|
||||
CMD_NOEXAMPLES
|
||||
},
|
||||
|
||||
{ "/correction",
|
||||
parse_args, 1, 1, &cons_correction_setting,
|
||||
CMD_NOSUBFUNCS
|
||||
CMD_MAINFUNC(cmd_os)
|
||||
CMD_TAGS(
|
||||
CMD_TAG_CHAT,
|
||||
CMD_TAG_GROUPCHAT)
|
||||
CMD_SYN(
|
||||
"/correction <on>|<off>",
|
||||
"/correction char <char>")
|
||||
CMD_DESC(
|
||||
"Settings regarding Last Message Correction (XEP-0308).")
|
||||
CMD_ARGS(
|
||||
{ "on|off", "Enable/Disable support for last message correction."},
|
||||
{ "char", "Set character that will prefix corrected messages. Default: +"})
|
||||
CMD_NOEXAMPLES
|
||||
},
|
||||
};
|
||||
|
||||
static GHashTable *search_index;
|
||||
|
@ -2021,6 +2021,12 @@ cons_os_setting(void)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
cons_correction_setting(void)
|
||||
{
|
||||
cons_show("TODO");
|
||||
}
|
||||
|
||||
void
|
||||
cons_show_connection_prefs(void)
|
||||
{
|
||||
|
@ -319,6 +319,7 @@ void cons_statusbar_setting(void);
|
||||
void cons_winpos_setting(void);
|
||||
void cons_color_setting(void);
|
||||
void cons_os_setting(void);
|
||||
void cons_correction_setting(void);
|
||||
void cons_show_contact_online(PContact contact, Resource *resource, GDateTime *last_activity);
|
||||
void cons_show_contact_offline(PContact contact, char *resource, char *status);
|
||||
void cons_theme_properties(void);
|
||||
|
Loading…
Reference in New Issue
Block a user