Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add unicode support for correction char #1909

Merged
merged 1 commit into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions src/command/cmd_funcs.c
Original file line number Diff line number Diff line change
Expand Up @@ -9329,7 +9329,6 @@ cmd_os(ProfWin* window, const char* const command, gchar** args)
gboolean
cmd_correction(ProfWin* window, const char* const command, gchar** args)
{
// enable/disable
if (g_strcmp0(args[0], "on") == 0) {
_cmd_set_boolean_preference(args[0], "Last Message Correction", PREF_CORRECTION_ALLOW);
caps_add_feature(XMPP_FEATURE_LAST_MESSAGE_CORRECTION);
Expand All @@ -9340,15 +9339,12 @@ cmd_correction(ProfWin* window, const char* const command, gchar** args)
return TRUE;
}

// char
if (g_strcmp0(args[0], "char") == 0) {
if (args[1] == NULL) {
cons_bad_cmd_usage(command);
} else if (strlen(args[1]) != 1) {
if (args[1] == NULL || g_utf8_strlen(args[1], 4) != 1) {
cons_bad_cmd_usage(command);
} else {
prefs_set_correction_char(args[1][0]);
cons_show("LMC char set to %c.", args[1][0]);
prefs_set_correction_char(args[1]);
cons_show("LMC char set to %s.", args[1]);
}
}

Expand Down
12 changes: 6 additions & 6 deletions src/config/preferences.c
Original file line number Diff line number Diff line change
Expand Up @@ -1281,13 +1281,13 @@ prefs_get_correction_char(void)
}

void
prefs_set_correction_char(char ch)
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);
if (g_utf8_strlen(ch, 4) == 1) {
g_key_file_set_string(prefs, PREF_GROUP_UI, "correction.char", ch);
} else {
log_error("Could not set correction char: %s", ch);
}
}

gboolean
Expand Down
2 changes: 1 addition & 1 deletion src/config/preferences.h
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ gint prefs_get_occupants_indent(void);
void prefs_set_occupants_indent(gint value);

gchar* prefs_get_correction_char(void);
void prefs_set_correction_char(char ch);
void prefs_set_correction_char(char* ch);

void prefs_add_login(const char* jid);

Expand Down
4 changes: 2 additions & 2 deletions src/config/theme.c
Original file line number Diff line number Diff line change
Expand Up @@ -484,8 +484,8 @@ _load_preferences(void)

if (g_key_file_has_key(theme, "ui", "correction.char", NULL)) {
auto_gchar gchar* ch = g_key_file_get_string(theme, "ui", "correction.char", NULL);
if (ch && strlen(ch) > 0) {
prefs_set_correction_char(ch[0]);
if (ch && g_utf8_strlen(ch, 4) == 1) {
prefs_set_correction_char(ch);
}
}

Expand Down
Loading