aboutsummaryrefslogtreecommitdiffstats
path: root/feature-tests
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--feature-tests/any_time.pl37
1 files changed, 37 insertions, 0 deletions
diff --git a/feature-tests/any_time.pl b/feature-tests/any_time.pl
new file mode 100644
index 0000000..fd00b02
--- /dev/null
+++ b/feature-tests/any_time.pl
@@ -0,0 +1,37 @@
+
+use strict;
+use warnings;
+
+use Irssi;
+use Irssi::TextUI; # for sbar_items_redraw
+use POSIX qw/strftime/;
+
+my $time_format;
+
+sub any_time_sb {
+ my ($sb_item, $get_size_only) = @_;
+
+ my @time_now = localtime();
+ my $formatted_time = strftime($time_format, @time_now);
+
+ $sb_item->default_handler($get_size_only, "{sb $formatted_time}", '', 0);
+}
+
+sub sig_setup_changed {
+ $time_format = Irssi::settings_get_str('any_time_format');
+}
+
+sub init {
+ Irssi::settings_add_str('any_time', 'any_time_format', '%H:%M');
+ Irssi::signal_add('setup changed', \&sig_setup_changed);
+
+ sig_setup_changed();
+
+ Irssi::signal_add('expando timer',
+ sub { Irssi::statusbar_items_redraw('any_time') });
+
+
+ Irssi::statusbar_item_register ('any_time', 0, 'any_time_sb');
+}
+
+init();