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"
10 struct terminal_screen
;
11 struct terminal_interlink
;
14 /** The terminal type, meaningful for frames (lines) drawing. */
23 /** This is a bitmask describing the environment we are living in,
24 * terminal-wise. We can then conditionally use various features available
25 * in such an environment. */
27 /** This basically means that we can use the text i/o :). Always set. */
29 /** We are running in a xterm-compatible box in some windowing
32 /** We are running under a screen. */
34 /** We are running in a OS/2 VIO terminal. */
36 /** BeOS text terminal. */
38 /** We live in a TWIN text-mode windowing environment. */
40 /** Microsoft Windows cmdline thing. */
42 /** Match all terminal environments */
46 enum term_redrawing_state
{
47 TREDRAW_READY
= 0, /**< Can redraw */
48 TREDRAW_BUSY
= 1, /**< Redrawing already in progress */
49 TREDRAW_DELAYED
= 2, /**< Do not redraw for now */
52 /** This is one of the axis of ELinks' user interaction. struct terminal
53 * defines the terminal ELinks is running on --- each ELinks instance has
54 * one. It contains the basic terminal attributes, the settings associated
55 * with this terminal, screen content (and more abstract description of what
56 * is currently displayed on it) etc. It also maintains some runtime
57 * information about the actual ELinks instance owning this terminal.
59 * \todo TODO: Regroup the following into logical chunks. --pasky */
61 LIST_HEAD(struct terminal
); /*!< ::terminals is the sentinel. */
63 /** This is (at least partially) a stack of all the windows living in
64 * this terminal. A window can be wide range of stuff, from a menu box
65 * through classical dialog window to a tab. See terminal/window.h for
68 * Tabs are special windows, though, and you never want to display them
69 * all, but only one of them. ALWAYS check inactive_tab() during
70 * iterations through this list (unless it is really useless or you
71 * are sure what are you doing) to make sure that you don't distribute
72 * events etc to inactive tabs.
74 * The stack is top-down, thus @c .next is the stack's top, the
75 * current window; and @c .prev is the bottom, covered by others.
76 * - Dialogs or active menus are at the top.
77 * - Next come all tabs (window.type == ::WINDOW_TAB). The tab
78 * listed leftmost in the tab bar is at the top, and the tab
79 * listed rightmost is at the bottom; but #current_tab controls
80 * which tab is actually displayed.
81 * - If the main menu is inactive, then it is at the very bottom,
82 * hidden under the tabs.
83 * Call assert_window_stacking() to verify this.
85 * @todo FIXME: Tabs violate the stack nature of this list, they
86 * appear there randomly but always in the order in which they were
87 * inserted there. Eventually, they should all live at the stack
88 * bottom, with the actual tab living on the VERY bottom. --pasky
90 * Keeping the current tab at the very bottom would require storing
91 * tab numbers explicitly, rather than computing them from the
92 * stack order as is done now. Also, what should be done with the
93 * inactive main menu? --KON */
94 LIST_OF(struct window
) windows
;
96 /** The specification of terminal in terms of terminal options. */
99 /** This is the terminal's current title, as perhaps displayed
100 * somewhere in the X window frame or so. */
101 unsigned char *title
;
103 /** This is the screen. See terminal/screen.h */
104 struct terminal_screen
*screen
;
106 /** This is for displaying main menu */
107 struct menu
*main_menu
;
109 /** These are pipes for communication with the ELinks instance owning
111 * @see struct itrm */
114 /** This indicates that the terminal is blocked, that is nothing should
115 * be drawn on it etc. Typically an external program is running on it
116 * right now. This is a file descriptor. */
119 /** Terminal dimensions. */
122 /** Indicates whether we are currently in the process of redrawing the
123 * stuff being displayed on the terminal. It is typically used to
124 * prevent redrawing inside of redrawing. */
125 enum term_redrawing_state redrawing
;
127 /** Indicates the master terminal, that is the terminal under
128 * supervision of the master ELinks instance (the one doing all the
129 * work and even maintaining these structures ;-). */
130 unsigned int master
:1;
133 /** Indicates whether the charset of the terminal is UTF-8. */
134 unsigned int utf8_cp
:1;
136 /** Indicates whether UTF-8 I/O is used. Forced on if the
137 * UTF-8 charset is selected. (bug 827) */
138 unsigned int utf8_io
:1;
139 #endif /* CONFIG_UTF8 */
141 /** The current tab number. */
145 /** Current length of leds part of status bar. */
149 /** The type of environment this terminal lives in. */
150 enum term_env_type environment
;
152 /** The current working directory for this terminal / ELinks instance. */
153 unsigned char cwd
[MAX_CWD_LEN
];
155 /** For communication between instances */
156 struct terminal_interlink
*interlink
;
158 struct term_event_mouse prev_mouse_event
;
161 #define do_not_ignore_next_mouse_event(term) \
162 memset(&(term)->prev_mouse_event, 0, sizeof((term)->prev_mouse_event))
164 /** We keep track about all the terminals in this list. */
165 extern LIST_OF(struct terminal
) terminals
;
168 extern const unsigned char frame_dumb
[];
170 struct terminal
*init_term(int, int);
171 void destroy_terminal(struct terminal
*);
172 void redraw_terminal(struct terminal
*term
);
173 void redraw_terminal_cls(struct terminal
*term
);
174 void cls_redraw_all_terminals(void);
176 void redraw_all_terminals(void);
177 void destroy_all_terminals(void);
178 void exec_thread(unsigned char *, int);
179 void close_handle(void *);
181 /** Operations that can be requested with do_terminal_function().
182 * The interlink protocol passes these values as one byte in a
183 * null-terminated string, so zero cannot be used. */
189 /** How to execute a program in a terminal. These values are used in
190 * the interlink protocol and must fit in one byte. */
192 /** Execute in the background. ELinks keeps using the terminal
193 * and the program should not use it. */
196 /** Execute in the foreground. The program may use the terminal.
197 * ELinks will redraw when the program exits. */
200 /** Execute in the background and in a new process group. */
204 void exec_on_terminal(struct terminal
*, unsigned char *, unsigned char *, enum term_exec
);
205 void exec_shell(struct terminal
*term
);
207 void set_terminal_title(struct terminal
*, unsigned char *);
208 void do_terminal_function(struct terminal
*, unsigned char, unsigned char *);
210 int check_terminal_pipes(void);
211 void close_terminal_pipes(void);
212 struct terminal
*attach_terminal(int in
, int out
, int ctl
, void *info
, int len
);
214 extern struct module terminal_module
;
216 #endif /* EL__TERMINAL_TERMINAL_H */