1
0
mirror of https://github.com/irssi/irssi.git synced 2024-11-03 04:27:19 -05:00

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
This commit is contained in:
Timo Sirainen 2001-11-20 03:11:02 +00:00 committed by cras
parent 9cf8d32198
commit 7bdd1cbec9
4 changed files with 19 additions and 3 deletions

View File

@ -217,6 +217,7 @@ abstracts = {
netjoin = "%C$*%n"; netjoin = "%C$*%n";
# /names list # /names list
names_prefix = "";
names_nick = "[%_$0%_$1-] "; names_nick = "[%_$0%_$1-] ";
names_nick_op = "{names_nick $*}"; names_nick_op = "{names_nick $*}";
names_nick_halfop = "{names_nick $*}"; names_nick_halfop = "{names_nick $*}";

View File

@ -329,7 +329,7 @@ static void display_sorted_nicks(CHANNEL_REC *channel, GSList *nicklist)
TEXT_DEST_REC dest; TEXT_DEST_REC dest;
GString *str; GString *str;
GSList *tmp; GSList *tmp;
char *format, *stripped; char *format, *stripped, *prefix_format;
char *linebuf, nickmode[2] = { 0, 0 }; char *linebuf, nickmode[2] = { 0, 0 };
int *columns, cols, rows, last_col_rows, col, row, max_width; int *columns, cols, rows, last_col_rows, col, row, max_width;
int item_extra, linebuf_size, formatnum; 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"))
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, format_create_dest(&dest, channel->server, channel->name,
MSGLEVEL_CLIENTCRAP, NULL); MSGLEVEL_CLIENTCRAP, NULL);
format = format_get_line_start(current_theme, &dest, time(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); 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 */ /* calculate columns */
cols = get_max_column_count(nicklist, get_nick_length, max_width, cols = get_max_column_count(nicklist, get_nick_length, max_width,
settings_get_int("names_max_columns"), 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) if (last_col_rows == 0)
last_col_rows = rows; 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); linebuf_size = max_width+1; linebuf = g_malloc(linebuf_size);
col = 0; row = 0; col = 0; row = 0;
@ -404,6 +414,8 @@ static void display_sorted_nicks(CHANNEL_REC *channel, GSList *nicklist)
printtext(channel->server, channel->name, printtext(channel->server, channel->name,
MSGLEVEL_CLIENTCRAP, "%s", str->str); MSGLEVEL_CLIENTCRAP, "%s", str->str);
g_string_truncate(str, 0); g_string_truncate(str, 0);
if (prefix_format != NULL)
g_string_assign(str, prefix_format);
col = 0; row++; col = 0; row++;
if (row == last_col_rows) if (row == last_col_rows)
@ -419,6 +431,7 @@ static void display_sorted_nicks(CHANNEL_REC *channel, GSList *nicklist)
g_slist_free(nicklist); g_slist_free(nicklist);
g_string_free(str, TRUE); g_string_free(str, TRUE);
g_free_not_null(columns); g_free_not_null(columns);
g_free_not_null(prefix_format);
g_free(linebuf); g_free(linebuf);
} }

View File

@ -102,6 +102,7 @@ FORMAT_REC fecommon_core_formats[] = {
{ "not_in_channels", "You are not on any channels", 0 }, { "not_in_channels", "You are not on any channels", 0 },
{ "current_channel", "Current channel {channel $0}", 1, { 0 } }, { "current_channel", "Current channel {channel $0}", 1, { 0 } },
{ "names", "{names_users Users {names_channel $0}} $1", 2, { 0, 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_op", "{names_nick_op $0 $1}", 2, { 0, 0 } },
{ "names_nick_halfop", "{names_nick_halfop $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 } }, { "names_nick_voice", "{names_nick_voice $0 $1}", 2, { 0, 0 } },

View File

@ -78,6 +78,7 @@ enum {
TXT_NOT_IN_CHANNELS, TXT_NOT_IN_CHANNELS,
TXT_CURRENT_CHANNEL, TXT_CURRENT_CHANNEL,
TXT_NAMES, TXT_NAMES,
TXT_NAMES_PREFIX,
TXT_NAMES_NICK_OP, TXT_NAMES_NICK_OP,
TXT_NAMES_NICK_HALFOP, TXT_NAMES_NICK_HALFOP,
TXT_NAMES_NICK_VOICE, TXT_NAMES_NICK_VOICE,