From e26b8d26ebfe24cee1ef9f301d3f426ca510f035 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Fri, 15 Dec 2017 21:51:24 +0100 Subject: Write input contents on key press Now instead of printing the current input to the Irssi window, write it to a script-specific file. The filename is inspired by Git. I figure we'll probably want to remove the file when we're done with it. Debated between creating a real temp file and using this one. We'll decide that later. --- vimput.pl | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/vimput.pl b/vimput.pl index 971616c..7cba39c 100644 --- a/vimput.pl +++ b/vimput.pl @@ -12,8 +12,24 @@ our %IRSSI = { }; +# 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) = @_; - print Irssi::parse_special('$L', undef, 0); + write_input(Irssi::parse_special('$L', undef, 0)); }; -- cgit v1.2.3