cli.js
function onRead (key) {
  if (key !== null) {
    if (cli.debug) console.log('Key:', key)
    // Exits on CTRL-C
    if (key === '\u0003') process.exit()
    // If enter is pressed and the program is waiting for the user to press enter
    // so that the emulator can step forward, then call the appropriate callback
    if (key.charCodeAt(0) === 13 && readingFn() && onReadCb) onReadCb(key.charCodeAt(0))
    else if (cpu) {
      // Since the CPU is initialized and the program is not waiting for the user
      // to press enter, pass the pressed key to the LC-2 CPU Console.
      cpu.console.input(key)
    }
    readingFn(false)
  }
}
function onRead (key) {
  if (key !== null) {
    if (cli.debug) console.log('Key:', key)
    // Exits on CTRL-C
    if (key === '\u0003') process.exit()
    // If enter is pressed and the program is waiting for the user to press enter
    // so that the emulator can step forward, then call the appropriate callback
    if (key.charCodeAt(0) === 13 && readingFn() && onReadCb) onReadCb(key.charCodeAt(0))
    else if (cpu) {
      // Since the CPU is initialized and the program is not waiting for the user
      // to press enter, pass the pressed key to the LC-2 CPU Console.
      cpu.console.input(key)
    }
    readingFn(false)
  }
}
function onRead ( key ) { if ( key !== null ) { if ( cli . debug ) console . log ( 'Key:' , key ) // Exits on CTRL-C if ( key === '\u0003' ) process . exit ( ) // If enter is pressed and the program is waiting for the user to press enter // so that the emulator can step forward, then call the appropriate callback if ( key . charCodeAt ( 0 ) === 13 && readingFn ( ) && onReadCb ) onReadCb ( key . charCodeAt ( 0 ) ) else if ( cpu ) { // Since the CPU is initialized and the program is not waiting for the user // to press enter, pass the pressed key to the LC-2 CPU Console. cpu . console . input ( key ) } readingFn ( false ) } }
This function processes an input key from STDIN.
This function processes an input key from STDIN .