diff options
Diffstat (limited to 'scrolled-reminder')
| -rw-r--r-- | scrolled-reminder/scrolled-reminder.pl | 65 | ||||
| -rw-r--r-- | scrolled-reminder/test.pl | 77 | 
2 files changed, 142 insertions, 0 deletions
| diff --git a/scrolled-reminder/scrolled-reminder.pl b/scrolled-reminder/scrolled-reminder.pl new file mode 100644 index 0000000..e2775dc --- /dev/null +++ b/scrolled-reminder/scrolled-reminder.pl @@ -0,0 +1,65 @@ +use strict; +use warnings; + +use Irssi; +use Irssi::TextUI; +use Irssi::Irc; + +use Data::Dumper; + +our $VERSION = '0.01'; +our %IRSSI = ( +              authors     => 'Tom Feist', +              contact     => 'shabble@cowu.be', +              name        => 'scrolled-reminder', +              description => 'Requires confirmation to messages sent' +              . 'when the current window is scrolled up', + +              license     => 'WTFPL; http://sam.zoy.org/wtfpl/', +              url         => 'http://metavore.org/', +             ); + + +sub handle_send_text { +    my ($text, $server_tag, $win_item) = @_; +    unless ($win_item) { +        # not all windows have window-items (eg: status window) +        return; +    } + +    my $window = $win_item->window; +    my $view = $window->view; + +    if ($view->{bottom} != 1) { +        # we're scrolled up. +        unless (require_confirmation($window)) { +            Irssi::signal_stop; +        } +    } +} + +sub handle_keypress { +    my ($key) = @_; +    Irssi::print("key pressed: " . $key); +    if ($key == 3) { # Ctrl-c +    } elsif ($key == 11) { # Ctrl-k +    } else { +    } +    Irssi::signal_remove('gui key pressed', 'handle_keypress'); +} + +sub require_confirmation { +    my ($window) = @_; +    Irssi::signal_add_first('gui key pressed', 'handle_keypress'); +    $window->print("You are scrolled up Really send?"); +    write_to_prompt($window, 'Press Ctrl-K to confirm, Ctrl-C to cancel '); +} + +sub write_to_prompt { +    my ($window, $msg) = @_; +    #$window->command("insert_text $msg"); + +} + +Irssi::signal_add_first('send text', 'handle_send_text'); + diff --git a/scrolled-reminder/test.pl b/scrolled-reminder/test.pl new file mode 100644 index 0000000..e5b3d2e --- /dev/null +++ b/scrolled-reminder/test.pl @@ -0,0 +1,77 @@ +use strict; +use warnings; + +use lib '/opt/stow/lib/perl5'; + +use Irssi; +use Irssi::TextUI; +use Data::Dumper; +use vars qw/$BACON/; + +my $bob = "hello bob"; +our $HATS = "i like hats"; + +#Irssi::print(Dumper(\@INC)); +Irssi::print("Package is " . __PACKAGE__); + +#Irssi::gui_input_set("Hello"); +# my $foo = Irssi::gui_input_get_pos(); +# Irssi::print("foo is: $foo"); +my $foo = Irssi::yay_horsies("What!"); +Irssi::print($foo); + +Irssi::command_bind('prompt', 'do_prompt'); +Irssi::command_bind('emit', 'do_emit'); +Irssi::command_bind('myprint', 'do_print'); +Irssi::command_bind('myprint2', 'do_print2'); + +#Irssi::signal_add_last("gui print text", "do_gui_print"); +Irssi::signal_add("print text", "do_print_intercept"); + +sub do_print_intercept { +    my ($dest, $text, $stripped) = @_; +    #if ($text =~ m/baconbacon/) { +    $text = $text . "lvl: " . $dest->{level}; + +        $dest->{level} |= MSGLEVEL_NO_ACT; +        $dest->{level} &= ~MSGLEVEL_HILIGHT; + +#} +    Irssi::signal_continue($dest, $text, $stripped); +} + +sub do_gui_print { +    Irssi::print(Dumper(\@_)); +    Irssi::signal_stop(); +    Irssi::signal_remove('gui print text', 'do_gui_print'); +} + +sub do_prompt { +    my ($msg) = @_; +    Irssi::gui_input_set_prompt($msg); +} + +sub do_emit { +    my ($key) = @_; +    Irssi::print("emitting signal: keypress for $key"); +    #Irssi::signal_emit("gui key pressed", $key); +    Irssi::signal_emit("gui dialog", "error", "What is going on?"); +} + +sub do_print { +    my ($msg) = @_; +    my $window = Irssi::active_win; +    my $len = length $msg; + +    $window->print(Dumper($window->view)); +    # $window->print("message is $msg which is $len long"); +    # my $str = join( ', ', map { ord } split( '', $msg)); +    # $window->print($str); + +} + + +sub do_print2 { +    my ($msg) = @_; +    Irssi::print("message2 is $msg", MSGLEVEL_PUBLIC + MSGLEVEL_NOHILIGHT); +} | 
