Last active
December 2, 2015 21:40
-
-
Save Alanaktion/3f54e7559af3915e70cf to your computer and use it in GitHub Desktop.
Terminal window helper functions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Get terminal window size in characters | |
* @return array | |
*/ | |
function getWindowSize() { | |
return array(exec('tput cols'), exec('tput lines')); | |
} | |
/** | |
* Clear terminal window | |
* @return void | |
*/ | |
function clearWindow() { | |
system('tput clear'); | |
} | |
/** | |
* Set cursor position | |
* @param int $x | |
* @param int $y | |
* @return void | |
*/ | |
function setCursorPosition($x, $y) { | |
system('tput cup ' . escapeshellarg($x) . ' ' . escapeshellarg($y)); | |
} | |
// Line chracters for drawing boxes | |
$lines = array( | |
"unicode" => array("\u2500", "\u2502", "\u250C", "\u2510", "\u2514", "\u2518", "\u251C", "\u2524", "\u252C", "\u2534", "\u253C"), | |
"unix" => array("\u6a", "\u6b", "\u6c", "\u6d", "\u6e", "\u71", "\u74", "\u75", "\u76", "\u77", "\u78"), | |
"dos" => array("\xC4", "\xB3", "\xDA", "\xBF", "\xC0", "\xB9"), | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment