| 1 | /* Define screen-object for GNU Emacs. |
| 2 | Copyright (C) 1988 Free Software Foundation, Inc. |
| 3 | |
| 4 | This file is part of GNU Emacs. |
| 5 | |
| 6 | GNU Emacs is free software; you can redistribute it and/or modify |
| 7 | it under the terms of the GNU General Public License as published by |
| 8 | the Free Software Foundation; either version 1, or (at your option) |
| 9 | any later version. |
| 10 | |
| 11 | GNU Emacs is distributed in the hope that it will be useful, |
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | GNU General Public License for more details. |
| 15 | |
| 16 | You should have received a copy of the GNU General Public License |
| 17 | along with GNU Emacs; see the file COPYING. If not, write to |
| 18 | the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ |
| 19 | |
| 20 | |
| 21 | #ifdef MULTI_SCREEN |
| 22 | |
| 23 | enum output_method |
| 24 | { output_termcap, output_x_window }; |
| 25 | |
| 26 | struct screen |
| 27 | { |
| 28 | int size; |
| 29 | struct Lisp_Vector *next; |
| 30 | |
| 31 | /* glyphs as they appear on the screen */ |
| 32 | struct screen_glyphs *current_glyphs; |
| 33 | |
| 34 | /* glyphs we'd like to appear on the screen */ |
| 35 | struct screen_glyphs *desired_glyphs; |
| 36 | |
| 37 | /* Cost of inserting 1 line on this screen */ |
| 38 | int *insert_line_cost; |
| 39 | |
| 40 | /* Cost of deleting 1 line on this screen */ |
| 41 | int *delete_line_cost; |
| 42 | |
| 43 | /* Cost of inserting n lines on this screen */ |
| 44 | int *insert_n_lines_cost; |
| 45 | |
| 46 | /* Cost of deleting n lines on this screen */ |
| 47 | int *delete_n_lines_cost; |
| 48 | |
| 49 | /* glyphs for the mode line */ |
| 50 | struct screen_glyphs *temp_glyphs; |
| 51 | |
| 52 | /* Intended cursor position of this screen. |
| 53 | Measured in characters, counting from upper left corner |
| 54 | within the screen. */ |
| 55 | int cursor_x; |
| 56 | int cursor_y; |
| 57 | |
| 58 | /* Actual cursor position of this screen, and the character under it. |
| 59 | (Not used for terminal screens.) */ |
| 60 | int phys_cursor_x; |
| 61 | int phys_cursor_y; |
| 62 | /* This is handy for undrawing the cursor, because current_glyphs is |
| 63 | not always accurate when in do_scrolling. */ |
| 64 | GLYPH phys_cursor_glyph; |
| 65 | |
| 66 | /* Size of this screen, in units of characters. */ |
| 67 | int height; |
| 68 | int width; |
| 69 | |
| 70 | /* New height and width for pending size change. 0 if no change pending. */ |
| 71 | int new_height, new_width; |
| 72 | |
| 73 | /* Name of this screen: a Lisp string. */ |
| 74 | Lisp_Object name; |
| 75 | |
| 76 | /* The screen which should recieve keystrokes that occur in this |
| 77 | screen. This is usually the screen itself, but if the screen is |
| 78 | minibufferless, this points to the minibuffer screen when it is |
| 79 | active. */ |
| 80 | Lisp_Object focus_screen; |
| 81 | |
| 82 | /* This screen's root window. Every screen has one. |
| 83 | If the screen has only a minibuffer window, this is it. |
| 84 | Otherwise, if the screen has a minibuffer window, this is its sibling. */ |
| 85 | Lisp_Object root_window; |
| 86 | |
| 87 | /* This screen's selected window. |
| 88 | Each screen has its own window hierarchy |
| 89 | and one of the windows in it is selected within the screen. |
| 90 | The selected window of the selected screen is Emacs's selected window. */ |
| 91 | Lisp_Object selected_window; |
| 92 | |
| 93 | /* This screen's minibuffer window. |
| 94 | Most screens have their own minibuffer windows, |
| 95 | but only the selected screen's minibuffer window |
| 96 | can actually appear to exist. */ |
| 97 | Lisp_Object minibuffer_window; |
| 98 | |
| 99 | /* Parameter alist of this screen. |
| 100 | These are the parameters specified when creating the screen |
| 101 | or modified with modify-screen-parameters. */ |
| 102 | Lisp_Object param_alist; |
| 103 | |
| 104 | /* The output method says how the contents of this screen |
| 105 | are displayed. It could be using termcap, or using an X window. */ |
| 106 | enum output_method output_method; |
| 107 | |
| 108 | /* A structure of auxiliary data used for displaying the contents. |
| 109 | struct x_display is used for X window screens; |
| 110 | it is defined in xterm.h. */ |
| 111 | union display { struct x_display *x; int nothing; } display; |
| 112 | |
| 113 | /* Nonzero if last attempt at redisplay on this screen was preempted. */ |
| 114 | char display_preempted; |
| 115 | |
| 116 | /* Nonzero if screen is currently displayed. */ |
| 117 | char visible; |
| 118 | |
| 119 | /* Nonzero if window is currently iconified. |
| 120 | This and visible are mutually exclusive. */ |
| 121 | char iconified; |
| 122 | |
| 123 | /* Nonzero if this screen should be redrawn. */ |
| 124 | char garbaged; |
| 125 | |
| 126 | /* True if screen actually has a minibuffer window on it. |
| 127 | 0 if using a minibuffer window that isn't on this screen. */ |
| 128 | char has_minibuffer; |
| 129 | |
| 130 | /* 0 means, if this screen has just one window, |
| 131 | show no modeline for that window. */ |
| 132 | char wants_modeline; |
| 133 | |
| 134 | /* Non-0 means raise this screen to the top of the heap when selected. */ |
| 135 | char auto_raise; |
| 136 | |
| 137 | /* Non-0 means lower this screen to the bottom of the stack when left. */ |
| 138 | char auto_lower; |
| 139 | |
| 140 | /* True if screen's root window can't be split. */ |
| 141 | char no_split; |
| 142 | |
| 143 | /* Storage for messages to this screen. */ |
| 144 | char *message_buf; |
| 145 | |
| 146 | /* Nonnegative if current redisplay should not do scroll computation |
| 147 | for lines beyond a certain vpos. This is the vpos. */ |
| 148 | int scroll_bottom_vpos; |
| 149 | }; |
| 150 | |
| 151 | typedef struct screen *SCREEN_PTR; |
| 152 | |
| 153 | #define XSCREEN(p) ((struct screen *) XPNTR (p)) |
| 154 | #define XSETSCREEN(p, v) ((struct screen *) XSETPNTR (p, v)) |
| 155 | |
| 156 | #define WINDOW_SCREEN(w) (w)->screen |
| 157 | |
| 158 | #define SCREENP(s) (XTYPE(s) == Lisp_Screen) |
| 159 | #define SCREEN_LIVE_P(s) ((s)->display.nothing != 0) |
| 160 | #define SET_SCREEN_GARBAGED(s) (screen_garbaged = 1, s->garbaged = 1) |
| 161 | #define SCREEN_IS_TERMCAP(s) ((s)->output_method == output_termcap) |
| 162 | #define SCREEN_IS_X(s) ((s)->output_method == output_x_window) |
| 163 | #define SCREEN_MINIBUF_ONLY_P(s) \ |
| 164 | EQ (SCREEN_ROOT_WINDOW (s), SCREEN_MINIBUF_WINDOW (s)) |
| 165 | #define SCREEN_HAS_MINIBUF(s) ((s)->has_minibuffer) |
| 166 | #define SCREEN_CURRENT_GLYPHS(s) (s)->current_glyphs |
| 167 | #define SCREEN_DESIRED_GLYPHS(s) (s)->desired_glyphs |
| 168 | #define SCREEN_TEMP_GLYPHS(s) (s)->temp_glyphs |
| 169 | #define SCREEN_HEIGHT(s) (s)->height |
| 170 | #define SCREEN_WIDTH(s) (s)->width |
| 171 | #define SCREEN_NEW_HEIGHT(s) (s)->new_height |
| 172 | #define SCREEN_NEW_WIDTH(s) (s)->new_width |
| 173 | #define SCREEN_CURSOR_X(s) (s)->cursor_x |
| 174 | #define SCREEN_CURSOR_Y(s) (s)->cursor_y |
| 175 | #define SCREEN_VISIBLE_P(s) (s)->visible |
| 176 | #define SCREEN_GARBAGED_P(s) (s)->garbaged |
| 177 | #define SCREEN_NO_SPLIT_P(s) (s)->no_split |
| 178 | #define SCREEN_WANTS_MODELINE_P(s) (s)->wants_modeline |
| 179 | #define SCREEN_ICONIFIED_P(s) (s)->iconified |
| 180 | #define SCREEN_MINIBUF_WINDOW(s) (s)->minibuffer_window |
| 181 | #define SCREEN_ROOT_WINDOW(s) (s)->root_window |
| 182 | #define SCREEN_SELECTED_WINDOW(s) (s)->selected_window |
| 183 | #define SET_GLYPHS_SCREEN(glyphs,screen) ((glyphs)->screen = (screen)) |
| 184 | #define SCREEN_INSERT_COST(s) (s)->insert_line_cost |
| 185 | #define SCREEN_DELETE_COST(s) (s)->delete_line_cost |
| 186 | #define SCREEN_INSERTN_COST(s) (s)->insert_n_lines_cost |
| 187 | #define SCREEN_DELETEN_COST(s) (s)->delete_n_lines_cost |
| 188 | #define SCREEN_MESSAGE_BUF(s) (s)->message_buf |
| 189 | #define SCREEN_SCROLL_BOTTOM_VPOS(s) (s)->scroll_bottom_vpos |
| 190 | #define SCREEN_FOCUS_SCREEN(s) (s)->focus_screen |
| 191 | |
| 192 | #define CHECK_SCREEN(x, i) \ |
| 193 | { \ |
| 194 | if (! SCREENP (x)) \ |
| 195 | x = wrong_type_argument (Qscreenp, (x)); \ |
| 196 | } |
| 197 | |
| 198 | #define CHECK_LIVE_SCREEN(x, i) \ |
| 199 | { \ |
| 200 | if (! SCREENP (x) \ |
| 201 | || ! SCREEN_LIVE_P (XSCREEN (x))) \ |
| 202 | x = wrong_type_argument (Qlive_screen_p, (x)); \ |
| 203 | } |
| 204 | |
| 205 | extern Lisp_Object Qscreenp, Qlive_screen_p; |
| 206 | |
| 207 | extern struct screen *selected_screen; |
| 208 | extern struct screen *last_nonminibuf_screen; |
| 209 | |
| 210 | extern struct screen *make_terminal_screen (); |
| 211 | extern struct screen *make_screen (); |
| 212 | extern struct screen *make_minibuffer_screen (); |
| 213 | extern struct screen *make_screen_without_minibuffer (); |
| 214 | |
| 215 | extern Lisp_Object Vscreen_list; |
| 216 | extern Lisp_Object Vdefault_screen_alist; |
| 217 | |
| 218 | extern Lisp_Object Vterminal_screen; |
| 219 | \f |
| 220 | #else /* not MULTI_SCREEN */ |
| 221 | |
| 222 | /* These definitions are used in a single-screen version of Emacs. */ |
| 223 | |
| 224 | #define SCREEN_PTR int |
| 225 | |
| 226 | extern int selected_screen; |
| 227 | #define last_nonminibuf_screen selected_screen |
| 228 | |
| 229 | #define XSCREEN(s) selected_screen |
| 230 | #define WINDOW_SCREEN(w) selected_screen |
| 231 | |
| 232 | #define SCREENP(s) (XTYPE(s) == Lisp_Screen) |
| 233 | #define SCREEN_LIVE_P(s) 1 |
| 234 | #define SET_SCREEN_GARBAGED(s) (screen_garbaged = 1) |
| 235 | #define SCREEN_IS_TERMCAP(s) 1 |
| 236 | #define SCREEN_IS_X(s) 0 |
| 237 | #define SCREEN_IS_MINIBUF_ONLY(s) 0 |
| 238 | #define SCREEN_HAS_MINIBUF(s) 1 |
| 239 | #define SCREEN_CURRENT_GLYPHS(s) current_glyphs |
| 240 | #define SCREEN_DESIRED_GLYPHS(s) desired_glyphs |
| 241 | #define SCREEN_TEMP_GLYPHS(s) temp_glyphs |
| 242 | #define SCREEN_HEIGHT(s) screen_height |
| 243 | #define SCREEN_WIDTH(s) screen_width |
| 244 | #define SCREEN_NEW_HEIGHT(s) delayed_screen_height |
| 245 | #define SCREEN_NEW_WIDTH(s) delayed_screen_width |
| 246 | #define SCREEN_CURSOR_X(s) cursX |
| 247 | #define SCREEN_CURSOR_Y(s) cursY |
| 248 | #define SCREEN_VISIBLE_P(s) 1 |
| 249 | #define SCREEN_GARBAGED_P(s) screen_garbaged |
| 250 | #define SCREEN_NO_SPLIT_P(s) 0 |
| 251 | #define SCREEN_WANTS_MODELINE_P(s) 1 |
| 252 | #define SCREEN_ICONIFIED_P(s) 0 |
| 253 | #define SCREEN_MINIBUF_WINDOW(s) minibuf_window |
| 254 | #define SCREEN_ROOT_WINDOW(s) root_window |
| 255 | #define SCREEN_SELECTED_WINDOW(s) selected_window |
| 256 | #define SET_GLYPHS_SCREEN(glyphs,screen) |
| 257 | #define SCREEN_INSERT_COST(screen) insert_line_cost |
| 258 | #define SCREEN_DELETE_COST(screen) delete_line_cost |
| 259 | #define SCREEN_INSERTN_COST(screen) insert_n_lines_cost |
| 260 | #define SCREEN_DELETEN_COST(screen) delete_n_lines_cost |
| 261 | #define SCREEN_MESSAGE_BUF(s) message_buf |
| 262 | #define SCREEN_SCROLL_BOTTOM_VPOS(s) scroll_bottom_vpos |
| 263 | |
| 264 | #define CHECK_SCREEN(x, i) { ; } |
| 265 | |
| 266 | extern int screen_width, screen_height; |
| 267 | extern int cursX, cursY; |
| 268 | |
| 269 | #endif /* not MULTI_SCREEN */ |