diff options
| -rw-r--r-- | colour-popup/colour_popup.pl | 60 | ||||
| -rw-r--r-- | feature-tests/sbar_test.pl | 31 | 
2 files changed, 91 insertions, 0 deletions
| diff --git a/colour-popup/colour_popup.pl b/colour-popup/colour_popup.pl new file mode 100644 index 0000000..b12c4f6 --- /dev/null +++ b/colour-popup/colour_popup.pl @@ -0,0 +1,60 @@ +#!/usr/bin/perl +# mirc_colour_popup irssi module +# +# Shows a mIRC-style colour popup when you hit ^C. +# +# usage: +# +# after loading the script, add the statusbar item somewhere convenient:  +#   /statusbar window add -after barstart colours +# + +use strict; +use Irssi; +use Irssi::TextUI; +use vars qw($VERSION %IRSSI); + +$VERSION = "1.0"; +%IRSSI = ( +    authors     => "Michael Kowalchuk", +    contact     => "michael.kowalchuk\@gmail.com", +    name        => "mirc_colour_popup", +    description => "Shows a mIRC-style colour popup when you hit ^C.", +    license     => "Public Domain", +    changed     => "9.26.2008", +); + + +my $vis; + +my @colours = ('W','k','b','g','R','r','m','y','Y','G','c','C','B','P','K','w'); + +sub colours_sb { +	my ($item, $get_size_only) = @_; + +	my $txt; +	if( $vis ) { +		$txt = join " ", map { "\%$colours[$_]$_" } 0 .. 15; +	} +	$item->default_handler($get_size_only, "{sb $txt}", undef, 1); +} + + +Irssi::signal_add_last 'gui key pressed' => sub { +	my ($key) = @_; + +	if( not $vis and $key eq 3 ) { +		$vis = 1; +		Irssi::statusbar_items_redraw('colours'); +	} + +	elsif( $vis and $key ne 3 ) { +		$vis = undef; +		Irssi::statusbar_items_redraw('colours'); +	} + +}; + +Irssi::statusbar_item_register('colours', undef, 'colours_sb'); + + diff --git a/feature-tests/sbar_test.pl b/feature-tests/sbar_test.pl new file mode 100644 index 0000000..6523842 --- /dev/null +++ b/feature-tests/sbar_test.pl @@ -0,0 +1,31 @@ + +use strict; +use warnings; + +use Irssi; +use Irssi::TextUI;              # for sbar_items_redraw + + +sub foo_sb { +    my ($sb_item, $get_size_only) = @_; + +    # my $prompt = Irssi::parse_special('$L'); +    # my $cmdchars = Irssi::parse_special('$K'); + +    # my $sb = ''; + +    # if ($prompt =~ /^(.)ws (.+)$/i && index($cmdchars,$1) != -1) { +    #     my $arg = $2; +    #     my $wins = find_wins($arg); + +    #     foreach my $win (@$wins) { +    #         $sb .= $win->{text} . ' '; +    #     } +    #     $sb =~ s/ $//; +    # } +    my $sb = '%gmoo%n'; +    print "Getsize: $get_size_only"; +    $sb_item->default_handler($get_size_only, "{sb $sb}", '', 0); +} + +Irssi::statusbar_item_register ('foo_bar', 0, 'foo_sb'); | 
