mirror of
https://github.com/weechat/weechat.git
synced 2026-06-28 05:46:38 +02:00
Added nicks count for channel buffers
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
WeeChat - Wee Enhanced Environment for Chat
|
||||
===========================================
|
||||
|
||||
ChangeLog - 2005-03-14
|
||||
ChangeLog - 2005-03-15
|
||||
|
||||
|
||||
Version 0.1.1 (under dev!):
|
||||
* added nicks count for channel buffers
|
||||
* added FIFO pipe for remote control
|
||||
* added crash dump when WeeChat receives SIGSEGV (Segmentation fault)
|
||||
* added new display engine: doesn't cut words at end of lines
|
||||
|
||||
@@ -1027,8 +1027,8 @@ gui_draw_buffer_status (t_gui_buffer *buffer, int erase)
|
||||
{
|
||||
t_gui_window *ptr_win;
|
||||
t_weechat_hotlist *ptr_hotlist;
|
||||
char format_more[32], *string;
|
||||
int i, first_mode;
|
||||
char format_more[32], str_nicks[32], *string;
|
||||
int i, first_mode, x;
|
||||
|
||||
/* make gcc happy */
|
||||
(void) buffer;
|
||||
@@ -1262,20 +1262,39 @@ gui_draw_buffer_status (t_gui_buffer *buffer, int erase)
|
||||
}
|
||||
}
|
||||
|
||||
/* display "-MORE-" if last line is not displayed */
|
||||
gui_window_set_color (ptr_win->win_status, COLOR_WIN_STATUS_MORE);
|
||||
/* display "-MORE-" (if last line is not displayed) & nicks count */
|
||||
if (gui_buffer_has_nicklist (ptr_win->buffer))
|
||||
{
|
||||
snprintf (str_nicks, sizeof (str_nicks) - 1, "%d", CHANNEL(ptr_win->buffer)->nicks_count);
|
||||
x = ptr_win->win_width - strlen (str_nicks) - 4;
|
||||
}
|
||||
else
|
||||
x = ptr_win->win_width;
|
||||
string = weechat_convert_encoding (cfg_look_charset_decode,
|
||||
(cfg_look_charset_internal && cfg_look_charset_internal[0]) ?
|
||||
cfg_look_charset_internal : local_charset,
|
||||
_("-MORE-"));
|
||||
x -= strlen (string) - 1;
|
||||
if (x < 0)
|
||||
x = 0;
|
||||
gui_window_set_color (ptr_win->win_status, COLOR_WIN_STATUS_MORE);
|
||||
if (ptr_win->sub_lines > 0)
|
||||
mvwprintw (ptr_win->win_status, 0, ptr_win->win_width - 7,
|
||||
"%s", string);
|
||||
mvwprintw (ptr_win->win_status, 0, x, "%s", string);
|
||||
else
|
||||
{
|
||||
snprintf (format_more, 32, "%%-%ds", strlen (string));
|
||||
mvwprintw (ptr_win->win_status, 0, ptr_win->win_width - 7,
|
||||
format_more, " ");
|
||||
snprintf (format_more, sizeof (format_more) - 1, "%%-%ds", strlen (string));
|
||||
mvwprintw (ptr_win->win_status, 0, x, format_more, " ");
|
||||
}
|
||||
if (gui_buffer_has_nicklist (ptr_win->buffer))
|
||||
{
|
||||
gui_window_set_color (ptr_win->win_status,
|
||||
COLOR_WIN_STATUS_DELIMITERS);
|
||||
wprintw (ptr_win->win_status, " [");
|
||||
gui_window_set_color (ptr_win->win_status, COLOR_WIN_STATUS);
|
||||
wprintw (ptr_win->win_status, "%s", str_nicks);
|
||||
gui_window_set_color (ptr_win->win_status,
|
||||
COLOR_WIN_STATUS_DELIMITERS);
|
||||
wprintw (ptr_win->win_status, "]");
|
||||
}
|
||||
free (string);
|
||||
|
||||
|
||||
@@ -61,6 +61,7 @@ channel_new (t_irc_server *server, int channel_type, char *channel_name,
|
||||
new_channel->modes[sizeof (new_channel->modes) - 1] = '\0';
|
||||
new_channel->limit = 0;
|
||||
new_channel->key = NULL;
|
||||
new_channel->nicks_count = 0;
|
||||
new_channel->checking_away = 0;
|
||||
new_channel->nicks = NULL;
|
||||
new_channel->last_nick = NULL;
|
||||
|
||||
@@ -191,6 +191,8 @@ nick_new (t_irc_channel *channel, char *nick_name,
|
||||
|
||||
nick_insert_sorted (channel, new_nick);
|
||||
|
||||
channel->nicks_count++;
|
||||
|
||||
/* all is ok, return address of new nick */
|
||||
return new_nick;
|
||||
}
|
||||
@@ -263,6 +265,8 @@ nick_free (t_irc_channel *channel, t_irc_nick *nick)
|
||||
if (nick->next_nick)
|
||||
(nick->next_nick)->prev_nick = nick->prev_nick;
|
||||
|
||||
channel->nicks_count--;
|
||||
|
||||
/* free data */
|
||||
if (nick->nick)
|
||||
free (nick->nick);
|
||||
@@ -280,6 +284,9 @@ nick_free_all (t_irc_channel *channel)
|
||||
/* remove all nicks for the channel */
|
||||
while (channel->nicks)
|
||||
nick_free (channel, channel->nicks);
|
||||
|
||||
/* sould be zero, but prevent any bug :D */
|
||||
channel->nicks_count = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
+6
-2
@@ -243,6 +243,7 @@ irc_cmd_recv_join (t_irc_server *server, char *host, char *arguments)
|
||||
"%s\n", arguments);
|
||||
(void) nick_new (ptr_channel, host, 0, 0, 0, 0, 0);
|
||||
gui_draw_buffer_nick (ptr_channel->buffer, 1);
|
||||
gui_draw_buffer_status (ptr_channel->buffer, 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -338,6 +339,7 @@ irc_cmd_recv_kick (t_irc_server *server, char *host, char *arguments)
|
||||
{
|
||||
nick_free (ptr_channel, ptr_nick);
|
||||
gui_draw_buffer_nick (ptr_channel->buffer, 1);
|
||||
gui_draw_buffer_status (ptr_channel->buffer, 1);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
@@ -975,10 +977,10 @@ irc_cmd_recv_part (t_irc_server *server, char *host, char *arguments)
|
||||
COLOR_WIN_CHAT_DARK, ")");
|
||||
}
|
||||
gui_printf (ptr_channel->buffer, "\n");
|
||||
|
||||
/* redraw nick list if this is current buffer */
|
||||
|
||||
if (gui_buffer_has_nicklist (ptr_channel->buffer))
|
||||
gui_draw_buffer_nick (ptr_channel->buffer, 1);
|
||||
gui_draw_buffer_status (ptr_channel->buffer, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1540,6 +1542,7 @@ irc_cmd_recv_quit (t_irc_server *server, char *host, char *arguments)
|
||||
COLOR_WIN_CHAT_DARK, ")\n");
|
||||
if (gui_buffer_has_nicklist (ptr_channel->buffer))
|
||||
gui_draw_buffer_nick (ptr_channel->buffer, 1);
|
||||
gui_draw_buffer_status (ptr_channel->buffer, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3064,6 +3067,7 @@ irc_cmd_recv_353 (t_irc_server *server, char *host, char *arguments)
|
||||
}
|
||||
}
|
||||
gui_draw_buffer_nick (ptr_channel->buffer, 1);
|
||||
gui_draw_buffer_status (ptr_channel->buffer, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -114,6 +114,7 @@ struct t_irc_channel
|
||||
char modes[NUM_CHANNEL_MODES+1];/* channel modes */
|
||||
int limit; /* user limit (0 is limit not set) */
|
||||
char *key; /* channel key (NULL if no key is set) */
|
||||
int nicks_count; /* # nicks on channel (0 if dcc/pv) */
|
||||
int checking_away; /* = 1 if checking away with WHO cmd */
|
||||
t_irc_nick *nicks; /* nicks on the channel */
|
||||
t_irc_nick *last_nick; /* last nick on the channel */
|
||||
|
||||
+2
-1
@@ -1,10 +1,11 @@
|
||||
WeeChat - Wee Enhanced Environment for Chat
|
||||
===========================================
|
||||
|
||||
ChangeLog - 2005-03-14
|
||||
ChangeLog - 2005-03-15
|
||||
|
||||
|
||||
Version 0.1.1 (under dev!):
|
||||
* added nicks count for channel buffers
|
||||
* added FIFO pipe for remote control
|
||||
* added crash dump when WeeChat receives SIGSEGV (Segmentation fault)
|
||||
* added new display engine: doesn't cut words at end of lines
|
||||
|
||||
@@ -1027,8 +1027,8 @@ gui_draw_buffer_status (t_gui_buffer *buffer, int erase)
|
||||
{
|
||||
t_gui_window *ptr_win;
|
||||
t_weechat_hotlist *ptr_hotlist;
|
||||
char format_more[32], *string;
|
||||
int i, first_mode;
|
||||
char format_more[32], str_nicks[32], *string;
|
||||
int i, first_mode, x;
|
||||
|
||||
/* make gcc happy */
|
||||
(void) buffer;
|
||||
@@ -1262,20 +1262,39 @@ gui_draw_buffer_status (t_gui_buffer *buffer, int erase)
|
||||
}
|
||||
}
|
||||
|
||||
/* display "-MORE-" if last line is not displayed */
|
||||
gui_window_set_color (ptr_win->win_status, COLOR_WIN_STATUS_MORE);
|
||||
/* display "-MORE-" (if last line is not displayed) & nicks count */
|
||||
if (gui_buffer_has_nicklist (ptr_win->buffer))
|
||||
{
|
||||
snprintf (str_nicks, sizeof (str_nicks) - 1, "%d", CHANNEL(ptr_win->buffer)->nicks_count);
|
||||
x = ptr_win->win_width - strlen (str_nicks) - 4;
|
||||
}
|
||||
else
|
||||
x = ptr_win->win_width;
|
||||
string = weechat_convert_encoding (cfg_look_charset_decode,
|
||||
(cfg_look_charset_internal && cfg_look_charset_internal[0]) ?
|
||||
cfg_look_charset_internal : local_charset,
|
||||
_("-MORE-"));
|
||||
x -= strlen (string) - 1;
|
||||
if (x < 0)
|
||||
x = 0;
|
||||
gui_window_set_color (ptr_win->win_status, COLOR_WIN_STATUS_MORE);
|
||||
if (ptr_win->sub_lines > 0)
|
||||
mvwprintw (ptr_win->win_status, 0, ptr_win->win_width - 7,
|
||||
"%s", string);
|
||||
mvwprintw (ptr_win->win_status, 0, x, "%s", string);
|
||||
else
|
||||
{
|
||||
snprintf (format_more, 32, "%%-%ds", strlen (string));
|
||||
mvwprintw (ptr_win->win_status, 0, ptr_win->win_width - 7,
|
||||
format_more, " ");
|
||||
snprintf (format_more, sizeof (format_more) - 1, "%%-%ds", strlen (string));
|
||||
mvwprintw (ptr_win->win_status, 0, x, format_more, " ");
|
||||
}
|
||||
if (gui_buffer_has_nicklist (ptr_win->buffer))
|
||||
{
|
||||
gui_window_set_color (ptr_win->win_status,
|
||||
COLOR_WIN_STATUS_DELIMITERS);
|
||||
wprintw (ptr_win->win_status, " [");
|
||||
gui_window_set_color (ptr_win->win_status, COLOR_WIN_STATUS);
|
||||
wprintw (ptr_win->win_status, "%s", str_nicks);
|
||||
gui_window_set_color (ptr_win->win_status,
|
||||
COLOR_WIN_STATUS_DELIMITERS);
|
||||
wprintw (ptr_win->win_status, "]");
|
||||
}
|
||||
free (string);
|
||||
|
||||
|
||||
@@ -61,6 +61,7 @@ channel_new (t_irc_server *server, int channel_type, char *channel_name,
|
||||
new_channel->modes[sizeof (new_channel->modes) - 1] = '\0';
|
||||
new_channel->limit = 0;
|
||||
new_channel->key = NULL;
|
||||
new_channel->nicks_count = 0;
|
||||
new_channel->checking_away = 0;
|
||||
new_channel->nicks = NULL;
|
||||
new_channel->last_nick = NULL;
|
||||
|
||||
@@ -191,6 +191,8 @@ nick_new (t_irc_channel *channel, char *nick_name,
|
||||
|
||||
nick_insert_sorted (channel, new_nick);
|
||||
|
||||
channel->nicks_count++;
|
||||
|
||||
/* all is ok, return address of new nick */
|
||||
return new_nick;
|
||||
}
|
||||
@@ -263,6 +265,8 @@ nick_free (t_irc_channel *channel, t_irc_nick *nick)
|
||||
if (nick->next_nick)
|
||||
(nick->next_nick)->prev_nick = nick->prev_nick;
|
||||
|
||||
channel->nicks_count--;
|
||||
|
||||
/* free data */
|
||||
if (nick->nick)
|
||||
free (nick->nick);
|
||||
@@ -280,6 +284,9 @@ nick_free_all (t_irc_channel *channel)
|
||||
/* remove all nicks for the channel */
|
||||
while (channel->nicks)
|
||||
nick_free (channel, channel->nicks);
|
||||
|
||||
/* sould be zero, but prevent any bug :D */
|
||||
channel->nicks_count = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -243,6 +243,7 @@ irc_cmd_recv_join (t_irc_server *server, char *host, char *arguments)
|
||||
"%s\n", arguments);
|
||||
(void) nick_new (ptr_channel, host, 0, 0, 0, 0, 0);
|
||||
gui_draw_buffer_nick (ptr_channel->buffer, 1);
|
||||
gui_draw_buffer_status (ptr_channel->buffer, 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -338,6 +339,7 @@ irc_cmd_recv_kick (t_irc_server *server, char *host, char *arguments)
|
||||
{
|
||||
nick_free (ptr_channel, ptr_nick);
|
||||
gui_draw_buffer_nick (ptr_channel->buffer, 1);
|
||||
gui_draw_buffer_status (ptr_channel->buffer, 1);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
@@ -975,10 +977,10 @@ irc_cmd_recv_part (t_irc_server *server, char *host, char *arguments)
|
||||
COLOR_WIN_CHAT_DARK, ")");
|
||||
}
|
||||
gui_printf (ptr_channel->buffer, "\n");
|
||||
|
||||
/* redraw nick list if this is current buffer */
|
||||
|
||||
if (gui_buffer_has_nicklist (ptr_channel->buffer))
|
||||
gui_draw_buffer_nick (ptr_channel->buffer, 1);
|
||||
gui_draw_buffer_status (ptr_channel->buffer, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1540,6 +1542,7 @@ irc_cmd_recv_quit (t_irc_server *server, char *host, char *arguments)
|
||||
COLOR_WIN_CHAT_DARK, ")\n");
|
||||
if (gui_buffer_has_nicklist (ptr_channel->buffer))
|
||||
gui_draw_buffer_nick (ptr_channel->buffer, 1);
|
||||
gui_draw_buffer_status (ptr_channel->buffer, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3064,6 +3067,7 @@ irc_cmd_recv_353 (t_irc_server *server, char *host, char *arguments)
|
||||
}
|
||||
}
|
||||
gui_draw_buffer_nick (ptr_channel->buffer, 1);
|
||||
gui_draw_buffer_status (ptr_channel->buffer, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -114,6 +114,7 @@ struct t_irc_channel
|
||||
char modes[NUM_CHANNEL_MODES+1];/* channel modes */
|
||||
int limit; /* user limit (0 is limit not set) */
|
||||
char *key; /* channel key (NULL if no key is set) */
|
||||
int nicks_count; /* # nicks on channel (0 if dcc/pv) */
|
||||
int checking_away; /* = 1 if checking away with WHO cmd */
|
||||
t_irc_nick *nicks; /* nicks on the channel */
|
||||
t_irc_nick *last_nick; /* last nick on the channel */
|
||||
|
||||
Reference in New Issue
Block a user