summaryrefslogtreecommitdiff
path: root/lib/perl5db.pl
diff options
context:
space:
mode:
authorRob Hoelz <rob@hoelz.ro>2013-06-09 21:25:09 +0200
committerTony Cook <tony@develop-help.com>2014-05-28 11:09:56 +1000
commitbabb663abd2abbcf054dab6d3c958d5175ab346d (patch)
tree10be05359d604c35ad1411beb4aa660406a18ce7 /lib/perl5db.pl
parent723edb963a2e0b7d9a2d27df3b7c3fd04c28e1b6 (diff)
downloadperl-babb663abd2abbcf054dab6d3c958d5175ab346d.tar.gz
Implement get_fork_TTY for tmux
Diffstat (limited to 'lib/perl5db.pl')
-rw-r--r--lib/perl5db.pl42
1 files changed, 42 insertions, 0 deletions
diff --git a/lib/perl5db.pl b/lib/perl5db.pl
index 707d04d639..e99ccc3cc9 100644
--- a/lib/perl5db.pl
+++ b/lib/perl5db.pl
@@ -1331,6 +1331,9 @@ if (not defined &get_fork_TTY) # only if no routine exists
{
*get_fork_TTY = \&xterm_get_fork_TTY; # use the xterm version
}
+ elsif ( $ENV{TMUX} ) {
+ *get_fork_TTY = \&tmux_get_fork_TTY;
+ }
elsif ( $^O eq 'os2' ) { # If this is OS/2,
*get_fork_TTY = \&os2_get_fork_TTY; # use the OS/2 version
}
@@ -7077,6 +7080,45 @@ sub macosx_get_fork_TTY
return $tty;
}
+=head3 C<tmux_get_fork_TTY>
+
+Creates a split window for subprocesses when a process running under the
+perl debugger in Tmux forks.
+
+=cut
+
+sub tmux_get_fork_TTY {
+ return unless $ENV{TMUX};
+
+ my $pipe;
+
+ my $status = open $pipe, '-|', 'tmux', 'split-window',
+ '-P', '-F', '#{pane_tty}', 'sleep 100000';
+
+ if ( !$status ) {
+ return;
+ }
+
+ my $tty = <$pipe>;
+ close $pipe;
+
+ if ( $tty ) {
+ chomp $tty;
+
+ if ( !defined $term ) {
+ require Term::ReadLine;
+ if ( !$rl ) {
+ $term = Term::ReadLine::Stub->new( 'perldb', $IN, $OUT );
+ }
+ else {
+ $term = Term::ReadLine->new( 'perldb', $IN, $OUT );
+ }
+ }
+ }
+
+ return $tty;
+}
+
=head2 C<create_IN_OUT($flags)>
Create a new pair of filehandles, pointing to a new TTY. If impossible,