Note: This class is not available with the PO_NO_TERMINAL_IO
parse option.
This class contains the data structure used to read and set terminal attributes on terminal I/O constants.
This class is used with File::getTerminalAttributes(), File::setTerminalAttributes(), and the terminal I/O constants to manipulate terminal attributes.
For example, here is some code to set terminal attributes, read in a character from stanrdard input with a timeout, and reset the terminal attributes:
my $t = new TermIOS(); stdin.getTerminalAttributes($t); my $orig = $t.copy(); on_exit stdin.setTerminalAttributes(TCSADRAIN, $orig); my $lflag = $t.getLFlag(); $lflag &= ~ICANON; $lflag &= ~ECHO; $lflag &= ~ISIG; $t.setLFlag($lflag); $t.setCC(VMIN, 1); $t.setCC(VTIME, 0); stdin.setTerminalAttributes(TCSADRAIN, $t); stdout.printf("Press any key: "); while (!stdin.isDataAvailable(20ms)) { stdout.printf("."); stdout.sync(); usleep(1ms); } my $c = stdin.read(1); stdout.printf(" GOT ASCII 0x%02x (%d) '%s'\n", ord($c), ord($c), $c);
For more information on terminal attributes, see your system's manual pages for "termios".
Table 4.199. TermIOS Method Overview
Method | Except? | Description |
---|---|---|
Y | Creates the TermIOS object. | |
N | Destroys the TermIOS object. | |
N | Returns a copy of the object. | |
N | Gets the local mode value of the object. | |
N | Gets the control mode value of the object. | |
N | Gets the output mode value of the object. | |
N | Gets the input mode value of the object. | |
N | Sets the local mode of the object. | |
N | Sets the control mode of the object. | |
N | Sets the output mode of the object. | |
N | Sets the input mode of the object. | |
N | Gets the value of a control character for the object. | |
N | Sets the value of a control character for the object. | |
Y | Returns true if the object passed is equal to the current object, false if not. |
Table 4.200. TermIOS Static Method Overview
Method | Except? | Description |
---|---|---|
Y | Returns a hash giving the current terminal window size in hash keys |
Creates the TermIOS object with random contents. Use File::getTerminalAttributes() with a terminal I/O constant to initialize the object with terminal settings.
new TermIOS()
my $termios = new TermIOS(); stdin.getTerminalAttributes($termios);
Table 4.201. Arguments for TermIOS::constructor()
Argument | Type | Description |
---|---|---|
n/a | n/a | The constructor takes no arguments. |
Table 4.202. Return Values for TermIOS::constructor()
Return Type | Description |
---|---|
TermIOS Object | The new TermIOS object. |
Destroys the TermIOS object.
delete lvalue
delete $termios;
This method does not throw any exceptions.
Returns a copy of the object.
This method does not throw any exceptions.
Returns the local mode flag for the object
TermIOS::getLFlag()
Table 4.203. Arguments for TermIOS::getLFlag()
Argument | Type | Description |
---|---|---|
n/a | n/a | This method takes no arguments. |
Table 4.204. Return Values for TermIOS::getLFlag()
Return Type | Description |
---|---|
Integer | The local mode flag for the object |
Returns the control mode flag for the object
TermIOS::getCFlag()
Table 4.205. Arguments for TermIOS::getCFlag()
Argument |
Type |
Description |
---|---|---|
n/a |
n/a |
This method takes no arguments. |
Table 4.206. Return Values for TermIOS::getCFlag()
Return Type |
Description |
---|---|
Integer |
The control mode flag for the object |
Returns the input mode flag for the object
TermIOS::getIFlag()
Table 4.207. Arguments for TermIOS::getIFlag()
Argument |
Type |
Description |
---|---|---|
n/a |
n/a |
This method takes no arguments. |
Table 4.208. Return Values for TermIOS::getIFlag()
Return Type |
Description |
---|---|
Integer |
The input mode flag for the object |
Returns the output mode flag for the object
TermIOS::getOFlag()
Table 4.209. Arguments for TermIOS::getOFlag()
Argument |
Type |
Description |
---|---|---|
n/a |
n/a |
This method takes no arguments. |
Table 4.210. Return Values for TermIOS::getOFlag()
Return Type |
Description |
---|---|
Integer |
The output mode flag for the object |
Sets the local mode flag for the object
TermIOS::setLFlag(lflag
)
Table 4.211. Arguments for TermIOS::setLFlag()
Argument |
Type |
Description |
---|---|---|
|
Integer |
The local mode to set for the object. |
Table 4.212. Return Values for TermIOS::setLFlag()
Return Type |
Description |
---|---|
n/a |
This method returns no value |
Sets the control mode flag for the object
TermIOS::setCFlag(cflag
)
Table 4.213. Arguments for TermIOS::setCFlag()
Argument |
Type |
Description |
---|---|---|
|
Integer |
The control mode to set for the object. |
Table 4.214. Return Values for TermIOS::setCFlag()
Return Type |
Description |
---|---|
n/a |
This method returns no value |
Sets the input mode flag for the object
TermIOS::setIFlag(iflag
)
Table 4.215. Arguments for TermIOS::setIFlag()
Argument |
Type |
Description |
---|---|---|
|
Integer |
The input mode to set for the object. |
Table 4.216. Return Values for TermIOS::setIFlag()
Return Type |
Description |
---|---|
n/a |
This method returns no value |
Sets the output mode flag for the object
TermIOS::setOFlag(oflag
)
Table 4.217. Arguments for TermIOS::setOFlag()
Argument |
Type |
Description |
---|---|---|
|
Integer |
The output mode to set for the object. |
Table 4.218. Return Values for TermIOS::setOFlag()
Return Type |
Description |
---|---|
n/a |
This method returns no value |
Returns the value of the control character corresponding to the argument passed.
TermIOS::getCC(cc
)
Table 4.219. Arguments for TermIOS::getCC()
Argument |
Type |
Description |
---|---|---|
| Integer | The control character to get from th object. |
Table 4.220. Return Values for TermIOS::getCC()
Return Type |
Description |
---|---|
Integer |
The value of the given control character. |
Sets the control character corresponding to the first argument to the value of the second argument.
TermIOS::setCC(cc, val
)
Table 4.221. Arguments for TermIOS::setCC()
Argument |
Type |
Description |
---|---|---|
|
Integer |
The control character to set. |
|
Integer |
The value to set |
Table 4.222. Return Values for TermIOS::setCC()
Return Type |
Description |
---|---|
n/a |
This method returns no value |
Returns True if the TermIOS object passed as an argument is equal to the current object; false if not. If the argument passed to this method is not a TermIOS object, an exception is raised
TermIOS::isEqual(termios
)
Table 4.223. Arguments for TermIOS::isEqual()
Argument |
Type |
Description |
---|---|---|
|
TermIOS |
The object to compare to the current object. |
Table 4.224. Return Values for TermIOS::isEqual()
Return Type |
Description |
---|---|
Boolean |
The result of comparing the current object to the argument |
Table 4.225. Exceptions thrown by TermIOS::isEqual()
err |
desc |
---|---|
|
argument passed is not a TermIOS object |
Returns a hash giving the current terminal window size in hash keys rows
and columns
.
TermIOS::getWindowSize()
$hash = TermIOS::getWindowSize()
Table 4.226. Arguments for TermIOS::getWindowSize()
Argument | Type | Description |
---|---|---|
n/a | n/a | This method takes no arguments. |
Table 4.227. Return Values for TermIOS::getWindowSize()
Return Type | Description |
---|---|
Hash | Returns a hash giving the current terminal window size in hash keys |