KPty 5.109.0
kpty.h
1/*
2 This file is part of the KDE libraries
3 SPDX-FileCopyrightText: 2003, 2007 Oswald Buddenhagen <ossi@kde.org>
4 SPDX-FileCopyrightText: 2022 Harald Sitter <sitter@kde.org>
5
6 SPDX-License-Identifier: LGPL-2.0-or-later
7*/
8
9#ifndef kpty_h
10#define kpty_h
11
12#include "kpty_export.h"
13
14#include <qglobal.h>
15
16#include <memory>
17
18class KPtyPrivate;
19struct termios;
20
25class KPTY_EXPORT KPty
26{
27 Q_DECLARE_PRIVATE(KPty)
28
29public:
34
42
43 KPty(const KPty &) = delete;
44 KPty &operator=(const KPty &) = delete;
45
51 bool open();
52
61 bool open(int fd);
62
66 void close();
67
80 void closeSlave();
81
89 bool openSlave();
90
102 void setCTtyEnabled(bool enable);
103
108 void setCTty();
109
120 void login(const char *user = nullptr, const char *remotehost = nullptr);
121
125 void logout();
126
140 bool tcGetAttr(struct ::termios *ttmode) const;
141
151 bool tcSetAttr(struct ::termios *ttmode);
152
167 bool setWinSize(int lines, int columns, int height, int width);
168
174 bool setWinSize(int lines, int columns);
175
188 bool setEcho(bool echo);
189
195 const char *ttyName() const;
196
202 int masterFd() const;
203
209 int slaveFd() const;
210
211protected:
215 KPTY_NO_EXPORT explicit KPty(KPtyPrivate *d);
216
220 std::unique_ptr<KPtyPrivate> const d_ptr;
221};
222
223#endif
Provides primitives for opening & closing a pseudo TTY pair, assigning the controlling TTY,...
Definition kpty.h:26
~KPty()
Destructor:
void setCTtyEnabled(bool enable)
Whether this will be a controlling terminal.
void setCTty()
Creates a new session and process group and makes this pty the controlling tty.
int masterFd() const
void login(const char *user=nullptr, const char *remotehost=nullptr)
Creates an utmp entry for the tty.
bool setWinSize(int lines, int columns, int height, int width)
Change the logical (screen) size of the pty.
bool setEcho(bool echo)
Set whether the pty should echo input.
bool open()
Create a pty master/slave pair.
bool tcGetAttr(struct ::termios *ttmode) const
Wrapper around tcgetattr(3).
void closeSlave()
Close the pty slave descriptor.
void logout()
Removes the utmp entry for this tty.
const char * ttyName() const
bool tcSetAttr(struct ::termios *ttmode)
Wrapper around tcsetattr(3) with mode TCSANOW.
bool setWinSize(int lines, int columns)
This is an overloaded member function, provided for convenience. It differs from the above function o...
KPty()
Constructor.
bool open(int fd)
Open using an existing pty master.
int slaveFd() const
void close()
Close the pty master/slave pair.
bool openSlave()
Open the pty slave descriptor.