Method _Stdio.Fd()->tcgetattr()

Method tcgetattr
Method tcsetattr

mapping tcgetattr()
int tcsetattr(mapping attr)
int tcsetattr(mapping attr, string when)


Gets/sets term attributes. The returned value/the attr parameter is a mapping on the form

"ispeed" : int(-1..)

In baud rate.

"ospeed" : int(-1..)

Out baud rate.

"csize" : int(-1)|int(5..8)

Character size in bits.

"rows" : int

Terminal rows.

"columns" : int

Terminal columns.

flag_name : bool

The value of a named flag. The flag name is the string describing the termios flags (IGNBRK, BRKINT, IGNPAR, PARMRK, INPCK, ISTRIP, INLCR, IGNCR, ICRNL, IUCLC, IXON, IXANY, IXOFF, IMAXBEL, OPOST, OLCUC, ONLCR, OCRNL, ONOCR, ONLRET, OFILL, OFDEL, OXTABS, ONOEOT, CSTOPB, CREAD, PARENB, PARODD, HUPCL, CLOCAL, CRTSCTS, ISIG, ICANON, XCASE, ECHO, ECHOE, ECHOK, ECHONL, ECHOCTL, ECHOPRT, ECHOKE, FLUSHO, NOFLSH, TOSTOP, PENDIN). See the manpage for termios or other documentation for more information. All flags are not available on all platforms.

character_name : int(8bit)

Sets the value of a control character (VINTR, VQUIT, VERASE, VKILL, VEOF, VTIME, VMIN, VSWTC, VSTART, VSTOP, VSUSP, VEOL, VREPRINT, VDISCARD, VWERASE, VLNEXT, VEOL2). All control characters are not available on all platforms.

Negative values are not allowed as indata, but might appear in the result from tcgetattr when the actual value is unknown. tcsetattr returns 0 if failed.

The argument when to tcsetattr describes when the changes are to take effect:


The change occurs immediately (default).


The change occurs after all output has been written.


The change occurs after all output has been written, and empties input buffers.


// setting the terminal in raw mode: Stdio.stdin->tcsetattr((["ECHO":0,"ICANON":0,"VMIN":0,"VTIME":0]));


Unknown flags are ignored by tcsetattr(). tcsetattr always changes the attribute, so only include attributes that actually should be altered in the attribute mapping.


Terminal rows and columns setting by tcsetattr() is not currently supported.

See also