diff options
| author | Juerd Waalboer | 2016-01-12 15:11:36 +0100 |
|---|---|---|
| committer | Juerd Waalboer | 2016-01-12 15:11:36 +0100 |
| commit | 8cfbdd2cf112fdaa962d2f5d107618b0b1746669 (patch) | |
| tree | 5e002dec87d3af60092e3baeb63ab86cf9da6e1b /scripts | |
| parent | 773c7ba9c045f12163771a258763a6a00ee4e642 (diff) | |
| download | scripts.irssi.org-8cfbdd2cf112fdaa962d2f5d107618b0b1746669.tar.bz2 | |
Add autonickprefix.pl sscipt
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/autonickprefix.pl | 36 |
1 files changed, 36 insertions, 0 deletions
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; +}; |
