GNU Octave
3.8.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
|
Provides primitives for opening & closing a pseudo TTY pair, assigning the controlling TTY, utmp registration and setting various terminal attributes. More...
#include "kpty.h"
Public Member Functions | |
KPty () | |
Constructor. | |
KPty (int masterFd, int slaveFd) | |
~KPty () | |
Destructor: | |
void | close () |
Close the pty master/slave pair. | |
void | closeSlave () |
Close the pty slave descriptor. | |
int | masterFd () const |
bool | open () |
Create a pty master/slave pair. | |
bool | setEcho (bool echo) |
Set whether the pty should echo input. | |
bool | setWinSize (int lines, int columns) |
Change the logical (screen) size of the pty. | |
int | slaveFd () const |
bool | tcGetAttr (struct::termios *ttmode) const |
Wrapper around tcgetattr(3). | |
bool | tcSetAttr (struct::termios *ttmode) |
Wrapper around tcsetattr(3) with mode TCSANOW. | |
const char * | ttyName () const |
Protected Member Functions | |
KPty (KPtyPrivate *d) |
Protected Attributes | |
KPtyPrivate *const | d_ptr |
Provides primitives for opening & closing a pseudo TTY pair, assigning the controlling TTY, utmp registration and setting various terminal attributes.
KPty::~KPty | ( | ) |
|
protected |
Definition at line 194 of file kpty.cpp.
References d_ptr, and KPtyPrivate::q_ptr.
Close the pty master/slave pair.
Definition at line 396 of file kpty.cpp.
References closeSlave(), d, and stat().
Referenced by closeSlave(), open(), and ~KPty().
void KPty::closeSlave | ( | ) |
Close the pty slave descriptor.
When creating the pty, KPty also opens the slave and keeps it open. Consequently the master will never receive an EOF notification. Usually this is the desired behavior, as a closed pty slave can be reopened any time - unlike a pipe or socket. However, in some cases pipe-alike behavior might be desired.
After this function was called, slaveFd() and setCTty() cannot be used.
Definition at line 386 of file kpty.cpp.
Referenced by close().
int KPty::masterFd | ( | ) | const |
This function should be called only while the pty is open.
Definition at line 472 of file kpty.cpp.
References d.
Referenced by TerminalModel::sendData(), and TerminalModel::TerminalModel().
bool KPty::open | ( | ) |
Create a pty master/slave pair.
Definition at line 206 of file kpty.cpp.
References close(), d, PATH_MAX, stat(), tcGetAttr(), tcSetAttr(), and TTY_GROUP.
Referenced by QUnixTerminalImpl::initialize().
Set whether the pty should echo input.
Echo is on by default. If the output of automatically fed (non-interactive) PTY clients needs to be parsed, disabling echo often makes it much simpler.
This function can be used only while the PTY is open.
echo | true if input should be echoed. |
true
on success, false otherwise Definition at line 453 of file kpty.cpp.
References ECHO, tcGetAttr(), and tcSetAttr().
Change the logical (screen) size of the pty.
The default is 24 lines by 80 columns.
This function can be used only while the PTY is open.
lines | the number of rows |
columns | the number of columns |
true
on success, false otherwise Definition at line 442 of file kpty.cpp.
References d.
Referenced by TerminalModel::updateTerminalSize().
int KPty::slaveFd | ( | ) | const |
This function should be called only while the pty slave is open.
Definition at line 479 of file kpty.cpp.
References d.
Referenced by QUnixTerminalImpl::connectToPty().
bool KPty::tcGetAttr | ( | struct::termios * | ttmode | ) | const |
Wrapper around tcgetattr(3).
This function can be used only while the PTY is open. You will need an #include <termios.h> to do anything useful with it.
ttmode | a pointer to a termios structure. Note: when declaring ttmode, struct ::termios must be used - without the '::' some version of HP-UX thinks, this declares the struct in your class, in your method. |
true
on success, false otherwise Definition at line 428 of file kpty.cpp.
References _tcgetattr, and d.
bool KPty::tcSetAttr | ( | struct::termios * | ttmode | ) |
Wrapper around tcsetattr(3) with mode TCSANOW.
This function can be used only while the PTY is open.
ttmode | a pointer to a termios structure. |
true
on success, false otherwise. Note that success means that at least one attribute could be set. Definition at line 435 of file kpty.cpp.
References _tcsetattr, and d.
const char * KPty::ttyName | ( | ) | const |
|
protected |