Skip to content

Instantly share code, notes, and snippets.

@bdw429s
Last active Jan 11, 2018
Embed
What would you like to do?
component {
property name='printer' inject='print';
function run() {
var lines = [
// bold text. Bold works on regular output, but not on prompt
'#chr(27)#[1mtest#chr(27)#[0m',
// bold GREEN text. Bold works on prompt but not on regular ouptut!
'#chr(27)#[1m#chr(27)#[32mtest#chr(27)#[0m',
// bold green text. Move the ESC[1 to AFTER the green code and suddendly both work!!
'#chr(27)#[32m#chr(27)#[1mtest#chr(27)#[0m',
// Two bold colors on backgrouds. The first sample is bold, but the second isn't on the prompt (note the bold escape code is still last here)
printer.boldblueOnWhite( 'blue on white' ) & printer.boldRedOnGreen( 'red on green' ),
// Same as above, but putting a space after the clear code suddendly makes bold work on both colors at the prompt!
printer.boldblueOnWhite( 'blue on white' ) & ' ' & printer.boldRedOnGreen( 'red on green' )
];
for( var ANSI in lines ) {
shell.printString( chr(10) );
shell.printString( 'ANSI sequence:' & chr(10) );
systemoutput( ANSI.replace( chr(27), 'ESC', 'all' ) & chr(10) );
shell.printString( chr(10) );
shell.printString( '"Regular" printed text:' & chr(10) );
shell.printString( ANSI & chr(10) );
shell.printString( chr(10) );
shell.printString( 'Prompt:' & chr(10) );
line = shell.getreader().readLine( ANSI );
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment