From 8cfbdd2cf112fdaa962d2f5d107618b0b1746669 Mon Sep 17 00:00:00 2001 From: Juerd Waalboer Date: Tue, 12 Jan 2016 15:11:36 +0100 Subject: Add autonickprefix.pl sscipt --- scripts/autonickprefix.pl | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 scripts/autonickprefix.pl (limited to 'scripts') diff --git a/scripts/autonickprefix.pl b/scripts/autonickprefix.pl new file mode 100644 index 0000000..5b9d656 --- /dev/null +++ b/scripts/autonickprefix.pl @@ -0,0 +1,36 @@ +our $VERSION = '1.00'; +our %IRSSI = ( + authors => 'Juerd', + contact => '#####@juerd.nl', + name => 'autonickprefix', + description => "Change 'nick: ' prefix if the nick is changed while you're still editing.", + license => 'Any OSI', +); + +use Irssi qw( + signal_add active_win settings_get_str parse_special + gui_input_get_pos gui_input_set gui_input_set_pos +); + +signal_add 'nicklist changed' => sub { + my ($chan, $newnick, $oldnick) = @_; + $newnick = $newnick->{nick}; + + # Ignore other channels than current + my $viewing = active_win->{active} or return; + $viewing->{_irssi} == $chan->{_irssi} or return; + + my $char = settings_get_str 'completion_char'; + my $pos = gui_input_get_pos; + + # Incomplete nick could be something else. + $pos >= length("$oldnick$char") or return; + + my $delta = length($newnick) - length($oldnick); + + my $input = parse_special '$L'; + $input =~ s/^\Q$oldnick$char/$newnick$char/ or return; + + gui_input_set $input; + gui_input_set_pos $pos + $delta; +}; -- cgit v1.2.3 From 96498fe320514e9442f0b1067d8596dca8a65481 Mon Sep 17 00:00:00 2001 From: Juerd Waalboer Date: Tue, 12 Jan 2016 15:36:17 +0100 Subject: Add 'use strict'. --- scripts/autonickprefix.pl | 2 ++ 1 file changed, 2 insertions(+) (limited to 'scripts') diff --git a/scripts/autonickprefix.pl b/scripts/autonickprefix.pl index 5b9d656..de32e29 100644 --- a/scripts/autonickprefix.pl +++ b/scripts/autonickprefix.pl @@ -1,3 +1,5 @@ +use strict; + our $VERSION = '1.00'; our %IRSSI = ( authors => 'Juerd', -- cgit v1.2.3