2 # Copyright (C) 2008-2014 Sebastien Helleu <flashcode@flashtux.org>
3 # Copyright (C) 2010-2014 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-09-30, arza <arza@arza.us>:
23 # version 3.6: fix current line counter when options aren't found
24 # 2014-06-03, nils_2 <weechatter@arcor.de>:
25 # version 3.5: add new option "use_mute"
26 # 2014-01-30, stfn <stfnmd@gmail.com>:
27 # version 3.4: add new options "color_value_diff" and "color_value_diff_selected"
28 # 2014-01-16, luz <ne.tetewi@gmail.com>:
29 # version 3.3: fix bug with column alignment in iset buffer when option
30 # name contains unicode characters
31 # 2013-08-03, Sebastien Helleu <flashcode@flashtux.org>:
32 # version 3.2: allow "q" as input in iset buffer to close it
33 # 2013-07-14, Sebastien Helleu <flashcode@flashtux.org>:
34 # version 3.1: remove unneeded calls to iset_refresh() in mouse callback
35 # (faster mouse actions when lot of options are displayed),
36 # fix bug when clicking on a line after the last option displayed
37 # 2013-04-30, arza <arza@arza.us>:
38 # version 3.0: simpler title, fix refresh on unset
39 # 2012-12-16, nils_2 <weechatter@arcor.de>:
40 # version 2.9: fix focus window with iset buffer on mouse click
41 # 2012-08-25, nils_2 <weechatter@arcor.de>:
42 # version 2.8: most important key and mouse bindings for iset buffer added to title-bar (idea The-Compiler)
43 # 2012-07-31, nils_2 <weechatter@arcor.de>:
44 # version 2.7: add combined option and value search (see /help iset)
45 # : add exact value search (see /help iset)
46 # : fix problem with metacharacter in value search
47 # : fix use of uninitialized value for unset option and reset value of option
48 # 2012-07-25, nils_2 <weechatter@arcor.de>:
49 # version 2.6: switch to iset buffer (if existing) when command /iset is called with arguments
50 # 2012-03-17, Sebastien Helleu <flashcode@flashtux.org>:
51 # version 2.5: fix check of sections when creating config file
52 # 2012-03-09, Sebastien Helleu <flashcode@flashtux.org>:
53 # version 2.4: fix reload of config file
54 # 2012-02-02, nils_2 <weechatter@arcor.de>:
55 # version 2.3: fixed: refresh problem with new search results and cursor was outside window.
56 # : add: new option "current_line" in title bar
57 # version 2.2: fixed: refresh error when toggling plugins description
58 # 2011-11-05, nils_2 <weechatter@arcor.de>:
59 # version 2.1: use own config file (iset.conf), fix own help color (used immediately)
60 # 2011-10-16, nils_2 <weechatter@arcor.de>:
61 # version 2.0: add support for left-mouse-button and more sensitive mouse gesture (for integer/color options)
62 # add help text for mouse support
63 # 2011-09-20, Sebastien Helleu <flashcode@flashtux.org>:
64 # version 1.9: add mouse support, fix iset buffer, fix errors on first load under FreeBSD
65 # 2011-07-21, nils_2 <weechatter@arcor.de>:
66 # version 1.8: added: option "show_plugin_description" (alt+p)
67 # fixed: typos in /help iset (lower case for alt+'x' keys)
68 # 2011-05-29, nils_2 <weechatter@arcor.de>:
69 # version 1.7: added: version check for future needs
70 # added: new option (scroll_horiz) and usage of scroll_horiz function (weechat >= 0.3.6 required)
71 # fixed: help_bar did not pop up immediately using key-shortcut
72 # 2011-02-19, nils_2 <weechatter@arcor.de>:
73 # version 1.6: added: display of all possible values in help bar (show_help_extra_info)
74 # fixed: external user options never loaded when starting iset first time
75 # 2011-02-13, Sebastien Helleu <flashcode@flashtux.org>:
76 # version 1.5: use new help format for command arguments
77 # 2011-02-03, nils_2 <weechatter@arcor.de>:
78 # version 1.4: fixed: restore value filter after /upgrade using buffer local variable.
79 # 2011-01-14, nils_2 <weechatter@arcor.de>:
80 # version 1.3: added function to search for values (option value_search_char).
82 # 2010-12-26, Sebastien Helleu <flashcode@flashtux.org>:
83 # version 1.2: improve speed of /upgrade when iset buffer is open,
84 # restore filter used after /upgrade using buffer local variable,
85 # use /iset filter argument if buffer is open.
86 # 2010-11-21, drubin <drubin+weechat@smartcube.co.za>:
87 # version 1.1.1: fix bugs with cursor position
88 # 2010-11-20, nils_2 <weechatter@arcor.de>:
89 # version 1.1: cursor position set to value
90 # 2010-08-03, Sebastien Helleu <flashcode@flashtux.org>:
91 # version 1.0: move misplaced call to infolist_free()
92 # 2010-02-02, rettub <rettub@gmx.net>:
93 # version 0.9: turn all the help stuff off if option 'show_help_bar' is 'off',
94 # new key binding <alt>-<v> to toggle help_bar and help stuff on/off
95 # 2010-01-30, nils_2 <weechatter@arcor.de>:
96 # version 0.8: fix error when option does not exist
97 # 2010-01-24, Sebastien Helleu <flashcode@flashtux.org>:
98 # version 0.7: display iset bar only on iset buffer
99 # 2010-01-22, nils_2 <weechatter@arcor.de> and drubin:
100 # version 0.6: add description in a bar, fix singular/plural bug in title bar,
101 # fix selected line when switching buffer
102 # 2009-06-21, Sebastien Helleu <flashcode@flashtux.org>:
103 # version 0.5: fix bug with iset buffer after /upgrade
104 # 2009-05-02, Sebastien Helleu <flashcode@flashtux.org>:
105 # version 0.4: sync with last API changes
106 # 2009-01-04, Sebastien Helleu <flashcode@flashtux.org>:
107 # version 0.3: open iset buffer when /iset command is executed
108 # 2009-01-04, Sebastien Helleu <flashcode@flashtux.org>:
109 # version 0.2: use null values for options, add colors, fix refresh bugs,
110 # use new keys to reset/unset options, sort options by name,
111 # display number of options in buffer's title
112 # 2008-11-05, Sebastien Helleu <flashcode@flashtux.org>:
113 # version 0.1: first official version
114 # 2008-04-19, Sebastien Helleu <flashcode@flashtux.org>:
119 my $PRGNAME = "iset";
121 my $DESCR = "Interactive Set for configuration options";
122 my $AUTHOR = "Sebastien Helleu <flashcode\@flashtux.org>";
123 my $LICENSE = "GPL3";
125 my $ISET_CONFIG_FILE_NAME = "iset";
127 my $iset_config_file;
128 my $iset_buffer = "";
129 my $wee_version_number = 0;
131 my @options_names = ();
132 my @options_types = ();
133 my @options_values = ();
134 my @options_default_values = ();
135 my @options_is_null = ();
136 my $option_max_length = 0;
137 my $current_line = 0;
139 my $description = "";
140 my $options_name_copy = "";
141 my $iset_filter_title = "";
142 # search modes: 0 = index() on value, 1 = grep() on value, 2 = grep() on option, 3 = grep on option & value
144 my $search_value = "";
145 my $help_text_keys = "alt + space: toggle, +/-: increase/decrease, enter: change, ir: reset, iu: unset, v: toggle help bar";
146 my $help_text_mouse = "Mouse: left: select, right: toggle/set, right + drag left/right: increase/decrease";
149 my %mouse_keys = ("\@chat(perl.$PRGNAME):button1" => "hsignal:iset_mouse",
150 "\@chat(perl.$PRGNAME):button2*" => "hsignal:iset_mouse",
151 "\@chat(perl.$PRGNAME):wheelup" => "/repeat 5 /iset **up",
152 "\@chat(perl.$PRGNAME):wheeldown" => "/repeat 5 /iset **down");
157 if ($iset_buffer ne "")
159 my $current_line_counter = "";
160 if (weechat
::config_boolean
($options_iset{"show_current_line"}) == 1)
162 if (@options_names eq 0)
164 $current_line_counter = "0/";
168 $current_line_counter = ($current_line + 1) . "/";
171 my $show_filter = "";
172 if ($search_mode eq 0)
174 $iset_filter_title = "(value) ";
175 $show_filter = $search_value;
176 if ( substr($show_filter,0,1) eq weechat
::config_string
($options_iset{"value_search_char"}) )
178 $show_filter = substr($show_filter,1,length($show_filter));
181 elsif ($search_mode eq 1)
183 $iset_filter_title = "(value) ";
184 $show_filter = "*".$search_value."*";
186 elsif ($search_mode eq 2)
188 $iset_filter_title = "";
189 $filter = "*" if ($filter eq "");
190 $show_filter = $filter;
192 elsif ($search_mode eq 3)
194 $iset_filter_title = "(option) ";
195 $show_filter = $filter
196 .weechat
::color
("default")
198 .weechat
::color
("yellow")
199 ."*".$search_value."*";
201 weechat
::buffer_set
($iset_buffer, "title",
203 .weechat
::color
("yellow")
205 .weechat
::color
("default")." | "
206 .$current_line_counter
215 sub iset_create_filter
218 if ( $search_mode == 3 )
220 my @cmd_array = split(/ /,$filter);
221 my $array_count = @cmd_array;
222 $filter = $cmd_array[0];
223 $filter = $cmd_array[0] . " " . $cmd_array[1] if ( $array_count >2 );
225 $filter = "$1.*" if ($filter =~ /f (.*)/); # search file
226 $filter = "*.$1.*" if ($filter =~ /s (.*)/); # search section
227 if ((substr($filter, 0, 1) ne "*") && (substr($filter, -1, 1) ne "*"))
229 $filter = "*".$filter."*";
231 if ($iset_buffer ne "")
233 weechat
::buffer_set
($iset_buffer, "localvar_set_iset_filter", $filter);
237 sub iset_buffer_input
239 my ($data, $buffer, $string) = ($_[0], $_[1], $_[2]);
242 weechat
::buffer_close
($buffer);
243 return weechat
::WEECHAT_RC_OK
;
246 my @cmd_array = split(/ /,$string);
247 my $array_count = @cmd_array;
248 my $string2 = substr($string, 0, 1);
249 if ($string2 eq weechat
::config_string
($options_iset{"value_search_char"})
250 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"})) )
253 $search_value = substr($string, 1);
254 iset_get_values
($search_value);
255 if ($iset_buffer ne "")
257 weechat
::buffer_set
($iset_buffer, "localvar_set_iset_search_value", $search_value);
263 if ( $array_count >= 2 and $cmd_array[0] ne "f" or $cmd_array[0] ne "s")
265 if ( defined $cmd_array[1] and substr($cmd_array[1], 0, 1) eq weechat
::config_string
($options_iset{"value_search_char"})
266 or defined $cmd_array[2] and substr($cmd_array[2], 0, 1) eq weechat
::config_string
($options_iset{"value_search_char"}) )
269 $search_value = substr($cmd_array[1], 1); # cut value_search_char
270 $search_value = substr($cmd_array[2], 1) if ( $array_count > 2); # cut value_search_char
273 if ( $search_mode == 3)
275 iset_create_filter
($string);
276 iset_get_options
($search_value);
279 iset_create_filter
($string);
280 iset_get_options
("");
283 weechat
::buffer_set
($iset_buffer, "localvar_set_iset_search_mode", $search_mode);
284 weechat
::buffer_clear
($buffer);
287 return weechat
::WEECHAT_RC_OK
;
290 sub iset_buffer_close
294 return weechat
::WEECHAT_RC_OK
;
300 $iset_buffer = weechat
::buffer_search
($LANG, $PRGNAME);
301 if ($iset_buffer eq "")
303 $iset_buffer = weechat
::buffer_new
($PRGNAME, "iset_buffer_input", "", "iset_buffer_close", "");
307 my $new_filter = weechat
::buffer_get_string
($iset_buffer, "localvar_iset_filter");
308 $search_mode = weechat
::buffer_get_string
($iset_buffer, "localvar_iset_search_mode");
309 $search_value = weechat
::buffer_get_string
($iset_buffer, "localvar_iset_search_value");
310 $filter = $new_filter if ($new_filter ne "");
312 if ($iset_buffer ne "")
314 weechat
::buffer_set
($iset_buffer, "type", "free");
316 weechat
::buffer_set
($iset_buffer, "key_bind_ctrl-L", "/iset **refresh");
317 weechat
::buffer_set
($iset_buffer, "key_bind_meta2-A", "/iset **up");
318 weechat
::buffer_set
($iset_buffer, "key_bind_meta2-B", "/iset **down");
319 weechat
::buffer_set
($iset_buffer, "key_bind_meta2-23~", "/iset **left");
320 weechat
::buffer_set
($iset_buffer, "key_bind_meta2-24~" , "/iset **right");
321 weechat
::buffer_set
($iset_buffer, "key_bind_meta- ", "/iset **toggle");
322 weechat
::buffer_set
($iset_buffer, "key_bind_meta-+", "/iset **incr");
323 weechat
::buffer_set
($iset_buffer, "key_bind_meta--", "/iset **decr");
324 weechat
::buffer_set
($iset_buffer, "key_bind_meta-imeta-r", "/iset **reset");
325 weechat
::buffer_set
($iset_buffer, "key_bind_meta-imeta-u", "/iset **unset");
326 weechat
::buffer_set
($iset_buffer, "key_bind_meta-ctrl-J", "/iset **set");
327 weechat
::buffer_set
($iset_buffer, "key_bind_meta-ctrl-M", "/iset **set");
328 weechat
::buffer_set
($iset_buffer, "key_bind_meta-meta2-1~", "/iset **scroll_top");
329 weechat
::buffer_set
($iset_buffer, "key_bind_meta-meta2-4~", "/iset **scroll_bottom");
330 weechat
::buffer_set
($iset_buffer, "key_bind_meta-v", "/iset **toggle_help");
331 weechat
::buffer_set
($iset_buffer, "key_bind_meta-p", "/iset **toggle_show_plugin_desc");
332 weechat
::buffer_set
($iset_buffer, "localvar_set_iset_filter", $filter);
333 weechat
::buffer_set
($iset_buffer, "localvar_set_iset_search_mode", $search_mode);
334 weechat
::buffer_set
($iset_buffer, "localvar_set_iset_search_value", $search_value);
340 my $var_value = $_[0];
341 $var_value = "" if (not defined $var_value);
342 $var_value = lc($var_value);
343 $search_value = $var_value;
347 @options_values = ();
348 @options_default_values = ();
349 @options_is_null = ();
350 $option_max_length = 0;
351 my %options_internal = ();
357 weechat
::buffer_set
($iset_buffer, "localvar_set_iset_search_value", $var_value) if ($search_mode == 3);
359 my $infolist = weechat
::infolist_get
("option", "", $filter);
360 while (weechat
::infolist_next
($infolist))
362 $key = sprintf("%08d", $i);
363 my $name = weechat
::infolist_string
($infolist, "full_name");
364 next if (weechat
::config_boolean
($options_iset{"show_plugin_description"}) == 0 and index ($name, "plugins.desc.") != -1);
365 my $type = weechat
::infolist_string
($infolist, "type");
366 my $value = weechat
::infolist_string
($infolist, "value");
367 my $default_value = weechat
::infolist_string
($infolist, "default_value");
368 my $is_null = weechat
::infolist_integer
($infolist, "value_is_null");
369 if ($search_mode == 3)
371 my $value = weechat
::infolist_string
($infolist, "value");
372 if ( grep /\Q$var_value/,lc($value) )
374 $options_internal{$name}{"type"} = $type;
375 $options_internal{$name}{"value"} = $value;
376 $options_internal{$name}{"default_value"} = $default_value;
377 $options_internal{$name}{"is_null"} = $is_null;
378 $option_max_length = length($name) if (length($name) > $option_max_length);
379 $iset_struct{$key} = $options_internal{$name};
380 push(@iset_focus, $iset_struct{$key});
385 $options_internal{$name}{"type"} = $type;
386 $options_internal{$name}{"value"} = $value;
387 $options_internal{$name}{"default_value"} = $default_value;
388 $options_internal{$name}{"is_null"} = $is_null;
389 $option_max_length = length($name) if (length($name) > $option_max_length);
390 $iset_struct{$key} = $options_internal{$name};
391 push(@iset_focus, $iset_struct{$key});
395 weechat
::infolist_free
($infolist);
397 foreach my $name (sort keys %options_internal)
399 push(@options_names, $name);
400 push(@options_types, $options_internal{$name}{"type"});
401 push(@options_values, $options_internal{$name}{"value"});
402 push(@options_default_values, $options_internal{$name}{"default_value"});
403 push(@options_is_null, $options_internal{$name}{"is_null"});
409 my $var_value = $_[0];
410 $var_value = lc($var_value);
411 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"}))
413 $var_value = substr($var_value,1,length($var_value));
416 iset_search_values
($var_value,$search_mode);
417 weechat
::buffer_set
($iset_buffer, "localvar_set_iset_search_mode", $search_mode);
418 weechat
::buffer_set
($iset_buffer, "localvar_set_iset_search_value", $var_value);
419 $search_value = $var_value;
421 sub iset_search_values
423 my ($var_value,$search_mode) = ($_[0],$_[1]);
426 @options_values = ();
427 @options_default_values = ();
428 @options_is_null = ();
429 $option_max_length = 0;
430 my %options_internal = ();
432 my $infolist = weechat
::infolist_get
("option", "", "*");
433 while (weechat
::infolist_next
($infolist))
435 my $name = weechat
::infolist_string
($infolist, "full_name");
436 next if (weechat
::config_boolean
($options_iset{"show_plugin_description"}) == 0 and index ($name, "plugins.desc.") != -1);
437 my $type = weechat
::infolist_string
($infolist, "type");
438 my $is_null = weechat
::infolist_integer
($infolist, "value_is_null");
439 my $value = weechat
::infolist_string
($infolist, "value");
440 my $default_value = weechat
::infolist_string
($infolist, "default_value");
443 if ( grep /\Q$var_value/,lc($value) )
445 $options_internal{$name}{"type"} = $type;
446 $options_internal{$name}{"value"} = $value;
447 $options_internal{$name}{"default_value"} = $default_value;
448 $options_internal{$name}{"is_null"} = $is_null;
449 $option_max_length = length($name) if (length($name) > $option_max_length);
454 # if ($value =~ /\Q$var_value/si)
455 if (lc($value) eq $var_value)
457 $options_internal{$name}{"type"} = $type;
458 $options_internal{$name}{"value"} = $value;
459 $options_internal{$name}{"default_value"} = $default_value;
460 $options_internal{$name}{"is_null"} = $is_null;
461 $option_max_length = length($name) if (length($name) > $option_max_length);
466 weechat
::infolist_free
($infolist);
467 foreach my $name (sort keys %options_internal)
469 push(@options_names, $name);
470 push(@options_types, $options_internal{$name}{"type"});
471 push(@options_values, $options_internal{$name}{"value"});
472 push(@options_default_values, $options_internal{$name}{"default_value"});
473 push(@options_is_null, $options_internal{$name}{"is_null"});
477 sub iset_refresh_line
479 if ($iset_buffer ne "")
482 if ($y <= $#options_names)
484 return if (! defined($options_types[$y]));
485 my $format = sprintf("%%s%%s%%s %%s %%-7s %%s %%s%%s%%s");
487 if ($wee_version_number >= 0x00040200)
489 $padding = " " x
($option_max_length - weechat
::strlen_screen
($options_names[$y]));
493 $padding = " " x
($option_max_length - length($options_names[$y]));
496 $around = "\"" if ((!$options_is_null[$y]) && ($options_types[$y] eq "string"));
498 my $color1 = weechat
::color
(weechat
::config_color
($options_iset{"color_option"}));
499 my $color2 = weechat
::color
(weechat
::config_color
($options_iset{"color_type"}));
501 if ($options_is_null[$y])
503 $color3 = weechat
::color
(weechat
::config_color
($options_iset{"color_value_undef"}));
505 elsif ($options_values[$y] ne $options_default_values[$y])
507 $color3 = weechat
::color
(weechat
::config_color
($options_iset{"color_value_diff"}));
511 $color3 = weechat
::color
(weechat
::config_color
($options_iset{"color_value"}));
513 if ($y == $current_line)
515 $color1 = weechat
::color
(weechat
::config_color
($options_iset{"color_option_selected"}).",".weechat
::config_color
($options_iset{"color_bg_selected"}));
516 $color2 = weechat
::color
(weechat
::config_color
($options_iset{"color_type_selected"}).",".weechat
::config_color
($options_iset{"color_bg_selected"}));
517 if ($options_is_null[$y])
519 $color3 = weechat
::color
(weechat
::config_color
($options_iset{"color_value_undef_selected"}).",".weechat
::config_color
($options_iset{"color_bg_selected"}));
521 elsif ($options_values[$y] ne $options_default_values[$y])
523 $color3 = weechat
::color
(weechat
::config_color
($options_iset{"color_value_diff_selected"}).",".weechat
::config_color
($options_iset{"color_bg_selected"}));
527 $color3 = weechat
::color
(weechat
::config_color
($options_iset{"color_value_selected"}).",".weechat
::config_color
($options_iset{"color_bg_selected"}));
530 my $value = $options_values[$y];
531 $value = "(undef)" if ($options_is_null[$y]);
532 my $strline = sprintf($format,
533 $color1, $options_names[$y], $padding,
534 $color2, $options_types[$y],
535 $color3, $around, $value, $around);
536 weechat
::print_y
($iset_buffer, $y, $strline);
544 if (($iset_buffer ne "") && ($#options_names >= 0))
546 foreach my $y (0 .. $#options_names)
548 iset_refresh_line
($y);
552 weechat
::bar_item_update
("isetbar_help") if (weechat
::config_boolean
($options_iset{"show_help_bar"}) == 1);
555 sub iset_full_refresh
557 $iset_buffer = weechat
::buffer_search
($LANG, $PRGNAME);
558 if ($iset_buffer ne "")
560 weechat
::buffer_clear
($iset_buffer) unless defined $_[0]; # iset_full_refresh(1) does a full refresh without clearing buffer
561 # search for "*" in $filter.
562 if ($filter =~ m/\*/ and $search_mode == 2)
564 iset_get_options
("");
568 if ($search_mode == 0)
570 $search_value = "=" . $search_value;
571 iset_get_values
($search_value);
573 elsif ($search_mode == 1)
575 iset_get_values
($search_value);
577 elsif ($search_mode == 3)
579 iset_create_filter
($filter);
580 iset_get_options
($search_value);
583 if (weechat
::config_boolean
($options_iset{"show_plugin_description"}) == 1)
585 iset_set_current_line
($current_line);
588 $current_line = $#options_names if ($current_line > $#options_names);
591 weechat
::command
($iset_buffer, "/window refresh");
595 sub iset_set_current_line
597 my $new_current_line = $_[0];
598 if ($new_current_line >= 0)
600 my $old_current_line = $current_line;
601 $current_line = $new_current_line;
602 $current_line = $#options_names if ($current_line > $#options_names);
603 if ($old_current_line != $current_line)
605 iset_refresh_line
($old_current_line);
606 iset_refresh_line
($current_line);
607 weechat
::bar_item_update
("isetbar_help") if (weechat
::config_boolean
($options_iset{"show_help_bar"}) == 1);
612 sub iset_signal_window_scrolled_cb
614 my ($data, $signal, $signal_data) = ($_[0], $_[1], $_[2]);
615 if ($iset_buffer ne "")
617 my $infolist = weechat
::infolist_get
("window", $signal_data, "");
618 if (weechat
::infolist_next
($infolist))
620 if (weechat
::infolist_pointer
($infolist, "buffer") eq $iset_buffer)
622 my $old_current_line = $current_line;
623 my $new_current_line = $current_line;
624 my $start_line_y = weechat
::infolist_integer
($infolist, "start_line_y");
625 my $chat_height = weechat
::infolist_integer
($infolist, "chat_height");
626 $new_current_line += $chat_height if ($new_current_line < $start_line_y);
627 $new_current_line -= $chat_height if ($new_current_line >= $start_line_y + $chat_height);
628 $new_current_line = $start_line_y if ($new_current_line < $start_line_y);
629 $new_current_line = $start_line_y + $chat_height - 1 if ($new_current_line >= $start_line_y + $chat_height);
630 iset_set_current_line
($new_current_line);
633 weechat
::infolist_free
($infolist);
636 return weechat
::WEECHAT_RC_OK
;
639 sub iset_get_window_number
641 if ($iset_buffer ne "")
643 my $window = weechat
::window_search_with_buffer
($iset_buffer);
644 return "-window ".weechat
::window_get_integer
($window, "number")." " if ($window ne "");
649 sub iset_check_line_outside_window
651 if ($iset_buffer ne "")
654 if ($wee_version_number >= 0x00030500)
656 my $window = weechat
::window_search_with_buffer
($iset_buffer);
657 $infolist = weechat
::infolist_get
("window", $window, "") if $window;
661 $infolist = weechat
::infolist_get
("window", "", "current");
665 if (weechat
::infolist_next
($infolist))
667 my $start_line_y = weechat
::infolist_integer
($infolist, "start_line_y");
668 my $chat_height = weechat
::infolist_integer
($infolist, "chat_height");
669 my $window_number = "";
670 if ($wee_version_number >= 0x00030500)
672 $window_number = "-window ".weechat
::infolist_integer
($infolist, "number")." ";
674 if ($start_line_y > $current_line)
676 weechat
::command
($iset_buffer, "/window scroll ".$window_number."-".($start_line_y - $current_line));
680 if ($start_line_y <= $current_line - $chat_height)
682 weechat
::command
($iset_buffer, "/window scroll ".$window_number."+".($current_line - $start_line_y - $chat_height + 1));
687 weechat
::infolist_free
($infolist);
692 sub iset_get_option_name_index
694 my $option_name = $_[0];
696 while ($index <= $#options_names)
698 return -1 if ($options_names[$index] gt $option_name);
699 return $index if ($options_names[$index] eq $option_name);
707 my ($data, $option_name, $value) = ($_[0], $_[1], $_[2]);
709 if ($iset_buffer ne "")
711 return weechat
::WEECHAT_RC_OK
if (weechat
::info_get
("weechat_upgrading", "") eq "1");
713 my $index = iset_get_option_name_index
($option_name);
716 # refresh info about changed option
717 my $infolist = weechat
::infolist_get
("option", "", $option_name);
720 weechat
::infolist_next
($infolist);
721 if (weechat
::infolist_fields
($infolist))
723 $options_types[$index] = weechat
::infolist_string
($infolist, "type");
724 $options_values[$index] = weechat
::infolist_string
($infolist, "value");
725 $options_default_values[$index] = weechat
::infolist_string
($infolist, "default_value");
726 $options_is_null[$index] = weechat
::infolist_integer
($infolist, "value_is_null");
727 iset_refresh_line
($index);
728 iset_title
() if ($option_name eq "iset.look.show_current_line");
732 iset_full_refresh
(1); # if not found, refresh fully without clearing buffer
733 weechat
::print_y
($iset_buffer, $#options_names + 1, "");
735 weechat
::infolist_free
($infolist);
740 iset_full_refresh
() if ($option_name ne "weechat.bar.isetbar.hidden");
744 return weechat
::WEECHAT_RC_OK
;
749 my ($option, $value) = ($_[0],$_[1]);
750 if (defined $option and defined $value)
752 $option = weechat
::config_get
($option);
753 weechat
::config_option_set
($option, $value, 1) if ($option ne "");
757 sub iset_reset_option
762 $option = weechat
::config_get
($option);
763 weechat
::config_option_reset
($option, 1) if ($option ne "");
767 sub iset_unset_option
772 $option = weechat
::config_get
($option);
773 weechat
::config_option_unset
($option) if ($option ne "");
780 my ($data, $buffer, $args) = ($_[0], $_[1], $_[2]);
782 # $search_value = "";
783 if (($args ne "") && (substr($args, 0, 2) ne "**"))
785 my @cmd_array = split(/ /,$args);
786 my $array_count = @cmd_array;
787 if (substr($args, 0, 1) eq weechat
::config_string
($options_iset{"value_search_char"})
788 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"})) )
791 my $search_value = substr($args, 1); # cut value_search_char
792 if ($iset_buffer ne "")
794 weechat
::buffer_clear
($iset_buffer);
795 weechat
::command
($iset_buffer, "/window refresh");
797 weechat
::buffer_set
($iset_buffer, "localvar_set_iset_search_mode", $search_mode);
798 weechat
::buffer_set
($iset_buffer, "localvar_set_iset_search_value", $search_value);
800 iset_get_values
($search_value);
802 weechat
::buffer_set
($iset_buffer, "display", "1");
803 # $filter = $var_value;
804 return weechat
::WEECHAT_RC_OK
;
811 if ( $array_count >= 2 and $cmd_array[0] ne "f" or $cmd_array[0] ne "s")
813 if ( defined $cmd_array[1] and substr($cmd_array[1], 0, 1) eq weechat
::config_string
($options_iset{"value_search_char"})
814 or defined $cmd_array[2] and substr($cmd_array[2], 0, 1) eq weechat
::config_string
($options_iset{"value_search_char"}) )
817 $search_value = substr($cmd_array[1], 1); # cut value_search_char
818 $search_value = substr($cmd_array[2], 1) if ( $array_count > 2); # cut value_search_char
821 iset_create_filter
($args);
823 my $ptrbuf = weechat
::buffer_search
($LANG, $PRGNAME);
827 iset_get_options
($search_value);
829 weechat
::buffer_set
(weechat
::buffer_search
($LANG, $PRGNAME), "display", "1");
830 weechat
::buffer_set
($iset_buffer, "localvar_set_iset_search_value", $search_value);
831 weechat
::buffer_set
($iset_buffer, "localvar_set_iset_search_mode", $search_mode);
832 return weechat
::WEECHAT_RC_OK
;
836 iset_get_options
($search_value);
838 weechat
::buffer_set
($ptrbuf, "display", "1");
841 weechat
::buffer_set
($iset_buffer, "localvar_set_iset_search_mode", $search_mode);
842 weechat
::buffer_set
($iset_buffer, "localvar_set_iset_search_value", $search_value);
844 if ($iset_buffer eq "")
847 iset_get_options
("");
852 # iset_get_options($search_value);
853 iset_full_refresh
() if ($filter_set);
858 weechat
::buffer_set
($iset_buffer, "display", "1");
862 if ($args eq "**refresh")
868 if ($current_line > 0)
871 iset_refresh_line
($current_line + 1);
872 iset_refresh_line
($current_line);
873 iset_check_line_outside_window
();
876 if ($args eq "**down")
878 if ($current_line < $#options_names)
881 iset_refresh_line
($current_line - 1);
882 iset_refresh_line
($current_line);
883 iset_check_line_outside_window
();
886 if ($args eq "**left" && $wee_version_number >= 0x00030600)
888 weechat
::command
($iset_buffer, "/window scroll_horiz ".iset_get_window_number
()."-".weechat
::config_integer
($options_iset{"scroll_horiz"})."%");
890 if ($args eq "**right" && $wee_version_number >= 0x00030600)
892 weechat
::command
($iset_buffer, "/window scroll_horiz ".iset_get_window_number
().weechat
::config_integer
($options_iset{"scroll_horiz"})."%");
894 if ($args eq "**scroll_top")
896 my $old_current_line = $current_line;
898 iset_refresh_line
($old_current_line);
899 iset_refresh_line
($current_line);
901 weechat
::command
($iset_buffer, "/window scroll_top ".iset_get_window_number
());
903 if ($args eq "**scroll_bottom")
905 my $old_current_line = $current_line;
906 $current_line = $#options_names;
907 iset_refresh_line
($old_current_line);
908 iset_refresh_line
($current_line);
910 weechat
::command
($iset_buffer, "/window scroll_bottom ".iset_get_window_number
());
912 if ($args eq "**toggle")
914 if ($options_types[$current_line] eq "boolean")
916 iset_set_option
($options_names[$current_line], "toggle");
919 if ($args eq "**incr")
921 if (($options_types[$current_line] eq "integer")
922 || ($options_types[$current_line] eq "color"))
924 iset_set_option
($options_names[$current_line], "++1");
927 if ($args eq "**decr")
929 if (($options_types[$current_line] eq "integer")
930 || ($options_types[$current_line] eq "color"))
932 iset_set_option
($options_names[$current_line], "--1");
935 if ($args eq "**reset")
937 iset_reset_option
($options_names[$current_line]);
939 if ($args eq "**unset")
941 iset_unset_option
($options_names[$current_line]);
943 if ($args eq "**toggle_help")
945 if (weechat
::config_boolean
($options_iset{"show_help_bar"}) == 1)
947 weechat
::config_option_set
($options_iset{"show_help_bar"},0,1);
952 weechat
::config_option_set
($options_iset{"show_help_bar"},1,1);
956 if ($args eq "**toggle_show_plugin_desc")
958 if (weechat
::config_boolean
($options_iset{"show_plugin_description"}) == 1)
960 weechat
::config_option_set
($options_iset{"show_plugin_description"},0,1);
962 iset_check_line_outside_window
();
967 weechat
::config_option_set
($options_iset{"show_plugin_description"},1,1);
969 iset_check_line_outside_window
();
973 if ($args eq "**set")
976 my $value = $options_values[$current_line];
977 if ($options_is_null[$current_line])
983 $quote = "\"" if ($options_types[$current_line] eq "string");
985 my $set_command = "/set";
986 $set_command = "/mute " . $set_command if (weechat
::config_boolean
($options_iset{"use_mute"}) == 1);
988 weechat
::buffer_set
($iset_buffer, "input", $set_command." ".$options_names[$current_line]." ".$quote.$value.$quote);
989 weechat
::command
($iset_buffer, "/input move_beginning_of_line");
990 weechat
::command
($iset_buffer, "/input move_next_word");
991 weechat
::command
($iset_buffer, "/input move_next_word");
992 weechat
::command
($iset_buffer, "/input move_next_word") if (weechat
::config_boolean
($options_iset{"use_mute"}) == 1);
993 weechat
::command
($iset_buffer, "/input move_next_char");
994 weechat
::command
($iset_buffer, "/input move_next_char") if ($quote ne "");
997 weechat
::bar_item_update
("isetbar_help") if (weechat
::config_boolean
($options_iset{"show_help_bar"}) == 1);
998 return weechat
::WEECHAT_RC_OK
;
1003 my ($redraw) = ($_[0]);
1005 return '' if (weechat
::config_boolean
($options_iset{"show_help_bar"}) == 0);
1007 if (not defined $options_names[$current_line])
1009 return "No option selected. Set a new filter using command line (use '*' to see all options)";
1011 if ($options_name_copy eq $options_names[$current_line] and not defined $redraw)
1013 return $description;
1015 $options_name_copy = $options_names[$current_line];
1017 $optionlist = weechat
::infolist_get
("option", "", $options_names[$current_line]);
1018 weechat
::infolist_next
($optionlist);
1019 my $full_name = weechat
::infolist_string
($optionlist,"full_name");
1020 my $option_desc = "";
1021 my $option_default_value = "";
1022 my $option_range = "";
1023 my $possible_values = "";
1024 my $re = qq(\Q$full_name);
1025 if (grep (/^$re$/,$options_names[$current_line]))
1027 $option_desc = weechat
::infolist_string
($optionlist, "description_nls");
1028 $option_desc = weechat
::infolist_string
($optionlist, "description") if ($option_desc eq "");
1029 $option_desc = "No help found" if ($option_desc eq "");
1030 $option_default_value = weechat
::infolist_string
($optionlist, "default_value");
1031 $possible_values = weechat
::infolist_string
($optionlist, "string_values") if (weechat
::infolist_string
($optionlist, "string_values") ne "");
1032 if ((weechat
::infolist_string
($optionlist, "type") eq "integer") && ($possible_values eq ""))
1034 $option_range = weechat
::infolist_integer
($optionlist, "min")
1035 ." .. ".weechat
::infolist_integer
($optionlist, "max");
1038 weechat
::infolist_free
($optionlist);
1041 $description = weechat
::color
(weechat
::config_color
($options_iset{"color_help_option_name"})).$options_names[$current_line]
1042 .weechat
::color
("bar_fg").": "
1043 .weechat
::color
(weechat
::config_color
($options_iset{"color_help_text"})).$option_desc;
1045 # show additional infos like default value and possible values
1047 if (weechat
::config_boolean
($options_iset{"show_help_extra_info"}) == 1)
1050 weechat
::color
("bar_delim")." ["
1051 .weechat
::color
("bar_fg")."default: "
1052 .weechat
::color
("bar_delim")."\""
1053 .weechat
::color
(weechat
::config_color
($options_iset{"color_help_default_value"})).$option_default_value
1054 .weechat
::color
("bar_delim")."\"";
1055 if ($option_range ne "")
1057 $description .= weechat
::color
("bar_fg").", values: ".$option_range;
1059 if ($possible_values ne "")
1061 $possible_values =~ s/\|/", "/g; # replace '|' to '", "'
1062 $description .= weechat
::color
("bar_fg").", values: ". "\"" . $possible_values . "\"";
1065 $description .= weechat
::color
("bar_delim")."]";
1067 return $description;
1070 sub iset_check_condition_isetbar_cb
1072 my ($data, $modifier, $modifier_data, $string) = ($_[0], $_[1], $_[2], $_[3]);
1073 my $buffer = weechat
::window_get_pointer
($modifier_data, "buffer");
1076 if ((weechat
::buffer_get_string
($buffer, "plugin") eq $LANG)
1077 && (weechat
::buffer_get_string
($buffer, "name") eq $PRGNAME))
1088 my $barhidden = weechat
::config_get
("weechat.bar.isetbar.hidden");
1093 if (weechat
::config_boolean
($options_iset{"show_help_bar"}) == 1)
1095 if (weechat
::config_boolean
($barhidden))
1097 weechat
::config_option_set
($barhidden, 0, 1);
1103 if (!weechat
::config_boolean
($barhidden))
1105 weechat
::config_option_set
($barhidden, 1, 1);
1111 sub iset_signal_buffer_switch_cb
1113 my $buffer_pointer = $_[2];
1115 $show_bar = 1 if (weechat
::buffer_get_integer
($iset_buffer, "num_displayed") > 0);
1116 iset_show_bar
($show_bar);
1117 iset_check_line_outside_window
() if ($buffer_pointer eq $iset_buffer);
1118 return weechat
::WEECHAT_RC_OK
;
1123 return iset_get_help
();
1126 sub iset_upgrade_ended
1128 iset_full_refresh
();
1133 # when script is unloaded, we hide bar
1137 # -------------------------------[ mouse support ]-------------------------------------
1139 sub hook_focus_iset_cb
1141 my %info = %{$_[1]};
1142 my $bar_item_line = int($info{"_bar_item_line"});
1144 if (($info{"_buffer_name"} eq $PRGNAME) && $info{"_buffer_plugin"} eq $LANG && ($bar_item_line >= 0) && ($bar_item_line <= $#iset_focus))
1146 $hash = $iset_focus[$bar_item_line];
1151 my $hash_focus = $iset_focus[0];
1152 foreach my $key (keys %$hash_focus)
1154 $hash->{$key} = "?";
1160 # _chat_line_y contains selected line
1161 sub iset_hsignal_mouse_cb
1163 my ($data, $signal, %hash) = ($_[0], $_[1], %{$_[2]});
1165 if ($hash{"_buffer_name"} eq $PRGNAME && ($hash{"_buffer_plugin"} eq $LANG))
1167 if ($hash{"_key"} eq "button1")
1169 iset_set_current_line
($hash{"_chat_line_y"});
1171 elsif ($hash{"_key"} eq "button2")
1173 if ($options_types[$hash{"_chat_line_y"}] eq "boolean")
1175 iset_set_option
($options_names[$hash{"_chat_line_y"}], "toggle");
1176 iset_set_current_line
($hash{"_chat_line_y"});
1178 elsif ($options_types[$hash{"_chat_line_y"}] eq "string")
1180 iset_set_current_line
($hash{"_chat_line_y"});
1181 weechat
::command
("", "/$PRGNAME **set");
1184 elsif ($hash{"_key"} eq "button2-gesture-left" or $hash{"_key"} eq "button2-gesture-left-long")
1186 if ($options_types[$hash{"_chat_line_y"}] eq "integer" or ($options_types[$hash{"_chat_line_y"}] eq "color"))
1188 iset_set_current_line
($hash{"_chat_line_y"});
1189 my $distance = distance
($hash{"_chat_line_x"},$hash{"_chat_line_x2"});
1190 weechat
::command
("", "/repeat $distance /$PRGNAME **decr");
1193 elsif ($hash{"_key"} eq "button2-gesture-right" or $hash{"_key"} eq "button2-gesture-right-long")
1195 if ($options_types[$hash{"_chat_line_y"}] eq "integer" or ($options_types[$hash{"_chat_line_y"}] eq "color"))
1197 iset_set_current_line
($hash{"_chat_line_y"});
1198 my $distance = distance
($hash{"_chat_line_x"},$hash{"_chat_line_x2"});
1199 weechat
::command
("", "/repeat $distance /$PRGNAME **incr");
1208 my $current_window = weechat
::current_window
();
1209 my $dest_window = weechat
::window_search_with_buffer
(weechat
::buffer_search
("perl","iset"));
1210 return 0 if ($dest_window eq "" or $current_window eq $dest_window);
1212 my $infolist = weechat
::infolist_get
("window", $dest_window, "");
1213 weechat
::infolist_next
($infolist);
1214 my $number = weechat
::infolist_integer
($infolist, "number");
1215 weechat
::infolist_free
($infolist);
1216 weechat
::command
("","/window " . $number);
1221 my ($x1,$x2) = ($_[0], $_[1]);
1223 $distance = $x1 - $x2;
1224 $distance = abs($distance);
1228 $distance = $distance / 3;
1229 $distance = 1 if ($distance == 0);
1231 elsif ($distance == 0)
1238 # -----------------------------------[ config ]---------------------------------------
1240 sub iset_config_init
1242 $iset_config_file = weechat
::config_new
($ISET_CONFIG_FILE_NAME,"iset_config_reload_cb","");
1243 return if ($iset_config_file eq "");
1246 my $section_color = weechat
::config_new_section
($iset_config_file,"color", 0, 0, "", "", "", "", "", "", "", "", "", "");
1247 if ($section_color eq "")
1249 weechat
::config_free
($iset_config_file);
1252 $options_iset{"color_option"} = weechat
::config_new_option
(
1253 $iset_config_file, $section_color,
1254 "option", "color", "Color for option name in iset buffer", "", 0, 0,
1255 "default", "default", 0, "", "", "full_refresh_cb", "", "", "");
1256 $options_iset{"color_option_selected"} = weechat
::config_new_option
(
1257 $iset_config_file, $section_color,
1258 "option_selected", "color", "Color for selected option name in iset buffer", "", 0, 0,
1259 "white", "white", 0, "", "", "full_refresh_cb", "", "", "");
1260 $options_iset{"color_type"} = weechat
::config_new_option
(
1261 $iset_config_file, $section_color,
1262 "type", "color", "Color for option type (integer, boolean, string)", "", 0, 0,
1263 "brown", "brown", 0, "", "", "full_refresh_cb", "", "", "");
1264 $options_iset{"color_type_selected"} = weechat
::config_new_option
(
1265 $iset_config_file, $section_color,
1266 "type_selected", "color", "Color for selected option type (integer, boolean, string)", "", 0, 0,
1267 "yellow", "yellow", 0, "", "", "full_refresh_cb", "", "", "");
1268 $options_iset{"color_value"} = weechat
::config_new_option
(
1269 $iset_config_file, $section_color,
1270 "value", "color", "Color for option value", "", 0, 0,
1271 "cyan", "cyan", 0, "", "", "full_refresh_cb", "", "", "");
1272 $options_iset{"color_value_selected"} = weechat
::config_new_option
(
1273 $iset_config_file, $section_color,
1274 "value_selected", "color", "Color for selected option value", "", 0, 0,
1275 "lightcyan", "lightcyan", 0, "", "", "full_refresh_cb", "", "", "");
1276 $options_iset{"color_value_diff"} = weechat
::config_new_option
(
1277 $iset_config_file, $section_color,
1278 "value_diff", "color", "Color for option value different from default", "", 0, 0,
1279 "magenta", "magenta", 0, "", "", "full_refresh_cb", "", "", "");
1280 $options_iset{"color_value_diff_selected"} = weechat
::config_new_option
(
1281 $iset_config_file, $section_color,
1282 "value_diff_selected", "color", "Color for selected option value different from default", "", 0, 0,
1283 "lightmagenta", "lightmagenta", 0, "", "", "full_refresh_cb", "", "", "");
1284 $options_iset{"color_value_undef"} = weechat
::config_new_option
(
1285 $iset_config_file, $section_color,
1286 "value_undef", "color", "Color for option value undef", "", 0, 0,
1287 "green", "green", 0, "", "", "full_refresh_cb", "", "", "");
1288 $options_iset{"color_value_undef_selected"} = weechat
::config_new_option
(
1289 $iset_config_file, $section_color,
1290 "value_undef_selected", "color", "Color for selected option value undef", "", 0, 0,
1291 "lightgreen", "lightgreen", 0, "", "", "full_refresh_cb", "", "", "");
1292 $options_iset{"color_bg_selected"} = weechat
::config_new_option
(
1293 $iset_config_file, $section_color,
1294 "bg_selected", "color", "Background color for current selected option", "", 0, 0,
1295 "red", "red", 0, "", "", "full_refresh_cb", "", "", "");
1296 $options_iset{"color_help_option_name"} = weechat
::config_new_option
(
1297 $iset_config_file, $section_color,
1298 "help_option_name", "color", "Color for option name in help-bar", "", 0, 0,
1299 "white", "white", 0, "", "", "bar_refresh", "", "", "");
1300 $options_iset{"color_help_text"} = weechat
::config_new_option
(
1301 $iset_config_file, $section_color,
1302 "help_text", "color", "Color for option description in help-bar", "", 0, 0,
1303 "default", "default", 0, "", "", "bar_refresh", "", "", "");
1304 $options_iset{"color_help_default_value"} = weechat
::config_new_option
(
1305 $iset_config_file, $section_color,
1306 "help_default_value", "color", "Color for default option value in help-bar", "", 0, 0,
1307 "green", "green", 0, "", "", "bar_refresh", "", "", "");
1310 my $section_help = weechat
::config_new_section
($iset_config_file,"help", 0, 0, "", "", "", "", "", "", "", "", "", "");
1311 if ($section_help eq "")
1313 weechat
::config_free
($iset_config_file);
1316 $options_iset{"show_help_bar"} = weechat
::config_new_option
(
1317 $iset_config_file, $section_help,
1318 "show_help_bar", "boolean", "Show help bar", "", 0, 0,
1319 "on", "on", 0, "", "", "toggle_help_cb", "", "", "");
1320 $options_iset{"show_help_extra_info"} = weechat
::config_new_option
(
1321 $iset_config_file, $section_help,
1322 "show_help_extra_info", "boolean", "Show additional information in help bar (default value, max./min. value) ", "", 0, 0,
1323 "on", "on", 0, "", "", "", "", "", "");
1324 $options_iset{"show_plugin_description"} = weechat
::config_new_option
(
1325 $iset_config_file, $section_help,
1326 "show_plugin_description", "boolean", "Show plugin description in iset buffer", "", 0, 0,
1327 "off", "off", 0, "", "", "full_refresh_cb", "", "", "");
1330 my $section_look = weechat
::config_new_section
($iset_config_file, "look", 0, 0, "", "", "", "", "", "", "", "", "", "");
1331 if ($section_look eq "")
1333 weechat
::config_free
($iset_config_file);
1336 $options_iset{"value_search_char"} = weechat
::config_new_option
(
1337 $iset_config_file, $section_look,
1338 "value_search_char", "string", "Trigger char to tell iset to search for value instead of option (for example: =red)", "", 0, 0,
1339 "=", "=", 0, "", "", "", "", "", "");
1340 $options_iset{"scroll_horiz"} = weechat
::config_new_option
(
1341 $iset_config_file, $section_look,
1342 "scroll_horiz", "integer", "scroll content of iset buffer n%", "", 1, 100,
1343 "10", "10", 0, "", "", "", "", "", "");
1344 $options_iset{"show_current_line"} = weechat
::config_new_option
(
1345 $iset_config_file, $section_look,
1346 "show_current_line", "boolean", "show current line in title bar.", "", 0, 0,
1347 "on", "on", 0, "", "", "", "", "", "");
1348 $options_iset{"use_mute"} = weechat
::config_new_option
(
1349 $iset_config_file, $section_look,
1350 "use_mute", "boolean", "/mute command will be used in input bar", "", 0, 0,
1351 "off", "off", 0, "", "", "", "", "", "");
1354 sub iset_config_reload_cb
1356 my ($data,$config_file) = ($_[0], $_[1]);
1357 return weechat
::config_reload
($config_file)
1360 sub iset_config_read
1362 return weechat
::config_read
($iset_config_file) if ($iset_config_file ne "");
1365 sub iset_config_write
1367 return weechat
::config_write
($iset_config_file) if ($iset_config_file ne "");
1372 iset_full_refresh
();
1373 return weechat
::WEECHAT_RC_OK
;
1379 weechat
::bar_item_update
("isetbar_help") if (weechat
::config_boolean
($options_iset{"show_help_bar"}) == 1);
1380 return weechat
::WEECHAT_RC_OK
;
1385 my $value = weechat
::config_boolean
($options_iset{"show_help_bar"});
1386 iset_show_bar
($value);
1387 return weechat
::WEECHAT_RC_OK
;
1390 # -----------------------------------[ main ]-----------------------------------------
1392 weechat
::register
($PRGNAME, $AUTHOR, $VERSION, $LICENSE,
1393 $DESCR, "iset_end", "");
1395 $wee_version_number = weechat
::info_get
("version_number", "") || 0;
1400 weechat
::hook_command
($PRGNAME, "Interactive set", "f <file> || s <section> || [=][=]<text>",
1401 "f file : show options for a file\n".
1402 "s section: show options for a section\n".
1403 "text : show options with 'text' in name\n".
1404 weechat
::config_string
($options_iset{"value_search_char"})."text : show options with 'text' in value\n".
1405 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".
1406 "Keys for iset buffer:\n".
1407 "f11,f12 : move iset content left/right\n".
1408 "up,down : move one option up/down\n".
1409 "pgup,pdwn : move one page up/down\n".
1410 "home,end : move to first/last option\n".
1411 "ctrl+'L' : refresh options and screen\n".
1412 "alt+space : toggle boolean on/off\n".
1413 "alt+'+' : increase value (for integer or color)\n".
1414 "alt+'-' : decrease value (for integer or color)\n".
1415 "alt+'i',alt+'r': reset value of option\n".
1416 "alt+'i',alt+'u': unset option\n".
1417 "alt+enter : set new value for option (edit it with command line)\n".
1418 "text,enter : set a new filter using command line (use '*' to see all options)\n".
1419 "alt+'v' : toggle help bar on/off\n".
1420 "alt+'p' : toggle option \"show_plugin_description\" on/off\n".
1423 "wheel up/down : move cursor up/down\n".
1424 "left button : select an option from list\n".
1425 "right button : toggle boolean (on/off) or set a new value for option (edit it with command line)\n".
1426 "right button + drag left/right: increase/decrease value (for integer or color)\n".
1429 " show options for file 'weechat'\n".
1430 " /iset f weechat\n".
1431 " show options for file 'irc'\n".
1433 " show options for section 'look'\n".
1435 " show all options with text 'nicklist' in name\n".
1436 " /iset nicklist\n".
1437 " show all values which contain 'red'. ('" . weechat
::config_string
($options_iset{"value_search_char"}) . "' is a trigger char).\n".
1438 " /iset ". weechat
::config_string
($options_iset{"value_search_char"}) ."red\n".
1439 " 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".
1440 " /iset ". weechat
::config_string
($options_iset{"value_search_char"}) . weechat
::config_string
($options_iset{"value_search_char"}) ."off\n".
1441 " show options for file 'weechat' which contains value 'off'\n".
1442 " /iset f weechat ".weechat
::config_string
($options_iset{"value_search_char"})."off\n".
1444 "", "iset_cmd_cb", "");
1445 weechat
::hook_signal
("upgrade_ended", "iset_upgrade_ended", "");
1446 weechat
::hook_signal
("window_scrolled", "iset_signal_window_scrolled_cb", "");
1447 weechat
::hook_signal
("buffer_switch", "iset_signal_buffer_switch_cb","");
1448 weechat
::bar_item_new
("isetbar_help", "iset_item_cb", "");
1449 weechat
::bar_new
("isetbar", "on", "0", "window", "", "top", "horizontal",
1450 "vertical", "3", "3", "default", "cyan", "default", "1",
1452 weechat
::hook_modifier
("bar_condition_isetbar", "iset_check_condition_isetbar_cb", "");
1453 weechat
::hook_config
("*", "iset_config_cb", "");
1454 $iset_buffer = weechat
::buffer_search
($LANG, $PRGNAME);
1455 iset_init
() if ($iset_buffer ne "");
1457 if ($wee_version_number >= 0x00030600)
1459 weechat
::hook_focus
("chat", "hook_focus_iset_cb", "");
1460 weechat
::hook_hsignal
($PRGNAME."_mouse", "iset_hsignal_mouse_cb", "");
1461 weechat
::key_bind
("mouse", \
%mouse_keys);