1 #ifndef EL__TERMINAL_TERMINAL_H
2 #define EL__TERMINAL_TERMINAL_H
4 #include "config/options.h"
5 #include "terminal/event.h"
6 #include "util/lists.h"
9 struct terminal_screen
;
10 struct terminal_interlink
;
13 /* The terminal type, meaningful for frames (lines) drawing. */
22 /* This is a bitmask describing the environment we are living in,
23 * terminal-wise. We can then conditionally use various features available
24 * in such an environment. */
26 /* This basically means that we can use the text i/o :). Always set. */
28 /* We are running in a xterm-compatible box in some windowing
31 /* We are running under a screen. */
33 /* We are running in a OS/2 VIO terminal. */
35 /* BeOS text terminal. */
37 /* We live in a TWIN text-mode windowing environment. */
39 /* Microsoft Windows cmdline thing. */
41 /* Match all terminal environments */
45 enum term_redrawing_state
{
46 TREDRAW_READY
= 0, /* Can redraw */
47 TREDRAW_BUSY
= 1, /* Redrawing already in progress */
48 TREDRAW_DELAYED
= 2, /* Do not redraw for now */
51 /* This is one of the axis of ELinks' user interaction. {struct terminal}
52 * defines the terminal ELinks is running on --- each ELinks instance has
53 * one. It contains the basic terminal attributes, the settings associated
54 * with this terminal, screen content (and more abstract description of what
55 * is currently displayed on it) etc. It also maintains some runtime
56 * information about the actual ELinks instance owning this terminal. */
57 /* TODO: Regroup the following into logical chunks. --pasky */
59 LIST_HEAD(struct terminal
); /* {terminals} */
61 /* This is (at least partially) a stack of all the windows living in
62 * this terminal. A window can be wide range of stuff, from a menu box
63 * through classical dialog window to a tab. See terminal/window.h for
66 * Tabs are special windows, though, and you never want to display them
67 * all, but only one of them. ALWAYS check {inactive_tab} during
68 * iterations through this list (unless it is really useless or you
69 * are sure what are you doing) to make sure that you don't distribute
70 * events etc to inactive tabs.
72 * The stack is top-down, thus .next is the stack's top, the current
73 * window. .prev is the first tab.
75 * FIXME: Tabs violate the stack nature of this list, they appear there
76 * randomly but always in the order in which they were inserted there.
77 * Eventually, they should all live at the stack bottom, with the
78 * actual tab living on the VERY bottom. --pasky */
79 struct list_head windows
; /* {struct window} */
81 /* The specification of terminal in terms of terminal options. */
84 /* This is the terminal's current title, as perhaps displayed somewhere
85 * in the X window frame or so. */
88 /* This is the screen. See terminal/screen.h */
89 struct terminal_screen
*screen
;
91 /* These are pipes for communication with the ELinks instance owning
95 /* This indicates that the terminal is blocked, that is nothing should
96 * be drawn on it etc. Typically an external program is running on it
97 * right now. This is a file descriptor. */
100 /* Terminal dimensions. */
103 /* Indicates whether we are currently in the process of redrawing the
104 * stuff being displayed on the terminal. It is typically used to
105 * prevent redrawing inside of redrawing. */
106 enum term_redrawing_state redrawing
;
108 /* Indicates the master terminal, that is the terminal under
109 * supervision of the master ELinks instance (the one doing all the
110 * work and even maintaining these structures ;-). */
111 unsigned int master
:1;
113 /* The current tab number. */
117 /* Current length of leds part of status bar. */
121 /* The type of environment this terminal lives in. */
122 enum term_env_type environment
;
124 /* The current working directory for this terminal / ELinks instance. */
125 unsigned char cwd
[MAX_CWD_LEN
];
127 /* For communication between instances */
128 struct terminal_interlink
*interlink
;
130 struct term_event_mouse prev_mouse_event
;
133 #define do_not_ignore_next_mouse_event(term) \
134 memset(&(term)->prev_mouse_event, 0, sizeof((term)->prev_mouse_event))
136 /* We keep track about all the terminals in this list. */
137 extern struct list_head terminals
;
140 extern unsigned char frame_dumb
[];
142 struct terminal
*init_term(int, int);
143 void destroy_terminal(struct terminal
*);
144 void redraw_terminal(struct terminal
*term
);
145 void redraw_terminal_cls(struct terminal
*term
);
146 void cls_redraw_all_terminals(void);
148 void redraw_all_terminals(void);
149 void destroy_all_terminals(void);
150 void exec_thread(unsigned char *, int);
151 void close_handle(void *);
153 #define TERM_FN_TITLE 1
154 #define TERM_FN_RESIZE 2
156 void exec_on_terminal(struct terminal
*, unsigned char *, unsigned char *, int);
157 void exec_shell(struct terminal
*term
);
159 void set_terminal_title(struct terminal
*, unsigned char *);
160 void do_terminal_function(struct terminal
*, unsigned char, unsigned char *);
162 int check_terminal_pipes(void);
163 void close_terminal_pipes(void);
164 struct terminal
*attach_terminal(int in
, int out
, int ctl
, void *info
, int len
);
166 #endif /* EL__TERMINAL_TERMINAL_H */