diff options
Diffstat (limited to 'doc')
50 files changed, 957 insertions, 246 deletions
diff --git a/doc/de/autogen/plugin_api/completions.asciidoc b/doc/de/autogen/plugin_api/completions.asciidoc index 87f703843..5c44eea82 100644 --- a/doc/de/autogen/plugin_api/completions.asciidoc +++ b/doc/de/autogen/plugin_api/completions.asciidoc @@ -46,6 +46,8 @@ | irc | nick | Liste der Nicks im aktuellen Channel +| javascript | javascript_script | Liste der Skripten + | lua | lua_script | Liste der Skripten | perl | perl_script | Liste der Skripten diff --git a/doc/de/autogen/plugin_api/hdata.asciidoc b/doc/de/autogen/plugin_api/hdata.asciidoc index a9c06fe16..989eb7036 100644 --- a/doc/de/autogen/plugin_api/hdata.asciidoc +++ b/doc/de/autogen/plugin_api/hdata.asciidoc @@ -222,6 +222,40 @@ ** Listen: *** 'irc_servers' *** 'last_irc_server' +* 'javascript_callback': Callback eines Skripts +** Erweiterung: javascript +** Variablen: +*** 'script' (pointer, hdata: "javascript_script") +*** 'function' (string) +*** 'data' (string) +*** 'config_file' (pointer, hdata: "config_file") +*** 'config_section' (pointer, hdata: "config_section") +*** 'config_option' (pointer, hdata: "config_option") +*** 'hook' (pointer) +*** 'buffer' (pointer, hdata: "buffer") +*** 'bar_item' (pointer, hdata: "bar_item") +*** 'upgrade_file' (pointer) +*** 'prev_callback' (pointer, hdata: "javascript_callback") +*** 'next_callback' (pointer, hdata: "javascript_callback") +* 'javascript_script': Liste der Skripten +** Erweiterung: javascript +** Variablen: +*** 'filename' (string) +*** 'interpreter' (pointer) +*** 'name' (string) +*** 'author' (string) +*** 'version' (string) +*** 'license' (string) +*** 'description' (string) +*** 'shutdown_func' (string) +*** 'charset' (string) +*** 'callbacks' (pointer, hdata: "javascript_callback") +*** 'unloading' (integer) +*** 'prev_script' (pointer, hdata: "javascript_script") +*** 'next_script' (pointer, hdata: "javascript_script") +** Listen: +*** 'last_script' +*** 'scripts' * 'lua_callback': Callback eines Skripts ** Erweiterung: lua ** Variablen: diff --git a/doc/de/autogen/plugin_api/infolists.asciidoc b/doc/de/autogen/plugin_api/infolists.asciidoc index 6394b993b..598a84784 100644 --- a/doc/de/autogen/plugin_api/infolists.asciidoc +++ b/doc/de/autogen/plugin_api/infolists.asciidoc @@ -18,6 +18,8 @@ | irc | irc_server | Liste der IRC-Server | Server Pointer (optional) | Servername (Platzhalter "*" kann verwendet werden) (optional) +| javascript | javascript_script | Liste der Skripten | Skript Pointer (optional) | Name des Skriptes (Platzhalter "*" kann verwendet werden) (optional) + | logger | logger_buffer | Auflistung der protokollierten Buffer | Logger-Pointer (optional) | - | lua | lua_script | Liste der Skripten | Skript Pointer (optional) | Name des Skriptes (Platzhalter "*" kann verwendet werden) (optional) diff --git a/doc/de/autogen/plugin_api/plugins_priority.asciidoc b/doc/de/autogen/plugin_api/plugins_priority.asciidoc index d5a171b0b..8156259db 100644 --- a/doc/de/autogen/plugin_api/plugins_priority.asciidoc +++ b/doc/de/autogen/plugin_api/plugins_priority.asciidoc @@ -8,5 +8,5 @@ . xfer (6000) . irc (5000) . relay (4000) -. guile, lua, perl, python, ruby, tcl (3000) +. guile, javascript, lua, perl, python, ruby, tcl (3000) . script (2000) diff --git a/doc/de/autogen/user/javascript_commands.asciidoc b/doc/de/autogen/user/javascript_commands.asciidoc new file mode 100644 index 000000000..0e405cbca --- /dev/null +++ b/doc/de/autogen/user/javascript_commands.asciidoc @@ -0,0 +1,22 @@ +[[command_javascript_javascript]] +[command]*`javascript`* auflisten/installieren/beenden von Skripten:: + +---- +/javascript list|listfull [<name>] + load [-q] <filename> + autoload + reload|unload [-q] [<name>] + + list: installierte Skripten werden aufgelistet +listfull: detaillierte Auflistung aller installierten Skripten + load: installiert ein Skript +autoload: startet automatisch alle Skripten aus dem "autoload" Verzeichnis + reload: ein Skript wird erneut gestartet (wird kein Name angegeben, dann werden alle Skripten beendet und erneut gestartet) + unload: beendet ein Skript (wird kein Name angegeben, dann werden alle Skripten beendet) +filename: Skript (Datei) welches geladen werden soll + name: Name eines Skriptes (der Name der in der "register" Funktion der Skript-API genutzt wird) + -q: unterdrückter Modus: Es werden keine Nachrichten ausgegeben + +Ohne Angabe eines Argumentes listet dieser Befehl alle geladenen Skripten auf. +---- + diff --git a/doc/de/weechat_scripting.de.asciidoc b/doc/de/weechat_scripting.de.asciidoc index 1371ec20d..765385136 100644 --- a/doc/de/weechat_scripting.de.asciidoc +++ b/doc/de/weechat_scripting.de.asciidoc @@ -33,6 +33,7 @@ werden folgende Programmiersprachen unterstützt: * lua * tcl * guile (scheme) +* javascript [NOTE] Beinahe alle Beispiele in dieser Dokumentation beziehen sich auf Python. @@ -87,6 +88,10 @@ Weechat.config_new_option(config, section, "name", "string", "description of opt ** config_new_option ** bar_new +==== Javascript + +* Funktionen werden im Format `weechat.xxx(arg1, arg2, ...);` ausgeführt + [[register_function]] === Die "Register" Funktion @@ -164,7 +169,15 @@ weechat::print "" "Hallo, von einem tcl Skript!" [source,lisp] ---- (weechat:register "test_scheme" "FlashCode" "1.0" "GPL3" "Test script" "" "") -(weechat:print "" "Hello, from scheme script!") +(weechat:print "" "Hallo, von einem scheme Skript!") +---- + +* javascript: + +[source,javascript] +---- +weechat.register("test_js", "FlashCode", "1.0", "GPL3", "Test Skript", "", ""); +weechat.print("", "Hallo, von einem javascript Skript!"); ---- [[load_script]] @@ -180,18 +193,20 @@ nutzen, zum Beispiel: /script load script.lua /script load script.tcl /script load script.scm +/script load script.js ---- Es besteht natürlich weiterhin die Möglichkeit, individuell für jede Skriptsprache, den entsprechenden Befehl zu nutzen: ---- -/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 +/python load script.py +/perl load script.pl +/ruby load script.rb +/lua load script.lua +/tcl load script.tcl +/guile load script.scm +/javascript load script.js ---- Um Skripten automatisch beim Start von WeeChat zu laden sollte man einen Link @@ -355,6 +370,18 @@ weechat::hook_timer 1000 0 1 timer_cb test (weechat:hook_timer 1000 0 1 "timer_cb" "test") ---- +* javascript: + +[source,javascript] +---- +function timer_cb(data, remaining_calls) { + weechat.print("", "timer! data=" + data); + return weechat.WEECHAT_RC_OK; +} + +weechat.hook_timer(1000, 0, 1, "timer_cb", "test"); +---- + [[script_api]] == Skript API @@ -533,7 +560,8 @@ weechat.prnt(buffer, "Nachricht im #weechat Channel") ---- [NOTE] -Die print Funktion heißt in Perl/Ruby/Lua/Tcl `print`. In Python lautet die Funktion `prnt`. +Die print Funktion heißt in Perl/Ruby/Lua/Tcl/Guile/Javascript `print`. +In Python lautet die Funktion `prnt`. [[buffers_send_text]] ==== Text in einen Buffer senden @@ -804,7 +832,7 @@ def config_cb(data, option, value): # ... weechat.hook_config("plugins.var.python." + SKRIPT_NAME + ".*", "config_cb", "") -# für die jeweilige Programmiersprache muss "python" durch "perl", "ruby", "lua" oder "tcl" ersetzt werden. +# für die jeweilige Programmiersprache muss "python" durch perl/ruby/lua/tcl/guile/javascript ersetzt werden. ---- [[config_options_weechat]] diff --git a/doc/de/weechat_user.de.asciidoc b/doc/de/weechat_user.de.asciidoc index 7077c5eb4..e798c577a 100644 --- a/doc/de/weechat_user.de.asciidoc +++ b/doc/de/weechat_user.de.asciidoc @@ -147,6 +147,9 @@ zu kompilieren und welche Pakete optional genutzt werden können. | guile-2.0-dev | ≥ 2.0 | | Guile (scheme) Erweiterung +| libv8-dev | | | + Javascript Erweiterung + | asciidoc | ≥ 8.5.0 | | Zum Erstellen der man page und der Dokumentation @@ -254,6 +257,9 @@ Liste von häufig verwendeten Optionen: | ENABLE_IRC | `ON`, `OFF` | ON | kompiliert <<irc_plugin,IRC Erweiterung>>. +| ENABLE_JAVASCRIPT | `ON`, `OFF` | ON | + kompiliert <<scripts_plugins,Javascript Erweiterung>>. + | ENABLE_LARGEFILE | `ON`, `OFF` | ON | Unterstützung großer Dateien. @@ -289,8 +295,8 @@ Liste von häufig verwendeten Optionen: kompiliert <<scripts_plugins,Script Erweiterung>>. | ENABLE_SCRIPTS | `ON`, `OFF` | ON | - kompiliert <<scripts_plugins,Skripten-Erweiterungen>> (Python, Perl, Ruby, Lua, Tcl, - Guile). + kompiliert <<scripts_plugins,Skripten-Erweiterungen>> (Python, Perl, Ruby, + Lua, Tcl, Guile, Javascript). | ENABLE_TCL | `ON`, `OFF` | ON | kompiliert <<scripts_plugins,Tcl Erweiterung>>. @@ -1816,7 +1822,7 @@ Beispiele wie man Erweiterungen lädt, entfernt und auflistet: Standarderweiterungen: -[width="50%",cols="^1,5",options="header"] +[width="100%",cols="^1,5",options="header"] |=== | Erweiterung | Beschreibung | alias | definiert Alias für Befehle @@ -1834,6 +1840,7 @@ Standarderweiterungen: | lua | Lua-Skript API | tcl | Tcl-Skript API | guile | Guile(scheme)-Skript API +| javascript | Javascript-Skript API | trigger | Veränderung von Text und Ausführen von Befehlen bei einem Ereignis, welche durch WeeChat oder eine Erweiterung ausgelöst werden | xfer | Datentransfer und Direktchat |=== @@ -2931,8 +2938,8 @@ Die URI muss immer auf "/weechat" enden ('irc' und 'weechat' Protokoll). [[scripts_plugins]] === Erweiterungen für Skripten -WeeChat unterstützt sechs Skript-Erweiterungen: Python, Perl, Ruby, Lua, Tcl und Guile -(scheme). +WeeChat unterstützt sechs Skript-Erweiterungen: Python, Perl, Ruby, Lua, Tcl, +Guile (scheme) und Javascript. Mit diesen Erweiterungen kann für die jeweilige Skript-Sprache, Skripten geladen, ausgeführt und entfernt werden. @@ -2996,6 +3003,11 @@ include::autogen/user/tcl_commands.asciidoc[] include::autogen/user/guile_commands.asciidoc[] +[[javascript_commands]] +==== Javascript Befehle + +include::autogen/user/javascript_commands.asciidoc[] + [[trigger_plugin]] === Trigger Erweiterung diff --git a/doc/docgen.py b/doc/docgen.py index 6ba11f0c4..662fd4853 100644 --- a/doc/docgen.py +++ b/doc/docgen.py @@ -98,6 +98,7 @@ PLUGIN_LIST = { 'script': 'o', 'perl': '', 'python': '', + 'javascript': '', 'ruby': '', 'lua': '', 'tcl': '', diff --git a/doc/en/autogen/plugin_api/completions.asciidoc b/doc/en/autogen/plugin_api/completions.asciidoc index d06f93f47..66da8e0fb 100644 --- a/doc/en/autogen/plugin_api/completions.asciidoc +++ b/doc/en/autogen/plugin_api/completions.asciidoc @@ -46,6 +46,8 @@ | irc | nick | nicks of current IRC channel +| javascript | javascript_script | list of scripts + | lua | lua_script | list of scripts | perl | perl_script | list of scripts diff --git a/doc/en/autogen/plugin_api/hdata.asciidoc b/doc/en/autogen/plugin_api/hdata.asciidoc index 637e5253d..86a48dc3d 100644 --- a/doc/en/autogen/plugin_api/hdata.asciidoc +++ b/doc/en/autogen/plugin_api/hdata.asciidoc @@ -222,6 +222,40 @@ ** lists: *** 'irc_servers' *** 'last_irc_server' +* 'javascript_callback': callback of a script +** plugin: javascript +** variables: +*** 'script' (pointer, hdata: "javascript_script") +*** 'function' (string) +*** 'data' (string) +*** 'config_file' (pointer, hdata: "config_file") +*** 'config_section' (pointer, hdata: "config_section") +*** 'config_option' (pointer, hdata: "config_option") +*** 'hook' (pointer) +*** 'buffer' (pointer, hdata: "buffer") +*** 'bar_item' (pointer, hdata: "bar_item") +*** 'upgrade_file' (pointer) +*** 'prev_callback' (pointer, hdata: "javascript_callback") +*** 'next_callback' (pointer, hdata: "javascript_callback") +* 'javascript_script': list of scripts +** plugin: javascript +** variables: +*** 'filename' (string) +*** 'interpreter' (pointer) +*** 'name' (string) +*** 'author' (string) +*** 'version' (string) +*** 'license' (string) +*** 'description' (string) +*** 'shutdown_func' (string) +*** 'charset' (string) +*** 'callbacks' (pointer, hdata: "javascript_callback") +*** 'unloading' (integer) +*** 'prev_script' (pointer, hdata: "javascript_script") +*** 'next_script' (pointer, hdata: "javascript_script") +** lists: +*** 'last_script' +*** 'scripts' * 'lua_callback': callback of a script ** plugin: lua ** variables: diff --git a/doc/en/autogen/plugin_api/infolists.asciidoc b/doc/en/autogen/plugin_api/infolists.asciidoc index 6f6990f9f..7e8e0119b 100644 --- a/doc/en/autogen/plugin_api/infolists.asciidoc +++ b/doc/en/autogen/plugin_api/infolists.asciidoc @@ -18,6 +18,8 @@ | irc | irc_server | list of IRC servers | server pointer (optional) | server name (wildcard "*" is allowed) (optional) +| javascript | javascript_script | list of scripts | script pointer (optional) | script name (wildcard "*" is allowed) (optional) + | logger | logger_buffer | list of logger buffers | logger pointer (optional) | - | lua | lua_script | list of scripts | script pointer (optional) | script name (wildcard "*" is allowed) (optional) diff --git a/doc/en/autogen/plugin_api/plugins_priority.asciidoc b/doc/en/autogen/plugin_api/plugins_priority.asciidoc index d5a171b0b..8156259db 100644 --- a/doc/en/autogen/plugin_api/plugins_priority.asciidoc +++ b/doc/en/autogen/plugin_api/plugins_priority.asciidoc @@ -8,5 +8,5 @@ . xfer (6000) . irc (5000) . relay (4000) -. guile, lua, perl, python, ruby, tcl (3000) +. guile, javascript, lua, perl, python, ruby, tcl (3000) . script (2000) diff --git a/doc/en/autogen/user/javascript_commands.asciidoc b/doc/en/autogen/user/javascript_commands.asciidoc new file mode 100644 index 000000000..033797446 --- /dev/null +++ b/doc/en/autogen/user/javascript_commands.asciidoc @@ -0,0 +1,22 @@ +[[command_javascript_javascript]] +[command]*`javascript`* list/load/unload scripts:: + +---- +/javascript list|listfull [<name>] + load [-q] <filename> + autoload + reload|unload [-q] [<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) + -q: quiet mode: do not display messages + +Without argument, this command lists all loaded scripts. +---- + diff --git a/doc/en/weechat_dev.en.asciidoc b/doc/en/weechat_dev.en.asciidoc index 976bb9471..6a2e2260b 100644 --- a/doc/en/weechat_dev.en.asciidoc +++ b/doc/en/weechat_dev.en.asciidoc @@ -46,35 +46,36 @@ The main WeeChat directories are: [width="100%",cols="1v,5",options="header"] |=== -| Directory | Description -| src/ | Root of sources -| core/ | Core functions: entry point, internal structures -| gui/ | Functions for buffers, windows, ... (used by all interfaces) -| curses/ | Curses interface -| plugins/ | Plugin and scripting API -| alias/ | Alias plugin -| aspell/ | Aspell plugin -| charset/ | Charset plugin -| exec/ | Exec plugin -| fifo/ | Fifo plugin (FIFO pipe used to remotely send commands to WeeChat) -| irc/ | IRC (Internet Relay Chat) plugin -| logger/ | Logger plugin (write messages displayed to files) -| relay/ | Relay plugin (irc proxy + relay for remote interfaces) -| script/ | Scripts manager -| 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 -| trigger/ | Trigger plugin -| xfer/ | Xfer plugin (IRC DCC file/chat) -| tests/ | Tests -| unit/ | Unit tests -| core/ | Unit tests for core functions -| doc/ | Documentation -| po/ | Translations files (gettext) -| debian/ | Debian packaging +| Directory | Description +| src/ | Root of sources +| core/ | Core functions: entry point, internal structures +| gui/ | Functions for buffers, windows, ... (used by all interfaces) +| curses/ | Curses interface +| plugins/ | Plugin and scripting API +| alias/ | Alias plugin +| aspell/ | Aspell plugin +| charset/ | Charset plugin +| exec/ | Exec plugin +| fifo/ | Fifo plugin (FIFO pipe used to remotely send commands to WeeChat) +| irc/ | IRC (Internet Relay Chat) plugin +| logger/ | Logger plugin (write messages displayed to files) +| relay/ | Relay plugin (irc proxy + relay for remote interfaces) +| script/ | Scripts manager +| 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 +| javascript/ | Javascript scripting API +| trigger/ | Trigger plugin +| xfer/ | Xfer plugin (IRC DCC file/chat) +| tests/ | Tests +| unit/ | Unit tests +| core/ | Unit tests for core functions +| doc/ | Documentation +| po/ | Translations files (gettext) +| debian/ | Debian packaging |=== [[sources]] @@ -215,6 +216,10 @@ WeeChat "core" is located in following directories: | irc-sasl.c | SASL authentication with IRC server | irc-server.c | I/O communication with IRC server | irc-upgrade.c | Save/restore of IRC data when upgrading WeeChat +| javascript/ | Javascript plugin +| weechat-js.cpp | Main javascript functions (load/unload scripts, execute javascript code) +| weechat-js-api.cpp | Javascript scripting API functions +| weechat-js-v8.cpp | Javascript v8 functions | logger/ | Logger plugin | logger.c | Main logger functions | logger-buffer.c | Logger buffer list management @@ -1031,7 +1036,7 @@ Then you can load this script in your WeeChat, and setup path to your '/doc' dir Then create this alias to build files: ---- -/alias doc /perl unload; /python unload; /ruby unload; /lua unload; /tcl unload; /guile unload; /python load docgen.py; /wait 1ms /docgen +/alias doc /perl unload; /python unload; /ruby unload; /lua unload; /tcl unload; /guile unload; /javascript unload; /python load docgen.py; /wait 1ms /docgen ---- And use command `/doc` to build all files, for all languages. diff --git a/doc/en/weechat_plugin_api.en.asciidoc b/doc/en/weechat_plugin_api.en.asciidoc index ea8ea38d2..449fbc86e 100644 --- a/doc/en/weechat_plugin_api.en.asciidoc +++ b/doc/en/weechat_plugin_api.en.asciidoc @@ -7985,6 +7985,26 @@ List of signals sent by WeeChat and plugins: String: server name + "," + nick | A nick in notify list is back (away status removed) +| javascript | javascript_script_loaded + + _(WeeChat ≥ 1.2)_ | + String: path to script | + Javascript script loaded + +| javascript | javascript_script_unloaded + + _(WeeChat ≥ 1.2)_ | + String: path to script | + Javascript script unloaded + +| javascript | javascript_script_installed + + _(WeeChat ≥ 1.2)_ | + String: comma-separated list of paths to scripts installed | + Javascript script(s) installed + +| javascript | javascript_script_removed + + _(WeeChat ≥ 1.2)_ | + String: comma-separated list of scripts removed | + Javascript script(s) removed + | logger | logger_start | Pointer: buffer | Start logging for buffer @@ -8565,6 +8585,8 @@ Five signals can be sent to install a script, according to language: * 'ruby_script_install' * 'lua_script_install' * 'tcl_script_install' +* 'guile_script_install' +* 'javascript_script_install' The callback will do following actions when receiving signal: @@ -8603,6 +8625,8 @@ Five signals can be sent to remove list of scripts, according to language: * 'ruby_script_remove' * 'lua_script_remove' * 'tcl_script_remove' +* 'guile_script_remove' +* 'javascript_script_remove' For each script in list, the callback will unload then remove script. diff --git a/doc/en/weechat_scripting.en.asciidoc b/doc/en/weechat_scripting.en.asciidoc index d4bb03e73..44dd440f8 100644 --- a/doc/en/weechat_scripting.en.asciidoc +++ b/doc/en/weechat_scripting.en.asciidoc @@ -28,6 +28,7 @@ script languages: * lua * tcl * guile (scheme) +* javascript [NOTE] Almost all examples in this doc are written in Python, but API is the same for @@ -82,6 +83,10 @@ Weechat.config_new_option(config, section, "name", "string", "description of opt ** config_new_option ** bar_new +==== Javascript + +* Functions are called with `weechat.xxx(arg1, arg2, ...);` + [[register_function]] === Register function @@ -162,6 +167,14 @@ weechat::print "" "Hello, from tcl script!" (weechat:print "" "Hello, from scheme script!") ---- +* javascript: + +[source,javascript] +---- +weechat.register("test_js", "FlashCode", "1.0", "GPL3", "Test script", "", ""); +weechat.print("", "Hello, from javascript script!"); +---- + [[load_script]] === Load script @@ -174,17 +187,19 @@ It is recommended to use the "script" plugin to load scripts, for example: /script load script.lua /script load script.tcl /script load script.scm +/script load script.js ---- Each language has also its own command: ---- -/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 +/python load script.py +/perl load script.pl +/ruby load script.rb +/lua load script.lua +/tcl load script.tcl +/guile load script.scm +/javascript load script.js ---- You can make link in directory 'language/autoload' to autoload script when @@ -343,6 +358,18 @@ weechat::hook_timer 1000 0 1 timer_cb test (weechat:hook_timer 1000 0 1 "timer_cb" "test") ---- +* javascript: + +[source,javascript] +---- +function timer_cb(data, remaining_calls) { + weechat.print("", "timer! data=" + data); + return weechat.WEECHAT_RC_OK; +} + +weechat.hook_timer(1000, 0, 1, "timer_cb", "test"); +---- + [[script_api]] == Script API @@ -520,7 +547,8 @@ weechat.prnt(buffer, "message on #weechat channel") ---- [NOTE] -Print function is called `print` in Perl/Ruby/Lua/Tcl and `prnt` in Python. +Print function is called `print` in Perl/Ruby/Lua/Tcl/Guile/Javascript and +`prnt` in Python. [[buffers_send_text]] ==== Send text to buffer @@ -783,7 +811,7 @@ def config_cb(data, option, value): # ... weechat.hook_config("plugins.var.python." + SCRIPT_NAME + ".*", "config_cb", "") -# for other languages, change "python" with your language ("perl", "ruby", "lua" or "tcl") +# for other languages, change "python" with your language (perl/ruby/lua/tcl/guile/javascript) ---- [[config_options_weechat]] diff --git a/doc/en/weechat_user.en.asciidoc b/doc/en/weechat_user.en.asciidoc index 4f78218d2..d76bc78ff 100644 --- a/doc/en/weechat_user.en.asciidoc +++ b/doc/en/weechat_user.en.asciidoc @@ -139,6 +139,9 @@ compile WeeChat. | guile-2.0-dev | ≥ 2.0 | | Guile (scheme) plugin +| libv8-dev | | | + Javascript plugin + | asciidoc | ≥ 8.5.0 | | Build man page and documentation @@ -245,6 +248,9 @@ List of commonly used options: | ENABLE_IRC | `ON`, `OFF` | ON | Compile <<irc_plugin,IRC plugin>>. +| ENABLE_JAVASCRIPT | `ON`, `OFF` | ON | + Compile <<scripts_plugins,Javascript plugin>>. + | ENABLE_LARGEFILE | `ON`, `OFF` | ON | Support of large files. @@ -281,7 +287,7 @@ List of commonly used options: | ENABLE_SCRIPTS | `ON`, `OFF` | ON | Compile <<scripts_plugins,script plugins>> (Python, Perl, Ruby, Lua, Tcl, - Guile). + Guile, Javascript). | ENABLE_TCL | `ON`, `OFF` | ON | Compile <<scripts_plugins,Tcl plugin>>. @@ -1773,26 +1779,27 @@ Examples to load, unload or list plugins: Default plugins are: -[width="50%",cols="^1,5",options="header"] -|=== -| Plugin | Description -| alias | Define alias for commands -| aspell | Spell checking for command line -| charset | Charset decoding/encoding for buffers -| exec | Execution of external commands in WeeChat -| fifo | FIFO pipe used to remotely send commands to WeeChat -| irc | IRC chat protocol -| logger | Log buffers to files -| relay | Relay data via network -| script | Scripts manager -| 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 -| trigger | Text replacement and command execution on events triggered by WeeChat/plugins -| xfer | File transfer and direct chat +[width="100%",cols="^1,5",options="header"] +|=== +| Plugin | Description +| alias | Define alias for commands +| aspell | Spell checking for command line +| charset | Charset decoding/encoding for buffers +| exec | Execution of external commands in WeeChat +| fifo | FIFO pipe used to remotely send commands to WeeChat +| irc | IRC chat protocol +| logger | Log buffers to files +| relay | Relay data via network +| script | Scripts manager +| 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 +| javascript | Javascript scripting API +| trigger | Text replacement and command execution on events triggered by WeeChat/plugins +| xfer | File transfer and direct chat |=== To learn more about plugin or script development (through API), please read @@ -2857,8 +2864,8 @@ The URI must always end with "/weechat" (for 'irc' and 'weechat' protocols). [[scripts_plugins]] === Scripts plugins -WeeChat provides 6 scripting plugins: Python, Perl, Ruby, Lua, Tcl and Guile -(scheme). +WeeChat provides 7 scripting plugins: Python, Perl, Ruby, Lua, Tcl, Guile +(scheme) and Javascript. These plugins can load, execute and unload scripts for these languages. Another plugin called "script" is a scripts manager and is used to load/unload @@ -2920,6 +2927,11 @@ include::autogen/user/tcl_commands.asciidoc[] include::autogen/user/guile_commands.asciidoc[] +[[javascript_commands]] +==== Javascript commands + +include::autogen/user/javascript_commands.asciidoc[] + [[trigger_plugin]] === Trigger plugin diff --git a/doc/fr/autogen/plugin_api/completions.asciidoc b/doc/fr/autogen/plugin_api/completions.asciidoc index 0c341bbcc..5db31f2ee 100644 --- a/doc/fr/autogen/plugin_api/completions.asciidoc +++ b/doc/fr/autogen/plugin_api/completions.asciidoc @@ -46,6 +46,8 @@ | irc | nick | pseudos du canal IRC courant +| javascript | javascript_script | liste des scripts + | lua | lua_script | liste des scripts | perl | perl_script | liste des scripts diff --git a/doc/fr/autogen/plugin_api/hdata.asciidoc b/doc/fr/autogen/plugin_api/hdata.asciidoc index 6fb158cb3..20427661b 100644 --- a/doc/fr/autogen/plugin_api/hdata.asciidoc +++ b/doc/fr/autogen/plugin_api/hdata.asciidoc @@ -222,6 +222,40 @@ ** listes: *** 'irc_servers' *** 'last_irc_server' +* 'javascript_callback': callback d'un script +** extension: javascript +** variables: +*** 'script' (pointer, hdata: "javascript_script") +*** 'function' (string) +*** 'data' (string) +*** 'config_file' (pointer, hdata: "config_file") +*** 'config_section' (pointer, hdata: "config_section") +*** 'config_option' (pointer, hdata: "config_option") +*** 'hook' (pointer) +*** 'buffer' (pointer, hdata: "buffer") +*** 'bar_item' (pointer, hdata: "bar_item") +*** 'upgrade_file' (pointer) +*** 'prev_callback' (pointer, hdata: "javascript_callback") +*** 'next_callback' (pointer, hdata: "javascript_callback") +* 'javascript_script': liste des scripts +** extension: javascript +** variables: +*** 'filename' (string) +*** 'interpreter' (pointer) +*** 'name' (string) +*** 'author' (string) +*** 'version' (string) +*** 'license' (string) +*** 'description' (string) +*** 'shutdown_func' (string) +*** 'charset' (string) +*** 'callbacks' (pointer, hdata: "javascript_callback") +*** 'unloading' (integer) +*** 'prev_script' (pointer, hdata: "javascript_script") +*** 'next_script' (pointer, hdata: "javascript_script") +** listes: +*** 'last_script' +*** 'scripts' * 'lua_callback': callback d'un script ** extension: lua ** variables: diff --git a/doc/fr/autogen/plugin_api/infolists.asciidoc b/doc/fr/autogen/plugin_api/infolists.asciidoc index 9330a29e3..b7eb74215 100644 --- a/doc/fr/autogen/plugin_api/infolists.asciidoc +++ b/doc/fr/autogen/plugin_api/infolists.asciidoc @@ -18,6 +18,8 @@ | irc | irc_server | liste des serveurs IRC | pointeur vers le serveur (optionnel) | nom de serveur (le caractère joker "*" est autorisé) (optionnel) +| javascript | javascript_script | liste des scripts | pointeur vers le script (optionnel) | nom de script (le caractère joker "*" est autorisé) (optionnel) + | logger | logger_buffer | liste des enregistreurs de tampons (loggers) | pointeur vers le logger (optionnel) | - | lua | lua_script | liste des scripts | pointeur vers le script (optionnel) | nom de script (le caractère joker "*" est autorisé) (optionnel) diff --git a/doc/fr/autogen/plugin_api/plugins_priority.asciidoc b/doc/fr/autogen/plugin_api/plugins_priority.asciidoc index d5a171b0b..8156259db 100644 --- a/doc/fr/autogen/plugin_api/plugins_priority.asciidoc +++ b/doc/fr/autogen/plugin_api/plugins_priority.asciidoc @@ -8,5 +8,5 @@ . xfer (6000) . irc (5000) . relay (4000) -. guile, lua, perl, python, ruby, tcl (3000) +. guile, javascript, lua, perl, python, ruby, tcl (3000) . script (2000) diff --git a/doc/fr/autogen/user/javascript_commands.asciidoc b/doc/fr/autogen/user/javascript_commands.asciidoc new file mode 100644 index 000000000..7185f3762 --- /dev/null +++ b/doc/fr/autogen/user/javascript_commands.asciidoc @@ -0,0 +1,22 @@ +[[command_javascript_javascript]] +[command]*`javascript`* lister/charger/décharger des scripts:: + +---- +/javascript list|listfull [<nom>] + load [-q] <fichier> + autoload + reload|unload [-q] [<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") + -q : mode silencieux : ne pas afficher de messages + +Sans paramètre, cette commande liste les scripts chargés. +---- + diff --git a/doc/fr/weechat_dev.fr.asciidoc b/doc/fr/weechat_dev.fr.asciidoc index 8b4f3ab9f..7928a8577 100644 --- a/doc/fr/weechat_dev.fr.asciidoc +++ b/doc/fr/weechat_dev.fr.asciidoc @@ -47,35 +47,36 @@ Les répertoires principaux de WeeChat sont : [width="100%",cols="1v,5",options="header"] |=== -| Répertoire | Description -| src/ | Racine des sources -| core/ | Fonctions du cœur : point d'entrée, structures internes -| gui/ | Fonctions pour les tampons, fenêtres, ... (utilisées par toutes les interfaces) -| curses/ | Interface Curses -| plugins/ | API extension/script -| alias/ | Extension Alias -| aspell/ | Extension Aspell -| charset/ | Extension Charset -| exec/ | Extension Exec -| fifo/ | Extension Fifo (tube FIFO utilisé pour envoyer des commandes à WeeChat) -| irc/ | Extension IRC (Internet Relay Chat) -| logger/ | Extension Logger (enregistrer les messages affichés dans des fichiers) -| relay/ | Extension Relay (proxy IRC + relai pour interfaces distantes) -| script/ | Gestionnaire de scripts -| python/ | API script Python -| perl/ | API script Perl -| ruby/ | API script Ruby -| lua/ | API script Lua -| tcl/ | API script Tcl -| guile/ | API script Guile (scheme) -| trigger/ | Extension Trigger -| xfer/ | Extension Xfer (IRC DCC fichier/discussion) -| tests/ | Tests -| unit/ | Tests unitaires -| core/ | Tests unitaires pour les fonctions du cœur -| doc/ | Documentation -| po/ | Fichiers de traductions (gettext) -| debian/ | Empaquetage Debian +| Répertoire | Description +| src/ | Racine des sources +| core/ | Fonctions du cœur : point d'entrée, structures internes +| gui/ | Fonctions pour les tampons, fenêtres, ... (utilisées par toutes les interfaces) +| curses/ | Interface Curses +| plugins/ | API extension/script +| alias/ | Extension Alias +| aspell/ | Extension Aspell +| charset/ | Extension Charset +| exec/ | Extension Exec +| fifo/ | Extension Fifo (tube FIFO utilisé pour envoyer des commandes à WeeChat) +| irc/ | Extension IRC (Internet Relay Chat) +| logger/ | Extension Logger (enregistrer les messages affichés dans des fichiers) +| relay/ | Extension Relay (proxy IRC + relai pour interfaces distantes) +| script/ | Gestionnaire de scripts +| python/ | API script Python +| perl/ | API script Perl +| ruby/ | API script Ruby +| lua/ | API script Lua +| tcl/ | API script Tcl +| guile/ | API script Guile (scheme) +| javascript/ | API script Javascript +| trigger/ | Extension Trigger +| xfer/ | Extension Xfer (IRC DCC fichier/discussion) +| tests/ | Tests +| unit/ | Tests unitaires +| core/ | Tests unitaires pour les fonctions du cœur +| doc/ | Documentation +| po/ | Fichiers de traductions (gettext) +| debian/ | Empaquetage Debian |=== [[sources]] @@ -216,6 +217,10 @@ Le cœur de WeeChat est situé dans les répertoires suivants : | irc-sasl.c | Authentification SASL avec le serveur IRC | irc-server.c | Communication avec le serveur IRC | irc-upgrade.c | Sauvegarde/restauration des données IRC lors de la mise à jour de WeeChat +| javascript/ | Extension Javascript +| weechat-js.cpp | Fonctions principales pour Javascript (chargement/déchargement des scripts, exécution de code Javascript) +| weechat-js-api.cpp | Fonctions de l'API script Javascript +| weechat-js-v8.cpp | Fonctions Javascript v8 | logger/ | Extension Logger | logger.c | Fonctions principales pour Logger | logger-buffer.c | Gestion des listes de tampons pour Logger @@ -1051,7 +1056,7 @@ vers votre répertoire '/doc' : Créez alors cet alias pour construire les fichiers : ---- -/alias doc /perl unload; /python unload; /ruby unload; /lua unload; /tcl unload; /guile unload; /python load docgen.py; /wait 1ms /docgen +/alias doc /perl unload; /python unload; /ruby unload; /lua unload; /tcl unload; /guile unload; /javascript unload; /python load docgen.py; /wait 1ms /docgen ---- Et utilisez la commande `/doc` pour construire tous les fichiers, pour toutes diff --git a/doc/fr/weechat_plugin_api.fr.asciidoc b/doc/fr/weechat_plugin_api.fr.asciidoc index b204c6fd1..fd9b6ac0d 100644 --- a/doc/fr/weechat_plugin_api.fr.asciidoc +++ b/doc/fr/weechat_plugin_api.fr.asciidoc @@ -8132,6 +8132,26 @@ Liste des signaux envoyés par WeeChat et les extensions : Un pseudo dans la liste de notifications est de retour (statut d'absence supprimé) +| javascript | javascript_script_loaded + + _(WeeChat ≥ 1.2)_ | + Chaîne : chemin vers le script | + Script javascript chargé + +| javascript | javascript_script_unloaded + + _(WeeChat ≥ 1.2)_ | + Chaîne : chemin vers le script | + Script javascript déchargé + +| javascript | javascript_script_installed + + _(WeeChat ≥ 1.2)_ | + Chaîne : liste de chemins vers scripts installés (séparés par des virgules) | + Script(s) javascript installé(s) + +| javascript | javascript_script_removed + + _(WeeChat ≥ 1.2)_ | + Chaîne : liste de scripts supprimés (séparés par des virgules) | + Script(s) javascript supprimé(s) + | logger | logger_start | Pointeur : tampon | Démarrage de l'enregistrement sur disque pour le tampon @@ -8713,6 +8733,8 @@ Cinq signaux peuvent être envoyés pour installer un script, selon le langage : * 'ruby_script_install' * 'lua_script_install' * 'tcl_script_install' +* 'guile_script_install' +* 'javascript_script_install' Le "callback" effectuera les actions suivantes lorsqu'il recevra le signal : @@ -8754,6 +8776,8 @@ langage : * 'ruby_script_remove' * 'lua_script_remove' * 'tcl_script_remove' +* 'guile_script_remove' +* 'javascript_script_remove' Pour chaque script dans la liste, le "callback" déchargera et supprimera le script. diff --git a/doc/fr/weechat_scripting.fr.asciidoc b/doc/fr/weechat_scripting.fr.asciidoc index 8831a0d5d..8b940551f 100644 --- a/doc/fr/weechat_scripting.fr.asciidoc +++ b/doc/fr/weechat_scripting.fr.asciidoc @@ -29,6 +29,7 @@ l'un des langages de script supportés : * lua * tcl * guile (scheme) +* javascript [NOTE] La majorité des exemples de cette documentation sont écrits en Python, mais @@ -84,6 +85,10 @@ Weechat.config_new_option(config, section, "name", "string", "description of opt ** config_new_option ** bar_new +==== Javascript + +* Les fonctions sont appelées par `weechat.xxx(arg1, arg2, ...);` + [[register_function]] === Fonction register @@ -165,6 +170,14 @@ weechat::print "" "Bonjour, du script tcl !" (weechat:print "" "Bonjour, du script scheme !") ---- +* javascript: + +[source,javascript] +---- +weechat.register("test_js", "FlashCode", "1.0", "GPL3", "Test script", "", ""); +weechat.print("", "Bonjour, du script javascript !"); +---- + [[load_script]] === Chargement du script @@ -178,17 +191,19 @@ par exemple : /script load script.lua /script load script.tcl /script load script.scm +/script load script.js ---- Chaque langage a également sa propre commande : ---- -/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 +/python load script.py +/perl load script.pl +/ruby load script.rb +/lua load script.lua +/tcl load script.tcl +/guile load script.scm +/javascript load script.js ---- Vous pouvez faire un lien dans le répertoire 'langage/autoload' pour charger @@ -353,6 +368,18 @@ weechat::hook_timer 1000 0 1 timer_cb test (weechat:hook_timer 1000 0 1 "timer_cb" "test") ---- +* javascript: + +[source,javascript] +---- +function timer_cb(data, remaining_calls) { + weechat.print("", "timer! data=" + data); + return weechat.WEECHAT_RC_OK; +} + +weechat.hook_timer(1000, 0, 1, "timer_cb", "test"); +---- + [[script_api]] == API script @@ -531,8 +558,8 @@ weechat.prnt(buffer, "message sur le canal #weechat") ---- [NOTE] -La fonction d'affichage est appelée `print` en Perl/Ruby/Lua/Tcl et `prnt` en -Python. +La fonction d'affichage est appelée `print` en +Perl/Ruby/Lua/Tcl/Guile/Javascript et `prnt` en Python. [[buffers_send_text]] ==== Envoyer du texte au tampon @@ -804,7 +831,7 @@ def config_cb(data, option, value): # ... weechat.hook_config("plugins.var.python." + SCRIPT_NAME + ".*", "config_cb", "") -# pour les autres langages, remplacez "python" par le langage ("perl", "ruby", "lua" ou "tcl") +# pour les autres langages, remplacez "python" par le langage (perl/ruby/lua/tcl/guile/javascript) ---- [[config_options_weechat]] diff --git a/doc/fr/weechat_user.fr.asciidoc b/doc/fr/weechat_user.fr.asciidoc index 4bec9cc34..faf7afd33 100644 --- a/doc/fr/weechat_user.fr.asciidoc +++ b/doc/fr/weechat_user.fr.asciidoc @@ -144,6 +144,9 @@ compiler WeeChat. | guile-2.0-dev | ≥ 2.0 | | Extension guile (scheme) +| libv8-dev | | | + Extension javascript + | asciidoc | ≥ 8.5.0 | | Construction de la page man et de la documentation @@ -250,6 +253,9 @@ Liste des options couramment utilisées : | ENABLE_IRC | `ON`, `OFF` | ON | Compiler <<irc_plugin,l'extension IRC>>. +| ENABLE_JAVASCRIPT | `ON`, `OFF` | ON | + Compiler <<scripts_plugins,l'extension Javascript>>. + | ENABLE_LARGEFILE | `ON`, `OFF` | ON | Support des gros fichiers. @@ -286,7 +292,7 @@ Liste des options couramment utilisées : | ENABLE_SCRIPTS | `ON`, `OFF` | ON | Compiler <<scripts_plugins,les extensions de script>> (Python, Perl, Ruby, - Lua, Tcl, Guile). + Lua, Tcl, Guile, Javascript). | ENABLE_TCL | `ON`, `OFF` | ON | Compiler <<scripts_plugins,l'extension Tcl>>. @@ -1829,26 +1835,27 @@ Exemples pour charger, décharger et afficher les extensions : Les extensions par défaut sont : -[width="50%",cols="^1,5",options="header"] -|=== -| Extension | Description -| alias | Définir des alias pour les commandes -| aspell | Vérification orthographique de la ligne de commande -| charset | Encodage/encodage avec jeu de caractère sur les tampons -| exec | Exécution de commandes externes dans WeeChat -| fifo | Tube FIFO pour envoyer des commandes à distance vers WeeChat -| irc | Discussion avec le protocole IRC -| logger | Enregistrement des tampons dans des fichiers -| relay | Relai de données via le réseau -| script | Gestionnaire de scripts -| 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) -| trigger | Remplacement de texte et exécution de commande sur des évènements de WeeChat ou des extensions -| xfer | Transfert de fichier et discussion directe +[width="100%",cols="^1,5",options="header"] +|=== +| Extension | Description +| alias | Définir des alias pour les commandes +| aspell | Vérification orthographique de la ligne de commande +| charset | Encodage/encodage avec jeu de caractère sur les tampons +| exec | Exécution de commandes externes dans WeeChat +| fifo | Tube FIFO pour envoyer des commandes à distance vers WeeChat +| irc | Discussion avec le protocole IRC +| logger | Enregistrement des tampons dans des fichiers +| relay | Relai de données via le réseau +| script | Gestionnaire de scripts +| 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) +| javascript | Interface (API) pour scripts Javascript +| trigger | Remplacement de texte et exécution de commande sur des évènements de WeeChat ou des extensions +| xfer | Transfert de fichier et discussion directe |=== Pour en apprendre plus sur le développement d'extension ou de script (via @@ -2951,8 +2958,8 @@ L'URI doit toujours se terminer par "/weechat" (pour les protocoles 'irc' et [[scripts_plugins]] === Extensions Scripts -WeeChat fournit 6 extensions pour scripts : Python, Perl, Ruby, Lua, Tcl et -Guile (scheme). +WeeChat fournit 7 extensions pour scripts : Python, Perl, Ruby, Lua, Tcl, +Guile (scheme) et Javascript. Ces extensions peuvent charger, exécuter et décharger des scripts pour ces langages. @@ -3016,6 +3023,11 @@ include::autogen/user/tcl_commands.asciidoc[] include::autogen/user/guile_commands.asciidoc[] +[[javascript_commands]] +==== Commandes Javascript + +include::autogen/user/javascript_commands.asciidoc[] + [[trigger_plugin]] === Extension Trigger diff --git a/doc/it/autogen/plugin_api/completions.asciidoc b/doc/it/autogen/plugin_api/completions.asciidoc index 623f9182b..7782b6956 100644 --- a/doc/it/autogen/plugin_api/completions.asciidoc +++ b/doc/it/autogen/plugin_api/completions.asciidoc @@ -46,6 +46,8 @@ | irc | nick | nick del canale IRC corrente +| javascript | javascript_script | elenco degli script + | lua | lua_script | elenco degli script | perl | perl_script | elenco degli script diff --git a/doc/it/autogen/plugin_api/hdata.asciidoc b/doc/it/autogen/plugin_api/hdata.asciidoc index 6f40652c9..f96094a05 100644 --- a/doc/it/autogen/plugin_api/hdata.asciidoc +++ b/doc/it/autogen/plugin_api/hdata.asciidoc @@ -222,6 +222,40 @@ ** lists: *** 'irc_servers' *** 'last_irc_server' +* 'javascript_callback': callback di uno script +** plugin: javascript +** variables: +*** 'script' (pointer, hdata: "javascript_script") +*** 'function' (string) +*** 'data' (string) +*** 'config_file' (pointer, hdata: "config_file") +*** 'config_section' (pointer, hdata: "config_section") +*** 'config_option' (pointer, hdata: "config_option") +*** 'hook' (pointer) +*** 'buffer' (pointer, hdata: "buffer") +*** 'bar_item' (pointer, hdata: "bar_item") +*** 'upgrade_file' (pointer) +*** 'prev_callback' (pointer, hdata: "javascript_callback") +*** 'next_callback' (pointer, hdata: "javascript_callback") +* 'javascript_script': elenco degli script +** plugin: javascript +** variables: +*** 'filename' (string) +*** 'interpreter' (pointer) +*** 'name' (string) +*** 'author' (string) +*** 'version' (string) +*** 'license' (string) +*** 'description' (string) +*** 'shutdown_func' (string) +*** 'charset' (string) +*** 'callbacks' (pointer, hdata: "javascript_callback") +*** 'unloading' (integer) +*** 'prev_script' (pointer, hdata: "javascript_script") +*** 'next_script' (pointer, hdata: "javascript_script") +** lists: +*** 'last_script' +*** 'scripts' * 'lua_callback': callback di uno script ** plugin: lua ** variables: diff --git a/doc/it/autogen/plugin_api/infolists.asciidoc b/doc/it/autogen/plugin_api/infolists.asciidoc index 3d2ebd2af..82c3c1cd7 100644 --- a/doc/it/autogen/plugin_api/infolists.asciidoc +++ b/doc/it/autogen/plugin_api/infolists.asciidoc @@ -18,6 +18,8 @@ | irc | irc_server | elenco di server IRC | puntatore al server (opzionale) | server name (wildcard "*" is allowed) (optional) +| javascript | javascript_script | elenco degli script | puntatore allo script (opzionale) | script name (wildcard "*" is allowed) (optional) + | logger | logger_buffer | elenco dei buffer logger | puntatore al logger (opzionale) | - | lua | lua_script | elenco degli script | puntatore allo script (opzionale) | script name (wildcard "*" is allowed) (optional) diff --git a/doc/it/autogen/plugin_api/plugins_priority.asciidoc b/doc/it/autogen/plugin_api/plugins_priority.asciidoc index d5a171b0b..8156259db 100644 --- a/doc/it/autogen/plugin_api/plugins_priority.asciidoc +++ b/doc/it/autogen/plugin_api/plugins_priority.asciidoc @@ -8,5 +8,5 @@ . xfer (6000) . irc (5000) . relay (4000) -. guile, lua, perl, python, ruby, tcl (3000) +. guile, javascript, lua, perl, python, ruby, tcl (3000) . script (2000) diff --git a/doc/it/autogen/user/javascript_commands.asciidoc b/doc/it/autogen/user/javascript_commands.asciidoc new file mode 100644 index 000000000..12fa76fdf --- /dev/null +++ b/doc/it/autogen/user/javascript_commands.asciidoc @@ -0,0 +1,22 @@ +[[command_javascript_javascript]] +[command]*`javascript`* elenca/carica/scarica script:: + +---- +/javascript list|listfull [<nome>] + load [-q] <nomefile> + autoload + reload|unload [-q][<nome>] + + list: elenca i plugin caricati + listfull: elenca i plugin caricati (dettagliato) + load: carica un plugin + autoload: carica automaticamente i plugin nella directory 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") + -q: modalità silenziosa: non mostra messaggi + +Senza argomento, questo comando elenca tutti i plugin caricati. +---- + diff --git a/doc/it/weechat_plugin_api.it.asciidoc b/doc/it/weechat_plugin_api.it.asciidoc index 52f81c09f..7bf302287 100644 --- a/doc/it/weechat_plugin_api.it.asciidoc +++ b/doc/it/weechat_plugin_api.it.asciidoc @@ -8165,6 +8165,30 @@ List of signals sent by WeeChat and plugins: String: nome server + "," + nick | Un nick nella lista notifiche è tornato (messaggio di assenza rimosso) +// TRANSLATION MISSING +| javascript | javascript_script_loaded + + _(WeeChat ≥ 1.2)_ | + String: path to script | + Javascript script loaded + +// TRANSLATION MISSING +| javascript | javascript_script_unloaded + + _(WeeChat ≥ 1.2)_ | + String: path to script | + Javascript script unloaded + +// TRANSLATION MISSING +| javascript | javascript_script_installed + + _(WeeChat ≥ 1.2)_ | + String: comma-separated list of paths to scripts installed | + Javascript script(s) installed + +// TRANSLATION MISSING +| javascript | javascript_script_removed + + _(WeeChat ≥ 1.2)_ | + String: comma-separated list of scripts removed | + Javascript script(s) removed + | logger | logger_start | Puntatore: buffer | Avvia il logging per il buffer @@ -8808,6 +8832,8 @@ del linguaggio: * 'ruby_script_install' * 'lua_script_install' * 'tcl_script_install' +* 'guile_script_install' +* 'javascript_script_install' La callback compirà le seguenti azioni alla ricezione del segnale: @@ -8849,6 +8875,8 @@ seconda del linguaggio: * 'ruby_script_remove' * 'lua_script_remove' * 'tcl_script_remove' +* 'guile_script_remove' +* 'javascript_script_remove' Per ogni script nella lista, la callback scaricherà e rimuoverà lo script. diff --git a/doc/it/weechat_scripting.it.asciidoc b/doc/it/weechat_scripting.it.asciidoc index 6f2b297aa..e058750c4 100644 --- a/doc/it/weechat_scripting.it.asciidoc +++ b/doc/it/weechat_scripting.it.asciidoc @@ -35,6 +35,7 @@ linguaggi di scripting supportati: * lua * tcl * guile (scheme) +* javascript [NOTE] Quasi tutti gli esempi in questo manuale sono scritti in Python, ma l'API @@ -90,6 +91,10 @@ Weechat.config_new_option(config, section, "name", "string", "description of opt ** config_new_option ** bar_new +==== Javascript + +* Le funzioni sono chiamate con `weechat.xxx(arg1, arg2, ...);` + [[register_function]] === Registrare una funzione @@ -170,6 +175,14 @@ weechat::print "" "Hello, from tcl script!" (weechat:print "" "Hello, from scheme script!") ---- +* javascript: + +[source,javascript] +---- +weechat.register("test_js", "FlashCode", "1.0", "GPL3", "Test script", "", ""); +weechat.print("", "Hello, from javascript script!"); +---- + [[load_script]] === Caricare uno script @@ -182,17 +195,19 @@ Si raccomanda di usare il plugin "script" per caricare gli script, ad esempio: /script load script.lua /script load script.tcl /script load script.scm +/script load script.js ---- Ogni linguaggio ha anche il suo comando specifico: ---- -/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 +/python load script.py +/perl load script.pl +/ruby load script.rb +/lua load script.lua +/tcl load script.tcl +/guile load script.scm +/javascript load script.js ---- È possibile creare un link nella directory 'linguaggio/autoload' per caricare @@ -357,6 +372,18 @@ weechat::hook_timer 1000 0 1 timer_cb test (weechat:hook_timer 1000 0 1 "timer_cb" "test") ---- +* javascript: + +[source,javascript] +---- +function timer_cb(data, remaining_calls) { + weechat.print("", "timer! data=" + data); + return weechat.WEECHAT_RC_OK; +} + +weechat.hook_timer(1000, 0, 1, "timer_cb", "test"); +---- + [[script_api]] == Script API @@ -536,7 +563,8 @@ weechat.prnt(buffer, "message on #weechat channel") ---- [NOTE] -La funzione print si chiama `print` in Perl/Ruby/Lua/Tcl e `prnt` in Python. +La funzione print si chiama `print` in Perl/Ruby/Lua/Tcl/Guile/Javascript e +`prnt` in Python. [[buffers_send_text]] ==== Invia testo al buffer @@ -808,7 +836,7 @@ def config_cb(data, option, value): # ... weechat.hook_config("plugins.var.python." + SCRIPT_NAME + ".*", "config_cb", "") -# for other languages, change "python" with your language ("perl", "ruby", "lua" or "tcl") +# for other languages, change "python" with your language (perl/ruby/lua/tcl/guile/javascript) ---- [[config_options_weechat]] diff --git a/doc/it/weechat_user.it.asciidoc b/doc/it/weechat_user.it.asciidoc index c44d2e6d0..9912a9ea1 100644 --- a/doc/it/weechat_user.it.asciidoc +++ b/doc/it/weechat_user.it.asciidoc @@ -156,6 +156,9 @@ compilare WeeChat. | guile-2.0-dev | ≥ 2.0 | | Plugin guile (scheme) +| libv8-dev | | | + Plugin Javascript + // TRANSLATION MISSING | asciidoc | ≥ 8.5.0 | | Build man page and documentation @@ -269,6 +272,9 @@ List of commonly used options: | ENABLE_IRC | `ON`, `OFF` | ON | Compile <<irc_plugin,IRC plugin>>. +| ENABLE_JAVASCRIPT | `ON`, `OFF` | ON | + Compile <<scripts_plugins,Javascript plugin>>. + | ENABLE_LARGEFILE | `ON`, `OFF` | ON | Support of large files. @@ -305,7 +311,7 @@ List of commonly used options: | ENABLE_SCRIPTS | `ON`, `OFF` | ON | Compile <<scripts_plugins,script plugins>> (Python, Perl, Ruby, Lua, Tcl, - Guile). + Guile, Javascript). | ENABLE_TCL | `ON`, `OFF` | ON | Compile <<scripts_plugins,Tcl plugin>>. @@ -1857,28 +1863,29 @@ Esempi per caricare, scaricare oppure elencare i plugin: I plugin predefiniti sono: -[width="50%",cols="^1,5",options="header"] +[width="100%",cols="^1,5",options="header"] |=== -| Plugin | Descrizione -| alias | Definisce gli alias per i comandi -| aspell | Controllo ortografico per la riga di comando -| charset | Set di caratteri per la codifica/decodifica nei buffer +| Plugin | Descrizione +| alias | Definisce gli alias per i comandi +| aspell | Controllo ortografico per la riga di comando +| charset | Set di caratteri per la codifica/decodifica nei buffer // TRANSLATION MISSING -| exec | Execution of external commands in WeeChat -| fifo | pipe FIFO utilizzata per inviare comandi da remoto su WeeChat -| irc | protocollo chat per IRC -| logger | Registra i buffer su file -| relay | Relay dei dati via rete -| script | Gestore script -| 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) +| exec | Execution of external commands in WeeChat +| fifo | pipe FIFO utilizzata per inviare comandi da remoto su WeeChat +| irc | protocollo chat per IRC +| logger | Registra i buffer su file +| relay | Relay dei dati via rete +| script | Gestore script +| 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) +| javascript | API per lo scripting in Javascript // TRANSLATION MISSING -| trigger | Text replacement and command execution on events triggered by WeeChat/plugins -| xfer | Trasferimento file e chat diretta +| trigger | Text replacement and command execution on events triggered by WeeChat/plugins +| xfer | Trasferimento file e chat diretta |=== Per saperne di più riguardo lo sviluppo di plugin o script (tramite le API), per @@ -3007,8 +3014,8 @@ The URI must always end with "/weechat" (for 'irc' and 'weechat' protocols). [[scripts_plugins]] === Plugin per gli script -WeeChat fornisce 6 plugin per lo scripting: Python, Perl, Ruby, Lua, Tcl, Guile -(scheme). +WeeChat fornisce 7 plugin per lo scripting: Python, Perl, Ruby, Lua, Tcl, Guile +(scheme), Javascript. Questi plugin possono caricare, eseguire e scaricare gli script per questi linguaggi. @@ -3076,6 +3083,11 @@ include::autogen/user/tcl_commands.asciidoc[] include::autogen/user/guile_commands.asciidoc[] +[[javascript_commands]] +==== Comandi Javascript + +include::autogen/user/javascript_commands.asciidoc[] + // TRANSLATION MISSING [[trigger_plugin]] === Trigger plugin diff --git a/doc/ja/autogen/plugin_api/completions.asciidoc b/doc/ja/autogen/plugin_api/completions.asciidoc index 9873fe98a..295c29918 100644 --- a/doc/ja/autogen/plugin_api/completions.asciidoc +++ b/doc/ja/autogen/plugin_api/completions.asciidoc @@ -46,6 +46,8 @@ | irc | nick | 現在の IRC チャンネルにいるニックネーム +| javascript | javascript_script | スクリプトのリスト + | lua | lua_script | スクリプトのリスト | perl | perl_script | スクリプトのリスト diff --git a/doc/ja/autogen/plugin_api/hdata.asciidoc b/doc/ja/autogen/plugin_api/hdata.asciidoc index c1d919b7b..73b5e3b73 100644 --- a/doc/ja/autogen/plugin_api/hdata.asciidoc +++ b/doc/ja/autogen/plugin_api/hdata.asciidoc @@ -222,6 +222,40 @@ ** リスト: *** 'irc_servers' *** 'last_irc_server' +* 'javascript_callback': スクリプトのコールバック +** プラグイン: javascript +** 変数: +*** 'script' (pointer, hdata: "javascript_script") +*** 'function' (string) +*** 'data' (string) +*** 'config_file' (pointer, hdata: "config_file") +*** 'config_section' (pointer, hdata: "config_section") +*** 'config_option' (pointer, hdata: "config_option") +*** 'hook' (pointer) +*** 'buffer' (pointer, hdata: "buffer") +*** 'bar_item' (pointer, hdata: "bar_item") +*** 'upgrade_file' (pointer) +*** 'prev_callback' (pointer, hdata: "javascript_callback") +*** 'next_callback' (pointer, hdata: "javascript_callback") +* 'javascript_script': スクリプトのリスト +** プラグイン: javascript +** 変数: +*** 'filename' (string) +*** 'interpreter' (pointer) +*** 'name' (string) +*** 'author' (string) +*** 'version' (string) +*** 'license' (string) +*** 'description' (string) +*** 'shutdown_func' (string) +*** 'charset' (string) +*** 'callbacks' (pointer, hdata: "javascript_callback") +*** 'unloading' (integer) +*** 'prev_script' (pointer, hdata: "javascript_script") +*** 'next_script' (pointer, hdata: "javascript_script") +** リスト: +*** 'last_script' +*** 'scripts' * 'lua_callback': スクリプトのコールバック ** プラグイン: lua ** 変数: diff --git a/doc/ja/autogen/plugin_api/infolists.asciidoc b/doc/ja/autogen/plugin_api/infolists.asciidoc index 3c51f216b..7865e43cd 100644 --- a/doc/ja/autogen/plugin_api/infolists.asciidoc +++ b/doc/ja/autogen/plugin_api/infolists.asciidoc @@ -18,6 +18,8 @@ | irc | irc_server | IRC サーバのリスト | サーバポインタ (任意) | サーバ名 (ワイルドカード "*" を使うことができます) (任意) +| javascript | javascript_script | スクリプトのリスト | スクリプトポインタ (任意) | スクリプト名 (ワイルドカード "*" を使うことができます) (任意) + | logger | logger_buffer | logger バッファのリスト | logger ポインタ (任意) | - | lua | lua_script | スクリプトのリスト | スクリプトポインタ (任意) | スクリプト名 (ワイルドカード "*" を使うことができます) (任意) diff --git a/doc/ja/autogen/plugin_api/plugins_priority.asciidoc b/doc/ja/autogen/plugin_api/plugins_priority.asciidoc index d5a171b0b..8156259db 100644 --- a/doc/ja/autogen/plugin_api/plugins_priority.asciidoc +++ b/doc/ja/autogen/plugin_api/plugins_priority.asciidoc @@ -8,5 +8,5 @@ . xfer (6000) . irc (5000) . relay (4000) -. guile, lua, perl, python, ruby, tcl (3000) +. guile, javascript, lua, perl, python, ruby, tcl (3000) . script (2000) diff --git a/doc/ja/autogen/user/javascript_commands.asciidoc b/doc/ja/autogen/user/javascript_commands.asciidoc new file mode 100644 index 000000000..e3448cb44 --- /dev/null +++ b/doc/ja/autogen/user/javascript_commands.asciidoc @@ -0,0 +1,22 @@ +[[command_javascript_javascript]] +[command]*`javascript`* スクリプトをリストアップ/ロード/アンロード:: + +---- +/javascript list|listfull [<name>] + load [-q] <filename> + autoload + reload|unload [-q] [<name>] + + list: ロード済みスクリプトをリストアップ +listfull: ロード済みスクリプトをリストアップ (詳細) + load: スクリプトをロード +autoload: "autoload" ディレクトリに含まれる全てのスクリプトをロード + reload: スクリプトのリロード (名前を指定しなかった場合、全てのスクリプトをアンロードし、"autoload" ディレクトリに含まれる全てのスクリプトをロード) + unload: スクリプトのアンロード (名前を指定しなかった場合、全てのスクリプトをアンロード) +filename: ロードするスクリプト (ファイル) + name: スクリプト名 (名前は "register" 関数を呼び出すために使われる) + -q: 出力抑制モード: メッセージを表示しない + +引数無しの場合、全てのロード済みスクリプトをリストアップします。 +---- + diff --git a/doc/ja/weechat_dev.ja.asciidoc b/doc/ja/weechat_dev.ja.asciidoc index c857a8cf1..d8db62cc9 100644 --- a/doc/ja/weechat_dev.ja.asciidoc +++ b/doc/ja/weechat_dev.ja.asciidoc @@ -51,35 +51,36 @@ WeeChat の主要なリポジトリは 2 つあります: [width="100%",cols="1v,5",options="header"] |=== -| ディレクトリ | 説明 -| src/ | ソースコードのルートディレクトリ -| core/ | コア関数: エントリポイント、内部構造体 -| gui/ | バッファ、ウィンドウ、... を操作する関数 (全てのインターフェイスで使う) -| curses/ | curses インターフェイス -| plugins/ | プラグインとスクリプト向け API -| alias/ | alias プラグイン -| aspell/ | aspell プラグイン -| charset/ | charset プラグイン -| exec/ | exec プラグイン -| fifo/ | fifo プラグイン (WeeChat にコマンドを送信する FIFO パイプ) -| irc/ | IRC (Internet Relay Chat) プラグイン -| logger/ | logger プラグイン (表示されたメッセージをファイルに書き込む) -| relay/ | relay プラグイン (irc プロキシ + リモートインターフェイス用の中継) -| script/ | スクリプトマネージャ -| python/ | python スクリプト用 API -| perl/ | perl スクリプト用 API -| ruby/ | ruby スクリプト用 API -| lua/ | lua スクリプト用 API -| tcl/ | tcl スクリプト用 API -| guile/ | guile (scheme) スクリプト用 API -| trigger/ | trigger プラグイン -| xfer/ | xfer (IRC DCC ファイル/チャット) -| tests/ | テスト -| unit/ | 単体テスト -| core/ | コア関数の単体テスト -| doc/ | 文書 -| po/ | 翻訳ファイル (gettext) -| debian/ | Debian パッケージ用 +| ディレクトリ | 説明 +| src/ | ソースコードのルートディレクトリ +| core/ | コア関数: エントリポイント、内部構造体 +| gui/ | バッファ、ウィンドウ、... を操作する関数 (全てのインターフェイスで使う) +| curses/ | curses インターフェイス +| plugins/ | プラグインとスクリプト向け API +| alias/ | alias プラグイン +| aspell/ | aspell プラグイン +| charset/ | charset プラグイン +| exec/ | exec プラグイン +| fifo/ | fifo プラグイン (WeeChat にコマンドを送信する FIFO パイプ) +| irc/ | IRC (Internet Relay Chat) プラグイン +| logger/ | logger プラグイン (表示されたメッセージをファイルに書き込む) +| relay/ | relay プラグイン (irc プロキシ + リモートインターフェイス用の中継) +| script/ | スクリプトマネージャ +| python/ | python スクリプト用 API +| perl/ | perl スクリプト用 API +| ruby/ | ruby スクリプト用 API +| lua/ | lua スクリプト用 API +| tcl/ | tcl スクリプト用 API +| guile/ | guile (scheme) スクリプト用 API +| javascript/ | javascript スクリプト用 API +| trigger/ | trigger プラグイン +| xfer/ | xfer (IRC DCC ファイル/チャット) +| tests/ | テスト +| unit/ | 単体テスト +| core/ | コア関数の単体テスト +| doc/ | 文書 +| po/ | 翻訳ファイル (gettext) +| debian/ | Debian パッケージ用 |=== [[sources]] @@ -220,6 +221,11 @@ WeeChat "core" は以下のディレクトリに配置されています: | irc-sasl.c | IRC サーバに対する SASL 認証 | irc-server.c | IRC サーバとの入出力通信 | irc-upgrade.c | WeeChat をアップグレードする際の IRC データの保存および読み込み +| javascript/ | javascript プラグイン +| weechat-js.cpp | javascript の主要関数 (スクリプトのロード/アンロード、javascript コードの実行) +| weechat-js-api.cpp | javascript スクリプト作成 API 関数 +// TRANSLATION MISSING +| weechat-js-v8.cpp | javascript v8 functions | logger/ | logger プラグイン | logger.c | logger の主要関数 | logger-buffer.c | logger バッファリスト管理 @@ -1028,7 +1034,7 @@ $ msgcheck.py xx.po ファイルを生成するエイリアスを作ってください: ---- -/alias doc /perl unload; /python unload; /ruby unload; /lua unload; /tcl unload; /guile unload; /python load docgen.py; /wait 1ms /docgen +/alias doc /perl unload; /python unload; /ruby unload; /lua unload; /tcl unload; /guile unload; /javascript unload; /python load docgen.py; /wait 1ms /docgen ---- コマンド `/doc` を使って全ての (全てのプログラミング言語について) 自動生成するファイルを作成してください。 diff --git a/doc/ja/weechat_plugin_api.ja.asciidoc b/doc/ja/weechat_plugin_api.ja.asciidoc index defe2bc69..23ec540aa 100644 --- a/doc/ja/weechat_plugin_api.ja.asciidoc +++ b/doc/ja/weechat_plugin_api.ja.asciidoc @@ -7984,6 +7984,26 @@ WeeChat とプラグインが送信するシグナルのリスト: String: サーバ名 + "," + ニックネーム | 通知リストに入っているニックネームが着席状態に (離席状態を解除) +| javascript | javascript_script_loaded + + _(WeeChat バージョン 1.2 以上で利用可)_ | + String: スクリプトへのパス | + Javascript スクリプトを読み込み + +| javascript | javascript_script_unloaded + + _(WeeChat バージョン 1.2 以上で利用可)_ | + String: スクリプトへのパス | + Javascript スクリプトを再読み込み + +| javascript | javascript_script_installed + + _(WeeChat バージョン 1.2 以上で利用可)_ | + String: インストールされたスクリプトへのパスのコンマ区切りリスト | + Javascript スクリプトをインストール + +| javascript | javascript_script_removed + + _(WeeChat バージョン 1.2 以上で利用可)_ | + String: 削除されたスクリプトへのパスのコンマ区切りリスト | + Javascript スクリプトを削除 + | logger | logger_start | Pointer: バッファ | バッファのログ保存を開始 @@ -8564,6 +8584,8 @@ weechat.hook_signal_send("logger_backlog", weechat.WEECHAT_HOOK_SIGNAL_POINTER, * 'ruby_script_install' * 'lua_script_install' * 'tcl_script_install' +* 'guile_script_install' +* 'javascript_script_install' シグナルを受け取ったらコールバックは以下のように働きます: @@ -8602,6 +8624,8 @@ weechat.hook_signal_send("python_script_install", WEECHAT_HOOK_SIGNAL_STRING, * 'ruby_script_remove' * 'lua_script_remove' * 'tcl_script_remove' +* 'guile_script_remove' +* 'javascript_script_remove' リスト文字列に含まれるそれぞれのスクリプトについて、コールバックはスクリプトを再読み込みして削除します。 diff --git a/doc/ja/weechat_scripting.ja.asciidoc b/doc/ja/weechat_scripting.ja.asciidoc index 97ef59a81..89120271f 100644 --- a/doc/ja/weechat_scripting.ja.asciidoc +++ b/doc/ja/weechat_scripting.ja.asciidoc @@ -33,6 +33,7 @@ WeeChat (Wee Enhanced Environment for Chat) はフリー、高速、軽量な * lua * tcl * guile (scheme) +* javascript [NOTE] この文書に含まれるほぼすべての例は Python @@ -168,6 +169,14 @@ weechat::print "" "Hello, from tcl script!" (weechat:print "" "Hello, from scheme script!") ---- +* javascript: + +[source,javascript] +---- +weechat.register("test_js", "FlashCode", "1.0", "GPL3", "Test script", "", ""); +weechat.print("", "Hello, from javascript script!"); +---- + [[load_script]] === スクリプトのロード @@ -180,17 +189,19 @@ weechat::print "" "Hello, from tcl script!" /script load script.lua /script load script.tcl /script load script.scm +/script load script.js ---- プログラミング言語ごとの固有コマンドを利用することもできます: ---- -/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 +/python load script.py +/perl load script.pl +/ruby load script.rb +/lua load script.lua +/tcl load script.tcl +/guile load script.scm +/javascript load script.js ---- WeeChat の開始時にスクリプトを自動ロードするには @@ -351,6 +362,18 @@ weechat::hook_timer 1000 0 1 timer_cb test (weechat:hook_timer 1000 0 1 "timer_cb" "test") ---- +* javascript: + +[source,javascript] +---- +function timer_cb(data, remaining_calls) { + weechat.print("", "timer! data=" + data); + return weechat.WEECHAT_RC_OK; +} + +weechat.hook_timer(1000, 0, 1, "timer_cb", "test"); +---- + [[script_api]] == スクリプト API @@ -528,7 +551,7 @@ weechat.prnt(buffer, "message on #weechat channel") ---- [NOTE] -Print 関数は Perl/Ruby/Lua/Tcl では `print` で、Python では `prnt` です。 +Print 関数は Perl/Ruby/Lua/Tcl/Guile/Javascript では `print` で、Python では `prnt` です。 [[buffers_send_text]] ==== バッファにテキストを送信 @@ -791,7 +814,7 @@ def config_cb(data, option, value): # ... weechat.hook_config("plugins.var.python." + SCRIPT_NAME + ".*", "config_cb", "") -# 他のスクリプト言語の場合は "python" を適当なもの ("perl"、"ruby"、"lua"、"tcl") に変更してください。 +# 他のスクリプト言語の場合は "python" を適当なもの (perl/ruby/lua/tcl/guile/javascript) に変更してください。 ---- [[config_options_weechat]] diff --git a/doc/ja/weechat_user.ja.asciidoc b/doc/ja/weechat_user.ja.asciidoc index 5ac8dce8a..e30260a97 100644 --- a/doc/ja/weechat_user.ja.asciidoc +++ b/doc/ja/weechat_user.ja.asciidoc @@ -143,6 +143,9 @@ OS X では、http://brew.sh/[Homebrew] を使ってください: | guile-2.0-dev | ≥ 2.0 | | guile (scheme) プラグイン +| libv8-dev | | | + javascript プラグイン + | asciidoc | ≥ 8.5.0 | | man ページと文書のビルド @@ -248,6 +251,9 @@ cmake に対するオプションを指定するには、以下のフォーマ | ENABLE_IRC | `ON`, `OFF` | ON | <<irc_plugin,IRC プラグイン>>のコンパイル +| ENABLE_JAVASCRIPT | `ON`, `OFF` | ON | + <<scripts_plugins,Javascript プラグイン>>のコンパイル。 + | ENABLE_LARGEFILE | `ON`, `OFF` | ON | 巨大ファイルのサポート。 @@ -284,7 +290,7 @@ cmake に対するオプションを指定するには、以下のフォーマ | ENABLE_SCRIPTS | `ON`, `OFF` | ON | すべての<<scripts_plugins,スクリプトプラグイン>> - (Python、Perl、Ruby、Lua、Tcl、Guile) のコンパイル + (Python、Perl、Ruby、Lua、Tcl、Guile、Javascript) のコンパイル | ENABLE_TCL | `ON`, `OFF` | ON | <<scripts_plugins,Tcl プラグイン>>のコンパイル @@ -1776,7 +1782,7 @@ GNU/Linux の場合、プラグインファイルは ".so" という拡張子を デフォルトプラグインのリスト: -[width="50%",cols="^1,5",options="header"] +[width="100%",cols="^1,5",options="header"] |=== | プラグイン | 説明 | alias | コマンドの別名を定義 @@ -1794,6 +1800,7 @@ GNU/Linux の場合、プラグインファイルは ".so" という拡張子を | lua | Lua スクリプト API | tcl | Tcl スクリプト API | guile | Guile (scheme) スクリプト API +| javascript | Javascript スクリプト API | trigger | WeeChat およびプラグインが発生させたイベントに対するテキスト置換とコマンド実行 | xfer | ファイル転送とダイレクトチャット |=== @@ -2860,8 +2867,8 @@ websocket = new WebSocket("ws://server.com:9000/weechat"); [[scripts_plugins]] === スクリプトプラグイン -WeeChat は 6 種類のスクリプトプラグインを備えています: Python、Perl、Ruby、Lua、Tcl、Guile -(scheme)。 +WeeChat は 7 種類のスクリプトプラグインを備えています: Python、Perl、Ruby、Lua、Tcl、Guile +(scheme)、Javascript。 これらのプラグインでそれぞれの言語で書かれたスクリプトのロード、実行、アンロードができます。 "スクリプト" と呼ばれるほかのプラグインはスクリプトマネージャで、任意の言語で書かれたスクリプトをロード @@ -2923,6 +2930,11 @@ include::autogen/user/tcl_commands.asciidoc[] include::autogen/user/guile_commands.asciidoc[] +[[javascript_commands]] +==== Javascript コマンド + +include::autogen/user/javascript_commands.asciidoc[] + [[trigger_plugin]] === トリガプラグイン diff --git a/doc/pl/autogen/plugin_api/completions.asciidoc b/doc/pl/autogen/plugin_api/completions.asciidoc index 916098593..63116a5fb 100644 --- a/doc/pl/autogen/plugin_api/completions.asciidoc +++ b/doc/pl/autogen/plugin_api/completions.asciidoc @@ -46,6 +46,8 @@ | irc | nick | użytkownicy obecnego kanału IRC +| javascript | javascript_script | lista skryptów + | lua | lua_script | lista skryptów | perl | perl_script | lista skryptów diff --git a/doc/pl/autogen/plugin_api/hdata.asciidoc b/doc/pl/autogen/plugin_api/hdata.asciidoc index a23a0622e..75dfedc76 100644 --- a/doc/pl/autogen/plugin_api/hdata.asciidoc +++ b/doc/pl/autogen/plugin_api/hdata.asciidoc @@ -222,6 +222,40 @@ ** listy: *** 'irc_servers' *** 'last_irc_server' +* 'javascript_callback': callback skryptu +** wtyczka: javascript +** zmienne: +*** 'script' (pointer, hdata: "javascript_script") +*** 'function' (string) +*** 'data' (string) +*** 'config_file' (pointer, hdata: "config_file") +*** 'config_section' (pointer, hdata: "config_section") +*** 'config_option' (pointer, hdata: "config_option") +*** 'hook' (pointer) +*** 'buffer' (pointer, hdata: "buffer") +*** 'bar_item' (pointer, hdata: "bar_item") +*** 'upgrade_file' (pointer) +*** 'prev_callback' (pointer, hdata: "javascript_callback") +*** 'next_callback' (pointer, hdata: "javascript_callback") +* 'javascript_script': lista skryptów +** wtyczka: javascript +** zmienne: +*** 'filename' (string) +*** 'interpreter' (pointer) +*** 'name' (string) +*** 'author' (string) +*** 'version' (string) +*** 'license' (string) +*** 'description' (string) +*** 'shutdown_func' (string) +*** 'charset' (string) +*** 'callbacks' (pointer, hdata: "javascript_callback") +*** 'unloading' (integer) +*** 'prev_script' (pointer, hdata: "javascript_script") +*** 'next_script' (pointer, hdata: "javascript_script") +** listy: +*** 'last_script' +*** 'scripts' * 'lua_callback': callback skryptu ** wtyczka: lua ** zmienne: diff --git a/doc/pl/autogen/plugin_api/infolists.asciidoc b/doc/pl/autogen/plugin_api/infolists.asciidoc index a93d27f02..931eba0b4 100644 --- a/doc/pl/autogen/plugin_api/infolists.asciidoc +++ b/doc/pl/autogen/plugin_api/infolists.asciidoc @@ -18,6 +18,8 @@ | irc | irc_server | lista serwerów IRC | wskaźnik serwera (opcjonalny) | nazwa serwera (wildcard "*" jest dozwolony) (opcjonalne) +| javascript | javascript_script | lista skryptów | wskaźnik skryptu (opcjonalne) | nazwa skryptu (wildcard "*" jest dozwolony) (opcjonalne) + | logger | logger_buffer | lista logowanych buforów | wskaźnik logger (opcjonalny) | - | lua | lua_script | lista skryptów | wskaźnik skryptu (opcjonalne) | nazwa skryptu (wildcard "*" jest dozwolony) (opcjonalne) diff --git a/doc/pl/autogen/plugin_api/plugins_priority.asciidoc b/doc/pl/autogen/plugin_api/plugins_priority.asciidoc index d5a171b0b..8156259db 100644 --- a/doc/pl/autogen/plugin_api/plugins_priority.asciidoc +++ b/doc/pl/autogen/plugin_api/plugins_priority.asciidoc @@ -8,5 +8,5 @@ . xfer (6000) . irc (5000) . relay (4000) -. guile, lua, perl, python, ruby, tcl (3000) +. guile, javascript, lua, perl, python, ruby, tcl (3000) . script (2000) diff --git a/doc/pl/autogen/user/javascript_commands.asciidoc b/doc/pl/autogen/user/javascript_commands.asciidoc new file mode 100644 index 000000000..2e5aef8f3 --- /dev/null +++ b/doc/pl/autogen/user/javascript_commands.asciidoc @@ -0,0 +1,22 @@ +[[command_javascript_javascript]] +[command]*`javascript`* list/load/unload skrypt:: + +---- +/javascript list|listfull [<nazwa>] + load [-q] <nazwapliku> + autoload + reload|unload [-q] [<nazwa>] + + list: lista załadowanych wtyczek +listfull: lista załadowanych wtyczek (szczegółowa) + load: ładuje wtyczkę +autoload: automatycznie ładuje wtyczki w katalogu systemowym lub użytkownika + reload: przeładuje pojedynczą wtyczkę (jeśli nie podano nazwy, wyładuje wszystkie wtyczki, następnie automatycznie załaduje wtyczki) + unload: wyładowuje jedną albo wszystkie wtyczki +nazwa_pliku: skrypt (plik) do załadowania + nazwa: nazwa skryptu (nazwa użyta do wywołania funkcji "register") + -q: tryb cichy: nie wyświetla wiadomości + +Bez argumentów ta komenda wyświetli wszystkie załadowane wtyczki. +---- + diff --git a/doc/pl/weechat_scripting.pl.asciidoc b/doc/pl/weechat_scripting.pl.asciidoc index 63ef78b2a..1e10db686 100644 --- a/doc/pl/weechat_scripting.pl.asciidoc +++ b/doc/pl/weechat_scripting.pl.asciidoc @@ -34,6 +34,7 @@ wspieranych języków skryptowych: * lua * tcl * guile (scheme) +* javascript [NOTE] Prawie wszystkie przykłady umieszczone w tym dokumencie są napisane w Pythonie, @@ -88,6 +89,10 @@ Weechat.config_new_option(config, section, "nazwa", "ciąg", "opis opcji", "", 0 ** config_new_option ** bar_new +==== Javascript + +* Funkcje są wywoływane za pomocą `weechat.xxx(arg1, arg2, ...);` + [[register_function]] === Funkcja rejestrująca @@ -168,6 +173,14 @@ weechat::print "" "Witaj ze skryptu tcl!" (weechat:print "" "Witaj ze skryptu scheme!") ---- +* javascript: + +[source,javascript] +---- +weechat.register("test_js", "FlashCode", "1.0", "GPL3", "Test script", "", ""); +weechat.print("", "Witaj ze skryptu javascript!"); +---- + [[load_script]] === Ładowanie skryptu @@ -180,17 +193,19 @@ Zaleca się używanie wtyczki "script" do ładowania skryptów, na przykład: /script load script.lua /script load script.tcl /script load script.scm +/script load script.js ---- Każdy język posiada również swoją własną komendę: ---- -/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 +/python load skrypt.py +/perl load skrypt.pl +/ruby load skrypt.rb +/lua load skrypt.lua +/tcl load skrypt.tcl +/guile load skrypt.scm +/javascript load skrypt.js ---- Możesz zrobić dowiązanie w katalogu 'język/autoload' jeśli chcesz automatycznie @@ -348,6 +363,18 @@ weechat::hook_timer 1000 0 1 timer_cb test (weechat:hook_timer 1000 0 1 "timer_cb" "test") ---- +* javascript: + +[source,javascript] +---- +function timer_cb(data, remaining_calls) { + weechat.print("", "timer! data=" + data); + return weechat.WEECHAT_RC_OK; +} + +weechat.hook_timer(1000, 0, 1, "timer_cb", "test"); +---- + [[script_api]] == API skryptów @@ -524,7 +551,8 @@ weechat.prnt(buffer, "wiadomość na kanale #weechat") ---- [NOTE] -Funkcja drukująca nazywa się `print` w Perl/Ruby/Lua/Tcl i `prnt` w Pythonie. +Funkcja drukująca nazywa się `print` w Perl/Ruby/Lua/Tcl/Guile/Javascript i +`prnt` w Pythonie. [[buffers_send_text]] ==== Wysyłanie tekstu do bufora @@ -787,7 +815,7 @@ def config_cb(data, option, value): # ... weechat.hook_config("plugins.var.python." + SCRIPT_NAME + ".*", "config_cb", "") -# dla innych języków, zmień "python" na swój język ("perl", "ruby", "lua" or "tcl") +# dla innych języków, zmień "python" na swój język (perl/ruby/lua/tcl/guile/javascript) ---- [[config_options_weechat]] diff --git a/doc/pl/weechat_user.pl.asciidoc b/doc/pl/weechat_user.pl.asciidoc index 1d6127b37..57882c9d5 100644 --- a/doc/pl/weechat_user.pl.asciidoc +++ b/doc/pl/weechat_user.pl.asciidoc @@ -146,6 +146,9 @@ WeeChat. | guile-2.0-dev | ≥ 2.0 | | Wtyczka guile (scheme) +| libv8-dev | | | + Wtyczka javascript + | asciidoc | ≥ 8.5.0 | | Tworzenie strony man i dokumentacji @@ -253,6 +256,9 @@ Lista popularnych opcji: | ENABLE_IRC | `ON`, `OFF` | ON | Kompilacja <<irc_plugin,wtyczki IRC>>. +| ENABLE_JAVASCRIPT | `ON`, `OFF` | ON | + Kompilacja <<scripts_plugins,wtyczki javascript>>. + | ENABLE_LARGEFILE | `ON`, `OFF` | ON | Wsparcie dla dużych plików. @@ -289,7 +295,7 @@ Lista popularnych opcji: | ENABLE_SCRIPTS | `ON`, `OFF` | ON | Kompilacja <<scripts_plugins,wtyczek skryptowych>> (Python, Perl, Ruby, Lua, - Tcl, Guile). + Tcl, Guile, Javascript). | ENABLE_TCL | `ON`, `OFF` | ON | Kompilacja <<scripts_plugins,wtyczki tcl>>. @@ -1792,26 +1798,27 @@ Przykłady ładowania, wyładowywania i wyświetlania załadowanych wtyczek: Domyślne wtyczki: -[width="50%",cols="^1,5",options="header"] -|=== -| Wtyczka | Opis -| alias | Definiuje aliasy dla komend -| aspell | Sprawdzanie pisowni w linii poleceń -| charset | Ustawianie kodowania dla buforów -| exec | Wykonuje zewnętrzną komendę z poziomu WeeChat -| fifo | Kolejka FIFO używana do zdalnego wysyłania poleceń dla WeeChat -| irc | Protokół IRC -| logger | Logowanie zawartości buforów do plików -| relay | Przekazuje dane przez sieć -| script | Zarządzanie skryptami -| python | Wsparcie dla skryptów napisanych w Pythonie -| perl | Wsparcie dla skryptów napisanych w Perlu -| ruby | Wsparcie dla skryptów napisanych w Ruby -| lua | Wsparcie dla skryptów napisanych w Lua -| tcl | Wsparcie dla skryptów napisanych w Tcl -| guile | Wsparcie dla skryptów napisanych w Guile (scheme) -| trigger | Zamiana tekstu i wykonywanie komend dla zdarzeń wywołanych przez WeeChat/wtyczki -| xfer | Przesyłanie plików i bezpośredni chat +[width="100%",cols="^1,5",options="header"] +|=== +| Wtyczka | Opis +| alias | Definiuje aliasy dla komend +| aspell | Sprawdzanie pisowni w linii poleceń +| charset | Ustawianie kodowania dla buforów +| exec | Wykonuje zewnętrzną komendę z poziomu WeeChat +| fifo | Kolejka FIFO używana do zdalnego wysyłania poleceń dla WeeChat +| irc | Protokół IRC +| logger | Logowanie zawartości buforów do plików +| relay | Przekazuje dane przez sieć +| script | Zarządzanie skryptami +| python | Wsparcie dla skryptów napisanych w Pythonie +| perl | Wsparcie dla skryptów napisanych w Perlu +| ruby | Wsparcie dla skryptów napisanych w Ruby +| lua | Wsparcie dla skryptów napisanych w Lua +| tcl | Wsparcie dla skryptów napisanych w Tcl +| guile | Wsparcie dla skryptów napisanych w Guile (scheme) +| javascript | Wsparcie dla skryptów napisanych w Javascript +| trigger | Zamiana tekstu i wykonywanie komend dla zdarzeń wywołanych przez WeeChat/wtyczki +| xfer | Przesyłanie plików i bezpośredni chat |=== Więcej informacji o wtyczkach i tworzeniu skryptów (przez API), można znaleźć w @@ -2891,8 +2898,8 @@ Adres URL musi się zawsze kończyć "/weechat" (dla protokołów 'irc' i 'weech [[scripts_plugins]] === Wtyczki skryptowe -WeeChat posiada 6 wtyczek skryptowych: Python, Perl, Ruby, Lua, Tcl i Guile -(scheme). +WeeChat posiada 7 wtyczek skryptowych: Python, Perl, Ruby, Lua, Tcl, Guile +(scheme) i Javascript. Wtyczki te potrafią ładować, wykonywać i wyładowywać skrypty w tych językach. Inna wtyczka nazwana "script" jest managerem skryptów i jest używana do @@ -2955,6 +2962,11 @@ include::autogen/user/tcl_commands.asciidoc[] include::autogen/user/guile_commands.asciidoc[] +[[javascript_commands]] +==== Komendy wtyczki javascript + +include::autogen/user/javascript_commands.asciidoc[] + [[trigger_plugin]] === Wtyczka trigger |