guile: new script plugin for scheme (task #7289)
parent
d95aef2134
commit
9b42328d55
|
@ -59,29 +59,30 @@ ELSE(DEFINED INCLUDEDIR)
|
|||
SET(INCLUDEDIR ${CMAKE_INSTALL_PREFIX}/include/${PROJECT_NAME})
|
||||
ENDIF(DEFINED INCLUDEDIR)
|
||||
|
||||
OPTION(ENABLE_NCURSES "Enable Ncurses interface" ON)
|
||||
OPTION(ENABLE_GTK "Enable GTK interface" OFF)
|
||||
OPTION(ENABLE_NLS "Enable Native Language Support" ON)
|
||||
OPTION(ENABLE_GCRYPT "Enable libgcrypt support" ON)
|
||||
OPTION(ENABLE_GNUTLS "Enable SSLv3/TLS support" ON)
|
||||
OPTION(ENABLE_LARGEFILE "Enable Large File Support" ON)
|
||||
OPTION(ENABLE_ALIAS "Enable Alias plugin" ON)
|
||||
OPTION(ENABLE_ASPELL "Enable Aspell plugin" ON)
|
||||
OPTION(ENABLE_CHARSET "Enable Charset plugin" ON)
|
||||
OPTION(ENABLE_DEMO "Enable Demo plugin" OFF)
|
||||
OPTION(ENABLE_FIFO "Enable FIFO plugin" ON)
|
||||
OPTION(ENABLE_IRC "Enable IRC plugin" ON)
|
||||
OPTION(ENABLE_LOGGER "Enable Logger plugin" ON)
|
||||
OPTION(ENABLE_RELAY "Enable Relay plugin" ON)
|
||||
OPTION(ENABLE_RMODIFIER "Enable Rmodifier plugin" ON)
|
||||
OPTION(ENABLE_SCRIPTS "Enable script plugins" ON)
|
||||
OPTION(ENABLE_PERL "Enable Perl scripting language" ON)
|
||||
OPTION(ENABLE_PYTHON "Enable Python scripting language" ON)
|
||||
OPTION(ENABLE_RUBY "Enable Ruby scripting language" ON)
|
||||
OPTION(ENABLE_LUA "Enable Lua scripting language" ON)
|
||||
OPTION(ENABLE_TCL "Enable Tcl scripting language" ON)
|
||||
OPTION(ENABLE_XFER "Enable Xfer plugin" ON)
|
||||
OPTION(ENABLE_DOC "Enable Documentation" ON)
|
||||
OPTION(ENABLE_NCURSES "Enable Ncurses interface" ON)
|
||||
OPTION(ENABLE_GTK "Enable GTK interface" OFF)
|
||||
OPTION(ENABLE_NLS "Enable Native Language Support" ON)
|
||||
OPTION(ENABLE_GCRYPT "Enable libgcrypt support" ON)
|
||||
OPTION(ENABLE_GNUTLS "Enable SSLv3/TLS support" ON)
|
||||
OPTION(ENABLE_LARGEFILE "Enable Large File Support" ON)
|
||||
OPTION(ENABLE_ALIAS "Enable Alias plugin" ON)
|
||||
OPTION(ENABLE_ASPELL "Enable Aspell plugin" ON)
|
||||
OPTION(ENABLE_CHARSET "Enable Charset plugin" ON)
|
||||
OPTION(ENABLE_DEMO "Enable Demo plugin" OFF)
|
||||
OPTION(ENABLE_FIFO "Enable FIFO plugin" ON)
|
||||
OPTION(ENABLE_IRC "Enable IRC plugin" ON)
|
||||
OPTION(ENABLE_LOGGER "Enable Logger plugin" ON)
|
||||
OPTION(ENABLE_RELAY "Enable Relay plugin" ON)
|
||||
OPTION(ENABLE_RMODIFIER "Enable Rmodifier plugin" ON)
|
||||
OPTION(ENABLE_SCRIPTS "Enable script plugins" ON)
|
||||
OPTION(ENABLE_PERL "Enable Perl scripting language" ON)
|
||||
OPTION(ENABLE_PYTHON "Enable Python scripting language" ON)
|
||||
OPTION(ENABLE_RUBY "Enable Ruby scripting language" ON)
|
||||
OPTION(ENABLE_LUA "Enable Lua scripting language" ON)
|
||||
OPTION(ENABLE_TCL "Enable Tcl scripting language" ON)
|
||||
OPTION(ENABLE_GUILE "Enable Scheme (guile) scripting language" ON)
|
||||
OPTION(ENABLE_XFER "Enable Xfer plugin" ON)
|
||||
OPTION(ENABLE_DOC "Enable Documentation" ON)
|
||||
|
||||
IF(ENABLE_NLS)
|
||||
ADD_SUBDIRECTORY( po )
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
WeeChat ChangeLog
|
||||
=================
|
||||
Sébastien Helleu <flashcode@flashtux.org>
|
||||
v0.3.7-dev, 2011-10-25
|
||||
v0.3.7-dev, 2011-10-26
|
||||
|
||||
|
||||
Version 0.3.7 (under dev!)
|
||||
|
@ -10,6 +10,7 @@ Version 0.3.7 (under dev!)
|
|||
* core: fix compilation error with "pid_t" on Mac OS X (bug #34639)
|
||||
* core: enable background process under Cygwin to connect to servers, fix
|
||||
reconnection problem (bug #34626)
|
||||
* guile: new script plugin for scheme (task #7289)
|
||||
|
||||
Version 0.3.6 (2011-10-22)
|
||||
--------------------------
|
||||
|
|
|
@ -43,6 +43,7 @@ EXTRA_DIST = CMakeLists.txt \
|
|||
cmake/FindRuby.cmake \
|
||||
cmake/FindSourcehighlight.cmake \
|
||||
cmake/FindTCL.cmake \
|
||||
cmake/FindGuile.cmake \
|
||||
cmake/makedist.sh.in \
|
||||
po/CMakeLists.txt \
|
||||
po/srcfiles.cmake \
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
#
|
||||
# Copyright (C) 2011 Sebastien 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/>.
|
||||
#
|
||||
|
||||
# - Find Guile
|
||||
# This module finds if Guile is installed and determines where the include files
|
||||
# and libraries are. It also determines what the name of the library is. This
|
||||
# code sets the following variables:
|
||||
#
|
||||
# GUILE_FOUND = Guile is installed
|
||||
# GUILE_INCLUDE_DIRS = Guile include directory
|
||||
# GUILE_LIBRARIES = Link options to compile Guile
|
||||
|
||||
IF(GUILE_FOUND)
|
||||
# Already in cache, be silent
|
||||
SET(GUILE_FIND_QUIETLY TRUE)
|
||||
ENDIF(GUILE_FOUND)
|
||||
|
||||
FIND_PATH(GUILE_INCLUDE_DIR libguile.h /usr/include /usr/local/include /usr/include/libguile /usr/local/include/libguile)
|
||||
|
||||
FIND_LIBRARY(GUILE_LIBRARY NAMES guile PATH /usr/lib /usr/local/lib)
|
||||
|
||||
IF(GUILE_INCLUDE_DIR AND GUILE_LIBRARY)
|
||||
SET(GUILE_FOUND TRUE)
|
||||
SET(GUILE_INCLUDE_DIRS ${GUILE_INCLUDE_DIR})
|
||||
SET(GUILE_LIBRARIES ${GUILE_LIBRARY})
|
||||
ELSE(GUILE_INCLUDE_DIR AND GUILE_LIBRARY)
|
||||
SET(GUILE_FOUND FALSE)
|
||||
SET(GUILE_INCLUDE_DIRS)
|
||||
SET(GUILE_LIBRARIES)
|
||||
ENDIF(GUILE_INCLUDE_DIR AND GUILE_LIBRARY)
|
||||
|
||||
MARK_AS_ADVANCED(
|
||||
GUILE_INCLUDE_DIR
|
||||
GUILE_LIBRARY
|
||||
)
|
42
configure.in
42
configure.in
|
@ -121,6 +121,7 @@ AH_VERBATIM([PLUGIN_PYTHON], [#undef PLUGIN_PYTHON])
|
|||
AH_VERBATIM([PLUGIN_RUBY], [#undef PLUGIN_RUBY])
|
||||
AH_VERBATIM([PLUGIN_LUA], [#undef PLUGIN_LUA])
|
||||
AH_VERBATIM([PLUGIN_TCL], [#undef PLUGIN_TCL])
|
||||
AH_VERBATIM([PLUGIN_GUILE], [#undef PLUGIN_GUILE])
|
||||
AH_VERBATIM([PLUGIN_XFER], [#undef PLUGIN_XFER])
|
||||
AH_VERBATIM([DOC], [#undef DOC])
|
||||
|
||||
|
@ -148,6 +149,7 @@ AC_ARG_ENABLE(python, [ --disable-python turn off Python script pl
|
|||
AC_ARG_ENABLE(ruby, [ --disable-ruby turn off Ruby script plugin (default=compiled if found)],enable_ruby=$enableval,enable_ruby=yes)
|
||||
AC_ARG_ENABLE(lua, [ --disable-lua turn off Lua script plugin (default=compiled if found)],enable_lua=$enableval,enable_lua=yes)
|
||||
AC_ARG_ENABLE(tcl, [ --disable-tcl turn off Tcl script plugin (default=compiled if found)],enable_tcl=$enableval,enable_tcl=yes)
|
||||
AC_ARG_ENABLE(guile, [ --disable-guile turn off Guile (scheme) script plugin (default=compiled if found)],enable_guile=$enableval,enable_guile=yes)
|
||||
AC_ARG_ENABLE(xfer, [ --disable-xfer turn off Xfer (file transfer) plugin (default=compiled if found)],enable_xfer=$enableval,enable_xfer=yes)
|
||||
AC_ARG_WITH(lua-inc, [ --with-lua-inc=DIR, lua include files are in DIR (default=autodetect)],lua_inc=$withval,lua_inc='')
|
||||
AC_ARG_WITH(lua-lib, [ --with-lua-lib=DIR, lua library files are in DIR (default=autodetect)],lua_lib=$withval,lua_lib='')
|
||||
|
@ -297,6 +299,7 @@ if test "x$enable_scripts" = "xno" ; then
|
|||
enable_ruby="no"
|
||||
enable_lua="no"
|
||||
enable_tcl="no"
|
||||
enable_guile="no"
|
||||
fi
|
||||
|
||||
# ---------------------------------- alias -------------------------------------
|
||||
|
@ -746,6 +749,40 @@ if test "x$enable_tcl" = "xyes" ; then
|
|||
AC_DEFINE(PLUGIN_TCL)
|
||||
fi
|
||||
|
||||
# --------------------------------- guile -------------------------------------
|
||||
|
||||
GUILE_VERSION=
|
||||
|
||||
if test "x$enable_guile" = "xyes" ; then
|
||||
enable_plugins="yes"
|
||||
|
||||
guile_found="no"
|
||||
GUILECONFIG=""
|
||||
AC_CHECK_PROGS(GUILECONFIG, guile-config)
|
||||
if test "x$GUILECONFIG" != "x" ; then
|
||||
AC_MSG_CHECKING(for Guile headers and librairies with guile-config)
|
||||
echo
|
||||
GUILE_CFLAGS=`$GUILECONFIG compile`
|
||||
GUILE_LFLAGS=`$GUILECONFIG link`
|
||||
GUILE_VERSION=`$GUILECONFIG info guileversion`
|
||||
tcl_found="yes"
|
||||
fi
|
||||
|
||||
if test "x$tcl_found" = "xno" ; then
|
||||
AC_MSG_WARN([
|
||||
*** Script guile-config couldn't be found on your system.
|
||||
*** WeeChat will be built without Guile (scheme) support.])
|
||||
enable_guile="no"
|
||||
not_found="$not_found guile"
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "x$enable_guile" = "xyes" ; then
|
||||
AC_SUBST(GUILE_CFLAGS)
|
||||
AC_SUBST(GUILE_LFLAGS)
|
||||
AC_DEFINE(PLUGIN_GUILE)
|
||||
fi
|
||||
|
||||
# ---------------------------------- xfer --------------------------------------
|
||||
|
||||
if test "x$enable_xfer" = "xyes" ; then
|
||||
|
@ -1023,6 +1060,7 @@ AM_CONDITIONAL(PLUGIN_PYTHON, test "$enable_python" = "yes")
|
|||
AM_CONDITIONAL(PLUGIN_RUBY, test "$enable_ruby" = "yes")
|
||||
AM_CONDITIONAL(PLUGIN_LUA, test "$enable_lua" = "yes")
|
||||
AM_CONDITIONAL(PLUGIN_TCL, test "$enable_tcl" = "yes")
|
||||
AM_CONDITIONAL(PLUGIN_GUILE, test "$enable_guile" = "yes")
|
||||
AM_CONDITIONAL(PLUGIN_XFER, test "$enable_xfer" = "yes")
|
||||
AM_CONDITIONAL(DOC, test "$enable_doc" = "yes")
|
||||
|
||||
|
@ -1053,6 +1091,7 @@ AC_OUTPUT([Makefile
|
|||
src/plugins/scripts/ruby/Makefile
|
||||
src/plugins/scripts/lua/Makefile
|
||||
src/plugins/scripts/tcl/Makefile
|
||||
src/plugins/scripts/guile/Makefile
|
||||
src/plugins/xfer/Makefile
|
||||
src/gui/Makefile
|
||||
src/gui/curses/Makefile
|
||||
|
@ -1129,6 +1168,9 @@ fi
|
|||
if test "x$enable_tcl" = "xyes"; then
|
||||
listplugins="$listplugins tcl($TCL_VERSION)"
|
||||
fi
|
||||
if test "x$enable_guile" = "xyes"; then
|
||||
listplugins="$listplugins guile($GUILE_VERSION)"
|
||||
fi
|
||||
if test "x$enable_xfer" = "xyes"; then
|
||||
listplugins="$listplugins xfer"
|
||||
fi
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
|
||||
| aspell | aspell_langs | Liste der Unterstützten Übersetzungen (lang) für Aspell
|
||||
|
||||
| guile | guile_script | Liste der Skripten
|
||||
|
||||
| irc | irc_channel | Aktueller IRC-Channel
|
||||
|
||||
| irc | irc_channel_nicks_hosts | Liste der Nicks und Hostnamen des aktuellen Channels
|
||||
|
@ -38,11 +40,11 @@
|
|||
|
||||
| irc | nick | Liste der Nicks im aktuellen Channel
|
||||
|
||||
| lua | lua_script | Liste der Skripten:
|
||||
| lua | lua_script | Liste der Skripten
|
||||
|
||||
| perl | perl_script | Liste der Skripten:
|
||||
| perl | perl_script | Liste der Skripten
|
||||
|
||||
| python | python_script | Liste der Skripten:
|
||||
| python | python_script | Liste der Skripten
|
||||
|
||||
| relay | relay_free_port | Erster freier Port für Relay-Erweiterung
|
||||
|
||||
|
@ -52,9 +54,9 @@
|
|||
|
||||
| rmodifier | rmodifier | Liste der rmodifier
|
||||
|
||||
| ruby | ruby_script | Liste der Skripten:
|
||||
| ruby | ruby_script | Liste der Skripten
|
||||
|
||||
| tcl | tcl_script | Liste der Skripten:
|
||||
| tcl | tcl_script | Liste der Skripten
|
||||
|
||||
| weechat | bars_names | Namen der Infobars
|
||||
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
|
||||
| alias | alias | Liste der Alias | Alias Pointer (optional) | Alias Name (darf mit einem "*" als Platzhalter beginnen oder enden) (optional)
|
||||
|
||||
| guile | guile_script | Liste der Skripten | Skript Pointer (optional) | Name des Skripts (darf mit einem "*" als Platzhalter beginnen oder enden) (optional)
|
||||
|
||||
| irc | irc_channel | Liste der Channels eines IRC-Servers | Channel Pointer (optional) | Server,Channel (Channel ist optional)
|
||||
|
||||
| irc | irc_ignore | Liste von ignorierten IRCs | Ignore Pointer (optional) | -
|
||||
|
@ -16,19 +18,19 @@
|
|||
|
||||
| logger | logger_buffer | Liste der protokollierten Buffer | Logger Pointer (optional) | -
|
||||
|
||||
| lua | lua_script | Liste der Skripten: | Skript Pointer (optional) | Name des Skripts (darf mit einem "*" als Platzhalter beginnen oder enden) (optional)
|
||||
| lua | lua_script | Liste der Skripten | Skript Pointer (optional) | Name des Skripts (darf mit einem "*" als Platzhalter beginnen oder enden) (optional)
|
||||
|
||||
| perl | perl_script | Liste der Skripten: | Skript Pointer (optional) | Name des Skripts (darf mit einem "*" als Platzhalter beginnen oder enden) (optional)
|
||||
| perl | perl_script | Liste der Skripten | Skript Pointer (optional) | Name des Skripts (darf mit einem "*" als Platzhalter beginnen oder enden) (optional)
|
||||
|
||||
| python | python_script | Liste der Skripten: | Skript Pointer (optional) | Name des Skripts (darf mit einem "*" als Platzhalter beginnen oder enden) (optional)
|
||||
| python | python_script | Liste der Skripten | Skript Pointer (optional) | Name des Skripts (darf mit einem "*" als Platzhalter beginnen oder enden) (optional)
|
||||
|
||||
| relay | relay | Liste der Relay-Clients | Relay Pointer (optional) | -
|
||||
|
||||
| rmodifier | rmodifier | Liste der rmodifier | rmodifier Pointer (optional) | rmodifier Name (darf mit einem "*" als Platzhalter beginnen oder enden) (optional)
|
||||
|
||||
| ruby | ruby_script | Liste der Skripten: | Skript Pointer (optional) | Name des Skripts (darf mit einem "*" als Platzhalter beginnen oder enden) (optional)
|
||||
| ruby | ruby_script | Liste der Skripten | Skript Pointer (optional) | Name des Skripts (darf mit einem "*" als Platzhalter beginnen oder enden) (optional)
|
||||
|
||||
| tcl | tcl_script | Liste der Skripten: | Skript Pointer (optional) | Name des Skripts (darf mit einem "*" als Platzhalter beginnen oder enden) (optional)
|
||||
| tcl | tcl_script | Liste der Skripten | Skript Pointer (optional) | Name des Skripts (darf mit einem "*" als Platzhalter beginnen oder enden) (optional)
|
||||
|
||||
| weechat | bar | Auflistung der Bars | Bar Pointer (optional) | Bar Name (darf mit einem "*" als Platzhalter beginnen oder enden) (optional)
|
||||
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
[[command_guile_guile]]
|
||||
[command]*`guile`* auflisten/installieren/deinstallieren von Skripten::
|
||||
........................................
|
||||
/guile list|listfull [<name>]
|
||||
load <filename>
|
||||
autoload
|
||||
reload|unload [<name>]
|
||||
|
||||
list: installierte Erweiterungen werden aufgelistet
|
||||
listfull: detaillierte Auflistung aller installierten Erweiterungen
|
||||
load: installiert eine Erweiterung
|
||||
autoload: installiert automatisch alle Erweiterungen aus System- oder Benutzerverzeichnis
|
||||
reload: eine Erweiterung wird erneut installiert (falls kein Name angegeben wird dann werden alle Erweiterungen entfernt und erneut installiert)
|
||||
unload: deinstalliert eine oder alle Erweiterungen
|
||||
filename: Skript (Datei) das geladen werden soll
|
||||
name: Name eines Skripts (Name welcher mit der "register" Funktion genutzt wird)
|
||||
|
||||
Ohne Angabe eines Argumentes listet /plugin alle geladenen Erweiterungen auf.
|
||||
........................................
|
||||
|
|
@ -16,9 +16,16 @@ Einleitung
|
|||
WeeChat (Wee Enhanced Environment for Chat) ist ein freier, schneller und
|
||||
schlanker Chat-Client der für viele Betriebssysteme entwickelt wird.
|
||||
|
||||
Diese Anleitung beschreibt die Vorgehensweise um Skripten für WeeChat zu
|
||||
erstellen. Dabei werden fünf Skriptsprachen unterstützt: perl, python,
|
||||
ruby, lua und tcl.
|
||||
// TRANSLATION MISSING
|
||||
This manual documents way to write scripts for WeeChat, using one of supported
|
||||
script languages:
|
||||
|
||||
* python
|
||||
* perl
|
||||
* ruby
|
||||
* lua
|
||||
* tcl
|
||||
* guile (scheme)
|
||||
|
||||
[NOTE]
|
||||
Beinahe alle Beispiele in dieser Dokumentation beziehen sich auf Python.
|
||||
|
@ -32,20 +39,46 @@ Skripten in WeeChat
|
|||
Besonderheiten der einzelnen Skriptsprachen
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Es existieren einige Besonderheiten für jede Skriptsprache:
|
||||
Python
|
||||
^^^^^^
|
||||
|
||||
* perl:
|
||||
** Funktionen werden im Format `weechat::xxx(arg1, arg2, ...);` ausgeführt
|
||||
* python:
|
||||
** WeeChat muss als Modul eingebunden werden: `import weechat`
|
||||
** Um die WeeChat Funktion `print*` nutzen zu können muss `prnt*` genutzt
|
||||
werden ('print' ist ein reservierter Befehl von Python!)
|
||||
** Funktionen werden im Format `weechat.xxx(arg1, arg2, ...)` ausgeführt
|
||||
* ruby:
|
||||
** Es muss 'weechat_init' definiert und darin die Funktion 'register' ausgeführt werden
|
||||
** Funktionen werden im Format `Weechat.xxx(arg1, arg2, ...)` ausgeführt
|
||||
* tcl:
|
||||
** Funktionen werden im Format `weechat::xxx arg1 arg2 ...` ausgeführt
|
||||
* WeeChat muss als Modul eingebunden werden: `import weechat`
|
||||
* Um die WeeChat Funktion `print*` nutzen zu können muss `prnt*` genutzt
|
||||
werden ('print' ist ein reservierter Befehl von Python!)
|
||||
* Funktionen werden im Format `weechat.xxx(arg1, arg2, ...)` ausgeführt
|
||||
|
||||
Perl
|
||||
^^^^
|
||||
|
||||
* Funktionen werden im Format `weechat::xxx(arg1, arg2, ...);` ausgeführt
|
||||
|
||||
Ruby
|
||||
^^^^
|
||||
|
||||
* Es muss 'weechat_init' definiert und darin die Funktion 'register' ausgeführt werden
|
||||
* Funktionen werden im Format `Weechat.xxx(arg1, arg2, ...)` ausgeführt
|
||||
|
||||
Lua
|
||||
^^^
|
||||
|
||||
* Funktionen werden im Format `weechat.xxx(arg1, arg2, ...)` ausgeführt
|
||||
|
||||
Tcl
|
||||
^^^
|
||||
|
||||
* Funktionen werden im Format `weechat::xxx arg1 arg2 ...` ausgeführt
|
||||
|
||||
Guile (scheme)
|
||||
^^^^^^^^^^^^^^
|
||||
|
||||
// TRANSLATION MISSING
|
||||
* Functions are called with `(weechat:xxx arg1 arg2 ...)`
|
||||
* Following functions take one list of arguments (instead of many arguments
|
||||
for other functions), because number of arguments exceed number of allowed
|
||||
arguments in Guile:
|
||||
** config_new_section
|
||||
** config_new_option
|
||||
** bar_new
|
||||
|
||||
[[register_function]]
|
||||
Die "Register" Funktion
|
||||
|
@ -74,14 +107,6 @@ Argumente:
|
|||
|
||||
Beispielskripten, für jede Sprache:
|
||||
|
||||
* perl:
|
||||
|
||||
[source,perl]
|
||||
----------------------------------------
|
||||
weechat::register("test_perl", "FlashCode", "1.0", "GPL3", "Test Skript", "", "");
|
||||
weechat::print("", "Hallo, von einem perl Skript!");
|
||||
----------------------------------------
|
||||
|
||||
* python:
|
||||
|
||||
[source,python]
|
||||
|
@ -92,6 +117,14 @@ weechat.register("test_python", "FlashCode", "1.0", "GPL3", "Test Skript", "", "
|
|||
weechat.prnt("", "Hallo, von einem python Skript!")
|
||||
----------------------------------------
|
||||
|
||||
* perl:
|
||||
|
||||
[source,perl]
|
||||
----------------------------------------
|
||||
weechat::register("test_perl", "FlashCode", "1.0", "GPL3", "Test Skript", "", "");
|
||||
weechat::print("", "Hallo, von einem perl Skript!");
|
||||
----------------------------------------
|
||||
|
||||
* ruby:
|
||||
|
||||
[source,ruby]
|
||||
|
@ -113,12 +146,20 @@ weechat.print("", "Hallo, von einem lua Skript!")
|
|||
|
||||
* tcl:
|
||||
|
||||
// [source,tcl]
|
||||
[source,tcl]
|
||||
----------------------------------------
|
||||
weechat::register "test_tcl" "FlashCode" "1.0" "GPL3" "Test Skript" "" ""
|
||||
weechat::print "" "Hallo, von einem tcl Skript!"
|
||||
----------------------------------------
|
||||
|
||||
* guile (scheme):
|
||||
|
||||
[source,lisp]
|
||||
----------------------------------------
|
||||
(weechat:register "test_scheme" "FlashCode" "1.0" "GPL3" "Test script" "" "")
|
||||
(weechat:print "" "Hello, from scheme script!")
|
||||
----------------------------------------
|
||||
|
||||
[[load_script]]
|
||||
Laden von Skripten
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
|
@ -127,11 +168,12 @@ Der Befehl zum Laden von Skripten ist davon abhängig welche Skriptsprache
|
|||
genutzt werden soll:
|
||||
|
||||
----------------------------------------
|
||||
/perl load perl/skript.pl
|
||||
/python load python/skript.py
|
||||
/perl load perl/skript.pl
|
||||
/ruby load ruby/skript.rb
|
||||
/lua load lua/skript.lua
|
||||
/tcl load tcl/skript.tcl
|
||||
/guile load guile/skript.scm
|
||||
----------------------------------------
|
||||
|
||||
Um Skripten automatisch beim Start von WeeChat zu laden kann man einen Link
|
||||
|
|
|
@ -86,23 +86,24 @@ Abhängigkeiten
|
|||
folgende Tabelle beschreibt welche Pakete zwingend notwendig sind um WeeChat zu kompilieren und
|
||||
welche Pakete optional genutzt werden können.
|
||||
|
||||
[width="80%",cols="4,^2,13",options="header"]
|
||||
[width="100%",cols="5,^3,^3,13",options="header"]
|
||||
|========================================
|
||||
| Paket ^(1)^ | benötigt | Funktion
|
||||
| cmake | *ja* | zum kompilieren (autotools ist möglich. cmake wird aber empfohlen)
|
||||
| libncursesw5-dev ^(2)^ | *ja* | ncurses Oberfläche
|
||||
| gettext | nein | Internationalisierung (Übersetzung der Mitteilungen; Hauptsprache ist englisch)
|
||||
| libgcrypt11-dev | nein | SASL Authentifikation am IRC Server mittels DH-BLOWFISH Methode
|
||||
| libgnutls-dev (≥ 2.2.0) | nein | SSL Verbindung zu einem IRC Server
|
||||
| ca-certificates | nein | Zertifikate für SSL Verbindungen
|
||||
| libaspell-dev | nein | aspell Erweiterung
|
||||
| libperl-dev | nein | perl Erweiterung
|
||||
| python-dev | nein | python Erweiterung
|
||||
| ruby1.8-dev | nein | ruby Erweiterung
|
||||
| liblua5.1-0-dev | nein | lua Erweiterung
|
||||
| tcl-dev (≥ 8.5) | nein | tcl Erweiterung
|
||||
| asciidoc (≥ 8.5.0) | nein | erstellt Dokumentation (HTML Dateien)
|
||||
| source-highlight | nein | Syntax highlight für Quelltext in HTML Dokumentation
|
||||
| Paket ^(1)^ | Version | benötigt | Funktion
|
||||
| cmake | | *ja* | zum kompilieren (autotools ist möglich. cmake wird aber empfohlen)
|
||||
| libncursesw5-dev ^(2)^ | | *ja* | ncurses Oberfläche
|
||||
| gettext | | | Internationalisierung (Übersetzung der Mitteilungen; Hauptsprache ist englisch)
|
||||
| libgcrypt11-dev | | | SASL Authentifikation am IRC Server mittels DH-BLOWFISH Methode
|
||||
| libgnutls-dev | ≥ 2.2.0 | | SSL Verbindung zu einem IRC Server
|
||||
| ca-certificates | | | Zertifikate für SSL Verbindungen
|
||||
| libaspell-dev | | | aspell Erweiterung
|
||||
| python-dev | 2.5 → 2.7 | | python Erweiterung
|
||||
| libperl-dev | | | perl Erweiterung
|
||||
| ruby1.8-dev | | | ruby Erweiterung
|
||||
| liblua5.1-0-dev | | | lua Erweiterung
|
||||
| tcl-dev | ≥ 8.5 | | tcl Erweiterung
|
||||
| guile-1.8-dev | | | guile (scheme) Erweiterung
|
||||
| asciidoc | ≥ 8.5.0 | | erstellt Dokumentation (HTML Dateien)
|
||||
| source-highlight | | | Syntax highlight für Quelltext in HTML Dokumentation
|
||||
|========================================
|
||||
|
||||
[NOTE]
|
||||
|
@ -1005,8 +1006,8 @@ nachträglich zu laden oder zu entfernen.
|
|||
|
||||
Es ist wichtig zwischen 'Erweiterung' und 'Skript' zu unterscheiden. Eine Erweiterung
|
||||
ist eine Binärdatei die kompiliert wurde und mit dem Befehl `/plugin` geladen wird.
|
||||
Dem gegenüber ist ein 'Skript' eine Textdatei die durch eine Erweiterung z.B. 'perl'
|
||||
mittels dem Befehl `/perl` geladen wird.
|
||||
Dem gegenüber ist ein 'Skript' eine Textdatei die durch eine Erweiterung z.B. 'python'
|
||||
mittels dem Befehl `/python` geladen wird.
|
||||
|
||||
Mit dem Befehl `/plugin` kann eine Erweiterung geladen bzw. entfernt werden. Auch können
|
||||
mit dem Befehl alle installierten Erweiterungen aufgelistet werden. Wird eine Erweiterung
|
||||
|
@ -1035,11 +1036,12 @@ Standarderweiterungen:
|
|||
| logger | erstellt Protokolldateien von Buffern
|
||||
| relay | Daten via Netzwerk übermitteln (IRC Proxy)
|
||||
| rmodifier | wandelt Schlüsselwörter mit regulären Ausdrücken
|
||||
| perl | Perl-Skript API
|
||||
| python | Python-Skript API
|
||||
| perl | Perl-Skript API
|
||||
| ruby | Ruby-Skript API
|
||||
| lua | Lua-Skript API
|
||||
| tcl | Tcl-Skript API
|
||||
| guile | Guile(scheme)-Skript API
|
||||
| xfer | Datentransfer und Direktchat
|
||||
|========================================
|
||||
|
||||
|
@ -1237,11 +1239,11 @@ $ echo 'irc.freenode.#weechat *Hallo!' >~/.weechat/weechat_fifo_12345
|
|||
$ echo '*hello!' >~/.weechat/weechat_fifo_12345
|
||||
----------------------------------------
|
||||
|
||||
* sendet zwei Befehle um alle Perl-Skripten zu entfernen und dann neu zu laden (die beiden Befehle müssen
|
||||
* sendet zwei Befehle um alle Python-Skripten zu entfernen und dann neu zu laden (die beiden Befehle müssen
|
||||
mit "\n" getrennt werden):
|
||||
|
||||
----------------------------------------
|
||||
$ echo -e '*/perl unload\n*/perl autoload' >~/.weechat/weechat_fifo_12345
|
||||
$ echo -e '*/python unload\n*/python autoload' >~/.weechat/weechat_fifo_12345
|
||||
----------------------------------------
|
||||
|
||||
Das nachfolgende Skript sendet einen Befehl an alle laufenden WeeChat Instanzen:
|
||||
|
@ -1943,7 +1945,8 @@ Lautet die Befehlszeile `/oper nick password` wird diese in der Befehlszeile als
|
|||
Skripten Erweiterungen
|
||||
~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
WeeChat unterstützt fünf Skript-Erweiterungen: Perl, Python, Ruby, Lua und Tcl.
|
||||
WeeChat unterstützt sechs Skript-Erweiterungen: Python, Perl, Ruby, Lua, Tcl und Guile
|
||||
(scheme).
|
||||
Diese Erweiterungen können für die jeweilige Sprache die Skripten laden, ausführen und
|
||||
entfernen.
|
||||
|
||||
|
@ -1952,18 +1955,18 @@ bitte die 'WeeChat Scripting Guide'.
|
|||
|
||||
Skripten für WeeChat finden Sie auf: http://www.weechat.org/scripts
|
||||
|
||||
[[perl_commands]]
|
||||
Perl Befehle
|
||||
^^^^^^^^^^^^
|
||||
|
||||
include::autogen/user/perl_commands.txt[]
|
||||
|
||||
[[python_commands]]
|
||||
Python Befehle
|
||||
^^^^^^^^^^^^^^
|
||||
|
||||
include::autogen/user/python_commands.txt[]
|
||||
|
||||
[[perl_commands]]
|
||||
Perl Befehle
|
||||
^^^^^^^^^^^^
|
||||
|
||||
include::autogen/user/perl_commands.txt[]
|
||||
|
||||
[[ruby_commands]]
|
||||
Ruby Befehle
|
||||
^^^^^^^^^^^^
|
||||
|
@ -1982,6 +1985,12 @@ Tcl Befehle
|
|||
|
||||
include::autogen/user/tcl_commands.txt[]
|
||||
|
||||
[[guile_commands]]
|
||||
Guile Befehle
|
||||
^^^^^^^^^^^^^
|
||||
|
||||
include::autogen/user/guile_commands.txt[]
|
||||
|
||||
[[xfer_plugin]]
|
||||
Xfer Erweiterung
|
||||
~~~~~~~~~~~~~~~~
|
||||
|
|
|
@ -93,6 +93,7 @@ plugin_list = { 'weechat' : 'co',
|
|||
'ruby' : '',
|
||||
'lua' : '',
|
||||
'tcl' : '',
|
||||
'guile' : '',
|
||||
'xfer' : 'co' }
|
||||
|
||||
# options to ignore
|
||||
|
@ -251,16 +252,24 @@ def get_completions():
|
|||
|
||||
def update_file(oldfile, newfile, num_files, num_files_updated, obj):
|
||||
"""Update a doc file."""
|
||||
shaold = hashlib.sha224(open(oldfile, 'r').read()).hexdigest()
|
||||
shanew = hashlib.sha224(open(newfile, 'r').read()).hexdigest()
|
||||
try:
|
||||
shaold = hashlib.sha224(open(oldfile, 'r').read()).hexdigest()
|
||||
except:
|
||||
shaold = ''
|
||||
try:
|
||||
shanew = hashlib.sha224(open(newfile, 'r').read()).hexdigest()
|
||||
except:
|
||||
shanew = ''
|
||||
if shaold != shanew:
|
||||
os.unlink(oldfile)
|
||||
if os.path.exists(oldfile):
|
||||
os.unlink(oldfile)
|
||||
os.rename(newfile, oldfile)
|
||||
num_files_updated['total1'] += 1
|
||||
num_files_updated['total2'] += 1
|
||||
num_files_updated[obj] += 1
|
||||
else:
|
||||
os.unlink(newfile)
|
||||
if os.path.exists(oldfile):
|
||||
os.unlink(newfile)
|
||||
num_files['total1'] += 1
|
||||
num_files['total2'] += 1
|
||||
num_files[obj] += 1
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
|
||||
| aspell | aspell_langs | list of supported langs for aspell
|
||||
|
||||
| guile | guile_script | list of scripts
|
||||
|
||||
| irc | irc_channel | current IRC channel
|
||||
|
||||
| irc | irc_channel_nicks_hosts | nicks and hostnames of current IRC channel
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
|
||||
| alias | alias | list of aliases | alias pointer (optional) | alias name (can start or end with "*" as wildcard) (optional)
|
||||
|
||||
| guile | guile_script | list of scripts | script pointer (optional) | script name (can start or end with "*" as wildcard) (optional)
|
||||
|
||||
| irc | irc_channel | list of channels for an IRC server | channel pointer (optional) | server,channel (channel is optional)
|
||||
|
||||
| irc | irc_ignore | list of IRC ignores | ignore pointer (optional) | -
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
[[command_guile_guile]]
|
||||
[command]*`guile`* list/load/unload scripts::
|
||||
........................................
|
||||
/guile list|listfull [<name>]
|
||||
load <filename>
|
||||
autoload
|
||||
reload|unload [<name>]
|
||||
|
||||
list: list loaded scripts
|
||||
listfull: list loaded scripts (verbose)
|
||||
load: load a script
|
||||
autoload: load all scripts in "autoload" directory
|
||||
reload: reload a script (if no name given, unload all scripts, then load all scripts in "autoload" directory)
|
||||
unload: unload a script (if no name given, unload all scripts)
|
||||
filename: script (file) to load
|
||||
name: a script name (name used in call to "register" function)
|
||||
|
||||
Without argument, this command lists all loaded scripts.
|
||||
........................................
|
||||
|
|
@ -16,8 +16,15 @@ Introduction
|
|||
WeeChat (Wee Enhanced Environment for Chat) is a free chat client, fast and
|
||||
light, designed for many operating systems.
|
||||
|
||||
This manual documents way to write scripts for WeeChat, using one of five
|
||||
supported script languages: perl, python, ruby, lua or tcl.
|
||||
This manual documents way to write scripts for WeeChat, using one of supported
|
||||
script languages:
|
||||
|
||||
* python
|
||||
* perl
|
||||
* ruby
|
||||
* lua
|
||||
* tcl
|
||||
* guile (scheme)
|
||||
|
||||
[NOTE]
|
||||
Almost all examples in this doc are written in Python, but API is the same for
|
||||
|
@ -31,20 +38,45 @@ Scripts in WeeChat
|
|||
Languages specificities
|
||||
~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Some things are specific to languages:
|
||||
Python
|
||||
^^^^^^
|
||||
|
||||
* perl:
|
||||
** functions are called with `weechat::xxx(arg1, arg2, ...);`
|
||||
* python:
|
||||
** you have to `import weechat`
|
||||
** functions `print*` are called `prnt*` in python (because 'print' is reserved
|
||||
keyword)
|
||||
** functions are called with `weechat.xxx(arg1, arg2, ...)`
|
||||
* ruby:
|
||||
** you have to define 'weechat_init' and call 'register' inside
|
||||
** functions are called with `Weechat.xxx(arg1, arg2, ...)`
|
||||
* tcl:
|
||||
** functions are called with `weechat::xxx arg1 arg2 ...`
|
||||
* You have to `import weechat`
|
||||
* Functions `print*` are called `prnt*` in python (because 'print' is reserved
|
||||
keyword)
|
||||
* Functions are called with `weechat.xxx(arg1, arg2, ...)`
|
||||
|
||||
Perl
|
||||
^^^^
|
||||
|
||||
* Functions are called with `weechat::xxx(arg1, arg2, ...);`
|
||||
|
||||
Ruby
|
||||
^^^^
|
||||
|
||||
* You have to define 'weechat_init' and call 'register' inside
|
||||
* Functions are called with `Weechat.xxx(arg1, arg2, ...)`
|
||||
|
||||
Lua
|
||||
^^^
|
||||
|
||||
* Functions are called with `weechat.xxx(arg1, arg2, ...)`
|
||||
|
||||
Tcl
|
||||
^^^
|
||||
|
||||
* Functions are called with `weechat::xxx arg1 arg2 ...`
|
||||
|
||||
Guile (scheme)
|
||||
^^^^^^^^^^^^^^
|
||||
|
||||
* Functions are called with `(weechat:xxx arg1 arg2 ...)`
|
||||
* Following functions take one list of arguments (instead of many arguments
|
||||
for other functions), because number of arguments exceed number of allowed
|
||||
arguments in Guile:
|
||||
** config_new_section
|
||||
** config_new_option
|
||||
** bar_new
|
||||
|
||||
[[register_function]]
|
||||
Register function
|
||||
|
@ -73,14 +105,6 @@ Arguments:
|
|||
|
||||
Example of script, for each language:
|
||||
|
||||
* perl:
|
||||
|
||||
[source,perl]
|
||||
----------------------------------------
|
||||
weechat::register("test_perl", "FlashCode", "1.0", "GPL3", "Test script", "", "");
|
||||
weechat::print("", "Hello, from perl script!");
|
||||
----------------------------------------
|
||||
|
||||
* python:
|
||||
|
||||
[source,python]
|
||||
|
@ -91,6 +115,14 @@ weechat.register("test_python", "FlashCode", "1.0", "GPL3", "Test script", "", "
|
|||
weechat.prnt("", "Hello, from python script!")
|
||||
----------------------------------------
|
||||
|
||||
* perl:
|
||||
|
||||
[source,perl]
|
||||
----------------------------------------
|
||||
weechat::register("test_perl", "FlashCode", "1.0", "GPL3", "Test script", "", "");
|
||||
weechat::print("", "Hello, from perl script!");
|
||||
----------------------------------------
|
||||
|
||||
* ruby:
|
||||
|
||||
[source,ruby]
|
||||
|
@ -112,12 +144,20 @@ weechat.print("", "Hello, from lua script!")
|
|||
|
||||
* tcl:
|
||||
|
||||
// [source,tcl]
|
||||
[source,tcl]
|
||||
----------------------------------------
|
||||
weechat::register "test_tcl" "FlashCode" "1.0" "GPL3" "Test script" "" ""
|
||||
weechat::print "" "Hello, from tcl script!"
|
||||
----------------------------------------
|
||||
|
||||
* guile (scheme):
|
||||
|
||||
[source,lisp]
|
||||
----------------------------------------
|
||||
(weechat:register "test_scheme" "FlashCode" "1.0" "GPL3" "Test script" "" "")
|
||||
(weechat:print "" "Hello, from scheme script!")
|
||||
----------------------------------------
|
||||
|
||||
[[load_script]]
|
||||
Load script
|
||||
~~~~~~~~~~~
|
||||
|
@ -125,11 +165,12 @@ Load script
|
|||
You have to use command, depending on language:
|
||||
|
||||
----------------------------------------
|
||||
/perl load perl/script.pl
|
||||
/python load python/script.py
|
||||
/perl load perl/script.pl
|
||||
/ruby load ruby/script.rb
|
||||
/lua load lua/script.lua
|
||||
/tcl load tcl/script.tcl
|
||||
/guile load guile/script.scm
|
||||
----------------------------------------
|
||||
|
||||
You can make link in directory 'language/autoload' to autoload script when
|
||||
|
|
|
@ -86,23 +86,24 @@ Dependencies
|
|||
Following table shows list of packages that are required or optional to
|
||||
compile WeeChat.
|
||||
|
||||
[width="80%",cols="4,^2,13",options="header"]
|
||||
[width="100%",cols="5,^3,^3,13",options="header"]
|
||||
|========================================
|
||||
| Package ^(1)^ | Required | Feature
|
||||
| cmake | *yes* | build (autotools still possible, but cmake is recommended)
|
||||
| libncursesw5-dev ^(2)^ | *yes* | ncurses interface
|
||||
| gettext | no | internationalization (translation of messages; base language is english)
|
||||
| libgcrypt11-dev | no | SASL authentication with IRC server using DH-BLOWFISH mechanism
|
||||
| libgnutls-dev (≥ 2.2.0) | no | SSL connection to IRC server
|
||||
| ca-certificates | no | certificates for SSL connections
|
||||
| libaspell-dev | no | aspell plugin
|
||||
| libperl-dev | no | perl plugin
|
||||
| python-dev | no | python plugin
|
||||
| ruby1.8-dev | no | ruby plugin
|
||||
| liblua5.1-0-dev | no | lua plugin
|
||||
| tcl-dev (≥ 8.5) | no | tcl plugin
|
||||
| asciidoc (≥ 8.5.0) | no | build documentation (HTML files)
|
||||
| source-highlight | no | syntax highlight for sources in HTML documentation
|
||||
| Package ^(1)^ | Version | Required | Feature
|
||||
| cmake | | *yes* | build (autotools still possible, but cmake is recommended)
|
||||
| libncursesw5-dev ^(2)^ | | *yes* | ncurses interface
|
||||
| gettext | | | internationalization (translation of messages; base language is english)
|
||||
| libgcrypt11-dev | | | SASL authentication with IRC server using DH-BLOWFISH mechanism
|
||||
| libgnutls-dev | ≥ 2.2.0 | | SSL connection to IRC server
|
||||
| ca-certificates | | | certificates for SSL connections
|
||||
| libaspell-dev | | | aspell plugin
|
||||
| python-dev | 2.5 → 2.7 | | python plugin
|
||||
| libperl-dev | | | perl plugin
|
||||
| ruby1.8-dev | | | ruby plugin
|
||||
| liblua5.1-0-dev | | | lua plugin
|
||||
| tcl-dev | ≥ 8.5 | | tcl plugin
|
||||
| guile-1.8-dev | | | guile (scheme) plugin
|
||||
| asciidoc | ≥ 8.5.0 | | build documentation (HTML files)
|
||||
| source-highlight | | | syntax highlight for sources in HTML documentation
|
||||
|========================================
|
||||
|
||||
[NOTE]
|
||||
|
@ -992,8 +993,8 @@ possible to load or unload plugins while WeeChat is running.
|
|||
|
||||
It's important to make difference between a 'plugin' and a 'script': a
|
||||
'plugin' is a binary file compiled and loaded with command `/plugin`, whereas
|
||||
a 'script' is a text file loaded with a plugin like 'perl' with command
|
||||
`/perl`.
|
||||
a 'script' is a text file loaded with a plugin like 'python' with command
|
||||
`/python`.
|
||||
|
||||
You can use command `/plugin` to load/unload a plugin, or list all loaded
|
||||
plugins.
|
||||
|
@ -1022,11 +1023,12 @@ Default plugins are:
|
|||
| logger | Log buffers to files
|
||||
| relay | Relay data via network (IRC proxy)
|
||||
| rmodifier | Alter modifier strings with regular expressions
|
||||
| perl | Perl scripting API
|
||||
| python | Python scripting API
|
||||
| perl | Perl scripting API
|
||||
| ruby | Ruby scripting API
|
||||
| lua | Lua scripting API
|
||||
| tcl | Tcl scripting API
|
||||
| guile | Guile (scheme) scripting API
|
||||
| xfer | File transfer and direct chat
|
||||
|========================================
|
||||
|
||||
|
@ -1220,11 +1222,11 @@ $ echo 'irc.freenode.#weechat *hello!' >~/.weechat/weechat_fifo_12345
|
|||
$ echo '*hello!' >~/.weechat/weechat_fifo_12345
|
||||
----------------------------------------
|
||||
|
||||
* send two commands to unload/reload Perl scripts (you have to separate them
|
||||
* send two commands to unload/reload Python scripts (you have to separate them
|
||||
with "\n"):
|
||||
|
||||
----------------------------------------
|
||||
$ echo -e '*/perl unload\n*/perl autoload' >~/.weechat/weechat_fifo_12345
|
||||
$ echo -e '*/python unload\n*/python autoload' >~/.weechat/weechat_fifo_12345
|
||||
----------------------------------------
|
||||
|
||||
You can write a script to send command to all running WeeChat at same time,
|
||||
|
@ -1913,7 +1915,8 @@ If command line contains: `/oper nick password` then display becomes:
|
|||
Scripts plugins
|
||||
~~~~~~~~~~~~~~~
|
||||
|
||||
WeeChat provides 5 scripting plugins: Perl, Python, Ruby, Lua and Tcl.
|
||||
WeeChat provides 6 scripting plugins: Python, Perl, Ruby, Lua, Tcl and Guile
|
||||
(scheme).
|
||||
These plugins can load, execute and unload scripts for these languages.
|
||||
|
||||
For more information about how to write scripts, or WeeChat API for
|
||||
|
@ -1921,18 +1924,18 @@ scripts, please read 'WeeChat Scripting Guide'.
|
|||
|
||||
You can find some scripts for WeeChat here: http://www.weechat.org/scripts
|
||||
|
||||
[[perl_commands]]
|
||||
Perl commands
|
||||
^^^^^^^^^^^^^
|
||||
|
||||
include::autogen/user/perl_commands.txt[]
|
||||
|
||||
[[python_commands]]
|
||||
Python commands
|
||||
^^^^^^^^^^^^^^^
|
||||
|
||||
include::autogen/user/python_commands.txt[]
|
||||
|
||||
[[perl_commands]]
|
||||
Perl commands
|
||||
^^^^^^^^^^^^^
|
||||
|
||||
include::autogen/user/perl_commands.txt[]
|
||||
|
||||
[[ruby_commands]]
|
||||
Ruby commands
|
||||
^^^^^^^^^^^^^
|
||||
|
@ -1951,6 +1954,12 @@ Tcl commands
|
|||
|
||||
include::autogen/user/tcl_commands.txt[]
|
||||
|
||||
[[guile_commands]]
|
||||
Guile commands
|
||||
^^^^^^^^^^^^^^
|
||||
|
||||
include::autogen/user/guile_commands.txt[]
|
||||
|
||||
[[xfer_plugin]]
|
||||
Xfer plugin
|
||||
~~~~~~~~~~~
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
|
||||
| aspell | aspell_langs | liste des langues supportées pour aspell
|
||||
|
||||
| guile | guile_script | liste des scripts
|
||||
|
||||
| irc | irc_channel | canal IRC courant
|
||||
|
||||
| irc | irc_channel_nicks_hosts | pseudos et noms d'hôtes du canal IRC courant
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
|
||||
| alias | alias | liste des alias | pointeur vers l'alias (optionnel) | nom d'alias (peut démarrer ou se terminer par "*" comme joker) (optionnel)
|
||||
|
||||
| guile | guile_script | liste des scripts | pointeur vers le script (optionnel) | nom de script (peut démarrer ou se terminer par "*" comme joker) (optionnel)
|
||||
|
||||
| irc | irc_channel | liste des canaux pour un serveur IRC | pointeur vers le canal (optionnel) | serveur,canal (le canal est optionnel)
|
||||
|
||||
| irc | irc_ignore | liste des ignores IRC | pointeur vers l'ignore (optionnel) | -
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
[[command_guile_guile]]
|
||||
[command]*`guile`* lister/charger/décharger des scripts::
|
||||
........................................
|
||||
/guile list|listfull [<nom>]
|
||||
load <fichier>
|
||||
autoload
|
||||
reload|unload [<nom>]
|
||||
|
||||
list: lister les scripts chargés
|
||||
listfull: lister les scripts chargés (verbeux)
|
||||
load: charger un script
|
||||
autoload: charger tous les scripts dans le répertoire "autoload"
|
||||
reload: recharger un script (si pas de nom donné, décharger tous les scripts puis charger tous les scripts dans le répertoire "autoload")
|
||||
unload: décharger un script (si pas de nom donné, décharger tous les scripts)
|
||||
fichier: script (fichier) à charger
|
||||
nom: nom de script (nom utilisé dans l'appel à la fonction "register")
|
||||
|
||||
Sans paramètre, cette commande liste les scripts chargés.
|
||||
........................................
|
||||
|
|
@ -18,7 +18,14 @@ WeeChat (Wee Enhanced Environment for Chat) est un client de discussion libre,
|
|||
rapide et léger, conçu pour différents systèmes d'exploitation.
|
||||
|
||||
Ce manuel documente la façon d'écrire des scripts pour WeeChat, en utilisant
|
||||
l'un des cinq langages de script supportés : perl, python, ruby, lua ou tcl.
|
||||
l'un des langages de script supportés :
|
||||
|
||||
* python
|
||||
* perl
|
||||
* ruby
|
||||
* lua
|
||||
* tcl
|
||||
* guile (scheme)
|
||||
|
||||
[NOTE]
|
||||
La majorité des exemples de cette documentation sont écrits en Python, mais
|
||||
|
@ -32,20 +39,45 @@ Scripts dans WeeChat
|
|||
Spécificités des langages
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Quelques choses sont spécifiques aux langages :
|
||||
Python
|
||||
^^^^^^
|
||||
|
||||
* perl :
|
||||
** les fonctions sont appelées par `weechat::xxx(arg1, arg2, ...);`
|
||||
* python :
|
||||
** vous devez utiliser `import weechat`
|
||||
** les fonctions `print*` se nomment `prnt*` en python (car 'print' est un mot
|
||||
clé réservé)
|
||||
** les fonctions sont appelées par `weechat.xxx(arg1, arg2, ...)`
|
||||
* ruby :
|
||||
** vous devez définir 'weechat_init' et appeler 'register' dedans
|
||||
** les fonctions sont appelées par `Weechat.xxx(arg1, arg2, ...)`
|
||||
* tcl :
|
||||
** les fonctions sont appelées par `weechat::xxx arg1 arg2 ...`
|
||||
* Vous devez utiliser `import weechat`
|
||||
* Les fonctions `print*` se nomment `prnt*` en python (car 'print' est un mot
|
||||
clé réservé)
|
||||
* Les fonctions sont appelées par `weechat.xxx(arg1, arg2, ...)`
|
||||
|
||||
Perl
|
||||
^^^^
|
||||
|
||||
* Les fonctions sont appelées par `weechat::xxx(arg1, arg2, ...);`
|
||||
|
||||
Ruby
|
||||
^^^^
|
||||
|
||||
* Vous devez définir 'weechat_init' et appeler 'register' dedans
|
||||
* Les fonctions sont appelées par `Weechat.xxx(arg1, arg2, ...)`
|
||||
|
||||
Lua
|
||||
^^^
|
||||
|
||||
* Les fonctions sont appelées par `weechat.xxx(arg1, arg2, ...)`
|
||||
|
||||
Tcl
|
||||
^^^
|
||||
|
||||
* Les fonctions sont appelées par `weechat::xxx arg1 arg2 ...`
|
||||
|
||||
Guile (scheme)
|
||||
^^^^^^^^^^^^^^
|
||||
|
||||
* Les fonctions sont appelées par `(weechat:xxx arg1 arg2 ...)`
|
||||
* Les fonctions suivantes prennent une liste de paramètres en entrée (au lieu
|
||||
de plusieurs paramètres pour les autres fonctions), car le nombre de
|
||||
paramètres excède la limite de Guile :
|
||||
** config_new_section
|
||||
** config_new_option
|
||||
** bar_new
|
||||
|
||||
[[register_function]]
|
||||
Fonction register
|
||||
|
@ -76,14 +108,6 @@ Paramètres :
|
|||
|
||||
Exemple, pour chaque langage :
|
||||
|
||||
* perl :
|
||||
|
||||
[source,perl]
|
||||
----------------------------------------
|
||||
weechat::register("test_perl", "FlashCode", "1.0", "GPL3", "Script de test", "", "");
|
||||
weechat::print("", "Bonjour, du script perl !");
|
||||
----------------------------------------
|
||||
|
||||
* python :
|
||||
|
||||
[source,python]
|
||||
|
@ -94,6 +118,14 @@ weechat.register("test_python", "FlashCode", "1.0", "GPL3", "Script de test", ""
|
|||
weechat.prnt("", "Bonjour, du script python !")
|
||||
----------------------------------------
|
||||
|
||||
* perl :
|
||||
|
||||
[source,perl]
|
||||
----------------------------------------
|
||||
weechat::register("test_perl", "FlashCode", "1.0", "GPL3", "Script de test", "", "");
|
||||
weechat::print("", "Bonjour, du script perl !");
|
||||
----------------------------------------
|
||||
|
||||
* ruby :
|
||||
|
||||
[source,ruby]
|
||||
|
@ -115,12 +147,20 @@ weechat.print("", "Bonjour, du script lua !")
|
|||
|
||||
* tcl :
|
||||
|
||||
// [source,tcl]
|
||||
[source,tcl]
|
||||
----------------------------------------
|
||||
weechat::register "test_tcl" "FlashCode" "1.0" "GPL3" "Script de test" "" ""
|
||||
weechat::print "" "Bonjour, du script tcl !"
|
||||
----------------------------------------
|
||||
|
||||
* guile (scheme):
|
||||
|
||||
[source,lisp]
|
||||
----------------------------------------
|
||||
(weechat:register "test_scheme" "FlashCode" "1.0" "GPL3" "Script de test" "" "")
|
||||
(weechat:print "" "Bonjour, du script scheme !")
|
||||
----------------------------------------
|
||||
|
||||
[[load_script]]
|
||||
Chargement du script
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
|
@ -128,11 +168,12 @@ Chargement du script
|
|||
Vous devez utiliser la commande, dépendant du langage :
|
||||
|
||||
----------------------------------------
|
||||
/perl load perl/script.pl
|
||||
/python load python/script.py
|
||||
/perl load perl/script.pl
|
||||
/ruby load ruby/script.rb
|
||||
/lua load lua/script.lua
|
||||
/tcl load tcl/script.tcl
|
||||
/guile load guile/script.scm
|
||||
----------------------------------------
|
||||
|
||||
Vous pouvez faire un lien dans le répertoire 'langage/autoload' pour charger
|
||||
|
|
|
@ -88,23 +88,24 @@ Dépendances
|
|||
Le tableau suivant liste les paquets qui sont requis ou optionnels pour
|
||||
compiler WeeChat.
|
||||
|
||||
[width="80%",cols="4,^2,13",options="header"]
|
||||
[width="100%",cols="5,^3,^3,13",options="header"]
|
||||
|========================================
|
||||
| Paquet ^(1)^ | Requis | Fonctionnalité
|
||||
| cmake | *oui* | construction (autotools toujours possible, mais cmake est recommandé)
|
||||
| libncursesw5-dev ^(2)^ | *oui* | interface ncurses
|
||||
| gettext | non | internationalisation (traduction des messages; la langue de base est l'anglais)
|
||||
| libgcrypt11-dev | non | authentification SASL avec le serveur IRC, en utilisant le mécanisme DH-BLOWFISH
|
||||
| libgnutls-dev (≥ 2.2.0) | non | connexion SSL au serveur IRC
|
||||
| ca-certificates | no | certificats pour les connexions SSL
|
||||
| libaspell-dev | non | extension aspell
|
||||
| libperl-dev | non | extension perl
|
||||
| python-dev | non | extension python
|
||||
| ruby1.8-dev | non | extension ruby
|
||||
| liblua5.1-0-dev | non | extension lua
|
||||
| tcl-dev (≥ 8.5) | non | extension tcl
|
||||
| asciidoc (≥ 8.5.0) | non | construction de la documentation (fichiers HTML)
|
||||
| source-highlight | non | coloration des sources dans la documentation HTML
|
||||
| Paquet ^(1)^ | Version | Requis | Fonctionnalité
|
||||
| cmake | | *oui* | construction (autotools toujours possible, mais cmake est recommandé)
|
||||
| libncursesw5-dev ^(2)^ | | *oui* | interface ncurses
|
||||
| gettext | | | internationalisation (traduction des messages; la langue de base est l'anglais)
|
||||
| libgcrypt11-dev | | | authentification SASL avec le serveur IRC, en utilisant le mécanisme DH-BLOWFISH
|
||||
| libgnutls-dev | ≥ 2.2.0 | | connexion SSL au serveur IRC
|
||||
| ca-certificates | | | certificats pour les connexions SSL
|
||||
| libaspell-dev | | | extension aspell
|
||||
| python-dev | 2.5 → 2.7 | | extension python
|
||||
| libperl-dev | | | extension perl
|
||||
| ruby1.8-dev | | | extension ruby
|
||||
| liblua5.1-0-dev | | | extension lua
|
||||
| tcl-dev | ≥ 8.5 | | extension tcl
|
||||
| guile-1.8-dev | | | extention guile (scheme)
|
||||
| asciidoc | ≥ 8.5.0 | | construction de la documentation (fichiers HTML)
|
||||
| source-highlight | | | coloration des sources dans la documentation HTML
|
||||
|========================================
|
||||
|
||||
[NOTE]
|
||||
|
@ -1020,7 +1021,7 @@ WeeChat tourne.
|
|||
Il est important de bien faire la différence entre une 'extension' et un
|
||||
'script' : une 'extension' est un fichier binaire compilé et chargé avec la
|
||||
commande `/plugin`, tandis qu'un 'script' est un fichier texte chargé par une
|
||||
extension comme 'perl' par la commande `perl`.
|
||||
extension comme 'python' par la commande `/python`.
|
||||
|
||||
Vous pouvez utiliser la commande `/plugin` pour charger/décharger une
|
||||
extension, ou afficher les extensions chargées.
|
||||
|
@ -1049,11 +1050,12 @@ Les extensions par défaut sont :
|
|||
| logger | Enregistrement des tampons dans des fichiers
|
||||
| relay | Relai de données via le réseau (proxy IRC)
|
||||
| rmodifier | Modification des chaînes de "modifier" avec des expressions régulières
|
||||
| perl | Interface (API) pour scripts Perl
|
||||
| python | Interface (API) pour scripts Python
|
||||
| perl | Interface (API) pour scripts Perl
|
||||
| ruby | Interface (API) pour scripts Ruby
|
||||
| lua | Interface (API) pour scripts Lua
|
||||
| tcl | Interface (API) pour scripts Tcl
|
||||
| guile | Interface (API) pour scripts Guile (scheme)
|
||||
| xfer | Transfert de fichier et discussion directe
|
||||
|========================================
|
||||
|
||||
|
@ -1258,11 +1260,11 @@ $ echo 'irc.freenode.#weechat *bonjour !' >~/.weechat/weechat_fifo_12345
|
|||
$ echo '*bonjour !' >~/.weechat/weechat_fifo_12345
|
||||
----------------------------------------
|
||||
|
||||
* envoyer deux commandes pour décharger/recharger les scripts Perl (vous devez
|
||||
* envoyer deux commandes pour décharger/recharger les scripts Python (vous devez
|
||||
les séparer par "\n") :
|
||||
|
||||
----------------------------------------
|
||||
$ echo -e '*/perl unload\n*/perl autoload' >~/.weechat/weechat_fifo_12345
|
||||
$ echo -e '*/python unload\n*/python autoload' >~/.weechat/weechat_fifo_12345
|
||||
----------------------------------------
|
||||
|
||||
Vous pouvez écrire un script qui envoie les commandes à tous les WeeChat qui
|
||||
|
@ -1971,7 +1973,8 @@ sera : `/oper nick ********`.
|
|||
Extensions Scripts
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
|
||||
WeeChat fournit 5 extensions pour scripts : Perl, Python, Ruby, Lua et Tcl.
|
||||
WeeChat fournit 6 extensions pour scripts : Python, Perl, Ruby, Lua, Tcl et
|
||||
Guile (scheme).
|
||||
Ces extensions peuvent charger, exécuter et décharger des scripts pour ces
|
||||
langages.
|
||||
|
||||
|
@ -1981,18 +1984,18 @@ WeeChat pour les scripts, merci de lire le 'Le Guide pour Scripts WeeChat'.
|
|||
Vous pouvez trouver des scripts pour WeeChat ici :
|
||||
http://www.weechat.org/scripts
|
||||
|
||||
[[perl_commands]]
|
||||
Commandes Perl
|
||||
^^^^^^^^^^^^^^
|
||||
|
||||
include::autogen/user/perl_commands.txt[]
|
||||
|
||||
[[python_commands]]
|
||||
Commandes Python
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
include::autogen/user/python_commands.txt[]
|
||||
|
||||
[[perl_commands]]
|
||||
Commandes Perl
|
||||
^^^^^^^^^^^^^^
|
||||
|
||||
include::autogen/user/perl_commands.txt[]
|
||||
|
||||
[[ruby_commands]]
|
||||
Commandes Ruby
|
||||
^^^^^^^^^^^^^^
|
||||
|
@ -2011,6 +2014,12 @@ Commandes Tcl
|
|||
|
||||
include::autogen/user/tcl_commands.txt[]
|
||||
|
||||
[[guile_commands]]
|
||||
Commandes Guile
|
||||
^^^^^^^^^^^^^^^
|
||||
|
||||
include::autogen/user/guile_commands.txt[]
|
||||
|
||||
[[xfer_plugin]]
|
||||
Extension Xfer
|
||||
~~~~~~~~~~~~~~
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
|
||||
| aspell | aspell_langs | elenco di lingue supportate per aspell
|
||||
|
||||
| guile | guile_script | elenco degli script
|
||||
|
||||
| irc | irc_channel | canale IRC corrente
|
||||
|
||||
| irc | irc_channel_nicks_hosts | nick e host del canale IRC corrente
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
|
||||
| alias | alias | elenco di alias | puntatore all'alias (opzionale) | nome alias (può iniziare o terminare con "*" come carattere jolly) (opzionale)
|
||||
|
||||
| guile | guile_script | elenco degli script | puntatore allo script (opzionale) | nome script (può iniziare o terminare con "*" come carattere jolly) (opzionale)
|
||||
|
||||
| irc | irc_channel | elenco dei canali per un server IRC | puntatore al canale (opzionale) | server,canale (canale è opzionale)
|
||||
|
||||
| irc | irc_ignore | elenco di ignore IRC | puntatore all'ignore (opzionale) | -
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
[[command_guile_guile]]
|
||||
[command]*`guile`* elenca/carica/scarica script::
|
||||
........................................
|
||||
/guile list|listfull [<nome>]
|
||||
load <nomefile>
|
||||
autoload
|
||||
reload|unload [<nome>]
|
||||
|
||||
list: elenca i plugin caricati
|
||||
listfull: elenca i plugin caricati (dettagliato)
|
||||
load: carica un plugin
|
||||
autoload: carica automaticamente i plugin nella cartella utente o di sistema
|
||||
reload: ricarica un plugin (se non specificato, scarica i plugin e li ricarica automaticamente)
|
||||
unload: scarica uno o tutti i plugin
|
||||
nome_file: (file) script da caricare
|
||||
nome: il nome di uno script (usato nella chiamata alla funzione "register")
|
||||
|
||||
Senza argomento, questo comando elenca tutti i plugin caricati.
|
||||
........................................
|
||||
|
|
@ -17,9 +17,16 @@ Introduzione
|
|||
WeeChat (Wee Enhanced Environment for Chat) è un client di chat libero,
|
||||
veloce e leggero, realizzato per molti sistemi operativi.
|
||||
|
||||
Questo manuale documenta i metodi per la realizzazione di script per
|
||||
WeeChat, utilizzando uno dei cinque linguaggi di script supportati: perl,
|
||||
python, ruby, lua o tcl.
|
||||
// TRANSLATION MISSING
|
||||
This manual documents way to write scripts for WeeChat, using one of supported
|
||||
script languages:
|
||||
|
||||
* python
|
||||
* perl
|
||||
* ruby
|
||||
* lua
|
||||
* tcl
|
||||
* guile (scheme)
|
||||
|
||||
[NOTE]
|
||||
Quasi tutti gli esempi in questo manuale sono scritti in Python, ma l'API
|
||||
|
@ -33,20 +40,46 @@ Script in WeeChat
|
|||
Specifiche per i linguaggi
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Alcune cose sono specifiche per i linguaggi:
|
||||
Python
|
||||
^^^^^^
|
||||
|
||||
* perl:
|
||||
** le funzioni sono chiamate con `weechat::xxx(arg1, arg2, ...);`
|
||||
* python:
|
||||
** è necessario `import weechat`
|
||||
** le funzioni `print*` sono chiamate `prnt*` in python (dato che 'print'
|
||||
è una parola riservata)
|
||||
** le funzioni sono chiamate con `weechat.xxx(arg1, arg2, ...)`
|
||||
* ruby:
|
||||
** è necessario definire 'weechat_init' e chiamare 'register' all'interno
|
||||
** le funzioni sono chiamate con `Weechat.xxx(arg1, arg2, ...)`
|
||||
* tcl:
|
||||
** le funzioni sono chiamate con `weechat::xxx arg1 arg2 ...`
|
||||
* E necessario `import weechat`
|
||||
* Le funzioni `print*` sono chiamate `prnt*` in python (dato che 'print'
|
||||
è una parola riservata)
|
||||
* Le funzioni sono chiamate con `weechat.xxx(arg1, arg2, ...)`
|
||||
|
||||
Perl
|
||||
^^^^
|
||||
|
||||
* Le funzioni sono chiamate con `weechat::xxx(arg1, arg2, ...);`
|
||||
|
||||
Ruby
|
||||
^^^^
|
||||
|
||||
* E necessario definire 'weechat_init' e chiamare 'register' all'interno
|
||||
* Le funzioni sono chiamate con `Weechat.xxx(arg1, arg2, ...)`
|
||||
|
||||
Lua
|
||||
^^^
|
||||
|
||||
* Le funzioni sono chiamate con `weechat.xxx(arg1, arg2, ...)`
|
||||
|
||||
Tcl
|
||||
^^^
|
||||
|
||||
* Le funzioni sono chiamate con `weechat::xxx arg1 arg2 ...`
|
||||
|
||||
Guile (scheme)
|
||||
^^^^^^^^^^^^^^
|
||||
|
||||
// TRANSLATION MISSING
|
||||
* Functions are called with `(weechat:xxx arg1 arg2 ...)`
|
||||
* Following functions take one list of arguments (instead of many arguments
|
||||
for other functions), because number of arguments exceed number of allowed
|
||||
arguments in Guile:
|
||||
** config_new_section
|
||||
** config_new_option
|
||||
** bar_new
|
||||
|
||||
[[register_function]]
|
||||
Registrare una funzione
|
||||
|
@ -76,14 +109,6 @@ Argomenti:
|
|||
|
||||
Esempio di script, per ogni linguaggio:
|
||||
|
||||
* perl:
|
||||
|
||||
[source,perl]
|
||||
----------------------------------------
|
||||
weechat::register("test_perl", "FlashCode", "1.0", "GPL3", "Test script", "", "");
|
||||
weechat::print("", "Hello, from perl script!");
|
||||
----------------------------------------
|
||||
|
||||
* python:
|
||||
|
||||
[source,python]
|
||||
|
@ -94,6 +119,14 @@ weechat.register("test_python", "FlashCode", "1.0", "GPL3", "Test script", "", "
|
|||
weechat.prnt("", "Hello, from python script!")
|
||||
----------------------------------------
|
||||
|
||||
* perl:
|
||||
|
||||
[source,perl]
|
||||
----------------------------------------
|
||||
weechat::register("test_perl", "FlashCode", "1.0", "GPL3", "Test script", "", "");
|
||||
weechat::print("", "Hello, from perl script!");
|
||||
----------------------------------------
|
||||
|
||||
* ruby:
|
||||
|
||||
[source,ruby]
|
||||
|
@ -115,12 +148,20 @@ weechat.print("", "Hello, from lua script!")
|
|||
|
||||
* tcl:
|
||||
|
||||
// [source,tcl]
|
||||
[source,tcl]
|
||||
----------------------------------------
|
||||
weechat::register "test_tcl" "FlashCode" "1.0" "GPL3" "Test script" "" ""
|
||||
weechat::print "" "Hello, from tcl script!"
|
||||
----------------------------------------
|
||||
|
||||
* guile (scheme):
|
||||
|
||||
[source,lisp]
|
||||
----------------------------------------
|
||||
(weechat:register "test_scheme" "FlashCode" "1.0" "GPL3" "Test script" "" "")
|
||||
(weechat:print "" "Hello, from scheme script!")
|
||||
----------------------------------------
|
||||
|
||||
[[load_script]]
|
||||
Caricare uno script
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
@ -128,11 +169,12 @@ Caricare uno script
|
|||
Il comando da utilizzare, in base al linguaggio:
|
||||
|
||||
----------------------------------------
|
||||
/perl load perl/script.pl
|
||||
/python load python/script.py
|
||||
/perl load perl/script.pl
|
||||
/ruby load ruby/script.rb
|
||||
/lua load lua/script.lua
|
||||
/tcl load tcl/script.tcl
|
||||
/guile load guile/script.scm
|
||||
----------------------------------------
|
||||
|
||||
È possibile creare un link nella cartella 'linguaggio/autoload' per caricare
|
||||
|
|
|
@ -90,23 +90,24 @@ Dipendenze
|
|||
La seguente tabella mostra l'elenco di pacchetti richiesti o opzionali per
|
||||
compilare WeeChat.
|
||||
|
||||
[width="80%",cols="4,^2,13",options="header"]
|
||||
[width="100%",cols="5,^3,^3,13",options="header"]
|
||||
|========================================
|
||||
| Pacchetto ^(1)^ | Richiesto | Caratteristica
|
||||
| cmake | *sì* | compilazione (ancora possibile con autotools, ma si raccomanda cmake)
|
||||
| libncursesw5-dev ^(2)^ | *sì* | interfaccia ncurses
|
||||
| gettext | no | internazionalizzazione (traduzione dei messaggi; la lingua base è l'inglese)
|
||||
| libgcrypt11-dev | no | autenticazione SASL per i server IRC che utilizzano il meccanismo DH-BLOWFISH
|
||||
| libgnutls-dev (≥ 2.2.0) | no | connessione SSL al server IRC
|
||||
| ca-certificates | no | certificati per le connessioni SSL
|
||||
| libaspell-dev | no | plugin aspell
|
||||
| libperl-dev | no | plugin perl
|
||||
| python-dev | no | plugin python
|
||||
| ruby1.8-dev | no | plugin ruby
|
||||
| liblua5.1-0-dev | no | plugin lua
|
||||
| tcl-dev (≥ 8.5) | no | plugin tcl
|
||||
| asciidoc (≥ 8.5.0) | no | compilazione della documentazione (file HTML)
|
||||
| source-highlight | no | evidenziazione della sintassi per i sorgenti nella documentazione HTML
|
||||
| Pacchetto ^(1)^ | Versione | Richiesto | Caratteristica
|
||||
| cmake | | *sì* | compilazione (ancora possibile con autotools, ma si raccomanda cmake)
|
||||
| libncursesw5-dev ^(2)^ | | *sì* | interfaccia ncurses
|
||||
| gettext | | | internazionalizzazione (traduzione dei messaggi; la lingua base è l'inglese)
|
||||
| libgcrypt11-dev | | | autenticazione SASL per i server IRC che utilizzano il meccanismo DH-BLOWFISH
|
||||
| libgnutls-dev | ≥ 2.2.0 | | connessione SSL al server IRC
|
||||
| ca-certificates | | | certificati per le connessioni SSL
|
||||
| libaspell-dev | | | plugin aspell
|
||||
| python-dev | 2.5 → 2.7 | | plugin python
|
||||
| libperl-dev | | | plugin perl
|
||||
| ruby1.8-dev | | | plugin ruby
|
||||
| liblua5.1-0-dev | | | plugin lua
|
||||
| tcl-dev | ≥ 8.5 | | plugin tcl
|
||||
| guile-1.8-dev | | | plugin guile (scheme)
|
||||
| asciidoc | ≥ 8.5.0 | | compilazione della documentazione (file HTML)
|
||||
| source-highlight | | | evidenziazione della sintassi per i sorgenti nella documentazione HTML
|
||||
|========================================
|
||||
|
||||
[NOTE]
|
||||
|
@ -1011,8 +1012,8 @@ I plugin trovati vengono caricati automaticamente all'avvio di WeeChat, ed
|
|||
|
||||
È importante evidenziare la differenza tra un 'plugin' ed uno 'script': un
|
||||
'plugin' è un file binario compilato e caricato con il comando `/plugin`,
|
||||
mentre uno 'script' è un file di testo caricato con un plugin come 'perl'
|
||||
con il comando `/perl`.
|
||||
mentre uno 'script' è un file di testo caricato con un plugin come 'python'
|
||||
con il comando `/python`.
|
||||
|
||||
È possibile utilizzare il comando `/plugin` per caricare/scaricare un plugin,
|
||||
oppure elencare tutti i plugin caricati.
|
||||
|
@ -1041,11 +1042,12 @@ I plugin predefiniti sono:
|
|||
| logger | Registra i buffer su file
|
||||
| relay | Relay dei dati via rete (proxy IRC)
|
||||
| rmodifier | Cambia le stringhe del modificatore con espressioni regolari
|
||||
| perl | API per lo scripting in Perl
|
||||
| python | API per lo scripting in Python
|
||||
| perl | API per lo scripting in Perl
|
||||
| ruby | API per lo scripting in Ruby
|
||||
| lua | API per lo scripting in Lua
|
||||
| tcl | API per lo scripting in TCL
|
||||
| guile | API per lo scripting in Guile (scheme)
|
||||
| xfer | Trasferimento file e chat diretta
|
||||
|=======================================
|
||||
|
||||
|
@ -1244,11 +1246,11 @@ $ echo 'irc.freenode.#weechat *hello!' >~/.weechat/weechat_fifo_12345
|
|||
$ echo '*hello!' >~/.weechat/weechat_fifo_12345
|
||||
----------------------------------------
|
||||
|
||||
* inviare due comandi per scaricare/caricare gli script Perl (è necessario
|
||||
* inviare due comandi per scaricare/caricare gli script Python (è necessario
|
||||
separarli con "\n"):
|
||||
|
||||
----------------------------------------
|
||||
$ echo -e '*/perl unload\n*/perl autoload' >~/.weechat/weechat_fifo_12345
|
||||
$ echo -e '*/python unload\n*/python autoload' >~/.weechat/weechat_fifo_12345
|
||||
----------------------------------------
|
||||
|
||||
È possibile realizzare uno script per inviare un comando a tutte le istanze di
|
||||
|
@ -1956,7 +1958,8 @@ Se la riga di comando contiene: `/oper nick password` allora sullo schermo diven
|
|||
Plugin per gli script
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
WeeChat fornisce 5 plugin per lo scripting: Perl, Python, Ruby, Lua, Tcl.
|
||||
WeeChat fornisce 6 plugin per lo scripting: Python, Perl, Ruby, Lua, Tcl, Guile
|
||||
(scheme).
|
||||
Questi plugin possono caricare, eseguire e scaricare gli script per questi
|
||||
linguaggi.
|
||||
|
||||
|
@ -1965,18 +1968,18 @@ per gli script, consultare la 'Guida allo Scripting di WeeChat'.
|
|||
|
||||
È possibile trovare alcuni script qui: http://www.weechat.org/scripts
|
||||
|
||||
[[perl_commands]]
|
||||
Comandi Perl
|
||||
^^^^^^^^^^^^
|
||||
|
||||
include::autogen/user/perl_commands.txt[]
|
||||
|
||||
[[python_commands]]
|
||||
Comandi Python
|
||||
^^^^^^^^^^^^^^
|
||||
|
||||
include::autogen/user/python_commands.txt[]
|
||||
|
||||
[[perl_commands]]
|
||||
Comandi Perl
|
||||
^^^^^^^^^^^^
|
||||
|
||||
include::autogen/user/perl_commands.txt[]
|
||||
|
||||
[[ruby_commands]]
|
||||
Comandi Ruby
|
||||
^^^^^^^^^^^^
|
||||
|
@ -1995,6 +1998,12 @@ Comandi Tcl
|
|||
|
||||
include::autogen/user/tcl_commands.txt[]
|
||||
|
||||
[[guile_commands]]
|
||||
Comandi Guile
|
||||
^^^^^^^^^^^^^
|
||||
|
||||
include::autogen/user/guile_commands.txt[]
|
||||
|
||||
[[xfer_plugin]]
|
||||
Plugin Xfer
|
||||
~~~~~~~~~~~
|
||||
|
|
|
@ -16,8 +16,16 @@ Wprowadzenie
|
|||
WeeChat (Wee Enhanced Environment for Chat) jest darmowym klientem rozmów, szybkim
|
||||
i lekkim, zaprojektowanym dla wielu systemów operacyjnych.
|
||||
|
||||
Ten podręcznik dokumentuje sposób pisania skryptów dla WeeChat, używając jednego
|
||||
z pięciu wspieranych języków skryptowych: perl, python, ruby, lua lub tcl.
|
||||
// TRANSLATION MISSING
|
||||
This manual documents way to write scripts for WeeChat, using one of supported
|
||||
script languages:
|
||||
|
||||
* python
|
||||
* perl
|
||||
* ruby
|
||||
* lua
|
||||
* tcl
|
||||
* guile (scheme)
|
||||
|
||||
[NOTE]
|
||||
Prawie wszystkie przykłady umieszczone w tym dokumencie są napisane w Pythonie,
|
||||
|
@ -31,20 +39,46 @@ Skrypty w WeeChat
|
|||
Specyfika języków
|
||||
~~~~~~~~~~~~~~~~~
|
||||
|
||||
Niektóre rzeczy są specyficzne dla danego języka:
|
||||
Python
|
||||
^^^^^^
|
||||
|
||||
* perl:
|
||||
** funkcje są wywoływane za pomocą `weechat::xxx(arg1, arg2, ...);`
|
||||
* python:
|
||||
** należy wykonać `import weechat`
|
||||
** funkcje `print*` są nazwane `prnt*` w pythonie (ponieważ 'print' jest zastrzeżonym
|
||||
słowem kluczowym)
|
||||
** funkcje są wywoływane za pomocą `weechat.xxx(arg1, arg2, ...)`
|
||||
* ruby:
|
||||
** trzeba zdefiniować 'weechat_init' i wywołać 'register' wewnątrz
|
||||
** funkcje są wywoływane za pomocą `Weechat.xxx(arg1, arg2, ...)`
|
||||
* tcl:
|
||||
** funkcje są wywoływane za pomocą `weechat::xxx arg1 arg2 ...`
|
||||
* Należy wykonać `import weechat`
|
||||
* Funkcje `print*` są nazwane `prnt*` w pythonie (ponieważ 'print' jest zastrzeżonym
|
||||
słowem kluczowym)
|
||||
* Funkcje są wywoływane za pomocą `weechat.xxx(arg1, arg2, ...)`
|
||||
|
||||
Perl
|
||||
^^^^
|
||||
|
||||
* Funkcje są wywoływane za pomocą `weechat::xxx(arg1, arg2, ...);`
|
||||
|
||||
Ruby
|
||||
^^^^
|
||||
|
||||
* Trzeba zdefiniować 'weechat_init' i wywołać 'register' wewnątrz
|
||||
* Funkcje są wywoływane za pomocą `Weechat.xxx(arg1, arg2, ...)`
|
||||
|
||||
Lua
|
||||
^^^
|
||||
|
||||
* Funkcje są wywoływane za pomocą `weechat.xxx(arg1, arg2, ...)`
|
||||
|
||||
Tcl
|
||||
^^^
|
||||
|
||||
* Funkcje są wywoływane za pomocą `weechat::xxx arg1 arg2 ...`
|
||||
|
||||
Guile (scheme)
|
||||
^^^^^^^^^^^^^^
|
||||
|
||||
// TRANSLATION MISSING
|
||||
* Functions are called with `(weechat:xxx arg1 arg2 ...)`
|
||||
* Following functions take one list of arguments (instead of many arguments
|
||||
for other functions), because number of arguments exceed number of allowed
|
||||
arguments in Guile:
|
||||
** config_new_section
|
||||
** config_new_option
|
||||
** bar_new
|
||||
|
||||
[[register_function]]
|
||||
Funkcja rejestrująca
|
||||
|
@ -73,14 +107,6 @@ Argumenty:
|
|||
|
||||
Przykład dla skryptu w każdym z języków:
|
||||
|
||||
* perl:
|
||||
|
||||
[source,perl]
|
||||
----------------------------------------
|
||||
weechat::register("test_perl", "FlashCode", "1.0", "GPL3", "Skrypt testowy", "", "");
|
||||
weechat::print("", "Witaj, z perlowego skryptu!");
|
||||
----------------------------------------
|
||||
|
||||
* python:
|
||||
|
||||
[source,python]
|
||||
|
@ -91,6 +117,14 @@ weechat.register("test_python", "FlashCode", "1.0", "GPL3", "Skrypt testowy", ""
|
|||
weechat.prnt("", "Witaj, z pythonowego skryptu!")
|
||||
----------------------------------------
|
||||
|
||||
* perl:
|
||||
|
||||
[source,perl]
|
||||
----------------------------------------
|
||||
weechat::register("test_perl", "FlashCode", "1.0", "GPL3", "Skrypt testowy", "", "");
|
||||
weechat::print("", "Witaj, z perlowego skryptu!");
|
||||
----------------------------------------
|
||||
|
||||
* ruby:
|
||||
|
||||
[source,ruby]
|
||||
|
@ -112,12 +146,20 @@ weechat.print("", "Witaj, ze skryptu lua!")
|
|||
|
||||
* tcl:
|
||||
|
||||
// [source,tcl]
|
||||
[source,tcl]
|
||||
----------------------------------------
|
||||
weechat::register "test_tcl" "FlashCode" "1.0" "GPL3" "Skrypt testowy" "" ""
|
||||
weechat::print "" "Witaj, ze skryptu tcl!"
|
||||
----------------------------------------
|
||||
|
||||
* guile (scheme):
|
||||
|
||||
[source,lisp]
|
||||
----------------------------------------
|
||||
(weechat:register "test_scheme" "FlashCode" "1.0" "GPL3" "Test script" "" "")
|
||||
(weechat:print "" "Hello, from scheme script!")
|
||||
----------------------------------------
|
||||
|
||||
[[load_script]]
|
||||
Ładowanie skryptu
|
||||
~~~~~~~~~~~~~~~~~
|
||||
|
@ -125,11 +167,12 @@ weechat::print "" "Witaj, ze skryptu tcl!"
|
|||
Musisz użyć komendy dla danego języka:
|
||||
|
||||
----------------------------------------
|
||||
/perl load perl/skrypt.pl
|
||||
/python load python/skrypt.py
|
||||
/perl load perl/skrypt.pl
|
||||
/ruby load ruby/skrypt.rb
|
||||
/lua load lua/skrypt.lua
|
||||
/tcl load tcl/skrypt.tcl
|
||||
/guile load guile/skrypt.scm
|
||||
----------------------------------------
|
||||
|
||||
Możesz zrobić dowiązanie w katalogu 'język/autoload' jeśli chcesz automatycznie
|
||||
|
|
|
@ -213,6 +213,10 @@
|
|||
./src/plugins/rmodifier/rmodifier.h
|
||||
./src/plugins/rmodifier/rmodifier-info.c
|
||||
./src/plugins/rmodifier/rmodifier-info.h
|
||||
./src/plugins/scripts/guile/weechat-guile-api.c
|
||||
./src/plugins/scripts/guile/weechat-guile-api.h
|
||||
./src/plugins/scripts/guile/weechat-guile.c
|
||||
./src/plugins/scripts/guile/weechat-guile.h
|
||||
./src/plugins/scripts/lua/weechat-lua-api.c
|
||||
./src/plugins/scripts/lua/weechat-lua-api.h
|
||||
./src/plugins/scripts/lua/weechat-lua.c
|
||||
|
|
|
@ -214,6 +214,10 @@ SET(WEECHAT_SOURCES
|
|||
./src/plugins/rmodifier/rmodifier.h
|
||||
./src/plugins/rmodifier/rmodifier-info.c
|
||||
./src/plugins/rmodifier/rmodifier-info.h
|
||||
./src/plugins/scripts/guile/weechat-guile-api.c
|
||||
./src/plugins/scripts/guile/weechat-guile-api.h
|
||||
./src/plugins/scripts/guile/weechat-guile.c
|
||||
./src/plugins/scripts/guile/weechat-guile.h
|
||||
./src/plugins/scripts/lua/weechat-lua-api.c
|
||||
./src/plugins/scripts/lua/weechat-lua-api.h
|
||||
./src/plugins/scripts/lua/weechat-lua.c
|
||||
|
|
|
@ -74,9 +74,9 @@ IF(ENABLE_RMODIFIER)
|
|||
ADD_SUBDIRECTORY( rmodifier )
|
||||
ENDIF(ENABLE_RMODIFIER)
|
||||
|
||||
IF(ENABLE_SCRIPTS OR ENABLE_PERL OR ENABLE_PYTHON OR ENABLE_RUBY OR ENABLE_LUA OR ENABLE_TCL)
|
||||
IF(ENABLE_SCRIPTS OR ENABLE_PERL OR ENABLE_PYTHON OR ENABLE_RUBY OR ENABLE_LUA OR ENABLE_TCL OR ENABLE_GUILE)
|
||||
ADD_SUBDIRECTORY( scripts )
|
||||
ENDIF(ENABLE_SCRIPTS OR ENABLE_PERL OR ENABLE_PYTHON OR ENABLE_RUBY OR ENABLE_LUA OR ENABLE_TCL)
|
||||
ENDIF(ENABLE_SCRIPTS OR ENABLE_PERL OR ENABLE_PYTHON OR ENABLE_RUBY OR ENABLE_LUA OR ENABLE_TCL OR ENABLE_GUILE)
|
||||
|
||||
IF(ENABLE_XFER)
|
||||
ADD_SUBDIRECTORY( xfer )
|
||||
|
|
|
@ -86,6 +86,10 @@ if PLUGIN_TCL
|
|||
script_dir = scripts
|
||||
endif
|
||||
|
||||
if PLUGIN_GUILE
|
||||
script_dir = scripts
|
||||
endif
|
||||
|
||||
if PLUGIN_XFER
|
||||
xfer_dir = xfer
|
||||
endif
|
||||
|
|
|
@ -58,3 +58,10 @@ IF(ENABLE_TCL)
|
|||
ADD_SUBDIRECTORY( tcl )
|
||||
ENDIF(TCL_FOUND)
|
||||
ENDIF(ENABLE_TCL)
|
||||
|
||||
IF(ENABLE_GUILE)
|
||||
FIND_PACKAGE(Guile)
|
||||
IF(GUILE_FOUND)
|
||||
ADD_SUBDIRECTORY( guile )
|
||||
ENDIF(GUILE_FOUND)
|
||||
ENDIF(ENABLE_GUILE)
|
||||
|
|
|
@ -48,6 +48,10 @@ if PLUGIN_TCL
|
|||
tcl_dir = tcl
|
||||
endif
|
||||
|
||||
SUBDIRS = . $(perl_dir) $(python_dir) $(ruby_dir) $(lua_dir) $(tcl_dir)
|
||||
if PLUGIN_GUILE
|
||||
guile_dir = guile
|
||||
endif
|
||||
|
||||
SUBDIRS = . $(perl_dir) $(python_dir) $(ruby_dir) $(lua_dir) $(tcl_dir) $(guile_dir)
|
||||
|
||||
EXTRA_DIST = CMakeLists.txt
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
#
|
||||
# Copyright (C) 2011 Sebastien 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(guile MODULE weechat-guile.c weechat-guile.h
|
||||
weechat-guile-api.c weechat-guile-api.h)
|
||||
|
||||
SET_TARGET_PROPERTIES(guile PROPERTIES PREFIX "")
|
||||
|
||||
IF(GUILE_FOUND)
|
||||
INCLUDE_DIRECTORIES(${GUILE_INCLUDE_PATH})
|
||||
SET(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${GUILE_LFLAGS}")
|
||||
TARGET_LINK_LIBRARIES(guile ${GUILE_LIBRARY} weechat_scripts)
|
||||
ENDIF(GUILE_FOUND)
|
||||
|
||||
INSTALL(TARGETS guile LIBRARY DESTINATION ${LIBDIR}/plugins)
|
|
@ -0,0 +1,33 @@
|
|||
#
|
||||
# Copyright (C) 2011 Sebastien 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/>.
|
||||
#
|
||||
|
||||
INCLUDES = -DLOCALEDIR=\"$(datadir)/locale\" $(GUILE_CFLAGS)
|
||||
|
||||
libdir = ${weechat_libdir}/plugins
|
||||
|
||||
lib_LTLIBRARIES = guile.la
|
||||
|
||||
guile_la_SOURCES = weechat-guile.c \
|
||||
weechat-guile.h \
|
||||
weechat-guile-api.c \
|
||||
weechat-guile-api.h
|
||||
guile_la_LDFLAGS = -module
|
||||
guile_la_LIBADD = ../lib_weechat_plugins_scripts.la $(GUILE_LFLAGS)
|
||||
|
||||
EXTRA_DIST = CMakeLists.txt
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* Copyright (C) 2011 Sebastien 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_GUILE_API_H
|
||||
#define __WEECHAT_GUILE_API_H 1
|
||||
|
||||
extern int weechat_guile_api_buffer_input_data_cb (void *data,
|
||||
struct t_gui_buffer *buffer,
|
||||
const char *input_data);
|
||||
extern int weechat_guile_api_buffer_close_cb (void *data,
|
||||
struct t_gui_buffer *buffer);
|
||||
extern void weechat_guile_api_module_init (void *data);
|
||||
|
||||
#endif /* __WEECHAT_GUILE_API_H */
|
|
@ -0,0 +1,891 @@
|
|||
/*
|
||||
* Copyright (C) 2011 Sebastien 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/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
* weechat-guile.c: guile (scheme) plugin for WeeChat
|
||||
*/
|
||||
|
||||
#undef _
|
||||
|
||||
#include <libguile.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <libgen.h>
|
||||
|
||||
#include "../../weechat-plugin.h"
|
||||
#include "../script.h"
|
||||
#include "weechat-guile.h"
|
||||
#include "weechat-guile-api.h"
|
||||
|
||||
|
||||
WEECHAT_PLUGIN_NAME(GUILE_PLUGIN_NAME);
|
||||
WEECHAT_PLUGIN_DESCRIPTION("Guile (scheme) plugin for WeeChat");
|
||||
WEECHAT_PLUGIN_AUTHOR("Sebastien Helleu <flashcode@flashtux.org>");
|
||||
WEECHAT_PLUGIN_VERSION(WEECHAT_VERSION);
|
||||
WEECHAT_PLUGIN_LICENSE(WEECHAT_LICENSE);
|
||||
|
||||
struct t_weechat_plugin *weechat_guile_plugin = NULL;
|
||||
|
||||
int guile_quiet;
|
||||
struct t_plugin_script *guile_scripts = NULL;
|
||||
struct t_plugin_script *last_guile_script = NULL;
|
||||
struct t_plugin_script *guile_current_script = NULL;
|
||||
struct t_plugin_script *guile_registered_script = NULL;
|
||||
const char *guile_current_script_filename = NULL;
|
||||
SCM guile_module_weechat;
|
||||
SCM guile_port;
|
||||
char *guile_stdout = NULL;
|
||||
|
||||
struct t_guile_function
|
||||
{
|
||||
SCM proc;
|
||||
SCM args;
|
||||
};
|
||||
|
||||
/*
|
||||
* string used to execute action "install":
|
||||
* when signal "guile_install_script" is received, name of string
|
||||
* is added to this string, to be installed later by a timer (when nothing is
|
||||
* running in script)
|
||||
*/
|
||||
char *guile_action_install_list = NULL;
|
||||
|
||||
/*
|
||||
* string used to execute action "remove":
|
||||
* when signal "guile_remove_script" is received, name of string
|
||||
* is added to this string, to be removed later by a timer (when nothing is
|
||||
* running in script)
|
||||
*/
|
||||
char *guile_action_remove_list = NULL;
|
||||
|
||||
|
||||
/*
|
||||
* weechat_guile_stdout_flush: flush stdout
|
||||
*/
|
||||
|
||||
void
|
||||
weechat_guile_stdout_flush ()
|
||||
{
|
||||
if (guile_stdout)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
weechat_gettext ("%s: stdout/stderr: %s%s"),
|
||||
GUILE_PLUGIN_NAME, guile_stdout, "");
|
||||
free (guile_stdout);
|
||||
guile_stdout = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_guile_catch: execute scheme procedure with internal catch
|
||||
* and return value
|
||||
*/
|
||||
|
||||
SCM
|
||||
weechat_guile_catch (void *procedure, void *data)
|
||||
{
|
||||
SCM value;
|
||||
|
||||
value = scm_internal_catch (SCM_BOOL_T,
|
||||
(scm_t_catch_body)procedure,
|
||||
data,
|
||||
(scm_t_catch_handler) scm_handle_by_message_noexit,
|
||||
NULL);
|
||||
return value;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_guile_scm_call_1: encapsulate call to scm_call_1 (to give arguments)
|
||||
*/
|
||||
|
||||
SCM
|
||||
weechat_guile_scm_call_1 (void *proc)
|
||||
{
|
||||
struct t_guile_function *guile_function;
|
||||
|
||||
guile_function = (struct t_guile_function *)proc;
|
||||
|
||||
return scm_call_1 (guile_function->proc, guile_function->args);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_guile_exec_function: execute scheme function (with optional args)
|
||||
* and return value
|
||||
*/
|
||||
|
||||
SCM
|
||||
weechat_guile_exec_function (const char *function, SCM args)
|
||||
{
|
||||
SCM func, func2, value;
|
||||
struct t_guile_function guile_function;
|
||||
|
||||
func = weechat_guile_catch (scm_c_lookup, (void *)function);
|
||||
func2 = weechat_guile_catch (scm_variable_ref, func);
|
||||
|
||||
if (args)
|
||||
{
|
||||
guile_function.proc = func2;
|
||||
guile_function.args = args;
|
||||
value = weechat_guile_catch (weechat_guile_scm_call_1, &guile_function);
|
||||
}
|
||||
else
|
||||
{
|
||||
value = weechat_guile_catch (scm_call_0, func2);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_guile_hashtable_map_cb: callback called for each key/value in a
|
||||
* hashtable
|
||||
*/
|
||||
|
||||
void
|
||||
weechat_guile_hashtable_map_cb (void *data,
|
||||
struct t_hashtable *hashtable,
|
||||
const void *key,
|
||||
const void *value)
|
||||
{
|
||||
SCM *alist, pair, list;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) hashtable;
|
||||
|
||||
alist = (SCM *)data;
|
||||
|
||||
pair = scm_cons (scm_from_locale_string ((const char *)key),
|
||||
scm_from_locale_string ((const char *)value));
|
||||
list = scm_list_1 (pair);
|
||||
|
||||
*alist = scm_append (scm_list_2 (*alist, list));
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_guile_hashtable_to_alist: get Guile alist with a WeeChat hashtable
|
||||
*/
|
||||
|
||||
SCM
|
||||
weechat_guile_hashtable_to_alist (struct t_hashtable *hashtable)
|
||||
{
|
||||
SCM alist;
|
||||
|
||||
alist = scm_list_n (SCM_UNDEFINED);
|
||||
|
||||
weechat_hashtable_map (hashtable,
|
||||
&weechat_guile_hashtable_map_cb,
|
||||
&alist);
|
||||
|
||||
return alist;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_guile_alist_to_hashtable: get WeeChat hashtable with Guile alist
|
||||
* Hashtable returned has type string for
|
||||
* both keys and values
|
||||
* Note: hashtable has to be released after
|
||||
* use with call to weechat_hashtable_free()
|
||||
*/
|
||||
|
||||
struct t_hashtable *
|
||||
weechat_guile_alist_to_hashtable (SCM alist, int hashtable_size)
|
||||
{
|
||||
struct t_hashtable *hashtable;
|
||||
int length, i;
|
||||
SCM pair;
|
||||
|
||||
hashtable = weechat_hashtable_new (hashtable_size,
|
||||
WEECHAT_HASHTABLE_STRING,
|
||||
WEECHAT_HASHTABLE_STRING,
|
||||
NULL,
|
||||
NULL);
|
||||
if (!hashtable)
|
||||
return NULL;
|
||||
|
||||
length = scm_to_int (scm_length (alist));
|
||||
for (i = 0; i < length; i++)
|
||||
{
|
||||
pair = scm_list_ref (alist, scm_from_int (i));
|
||||
weechat_hashtable_set (hashtable,
|
||||
scm_i_string_chars (scm_list_ref (pair,
|
||||
scm_from_int (0))),
|
||||
scm_i_string_chars (scm_list_ref (pair,
|
||||
scm_from_int (1))));
|
||||
}
|
||||
|
||||
return hashtable;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_guile_exec: execute a Guile function
|
||||
*/
|
||||
|
||||
void *
|
||||
weechat_guile_exec (struct t_plugin_script *script,
|
||||
int ret_type, const char *function,
|
||||
char *format, void **argv)
|
||||
{
|
||||
struct t_plugin_script *old_guile_current_script;
|
||||
SCM argv_list, rc;
|
||||
void *argv2[17], *ret_value;
|
||||
int i, argc, *ret_int;
|
||||
|
||||
old_guile_current_script = guile_current_script;
|
||||
scm_set_current_module ((SCM)(script->interpreter));
|
||||
guile_current_script = script;
|
||||
|
||||
if (argv && argv[0])
|
||||
{
|
||||
argc = strlen (format);
|
||||
for (i = 0; i < argc; i++)
|
||||
{
|
||||
switch (format[i])
|
||||
{
|
||||
case 's': /* string */
|
||||
argv2[i] = scm_from_locale_string ((char *)argv[i]);
|
||||
break;
|
||||
case 'i': /* integer */
|
||||
argv2[i] = scm_from_int (*((int *)argv[i]));
|
||||
break;
|
||||
case 'h': /* hash */
|
||||
argv2[i] = weechat_guile_hashtable_to_alist (argv[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (i = argc; i < 17; i++)
|
||||
{
|
||||
argv2[i] = SCM_UNDEFINED;
|
||||
}
|
||||
argv_list = scm_list_n (argv2[0], argv2[1],
|
||||
argv2[2], argv2[3],
|
||||
argv2[4], argv2[5],
|
||||
argv2[6], argv2[7],
|
||||
argv2[8], argv2[9],
|
||||
argv2[10], argv2[11],
|
||||
argv2[12], argv2[13],
|
||||
argv2[14], argv2[15],
|
||||
argv2[16]);
|
||||
rc = weechat_guile_exec_function (function, argv_list);
|
||||
}
|
||||
else
|
||||
{
|
||||
rc = weechat_guile_exec_function (function, NULL);
|
||||
}
|
||||
|
||||
ret_value = NULL;
|
||||
|
||||
if ((ret_type == WEECHAT_SCRIPT_EXEC_STRING) && (scm_is_string (rc)))
|
||||
{
|
||||
ret_value = scm_to_locale_string (rc);
|
||||
}
|
||||
else if ((ret_type == WEECHAT_SCRIPT_EXEC_INT) && (scm_is_integer (rc)))
|
||||
{
|
||||
ret_int = malloc (sizeof (*ret_int));
|
||||
if (ret_int)
|
||||
*ret_int = scm_to_int (rc);
|
||||
ret_value = ret_int;
|
||||
}
|
||||
else if (ret_type == WEECHAT_SCRIPT_EXEC_HASHTABLE)
|
||||
{
|
||||
ret_value = weechat_guile_alist_to_hashtable (rc,
|
||||
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE);
|
||||
}
|
||||
else
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
weechat_gettext ("%s%s: function \"%s\" must return "
|
||||
"a valid value"),
|
||||
weechat_prefix ("error"), GUILE_PLUGIN_NAME, function);
|
||||
}
|
||||
|
||||
if (ret_value == NULL)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
weechat_gettext ("%s%s: error in function \"%s\""),
|
||||
weechat_prefix ("error"), GUILE_PLUGIN_NAME, function);
|
||||
}
|
||||
|
||||
if (old_guile_current_script)
|
||||
scm_set_current_module ((SCM)(old_guile_current_script->interpreter));
|
||||
|
||||
guile_current_script = old_guile_current_script;
|
||||
|
||||
return ret_value;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_guile_module_init_script: init Guile module for script
|
||||
*/
|
||||
|
||||
void
|
||||
weechat_guile_module_init_script (void *data)
|
||||
{
|
||||
weechat_guile_catch (scm_c_eval_string, "(use-modules (weechat))");
|
||||
weechat_guile_catch (scm_c_primitive_load, data);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_guile_load: load a Guile script
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_guile_load (const char *filename)
|
||||
{
|
||||
char *filename2, *ptr_base_name, *base_name;
|
||||
SCM module;
|
||||
|
||||
if ((weechat_guile_plugin->debug >= 1) || !guile_quiet)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
weechat_gettext ("%s: loading script \"%s\""),
|
||||
GUILE_PLUGIN_NAME, filename);
|
||||
}
|
||||
|
||||
guile_current_script = NULL;
|
||||
guile_registered_script = NULL;
|
||||
guile_current_script_filename = filename;
|
||||
|
||||
filename2 = strdup (filename);
|
||||
if (!filename2)
|
||||
return 0;
|
||||
|
||||
ptr_base_name = basename (filename2);
|
||||
base_name = strdup (ptr_base_name);
|
||||
module = scm_c_define_module (base_name,
|
||||
&weechat_guile_module_init_script, filename2);
|
||||
free (filename2);
|
||||
|
||||
if (!guile_registered_script)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
weechat_gettext ("%s%s: function \"register\" not "
|
||||
"found (or failed) in file \"%s\""),
|
||||
weechat_prefix ("error"), GUILE_PLUGIN_NAME, filename);
|
||||
return 0;
|
||||
}
|
||||
|
||||
scm_gc_protect_object (module);
|
||||
|
||||
guile_current_script = guile_registered_script;
|
||||
guile_current_script->interpreter = (void *)module;
|
||||
|
||||
/*
|
||||
* set input/close callbacks for buffers created by this script
|
||||
* (to restore callbacks after upgrade)
|
||||
*/
|
||||
script_set_buffer_callbacks (weechat_guile_plugin,
|
||||
guile_scripts,
|
||||
guile_current_script,
|
||||
&weechat_guile_api_buffer_input_data_cb,
|
||||
&weechat_guile_api_buffer_close_cb);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_guile_load_cb: callback for script_auto_load() function
|
||||
*/
|
||||
|
||||
void
|
||||
weechat_guile_load_cb (void *data, const char *filename)
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
weechat_guile_load (filename);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_guile_unload: unload a Guile script
|
||||
*/
|
||||
|
||||
void
|
||||
weechat_guile_unload (struct t_plugin_script *script)
|
||||
{
|
||||
int *rc;
|
||||
|
||||
if ((weechat_guile_plugin->debug >= 1) || !guile_quiet)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
weechat_gettext ("%s: unloading script \"%s\""),
|
||||
GUILE_PLUGIN_NAME, script->name);
|
||||
}
|
||||
|
||||
if (script->shutdown_func && script->shutdown_func[0])
|
||||
{
|
||||
rc = (int *)weechat_guile_exec (script, WEECHAT_SCRIPT_EXEC_INT,
|
||||
script->shutdown_func, NULL, NULL);
|
||||
if (rc)
|
||||
free (rc);
|
||||
}
|
||||
|
||||
scm_gc_unprotect_object (script->interpreter);
|
||||
|
||||
if (guile_current_script == script)
|
||||
guile_current_script = (guile_current_script->prev_script) ?
|
||||
guile_current_script->prev_script : guile_current_script->next_script;
|
||||
|
||||
script_remove (weechat_guile_plugin, &guile_scripts, &last_guile_script,
|
||||
script);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_guile_unload_name: unload a Guile script by name
|
||||
*/
|
||||
|
||||
void
|
||||
weechat_guile_unload_name (const char *name)
|
||||
{
|
||||
struct t_plugin_script *ptr_script;
|
||||
|
||||
ptr_script = script_search (weechat_guile_plugin, guile_scripts, name);
|
||||
if (ptr_script)
|
||||
{
|
||||
weechat_guile_unload (ptr_script);
|
||||
weechat_printf (NULL,
|
||||
weechat_gettext ("%s: script \"%s\" unloaded"),
|
||||
GUILE_PLUGIN_NAME, name);
|
||||
}
|
||||
else
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
weechat_gettext ("%s%s: script \"%s\" not loaded"),
|
||||
weechat_prefix ("error"), GUILE_PLUGIN_NAME, name);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_guile_unload_all: unload all Guile scripts
|
||||
*/
|
||||
|
||||
void
|
||||
weechat_guile_unload_all ()
|
||||
{
|
||||
while (guile_scripts)
|
||||
{
|
||||
weechat_guile_unload (guile_scripts);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_guile_reload_name: reload a Guile script by name
|
||||
*/
|
||||
|
||||
void
|
||||
weechat_guile_reload_name (const char *name)
|
||||
{
|
||||
struct t_plugin_script *ptr_script;
|
||||
char *filename;
|
||||
|
||||
ptr_script = script_search (weechat_guile_plugin, guile_scripts, name);
|
||||
if (ptr_script)
|
||||
{
|
||||
filename = strdup (ptr_script->filename);
|
||||
if (filename)
|
||||
{
|
||||
weechat_guile_unload (ptr_script);
|
||||
weechat_printf (NULL,
|
||||
weechat_gettext ("%s: script \"%s\" unloaded"),
|
||||
GUILE_PLUGIN_NAME, name);
|
||||
weechat_guile_load (filename);
|
||||
free (filename);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
weechat_gettext ("%s%s: script \"%s\" not loaded"),
|
||||
weechat_prefix ("error"), GUILE_PLUGIN_NAME, name);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_guile_cmd: callback for "/guile" command
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_guile_command_cb (void *data, struct t_gui_buffer *buffer,
|
||||
int argc, char **argv, char **argv_eol)
|
||||
{
|
||||
char *path_script;
|
||||
SCM value;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) buffer;
|
||||
|
||||
if (argc == 1)
|
||||
{
|
||||
script_display_list (weechat_guile_plugin, guile_scripts,
|
||||
NULL, 0);
|
||||
}
|
||||
else if (argc == 2)
|
||||
{
|
||||
if (weechat_strcasecmp (argv[1], "list") == 0)
|
||||
{
|
||||
script_display_list (weechat_guile_plugin, guile_scripts,
|
||||
NULL, 0);
|
||||
}
|
||||
else if (weechat_strcasecmp (argv[1], "listfull") == 0)
|
||||
{
|
||||
script_display_list (weechat_guile_plugin, guile_scripts,
|
||||
NULL, 1);
|
||||
}
|
||||
else if (weechat_strcasecmp (argv[1], "autoload") == 0)
|
||||
{
|
||||
script_auto_load (weechat_guile_plugin, &weechat_guile_load_cb);
|
||||
}
|
||||
else if (weechat_strcasecmp (argv[1], "reload") == 0)
|
||||
{
|
||||
weechat_guile_unload_all ();
|
||||
script_auto_load (weechat_guile_plugin, &weechat_guile_load_cb);
|
||||
}
|
||||
else if (weechat_strcasecmp (argv[1], "unload") == 0)
|
||||
{
|
||||
weechat_guile_unload_all ();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (weechat_strcasecmp (argv[1], "list") == 0)
|
||||
{
|
||||
script_display_list (weechat_guile_plugin, guile_scripts,
|
||||
argv_eol[2], 0);
|
||||
}
|
||||
else if (weechat_strcasecmp (argv[1], "listfull") == 0)
|
||||
{
|
||||
script_display_list (weechat_guile_plugin, guile_scripts,
|
||||
argv_eol[2], 1);
|
||||
}
|
||||
else if (weechat_strcasecmp (argv[1], "load") == 0)
|
||||
{
|
||||
/* load Guile script */
|
||||
path_script = script_search_path (weechat_guile_plugin,
|
||||
argv_eol[2]);
|
||||
weechat_guile_load ((path_script) ? path_script : argv_eol[2]);
|
||||
if (path_script)
|
||||
free (path_script);
|
||||
}
|
||||
else if (weechat_strcasecmp (argv[1], "reload") == 0)
|
||||
{
|
||||
/* reload one Guile script */
|
||||
weechat_guile_reload_name (argv_eol[2]);
|
||||
}
|
||||
else if (weechat_strcasecmp (argv[1], "unload") == 0)
|
||||
{
|
||||
/* unload Guile script */
|
||||
weechat_guile_unload_name (argv_eol[2]);
|
||||
}
|
||||
else if (weechat_strcasecmp (argv[1], "eval") == 0)
|
||||
{
|
||||
/* eval Guile code */
|
||||
value = weechat_guile_catch (scm_c_eval_string, argv_eol[2]);
|
||||
if (!SCM_EQ_P (value, SCM_UNDEFINED)
|
||||
&& !SCM_EQ_P (value, SCM_UNSPECIFIED))
|
||||
{
|
||||
scm_display (value, guile_port);
|
||||
}
|
||||
weechat_guile_stdout_flush ();
|
||||
}
|
||||
else
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
weechat_gettext ("%s%s: unknown option for "
|
||||
"command \"%s\""),
|
||||
weechat_prefix ("error"), GUILE_PLUGIN_NAME,
|
||||
"guile");
|
||||
}
|
||||
}
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_guile_completion_cb: callback for script completion
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_guile_completion_cb (void *data, const char *completion_item,
|
||||
struct t_gui_buffer *buffer,
|
||||
struct t_gui_completion *completion)
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) completion_item;
|
||||
(void) buffer;
|
||||
|
||||
script_completion (weechat_guile_plugin, completion, guile_scripts);
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_guile_infolist_cb: callback for infolist
|
||||
*/
|
||||
|
||||
struct t_infolist *
|
||||
weechat_guile_infolist_cb (void *data, const char *infolist_name,
|
||||
void *pointer, const char *arguments)
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
if (!infolist_name || !infolist_name[0])
|
||||
return NULL;
|
||||
|
||||
if (weechat_strcasecmp (infolist_name, "guile_script") == 0)
|
||||
{
|
||||
return script_infolist_list_scripts (weechat_guile_plugin,
|
||||
guile_scripts, pointer,
|
||||
arguments);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_guile_signal_debug_dump_cb: dump Guile plugin data in WeeChat log
|
||||
* file
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_guile_signal_debug_dump_cb (void *data, const char *signal,
|
||||
const char *type_data, void *signal_data)
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) signal;
|
||||
(void) type_data;
|
||||
|
||||
if (!signal_data
|
||||
|| (weechat_strcasecmp ((char *)signal_data, GUILE_PLUGIN_NAME) == 0))
|
||||
{
|
||||
script_print_log (weechat_guile_plugin, guile_scripts);
|
||||
}
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_guile_signal_buffer_closed_cb: callback called when a buffer is
|
||||
* closed
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_guile_signal_buffer_closed_cb (void *data, const char *signal,
|
||||
const char *type_data,
|
||||
void *signal_data)
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) signal;
|
||||
(void) type_data;
|
||||
|
||||
if (signal_data)
|
||||
script_remove_buffer_callbacks (guile_scripts, signal_data);
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_guile_timer_action_cb: timer for executing actions
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_guile_timer_action_cb (void *data, int remaining_calls)
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) remaining_calls;
|
||||
|
||||
if (data)
|
||||
{
|
||||
if (data == &guile_action_install_list)
|
||||
{
|
||||
script_action_install (weechat_guile_plugin,
|
||||
guile_scripts,
|
||||
&weechat_guile_unload,
|
||||
&weechat_guile_load,
|
||||
&guile_action_install_list);
|
||||
}
|
||||
else if (data == &guile_action_remove_list)
|
||||
{
|
||||
script_action_remove (weechat_guile_plugin,
|
||||
guile_scripts,
|
||||
&weechat_guile_unload,
|
||||
&guile_action_remove_list);
|
||||
}
|
||||
}
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_guile_signal_script_action_cb: callback called when a script action
|
||||
* is asked (install/remove a script)
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_guile_signal_script_action_cb (void *data, const char *signal,
|
||||
const char *type_data,
|
||||
void *signal_data)
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_STRING) == 0)
|
||||
{
|
||||
if (strcmp (signal, "guile_script_install") == 0)
|
||||
{
|
||||
script_action_add (&guile_action_install_list,
|
||||
(const char *)signal_data);
|
||||
weechat_hook_timer (1, 0, 1,
|
||||
&weechat_guile_timer_action_cb,
|
||||
&guile_action_install_list);
|
||||
}
|
||||
else if (strcmp (signal, "guile_script_remove") == 0)
|
||||
{
|
||||
script_action_add (&guile_action_remove_list,
|
||||
(const char *)signal_data);
|
||||
weechat_hook_timer (1, 0, 1,
|
||||
&weechat_guile_timer_action_cb,
|
||||
&guile_action_remove_list);
|
||||
}
|
||||
}
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_guile_port_fill_input: fill input
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_guile_port_fill_input (SCM port)
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) port;
|
||||
|
||||
return ' ';
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_guile_port_write: write
|
||||
*/
|
||||
|
||||
void
|
||||
weechat_guile_port_write (SCM port, const void *data, size_t size)
|
||||
{
|
||||
char *new_stdout;
|
||||
int length_stdout;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) port;
|
||||
|
||||
/* concatenate str to guile_stdout */
|
||||
if (guile_stdout)
|
||||
{
|
||||
length_stdout = strlen (guile_stdout);
|
||||
new_stdout = realloc (guile_stdout, length_stdout + size + 1);
|
||||
if (!new_stdout)
|
||||
{
|
||||
free (guile_stdout);
|
||||
return;
|
||||
}
|
||||
guile_stdout = new_stdout;
|
||||
memcpy (guile_stdout + length_stdout, data, size);
|
||||
guile_stdout[length_stdout + size] = '\0';
|
||||
}
|
||||
else
|
||||
{
|
||||
guile_stdout = malloc (size + 1);
|
||||
if (guile_stdout)
|
||||
{
|
||||
memcpy (guile_stdout, data, size);
|
||||
guile_stdout[size] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
/* flush stdout if at least "\n" is in string */
|
||||
if (guile_stdout && (strchr (guile_stdout, '\n')))
|
||||
weechat_guile_stdout_flush ();
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_plugin_init: initialize Guile plugin
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
{
|
||||
weechat_guile_plugin = plugin;
|
||||
|
||||
guile_stdout = NULL;
|
||||
|
||||
scm_init_guile ();
|
||||
|
||||
guile_module_weechat = scm_c_define_module ("weechat",
|
||||
&weechat_guile_api_module_init,
|
||||
NULL);
|
||||
scm_c_use_module ("weechat");
|
||||
scm_gc_protect_object (guile_module_weechat);
|
||||
|
||||
guile_quiet = 1;
|
||||
script_init (weechat_guile_plugin,
|
||||
argc,
|
||||
argv,
|
||||
&weechat_guile_command_cb,
|
||||
&weechat_guile_completion_cb,
|
||||
&weechat_guile_infolist_cb,
|
||||
&weechat_guile_signal_debug_dump_cb,
|
||||
&weechat_guile_signal_buffer_closed_cb,
|
||||
&weechat_guile_signal_script_action_cb,
|
||||
&weechat_guile_load_cb);
|
||||
guile_quiet = 0;
|
||||
|
||||
script_display_short_list (weechat_guile_plugin,
|
||||
guile_scripts);
|
||||
|
||||
/* init ok */
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_plugin_end: shutdown Guile interface
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_plugin_end (struct t_weechat_plugin *plugin)
|
||||
{
|
||||
/* unload all scripts */
|
||||
guile_quiet = 1;
|
||||
script_end (plugin, &guile_scripts, &weechat_guile_unload_all);
|
||||
guile_quiet = 0;
|
||||
|
||||
/* unprotect module */
|
||||
scm_gc_unprotect_object (guile_module_weechat);
|
||||
|
||||
/* free some data */
|
||||
if (guile_action_install_list)
|
||||
free (guile_action_install_list);
|
||||
if (guile_action_remove_list)
|
||||
free (guile_action_remove_list);
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* Copyright (C) 2011 Sebastien 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_GUILE_H
|
||||
#define __WEECHAT_GUILE_H 1
|
||||
|
||||
#define weechat_plugin weechat_guile_plugin
|
||||
#define GUILE_PLUGIN_NAME "guile"
|
||||
|
||||
#define GUILE_CURRENT_SCRIPT_NAME ((guile_current_script) ? guile_current_script->name : "-")
|
||||
|
||||
extern struct t_weechat_plugin *weechat_guile_plugin;
|
||||
|
||||
extern int guile_quiet;
|
||||
extern struct t_plugin_script *guile_scripts;
|
||||
extern struct t_plugin_script *last_guile_script;
|
||||
extern struct t_plugin_script *guile_current_script;
|
||||
extern struct t_plugin_script *guile_registered_script;
|
||||
extern const char *guile_current_script_filename;
|
||||
extern SCM guile_port;
|
||||
|
||||
extern SCM weechat_guile_hashtable_to_alist (struct t_hashtable *hashtable);
|
||||
extern struct t_hashtable *weechat_guile_alist_to_hashtable (SCM dict,
|
||||
int hashtable_size);
|
||||
extern void *weechat_guile_exec (struct t_plugin_script *script,
|
||||
int ret_type, const char *function,
|
||||
char *format, void **argv);
|
||||
extern int weechat_guile_port_fill_input (SCM port);
|
||||
extern void weechat_guile_port_write (SCM port, const void *data, size_t size);
|
||||
|
||||
#endif /* __WEECHAT_GUILE_H */
|
Loading…
Reference in New Issue