summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--NEWS6
-rw-r--r--doc/de/autogen/plugin_api/hdata.txt2
-rw-r--r--doc/de/autogen/user/weechat_commands.txt125
-rw-r--r--doc/de/weechat_user.de.txt213
-rw-r--r--doc/en/autogen/plugin_api/hdata.txt2
-rw-r--r--doc/en/autogen/user/weechat_commands.txt61
-rw-r--r--doc/en/weechat_dev.en.txt1
-rw-r--r--doc/en/weechat_plugin_api.en.txt53
-rw-r--r--doc/en/weechat_user.en.txt212
-rw-r--r--doc/fr/autogen/plugin_api/hdata.txt2
-rw-r--r--doc/fr/autogen/user/weechat_commands.txt59
-rw-r--r--doc/fr/weechat_plugin_api.fr.txt55
-rw-r--r--doc/fr/weechat_user.fr.txt223
-rw-r--r--doc/it/autogen/plugin_api/hdata.txt2
-rw-r--r--doc/it/autogen/user/weechat_commands.txt137
-rw-r--r--doc/it/weechat_plugin_api.it.txt56
-rw-r--r--doc/it/weechat_user.it.txt213
-rw-r--r--doc/ja/autogen/plugin_api/hdata.txt2
-rw-r--r--doc/ja/autogen/user/weechat_commands.txt123
-rw-r--r--po/POTFILES.in2
-rw-r--r--po/cs.po101
-rw-r--r--po/de.po114
-rw-r--r--po/es.po115
-rw-r--r--po/fr.po190
-rw-r--r--po/hu.po100
-rw-r--r--po/it.po115
-rw-r--r--po/ja.po114
-rw-r--r--po/pl.po114
-rw-r--r--po/pt_BR.po114
-rw-r--r--po/ru.po100
-rw-r--r--po/srcfiles.cmake2
-rw-r--r--po/weechat.pot100
-rw-r--r--src/core/CMakeLists.txt1
-rw-r--r--src/core/Makefile.am2
-rw-r--r--src/core/wee-command.c142
-rw-r--r--src/core/wee-config.c20
-rw-r--r--src/core/wee-eval.c717
-rw-r--r--src/core/wee-eval.h55
-rw-r--r--src/core/wee-string.c34
-rw-r--r--src/core/wee-string.h7
-rw-r--r--src/gui/gui-bar-item.c49
-rw-r--r--src/gui/gui-bar-item.h7
-rw-r--r--src/gui/gui-bar.c136
-rw-r--r--src/gui/gui-bar.h4
-rw-r--r--src/gui/gui-key.c30
-rw-r--r--src/plugins/guile/weechat-guile-api.c59
-rw-r--r--src/plugins/guile/weechat-guile.c38
-rw-r--r--src/plugins/guile/weechat-guile.h4
-rw-r--r--src/plugins/lua/weechat-lua-api.c57
-rw-r--r--src/plugins/lua/weechat-lua.c32
-rw-r--r--src/plugins/lua/weechat-lua.h4
-rw-r--r--src/plugins/perl/weechat-perl-api.c55
-rw-r--r--src/plugins/perl/weechat-perl.c25
-rw-r--r--src/plugins/perl/weechat-perl.h5
-rw-r--r--src/plugins/plugin-script.c2
-rw-r--r--src/plugins/plugin.c2
-rw-r--r--src/plugins/python/weechat-python-api.c58
-rw-r--r--src/plugins/python/weechat-python.c28
-rw-r--r--src/plugins/python/weechat-python.h4
-rw-r--r--src/plugins/ruby/weechat-ruby-api.c62
-rw-r--r--src/plugins/ruby/weechat-ruby.c31
-rw-r--r--src/plugins/ruby/weechat-ruby.h4
-rw-r--r--src/plugins/tcl/weechat-tcl-api.c60
-rw-r--r--src/plugins/tcl/weechat-tcl.c32
-rw-r--r--src/plugins/tcl/weechat-tcl.h4
-rw-r--r--src/plugins/weechat-plugin.h9
67 files changed, 4145 insertions, 466 deletions
diff --git a/ChangeLog b/ChangeLog
index 36777db2e..78ff73987 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,12 +1,13 @@
WeeChat ChangeLog
=================
Sébastien Helleu <flashcode@flashtux.org>
-v0.4.0-dev, 2012-10-20
+v0.4.0-dev, 2012-11-02
Version 0.4.0 (under dev!)
--------------------------
+* core: add command /eval, use expression in conditions for bars
* core: add option "-quit" for command /upgrade (save session and quit without
restarting WeeChat, for delayed restoration)
* core: fix display of zoomed/merged buffer (with number >= 2) after switching
@@ -15,6 +16,7 @@ Version 0.4.0 (under dev!)
(problem with nick displayed in first line of screen) (bug #37556)
* core: fix wrapping of words with wide chars (the break was made before the
correct position)
+* api: add new function "string_eval_expression"
* api: connect with IPv6 by default in hook_connect (with fallback to IPv4),
shuffle list of hosts for a same address, add argument "retry" for
hook_connect, move "sock" from hook_connect arguments to callback of
diff --git a/NEWS b/NEWS
index 15d704b12..e9cf3719a 100644
--- a/NEWS
+++ b/NEWS
@@ -1,7 +1,7 @@
WeeChat Release Notes
=====================
Sébastien Helleu <flashcode@flashtux.org>
-v0.4.0-dev, 2012-10-16
+v0.4.0-dev, 2012-11-02
Version 0.4.0 (under dev!)
@@ -9,6 +9,10 @@ Version 0.4.0 (under dev!)
Important release notes:
+* conditions in bars have changed, and now an expression is evaluated.
+ If you have a value with many conditions in a bar, like: `nicklist,active`,
+ you must now use an expression like: `${nicklist} && ${active}` (see
+ the chapter about bars in the 'WeeChat User's guide').
* IPv6 is now used by default to connect to IRC servers, with fallback to IPv4.
The option irc.server_default.ipv6 is now "on" by default. If IPv6 is not
enabled or fails, IPv4 will be used. The "ipv6" option in server is now used
diff --git a/doc/de/autogen/plugin_api/hdata.txt b/doc/de/autogen/plugin_api/hdata.txt
index f5302dd5b..f6a441e0d 100644
--- a/doc/de/autogen/plugin_api/hdata.txt
+++ b/doc/de/autogen/plugin_api/hdata.txt
@@ -325,8 +325,6 @@
| weechat | bar | Bar |
'name' (string) +
'options' (pointer) +
- 'conditions_count' (integer) +
- 'conditions_array' (string, array_size: "conditions_count") +
'items_count' (integer) +
'items_subcount' (pointer) +
'items_array' (pointer) +
diff --git a/doc/de/autogen/user/weechat_commands.txt b/doc/de/autogen/user/weechat_commands.txt
index 9e4780cfc..f1dffb0ec 100644
--- a/doc/de/autogen/user/weechat_commands.txt
+++ b/doc/de/autogen/user/weechat_commands.txt
@@ -11,49 +11,50 @@ message: Abwesenheitsnachricht (ohne eine Nachricht wird der Abwesenheitszustand
[command]*`bar`* Infobars verwalten::
........................................
/bar list|listfull|listitems
- add <name> <type>[,<cond1>[,<cond2>...]] <position> <size> <separator> <item1>[,<item2>...]
+ add <name> <type>[,<condition>] <position> <size> <separator> <item1>[,<item2>...]
default [input|title|status|nicklist]
del <name>|-all
set <name> <option> <value>
hide|show|toggle <name>
scroll <name> <window> <scroll_value>
- list: listet alle Infobars auf
- listfull: listet alle Infobars detailliert auf (Standardaufruf)
- listitems: listet alle Items auf, die in den Infobars genutzt werden
- add: füge eine neue Infobar hinzu
- name: Name der Infobar (muss einmalig sein)
- type: root: außerhalb des Fensters,
- window: innerhalb des Fensters, mit optionalen Merkmalen (siehe unten)
- cond1,...: Merkmal(e) für eine Infobar (nur nutzbar mit der Type-Option "window"):
- active: in einem aktiven Fenster
- inactive: in einem inaktiven Fenster
- nicklist: in Fenstern mit einer Nickliste
- werden keine Merkmale angegeben, ist die Infobar immer sichtbar
- position: bottom (unten), top (oben), left (links) oder right (rechts)
- size: Größe der Infobar (in Zeichen)
- separator: 1 um eine Trennlinien zu zeichnen, bei 0 oder ohne eine Angabe wird keine Trennlinien gezeichnet
- item1,...: Items die in der Infobar genutzt werden sollen (Items können durch Kommata oder Leerzeichen getrennt werden ("+" (verbindet Items))
- default: erstellt standardisierte Infobars
- del: entfernt eine Infobar (alle Infobars können mit der Option "-all" entfernt werden).
- set: setzt einen Wert für Infobar
- option: Option die verändert werden soll (für eine Liste aller möglichen Optionen, bitte folgenden Befehl nutzen: /set weechat.bar.<barname>.*)
- value: neuer Wert für Option
- hide: Infobar wird ausgeblendet
- show: zeigt eine ausgeblendete Infobar an
- toggle: zeigt/versteckt eine Infobar
- scroll: scrollt Infobar hoch/runter
- window: Nummer des Fensters (nutze '*' für aktuelles Fenster oder für die Root-Bars)
- scroll_value: Werte für Scroll-Funktion: 'x' oder 'y', gefolgt von '+', '-', 'b' (Beginn) oder 'e' (Ende), Wert (für +/-), und optional % (zum scrollen der Breite/Höhe in %, ansonsten wird dieser Wert als Anzahl der Zeichen interpretiert um die gescrollt werden soll)
-
-Beispiele:
- erstellt eine Infobar mit den Items: time, buffer number + name, und Vervollständigung:
+ list: list all bars
+ listfull: list all bars (verbose)
+ listitems: list all bar items
+ add: add a new bar
+ name: name of bar (must be unique)
+ type: root: outside windows,
+ window: inside windows, with optional conditions (see below)
+ condition: condition(s) for displaying bar (only for type "window"):
+ active: on active window
+ inactive: on inactive windows
+ nicklist: on windows with nicklist
+ other condition: see /help weechat.bar.xxx.conditions and /help eval
+ without condition, the bar is always displayed
+ position: bottom, top, left or right
+ size: size of bar (in chars)
+ separator: 1 for using separator (line), 0 or nothing means no separator
+ item1,...: items for this bar (items can be separated by comma (space between items) or "+" (glued items))
+ default: create a default bar (all default bars if no bar name is given)
+ del: delete a bar (or all bars with -all)
+ set: set a value for a bar property
+ option: option to change (for options list, look at /set weechat.bar.<barname>.*)
+ value: new value for option
+ hide: hide a bar
+ show: show an hidden bar
+ toggle: hide/show a bar
+ scroll: scroll bar
+ window: window number (use '*' for current window or for root bars)
+ scroll_value: value for scroll: 'x' or 'y' (optional), followed by '+', '-', 'b' (beginning) or 'e' (end), value (for +/-), and optional % (to scroll by % of width/height, otherwise value is number of chars)
+
+Examples:
+ create a bar with time, buffer number + name, and completion:
/bar add mybar root bottom 1 0 [time],buffer_number+:+buffer_name,completion
- versteckt die Infobar (meinebar):
- /bar hide meinebar
- scrollt die Nickliste im aktuellen Buffer um 10 Zeilen nach unten:
+ hide a bar:
+ /bar hide mybar
+ scroll nicklist 10 lines down on current buffer:
/bar scroll nicklist * y+10
- scrollt zum Ende der Nicklist im aktuellen Buffer:
+ scroll to end of nicklist on current buffer:
/bar scroll nicklist * ye
........................................
@@ -199,6 +200,60 @@ infolists: zeigt Information über die Infolists an
windows: zeigt die Fensterstruktur an
........................................
+[[command_weechat_eval]]
+[command]*`eval`* evaluate expression and send result to buffer::
+........................................
+/eval [-n] <expression>
+ [-n] <expression1> <operator> <expression2>
+
+ -n: display result without sending it to buffer (debug mode)
+expression: expression to evaluate, variables with format ${variable} are replaced (see below)
+ operator: a logical or comparison operator:
+ - logical operators:
+ && boolean "and"
+ || boolean "or"
+ - comparison operators:
+ == equal
+ != not equal
+ <= less or equal
+ < less
+ >= greater or equal
+ > greater
+ =~ is matching regex
+ !~ is NOT matching regex
+
+An expression is considered as "true" if it is not NULL, not empty, and different from "0".
+The comparison is made using integers if the two expressions are valid integers.
+To force a string comparison, add double quotes around each expression, for example:
+ 50 > 100 ==> 0
+ "50" > "100" ==> 1
+
+Some variables are replaced in expression, using the format ${variable}, variable can be, by order of prioity :
+ 1. the name of an option (file.section.option)
+ 2. a hdata name/variable (the value is automatically converted to string), by default "window" and "buffer" point to current window/buffer.
+Format for hdata can be one of following:
+ hdata.var1.var2...: start with a hdata (pointer must be known), and ask variables one after one (other hdata can be followed)
+ hdata(list).var1.var2...: start with a hdata using a list, for example:
+ ${buffer[gui_buffers].full_name}: full name of first buffer in linked list of buffers
+ ${plugin[weechat_plugins].name}: name of first plugin in linked list of plugins
+For name of hdata and variables, please look at "Plugin API reference", function "weechat_hdata_get".
+
+Examples:
+ /eval -n ${weechat.look.scroll_amount} ==> 3
+ /eval -n ${window} ==> 0x2549aa0
+ /eval -n ${window.buffer} ==> 0x2549320
+ /eval -n ${window.buffer.full_name} ==> core.weechat
+ /eval -n ${window.buffer.number} ==> 1
+ /eval -n ${window.buffer.number} > 2 ==> 0
+ /eval -n ${window.win_width} > 100 ==> 1
+ /eval -n (8 > 12) || (5 > 2) ==> 1
+ /eval -n (8 > 12) && (5 > 2) ==> 0
+ /eval -n abcd =~ ^ABC ==> 1
+ /eval -n abcd =~ (?-i)^ABC ==> 0
+ /eval -n abcd =~ (?-i)^abc ==> 1
+ /eval -n abcd !~ abc ==> 0
+........................................
+
[[command_weechat_filter]]
[command]*`filter`* Filterfunktion um Nachrichten in Buffern aus- oder einzublenden, dazu können Schlagwörter oder reguläre Ausdrücke verwendet werden::
........................................
diff --git a/doc/de/weechat_user.de.txt b/doc/de/weechat_user.de.txt
index e8c12c538..c857ca784 100644
--- a/doc/de/weechat_user.de.txt
+++ b/doc/de/weechat_user.de.txt
@@ -555,6 +555,219 @@ Beispiele für eine vertikale und horizontale Fensteraufteilung:
(Buffer #3)
........................................
+// TRANSLATION MISSING
+[[bars]]
+Bars
+~~~~
+
+A 'bar' is an area beside the chat that can contain any type of text.
+
+The bar options can be set with options `weechat.bar.name.option` where `name`
+is the name of the bar and `option` the option for this bar.
+
+List of bar options:
+
+[width="100%",cols="2m,2,10",options="header"]
+|========================================
+| Option | Values | Description
+
+| type | `root`, `window` |
+ A bar with type `root` is displayed exactly one time on screen, outside all
+ windows. There is no root bar by default, but an example is the bar 'buffers'
+ created by script 'buffers.pl' (sidebar with list of buffers). +
+ A bar with type `window` is displayed in each window, for example if you
+ split one time the screen (with `/window splith` or `/window splitv`), you
+ will have one bar in each window. The four default bars ('title', 'status',
+ 'input', 'nicklist') have type `window`.
+
+| position | `top`, `bottom`, `left`, `right` |
+ Position of the bar: above/below chat, on the left/right.
+
+| priority | integer ≥ 0 |
+ Priority for display of bar: this is used for ordering the bars on screen when
+ many bars have same type and position. +
+ The bars are displayed from the edge of the screen to the center. A higher
+ priority will display bar at the beginning, so closer to the edge. +
+ Example: 'input' bar has priority 1000, so it is displayed before the 'status'
+ bar, which has priority 500.
+
+| size | integer ≥ 0 |
+ The size of the bar: number of columns for position left/right, number
+ of lines for position top/tobbom. A size of `0` means automatic, so the size
+ will be computed according to content displayed in bar.
+
+| size_max | integer ≥ 0 |
+ The maximum size for a bar, `0` = no limit (this option is used only if
+ `size` = `0`).
+
+| color_bg | color |
+ The default background color for the bar.
+
+| color_fg | color |
+ The default text color for the bar.
+
+| color_delim | color |
+ The color for delimiters in bar.
+
+| hidden | `on`, `off` |
+ When option is `on`, the bar is hidden. +
+ Note: instead of changing this option, the command `/bar` is preferred, for
+ example: `/bar toggle nicklist` (see command <<command_weechat_bar,/bar>>).
+
+| separator | `on`, `off` |
+ When option is `on`, a separator (line) is displayed between this bar and
+ other bars (or chat).
+
+| items | string |
+ A list of 'items' (see <<bar_items,items>> for more info).
+
+| filling_left_right | `horizontal`, `vertical`, `columns_horizontal`, `columns_vertical` |
+ Type of filling for a bar which has position `left` or `right` (see
+ <<bar_filling,filling>> for more info).
+
+| filling_top_bottom | `horizontal`, `vertical`, `columns_horizontal`, `columns_vertical` |
+ Type of filling for a bar which has position `top` or `bottom` (see
+ <<bar_filling,filling>> for more info).
+
+| conditions | string |
+ The conditions to display the bar (see <<bar_conditions,conditions>> for more
+ info).
+|========================================
+
+[[bar_items]]
+Items
+^^^^^
+
+The option 'items' is a string with a list of bar items, separated by a comma
+(space between items on screen) or "+" (glued items).
+
+The list of bar items is displayed with command `/bar listitems`.
+
+Example of bar with items "[time],buffer_number+:+buffer_plugin+.+buffer_name":
+
+........................................
+┌─────────────────────────────────────────────────────────────────────────────────────────┐
+│[12:55] 3:irc/freenode.#weechat │
+└─────────────────────────────────────────────────────────────────────────────────────────┘
+........................................
+
+[[bar_filling]]
+Filling
+^^^^^^^
+
+There are four types of filling:
+
+* `horizontal`: the items are displayed horizontally, from left to right. If
+ there are new lines in items, a space is used to separate lines.
+* `vertical`: the items are displayed from top to bottom. If there are new
+ lines in items, a new line is used to separate lines.
+* `columns_horizontal`: items are displayed using columns, where text is
+ aligned on the left. The first item is on top left, the second is on same
+ line, on the right.
+* `columns_vertical`: items are displayed using columns, where text is aligned
+ on the left. The first item is on top left, the second is one line below.
+
+Default bars 'title', 'status' and 'input' have 'horizontal' filling, and
+default bar 'nicklist' has 'vertical' filling.
+
+Some examples of filling for bar 'nicklist':
+
+........................................
+┌──────────────────────────────────────────────────┐
+│Welcome to #test, this is a test channel │
+│12:54:15 peter | hey! │@carl │
+│12:55:01 +Max | hello │@jessika│
+│ │@maddy │
+│ │%Diego │
+│ │%Melody │
+│ │+Max │
+│ │ celia │
+│ │ Eva │
+│ │ freddy │
+│ │ Harold^│
+│ │ henry4 │
+│ │ jimmy17│
+│ │ jodie ▼│
+│[12:55] [6] [irc/freenode] 3:#test(+n){24} │
+└──────────────────────────────────────────────────┘
+ filling_left_right = vertical ▲
+
+┌──────────────────────────────────────────────────┐
+│Welcome to #test, this is a test channel │
+│12:54:15 peter | hey! │@carl lee │
+│12:55:01 +Max | hello │@jessika louise │
+│ │@maddy mario │
+│ │%Diego mark │
+│ │%Melody peter │
+│ │+Max Rachel │
+│ │ celia richard│
+│ │ Eva sheryl │
+│ │ freddy Vince │
+│ │ Harold^ warren │
+│ │ henry4 zack │
+│ │ jimmy17 │
+│ │ jodie │
+│[12:55] [6] [irc/freenode] 3:#test(+n){24} │
+└──────────────────────────────────────────────────┘
+ filling_left_right = columns_vertical ▲
+
+┌───────────────────────────────────────────────────────────────────────┐
+│@carl %Diego celia Harold^ jodie mario Rachel Vince │
+│@jessika %Melody Eva henry4 lee mark richard warren │
+│@maddy +Max freddy jimmy17 louise peter sheryl zack │
+│───────────────────────────────────────────────────────────────────────│
+│ │
+ filling_top_bottom = columns_vertical ▲
+
+┌───────────────────────────────────────────────────────────────────────┐
+│@carl @jessika @maddy %Diego %Melody +Max celia Eva │
+│ freddy Harold^ henry4 jimmy17 jodie lee louise mario │
+│ mark peter Rachel richard sheryl Vince warren zack │
+│───────────────────────────────────────────────────────────────────────│
+│ │
+ filling_top_bottom = columns_horizontal ▲
+........................................
+
+[[bar_conditions]]
+Conditions
+^^^^^^^^^^
+
+The option 'conditions' is a string evaluated to know if the bar is displayed
+or not in the window (it is used only for bars with type 'window').
+
+The string can be:
+
+* 'active': the window must be active
+* 'inactive': the window must be inactive
+* 'nicklist': the buffer displayed in window must have a nicklist
+* an expression: it is evaluated as boolean (see command
+ <<command_weechat_eval,/eval>>)
+
+For the expression, following variables are available:
+
+* `${active}`: true if window is active
+* `${inactive}`: true if window is inactive
+* `$[nicklist}`: true if buffer displayed in window has a nicklist
+
+Following pointers are available:
+
+* `${window}`: the window where condition is evaluated
+* `${buffer}`: the buffer of window where condition is evaluated
+
+Exemple to display nicklist bar in all buffers with a nicklist, and only if
+width of window is > 100 :
+
+----------------------------------------
+/set weechat.bar.nicklist.conditions "${nicklist} && ${window.win_width} > 100"
+----------------------------------------
+
+Same condition, but always display nicklist on buffer '&bitlbee' (even if window
+is small):
+
+----------------------------------------
+/set weechat.bar.nicklist.conditions "${nicklist} && (${window.win_width} > 100 || ${buffer.full_name} == irc.bitlbee.&bitlbee)"
+----------------------------------------
+
[[notify_levels]]
Benachrichtigungsstufen
~~~~~~~~~~~~~~~~~~~~~~~
diff --git a/doc/en/autogen/plugin_api/hdata.txt b/doc/en/autogen/plugin_api/hdata.txt
index aa379c246..464880912 100644
--- a/doc/en/autogen/plugin_api/hdata.txt
+++ b/doc/en/autogen/plugin_api/hdata.txt
@@ -325,8 +325,6 @@
| weechat | bar | bar |
'name' (string) +
'options' (pointer) +
- 'conditions_count' (integer) +
- 'conditions_array' (string, array_size: "conditions_count") +
'items_count' (integer) +
'items_subcount' (pointer) +
'items_array' (pointer) +
diff --git a/doc/en/autogen/user/weechat_commands.txt b/doc/en/autogen/user/weechat_commands.txt
index 17eeb9b6f..7438d2805 100644
--- a/doc/en/autogen/user/weechat_commands.txt
+++ b/doc/en/autogen/user/weechat_commands.txt
@@ -11,7 +11,7 @@ message: message for away (if no message is given, away status is removed)
[command]*`bar`* manage bars::
........................................
/bar list|listfull|listitems
- add <name> <type>[,<cond1>[,<cond2>...]] <position> <size> <separator> <item1>[,<item2>...]
+ add <name> <type>[,<condition>] <position> <size> <separator> <item1>[,<item2>...]
default [input|title|status|nicklist]
del <name>|-all
set <name> <option> <value>
@@ -25,11 +25,12 @@ message: message for away (if no message is given, away status is removed)
name: name of bar (must be unique)
type: root: outside windows,
window: inside windows, with optional conditions (see below)
- cond1,...: condition(s) for displaying bar (only for type "window"):
+ condition: condition(s) for displaying bar (only for type "window"):
active: on active window
inactive: on inactive windows
nicklist: on windows with nicklist
- without condition, bar is always displayed
+ other condition: see /help weechat.bar.xxx.conditions and /help eval
+ without condition, the bar is always displayed
position: bottom, top, left or right
size: size of bar (in chars)
separator: 1 for using separator (line), 0 or nothing means no separator
@@ -199,6 +200,60 @@ infolists: display infos about infolists
windows: display windows tree
........................................
+[[command_weechat_eval]]
+[command]*`eval`* evaluate expression and send result to buffer::
+........................................
+/eval [-n] <expression>
+ [-n] <expression1> <operator> <expression2>
+
+ -n: display result without sending it to buffer (debug mode)
+expression: expression to evaluate, variables with format ${variable} are replaced (see below)
+ operator: a logical or comparison operator:
+ - logical operators:
+ && boolean "and"
+ || boolean "or"
+ - comparison operators:
+ == equal
+ != not equal
+ <= less or equal
+ < less
+ >= greater or equal
+ > greater
+ =~ is matching regex
+ !~ is NOT matching regex
+
+An expression is considered as "true" if it is not NULL, not empty, and different from "0".
+The comparison is made using integers if the two expressions are valid integers.
+To force a string comparison, add double quotes around each expression, for example:
+ 50 > 100 ==> 0
+ "50" > "100" ==> 1
+
+Some variables are replaced in expression, using the format ${variable}, variable can be, by order of prioity :
+ 1. the name of an option (file.section.option)
+ 2. a hdata name/variable (the value is automatically converted to string), by default "window" and "buffer" point to current window/buffer.
+Format for hdata can be one of following:
+ hdata.var1.var2...: start with a hdata (pointer must be known), and ask variables one after one (other hdata can be followed)
+ hdata(list).var1.var2...: start with a hdata using a list, for example:
+ ${buffer[gui_buffers].full_name}: full name of first buffer in linked list of buffers
+ ${plugin[weechat_plugins].name}: name of first plugin in linked list of plugins
+For name of hdata and variables, please look at "Plugin API reference", function "weechat_hdata_get".
+
+Examples:
+ /eval -n ${weechat.look.scroll_amount} ==> 3
+ /eval -n ${window} ==> 0x2549aa0
+ /eval -n ${window.buffer} ==> 0x2549320
+ /eval -n ${window.buffer.full_name} ==> core.weechat
+ /eval -n ${window.buffer.number} ==> 1
+ /eval -n ${window.buffer.number} > 2 ==> 0
+ /eval -n ${window.win_width} > 100 ==> 1
+ /eval -n (8 > 12) || (5 > 2) ==> 1
+ /eval -n (8 > 12) && (5 > 2) ==> 0
+ /eval -n abcd =~ ^ABC ==> 1
+ /eval -n abcd =~ (?-i)^ABC ==> 0
+ /eval -n abcd =~ (?-i)^abc ==> 1
+ /eval -n abcd !~ abc ==> 0
+........................................
+
[[command_weechat_filter]]
[command]*`filter`* filter messages in buffers, to hide/show them according to tags or regex::
........................................
diff --git a/doc/en/weechat_dev.en.txt b/doc/en/weechat_dev.en.txt
index d706e23c0..32efb14e9 100644
--- a/doc/en/weechat_dev.en.txt
+++ b/doc/en/weechat_dev.en.txt
@@ -99,6 +99,7 @@ WeeChat "core" reside in following directories:
| wee-config-file.c | Configuration file management
| wee-config.c | Configuration options for WeeChat core (options weechat.*)
| wee-debug.c | Some debug functions
+| wee-eval.c | Evaluate expressions with references to internal vars
| wee-hashtable.c | Hashtables
| wee-hdata.c | Hdata (direct access to data using hashtables)
| wee-hook.c | Hooks
diff --git a/doc/en/weechat_plugin_api.en.txt b/doc/en/weechat_plugin_api.en.txt
index b4784dfa8..5b4b913f7 100644
--- a/doc/en/weechat_plugin_api.en.txt
+++ b/doc/en/weechat_plugin_api.en.txt
@@ -1654,6 +1654,59 @@ str2 = weechat.string_input_for_buffer("/test") # ""
str3 = weechat.string_input_for_buffer("//test") # "/test"
----------------------------------------
+weechat_string_eval_expression
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+_New in version 0.4.0._
+
+Evaluate an expression and return result as a string.
+Special variables with format `${variable}` are expanded (see command `/eval` in
+'WeeChat User's guide').
+
+Prototype:
+
+[source,C]
+----------------------------------------
+char *weechat_string_eval_expression (const char *expr,
+ struct t_hashtable *pointers,
+ struct t_hashtable *extra_vars);
+----------------------------------------
+
+Arguments:
+
+* 'expr': the expression to evaluate
+* 'pointers': hashtable with pointers (keys must be string, values must be
+ pointer); pointers "window" and "buffer" are automatically added if they are
+ not in hashtable (with pointer to current window/buffer) (can be NULL)
+* 'extra_vars': extra variables that will be expanded (can be NULL)
+
+Return value:
+
+* evaluated expression (must be freed by calling "free" after use), or NULL
+ if problem (invalid expression or not enough memory)
+
+C examples:
+
+[source,C]
+----------------------------------------
+char *str1 = weechat_string_eval_expression ("${buffer.full_name}", NULL, NULL); /* "core.weechat" */
+char *str2 = weechat_string_eval_expression ("${window.win_width} > 100", NULL, NULL); /* "1" */
+char *str3 = weechat_string_eval_expression ("abc =~ def", NULL, NULL); /* "0" */
+----------------------------------------
+
+Script (Python):
+
+[source,python]
+----------------------------------------
+# prototype
+str = weechat.string_eval_expression(expr, pointers, extra_vars)
+
+# examples
+str1 = weechat.string_input_for_buffer("${buffer.full_name}", {}, {}) # "core.weechat"
+str2 = weechat.string_input_for_buffer("${window.win_width} > 100", {}, {}) # "1"
+str3 = weechat.string_input_for_buffer("abc =~ def", {}, {}) # "0"
+----------------------------------------
+
[[utf-8]]
UTF-8
~~~~~
diff --git a/doc/en/weechat_user.en.txt b/doc/en/weechat_user.en.txt
index 5f021b90f..0d2514bd4 100644
--- a/doc/en/weechat_user.en.txt
+++ b/doc/en/weechat_user.en.txt
@@ -554,6 +554,218 @@ Example of vertical + horizontal splits:
(buffer #3)
........................................
+[[bars]]
+Bars
+~~~~
+
+A 'bar' is an area beside the chat that can contain any type of text.
+
+The bar options can be set with options `weechat.bar.name.option` where `name`
+is the name of the bar and `option` the option for this bar.
+
+List of bar options:
+
+[width="100%",cols="2m,2,10",options="header"]
+|========================================
+| Option | Values | Description
+
+| type | `root`, `window` |
+ A bar with type `root` is displayed exactly one time on screen, outside all
+ windows. There is no root bar by default, but an example is the bar 'buffers'
+ created by script 'buffers.pl' (sidebar with list of buffers). +
+ A bar with type `window` is displayed in each window, for example if you
+ split one time the screen (with `/window splith` or `/window splitv`), you
+ will have one bar in each window. The four default bars ('title', 'status',
+ 'input', 'nicklist') have type `window`.
+
+| position | `top`, `bottom`, `left`, `right` |
+ Position of the bar: above/below chat, on the left/right.
+
+| priority | integer ≥ 0 |
+ Priority for display of bar: this is used for ordering the bars on screen when
+ many bars have same type and position. +
+ The bars are displayed from the edge of the screen to the center. A higher
+ priority will display bar at the beginning, so closer to the edge. +
+ Example: 'input' bar has priority 1000, so it is displayed before the 'status'
+ bar, which has priority 500.
+
+| size | integer ≥ 0 |
+ The size of the bar: number of columns for position left/right, number
+ of lines for position top/tobbom. A size of `0` means automatic, so the size
+ will be computed according to content displayed in bar.
+
+| size_max | integer ≥ 0 |
+ The maximum size for a bar, `0` = no limit (this option is used only if
+ `size` = `0`).
+
+| color_bg | color |
+ The default background color for the bar.
+
+| color_fg | color |
+ The default text color for the bar.
+
+| color_delim | color |
+ The color for delimiters in bar.
+
+| hidden | `on`, `off` |
+ When option is `on`, the bar is hidden. +
+ Note: instead of changing this option, the command `/bar` is preferred, for
+ example: `/bar toggle nicklist` (see command <<command_weechat_bar,/bar>>).
+
+| separator | `on`, `off` |
+ When option is `on`, a separator (line) is displayed between this bar and
+ other bars (or chat).
+
+| items | string |
+ A list of 'items' (see <<bar_items,items>> for more info).
+
+| filling_left_right | `horizontal`, `vertical`, `columns_horizontal`, `columns_vertical` |
+ Type of filling for a bar which has position `left` or `right` (see
+ <<bar_filling,filling>> for more info).
+
+| filling_top_bottom | `horizontal`, `vertical`, `columns_horizontal`, `columns_vertical` |
+ Type of filling for a bar which has position `top` or `bottom` (see
+ <<bar_filling,filling>> for more info).
+
+| conditions | string |
+ The conditions to display the bar (see <<bar_conditions,conditions>> for more
+ info).
+|========================================
+
+[[bar_items]]
+Items
+^^^^^
+
+The option 'items' is a string with a list of bar items, separated by a comma
+(space between items on screen) or "+" (glued items).
+
+The list of bar items is displayed with command `/bar listitems`.
+
+Example of bar with items "[time],buffer_number+:+buffer_plugin+.+buffer_name":
+
+........................................
+┌─────────────────────────────────────────────────────────────────────────────────────────┐
+│[12:55] 3:irc/freenode.#weechat │
+└─────────────────────────────────────────────────────────────────────────────────────────┘
+........................................
+
+[[bar_filling]]
+Filling
+^^^^^^^
+
+There are four types of filling:
+
+* `horizontal`: the items are displayed horizontally, from left to right. If
+ there are new lines in items, a space is used to separate lines.
+* `vertical`: the items are displayed from top to bottom. If there are new
+ lines in items, a new line is used to separate lines.
+* `columns_horizontal`: items are displayed using columns, where text is
+ aligned on the left. The first item is on top left, the second is on same
+ line, on the right.
+* `columns_vertical`: items are displayed using columns, where text is aligned
+ on the left. The first item is on top left, the second is one line below.
+
+Default bars 'title', 'status' and 'input' have 'horizontal' filling, and
+default bar 'nicklist' has 'vertical' filling.
+
+Some examples of filling for bar 'nicklist':
+
+........................................
+┌──────────────────────────────────────────────────┐
+│Welcome to #test, this is a test channel │
+│12:54:15 peter | hey! │@carl │
+│12:55:01 +Max | hello │@jessika│
+│ │@maddy │
+│ │%Diego │
+│ │%Melody │
+│ │+Max │
+│ │ celia │
+│ │ Eva │
+│ │ freddy │
+│ │ Harold^│
+│ │ henry4 │
+│ │ jimmy17│
+│ │ jodie ▼│
+│[12:55] [6] [irc/freenode] 3:#test(+n){24} │
+└──────────────────────────────────────────────────┘
+ filling_left_right = vertical ▲
+
+┌──────────────────────────────────────────────────┐
+│Welcome to #test, this is a test channel │
+│12:54:15 peter | hey! │@carl lee │
+│12:55:01 +Max | hello │@jessika louise │
+│ │@maddy mario │
+│ │%Diego mark │
+│ │%Melody peter │
+│ │+Max Rachel │
+│ │ celia richard│
+│ │ Eva sheryl │
+│ │ freddy Vince │
+│ │ Harold^ warren │
+│ │ henry4 zack │
+│ │ jimmy17 │
+│ │ jodie │
+│[12:55] [6] [irc/freenode] 3:#test(+n){24} │
+└──────────────────────────────────────────────────┘
+ filling_left_right = columns_vertical ▲
+
+┌───────────────────────────────────────────────────────────────────────┐
+│@carl %Diego celia Harold^ jodie mario Rachel Vince │
+│@jessika %Melody Eva henry4 lee mark richard warren │
+│@maddy +Max freddy jimmy17 louise peter sheryl zack │
+│───────────────────────────────────────────────────────────────────────│
+│ │
+ filling_top_bottom = columns_vertical ▲
+
+┌───────────────────────────────────────────────────────────────────────┐
+│@carl @jessika @maddy %Diego %Melody +Max celia Eva │
+│ freddy Harold^ henry4 jimmy17 jodie lee louise mario │
+│ mark peter Rachel richard sheryl Vince warren zack │
+│───────────────────────────────────────────────────────────────────────│
+│ │
+ filling_top_bottom = columns_horizontal ▲
+........................................
+
+[[bar_conditions]]
+Conditions
+^^^^^^^^^^
+
+The option 'conditions' is a string evaluated to know if the bar is displayed
+or not in the window (it is used only for bars with type 'window').
+
+The string can be:
+
+* 'active': the window must be active
+* 'inactive': the window must be inactive
+* 'nicklist': the buffer displayed in window must have a nicklist
+* an expression: it is evaluated as boolean (see command
+ <<command_weechat_eval,/eval>>)
+
+For the expression, following variables are available:
+
+* `${active}`: true if window is active
+* `${inactive}`: true if window is inactive
+* `$[nicklist}`: true if buffer displayed in window has a nicklist
+
+Following pointers are available:
+
+* `${window}`: the window where condition is evaluated
+* `${buffer}`: the buffer of window where condition is evaluated
+
+Exemple to display nicklist bar in all buffers with a nicklist, and only if
+width of window is > 100 :
+
+----------------------------------------
+/set weechat.bar.nicklist.conditions "${nicklist} && ${window.win_width} > 100"
+----------------------------------------
+
+Same condition, but always display nicklist on buffer '&bitlbee' (even if window
+is small):
+
+----------------------------------------
+/set weechat.bar.nicklist.conditions "${nicklist} && (${window.win_width} > 100 || ${buffer.full_name} == irc.bitlbee.&bitlbee)"
+----------------------------------------
+
[[notify_levels]]
Notify levels
~~~~~~~~~~~~~
diff --git a/doc/fr/autogen/plugin_api/hdata.txt b/doc/fr/autogen/plugin_api/hdata.txt
index 7ed0a160b..16ca00f49 100644
--- a/doc/fr/autogen/plugin_api/hdata.txt
+++ b/doc/fr/autogen/plugin_api/hdata.txt
@@ -325,8 +325,6 @@
| weechat | bar | barre |
'name' (string) +
'options' (pointer) +
- 'conditions_count' (integer) +
- 'conditions_array' (string, array_size: "conditions_count") +
'items_count' (integer) +
'items_subcount' (pointer) +
'items_array' (pointer) +
diff --git a/doc/fr/autogen/user/weechat_commands.txt b/doc/fr/autogen/user/weechat_commands.txt
index b98bc1725..9af2d263b 100644
--- a/doc/fr/autogen/user/weechat_commands.txt
+++ b/doc/fr/autogen/user/weechat_commands.txt
@@ -11,7 +11,7 @@ message: message pour l'absence (si pas de message donné, le statut d'absence e
[command]*`bar`* gestion des barres::
........................................
/bar list|listfull|listitems
- add <nom> <type>[,<cond1>[,<cond2>...]] <position> <taille> <séparateur> <objet1>[,<objet2>...]
+ add <nom> <type>[,<conditions>] <position> <taille> <séparateur> <objet1>[,<objet2>...]
default [input|title|status|nicklist]
del <nom>|-all
set <nom> <option> <valeur>
@@ -25,10 +25,11 @@ message: message pour l'absence (si pas de message donné, le statut d'absence e
nom: nom de la barre (doit être unique)
type: root: en dehors des fenêtres
window: dans les fenêtres, avec condition(s) optionnelle(s) (voir ci-dessous)
- cond1,...: condition(s) pour afficher cette barre (seulement pour le type "window"):
+ condition: condition(s) pour afficher cette barre (seulement pour le type "window"):
active: sur la fenêtre active
inactive: sur les fenêtres inactives
nicklist: sur les fenêtres avec liste de pseudos
+ autre condition: voir /help weechat.bar.xxx.conditions et /help eval
sans condition, la barre est toujours affichée
position: bottom (bas), top (haut), left (gauche) ou right (droite)
taille: taille de la barre (en caractères)
@@ -199,6 +200,60 @@ infolists: afficher des infos sur les infolists
windows: afficher l'arbre des fenêtres
........................................
+[[command_weechat_eval]]
+[command]*`eval`* évaluer une expression et envoyer le résultat au tampon::
+........................................
+/eval [-n] <expression>
+ [-n] <expression1> <opérateur> <expression2>
+
+ -n: afficher le résultat sans envoyer au tampon (mode debug)
+expression: expression à évaluer, les variables avec le format ${variable} sont remplacées (voir ci-dessous)
+ opérateur: un opérateur logique ou de comparaison :
+ - opérateurs logiques :
+ && "et" booléen
+ || "ou" booléen
+ - opérateurs de comparaison :
+ == égal
+ != non égal
+ <= inférieur ou égal
+ < inférieur
+ >= supérieur ou égal
+ > supérieur
+ =~ correspond à l'expression régulière
+ !~ ne correspond PAS à l'expression régulière
+
+Une expression est considérée comme "vraie" si elle est non NULL, non vide, et différente de "0".
+La comparaison est faite en utilisant des entiers si les deux expressions sont des entiers valides.
+Pour forcer une comparaison de chaînes, ajoutez des guillemets autour de chaque expression, par exemple :
+ 50 > 100 ==> 0
+ "50" > "100" ==> 1
+
+Des variables sont remplacées dans l'expression, en utilisant le format ${variable}, la variable pouvant être, par ordre de priorité :
+ 1. le nom d'une option (fichier.section.option)
+ 2. le nom d'un hdata/variable (la valeur est automatiquement convertie en chaîne), par défaut "window" et "buffer" pointent vers la fenêtre et le tampon courants.
+Le format du hdata peut être le suivant :
+ hdata.var1.var2...: démarrer avec un hdata (le pointeur doit être connu), et demander les variables l'une après l'autre (d'autres hdata peuvent être suivis)
+ hdata(list).var1.var2...: démarrer avec un hdata en utlisant une liste, par exemple :
+ ${buffer[gui_buffers].full_name}: nom complet du premier tampon dans la liste chaînée des tampons
+ ${plugin[weechat_plugins].name}: nom de la première extension dans la liste chaînée des extensions
+Pour le nom du hdata et des variables, voir la "Référence API extension", fonction "weechat_hdata_get".
+
+Exemples:
+ /eval -n ${weechat.look.scroll_amount} ==> 3
+ /eval -n ${window} ==> 0x2549aa0
+ /eval -n ${window.buffer} ==> 0x2549320
+ /eval -n ${window.buffer.full_name} ==> core.weechat
+ /eval -n ${window.buffer.number} ==> 1
+ /eval -n ${window.buffer.number} > 2 ==> 0
+ /eval -n ${window.win_width} > 100 ==> 1
+ /eval -n (8 > 12) || (5 > 2) ==> 1
+ /eval -n (8 > 12) && (5 > 2) ==> 0
+ /eval -n abcd =~ ^ABC ==> 1
+ /eval -n abcd =~ (?-i)^ABC ==> 0
+ /eval -n abcd =~ (?-i)^abc ==> 1
+ /eval -n abcd !~ abc ==> 0
+........................................
+
[[command_weechat_filter]]
[command]*`filter`* filtrer les messages dans les tampons, pour les cacher/afficher selon des tags ou expressions régulières::
........................................
diff --git a/doc/fr/weechat_plugin_api.fr.txt b/doc/fr/weechat_plugin_api.fr.txt
index c042dc0ae..d6348e0b4 100644
--- a/doc/fr/weechat_plugin_api.fr.txt
+++ b/doc/fr/weechat_plugin_api.fr.txt
@@ -1677,6 +1677,61 @@ str2 = weechat.string_input_for_buffer("/test") # ""
str3 = weechat.string_input_for_buffer("//test") # "/test"
----------------------------------------
+weechat_string_eval_expression
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+_Nouveau dans la version 0.4.0._
+
+Evalue l'expression et retourne le résultat sous forme de chaîne.
+Les variables spéciales avec le format `${variable}` sont étendues (voir la
+commande `/eval` dans le 'Guide utilisateur WeeChat').
+
+Prototype :
+
+[source,C]
+----------------------------------------
+char *weechat_string_eval_expression (const char *expr,
+ struct t_hashtable *pointers,
+ struct t_hashtable *extra_vars);
+----------------------------------------
+
+Paramètres :
+
+* 'expr' : l'expression à évaluer
+* 'pointers' : hashtable avec les pointeurs (les clés doivent être des chaînes,
+ les valeurs doivent être des pointeurs); les pointeurs "window" et "buffer"
+ sont automatiquement ajoutés s'ils ne sont pas dans la hashtable (avec le
+ pointer vers fenêtre/tampon courants) (peut être NULL)
+* 'extra_vars' : variables additionnelles qui seront étendues (peut être NULL)
+
+Valeur de retour :
+
+* expression évaluée (doit être libérée après un appel à "free" après
+ utilisation), ou NULL si problème (expression invalide ou pas assez de
+ mémoire)
+
+Exemples en C :
+
+[source,C]
+----------------------------------------
+char *str1 = weechat_string_eval_expression ("${buffer.full_name}", NULL, NULL); /* "core.weechat" */
+char *str2 = weechat_string_eval_expression ("${window.win_width} > 100", NULL, NULL); /* "1" */
+char *str3 = weechat_string_eval_expression ("abc =~ def", NULL, NULL); /* "0" */
+----------------------------------------
+
+Script (Python) :
+
+[source,python]
+----------------------------------------
+# prototype
+str = weechat.string_eval_expression(expr, pointers, extra_vars)
+
+# exemples
+str1 = weechat.string_input_for_buffer("${buffer.full_name}", {}, {}) # "core.weechat"
+str2 = weechat.string_input_for_buffer("${window.win_width} > 100", {}, {}) # "1"
+str3 = weechat.string_input_for_buffer("abc =~ def", {}, {}) # "0"
+----------------------------------------
+
[[utf-8]]
UTF-8
~~~~~
diff --git a/doc/fr/weechat_user.fr.txt b/doc/fr/weechat_user.fr.txt
index ba4b27ce8..7db404f4f 100644
--- a/doc/fr/weechat_user.fr.txt
+++ b/doc/fr/weechat_user.fr.txt
@@ -565,6 +565,229 @@ Exemple de découpage vertical + horizontal :
(tampon n°3)
........................................
+[[bars]]
+Barres
+~~~~~~
+
+Une 'barre' est une zone à côté de la discussion qui peut contenir tout type de
+texte.
+
+Les options de barre sont définies avec les options `weechat.bar.nom.option` où
+`nom` et le nom de la barre et `option` l'option pour cette barre.
+
+Liste des options de barre :
+
+[width="100%",cols="2m,2,10",options="header"]
+|========================================
+| Option | Valeurs | Description
+
+| type | `root`, `window` |
+ Une barre avec le type `root` est affichée exactement une fois à l'écran, en
+ dehors de toutes les fenêtres. Il n'y a pas de barre root par défaut, mais un
+ exemple est la barre 'buffers' créée par le script 'buffers.pl' (barre
+ latérale avec la liste des tampons). +
+ Une barre avec le type `window` est affichée dans chaque fenêtre, par exemple
+ si vous découpez l'écran (avec `/window splith` ou `/window splitv`), vous
+ aurez une barre dans chaque fenêtre. Les quatre barres par défaut ('title',
+ 'status', 'input', 'nicklist') sont de type `window`.
+
+| position | `top`, `bottom`, `left`, `right` |
+ Position de la barre : au dessus/en dessous de la discussion, sur la
+ gauche/droite.
+
+| priority | entier ≥ 0 |
+ Priorité de la barre : elle est utilisée pour ordonner les barres à l'écran,
+ quand plusieurs barres utilisent le même type et position. +
+ Les barres sont affichées depuis le bord de l'écran vers le centre. Une
+ priorité plus haute affichera la barre au début, donc près du bord. +
+ Exemple : la barre 'input' a une priorité de 1000, donc elle est affichée
+ avant la barre 'status', qui a une priorité de 500.
+
+| size | entier ≥ 0 |
+ La taille de la barre : nombre de colonnes pour une position left/right,
+ nombre de lignes pour une position top/bottom. Une taille de `0` signifie
+ automatique, donc la taille sera calculée en fonction du contenu affiché dans
+ la barre.
+
+| size_max | entier ≥ 0 |
+ La taille maximum pour la barre, `0` = pas de limite (cette option est
+ utilisée seulement si `size` = `0`).
+
+| color_bg | couleur |
+ La couleur par défaut du fond de la barre.
+
+| color_fg | couleur |
+ La couleur par défaut du texte dans la barre.
+
+| color_delim | couleur |
+ La couleur des délimiteurs dans la barre.
+
+| hidden | `on`, `off` |
+ Lorsque l'option est `on`, la barre est cachée. +
+ Note : plutôt que de changer cette option, il est préférable d'utiliser la
+ commande `/bar`, par exemple : `/bar toggle nicklist` (voir la commande
+ <<command_weechat_bar,/bar>>).
+
+| separator | `on`, `off` |
+ Lorsque l'option est `on`, un séparateur (ligne) est affiché entre la barre et
+ les autres barres (ou la discussion).
+
+| items | chaîne |
+ Une liste d'objets (voir <<bar_items,objets>> pour plus d'infos).
+
+| filling_left_right | `horizontal`, `vertical`, `columns_horizontal`, `columns_vertical` |
+ Type de remplissage pour la barre lorsqu'elle a une position `left` ou
+ `right` (voir <<bar_filling,remplissage>> pour plus d'infos).
+
+| filling_top_bottom | `horizontal`, `vertical`, `columns_horizontal`, `columns_vertical` |
+ Type de remplissage pour la barre lorsqu'elle a une position `top` ou `bottom`
+ (voir <<bar_filling,remplissage>> pour plus d'infos).
+
+| conditions | chaîne |
+ Les conditions pour afficher la barre (voir <<bar_conditions,conditions>> pour
+ plus d'infos).
+|========================================
+
+[[bar_items]]
+Objets
+^^^^^^
+
+L'option 'items' est une chaîne avec une liste d'objets de barre, séparés par
+une virgule (espace entre les objets à l'écran) ou un "+" (objets collés).
+
+La liste des objets de barre est affichée avec la commande `/bar listitems`.
+
+Exemple de barre avec les objets
+"[time],buffer_number+:+buffer_plugin+.+buffer_name" :
+
+........................................
+┌─────────────────────────────────────────────────────────────────────────────────────────┐
+│[12:55] 3:irc/freenode.#weechat │
+└─────────────────────────────────────────────────────────────────────────────────────────┘
+........................................
+
+[[bar_filling]]
+Remplissage
+^^^^^^^^^^^
+
+Il y a quatre types de remplissage :
+
+* `horizontal` : les objets sont affichés horizontalement, de gauche à droite.
+ S'il y a des retours à la ligne dans les objets, un espace est utilisé pour
+ séparer les lignes.
+* `vertical` : les objets sont affichés de haut en bas. S'il y a des retours à
+ la ligne dans les objets, une nouvelle ligne est utilisée pour séparer les
+ lignes.
+* `columns_horizontal` : les objets sont affichés en utilisant des colonnes, où
+ le texte est aligné à gauche. Le premier objet est en haut à gauche, le second
+ est sur la même ligne, sur la droite.
+* `columns_vertical` : les objets sont affichés en utilisant des colonnes, où
+ le texte est aligné à gauche. Le premier objet est en haut à gauche, le second
+ est sur la ligne en dessous.
+
+Les barres par défaut 'title', 'status' et 'input' ont un remplissage
+'horizontal', et la barre par défaut 'nicklist' a un remplissage 'vertical'.
+
+Quelques exemples de remplissage pour la barre 'nicklist' :
+
+........................................
+┌──────────────────────────────────────────────────┐
+│Welcome to #test, this is a test channel │
+│12:54:15 peter | hey! │@carl │
+│12:55:01 +Max | hello │@jessika│
+│ │@maddy │
+│ │%Diego │
+│ │%Melody │
+│ │+Max │
+│ │ celia │
+│ │ Eva │
+│ │ freddy │
+│ │ Harold^│
+│ │ henry4 │
+│ │ jimmy17│
+│ │ jodie ▼│
+│[12:55] [6] [irc/freenode] 3:#test(+n){24} │
+└──────────────────────────────────────────────────┘
+ filling_left_right = vertical ▲
+
+┌──────────────────────────────────────────────────┐
+│Welcome to #test, this is a test channel │
+│12:54:15 peter | hey! │@carl lee │
+│12:55:01 +Max | hello │@jessika louise │
+│ │@maddy mario │
+│ │%Diego mark │
+│ │%Melody peter │
+│ │+Max Rachel │
+│ │ celia richard│
+│ │ Eva sheryl │
+│ │ freddy Vince │
+│ │ Harold^ warren │
+│ │ henry4 zack │
+│ │ jimmy17 │
+│ │ jodie │
+│[12:55] [6] [irc/freenode] 3:#test(+n){24} │
+└──────────────────────────────────────────────────┘
+ filling_left_right = columns_vertical ▲
+
+┌───────────────────────────────────────────────────────────────────────┐
+│@carl %Diego celia Harold^ jodie mario Rachel Vince │
+│@jessika %Melody Eva henry4 lee mark richard warren │
+│@maddy +Max freddy jimmy17 louise peter sheryl zack │
+│───────────────────────────────────────────────────────────────────────│
+│ │
+ filling_top_bottom = columns_vertical ▲
+
+┌───────────────────────────────────────────────────────────────────────┐
+│@carl @jessika @maddy %Diego %Melody +Max celia Eva │
+│ freddy Harold^ henry4 jimmy17 jodie lee louise mario │
+│ mark peter Rachel richard sheryl Vince warren zack │
+│───────────────────────────────────────────────────────────────────────│
+│ │
+ filling_top_bottom = columns_horizontal ▲
+........................................
+
+[[bar_conditions]]
+Conditions
+^^^^^^^^^^
+
+L'option 'conditions' est uen chaîne évaluée pour savoir si la barre doit être
+affichée ou non dans la fenêtre (elle est utilisée seulement pour les barres
+avec type 'window').
+
+La chaîne peut être :
+
+* 'active' : la fenêtre doit être active
+* 'inactive' : la fenêtre doit être inactive
+* 'nicklist' : le tampon affiché dans la fenêtre doit avoir une liste de pseudos
+* une expression : elle est évaluée comme booléen (voir la commande
+ <<command_weechat_eval,/eval>>)
+
+Pour une expression, les variables suivantes sont disponibles :
+
+* `${active}` : vrai si la fenêtre est active
+* `${inactive}` : vrai si la fenêtre est inactive
+* `$[nicklist}` : vrai si le tampon affiché dans la fenêtre a une liste de
+ pseudos
+
+Les pointeurs suivants sont disponibles :
+
+* `${window}` : la fenêtre où la condition est évaluée
+* `${buffer}` : le tampon de la fenêtre où la condition est évaluée
+
+Exemple pour afficher la liste de pseudos dans tous les tampons possédant une
+liste de pseudos, et seulement si la largeur de fenêtre est supérieurs à 100 :
+
+----------------------------------------
+/set weechat.bar.nicklist.conditions "${nicklist} && ${window.win_width} > 100"
+----------------------------------------
+
+Même condition, mais affichier toujours la liste de pseudos sur le tampon
+'&bitlbee' (même si la fenêtre est petite) :
+
+----------------------------------------
+/set weechat.bar.nicklist.conditions "${nicklist} && (${window.win_width} > 100 || ${buffer.full_name} == irc.bitlbee.&bitlbee)"
+----------------------------------------
+
[[notify_levels]]
Niveaux de notification
~~~~~~~~~~~~~~~~~~~~~~~
diff --git a/doc/it/autogen/plugin_api/hdata.txt b/doc/it/autogen/plugin_api/hdata.txt
index b6eea6f14..6fac22ed9 100644
--- a/doc/it/autogen/plugin_api/hdata.txt
+++ b/doc/it/autogen/plugin_api/hdata.txt
@@ -325,8 +325,6 @@
| weechat | bar | barra |
'name' (string) +
'options' (pointer) +
- 'conditions_count' (integer) +
- 'conditions_array' (string, array_size: "conditions_count") +
'items_count' (integer) +
'items_subcount' (pointer) +
'items_array' (pointer) +
diff --git a/doc/it/autogen/user/weechat_commands.txt b/doc/it/autogen/user/weechat_commands.txt
index 2508775bf..ba77936b3 100644
--- a/doc/it/autogen/user/weechat_commands.txt
+++ b/doc/it/autogen/user/weechat_commands.txt
@@ -11,49 +11,50 @@ messaggio: messaggio di assenza (se non specificato, lo stato di assenza viene r
[command]*`bar`* gestione delle barre::
........................................
/bar list|listfull|listitems
- add <nome> <tipo>[,<cond1>[,<cond2>...]] <posizione> <dimensione> <separatore> <item1>[,<item2>...]
+ add <name> <type>[,<condition>] <position> <size> <separator> <item1>[,<item2>...]
default [input|title|status|nicklist]
- del <nome>|-all
- set <nome> <opzione> <valore>
- hide|show|toggle <nome>
- scroll <nome> <finestra> <scroll_value>
-
- list: elenca tutte le barre
- listfull: elenca tutte le barre (dettagliato)
- listitems: elenca tutti gli elementi della barra
- add: aggiunge una nuova barra
- nome: nome della barra (deve essere unico)
- tipo: root: al di fuori delle finestre,
- window: all'interno delle finestre, con opzioni condizionali (a seguire)
- cond1,...: condizione(i) per visualizzare la barra (solo per il tipo "window"):
- active: sulla finestra attiva
- inactive: sulle finestre inattive
- nicklist: sulle finestre con la lista nick
- senza condizione, viene sempre mostrata
- posizione: bottom (basso), top (alto), left (sinistra) o right (destra)
- dimensione: dimensione della barra (in caratteri)
- separatore: 1 per usarlo (riga), 0 o nulla equivale a nessun separatore
- item1,...: elementi per questa barra (possono essere separati da virgole (spazio tra gli elementi) o "+" (elementi incollati))
- default: crea una barra predefinita (saranno tutte predefinite se non viene dato un nome per la barra)
- del: elimina una barra (o tutte le barre con -all)
- set: imposta un valore per la proprietà di una barra
- opzione: opzione da cambiare (per una lista di opzioni, consultare /set weechat.bar.<barname>.*)
- valore: nuovo valore per l'opzione
- hide: nasconde una barra
- show: mostra una barra nascosta
- toggle: nasconde/mostra una barra
- scroll: scorre una barra
- finestra: numero della finestra (usare '*' per la finestra corrente o le barre root)
- scroll_value: valore per lo scorrimento: 'x' o 'y', seguite da '+', '-', 'b' (inizio) or 'e' (fine), valore (per +/-), e %% opzionale (per scorrere di %% di larghezza/altezza, altrimenti il valore è il numero di caratteri)
-
-Esempi:
- crea una barra con l'ora, numero del buffer + nome, e completamento:
- /bar add miabarra root bottom 1 0 [time],buffer_number+:+buffer_name,completion
- nasconde una barra:
- /bar hide miabarra
- scorre la lista nick di 10 righe in basso sul buffer corrente:
+ del <name>|-all
+ set <name> <option> <value>
+ hide|show|toggle <name>
+ scroll <name> <window> <scroll_value>
+
+ list: list all bars
+ listfull: list all bars (verbose)
+ listitems: list all bar items
+ add: add a new bar
+ name: name of bar (must be unique)
+ type: root: outside windows,
+ window: inside windows, with optional conditions (see below)
+ condition: condition(s) for displaying bar (only for type "window"):
+ active: on active window
+ inactive: on inactive windows
+ nicklist: on windows with nicklist
+ other condition: see /help weechat.bar.xxx.conditions and /help eval
+ without condition, the bar is always displayed
+ position: bottom, top, left or right
+ size: size of bar (in chars)
+ separator: 1 for using separator (line), 0 or nothing means no separator
+ item1,...: items for this bar (items can be separated by comma (space between items) or "+" (glued items))
+ default: create a default bar (all default bars if no bar name is given)
+ del: delete a bar (or all bars with -all)
+ set: set a value for a bar property
+ option: option to change (for options list, look at /set weechat.bar.<barname>.*)
+ value: new value for option
+ hide: hide a bar
+ show: show an hidden bar
+ toggle: hide/show a bar
+ scroll: scroll bar
+ window: window number (use '*' for current window or for root bars)
+ scroll_value: value for scroll: 'x' or 'y' (optional), followed by '+', '-', 'b' (beginning) or 'e' (end), value (for +/-), and optional % (to scroll by % of width/height, otherwise value is number of chars)
+
+Examples:
+ create a bar with time, buffer number + name, and completion:
+ /bar add mybar root bottom 1 0 [time],buffer_number+:+buffer_name,completion
+ hide a bar:
+ /bar hide mybar
+ scroll nicklist 10 lines down on current buffer:
/bar scroll nicklist * y+10
- scorre fino alla fine della lista nick sul buffer corrente:
+ scroll to end of nicklist on current buffer:
/bar scroll nicklist * ye
........................................
@@ -199,6 +200,60 @@ infolists: mostra informazioni sulle liste info
windows: mostra l'albero delle finestre
........................................
+[[command_weechat_eval]]
+[command]*`eval`* evaluate expression and send result to buffer::
+........................................
+/eval [-n] <expression>
+ [-n] <expression1> <operator> <expression2>
+
+ -n: display result without sending it to buffer (debug mode)
+expression: expression to evaluate, variables with format ${variable} are replaced (see below)
+ operator: a logical or comparison operator:
+ - logical operators:
+ && boolean "and"
+ || boolean "or"
+ - comparison operators:
+ == equal
+ != not equal
+ <= less or equal
+ < less
+ >= greater or equal
+ > greater
+ =~ is matching regex
+ !~ is NOT matching regex
+
+An expression is considered as "true" if it is not NULL, not empty, and different from "0".
+The comparison is made using integers if the two expressions are valid integers.
+To force a string comparison, add double quotes around each expression, for example:
+ 50 > 100 ==> 0
+ "50" > "100" ==> 1
+
+Some variables are replaced in expression, using the format ${variable}, variable can be, by order of prioity :
+ 1. the name of an option (file.section.option)
+ 2. a hdata name/variable (the value is automatically converted to string), by default "window" and "buffer" point to current window/buffer.
+Format for hdata can be one of following:
+ hdata.var1.var2...: start with a hdata (pointer must be known), and ask variables one after one (other hdata can be followed)
+ hdata(list).var1.var2...: start with a hdata using a list, for example:
+ ${buffer[gui_buffers].full_name}: full name of first buffer in linked list of buffers
+ ${plugin[weechat_plugins].name}: name of first plugin in linked list of plugins
+For name of hdata and variables, please look at "Plugin API reference", function "weechat_hdata_get".
+
+Examples:
+ /eval -n ${weechat.look.scroll_amount} ==> 3
+ /eval -n ${window} ==> 0x2549aa0
+ /eval -n ${window.buffer} ==> 0x2549320
+ /eval -n ${window.buffer.full_name} ==> core.weechat
+ /eval -n ${window.buffer.number} ==> 1
+ /eval -n ${window.buffer.number} > 2 ==> 0
+ /eval -n ${window.win_width} > 100 ==> 1
+ /eval -n (8 > 12) || (5 > 2) ==> 1
+ /eval -n (8 > 12) && (5 > 2) ==> 0
+ /eval -n abcd =~ ^ABC ==> 1
+ /eval -n abcd =~ (?-i)^ABC ==> 0
+ /eval -n abcd =~ (?-i)^abc ==> 1
+ /eval -n abcd !~ abc ==> 0
+........................................
+
[[command_weechat_filter]]
[command]*`filter`* filtra messaggi nei buffer, per nascondere/mostrare in base a tag o regexp::
........................................
diff --git a/doc/it/weechat_plugin_api.it.txt b/doc/it/weechat_plugin_api.it.txt
index 07f9c2288..8f5697b61 100644
--- a/doc/it/weechat_plugin_api.it.txt
+++ b/doc/it/weechat_plugin_api.it.txt
@@ -1635,6 +1635,62 @@ str2 = weechat.string_input_for_buffer("/test") # ""
str3 = weechat.string_input_for_buffer("//test") # "/test"
----------------------------------------
+weechat_string_eval_expression
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+_Novità nella versione 0.4.0._
+
+// TRANSLATION MISSING
+Evaluate an expression and return result as a string.
+Special variables with format `${variable}` are expanded (see command `/eval` in
+'WeeChat User's guide').
+
+Prototipo:
+
+[source,C]
+----------------------------------------
+char *weechat_string_eval_expression (const char *expr,
+ struct t_hashtable *pointers,
+ struct t_hashtable *extra_vars);
+----------------------------------------
+
+Argomenti:
+
+// TRANSLATION MISSING
+* 'expr': the expression to evaluate
+* 'pointers': hashtable with pointers (keys must be string, values must be
+ pointer); pointers "window" and "buffer" are automatically added if they are
+ not in hashtable (with pointer to current window/buffer) (can be NULL)
+* 'extra_vars': extra variables that will be expanded (can be NULL)
+
+Valore restituito:
+
+// TRANSLATION MISSING
+* evaluated expression (must be freed by calling "free" after use), or NULL
+ if problem (invalid expression or not enough memory)
+
+Esempi in C:
+
+[source,C]
+----------------------------------------
+char *str1 = weechat_string_eval_expression ("${buffer.full_name}", NULL, NULL); /* "core.weechat" */
+char *str2 = weechat_string_eval_expression ("${window.win_width} > 100", NULL, NULL); /* "1" */
+char *str3 = weechat_string_eval_expression ("abc =~ def", NULL, NULL); /* "0" */
+----------------------------------------
+
+Script (Python):
+
+[source,python]
+----------------------------------------
+# prototipo
+str = weechat.string_eval_expression(expr, pointers, extra_vars)
+
+# esempi
+str1 = weechat.string_input_for_buffer("${buffer.full_name}", {}, {}) # "core.weechat"
+str2 = weechat.string_input_for_buffer("${window.win_width} > 100", {}, {}) # "1"
+str3 = weechat.string_input_for_buffer("abc =~ def", {}, {}) # "0"
+----------------------------------------
+
[[utf-8]]
UTF-8
~~~~~
diff --git a/doc/it/weechat_user.it.txt b/doc/it/weechat_user.it.txt
index 2ea159ac0..c45cba988 100644
--- a/doc/it/weechat_user.it.txt
+++ b/doc/it/weechat_user.it.txt
@@ -568,6 +568,219 @@ Esempio di split orizzontale + verticale:
(buffer #3)
........................................
+// TRANSLATION MISSING
+[[bars]]
+Bars
+~~~~
+
+A 'bar' is an area beside the chat that can contain any type of text.
+
+The bar options can be set with options `weechat.bar.name.option` where `name`
+is the name of the bar and `option` the option for this bar.
+
+List of bar options:
+
+[width="100%",cols="2m,2,10",options="header"]
+|========================================
+| Option | Values | Description
+
+| type | `root`, `window` |
+ A bar with type `root` is displayed exactly one time on screen, outside all
+ windows. There is no root bar by default, but an example is the bar 'buffers'
+ created by script 'buffers.pl' (sidebar with list of buffers). +
+ A bar with type `window` is displayed in each window, for example if you
+ split one time the screen (with `/window splith` or `/window splitv`), you
+ will have one bar in each window. The four default bars ('title', 'status',
+ 'input', 'nicklist') have type `window`.
+
+| position | `top`, `bottom`, `left`, `right` |
+ Position of the bar: above/below chat, on the left/right.
+
+| priority | integer ≥ 0 |
+ Priority for display of bar: this is used for ordering the bars on screen when
+ many bars have same type and position. +
+ The bars are displayed from the edge of the screen to the center. A higher
+ priority will display bar at the beginning, so closer to the edge. +
+ Example: 'input' bar has priority 1000, so it is displayed before the 'status'
+ bar, which has priority 500.
+
+| size | integer ≥ 0 |
+ The size of the bar: number of columns for position left/right, number
+ of lines for position top/tobbom. A size of `0` means automatic, so the size
+ will be computed according to content displayed in bar.
+
+| size_max | integer ≥ 0 |
+ The maximum size for a bar, `0` = no limit (this option is used only if
+ `size` = `0`).
+
+| color_bg | color |
+ The default background color for the bar.
+
+| color_fg | color |
+ The default text color for the bar.
+
+| color_delim | color |
+ The color for delimiters in bar.
+
+| hidden | `on`, `off` |
+ When option is `on`, the bar is hidden. +
+ Note: instead of changing this option, the command `/bar` is preferred, for
+ example: `/bar toggle nicklist` (see command <<command_weechat_bar,/bar>>).
+
+| separator | `on`, `off` |
+ When option is `on`, a separator (line) is displayed between this bar and
+ other bars (or chat).
+
+| items | string |
+ A list of 'items' (see <<bar_items,items>> for more info).
+
+| filling_left_right | `horizontal`, `vertical`, `columns_horizontal`, `columns_vertical` |
+ Type of filling for a bar which has position `left` or `right` (see
+ <<bar_filling,filling>> for more info).
+
+| filling_top_bottom | `horizontal`, `vertical`, `columns_horizontal`, `columns_vertical` |
+ Type of filling for a bar which has position `top` or `bottom` (see
+ <<bar_filling,filling>> for more info).
+
+| conditions | string |
+ The conditions to display the bar (see <<bar_conditions,conditions>> for more
+ info).
+|========================================
+
+[[bar_items]]
+Items
+^^^^^
+
+The option 'items' is a string with a list of bar items, separated by a comma
+(space between items on screen) or "+" (glued items).
+
+The list of bar items is displayed with command `/bar listitems`.
+
+Example of bar with items "[time],buffer_number+:+buffer_plugin+.+buffer_name":
+
+........................................
+┌─────────────────────────────────────────────────────────────────────────────────────────┐
+│[12:55] 3:irc/freenode.#weechat │
+└─────────────────────────────────────────────────────────────────────────────────────────┘
+........................................
+
+[[bar_filling]]
+Filling
+^^^^^^^
+
+There are four types of filling:
+
+* `horizontal`: the items are displayed horizontally, from left to right. If
+ there are new lines in items, a space is used to separate lines.
+* `vertical`: the items are displayed from top to bottom. If there are new
+ lines in items, a new line is used to separate lines.
+* `columns_horizontal`: items are displayed using columns, where text is
+ aligned on the left. The first item is on top left, the second is on same
+ line, on the right.
+* `columns_vertical`: items are displayed using columns, where text is aligned
+ on the left. The first item is on top left, the second is one line below.
+
+Default bars 'title', 'status' and 'input' have 'horizontal' filling, and
+default bar 'nicklist' has 'vertical' filling.
+
+Some examples of filling for bar 'nicklist':
+
+........................................
+┌──────────────────────────────────────────────────┐
+│Welcome to #test, this is a test channel │
+│12:54:15 peter | hey! │@carl │
+│12:55:01 +Max | hello │@jessika│
+│ │@maddy │
+│ │%Diego │
+│ │%Melody │
+│ │+Max │
+│ │ celia │
+│ │ Eva │
+│ │ freddy │
+│ │ Harold^│
+│ │ henry4 │
+│ │ jimmy17│
+│ │ jodie ▼│
+│[12:55] [6] [irc/freenode] 3:#test(+n){24} │
+└──────────────────────────────────────────────────┘
+ filling_left_right = vertical ▲
+
+┌──────────────────────────────────────────────────┐
+│Welcome to #test, this is a test channel │
+│12:54:15 peter | hey! │@carl lee │
+│12:55:01 +Max | hello │@jessika louise │
+│ │@maddy mario │
+│ │%Diego mark │
+│ │%Melody peter │
+│ │+Max Rachel │
+│ │ celia richard│
+│ │ Eva sheryl │
+│ │ freddy Vince │
+│ │ Harold^ warren │
+│ │ henry4 zack │
+│ │ jimmy17 │
+│ │ jodie │
+│[12:55] [6] [irc/freenode] 3:#test(+n){24} │
+└──────────────────────────────────────────────────┘
+ filling_left_right = columns_vertical ▲
+
+┌───────────────────────────────────────────────────────────────────────┐
+│@carl %Diego celia Harold^ jodie mario Rachel Vince │
+│@jessika %Melody Eva henry4 lee mark richard warren │
+│@maddy +Max freddy jimmy17 louise peter sheryl zack │
+│───────────────────────────────────────────────────────────────────────│
+│ │
+ filling_top_bottom = columns_vertical ▲
+
+┌───────────────────────────────────────────────────────────────────────┐
+│@carl @jessika @maddy %Diego %Melody +Max celia Eva │
+│ freddy Harold^ henry4 jimmy17 jodie lee louise mario │
+│ mark peter Rachel richard sheryl Vince warren zack │
+│───────────────────────────────────────────────────────────────────────│
+│ │
+ filling_top_bottom = columns_horizontal ▲
+........................................
+
+[[bar_conditions]]
+Conditions
+^^^^^^^^^^
+
+The option 'conditions' is a string evaluated to know if the bar is displayed
+or not in the window (it is used only for bars with type 'window').
+
+The string can be:
+
+* 'active': the window must be active
+* 'inactive': the window must be inactive
+* 'nicklist': the buffer displayed in window must have a nicklist
+* an expression: it is evaluated as boolean (see command
+ <<command_weechat_eval,/eval>>)
+
+For the expression, following variables are available:
+
+* `${active}`: true if window is active
+* `${inactive}`: true if window is inactive
+* `$[nicklist}`: true if buffer displayed in window has a nicklist
+
+Following pointers are available:
+
+* `${window}`: the window where condition is evaluated
+* `${buffer}`: the buffer of window where condition is evaluated
+
+Exemple to display nicklist bar in all buffers with a nicklist, and only if
+width of window is > 100 :
+
+----------------------------------------
+/set weechat.bar.nicklist.conditions "${nicklist} && ${window.win_width} > 100"
+----------------------------------------
+
+Same condition, but always display nicklist on buffer '&bitlbee' (even if window
+is small):
+
+----------------------------------------
+/set weechat.bar.nicklist.conditions "${nicklist} && (${window.win_width} > 100 || ${buffer.full_name} == irc.bitlbee.&bitlbee)"
+----------------------------------------
+
[[notify_levels]]
Livelli di notifica
~~~~~~~~~~~~~~~~~~~
diff --git a/doc/ja/autogen/plugin_api/hdata.txt b/doc/ja/autogen/plugin_api/hdata.txt
index dbfa893f8..430ccadf1 100644
--- a/doc/ja/autogen/plugin_api/hdata.txt
+++ b/doc/ja/autogen/plugin_api/hdata.txt
@@ -325,8 +325,6 @@
| weechat | bar | バー |
'name' (string) +
'options' (pointer) +
- 'conditions_count' (integer) +
- 'conditions_array' (string, array_size: "conditions_count") +
'items_count' (integer) +
'items_subcount' (pointer) +
'items_array' (pointer) +
diff --git a/doc/ja/autogen/user/weechat_commands.txt b/doc/ja/autogen/user/weechat_commands.txt
index 49c1a5286..9bf0c3a08 100644
--- a/doc/ja/autogen/user/weechat_commands.txt
+++ b/doc/ja/autogen/user/weechat_commands.txt
@@ -11,49 +11,50 @@ message: 離席メッセージ (メッセージが無い場合は、離席状態
[command]*`bar`* バーの管理::
........................................
/bar list|listfull|listitems
- add <name> <type>[,<cond1>[,<cond2>...]] <position> <size> <separator> <item1>[,<item2>...]
+ add <name> <type>[,<condition>] <position> <size> <separator> <item1>[,<item2>...]
default [input|title|status|nicklist]
del <name>|-all
set <name> <option> <value>
hide|show|toggle <name>
scroll <name> <window> <scroll_value>
- list: 全てのバーをリストアップ
- listfull: 全てのバーをリストアップ (詳細)
- listitems: 全てのバーアイテムをリストアップ
- add: 新しいバーを追加
- name: バーの名称 (ユニークな)
- type: root: 外側のウィンドウ、
- window: 内側のウィンドウ、任意の状態を取れる (以下を参照)
- cond1,...: バーの表示状態 (タイプが "window" のバー以外は無効):
- active: アクティブウィンドウに表示
- inactive: 非アクティブウィンドウに表示
- nicklist: ニックネームリストを持つウィンドウに表示
- 表示状態の指定が無ければ、バーは常に表示されます。
- position: bottom、top、left、right
- size: バーのサイズ (文字数で指定)
- separator: 1 はセパレータ (線) を使用、0 または指定無しはセパレータ無し
- item1,...: バーのアイテム (アイテムはコンマ (アイテム間にスペース) または "+" (アイテム間にスペース無し) で区切ります)
- default: デフォルトバーを作成 (バーの名前が無ければ全てのデフォルトバーが作成されます)
- del: バーを削除 (-all を付ければ全てのバーを削除)
- set: バー属性に値を設定
- option: 変更するオプション (オプション一覧は /set weechat.bar.<barname>.* を参照)
- value: オプションの新しい値
- hide: バーを隠す
- show: 隠されたバーを表示
- toggle: バーの非表示/表示を切り替え
- scroll: バーをスクロール
- window: ウィンドウ番号 (現在のウィンドウかルートバーを指定するには '*' を使う)
- scroll_value: スクロールする量: 'x' または 'y' (任意)の後に、'+' か '-' か 'b' (最初) か 'e' (最後)の後に、値 (+/- を付けて)、任意で % (スクロールする幅/高さの割合、% が無ければ値は文字数と解釈されます)
-
-例:
- 時間、バー番号 + 名前、補完候補からなるバーを作成:
+ list: list all bars
+ listfull: list all bars (verbose)
+ listitems: list all bar items
+ add: add a new bar
+ name: name of bar (must be unique)
+ type: root: outside windows,
+ window: inside windows, with optional conditions (see below)
+ condition: condition(s) for displaying bar (only for type "window"):
+ active: on active window
+ inactive: on inactive windows
+ nicklist: on windows with nicklist
+ other condition: see /help weechat.bar.xxx.conditions and /help eval
+ without condition, the bar is always displayed
+ position: bottom, top, left or right
+ size: size of bar (in chars)
+ separator: 1 for using separator (line), 0 or nothing means no separator
+ item1,...: items for this bar (items can be separated by comma (space between items) or "+" (glued items))
+ default: create a default bar (all default bars if no bar name is given)
+ del: delete a bar (or all bars with -all)
+ set: set a value for a bar property
+ option: option to change (for options list, look at /set weechat.bar.<barname>.*)
+ value: new value for option
+ hide: hide a bar
+ show: show an hidden bar
+ toggle: hide/show a bar
+ scroll: scroll bar
+ window: window number (use '*' for current window or for root bars)
+ scroll_value: value for scroll: 'x' or 'y' (optional), followed by '+', '-', 'b' (beginning) or 'e' (end), value (for +/-), and optional % (to scroll by % of width/height, otherwise value is number of chars)
+
+Examples:
+ create a bar with time, buffer number + name, and completion:
/bar add mybar root bottom 1 0 [time],buffer_number+:+buffer_name,completion
- バーを隠す:
+ hide a bar:
/bar hide mybar
- 現在のバッファに対応したニックネームリストを10行分、下方向にスクロール:
+ scroll nicklist 10 lines down on current buffer:
/bar scroll nicklist * y+10
- 現在のバッファに対応したニックネームリストを最後までスクロール:
+ scroll to end of nicklist on current buffer:
/bar scroll nicklist * ye
........................................
@@ -199,6 +200,60 @@ infolists: infolist に関する情報を表示
windows: ウィンドウツリーの情報を表示
........................................
+[[command_weechat_eval]]
+[command]*`eval`* evaluate expression and send result to buffer::
+........................................
+/eval [-n] <expression>
+ [-n] <expression1> <operator> <expression2>
+
+ -n: display result without sending it to buffer (debug mode)
+expression: expression to evaluate, variables with format ${variable} are replaced (see below)
+ operator: a logical or comparison operator:
+ - logical operators:
+ && boolean "and"
+ || boolean "or"
+ - comparison operators:
+ == equal
+ != not equal
+ <= less or equal
+ < less
+ >= greater or equal
+ > greater
+ =~ is matching regex
+ !~ is NOT matching regex
+
+An expression is considered as "true" if it is not NULL, not empty, and different from "0".
+The comparison is made using integers if the two expressions are valid integers.
+To force a string comparison, add double quotes around each expression, for example:
+ 50 > 100 ==> 0
+ "50" > "100" ==> 1
+
+Some variables are replaced in expression, using the format ${variable}, variable can be, by order of prioity :
+ 1. the name of an option (file.section.option)
+ 2. a hdata name/variable (the value is automatically converted to string), by default "window" and "buffer" point to current window/buffer.
+Format for hdata can be one of following:
+ hdata.var1.var2...: start with a hdata (pointer must be known), and ask variables one after one (other hdata can be followed)
+ hdata(list).var1.var2...: start with a hdata using a list, for example:
+ ${buffer[gui_buffers].full_name}: full name of first buffer in linked list of buffers
+ ${plugin[weechat_plugins].name}: name of first plugin in linked list of plugins
+For name of hdata and variables, please look at "Plugin API reference", function "weechat_hdata_get".
+
+Examples:
+ /eval -n ${weechat.look.scroll_amount} ==> 3
+ /eval -n ${window} ==> 0x2549aa0
+ /eval -n ${window.buffer} ==> 0x2549320
+ /eval -n ${window.buffer.full_name} ==> core.weechat
+ /eval -n ${window.buffer.number} ==> 1
+ /eval -n ${window.buffer.number} > 2 ==> 0
+ /eval -n ${window.win_width} > 100 ==> 1
+ /eval -n (8 > 12) || (5 > 2) ==> 1
+ /eval -n (8 > 12) && (5 > 2) ==> 0
+ /eval -n abcd =~ ^ABC ==> 1
+ /eval -n abcd =~ (?-i)^ABC ==> 0
+ /eval -n abcd =~ (?-i)^abc ==> 1
+ /eval -n abcd !~ abc ==> 0
+........................................
+
[[command_weechat_filter]]
[command]*`filter`* タグか正規表現に基づくバッファメッセージの非表示/表示::
........................................
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 7bb755b0d..c17d1c59a 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -12,6 +12,8 @@
./src/core/wee-config.h
./src/core/wee-debug.c
./src/core/wee-debug.h
+./src/core/wee-eval.c
+./src/core/wee-eval.h
./src/core/wee-hook.c
./src/core/wee-hook.h
./src/core/wee-infolist.c
diff --git a/po/cs.po b/po/cs.po
index c47e9a4b8..5e3a25aa8 100644
--- a/po/cs.po
+++ b/po/cs.po
@@ -20,7 +20,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.4.0-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
-"POT-Creation-Date: 2012-10-20 17:54+0200\n"
+"POT-Creation-Date: 2012-11-02 08:59+0100\n"
"PO-Revision-Date: 2012-09-29 11:42+0200\n"
"Last-Translator: Jiri Golembiovsky <golemj@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -247,6 +247,13 @@ msgstr "Hrubý obsah bufferů byl zapsán do logovacího souboru"
msgid "Debug disabled for \"%s\""
msgstr "Ladění vypnuto pro \"%s\""
+msgid "error"
+msgstr ""
+
+#, c-format
+msgid "%sError in expression to evaluate"
+msgstr ""
+
#, c-format
msgid " %s[%s%s%s]%s buffer: %s%s%s / tags: %s / regex: %s %s"
msgstr " %s[%s%s%s]%s buffer: %s%s%s / značky: %s / regulární výraz: %s %s"
@@ -835,10 +842,10 @@ msgstr "řídit pole"
#, fuzzy
msgid ""
-"list|listfull|listitems || add <name> <type>[,<cond1>[,<cond2>...]] "
-"<position> <size> <separator> <item1>[,<item2>...] || default [input|title|"
-"status|nicklist] || del <name>|-all || set <name> <option> <value> || hide|"
-"show|toggle <name> || scroll <name> <window> <scroll_value>"
+"list|listfull|listitems || add <name> <type>[,<condition>] <position> <size> "
+"<separator> <item1>[,<item2>...] || default [input|title|status|nicklist] || "
+"del <name>|-all || set <name> <option> <value> || hide|show|toggle <name> || "
+"scroll <name> <window> <scroll_value>"
msgstr ""
"list|listfull|listitems || add <jméno> <typ>[,<podmínka1>[,<podmínka2>...]] "
"<pozice> <velikost> <oddělovac> <položka1>[,<položka2>...] || default [input|"
@@ -855,11 +862,13 @@ msgid ""
" name: name of bar (must be unique)\n"
" type: root: outside windows,\n"
" window: inside windows, with optional conditions (see below)\n"
-" cond1,...: condition(s) for displaying bar (only for type \"window\"):\n"
+" condition: condition(s) for displaying bar (only for type \"window\"):\n"
" active: on active window\n"
" inactive: on inactive windows\n"
" nicklist: on windows with nicklist\n"
-" without condition, bar is always displayed\n"
+" other condition: see /help weechat.bar.xxx.conditions and /"
+"help eval\n"
+" without condition, the bar is always displayed\n"
" position: bottom, top, left or right\n"
" size: size of bar (in chars)\n"
" separator: 1 for using separator (line), 0 or nothing means no "
@@ -1182,6 +1191,71 @@ msgstr ""
" term: zobrazit informace o terminálu a dostupných barvách\n"
"windows: zobrazit strom oken"
+msgid "evaluate expression and send result to buffer"
+msgstr ""
+
+msgid "[-n] <expression> || [-n] <expression1> <operator> <expression2>"
+msgstr ""
+
+msgid ""
+" -n: display result without sending it to buffer (debug mode)\n"
+"expression: expression to evaluate, variables with format ${variable} are "
+"replaced (see below)\n"
+" operator: a logical or comparison operator:\n"
+" - logical operators:\n"
+" && boolean \"and\"\n"
+" || boolean \"or\"\n"
+" - comparison operators:\n"
+" == equal\n"
+" != not equal\n"
+" <= less or equal\n"
+" < less\n"
+" >= greater or equal\n"
+" > greater\n"
+" =~ is matching regex\n"
+" !~ is NOT matching regex\n"
+"\n"
+"An expression is considered as \"true\" if it is not NULL, not empty, and "
+"different from \"0\".\n"
+"The comparison is made using integers if the two expressions are valid "
+"integers.\n"
+"To force a string comparison, add double quotes around each expression, for "
+"example:\n"
+" 50 > 100 ==> 0\n"
+" \"50\" > \"100\" ==> 1\n"
+"\n"
+"Some variables are replaced in expression, using the format ${variable}, "
+"variable can be, by order of prioity :\n"
+" 1. the name of an option (file.section.option)\n"
+" 2. a hdata name/variable (the value is automatically converted to string), "
+"by default \"window\" and \"buffer\" point to current window/buffer.\n"
+"Format for hdata can be one of following:\n"
+" hdata.var1.var2...: start with a hdata (pointer must be known), and ask "
+"variables one after one (other hdata can be followed)\n"
+" hdata(list).var1.var2...: start with a hdata using a list, for example:\n"
+" ${buffer[gui_buffers].full_name}: full name of first buffer in linked "
+"list of buffers\n"
+" ${plugin[weechat_plugins].name}: name of first plugin in linked list of "
+"plugins\n"
+"For name of hdata and variables, please look at \"Plugin API reference\", "
+"function \"weechat_hdata_get\".\n"
+"\n"
+"Examples:\n"
+" /eval -n ${weechat.look.scroll_amount} ==> 3\n"
+" /eval -n ${window} ==> 0x2549aa0\n"
+" /eval -n ${window.buffer} ==> 0x2549320\n"
+" /eval -n ${window.buffer.full_name} ==> core.weechat\n"
+" /eval -n ${window.buffer.number} ==> 1\n"
+" /eval -n ${window.buffer.number} > 2 ==> 0\n"
+" /eval -n ${window.win_width} > 100 ==> 1\n"
+" /eval -n (8 > 12) || (5 > 2) ==> 1\n"
+" /eval -n (8 > 12) && (5 > 2) ==> 0\n"
+" /eval -n abcd =~ ^ABC ==> 1\n"
+" /eval -n abcd =~ (?-i)^ABC ==> 0\n"
+" /eval -n abcd =~ (?-i)^abc ==> 1\n"
+" /eval -n abcd !~ abc ==> 0"
+msgstr ""
+
msgid ""
"filter messages in buffers, to hide/show them according to tags or regex"
msgstr ""
@@ -2224,6 +2298,11 @@ msgstr "alias pro barvu"
msgid "%sError: palette option must be numeric"
msgstr "%sChyba: voleba palety musí být číselná"
+#, fuzzy, c-format
+msgid "%sWarning: unknown option for section \"%s\": %s (value: \"%s\")"
+msgstr ""
+"%sUpozornění: %s, řádek %d: nastavení \"%s\" je neznámé pro sekci \"%s\""
+
msgid "Notify level for buffer"
msgstr "Úroveň upozornění pro buffer"
@@ -3369,9 +3448,11 @@ msgid "bar type (root, window, window_active, window_inactive)"
msgstr "typ pole (root, window, window_active, window_inactive)"
msgid ""
-"condition(s) for displaying bar (for bars of type \"window\"): \"active\" = "
-"window must be active, \"inactive\" = window must be inactive, \"nicklist\" "
-"= buffer must have a nicklist"
+"condition(s) for displaying bar (for bars of type \"window\"): a simple "
+"condition: \"active\", \"inactive\", \"nicklist\" (window must be active/"
+"inactive, buffer must have a nicklist), or an expression with condition(s) "
+"(see /help eval), like: \"${nicklist} && ${window.win_width} > 100\" (local "
+"variables for expression are ${active}, ${inactive} and ${nicklist})"
msgstr ""
msgid "bar position (bottom, top, left, right)"
diff --git a/po/de.po b/po/de.po
index d17bb8f23..23db423a6 100644
--- a/po/de.po
+++ b/po/de.po
@@ -23,7 +23,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.3.7-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
-"POT-Creation-Date: 2012-10-20 17:54+0200\n"
+"POT-Creation-Date: 2012-11-02 08:59+0100\n"
"PO-Revision-Date: 2012-10-19 17:57+0100\n"
"Last-Translator: Nils Görs <weechatter@arcor.de>\n"
"Language-Team: German <weechatter@arcor.de>\n"
@@ -265,6 +265,13 @@ msgstr ""
msgid "Debug disabled for \"%s\""
msgstr "Debug-Modus für \"%s\" deaktiviert"
+msgid "error"
+msgstr ""
+
+#, c-format
+msgid "%sError in expression to evaluate"
+msgstr ""
+
#, c-format
msgid " %s[%s%s%s]%s buffer: %s%s%s / tags: %s / regex: %s %s"
msgstr " %s[%s%s%s]%s Buffer: %s%s%s / Schlagwörter: %s / regex: %s %s"
@@ -853,17 +860,19 @@ msgstr ""
msgid "manage bars"
msgstr "Infobars verwalten"
+#, fuzzy
msgid ""
-"list|listfull|listitems || add <name> <type>[,<cond1>[,<cond2>...]] "
-"<position> <size> <separator> <item1>[,<item2>...] || default [input|title|"
-"status|nicklist] || del <name>|-all || set <name> <option> <value> || hide|"
-"show|toggle <name> || scroll <name> <window> <scroll_value>"
+"list|listfull|listitems || add <name> <type>[,<condition>] <position> <size> "
+"<separator> <item1>[,<item2>...] || default [input|title|status|nicklist] || "
+"del <name>|-all || set <name> <option> <value> || hide|show|toggle <name> || "
+"scroll <name> <window> <scroll_value>"
msgstr ""
"list|listfull|listitems || add <name> <type>[,<cond1>[,<cond2>...]] "
"<position> <size> <separator> <item1>[,<item2>...] || default [input|title|"
"status|nicklist] || del <name>|-all || set <name> <option> <value> || hide|"
"show|toggle <name> || scroll <name> <window> <scroll_value>"
+#, fuzzy
msgid ""
" list: list all bars\n"
" listfull: list all bars (verbose)\n"
@@ -872,11 +881,13 @@ msgid ""
" name: name of bar (must be unique)\n"
" type: root: outside windows,\n"
" window: inside windows, with optional conditions (see below)\n"
-" cond1,...: condition(s) for displaying bar (only for type \"window\"):\n"
+" condition: condition(s) for displaying bar (only for type \"window\"):\n"
" active: on active window\n"
" inactive: on inactive windows\n"
" nicklist: on windows with nicklist\n"
-" without condition, bar is always displayed\n"
+" other condition: see /help weechat.bar.xxx.conditions and /"
+"help eval\n"
+" without condition, the bar is always displayed\n"
" position: bottom, top, left or right\n"
" size: size of bar (in chars)\n"
" separator: 1 for using separator (line), 0 or nothing means no "
@@ -1239,6 +1250,71 @@ msgstr ""
" term: gibt Informationen über das Terminal und verfügbare Farben aus\n"
" windows: zeigt die Fensterstruktur an"
+msgid "evaluate expression and send result to buffer"
+msgstr ""
+
+msgid "[-n] <expression> || [-n] <expression1> <operator> <expression2>"
+msgstr ""
+
+msgid ""
+" -n: display result without sending it to buffer (debug mode)\n"
+"expression: expression to evaluate, variables with format ${variable} are "
+"replaced (see below)\n"
+" operator: a logical or comparison operator:\n"
+" - logical operators:\n"
+" && boolean \"and\"\n"
+" || boolean \"or\"\n"
+" - comparison operators:\n"
+" == equal\n"
+" != not equal\n"
+" <= less or equal\n"
+" < less\n"
+" >= greater or equal\n"
+" > greater\n"
+" =~ is matching regex\n"
+" !~ is NOT matching regex\n"
+"\n"
+"An expression is considered as \"true\" if it is not NULL, not empty, and "
+"different from \"0\".\n"
+"The comparison is made using integers if the two expressions are valid "
+"integers.\n"
+"To force a string comparison, add double quotes around each expression, for "
+"example:\n"
+" 50 > 100 ==> 0\n"
+" \"50\" > \"100\" ==> 1\n"
+"\n"
+"Some variables are replaced in expression, using the format ${variable}, "
+"variable can be, by order of prioity :\n"
+" 1. the name of an option (file.section.option)\n"
+" 2. a hdata name/variable (the value is automatically converted to string), "
+"by default \"window\" and \"buffer\" point to current window/buffer.\n"
+"Format for hdata can be one of following:\n"
+" hdata.var1.var2...: start with a hdata (pointer must be known), and ask "
+"variables one after one (other hdata can be followed)\n"
+" hdata(list).var1.var2...: start with a hdata using a list, for example:\n"
+" ${buffer[gui_buffers].full_name}: full name of first buffer in linked "
+"list of buffers\n"
+" ${plugin[weechat_plugins].name}: name of first plugin in linked list of "
+"plugins\n"
+"For name of hdata and variables, please look at \"Plugin API reference\", "
+"function \"weechat_hdata_get\".\n"
+"\n"
+"Examples:\n"
+" /eval -n ${weechat.look.scroll_amount} ==> 3\n"
+" /eval -n ${window} ==> 0x2549aa0\n"
+" /eval -n ${window.buffer} ==> 0x2549320\n"
+" /eval -n ${window.buffer.full_name} ==> core.weechat\n"
+" /eval -n ${window.buffer.number} ==> 1\n"
+" /eval -n ${window.buffer.number} > 2 ==> 0\n"
+" /eval -n ${window.win_width} > 100 ==> 1\n"
+" /eval -n (8 > 12) || (5 > 2) ==> 1\n"
+" /eval -n (8 > 12) && (5 > 2) ==> 0\n"
+" /eval -n abcd =~ ^ABC ==> 1\n"
+" /eval -n abcd =~ (?-i)^ABC ==> 0\n"
+" /eval -n abcd =~ (?-i)^abc ==> 1\n"
+" /eval -n abcd !~ abc ==> 0"
+msgstr ""
+
msgid ""
"filter messages in buffers, to hide/show them according to tags or regex"
msgstr ""
@@ -2438,6 +2514,10 @@ msgstr "Alias für Farbe"
msgid "%sError: palette option must be numeric"
msgstr "%sFehler: Option Palette muss numerisch sein"
+#, fuzzy, c-format
+msgid "%sWarning: unknown option for section \"%s\": %s (value: \"%s\")"
+msgstr "%sWarnung: %s, Zeile %d: unbekannte Option für Sektion \"%s\": %s"
+
msgid "Notify level for buffer"
msgstr "Benachrichtigungsstufe für Buffer"
@@ -3738,13 +3818,12 @@ msgid "bar type (root, window, window_active, window_inactive)"
msgstr "Bar-Typ (root, window, window_active, window_inactive)"
msgid ""
-"condition(s) for displaying bar (for bars of type \"window\"): \"active\" = "
-"window must be active, \"inactive\" = window must be inactive, \"nicklist\" "
-"= buffer must have a nicklist"
+"condition(s) for displaying bar (for bars of type \"window\"): a simple "
+"condition: \"active\", \"inactive\", \"nicklist\" (window must be active/"
+"inactive, buffer must have a nicklist), or an expression with condition(s) "
+"(see /help eval), like: \"${nicklist} && ${window.win_width} > 100\" (local "
+"variables for expression are ${active}, ${inactive} and ${nicklist})"
msgstr ""
-"Bedingung(en) um eine Bar anzuzeigen (gilt für Bars des Typs \"window\"): "
-"\"active\" = window muss aktiv sein \"inactive\" = window muss inaktiv sein, "
-"\"nicklist\" = Buffer muss über eine Nickliste verfügen"
msgid "bar position (bottom, top, left, right)"
msgstr "Position der Infobar (unten, oben, links, rechts)"
@@ -9857,6 +9936,15 @@ msgid "Constants"
msgstr "Konstanten"
#~ msgid ""
+#~ "condition(s) for displaying bar (for bars of type \"window\"): \"active\" "
+#~ "= window must be active, \"inactive\" = window must be inactive, "
+#~ "\"nicklist\" = buffer must have a nicklist"
+#~ msgstr ""
+#~ "Bedingung(en) um eine Bar anzuzeigen (gilt für Bars des Typs \"window\"): "
+#~ "\"active\" = window muss aktiv sein \"inactive\" = window muss inaktiv "
+#~ "sein, \"nicklist\" = Buffer muss über eine Nickliste verfügen"
+
+#~ msgid ""
#~ "server: server name\n"
#~ " nick: nick (may be a mask)"
#~ msgstr ""
diff --git a/po/es.po b/po/es.po
index 5ba44fb5f..005918e54 100644
--- a/po/es.po
+++ b/po/es.po
@@ -22,7 +22,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.4.0-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
-"POT-Creation-Date: 2012-10-20 17:54+0200\n"
+"POT-Creation-Date: 2012-11-02 08:59+0100\n"
"PO-Revision-Date: 2012-09-29 11:42+0200\n"
"Last-Translator: Elián Hanisch <lambdae2@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -253,6 +253,13 @@ msgstr ""
msgid "Debug disabled for \"%s\""
msgstr "Depurado de \"%s\" desactivado"
+msgid "error"
+msgstr ""
+
+#, c-format
+msgid "%sError in expression to evaluate"
+msgstr ""
+
#, c-format
msgid " %s[%s%s%s]%s buffer: %s%s%s / tags: %s / regex: %s %s"
msgstr " %s[%s%s%s]%s buffer: %s%s%s / etiquetas: %s / expresión: %s %s"
@@ -836,11 +843,12 @@ msgstr ""
msgid "manage bars"
msgstr "gestionar las barras"
+#, fuzzy
msgid ""
-"list|listfull|listitems || add <name> <type>[,<cond1>[,<cond2>...]] "
-"<position> <size> <separator> <item1>[,<item2>...] || default [input|title|"
-"status|nicklist] || del <name>|-all || set <name> <option> <value> || hide|"
-"show|toggle <name> || scroll <name> <window> <scroll_value>"
+"list|listfull|listitems || add <name> <type>[,<condition>] <position> <size> "
+"<separator> <item1>[,<item2>...] || default [input|title|status|nicklist] || "
+"del <name>|-all || set <name> <option> <value> || hide|show|toggle <name> || "
+"scroll <name> <window> <scroll_value>"
msgstr ""
"list|listfull|listitems || add <nombre> <tipo>[,<cond1>[,<cond2>...]] "
"<posición> <tamaño> <separador> <elemento1>[,<elemento2>...] || default "
@@ -848,6 +856,7 @@ msgstr ""
"<valor> || hide|show|toggle <nombre> || scroll <nombre> <ventana> "
"<desplazamiento>"
+#, fuzzy
msgid ""
" list: list all bars\n"
" listfull: list all bars (verbose)\n"
@@ -856,11 +865,13 @@ msgid ""
" name: name of bar (must be unique)\n"
" type: root: outside windows,\n"
" window: inside windows, with optional conditions (see below)\n"
-" cond1,...: condition(s) for displaying bar (only for type \"window\"):\n"
+" condition: condition(s) for displaying bar (only for type \"window\"):\n"
" active: on active window\n"
" inactive: on inactive windows\n"
" nicklist: on windows with nicklist\n"
-" without condition, bar is always displayed\n"
+" other condition: see /help weechat.bar.xxx.conditions and /"
+"help eval\n"
+" without condition, the bar is always displayed\n"
" position: bottom, top, left or right\n"
" size: size of bar (in chars)\n"
" separator: 1 for using separator (line), 0 or nothing means no "
@@ -1216,6 +1227,71 @@ msgstr ""
" term: muestra información sobre la terminal.\n"
" windows: muestra el árbol de ventanas."
+msgid "evaluate expression and send result to buffer"
+msgstr ""
+
+msgid "[-n] <expression> || [-n] <expression1> <operator> <expression2>"
+msgstr ""
+
+msgid ""
+" -n: display result without sending it to buffer (debug mode)\n"
+"expression: expression to evaluate, variables with format ${variable} are "
+"replaced (see below)\n"
+" operator: a logical or comparison operator:\n"
+" - logical operators:\n"
+" && boolean \"and\"\n"
+" || boolean \"or\"\n"
+" - comparison operators:\n"
+" == equal\n"
+" != not equal\n"
+" <= less or equal\n"
+" < less\n"
+" >= greater or equal\n"
+" > greater\n"
+" =~ is matching regex\n"
+" !~ is NOT matching regex\n"
+"\n"
+"An expression is considered as \"true\" if it is not NULL, not empty, and "
+"different from \"0\".\n"
+"The comparison is made using integers if the two expressions are valid "
+"integers.\n"
+"To force a string comparison, add double quotes around each expression, for "
+"example:\n"
+" 50 > 100 ==> 0\n"
+" \"50\" > \"100\" ==> 1\n"
+"\n"
+"Some variables are replaced in expression, using the format ${variable}, "
+"variable can be, by order of prioity :\n"
+" 1. the name of an option (file.section.option)\n"
+" 2. a hdata name/variable (the value is automatically converted to string), "
+"by default \"window\" and \"buffer\" point to current window/buffer.\n"
+"Format for hdata can be one of following:\n"
+" hdata.var1.var2...: start with a hdata (pointer must be known), and ask "
+"variables one after one (other hdata can be followed)\n"
+" hdata(list).var1.var2...: start with a hdata using a list, for example:\n"
+" ${buffer[gui_buffers].full_name}: full name of first buffer in linked "
+"list of buffers\n"
+" ${plugin[weechat_plugins].name}: name of first plugin in linked list of "
+"plugins\n"
+"For name of hdata and variables, please look at \"Plugin API reference\", "
+"function \"weechat_hdata_get\".\n"
+"\n"
+"Examples:\n"
+" /eval -n ${weechat.look.scroll_amount} ==> 3\n"
+" /eval -n ${window} ==> 0x2549aa0\n"
+" /eval -n ${window.buffer} ==> 0x2549320\n"
+" /eval -n ${window.buffer.full_name} ==> core.weechat\n"
+" /eval -n ${window.buffer.number} ==> 1\n"
+" /eval -n ${window.buffer.number} > 2 ==> 0\n"
+" /eval -n ${window.win_width} > 100 ==> 1\n"
+" /eval -n (8 > 12) || (5 > 2) ==> 1\n"
+" /eval -n (8 > 12) && (5 > 2) ==> 0\n"
+" /eval -n abcd =~ ^ABC ==> 1\n"
+" /eval -n abcd =~ (?-i)^ABC ==> 0\n"
+" /eval -n abcd =~ (?-i)^abc ==> 1\n"
+" /eval -n abcd !~ abc ==> 0"
+msgstr ""
+
msgid ""
"filter messages in buffers, to hide/show them according to tags or regex"
msgstr ""
@@ -2348,6 +2424,11 @@ msgstr "alias para el color"
msgid "%sError: palette option must be numeric"
msgstr "%sError: el valor de la paleta debe ser un número"
+#, fuzzy, c-format
+msgid "%sWarning: unknown option for section \"%s\": %s (value: \"%s\")"
+msgstr ""
+"%sAtención: %s, línea %d: opción desconocida para la sección \"%s\": %s"
+
msgid "Notify level for buffer"
msgstr "Nivel de notificación para el buffer"
@@ -3559,13 +3640,12 @@ msgid "bar type (root, window, window_active, window_inactive)"
msgstr "tipo de barra (root, window, window_active, window_inactive)"
msgid ""
-"condition(s) for displaying bar (for bars of type \"window\"): \"active\" = "
-"window must be active, \"inactive\" = window must be inactive, \"nicklist\" "
-"= buffer must have a nicklist"
+"condition(s) for displaying bar (for bars of type \"window\"): a simple "
+"condition: \"active\", \"inactive\", \"nicklist\" (window must be active/"
+"inactive, buffer must have a nicklist), or an expression with condition(s) "
+"(see /help eval), like: \"${nicklist} && ${window.win_width} > 100\" (local "
+"variables for expression are ${active}, ${inactive} and ${nicklist})"
msgstr ""
-"condicion(es) para mostrar barras del tipo \"window\": \"active\" = la "
-"ventana debe estar activa, \"inactive\" = la ventana deber estar inactiva, "
-"\"nicklist\" = buffer debe tener una lista de apodos"
msgid "bar position (bottom, top, left, right)"
msgstr "posición de la barra (bottom, top, left, right)"
@@ -9404,6 +9484,15 @@ msgid "Constants"
msgstr "Constantes"
#~ msgid ""
+#~ "condition(s) for displaying bar (for bars of type \"window\"): \"active\" "
+#~ "= window must be active, \"inactive\" = window must be inactive, "
+#~ "\"nicklist\" = buffer must have a nicklist"
+#~ msgstr ""
+#~ "condicion(es) para mostrar barras del tipo \"window\": \"active\" = la "
+#~ "ventana debe estar activa, \"inactive\" = la ventana deber estar "
+#~ "inactiva, \"nicklist\" = buffer debe tener una lista de apodos"
+
+#~ msgid ""
#~ "server: server name\n"
#~ " nick: nick (may be a mask)"
#~ msgstr ""
diff --git a/po/fr.po b/po/fr.po
index 00e424d2d..dbdbd5e00 100644
--- a/po/fr.po
+++ b/po/fr.po
@@ -21,8 +21,8 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.4.0-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
-"POT-Creation-Date: 2012-10-20 17:54+0200\n"
-"PO-Revision-Date: 2012-10-20 17:54+0200\n"
+"POT-Creation-Date: 2012-11-02 08:59+0100\n"
+"PO-Revision-Date: 2012-10-27 12:51+0200\n"
"Last-Translator: Sebastien Helleu <flashcode@flashtux.org>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
"Language: French\n"
@@ -252,6 +252,13 @@ msgstr "Le contenu brut des tampons a été écrit dans le fichier de log"
msgid "Debug disabled for \"%s\""
msgstr "Debug désactivé pour \"%s\""
+msgid "error"
+msgstr "erreur"
+
+#, c-format
+msgid "%sError in expression to evaluate"
+msgstr "%sErreur dans l'expression à évaluer"
+
#, c-format
msgid " %s[%s%s%s]%s buffer: %s%s%s / tags: %s / regex: %s %s"
msgstr " %s[%s%s%s]%s tampon: %s%s%s / tags: %s / regex: %s %s"
@@ -838,15 +845,15 @@ msgid "manage bars"
msgstr "gestion des barres"
msgid ""
-"list|listfull|listitems || add <name> <type>[,<cond1>[,<cond2>...]] "
-"<position> <size> <separator> <item1>[,<item2>...] || default [input|title|"
-"status|nicklist] || del <name>|-all || set <name> <option> <value> || hide|"
-"show|toggle <name> || scroll <name> <window> <scroll_value>"
+"list|listfull|listitems || add <name> <type>[,<condition>] <position> <size> "
+"<separator> <item1>[,<item2>...] || default [input|title|status|nicklist] || "
+"del <name>|-all || set <name> <option> <value> || hide|show|toggle <name> || "
+"scroll <name> <window> <scroll_value>"
msgstr ""
-"list|listfull|listitems || add <nom> <type>[,<cond1>[,<cond2>...]] "
-"<position> <taille> <séparateur> <objet1>[,<objet2>...] || default [input|"
-"title|status|nicklist] || del <nom>|-all || set <nom> <option> <valeur> || "
-"hide|show|toggle <nom> || scroll <nom> <fenêtre> <valeur_scroll>"
+"list|listfull|listitems || add <nom> <type>[,<conditions>] <position> "
+"<taille> <séparateur> <objet1>[,<objet2>...] || default [input|title|status|"
+"nicklist] || del <nom>|-all || set <nom> <option> <valeur> || hide|show|"
+"toggle <nom> || scroll <nom> <fenêtre> <valeur_scroll>"
msgid ""
" list: list all bars\n"
@@ -856,11 +863,13 @@ msgid ""
" name: name of bar (must be unique)\n"
" type: root: outside windows,\n"
" window: inside windows, with optional conditions (see below)\n"
-" cond1,...: condition(s) for displaying bar (only for type \"window\"):\n"
+" condition: condition(s) for displaying bar (only for type \"window\"):\n"
" active: on active window\n"
" inactive: on inactive windows\n"
" nicklist: on windows with nicklist\n"
-" without condition, bar is always displayed\n"
+" other condition: see /help weechat.bar.xxx.conditions and /"
+"help eval\n"
+" without condition, the bar is always displayed\n"
" position: bottom, top, left or right\n"
" size: size of bar (in chars)\n"
" separator: 1 for using separator (line), 0 or nothing means no "
@@ -902,11 +911,13 @@ msgstr ""
" type: root: en dehors des fenêtres\n"
" window: dans les fenêtres, avec condition(s) optionnelle(s) "
"(voir ci-dessous)\n"
-" cond1,...: condition(s) pour afficher cette barre (seulement pour le "
+" condition: condition(s) pour afficher cette barre (seulement pour le "
"type \"window\"):\n"
" active: sur la fenêtre active\n"
" inactive: sur les fenêtres inactives\n"
" nicklist: sur les fenêtres avec liste de pseudos\n"
+" autre condition: voir /help weechat.bar.xxx.conditions et /"
+"help eval\n"
" sans condition, la barre est toujours affichée\n"
" position: bottom (bas), top (haut), left (gauche) ou right (droite)\n"
" taille: taille de la barre (en caractères)\n"
@@ -1216,6 +1227,130 @@ msgstr ""
" term: afficher des infos sur le terminal\n"
" windows: afficher l'arbre des fenêtres"
+msgid "evaluate expression and send result to buffer"
+msgstr "évaluer une expression et envoyer le résultat au tampon"
+
+msgid "[-n] <expression> || [-n] <expression1> <operator> <expression2>"
+msgstr "[-n] <expression> || [-n] <expression1> <opérateur> <expression2>"
+
+msgid ""
+" -n: display result without sending it to buffer (debug mode)\n"
+"expression: expression to evaluate, variables with format ${variable} are "
+"replaced (see below)\n"
+" operator: a logical or comparison operator:\n"
+" - logical operators:\n"
+" && boolean \"and\"\n"
+" || boolean \"or\"\n"
+" - comparison operators:\n"
+" == equal\n"
+" != not equal\n"
+" <= less or equal\n"
+" < less\n"
+" >= greater or equal\n"
+" > greater\n"
+" =~ is matching regex\n"
+" !~ is NOT matching regex\n"
+"\n"
+"An expression is considered as \"true\" if it is not NULL, not empty, and "
+"different from \"0\".\n"
+"The comparison is made using integers if the two expressions are valid "
+"integers.\n"
+"To force a string comparison, add double quotes around each expression, for "
+"example:\n"
+" 50 > 100 ==> 0\n"
+" \"50\" > \"100\" ==> 1\n"
+"\n"
+"Some variables are replaced in expression, using the format ${variable}, "
+"variable can be, by order of prioity :\n"
+" 1. the name of an option (file.section.option)\n"
+" 2. a hdata name/variable (the value is automatically converted to string), "
+"by default \"window\" and \"buffer\" point to current window/buffer.\n"
+"Format for hdata can be one of following:\n"
+" hdata.var1.var2...: start with a hdata (pointer must be known), and ask "
+"variables one after one (other hdata can be followed)\n"
+" hdata(list).var1.var2...: start with a hdata using a list, for example:\n"
+" ${buffer[gui_buffers].full_name}: full name of first buffer in linked "
+"list of buffers\n"
+" ${plugin[weechat_plugins].name}: name of first plugin in linked list of "
+"plugins\n"
+"For name of hdata and variables, please look at \"Plugin API reference\", "
+"function \"weechat_hdata_get\".\n"
+"\n"
+"Examples:\n"
+" /eval -n ${weechat.look.scroll_amount} ==> 3\n"
+" /eval -n ${window} ==> 0x2549aa0\n"
+" /eval -n ${window.buffer} ==> 0x2549320\n"
+" /eval -n ${window.buffer.full_name} ==> core.weechat\n"
+" /eval -n ${window.buffer.number} ==> 1\n"
+" /eval -n ${window.buffer.number} > 2 ==> 0\n"
+" /eval -n ${window.win_width} > 100 ==> 1\n"
+" /eval -n (8 > 12) || (5 > 2) ==> 1\n"
+" /eval -n (8 > 12) && (5 > 2) ==> 0\n"
+" /eval -n abcd =~ ^ABC ==> 1\n"
+" /eval -n abcd =~ (?-i)^ABC ==> 0\n"
+" /eval -n abcd =~ (?-i)^abc ==> 1\n"
+" /eval -n abcd !~ abc ==> 0"
+msgstr ""
+" -n: afficher le résultat sans envoyer au tampon (mode debug)\n"
+"expression: expression à évaluer, les variables avec le format ${variable} "
+"sont remplacées (voir ci-dessous)\n"
+" opérateur: un opérateur logique ou de comparaison :\n"
+" - opérateurs logiques :\n"
+" && \"et\" booléen\n"
+" || \"ou\" booléen\n"
+" - opérateurs de comparaison :\n"
+" == égal\n"
+" != non égal\n"
+" <= inférieur ou égal\n"
+" < inférieur\n"
+" >= supérieur ou égal\n"
+" > supérieur\n"
+" =~ correspond à l'expression régulière\n"
+" !~ ne correspond PAS à l'expression régulière\n"
+"\n"
+"Une expression est considérée comme \"vraie\" si elle est non NULL, non "
+"vide, et différente de \"0\".\n"
+"La comparaison est faite en utilisant des entiers si les deux expressions "
+"sont des entiers valides.\n"
+"Pour forcer une comparaison de chaînes, ajoutez des guillemets autour de "
+"chaque expression, par exemple :\n"
+" 50 > 100 ==> 0\n"
+" \"50\" > \"100\" ==> 1\n"
+"\n"
+"Des variables sont remplacées dans l'expression, en utilisant le format "
+"${variable}, la variable pouvant être, par ordre de priorité :\n"
+" 1. le nom d'une option (fichier.section.option)\n"
+" 2. le nom d'un hdata/variable (la valeur est automatiquement convertie en "
+"chaîne), par défaut \"window\" et \"buffer\" pointent vers la fenêtre et le "
+"tampon courants.\n"
+"Le format du hdata peut être le suivant :\n"
+" hdata.var1.var2...: démarrer avec un hdata (le pointeur doit être connu), "
+"et demander les variables l'une après l'autre (d'autres hdata peuvent être "
+"suivis)\n"
+" hdata(list).var1.var2...: démarrer avec un hdata en utlisant une liste, "
+"par exemple :\n"
+" ${buffer[gui_buffers].full_name}: nom complet du premier tampon dans la "
+"liste chaînée des tampons\n"
+" ${plugin[weechat_plugins].name}: nom de la première extension dans la "
+"liste chaînée des extensions\n"
+"Pour le nom du hdata et des variables, voir la \"Référence API extension\", "
+"fonction \"weechat_hdata_get\".\n"
+"\n"
+"Exemples:\n"
+" /eval -n ${weechat.look.scroll_amount} ==> 3\n"
+" /eval -n ${window} ==> 0x2549aa0\n"
+" /eval -n ${window.buffer} ==> 0x2549320\n"
+" /eval -n ${window.buffer.full_name} ==> core.weechat\n"
+" /eval -n ${window.buffer.number} ==> 1\n"
+" /eval -n ${window.buffer.number} > 2 ==> 0\n"
+" /eval -n ${window.win_width} > 100 ==> 1\n"
+" /eval -n (8 > 12) || (5 > 2) ==> 1\n"
+" /eval -n (8 > 12) && (5 > 2) ==> 0\n"
+" /eval -n abcd =~ ^ABC ==> 1\n"
+" /eval -n abcd =~ (?-i)^ABC ==> 0\n"
+" /eval -n abcd =~ (?-i)^abc ==> 1\n"
+" /eval -n abcd !~ abc ==> 0"
+
msgid ""
"filter messages in buffers, to hide/show them according to tags or regex"
msgstr ""
@@ -2365,6 +2500,11 @@ msgstr "alias pour la couleur"
msgid "%sError: palette option must be numeric"
msgstr "%sErreur: l'option de palette doit être numérique"
+#, c-format
+msgid "%sWarning: unknown option for section \"%s\": %s (value: \"%s\")"
+msgstr ""
+"%sAttention: option inconnue pour la section \"%s\": %s (valeur: \"%s\")"
+
msgid "Notify level for buffer"
msgstr "Niveau de notification pour le tampon"
@@ -3617,13 +3757,18 @@ msgid "bar type (root, window, window_active, window_inactive)"
msgstr "type de barre (root, window, window_active, window_inactive)"
msgid ""
-"condition(s) for displaying bar (for bars of type \"window\"): \"active\" = "
-"window must be active, \"inactive\" = window must be inactive, \"nicklist\" "
-"= buffer must have a nicklist"
+"condition(s) for displaying bar (for bars of type \"window\"): a simple "
+"condition: \"active\", \"inactive\", \"nicklist\" (window must be active/"
+"inactive, buffer must have a nicklist), or an expression with condition(s) "
+"(see /help eval), like: \"${nicklist} && ${window.win_width} > 100\" (local "
+"variables for expression are ${active}, ${inactive} and ${nicklist})"
msgstr ""
"condition(s) pour afficher la barre (pour les barres de type \"window\"): "
-"\"active\" = la fenêtre doit être active, \"inactive\" = la fenêtre doit "
-"être inactive, \"nicklist\" = le tampon doit avoir une liste de pseudos"
+"une simple condition: \"active\", \"inactive\", \"nicklist\" (la fenêtre "
+"doit être active/inactive, le tampon doit avoir une liste de pseudos), ou "
+"une expression avec condition(s) (voir /help eval), comme: \"${nicklist} && "
+"${window.win_width} > 100\" (les variables locales pour l'expression sont "
+"${active}, ${inactive} et ${nicklist})"
msgid "bar position (bottom, top, left, right)"
msgstr ""
@@ -9613,6 +9758,15 @@ msgid "Constants"
msgstr "Constantes"
#~ msgid ""
+#~ "condition(s) for displaying bar (for bars of type \"window\"): \"active\" "
+#~ "= window must be active, \"inactive\" = window must be inactive, "
+#~ "\"nicklist\" = buffer must have a nicklist"
+#~ msgstr ""
+#~ "condition(s) pour afficher la barre (pour les barres de type \"window\"): "
+#~ "\"active\" = la fenêtre doit être active, \"inactive\" = la fenêtre doit "
+#~ "être inactive, \"nicklist\" = le tampon doit avoir une liste de pseudos"
+
+#~ msgid ""
#~ "server: server name\n"
#~ " nick: nick (may be a mask)"
#~ msgstr ""
diff --git a/po/hu.po b/po/hu.po
index d895a5f03..20a95a5ce 100644
--- a/po/hu.po
+++ b/po/hu.po
@@ -20,7 +20,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.4.0-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
-"POT-Creation-Date: 2012-10-20 17:54+0200\n"
+"POT-Creation-Date: 2012-11-02 08:59+0100\n"
"PO-Revision-Date: 2012-09-29 11:42+0200\n"
"Last-Translator: Andras Voroskoi <voroskoi@frugalware.org>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -250,6 +250,13 @@ msgstr ""
msgid "Debug disabled for \"%s\""
msgstr ""
+msgid "error"
+msgstr ""
+
+#, c-format
+msgid "%sError in expression to evaluate"
+msgstr ""
+
#, fuzzy, c-format
msgid " %s[%s%s%s]%s buffer: %s%s%s / tags: %s / regex: %s %s"
msgstr " (nincs üzenetkezelő)\n"
@@ -873,10 +880,10 @@ msgid "manage bars"
msgstr "pufferek kezelése"
msgid ""
-"list|listfull|listitems || add <name> <type>[,<cond1>[,<cond2>...]] "
-"<position> <size> <separator> <item1>[,<item2>...] || default [input|title|"
-"status|nicklist] || del <name>|-all || set <name> <option> <value> || hide|"
-"show|toggle <name> || scroll <name> <window> <scroll_value>"
+"list|listfull|listitems || add <name> <type>[,<condition>] <position> <size> "
+"<separator> <item1>[,<item2>...] || default [input|title|status|nicklist] || "
+"del <name>|-all || set <name> <option> <value> || hide|show|toggle <name> || "
+"scroll <name> <window> <scroll_value>"
msgstr ""
msgid ""
@@ -887,11 +894,13 @@ msgid ""
" name: name of bar (must be unique)\n"
" type: root: outside windows,\n"
" window: inside windows, with optional conditions (see below)\n"
-" cond1,...: condition(s) for displaying bar (only for type \"window\"):\n"
+" condition: condition(s) for displaying bar (only for type \"window\"):\n"
" active: on active window\n"
" inactive: on inactive windows\n"
" nicklist: on windows with nicklist\n"
-" without condition, bar is always displayed\n"
+" other condition: see /help weechat.bar.xxx.conditions and /"
+"help eval\n"
+" without condition, the bar is always displayed\n"
" position: bottom, top, left or right\n"
" size: size of bar (in chars)\n"
" separator: 1 for using separator (line), 0 or nothing means no "
@@ -1120,6 +1129,71 @@ msgstr ""
" buffer: hexadecimális puffertartalom logba írása\n"
"windows: ablakfa megjelenítése"
+msgid "evaluate expression and send result to buffer"
+msgstr ""
+
+msgid "[-n] <expression> || [-n] <expression1> <operator> <expression2>"
+msgstr ""
+
+msgid ""
+" -n: display result without sending it to buffer (debug mode)\n"
+"expression: expression to evaluate, variables with format ${variable} are "
+"replaced (see below)\n"
+" operator: a logical or comparison operator:\n"
+" - logical operators:\n"
+" && boolean \"and\"\n"
+" || boolean \"or\"\n"
+" - comparison operators:\n"
+" == equal\n"
+" != not equal\n"
+" <= less or equal\n"
+" < less\n"
+" >= greater or equal\n"
+" > greater\n"
+" =~ is matching regex\n"
+" !~ is NOT matching regex\n"
+"\n"
+"An expression is considered as \"true\" if it is not NULL, not empty, and "
+"different from \"0\".\n"
+"The comparison is made using integers if the two expressions are valid "
+"integers.\n"
+"To force a string comparison, add double quotes around each expression, for "
+"example:\n"
+" 50 > 100 ==> 0\n"
+" \"50\" > \"100\" ==> 1\n"
+"\n"
+"Some variables are replaced in expression, using the format ${variable}, "
+"variable can be, by order of prioity :\n"
+" 1. the name of an option (file.section.option)\n"
+" 2. a hdata name/variable (the value is automatically converted to string), "
+"by default \"window\" and \"buffer\" point to current window/buffer.\n"
+"Format for hdata can be one of following:\n"
+" hdata.var1.var2...: start with a hdata (pointer must be known), and ask "
+"variables one after one (other hdata can be followed)\n"
+" hdata(list).var1.var2...: start with a hdata using a list, for example:\n"
+" ${buffer[gui_buffers].full_name}: full name of first buffer in linked "
+"list of buffers\n"
+" ${plugin[weechat_plugins].name}: name of first plugin in linked list of "
+"plugins\n"
+"For name of hdata and variables, please look at \"Plugin API reference\", "
+"function \"weechat_hdata_get\".\n"
+"\n"
+"Examples:\n"
+" /eval -n ${weechat.look.scroll_amount} ==> 3\n"
+" /eval -n ${window} ==> 0x2549aa0\n"
+" /eval -n ${window.buffer} ==> 0x2549320\n"
+" /eval -n ${window.buffer.full_name} ==> core.weechat\n"
+" /eval -n ${window.buffer.number} ==> 1\n"
+" /eval -n ${window.buffer.number} > 2 ==> 0\n"
+" /eval -n ${window.win_width} > 100 ==> 1\n"
+" /eval -n (8 > 12) || (5 > 2) ==> 1\n"
+" /eval -n (8 > 12) && (5 > 2) ==> 0\n"
+" /eval -n abcd =~ ^ABC ==> 1\n"
+" /eval -n abcd =~ (?-i)^ABC ==> 0\n"
+" /eval -n abcd =~ (?-i)^abc ==> 1\n"
+" /eval -n abcd !~ abc ==> 0"
+msgstr ""
+
msgid ""
"filter messages in buffers, to hide/show them according to tags or regex"
msgstr ""
@@ -1919,6 +1993,10 @@ msgstr ""
msgid "%sError: palette option must be numeric"
msgstr "%s nem sikerült a modul opciókat elmenteni\n"
+#, fuzzy, c-format
+msgid "%sWarning: unknown option for section \"%s\": %s (value: \"%s\")"
+msgstr "%s %s, %d. sor: ismeretlen csoportazonosító (\"%s\")\n"
+
#, fuzzy
msgid "Notify level for buffer"
msgstr "szobanév nem található a pufferhez"
@@ -3029,9 +3107,11 @@ msgid "bar type (root, window, window_active, window_inactive)"
msgstr ""
msgid ""
-"condition(s) for displaying bar (for bars of type \"window\"): \"active\" = "
-"window must be active, \"inactive\" = window must be inactive, \"nicklist\" "
-"= buffer must have a nicklist"
+"condition(s) for displaying bar (for bars of type \"window\"): a simple "
+"condition: \"active\", \"inactive\", \"nicklist\" (window must be active/"
+"inactive, buffer must have a nicklist), or an expression with condition(s) "
+"(see /help eval), like: \"${nicklist} && ${window.win_width} > 100\" (local "
+"variables for expression are ${active}, ${inactive} and ${nicklist})"
msgstr ""
#, fuzzy
diff --git a/po/it.po b/po/it.po
index 515a0e6b1..bc3556fa3 100644
--- a/po/it.po
+++ b/po/it.po
@@ -20,7 +20,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.4.0-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
-"POT-Creation-Date: 2012-10-20 17:54+0200\n"
+"POT-Creation-Date: 2012-11-02 08:59+0100\n"
"PO-Revision-Date: 2012-09-29 11:42+0200\n"
"Last-Translator: Marco Paolone <marcopaolone@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -249,6 +249,13 @@ msgstr "Il contenuto raw dei buffer è stato salvato sul file di log"
msgid "Debug disabled for \"%s\""
msgstr "Debug disabilitato per \"%s\""
+msgid "error"
+msgstr ""
+
+#, c-format
+msgid "%sError in expression to evaluate"
+msgstr ""
+
#, c-format
msgid " %s[%s%s%s]%s buffer: %s%s%s / tags: %s / regex: %s %s"
msgstr " %s[%s%s%s]%s buffer: %s%s%s / tag: %s /regex: %s %s"
@@ -831,17 +838,19 @@ msgstr ""
msgid "manage bars"
msgstr "gestione delle barre"
+#, fuzzy
msgid ""
-"list|listfull|listitems || add <name> <type>[,<cond1>[,<cond2>...]] "
-"<position> <size> <separator> <item1>[,<item2>...] || default [input|title|"
-"status|nicklist] || del <name>|-all || set <name> <option> <value> || hide|"
-"show|toggle <name> || scroll <name> <window> <scroll_value>"
+"list|listfull|listitems || add <name> <type>[,<condition>] <position> <size> "
+"<separator> <item1>[,<item2>...] || default [input|title|status|nicklist] || "
+"del <name>|-all || set <name> <option> <value> || hide|show|toggle <name> || "
+"scroll <name> <window> <scroll_value>"
msgstr ""
"list|listfull|listitems || add <nome> <tipo>[,<cond1>[,<cond2>...]] "
"<posizione> <dimensione> <separatore> <item1>[,<item2>...] || default [input|"
"title|status|nicklist] || del <nome>|-all || set <nome> <opzione> <valore> "
"|| hide|show|toggle <nome> || scroll <nome> <finestra> <scroll_value>"
+#, fuzzy
msgid ""
" list: list all bars\n"
" listfull: list all bars (verbose)\n"
@@ -850,11 +859,13 @@ msgid ""
" name: name of bar (must be unique)\n"
" type: root: outside windows,\n"
" window: inside windows, with optional conditions (see below)\n"
-" cond1,...: condition(s) for displaying bar (only for type \"window\"):\n"
+" condition: condition(s) for displaying bar (only for type \"window\"):\n"
" active: on active window\n"
" inactive: on inactive windows\n"
" nicklist: on windows with nicklist\n"
-" without condition, bar is always displayed\n"
+" other condition: see /help weechat.bar.xxx.conditions and /"
+"help eval\n"
+" without condition, the bar is always displayed\n"
" position: bottom, top, left or right\n"
" size: size of bar (in chars)\n"
" separator: 1 for using separator (line), 0 or nothing means no "
@@ -1205,6 +1216,71 @@ msgstr ""
" term: mostra informazioni sul terminale\n"
" windows: mostra l'albero delle finestre"
+msgid "evaluate expression and send result to buffer"
+msgstr ""
+
+msgid "[-n] <expression> || [-n] <expression1> <operator> <expression2>"
+msgstr ""
+
+msgid ""
+" -n: display result without sending it to buffer (debug mode)\n"
+"expression: expression to evaluate, variables with format ${variable} are "
+"replaced (see below)\n"
+" operator: a logical or comparison operator:\n"
+" - logical operators:\n"
+" && boolean \"and\"\n"
+" || boolean \"or\"\n"
+" - comparison operators:\n"
+" == equal\n"
+" != not equal\n"
+" <= less or equal\n"
+" < less\n"
+" >= greater or equal\n"
+" > greater\n"
+" =~ is matching regex\n"
+" !~ is NOT matching regex\n"
+"\n"
+"An expression is considered as \"true\" if it is not NULL, not empty, and "
+"different from \"0\".\n"
+"The comparison is made using integers if the two expressions are valid "
+"integers.\n"
+"To force a string comparison, add double quotes around each expression, for "
+"example:\n"
+" 50 > 100 ==> 0\n"
+" \"50\" > \"100\" ==> 1\n"
+"\n"
+"Some variables are replaced in expression, using the format ${variable}, "
+"variable can be, by order of prioity :\n"
+" 1. the name of an option (file.section.option)\n"
+" 2. a hdata name/variable (the value is automatically converted to string), "
+"by default \"window\" and \"buffer\" point to current window/buffer.\n"
+"Format for hdata can be one of following:\n"
+" hdata.var1.var2...: start with a hdata (pointer must be known), and ask "
+"variables one after one (other hdata can be followed)\n"
+" hdata(list).var1.var2...: start with a hdata using a list, for example:\n"
+" ${buffer[gui_buffers].full_name}: full name of first buffer in linked "
+"list of buffers\n"
+" ${plugin[weechat_plugins].name}: name of first plugin in linked list of "
+"plugins\n"
+"For name of hdata and variables, please look at \"Plugin API reference\", "
+"function \"weechat_hdata_get\".\n"
+"\n"
+"Examples:\n"
+" /eval -n ${weechat.look.scroll_amount} ==> 3\n"
+" /eval -n ${window} ==> 0x2549aa0\n"
+" /eval -n ${window.buffer} ==> 0x2549320\n"
+" /eval -n ${window.buffer.full_name} ==> core.weechat\n"
+" /eval -n ${window.buffer.number} ==> 1\n"
+" /eval -n ${window.buffer.number} > 2 ==> 0\n"
+" /eval -n ${window.win_width} > 100 ==> 1\n"
+" /eval -n (8 > 12) || (5 > 2) ==> 1\n"
+" /eval -n (8 > 12) && (5 > 2) ==> 0\n"
+" /eval -n abcd =~ ^ABC ==> 1\n"
+" /eval -n abcd =~ (?-i)^ABC ==> 0\n"
+" /eval -n abcd =~ (?-i)^abc ==> 1\n"
+" /eval -n abcd !~ abc ==> 0"
+msgstr ""
+
msgid ""
"filter messages in buffers, to hide/show them according to tags or regex"
msgstr ""
@@ -2334,6 +2410,11 @@ msgstr "alias per il colore"
msgid "%sError: palette option must be numeric"
msgstr "%sErrore: l'opzione per la tavolozza deve essere numerica"
+#, fuzzy, c-format
+msgid "%sWarning: unknown option for section \"%s\": %s (value: \"%s\")"
+msgstr ""
+"%sAttenzione: %s, riga %d: opzione sconosciuta per la sezione \"%s\": %s"
+
msgid "Notify level for buffer"
msgstr "Livello di notifica per il buffer"
@@ -3543,13 +3624,12 @@ msgid "bar type (root, window, window_active, window_inactive)"
msgstr "tipo di barra (root, window, window_active, window_inactive)"
msgid ""
-"condition(s) for displaying bar (for bars of type \"window\"): \"active\" = "
-"window must be active, \"inactive\" = window must be inactive, \"nicklist\" "
-"= buffer must have a nicklist"
+"condition(s) for displaying bar (for bars of type \"window\"): a simple "
+"condition: \"active\", \"inactive\", \"nicklist\" (window must be active/"
+"inactive, buffer must have a nicklist), or an expression with condition(s) "
+"(see /help eval), like: \"${nicklist} && ${window.win_width} > 100\" (local "
+"variables for expression are ${active}, ${inactive} and ${nicklist})"
msgstr ""
-"condizioni per mostrare la barra (per le barre di tipo \"window\"): \"active"
-"\"= la finestra deve essere attiva, \"inactive\" = la finestra deve essere "
-"inattiva, \"nicklist\" = il buffer deve avere una lista nick"
msgid "bar position (bottom, top, left, right)"
msgstr ""
@@ -9390,6 +9470,15 @@ msgid "Constants"
msgstr "Costanti"
#~ msgid ""
+#~ "condition(s) for displaying bar (for bars of type \"window\"): \"active\" "
+#~ "= window must be active, \"inactive\" = window must be inactive, "
+#~ "\"nicklist\" = buffer must have a nicklist"
+#~ msgstr ""
+#~ "condizioni per mostrare la barra (per le barre di tipo \"window\"): "
+#~ "\"active\"= la finestra deve essere attiva, \"inactive\" = la finestra "
+#~ "deve essere inattiva, \"nicklist\" = il buffer deve avere una lista nick"
+
+#~ msgid ""
#~ "server: server name\n"
#~ " nick: nick (may be a mask)"
#~ msgstr ""
diff --git a/po/ja.po b/po/ja.po
index b13cd0789..d13a6f67c 100644
--- a/po/ja.po
+++ b/po/ja.po
@@ -20,7 +20,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.4.0-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
-"POT-Creation-Date: 2012-10-20 17:54+0200\n"
+"POT-Creation-Date: 2012-11-02 08:59+0100\n"
"PO-Revision-Date: 2012-09-29 11:42+0200\n"
"Last-Translator: AYANOKOUZI, Ryuunosuke <i38w7i3@yahoo.co.jp>\n"
"Language-Team: Japanese <https://github.com/l/WeeChat>\n"
@@ -249,6 +249,13 @@ msgstr "バッファの生データがログファイルに書き込まれまし
msgid "Debug disabled for \"%s\""
msgstr "\"%s\" に対するデバッグが無効になりました"
+msgid "error"
+msgstr ""
+
+#, c-format
+msgid "%sError in expression to evaluate"
+msgstr ""
+
#, c-format
msgid " %s[%s%s%s]%s buffer: %s%s%s / tags: %s / regex: %s %s"
msgstr " %s[%s%s%s]%s バッファ: %s%s%s / タグ: %s / 正規表現: %s %s"
@@ -825,17 +832,19 @@ msgstr ""
msgid "manage bars"
msgstr "バーの管理"
+#, fuzzy
msgid ""
-"list|listfull|listitems || add <name> <type>[,<cond1>[,<cond2>...]] "
-"<position> <size> <separator> <item1>[,<item2>...] || default [input|title|"
-"status|nicklist] || del <name>|-all || set <name> <option> <value> || hide|"
-"show|toggle <name> || scroll <name> <window> <scroll_value>"
+"list|listfull|listitems || add <name> <type>[,<condition>] <position> <size> "
+"<separator> <item1>[,<item2>...] || default [input|title|status|nicklist] || "
+"del <name>|-all || set <name> <option> <value> || hide|show|toggle <name> || "
+"scroll <name> <window> <scroll_value>"
msgstr ""
"list|listfull|listitems || add <name> <type>[,<cond1>[,<cond2>...]] "
"<position> <size> <separator> <item1>[,<item2>...] || default [input|title|"
"status|nicklist] || del <name>|-all || set <name> <option> <value> || hide|"
"show|toggle <name> || scroll <name> <window> <scroll_value>"
+#, fuzzy
msgid ""
" list: list all bars\n"
" listfull: list all bars (verbose)\n"
@@ -844,11 +853,13 @@ msgid ""
" name: name of bar (must be unique)\n"
" type: root: outside windows,\n"
" window: inside windows, with optional conditions (see below)\n"
-" cond1,...: condition(s) for displaying bar (only for type \"window\"):\n"
+" condition: condition(s) for displaying bar (only for type \"window\"):\n"
" active: on active window\n"
" inactive: on inactive windows\n"
" nicklist: on windows with nicklist\n"
-" without condition, bar is always displayed\n"
+" other condition: see /help weechat.bar.xxx.conditions and /"
+"help eval\n"
+" without condition, the bar is always displayed\n"
" position: bottom, top, left or right\n"
" size: size of bar (in chars)\n"
" separator: 1 for using separator (line), 0 or nothing means no "
@@ -1191,6 +1202,71 @@ msgstr ""
" term: ターミナルに関する情報を表示\n"
" windows: ウィンドウツリーの情報を表示"
+msgid "evaluate expression and send result to buffer"
+msgstr ""
+
+msgid "[-n] <expression> || [-n] <expression1> <operator> <expression2>"
+msgstr ""
+
+msgid ""
+" -n: display result without sending it to buffer (debug mode)\n"
+"expression: expression to evaluate, variables with format ${variable} are "
+"replaced (see below)\n"
+" operator: a logical or comparison operator:\n"
+" - logical operators:\n"
+" && boolean \"and\"\n"
+" || boolean \"or\"\n"
+" - comparison operators:\n"
+" == equal\n"
+" != not equal\n"
+" <= less or equal\n"
+" < less\n"
+" >= greater or equal\n"
+" > greater\n"
+" =~ is matching regex\n"
+" !~ is NOT matching regex\n"
+"\n"
+"An expression is considered as \"true\" if it is not NULL, not empty, and "
+"different from \"0\".\n"
+"The comparison is made using integers if the two expressions are valid "
+"integers.\n"
+"To force a string comparison, add double quotes around each expression, for "
+"example:\n"
+" 50 > 100 ==> 0\n"
+" \"50\" > \"100\" ==> 1\n"
+"\n"
+"Some variables are replaced in expression, using the format ${variable}, "
+"variable can be, by order of prioity :\n"
+" 1. the name of an option (file.section.option)\n"
+" 2. a hdata name/variable (the value is automatically converted to string), "
+"by default \"window\" and \"buffer\" point to current window/buffer.\n"
+"Format for hdata can be one of following:\n"
+" hdata.var1.var2...: start with a hdata (pointer must be known), and ask "
+"variables one after one (other hdata can be followed)\n"
+" hdata(list).var1.var2...: start with a hdata using a list, for example:\n"
+" ${buffer[gui_buffers].full_name}: full name of first buffer in linked "
+"list of buffers\n"
+" ${plugin[weechat_plugins].name}: name of first plugin in linked list of "
+"plugins\n"
+"For name of hdata and variables, please look at \"Plugin API reference\", "
+"function \"weechat_hdata_get\".\n"
+"\n"
+"Examples:\n"
+" /eval -n ${weechat.look.scroll_amount} ==> 3\n"
+" /eval -n ${window} ==> 0x2549aa0\n"
+" /eval -n ${window.buffer} ==> 0x2549320\n"
+" /eval -n ${window.buffer.full_name} ==> core.weechat\n"
+" /eval -n ${window.buffer.number} ==> 1\n"
+" /eval -n ${window.buffer.number} > 2 ==> 0\n"
+" /eval -n ${window.win_width} > 100 ==> 1\n"
+" /eval -n (8 > 12) || (5 > 2) ==> 1\n"
+" /eval -n (8 > 12) && (5 > 2) ==> 0\n"
+" /eval -n abcd =~ ^ABC ==> 1\n"
+" /eval -n abcd =~ (?-i)^ABC ==> 0\n"
+" /eval -n abcd =~ (?-i)^abc ==> 1\n"
+" /eval -n abcd !~ abc ==> 0"
+msgstr ""
+
msgid ""
"filter messages in buffers, to hide/show them according to tags or regex"
msgstr "タグか正規表現に基づくバッファメッセージの非表示/表示"
@@ -2302,6 +2378,10 @@ msgstr "色の別名"
msgid "%sError: palette option must be numeric"
msgstr "%sエラー: パレットオプションは数字でなければいけません"
+#, fuzzy, c-format
+msgid "%sWarning: unknown option for section \"%s\": %s (value: \"%s\")"
+msgstr "%s警告: %s、行 %d: セクション \"%s\" の無効なオプション: %s"
+
msgid "Notify level for buffer"
msgstr "バッファの通知レベル"
@@ -3466,13 +3546,12 @@ msgid "bar type (root, window, window_active, window_inactive)"
msgstr "バー型 (root、window、window_active、window_inactive)"
msgid ""
-"condition(s) for displaying bar (for bars of type \"window\"): \"active\" = "
-"window must be active, \"inactive\" = window must be inactive, \"nicklist\" "
-"= buffer must have a nicklist"
+"condition(s) for displaying bar (for bars of type \"window\"): a simple "
+"condition: \"active\", \"inactive\", \"nicklist\" (window must be active/"
+"inactive, buffer must have a nicklist), or an expression with condition(s) "
+"(see /help eval), like: \"${nicklist} && ${window.win_width} > 100\" (local "
+"variables for expression are ${active}, ${inactive} and ${nicklist})"
msgstr ""
-"バー表示状態 (\"window\" 型のバー): \"active\" = ウィンドウはアクティブ状"
-"態、\"inactive\" = ウィンドウはインアクティブ状態、\"nicklist\" = バッファは"
-"ニックネームリストを持つ"
msgid "bar position (bottom, top, left, right)"
msgstr "バー位置 (下、上、左、右)"
@@ -9258,6 +9337,15 @@ msgid "Constants"
msgstr "定数"
#~ msgid ""
+#~ "condition(s) for displaying bar (for bars of type \"window\"): \"active\" "
+#~ "= window must be active, \"inactive\" = window must be inactive, "
+#~ "\"nicklist\" = buffer must have a nicklist"
+#~ msgstr ""
+#~ "バー表示状態 (\"window\" 型のバー): \"active\" = ウィンドウはアクティブ状"
+#~ "態、\"inactive\" = ウィンドウはインアクティブ状態、\"nicklist\" = バッファ"
+#~ "はニックネームリストを持つ"
+
+#~ msgid ""
#~ "server: server name\n"
#~ " nick: nick (may be a mask)"
#~ msgstr ""
diff --git a/po/pl.po b/po/pl.po
index 05d959c11..df21e7917 100644
--- a/po/pl.po
+++ b/po/pl.po
@@ -21,7 +21,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.4.0-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
-"POT-Creation-Date: 2012-10-20 17:54+0200\n"
+"POT-Creation-Date: 2012-11-02 08:59+0100\n"
"PO-Revision-Date: 2012-09-29 11:42+0200\n"
"Last-Translator: Krzysztof Korościk <soltys@szluug.org>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -251,6 +251,13 @@ msgstr "Surowa zawartość bufora została zapisana do pliku z logiem"
msgid "Debug disabled for \"%s\""
msgstr "Debugowanie wyłączone dla\"%s\""
+msgid "error"
+msgstr ""
+
+#, c-format
+msgid "%sError in expression to evaluate"
+msgstr ""
+
#, c-format
msgid " %s[%s%s%s]%s buffer: %s%s%s / tags: %s / regex: %s %s"
msgstr " %s[%s%s%s]%s bufor: %s%s%s / tagi: %s / wyrażenie: %s %s"
@@ -844,17 +851,19 @@ msgstr ""
msgid "manage bars"
msgstr "zarządzaj paskami"
+#, fuzzy
msgid ""
-"list|listfull|listitems || add <name> <type>[,<cond1>[,<cond2>...]] "
-"<position> <size> <separator> <item1>[,<item2>...] || default [input|title|"
-"status|nicklist] || del <name>|-all || set <name> <option> <value> || hide|"
-"show|toggle <name> || scroll <name> <window> <scroll_value>"
+"list|listfull|listitems || add <name> <type>[,<condition>] <position> <size> "
+"<separator> <item1>[,<item2>...] || default [input|title|status|nicklist] || "
+"del <name>|-all || set <name> <option> <value> || hide|show|toggle <name> || "
+"scroll <name> <window> <scroll_value>"
msgstr ""
"list|listfull|listitems || add <nazwa> <typ>[,<warunek1>[,<warunek2>...]] "
"<pozycja> <rozmiar> <separator> <element1>[,<element2>...] || default [input|"
"title|status|nicklist] || del <nazwa>|-all || set <nazwa> <opcja> <wartość> "
"|| hide|show|toggle <nazwa> || scroll <nazwa> <okno> <wartość_przewinięcia>"
+#, fuzzy
msgid ""
" list: list all bars\n"
" listfull: list all bars (verbose)\n"
@@ -863,11 +872,13 @@ msgid ""
" name: name of bar (must be unique)\n"
" type: root: outside windows,\n"
" window: inside windows, with optional conditions (see below)\n"
-" cond1,...: condition(s) for displaying bar (only for type \"window\"):\n"
+" condition: condition(s) for displaying bar (only for type \"window\"):\n"
" active: on active window\n"
" inactive: on inactive windows\n"
" nicklist: on windows with nicklist\n"
-" without condition, bar is always displayed\n"
+" other condition: see /help weechat.bar.xxx.conditions and /"
+"help eval\n"
+" without condition, the bar is always displayed\n"
" position: bottom, top, left or right\n"
" size: size of bar (in chars)\n"
" separator: 1 for using separator (line), 0 or nothing means no "
@@ -1212,6 +1223,71 @@ msgstr ""
" term: wyświetla informacje o terminalu\n"
" windows: wyświetla drzewo okien"
+msgid "evaluate expression and send result to buffer"
+msgstr ""
+
+msgid "[-n] <expression> || [-n] <expression1> <operator> <expression2>"
+msgstr ""
+
+msgid ""
+" -n: display result without sending it to buffer (debug mode)\n"
+"expression: expression to evaluate, variables with format ${variable} are "
+"replaced (see below)\n"
+" operator: a logical or comparison operator:\n"
+" - logical operators:\n"
+" && boolean \"and\"\n"
+" || boolean \"or\"\n"
+" - comparison operators:\n"
+" == equal\n"
+" != not equal\n"
+" <= less or equal\n"
+" < less\n"
+" >= greater or equal\n"
+" > greater\n"
+" =~ is matching regex\n"
+" !~ is NOT matching regex\n"
+"\n"
+"An expression is considered as \"true\" if it is not NULL, not empty, and "
+"different from \"0\".\n"
+"The comparison is made using integers if the two expressions are valid "
+"integers.\n"
+"To force a string comparison, add double quotes around each expression, for "
+"example:\n"
+" 50 > 100 ==> 0\n"
+" \"50\" > \"100\" ==> 1\n"
+"\n"
+"Some variables are replaced in expression, using the format ${variable}, "
+"variable can be, by order of prioity :\n"
+" 1. the name of an option (file.section.option)\n"
+" 2. a hdata name/variable (the value is automatically converted to string), "
+"by default \"window\" and \"buffer\" point to current window/buffer.\n"
+"Format for hdata can be one of following:\n"
+" hdata.var1.var2...: start with a hdata (pointer must be known), and ask "
+"variables one after one (other hdata can be followed)\n"
+" hdata(list).var1.var2...: start with a hdata using a list, for example:\n"
+" ${buffer[gui_buffers].full_name}: full name of first buffer in linked "
+"list of buffers\n"
+" ${plugin[weechat_plugins].name}: name of first plugin in linked list of "
+"plugins\n"
+"For name of hdata and variables, please look at \"Plugin API reference\", "
+"function \"weechat_hdata_get\".\n"
+"\n"
+"Examples:\n"
+" /eval -n ${weechat.look.scroll_amount} ==> 3\n"
+" /eval -n ${window} ==> 0x2549aa0\n"
+" /eval -n ${window.buffer} ==> 0x2549320\n"
+" /eval -n ${window.buffer.full_name} ==> core.weechat\n"
+" /eval -n ${window.buffer.number} ==> 1\n"
+" /eval -n ${window.buffer.number} > 2 ==> 0\n"
+" /eval -n ${window.win_width} > 100 ==> 1\n"
+" /eval -n (8 > 12) || (5 > 2) ==> 1\n"
+" /eval -n (8 > 12) && (5 > 2) ==> 0\n"
+" /eval -n abcd =~ ^ABC ==> 1\n"
+" /eval -n abcd =~ (?-i)^ABC ==> 0\n"
+" /eval -n abcd =~ (?-i)^abc ==> 1\n"
+" /eval -n abcd !~ abc ==> 0"
+msgstr ""
+
msgid ""
"filter messages in buffers, to hide/show them according to tags or regex"
msgstr ""
@@ -2341,6 +2417,10 @@ msgstr "alias dla kolorów"
msgid "%sError: palette option must be numeric"
msgstr "%sBłąd: opcja palety musi być numerem"
+#, fuzzy, c-format
+msgid "%sWarning: unknown option for section \"%s\": %s (value: \"%s\")"
+msgstr "%sOstrzeżenie: %s, linia %d: nieznana opcja dla sekcji \"%s\": %s"
+
msgid "Notify level for buffer"
msgstr "Poziom powiadomień dla buforu"
@@ -3540,13 +3620,12 @@ msgid "bar type (root, window, window_active, window_inactive)"
msgstr "typ paska (root, window, window_active, window_inactive)"
msgid ""
-"condition(s) for displaying bar (for bars of type \"window\"): \"active\" = "
-"window must be active, \"inactive\" = window must be inactive, \"nicklist\" "
-"= buffer must have a nicklist"
+"condition(s) for displaying bar (for bars of type \"window\"): a simple "
+"condition: \"active\", \"inactive\", \"nicklist\" (window must be active/"
+"inactive, buffer must have a nicklist), or an expression with condition(s) "
+"(see /help eval), like: \"${nicklist} && ${window.win_width} > 100\" (local "
+"variables for expression are ${active}, ${inactive} and ${nicklist})"
msgstr ""
-"warunek(-ki) wyświetlania paska (dla pasków typu \"window\"): \"active\" = "
-"okno musi być aktywne, \"inactive\" = okno musi być nieaktywne, \"nicklist\" "
-"= bufor musi posiadać listę nicków"
msgid "bar position (bottom, top, left, right)"
msgstr "pozycja paska (bottom (dół), top (góra), left (lewo), right (prawo))"
@@ -9320,6 +9399,15 @@ msgid "Constants"
msgstr "Stałe"
#~ msgid ""
+#~ "condition(s) for displaying bar (for bars of type \"window\"): \"active\" "
+#~ "= window must be active, \"inactive\" = window must be inactive, "
+#~ "\"nicklist\" = buffer must have a nicklist"
+#~ msgstr ""
+#~ "warunek(-ki) wyświetlania paska (dla pasków typu \"window\"): \"active\" "
+#~ "= okno musi być aktywne, \"inactive\" = okno musi być nieaktywne, "
+#~ "\"nicklist\" = bufor musi posiadać listę nicków"
+
+#~ msgid ""
#~ "server: server name\n"
#~ " nick: nick (may be a mask)"
#~ msgstr ""
diff --git a/po/pt_BR.po b/po/pt_BR.po
index 37975e015..1c66c5ef6 100644
--- a/po/pt_BR.po
+++ b/po/pt_BR.po
@@ -21,7 +21,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.4.0-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
-"POT-Creation-Date: 2012-10-20 17:54+0200\n"
+"POT-Creation-Date: 2012-11-02 08:59+0100\n"
"PO-Revision-Date: 2012-09-29 11:43+0200\n"
"Last-Translator: Sergio Durigan Junior <sergiosdj@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -273,6 +273,13 @@ msgstr "Conteúdo bruto dos buffers foi escrito no arquivo de log"
msgid "Debug disabled for \"%s\""
msgstr "Depuração desabilitada para \"%s\""
+msgid "error"
+msgstr ""
+
+#, c-format
+msgid "%sError in expression to evaluate"
+msgstr ""
+
#, c-format
msgid " %s[%s%s%s]%s buffer: %s%s%s / tags: %s / regex: %s %s"
msgstr ""
@@ -868,11 +875,12 @@ msgstr ""
msgid "manage bars"
msgstr "gerenciar barras"
+#, fuzzy
msgid ""
-"list|listfull|listitems || add <name> <type>[,<cond1>[,<cond2>...]] "
-"<position> <size> <separator> <item1>[,<item2>...] || default [input|title|"
-"status|nicklist] || del <name>|-all || set <name> <option> <value> || hide|"
-"show|toggle <name> || scroll <name> <window> <scroll_value>"
+"list|listfull|listitems || add <name> <type>[,<condition>] <position> <size> "
+"<separator> <item1>[,<item2>...] || default [input|title|status|nicklist] || "
+"del <name>|-all || set <name> <option> <value> || hide|show|toggle <name> || "
+"scroll <name> <window> <scroll_value>"
msgstr ""
"list|listfull|listitems || add <nome> <tipo>[,<cond1>[,<cond2>...]] "
"<posição> <tamanho> <separador> <item1>[,<item2>...] || default [input|title|"
@@ -881,6 +889,7 @@ msgstr ""
# in the option "position", the parameters must be passes in english, but the
# options were translated (inside parentesis) to become clearer
+#, fuzzy
msgid ""
" list: list all bars\n"
" listfull: list all bars (verbose)\n"
@@ -889,11 +898,13 @@ msgid ""
" name: name of bar (must be unique)\n"
" type: root: outside windows,\n"
" window: inside windows, with optional conditions (see below)\n"
-" cond1,...: condition(s) for displaying bar (only for type \"window\"):\n"
+" condition: condition(s) for displaying bar (only for type \"window\"):\n"
" active: on active window\n"
" inactive: on inactive windows\n"
" nicklist: on windows with nicklist\n"
-" without condition, bar is always displayed\n"
+" other condition: see /help weechat.bar.xxx.conditions and /"
+"help eval\n"
+" without condition, the bar is always displayed\n"
" position: bottom, top, left or right\n"
" size: size of bar (in chars)\n"
" separator: 1 for using separator (line), 0 or nothing means no "
@@ -1247,6 +1258,71 @@ msgstr ""
" term: exibe informações sobre o terminal\n"
" windows: exibe árvore de janelas"
+msgid "evaluate expression and send result to buffer"
+msgstr ""
+
+msgid "[-n] <expression> || [-n] <expression1> <operator> <expression2>"
+msgstr ""
+
+msgid ""
+" -n: display result without sending it to buffer (debug mode)\n"
+"expression: expression to evaluate, variables with format ${variable} are "
+"replaced (see below)\n"
+" operator: a logical or comparison operator:\n"
+" - logical operators:\n"
+" && boolean \"and\"\n"
+" || boolean \"or\"\n"
+" - comparison operators:\n"
+" == equal\n"
+" != not equal\n"
+" <= less or equal\n"
+" < less\n"
+" >= greater or equal\n"
+" > greater\n"
+" =~ is matching regex\n"
+" !~ is NOT matching regex\n"
+"\n"
+"An expression is considered as \"true\" if it is not NULL, not empty, and "
+"different from \"0\".\n"
+"The comparison is made using integers if the two expressions are valid "
+"integers.\n"
+"To force a string comparison, add double quotes around each expression, for "
+"example:\n"
+" 50 > 100 ==> 0\n"
+" \"50\" > \"100\" ==> 1\n"
+"\n"
+"Some variables are replaced in expression, using the format ${variable}, "
+"variable can be, by order of prioity :\n"
+" 1. the name of an option (file.section.option)\n"
+" 2. a hdata name/variable (the value is automatically converted to string), "
+"by default \"window\" and \"buffer\" point to current window/buffer.\n"
+"Format for hdata can be one of following:\n"
+" hdata.var1.var2...: start with a hdata (pointer must be known), and ask "
+"variables one after one (other hdata can be followed)\n"
+" hdata(list).var1.var2...: start with a hdata using a list, for example:\n"
+" ${buffer[gui_buffers].full_name}: full name of first buffer in linked "
+"list of buffers\n"
+" ${plugin[weechat_plugins].name}: name of first plugin in linked list of "
+"plugins\n"
+"For name of hdata and variables, please look at \"Plugin API reference\", "
+"function \"weechat_hdata_get\".\n"
+"\n"
+"Examples:\n"
+" /eval -n ${weechat.look.scroll_amount} ==> 3\n"
+" /eval -n ${window} ==> 0x2549aa0\n"
+" /eval -n ${window.buffer} ==> 0x2549320\n"
+" /eval -n ${window.buffer.full_name} ==> core.weechat\n"
+" /eval -n ${window.buffer.number} ==> 1\n"
+" /eval -n ${window.buffer.number} > 2 ==> 0\n"
+" /eval -n ${window.win_width} > 100 ==> 1\n"
+" /eval -n (8 > 12) || (5 > 2) ==> 1\n"
+" /eval -n (8 > 12) && (5 > 2) ==> 0\n"
+" /eval -n abcd =~ ^ABC ==> 1\n"
+" /eval -n abcd =~ (?-i)^ABC ==> 0\n"
+" /eval -n abcd =~ (?-i)^abc ==> 1\n"
+" /eval -n abcd !~ abc ==> 0"
+msgstr ""
+
msgid ""
"filter messages in buffers, to hide/show them according to tags or regex"
msgstr ""
@@ -2299,6 +2375,10 @@ msgstr "apelido para cor"
msgid "%sError: palette option must be numeric"
msgstr "%sErro: opção da palheta deve ser numérica"
+#, fuzzy, c-format
+msgid "%sWarning: unknown option for section \"%s\": %s (value: \"%s\")"
+msgstr "%sAviso: %s, linha %d: opção \"%s\" desconhecido para seção \"%s\""
+
msgid "Notify level for buffer"
msgstr "Nível de notificação para o buffer"
@@ -3455,13 +3535,12 @@ msgid "bar type (root, window, window_active, window_inactive)"
msgstr "tipo da barra (root, window, window_active, window_inactive)"
msgid ""
-"condition(s) for displaying bar (for bars of type \"window\"): \"active\" = "
-"window must be active, \"inactive\" = window must be inactive, \"nicklist\" "
-"= buffer must have a nicklist"
+"condition(s) for displaying bar (for bars of type \"window\"): a simple "
+"condition: \"active\", \"inactive\", \"nicklist\" (window must be active/"
+"inactive, buffer must have a nicklist), or an expression with condition(s) "
+"(see /help eval), like: \"${nicklist} && ${window.win_width} > 100\" (local "
+"variables for expression are ${active}, ${inactive} and ${nicklist})"
msgstr ""
-"condição(ões) para exibição da barra (para barras do tipo \"window\"): "
-"\"active\" = janela deve estar ativa, \"inactive\" = janela deve estar "
-"inativa, \"nicklist\" = buffer deve possuir uma lista de apelidos"
msgid "bar position (bottom, top, left, right)"
msgstr ""
@@ -8760,6 +8839,15 @@ msgstr ""
msgid "Constants"
msgstr ""
+#~ msgid ""
+#~ "condition(s) for displaying bar (for bars of type \"window\"): \"active\" "
+#~ "= window must be active, \"inactive\" = window must be inactive, "
+#~ "\"nicklist\" = buffer must have a nicklist"
+#~ msgstr ""
+#~ "condição(ões) para exibição da barra (para barras do tipo \"window\"): "
+#~ "\"active\" = janela deve estar ativa, \"inactive\" = janela deve estar "
+#~ "inativa, \"nicklist\" = buffer deve possuir uma lista de apelidos"
+
#~ msgid "use IPv6 protocol for server communication"
#~ msgstr "usar protocolo IPv6 para comunicação com o servidor"
diff --git a/po/ru.po b/po/ru.po
index 8544373f6..eaa57a380 100644
--- a/po/ru.po
+++ b/po/ru.po
@@ -21,7 +21,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.4.0-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
-"POT-Creation-Date: 2012-10-20 17:54+0200\n"
+"POT-Creation-Date: 2012-11-02 08:59+0100\n"
"PO-Revision-Date: 2012-09-29 11:43+0200\n"
"Last-Translator: Aleksey V Zapparov AKA ixti <ixti@member.fsf.org>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -254,6 +254,13 @@ msgstr "Содержимое буфера записано в файл журн
msgid "Debug disabled for \"%s\""
msgstr "Отладка отключена для \"%s\""
+msgid "error"
+msgstr ""
+
+#, c-format
+msgid "%sError in expression to evaluate"
+msgstr ""
+
#, fuzzy, c-format
msgid " %s[%s%s%s]%s buffer: %s%s%s / tags: %s / regex: %s %s"
msgstr " (нет обработчика сообщений)\n"
@@ -890,10 +897,10 @@ msgid "manage bars"
msgstr "управление буферами"
msgid ""
-"list|listfull|listitems || add <name> <type>[,<cond1>[,<cond2>...]] "
-"<position> <size> <separator> <item1>[,<item2>...] || default [input|title|"
-"status|nicklist] || del <name>|-all || set <name> <option> <value> || hide|"
-"show|toggle <name> || scroll <name> <window> <scroll_value>"
+"list|listfull|listitems || add <name> <type>[,<condition>] <position> <size> "
+"<separator> <item1>[,<item2>...] || default [input|title|status|nicklist] || "
+"del <name>|-all || set <name> <option> <value> || hide|show|toggle <name> || "
+"scroll <name> <window> <scroll_value>"
msgstr ""
msgid ""
@@ -904,11 +911,13 @@ msgid ""
" name: name of bar (must be unique)\n"
" type: root: outside windows,\n"
" window: inside windows, with optional conditions (see below)\n"
-" cond1,...: condition(s) for displaying bar (only for type \"window\"):\n"
+" condition: condition(s) for displaying bar (only for type \"window\"):\n"
" active: on active window\n"
" inactive: on inactive windows\n"
" nicklist: on windows with nicklist\n"
-" without condition, bar is always displayed\n"
+" other condition: see /help weechat.bar.xxx.conditions and /"
+"help eval\n"
+" without condition, the bar is always displayed\n"
" position: bottom, top, left or right\n"
" size: size of bar (in chars)\n"
" separator: 1 for using separator (line), 0 or nothing means no "
@@ -1138,6 +1147,71 @@ msgstr ""
"файл\n"
"windows: отобразить дерево окон"
+msgid "evaluate expression and send result to buffer"
+msgstr ""
+
+msgid "[-n] <expression> || [-n] <expression1> <operator> <expression2>"
+msgstr ""
+
+msgid ""
+" -n: display result without sending it to buffer (debug mode)\n"
+"expression: expression to evaluate, variables with format ${variable} are "
+"replaced (see below)\n"
+" operator: a logical or comparison operator:\n"
+" - logical operators:\n"
+" && boolean \"and\"\n"
+" || boolean \"or\"\n"
+" - comparison operators:\n"
+" == equal\n"
+" != not equal\n"
+" <= less or equal\n"
+" < less\n"
+" >= greater or equal\n"
+" > greater\n"
+" =~ is matching regex\n"
+" !~ is NOT matching regex\n"
+"\n"
+"An expression is considered as \"true\" if it is not NULL, not empty, and "
+"different from \"0\".\n"
+"The comparison is made using integers if the two expressions are valid "
+"integers.\n"
+"To force a string comparison, add double quotes around each expression, for "
+"example:\n"
+" 50 > 100 ==> 0\n"
+" \"50\" > \"100\" ==> 1\n"
+"\n"
+"Some variables are replaced in expression, using the format ${variable}, "
+"variable can be, by order of prioity :\n"
+" 1. the name of an option (file.section.option)\n"
+" 2. a hdata name/variable (the value is automatically converted to string), "
+"by default \"window\" and \"buffer\" point to current window/buffer.\n"
+"Format for hdata can be one of following:\n"
+" hdata.var1.var2...: start with a hdata (pointer must be known), and ask "
+"variables one after one (other hdata can be followed)\n"
+" hdata(list).var1.var2...: start with a hdata using a list, for example:\n"
+" ${buffer[gui_buffers].full_name}: full name of first buffer in linked "
+"list of buffers\n"
+" ${plugin[weechat_plugins].name}: name of first plugin in linked list of "
+"plugins\n"
+"For name of hdata and variables, please look at \"Plugin API reference\", "
+"function \"weechat_hdata_get\".\n"
+"\n"
+"Examples:\n"
+" /eval -n ${weechat.look.scroll_amount} ==> 3\n"
+" /eval -n ${window} ==> 0x2549aa0\n"
+" /eval -n ${window.buffer} ==> 0x2549320\n"
+" /eval -n ${window.buffer.full_name} ==> core.weechat\n"
+" /eval -n ${window.buffer.number} ==> 1\n"
+" /eval -n ${window.buffer.number} > 2 ==> 0\n"
+" /eval -n ${window.win_width} > 100 ==> 1\n"
+" /eval -n (8 > 12) || (5 > 2) ==> 1\n"
+" /eval -n (8 > 12) && (5 > 2) ==> 0\n"
+" /eval -n abcd =~ ^ABC ==> 1\n"
+" /eval -n abcd =~ (?-i)^ABC ==> 0\n"
+" /eval -n abcd =~ (?-i)^abc ==> 1\n"
+" /eval -n abcd !~ abc ==> 0"
+msgstr ""
+
msgid ""
"filter messages in buffers, to hide/show them according to tags or regex"
msgstr ""
@@ -1938,6 +2012,10 @@ msgstr ""
msgid "%sError: palette option must be numeric"
msgstr "%s не могу сохранить конфигурационный файл pluginов\n"
+#, fuzzy, c-format
+msgid "%sWarning: unknown option for section \"%s\": %s (value: \"%s\")"
+msgstr "%s %s, строка %d: неизвестный идентификатор секции (\"%s\")\n"
+
#, fuzzy
msgid "Notify level for buffer"
msgstr "не найдено имя канала для буфера"
@@ -3055,9 +3133,11 @@ msgid "bar type (root, window, window_active, window_inactive)"
msgstr ""
msgid ""
-"condition(s) for displaying bar (for bars of type \"window\"): \"active\" = "
-"window must be active, \"inactive\" = window must be inactive, \"nicklist\" "
-"= buffer must have a nicklist"
+"condition(s) for displaying bar (for bars of type \"window\"): a simple "
+"condition: \"active\", \"inactive\", \"nicklist\" (window must be active/"
+"inactive, buffer must have a nicklist), or an expression with condition(s) "
+"(see /help eval), like: \"${nicklist} && ${window.win_width} > 100\" (local "
+"variables for expression are ${active}, ${inactive} and ${nicklist})"
msgstr ""
#, fuzzy
diff --git a/po/srcfiles.cmake b/po/srcfiles.cmake
index be33e36da..fcbf7c67e 100644
--- a/po/srcfiles.cmake
+++ b/po/srcfiles.cmake
@@ -13,6 +13,8 @@ SET(WEECHAT_SOURCES
./src/core/wee-config.h
./src/core/wee-debug.c
./src/core/wee-debug.h
+./src/core/wee-eval.c
+./src/core/wee-eval.h
./src/core/wee-hook.c
./src/core/wee-hook.h
./src/core/wee-infolist.c
diff --git a/po/weechat.pot b/po/weechat.pot
index bd7bb605e..6e129f57a 100644
--- a/po/weechat.pot
+++ b/po/weechat.pot
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
-"POT-Creation-Date: 2012-10-20 17:54+0200\n"
+"POT-Creation-Date: 2012-11-02 08:59+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -212,6 +212,13 @@ msgstr ""
msgid "Debug disabled for \"%s\""
msgstr ""
+msgid "error"
+msgstr ""
+
+#, c-format
+msgid "%sError in expression to evaluate"
+msgstr ""
+
#, c-format
msgid " %s[%s%s%s]%s buffer: %s%s%s / tags: %s / regex: %s %s"
msgstr ""
@@ -771,10 +778,10 @@ msgid "manage bars"
msgstr ""
msgid ""
-"list|listfull|listitems || add <name> <type>[,<cond1>[,<cond2>...]] "
-"<position> <size> <separator> <item1>[,<item2>...] || default [input|title|"
-"status|nicklist] || del <name>|-all || set <name> <option> <value> || hide|"
-"show|toggle <name> || scroll <name> <window> <scroll_value>"
+"list|listfull|listitems || add <name> <type>[,<condition>] <position> <size> "
+"<separator> <item1>[,<item2>...] || default [input|title|status|nicklist] || "
+"del <name>|-all || set <name> <option> <value> || hide|show|toggle <name> || "
+"scroll <name> <window> <scroll_value>"
msgstr ""
msgid ""
@@ -785,11 +792,13 @@ msgid ""
" name: name of bar (must be unique)\n"
" type: root: outside windows,\n"
" window: inside windows, with optional conditions (see below)\n"
-" cond1,...: condition(s) for displaying bar (only for type \"window\"):\n"
+" condition: condition(s) for displaying bar (only for type \"window\"):\n"
" active: on active window\n"
" inactive: on inactive windows\n"
" nicklist: on windows with nicklist\n"
-" without condition, bar is always displayed\n"
+" other condition: see /help weechat.bar.xxx.conditions and /"
+"help eval\n"
+" without condition, the bar is always displayed\n"
" position: bottom, top, left or right\n"
" size: size of bar (in chars)\n"
" separator: 1 for using separator (line), 0 or nothing means no "
@@ -980,6 +989,71 @@ msgid ""
" windows: display windows tree"
msgstr ""
+msgid "evaluate expression and send result to buffer"
+msgstr ""
+
+msgid "[-n] <expression> || [-n] <expression1> <operator> <expression2>"
+msgstr ""
+
+msgid ""
+" -n: display result without sending it to buffer (debug mode)\n"
+"expression: expression to evaluate, variables with format ${variable} are "
+"replaced (see below)\n"
+" operator: a logical or comparison operator:\n"
+" - logical operators:\n"
+" && boolean \"and\"\n"
+" || boolean \"or\"\n"
+" - comparison operators:\n"
+" == equal\n"
+" != not equal\n"
+" <= less or equal\n"
+" < less\n"
+" >= greater or equal\n"
+" > greater\n"
+" =~ is matching regex\n"
+" !~ is NOT matching regex\n"
+"\n"
+"An expression is considered as \"true\" if it is not NULL, not empty, and "
+"different from \"0\".\n"
+"The comparison is made using integers if the two expressions are valid "
+"integers.\n"
+"To force a string comparison, add double quotes around each expression, for "
+"example:\n"
+" 50 > 100 ==> 0\n"
+" \"50\" > \"100\" ==> 1\n"
+"\n"
+"Some variables are replaced in expression, using the format ${variable}, "
+"variable can be, by order of prioity :\n"
+" 1. the name of an option (file.section.option)\n"
+" 2. a hdata name/variable (the value is automatically converted to string), "
+"by default \"window\" and \"buffer\" point to current window/buffer.\n"
+"Format for hdata can be one of following:\n"
+" hdata.var1.var2...: start with a hdata (pointer must be known), and ask "
+"variables one after one (other hdata can be followed)\n"
+" hdata(list).var1.var2...: start with a hdata using a list, for example:\n"
+" ${buffer[gui_buffers].full_name}: full name of first buffer in linked "
+"list of buffers\n"
+" ${plugin[weechat_plugins].name}: name of first plugin in linked list of "
+"plugins\n"
+"For name of hdata and variables, please look at \"Plugin API reference\", "
+"function \"weechat_hdata_get\".\n"
+"\n"
+"Examples:\n"
+" /eval -n ${weechat.look.scroll_amount} ==> 3\n"
+" /eval -n ${window} ==> 0x2549aa0\n"
+" /eval -n ${window.buffer} ==> 0x2549320\n"
+" /eval -n ${window.buffer.full_name} ==> core.weechat\n"
+" /eval -n ${window.buffer.number} ==> 1\n"
+" /eval -n ${window.buffer.number} > 2 ==> 0\n"
+" /eval -n ${window.win_width} > 100 ==> 1\n"
+" /eval -n (8 > 12) || (5 > 2) ==> 1\n"
+" /eval -n (8 > 12) && (5 > 2) ==> 0\n"
+" /eval -n abcd =~ ^ABC ==> 1\n"
+" /eval -n abcd =~ (?-i)^ABC ==> 0\n"
+" /eval -n abcd =~ (?-i)^abc ==> 1\n"
+" /eval -n abcd !~ abc ==> 0"
+msgstr ""
+
msgid ""
"filter messages in buffers, to hide/show them according to tags or regex"
msgstr ""
@@ -1683,6 +1757,10 @@ msgstr ""
msgid "%sError: palette option must be numeric"
msgstr ""
+#, c-format
+msgid "%sWarning: unknown option for section \"%s\": %s (value: \"%s\")"
+msgstr ""
+
msgid "Notify level for buffer"
msgstr ""
@@ -2664,9 +2742,11 @@ msgid "bar type (root, window, window_active, window_inactive)"
msgstr ""
msgid ""
-"condition(s) for displaying bar (for bars of type \"window\"): \"active\" = "
-"window must be active, \"inactive\" = window must be inactive, \"nicklist\" "
-"= buffer must have a nicklist"
+"condition(s) for displaying bar (for bars of type \"window\"): a simple "
+"condition: \"active\", \"inactive\", \"nicklist\" (window must be active/"
+"inactive, buffer must have a nicklist), or an expression with condition(s) "
+"(see /help eval), like: \"${nicklist} && ${window.win_width} > 100\" (local "
+"variables for expression are ${active}, ${inactive} and ${nicklist})"
msgstr ""
msgid "bar position (bottom, top, left, right)"
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt
index f5afb1803..984c5be15 100644
--- a/src/core/CMakeLists.txt
+++ b/src/core/CMakeLists.txt
@@ -27,6 +27,7 @@ wee-completion.c wee-completion.h
wee-config.c wee-config.h
wee-config-file.c wee-config-file.h
wee-debug.c wee-debug.h
+wee-eval.c wee-eval.h
wee-hashtable.c wee-hashtable.h
wee-hdata.c wee-hdata.h
wee-hook.c wee-hook.h
diff --git a/src/core/Makefile.am b/src/core/Makefile.am
index ae69f3ec0..6abf84b99 100644
--- a/src/core/Makefile.am
+++ b/src/core/Makefile.am
@@ -35,6 +35,8 @@ lib_weechat_core_a_SOURCES = weechat.c \
wee-config-file.h \
wee-debug.c \
wee-debug.h \
+ wee-eval.c \
+ wee-eval.h \
wee-hashtable.c \
wee-hashtable.h \
wee-hdata.c \
diff --git a/src/core/wee-command.c b/src/core/wee-command.c
index 99e26d7a4..c0fce2c86 100644
--- a/src/core/wee-command.c
+++ b/src/core/wee-command.c
@@ -39,6 +39,7 @@
#include "wee-config.h"
#include "wee-config-file.h"
#include "wee-debug.h"
+#include "wee-eval.h"
#include "wee-hashtable.h"
#include "wee-hdata.h"
#include "wee-hook.h"
@@ -1444,6 +1445,73 @@ COMMAND_CALLBACK(debug)
}
/*
+ * command_eval: evaluate expression and send result to buffer
+ */
+
+COMMAND_CALLBACK(eval)
+{
+ int print_only;
+ char *result, *ptr_args;
+
+ /* make C compiler happy */
+ (void) buffer;
+ (void) data;
+ (void) argv;
+
+ print_only = 0;
+
+ if (argc < 2)
+ return WEECHAT_RC_OK;
+
+ ptr_args = argv_eol[1];
+ if (string_strcasecmp (argv[1], "-n") == 0)
+ {
+ print_only = 1;
+ ptr_args = argv_eol[2];
+ }
+
+ if (ptr_args)
+ {
+ result = eval_expression (ptr_args, NULL, NULL);
+ if (print_only)
+ {
+ gui_chat_printf_date_tags (NULL, 0, "no_log", ">> %s", ptr_args);
+ if (result)
+ {
+ gui_chat_printf_date_tags (NULL, 0, "no_log", "== %s[%s%s%s]",
+ GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS),
+ GUI_COLOR(GUI_COLOR_CHAT),
+ result,
+ GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS));
+ }
+ else
+ {
+ gui_chat_printf_date_tags (NULL, 0, "no_log", "== %s<%s%s%s>",
+ GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS),
+ GUI_COLOR(GUI_COLOR_CHAT),
+ _("error"),
+ GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS));
+ }
+ }
+ else
+ {
+ if (result)
+ input_data (buffer, result);
+ else
+ {
+ gui_chat_printf (NULL,
+ _("%sError in expression to evaluate"),
+ gui_chat_prefix[GUI_CHAT_PREFIX_ERROR]);
+ }
+ }
+ if (result)
+ free (result);
+ }
+
+ return WEECHAT_RC_OK;
+}
+
+/*
* command_filter_display: display one filter
*/
@@ -5438,8 +5506,8 @@ command_init ()
hook_command (NULL, "bar",
N_("manage bars"),
N_("list|listfull|listitems"
- " || add <name> <type>[,<cond1>[,<cond2>...]] <position> "
- "<size> <separator> <item1>[,<item2>...]"
+ " || add <name> <type>[,<condition>] <position> <size> "
+ "<separator> <item1>[,<item2>...]"
" || default [input|title|status|nicklist]"
" || del <name>|-all"
" || set <name> <option> <value>"
@@ -5453,12 +5521,15 @@ command_init ()
" type: root: outside windows,\n"
" window: inside windows, with optional "
"conditions (see below)\n"
- " cond1,...: condition(s) for displaying bar (only for "
+ " condition: condition(s) for displaying bar (only for "
"type \"window\"):\n"
" active: on active window\n"
" inactive: on inactive windows\n"
" nicklist: on windows with nicklist\n"
- " without condition, bar is always displayed\n"
+ " other condition: see /help "
+ "weechat.bar.xxx.conditions and /help eval\n"
+ " without condition, the bar is always "
+ "displayed\n"
" position: bottom, top, left or right\n"
" size: size of bar (in chars)\n"
" separator: 1 for using separator (line), 0 or nothing "
@@ -5683,6 +5754,69 @@ command_init ()
" || term"
" || windows",
&command_debug, NULL);
+ hook_command (NULL, "eval",
+ N_("evaluate expression and send result to buffer"),
+ N_("[-n] <expression>"
+ " || [-n] <expression1> <operator> <expression2>"),
+ N_(" -n: display result without sending it to buffer "
+ "(debug mode)\n"
+ "expression: expression to evaluate, variables with format "
+ "${variable} are replaced (see below)\n"
+ " operator: a logical or comparison operator:\n"
+ " - logical operators:\n"
+ " && boolean \"and\"\n"
+ " || boolean \"or\"\n"
+ " - comparison operators:\n"
+ " == equal\n"
+ " != not equal\n"
+ " <= less or equal\n"
+ " < less\n"
+ " >= greater or equal\n"
+ " > greater\n"
+ " =~ is matching regex\n"
+ " !~ is NOT matching regex\n\n"
+ "An expression is considered as \"true\" if it is not NULL, "
+ "not empty, and different from \"0\".\n"
+ "The comparison is made using integers if the two "
+ "expressions are valid integers.\n"
+ "To force a string comparison, add double quotes around "
+ "each expression, for example:\n"
+ " 50 > 100 ==> 0\n"
+ " \"50\" > \"100\" ==> 1\n\n"
+ "Some variables are replaced in expression, using the "
+ "format ${variable}, variable can be, by order of prioity :\n"
+ " 1. the name of an option (file.section.option)\n"
+ " 2. a hdata name/variable (the value is automatically "
+ "converted to string), by default \"window\" and \"buffer\" "
+ "point to current window/buffer.\n"
+ "Format for hdata can be one of following:\n"
+ " hdata.var1.var2...: start with a hdata (pointer must be "
+ "known), and ask variables one after one (other hdata can "
+ "be followed)\n"
+ " hdata(list).var1.var2...: start with a hdata using a "
+ "list, for example:\n"
+ " ${buffer[gui_buffers].full_name}: full name of first "
+ "buffer in linked list of buffers\n"
+ " ${plugin[weechat_plugins].name}: name of first plugin "
+ "in linked list of plugins\n"
+ "For name of hdata and variables, please look at \"Plugin "
+ "API reference\", function \"weechat_hdata_get\".\n\n"
+ "Examples:\n"
+ " /eval -n ${weechat.look.scroll_amount} ==> 3\n"
+ " /eval -n ${window} ==> 0x2549aa0\n"
+ " /eval -n ${window.buffer} ==> 0x2549320\n"
+ " /eval -n ${window.buffer.full_name} ==> core.weechat\n"
+ " /eval -n ${window.buffer.number} ==> 1\n"
+ " /eval -n ${window.buffer.number} > 2 ==> 0\n"
+ " /eval -n ${window.win_width} > 100 ==> 1\n"
+ " /eval -n (8 > 12) || (5 > 2) ==> 1\n"
+ " /eval -n (8 > 12) && (5 > 2) ==> 0\n"
+ " /eval -n abcd =~ ^ABC ==> 1\n"
+ " /eval -n abcd =~ (?-i)^ABC ==> 0\n"
+ " /eval -n abcd =~ (?-i)^abc ==> 1\n"
+ " /eval -n abcd !~ abc ==> 0"),
+ "-n",
+ &command_eval, NULL);
hook_command (NULL, "filter",
N_("filter messages in buffers, to hide/show them according "
"to tags or regex"),
diff --git a/src/core/wee-config.c b/src/core/wee-config.c
index 7070fe75f..390a75ba6 100644
--- a/src/core/wee-config.c
+++ b/src/core/wee-config.c
@@ -1163,6 +1163,16 @@ config_weechat_proxy_read_cb (void *data, struct t_config_file *config_file,
proxy_create_option_temp (ptr_temp_proxy, index_option,
value);
}
+ else
+ {
+ gui_chat_printf (NULL,
+ _("%sWarning: unknown option for "
+ "section \"%s\": %s (value: \"%s\")"),
+ gui_chat_prefix[GUI_CHAT_PREFIX_ERROR],
+ section->name,
+ option_name,
+ value);
+ }
}
free (proxy_name);
@@ -1232,6 +1242,16 @@ config_weechat_bar_read_cb (void *data, struct t_config_file *config_file,
gui_bar_create_option_temp (ptr_temp_bar, index_option,
value);
}
+ else
+ {
+ gui_chat_printf (NULL,
+ _("%sWarning: unknown option for "
+ "section \"%s\": %s (value: \"%s\")"),
+ gui_chat_prefix[GUI_CHAT_PREFIX_ERROR],
+ section->name,
+ option_name,
+ value);
+ }
}
free (bar_name);
diff --git a/src/core/wee-eval.c b/src/core/wee-eval.c
new file mode 100644
index 000000000..45b2e1f01
--- /dev/null
+++ b/src/core/wee-eval.c
@@ -0,0 +1,717 @@
+/*
+ * Copyright (C) 2012 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/>.
+ */
+
+/*
+ * wee-eval.c: evaluate expressions with references to internal vars
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdlib.h>
+#include <string.h>
+#include <regex.h>
+
+#include "weechat.h"
+#include "wee-eval.h"
+#include "wee-config-file.h"
+#include "wee-hashtable.h"
+#include "wee-hdata.h"
+#include "wee-hook.h"
+#include "wee-string.h"
+#include "../gui/gui-color.h"
+#include "../gui/gui-window.h"
+#include "../plugins/plugin.h"
+
+
+char *logical_ops[EVAL_NUM_LOGICAL_OPS] = { "&&", "||" };
+char *comparisons[EVAL_NUM_COMPARISONS] = { "==", "!=", "<=", "<", ">=", ">",
+ "=~", "!~" };
+
+
+/*
+ * eval_is_true: return 1 if value is true, 0 otherwise
+ * A value is true if string is non-NULL, non-empty and different
+ * from "0".
+ */
+
+int
+eval_is_true (const char *value)
+{
+ return (value && value[0] && (strcmp (value, "0") != 0)) ? 1 : 0;
+}
+
+/*
+ * eval_hdata_get_value: get value of hdata using "path" to a variable
+ * Note: result must be freed after use
+ */
+
+char *
+eval_hdata_get_value (struct t_hdata *hdata, void *pointer, const char *path)
+{
+ char *value, *old_value, *var_name, str_value[128], *pos;
+ const char *ptr_value, *hdata_name;
+ int type;
+ struct t_hashtable *hashtable;
+
+ value = NULL;
+ var_name = NULL;
+
+ /* NULL pointer? return empty string */
+ if (!pointer)
+ return strdup ("");
+
+ /* no path? just return current pointer as string */
+ if (!path || !path[0])
+ {
+ snprintf (str_value, sizeof (str_value),
+ "0x%lx", (long unsigned int)pointer);
+ return strdup (str_value);
+ }
+
+ /*
+ * look for name of hdata, for example in "window.buffer.full_name", the
+ * hdata name is "window"
+ */
+ pos = strchr (path, '.');
+ if (pos > path)
+ var_name = string_strndup (path, pos - path);
+ else
+ var_name = strdup (path);
+
+ if (!var_name)
+ goto end;
+
+ /* search type of variable in hdata */
+ type = hdata_get_var_type (hdata, var_name);
+ if (type < 0)
+ goto end;
+
+ /* build a string with the value or variable */
+ switch (type)
+ {
+ case WEECHAT_HDATA_CHAR:
+ snprintf (str_value, sizeof (str_value),
+ "%c", hdata_char (hdata, pointer, var_name));
+ value = strdup (str_value);
+ break;
+ case WEECHAT_HDATA_INTEGER:
+ snprintf (str_value, sizeof (str_value),
+ "%d", hdata_integer (hdata, pointer, var_name));
+ value = strdup (str_value);
+ break;
+ case WEECHAT_HDATA_LONG:
+ snprintf (str_value, sizeof (str_value),
+ "%ld", hdata_long (hdata, pointer, var_name));
+ value = strdup (str_value);
+ break;
+ case WEECHAT_HDATA_STRING:
+ value = strdup (hdata_string (hdata, pointer, var_name));
+ break;
+ case WEECHAT_HDATA_POINTER:
+ pointer = hdata_pointer (hdata, pointer, var_name);
+ snprintf (str_value, sizeof (str_value),
+ "0x%lx", (long unsigned int)pointer);
+ value = strdup (str_value);
+ break;
+ case WEECHAT_HDATA_TIME:
+ snprintf (str_value, sizeof (str_value),
+ "%ld", hdata_time (hdata, pointer, var_name));
+ value = strdup (str_value);
+ break;
+ case WEECHAT_HDATA_HASHTABLE:
+ pointer = hdata_hashtable (hdata, pointer, var_name);
+ if (pos)
+ {
+ /*
+ * for a hashtable, if there is a "." after name of hdata,
+ * get the value for this key in hashtable
+ */
+ hashtable = pointer;
+ ptr_value = hashtable_get (hashtable, pos + 1);
+ if (ptr_value)
+ {
+ switch (hashtable->type_values)
+ {
+ case HASHTABLE_INTEGER:
+ snprintf (str_value, sizeof (str_value),
+ "%d", *((int *)ptr_value));
+ value = strdup (str_value);
+ break;
+ case HASHTABLE_STRING:
+ value = strdup (ptr_value);
+ break;
+ case HASHTABLE_POINTER:
+ case HASHTABLE_BUFFER:
+ snprintf (str_value, sizeof (str_value),
+ "0x%lx", (long unsigned int)ptr_value);
+ value = strdup (str_value);
+ break;
+ case HASHTABLE_TIME:
+ snprintf (str_value, sizeof (str_value),
+ "%ld", *((time_t *)ptr_value));
+ value = strdup (str_value);
+ break;
+ case HASHTABLE_NUM_TYPES:
+ break;
+ }
+ }
+ }
+ else
+ {
+ snprintf (str_value, sizeof (str_value),
+ "0x%lx", (long unsigned int)pointer);
+ value = strdup (str_value);
+ }
+ break;
+ }
+
+ /*
+ * if we are on a pointer and that something else is in path (after "."),
+ * go on with this pointer and remaining path
+ */
+ if ((type == WEECHAT_HDATA_POINTER) && pos)
+ {
+ hdata_name = hdata_get_var_hdata (hdata, var_name);
+ if (!hdata_name)
+ goto end;
+
+ hdata = hook_hdata_get (NULL, hdata_name);
+ old_value = value;
+ value = eval_hdata_get_value (hdata, pointer, (pos) ? pos + 1 : NULL);
+ if (old_value)
+ free (old_value);
+ }
+
+end:
+ if (var_name)
+ free (var_name);
+
+ return value;
+}
+
+/*
+ * eval_replace_vars_cb: callback to replace variables, which can be,
+ * by order of priority:
+ * 1. an extra variable (from hashtable "extra_vars")
+ * 2. an name of option (file.section.option)
+ * 3. a hdata name/variable
+ * Examples:
+ * option: ${weechat.look.scroll_amount}
+ * hdata : ${window.buffer.full_name}
+ * ${window.buffer.local_variables.type}
+ */
+
+char *
+eval_replace_vars_cb (void *data, const char *text)
+{
+ struct t_hashtable *pointers, *extra_vars;
+ struct t_config_option *ptr_option;
+ char str_value[64], *value, *pos, *pos1, *pos2, *hdata_name, *list_name;
+ char *tmp;
+ const char *ptr_value;
+ struct t_hdata *hdata;
+ void *pointer;
+
+ pointers = (struct t_hashtable *)(((void **)data)[0]);
+ extra_vars = (struct t_hashtable *)(((void **)data)[1]);
+
+ /* first look for var in hashtable "extra_vars" */
+ ptr_value = hashtable_get (extra_vars, text);
+ if (ptr_value)
+ return strdup (ptr_value);
+
+ /* look for name of option: if found, return this value */
+ config_file_search_with_string (text, NULL, NULL, &ptr_option, NULL);
+ if (ptr_option)
+ {
+ switch (ptr_option->type)
+ {
+ case CONFIG_OPTION_TYPE_BOOLEAN:
+ return strdup (CONFIG_BOOLEAN(ptr_option) ? EVAL_STR_TRUE : EVAL_STR_FALSE);
+ case CONFIG_OPTION_TYPE_INTEGER:
+ if (ptr_option->string_values)
+ return strdup (ptr_option->string_values[CONFIG_INTEGER(ptr_option)]);
+ snprintf (str_value, sizeof (str_value),
+ "%d", CONFIG_INTEGER(ptr_option));
+ return strdup (str_value);
+ case CONFIG_OPTION_TYPE_STRING:
+ return strdup (CONFIG_STRING(ptr_option));
+ case CONFIG_OPTION_TYPE_COLOR:
+ return strdup (gui_color_get_name (CONFIG_COLOR(ptr_option)));
+ case CONFIG_NUM_OPTION_TYPES:
+ return NULL;
+ }
+ }
+
+ /* look for hdata */
+ value = NULL;
+ hdata_name = NULL;
+ list_name = NULL;
+ pointer = NULL;
+
+ pos = strchr (text, '.');
+ if (pos > text)
+ hdata_name = string_strndup (text, pos - text);
+ else
+ hdata_name = strdup (text);
+
+ if (!hdata_name)
+ goto end;
+
+ pos1 = strchr (hdata_name, '[');
+ if (pos1 > hdata_name)
+ {
+ pos2 = strchr (pos1 + 1, ']');
+ if (pos2 > pos1 + 1)
+ {
+ list_name = string_strndup (pos1 + 1, pos2 - pos1 - 1);
+ }
+ tmp = string_strndup (hdata_name, pos1 - hdata_name);
+ if (tmp)
+ {
+ free (hdata_name);
+ hdata_name = tmp;
+ }
+ }
+
+ hdata = hook_hdata_get (NULL, hdata_name);
+ if (!hdata)
+ goto end;
+
+ if (list_name)
+ pointer = hdata_get_list (hdata, list_name);
+ if (!pointer)
+ {
+ pointer = hashtable_get (pointers, hdata_name);
+ if (!pointer)
+ goto end;
+ }
+
+ value = eval_hdata_get_value (hdata, pointer, (pos) ? pos + 1 : NULL);
+
+end:
+ if (hdata_name)
+ free (hdata_name);
+ if (list_name)
+ free (list_name);
+
+ return (value) ? value : strdup ("");
+}
+
+/*
+ * eval_replace_vars: replace variables in a string
+ */
+
+char *
+eval_replace_vars (const char *expr, struct t_hashtable *pointers,
+ struct t_hashtable *extra_vars)
+{
+ int errors;
+ void *ptr[2];
+
+ ptr[0] = pointers;
+ ptr[1] = extra_vars;
+
+ return string_replace_with_callback (expr,
+ &eval_replace_vars_cb,
+ ptr,
+ &errors);
+}
+
+/*
+ * eval_compare: compate two expressions
+ */
+
+char *
+eval_compare (const char *expr1, int comparison, const char *expr2)
+{
+ int rc, string_compare, length1, length2;
+ regex_t regex;
+ long value1, value2;
+ char *error;
+
+ rc = 0;
+ string_compare = 0;
+
+ if (!expr1 || !expr2)
+ goto end;
+
+ if ((comparison == EVAL_COMPARE_REGEX_MATCHING)
+ || (comparison == EVAL_COMPARE_REGEX_NOT_MATCHING))
+ {
+ if (string_regcomp (&regex, expr2,
+ REG_EXTENDED | REG_ICASE | REG_NOSUB) != 0)
+ {
+ goto end;
+ }
+ rc = (regexec (&regex, expr1, 0, NULL, 0) == 0) ? 1 : 0;
+ if (comparison == EVAL_COMPARE_REGEX_NOT_MATCHING)
+ rc ^= 1;
+ goto end;
+ }
+
+ length1 = strlen (expr1);
+ length2 = strlen (expr2);
+
+ /*
+ * string comparison is forced if expr1 and expr2 have double quotes at
+ * beginning/end
+ */
+ if (((length1 == 0) || ((expr1[0] == '"') && expr1[length1 - 1] == '"'))
+ && ((length2 == 0) || ((expr2[0] == '"') && expr2[length2 - 1] == '"')))
+ {
+ string_compare = 1;
+ }
+
+ if (!string_compare)
+ {
+ value1 = strtol (expr1, &error, 10);
+ if (!error || error[0])
+ string_compare = 1;
+ else
+ {
+ value2 = strtol (expr2, &error, 10);
+ if (!error || error[0])
+ string_compare = 1;
+ }
+ }
+
+ if (string_compare)
+ rc = strcmp (expr1, expr2);
+ else
+ rc = (value1 < value2) ? -1 : ((value1 > value2) ? 1 : 0);
+
+ switch (comparison)
+ {
+ case EVAL_COMPARE_EQUAL:
+ rc = (rc == 0);
+ break;
+ case EVAL_COMPARE_NOT_EQUAL:
+ rc = (rc != 0);
+ break;
+ case EVAL_COMPARE_LESS_EQUAL:
+ rc = (rc <= 0);
+ break;
+ case EVAL_COMPARE_LESS:
+ rc = (rc < 0);
+ break;
+ case EVAL_COMPARE_GREATER_EQUAL:
+ rc = (rc >= 0);
+ break;
+ case EVAL_COMPARE_GREATER:
+ rc = (rc > 0);
+ break;
+ case EVAL_NUM_COMPARISONS:
+ break;
+ }
+
+end:
+ return strdup ((rc) ? EVAL_STR_TRUE : EVAL_STR_FALSE);
+}
+
+/*
+ * eval_expression_internal: evaluate an expression and return a string with
+ * the result (see function eval_expression())
+ * (should not be called directly)
+ * Argument keep_parentheses is almost always 0,
+ * it is 1 only if the expression is a regex (to keep
+ * flags inside the parentheses)
+ */
+
+char *
+eval_expression_internal (const char *expr, struct t_hashtable *pointers,
+ struct t_hashtable *extra_vars,
+ int keep_parentheses)
+{
+ int logic, comp, length, level, rc;
+ const char *pos_end;
+ char *expr2, *sub_expr, *pos, *value, *tmp_value, *tmp_value2;
+
+ value = NULL;
+
+ if (!expr)
+ return NULL;
+
+ if (!expr[0])
+ return strdup (expr);
+
+ /*
+ * skip spaces at beginning of string
+ */
+ while (expr[0] == ' ')
+ {
+ expr++;
+ }
+ if (!expr[0])
+ return strdup (expr);
+
+ /* skip spaces at end of string */
+ pos_end = expr + strlen (expr) - 1;
+ while ((pos_end > expr) && (pos_end[0] == ' '))
+ {
+ pos_end--;
+ }
+
+ expr2 = string_strndup (expr, pos_end + 1 - expr);
+ if (!expr2)
+ return NULL;
+
+ /* evaluate sub-expression in parentheses and replace it with value */
+ if (!keep_parentheses)
+ {
+ while (expr2[0] == '(')
+ {
+ level = 0;
+ pos = expr2 + 1;
+ while (pos[0])
+ {
+ if (pos[0] == '(')
+ level++;
+ else if (pos[0] == ')')
+ {
+ if (level == 0)
+ break;
+ level--;
+ }
+ pos++;
+ }
+ /* closing parenthese not found */
+ if (pos[0] != ')')
+ goto end;
+ sub_expr = string_strndup (expr2 + 1, pos - expr2 - 1);
+ if (!sub_expr)
+ goto end;
+ tmp_value = eval_expression_internal (sub_expr, pointers, extra_vars, 0);
+ free (sub_expr);
+ if (!pos[1])
+ {
+ /* nothing after ')', then return value of sub-expression as-is */
+ value = tmp_value;
+ goto end;
+ }
+ length = ((tmp_value) ? strlen (tmp_value) : 0) + 1 + strlen (pos + 1) + 1;
+ tmp_value2 = malloc (length);
+ if (!tmp_value2)
+ goto end;
+ tmp_value2[0] = '\0';
+ if (tmp_value)
+ strcat (tmp_value2, tmp_value);
+ strcat (tmp_value2, " ");
+ strcat (tmp_value2, pos + 1);
+ free (expr2);
+ expr2 = tmp_value2;
+ }
+ }
+
+ /*
+ * search for a logical operator, and if one is found:
+ * - split expression into two sub-expressions
+ * - evaluate first sub-expression
+ * - if needed, evaluate second sub-expression
+ * - return result
+ */
+ for (logic = 0; logic < EVAL_NUM_LOGICAL_OPS; logic++)
+ {
+ pos = strstr (expr2, logical_ops[logic]);
+ if (pos > expr2)
+ {
+ pos_end = pos - 1;
+ while ((pos_end > expr2) && (pos_end[0] == ' '))
+ {
+ pos_end--;
+ }
+ sub_expr = string_strndup (expr2, pos_end + 1 - expr2);
+ if (!sub_expr)
+ goto end;
+ tmp_value = eval_expression_internal (sub_expr, pointers, extra_vars, 0);
+ free (sub_expr);
+ rc = eval_is_true (tmp_value);
+ /*
+ * if rc == 0 with "&&" or rc == 1 with "||", no need to evaluate
+ * second sub-expression, just return the rc
+ */
+ if ((!rc && (logic == EVAL_LOGICAL_OP_AND))
+ || (rc && (logic == EVAL_LOGICAL_OP_OR)))
+ {
+ if (tmp_value)
+ free (tmp_value);
+ value = strdup ((rc) ? EVAL_STR_TRUE : EVAL_STR_FALSE);
+ goto end;
+ }
+ pos += strlen (logical_ops[logic]);
+ while (pos[0] == ' ')
+ {
+ pos++;
+ }
+ tmp_value = eval_expression_internal (pos, pointers, extra_vars, 0);
+ rc = eval_is_true (tmp_value);
+ if (tmp_value)
+ free (tmp_value);
+ value = strdup ((rc) ? EVAL_STR_TRUE : EVAL_STR_FALSE);
+ goto end;
+ }
+ }
+
+ /*
+ * search for a comparison, and if one is found:
+ * - split expression into two sub-expressions
+ * - evaluate the two sub-expressions
+ * - compare sub-expressions
+ * - return result
+ */
+ for (comp = 0; comp < EVAL_NUM_COMPARISONS; comp++)
+ {
+ pos = strstr (expr2, comparisons[comp]);
+ if (pos > expr2)
+ {
+ pos_end = pos - 1;
+ while ((pos_end > expr2) && (pos_end[0] == ' '))
+ {
+ pos_end--;
+ }
+ sub_expr = string_strndup (expr2, pos_end + 1 - expr2);
+ if (!sub_expr)
+ goto end;
+ tmp_value = eval_expression_internal (sub_expr, pointers, extra_vars, 0);
+ free (sub_expr);
+ pos += strlen (comparisons[comp]);
+ while (pos[0] == ' ')
+ {
+ pos++;
+ }
+ tmp_value2 = eval_expression_internal (pos, pointers, extra_vars,
+ ((comp == EVAL_COMPARE_REGEX_MATCHING)
+ || (comp == EVAL_COMPARE_REGEX_NOT_MATCHING)) ? 1 : 0);
+ value = eval_compare (tmp_value, comp, tmp_value2);
+ if (tmp_value)
+ free (tmp_value);
+ if (tmp_value2)
+ free (tmp_value2);
+ goto end;
+ }
+ }
+
+ /*
+ * at this point, there is no more logical operator neither comparison,
+ * so we just replace variables in string and return the result
+ */
+ value = eval_replace_vars (expr2, pointers, extra_vars);
+
+end:
+ if (expr2)
+ free (expr2);
+
+ return value;
+}
+
+/*
+ * eval_expression: evaluate an expression and return a string with the result
+ * The hashtable "pointers" must have string for keys, pointer
+ * for values.
+ * The hashtable "extra_vars" must have string for keys and
+ * values.
+ * The expression can contain:
+ * - conditions: == != < <= > >=
+ * - logical operators: && ||
+ * - parentheses for priority
+ * Examples (the [ ] are NOT part of result):
+ * >> ${window.buffer.number}
+ * == [2]
+ * >> buffer:${window.buffer.full_name}
+ * == [buffer:irc.freenode.#weechat]
+ * >> ${window.buffer.full_name} == irc.freenode.#weechat
+ * == [1]
+ * >> ${window.buffer.full_name} == irc.freenode.#test
+ * == [0]
+ * >> ${window.win_width}
+ * == [112]
+ * >> ${window.win_height}
+ * == [40]
+ * >> ${window.win_width} >= 30 && ${window.win_height} >= 20
+ * == [1]
+ * Note: result must be freed after use
+ */
+
+char *
+eval_expression (const char *expr, struct t_hashtable *pointers,
+ struct t_hashtable *extra_vars)
+{
+ int pointers_created, extra_vars_created;
+ char *value;
+ struct t_gui_window *window;
+
+ if (!expr)
+ return NULL;
+
+ pointers_created = 0;
+ extra_vars_created = 0;
+
+ /* create hashtable pointers if it's NULL */
+ if (!pointers)
+ {
+ pointers = hashtable_new (16,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_POINTER,
+ NULL,
+ NULL);
+ if (!pointers)
+ return NULL;
+ pointers_created = 1;
+ }
+
+ /*
+ * set window/buffer with pointer to current window/buffer
+ * (if not already defined in the hashtable)
+ */
+ if (gui_current_window)
+ {
+ if (!hashtable_has_key (pointers, "window"))
+ hashtable_set (pointers, "window", gui_current_window);
+ if (!hashtable_has_key (pointers, "buffer"))
+ {
+ window = (struct t_gui_window *)hashtable_get (pointers, "window");
+ if (window)
+ hashtable_set (pointers, "buffer", window->buffer);
+ }
+ }
+
+ /* create hashtable extra_vars if it's NULL */
+ if (!extra_vars)
+ {
+ extra_vars = hashtable_new (16,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_STRING,
+ NULL,
+ NULL);
+ if (!extra_vars)
+ return NULL;
+ extra_vars_created = 1;
+ }
+
+ value = eval_expression_internal (expr, pointers, extra_vars, 0);
+
+ if (pointers_created)
+ hashtable_free (pointers);
+ if (extra_vars_created)
+ hashtable_free (extra_vars);
+
+ return value;
+}
diff --git a/src/core/wee-eval.h b/src/core/wee-eval.h
new file mode 100644
index 000000000..482de2e2e
--- /dev/null
+++ b/src/core/wee-eval.h
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2012 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_EVAL_H
+#define __WEECHAT_EVAL_H 1
+
+#define EVAL_STR_FALSE "0"
+#define EVAL_STR_TRUE "1"
+
+struct t_hashtable;
+
+enum t_eval_logical_op
+{
+ EVAL_LOGICAL_OP_AND = 0,
+ EVAL_LOGICAL_OP_OR,
+ /* number of comparison strings */
+ EVAL_NUM_LOGICAL_OPS,
+};
+
+enum t_eval_comparison
+{
+ EVAL_COMPARE_EQUAL = 0,
+ EVAL_COMPARE_NOT_EQUAL,
+ EVAL_COMPARE_LESS_EQUAL,
+ EVAL_COMPARE_LESS,
+ EVAL_COMPARE_GREATER_EQUAL,
+ EVAL_COMPARE_GREATER,
+ EVAL_COMPARE_REGEX_MATCHING,
+ EVAL_COMPARE_REGEX_NOT_MATCHING,
+ /* number of comparison strings */
+ EVAL_NUM_COMPARISONS,
+};
+
+extern int eval_is_true (const char *value);
+extern char *eval_expression (const char *expr,
+ struct t_hashtable *pointers,
+ struct t_hashtable *extra_vars);
+
+#endif /* __WEECHAT_EVAL_H */
diff --git a/src/core/wee-string.c b/src/core/wee-string.c
index 1d16d6d0f..269663cb8 100644
--- a/src/core/wee-string.c
+++ b/src/core/wee-string.c
@@ -49,7 +49,6 @@
#include "weechat.h"
#include "wee-string.h"
#include "wee-config.h"
-#include "wee-hashtable.h"
#include "wee-utf8.h"
#include "../gui/gui-color.h"
#include "../plugins/plugin.h"
@@ -1774,28 +1773,29 @@ string_input_for_buffer (const char *string)
}
/*
- * string_replace_with_hashtable: replace ${codes} with value from hashtable
- * "errors" is set with number of keys not found
- * in hashtable
+ * string_replace_with_callback: replace ${codes} using a callback that return
+ * replacement value (this value must be newly
+ * allocated because it will be freed in this
+ * function)
+ * "errors" is set with number of keys not found
+ * by callback
*/
char *
-string_replace_with_hashtable (const char *string,
- struct t_hashtable *hashtable,
- int *errors)
+string_replace_with_callback (const char *string,
+ char *(*callback)(void *data, const char *text),
+ void *callback_data,
+ int *errors)
{
int length, length_value, index_string, index_result;
- char *result, *result2, *key;
- const char *pos_end_name, *ptr_value;
+ char *result, *result2, *key, *value;
+ const char *pos_end_name;
*errors = 0;
if (!string)
return NULL;
- if (!hashtable)
- return strdup (string);
-
length = strlen (string) + 1;
result = malloc (length);
if (result)
@@ -1820,10 +1820,10 @@ string_replace_with_hashtable (const char *string,
pos_end_name - (string + index_string + 2));
if (key)
{
- ptr_value = (const char *)hashtable_get (hashtable, key);
- if (ptr_value)
+ value = (*callback) (callback_data, key);
+ if (value)
{
- length_value = strlen (ptr_value);
+ length_value = strlen (value);
length += length_value;
result2 = realloc (result, length);
if (!result2)
@@ -1831,13 +1831,15 @@ string_replace_with_hashtable (const char *string,
if (result)
free (result);
free (key);
+ free (value);
return NULL;
}
result = result2;
- strcpy (result + index_result, ptr_value);
+ strcpy (result + index_result, value);
index_result += length_value;
index_string += pos_end_name - string -
index_string + 1;
+ free (value);
}
else
{
diff --git a/src/core/wee-string.h b/src/core/wee-string.h
index a000e65f3..a9fc76ea8 100644
--- a/src/core/wee-string.h
+++ b/src/core/wee-string.h
@@ -75,8 +75,9 @@ extern void string_encode_base64 (const char *from, int length, char *to);
extern int string_decode_base64 (const char *from, char *to);
extern int string_is_command_char (const char *string);
extern const char *string_input_for_buffer (const char *string);
-extern char *string_replace_with_hashtable (const char *string,
- struct t_hashtable *hashtable,
- int *errors);
+extern char *string_replace_with_callback (const char *string,
+ char *(*callback)(void *data, const char *text),
+ void *callback_data,
+ int *errors);
#endif /* __WEECHAT_STRING_H */
diff --git a/src/gui/gui-bar-item.c b/src/gui/gui-bar-item.c
index fade60939..43d5dbb53 100644
--- a/src/gui/gui-bar-item.c
+++ b/src/gui/gui-bar-item.c
@@ -176,13 +176,52 @@ gui_bar_item_search_with_plugin (struct t_weechat_plugin *plugin,
}
/*
- * gui_bar_item_used_in_a_bar: return 1 if an item is used in at least one bar
- * if partial_name == 1, then search a bar that
- * contains item beginning with "item_name"
+ * gui_bar_item_used_in_bar: return 1 if an item is used in the bar
+ * if partial_name == 1, then search if an item
+ * begins with "item_name"
*/
int
-gui_bar_item_used_in_a_bar (const char *item_name, int partial_name)
+gui_bar_item_used_in_bar (struct t_gui_bar *bar, const char *item_name,
+ int partial_name)
+{
+ int i, j, length;
+
+ length = strlen (item_name);
+
+ for (i = 0; i < bar->items_count; i++)
+ {
+ for (j = 0; j < bar->items_subcount[i]; j++)
+ {
+ if (bar->items_name[i][j])
+ {
+ if ((partial_name
+ && strncmp (bar->items_name[i][j],
+ item_name, length) == 0)
+ || (!partial_name
+ && strcmp (bar->items_name[i][j],
+ item_name) == 0))
+ {
+ return 1;
+ }
+ }
+ }
+ }
+
+ /* item not used in the bar */
+ return 0;
+}
+
+/*
+ * gui_bar_item_used_in_at_least_one_bar: return 1 if an item is used in at
+ * least one bar
+ * if partial_name == 1, then search a
+ * bar that contains item beginning with
+ * "item_name"
+ */
+
+int
+gui_bar_item_used_in_at_least_one_bar (const char *item_name, int partial_name)
{
struct t_gui_bar *ptr_bar;
int i, j, length;
@@ -211,7 +250,7 @@ gui_bar_item_used_in_a_bar (const char *item_name, int partial_name)
}
}
- /* item not used by any bar */
+ /* item not used in any bar */
return 0;
}
diff --git a/src/gui/gui-bar-item.h b/src/gui/gui-bar-item.h
index 2b7b92d6d..8e7ae338d 100644
--- a/src/gui/gui-bar-item.h
+++ b/src/gui/gui-bar-item.h
@@ -76,8 +76,11 @@ extern char *gui_bar_items_default_for_bars[][2];
extern int gui_bar_item_valid (struct t_gui_bar_item *bar_item);
extern struct t_gui_bar_item *gui_bar_item_search (const char *name);
-extern int gui_bar_item_used_in_a_bar (const char *item_name,
- int partial_name);
+extern int gui_bar_item_used_in_bar (struct t_gui_bar *bar,
+ const char *item_name,
+ int partial_name);
+extern int gui_bar_item_used_in_at_least_one_bar (const char *item_name,
+ int partial_name);
extern void gui_bar_item_set_prefix_name_suffix (const char *item_name,
char **prefix, char **name,
char **suffix);
diff --git a/src/gui/gui-bar.c b/src/gui/gui-bar.c
index 31ec7f677..eb2c4299c 100644
--- a/src/gui/gui-bar.c
+++ b/src/gui/gui-bar.c
@@ -32,6 +32,8 @@
#include "../core/weechat.h"
#include "../core/wee-config.h"
+#include "../core/wee-eval.h"
+#include "../core/wee-hashtable.h"
#include "../core/wee-hdata.h"
#include "../core/wee-hook.h"
#include "../core/wee-infolist.h"
@@ -372,27 +374,64 @@ int
gui_bar_check_conditions_for_window (struct t_gui_bar *bar,
struct t_gui_window *window)
{
- int i, rc;
- char str_modifier[256], str_window[128], *str_displayed;
+ int rc;
+ char str_modifier[256], str_window[128], *str_displayed, *result;
+ const char *conditions;
+ struct t_hashtable *pointers, *extra_vars;
- /* check bar conditions */
- for (i = 0; i < bar->conditions_count; i++)
+ /* check bar condition(s) */
+ conditions = CONFIG_STRING(bar->options[GUI_BAR_OPTION_CONDITIONS]);
+ if (string_strcasecmp (conditions, "active") == 0)
{
- if (string_strcasecmp (bar->conditions_array[i], "active") == 0)
- {
- if (gui_current_window && (gui_current_window != window))
- return 0;
- }
- else if (string_strcasecmp (bar->conditions_array[i], "inactive") == 0)
+ if (gui_current_window && (gui_current_window != window))
+ return 0;
+ }
+ else if (string_strcasecmp (conditions, "inactive") == 0)
+ {
+ if (!gui_current_window || (gui_current_window == window))
+ return 0;
+ }
+ else if (string_strcasecmp (conditions, "nicklist") == 0)
+ {
+ if (window->buffer && !window->buffer->nicklist)
+ return 0;
+ }
+ else if (conditions[0])
+ {
+ pointers = hashtable_new (16,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_POINTER,
+ NULL,
+ NULL);
+ if (pointers)
{
- if (!gui_current_window || (gui_current_window == window))
- return 0;
+ hashtable_set (pointers, "window", window);
+ hashtable_set (pointers, "buffer", window->buffer);
}
- else if (string_strcasecmp (bar->conditions_array[i], "nicklist") == 0)
+ extra_vars = hashtable_new (16,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_POINTER,
+ NULL,
+ NULL);
+ if (extra_vars)
{
- if (window->buffer && !window->buffer->nicklist)
- return 0;
+ hashtable_set (extra_vars, "active",
+ (gui_current_window && (gui_current_window == window)) ? "1" : "0");
+ hashtable_set (extra_vars, "inactive",
+ (gui_current_window && (gui_current_window != window)) ? "1" : "0");
+ hashtable_set (extra_vars, "nicklist",
+ (window->buffer && window->buffer->nicklist) ? "1" : "0");
}
+ result = eval_expression (conditions, pointers, extra_vars);
+ rc = eval_is_true (result);
+ if (result)
+ free (result);
+ if (pointers)
+ hashtable_free (pointers);
+ if (extra_vars)
+ hashtable_free (extra_vars);
+ if (!rc)
+ return 0;
}
/*
@@ -413,6 +452,7 @@ gui_bar_check_conditions_for_window (struct t_gui_bar *bar,
rc = 0;
else
rc = 1;
+
if (str_displayed)
free (str_displayed);
@@ -885,30 +925,9 @@ gui_bar_config_change_priority (void *data, struct t_config_option *option)
void
gui_bar_config_change_conditions (void *data, struct t_config_option *option)
{
- struct t_gui_bar *ptr_bar;
-
/* make C compiler happy */
(void) data;
-
- ptr_bar = gui_bar_search_with_option_name (option->name);
- if (ptr_bar)
- {
- if (ptr_bar->conditions_array)
- string_free_split (ptr_bar->conditions_array);
-
- if (CONFIG_STRING(ptr_bar->options[GUI_BAR_OPTION_CONDITIONS])
- && CONFIG_STRING(ptr_bar->options[GUI_BAR_OPTION_CONDITIONS])[0])
- {
- ptr_bar->conditions_array = string_split (CONFIG_STRING(ptr_bar->options[GUI_BAR_OPTION_CONDITIONS]),
- ",", 0, 0,
- &ptr_bar->conditions_count);
- }
- else
- {
- ptr_bar->conditions_count = 0;
- ptr_bar->conditions_array = NULL;
- }
- }
+ (void) option;
gui_window_ask_refresh (1);
}
@@ -1343,9 +1362,13 @@ gui_bar_create_option (const char *bar_name, int index_option, const char *value
weechat_config_file, weechat_config_section_bar,
option_name, "string",
N_("condition(s) for displaying bar (for bars of type "
- "\"window\"): \"active\" = window must be active, "
- "\"inactive\" = window must be inactive, "
- "\"nicklist\" = buffer must have a nicklist"),
+ "\"window\"): a simple condition: \"active\", "
+ "\"inactive\", \"nicklist\" (window must be active/"
+ "inactive, buffer must have a nicklist), or an "
+ "expression with condition(s) (see /help eval), like: "
+ "\"${nicklist} && ${window.win_width} > 100\" "
+ "(local variables for expression are ${active}, "
+ "${inactive} and ${nicklist})"),
NULL, 0, 0, value, NULL, 0,
NULL, NULL, &gui_bar_config_change_conditions, NULL, NULL, NULL);
break;
@@ -1537,8 +1560,6 @@ gui_bar_alloc (const char *name)
{
new_bar->options[i] = NULL;
}
- new_bar->conditions_count = 0;
- new_bar->conditions_array = NULL;
new_bar->items_count = 0;
new_bar->items_array = NULL;
new_bar->items_prefix = NULL;
@@ -1585,17 +1606,6 @@ gui_bar_new_with_options (const char *name,
new_bar->options[GUI_BAR_OPTION_PRIORITY] = priority;
new_bar->options[GUI_BAR_OPTION_TYPE] = type;
new_bar->options[GUI_BAR_OPTION_CONDITIONS] = conditions;
- if (CONFIG_STRING(conditions) && CONFIG_STRING(conditions)[0])
- {
- new_bar->conditions_array = string_split (CONFIG_STRING(conditions),
- ",", 0, 0,
- &new_bar->conditions_count);
- }
- else
- {
- new_bar->conditions_count = 0;
- new_bar->conditions_array = NULL;
- }
new_bar->options[GUI_BAR_OPTION_POSITION] = position;
new_bar->options[GUI_BAR_OPTION_FILLING_TOP_BOTTOM] = filling_top_bottom;
new_bar->options[GUI_BAR_OPTION_FILLING_LEFT_RIGHT] = filling_left_right;
@@ -1832,7 +1842,7 @@ gui_bar_create_default_input ()
char *buf;
/* search an input_text item */
- if (!gui_bar_item_used_in_a_bar (gui_bar_item_names[GUI_BAR_ITEM_INPUT_TEXT], 1))
+ if (!gui_bar_item_used_in_at_least_one_bar (gui_bar_item_names[GUI_BAR_ITEM_INPUT_TEXT], 1))
{
ptr_bar = gui_bar_search (GUI_BAR_DEFAULT_NAME_INPUT);
if (ptr_bar)
@@ -1973,7 +1983,7 @@ gui_bar_create_default_nicklist ()
"0", /* hidden */
"200", /* priority */
"window", /* type */
- "nicklist", /* conditions */
+ "${nicklist}", /* conditions */
"right", /* position */
"columns_vertical", /* filling_top_bottom */
"vertical", /* filling_left_right */
@@ -2178,8 +2188,6 @@ gui_bar_free (struct t_gui_bar *bar)
if (bar->options[i])
config_file_option_free (bar->options[i]);
}
- if (bar->conditions_array)
- string_free_split (bar->conditions_array);
gui_bar_free_items_arrays (bar);
free (bar);
@@ -2249,8 +2257,6 @@ gui_bar_hdata_bar_cb (void *data, const char *hdata_name)
{
HDATA_VAR(struct t_gui_bar, name, STRING, 0, NULL, NULL);
HDATA_VAR(struct t_gui_bar, options, POINTER, 0, NULL, NULL);
- HDATA_VAR(struct t_gui_bar, conditions_count, INTEGER, 0, NULL, NULL);
- HDATA_VAR(struct t_gui_bar, conditions_array, STRING, 0, "conditions_count", NULL);
HDATA_VAR(struct t_gui_bar, items_count, INTEGER, 0, NULL, NULL);
HDATA_VAR(struct t_gui_bar, items_subcount, POINTER, 0, NULL, NULL);
HDATA_VAR(struct t_gui_bar, items_array, POINTER, 0, NULL, NULL);
@@ -2297,16 +2303,6 @@ gui_bar_add_to_infolist (struct t_infolist *infolist,
return 0;
if (!infolist_new_var_string (ptr_item, "conditions", CONFIG_STRING(bar->options[GUI_BAR_OPTION_CONDITIONS])))
return 0;
- if (!infolist_new_var_integer (ptr_item, "conditions_count", bar->conditions_count))
- return 0;
- for (i = 0; i < bar->conditions_count; i++)
- {
- snprintf (option_name, sizeof (option_name),
- "conditions_array_%05d", i + 1);
- if (!infolist_new_var_string (ptr_item, option_name,
- bar->conditions_array[i]))
- return 0;
- }
if (!infolist_new_var_integer (ptr_item, "position", CONFIG_INTEGER(bar->options[GUI_BAR_OPTION_POSITION])))
return 0;
if (!infolist_new_var_integer (ptr_item, "filling_top_bottom", CONFIG_INTEGER(bar->options[GUI_BAR_OPTION_FILLING_TOP_BOTTOM])))
@@ -2377,8 +2373,6 @@ gui_bar_print_log ()
CONFIG_INTEGER(ptr_bar->options[GUI_BAR_OPTION_TYPE]),
gui_bar_type_string[CONFIG_INTEGER(ptr_bar->options[GUI_BAR_OPTION_TYPE])]);
log_printf (" conditions . . . . . . : '%s'", CONFIG_STRING(ptr_bar->options[GUI_BAR_OPTION_CONDITIONS]));
- log_printf (" conditions_count . . . : %d", ptr_bar->conditions_count);
- log_printf (" conditions_array . . . : 0x%lx", ptr_bar->conditions_array);
log_printf (" position . . . . . . . : %d (%s)",
CONFIG_INTEGER(ptr_bar->options[GUI_BAR_OPTION_POSITION]),
gui_bar_position_string[CONFIG_INTEGER(ptr_bar->options[GUI_BAR_OPTION_POSITION])]);
diff --git a/src/gui/gui-bar.h b/src/gui/gui-bar.h
index aec264129..6743f9fc1 100644
--- a/src/gui/gui-bar.h
+++ b/src/gui/gui-bar.h
@@ -34,7 +34,7 @@ enum t_gui_bar_option
GUI_BAR_OPTION_HIDDEN = 0, /* true if bar is hidden */
GUI_BAR_OPTION_PRIORITY, /* bar priority */
GUI_BAR_OPTION_TYPE, /* type (root or window) */
- GUI_BAR_OPTION_CONDITIONS, /* conditions for display */
+ GUI_BAR_OPTION_CONDITIONS, /* condition(s) for display */
GUI_BAR_OPTION_POSITION, /* bottom, top, left, right */
GUI_BAR_OPTION_FILLING_TOP_BOTTOM, /* filling when pos. is top/bottom */
GUI_BAR_OPTION_FILLING_LEFT_RIGHT, /* filling when pos. is left/right */
@@ -84,8 +84,6 @@ struct t_gui_bar
struct t_config_option *options[GUI_BAR_NUM_OPTIONS];
/* internal vars */
- int conditions_count; /* number of conditions */
- char **conditions_array; /* bar conditions (after split) */
int items_count; /* number of bar items */
int *items_subcount; /* number of sub items */
char ***items_array; /* bar items (after split) */
diff --git a/src/gui/gui-key.c b/src/gui/gui-key.c
index 492e0d9e4..93938ec2a 100644
--- a/src/gui/gui-key.c
+++ b/src/gui/gui-key.c
@@ -950,6 +950,29 @@ gui_key_focus_matching (struct t_gui_key *key,
}
/*
+ * gui_key_focus_command_replace_cb: callback for replacing values in string
+ * with a hashtable
+ */
+
+char *
+gui_key_focus_command_replace_cb (void *data, const char *text)
+{
+ struct t_hashtable *ptr_hashtable;
+ const char *ptr_value;
+
+ ptr_hashtable = (struct t_hashtable *)data;
+
+ if (ptr_hashtable)
+ {
+ ptr_value = hashtable_get (ptr_hashtable, text);
+ if (ptr_value)
+ return strdup (ptr_value);
+ }
+
+ return NULL;
+}
+
+/*
* gui_key_focus_command: run command according to focus
* return 1 if a command was executed, otherwise 0
*/
@@ -1038,9 +1061,10 @@ gui_key_focus_command (const char *key, int context,
}
else
{
- command = string_replace_with_hashtable (commands[i],
- hashtable,
- &errors);
+ command = string_replace_with_callback (commands[i],
+ &gui_key_focus_command_replace_cb,
+ hashtable,
+ &errors);
if (command)
{
if (errors == 0)
diff --git a/src/plugins/guile/weechat-guile-api.c b/src/plugins/guile/weechat-guile-api.c
index 378fb7e0f..f2267b19d 100644
--- a/src/plugins/guile/weechat-guile-api.c
+++ b/src/plugins/guile/weechat-guile-api.c
@@ -421,6 +421,44 @@ weechat_guile_api_string_input_for_buffer (SCM string)
}
/*
+ * weechat_guile_api_string_eval_expression: evaluate an expression and return
+ * result
+ */
+
+SCM
+weechat_guile_api_string_eval_expression (SCM expr, SCM pointers,
+ SCM extra_vars)
+{
+ char *result;
+ SCM return_value;
+ struct t_hashtable *c_pointers, *c_extra_vars;
+
+ API_FUNC(1, "string_eval_expression", API_RETURN_EMPTY);
+ if (!scm_is_string (expr) || !scm_list_p (pointers)
+ || !scm_list_p (extra_vars))
+ API_WRONG_ARGS(API_RETURN_EMPTY);
+
+ c_pointers = weechat_guile_alist_to_hashtable (pointers,
+ WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_POINTER);
+ c_extra_vars = weechat_guile_alist_to_hashtable (extra_vars,
+ WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_STRING);
+
+ result = weechat_string_eval_expression (scm_i_string_chars (expr),
+ c_pointers, c_extra_vars);
+
+ if (c_pointers)
+ weechat_hashtable_free (c_pointers);
+ if (c_extra_vars)
+ weechat_hashtable_free (c_extra_vars);
+
+ API_RETURN_STRING_FREE(result);
+}
+
+/*
* weechat_guile_api_mkdir_home: create a directory in WeeChat home
*/
@@ -1933,7 +1971,9 @@ weechat_guile_api_key_bind (SCM context, SCM keys)
API_WRONG_ARGS(API_RETURN_INT(0));
c_keys = weechat_guile_alist_to_hashtable (keys,
- WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE);
+ WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_STRING);
num_keys = weechat_key_bind (scm_i_string_chars (context), c_keys);
@@ -2454,7 +2494,9 @@ weechat_guile_api_hook_process_hashtable (SCM command, SCM options, SCM timeout,
API_WRONG_ARGS(API_RETURN_EMPTY);
c_options = weechat_guile_alist_to_hashtable (options,
- WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE);
+ WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_STRING);
result = API_PTR2STR(plugin_script_api_hook_process_hashtable (weechat_guile_plugin,
guile_current_script,
@@ -2861,7 +2903,9 @@ weechat_guile_api_hook_hsignal_send (SCM signal, SCM hashtable)
API_WRONG_ARGS(API_RETURN_ERROR);
c_hashtable = weechat_guile_alist_to_hashtable (hashtable,
- WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE);
+ WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_STRING);
weechat_hook_hsignal_send (scm_i_string_chars (signal), c_hashtable);
@@ -4462,7 +4506,9 @@ weechat_guile_api_info_get_hashtable (SCM info_name, SCM hash)
API_WRONG_ARGS(API_RETURN_EMPTY);
c_hashtable = weechat_guile_alist_to_hashtable (hash,
- WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE);
+ WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_STRING);
result_hashtable = weechat_info_get_hashtable (scm_i_string_chars (info_name),
c_hashtable);
@@ -5160,7 +5206,9 @@ weechat_guile_api_hdata_update (SCM hdata, SCM pointer, SCM hashtable)
API_WRONG_ARGS(API_RETURN_INT(0));
c_hashtable = weechat_guile_alist_to_hashtable (hashtable,
- WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE);
+ WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_STRING);
value = weechat_hdata_update (API_STR2PTR(scm_i_string_chars (hdata)),
API_STR2PTR(scm_i_string_chars (pointer)),
@@ -5358,6 +5406,7 @@ weechat_guile_api_module_init (void *data)
API_DEF_FUNC(string_remove_color, 2);
API_DEF_FUNC(string_is_command_char, 1);
API_DEF_FUNC(string_input_for_buffer, 1);
+ API_DEF_FUNC(string_eval_expression, 3);
API_DEF_FUNC(mkdir_home, 2);
API_DEF_FUNC(mkdir, 2);
API_DEF_FUNC(mkdir_parents, 2);
diff --git a/src/plugins/guile/weechat-guile.c b/src/plugins/guile/weechat-guile.c
index 7dbd5ce4b..a46093167 100644
--- a/src/plugins/guile/weechat-guile.c
+++ b/src/plugins/guile/weechat-guile.c
@@ -198,22 +198,21 @@ weechat_guile_hashtable_to_alist (struct t_hashtable *hashtable)
/*
* 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)
+weechat_guile_alist_to_hashtable (SCM alist, int size, const char *type_keys,
+ const char *type_values)
{
struct t_hashtable *hashtable;
int length, i;
SCM pair;
- hashtable = weechat_hashtable_new (hashtable_size,
- WEECHAT_HASHTABLE_STRING,
- WEECHAT_HASHTABLE_STRING,
+ hashtable = weechat_hashtable_new (size,
+ type_keys,
+ type_values,
NULL,
NULL);
if (!hashtable)
@@ -223,11 +222,24 @@ weechat_guile_alist_to_hashtable (SCM alist, int hashtable_size)
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))));
+ if (strcmp (type_values, WEECHAT_HASHTABLE_STRING) == 0)
+ {
+ 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))));
+ }
+ else if (strcmp (type_values, WEECHAT_HASHTABLE_POINTER) == 0)
+ {
+ weechat_hashtable_set (hashtable,
+ scm_i_string_chars (scm_list_ref (pair,
+ scm_from_int (0))),
+ plugin_script_str2ptr (weechat_guile_plugin,
+ NULL, NULL,
+ scm_i_string_chars (scm_list_ref (pair,
+ scm_from_int (1)))));
+ }
}
return hashtable;
@@ -305,7 +317,9 @@ weechat_guile_exec (struct t_plugin_script *script,
else if (ret_type == WEECHAT_SCRIPT_EXEC_HASHTABLE)
{
ret_value = weechat_guile_alist_to_hashtable (rc,
- WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE);
+ WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_STRING);
}
else
{
diff --git a/src/plugins/guile/weechat-guile.h b/src/plugins/guile/weechat-guile.h
index b868a4c10..03c104b64 100644
--- a/src/plugins/guile/weechat-guile.h
+++ b/src/plugins/guile/weechat-guile.h
@@ -37,7 +37,9 @@ 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);
+ int size,
+ const char *type_keys,
+ const char *type_values);
extern void *weechat_guile_exec (struct t_plugin_script *script,
int ret_type, const char *function,
char *format, void **argv);
diff --git a/src/plugins/lua/weechat-lua-api.c b/src/plugins/lua/weechat-lua-api.c
index ce8a1e61f..6c1f83537 100644
--- a/src/plugins/lua/weechat-lua-api.c
+++ b/src/plugins/lua/weechat-lua-api.c
@@ -461,6 +461,42 @@ weechat_lua_api_string_input_for_buffer (lua_State *L)
}
/*
+ * weechat_lua_api_string_eval_expression: evaluate an expression and return
+ * result
+ */
+
+static int
+weechat_lua_api_string_eval_expression (lua_State *L)
+{
+ const char *expr;
+ struct t_hashtable *pointers, *extra_vars;
+ char *result;
+
+ API_FUNC(1, "string_eval_expression", API_RETURN_EMPTY);
+ if (lua_gettop (lua_current_interpreter) < 3)
+ API_WRONG_ARGS(API_RETURN_EMPTY);
+
+ expr = lua_tostring (lua_current_interpreter, -3);
+ pointers = weechat_lua_tohashtable (lua_current_interpreter, -2,
+ WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_POINTER);
+ extra_vars = weechat_lua_tohashtable (lua_current_interpreter, -1,
+ WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_STRING);
+
+ result = weechat_string_eval_expression (expr, pointers, extra_vars);
+
+ if (pointers)
+ weechat_hashtable_free (pointers);
+ if (extra_vars)
+ weechat_hashtable_free (extra_vars);
+
+ API_RETURN_STRING_FREE(result);
+}
+
+/*
* weechat_lua_api_mkdir_home: create a directory in WeeChat home
*/
@@ -2133,7 +2169,9 @@ weechat_lua_api_key_bind (lua_State *L)
context = lua_tostring (lua_current_interpreter, -2);
hashtable = weechat_lua_tohashtable (lua_current_interpreter, -1,
- WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE);
+ WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_STRING);
num_keys = weechat_key_bind (context, hashtable);
@@ -2702,7 +2740,9 @@ weechat_lua_api_hook_process_hashtable (lua_State *L)
command = lua_tostring (lua_current_interpreter, -5);
options = weechat_lua_tohashtable (lua_current_interpreter, -4,
- WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE);
+ WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_STRING);
timeout = lua_tonumber (lua_current_interpreter, -3);
function = lua_tostring (lua_current_interpreter, -2);
data = lua_tostring (lua_current_interpreter, -1);
@@ -3127,7 +3167,9 @@ weechat_lua_api_hook_hsignal_send (lua_State *L)
signal = lua_tostring (lua_current_interpreter, -2);
hashtable = weechat_lua_tohashtable (lua_current_interpreter, -1,
- WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE);
+ WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_STRING);
weechat_hook_hsignal_send (signal, hashtable);
@@ -4899,7 +4941,9 @@ weechat_lua_api_info_get_hashtable (lua_State *L)
info_name = lua_tostring (lua_current_interpreter, -2);
table = weechat_lua_tohashtable (lua_current_interpreter, -1,
- WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE);
+ WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_STRING);
result_hashtable = weechat_info_get_hashtable (info_name, table);
@@ -5695,7 +5739,9 @@ weechat_lua_api_hdata_update (lua_State *L)
hdata = lua_tostring (lua_current_interpreter, -3);
pointer = lua_tostring (lua_current_interpreter, -2);
hashtable = weechat_lua_tohashtable (lua_current_interpreter, -1,
- WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE);
+ WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_STRING);
value = weechat_hdata_update (API_STR2PTR(hdata),
API_STR2PTR(pointer),
@@ -6296,6 +6342,7 @@ const struct luaL_Reg weechat_lua_api_funcs[] = {
API_DEF_FUNC(string_remove_color),
API_DEF_FUNC(string_is_command_char),
API_DEF_FUNC(string_input_for_buffer),
+ API_DEF_FUNC(string_eval_expression),
API_DEF_FUNC(mkdir_home),
API_DEF_FUNC(mkdir),
API_DEF_FUNC(mkdir_parents),
diff --git a/src/plugins/lua/weechat-lua.c b/src/plugins/lua/weechat-lua.c
index 89cede0b8..8711eead1 100644
--- a/src/plugins/lua/weechat-lua.c
+++ b/src/plugins/lua/weechat-lua.c
@@ -108,20 +108,19 @@ weechat_lua_pushhashtable (lua_State *interpreter, struct t_hashtable *hashtable
/*
* weechat_lua_hash_to_hashtable: get WeeChat hashtable with lua hash (on stack)
- * 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_lua_tohashtable (lua_State *interpreter, int index, int hashtable_size)
+weechat_lua_tohashtable (lua_State *interpreter, int index, int size,
+ const char *type_keys, const char *type_values)
{
struct t_hashtable *hashtable;
- hashtable = weechat_hashtable_new (hashtable_size,
- WEECHAT_HASHTABLE_STRING,
- WEECHAT_HASHTABLE_STRING,
+ hashtable = weechat_hashtable_new (size,
+ type_keys,
+ type_values,
NULL,
NULL);
if (!hashtable)
@@ -130,9 +129,20 @@ weechat_lua_tohashtable (lua_State *interpreter, int index, int hashtable_size)
lua_pushnil (interpreter);
while (lua_next (interpreter, index - 1) != 0)
{
- weechat_hashtable_set (hashtable,
- lua_tostring (interpreter, -2),
- lua_tostring (interpreter, -1));
+ if (strcmp (type_values, WEECHAT_HASHTABLE_STRING) == 0)
+ {
+ weechat_hashtable_set (hashtable,
+ lua_tostring (interpreter, -2),
+ lua_tostring (interpreter, -1));
+ }
+ else if (strcmp (type_values, WEECHAT_HASHTABLE_POINTER) == 0)
+ {
+ weechat_hashtable_set (hashtable,
+ lua_tostring (interpreter, -2),
+ plugin_script_str2ptr (weechat_lua_plugin,
+ NULL, NULL,
+ lua_tostring (interpreter, -1)));
+ }
/* remove value from stack (keep key for next iteration) */
lua_pop (interpreter, 1);
}
@@ -209,7 +219,9 @@ weechat_lua_exec (struct t_plugin_script *script, int ret_type,
else if (ret_type == WEECHAT_SCRIPT_EXEC_HASHTABLE)
{
ret_value = weechat_lua_tohashtable (lua_current_interpreter, -1,
- WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE);
+ WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_STRING);
}
else
{
diff --git a/src/plugins/lua/weechat-lua.h b/src/plugins/lua/weechat-lua.h
index 0512d2272..7f4de2085 100644
--- a/src/plugins/lua/weechat-lua.h
+++ b/src/plugins/lua/weechat-lua.h
@@ -40,7 +40,9 @@ extern void weechat_lua_pushhashtable (lua_State *interpreter,
struct t_hashtable *hashtable);
extern struct t_hashtable *weechat_lua_tohashtable (lua_State *interpreter,
int index,
- int hashtable_size);
+ int size,
+ const char *type_keys,
+ const char *type_values);
extern void *weechat_lua_exec (struct t_plugin_script *script, int ret_type,
const char *function,
const char *format, void **argv);
diff --git a/src/plugins/perl/weechat-perl-api.c b/src/plugins/perl/weechat-perl-api.c
index 3d0cb645e..d182bbb04 100644
--- a/src/plugins/perl/weechat-perl-api.c
+++ b/src/plugins/perl/weechat-perl-api.c
@@ -437,6 +437,40 @@ XS (XS_weechat_api_string_input_for_buffer)
}
/*
+ * weechat::string_eval_expression: evaluate expression and return result
+ */
+
+XS (XS_weechat_api_string_eval_expression)
+{
+ char *expr, *result;
+ struct t_hashtable *pointers, *extra_vars;
+ dXSARGS;
+
+ API_FUNC(1, "string_eval_expression", API_RETURN_EMPTY);
+ if (items < 3)
+ API_WRONG_ARGS(API_RETURN_EMPTY);
+
+ expr = SvPV_nolen (ST (0));
+ pointers = weechat_perl_hash_to_hashtable (ST (1),
+ WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_POINTER);
+ extra_vars = weechat_perl_hash_to_hashtable (ST (2),
+ WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_STRING);
+
+ result = weechat_string_eval_expression (expr, pointers, extra_vars);
+
+ if (pointers)
+ weechat_hashtable_free (pointers);
+ if (extra_vars)
+ weechat_hashtable_free (extra_vars);
+
+ API_RETURN_STRING_FREE(result);
+}
+
+/*
* weechat::mkdir_home: create a directory in WeeChat home
*/
@@ -2003,7 +2037,9 @@ XS (XS_weechat_api_key_bind)
context = SvPV_nolen (ST (0));
hashtable = weechat_perl_hash_to_hashtable (ST (1),
- WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE);
+ WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_STRING);
num_keys = weechat_key_bind (context, hashtable);
@@ -2537,7 +2573,9 @@ XS (XS_weechat_api_hook_process_hashtable)
command = SvPV_nolen (ST (0));
options = weechat_perl_hash_to_hashtable (ST (1),
- WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE);
+ WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_STRING);
function = SvPV_nolen (ST (3));
data = SvPV_nolen (ST (4));
@@ -2951,7 +2989,9 @@ XS (XS_weechat_api_hook_hsignal_send)
signal = SvPV_nolen (ST (0));
hashtable = weechat_perl_hash_to_hashtable (ST (1),
- WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE);
+ WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_STRING);
weechat_hook_hsignal_send (signal, hashtable);
@@ -4663,7 +4703,9 @@ XS (XS_weechat_api_info_get_hashtable)
info_name = SvPV_nolen (ST (0));
hashtable = weechat_perl_hash_to_hashtable (ST (1),
- WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE);
+ WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_STRING);
result_hashtable = weechat_info_get_hashtable (info_name, hashtable);
result_hash = weechat_perl_hashtable_to_hash (result_hashtable);
@@ -5428,7 +5470,9 @@ XS (XS_weechat_api_hdata_update)
hdata = SvPV_nolen (ST (0));
pointer = SvPV_nolen (ST (1));
hashtable = weechat_perl_hash_to_hashtable (ST (2),
- WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE);
+ WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_STRING);
value = weechat_hdata_update (API_STR2PTR(hdata),
API_STR2PTR(pointer),
@@ -5630,6 +5674,7 @@ weechat_perl_api_init (pTHX)
API_DEF_FUNC(string_remove_color);
API_DEF_FUNC(string_is_command_char);
API_DEF_FUNC(string_input_for_buffer);
+ API_DEF_FUNC(string_eval_expression);
API_DEF_FUNC(mkdir_home);
API_DEF_FUNC(mkdir);
API_DEF_FUNC(mkdir_parents);
diff --git a/src/plugins/perl/weechat-perl.c b/src/plugins/perl/weechat-perl.c
index f889aa6be..63ab186bd 100644
--- a/src/plugins/perl/weechat-perl.c
+++ b/src/plugins/perl/weechat-perl.c
@@ -169,14 +169,13 @@ weechat_perl_hashtable_to_hash (struct t_hashtable *hashtable)
/*
* weechat_perl_hash_to_hashtable: get WeeChat hashtable with perl hash
- * 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_perl_hash_to_hashtable (SV *hash, int hashtable_size)
+weechat_perl_hash_to_hashtable (SV *hash, int size, const char *type_keys,
+ const char *type_values)
{
struct t_hashtable *hashtable;
HV *hash2;
@@ -184,9 +183,9 @@ weechat_perl_hash_to_hashtable (SV *hash, int hashtable_size)
char *str_key;
I32 retlen;
- hashtable = weechat_hashtable_new (hashtable_size,
- WEECHAT_HASHTABLE_STRING,
- WEECHAT_HASHTABLE_STRING,
+ hashtable = weechat_hashtable_new (size,
+ type_keys,
+ type_values,
NULL,
NULL);
if (!hashtable)
@@ -198,7 +197,15 @@ weechat_perl_hash_to_hashtable (SV *hash, int hashtable_size)
hv_iterinit (hash2);
while ((value = hv_iternextsv (hash2, &str_key, &retlen)))
{
- weechat_hashtable_set (hashtable, str_key, SvPV (value, PL_na));
+ if (strcmp (type_values, WEECHAT_HASHTABLE_STRING) == 0)
+ weechat_hashtable_set (hashtable, str_key, SvPV (value, PL_na));
+ else if (strcmp (type_values, WEECHAT_HASHTABLE_POINTER) == 0)
+ {
+ weechat_hashtable_set (hashtable, str_key,
+ plugin_script_str2ptr (weechat_perl_plugin,
+ NULL, NULL,
+ SvPV (value, PL_na)));
+ }
}
}
@@ -316,7 +323,9 @@ weechat_perl_exec (struct t_plugin_script *script,
else if (ret_type == WEECHAT_SCRIPT_EXEC_HASHTABLE)
{
ret_value = weechat_perl_hash_to_hashtable (POPs,
- WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE);
+ WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_STRING);
}
else
{
diff --git a/src/plugins/perl/weechat-perl.h b/src/plugins/perl/weechat-perl.h
index 87a601aac..5e1eabe48 100644
--- a/src/plugins/perl/weechat-perl.h
+++ b/src/plugins/perl/weechat-perl.h
@@ -35,8 +35,9 @@ extern struct t_plugin_script *perl_registered_script;
extern const char *perl_current_script_filename;
extern HV *weechat_perl_hashtable_to_hash (struct t_hashtable *hashtable);
-extern struct t_hashtable *weechat_perl_hash_to_hashtable (SV *hash,
- int hashtable_size);
+extern struct t_hashtable *weechat_perl_hash_to_hashtable (SV *hash, int size,
+ const char *type_keys,
+ const char *type_values);
extern void *weechat_perl_exec (struct t_plugin_script *script,
int ret_type, const char *function,
const char *format, void **argv);
diff --git a/src/plugins/plugin-script.c b/src/plugins/plugin-script.c
index b1df0f49d..bc2babc49 100644
--- a/src/plugins/plugin-script.c
+++ b/src/plugins/plugin-script.c
@@ -286,7 +286,7 @@ plugin_script_str2ptr (struct t_weechat_plugin *weechat_plugin,
return (void *)value;
invalid:
- if (weechat_plugin->debug >= 1)
+ if ((weechat_plugin->debug >= 1) && script_name && function_name)
{
ptr_buffer = weechat_buffer_search_main ();
if (ptr_buffer)
diff --git a/src/plugins/plugin.c b/src/plugins/plugin.c
index 323e5068b..dfec3a14c 100644
--- a/src/plugins/plugin.c
+++ b/src/plugins/plugin.c
@@ -39,6 +39,7 @@
#include "../core/weechat.h"
#include "../core/wee-config.h"
+#include "../core/wee-eval.h"
#include "../core/wee-hashtable.h"
#include "../core/wee-hdata.h"
#include "../core/wee-hook.h"
@@ -521,6 +522,7 @@ plugin_load (const char *filename, int argc, char **argv)
new_plugin->string_decode_base64 = &string_decode_base64;
new_plugin->string_is_command_char = &string_is_command_char;
new_plugin->string_input_for_buffer = &string_input_for_buffer;
+ new_plugin->string_eval_expression = &eval_expression;
new_plugin->utf8_has_8bits = &utf8_has_8bits;
new_plugin->utf8_is_valid = &utf8_is_valid;
diff --git a/src/plugins/python/weechat-python-api.c b/src/plugins/python/weechat-python-api.c
index cc8f2a4e1..f450f556b 100644
--- a/src/plugins/python/weechat-python-api.c
+++ b/src/plugins/python/weechat-python-api.c
@@ -444,6 +444,43 @@ weechat_python_api_string_input_for_buffer (PyObject *self, PyObject *args)
}
/*
+ * weechat_python_api_string_eval_expression: evaluate expression and return
+ * result
+ */
+
+static PyObject *
+weechat_python_api_string_eval_expression (PyObject *self, PyObject *args)
+{
+ char *expr, *result;
+ struct t_hashtable *pointers, *extra_vars;
+ PyObject *dict, *dict2, *return_value;
+
+ API_FUNC(1, "string_eval_expression", API_RETURN_EMPTY);
+ expr = NULL;
+ pointers = NULL;
+ extra_vars = NULL;
+ if (!PyArg_ParseTuple (args, "sOO", &expr, &dict, &dict2))
+ API_WRONG_ARGS(API_RETURN_EMPTY);
+ pointers = weechat_python_dict_to_hashtable (dict,
+ WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_POINTER);
+ extra_vars = weechat_python_dict_to_hashtable (dict2,
+ WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_STRING);
+
+ result = weechat_string_eval_expression (expr, pointers, extra_vars);
+
+ if (pointers)
+ weechat_hashtable_free (pointers);
+ if (extra_vars)
+ weechat_hashtable_free (extra_vars);
+
+ API_RETURN_STRING_FREE(result);
+}
+
+/*
* weechat_python_api_mkdir_home: create a directory in WeeChat home
*/
@@ -2081,7 +2118,9 @@ weechat_python_api_key_bind (PyObject *self, PyObject *args)
API_WRONG_ARGS(API_RETURN_INT(0));
hashtable = weechat_python_dict_to_hashtable (dict,
- WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE);
+ WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_STRING);
num_keys = weechat_key_bind (context, hashtable);
@@ -2652,7 +2691,9 @@ weechat_python_api_hook_process_hashtable (PyObject *self, PyObject *args)
&data))
API_WRONG_ARGS(API_RETURN_EMPTY);
options = weechat_python_dict_to_hashtable (dict,
- WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE);
+ WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_STRING);
result = API_PTR2STR(plugin_script_api_hook_process_hashtable (weechat_python_plugin,
python_current_script,
@@ -3077,7 +3118,9 @@ weechat_python_api_hook_hsignal_send (PyObject *self, PyObject *args)
API_WRONG_ARGS(API_RETURN_ERROR);
hashtable = weechat_python_dict_to_hashtable (dict,
- WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE);
+ WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_STRING);
weechat_hook_hsignal_send (signal, hashtable);
@@ -4840,7 +4883,9 @@ weechat_python_api_info_get_hashtable (PyObject *self, PyObject *args)
if (!PyArg_ParseTuple (args, "sO", &info_name, &dict))
API_WRONG_ARGS(API_RETURN_EMPTY);
hashtable = weechat_python_dict_to_hashtable (dict,
- WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE);
+ WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_STRING);
result_hashtable = weechat_info_get_hashtable (info_name, hashtable);
result_dict = weechat_python_hashtable_to_dict (result_hashtable);
@@ -5613,7 +5658,9 @@ weechat_python_api_hdata_update (PyObject *self, PyObject *args)
if (!PyArg_ParseTuple (args, "ssO", &hdata, &pointer, &dict))
API_WRONG_ARGS(API_RETURN_INT(0));
hashtable = weechat_python_dict_to_hashtable (dict,
- WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE);
+ WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_STRING);
value = weechat_hdata_update (API_STR2PTR(hdata),
API_STR2PTR(pointer),
@@ -5807,6 +5854,7 @@ PyMethodDef weechat_python_funcs[] =
API_DEF_FUNC(string_remove_color),
API_DEF_FUNC(string_is_command_char),
API_DEF_FUNC(string_input_for_buffer),
+ API_DEF_FUNC(string_eval_expression),
API_DEF_FUNC(mkdir_home),
API_DEF_FUNC(mkdir),
API_DEF_FUNC(mkdir_parents),
diff --git a/src/plugins/python/weechat-python.c b/src/plugins/python/weechat-python.c
index 2eba42de4..d1a6d4185 100644
--- a/src/plugins/python/weechat-python.c
+++ b/src/plugins/python/weechat-python.c
@@ -232,23 +232,23 @@ weechat_python_hashtable_to_dict (struct t_hashtable *hashtable)
/*
* weechat_python_dict_to_hashtable: get WeeChat hashtable with python
* dictionary
- * 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_python_dict_to_hashtable (PyObject *dict, int hashtable_size)
+weechat_python_dict_to_hashtable (PyObject *dict, int size,
+ const char *type_keys,
+ const char *type_values)
{
struct t_hashtable *hashtable;
PyObject *key, *value;
Py_ssize_t pos;
char *str_key, *str_value;
- hashtable = weechat_hashtable_new (hashtable_size,
- WEECHAT_HASHTABLE_STRING,
- WEECHAT_HASHTABLE_STRING,
+ hashtable = weechat_hashtable_new (size,
+ type_keys,
+ type_values,
NULL,
NULL);
if (!hashtable)
@@ -275,7 +275,17 @@ weechat_python_dict_to_hashtable (PyObject *dict, int hashtable_size)
str_value = weechat_python_unicode_to_string (value);
if (str_key)
- weechat_hashtable_set (hashtable, str_key, str_value);
+ {
+ if (strcmp (type_values, WEECHAT_HASHTABLE_STRING) == 0)
+ weechat_hashtable_set (hashtable, str_key, str_value);
+ else if (strcmp (type_values, WEECHAT_HASHTABLE_POINTER) == 0)
+ {
+ weechat_hashtable_set (hashtable, str_key,
+ plugin_script_str2ptr (weechat_python_plugin,
+ NULL, NULL,
+ str_value));
+ }
+ }
if (str_key)
free (str_key);
@@ -388,7 +398,9 @@ weechat_python_exec (struct t_plugin_script *script,
else if (ret_type == WEECHAT_SCRIPT_EXEC_HASHTABLE)
{
ret_value = weechat_python_dict_to_hashtable (rc,
- WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE);
+ WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_STRING);
Py_XDECREF(rc);
}
else
diff --git a/src/plugins/python/weechat-python.h b/src/plugins/python/weechat-python.h
index 1a522603a..0a1aa2fe5 100644
--- a/src/plugins/python/weechat-python.h
+++ b/src/plugins/python/weechat-python.h
@@ -45,7 +45,9 @@ extern const char *python_current_script_filename;
extern PyObject *weechat_python_hashtable_to_dict (struct t_hashtable *hashtable);
extern struct t_hashtable *weechat_python_dict_to_hashtable (PyObject *dict,
- int hashtable_size);
+ int size,
+ const char *type_keys,
+ const char *type_values);
extern void *weechat_python_exec (struct t_plugin_script *script,
int ret_type, const char *function,
char *format, void **argv);
diff --git a/src/plugins/ruby/weechat-ruby-api.c b/src/plugins/ruby/weechat-ruby-api.c
index 23420282e..a0911bfe9 100644
--- a/src/plugins/ruby/weechat-ruby-api.c
+++ b/src/plugins/ruby/weechat-ruby-api.c
@@ -508,6 +508,47 @@ weechat_ruby_api_string_input_for_buffer (VALUE class, VALUE string)
}
/*
+ * weechat_ruby_api_string_eval_expression: evaluate an expression and return
+ * result
+ */
+
+static VALUE
+weechat_ruby_api_string_eval_expression (VALUE class, VALUE expr,
+ VALUE pointers, VALUE extra_vars)
+{
+ char *c_expr, *result;
+ struct t_hashtable *c_pointers, *c_extra_vars;
+ VALUE return_value;
+
+ API_FUNC(1, "string_eval_expression", API_RETURN_EMPTY);
+ if (NIL_P (expr) || NIL_P (pointers) || NIL_P (extra_vars))
+ API_WRONG_ARGS(API_RETURN_EMPTY);
+
+ Check_Type (expr, T_STRING);
+ Check_Type (pointers, T_HASH);
+ Check_Type (extra_vars, T_HASH);
+
+ c_expr = StringValuePtr (expr);
+ c_pointers = weechat_ruby_hash_to_hashtable (pointers,
+ WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_POINTER);
+ c_extra_vars = weechat_ruby_hash_to_hashtable (extra_vars,
+ WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_STRING);
+
+ result = weechat_string_eval_expression (c_expr, c_pointers, c_extra_vars);
+
+ if (c_pointers)
+ weechat_hashtable_free (c_pointers);
+ if (c_extra_vars)
+ weechat_hashtable_free (c_extra_vars);
+
+ API_RETURN_STRING_FREE(result);
+}
+
+/*
* weechat_ruby_api_mkdir_home: create a directory in WeeChat home
*/
@@ -2389,7 +2430,9 @@ weechat_ruby_api_key_bind (VALUE class, VALUE context, VALUE keys)
c_context = StringValuePtr (context);
c_keys = weechat_ruby_hash_to_hashtable (keys,
- WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE);
+ WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_STRING);
num_keys = weechat_key_bind (c_context, c_keys);
@@ -3031,7 +3074,9 @@ weechat_ruby_api_hook_process_hashtable (VALUE class, VALUE command,
c_command = StringValuePtr (command);
c_options = weechat_ruby_hash_to_hashtable (options,
- WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE);
+ WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_STRING);
c_timeout = FIX2INT (timeout);
c_function = StringValuePtr (function);
c_data = StringValuePtr (data);
@@ -3498,7 +3543,9 @@ weechat_ruby_api_hook_hsignal_send (VALUE class, VALUE signal, VALUE hashtable)
c_signal = StringValuePtr (signal);
c_hashtable = weechat_ruby_hash_to_hashtable (hashtable,
- WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE);
+ WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_STRING);
weechat_hook_hsignal_send (c_signal, c_hashtable);
@@ -5543,7 +5590,9 @@ weechat_ruby_api_info_get_hashtable (VALUE class, VALUE info_name,
c_info_name = StringValuePtr (info_name);
c_hashtable = weechat_ruby_hash_to_hashtable (hash,
- WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE);
+ WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_STRING);
result_hashtable = weechat_info_get_hashtable (c_info_name, c_hashtable);
result_hash = weechat_ruby_hashtable_to_hash (result_hashtable);
@@ -6465,7 +6514,9 @@ weechat_ruby_api_hdata_update (VALUE class, VALUE hdata, VALUE pointer,
c_hdata = StringValuePtr (hdata);
c_pointer = StringValuePtr (pointer);
c_hashtable = weechat_ruby_hash_to_hashtable (hashtable,
- WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE);
+ WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_STRING);
value = weechat_hdata_update (API_STR2PTR(c_hdata),
API_STR2PTR(c_pointer),
@@ -6732,6 +6783,7 @@ weechat_ruby_api_init (VALUE ruby_mWeechat)
API_DEF_FUNC(string_remove_color, 2);
API_DEF_FUNC(string_is_command_char, 1);
API_DEF_FUNC(string_input_for_buffer, 1);
+ API_DEF_FUNC(string_eval_expression, 3);
API_DEF_FUNC(mkdir_home, 2);
API_DEF_FUNC(mkdir, 2);
API_DEF_FUNC(mkdir_parents, 2);
diff --git a/src/plugins/ruby/weechat-ruby.c b/src/plugins/ruby/weechat-ruby.c
index 882796d7d..e2b68db58 100644
--- a/src/plugins/ruby/weechat-ruby.c
+++ b/src/plugins/ruby/weechat-ruby.c
@@ -147,32 +147,43 @@ int
weechat_ruby_hash_foreach_cb (VALUE key, VALUE value, void *arg)
{
struct t_hashtable *hashtable;
+ const char *type_values;
hashtable = (struct t_hashtable *)arg;
if ((TYPE(key) == T_STRING) && (TYPE(value) == T_STRING))
{
- weechat_hashtable_set (hashtable, StringValuePtr(key),
- StringValuePtr(value));
+ type_values = weechat_hashtable_get_string (hashtable, "type_values");
+ if (strcmp (type_values, WEECHAT_HASHTABLE_STRING) == 0)
+ {
+ weechat_hashtable_set (hashtable, StringValuePtr(key),
+ StringValuePtr(value));
+ }
+ else if (strcmp (type_values, WEECHAT_HASHTABLE_POINTER) == 0)
+ {
+ weechat_hashtable_set (hashtable, StringValuePtr(key),
+ plugin_script_str2ptr (weechat_ruby_plugin,
+ NULL, NULL,
+ StringValuePtr(value)));
+ }
}
return 0;
}
/*
* weechat_ruby_hash_to_hashtable: get WeeChat hashtable with ruby hashtable
- * 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_ruby_hash_to_hashtable (VALUE hash, int hashtable_size)
+weechat_ruby_hash_to_hashtable (VALUE hash, int size, const char *type_keys,
+ const char *type_values)
{
struct t_hashtable *hashtable;
- hashtable = weechat_hashtable_new (hashtable_size,
- WEECHAT_HASHTABLE_STRING,
- WEECHAT_HASHTABLE_STRING,
+ hashtable = weechat_hashtable_new (size,
+ type_keys,
+ type_values,
NULL,
NULL);
if (!hashtable)
@@ -375,7 +386,9 @@ weechat_ruby_exec (struct t_plugin_script *script,
else if (ret_type == WEECHAT_SCRIPT_EXEC_HASHTABLE)
{
ret_value = weechat_ruby_hash_to_hashtable (rc,
- WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE);
+ WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_STRING);
}
else
{
diff --git a/src/plugins/ruby/weechat-ruby.h b/src/plugins/ruby/weechat-ruby.h
index cf3e7a1b2..398616afa 100644
--- a/src/plugins/ruby/weechat-ruby.h
+++ b/src/plugins/ruby/weechat-ruby.h
@@ -37,7 +37,9 @@ extern const char *ruby_current_script_filename;
extern VALUE weechat_ruby_hashtable_to_hash (struct t_hashtable *hashtable);
extern struct t_hashtable *weechat_ruby_hash_to_hashtable (VALUE dict,
- int hashtable_size);
+ int size,
+ const char *type_keys,
+ const char *type_values);
void *weechat_ruby_exec (struct t_plugin_script *script,
int ret_type, const char *function,
const char *format, void **argv);
diff --git a/src/plugins/tcl/weechat-tcl-api.c b/src/plugins/tcl/weechat-tcl-api.c
index 0738fc39e..5e89aa3f3 100644
--- a/src/plugins/tcl/weechat-tcl-api.c
+++ b/src/plugins/tcl/weechat-tcl-api.c
@@ -612,6 +612,45 @@ weechat_tcl_api_string_input_for_buffer (ClientData clientData, Tcl_Interp *inte
}
/*
+ * weechat_tcl_api_string_eval_expression: evaluate an expression and return
+ * result
+ */
+
+static int
+weechat_tcl_api_string_eval_expression (ClientData clientData,
+ Tcl_Interp *interp,
+ int objc, Tcl_Obj *CONST objv[])
+{
+ Tcl_Obj *objp;
+ char *expr, *result;
+ struct t_hashtable *pointers, *extra_vars;
+ int i;
+
+ API_FUNC(1, "string_eval_expression", API_RETURN_EMPTY);
+ if (objc < 4)
+ API_WRONG_ARGS(API_RETURN_EMPTY);
+
+ expr = Tcl_GetStringFromObj (objv[1], &i);
+ pointers = weechat_tcl_dict_to_hashtable (interp, objv[2],
+ WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_POINTER);
+ extra_vars = weechat_tcl_dict_to_hashtable (interp, objv[3],
+ WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_STRING);
+
+ result = weechat_string_eval_expression (expr, pointers, extra_vars);
+
+ if (pointers)
+ weechat_hashtable_free (pointers);
+ if (extra_vars)
+ weechat_hashtable_free (extra_vars);
+
+ API_RETURN_STRING_FREE(result);
+}
+
+/*
* weechat_tcl_api_mkdir_home: create a directory in WeeChat home
*/
@@ -2372,7 +2411,9 @@ weechat_tcl_api_key_bind (ClientData clientData, Tcl_Interp *interp,
context = Tcl_GetStringFromObj (objv[1], &i);
hashtable = weechat_tcl_dict_to_hashtable (interp, objv[2],
- WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE);
+ WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_STRING);
num_keys = weechat_key_bind (context, hashtable);
@@ -2973,7 +3014,9 @@ weechat_tcl_api_hook_process_hashtable (ClientData clientData,
command = Tcl_GetStringFromObj (objv[1], &i);
options = weechat_tcl_dict_to_hashtable (interp, objv[2],
- WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE);
+ WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_STRING);
function = Tcl_GetStringFromObj (objv[4], &i);
data = Tcl_GetStringFromObj (objv[5], &i);
@@ -3416,7 +3459,9 @@ weechat_tcl_api_hook_hsignal_send (ClientData clientData, Tcl_Interp *interp,
signal = Tcl_GetStringFromObj (objv[1], &i);
hashtable = weechat_tcl_dict_to_hashtable (interp, objv[2],
- WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE);
+ WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_STRING);
weechat_hook_hsignal_send (signal, hashtable);
@@ -5320,7 +5365,9 @@ weechat_tcl_api_info_get_hashtable (ClientData clientData, Tcl_Interp *interp,
API_WRONG_ARGS(API_RETURN_EMPTY);
hashtable = weechat_tcl_dict_to_hashtable (interp, objv[2],
- WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE);
+ WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_STRING);
result_hashtable = weechat_info_get_hashtable (Tcl_GetStringFromObj (objv[1], &i),
hashtable);
@@ -6178,7 +6225,9 @@ weechat_tcl_api_hdata_update (ClientData clientData, Tcl_Interp *interp,
hdata = Tcl_GetStringFromObj (objv[1], &i);
pointer = Tcl_GetStringFromObj (objv[2], &i);
hashtable = weechat_tcl_dict_to_hashtable (interp, objv[3],
- WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE);
+ WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_STRING);
value = weechat_hdata_update (API_STR2PTR(hdata),
API_STR2PTR(pointer),
@@ -6495,6 +6544,7 @@ void weechat_tcl_api_init (Tcl_Interp *interp)
API_DEF_FUNC(string_remove_color);
API_DEF_FUNC(string_is_command_char);
API_DEF_FUNC(string_input_for_buffer);
+ API_DEF_FUNC(string_eval_expression);
API_DEF_FUNC(mkdir_home);
API_DEF_FUNC(mkdir);
API_DEF_FUNC(mkdir_parents);
diff --git a/src/plugins/tcl/weechat-tcl.c b/src/plugins/tcl/weechat-tcl.c
index 26095c467..95a55fe71 100644
--- a/src/plugins/tcl/weechat-tcl.c
+++ b/src/plugins/tcl/weechat-tcl.c
@@ -125,24 +125,23 @@ weechat_tcl_hashtable_to_dict (Tcl_Interp *interp,
/*
* weechat_tcl_dict_to_hashtable: get WeeChat hashtable with tcl dict
- * 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_tcl_dict_to_hashtable (Tcl_Interp *interp, Tcl_Obj *dict,
- int hashtable_size)
+ int size, const char *type_keys,
+ const char *type_values)
{
struct t_hashtable *hashtable;
Tcl_DictSearch search;
Tcl_Obj *key, *value;
int done;
- hashtable = weechat_hashtable_new (hashtable_size,
- WEECHAT_HASHTABLE_STRING,
- WEECHAT_HASHTABLE_STRING,
+ hashtable = weechat_hashtable_new (size,
+ type_keys,
+ type_values,
NULL,
NULL);
if (!hashtable)
@@ -152,9 +151,20 @@ weechat_tcl_dict_to_hashtable (Tcl_Interp *interp, Tcl_Obj *dict,
{
for (; !done ; Tcl_DictObjNext(&search, &key, &value, &done))
{
- weechat_hashtable_set (hashtable,
- Tcl_GetString (key),
- Tcl_GetString (value));
+ if (strcmp (type_values, WEECHAT_HASHTABLE_STRING) == 0)
+ {
+ weechat_hashtable_set (hashtable,
+ Tcl_GetString (key),
+ Tcl_GetString (value));
+ }
+ else if (strcmp (type_values, WEECHAT_HASHTABLE_POINTER) == 0)
+ {
+ weechat_hashtable_set (hashtable,
+ Tcl_GetString (key),
+ plugin_script_str2ptr (weechat_tcl_plugin,
+ NULL, NULL,
+ Tcl_GetString (value)));
+ }
}
}
Tcl_DictObjDone(&search);
@@ -246,7 +256,9 @@ weechat_tcl_exec (struct t_plugin_script *script,
{
ret_val = weechat_tcl_dict_to_hashtable (interp,
Tcl_GetObjResult (interp),
- WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE);
+ WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_STRING);
}
tcl_current_script = old_tcl_script;
diff --git a/src/plugins/tcl/weechat-tcl.h b/src/plugins/tcl/weechat-tcl.h
index 62a258885..65453fc83 100644
--- a/src/plugins/tcl/weechat-tcl.h
+++ b/src/plugins/tcl/weechat-tcl.h
@@ -39,7 +39,9 @@ extern Tcl_Obj *weechat_tcl_hashtable_to_dict (Tcl_Interp *interp,
struct t_hashtable *hashtable);
extern struct t_hashtable *weechat_tcl_dict_to_hashtable (Tcl_Interp *interp,
Tcl_Obj *dict,
- int hashtable_size);
+ int size,
+ const char *type_keys,
+ const char *type_values);
extern void *weechat_tcl_exec (struct t_plugin_script *script,
int ret_type, const char *function,
const char *format, void **argv);
diff --git a/src/plugins/weechat-plugin.h b/src/plugins/weechat-plugin.h
index b70c75de4..8b55e560c 100644
--- a/src/plugins/weechat-plugin.h
+++ b/src/plugins/weechat-plugin.h
@@ -50,7 +50,7 @@ struct timeval;
* please change the date with current one; for a second change at same
* date, increment the 01, otherwise please keep 01.
*/
-#define WEECHAT_PLUGIN_API_VERSION "20121014-01"
+#define WEECHAT_PLUGIN_API_VERSION "20121102-01"
/* macros for defining plugin infos */
#define WEECHAT_PLUGIN_NAME(__name) \
@@ -251,6 +251,9 @@ struct t_weechat_plugin
int (*string_decode_base64) (const char *from, char *to);
int (*string_is_command_char) (const char *string);
const char *(*string_input_for_buffer) (const char *string);
+ char *(*string_eval_expression )(const char *expr,
+ struct t_hashtable *pointers,
+ struct t_hashtable *extra_vars);
/* UTF-8 strings */
int (*utf8_has_8bits) (const char *string);
@@ -1009,6 +1012,10 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin);
weechat_plugin->string_is_command_char(__string)
#define weechat_string_input_for_buffer(__string) \
weechat_plugin->string_input_for_buffer(__string)
+#define weechat_string_eval_expression(__expr, __pointers, \
+ __extra_vars) \
+ weechat_plugin->string_eval_expression(__expr, __pointers, \
+ __extra_vars) \
/* UTF-8 strings */
#define weechat_utf8_has_8bits(__string) \