2005-09-15 09:58:31 -04:00
|
|
|
#ifndef EL__TERMINAL_ITRM_H
|
|
|
|
#define EL__TERMINAL_ITRM_H
|
|
|
|
|
|
|
|
|
|
|
|
#define ITRM_OUT_QUEUE_SIZE 16384
|
|
|
|
#define ITRM_IN_QUEUE_SIZE 16
|
|
|
|
|
|
|
|
struct itrm_queue {
|
|
|
|
unsigned char *data;
|
2006-07-24 12:35:58 -04:00
|
|
|
|
|
|
|
/* The amount of data in the queue, in bytes. This may be
|
|
|
|
* less than the amount of memory allocated for the buffer;
|
|
|
|
* struct itrm_queue does not keep track of that, and has
|
|
|
|
* no global policy on whether the buffer can be resized. */
|
2005-09-15 09:58:31 -04:00
|
|
|
int len;
|
|
|
|
};
|
|
|
|
|
2006-07-24 12:35:58 -04:00
|
|
|
/* Things coming into an itrm, whether from the terminal or from the
|
|
|
|
* master. */
|
2005-09-15 09:58:31 -04:00
|
|
|
struct itrm_in {
|
2006-07-24 12:35:58 -04:00
|
|
|
/* A file descriptor for the standard input. In some ports,
|
|
|
|
* this is the terminal device itself; in others, this is a
|
|
|
|
* pipe from an input thread. In principle, the data format
|
|
|
|
* depends on the terminal. */
|
2005-09-15 09:58:31 -04:00
|
|
|
int std;
|
2006-07-24 12:35:58 -04:00
|
|
|
|
|
|
|
/* In a slave process, a file descriptor for a socket from
|
|
|
|
* which it reads data sent by the master process. The other
|
|
|
|
* end of the socket connection is terminal.fdout in the
|
2006-07-27 03:55:31 -04:00
|
|
|
* master process. The format of these data is almost the
|
|
|
|
* same as could be sent to the terminal (via itrm.out.std),
|
|
|
|
* but there are special commands that begin with a null byte.
|
2006-07-24 12:35:58 -04:00
|
|
|
*
|
2006-08-01 02:48:26 -04:00
|
|
|
* In the master process, @sock is the same as itrm.out.std,
|
|
|
|
* but nothing actually uses it. */
|
2005-09-15 09:58:31 -04:00
|
|
|
int sock;
|
2006-07-24 12:35:58 -04:00
|
|
|
|
|
|
|
/* A file descriptor for controlling the standard input. This
|
|
|
|
* is always the terminal device itself, thus the same as @std
|
|
|
|
* in some ports. ELinks doesn't read or write with this file
|
|
|
|
* descriptor; it only does things like tcsetattr. */
|
2005-09-15 09:58:31 -04:00
|
|
|
int ctl;
|
2006-07-24 12:35:58 -04:00
|
|
|
|
|
|
|
/* Bytes that have been received from @std but not yet
|
|
|
|
* converted to events. queue.data is allocated for
|
|
|
|
* ITRM_IN_QUEUE_SIZE bytes and never resized. The itrm
|
2006-07-28 08:40:00 -04:00
|
|
|
* layer cannot parse control sequences longer than that.
|
|
|
|
* Anything that modifies queue.len should also call
|
|
|
|
* unhandle_itrm_stdin() if the queue becomes full, or
|
|
|
|
* handle_itrm_stdin() if the queue stops being full.
|
|
|
|
* Those functions are internal to kbd.c. */
|
2005-09-15 09:58:31 -04:00
|
|
|
struct itrm_queue queue;
|
|
|
|
};
|
|
|
|
|
2006-07-24 12:35:58 -04:00
|
|
|
/* Things going out from an itrm, whether to the terminal or to the
|
|
|
|
* master. */
|
2005-09-15 09:58:31 -04:00
|
|
|
struct itrm_out {
|
2006-07-24 12:35:58 -04:00
|
|
|
/* A file descriptor for the standard output. In some ports,
|
|
|
|
* this is the terminal device itself; in others, this is a
|
2006-07-27 03:55:31 -04:00
|
|
|
* pipe to an output thread. The data format depends on the
|
|
|
|
* terminal in principle, but this has not yet been
|
|
|
|
* implemented; see bug 96. */
|
2005-09-15 09:58:31 -04:00
|
|
|
int std;
|
2006-07-24 12:35:58 -04:00
|
|
|
|
|
|
|
/* A file descriptor for a pipe or socket to which this
|
|
|
|
* process sends input events. The other end of the pipe or
|
|
|
|
* socket connection is terminal.fdin in the master process.
|
|
|
|
* If the connection is from the master process to itself, it
|
|
|
|
* uses a pipe; otherwise a socket. The events are formatted
|
2006-08-05 04:49:57 -04:00
|
|
|
* as struct interlink_event, but at the beginning of the
|
2006-07-27 03:55:31 -04:00
|
|
|
* connection, a struct terminal_info and extra data are also
|
2006-07-24 12:35:58 -04:00
|
|
|
* sent. */
|
2005-09-15 09:58:31 -04:00
|
|
|
int sock;
|
2006-07-24 12:35:58 -04:00
|
|
|
|
|
|
|
/* Bytes that should be written to @sock. They will be
|
|
|
|
* written when select() indicates the write won't block. To
|
|
|
|
* add data here, call itrm_queue_event(), which reallocates
|
|
|
|
* queue.data if appropriate. The size of this queue is
|
|
|
|
* unrelated to ITRM_OUT_QUEUE_SIZE. */
|
2005-09-15 09:58:31 -04:00
|
|
|
struct itrm_queue queue;
|
|
|
|
};
|
|
|
|
|
2006-07-24 12:35:58 -04:00
|
|
|
/* A connection between a terminal and a master ELinks process.
|
|
|
|
* Normally, only one struct itrm exists in each master or slave
|
|
|
|
* process, and the global pointer @ditrm (not declared here)
|
|
|
|
* points to it. */
|
2005-09-15 09:58:31 -04:00
|
|
|
struct itrm {
|
|
|
|
struct itrm_in in; /* Input */
|
|
|
|
struct itrm_out out; /* Output */
|
|
|
|
|
|
|
|
timer_id_T timer; /* ESC timeout timer */
|
|
|
|
struct termios t; /* For restoring original attributes */
|
|
|
|
void *mouse_h; /* Mouse handle */
|
|
|
|
unsigned char *orig_title; /* For restoring window title */
|
|
|
|
|
|
|
|
unsigned int blocked:1; /* Whether it was blocked */
|
|
|
|
unsigned int altscreen:1; /* Whether to use alternate screen */
|
|
|
|
unsigned int touched_title:1; /* Whether the term title was changed */
|
2006-07-27 03:55:31 -04:00
|
|
|
/* The @remote flag is not set in regular slave terminals.
|
|
|
|
* Instead, it means the itrm controls a preexisting terminal,
|
|
|
|
* and windows should not be displayed on the terminal of the
|
|
|
|
* itrm (but see bug 776: the master clears the terminal anyway);
|
|
|
|
* thus the terminal init and done strings are not sent. */
|
2005-09-15 09:58:31 -04:00
|
|
|
unsigned int remote:1; /* Whether it is a remote session */
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|