2 # Copyright (C) 2008-2013 Sebastien Helleu <flashcode@flashtux.org>
3 # Copyright (C) 2010-2012 Nils Görs <weechatter@arcor.de>
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18 # Set WeeChat and plugins options interactively.
22 # 2014-01-30, stfn <stfnmd@gmail.com>:
23 # version 3.4: add new options "color_value_diff" and "color_value_diff_selected"
24 # 2014-01-16, luz <ne.tetewi@gmail.com>:
25 # version 3.3: fix bug with column alignment in iset buffer when option
26 # name contains unicode characters
27 # 2013-08-03, Sebastien Helleu <flashcode@flashtux.org>:
28 # version 3.2: allow "q" as input in iset buffer to close it
29 # 2013-07-14, Sebastien Helleu <flashcode@flashtux.org>:
30 # version 3.1: remove unneeded calls to iset_refresh() in mouse callback
31 # (faster mouse actions when lot of options are displayed),
32 # fix bug when clicking on a line after the last option displayed
33 # 2013-04-30, arza <arza@arza.us>:
34 # version 3.0: simpler title, fix refresh on unset
35 # 2012-12-16, nils_2 <weechatter@arcor.de>:
36 # version 2.9: fix focus window with iset buffer on mouse click
37 # 2012-08-25, nils_2 <weechatter@arcor.de>:
38 # version 2.8: most important key and mouse bindings for iset buffer added to title-bar (idea The-Compiler)
39 # 2012-07-31, nils_2 <weechatter@arcor.de>:
40 # version 2.7: add combined option and value search (see /help iset)
41 # : add exact value search (see /help iset)
42 # : fix problem with metacharacter in value search
43 # : fix use of uninitialized value for unset option and reset value of option
44 # 2012-07-25, nils_2 <weechatter@arcor.de>:
45 # version 2.6: switch to iset buffer (if existing) when command /iset is called with arguments
46 # 2012-03-17, Sebastien Helleu <flashcode@flashtux.org>:
47 # version 2.5: fix check of sections when creating config file
48 # 2012-03-09, Sebastien Helleu <flashcode@flashtux.org>:
49 # version 2.4: fix reload of config file
50 # 2012-02-02, nils_2 <weechatter@arcor.de>:
51 # version 2.3: fixed: refresh problem with new search results and cursor was outside window.
52 # : add: new option "current_line" in title bar
53 # version 2.2: fixed: refresh error when toggling plugins description
54 # 2011-11-05, nils_2 <weechatter@arcor.de>:
55 # version 2.1: use own config file (iset.conf), fix own help color (used immediately)
56 # 2011-10-16, nils_2 <weechatter@arcor.de>:
57 # version 2.0: add support for left-mouse-button and more sensitive mouse gesture (for integer/color options)
58 # add help text for mouse support
59 # 2011-09-20, Sebastien Helleu <flashcode@flashtux.org>:
60 # version 1.9: add mouse support, fix iset buffer, fix errors on first load under FreeBSD
61 # 2011-07-21, nils_2 <weechatter@arcor.de>:
62 # version 1.8: added: option "show_plugin_description" (alt+p)
63 # fixed: typos in /help iset (lower case for alt+'x' keys)
64 # 2011-05-29, nils_2 <weechatter@arcor.de>:
65 # version 1.7: added: version check for future needs
66 # added: new option (scroll_horiz) and usage of scroll_horiz function (weechat >= 0.3.6 required)
67 # fixed: help_bar did not pop up immediately using key-shortcut
68 # 2011-02-19, nils_2 <weechatter@arcor.de>:
69 # version 1.6: added: display of all possible values in help bar (show_help_extra_info)
70 # fixed: external user options never loaded when starting iset first time
71 # 2011-02-13, Sebastien Helleu <flashcode@flashtux.org>:
72 # version 1.5: use new help format for command arguments
73 # 2011-02-03, nils_2 <weechatter@arcor.de>:
74 # version 1.4: fixed: restore value filter after /upgrade using buffer local variable.
75 # 2011-01-14, nils_2 <weechatter@arcor.de>:
76 # version 1.3: added function to search for values (option value_search_char).
78 # 2010-12-26, Sebastien Helleu <flashcode@flashtux.org>:
79 # version 1.2: improve speed of /upgrade when iset buffer is open,
80 # restore filter used after /upgrade using buffer local variable,
81 # use /iset filter argument if buffer is open.
82 # 2010-11-21, drubin <drubin+weechat@smartcube.co.za>:
83 # version 1.1.1: fix bugs with cursor position
84 # 2010-11-20, nils_2 <weechatter@arcor.de>:
85 # version 1.1: cursor position set to value
86 # 2010-08-03, Sebastien Helleu <flashcode@flashtux.org>:
87 # version 1.0: move misplaced call to infolist_free()
88 # 2010-02-02, rettub <rettub@gmx.net>:
89 # version 0.9: turn all the help stuff off if option 'show_help_bar' is 'off',
90 # new key binding <alt>-<v> to toggle help_bar and help stuff on/off
91 # 2010-01-30, nils_2 <weechatter@arcor.de>:
92 # version 0.8: fix error when option does not exist
93 # 2010-01-24, Sebastien Helleu <flashcode@flashtux.org>:
94 # version 0.7: display iset bar only on iset buffer
95 # 2010-01-22, nils_2 <weechatter@arcor.de> and drubin:
96 # version 0.6: add description in a bar, fix singular/plural bug in title bar,
97 # fix selected line when switching buffer
98 # 2009-06-21, Sebastien Helleu <flashcode@flashtux.org>:
99 # version 0.5: fix bug with iset buffer after /upgrade
100 # 2009-05-02, Sebastien Helleu <flashcode@flashtux.org>:
101 # version 0.4: sync with last API changes
102 # 2009-01-04, Sebastien Helleu <flashcode@flashtux.org>:
103 # version 0.3: open iset buffer when /iset command is executed
104 # 2009-01-04, Sebastien Helleu <flashcode@flashtux.org>:
105 # version 0.2: use null values for options, add colors, fix refresh bugs,
106 # use new keys to reset/unset options, sort options by name,
107 # display number of options in buffer's title
108 # 2008-11-05, Sebastien Helleu <flashcode@flashtux.org>:
109 # version 0.1: first official version
110 # 2008-04-19, Sebastien Helleu <flashcode@flashtux.org>:
115 my $PRGNAME = "iset";
117 my $DESCR = "Interactive Set for configuration options";
118 my $AUTHOR = "Sebastien Helleu <flashcode\@flashtux.org>";
119 my $LICENSE = "GPL3";
121 my $ISET_CONFIG_FILE_NAME = "iset";
123 my $iset_config_file;
124 my $iset_buffer = "";
125 my $wee_version_number = 0;
127 my @options_names = ();
128 my @options_types = ();
129 my @options_values = ();
130 my @options_default_values = ();
131 my @options_is_null = ();
132 my $option_max_length = 0;
133 my $current_line = 0;
135 my $description = "";
136 my $options_name_copy = "";
137 my $iset_filter_title = "";
138 # search modes: 0 = index() on value, 1 = grep() on value, 2 = grep() on option, 3 = grep on option & value
140 my $search_value = "";
141 my $help_text_keys = "alt + space: toggle, +/-: increase/decrease, enter: change, ir: reset, iu: unset, v: toggle help bar";
142 my $help_text_mouse = "Mouse: left: select, right: toggle/set, right + drag left/right: increase/decrease";
145 my %mouse_keys = ("\@chat(perl.$PRGNAME):button1" => "hsignal:iset_mouse",
146 "\@chat(perl.$PRGNAME):button2*" => "hsignal:iset_mouse",
147 "\@chat(perl.$PRGNAME):wheelup" => "/repeat 5 /iset **up",
148 "\@chat(perl.$PRGNAME):wheeldown" => "/repeat 5 /iset **down");
153 if ($iset_buffer ne "")
155 my $current_line_counter = "";
156 $current_line_counter = ($current_line + 1) . "/" if (weechat
::config_boolean
($options_iset{"show_current_line"}) == 1);
157 my $show_filter = "";
158 if ($search_mode eq 0)
160 $iset_filter_title = "(value) ";
161 $show_filter = $search_value;
162 if ( substr($show_filter,0,1) eq weechat
::config_string
($options_iset{"value_search_char"}) )
164 $show_filter = substr($show_filter,1,length($show_filter));
167 elsif ($search_mode eq 1)
169 $iset_filter_title = "(value) ";
170 $show_filter = "*".$search_value."*";
172 elsif ($search_mode eq 2)
174 $iset_filter_title = "";
175 $filter = "*" if ($filter eq "");
176 $show_filter = $filter;
178 elsif ($search_mode eq 3)
180 $iset_filter_title = "(option) ";
181 $show_filter = $filter
182 .weechat
::color
("default")
184 .weechat
::color
("yellow")
185 ."*".$search_value."*";
187 weechat
::buffer_set
($iset_buffer, "title",
189 .weechat
::color
("yellow")
191 .weechat
::color
("default")." | "
192 .$current_line_counter
201 sub iset_create_filter
204 if ( $search_mode == 3 )
206 my @cmd_array = split(/ /,$filter);
207 my $array_count = @cmd_array;
208 $filter = $cmd_array[0];
209 $filter = $cmd_array[0] . " " . $cmd_array[1] if ( $array_count >2 );
211 $filter = "$1.*" if ($filter =~ /f (.*)/); # search file
212 $filter = "*.$1.*" if ($filter =~ /s (.*)/); # search section
213 if ((substr($filter, 0, 1) ne "*") && (substr($filter, -1, 1) ne "*"))
215 $filter = "*".$filter."*";
217 if ($iset_buffer ne "")
219 weechat
::buffer_set
($iset_buffer, "localvar_set_iset_filter", $filter);
223 sub iset_buffer_input
225 my ($data, $buffer, $string) = ($_[0], $_[1], $_[2]);
228 weechat
::buffer_close
($buffer);
229 return weechat
::WEECHAT_RC_OK
;
232 my @cmd_array = split(/ /,$string);
233 my $array_count = @cmd_array;
234 my $string2 = substr($string, 0, 1);
235 if ($string2 eq weechat
::config_string
($options_iset{"value_search_char"})
236 or (defined $cmd_array[0] and $cmd_array[0] eq weechat
::config_string
($options_iset{"value_search_char"}).weechat
::config_string
($options_iset{"value_search_char"})) )
239 $search_value = substr($string, 1);
240 iset_get_values
($search_value);
241 if ($iset_buffer ne "")
243 weechat
::buffer_set
($iset_buffer, "localvar_set_iset_search_value", $search_value);
249 if ( $array_count >= 2 and $cmd_array[0] ne "f" or $cmd_array[0] ne "s")
251 if ( defined $cmd_array[1] and substr($cmd_array[1], 0, 1) eq weechat
::config_string
($options_iset{"value_search_char"})
252 or defined $cmd_array[2] and substr($cmd_array[2], 0, 1) eq weechat
::config_string
($options_iset{"value_search_char"}) )
255 $search_value = substr($cmd_array[1], 1); # cut value_search_char
256 $search_value = substr($cmd_array[2], 1) if ( $array_count > 2); # cut value_search_char
259 if ( $search_mode == 3)
261 iset_create_filter
($string);
262 iset_get_options
($search_value);
265 iset_create_filter
($string);
266 iset_get_options
("");
269 weechat
::buffer_set
($iset_buffer, "localvar_set_iset_search_mode", $search_mode);
270 weechat
::buffer_clear
($buffer);
273 return weechat
::WEECHAT_RC_OK
;
276 sub iset_buffer_close
280 return weechat
::WEECHAT_RC_OK
;
286 $iset_buffer = weechat
::buffer_search
($LANG, $PRGNAME);
287 if ($iset_buffer eq "")
289 $iset_buffer = weechat
::buffer_new
($PRGNAME, "iset_buffer_input", "", "iset_buffer_close", "");
293 my $new_filter = weechat
::buffer_get_string
($iset_buffer, "localvar_iset_filter");
294 $search_mode = weechat
::buffer_get_string
($iset_buffer, "localvar_iset_search_mode");
295 $search_value = weechat
::buffer_get_string
($iset_buffer, "localvar_iset_search_value");
296 $filter = $new_filter if ($new_filter ne "");
298 if ($iset_buffer ne "")
300 weechat
::buffer_set
($iset_buffer, "type", "free");
302 weechat
::buffer_set
($iset_buffer, "key_bind_ctrl-L", "/iset **refresh");
303 weechat
::buffer_set
($iset_buffer, "key_bind_meta2-A", "/iset **up");
304 weechat
::buffer_set
($iset_buffer, "key_bind_meta2-B", "/iset **down");
305 weechat
::buffer_set
($iset_buffer, "key_bind_meta2-23~", "/iset **left");
306 weechat
::buffer_set
($iset_buffer, "key_bind_meta2-24~" , "/iset **right");
307 weechat
::buffer_set
($iset_buffer, "key_bind_meta- ", "/iset **toggle");
308 weechat
::buffer_set
($iset_buffer, "key_bind_meta-+", "/iset **incr");
309 weechat
::buffer_set
($iset_buffer, "key_bind_meta--", "/iset **decr");
310 weechat
::buffer_set
($iset_buffer, "key_bind_meta-imeta-r", "/iset **reset");
311 weechat
::buffer_set
($iset_buffer, "key_bind_meta-imeta-u", "/iset **unset");
312 weechat
::buffer_set
($iset_buffer, "key_bind_meta-ctrl-J", "/iset **set");
313 weechat
::buffer_set
($iset_buffer, "key_bind_meta-ctrl-M", "/iset **set");
314 weechat
::buffer_set
($iset_buffer, "key_bind_meta-meta2-1~", "/iset **scroll_top");
315 weechat
::buffer_set
($iset_buffer, "key_bind_meta-meta2-4~", "/iset **scroll_bottom");
316 weechat
::buffer_set
($iset_buffer, "key_bind_meta-v", "/iset **toggle_help");
317 weechat
::buffer_set
($iset_buffer, "key_bind_meta-p", "/iset **toggle_show_plugin_desc");
318 weechat
::buffer_set
($iset_buffer, "localvar_set_iset_filter", $filter);
319 weechat
::buffer_set
($iset_buffer, "localvar_set_iset_search_mode", $search_mode);
320 weechat
::buffer_set
($iset_buffer, "localvar_set_iset_search_value", $search_value);
326 my $var_value = $_[0];
327 $var_value = "" if (not defined $var_value);
328 $var_value = lc($var_value);
329 $search_value = $var_value;
333 @options_values = ();
334 @options_default_values = ();
335 @options_is_null = ();
336 $option_max_length = 0;
337 my %options_internal = ();
343 weechat
::buffer_set
($iset_buffer, "localvar_set_iset_search_value", $var_value) if ($search_mode == 3);
345 my $infolist = weechat
::infolist_get
("option", "", $filter);
346 while (weechat
::infolist_next
($infolist))
348 $key = sprintf("%08d", $i);
349 my $name = weechat
::infolist_string
($infolist, "full_name");
350 next if (weechat
::config_boolean
($options_iset{"show_plugin_description"}) == 0 and index ($name, "plugins.desc.") != -1);
351 my $type = weechat
::infolist_string
($infolist, "type");
352 my $value = weechat
::infolist_string
($infolist, "value");
353 my $default_value = weechat
::infolist_string
($infolist, "default_value");
354 my $is_null = weechat
::infolist_integer
($infolist, "value_is_null");
355 if ($search_mode == 3)
357 my $value = weechat
::infolist_string
($infolist, "value");
358 if ( grep /\Q$var_value/,lc($value) )
360 $options_internal{$name}{"type"} = $type;
361 $options_internal{$name}{"value"} = $value;
362 $options_internal{$name}{"default_value"} = $default_value;
363 $options_internal{$name}{"is_null"} = $is_null;
364 $option_max_length = length($name) if (length($name) > $option_max_length);
365 $iset_struct{$key} = $options_internal{$name};
366 push(@iset_focus, $iset_struct{$key});
371 $options_internal{$name}{"type"} = $type;
372 $options_internal{$name}{"value"} = $value;
373 $options_internal{$name}{"default_value"} = $default_value;
374 $options_internal{$name}{"is_null"} = $is_null;
375 $option_max_length = length($name) if (length($name) > $option_max_length);
376 $iset_struct{$key} = $options_internal{$name};
377 push(@iset_focus, $iset_struct{$key});
381 weechat
::infolist_free
($infolist);
383 foreach my $name (sort keys %options_internal)
385 push(@options_names, $name);
386 push(@options_types, $options_internal{$name}{"type"});
387 push(@options_values, $options_internal{$name}{"value"});
388 push(@options_default_values, $options_internal{$name}{"default_value"});
389 push(@options_is_null, $options_internal{$name}{"is_null"});
395 my $var_value = $_[0];
396 $var_value = lc($var_value);
397 if (substr($var_value,0,1) eq weechat
::config_string
($options_iset{"value_search_char"}) and $var_value ne weechat
::config_string
($options_iset{"value_search_char"}))
399 $var_value = substr($var_value,1,length($var_value));
402 iset_search_values
($var_value,$search_mode);
403 weechat
::buffer_set
($iset_buffer, "localvar_set_iset_search_mode", $search_mode);
404 weechat
::buffer_set
($iset_buffer, "localvar_set_iset_search_value", $var_value);
405 $search_value = $var_value;
407 sub iset_search_values
409 my ($var_value,$search_mode) = ($_[0],$_[1]);
412 @options_values = ();
413 @options_default_values = ();
414 @options_is_null = ();
415 $option_max_length = 0;
416 my %options_internal = ();
418 my $infolist = weechat
::infolist_get
("option", "", "*");
419 while (weechat
::infolist_next
($infolist))
421 my $name = weechat
::infolist_string
($infolist, "full_name");
422 next if (weechat
::config_boolean
($options_iset{"show_plugin_description"}) == 0 and index ($name, "plugins.desc.") != -1);
423 my $type = weechat
::infolist_string
($infolist, "type");
424 my $is_null = weechat
::infolist_integer
($infolist, "value_is_null");
425 my $value = weechat
::infolist_string
($infolist, "value");
426 my $default_value = weechat
::infolist_string
($infolist, "default_value");
429 if ( grep /\Q$var_value/,lc($value) )
431 $options_internal{$name}{"type"} = $type;
432 $options_internal{$name}{"value"} = $value;
433 $options_internal{$name}{"default_value"} = $default_value;
434 $options_internal{$name}{"is_null"} = $is_null;
435 $option_max_length = length($name) if (length($name) > $option_max_length);
440 # if ($value =~ /\Q$var_value/si)
441 if (lc($value) eq $var_value)
443 $options_internal{$name}{"type"} = $type;
444 $options_internal{$name}{"value"} = $value;
445 $options_internal{$name}{"default_value"} = $default_value;
446 $options_internal{$name}{"is_null"} = $is_null;
447 $option_max_length = length($name) if (length($name) > $option_max_length);
452 weechat
::infolist_free
($infolist);
453 foreach my $name (sort keys %options_internal)
455 push(@options_names, $name);
456 push(@options_types, $options_internal{$name}{"type"});
457 push(@options_values, $options_internal{$name}{"value"});
458 push(@options_default_values, $options_internal{$name}{"default_value"});
459 push(@options_is_null, $options_internal{$name}{"is_null"});
463 sub iset_refresh_line
465 if ($iset_buffer ne "")
468 if ($y <= $#options_names)
470 return if (! defined($options_types[$y]));
471 my $format = sprintf("%%s%%s%%s %%s %%-7s %%s %%s%%s%%s");
473 if ($wee_version_number >= 0x00040200)
475 $padding = " " x
($option_max_length - weechat
::strlen_screen
($options_names[$y]));
479 $padding = " " x
($option_max_length - length($options_names[$y]));
482 $around = "\"" if ((!$options_is_null[$y]) && ($options_types[$y] eq "string"));
484 my $color1 = weechat
::color
(weechat
::config_color
($options_iset{"color_option"}));
485 my $color2 = weechat
::color
(weechat
::config_color
($options_iset{"color_type"}));
487 if ($options_is_null[$y])
489 $color3 = weechat
::color
(weechat
::config_color
($options_iset{"color_value_undef"}));
491 elsif ($options_values[$y] ne $options_default_values[$y])
493 $color3 = weechat
::color
(weechat
::config_color
($options_iset{"color_value_diff"}));
497 $color3 = weechat
::color
(weechat
::config_color
($options_iset{"color_value"}));
499 if ($y == $current_line)
501 $color1 = weechat
::color
(weechat
::config_color
($options_iset{"color_option_selected"}).",".weechat
::config_color
($options_iset{"color_bg_selected"}));
502 $color2 = weechat
::color
(weechat
::config_color
($options_iset{"color_type_selected"}).",".weechat
::config_color
($options_iset{"color_bg_selected"}));
503 if ($options_is_null[$y])
505 $color3 = weechat
::color
(weechat
::config_color
($options_iset{"color_value_undef_selected"}).",".weechat
::config_color
($options_iset{"color_bg_selected"}));
507 elsif ($options_values[$y] ne $options_default_values[$y])
509 $color3 = weechat
::color
(weechat
::config_color
($options_iset{"color_value_diff_selected"}).",".weechat
::config_color
($options_iset{"color_bg_selected"}));
513 $color3 = weechat
::color
(weechat
::config_color
($options_iset{"color_value_selected"}).",".weechat
::config_color
($options_iset{"color_bg_selected"}));
516 my $value = $options_values[$y];
517 $value = "(undef)" if ($options_is_null[$y]);
518 my $strline = sprintf($format,
519 $color1, $options_names[$y], $padding,
520 $color2, $options_types[$y],
521 $color3, $around, $value, $around);
522 weechat
::print_y
($iset_buffer, $y, $strline);
530 if (($iset_buffer ne "") && ($#options_names >= 0))
532 foreach my $y (0 .. $#options_names)
534 iset_refresh_line
($y);
538 weechat
::bar_item_update
("isetbar_help") if (weechat
::config_boolean
($options_iset{"show_help_bar"}) == 1);
541 sub iset_full_refresh
543 $iset_buffer = weechat
::buffer_search
($LANG, $PRGNAME);
544 if ($iset_buffer ne "")
546 weechat
::buffer_clear
($iset_buffer) unless defined $_[0]; # iset_full_refresh(1) does a full refresh without clearing buffer
547 # search for "*" in $filter.
548 if ($filter =~ m/\*/ and $search_mode == 2)
550 iset_get_options
("");
554 if ($search_mode == 0)
556 $search_value = "=" . $search_value;
557 iset_get_values
($search_value);
559 elsif ($search_mode == 1)
561 iset_get_values
($search_value);
563 elsif ($search_mode == 3)
565 iset_create_filter
($filter);
566 iset_get_options
($search_value);
569 if (weechat
::config_boolean
($options_iset{"show_plugin_description"}) == 1)
571 iset_set_current_line
($current_line);
574 $current_line = $#options_names if ($current_line > $#options_names);
577 weechat
::command
($iset_buffer, "/window refresh");
581 sub iset_set_current_line
583 my $new_current_line = $_[0];
584 if ($new_current_line >= 0)
586 my $old_current_line = $current_line;
587 $current_line = $new_current_line;
588 $current_line = $#options_names if ($current_line > $#options_names);
589 if ($old_current_line != $current_line)
591 iset_refresh_line
($old_current_line);
592 iset_refresh_line
($current_line);
593 weechat
::bar_item_update
("isetbar_help") if (weechat
::config_boolean
($options_iset{"show_help_bar"}) == 1);
598 sub iset_signal_window_scrolled_cb
600 my ($data, $signal, $signal_data) = ($_[0], $_[1], $_[2]);
601 if ($iset_buffer ne "")
603 my $infolist = weechat
::infolist_get
("window", $signal_data, "");
604 if (weechat
::infolist_next
($infolist))
606 if (weechat
::infolist_pointer
($infolist, "buffer") eq $iset_buffer)
608 my $old_current_line = $current_line;
609 my $new_current_line = $current_line;
610 my $start_line_y = weechat
::infolist_integer
($infolist, "start_line_y");
611 my $chat_height = weechat
::infolist_integer
($infolist, "chat_height");
612 $new_current_line += $chat_height if ($new_current_line < $start_line_y);
613 $new_current_line -= $chat_height if ($new_current_line >= $start_line_y + $chat_height);
614 $new_current_line = $start_line_y if ($new_current_line < $start_line_y);
615 $new_current_line = $start_line_y + $chat_height - 1 if ($new_current_line >= $start_line_y + $chat_height);
616 iset_set_current_line
($new_current_line);
619 weechat
::infolist_free
($infolist);
622 return weechat
::WEECHAT_RC_OK
;
625 sub iset_get_window_number
627 if ($iset_buffer ne "")
629 my $window = weechat
::window_search_with_buffer
($iset_buffer);
630 return "-window ".weechat
::window_get_integer
($window, "number")." " if ($window ne "");
635 sub iset_check_line_outside_window
637 if ($iset_buffer ne "")
640 if ($wee_version_number >= 0x00030500)
642 my $window = weechat
::window_search_with_buffer
($iset_buffer);
643 $infolist = weechat
::infolist_get
("window", $window, "") if $window;
647 $infolist = weechat
::infolist_get
("window", "", "current");
651 if (weechat
::infolist_next
($infolist))
653 my $start_line_y = weechat
::infolist_integer
($infolist, "start_line_y");
654 my $chat_height = weechat
::infolist_integer
($infolist, "chat_height");
655 my $window_number = "";
656 if ($wee_version_number >= 0x00030500)
658 $window_number = "-window ".weechat
::infolist_integer
($infolist, "number")." ";
660 if ($start_line_y > $current_line)
662 weechat
::command
($iset_buffer, "/window scroll ".$window_number."-".($start_line_y - $current_line));
666 if ($start_line_y <= $current_line - $chat_height)
668 weechat
::command
($iset_buffer, "/window scroll ".$window_number."+".($current_line - $start_line_y - $chat_height + 1));
673 weechat
::infolist_free
($infolist);
678 sub iset_get_option_name_index
680 my $option_name = $_[0];
682 while ($index <= $#options_names)
684 return -1 if ($options_names[$index] gt $option_name);
685 return $index if ($options_names[$index] eq $option_name);
693 my ($data, $option_name, $value) = ($_[0], $_[1], $_[2]);
695 if ($iset_buffer ne "")
697 return weechat
::WEECHAT_RC_OK
if (weechat
::info_get
("weechat_upgrading", "") eq "1");
699 my $index = iset_get_option_name_index
($option_name);
702 # refresh info about changed option
703 my $infolist = weechat
::infolist_get
("option", "", $option_name);
706 weechat
::infolist_next
($infolist);
707 if (weechat
::infolist_fields
($infolist))
709 $options_types[$index] = weechat
::infolist_string
($infolist, "type");
710 $options_values[$index] = weechat
::infolist_string
($infolist, "value");
711 $options_default_values[$index] = weechat
::infolist_string
($infolist, "default_value");
712 $options_is_null[$index] = weechat
::infolist_integer
($infolist, "value_is_null");
713 iset_refresh_line
($index);
714 iset_title
() if ($option_name eq "iset.look.show_current_line");
718 iset_full_refresh
(1); # if not found, refresh fully without clearing buffer
719 weechat
::print_y
($iset_buffer, $#options_names + 1, "");
721 weechat
::infolist_free
($infolist);
726 iset_full_refresh
() if ($option_name ne "weechat.bar.isetbar.hidden");
730 return weechat
::WEECHAT_RC_OK
;
735 my ($option, $value) = ($_[0],$_[1]);
736 if (defined $option and defined $value)
738 $option = weechat
::config_get
($option);
739 weechat
::config_option_set
($option, $value, 1) if ($option ne "");
743 sub iset_reset_option
748 $option = weechat
::config_get
($option);
749 weechat
::config_option_reset
($option, 1) if ($option ne "");
753 sub iset_unset_option
758 $option = weechat
::config_get
($option);
759 weechat
::config_option_unset
($option) if ($option ne "");
766 my ($data, $buffer, $args) = ($_[0], $_[1], $_[2]);
768 # $search_value = "";
769 if (($args ne "") && (substr($args, 0, 2) ne "**"))
771 my @cmd_array = split(/ /,$args);
772 my $array_count = @cmd_array;
773 if (substr($args, 0, 1) eq weechat
::config_string
($options_iset{"value_search_char"})
774 or (defined $cmd_array[0] and $cmd_array[0] eq weechat
::config_string
($options_iset{"value_search_char"}).weechat
::config_string
($options_iset{"value_search_char"})) )
777 my $search_value = substr($args, 1); # cut value_search_char
778 if ($iset_buffer ne "")
780 weechat
::buffer_clear
($iset_buffer);
781 weechat
::command
($iset_buffer, "/window refresh");
783 weechat
::buffer_set
($iset_buffer, "localvar_set_iset_search_mode", $search_mode);
784 weechat
::buffer_set
($iset_buffer, "localvar_set_iset_search_value", $search_value);
786 iset_get_values
($search_value);
788 weechat
::buffer_set
($iset_buffer, "display", "1");
789 # $filter = $var_value;
790 return weechat
::WEECHAT_RC_OK
;
797 if ( $array_count >= 2 and $cmd_array[0] ne "f" or $cmd_array[0] ne "s")
799 if ( defined $cmd_array[1] and substr($cmd_array[1], 0, 1) eq weechat
::config_string
($options_iset{"value_search_char"})
800 or defined $cmd_array[2] and substr($cmd_array[2], 0, 1) eq weechat
::config_string
($options_iset{"value_search_char"}) )
803 $search_value = substr($cmd_array[1], 1); # cut value_search_char
804 $search_value = substr($cmd_array[2], 1) if ( $array_count > 2); # cut value_search_char
807 iset_create_filter
($args);
809 my $ptrbuf = weechat
::buffer_search
($LANG, $PRGNAME);
813 iset_get_options
($search_value);
815 weechat
::buffer_set
(weechat
::buffer_search
($LANG, $PRGNAME), "display", "1");
816 weechat
::buffer_set
($iset_buffer, "localvar_set_iset_search_value", $search_value);
817 weechat
::buffer_set
($iset_buffer, "localvar_set_iset_search_mode", $search_mode);
818 return weechat
::WEECHAT_RC_OK
;
822 iset_get_options
($search_value);
824 weechat
::buffer_set
($ptrbuf, "display", "1");
827 weechat
::buffer_set
($iset_buffer, "localvar_set_iset_search_mode", $search_mode);
828 weechat
::buffer_set
($iset_buffer, "localvar_set_iset_search_value", $search_value);
830 if ($iset_buffer eq "")
833 iset_get_options
("");
838 # iset_get_options($search_value);
839 iset_full_refresh
() if ($filter_set);
844 weechat
::buffer_set
($iset_buffer, "display", "1");
848 if ($args eq "**refresh")
854 if ($current_line > 0)
857 iset_refresh_line
($current_line + 1);
858 iset_refresh_line
($current_line);
859 iset_check_line_outside_window
();
862 if ($args eq "**down")
864 if ($current_line < $#options_names)
867 iset_refresh_line
($current_line - 1);
868 iset_refresh_line
($current_line);
869 iset_check_line_outside_window
();
872 if ($args eq "**left" && $wee_version_number >= 0x00030600)
874 weechat
::command
($iset_buffer, "/window scroll_horiz ".iset_get_window_number
()."-".weechat
::config_integer
($options_iset{"scroll_horiz"})."%");
876 if ($args eq "**right" && $wee_version_number >= 0x00030600)
878 weechat
::command
($iset_buffer, "/window scroll_horiz ".iset_get_window_number
().weechat
::config_integer
($options_iset{"scroll_horiz"})."%");
880 if ($args eq "**scroll_top")
882 my $old_current_line = $current_line;
884 iset_refresh_line
($old_current_line);
885 iset_refresh_line
($current_line);
887 weechat
::command
($iset_buffer, "/window scroll_top ".iset_get_window_number
());
889 if ($args eq "**scroll_bottom")
891 my $old_current_line = $current_line;
892 $current_line = $#options_names;
893 iset_refresh_line
($old_current_line);
894 iset_refresh_line
($current_line);
896 weechat
::command
($iset_buffer, "/window scroll_bottom ".iset_get_window_number
());
898 if ($args eq "**toggle")
900 if ($options_types[$current_line] eq "boolean")
902 iset_set_option
($options_names[$current_line], "toggle");
905 if ($args eq "**incr")
907 if (($options_types[$current_line] eq "integer")
908 || ($options_types[$current_line] eq "color"))
910 iset_set_option
($options_names[$current_line], "++1");
913 if ($args eq "**decr")
915 if (($options_types[$current_line] eq "integer")
916 || ($options_types[$current_line] eq "color"))
918 iset_set_option
($options_names[$current_line], "--1");
921 if ($args eq "**reset")
923 iset_reset_option
($options_names[$current_line]);
925 if ($args eq "**unset")
927 iset_unset_option
($options_names[$current_line]);
929 if ($args eq "**toggle_help")
931 if (weechat
::config_boolean
($options_iset{"show_help_bar"}) == 1)
933 weechat
::config_option_set
($options_iset{"show_help_bar"},0,1);
938 weechat
::config_option_set
($options_iset{"show_help_bar"},1,1);
942 if ($args eq "**toggle_show_plugin_desc")
944 if (weechat
::config_boolean
($options_iset{"show_plugin_description"}) == 1)
946 weechat
::config_option_set
($options_iset{"show_plugin_description"},0,1);
948 iset_check_line_outside_window
();
953 weechat
::config_option_set
($options_iset{"show_plugin_description"},1,1);
955 iset_check_line_outside_window
();
959 if ($args eq "**set")
962 my $value = $options_values[$current_line];
963 if ($options_is_null[$current_line])
969 $quote = "\"" if ($options_types[$current_line] eq "string");
971 weechat
::buffer_set
($iset_buffer, "input", "/set ".$options_names[$current_line]." ".$quote.$value.$quote);
972 weechat
::command
($iset_buffer, "/input move_beginning_of_line");
973 weechat
::command
($iset_buffer, "/input move_next_word");
974 weechat
::command
($iset_buffer, "/input move_next_word");
975 weechat
::command
($iset_buffer, "/input move_next_char");
976 weechat
::command
($iset_buffer, "/input move_next_char") if ($quote ne "");
979 weechat
::bar_item_update
("isetbar_help") if (weechat
::config_boolean
($options_iset{"show_help_bar"}) == 1);
980 return weechat
::WEECHAT_RC_OK
;
985 my ($redraw) = ($_[0]);
987 return '' if (weechat
::config_boolean
($options_iset{"show_help_bar"}) == 0);
989 if (not defined $options_names[$current_line])
991 return "No option selected. Set a new filter using command line (use '*' to see all options)";
993 if ($options_name_copy eq $options_names[$current_line] and not defined $redraw)
997 $options_name_copy = $options_names[$current_line];
999 $optionlist = weechat
::infolist_get
("option", "", $options_names[$current_line]);
1000 weechat
::infolist_next
($optionlist);
1001 my $full_name = weechat
::infolist_string
($optionlist,"full_name");
1002 my $option_desc = "";
1003 my $option_default_value = "";
1004 my $option_range = "";
1005 my $possible_values = "";
1006 my $re = qq(\Q$full_name);
1007 if (grep (/^$re$/,$options_names[$current_line]))
1009 $option_desc = weechat
::infolist_string
($optionlist, "description_nls");
1010 $option_desc = weechat
::infolist_string
($optionlist, "description") if ($option_desc eq "");
1011 $option_desc = "No help found" if ($option_desc eq "");
1012 $option_default_value = weechat
::infolist_string
($optionlist, "default_value");
1013 $possible_values = weechat
::infolist_string
($optionlist, "string_values") if (weechat
::infolist_string
($optionlist, "string_values") ne "");
1014 if ((weechat
::infolist_string
($optionlist, "type") eq "integer") && ($possible_values eq ""))
1016 $option_range = weechat
::infolist_integer
($optionlist, "min")
1017 ." .. ".weechat
::infolist_integer
($optionlist, "max");
1020 weechat
::infolist_free
($optionlist);
1023 $description = weechat
::color
(weechat
::config_color
($options_iset{"color_help_option_name"})).$options_names[$current_line]
1024 .weechat
::color
("bar_fg").": "
1025 .weechat
::color
(weechat
::config_color
($options_iset{"color_help_text"})).$option_desc;
1027 # show additional infos like default value and possible values
1029 if (weechat
::config_boolean
($options_iset{"show_help_extra_info"}) == 1)
1032 weechat
::color
("bar_delim")." ["
1033 .weechat
::color
("bar_fg")."default: "
1034 .weechat
::color
("bar_delim")."\""
1035 .weechat
::color
(weechat
::config_color
($options_iset{"color_help_default_value"})).$option_default_value
1036 .weechat
::color
("bar_delim")."\"";
1037 if ($option_range ne "")
1039 $description .= weechat
::color
("bar_fg").", values: ".$option_range;
1041 if ($possible_values ne "")
1043 $possible_values =~ s/\|/", "/g; # replace '|' to '", "'
1044 $description .= weechat
::color
("bar_fg").", values: ". "\"" . $possible_values . "\"";
1047 $description .= weechat
::color
("bar_delim")."]";
1049 return $description;
1052 sub iset_check_condition_isetbar_cb
1054 my ($data, $modifier, $modifier_data, $string) = ($_[0], $_[1], $_[2], $_[3]);
1055 my $buffer = weechat
::window_get_pointer
($modifier_data, "buffer");
1058 if ((weechat
::buffer_get_string
($buffer, "plugin") eq $LANG)
1059 && (weechat
::buffer_get_string
($buffer, "name") eq $PRGNAME))
1070 my $barhidden = weechat
::config_get
("weechat.bar.isetbar.hidden");
1075 if (weechat
::config_boolean
($options_iset{"show_help_bar"}) == 1)
1077 if (weechat
::config_boolean
($barhidden))
1079 weechat
::config_option_set
($barhidden, 0, 1);
1085 if (!weechat
::config_boolean
($barhidden))
1087 weechat
::config_option_set
($barhidden, 1, 1);
1093 sub iset_signal_buffer_switch_cb
1095 my $buffer_pointer = $_[2];
1097 $show_bar = 1 if (weechat
::buffer_get_integer
($iset_buffer, "num_displayed") > 0);
1098 iset_show_bar
($show_bar);
1099 iset_check_line_outside_window
() if ($buffer_pointer eq $iset_buffer);
1100 return weechat
::WEECHAT_RC_OK
;
1105 return iset_get_help
();
1108 sub iset_upgrade_ended
1110 iset_full_refresh
();
1115 # when script is unloaded, we hide bar
1119 # -------------------------------[ mouse support ]-------------------------------------
1121 sub hook_focus_iset_cb
1123 my %info = %{$_[1]};
1124 my $bar_item_line = int($info{"_bar_item_line"});
1126 if (($info{"_buffer_name"} eq $PRGNAME) && $info{"_buffer_plugin"} eq $LANG && ($bar_item_line >= 0) && ($bar_item_line <= $#iset_focus))
1128 $hash = $iset_focus[$bar_item_line];
1133 my $hash_focus = $iset_focus[0];
1134 foreach my $key (keys %$hash_focus)
1136 $hash->{$key} = "?";
1142 # _chat_line_y contains selected line
1143 sub iset_hsignal_mouse_cb
1145 my ($data, $signal, %hash) = ($_[0], $_[1], %{$_[2]});
1147 if ($hash{"_buffer_name"} eq $PRGNAME && ($hash{"_buffer_plugin"} eq $LANG))
1149 if ($hash{"_key"} eq "button1")
1151 iset_set_current_line
($hash{"_chat_line_y"});
1153 elsif ($hash{"_key"} eq "button2")
1155 if ($options_types[$hash{"_chat_line_y"}] eq "boolean")
1157 iset_set_option
($options_names[$hash{"_chat_line_y"}], "toggle");
1158 iset_set_current_line
($hash{"_chat_line_y"});
1160 elsif ($options_types[$hash{"_chat_line_y"}] eq "string")
1162 iset_set_current_line
($hash{"_chat_line_y"});
1163 weechat
::command
("", "/$PRGNAME **set");
1166 elsif ($hash{"_key"} eq "button2-gesture-left" or $hash{"_key"} eq "button2-gesture-left-long")
1168 if ($options_types[$hash{"_chat_line_y"}] eq "integer" or ($options_types[$hash{"_chat_line_y"}] eq "color"))
1170 iset_set_current_line
($hash{"_chat_line_y"});
1171 my $distance = distance
($hash{"_chat_line_x"},$hash{"_chat_line_x2"});
1172 weechat
::command
("", "/repeat $distance /$PRGNAME **decr");
1175 elsif ($hash{"_key"} eq "button2-gesture-right" or $hash{"_key"} eq "button2-gesture-right-long")
1177 if ($options_types[$hash{"_chat_line_y"}] eq "integer" or ($options_types[$hash{"_chat_line_y"}] eq "color"))
1179 iset_set_current_line
($hash{"_chat_line_y"});
1180 my $distance = distance
($hash{"_chat_line_x"},$hash{"_chat_line_x2"});
1181 weechat
::command
("", "/repeat $distance /$PRGNAME **incr");
1190 my $current_window = weechat
::current_window
();
1191 my $dest_window = weechat
::window_search_with_buffer
(weechat
::buffer_search
("perl","iset"));
1192 return 0 if ($dest_window eq "" or $current_window eq $dest_window);
1194 my $infolist = weechat
::infolist_get
("window", $dest_window, "");
1195 weechat
::infolist_next
($infolist);
1196 my $number = weechat
::infolist_integer
($infolist, "number");
1197 weechat
::infolist_free
($infolist);
1198 weechat
::command
("","/window " . $number);
1203 my ($x1,$x2) = ($_[0], $_[1]);
1205 $distance = $x1 - $x2;
1206 $distance = abs($distance);
1210 $distance = $distance / 3;
1211 $distance = 1 if ($distance == 0);
1213 elsif ($distance == 0)
1220 # -----------------------------------[ config ]---------------------------------------
1222 sub iset_config_init
1224 $iset_config_file = weechat
::config_new
($ISET_CONFIG_FILE_NAME,"iset_config_reload_cb","");
1225 return if ($iset_config_file eq "");
1228 my $section_color = weechat
::config_new_section
($iset_config_file,"color", 0, 0, "", "", "", "", "", "", "", "", "", "");
1229 if ($section_color eq "")
1231 weechat
::config_free
($iset_config_file);
1234 $options_iset{"color_option"} = weechat
::config_new_option
(
1235 $iset_config_file, $section_color,
1236 "option", "color", "Color for option name in iset buffer", "", 0, 0,
1237 "default", "default", 0, "", "", "full_refresh_cb", "", "", "");
1238 $options_iset{"color_option_selected"} = weechat
::config_new_option
(
1239 $iset_config_file, $section_color,
1240 "option_selected", "color", "Color for selected option name in iset buffer", "", 0, 0,
1241 "white", "white", 0, "", "", "full_refresh_cb", "", "", "");
1242 $options_iset{"color_type"} = weechat
::config_new_option
(
1243 $iset_config_file, $section_color,
1244 "type", "color", "Color for option type (integer, boolean, string)", "", 0, 0,
1245 "brown", "brown", 0, "", "", "full_refresh_cb", "", "", "");
1246 $options_iset{"color_type_selected"} = weechat
::config_new_option
(
1247 $iset_config_file, $section_color,
1248 "type_selected", "color", "Color for selected option type (integer, boolean, string)", "", 0, 0,
1249 "yellow", "yellow", 0, "", "", "full_refresh_cb", "", "", "");
1250 $options_iset{"color_value"} = weechat
::config_new_option
(
1251 $iset_config_file, $section_color,
1252 "value", "color", "Color for option value", "", 0, 0,
1253 "cyan", "cyan", 0, "", "", "full_refresh_cb", "", "", "");
1254 $options_iset{"color_value_selected"} = weechat
::config_new_option
(
1255 $iset_config_file, $section_color,
1256 "value_selected", "color", "Color for selected option value", "", 0, 0,
1257 "lightcyan", "lightcyan", 0, "", "", "full_refresh_cb", "", "", "");
1258 $options_iset{"color_value_diff"} = weechat
::config_new_option
(
1259 $iset_config_file, $section_color,
1260 "value_diff", "color", "Color for option value different from default", "", 0, 0,
1261 "magenta", "magenta", 0, "", "", "full_refresh_cb", "", "", "");
1262 $options_iset{"color_value_diff_selected"} = weechat
::config_new_option
(
1263 $iset_config_file, $section_color,
1264 "value_diff_selected", "color", "Color for selected option value different from default", "", 0, 0,
1265 "lightmagenta", "lightmagenta", 0, "", "", "full_refresh_cb", "", "", "");
1266 $options_iset{"color_value_undef"} = weechat
::config_new_option
(
1267 $iset_config_file, $section_color,
1268 "value_undef", "color", "Color for option value undef", "", 0, 0,
1269 "green", "green", 0, "", "", "full_refresh_cb", "", "", "");
1270 $options_iset{"color_value_undef_selected"} = weechat
::config_new_option
(
1271 $iset_config_file, $section_color,
1272 "value_undef_selected", "color", "Color for selected option value undef", "", 0, 0,
1273 "lightgreen", "lightgreen", 0, "", "", "full_refresh_cb", "", "", "");
1274 $options_iset{"color_bg_selected"} = weechat
::config_new_option
(
1275 $iset_config_file, $section_color,
1276 "bg_selected", "color", "Background color for current selected option", "", 0, 0,
1277 "red", "red", 0, "", "", "full_refresh_cb", "", "", "");
1278 $options_iset{"color_help_option_name"} = weechat
::config_new_option
(
1279 $iset_config_file, $section_color,
1280 "help_option_name", "color", "Color for option name in help-bar", "", 0, 0,
1281 "white", "white", 0, "", "", "bar_refresh", "", "", "");
1282 $options_iset{"color_help_text"} = weechat
::config_new_option
(
1283 $iset_config_file, $section_color,
1284 "help_text", "color", "Color for option description in help-bar", "", 0, 0,
1285 "default", "default", 0, "", "", "bar_refresh", "", "", "");
1286 $options_iset{"color_help_default_value"} = weechat
::config_new_option
(
1287 $iset_config_file, $section_color,
1288 "help_default_value", "color", "Color for default option value in help-bar", "", 0, 0,
1289 "green", "green", 0, "", "", "bar_refresh", "", "", "");
1292 my $section_help = weechat
::config_new_section
($iset_config_file,"help", 0, 0, "", "", "", "", "", "", "", "", "", "");
1293 if ($section_help eq "")
1295 weechat
::config_free
($iset_config_file);
1298 $options_iset{"show_help_bar"} = weechat
::config_new_option
(
1299 $iset_config_file, $section_help,
1300 "show_help_bar", "boolean", "Show help bar", "", 0, 0,
1301 "on", "on", 0, "", "", "toggle_help_cb", "", "", "");
1302 $options_iset{"show_help_extra_info"} = weechat
::config_new_option
(
1303 $iset_config_file, $section_help,
1304 "show_help_extra_info", "boolean", "Show additional information in help bar (default value, max./min. value) ", "", 0, 0,
1305 "on", "on", 0, "", "", "", "", "", "");
1306 $options_iset{"show_plugin_description"} = weechat
::config_new_option
(
1307 $iset_config_file, $section_help,
1308 "show_plugin_description", "boolean", "Show plugin description in iset buffer", "", 0, 0,
1309 "off", "off", 0, "", "", "full_refresh_cb", "", "", "");
1312 my $section_look = weechat
::config_new_section
($iset_config_file, "look", 0, 0, "", "", "", "", "", "", "", "", "", "");
1313 if ($section_look eq "")
1315 weechat
::config_free
($iset_config_file);
1318 $options_iset{"value_search_char"} = weechat
::config_new_option
(
1319 $iset_config_file, $section_look,
1320 "value_search_char", "string", "Trigger char to tell iset to search for value instead of option (for example: =red)", "", 0, 0,
1321 "=", "=", 0, "", "", "", "", "", "");
1322 $options_iset{"scroll_horiz"} = weechat
::config_new_option
(
1323 $iset_config_file, $section_look,
1324 "scroll_horiz", "integer", "scroll content of iset buffer n%", "", 1, 100,
1325 "10", "10", 0, "", "", "", "", "", "");
1326 $options_iset{"show_current_line"} = weechat
::config_new_option
(
1327 $iset_config_file, $section_look,
1328 "show_current_line", "boolean", "show current line in title bar.", "", 0, 0,
1329 "on", "on", 0, "", "", "", "", "", "");
1332 sub iset_config_reload_cb
1334 my ($data,$config_file) = ($_[0], $_[1]);
1335 return weechat
::config_reload
($config_file)
1338 sub iset_config_read
1340 return weechat
::config_read
($iset_config_file) if ($iset_config_file ne "");
1343 sub iset_config_write
1345 return weechat
::config_write
($iset_config_file) if ($iset_config_file ne "");
1350 iset_full_refresh
();
1351 return weechat
::WEECHAT_RC_OK
;
1357 weechat
::bar_item_update
("isetbar_help") if (weechat
::config_boolean
($options_iset{"show_help_bar"}) == 1);
1358 return weechat
::WEECHAT_RC_OK
;
1363 my $value = weechat
::config_boolean
($options_iset{"show_help_bar"});
1364 iset_show_bar
($value);
1365 return weechat
::WEECHAT_RC_OK
;
1368 # -----------------------------------[ main ]-----------------------------------------
1370 weechat
::register
($PRGNAME, $AUTHOR, $VERSION, $LICENSE,
1371 $DESCR, "iset_end", "");
1373 $wee_version_number = weechat
::info_get
("version_number", "") || 0;
1378 weechat
::hook_command
($PRGNAME, "Interactive set", "f <file> || s <section> || [=][=]<text>",
1379 "f file : show options for a file\n".
1380 "s section: show options for a section\n".
1381 "text : show options with 'text' in name\n".
1382 weechat
::config_string
($options_iset{"value_search_char"})."text : show options with 'text' in value\n".
1383 weechat
::config_string
($options_iset{"value_search_char"}).weechat
::config_string
($options_iset{"value_search_char"})."text : show options with exact 'text' in value\n\n".
1384 "Keys for iset buffer:\n".
1385 "f11,f12 : move iset content left/right\n".
1386 "up,down : move one option up/down\n".
1387 "pgup,pdwn : move one page up/down\n".
1388 "home,end : move to first/last option\n".
1389 "ctrl+'L' : refresh options and screen\n".
1390 "alt+space : toggle boolean on/off\n".
1391 "alt+'+' : increase value (for integer or color)\n".
1392 "alt+'-' : decrease value (for integer or color)\n".
1393 "alt+'i',alt+'r': reset value of option\n".
1394 "alt+'i',alt+'u': unset option\n".
1395 "alt+enter : set new value for option (edit it with command line)\n".
1396 "text,enter : set a new filter using command line (use '*' to see all options)\n".
1397 "alt+'v' : toggle help bar on/off\n".
1398 "alt+'p' : toggle option \"show_plugin_description\" on/off\n".
1401 "wheel up/down : move cursor up/down\n".
1402 "left button : select an option from list\n".
1403 "right button : toggle boolean (on/off) or set a new value for option (edit it with command line)\n".
1404 "right button + drag left/right: increase/decrease value (for integer or color)\n".
1407 " show options for file 'weechat'\n".
1408 " /iset f weechat\n".
1409 " show options for file 'irc'\n".
1411 " show options for section 'look'\n".
1413 " show all options with text 'nicklist' in name\n".
1414 " /iset nicklist\n".
1415 " show all values which contain 'red'. ('" . weechat
::config_string
($options_iset{"value_search_char"}) . "' is a trigger char).\n".
1416 " /iset ". weechat
::config_string
($options_iset{"value_search_char"}) ."red\n".
1417 " show all values which hit 'off'. ('" . weechat
::config_string
($options_iset{"value_search_char"}) . weechat
::config_string
($options_iset{"value_search_char"}) . "' is a trigger char).\n".
1418 " /iset ". weechat
::config_string
($options_iset{"value_search_char"}) . weechat
::config_string
($options_iset{"value_search_char"}) ."off\n".
1419 " show options for file 'weechat' which contains value 'off'\n".
1420 " /iset f weechat ".weechat
::config_string
($options_iset{"value_search_char"})."off\n".
1422 "", "iset_cmd_cb", "");
1423 weechat
::hook_signal
("upgrade_ended", "iset_upgrade_ended", "");
1424 weechat
::hook_signal
("window_scrolled", "iset_signal_window_scrolled_cb", "");
1425 weechat
::hook_signal
("buffer_switch", "iset_signal_buffer_switch_cb","");
1426 weechat
::bar_item_new
("isetbar_help", "iset_item_cb", "");
1427 weechat
::bar_new
("isetbar", "on", "0", "window", "", "top", "horizontal",
1428 "vertical", "3", "3", "default", "cyan", "default", "1",
1430 weechat
::hook_modifier
("bar_condition_isetbar", "iset_check_condition_isetbar_cb", "");
1431 weechat
::hook_config
("*", "iset_config_cb", "");
1432 $iset_buffer = weechat
::buffer_search
($LANG, $PRGNAME);
1433 iset_init
() if ($iset_buffer ne "");
1435 if ($wee_version_number >= 0x00030600)
1437 weechat
::hook_focus
("chat", "hook_focus_iset_cb", "");
1438 weechat
::hook_hsignal
($PRGNAME."_mouse", "iset_hsignal_mouse_cb", "");
1439 weechat
::key_bind
("mouse", \
%mouse_keys);