summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorailin-nemui2016-04-27 13:38:57 +0200
committerailin-nemui2016-04-27 13:38:57 +0200
commit4667723f748700c7fca75fd9f7f0320bd3093135 (patch)
tree7f9ae2ce2c45c28b8a845579be93dbb0241435bd /scripts
parente57ab885f902dff656f918f5e5b08977af7daaaf (diff)
parent71fbc723a80cd953bd4f5cb362823dea6bcf6db5 (diff)
downloadscripts.irssi.org-4667723f748700c7fca75fd9f7f0320bd3093135.tar.bz2
Merge pull request #263 from ailin-nemui/beforespace
Add script beforespace
Diffstat (limited to 'scripts')
-rw-r--r--scripts/beforespace.pl36
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);
+ });