Skip to content

Commit

Permalink
Add unicode support for correction char
Browse files Browse the repository at this point in the history
Commit to allow unicode support in omemo/pgp/otr chars misses
adding support to set correction character.
1f8b1eb

Further fixing commit also misses adding support to set the unicode character,
it only adds ability to display unicode correction character in the settings.
5cf6ee15cf6ee1bc6d0b99b01891bc455a657bf022a72b0
  • Loading branch information
H3rnand3zzz committed Nov 3, 2023
1 parent 11e78e0 commit 8e40ca1
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 16 deletions.
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

0 comments on commit 8e40ca1

Please sign in to comment.