1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

xep-0308: set correction char in config

This commit is contained in:
Michael Vetter 2020-02-10 13:48:31 +01:00
parent 039bf5d04d
commit c2d70a071f
5 changed files with 58 additions and 1 deletions

View File

@ -2365,7 +2365,7 @@ static struct cmd_t command_defs[] =
{ "/correction", { "/correction",
parse_args, 1, 1, &cons_correction_setting, parse_args, 1, 1, &cons_correction_setting,
CMD_NOSUBFUNCS CMD_NOSUBFUNCS
CMD_MAINFUNC(cmd_os) CMD_MAINFUNC(cmd_correction)
CMD_TAGS( CMD_TAGS(
CMD_TAG_CHAT, CMD_TAG_CHAT,
CMD_TAG_GROUPCHAT) CMD_TAG_GROUPCHAT)

View File

@ -8651,3 +8651,30 @@ cmd_os(ProfWin *window, const char *const command, gchar **args)
return TRUE; return TRUE;
} }
gboolean
cmd_correction(ProfWin *window, const char *const command, gchar **args)
{
// enable/disable
if (g_strcmp0(args[0], "on") == 0) {
prefs_set_boolean(PREF_BOOKMARK_INVITE, TRUE);
return TRUE;
} else if (g_strcmp0(args[0], "off") == 0) {
prefs_set_boolean(PREF_BOOKMARK_INVITE, FALSE);
return TRUE;
}
// char
if (g_strcmp(args[0], "char") == 0) {
if (args[1] == NULL) {
cons_bad_cmd_usage(command);
} else if (strlen(args[1]) != 1) {
cons_bad_cmd_usage(command);
} else {
prefs_set_correction_char(args[1][0]);
cons_show("LMC char set to %c.", args[1][0]);
}
}
return TRUE;
}

View File

@ -227,4 +227,5 @@ gboolean cmd_paste(ProfWin *window, const char *const command, gchar **args);
gboolean cmd_color(ProfWin *window, const char *const command, gchar **args); gboolean cmd_color(ProfWin *window, const char *const command, gchar **args);
gboolean cmd_avatar(ProfWin *window, const char *const command, gchar **args); gboolean cmd_avatar(ProfWin *window, const char *const command, gchar **args);
gboolean cmd_os(ProfWin *window, const char *const command, gchar **args); gboolean cmd_os(ProfWin *window, const char *const command, gchar **args);
gboolean cmd_correction(ProfWin *window, const char *const command, gchar **args);
#endif #endif

View File

@ -1201,6 +1201,32 @@ prefs_set_roster_presence_indent(gint value)
g_key_file_set_integer(prefs, PREF_GROUP_UI, "roster.presence.indent", value); g_key_file_set_integer(prefs, PREF_GROUP_UI, "roster.presence.indent", value);
} }
char
prefs_get_correction_char(void)
{
char result = '+';
char *resultstr = g_key_file_get_string(prefs, PREF_GROUP_UI, "correction.char", NULL);
if (!resultstr) {
result = '+';
} else {
result = resultstr[0];
}
free(resultstr);
return result;
}
void
prefs_set_correction_char(char ch)
{
char str[2];
str[0] = ch;
str[1] = '\0';
g_key_file_set_string(prefs, PREF_GROUP_UI, "correction.char", str);
}
gboolean gboolean
prefs_add_room_notify_trigger(const char * const text) prefs_add_room_notify_trigger(const char * const text)
{ {

View File

@ -268,6 +268,9 @@ void prefs_set_roster_presence_indent(gint value);
gint prefs_get_occupants_indent(void); gint prefs_get_occupants_indent(void);
void prefs_set_occupants_indent(gint value); void prefs_set_occupants_indent(gint value);
char prefs_get_correction_char(void);
void prefs_set_correction_char(char ch);
void prefs_add_login(const char *jid); void prefs_add_login(const char *jid);
void prefs_set_tray_timer(gint value); void prefs_set_tray_timer(gint value);