# Anti sb oops - Prevent replying to stuff in scrollback
#
# -- 0.1 (2009-08-19)
# * Does what it says on the tin.
# * Won't stop you from pasting or causing output in other ways than pressing
#   enter.

$VERSION = "0.1";
%IRSSI = (
    authors     => "Jonas Haggqvist",
    contact     => "rasher@rasher.dk",
    name        => "antisboops",
    description => "Prevent accidental typing while in scrollback",
    license     => "BSD license without advertising clause",
    url         => "http://rasher.dk/pub/irssi",
);

use strict;
use Irssi::TextUI;

our $ENTER = 10;

sub check_enter {
    my ($key) = @_;
    my $atbottom = Irssi::active_win()->view()->{bottom};
    if ($key eq $ENTER and !$atbottom) {
        Irssi::signal_stop();
    }
}

# Signal hooks
Irssi::signal_add_first('gui key pressed', 'check_enter');
