-
Notifications
You must be signed in to change notification settings - Fork 234
/
Copy pathautonickprefix.pl
39 lines (30 loc) · 1.07 KB
/
autonickprefix.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
use strict;
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::TextUI;
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;
};