From 7bdd1cbec9cb030a0a41a5414d24a8cb707a2748 Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Tue, 20 Nov 2001 03:11:02 +0000 Subject: [PATCH] Added /FORMAT names_prefix to print prefix at the beginning of each /NAMES list line. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@2121 dbcabf3a-b0e7-0310-adc4-f8d773084564 --- default.theme | 1 + src/fe-common/core/fe-channels.c | 19 ++++++++++++++++--- src/fe-common/core/module-formats.c | 1 + src/fe-common/core/module-formats.h | 1 + 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/default.theme b/default.theme index f4de16c6..97c2fa7f 100644 --- a/default.theme +++ b/default.theme @@ -217,6 +217,7 @@ abstracts = { netjoin = "%C$*%n"; # /names list + names_prefix = ""; names_nick = "[%_$0%_$1-] "; names_nick_op = "{names_nick $*}"; names_nick_halfop = "{names_nick $*}"; diff --git a/src/fe-common/core/fe-channels.c b/src/fe-common/core/fe-channels.c index b430c3f6..3813534b 100644 --- a/src/fe-common/core/fe-channels.c +++ b/src/fe-common/core/fe-channels.c @@ -329,7 +329,7 @@ static void display_sorted_nicks(CHANNEL_REC *channel, GSList *nicklist) TEXT_DEST_REC dest; GString *str; GSList *tmp; - char *format, *stripped; + char *format, *stripped, *prefix_format; char *linebuf, nickmode[2] = { 0, 0 }; int *columns, cols, rows, last_col_rows, col, row, max_width; int item_extra, linebuf_size, formatnum; @@ -351,7 +351,7 @@ static void display_sorted_nicks(CHANNEL_REC *channel, GSList *nicklist) max_width > settings_get_int("names_max_width")) max_width = settings_get_int("names_max_width"); - /* remove width of timestamp from max_width */ + /* remove width of the timestamp from max_width */ format_create_dest(&dest, channel->server, channel->name, MSGLEVEL_CLIENTCRAP, NULL); format = format_get_line_start(current_theme, &dest, time(NULL)); @@ -362,6 +362,16 @@ static void display_sorted_nicks(CHANNEL_REC *channel, GSList *nicklist) g_free(format); } + /* remove width of the prefix from max_width */ + prefix_format = format_get_text(MODULE_NAME, NULL, + channel->server, channel->name, + TXT_NAMES_PREFIX, channel->name); + if (prefix_format != NULL) { + stripped = strip_codes(prefix_format); + max_width -= strlen(stripped); + g_free(stripped); + } + /* calculate columns */ cols = get_max_column_count(nicklist, get_nick_length, max_width, settings_get_int("names_max_columns"), @@ -373,7 +383,7 @@ static void display_sorted_nicks(CHANNEL_REC *channel, GSList *nicklist) if (last_col_rows == 0) last_col_rows = rows; - str = g_string_new(NULL); + str = g_string_new(prefix_format); linebuf_size = max_width+1; linebuf = g_malloc(linebuf_size); col = 0; row = 0; @@ -404,6 +414,8 @@ static void display_sorted_nicks(CHANNEL_REC *channel, GSList *nicklist) printtext(channel->server, channel->name, MSGLEVEL_CLIENTCRAP, "%s", str->str); g_string_truncate(str, 0); + if (prefix_format != NULL) + g_string_assign(str, prefix_format); col = 0; row++; if (row == last_col_rows) @@ -419,6 +431,7 @@ static void display_sorted_nicks(CHANNEL_REC *channel, GSList *nicklist) g_slist_free(nicklist); g_string_free(str, TRUE); g_free_not_null(columns); + g_free_not_null(prefix_format); g_free(linebuf); } diff --git a/src/fe-common/core/module-formats.c b/src/fe-common/core/module-formats.c index 480c705c..e98889a4 100644 --- a/src/fe-common/core/module-formats.c +++ b/src/fe-common/core/module-formats.c @@ -102,6 +102,7 @@ FORMAT_REC fecommon_core_formats[] = { { "not_in_channels", "You are not on any channels", 0 }, { "current_channel", "Current channel {channel $0}", 1, { 0 } }, { "names", "{names_users Users {names_channel $0}} $1", 2, { 0, 0 } }, + { "names_prefix", "{names_prefix $0}", 1, { 0 } }, { "names_nick_op", "{names_nick_op $0 $1}", 2, { 0, 0 } }, { "names_nick_halfop", "{names_nick_halfop $0 $1}", 2, { 0, 0 } }, { "names_nick_voice", "{names_nick_voice $0 $1}", 2, { 0, 0 } }, diff --git a/src/fe-common/core/module-formats.h b/src/fe-common/core/module-formats.h index db07b2f8..2b25530f 100644 --- a/src/fe-common/core/module-formats.h +++ b/src/fe-common/core/module-formats.h @@ -78,6 +78,7 @@ enum { TXT_NOT_IN_CHANNELS, TXT_CURRENT_CHANNEL, TXT_NAMES, + TXT_NAMES_PREFIX, TXT_NAMES_NICK_OP, TXT_NAMES_NICK_HALFOP, TXT_NAMES_NICK_VOICE,