@@ -853,7 +853,7 @@ protected function getTerminalWidth()
853
853
return preg_replace ('{^(\d+)x.*$} ' , '$1 ' , $ ansicon );
854
854
}
855
855
856
- if (preg_match ('{columns:\s* (\d+)}i ' , $ this ->getConsoleMode (), $ matches )) {
856
+ if (preg_match ('{^ (\d+)x\d+$ }i ' , $ this ->getConsoleMode (), $ matches )) {
857
857
return $ matches [1 ];
858
858
}
859
859
}
@@ -875,7 +875,7 @@ protected function getTerminalHeight()
875
875
return preg_replace ('{^\d+x\d+ \(\d+x(\d+)\)$} ' , '$1 ' , trim ($ ansicon ));
876
876
}
877
877
878
- if (preg_match ('{lines:\s* (\d+)}i ' , $ this ->getConsoleMode (), $ matches )) {
878
+ if (preg_match ('{^\d+x (\d+)$ }i ' , $ this ->getConsoleMode (), $ matches )) {
879
879
return $ matches [1 ];
880
880
}
881
881
}
@@ -966,7 +966,7 @@ private function getSttyColumns()
966
966
/**
967
967
* Runs and parses mode CON if it's available, suppressing any error output
968
968
*
969
- * @return string
969
+ * @return string <width>x<height> or null if it could not be parsed
970
970
*/
971
971
private function getConsoleMode ()
972
972
{
@@ -982,7 +982,9 @@ private function getConsoleMode()
982
982
fclose ($ pipes [2 ]);
983
983
proc_close ($ process );
984
984
985
- return $ info ;
985
+ if (preg_match ('{--------+\r?\n.+?(\d+)\r?\n.+?(\d+)\r?\n} ' , $ info , $ matches )) {
986
+ return $ matches [2 ].'x ' .$ matches [1 ];
987
+ }
986
988
}
987
989
}
988
990
0 commit comments