aboutsummaryrefslogtreecommitdiffstats
path: root/root_commands.c
diff options
context:
space:
mode:
authorMarius Halden <marius.h@lden.org>2016-10-18 09:16:49 +0200
committerMarius Halden <marius.h@lden.org>2016-10-18 09:16:49 +0200
commit0ecf67ec71df1c119308d6501e6fc54df3ba10d2 (patch)
tree8ad0a47ffaa1e76786bd7947de18036287850b3c /root_commands.c
parentbfce290626ae7b771f8dafdc1e0c77279ce16fc8 (diff)
Align utf8 nicks in blist
Diffstat (limited to 'root_commands.c')
-rw-r--r--root_commands.c30
1 files changed, 24 insertions, 6 deletions
diff --git a/root_commands.c b/root_commands.c
index 6ec2f179..fde84527 100644
--- a/root_commands.c
+++ b/root_commands.c
@@ -1034,6 +1034,8 @@ static void cmd_set(irc_t *irc, char **cmd)
cmd_set_real(irc, cmd, &irc->b->set, NULL);
}
+#define BLIST_NICK_MAXLEN 16
+
static void cmd_blist(irc_t *irc, char **cmd)
{
int online = 0, away = 0, offline = 0, ismatch = 0;
@@ -1042,7 +1044,8 @@ static void cmd_blist(irc_t *irc, char **cmd)
GError *error = NULL;
char s[256];
char *format;
- int n_online = 0, n_away = 0, n_offline = 0;
+ char *padded;
+ int n_online = 0, n_away = 0, n_offline = 0, b_mode = 0;
if (cmd[1] && g_strcasecmp(cmd[1], "all") == 0) {
online = offline = away = 1;
@@ -1067,11 +1070,14 @@ static void cmd_blist(irc_t *irc, char **cmd)
if (strchr(irc->umode, 'b') != NULL) {
format = "%s\t%s\t%s";
+ b_mode = 1;
} else {
- format = "%-16.16s %-40.40s %s";
+ format = "%s %-40.40s %s";
}
- irc_rootmsg(irc, format, "Nick", "Handle/Account", "Status");
+ padded = b_mode ? g_strdup("Nick") : str_pad_and_truncate("Nick", BLIST_NICK_MAXLEN, NULL);
+ irc_rootmsg(irc, format, padded, "Handle/Account", "Status");
+ g_free(padded);
if (irc->root->last_channel &&
strcmp(set_getstr(&irc->root->last_channel->set, "type"), "control") != 0) {
@@ -1101,7 +1107,11 @@ static void cmd_blist(irc_t *irc, char **cmd)
}
g_snprintf(s, sizeof(s) - 1, "%s %s", bu->handle, bu->ic->acc->tag);
- irc_rootmsg(irc, format, iu->nick, s, st);
+
+ padded = b_mode ? g_strdup(iu->nick) : str_pad_and_truncate(iu->nick, BLIST_NICK_MAXLEN, NULL);
+ irc_rootmsg(irc, format, padded, s, st);
+
+ g_free(padded);
}
n_online++;
@@ -1110,7 +1120,11 @@ static void cmd_blist(irc_t *irc, char **cmd)
if ((bu->flags & BEE_USER_ONLINE) && (bu->flags & BEE_USER_AWAY)) {
if (ismatch == 1 && away == 1) {
g_snprintf(s, sizeof(s) - 1, "%s %s", bu->handle, bu->ic->acc->tag);
- irc_rootmsg(irc, format, iu->nick, s, irc_user_get_away(iu));
+
+ padded = b_mode ? g_strdup(iu->nick) : str_pad_and_truncate(iu->nick, BLIST_NICK_MAXLEN, NULL);
+ irc_rootmsg(irc, format, padded, s, irc_user_get_away(iu));
+
+ g_free(padded);
}
n_away++;
}
@@ -1118,7 +1132,11 @@ static void cmd_blist(irc_t *irc, char **cmd)
if (!(bu->flags & BEE_USER_ONLINE)) {
if (ismatch == 1 && offline == 1) {
g_snprintf(s, sizeof(s) - 1, "%s %s", bu->handle, bu->ic->acc->tag);
- irc_rootmsg(irc, format, iu->nick, s, "Offline");
+
+ padded = b_mode ? g_strdup(iu->nick) : str_pad_and_truncate(iu->nick, BLIST_NICK_MAXLEN, NULL);
+ irc_rootmsg(irc, format, padded, s, "Offline");
+
+ g_free(padded);
}
n_offline++;
}