move-link-up-line: segfault when cursor was below last line.
[elinks.git] / src / terminal / window.h
blobe94da64b9476f2c1263fb847e84f366da2e62aaa
1 #ifndef EL__TERMINAL_WINDOW_H
2 #define EL__TERMINAL_WINDOW_H
4 #include "util/lists.h"
6 struct term_event;
7 struct terminal;
8 struct window;
10 enum window_type {
11 /** Normal windows.
12 * Used for things like dialogs. The default type when adding windows
13 * with add_window(). */
14 WINDOW_NORMAL,
16 /** Tab windows.
17 * Tabs are a separate session and has separate history, current
18 * document and action-in-progress .. basically a separate browsing
19 * state. */
20 WINDOW_TAB,
23 typedef void (window_handler_T)(struct window *, struct term_event *);
25 /** A window in the terminal screen. This structure does not know the
26 * position and size of the window, and no functions are provided for
27 * drawing into a window. Instead, when window.handler draws the
28 * window, it should decide the position and size of the window, and
29 * then draw directly to the terminal, taking care not to draw outside
30 * the window. Windows generally do not have their own coordinate
31 * systems; they get mouse events in the coordinate system of the
32 * terminal. */
33 struct window {
34 LIST_HEAD(struct window); /*!< terminal.windows is the sentinel. */
36 /** Whether this is a normal window or a tab window. */
37 enum window_type type;
39 /** The window event handler */
40 window_handler_T *handler;
42 /** For tab windows the session is stored in @c data.
43 * For normal windows it can contain dialog data.
44 * It is free()'d by delete_window() */
45 void *data;
47 /** The terminal (and screen) that hosts the window */
48 struct terminal *term;
50 /** For ::WINDOW_TAB, the position and size in the tab bar.
51 * Updated while the tab bar is being drawn, and read if the
52 * user clicks there with the mouse. */
53 int xpos, width;
55 /** The position of something that has focus in the window.
56 * Any popup menus are drawn near this position.
57 * In tab windows, during ::NAVIGATE_CURSOR_ROUTING, this is
58 * also the position of the cursor that the user can move;
59 * there is no separate cursor position for each frame.
60 * In dialog boxes, this is typically the top left corner of
61 * the focused widget, while the cursor is somewhere within
62 * the widget.
63 * @see set_window_ptr, get_parent_ptr, set_cursor */
64 int x, y;
66 /** For delayed tab resizing */
67 unsigned int resize:1;
70 void redraw_from_window(struct window *);
71 void redraw_below_window(struct window *);
72 void add_window(struct terminal *, window_handler_T, void *);
73 void delete_window(struct window *);
74 void delete_window_ev(struct window *, struct term_event *ev);
75 #define set_window_ptr(window, x_, y_) do { (window)->x = (x_); (window)->y = (y_); } while (0)
76 void get_parent_ptr(struct window *, int *, int *);
78 void add_empty_window(struct terminal *, void (*)(void *), void *);
80 #if CONFIG_DEBUG
81 void assert_window_stacking(struct terminal *);
82 #else
83 #define assert_window_stacking(t) ((void) (t))
84 #endif
86 #endif