Skip to content

Commit 6bff21f

Browse files
author
Daniel Bachhuber
committed
Merge pull request #82 from nochso/master
Add retrieval of shell column length on Windows
2 parents 228e8c1 + 0e60324 commit 6bff21f

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

lib/cli/Shell.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,21 @@ static public function columns() {
2828
static $columns;
2929

3030
if ( null === $columns ) {
31-
if ( ! self::is_windows() ) {
31+
if (self::is_windows() ) {
32+
$output = array();
33+
exec('mode CON', $output);
34+
foreach ($output as $line) {
35+
if (preg_match('/Columns:( )*([0-9]+)/', $line, $matches)) {
36+
$columns = (int)$matches[2];
37+
break;
38+
}
39+
}
40+
} else {
3241
$columns = (int) exec('/usr/bin/env tput cols');
3342
}
3443

3544
if ( !$columns ) {
36-
$columns = 80; // default width of cmd window on Windows OS, maybe force using MODE CON COLS=XXX?
45+
$columns = 80; // default width of cmd window on Windows OS
3746
}
3847
}
3948

0 commit comments

Comments
 (0)