1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-12 14:14:48 +02:00

buflist: add command /buflist

This commit is contained in:
Sébastien Helleu
2017-03-25 12:14:50 +01:00
parent 887362dfd9
commit 98487253ca
13 changed files with 173 additions and 11 deletions
+1 -1
View File
@@ -90,7 +90,7 @@ PLUGIN_LIST = {
'weechat': 'co',
'alias': '',
'aspell': 'o',
'buflist': 'o',
'buflist': 'co',
'charset': 'o',
'exec': 'o',
'fifo': 'o',
+1
View File
@@ -197,6 +197,7 @@ WeeChat "core" is located in following directories:
|    buflist/ | Buflist plugin.
|       buflist.c | Main buflist functions.
|       buflist-bar-item.c | Buflist bar items.
|       buflist-command.c | Buflist commands.
|       buflist-config.c | Buflist config options (file buflist.conf).
|    charset/ | Charset plugin.
|       charset.c | Charset functions.
+1
View File
@@ -199,6 +199,7 @@ Le cœur de WeeChat est situé dans les répertoires suivants :
|    buflist/ | Extension Buflist.
|       buflist.c | Fonctions principales de Buflist.
|       buflist-bar-item.c | Objets de barre Buflist.
|       buflist-command.c | Commandes pour Buflist.
|       buflist-config.c | Options de configuration pour Buflist (fichier buflist.conf).
|    charset/ | Extension Charset.
|       charset.c | Fonctions pour Charset.
+1
View File
@@ -203,6 +203,7 @@ WeeChat "core" は以下のディレクトリに配置されています:
|    buflist/ | buflist プラグイン
|       buflist.c | buflist の主要関数
|       buflist-bar-item.c | buflist バー要素
|       buflist-command.c | buflist コマンド
|       buflist-config.c | buflist 設定オプション (buflist.conf ファイル)
|    charset/ | charset プラグイン
|       charset.c | charset 関数
+2
View File
@@ -124,6 +124,8 @@
./src/plugins/buflist/buflist-bar-item.c
./src/plugins/buflist/buflist-bar-item.h
./src/plugins/buflist/buflist.c
./src/plugins/buflist/buflist-command.c
./src/plugins/buflist/buflist-command.h
./src/plugins/buflist/buflist-config.c
./src/plugins/buflist/buflist-config.h
./src/plugins/buflist/buflist.h
+2
View File
@@ -125,6 +125,8 @@ SET(WEECHAT_SOURCES
./src/plugins/buflist/buflist-bar-item.c
./src/plugins/buflist/buflist-bar-item.h
./src/plugins/buflist/buflist.c
./src/plugins/buflist/buflist-command.c
./src/plugins/buflist/buflist-command.h
./src/plugins/buflist/buflist-config.c
./src/plugins/buflist/buflist-config.h
./src/plugins/buflist/buflist.h
+1
View File
@@ -20,6 +20,7 @@
add_library(buflist MODULE
buflist.c buflist.h
buflist-bar-item.c buflist-bar-item.h
buflist-command.c buflist-command.h
buflist-config.c buflist-config.h)
set_target_properties(buflist PROPERTIES PREFIX "")
+2
View File
@@ -27,6 +27,8 @@ buflist_la_SOURCES = buflist.c \
buflist.h \
buflist-bar-item.c \
buflist-bar-item.h \
buflist-command.c \
buflist-command.h \
buflist-config.c \
buflist-config.h
+4
View File
@@ -144,6 +144,10 @@ buflist_bar_item_buflist_cb (const void *pointer, void *data,
"buffer", ptr_buffer);
/* set extra variables */
weechat_hashtable_set (buflist_hashtable_extra_vars,
"format_buffer",
weechat_config_string (
buflist_config_format_buffer));
weechat_hashtable_set (buflist_hashtable_extra_vars,
"number", str_number);
weechat_hashtable_set (buflist_hashtable_extra_vars,
+110
View File
@@ -0,0 +1,110 @@
/*
* buflist-command.c - buflist command
*
* Copyright (C) 2003-2017 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
* WeeChat is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* WeeChat is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with WeeChat. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include "../weechat-plugin.h"
#include "buflist.h"
#include "buflist-bar-item.h"
#include "buflist-command.h"
/*
* Callback for command "/buflist".
*/
int
buflist_command_buflist (const void *pointer, void *data,
struct t_gui_buffer *buffer, int argc,
char **argv, char **argv_eol)
{
/* make C compiler happy */
(void) pointer;
(void) data;
(void) buffer;
(void) argc;
(void) argv;
(void) argv_eol;
if (argc == 1)
return WEECHAT_RC_OK;
if (weechat_strcasecmp (argv[1], "refresh") == 0)
{
weechat_bar_item_update (BUFLIST_BAR_ITEM_NAME);
return WEECHAT_RC_OK;
}
WEECHAT_COMMAND_ERROR;
}
/*
* Hooks buflist commands.
*/
void
buflist_command_init ()
{
weechat_hook_command (
"buflist",
N_("bar item with list of buffers"),
"refresh",
N_("refresh: force the refresh of the buflist bar item\n"
"\n"
"The lines with buffers are displayed using string evaluation "
"(see /help eval for the format), with two main options:\n"
" - buflist.format.buffer: format for a buffer which is not "
"current buffer\n"
" - buflist.format.buffer_current: format for the current buffer\n"
"\n"
"The following variables can be used in these options:\n"
" - buffer data (see hdata \"buffer\" in API doc for a complete "
"list), for example:\n"
" - ${buffer.number}\n"
" - ${buffer.name}\n"
" - ${buffer.full_name}\n"
" - ${buffer.short_name}\n"
" - ${buffer.nicklist_nicks_count}\n"
" - extra variables added by buflist for convenience:\n"
" - ${format_buffer}: the evaluated value of option "
"buflist.format.buffer; this can be used in option "
"buflist.format.buffer_current to just change the background color "
"for example\n"
" - ${number}: indented number, for example \" 1\" if there "
"are between 10 and 99 buffers opened\n"
" - ${indent}: indentation for name (channel and private "
"buffers are indented)\n"
" - ${name}: the short name (if set), with a fallback on the "
"name\n"
" - ${color_hotlist}: the color depending on the highest "
"hotlist level for the buffer, which is the content of option "
"buflist.format.hotlist_xxx (xxx is the level)\n"
" - ${format_hotlist}: the formatted hotlist (evaluation "
"of option buflist.format.hotlist)\n"
" - ${hotlist}: the raw hotlist\n"
" - ${format_lag}: the lag for an IRC server buffer "
"(empty if there's no lag)\n"),
"refresh",
&buflist_command_buflist, NULL, NULL);
}
+25
View File
@@ -0,0 +1,25 @@
/*
* Copyright (C) 2003-2017 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
* WeeChat is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* WeeChat is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with WeeChat. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef WEECHAT_BUFLIST_COMMAND_H
#define WEECHAT_BUFLIST_COMMAND_H 1
extern void buflist_command_init ();
#endif /* WEECHAT_BUFLIST_COMMAND_H */
+20 -10
View File
@@ -148,7 +148,8 @@ buflist_config_init ()
buflist_config_format_buffer = weechat_config_new_option (
buflist_config_file, ptr_section,
"buffer", "string",
N_("format of each line with a buffer"),
N_("format of each line with a buffer "
"(note: content is evaluated, see /help buflist)"),
NULL, 0, 0,
"${color:green}${number}.${indent}${color_hotlist}${name}",
NULL, 0,
@@ -158,7 +159,8 @@ buflist_config_init ()
buflist_config_format_buffer_current = weechat_config_new_option (
buflist_config_file, ptr_section,
"buffer_current", "string",
N_("format for the line with current buffer"),
N_("format for the line with current buffer "
"(note: content is evaluated, see /help buflist)"),
NULL, 0, 0,
"${color:lightgreen,blue}${number}.${indent}${color_hotlist}${name}",
NULL, 0,
@@ -168,7 +170,8 @@ buflist_config_init ()
buflist_config_format_hotlist = weechat_config_new_option (
buflist_config_file, ptr_section,
"hotlist", "string",
N_("format for hotlist"),
N_("format for hotlist "
"(note: content is evaluated, see /help buflist)"),
NULL, 0, 0,
" ${color:green}(${hotlist}${color:green})",
NULL, 0,
@@ -178,7 +181,8 @@ buflist_config_init ()
buflist_config_format_hotlist_level[0] = weechat_config_new_option (
buflist_config_file, ptr_section,
"hotlist_low", "string",
N_("format for a buffer with hotlist level \"low\""),
N_("format for a buffer with hotlist level \"low\" "
"(note: content is evaluated, see /help buflist)"),
NULL, 0, 0,
"${color:white}",
NULL, 0,
@@ -188,7 +192,8 @@ buflist_config_init ()
buflist_config_format_hotlist_level[1] = weechat_config_new_option (
buflist_config_file, ptr_section,
"hotlist_message", "string",
N_("format for a buffer with hotlist level \"message\""),
N_("format for a buffer with hotlist level \"message\" "
"(note: content is evaluated, see /help buflist)"),
NULL, 0, 0,
"${color:brown}",
NULL, 0,
@@ -198,7 +203,8 @@ buflist_config_init ()
buflist_config_format_hotlist_level[2] = weechat_config_new_option (
buflist_config_file, ptr_section,
"hotlist_private", "string",
N_("format for a buffer with hotlist level \"private\""),
N_("format for a buffer with hotlist level \"private\" "
"(note: content is evaluated, see /help buflist)"),
NULL, 0, 0,
"${color:green}",
NULL, 0,
@@ -208,7 +214,8 @@ buflist_config_init ()
buflist_config_format_hotlist_level[3] = weechat_config_new_option (
buflist_config_file, ptr_section,
"hotlist_highlight", "string",
N_("format for a buffer with hotlist level \"highlight\""),
N_("format for a buffer with hotlist level \"highlight\" "
"(note: content is evaluated, see /help buflist)"),
NULL, 0, 0,
"${color:magenta}",
NULL, 0,
@@ -218,7 +225,8 @@ buflist_config_init ()
buflist_config_format_hotlist_level_none = weechat_config_new_option (
buflist_config_file, ptr_section,
"hotlist_none", "string",
N_("format for a buffer not in hotlist"),
N_("format for a buffer not in hotlist "
"(note: content is evaluated, see /help buflist)"),
NULL, 0, 0,
"${color:default}",
NULL, 0,
@@ -228,7 +236,8 @@ buflist_config_init ()
buflist_config_format_hotlist_separator = weechat_config_new_option (
buflist_config_file, ptr_section,
"hotlist_separator", "string",
N_("separator for counts in hotlist"),
N_("separator for counts in hotlist "
"(note: content is evaluated, see /help buflist)"),
NULL, 0, 0,
"${color:default},",
NULL, 0,
@@ -238,7 +247,8 @@ buflist_config_init ()
buflist_config_format_lag = weechat_config_new_option (
buflist_config_file, ptr_section,
"lag", "string",
N_("format for lag on an irc server buffer"),
N_("format for lag on an irc server buffer "
"(note: content is evaluated, see /help buflist)"),
NULL, 0, 0,
" ${color:green}[${color:brown}${lag}${color:green}]",
NULL, 0,
+3
View File
@@ -25,6 +25,7 @@
#include "../weechat-plugin.h"
#include "buflist.h"
#include "buflist-bar-item.h"
#include "buflist-command.h"
#include "buflist-config.h"
@@ -272,6 +273,8 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
if (!buflist_bar_item_init ())
return WEECHAT_RC_ERROR;
buflist_command_init ();
/* hook some signals */
for (i = 0; signals_buffers[i]; i++)
{