From 1554c2aec40f6265d87622fc858bf710b909cc10 Mon Sep 17 00:00:00 2001 From: Tom Feist Date: Fri, 25 Nov 2011 02:48:28 +0000 Subject: update template with some generic debugging features. --- feature-tests/template.pl | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/feature-tests/template.pl b/feature-tests/template.pl index a49d742..a5f59fa 100644 --- a/feature-tests/template.pl +++ b/feature-tests/template.pl @@ -67,3 +67,35 @@ our %IRSSI = ( license => 'MIT', updated => '$DATE' ); + +my $NAME = $IRSSI{name}; +my $DEBUG = 0; + +sub DEBUG () { $DEBUG } + +sub _debug_print { + my ($msg) = @_; + Irssi::active_window()->print($msg); +} + +sub sig_setup_changed { + $DEBUG = Irssi::settings_get_bool($NAME . '_debug'); + _debug_print($NAME . ': debug enabled') if $DEBUG; +} + +sub init { + Irssi::theme_register + ([ + verbatim => '[$*]', + script_loaded => 'Loaded script {hilight $0} v$1', + ]); + Irssi::settings_add_bool($NAME, $NAME . '_debug', 0); + Irssi::signal_add('setup changed', \&sig_setup_changed); + + sig_setup_changed(); + + Irssi::printformat(Irssi::MSGLEVEL_CLIENTCRAP, + 'script_loaded', $NAME, $VERSION); +} + +init(); -- cgit v1.2.3