aboutsummaryrefslogtreecommitdiffstats
path: root/vimput.pl
diff options
context:
space:
mode:
authorTeddy Wing2017-12-16 21:14:55 +0100
committerTeddy Wing2017-12-16 21:14:55 +0100
commit471af2ce8aa3e152336761b2c618f673f2c0adf8 (patch)
treedaa99e31ae1ddcbca8375b753ac564a4c14e7d39 /vimput.pl
parent944625d9a600d1f70ce5026437856b7eb97b2074 (diff)
downloadirssi-vimput-471af2ce8aa3e152336761b2c618f673f2c0adf8.tar.bz2
Use separate `Irssi::input_add` handlers for command & input
Instead of handling both commands and text input in the same subroutine, use separate ones so we can keep the code more isolated and handle the subseqent actions differently.
Diffstat (limited to 'vimput.pl')
-rw-r--r--vimput.pl24
1 files changed, 17 insertions, 7 deletions
diff --git a/vimput.pl b/vimput.pl
index 4ab42ed..fc9d38e 100644
--- a/vimput.pl
+++ b/vimput.pl
@@ -241,7 +241,7 @@ else {
$p2 = Irssi::input_add(
fileno $fuckface,
Irssi::INPUT_READ,
- \&pipe_input,
+ \&pipe_open_tmux_split,
\@ar2,
);
}
@@ -254,12 +254,22 @@ sub pipe_input {
my $input = <$read_handle>;
- if (index($input, VIMPUT_IPC_COMMAND_PREFIX) == 0) {
- print substr $input, length(VIMPUT_IPC_COMMAND_PREFIX);
- }
- else {
- print 'I: ' . $input;
- }
+ print 'I: ' . $input;
+
+ # TODO: Add $forked to not spawn more than one children unnecessarily
+
+ close $read_handle;
+ Irssi::input_remove($$pipe_tag);
+}
+
+
+sub pipe_open_tmux_split {
+ my ($args) = @_;
+ my ($read_handle, $pipe_tag) = @$args;
+
+ my $input = <$read_handle>;
+
+ print 'C: ' . $input;
# TODO: Add $forked to not spawn more than one children unnecessarily