mirror of https://github.com/buggins/dlangide.git
ptty test
This commit is contained in:
parent
58fec37c25
commit
c3293a6d09
|
@ -181,7 +181,10 @@ class OutputPanel : DockWindow {
|
||||||
_terminalWidget.write("\x1b[34;45m blue on magenta "d);
|
_terminalWidget.write("\x1b[34;45m blue on magenta "d);
|
||||||
_terminalWidget.write("\x1b[31;46m red on cyan "d);
|
_terminalWidget.write("\x1b[31;46m red on cyan "d);
|
||||||
//_terminalWidget.write("\x1b[2Jerased screen"d);
|
//_terminalWidget.write("\x1b[2Jerased screen"d);
|
||||||
|
TerminalDevice term = new TerminalDevice();
|
||||||
|
if (!term.create()) {
|
||||||
|
Log.e("Cannot create terminal device");
|
||||||
|
}
|
||||||
return _tabs;
|
return _tabs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -654,3 +654,48 @@ class TerminalWidget : WidgetGroup, OnScrollHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class TerminalDevice {
|
||||||
|
int masterfd;
|
||||||
|
int slavefd;
|
||||||
|
string name;
|
||||||
|
void close() {
|
||||||
|
if (masterfd && masterfd != -1) {
|
||||||
|
import core.sys.posix.unistd;
|
||||||
|
close(masterfd);
|
||||||
|
masterfd = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
bool create() {
|
||||||
|
import std.string;
|
||||||
|
const(char) * s = null;
|
||||||
|
{
|
||||||
|
import core.sys.posix.fcntl;
|
||||||
|
import core.sys.posix.stdio;
|
||||||
|
import core.sys.posix.stdlib;
|
||||||
|
import core.sys.posix.unistd;
|
||||||
|
masterfd = posix_openpt(O_RDWR | O_NOCTTY);
|
||||||
|
if (masterfd == -1) {
|
||||||
|
Log.e("posix_openpt failed - cannot open terminal");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (grantpt(masterfd) == -1 || unlockpt(masterfd) == -1) {
|
||||||
|
Log.e("grantpt / unlockpt failed - cannot open terminal");
|
||||||
|
close(masterfd);
|
||||||
|
masterfd = 0;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
s = ptsname(masterfd);
|
||||||
|
if (!s) {
|
||||||
|
Log.e("ptsname failed - cannot open terminal");
|
||||||
|
close(masterfd);
|
||||||
|
masterfd = 0;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
name = fromStringz(s).dup;
|
||||||
|
Log.i("ptty device created: ", name);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue