Created
May 9, 2018 13:38
-
-
Save bdw429s/747e993d40ab1af5e7d843fce2fe23f6 to your computer and use it in GitHub Desktop.
task.cfc
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
component { | |
function run() { | |
var terminal = shell.getReader().getTerminal(); | |
var capability = createObject( 'java', 'org.jline.utils.InfoCmp$Capability' ); | |
var keys = createObject( 'java', 'org.jline.keymap.KeyMap' ); | |
var bindingReader = createObject( 'java', 'org.jline.keymap.BindingReader' ).init( terminal.reader() ); | |
keys.bind( capability.key_left.name(), keys.key( terminal, capability.key_left ) ); | |
keys.setnomatch( 'self-insert' ); | |
try { | |
attr = terminal.enterRawMode(); | |
terminal.puts( capability.keypad_xmit, [] ); | |
terminal.flush(); | |
var binding = bindingReader.readBinding( keys ); | |
} finally { | |
if( !isNull( attr ) ) { | |
terminal.setAttributes( attr ); | |
} | |
terminal.puts( capability.keypad_local, [] ); | |
terminal.flush(); | |
} | |
if( binding == 'self-insert' ) { | |
var key = bindingReader.getLastBinding(); | |
print.line( 'you pressed: ' & key & ' (ASCII Code #asc( key )#)' ); | |
} else { | |
print.line( 'you pressed: ' & binding ); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment