diff options
| author | Ailin Nemui | 2016-04-26 23:42:54 +0200 |
|---|---|---|
| committer | Ailin Nemui | 2016-04-26 23:42:54 +0200 |
| commit | 71fbc723a80cd953bd4f5cb362823dea6bcf6db5 (patch) | |
| tree | 403f4dbdfbe918ed34ac643f0ea4a12bb1ab116c /scripts | |
| parent | 91c8e2ec878d6942b11f61daa5cfef1d211de0d9 (diff) | |
| download | scripts.irssi.org-71fbc723a80cd953bd4f5cb362823dea6bcf6db5.tar.bz2 | |
Add script beforespace
Rebind certain keys so that they are inserted before the space
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/beforespace.pl | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/scripts/beforespace.pl b/scripts/beforespace.pl new file mode 100644 index 0000000..d689810 --- /dev/null +++ b/scripts/beforespace.pl @@ -0,0 +1,36 @@ +use strict; +use warnings; + +our $VERSION = '0.1'; # fca02729ae64034 +our %IRSSI = ( + authors => 'Nei', + contact => 'Nei @ anti@conference.jabber.teamidiot.de', + url => "http://anti.teamidiot.de/", + name => 'beforespace', + description => 'Rebind certain keys so that they are inserted before the space', + license => 'ISC', + ); + +# Usage +# ===== +# after loading the script, rebind the desired keys like so: +# +# /bind , /key_insert_before_space , +# /bind : /key_insert_before_space : +# +# don't forget to put the script in autorun otherwise next time you +# cannot type those keys anymore ;-) + +use Irssi::TextUI; +use Irssi; + +Irssi::command_bind( + key_insert_before_space => sub { + my ($data) = @_; + my $input = Irssi::parse_special('$L'); + my $pos = Irssi::gui_input_get_pos; + my ($p1, $p2) = ((substr $input, 0, $pos), (substr $input, $pos)); + $p1 =~ s/(\s*)$/$data$1/; + Irssi::gui_input_set("$p1$p2"); + Irssi::gui_input_set_pos(length $p1); + }); |
