]> git.vpit.fr Git - perl/scripts/xchat.git/blobdiff - Xchat/XPI/Utils.pm
Factor the GUI commands into a new utility function
[perl/scripts/xchat.git] / Xchat / XPI / Utils.pm
index 8fab3c469aae892395cf1ceec3f48bd49e1df141..cbd9494ae1cd5a158d34dc78a32a2196eadd7ff8 100644 (file)
@@ -23,6 +23,17 @@ sub dye_nick {
  return sprintf "\003%d%s", $rcolors[$col % @rcolors], $nick;
 }
 
+my %gui_commands = (
+ 'clear'     => [ 'COLOR 0' ],
+ 'highlight' => [ 'FLASH' => 'COLOR 3' ],
+);
+
+sub gui {
+ my $commands = $gui_commands{$_[0] || 'nope'};
+ die 'Invalid command' unless defined $commands;
+ command "GUI $_" for @$commands;
+}
+
 sub save_context {
  my $cur_cxt = get_context;
  bless \$cur_cxt, 'Xchat::XPI::Utils::ContextGuard';
@@ -73,6 +84,7 @@ use base qw<Exporter>;
 our @EXPORT         = ();
 our %EXPORT_TAGS    = ('funcs' => [ qw<
  dye_nick
+ gui
  save_context local_context
  called_from_script
 > ]);