1 #ifndef EL__TERMINAL_ITRM_H
2 #define EL__TERMINAL_ITRM_H
5 #define ITRM_OUT_QUEUE_SIZE 16384
7 /* Currently, ELinks treats control sequences as text if they are
8 * longer than ITRM_IN_QUEUE_SIZE bytes. So it should be defined
9 * as greater than the length of any control sequence that ELinks
10 * is expected to receive. These are the longest so far:
11 * VT420: "\E[?64;1;2;6;7;8;9;15;18;19;21c"
12 * VT510: "\E[?64;1;2;7;8;9;12;15;18;21;23;24;42;44;45;46c" */
13 #define ITRM_IN_QUEUE_SIZE 64
18 /* The amount of data in the queue, in bytes. This may be
19 * less than the amount of memory allocated for the buffer;
20 * struct itrm_queue does not keep track of that, and has
21 * no global policy on whether the buffer can be resized. */
25 /* Things coming into an itrm, whether from the terminal or from the
28 /* A file descriptor for the standard input. In some ports,
29 * this is the terminal device itself; in others, this is a
30 * pipe from an input thread. In principle, the data format
31 * depends on the terminal. */
34 /* In a slave process, a file descriptor for a socket from
35 * which it reads data sent by the master process. The other
36 * end of the socket connection is terminal.fdout in the
37 * master process. The format of these data is almost the
38 * same as could be sent to the terminal (via itrm.out.std),
39 * but there are special commands that begin with a null byte.
41 * In the master process, @sock is the same as itrm.out.std,
42 * but nothing actually uses it. */
45 /* A file descriptor for controlling the standard input. This
46 * is always the terminal device itself, thus the same as @std
47 * in some ports. ELinks doesn't read or write with this file
48 * descriptor; it only does things like tcsetattr. */
51 /* Bytes that have been received from @std but not yet
52 * converted to events. queue.data is allocated for
53 * ITRM_IN_QUEUE_SIZE bytes and never resized. The itrm
54 * layer cannot parse control sequences longer than that.
55 * Anything that modifies queue.len should also call
56 * unhandle_itrm_stdin() if the queue becomes full, or
57 * handle_itrm_stdin() if the queue stops being full.
58 * Those functions are internal to kbd.c. */
59 struct itrm_queue queue
;
62 /* Things going out from an itrm, whether to the terminal or to the
65 /* A file descriptor for the standard output. In some ports,
66 * this is the terminal device itself; in others, this is a
67 * pipe to an output thread. The data format depends on the
68 * terminal in principle, but this has not yet been
69 * implemented; see bug 96. */
72 /* A file descriptor for a pipe or socket to which this
73 * process sends input events. The other end of the pipe or
74 * socket connection is terminal.fdin in the master process.
75 * If the connection is from the master process to itself, it
76 * uses a pipe; otherwise a socket. The events are formatted
77 * as struct interlink_event, but at the beginning of the
78 * connection, a struct terminal_info and extra data are also
82 /* Bytes that should be written to @sock. They will be
83 * written when select() indicates the write won't block. To
84 * add data here, call itrm_queue_event(), which reallocates
85 * queue.data if appropriate. The size of this queue is
86 * unrelated to ITRM_OUT_QUEUE_SIZE. */
87 struct itrm_queue queue
;
90 /* A connection between a terminal and a master ELinks process.
91 * Normally, only one struct itrm exists in each master or slave
92 * process, and the global pointer @ditrm (not declared here)
95 struct itrm_in in
; /* Input */
96 struct itrm_out out
; /* Output */
98 timer_id_T timer
; /* ESC timeout timer */
99 struct termios t
; /* For restoring original attributes */
100 void *mouse_h
; /* Mouse handle */
101 unsigned char *orig_title
; /* For restoring window title */
103 unsigned int blocked
:1; /* Whether it was blocked */
104 unsigned int altscreen
:1; /* Whether to use alternate screen */
105 unsigned int touched_title
:1; /* Whether the term title was changed */
106 /* The @remote flag is not set in regular slave terminals.
107 * Instead, it means the itrm controls a preexisting terminal,
108 * and windows should not be displayed on the terminal of the
109 * itrm (but see bug 776: the master clears the terminal anyway);
110 * thus the terminal init and done strings are not sent. */
111 unsigned int remote
:1; /* Whether it is a remote session */