From 8e4cc4df3ee71010ec9654112f1bd9d588f64e9e Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Fri, 15 Dec 2017 22:23:43 +0100 Subject: Open a Tmux split with the prompt contents After writing to the file, our keyboard shortcut opens a Tmux pane with a Vim and our input message available for editing. If we're not in Tmux, we should print an error message. Need to rewrite that to print a real Irssi message. --- vimput.pl | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'vimput.pl') diff --git a/vimput.pl b/vimput.pl index 0c09d36..8563f44 100644 --- a/vimput.pl +++ b/vimput.pl @@ -31,10 +31,23 @@ sub write_input { } +# Open a Tmux split containing a Vim instance editing the tempfile. +sub open_tmux_split { + if (!$ENV{TMUX}) { + print 'no tmux'; # TODO: Replace with Irssi print + return; + } + + my $command = "vim ${\tempfile}"; + system('tmux', 'split-window', $command); +} + + Irssi::signal_add_last 'gui key pressed' => sub { my ($key) = @_; if ($key eq CTRL_X) { write_input(Irssi::parse_special('$L', undef, 0)); + open_tmux_split(); } }; -- cgit v1.2.3