mirror of
https://github.com/weechat/weechat.git
synced 2026-06-28 13:56:37 +02:00
Add new values for option irc.look.nick_completion_smart: off / speakers / speakers_highlights
This commit is contained in:
@@ -307,21 +307,17 @@ irc_channel_set_away (struct t_irc_channel *channel, const char *nick_name,
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_channel_nick_speaking_add: add a nick speaking on a channel
|
||||
* irc_channel_nick_speaking_add_to_list: add a nick speaking on a channel
|
||||
*/
|
||||
|
||||
void
|
||||
irc_channel_nick_speaking_add (struct t_irc_channel *channel,
|
||||
const char *nick_name, int highlight)
|
||||
irc_channel_nick_speaking_add_to_list (struct t_irc_channel *channel,
|
||||
const char *nick_name,
|
||||
int highlight)
|
||||
{
|
||||
int size, to_remove, i;
|
||||
struct t_weelist_item *ptr_item;
|
||||
|
||||
if (highlight < 0)
|
||||
highlight = 0;
|
||||
if (highlight > 1)
|
||||
highlight = 1;
|
||||
|
||||
/* create list if it does not exist */
|
||||
if (!channel->nicks_speaking[highlight])
|
||||
channel->nicks_speaking[highlight] = weechat_list_new ();
|
||||
@@ -349,6 +345,24 @@ irc_channel_nick_speaking_add (struct t_irc_channel *channel,
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_channel_nick_speaking_add: add a nick speaking on a channel
|
||||
*/
|
||||
|
||||
void
|
||||
irc_channel_nick_speaking_add (struct t_irc_channel *channel,
|
||||
const char *nick_name, int highlight)
|
||||
{
|
||||
if (highlight < 0)
|
||||
highlight = 0;
|
||||
if (highlight > 1)
|
||||
highlight = 1;
|
||||
if (highlight)
|
||||
irc_channel_nick_speaking_add_to_list (channel, nick_name, 1);
|
||||
|
||||
irc_channel_nick_speaking_add_to_list (channel, nick_name, 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_channel_nick_speaking_rename: rename a nick speaking on a channel
|
||||
*/
|
||||
|
||||
@@ -176,6 +176,36 @@ irc_completion_channel_cb (void *data, const char *completion_item,
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_completion_channel_nicks_add_speakers: add recent speakers to completion
|
||||
* list
|
||||
*/
|
||||
|
||||
void
|
||||
irc_completion_channel_nicks_add_speakers (struct t_gui_completion *completion,
|
||||
struct t_irc_channel *channel,
|
||||
int highlight)
|
||||
{
|
||||
int list_size, i;
|
||||
const char *nick;
|
||||
|
||||
if (channel->nicks_speaking[highlight])
|
||||
{
|
||||
list_size = weechat_list_size (channel->nicks_speaking[highlight]);
|
||||
for (i = 0; i < list_size; i++)
|
||||
{
|
||||
nick = weechat_list_string (weechat_list_get (channel->nicks_speaking[highlight], i));
|
||||
if (nick && irc_nick_search (channel, nick))
|
||||
{
|
||||
weechat_hook_completion_list_add (completion,
|
||||
nick,
|
||||
1,
|
||||
WEECHAT_LIST_POS_BEGINNING);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_completion_channel_nicks_cb: callback for completion with nicks
|
||||
* of current channel
|
||||
@@ -187,8 +217,6 @@ irc_completion_channel_nicks_cb (void *data, const char *completion_item,
|
||||
struct t_gui_completion *completion)
|
||||
{
|
||||
struct t_irc_nick *ptr_nick;
|
||||
const char *nick;
|
||||
int list_size, i, j;
|
||||
|
||||
IRC_GET_SERVER_CHANNEL(buffer);
|
||||
|
||||
@@ -209,28 +237,15 @@ irc_completion_channel_nicks_cb (void *data, const char *completion_item,
|
||||
1,
|
||||
WEECHAT_LIST_POS_SORT);
|
||||
}
|
||||
/* add nicks speaking recently on this channel */
|
||||
if (weechat_config_boolean (irc_config_look_nick_completion_smart))
|
||||
/* add recent speakers on channel */
|
||||
if (weechat_config_integer (irc_config_look_nick_completion_smart) == IRC_CONFIG_NICK_COMPLETION_SMART_SPEAKERS)
|
||||
{
|
||||
/* 0 => nick speaking ; 1 => nick speaking to me (with highlight) */
|
||||
for (i = 0; i < 2; i++)
|
||||
{
|
||||
if (ptr_channel->nicks_speaking[i])
|
||||
{
|
||||
list_size = weechat_list_size (ptr_channel->nicks_speaking[i]);
|
||||
for (j = 0; j < list_size; j++)
|
||||
{
|
||||
nick = weechat_list_string (weechat_list_get (ptr_channel->nicks_speaking[i], j));
|
||||
if (nick && irc_nick_search (ptr_channel, nick))
|
||||
{
|
||||
weechat_hook_completion_list_add (completion,
|
||||
nick,
|
||||
1,
|
||||
WEECHAT_LIST_POS_BEGINNING);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
irc_completion_channel_nicks_add_speakers (completion, ptr_channel, 0);
|
||||
}
|
||||
/* add nicks whose make highlights on me recently on this channel */
|
||||
if (weechat_config_integer (irc_config_look_nick_completion_smart) == IRC_CONFIG_NICK_COMPLETION_SMART_SPEAKERS_HIGHLIGHTS)
|
||||
{
|
||||
irc_completion_channel_nicks_add_speakers (completion, ptr_channel, 1);
|
||||
}
|
||||
/* add self nick at the end */
|
||||
weechat_hook_completion_list_add (completion,
|
||||
|
||||
@@ -1060,14 +1060,16 @@ irc_config_init ()
|
||||
NULL, 0, 0, "", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
irc_config_look_nick_completion_smart = weechat_config_new_option (
|
||||
irc_config_file, ptr_section,
|
||||
"nick_completion_smart", "boolean",
|
||||
N_("smart completion for nicks (completes with last speakers first)"),
|
||||
NULL, 0, 0, "on", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
"nick_completion_smart", "integer",
|
||||
N_("smart completion for nicks (completes first with last speakers)"),
|
||||
"off|speakers|speakers_highlights", 0, 0, "speakers", NULL, 0, NULL, NULL,
|
||||
NULL, NULL, NULL, NULL);
|
||||
irc_config_look_display_away = weechat_config_new_option (
|
||||
irc_config_file, ptr_section,
|
||||
"display_away", "integer",
|
||||
N_("display message when (un)marking as away"),
|
||||
"off|local|channel", 0, 0, "local", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
"off|local|channel", 0, 0, "local", NULL, 0, NULL, NULL, NULL, NULL,
|
||||
NULL, NULL);
|
||||
irc_config_look_display_channel_modes = weechat_config_new_option (
|
||||
irc_config_file, ptr_section,
|
||||
"display_channel_modes", "boolean",
|
||||
|
||||
@@ -22,6 +22,10 @@
|
||||
|
||||
#define IRC_CONFIG_NAME "irc"
|
||||
|
||||
#define IRC_CONFIG_NICK_COMPLETION_SMART_OFF 0
|
||||
#define IRC_CONFIG_NICK_COMPLETION_SMART_SPEAKERS 1
|
||||
#define IRC_CONFIG_NICK_COMPLETION_SMART_SPEAKERS_HIGHLIGHTS 2
|
||||
|
||||
#define IRC_CONFIG_DISPLAY_AWAY_OFF 0
|
||||
#define IRC_CONFIG_DISPLAY_AWAY_LOCAL 1
|
||||
#define IRC_CONFIG_DISPLAY_AWAY_CHANNEL 2
|
||||
|
||||
Reference in New Issue
Block a user