terminal-kit
Advanced tools
Comparing version 0.1.15 to 0.1.16
@@ -273,2 +273,14 @@ | ||
## .fullscreen( options ) | ||
* options: true/false/object: if truthy it activate fullscreen mode, falsy return to normal mode, | ||
if it is an object it supports those properties: | ||
* noAlternate `boolean` true if the alternate screen buffer should not be used | ||
Basically, this method try to achieve the same goal than the native terminal capability *alternate screen buffer*. | ||
If *alternate screen buffer* is disabled on your terminal, it will provide a clean fallback, clearing the screen and positionning | ||
the cursor at the upper-left corner. | ||
## .grabInput( options ) | ||
@@ -275,0 +287,0 @@ |
@@ -729,22 +729,2 @@ /* | ||
/* | ||
// Code from 'cli-color' | ||
Object.defineProperties( term , { | ||
width: { get: function() { | ||
if ( this.stdout.getWindowSize ) { return this.stdout.getWindowSize()[ 0 ] ; } | ||
else if ( this.couldTTY && tty.getWindowSize ) { return tty.getWindowSize()[ 1 ] ; } | ||
else { return 0 ; } | ||
} } , | ||
height: { get: function() { | ||
if ( this.stdout.getWindowSize ) { return this.stdout.getWindowSize()[ 1 ] ; } | ||
else if ( this.couldTTY && tty.getWindowSize ) { return tty.getWindowSize()[ 0 ] ; } | ||
else { return 0 ; } | ||
} } | ||
} ) ; | ||
*/ | ||
// The following is PHP code from the CSK PHP lib. | ||
@@ -792,55 +772,2 @@ // This is not backported ATM. | ||
static function clear( $home = false ) { if ( $home ) echo "\x1b[2J\x1b[0;0f" ; else echo "\x1b[2J" ; } | ||
static function set_cursor_yx( $y , $x ) { $y = intval( $y ) ; $x = intval( $x ) ; echo "\x1b[{$y};{$x}f" ; } | ||
// bugs: | ||
// il faudrait ré-injecter dans le flux les caractères hors contrôle | ||
// l'appli freeze tant que l'utilisateur n'appuie pas sur entrée | ||
static function get_cursor_yx( &$y , &$x ) | ||
{ | ||
// tmp, annule l'affichage issue de STDIN (les réponses du terminal se font par STDIN) | ||
system( 'stty -echo' ) ; | ||
// Demande au terminal les coordonnées du curseur | ||
echo "\x1b[?6n" ; | ||
$code = '' ; | ||
while ( 1 ) | ||
{ | ||
$input = self::check_input() ; | ||
if ( $input ) $code .= $input ; | ||
//if ( $code ) echo "\n\nDebug , Hex: " , StringTB::str2hex( $code ) , "\n\n" ; | ||
if ( preg_match( '(\x1b\[\?([0-9]+);([0-9]+)R)' , $code , $matches ) ) | ||
{ | ||
$y = $matches[ 1 ] ; | ||
$x = $matches[ 2 ] ; | ||
break ; | ||
} | ||
usleep( 1000 ) ; | ||
} | ||
} | ||
// Les modes du terminal | ||
// Pour le moment, on dirait qu'on est obligé d'utiliser un appel système, je ne trouve pas de séquence d'échappement | ||
static function cooked() { system( 'stty cooked icanon' ) ; } | ||
static function cbreak() { system( 'stty cbreak' ) ; } | ||
static function raw() { system( 'stty raw' ) ; } // ATTENTION: Ctrl-C ne pourra pas quitter le programme | ||
static function echo_on() { self::$echo = true ; system( 'stty echo' ) ; } | ||
static function echo_off() { self::$echo = false ; system( 'stty -echo' ) ; } | ||
// input non bloquant | ||
static function check_input() | ||
{ | ||
stream_set_blocking( STDIN , 0 ) ; | ||
$input = stream_get_contents( STDIN ) ; | ||
stream_set_blocking( STDIN , 1 ) ; | ||
return $input ; | ||
} | ||
// attend que l'utilisateur tape un des deux caractères (par défaut 'y' pour 'yes' et 'n' pour 'no') et retourne true pour yes, et false pour no | ||
@@ -882,53 +809,2 @@ static function yes_no( $yes = 'y' , $no = 'n' ) | ||
static function init( $force_tty = false ) | ||
{ | ||
if ( self::$is_init ) return true ; | ||
if ( ! $force_tty && ! System::is_unix() ) return false ; | ||
if ( ! posix_isatty( STDOUT ) ) | ||
{ | ||
if ( ! $force_tty ) return false ; | ||
self::$tty = posix_ttyname( STDOUT ) ; | ||
self::$termid = posix_ctermid() ; | ||
self::$init_termstate = trim( `stty -g` ) ; // il faut retirer le \n final | ||
} | ||
else | ||
{ | ||
self::$tty = posix_ttyname( STDOUT ) ; | ||
self::$termid = posix_ctermid() ; | ||
self::$init_termstate = trim( `stty -g` ) ; // il faut retirer le \n final | ||
} | ||
// Si le module est initialisé, l'utilisateur a peut-être changé les couleurs... | ||
// On lui reset son terminal | ||
register_shutdown_function( 'Wtermless::close' ) ; | ||
self::$is_init = true ; | ||
return true ; | ||
} | ||
static function close() | ||
{ | ||
if ( ! self::$is_init ) return ; | ||
self::reset() ; | ||
system( 'stty "' . self::$init_termstate . '"' ) ; | ||
self::$is_init = false ; | ||
} | ||
static function get_tty() { return self::$tty ; } | ||
static function get_termid() { return self::$termid ; } | ||
static private $is_init = false ; | ||
static private $tty = false ; | ||
static private $termid = '' ; | ||
static private $init_termstate = '' ; | ||
static private $echo = true ; | ||
*/ |
{ | ||
"name": "terminal-kit", | ||
"version": "0.1.15", | ||
"version": "0.1.16", | ||
"description": "Terminal utilities with supports for colors, styles, inputs, mouse and many more...", | ||
@@ -5,0 +5,0 @@ "main": "lib/terminal.js", |
@@ -273,2 +273,14 @@ | ||
## .fullscreen( options ) | ||
* options: true/false/object: if truthy it activate fullscreen mode, falsy return to normal mode, | ||
if it is an object it supports those properties: | ||
* noAlternate `boolean` true if the alternate screen buffer should not be used | ||
Basically, this method try to achieve the same goal than the native terminal capability *alternate screen buffer*. | ||
If *alternate screen buffer* is disabled on your terminal, it will provide a clean fallback, clearing the screen and positionning | ||
the cursor at the upper-left corner. | ||
## .grabInput( options ) | ||
@@ -275,0 +287,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
431
348008
1726