buflist: new plugin "buflist" (bar with list of buffers)
This commit is contained in:
parent
83117f8d2a
commit
edfeb60e32
@ -89,6 +89,7 @@ option(ENABLE_LARGEFILE "Enable Large File Support" ON)
|
||||
option(ENABLE_ALIAS "Enable Alias plugin" ON)
|
||||
option(ENABLE_ASPELL "Enable Aspell plugin" ON)
|
||||
option(ENABLE_ENCHANT "Enable Enchant lib for Aspell plugin" OFF)
|
||||
option(ENABLE_BUFLIST "Enable Buflist plugin" ON)
|
||||
option(ENABLE_CHARSET "Enable Charset plugin" ON)
|
||||
option(ENABLE_EXEC "Enable Exec plugin" ON)
|
||||
option(ENABLE_FIFO "Enable FIFO plugin" ON)
|
||||
|
15
configure.ac
15
configure.ac
@ -109,6 +109,7 @@ AH_VERBATIM([HAVE_ENCHANT_GET_VERSION], [#undef HAVE_ENCHANT_GET_VERSION])
|
||||
AH_VERBATIM([HAVE_GUILE_GMP_MEMORY_FUNCTIONS], [#undef HAVE_GUILE_GMP_MEMORY_FUNCTIONS])
|
||||
AH_VERBATIM([PLUGIN_ALIAS], [#undef PLUGIN_ALIAS])
|
||||
AH_VERBATIM([PLUGIN_ASPELL], [#undef PLUGIN_ASPELL])
|
||||
AH_VERBATIM([PLUGIN_BUFLIST], [#undef PLUGIN_BUFLIST])
|
||||
AH_VERBATIM([PLUGIN_CHARSET], [#undef PLUGIN_CHARSET])
|
||||
AH_VERBATIM([PLUGIN_EXEC], [#undef PLUGIN_EXEC])
|
||||
AH_VERBATIM([PLUGIN_FIFO], [#undef PLUGIN_FIFO])
|
||||
@ -139,6 +140,7 @@ AC_ARG_ENABLE(largefile, [ --disable-largefile turn off Large File Suppo
|
||||
AC_ARG_ENABLE(alias, [ --disable-alias turn off Alias plugin (default=compiled)],enable_alias=$enableval,enable_alias=yes)
|
||||
AC_ARG_ENABLE(aspell, [ --disable-aspell turn off Aspell plugin (default=compiled)],enable_aspell=$enableval,enable_aspell=yes)
|
||||
AC_ARG_ENABLE(enchant, [ --enable-enchant turn on Enchant lib for Aspell plugin (default=off)],enable_enchant=$enableval,enable_enchant=no)
|
||||
AC_ARG_ENABLE(buflist, [ --disable-buflist turn off Buflist plugin (default=compiled if found)],enable_buflist=$enableval,enable_buflist=yes)
|
||||
AC_ARG_ENABLE(charset, [ --disable-charset turn off Charset plugin (default=compiled if found)],enable_charset=$enableval,enable_charset=yes)
|
||||
AC_ARG_ENABLE(exec, [ --disable-exec turn off Exec plugin (default=compiled)],enable_exec=$enableval,enable_exec=yes)
|
||||
AC_ARG_ENABLE(fifo, [ --disable-fifo turn off Fifo plugin (default=compiled)],enable_fifo=$enableval,enable_fifo=yes)
|
||||
@ -375,6 +377,14 @@ if test "x$enable_aspell" = "xyes" ; then
|
||||
AC_DEFINE(PLUGIN_ASPELL)
|
||||
fi
|
||||
|
||||
# --------------------------------- buflist ------------------------------------
|
||||
|
||||
if test "x$enable_buflist" = "xyes" ; then
|
||||
AC_DEFINE(PLUGIN_BUFLIST)
|
||||
else
|
||||
not_asked="$not_asked buflist"
|
||||
fi
|
||||
|
||||
# --------------------------------- charset ------------------------------------
|
||||
|
||||
if test "x$enable_charset" = "xyes" ; then
|
||||
@ -1245,6 +1255,7 @@ AM_CONDITIONAL(HAVE_EAT_NEWLINE_GLITCH, test "$enable_eatnewlineglitch" = "yes")
|
||||
AM_CONDITIONAL(GUI_NCURSES, test "$enable_ncurses" = "yes")
|
||||
AM_CONDITIONAL(PLUGIN_ALIAS, test "$enable_alias" = "yes")
|
||||
AM_CONDITIONAL(PLUGIN_ASPELL, test "$enable_aspell" = "yes")
|
||||
AM_CONDITIONAL(PLUGIN_BUFLIST, test "$enable_buflist" = "yes")
|
||||
AM_CONDITIONAL(PLUGIN_CHARSET, test "$enable_charset" = "yes")
|
||||
AM_CONDITIONAL(PLUGIN_EXEC, test "$enable_exec" = "yes")
|
||||
AM_CONDITIONAL(PLUGIN_FIFO, test "$enable_fifo" = "yes")
|
||||
@ -1281,6 +1292,7 @@ AC_OUTPUT([Makefile
|
||||
src/plugins/Makefile
|
||||
src/plugins/alias/Makefile
|
||||
src/plugins/aspell/Makefile
|
||||
src/plugins/buflist/Makefile
|
||||
src/plugins/charset/Makefile
|
||||
src/plugins/exec/Makefile
|
||||
src/plugins/fifo/Makefile
|
||||
@ -1325,6 +1337,9 @@ fi
|
||||
if test "x$enable_aspell" = "xyes"; then
|
||||
listplugins="$listplugins aspell($ASPELL_LIB_USED)"
|
||||
fi
|
||||
if test "x$enable_buflist" = "xyes"; then
|
||||
listplugins="$listplugins buflist"
|
||||
fi
|
||||
if test "x$enable_charset" = "xyes"; then
|
||||
listplugins="$listplugins charset"
|
||||
fi
|
||||
|
@ -88,8 +88,8 @@ Description: Fast, light and extensible chat client - core files
|
||||
for many operating systems. Everything can be done with a keyboard.
|
||||
.
|
||||
This package provides core plugins and locales files for WeeChat. It
|
||||
currently ships the following plugins: alias, xfer, irc, charset and
|
||||
logger. It is useless without weechat-curses.
|
||||
currently ships the following plugins: alias, buflist, charset, irc, logger
|
||||
and xfer. It is useless without weechat-curses.
|
||||
|
||||
Package: weechat-devel-plugins
|
||||
Architecture: any
|
||||
|
@ -88,8 +88,8 @@ Description: Fast, light and extensible chat client - core files
|
||||
for many operating systems. Everything can be done with a keyboard.
|
||||
.
|
||||
This package provides core plugins and locales files for WeeChat. It
|
||||
currently ships the following plugins: alias, xfer, irc, charset and
|
||||
logger. It is useless without weechat-curses.
|
||||
currently ships the following plugins: alias, buflist, charset, irc, logger
|
||||
and xfer. It is useless without weechat-curses.
|
||||
|
||||
Package: weechat-plugins
|
||||
Architecture: any
|
||||
|
@ -1,6 +1,7 @@
|
||||
usr/share/locale/
|
||||
usr/lib/weechat/plugins/alias.so
|
||||
usr/lib/weechat/plugins/xfer.so
|
||||
usr/lib/weechat/plugins/irc.so
|
||||
usr/lib/weechat/plugins/buflist.so
|
||||
usr/lib/weechat/plugins/charset.so
|
||||
usr/lib/weechat/plugins/irc.so
|
||||
usr/lib/weechat/plugins/logger.so
|
||||
usr/lib/weechat/plugins/xfer.so
|
||||
|
@ -121,6 +121,12 @@
|
||||
./src/plugins/aspell/weechat-aspell-info.h
|
||||
./src/plugins/aspell/weechat-aspell-speller.c
|
||||
./src/plugins/aspell/weechat-aspell-speller.h
|
||||
./src/plugins/buflist/buflist-bar-item.c
|
||||
./src/plugins/buflist/buflist-bar-item.h
|
||||
./src/plugins/buflist/buflist.c
|
||||
./src/plugins/buflist/buflist-config.c
|
||||
./src/plugins/buflist/buflist-config.h
|
||||
./src/plugins/buflist/buflist.h
|
||||
./src/plugins/charset/charset.c
|
||||
./src/plugins/exec/exec.c
|
||||
./src/plugins/exec/exec-buffer.c
|
||||
|
@ -122,6 +122,12 @@ SET(WEECHAT_SOURCES
|
||||
./src/plugins/aspell/weechat-aspell-info.h
|
||||
./src/plugins/aspell/weechat-aspell-speller.c
|
||||
./src/plugins/aspell/weechat-aspell-speller.h
|
||||
./src/plugins/buflist/buflist-bar-item.c
|
||||
./src/plugins/buflist/buflist-bar-item.h
|
||||
./src/plugins/buflist/buflist.c
|
||||
./src/plugins/buflist/buflist-config.c
|
||||
./src/plugins/buflist/buflist-config.h
|
||||
./src/plugins/buflist/buflist.h
|
||||
./src/plugins/charset/charset.c
|
||||
./src/plugins/exec/exec.c
|
||||
./src/plugins/exec/exec-buffer.c
|
||||
|
@ -67,6 +67,10 @@ if(ENABLE_ASPELL)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(ENABLE_BUFLIST)
|
||||
add_subdirectory(buflist)
|
||||
endif()
|
||||
|
||||
if(ENABLE_CHARSET)
|
||||
# Check for iconv support.
|
||||
if(ICONV_FOUND)
|
||||
|
@ -45,6 +45,10 @@ if PLUGIN_ASPELL
|
||||
aspell_dir = aspell
|
||||
endif
|
||||
|
||||
if PLUGIN_BUFLIST
|
||||
buflist_dir = buflist
|
||||
endif
|
||||
|
||||
if PLUGIN_CHARSET
|
||||
charset_dir = charset
|
||||
endif
|
||||
@ -109,10 +113,26 @@ if PLUGIN_XFER
|
||||
xfer_dir = xfer
|
||||
endif
|
||||
|
||||
SUBDIRS = . $(alias_dir) $(aspell_dir) $(charset_dir) $(exec_dir) $(fifo_dir) \
|
||||
$(irc_dir) $(logger_dir) $(relay_dir) $(script_dir) $(perl_dir) \
|
||||
$(python_dir) $(ruby_dir) $(lua_dir) $(tcl_dir) $(guile_dir) \
|
||||
$(javascript_dir) $(trigger_dir) $(xfer_dir)
|
||||
SUBDIRS = . \
|
||||
$(alias_dir) \
|
||||
$(aspell_dir) \
|
||||
$(buflist_dir) \
|
||||
$(charset_dir) \
|
||||
$(exec_dir) \
|
||||
$(fifo_dir) \
|
||||
$(irc_dir) \
|
||||
$(logger_dir) \
|
||||
$(relay_dir) \
|
||||
$(script_dir) \
|
||||
$(perl_dir) \
|
||||
$(python_dir) \
|
||||
$(ruby_dir) \
|
||||
$(lua_dir) \
|
||||
$(tcl_dir) \
|
||||
$(guile_dir) \
|
||||
$(javascript_dir) \
|
||||
$(trigger_dir) \
|
||||
$(xfer_dir)
|
||||
|
||||
EXTRA_DIST = CMakeLists.txt
|
||||
|
||||
|
28
src/plugins/buflist/CMakeLists.txt
Normal file
28
src/plugins/buflist/CMakeLists.txt
Normal file
@ -0,0 +1,28 @@
|
||||
#
|
||||
# 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/>.
|
||||
#
|
||||
|
||||
add_library(buflist MODULE
|
||||
buflist.c buflist.h
|
||||
buflist-bar-item.c buflist-bar-item.h
|
||||
buflist-config.c buflist-config.h)
|
||||
set_target_properties(buflist PROPERTIES PREFIX "")
|
||||
|
||||
target_link_libraries(buflist)
|
||||
|
||||
install(TARGETS buflist LIBRARY DESTINATION ${LIBDIR}/plugins)
|
36
src/plugins/buflist/Makefile.am
Normal file
36
src/plugins/buflist/Makefile.am
Normal file
@ -0,0 +1,36 @@
|
||||
#
|
||||
# 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/>.
|
||||
#
|
||||
|
||||
AM_CPPFLAGS = -DLOCALEDIR=\"$(datadir)/locale\" $(BUFLIST_CFLAGS)
|
||||
|
||||
libdir = ${weechat_libdir}/plugins
|
||||
|
||||
lib_LTLIBRARIES = buflist.la
|
||||
|
||||
buflist_la_SOURCES = buflist.c \
|
||||
buflist.h \
|
||||
buflist-bar-item.c \
|
||||
buflist-bar-item.h \
|
||||
buflist-config.c \
|
||||
buflist-config.h
|
||||
|
||||
buflist_la_LDFLAGS = -module -no-undefined
|
||||
buflist_la_LIBADD = $(BUFLIST_LFLAGS)
|
||||
|
||||
EXTRA_DIST = CMakeLists.txt
|
181
src/plugins/buflist/buflist-bar-item.c
Normal file
181
src/plugins/buflist/buflist-bar-item.c
Normal file
@ -0,0 +1,181 @@
|
||||
/*
|
||||
* buflist-bar-item.c - bar item for buflist plugin
|
||||
*
|
||||
* 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 "../weechat-plugin.h"
|
||||
#include "buflist.h"
|
||||
#include "buflist-config.h"
|
||||
|
||||
|
||||
/*
|
||||
* Returns content of bar item "buffer_plugin": bar item with buffer plugin.
|
||||
*/
|
||||
|
||||
char *
|
||||
buflist_bar_item_buflist (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_hdata *hdata_buffer;
|
||||
struct t_gui_buffer *ptr_buffer, *ptr_next_buffer, *ptr_current_buffer;
|
||||
char **buflist, *str_buflist;
|
||||
char str_format_number[32], str_format_number_empty[32];
|
||||
char str_number[32], str_indent_name[4], *line;
|
||||
const char *ptr_format, *ptr_format_current, *ptr_name, *ptr_type;
|
||||
int length_max_number, current_buffer, number, prev_number;
|
||||
struct t_hashtable *pointers, *extra_vars;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) pointer;
|
||||
(void) data;
|
||||
(void) item;
|
||||
(void) window;
|
||||
(void) buffer;
|
||||
(void) extra_info;
|
||||
|
||||
prev_number = -1;
|
||||
|
||||
pointers = weechat_hashtable_new (8,
|
||||
WEECHAT_HASHTABLE_STRING,
|
||||
WEECHAT_HASHTABLE_POINTER,
|
||||
NULL,
|
||||
NULL);
|
||||
if (!pointers)
|
||||
return NULL;
|
||||
extra_vars = weechat_hashtable_new (32,
|
||||
WEECHAT_HASHTABLE_STRING,
|
||||
WEECHAT_HASHTABLE_POINTER,
|
||||
NULL,
|
||||
NULL);
|
||||
if (!extra_vars)
|
||||
{
|
||||
weechat_hashtable_free (pointers);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
buflist = weechat_string_dyn_alloc (1);
|
||||
|
||||
ptr_format = weechat_config_string (buflist_config_format_buffer);
|
||||
ptr_format_current = weechat_config_string (buflist_config_format_buffer_current);
|
||||
|
||||
ptr_current_buffer = weechat_current_buffer ();
|
||||
|
||||
hdata_buffer = weechat_hdata_get ("buffer");
|
||||
ptr_buffer = weechat_hdata_get_list (hdata_buffer, "last_gui_buffer");
|
||||
|
||||
length_max_number = snprintf (
|
||||
str_number, sizeof (str_number),
|
||||
"%d", weechat_hdata_integer (hdata_buffer, ptr_buffer, "number"));
|
||||
snprintf (str_format_number, sizeof (str_format_number),
|
||||
"%%%dd", length_max_number);
|
||||
snprintf (str_format_number_empty, sizeof (str_format_number_empty),
|
||||
"%%-%ds", length_max_number);
|
||||
|
||||
ptr_buffer = weechat_hdata_get_list (hdata_buffer, "gui_buffers");
|
||||
|
||||
while (ptr_buffer)
|
||||
{
|
||||
ptr_next_buffer = weechat_hdata_move (hdata_buffer, ptr_buffer, 1);
|
||||
|
||||
current_buffer = (ptr_buffer == ptr_current_buffer);
|
||||
|
||||
ptr_name = weechat_hdata_string (hdata_buffer, ptr_buffer,
|
||||
"short_name");
|
||||
if (!ptr_name)
|
||||
ptr_name = weechat_hdata_string (hdata_buffer, ptr_buffer, "name");
|
||||
|
||||
if (*buflist[0])
|
||||
{
|
||||
if (!weechat_string_dyn_concat (buflist, "\n"))
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* buffer number */
|
||||
number = weechat_hdata_integer (hdata_buffer, ptr_buffer, "number");
|
||||
if (number != prev_number)
|
||||
{
|
||||
snprintf (str_number, sizeof (str_number),
|
||||
str_format_number, number);
|
||||
}
|
||||
else
|
||||
{
|
||||
snprintf (str_number, sizeof (str_number),
|
||||
str_format_number_empty, " ");
|
||||
}
|
||||
prev_number = number;
|
||||
|
||||
/* buffer name */
|
||||
str_indent_name[0] = '\0';
|
||||
ptr_type = weechat_buffer_get_string (ptr_buffer, "localvar_type");
|
||||
if (ptr_type
|
||||
&& ((strcmp (ptr_type, "channel") == 0)
|
||||
|| (strcmp (ptr_type, "private") == 0)))
|
||||
{
|
||||
snprintf (str_indent_name, sizeof (str_indent_name), " ");
|
||||
}
|
||||
|
||||
/* set pointers */
|
||||
weechat_hashtable_set (pointers, "buffer", ptr_buffer);
|
||||
|
||||
/* set extra variables */
|
||||
weechat_hashtable_set (extra_vars, "number", str_number);
|
||||
weechat_hashtable_set (extra_vars, "indent", str_indent_name);
|
||||
weechat_hashtable_set (extra_vars, "name", ptr_name);
|
||||
|
||||
/* build string */
|
||||
line = weechat_string_eval_expression (
|
||||
(current_buffer) ? ptr_format_current : ptr_format,
|
||||
pointers, extra_vars, NULL);
|
||||
if (!weechat_string_dyn_concat (buflist, line))
|
||||
{
|
||||
free (line);
|
||||
weechat_hashtable_free (extra_vars);
|
||||
return NULL;
|
||||
}
|
||||
free (line);
|
||||
|
||||
ptr_buffer = ptr_next_buffer;
|
||||
}
|
||||
|
||||
weechat_hashtable_free (pointers);
|
||||
weechat_hashtable_free (extra_vars);
|
||||
|
||||
str_buflist = *buflist;
|
||||
weechat_string_dyn_free (buflist, 0);
|
||||
|
||||
return str_buflist;
|
||||
}
|
||||
|
||||
/*
|
||||
* Initializes buflist bar items.
|
||||
*/
|
||||
|
||||
void
|
||||
buflist_bar_item_init ()
|
||||
{
|
||||
weechat_bar_item_new ("buflist",
|
||||
&buflist_bar_item_buflist, NULL, NULL);
|
||||
}
|
27
src/plugins/buflist/buflist-bar-item.h
Normal file
27
src/plugins/buflist/buflist-bar-item.h
Normal file
@ -0,0 +1,27 @@
|
||||
/*
|
||||
* 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_BAR_ITEM_H
|
||||
#define WEECHAT_BUFLIST_BAR_ITEM_H 1
|
||||
|
||||
#define BUFLIST_BAR_ITEM_NAME "buflist"
|
||||
|
||||
extern void buflist_bar_item_init ();
|
||||
|
||||
#endif /* WEECHAT_BUFLIST_BAR_ITEM_H */
|
137
src/plugins/buflist/buflist-config.c
Normal file
137
src/plugins/buflist/buflist-config.c
Normal file
@ -0,0 +1,137 @@
|
||||
/*
|
||||
* buflist-config.c - buflist configuration options (file buflist.conf)
|
||||
*
|
||||
* 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 "../weechat-plugin.h"
|
||||
#include "buflist.h"
|
||||
#include "buflist-config.h"
|
||||
|
||||
|
||||
struct t_config_file *buflist_config_file = NULL;
|
||||
|
||||
/* buflist config, format section */
|
||||
|
||||
struct t_config_option *buflist_config_format_buffer;
|
||||
struct t_config_option *buflist_config_format_buffer_current;
|
||||
|
||||
|
||||
/*
|
||||
* Callback for changes on option "irc.network.lag_min_show".
|
||||
*/
|
||||
|
||||
void
|
||||
buflist_config_change_buflist (const void *pointer, void *data,
|
||||
struct t_config_option *option)
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) pointer;
|
||||
(void) data;
|
||||
(void) option;
|
||||
|
||||
weechat_bar_item_update ("buflist");
|
||||
}
|
||||
|
||||
/*
|
||||
* Initializes buflist configuration file.
|
||||
*
|
||||
* Returns:
|
||||
* 1: OK
|
||||
* 0: error
|
||||
*/
|
||||
|
||||
int
|
||||
buflist_config_init ()
|
||||
{
|
||||
struct t_config_section *ptr_section;
|
||||
|
||||
buflist_config_file = weechat_config_new (BUFLIST_CONFIG_NAME,
|
||||
NULL, NULL, NULL);
|
||||
if (!buflist_config_file)
|
||||
return 0;
|
||||
|
||||
/* format */
|
||||
ptr_section = weechat_config_new_section (buflist_config_file, "format",
|
||||
0, 0,
|
||||
NULL, NULL, NULL,
|
||||
NULL, NULL, NULL,
|
||||
NULL, NULL, NULL,
|
||||
NULL, NULL, NULL,
|
||||
NULL, NULL, NULL);
|
||||
if (!ptr_section)
|
||||
{
|
||||
weechat_config_free (buflist_config_file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
buflist_config_format_buffer = weechat_config_new_option (
|
||||
buflist_config_file, ptr_section,
|
||||
"buffer", "string",
|
||||
N_("format of each line with a buffer"),
|
||||
NULL, 0, 0,
|
||||
"${color:green}${number}.${indent}${color:default}${name}",
|
||||
NULL, 0,
|
||||
NULL, NULL, NULL,
|
||||
&buflist_config_change_buflist, NULL, NULL,
|
||||
NULL, NULL, NULL);
|
||||
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"),
|
||||
NULL, 0, 0,
|
||||
"${color:lightgreen,blue}${number}.${indent}${color:*white}${name}",
|
||||
NULL, 0,
|
||||
NULL, NULL, NULL,
|
||||
&buflist_config_change_buflist, NULL, NULL,
|
||||
NULL, NULL, NULL);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Reads buflist configuration file.
|
||||
*/
|
||||
|
||||
int
|
||||
buflist_config_read ()
|
||||
{
|
||||
return weechat_config_read (buflist_config_file);
|
||||
}
|
||||
|
||||
/*
|
||||
* Writes buflist configuration file.
|
||||
*/
|
||||
|
||||
int
|
||||
buflist_config_write ()
|
||||
{
|
||||
return weechat_config_write (buflist_config_file);
|
||||
}
|
||||
|
||||
/*
|
||||
* Frees buflist configuration.
|
||||
*/
|
||||
|
||||
void
|
||||
buflist_config_free ()
|
||||
{
|
||||
weechat_config_free (buflist_config_file);
|
||||
}
|
35
src/plugins/buflist/buflist-config.h
Normal file
35
src/plugins/buflist/buflist-config.h
Normal file
@ -0,0 +1,35 @@
|
||||
/*
|
||||
* 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_CONFIG_H
|
||||
#define WEECHAT_BUFLIST_CONFIG_H 1
|
||||
|
||||
#define BUFLIST_CONFIG_NAME "buflist"
|
||||
|
||||
extern struct t_config_file *buflist_config_file;
|
||||
|
||||
extern struct t_config_option *buflist_config_format_buffer;
|
||||
extern struct t_config_option *buflist_config_format_buffer_current;
|
||||
|
||||
extern int buflist_config_init ();
|
||||
extern int buflist_config_read ();
|
||||
extern int buflist_config_write ();
|
||||
extern void buflist_config_free ();
|
||||
|
||||
#endif /* WEECHAT_BUFLIST_CONFIG_H */
|
118
src/plugins/buflist/buflist.c
Normal file
118
src/plugins/buflist/buflist.c
Normal file
@ -0,0 +1,118 @@
|
||||
/*
|
||||
* buflist.c - Bar with list of buffers
|
||||
*
|
||||
* 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 "../weechat-plugin.h"
|
||||
#include "buflist.h"
|
||||
#include "buflist-bar-item.h"
|
||||
#include "buflist-config.h"
|
||||
|
||||
|
||||
WEECHAT_PLUGIN_NAME(BUFLIST_PLUGIN_NAME);
|
||||
WEECHAT_PLUGIN_DESCRIPTION(N_("Buffers list"));
|
||||
WEECHAT_PLUGIN_AUTHOR("Sébastien Helleu <flashcode@flashtux.org>");
|
||||
WEECHAT_PLUGIN_VERSION(WEECHAT_VERSION);
|
||||
WEECHAT_PLUGIN_LICENSE(WEECHAT_LICENSE);
|
||||
WEECHAT_PLUGIN_PRIORITY(14000);
|
||||
|
||||
struct t_weechat_plugin *weechat_buflist_plugin = NULL;
|
||||
|
||||
|
||||
/*
|
||||
* Callback for a signal on a buffer.
|
||||
*/
|
||||
|
||||
int
|
||||
buflist_signal_buffer_cb (const void *pointer, void *data,
|
||||
const char *signal, const char *type_data,
|
||||
void *signal_data)
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) pointer;
|
||||
(void) data;
|
||||
(void) signal;
|
||||
(void) type_data;
|
||||
(void) signal_data;
|
||||
|
||||
weechat_bar_item_update ("buflist");
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* Initializes buflist plugin.
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
{
|
||||
char *signals_buffers[] =
|
||||
{ "buffer_opened", "buffer_closed", "buffer_merged", "buffer_unmerged",
|
||||
"buffer_moved", "buffer_renamed", "buffer_switch", "buffer_hidden",
|
||||
"buffer_unhidden", "buffer_localvar_added", "buffer_localvar_changed",
|
||||
"window_switch", NULL
|
||||
};
|
||||
int i;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) argc;
|
||||
(void) argv;
|
||||
|
||||
weechat_plugin = plugin;
|
||||
|
||||
if (!buflist_config_init ())
|
||||
return WEECHAT_RC_ERROR;
|
||||
|
||||
buflist_config_read ();
|
||||
|
||||
/* hook some signals */
|
||||
for (i = 0; signals_buffers[i]; i++)
|
||||
{
|
||||
weechat_hook_signal (signals_buffers[i],
|
||||
&buflist_signal_buffer_cb, NULL, NULL);
|
||||
}
|
||||
|
||||
buflist_bar_item_init ();
|
||||
|
||||
weechat_bar_new (BUFLIST_BAR_NAME, "off", "0", "root", "", "left",
|
||||
"columns_vertical", "vertical", "0", "0",
|
||||
"default", "default", "default", "on",
|
||||
BUFLIST_BAR_ITEM_NAME);
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* Ends buflist plugin.
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_plugin_end (struct t_weechat_plugin *plugin)
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) plugin;
|
||||
|
||||
buflist_config_write ();
|
||||
buflist_config_free ();
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
31
src/plugins/buflist/buflist.h
Normal file
31
src/plugins/buflist/buflist.h
Normal file
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright (C) 2003-2017 Sébastien Helleu <flashcode@flashtux.org>
|
||||
* Copyright (C) 2006 Emmanuel Bouthenot <kolter@openics.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_H
|
||||
#define WEECHAT_BUFLIST_H 1
|
||||
|
||||
#define weechat_plugin weechat_buflist_plugin
|
||||
#define BUFLIST_PLUGIN_NAME "buflist"
|
||||
|
||||
#define BUFLIST_BAR_NAME "buflist"
|
||||
|
||||
extern struct t_weechat_plugin *weechat_buflist_plugin;
|
||||
|
||||
#endif /* WEECHAT_BUFLIST_H */
|
@ -53,6 +53,7 @@ TEST(Plugins, Loaded)
|
||||
/* check that all plugins are properly loaded */
|
||||
CHECK(hdata_search (hdata, plugins, "${plugin.name} == alias", 1));
|
||||
CHECK(hdata_search (hdata, plugins, "${plugin.name} == aspell", 1));
|
||||
CHECK(hdata_search (hdata, plugins, "${plugin.name} == buflist", 1));
|
||||
CHECK(hdata_search (hdata, plugins, "${plugin.name} == charset", 1));
|
||||
CHECK(hdata_search (hdata, plugins, "${plugin.name} == exec", 1));
|
||||
CHECK(hdata_search (hdata, plugins, "${plugin.name} == fifo", 1));
|
||||
|
@ -93,6 +93,7 @@ weechat_CONTENTS="
|
||||
usr/bin/
|
||||
usr/lib/weechat/plugins/alias.dll
|
||||
usr/lib/weechat/plugins/aspell.dll
|
||||
usr/lib/weechat/plugins/buflist.dll
|
||||
usr/lib/weechat/plugins/charset.dll
|
||||
usr/lib/weechat/plugins/exec.dll
|
||||
usr/lib/weechat/plugins/fifo.dll
|
||||
|
Loading…
x
Reference in New Issue
Block a user