mirror of
https://github.com/irssi/irssi.git
synced 2024-10-27 05:20:20 -04:00
/SET names_max_columns, /SET names_max_width: Limit width of /NAMES list.
Forced max. 6 columns limit to /HELP git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1199 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
parent
0de0499fd8
commit
194dd60f36
@ -609,13 +609,14 @@ char *my_asctime(time_t t)
|
||||
/* Returns number of columns needed to print items.
|
||||
save_column_widths is filled with length of each column. */
|
||||
int get_max_column_count(GSList *items, COLUMN_LEN_FUNC len_func,
|
||||
int max_width, int item_extra, int item_min_size,
|
||||
int max_width, int max_columns,
|
||||
int item_extra, int item_min_size,
|
||||
int **save_column_widths, int *rows)
|
||||
{
|
||||
GSList *tmp;
|
||||
int **columns, *columns_width, *columns_rows;
|
||||
int item_pos, items_count;
|
||||
int ret, len, n, col, max_columns;
|
||||
int ret, len, n, col;
|
||||
|
||||
items_count = g_slist_length(items);
|
||||
if (items_count == 0) {
|
||||
@ -624,7 +625,10 @@ int get_max_column_count(GSList *items, COLUMN_LEN_FUNC len_func,
|
||||
return 0;
|
||||
}
|
||||
|
||||
max_columns = max_width/(item_extra+item_min_size);
|
||||
len = max_width/(item_extra+item_min_size);
|
||||
if (max_columns <= 0 || len < max_columns)
|
||||
max_columns = len;
|
||||
|
||||
columns = g_new0(int *, max_columns);
|
||||
columns_width = g_new0(int, max_columns);
|
||||
columns_rows = g_new0(int, max_columns);
|
||||
|
@ -78,7 +78,8 @@ char *my_asctime(time_t t);
|
||||
/* Returns number of columns needed to print items.
|
||||
save_column_widths is filled with length of each column. */
|
||||
int get_max_column_count(GSList *items, COLUMN_LEN_FUNC len_func,
|
||||
int max_width, int item_extra, int item_min_size,
|
||||
int max_width, int max_columns,
|
||||
int item_extra, int item_min_size,
|
||||
int **save_column_widths, int *rows);
|
||||
|
||||
/* Return a column sorted copy of a list. */
|
||||
|
@ -329,8 +329,13 @@ static void display_sorted_nicks(CHANNEL_REC *channel, GSList *nicklist)
|
||||
g_free(format);
|
||||
}
|
||||
|
||||
/* calculate columns */
|
||||
/* calculate columns */
|
||||
if (settings_get_int("names_max_width") > 0 &&
|
||||
max_width > settings_get_int("names_max_width"))
|
||||
max_width = settings_get_int("names_max_width");
|
||||
|
||||
cols = get_max_column_count(nicklist, get_nick_length, max_width,
|
||||
settings_get_int("names_max_columns"),
|
||||
item_extra, 3, &columns, &rows);
|
||||
nicklist = columns_sort_list(nicklist, rows);
|
||||
|
||||
@ -442,6 +447,8 @@ static void cmd_names(const char *data, SERVER_REC *server, WI_ITEM_REC *item)
|
||||
void fe_channels_init(void)
|
||||
{
|
||||
settings_add_bool("lookandfeel", "autoclose_windows", TRUE);
|
||||
settings_add_int("lookandfeel", "names_max_columns", 6);
|
||||
settings_add_int("lookandfeel", "names_max_width", 0);
|
||||
|
||||
signal_add("channel created", (SIGNAL_FUNC) signal_channel_created);
|
||||
signal_add("channel destroyed", (SIGNAL_FUNC) signal_channel_destroyed);
|
||||
|
@ -96,7 +96,7 @@ static void help_category(GSList *cmdlist, int items)
|
||||
|
||||
/* calculate columns */
|
||||
cols = get_max_column_count(cmdlist, get_cmd_length,
|
||||
max_width, 1, 3, &columns, &rows);
|
||||
max_width, 6, 1, 3, &columns, &rows);
|
||||
cmdlist = columns_sort_list(cmdlist, rows);
|
||||
|
||||
/* rows in last column */
|
||||
|
Loading…
Reference in New Issue
Block a user