diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2009-04-03 17:07:00 +0200 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2009-04-03 17:07:00 +0200 |
commit | 76b700a55552891d29bd09c83d1ab001bef4e449 (patch) | |
tree | 8ffebeebaa70cbcc5e54459c0c5758acf8fd7b6c /src | |
parent | 00580b1670fe63f55e98ac159abb6f1f57258291 (diff) | |
download | weechat-76b700a55552891d29bd09c83d1ab001bef4e449.zip |
Add new values for option irc.look.nick_completion_smart: off / speakers / speakers_highlights
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/irc/irc-channel.c | 30 | ||||
-rw-r--r-- | src/plugins/irc/irc-completion.c | 61 | ||||
-rw-r--r-- | src/plugins/irc/irc-config.c | 10 | ||||
-rw-r--r-- | src/plugins/irc/irc-config.h | 4 |
4 files changed, 70 insertions, 35 deletions
diff --git a/src/plugins/irc/irc-channel.c b/src/plugins/irc/irc-channel.c index 537d18bf7..b5c2d8af6 100644 --- a/src/plugins/irc/irc-channel.c +++ b/src/plugins/irc/irc-channel.c @@ -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 (); @@ -350,6 +346,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 */ diff --git a/src/plugins/irc/irc-completion.c b/src/plugins/irc/irc-completion.c index 3ca5d69a2..0de87a2ca 100644 --- a/src/plugins/irc/irc-completion.c +++ b/src/plugins/irc/irc-completion.c @@ -177,6 +177,36 @@ irc_completion_channel_cb (void *data, const char *completion_item, } /* + * 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, diff --git a/src/plugins/irc/irc-config.c b/src/plugins/irc/irc-config.c index f7bb28ffa..20cf063bc 100644 --- a/src/plugins/irc/irc-config.c +++ b/src/plugins/irc/irc-config.c @@ -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", diff --git a/src/plugins/irc/irc-config.h b/src/plugins/irc/irc-config.h index 0a09e6b8a..44a46d288 100644 --- a/src/plugins/irc/irc-config.h +++ b/src/plugins/irc/irc-config.h @@ -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 |