copy some methods from KPty - they are used only here, so they will be

deleted from kdelibs.

svn path=/trunk/KDE/kdebase/apps/konsole/; revision=676799
This commit is contained in:
Oswald Buddenhagen
2007-06-17 18:53:59 +00:00
parent b2ff3cd0dc
commit 87f3afcdd0
4 changed files with 60 additions and 19 deletions

View File

@@ -46,32 +46,57 @@ void Pty::donePty()
void Pty::setWindowSize(int lines, int cols)
{
pty()->setWinSize(lines, cols);
wsX = cols;
wsY = lines;
if (pty()->masterFd() >= 0)
pty()->setWinSize(lines, cols);
}
void Pty::setXonXoff(bool on)
{
pty()->setXonXoff(on);
xonXoff = on;
if (pty()->masterFd() >= 0)
{
struct ::termios ttmode;
pty()->tcGetAttr(&ttmode);
if (!on)
ttmode.c_iflag &= ~(IXOFF | IXON);
else
ttmode.c_iflag |= (IXOFF | IXON);
if (!pty()->tcSetAttr(&ttmode))
qWarning("Unable to set terminal attributes.");
}
}
void Pty::setUtf8Mode(bool on)
{
pty()->setUtf8Mode(on);
#ifdef IUTF8 // XXX not a reasonable place to check it.
utf8 = on;
if (pty()->masterFd() >= 0)
{
struct ::termios ttmode;
pty()->tcGetAttr(&ttmode);
if (!on)
ttmode.c_iflag &= ~IUTF8;
else
ttmode.c_iflag |= IUTF8;
if (!pty()->tcSetAttr(&ttmode))
qWarning("Unable to set terminal attributes.");
}
#endif
}
void Pty::setErase(char erase)
{
struct termios tios;
int fd = pty()->slaveFd();
if(tcgetattr(fd, &tios))
this->erase = erase;
if (pty()->masterFd() >= 0)
{
qWarning("Unable to get terminal attributes.");
return;
struct ::termios ttmode;
pty()->tcGetAttr(&ttmode);
ttmode.c_cc[VERASE] = erase;
if (!pty()->tcSetAttr(&ttmode))
qWarning("Unable to set terminal attributes.");
}
tios.c_cc[VERASE] = erase;
if(tcsetattr(fd, TCSANOW, &tios))
qWarning("Unable to set terminal attributes.");
}
int Pty::start(const QString& program,
@@ -101,6 +126,24 @@ int Pty::start(const QString& program,
setUsePty(All, addToUtmp);
pty()->open();
struct ::termios ttmode;
pty()->tcGetAttr(&ttmode);
if (!xonXoff)
ttmode.c_iflag &= ~(IXOFF | IXON);
else
ttmode.c_iflag |= (IXOFF | IXON);
#ifdef IUTF8 // XXX not a reasonable place to check it.
if (!utf8)
ttmode.c_iflag &= ~IUTF8;
else
ttmode.c_iflag |= IUTF8;
#endif
ttmode.c_cc[VERASE] = erase;
if (!pty()->tcSetAttr(&ttmode))
qWarning("Unable to set terminal attributes.");
pty()->setWinSize(wsY, wsX);
if ( K3Process::start(NotifyOnExit, (Communication) (Stdin | Stdout)) == false )
return -1;