irc: add bar item "irc_nick_prefix"

This commit is contained in:
Sébastien Helleu 2021-02-27 13:44:24 +01:00
parent a811da3a42
commit 0f71b4ccc8
8 changed files with 63 additions and 0 deletions

View File

@ -39,6 +39,7 @@ Bug fixes::
* core: do not remove quotes in arguments of command /eval as they can be part of the evaluated expression/condition (issue #1601)
* core: display an error when the buffer is not found with command /command -buffer
* buflist: add option buflist.look.use_items to speed up display of buflist (issue #1613)
* irc: add bar item "irc_nick_prefix"
* irc: fix separator between nick and host in bar item "irc_nick_host"
* irc: fix completion of commands /halfop and /dehalfop

View File

@ -774,6 +774,8 @@ andere Items die man nutzen kann (die aber nicht standardmäßig in einer Bar ak
// TRANSLATION MISSING
| irc_nick_host | `+Flashy!user@host.com+` | Current IRC nick and host.
| irc_nick_modes | `i` | IRC Modi für den eigenen Nick.
// TRANSLATION MISSING
| irc_nick_prefix | `@` | IRC nick prefix on channel.
| mouse_status | `M` | Status der Maus (keine Anzeige, falls Maus deaktiviert).
| spell_dict | `de,en` | zeigt an welche Wörterbücher für die Rechtschreibung im aktuellen Buffer genutzt werden.
| spell_suggest | `Glück,Glocke,Block` | Vorschläge für ein falsch geschriebenes Wort.

View File

@ -759,6 +759,7 @@ Other items available (not used in bars by default):
| irc_nick | `+Flashy+` | Current IRC nick.
| irc_nick_host | `+Flashy!user@host.com+` | Current IRC nick and host.
| irc_nick_modes | `i` | IRC modes for self nick.
| irc_nick_prefix | `@` | IRC nick prefix on channel.
| mouse_status | `M` | Mouse status (empty if mouse is disabled).
| spell_dict | `fr,en` | Spelling dictionaries used on current buffer.
| spell_suggest | `print,prone,prune` | Spelling suggestions for word under cursor (if misspelled).

View File

@ -774,6 +774,7 @@ Autres objets (non utilisés dans des barres par défaut) :
| irc_nick | `+Flashy+` | Pseudo IRC.
| irc_nick_host | `+Flashy!user@host.com+` | Pseudo et hôte IRC.
| irc_nick_modes | `i` | Modes IRC pour le pseudo.
| irc_nick_prefix | `@` | Préfixe de pseudo IRC sur le canal.
| mouse_status | `M` | Statut de la souris (vide si la souris est désactivée).
| spell_dict | `fr,en` | Dictionnaires utilisés pour la vérification de l'orthographe sur le tampon courant.
| spell_suggest | `print,prone,prune` | Suggestions pour le mot sous le curseur (si mal orthographié).

View File

@ -832,6 +832,7 @@ Other items available (not used in bars by default):
| irc_nick | `+Flashy+` | Current IRC nick.
| irc_nick_host | `+Flashy!user@host.com+` | Current IRC nick and host.
| irc_nick_modes | `i` | IRC modes for self nick.
| irc_nick_prefix | `@` | IRC nick prefix on channel.
| mouse_status | `M` | Mouse status (empty if mouse is disabled).
| spell_dict | `fr,en` | Spelling dictionaries used on current buffer.
| spell_suggest | `print,prone,prune` | Spelling suggestions for word under cursor (if misspelled).

View File

@ -790,6 +790,8 @@ WeeChat を起動した端末の例:
// TRANSLATION MISSING
| irc_nick_host | `+Flashy!user@host.com+` | Current IRC nick and host.
| irc_nick_modes | `i` | 自分のニックネームに対する IRC モード
// TRANSLATION MISSING
| irc_nick_prefix | `@` | IRC nick prefix on channel.
| mouse_status | `M` | マウスの状態 (マウスが無効化されている場合は空文字列)
| spell_dict | `fr,en` | 現在のバッファにおけるスペリング辞書
| spell_suggest | `print,prone,prune` | カーソル下の単語に対するスペリング候補 (スペルが間違っている場合)

View File

@ -774,6 +774,8 @@ Inne dostępne elementy (nie używane domyślnie w paskach):
// TRANSLATION MISSING
| irc_nick_host | `+Flashy!user@host.com+` | Current IRC nick and host.
| irc_nick_modes | `i` | Atrybuty IRC dla własnego nicka.
// TRANSLATION MISSING
| irc_nick_prefix | `@` | IRC nick prefix on channel.
| mouse_status | `M` | Status obsługi myszy (pusty jeśli obsługa myszy jest wyłączona).
| spell_dict | `fr,en` | Słowniki używane w obecnym buforze.
| spell_suggest | `print,prone,prune` | Sugestie dla słowa pod kursorem (jeśli zawiera błąd).

View File

@ -643,6 +643,57 @@ irc_bar_item_nick_modes (const void *pointer, void *data,
return buf;
}
/*
* Returns content of bar item "nick_prefix": bar item with nick prefix.
*/
char *
irc_bar_item_nick_prefix (const void *pointer, void *data,
struct t_gui_bar_item *item,
struct t_gui_window *window,
struct t_gui_buffer *buffer,
struct t_hashtable *extra_info)
{
struct t_irc_server *server;
struct t_irc_channel *channel;
struct t_irc_nick *ptr_nick;
char str_prefix[64];
/* make C compiler happy */
(void) pointer;
(void) data;
(void) item;
(void) window;
(void) extra_info;
if (!buffer)
return NULL;
irc_buffer_get_server_and_channel (buffer, &server, &channel);
if (!server || !server->nick)
return NULL;
str_prefix[0] = '\0';
if (channel && (channel->type == IRC_CHANNEL_TYPE_CHANNEL))
{
ptr_nick = irc_nick_search (server, channel, server->nick);
if (ptr_nick)
{
if (weechat_config_boolean (irc_config_look_nick_mode_empty)
|| (ptr_nick->prefix[0] != ' '))
{
snprintf (str_prefix, sizeof (str_prefix), "%s%s",
weechat_color (
irc_nick_get_prefix_color_name (
server, ptr_nick->prefix[0])),
ptr_nick->prefix);
}
}
}
return (str_prefix[0]) ? strdup (str_prefix) : NULL;
}
/*
* Focus on nicklist.
*/
@ -769,6 +820,8 @@ irc_bar_item_init ()
&irc_bar_item_input_prompt, NULL, NULL);
weechat_bar_item_new ("irc_nick_modes",
&irc_bar_item_nick_modes, NULL, NULL);
weechat_bar_item_new ("irc_nick_prefix",
&irc_bar_item_nick_prefix, NULL, NULL);
weechat_hook_focus ("buffer_nicklist",
&irc_bar_item_focus_buffer_nicklist, NULL, NULL);