iset.pl 65 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625
  1. #
  2. # Copyright (C) 2008-2014 Sebastien Helleu <flashcode@flashtux.org>
  3. # Copyright (C) 2010-2015 Nils Görs <weechatter@arcor.de>
  4. #
  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.
  9. #
  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.
  14. #
  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/>.
  17. #
  18. # Set WeeChat and plugins options interactively.
  19. #
  20. # History:
  21. #
  22. # 2016-07-08, nils_2 <weechatter@arcor.de>
  23. # version 4.2: add diff function
  24. # 2016-02-06, Sebastien Helleu <flashcode@flashtux.org>:
  25. # version 4.1: remove debug print
  26. # 2015-12-24, Sebastien Helleu <flashcode@flashtux.org>:
  27. # version 4.0: add support of parent options (inherited values in irc servers)
  28. # with WeeChat >= 1.4
  29. # 2015-05-16, Sebastien Helleu <flashcode@flashtux.org>:
  30. # version 3.9: fix cursor position when editing an option with WeeChat >= 1.2
  31. # 2015-05-02, arza <arza@arza.us>:
  32. # version 3.8: don't append "null" to /set when setting an undefined setting
  33. # 2015-05-01, nils_2 <weechatter@arcor.de>:
  34. # version 3.7: fix two perl warnings (reported by t3chguy)
  35. # 2014-09-30, arza <arza@arza.us>:
  36. # version 3.6: fix current line counter when options aren't found
  37. # 2014-06-03, nils_2 <weechatter@arcor.de>:
  38. # version 3.5: add new option "use_mute"
  39. # 2014-01-30, stfn <stfnmd@gmail.com>:
  40. # version 3.4: add new options "color_value_diff" and "color_value_diff_selected"
  41. # 2014-01-16, luz <ne.tetewi@gmail.com>:
  42. # version 3.3: fix bug with column alignment in iset buffer when option
  43. # name contains unicode characters
  44. # 2013-08-03, Sebastien Helleu <flashcode@flashtux.org>:
  45. # version 3.2: allow "q" as input in iset buffer to close it
  46. # 2013-07-14, Sebastien Helleu <flashcode@flashtux.org>:
  47. # version 3.1: remove unneeded calls to iset_refresh() in mouse callback
  48. # (faster mouse actions when lot of options are displayed),
  49. # fix bug when clicking on a line after the last option displayed
  50. # 2013-04-30, arza <arza@arza.us>:
  51. # version 3.0: simpler title, fix refresh on unset
  52. # 2012-12-16, nils_2 <weechatter@arcor.de>:
  53. # version 2.9: fix focus window with iset buffer on mouse click
  54. # 2012-08-25, nils_2 <weechatter@arcor.de>:
  55. # version 2.8: most important key and mouse bindings for iset buffer added to title-bar (idea The-Compiler)
  56. # 2012-07-31, nils_2 <weechatter@arcor.de>:
  57. # version 2.7: add combined option and value search (see /help iset)
  58. # : add exact value search (see /help iset)
  59. # : fix problem with metacharacter in value search
  60. # : fix use of uninitialized value for unset option and reset value of option
  61. # 2012-07-25, nils_2 <weechatter@arcor.de>:
  62. # version 2.6: switch to iset buffer (if existing) when command /iset is called with arguments
  63. # 2012-03-17, Sebastien Helleu <flashcode@flashtux.org>:
  64. # version 2.5: fix check of sections when creating config file
  65. # 2012-03-09, Sebastien Helleu <flashcode@flashtux.org>:
  66. # version 2.4: fix reload of config file
  67. # 2012-02-02, nils_2 <weechatter@arcor.de>:
  68. # version 2.3: fixed: refresh problem with new search results and cursor was outside window.
  69. # : add: new option "current_line" in title bar
  70. # version 2.2: fixed: refresh error when toggling plugins description
  71. # 2011-11-05, nils_2 <weechatter@arcor.de>:
  72. # version 2.1: use own config file (iset.conf), fix own help color (used immediately)
  73. # 2011-10-16, nils_2 <weechatter@arcor.de>:
  74. # version 2.0: add support for left-mouse-button and more sensitive mouse gesture (for integer/color options)
  75. # add help text for mouse support
  76. # 2011-09-20, Sebastien Helleu <flashcode@flashtux.org>:
  77. # version 1.9: add mouse support, fix iset buffer, fix errors on first load under FreeBSD
  78. # 2011-07-21, nils_2 <weechatter@arcor.de>:
  79. # version 1.8: added: option "show_plugin_description" (alt+p)
  80. # fixed: typos in /help iset (lower case for alt+'x' keys)
  81. # 2011-05-29, nils_2 <weechatter@arcor.de>:
  82. # version 1.7: added: version check for future needs
  83. # added: new option (scroll_horiz) and usage of scroll_horiz function (weechat >= 0.3.6 required)
  84. # fixed: help_bar did not pop up immediately using key-shortcut
  85. # 2011-02-19, nils_2 <weechatter@arcor.de>:
  86. # version 1.6: added: display of all possible values in help bar (show_help_extra_info)
  87. # fixed: external user options never loaded when starting iset first time
  88. # 2011-02-13, Sebastien Helleu <flashcode@flashtux.org>:
  89. # version 1.5: use new help format for command arguments
  90. # 2011-02-03, nils_2 <weechatter@arcor.de>:
  91. # version 1.4: fixed: restore value filter after /upgrade using buffer local variable.
  92. # 2011-01-14, nils_2 <weechatter@arcor.de>:
  93. # version 1.3: added function to search for values (option value_search_char).
  94. # code optimization.
  95. # 2010-12-26, Sebastien Helleu <flashcode@flashtux.org>:
  96. # version 1.2: improve speed of /upgrade when iset buffer is open,
  97. # restore filter used after /upgrade using buffer local variable,
  98. # use /iset filter argument if buffer is open.
  99. # 2010-11-21, drubin <drubin+weechat@smartcube.co.za>:
  100. # version 1.1.1: fix bugs with cursor position
  101. # 2010-11-20, nils_2 <weechatter@arcor.de>:
  102. # version 1.1: cursor position set to value
  103. # 2010-08-03, Sebastien Helleu <flashcode@flashtux.org>:
  104. # version 1.0: move misplaced call to infolist_free()
  105. # 2010-02-02, rettub <rettub@gmx.net>:
  106. # version 0.9: turn all the help stuff off if option 'show_help_bar' is 'off',
  107. # new key binding <alt>-<v> to toggle help_bar and help stuff on/off
  108. # 2010-01-30, nils_2 <weechatter@arcor.de>:
  109. # version 0.8: fix error when option does not exist
  110. # 2010-01-24, Sebastien Helleu <flashcode@flashtux.org>:
  111. # version 0.7: display iset bar only on iset buffer
  112. # 2010-01-22, nils_2 <weechatter@arcor.de> and drubin:
  113. # version 0.6: add description in a bar, fix singular/plural bug in title bar,
  114. # fix selected line when switching buffer
  115. # 2009-06-21, Sebastien Helleu <flashcode@flashtux.org>:
  116. # version 0.5: fix bug with iset buffer after /upgrade
  117. # 2009-05-02, Sebastien Helleu <flashcode@flashtux.org>:
  118. # version 0.4: sync with last API changes
  119. # 2009-01-04, Sebastien Helleu <flashcode@flashtux.org>:
  120. # version 0.3: open iset buffer when /iset command is executed
  121. # 2009-01-04, Sebastien Helleu <flashcode@flashtux.org>:
  122. # version 0.2: use null values for options, add colors, fix refresh bugs,
  123. # use new keys to reset/unset options, sort options by name,
  124. # display number of options in buffer's title
  125. # 2008-11-05, Sebastien Helleu <flashcode@flashtux.org>:
  126. # version 0.1: first official version
  127. # 2008-04-19, Sebastien Helleu <flashcode@flashtux.org>:
  128. # script creation
  129. use strict;
  130. my $PRGNAME = "iset";
  131. my $VERSION = "4.2";
  132. my $DESCR = "Interactive Set for configuration options";
  133. my $AUTHOR = "Sebastien Helleu <flashcode\@flashtux.org>";
  134. my $LICENSE = "GPL3";
  135. my $LANG = "perl";
  136. my $ISET_CONFIG_FILE_NAME = "iset";
  137. my $iset_config_file;
  138. my $iset_buffer = "";
  139. my $wee_version_number = 0;
  140. my @iset_focus = ();
  141. my @options_names = ();
  142. my @options_parent_names = ();
  143. my @options_types = ();
  144. my @options_values = ();
  145. my @options_default_values = ();
  146. my @options_parent_values = ();
  147. my @options_is_null = ();
  148. my $option_max_length = 0;
  149. my $current_line = 0;
  150. my $filter = "*";
  151. my $description = "";
  152. my $options_name_copy = "";
  153. my $iset_filter_title = "";
  154. # search modes: 0 = index() on value, 1 = grep() on value, 2 = grep() on option, 3 = grep on option & value, 4 = diff all, 5 = diff parts
  155. my $search_mode = 2;
  156. my $search_value = "";
  157. my $help_text_keys = "alt + space: toggle, +/-: increase/decrease, enter: change, ir: reset, iu: unset, v: toggle help bar";
  158. my $help_text_mouse = "Mouse: left: select, right: toggle/set, right + drag left/right: increase/decrease";
  159. my %options_iset;
  160. my %mouse_keys = ("\@chat(perl.$PRGNAME):button1" => "hsignal:iset_mouse",
  161. "\@chat(perl.$PRGNAME):button2*" => "hsignal:iset_mouse",
  162. "\@chat(perl.$PRGNAME):wheelup" => "/repeat 5 /iset **up",
  163. "\@chat(perl.$PRGNAME):wheeldown" => "/repeat 5 /iset **down");
  164. sub iset_title
  165. {
  166. if ($iset_buffer ne "")
  167. {
  168. my $current_line_counter = "";
  169. if (weechat::config_boolean($options_iset{"show_current_line"}) == 1)
  170. {
  171. if (@options_names eq 0)
  172. {
  173. $current_line_counter = "0/";
  174. }
  175. else
  176. {
  177. $current_line_counter = ($current_line + 1) . "/";
  178. }
  179. }
  180. my $show_filter = "";
  181. if ($search_mode eq 0)
  182. {
  183. $iset_filter_title = "(value) ";
  184. $show_filter = $search_value;
  185. if ( substr($show_filter,0,1) eq weechat::config_string($options_iset{"value_search_char"}) )
  186. {
  187. $show_filter = substr($show_filter,1,length($show_filter));
  188. }
  189. }
  190. elsif ($search_mode eq 1)
  191. {
  192. $iset_filter_title = "(value) ";
  193. $show_filter = "*".$search_value."*";
  194. }
  195. elsif ($search_mode eq 2)
  196. {
  197. $iset_filter_title = "";
  198. $filter = "*" if ($filter eq "");
  199. $show_filter = $filter;
  200. }
  201. elsif ($search_mode == 4 or $search_mode == 5)
  202. {
  203. $iset_filter_title = "diff: ";
  204. $show_filter = "all";
  205. $show_filter = $search_value if $search_mode == 5;
  206. }
  207. elsif ($search_mode eq 3)
  208. {
  209. $iset_filter_title = "(option) ";
  210. $show_filter = $filter
  211. .weechat::color("default")
  212. ." / (value) "
  213. .weechat::color("yellow")
  214. ."*".$search_value."*";
  215. }
  216. weechat::buffer_set($iset_buffer, "title",
  217. $iset_filter_title
  218. .weechat::color("yellow")
  219. .$show_filter
  220. .weechat::color("default")." | "
  221. .$current_line_counter
  222. .@options_names
  223. ." | "
  224. .$help_text_keys
  225. ." | "
  226. .$help_text_mouse);
  227. }
  228. }
  229. sub iset_create_filter
  230. {
  231. $filter = $_[0];
  232. if ( $search_mode == 3 )
  233. {
  234. my @cmd_array = split(/ /,$filter);
  235. my $array_count = @cmd_array;
  236. $filter = $cmd_array[0];
  237. $filter = $cmd_array[0] . " " . $cmd_array[1] if ( $array_count >2 );
  238. }
  239. $filter = "$1.*" if ($filter =~ /f (.*)/); # search file
  240. $filter = "*.$1.*" if ($filter =~ /s (.*)/); # search section
  241. if ((substr($filter, 0, 1) ne "*") && (substr($filter, -1, 1) ne "*"))
  242. {
  243. $filter = "*".$filter."*";
  244. }
  245. if ($iset_buffer ne "")
  246. {
  247. weechat::buffer_set($iset_buffer, "localvar_set_iset_filter", $filter);
  248. }
  249. }
  250. sub iset_buffer_input
  251. {
  252. my ($data, $buffer, $string) = ($_[0], $_[1], $_[2]);
  253. # string begins with space?
  254. return weechat::WEECHAT_RC_OK if (substr($string, 0, 1 ) eq " ");
  255. if ($string eq "q")
  256. {
  257. weechat::buffer_close($buffer);
  258. return weechat::WEECHAT_RC_OK;
  259. }
  260. $search_value = "";
  261. my @cmd_array = split(/ /,$string);
  262. my $array_count = @cmd_array;
  263. my $string2 = substr($string, 0, 1);
  264. if ($string2 eq weechat::config_string($options_iset{"value_search_char"})
  265. 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"})) )
  266. {
  267. $search_mode = 1;
  268. $search_value = substr($string, 1);
  269. iset_get_values($search_value);
  270. if ($iset_buffer ne "")
  271. {
  272. weechat::buffer_set($iset_buffer, "localvar_set_iset_search_value", $search_value);
  273. }
  274. }
  275. # show all diff values
  276. elsif ($string eq "d")
  277. {
  278. $search_mode = 4;
  279. # iset_title();
  280. iset_create_filter("*");
  281. iset_get_options("*");
  282. }
  283. elsif ( $array_count >= 2 and $cmd_array[0] eq "d")
  284. {
  285. $search_mode = 5;
  286. $search_value = substr($cmd_array[1], 0); # cut value_search_char
  287. $search_value = substr($cmd_array[2], 0) if ( $array_count > 2); # cut value_search_char
  288. iset_create_filter($search_value);
  289. iset_get_options($search_value);
  290. }
  291. else
  292. {
  293. $search_mode = 2;
  294. if ( $array_count >= 2 and $cmd_array[0] ne "f" or $cmd_array[0] ne "s" )
  295. {
  296. if ( defined $cmd_array[1] and substr($cmd_array[1], 0, 1) eq weechat::config_string($options_iset{"value_search_char"})
  297. or defined $cmd_array[2] and substr($cmd_array[2], 0, 1) eq weechat::config_string($options_iset{"value_search_char"}) )
  298. {
  299. $search_mode = 3;
  300. $search_value = substr($cmd_array[1], 1); # cut value_search_char
  301. $search_value = substr($cmd_array[2], 1) if ( $array_count > 2); # cut value_search_char
  302. }
  303. }
  304. if ( $search_mode == 3)
  305. {
  306. iset_create_filter($string);
  307. iset_get_options($search_value);
  308. }
  309. else
  310. {
  311. iset_create_filter($string);
  312. iset_get_options("");
  313. }
  314. }
  315. weechat::buffer_set($iset_buffer, "localvar_set_iset_search_mode", $search_mode);
  316. weechat::buffer_clear($buffer);
  317. $current_line = 0;
  318. iset_refresh();
  319. return weechat::WEECHAT_RC_OK;
  320. }
  321. sub iset_buffer_close
  322. {
  323. $iset_buffer = "";
  324. return weechat::WEECHAT_RC_OK;
  325. }
  326. sub iset_init
  327. {
  328. $current_line = 0;
  329. $iset_buffer = weechat::buffer_search($LANG, $PRGNAME);
  330. if ($iset_buffer eq "")
  331. {
  332. $iset_buffer = weechat::buffer_new($PRGNAME, "iset_buffer_input", "", "iset_buffer_close", "");
  333. }
  334. else
  335. {
  336. my $new_filter = weechat::buffer_get_string($iset_buffer, "localvar_iset_filter");
  337. $search_mode = weechat::buffer_get_string($iset_buffer, "localvar_iset_search_mode");
  338. $search_value = weechat::buffer_get_string($iset_buffer, "localvar_iset_search_value");
  339. $filter = $new_filter if ($new_filter ne "");
  340. }
  341. if ($iset_buffer ne "")
  342. {
  343. weechat::buffer_set($iset_buffer, "type", "free");
  344. iset_title();
  345. weechat::buffer_set($iset_buffer, "key_bind_ctrl-L", "/iset **refresh");
  346. weechat::buffer_set($iset_buffer, "key_bind_meta2-A", "/iset **up");
  347. weechat::buffer_set($iset_buffer, "key_bind_meta2-B", "/iset **down");
  348. weechat::buffer_set($iset_buffer, "key_bind_meta2-23~", "/iset **left");
  349. weechat::buffer_set($iset_buffer, "key_bind_meta2-24~" , "/iset **right");
  350. weechat::buffer_set($iset_buffer, "key_bind_meta- ", "/iset **toggle");
  351. weechat::buffer_set($iset_buffer, "key_bind_meta-+", "/iset **incr");
  352. weechat::buffer_set($iset_buffer, "key_bind_meta--", "/iset **decr");
  353. weechat::buffer_set($iset_buffer, "key_bind_meta-imeta-r", "/iset **reset");
  354. weechat::buffer_set($iset_buffer, "key_bind_meta-imeta-u", "/iset **unset");
  355. weechat::buffer_set($iset_buffer, "key_bind_meta-ctrl-J", "/iset **set");
  356. weechat::buffer_set($iset_buffer, "key_bind_meta-ctrl-M", "/iset **set");
  357. weechat::buffer_set($iset_buffer, "key_bind_meta-meta2-1~", "/iset **scroll_top");
  358. weechat::buffer_set($iset_buffer, "key_bind_meta-meta2-4~", "/iset **scroll_bottom");
  359. weechat::buffer_set($iset_buffer, "key_bind_meta-v", "/iset **toggle_help");
  360. weechat::buffer_set($iset_buffer, "key_bind_meta-p", "/iset **toggle_show_plugin_desc");
  361. weechat::buffer_set($iset_buffer, "localvar_set_iset_filter", $filter);
  362. weechat::buffer_set($iset_buffer, "localvar_set_iset_search_mode", $search_mode);
  363. weechat::buffer_set($iset_buffer, "localvar_set_iset_search_value", $search_value);
  364. }
  365. }
  366. sub iset_get_options
  367. {
  368. my $var_value = $_[0];
  369. $var_value = "" if (not defined $var_value);
  370. $var_value = lc($var_value);
  371. $search_value = $var_value;
  372. @iset_focus = ();
  373. @options_names = ();
  374. @options_parent_names = ();
  375. @options_types = ();
  376. @options_values = ();
  377. @options_default_values = ();
  378. @options_parent_values = ();
  379. @options_is_null = ();
  380. $option_max_length = 0;
  381. my %options_internal = ();
  382. my $i = 0;
  383. my $key;
  384. my $iset_struct;
  385. my %iset_struct;
  386. weechat::buffer_set($iset_buffer, "localvar_set_iset_search_value", $var_value) if ($search_mode == 3);
  387. my $infolist = weechat::infolist_get("option", "", $filter);
  388. while (weechat::infolist_next($infolist))
  389. {
  390. $key = sprintf("%08d", $i);
  391. my $name = weechat::infolist_string($infolist, "full_name");
  392. my $parent_name = weechat::infolist_string($infolist, "parent_name");
  393. next if (weechat::config_boolean($options_iset{"show_plugin_description"}) == 0 and index ($name, "plugins.desc.") != -1);
  394. my $type = weechat::infolist_string($infolist, "type");
  395. my $value = weechat::infolist_string($infolist, "value");
  396. my $default_value = weechat::infolist_string($infolist, "default_value");
  397. my $parent_value;
  398. if ($parent_name && (($wee_version_number < 0x00040300) || (weechat::infolist_search_var($infolist, "parent_value"))))
  399. {
  400. $parent_value = weechat::infolist_string($infolist, "parent_value");
  401. }
  402. my $is_null = weechat::infolist_integer($infolist, "value_is_null");
  403. if ($search_mode == 3)
  404. {
  405. my $value = weechat::infolist_string($infolist, "value");
  406. if ( grep /\Q$var_value/,lc($value) )
  407. {
  408. $options_internal{$name}{"parent_name"} = $parent_name;
  409. $options_internal{$name}{"type"} = $type;
  410. $options_internal{$name}{"value"} = $value;
  411. $options_internal{$name}{"default_value"} = $default_value;
  412. $options_internal{$name}{"parent_value"} = $parent_value;
  413. $options_internal{$name}{"is_null"} = $is_null;
  414. $option_max_length = length($name) if (length($name) > $option_max_length);
  415. $iset_struct{$key} = $options_internal{$name};
  416. push(@iset_focus, $iset_struct{$key});
  417. }
  418. }
  419. # search for diff?
  420. elsif ( $search_mode == 4 or $search_mode == 5)
  421. {
  422. if ($value ne $default_value )
  423. {
  424. $options_internal{$name}{"parent_name"} = $parent_name;
  425. $options_internal{$name}{"type"} = $type;
  426. $options_internal{$name}{"value"} = $value;
  427. $options_internal{$name}{"default_value"} = $default_value;
  428. $options_internal{$name}{"parent_value"} = $parent_value;
  429. $options_internal{$name}{"is_null"} = $is_null;
  430. $option_max_length = length($name) if (length($name) > $option_max_length);
  431. $iset_struct{$key} = $options_internal{$name};
  432. push(@iset_focus, $iset_struct{$key});
  433. }
  434. }
  435. else
  436. {
  437. $options_internal{$name}{"parent_name"} = $parent_name;
  438. $options_internal{$name}{"type"} = $type;
  439. $options_internal{$name}{"value"} = $value;
  440. $options_internal{$name}{"default_value"} = $default_value;
  441. $options_internal{$name}{"parent_value"} = $parent_value;
  442. $options_internal{$name}{"is_null"} = $is_null;
  443. $option_max_length = length($name) if (length($name) > $option_max_length);
  444. $iset_struct{$key} = $options_internal{$name};
  445. push(@iset_focus, $iset_struct{$key});
  446. }
  447. $i++;
  448. }
  449. weechat::infolist_free($infolist);
  450. foreach my $name (sort keys %options_internal)
  451. {
  452. push(@options_names, $name);
  453. push(@options_parent_names, $options_internal{$name}{"parent_name"});
  454. push(@options_types, $options_internal{$name}{"type"});
  455. push(@options_values, $options_internal{$name}{"value"});
  456. push(@options_default_values, $options_internal{$name}{"default_value"});
  457. push(@options_parent_values, $options_internal{$name}{"parent_value"});
  458. push(@options_is_null, $options_internal{$name}{"is_null"});
  459. }
  460. }
  461. sub iset_get_values
  462. {
  463. my $var_value = $_[0];
  464. $var_value = lc($var_value);
  465. 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"}))
  466. {
  467. $var_value = substr($var_value,1,length($var_value));
  468. $search_mode = 0;
  469. }
  470. iset_search_values($var_value,$search_mode);
  471. weechat::buffer_set($iset_buffer, "localvar_set_iset_search_mode", $search_mode);
  472. weechat::buffer_set($iset_buffer, "localvar_set_iset_search_value", $var_value);
  473. $search_value = $var_value;
  474. }
  475. sub iset_search_values
  476. {
  477. my ($var_value,$search_mode) = ($_[0],$_[1]);
  478. @options_names = ();
  479. @options_parent_names = ();
  480. @options_types = ();
  481. @options_values = ();
  482. @options_default_values = ();
  483. @options_parent_values = ();
  484. @options_is_null = ();
  485. $option_max_length = 0;
  486. my %options_internal = ();
  487. my $i = 0;
  488. my $infolist = weechat::infolist_get("option", "", "*");
  489. while (weechat::infolist_next($infolist))
  490. {
  491. my $name = weechat::infolist_string($infolist, "full_name");
  492. my $parent_name = weechat::infolist_string($infolist, "parent_name");
  493. next if (weechat::config_boolean($options_iset{"show_plugin_description"}) == 0 and index ($name, "plugins.desc.") != -1);
  494. my $type = weechat::infolist_string($infolist, "type");
  495. my $is_null = weechat::infolist_integer($infolist, "value_is_null");
  496. my $value = weechat::infolist_string($infolist, "value");
  497. my $default_value = weechat::infolist_string($infolist, "default_value");
  498. my $parent_value;
  499. if ($parent_name && (($wee_version_number < 0x00040300) || (weechat::infolist_search_var($infolist, "parent_value"))))
  500. {
  501. $parent_value = weechat::infolist_string($infolist, "parent_value");
  502. }
  503. if ($search_mode)
  504. {
  505. if ( grep /\Q$var_value/,lc($value) )
  506. {
  507. $options_internal{$name}{"parent_name"} = $parent_name;
  508. $options_internal{$name}{"type"} = $type;
  509. $options_internal{$name}{"value"} = $value;
  510. $options_internal{$name}{"default_value"} = $default_value;
  511. $options_internal{$name}{"parent_value"} = $parent_value;
  512. $options_internal{$name}{"is_null"} = $is_null;
  513. $option_max_length = length($name) if (length($name) > $option_max_length);
  514. }
  515. }
  516. else
  517. {
  518. # if ($value =~ /\Q$var_value/si)
  519. if (lc($value) eq $var_value)
  520. {
  521. $options_internal{$name}{"parent_name"} = $parent_name;
  522. $options_internal{$name}{"type"} = $type;
  523. $options_internal{$name}{"value"} = $value;
  524. $options_internal{$name}{"default_value"} = $default_value;
  525. $options_internal{$name}{"parent_value"} = $parent_value;
  526. $options_internal{$name}{"is_null"} = $is_null;
  527. $option_max_length = length($name) if (length($name) > $option_max_length);
  528. }
  529. }
  530. $i++;
  531. }
  532. weechat::infolist_free($infolist);
  533. foreach my $name (sort keys %options_internal)
  534. {
  535. push(@options_names, $name);
  536. push(@options_parent_names, $options_internal{$name}{"parent_name"});
  537. push(@options_types, $options_internal{$name}{"type"});
  538. push(@options_values, $options_internal{$name}{"value"});
  539. push(@options_default_values, $options_internal{$name}{"default_value"});
  540. push(@options_parent_values, $options_internal{$name}{"parent_value"});
  541. push(@options_is_null, $options_internal{$name}{"is_null"});
  542. }
  543. }
  544. sub iset_refresh_line
  545. {
  546. if ($iset_buffer ne "")
  547. {
  548. my $y = $_[0];
  549. if ($y <= $#options_names)
  550. {
  551. return if (! defined($options_types[$y]));
  552. my $format = sprintf("%%s%%s%%s %%s %%-7s %%s %%s%%s%%s");
  553. my $padding;
  554. if ($wee_version_number >= 0x00040200)
  555. {
  556. $padding = " " x ($option_max_length - weechat::strlen_screen($options_names[$y]));
  557. }
  558. else
  559. {
  560. $padding = " " x ($option_max_length - length($options_names[$y]));
  561. }
  562. my $around = "";
  563. $around = "\"" if ((!$options_is_null[$y]) && ($options_types[$y] eq "string"));
  564. my $color1 = weechat::color(weechat::config_color($options_iset{"color_option"}));
  565. my $color2 = weechat::color(weechat::config_color($options_iset{"color_type"}));
  566. my $color3 = "";
  567. my $color4 = "";
  568. if ($options_is_null[$y])
  569. {
  570. $color3 = weechat::color(weechat::config_color($options_iset{"color_value_undef"}));
  571. $color4 = weechat::color(weechat::config_color($options_iset{"color_value"}));
  572. }
  573. elsif ($options_values[$y] ne $options_default_values[$y])
  574. {
  575. $color3 = weechat::color(weechat::config_color($options_iset{"color_value_diff"}));
  576. }
  577. else
  578. {
  579. $color3 = weechat::color(weechat::config_color($options_iset{"color_value"}));
  580. }
  581. if ($y == $current_line)
  582. {
  583. $color1 = weechat::color(weechat::config_color($options_iset{"color_option_selected"}).",".weechat::config_color($options_iset{"color_bg_selected"}));
  584. $color2 = weechat::color(weechat::config_color($options_iset{"color_type_selected"}).",".weechat::config_color($options_iset{"color_bg_selected"}));
  585. if ($options_is_null[$y])
  586. {
  587. $color3 = weechat::color(weechat::config_color($options_iset{"color_value_undef_selected"}).",".weechat::config_color($options_iset{"color_bg_selected"}));
  588. $color4 = weechat::color(weechat::config_color($options_iset{"color_value_selected"}).",".weechat::config_color($options_iset{"color_bg_selected"}));
  589. }
  590. elsif ($options_values[$y] ne $options_default_values[$y])
  591. {
  592. $color3 = weechat::color(weechat::config_color($options_iset{"color_value_diff_selected"}).",".weechat::config_color($options_iset{"color_bg_selected"}));
  593. }
  594. else
  595. {
  596. $color3 = weechat::color(weechat::config_color($options_iset{"color_value_selected"}).",".weechat::config_color($options_iset{"color_bg_selected"}));
  597. }
  598. }
  599. my $value = $options_values[$y];
  600. if ($options_is_null[$y])
  601. {
  602. $value = "null";
  603. if ($options_parent_names[$y])
  604. {
  605. if (defined $options_parent_values[$y])
  606. {
  607. my $around_parent = "";
  608. $around_parent = "\"" if ($options_types[$y] eq "string");
  609. $value .= $color1." -> ".$color4.$around_parent.$options_parent_values[$y].$around_parent;
  610. }
  611. else
  612. {
  613. $value .= $color1." -> ".$color3."null";
  614. }
  615. }
  616. }
  617. my $strline = sprintf($format,
  618. $color1, $options_names[$y], $padding,
  619. $color2, $options_types[$y],
  620. $color3, $around, $value, $around);
  621. weechat::print_y($iset_buffer, $y, $strline);
  622. }
  623. }
  624. }
  625. sub iset_refresh
  626. {
  627. iset_title();
  628. if (($iset_buffer ne "") && ($#options_names >= 0))
  629. {
  630. foreach my $y (0 .. $#options_names)
  631. {
  632. iset_refresh_line($y);
  633. }
  634. }
  635. weechat::bar_item_update("isetbar_help") if (weechat::config_boolean($options_iset{"show_help_bar"}) == 1);
  636. }
  637. sub iset_full_refresh
  638. {
  639. $iset_buffer = weechat::buffer_search($LANG, $PRGNAME);
  640. if ($iset_buffer ne "")
  641. {
  642. weechat::buffer_clear($iset_buffer) unless defined $_[0]; # iset_full_refresh(1) does a full refresh without clearing buffer
  643. # search for "*" in $filter.
  644. if ($filter =~ m/\*/ and $search_mode == 2)
  645. {
  646. iset_get_options("");
  647. }
  648. else
  649. {
  650. if ($search_mode == 0)
  651. {
  652. $search_value = "=" . $search_value;
  653. iset_get_values($search_value);
  654. }
  655. elsif ($search_mode == 1)
  656. {
  657. iset_get_values($search_value);
  658. }
  659. elsif ($search_mode == 3)
  660. {
  661. iset_create_filter($filter);
  662. iset_get_options($search_value);
  663. }
  664. }
  665. if (weechat::config_boolean($options_iset{"show_plugin_description"}) == 1)
  666. {
  667. iset_set_current_line($current_line);
  668. }else
  669. {
  670. $current_line = $#options_names if ($current_line > $#options_names);
  671. }
  672. iset_refresh();
  673. weechat::command($iset_buffer, "/window refresh");
  674. }
  675. }
  676. sub iset_set_current_line
  677. {
  678. my $new_current_line = $_[0];
  679. if ($new_current_line >= 0)
  680. {
  681. my $old_current_line = $current_line;
  682. $current_line = $new_current_line;
  683. $current_line = $#options_names if ($current_line > $#options_names);
  684. if ($old_current_line != $current_line)
  685. {
  686. iset_refresh_line($old_current_line);
  687. iset_refresh_line($current_line);
  688. weechat::bar_item_update("isetbar_help") if (weechat::config_boolean($options_iset{"show_help_bar"}) == 1);
  689. }
  690. }
  691. }
  692. sub iset_signal_window_scrolled_cb
  693. {
  694. my ($data, $signal, $signal_data) = ($_[0], $_[1], $_[2]);
  695. if ($iset_buffer ne "")
  696. {
  697. my $infolist = weechat::infolist_get("window", $signal_data, "");
  698. if (weechat::infolist_next($infolist))
  699. {
  700. if (weechat::infolist_pointer($infolist, "buffer") eq $iset_buffer)
  701. {
  702. my $old_current_line = $current_line;
  703. my $new_current_line = $current_line;
  704. my $start_line_y = weechat::infolist_integer($infolist, "start_line_y");
  705. my $chat_height = weechat::infolist_integer($infolist, "chat_height");
  706. $new_current_line += $chat_height if ($new_current_line < $start_line_y);
  707. $new_current_line -= $chat_height if ($new_current_line >= $start_line_y + $chat_height);
  708. $new_current_line = $start_line_y if ($new_current_line < $start_line_y);
  709. $new_current_line = $start_line_y + $chat_height - 1 if ($new_current_line >= $start_line_y + $chat_height);
  710. iset_set_current_line($new_current_line);
  711. }
  712. }
  713. weechat::infolist_free($infolist);
  714. }
  715. return weechat::WEECHAT_RC_OK;
  716. }
  717. sub iset_get_window_number
  718. {
  719. if ($iset_buffer ne "")
  720. {
  721. my $window = weechat::window_search_with_buffer($iset_buffer);
  722. return "-window ".weechat::window_get_integer ($window, "number")." " if ($window ne "");
  723. }
  724. return "";
  725. }
  726. sub iset_check_line_outside_window
  727. {
  728. if ($iset_buffer ne "")
  729. {
  730. undef my $infolist;
  731. if ($wee_version_number >= 0x00030500)
  732. {
  733. my $window = weechat::window_search_with_buffer($iset_buffer);
  734. $infolist = weechat::infolist_get("window", $window, "") if $window;
  735. }
  736. else
  737. {
  738. $infolist = weechat::infolist_get("window", "", "current");
  739. }
  740. if ($infolist)
  741. {
  742. if (weechat::infolist_next($infolist))
  743. {
  744. my $start_line_y = weechat::infolist_integer($infolist, "start_line_y");
  745. my $chat_height = weechat::infolist_integer($infolist, "chat_height");
  746. my $window_number = "";
  747. if ($wee_version_number >= 0x00030500)
  748. {
  749. $window_number = "-window ".weechat::infolist_integer($infolist, "number")." ";
  750. }
  751. if ($start_line_y > $current_line)
  752. {
  753. weechat::command($iset_buffer, "/window scroll ".$window_number."-".($start_line_y - $current_line));
  754. }
  755. else
  756. {
  757. if ($start_line_y <= $current_line - $chat_height)
  758. {
  759. weechat::command($iset_buffer, "/window scroll ".$window_number."+".($current_line - $start_line_y - $chat_height + 1));
  760. }
  761. }
  762. }
  763. weechat::infolist_free($infolist);
  764. }
  765. }
  766. }
  767. sub iset_get_option_name_index
  768. {
  769. my $option_name = $_[0];
  770. my $index = 0;
  771. while ($index <= $#options_names)
  772. {
  773. return -1 if ($options_names[$index] gt $option_name);
  774. return $index if ($options_names[$index] eq $option_name);
  775. $index++;
  776. }
  777. return -1;
  778. }
  779. sub iset_refresh_option
  780. {
  781. my $option_name = $_[0];
  782. my $index = $_[1];
  783. my $infolist = weechat::infolist_get("option", "", $option_name);
  784. if ($infolist)
  785. {
  786. weechat::infolist_next($infolist);
  787. if (weechat::infolist_fields($infolist))
  788. {
  789. $options_parent_names[$index] = weechat::infolist_string($infolist, "parent_name");
  790. $options_types[$index] = weechat::infolist_string($infolist, "type");
  791. $options_values[$index] = weechat::infolist_string($infolist, "value");
  792. $options_default_values[$index] = weechat::infolist_string($infolist, "default_value");
  793. $options_is_null[$index] = weechat::infolist_integer($infolist, "value_is_null");
  794. $options_parent_values[$index] = undef;
  795. if ($options_parent_names[$index]
  796. && (($wee_version_number < 0x00040300) || (weechat::infolist_search_var($infolist, "parent_value"))))
  797. {
  798. $options_parent_values[$index] = weechat::infolist_string($infolist, "parent_value");
  799. }
  800. iset_refresh_line($index);
  801. iset_title() if ($option_name eq "iset.look.show_current_line");
  802. }
  803. else
  804. {
  805. iset_full_refresh(1); # if not found, refresh fully without clearing buffer
  806. weechat::print_y($iset_buffer, $#options_names + 1, "");
  807. }
  808. weechat::infolist_free($infolist);
  809. }
  810. }
  811. sub iset_config_cb
  812. {
  813. my ($data, $option_name, $value) = ($_[0], $_[1], $_[2]);
  814. if ($iset_buffer ne "")
  815. {
  816. return weechat::WEECHAT_RC_OK if (weechat::info_get("weechat_upgrading", "") eq "1");
  817. my $index = iset_get_option_name_index($option_name);
  818. if ($index >= 0)
  819. {
  820. # refresh info about changed option
  821. iset_refresh_option($option_name, $index);
  822. # refresh any other option having this changed option as parent
  823. foreach my $i (0 .. $#options_names)
  824. {
  825. if ($options_parent_names[$i] eq $option_name)
  826. {
  827. iset_refresh_option($options_names[$i], $i);
  828. }
  829. }
  830. }
  831. else
  832. {
  833. iset_full_refresh() if ($option_name ne "weechat.bar.isetbar.hidden");
  834. }
  835. }
  836. return weechat::WEECHAT_RC_OK;
  837. }
  838. sub iset_set_option
  839. {
  840. my ($option, $value) = ($_[0],$_[1]);
  841. if (defined $option and defined $value)
  842. {
  843. $option = weechat::config_get($option);
  844. weechat::config_option_set($option, $value, 1) if ($option ne "");
  845. }
  846. }
  847. sub iset_reset_option
  848. {
  849. my $option = $_[0];
  850. if (defined $option)
  851. {
  852. $option = weechat::config_get($option);
  853. weechat::config_option_reset($option, 1) if ($option ne "");
  854. }
  855. }
  856. sub iset_unset_option
  857. {
  858. my $option = $_[0];
  859. if (defined $option)
  860. {
  861. $option = weechat::config_get($option);
  862. weechat::config_option_unset($option) if ($option ne "");
  863. }
  864. }
  865. sub iset_cmd_cb
  866. {
  867. my ($data, $buffer, $args) = ($_[0], $_[1], $_[2]);
  868. my $filter_set = 0;
  869. # $search_value = "";
  870. if (($args ne "") && (substr($args, 0, 2) ne "**"))
  871. {
  872. my @cmd_array = split(/ /,$args);
  873. my $array_count = @cmd_array;
  874. if (substr($args, 0, 1) eq weechat::config_string($options_iset{"value_search_char"})
  875. 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"})) )
  876. {
  877. $search_mode = 1;
  878. my $search_value = substr($args, 1); # cut value_search_char
  879. if ($iset_buffer ne "")
  880. {
  881. weechat::buffer_clear($iset_buffer);
  882. weechat::command($iset_buffer, "/window refresh");
  883. }
  884. weechat::buffer_set($iset_buffer, "localvar_set_iset_search_mode", $search_mode);
  885. weechat::buffer_set($iset_buffer, "localvar_set_iset_search_value", $search_value);
  886. iset_init();
  887. iset_get_values($search_value);
  888. iset_refresh();
  889. weechat::buffer_set($iset_buffer, "display", "1");
  890. # $filter = $var_value;
  891. return weechat::WEECHAT_RC_OK;
  892. }
  893. else
  894. {
  895. # f/s option =value
  896. # option =value
  897. $search_mode = 2; # grep on option
  898. if ( $array_count >= 2 and $cmd_array[0] ne "f" or $cmd_array[0] ne "s")
  899. {
  900. if ( defined $cmd_array[1] and substr($cmd_array[1], 0, 1) eq weechat::config_string($options_iset{"value_search_char"})
  901. or defined $cmd_array[2] and substr($cmd_array[2], 0, 1) eq weechat::config_string($options_iset{"value_search_char"}) )
  902. {
  903. $search_mode = 3; # grep on option and value
  904. $search_value = substr($cmd_array[1], 1); # cut value_search_char
  905. $search_value = substr($cmd_array[2], 1) if ( $array_count > 2); # cut value_search_char
  906. }
  907. }
  908. # show all diff values
  909. if ( $args eq "d")
  910. {
  911. $search_mode = 4;
  912. $search_value = "*";
  913. $args = $search_value;
  914. }
  915. if ( $array_count >= 2 and $cmd_array[0] eq "d")
  916. {
  917. $search_mode = 5;
  918. $search_value = substr($cmd_array[1], 0); # cut value_search_char
  919. $search_value = substr($cmd_array[2], 0) if ( $array_count > 2); # cut value_search_char
  920. $args = $search_value;
  921. }
  922. iset_create_filter($args);
  923. $filter_set = 1;
  924. my $ptrbuf = weechat::buffer_search($LANG, $PRGNAME);
  925. if ($ptrbuf eq "")
  926. {
  927. iset_init();
  928. iset_get_options($search_value);
  929. iset_full_refresh();
  930. weechat::buffer_set(weechat::buffer_search($LANG, $PRGNAME), "display", "1");
  931. weechat::buffer_set($iset_buffer, "localvar_set_iset_search_value", $search_value);
  932. weechat::buffer_set($iset_buffer, "localvar_set_iset_search_mode", $search_mode);
  933. return weechat::WEECHAT_RC_OK;
  934. }
  935. else
  936. {
  937. iset_get_options($search_value);
  938. iset_full_refresh();
  939. weechat::buffer_set($ptrbuf, "display", "1");
  940. }
  941. }
  942. weechat::buffer_set($iset_buffer, "localvar_set_iset_search_mode", $search_mode);
  943. weechat::buffer_set($iset_buffer, "localvar_set_iset_search_value", $search_value);
  944. }
  945. if ($iset_buffer eq "")
  946. {
  947. iset_init();
  948. iset_get_options("");
  949. iset_refresh();
  950. }
  951. else
  952. {
  953. # iset_get_options($search_value);
  954. iset_full_refresh() if ($filter_set);
  955. }
  956. if ($args eq "")
  957. {
  958. weechat::buffer_set($iset_buffer, "display", "1");
  959. }
  960. else
  961. {
  962. if ($args eq "**refresh")
  963. {
  964. iset_full_refresh();
  965. }
  966. if ($args eq "**up")
  967. {
  968. if ($current_line > 0)
  969. {
  970. $current_line--;
  971. iset_refresh_line($current_line + 1);
  972. iset_refresh_line($current_line);
  973. iset_check_line_outside_window();
  974. }
  975. }
  976. if ($args eq "**down")
  977. {
  978. if ($current_line < $#options_names)
  979. {
  980. $current_line++;
  981. iset_refresh_line($current_line - 1);
  982. iset_refresh_line($current_line);
  983. iset_check_line_outside_window();
  984. }
  985. }
  986. if ($args eq "**left" && $wee_version_number >= 0x00030600)
  987. {
  988. weechat::command($iset_buffer, "/window scroll_horiz ".iset_get_window_number()."-".weechat::config_integer($options_iset{"scroll_horiz"})."%");
  989. }
  990. if ($args eq "**right" && $wee_version_number >= 0x00030600)
  991. {
  992. weechat::command($iset_buffer, "/window scroll_horiz ".iset_get_window_number().weechat::config_integer($options_iset{"scroll_horiz"})."%");
  993. }
  994. if ($args eq "**scroll_top")
  995. {
  996. my $old_current_line = $current_line;
  997. $current_line = 0;
  998. iset_refresh_line ($old_current_line);
  999. iset_refresh_line ($current_line);
  1000. iset_title();
  1001. weechat::command($iset_buffer, "/window scroll_top ".iset_get_window_number());
  1002. }
  1003. if ($args eq "**scroll_bottom")
  1004. {
  1005. my $old_current_line = $current_line;
  1006. $current_line = $#options_names;
  1007. iset_refresh_line ($old_current_line);
  1008. iset_refresh_line ($current_line);
  1009. iset_title();
  1010. weechat::command($iset_buffer, "/window scroll_bottom ".iset_get_window_number());
  1011. }
  1012. if ($args eq "**toggle")
  1013. {
  1014. if ($options_types[$current_line] eq "boolean")
  1015. {
  1016. iset_set_option($options_names[$current_line], "toggle");
  1017. }
  1018. }
  1019. if ($args eq "**incr")
  1020. {
  1021. if (($options_types[$current_line] eq "integer")
  1022. || ($options_types[$current_line] eq "color"))
  1023. {
  1024. iset_set_option($options_names[$current_line], "++1");
  1025. }
  1026. }
  1027. if ($args eq "**decr")
  1028. {
  1029. if (($options_types[$current_line] eq "integer")
  1030. || ($options_types[$current_line] eq "color"))
  1031. {
  1032. iset_set_option($options_names[$current_line], "--1");
  1033. }
  1034. }
  1035. if ($args eq "**reset")
  1036. {
  1037. iset_reset_option($options_names[$current_line]);
  1038. }
  1039. if ($args eq "**unset")
  1040. {
  1041. iset_unset_option($options_names[$current_line]);
  1042. }
  1043. if ($args eq "**toggle_help")
  1044. {
  1045. if (weechat::config_boolean($options_iset{"show_help_bar"}) == 1)
  1046. {
  1047. weechat::config_option_set($options_iset{"show_help_bar"},0,1);
  1048. iset_show_bar(0);
  1049. }
  1050. else
  1051. {
  1052. weechat::config_option_set($options_iset{"show_help_bar"},1,1);
  1053. iset_show_bar(1);
  1054. }
  1055. }
  1056. if ($args eq "**toggle_show_plugin_desc")
  1057. {
  1058. if (weechat::config_boolean($options_iset{"show_plugin_description"}) == 1)
  1059. {
  1060. weechat::config_option_set($options_iset{"show_plugin_description"},0,1);
  1061. iset_full_refresh();
  1062. iset_check_line_outside_window();
  1063. iset_title();
  1064. }
  1065. else
  1066. {
  1067. weechat::config_option_set($options_iset{"show_plugin_description"},1,1);
  1068. iset_full_refresh();
  1069. iset_check_line_outside_window();
  1070. iset_title();
  1071. }
  1072. }
  1073. if ($args eq "**set")
  1074. {
  1075. my $quote = "";
  1076. my $value = $options_values[$current_line];
  1077. if ($options_is_null[$current_line])
  1078. {
  1079. $value = "";
  1080. }
  1081. else
  1082. {
  1083. $quote = "\"" if ($options_types[$current_line] eq "string");
  1084. }
  1085. $value = " ".$quote.$value.$quote if ($value ne "" or $quote ne "");
  1086. my $set_command = "/set";
  1087. my $start_index = 5;
  1088. if (weechat::config_boolean($options_iset{"use_mute"}) == 1)
  1089. {
  1090. $set_command = "/mute ".$set_command;
  1091. $start_index += 11;
  1092. }
  1093. $set_command = $set_command." ".$options_names[$current_line].$value;
  1094. my $pos_space = index($set_command, " ", $start_index);
  1095. if ($pos_space < 0)
  1096. {
  1097. $pos_space = 9999;
  1098. }
  1099. else
  1100. {
  1101. $pos_space = $pos_space + 1;
  1102. $pos_space = $pos_space + 1 if ($quote ne "");
  1103. }
  1104. weechat::buffer_set($iset_buffer, "input", $set_command);
  1105. weechat::buffer_set($iset_buffer, "input_pos", "".$pos_space);
  1106. }
  1107. }
  1108. weechat::bar_item_update("isetbar_help") if (weechat::config_boolean($options_iset{"show_help_bar"}) == 1);
  1109. return weechat::WEECHAT_RC_OK;
  1110. }
  1111. sub iset_get_help
  1112. {
  1113. my ($redraw) = ($_[0]);
  1114. return '' if (weechat::config_boolean($options_iset{"show_help_bar"}) == 0);
  1115. if (not defined $options_names[$current_line])
  1116. {
  1117. return "No option selected. Set a new filter using command line (use '*' to see all options)";
  1118. }
  1119. if ($options_name_copy eq $options_names[$current_line] and not defined $redraw)
  1120. {
  1121. return $description;
  1122. }
  1123. $options_name_copy = $options_names[$current_line];
  1124. my $optionlist ="";
  1125. $optionlist = weechat::infolist_get("option", "", $options_names[$current_line]);
  1126. weechat::infolist_next($optionlist);
  1127. my $full_name = weechat::infolist_string($optionlist,"full_name");
  1128. my $option_desc = "";
  1129. my $option_default_value = "";
  1130. my $option_range = "";
  1131. my $possible_values = "";
  1132. my $re = qq(\Q$full_name);
  1133. if (grep (/^$re$/,$options_names[$current_line]))
  1134. {
  1135. $option_desc = weechat::infolist_string($optionlist, "description_nls");
  1136. $option_desc = weechat::infolist_string($optionlist, "description") if ($option_desc eq "");
  1137. $option_desc = "No help found" if ($option_desc eq "");
  1138. $option_default_value = weechat::infolist_string($optionlist, "default_value");
  1139. $possible_values = weechat::infolist_string($optionlist, "string_values") if (weechat::infolist_string($optionlist, "string_values") ne "");
  1140. if ((weechat::infolist_string($optionlist, "type") eq "integer") && ($possible_values eq ""))
  1141. {
  1142. $option_range = weechat::infolist_integer($optionlist, "min")
  1143. ." .. ".weechat::infolist_integer($optionlist, "max");
  1144. }
  1145. }
  1146. weechat::infolist_free($optionlist);
  1147. iset_title();
  1148. $description = weechat::color(weechat::config_color($options_iset{"color_help_option_name"})).$options_names[$current_line]
  1149. .weechat::color("bar_fg").": "
  1150. .weechat::color(weechat::config_color($options_iset{"color_help_text"})).$option_desc;
  1151. # show additional infos like default value and possible values
  1152. if (weechat::config_boolean($options_iset{"show_help_extra_info"}) == 1)
  1153. {
  1154. $description .=
  1155. weechat::color("bar_delim")." ["
  1156. .weechat::color("bar_fg")."default: "
  1157. .weechat::color("bar_delim")."\""
  1158. .weechat::color(weechat::config_color($options_iset{"color_help_default_value"})).$option_default_value
  1159. .weechat::color("bar_delim")."\"";
  1160. if ($option_range ne "")
  1161. {
  1162. $description .= weechat::color("bar_fg").", values: ".$option_range;
  1163. }
  1164. if ($possible_values ne "")
  1165. {
  1166. $possible_values =~ s/\|/", "/g; # replace '|' to '", "'
  1167. $description .= weechat::color("bar_fg").", values: ". "\"" . $possible_values . "\"";
  1168. }
  1169. $description .= weechat::color("bar_delim")."]";
  1170. }
  1171. return $description;
  1172. }
  1173. sub iset_check_condition_isetbar_cb
  1174. {
  1175. my ($data, $modifier, $modifier_data, $string) = ($_[0], $_[1], $_[2], $_[3]);
  1176. my $buffer = weechat::window_get_pointer($modifier_data, "buffer");
  1177. if ($buffer ne "")
  1178. {
  1179. if ((weechat::buffer_get_string($buffer, "plugin") eq $LANG)
  1180. && (weechat::buffer_get_string($buffer, "name") eq $PRGNAME))
  1181. {
  1182. return "1";
  1183. }
  1184. }
  1185. return "0";
  1186. }
  1187. sub iset_show_bar
  1188. {
  1189. my $show = $_[0];
  1190. my $barhidden = weechat::config_get("weechat.bar.isetbar.hidden");
  1191. if ($barhidden)
  1192. {
  1193. if ($show)
  1194. {
  1195. if (weechat::config_boolean($options_iset{"show_help_bar"}) == 1)
  1196. {
  1197. if (weechat::config_boolean($barhidden))
  1198. {
  1199. weechat::config_option_set($barhidden, 0, 1);
  1200. }
  1201. }
  1202. }
  1203. else
  1204. {
  1205. if (!weechat::config_boolean($barhidden))
  1206. {
  1207. weechat::config_option_set($barhidden, 1, 1);
  1208. }
  1209. }
  1210. }
  1211. }
  1212. sub iset_signal_buffer_switch_cb
  1213. {
  1214. my $buffer_pointer = $_[2];
  1215. my $show_bar = 0;
  1216. $show_bar = 1 if (weechat::buffer_get_integer($iset_buffer, "num_displayed") > 0);
  1217. iset_show_bar($show_bar);
  1218. iset_check_line_outside_window() if ($buffer_pointer eq $iset_buffer);
  1219. return weechat::WEECHAT_RC_OK;
  1220. }
  1221. sub iset_item_cb
  1222. {
  1223. return iset_get_help();
  1224. }
  1225. sub iset_upgrade_ended
  1226. {
  1227. iset_full_refresh();
  1228. }
  1229. sub iset_end
  1230. {
  1231. # when script is unloaded, we hide bar
  1232. iset_show_bar(0);
  1233. }
  1234. # -------------------------------[ mouse support ]-------------------------------------
  1235. sub hook_focus_iset_cb
  1236. {
  1237. my %info = %{$_[1]};
  1238. my $bar_item_line = int($info{"_bar_item_line"});
  1239. undef my $hash;
  1240. if (($info{"_buffer_name"} eq $PRGNAME) && $info{"_buffer_plugin"} eq $LANG && ($bar_item_line >= 0) && ($bar_item_line <= $#iset_focus))
  1241. {
  1242. $hash = $iset_focus[$bar_item_line];
  1243. }
  1244. else
  1245. {
  1246. $hash = {};
  1247. my $hash_focus = $iset_focus[0];
  1248. foreach my $key (keys %$hash_focus)
  1249. {
  1250. $hash->{$key} = "?";
  1251. }
  1252. }
  1253. return $hash;
  1254. }
  1255. # _chat_line_y contains selected line
  1256. sub iset_hsignal_mouse_cb
  1257. {
  1258. my ($data, $signal, %hash) = ($_[0], $_[1], %{$_[2]});
  1259. return weechat::WEECHAT_RC_OK unless (@options_types);
  1260. if ($hash{"_buffer_name"} eq $PRGNAME && ($hash{"_buffer_plugin"} eq $LANG))
  1261. {
  1262. if ($hash{"_key"} eq "button1")
  1263. {
  1264. iset_set_current_line($hash{"_chat_line_y"});
  1265. }
  1266. elsif ($hash{"_key"} eq "button2")
  1267. {
  1268. if ($options_types[$hash{"_chat_line_y"}] eq "boolean")
  1269. {
  1270. iset_set_option($options_names[$hash{"_chat_line_y"}], "toggle");
  1271. iset_set_current_line($hash{"_chat_line_y"});
  1272. }
  1273. elsif ($options_types[$hash{"_chat_line_y"}] eq "string")
  1274. {
  1275. iset_set_current_line($hash{"_chat_line_y"});
  1276. weechat::command("", "/$PRGNAME **set");
  1277. }
  1278. }
  1279. elsif ($hash{"_key"} eq "button2-gesture-left" or $hash{"_key"} eq "button2-gesture-left-long")
  1280. {
  1281. if ($options_types[$hash{"_chat_line_y"}] eq "integer" or ($options_types[$hash{"_chat_line_y"}] eq "color"))
  1282. {
  1283. iset_set_current_line($hash{"_chat_line_y"});
  1284. my $distance = distance($hash{"_chat_line_x"},$hash{"_chat_line_x2"});
  1285. weechat::command("", "/repeat $distance /$PRGNAME **decr");
  1286. }
  1287. }
  1288. elsif ($hash{"_key"} eq "button2-gesture-right" or $hash{"_key"} eq "button2-gesture-right-long")
  1289. {
  1290. if ($options_types[$hash{"_chat_line_y"}] eq "integer" or ($options_types[$hash{"_chat_line_y"}] eq "color"))
  1291. {
  1292. iset_set_current_line($hash{"_chat_line_y"});
  1293. my $distance = distance($hash{"_chat_line_x"},$hash{"_chat_line_x2"});
  1294. weechat::command("", "/repeat $distance /$PRGNAME **incr");
  1295. }
  1296. }
  1297. }
  1298. window_switch();
  1299. }
  1300. sub window_switch
  1301. {
  1302. my $current_window = weechat::current_window();
  1303. my $dest_window = weechat::window_search_with_buffer(weechat::buffer_search("perl","iset"));
  1304. return 0 if ($dest_window eq "" or $current_window eq $dest_window);
  1305. my $infolist = weechat::infolist_get("window", $dest_window, "");
  1306. weechat::infolist_next($infolist);
  1307. my $number = weechat::infolist_integer($infolist, "number");
  1308. weechat::infolist_free($infolist);
  1309. weechat::command("","/window " . $number);
  1310. }
  1311. sub distance
  1312. {
  1313. my ($x1,$x2) = ($_[0], $_[1]);
  1314. my $distance;
  1315. $distance = $x1 - $x2;
  1316. $distance = abs($distance);
  1317. if ($distance > 0)
  1318. {
  1319. use integer;
  1320. $distance = $distance / 3;
  1321. $distance = 1 if ($distance == 0);
  1322. }
  1323. elsif ($distance == 0)
  1324. {
  1325. $distance = 1;
  1326. }
  1327. return $distance;
  1328. }
  1329. # -----------------------------------[ config ]---------------------------------------
  1330. sub iset_config_init
  1331. {
  1332. $iset_config_file = weechat::config_new($ISET_CONFIG_FILE_NAME,"iset_config_reload_cb","");
  1333. return if ($iset_config_file eq "");
  1334. # section "color"
  1335. my $section_color = weechat::config_new_section($iset_config_file,"color", 0, 0, "", "", "", "", "", "", "", "", "", "");
  1336. if ($section_color eq "")
  1337. {
  1338. weechat::config_free($iset_config_file);
  1339. return;
  1340. }
  1341. $options_iset{"color_option"} = weechat::config_new_option(
  1342. $iset_config_file, $section_color,
  1343. "option", "color", "Color for option name in iset buffer", "", 0, 0,
  1344. "default", "default", 0, "", "", "full_refresh_cb", "", "", "");
  1345. $options_iset{"color_option_selected"} = weechat::config_new_option(
  1346. $iset_config_file, $section_color,
  1347. "option_selected", "color", "Color for selected option name in iset buffer", "", 0, 0,
  1348. "white", "white", 0, "", "", "full_refresh_cb", "", "", "");
  1349. $options_iset{"color_type"} = weechat::config_new_option(
  1350. $iset_config_file, $section_color,
  1351. "type", "color", "Color for option type (integer, boolean, string)", "", 0, 0,
  1352. "brown", "brown", 0, "", "", "full_refresh_cb", "", "", "");
  1353. $options_iset{"color_type_selected"} = weechat::config_new_option(
  1354. $iset_config_file, $section_color,
  1355. "type_selected", "color", "Color for selected option type (integer, boolean, string)", "", 0, 0,
  1356. "yellow", "yellow", 0, "", "", "full_refresh_cb", "", "", "");
  1357. $options_iset{"color_value"} = weechat::config_new_option(
  1358. $iset_config_file, $section_color,
  1359. "value", "color", "Color for option value", "", 0, 0,
  1360. "cyan", "cyan", 0, "", "", "full_refresh_cb", "", "", "");
  1361. $options_iset{"color_value_selected"} = weechat::config_new_option(
  1362. $iset_config_file, $section_color,
  1363. "value_selected", "color", "Color for selected option value", "", 0, 0,
  1364. "lightcyan", "lightcyan", 0, "", "", "full_refresh_cb", "", "", "");
  1365. $options_iset{"color_value_diff"} = weechat::config_new_option(
  1366. $iset_config_file, $section_color,
  1367. "value_diff", "color", "Color for option value different from default", "", 0, 0,
  1368. "magenta", "magenta", 0, "", "", "full_refresh_cb", "", "", "");
  1369. $options_iset{"color_value_diff_selected"} = weechat::config_new_option(
  1370. $iset_config_file, $section_color,
  1371. "value_diff_selected", "color", "Color for selected option value different from default", "", 0, 0,
  1372. "lightmagenta", "lightmagenta", 0, "", "", "full_refresh_cb", "", "", "");
  1373. $options_iset{"color_value_undef"} = weechat::config_new_option(
  1374. $iset_config_file, $section_color,
  1375. "value_undef", "color", "Color for option value undef", "", 0, 0,
  1376. "green", "green", 0, "", "", "full_refresh_cb", "", "", "");
  1377. $options_iset{"color_value_undef_selected"} = weechat::config_new_option(
  1378. $iset_config_file, $section_color,
  1379. "value_undef_selected", "color", "Color for selected option value undef", "", 0, 0,
  1380. "lightgreen", "lightgreen", 0, "", "", "full_refresh_cb", "", "", "");
  1381. $options_iset{"color_bg_selected"} = weechat::config_new_option(
  1382. $iset_config_file, $section_color,
  1383. "bg_selected", "color", "Background color for current selected option", "", 0, 0,
  1384. "red", "red", 0, "", "", "full_refresh_cb", "", "", "");
  1385. $options_iset{"color_help_option_name"} = weechat::config_new_option(
  1386. $iset_config_file, $section_color,
  1387. "help_option_name", "color", "Color for option name in help-bar", "", 0, 0,
  1388. "white", "white", 0, "", "", "bar_refresh", "", "", "");
  1389. $options_iset{"color_help_text"} = weechat::config_new_option(
  1390. $iset_config_file, $section_color,
  1391. "help_text", "color", "Color for option description in help-bar", "", 0, 0,
  1392. "default", "default", 0, "", "", "bar_refresh", "", "", "");
  1393. $options_iset{"color_help_default_value"} = weechat::config_new_option(
  1394. $iset_config_file, $section_color,
  1395. "help_default_value", "color", "Color for default option value in help-bar", "", 0, 0,
  1396. "green", "green", 0, "", "", "bar_refresh", "", "", "");
  1397. # section "help"
  1398. my $section_help = weechat::config_new_section($iset_config_file,"help", 0, 0, "", "", "", "", "", "", "", "", "", "");
  1399. if ($section_help eq "")
  1400. {
  1401. weechat::config_free($iset_config_file);
  1402. return;
  1403. }
  1404. $options_iset{"show_help_bar"} = weechat::config_new_option(
  1405. $iset_config_file, $section_help,
  1406. "show_help_bar", "boolean", "Show help bar", "", 0, 0,
  1407. "on", "on", 0, "", "", "toggle_help_cb", "", "", "");
  1408. $options_iset{"show_help_extra_info"} = weechat::config_new_option(
  1409. $iset_config_file, $section_help,
  1410. "show_help_extra_info", "boolean", "Show additional information in help bar (default value, max./min. value) ", "", 0, 0,
  1411. "on", "on", 0, "", "", "", "", "", "");
  1412. $options_iset{"show_plugin_description"} = weechat::config_new_option(
  1413. $iset_config_file, $section_help,
  1414. "show_plugin_description", "boolean", "Show plugin description in iset buffer", "", 0, 0,
  1415. "off", "off", 0, "", "", "full_refresh_cb", "", "", "");
  1416. # section "look"
  1417. my $section_look = weechat::config_new_section($iset_config_file, "look", 0, 0, "", "", "", "", "", "", "", "", "", "");
  1418. if ($section_look eq "")
  1419. {
  1420. weechat::config_free($iset_config_file);
  1421. return;
  1422. }
  1423. $options_iset{"value_search_char"} = weechat::config_new_option(
  1424. $iset_config_file, $section_look,
  1425. "value_search_char", "string", "Trigger char to tell iset to search for value instead of option (for example: =red)", "", 0, 0,
  1426. "=", "=", 0, "", "", "", "", "", "");
  1427. $options_iset{"scroll_horiz"} = weechat::config_new_option(
  1428. $iset_config_file, $section_look,
  1429. "scroll_horiz", "integer", "scroll content of iset buffer n%", "", 1, 100,
  1430. "10", "10", 0, "", "", "", "", "", "");
  1431. $options_iset{"show_current_line"} = weechat::config_new_option(
  1432. $iset_config_file, $section_look,
  1433. "show_current_line", "boolean", "show current line in title bar.", "", 0, 0,
  1434. "on", "on", 0, "", "", "", "", "", "");
  1435. $options_iset{"use_mute"} = weechat::config_new_option(
  1436. $iset_config_file, $section_look,
  1437. "use_mute", "boolean", "/mute command will be used in input bar", "", 0, 0,
  1438. "off", "off", 0, "", "", "", "", "", "");
  1439. }
  1440. sub iset_config_reload_cb
  1441. {
  1442. my ($data,$config_file) = ($_[0], $_[1]);
  1443. return weechat::config_reload($config_file)
  1444. }
  1445. sub iset_config_read
  1446. {
  1447. return weechat::config_read($iset_config_file) if ($iset_config_file ne "");
  1448. }
  1449. sub iset_config_write
  1450. {
  1451. return weechat::config_write($iset_config_file) if ($iset_config_file ne "");
  1452. }
  1453. sub full_refresh_cb
  1454. {
  1455. iset_full_refresh();
  1456. return weechat::WEECHAT_RC_OK;
  1457. }
  1458. sub bar_refresh
  1459. {
  1460. iset_get_help(1);
  1461. weechat::bar_item_update("isetbar_help") if (weechat::config_boolean($options_iset{"show_help_bar"}) == 1);
  1462. return weechat::WEECHAT_RC_OK;
  1463. }
  1464. sub toggle_help_cb
  1465. {
  1466. my $value = weechat::config_boolean($options_iset{"show_help_bar"});
  1467. iset_show_bar($value);
  1468. return weechat::WEECHAT_RC_OK;
  1469. }
  1470. # -----------------------------------[ main ]-----------------------------------------
  1471. weechat::register($PRGNAME, $AUTHOR, $VERSION, $LICENSE,
  1472. $DESCR, "iset_end", "");
  1473. $wee_version_number = weechat::info_get("version_number", "") || 0;
  1474. iset_config_init();
  1475. iset_config_read();
  1476. weechat::hook_command($PRGNAME, "Interactive set", "d <text> || f <file> || s <section> || [=][=]<text>",
  1477. "d <text> : show only changed options\n".
  1478. "f file : show options for a file\n".
  1479. "s section: show options for a section\n".
  1480. "text : show options with 'text' in name\n".
  1481. weechat::config_string($options_iset{"value_search_char"})."text : show options with 'text' in value\n".
  1482. 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".
  1483. "Keys for iset buffer:\n".
  1484. "f11,f12 : move iset content left/right\n".
  1485. "up,down : move one option up/down\n".
  1486. "pgup,pdwn : move one page up/down\n".
  1487. "home,end : move to first/last option\n".
  1488. "ctrl+'L' : refresh options and screen\n".
  1489. "alt+space : toggle boolean on/off\n".
  1490. "alt+'+' : increase value (for integer or color)\n".
  1491. "alt+'-' : decrease value (for integer or color)\n".
  1492. "alt+'i',alt+'r': reset value of option\n".
  1493. "alt+'i',alt+'u': unset option\n".
  1494. "alt+enter : set new value for option (edit it with command line)\n".
  1495. "text,enter : set a new filter using command line (use '*' to see all options)\n".
  1496. "alt+'v' : toggle help bar on/off\n".
  1497. "alt+'p' : toggle option \"show_plugin_description\" on/off\n".
  1498. "q : as input in iset buffer to close it\n".
  1499. "\n".
  1500. "Mouse actions:\n".
  1501. "wheel up/down : move cursor up/down\n".
  1502. "left button : select an option from list\n".
  1503. "right button : toggle boolean (on/off) or set a new value for option (edit it with command line)\n".
  1504. "right button + drag left/right: increase/decrease value (for integer or color)\n".
  1505. "\n".
  1506. "Examples:\n".
  1507. " show changed options in 'aspell' plugin\n".
  1508. " /iset d aspell\n".
  1509. " show options for file 'irc'\n".
  1510. " /iset f irc\n".
  1511. " show options for section 'look'\n".
  1512. " /iset s look\n".
  1513. " show all options with text 'nicklist' in name\n".
  1514. " /iset nicklist\n".
  1515. " show all values which contain 'red'. ('" . weechat::config_string($options_iset{"value_search_char"}) . "' is a trigger char).\n".
  1516. " /iset ". weechat::config_string($options_iset{"value_search_char"}) ."red\n".
  1517. " 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".
  1518. " /iset ". weechat::config_string($options_iset{"value_search_char"}) . weechat::config_string($options_iset{"value_search_char"}) ."off\n".
  1519. " show options for file 'weechat' which contains value 'off'\n".
  1520. " /iset f weechat ".weechat::config_string($options_iset{"value_search_char"})."off\n".
  1521. "",
  1522. "", "iset_cmd_cb", "");
  1523. weechat::hook_signal("upgrade_ended", "iset_upgrade_ended", "");
  1524. weechat::hook_signal("window_scrolled", "iset_signal_window_scrolled_cb", "");
  1525. weechat::hook_signal("buffer_switch", "iset_signal_buffer_switch_cb","");
  1526. weechat::bar_item_new("isetbar_help", "iset_item_cb", "");
  1527. weechat::bar_new("isetbar", "on", "0", "window", "", "top", "horizontal",
  1528. "vertical", "3", "3", "default", "cyan", "default", "1",
  1529. "isetbar_help");
  1530. weechat::hook_modifier("bar_condition_isetbar", "iset_check_condition_isetbar_cb", "");
  1531. weechat::hook_config("*", "iset_config_cb", "");
  1532. $iset_buffer = weechat::buffer_search($LANG, $PRGNAME);
  1533. iset_init() if ($iset_buffer ne "");
  1534. if ($wee_version_number >= 0x00030600)
  1535. {
  1536. weechat::hook_focus("chat", "hook_focus_iset_cb", "");
  1537. weechat::hook_hsignal($PRGNAME."_mouse", "iset_hsignal_mouse_cb", "");
  1538. weechat::key_bind("mouse", \%mouse_keys);
  1539. }