Skip to content
This repository has been archived by the owner on Sep 20, 2021. It is now read-only.

Commit

Permalink
Add timeout on getTitle and getLabel for tmux.
Browse files Browse the repository at this point in the history
Some versions of tmux does not support the dialog inside `getTitle` and
`getLabel`. Thus we add a timeout to avoid an infinite wait.
  • Loading branch information
Hywan committed Mar 19, 2015
1 parent eb392b0 commit 5cabbb0
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions Window.php
Original file line number Diff line number Diff line change
Expand Up @@ -423,9 +423,16 @@ public static function getTitle ( ) {
// DECSLPP.
echo "\033[21t";

$read = [STDIN];
$write = [];
$except = [];
$out = null;

if(0 === stream_select($read, $write, $except, 0, 50000))
return $out;

// Read \033]l<title>\033\
fread(STDIN, 3); // skip \033, ] and l.
$out = null;

do {

Expand Down Expand Up @@ -462,9 +469,16 @@ public static function getLabel ( ) {
// DECSLPP.
echo "\033[20t";

$read = [STDIN];
$write = [];
$except = [];
$out = null;

if(0 === stream_select($read, $write, $except, 0, 50000))
return $out;

// Read \033]L<label>\033\
fread(STDIN, 3); // skip \033, ] and L.
$out = null;

do {

Expand Down

0 comments on commit 5cabbb0

Please sign in to comment.