From a02c89a8e8f6abe8935f6cf95e0b016d1ac40a34 Mon Sep 17 00:00:00 2001 From: James Booth Date: Sat, 19 Dec 2015 23:21:07 +0000 Subject: [PATCH 1/2] Use MB_CUR_MAX when calculating cursor position --- src/ui/inputwin.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ui/inputwin.c b/src/ui/inputwin.c index a6711bab..d5643f76 100644 --- a/src/ui/inputwin.c +++ b/src/ui/inputwin.c @@ -311,7 +311,7 @@ _inp_offset_to_col(char *str, int offset) while (i < offset && str[i] != '\0') { gunichar uni = g_utf8_get_char(&str[i]); - size_t ch_len = mbrlen(&str[i], 4, NULL); + size_t ch_len = mbrlen(&str[i], MB_CUR_MAX, NULL); i += ch_len; col++; if (g_unichar_iswide(uni)) { From 8f6b37f650aaf9c2f59cae401ee3ce9a063072cd Mon Sep 17 00:00:00 2001 From: James Booth Date: Sat, 19 Dec 2015 23:32:58 +0000 Subject: [PATCH 2/2] Added /charset command --- src/command/command.c | 12 ++++++++++++ src/command/commands.c | 21 +++++++++++++++++++++ src/command/commands.h | 1 + 3 files changed, 34 insertions(+) diff --git a/src/command/command.c b/src/command/command.c index 5745e5cb..72c0c42c 100644 --- a/src/command/command.c +++ b/src/command/command.c @@ -945,6 +945,18 @@ static struct cmd_t command_defs[] = CMD_NOEXAMPLES }, + { "/charset", + cmd_charset, parse_args, 0, 0, NULL, + CMD_TAGS( + CMD_TAG_UI) + CMD_SYN( + "/beep") + CMD_DESC( + "Display information about the current character set supported by the terminal. ") + CMD_NOARGS + CMD_NOEXAMPLES + }, + { "/beep", cmd_beep, parse_args, 1, 1, &cons_beep_setting, CMD_TAGS( diff --git a/src/command/commands.c b/src/command/commands.c index 53f06b95..d3a648ac 100644 --- a/src/command/commands.c +++ b/src/command/commands.c @@ -43,6 +43,7 @@ #include #include #include +#include #include "chat_session.h" #include "command/commands.h" @@ -4007,6 +4008,26 @@ cmd_privileges(ProfWin *window, const char *const command, gchar **args) return result; } +gboolean +cmd_charset(ProfWin *window, const char *const command, gchar **args) +{ + char *codeset = nl_langinfo(CODESET); + char *lang = getenv("LANG"); + + cons_show("Charset information:"); + + if (lang) { + cons_show(" LANG: %s", lang); + } + if (codeset) { + cons_show(" CODESET: %s", codeset); + } + cons_show(" MB_CUR_MAX: %d", MB_CUR_MAX); + cons_show(" MB_LEN_MAX: %d", MB_LEN_MAX); + + return TRUE; +} + gboolean cmd_beep(ProfWin *window, const char *const command, gchar **args) { diff --git a/src/command/commands.h b/src/command/commands.h index 501046d4..76794f71 100644 --- a/src/command/commands.h +++ b/src/command/commands.h @@ -151,6 +151,7 @@ gboolean cmd_inpblock(ProfWin *window, const char *const command, gchar **args); gboolean cmd_encwarn(ProfWin *window, const char *const command, gchar **args); gboolean cmd_script(ProfWin *window, const char *const command, gchar **args); gboolean cmd_export(ProfWin *window, const char *const command, gchar **args); +gboolean cmd_charset(ProfWin *window, const char *const command, gchar **args); gboolean cmd_form_field(ProfWin *window, char *tag, gchar **args);