#include <errno.h>
#include <stdlib.h>
#include <fcntl.h>
-#ifdef USE_PTY
-#include <pty.h>
-#endif
#include <stdio.h>
#include <string.h>
+#include <sys/ioctl.h>
#include "madtty.h"
#include "roteprivate.h"
/* allocate private data */
rt->pd = (RoteTermPrivate*)calloc(sizeof(RoteTermPrivate), 1);
- rt->pd->pty = -1; /* no pty for now */
+ rt->pty = -1; /* no pty for now */
/* initial scrolling area is the whole window */
rt->pd->scrolltop = 0;
return 0;
}
-
-#ifdef USE_PTY
-
pid_t rote_vt_forkpty(RoteTerm *rt, const char *path, const char *argv[])
{
struct winsize ws;
ws.ws_col = rt->cols;
ws.ws_xpixel = ws.ws_ypixel = 0;
- if (run_process(path, argv, &rt->pd->pty, &rt->childpid)) {
+ if (run_process(path, argv, &rt->pty, &rt->childpid)) {
return -1;
}
- ioctl(rt->pd->pty, TIOCSWINSZ, &ws);
+ ioctl(rt->pty, TIOCSWINSZ, &ws);
return rt->childpid;
}
void rote_vt_forsake_child(RoteTerm *rt)
{
- if (rt->pd->pty >= 0)
- close(rt->pd->pty);
- rt->pd->pty = -1;
+ if (rt->pty >= 0)
+ close(rt->pty);
+ rt->pty = -1;
rt->childpid = 0;
}
-#endif
-
void rote_vt_update(RoteTerm *rt)
{
char buf[512];
int rote_vt_read(RoteTerm *rt, char *buf, int buflen)
{
- if (rt->pd->pty < 0) {
+ if (rt->pty < 0) {
errno = EINVAL;
return -1;
}
- return read(rt->pd->pty, buf, buflen);
+ return read(rt->pty, buf, buflen);
}
void rote_vt_write(RoteTerm *rt, const char *data, int len)
{
- if (rt->pd->pty < 0) {
+ if (rt->pty < 0) {
/* no pty, so just inject the data plain and simple */
rote_vt_inject(rt, data, len);
return;
/* write data to pty. Keep calling write() until we have written
* everything. */
while (len > 0) {
- int byteswritten = write(rt->pd->pty, data, len);
+ int byteswritten = write(rt->pty, data, len);
if (byteswritten < 0) {
/* very ugly way to inform the error. Improvements welcome! */
static char errormsg[] = "\n(ROTE: pty write() error)\n";
}
}
-int rote_vt_get_pty_fd(RoteTerm *rt)
-{
- return rt->pd->pty;
-}
-
static const char *keytable[KEY_MAX+1];
static void keytable_init()