The lw_terminal_parser should not hold the master file descriptor
This commit is contained in:
parent
098ab5d70f
commit
5da2786c14
|
@ -105,6 +105,14 @@ static int main_loop(struct vt100_headless *this)
|
|||
}
|
||||
}
|
||||
|
||||
void master_write(void *user_data, void *buffer, size_t len)
|
||||
{
|
||||
struct vt100_headless *this;
|
||||
|
||||
this = (struct vt100_headless*)user_data;
|
||||
write(this->master, buffer, len);
|
||||
}
|
||||
|
||||
void vt100_headless_fork(struct vt100_headless *this,
|
||||
const char *progname,
|
||||
char *const argv[])
|
||||
|
@ -125,9 +133,9 @@ void vt100_headless_fork(struct vt100_headless *this,
|
|||
}
|
||||
else
|
||||
{
|
||||
this->term = vt100_init(lw_terminal_default_unimplemented);
|
||||
this->term = vt100_init(this, lw_terminal_default_unimplemented);
|
||||
this->term->master_write = master_write;
|
||||
ioctl(this->master, TIOCSWINSZ, &winsize);
|
||||
this->term->lw_terminal->fd = this->master;
|
||||
main_loop(this);
|
||||
}
|
||||
restore_termios(this, 0);
|
||||
|
|
|
@ -192,7 +192,6 @@ struct lw_terminal
|
|||
void *user_data;
|
||||
void (*unimplemented)(struct lw_terminal*,
|
||||
char *seq, char chr);
|
||||
int fd;
|
||||
};
|
||||
|
||||
struct lw_terminal *lw_terminal_init(void);
|
||||
|
|
|
@ -448,7 +448,7 @@ static void DA(struct lw_terminal *term_emul)
|
|||
struct lw_terminal_vt100 *vt100;
|
||||
|
||||
vt100 = (struct lw_terminal_vt100 *)term_emul->user_data;
|
||||
write(term_emul->fd, "\033[?1;0c", 7); /* Do not write directly ? */
|
||||
vt100->master_write(vt100->user_data, "\033[?1;0c", 7);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -895,13 +895,15 @@ const char **vt100_getlines(struct lw_terminal_vt100 *vt100)
|
|||
return (const char **)vt100->lines;
|
||||
}
|
||||
|
||||
struct lw_terminal_vt100 *vt100_init(void (*unimplemented)(struct lw_terminal* term_emul, char *seq, char chr))
|
||||
struct lw_terminal_vt100 *vt100_init(void *user_data,
|
||||
void (*unimplemented)(struct lw_terminal* term_emul, char *seq, char chr))
|
||||
{
|
||||
struct lw_terminal_vt100 *this;
|
||||
|
||||
this = calloc(1, sizeof(*this));
|
||||
if (this == NULL)
|
||||
return NULL;
|
||||
this->user_data = user_data;
|
||||
this->height = 24;
|
||||
this->width = 80;
|
||||
this->screen = malloc(132 * SCROLLBACK * this->height);
|
||||
|
|
|
@ -62,9 +62,13 @@ struct lw_terminal_vt100
|
|||
unsigned int selected_charset;
|
||||
unsigned int modes;
|
||||
char *lines[80];
|
||||
void (*master_write)(void *user_data, void *buffer, size_t len);
|
||||
void *user_data;
|
||||
};
|
||||
|
||||
struct lw_terminal_vt100 *vt100_init(void (*unimplemented)(struct lw_terminal* term_emul, char *seq, char chr));
|
||||
struct lw_terminal_vt100 *vt100_init(void *user_data,
|
||||
void (*unimplemented)(struct lw_terminal* term_emul,
|
||||
char *seq, char chr));
|
||||
char vt100_get(struct lw_terminal_vt100 *vt100, unsigned int x, unsigned int y);
|
||||
const char **vt100_getlines(struct lw_terminal_vt100 *vt100);
|
||||
void lw_terminal_this_destroy(struct lw_terminal_vt100 *this);
|
||||
|
|
Loading…
Reference in New Issue