aboutsummaryrefslogtreecommitdiffstats
path: root/vimput.pl
blob: 0c09d36eced66c26d45e56eb2cb8ac5d41167f84 (plain)
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
40
use strict;

use Irssi;

our $VERSION = '1.00';
our %IRSSI = {
	authors     => 'Teddy Wing',
	contact     => 'irssi@teddywing.com',
	name        => 'Vimput',
	description => '',
	license     => 'GPL',
};


use constant CTRL_X => 24;


# The location of the temporary file where prompt contents are written.
sub tempfile {
	Irssi::get_irssi_dir() . '/VIMPUT_MSG';
}


# Write the given string to our tempfile.
sub write_input {
	my ($message) = @_;

	open my $handle, '>', tempfile or die $!;
	print $handle $message;
	close $handle;
}


Irssi::signal_add_last 'gui key pressed' => sub {
	my ($key) = @_;

	if ($key eq CTRL_X) {
		write_input(Irssi::parse_special('$L', undef, 0));
	}
};