node-termios is a module for getting and setting terminal attributes.
-
an
attr
object may contain on or more of the following boolean fields:attr.iflag
:IGNBRK
: ignore BREAK conditionBRKINT
: map BREAK to SIGINTIGNPAR
: ignore (discard) parity errorsPARMRK
: mark parity and framing errorsINPCK
: enable checking of parity errorsISTRIP
: strip 8th bit off charsINLCR
: map NL into CRIGNCR
: ignore CRICRNL
: map CR to NL (ala CRMOD)IXON
: enable output flow controlIXOFF
: enable input flow controlIXANY
: any char will restart after stopIMAXBEL
: ring bell on input queue full
attr.oflag
:OPOST
: enable following output processingONLCR
: map NL to CR-NL (ala CRMOD)OCRNL
: map CR to NLONOCR
: No CR output at column 0ONLRET
: NL performs the CR function
attr.cflag
:CSIZE
: character size maskCS5
: 5 bits (pseudo)CS6
: 6 bitsCS7
: 7 bitsCS8
: 8 bitsCSTOPB
: send 2 stop bitsCREAD
: enable receiverPARENB
: parity enablePARODD
: odd parity, else evenHUPCL
: hang up on last closeCLOCAL
: ignore modem status lines
attr.lflag
:ECHOKE
: visual erase for line killECHOE
: visually erase charsECHOK
: echo NL after line killECHO
: enable echoingECHONL
: echo NL even if ECHO is offECHOPRT
: visual erase mode for hardcopyECHOCTL
: echo control chars as ^(Char)ISIG
: enable signals INTR, QUIT, [D]SUSPICANON
: canonicalize input linesIEXTEN
: enable DISCARD and LNEXTEXTPROC
: external processingTOSTOP
: stop background jobs from outputFLUSHO
: output being flushed (state)PENDIN
: XXX retype pending input (state)NOFLSH
: don't flush after interruptXCASE
: canonical upper/lower case
-
.setattr(fd, attr)
: Sets attributes of the terminal bound to the file descriptor:- fd: file descriptor
- attr: object as described above
- returns: undefined
-
.getattr(fd)
: Returns an object describing the current settings of the terminal bound to the file descriptor:- fd: file descriptor
var termios = require('termios'), data = '';
console.log("Please type something:");
process.stdin.on("data", function(d) {data += d.toString()});
setTimeout(function() {
console.log("Disabling ECHO. You won't see what you type now");
termios.setattr(process.stdin.fd, {lflag: { ECHO: false }})
console.log("\nYou typed '"+data+"'");
data = "";
}, 3000);
setTimeout(function() {
console.log("Enabling ECHO.");
termios.setattr(process.stdin.fd, {lflag: { ECHO: false }})
console.log("\nYou typed '"+data+"'");
}, 6000);
- v0.1 - initial release