frame.h 11.1 KB
Newer Older
Jim Blandy's avatar
Jim Blandy committed
1
/* Define screen-object for GNU Emacs.
Jim Blandy's avatar
Jim Blandy committed
2
   Copyright (C) 1988, 1992 Free Software Foundation, Inc.
Jim Blandy's avatar
Jim Blandy committed
3 4 5 6 7

This file is part of GNU Emacs.

GNU Emacs is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Jim Blandy's avatar
Jim Blandy committed
8
the Free Software Foundation; either version 2, or (at your option)
Jim Blandy's avatar
Jim Blandy committed
9 10 11 12 13 14 15 16 17 18 19 20
any later version.

GNU Emacs is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with GNU Emacs; see the file COPYING.  If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */


Jim Blandy's avatar
Jim Blandy committed
21 22 23 24 25 26
/* The structure representing a screen.

   We declare this even if MULTI_SCREEN is not defined, because when
   we lack multi-screen support, we use one instance of this structure
   to represent the one screen we support.  This is cleaner than
   having miscellaneous random variables scattered about.  */
Jim Blandy's avatar
Jim Blandy committed
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41

enum output_method
{ output_termcap, output_x_window };

struct screen
{
  int size;
  struct Lisp_Vector *next;

  /* glyphs as they appear on the screen */
  struct screen_glyphs *current_glyphs;

  /* glyphs we'd like to appear on the screen */
  struct screen_glyphs *desired_glyphs;

Jim Blandy's avatar
Jim Blandy committed
42
  /* See do_line_insertion_deletion_costs for info on these arrays. */
Jim Blandy's avatar
Jim Blandy committed
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
  /* Cost of inserting 1 line on this screen */
  int *insert_line_cost;
  /* Cost of deleting 1 line on this screen */
  int *delete_line_cost;
  /* Cost of inserting n lines on this screen */
  int *insert_n_lines_cost;
  /* Cost of deleting n lines on this screen */
  int *delete_n_lines_cost;

  /* glyphs for the mode line */
  struct screen_glyphs *temp_glyphs;

  /* Intended cursor position of this screen.
     Measured in characters, counting from upper left corner
     within the screen.  */
  int cursor_x;
  int cursor_y;

Jim Blandy's avatar
Jim Blandy committed
61
  /* Actual cursor position of this screen, and the character under it.
Jim Blandy's avatar
Jim Blandy committed
62 63 64
     (Not used for terminal screens.)  */
  int phys_cursor_x;
  int phys_cursor_y;
Jim Blandy's avatar
Jim Blandy committed
65 66 67
  /* This is handy for undrawing the cursor, because current_glyphs is
     not always accurate when in do_scrolling.  */
  GLYPH phys_cursor_glyph;
Jim Blandy's avatar
Jim Blandy committed
68 69 70 71 72 73 74 75 76 77 78

  /* Size of this screen, in units of characters.  */
  int height;
  int width;

  /* New height and width for pending size change.  0 if no change pending.  */
  int new_height, new_width;

  /* Name of this screen: a Lisp string.  */
  Lisp_Object name;

Jim Blandy's avatar
Jim Blandy committed
79 80 81 82 83 84
  /* The screen which should recieve keystrokes that occur in this
     screen.  This is usually the screen itself, but if the screen is
     minibufferless, this points to the minibuffer screen when it is
     active.  */
  Lisp_Object focus_screen;

Jim Blandy's avatar
Jim Blandy committed
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128
  /* This screen's root window.  Every screen has one.
     If the screen has only a minibuffer window, this is it.
     Otherwise, if the screen has a minibuffer window, this is its sibling.  */
  Lisp_Object root_window;

  /* This screen's selected window.
     Each screen has its own window hierarchy
     and one of the windows in it is selected within the screen.
     The selected window of the selected screen is Emacs's selected window.  */
  Lisp_Object selected_window;

  /* This screen's minibuffer window.
     Most screens have their own minibuffer windows,
     but only the selected screen's minibuffer window
     can actually appear to exist.  */
  Lisp_Object minibuffer_window;

  /* Parameter alist of this screen.
     These are the parameters specified when creating the screen
     or modified with modify-screen-parameters.  */
  Lisp_Object param_alist;

  /* The output method says how the contents of this screen
     are displayed.  It could be using termcap, or using an X window.  */
  enum output_method output_method;

  /* A structure of auxiliary data used for displaying the contents.
     struct x_display is used for X window screens;
     it is defined in xterm.h.  */
  union display { struct x_display *x; int nothing; } display;

  /* Nonzero if last attempt at redisplay on this screen was preempted.  */
  char display_preempted;

  /* Nonzero if screen is currently displayed.  */
  char visible;

  /* Nonzero if window is currently iconified.
     This and visible are mutually exclusive.  */
  char iconified;

  /* Nonzero if this screen should be redrawn.  */
  char garbaged;

Jim Blandy's avatar
Jim Blandy committed
129
  /* True if screen actually has a minibuffer window on it.
Jim Blandy's avatar
Jim Blandy committed
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153
     0 if using a minibuffer window that isn't on this screen.  */
  char has_minibuffer;
     
  /* 0 means, if this screen has just one window,
     show no modeline for that window.  */
  char wants_modeline;

  /* Non-0 means raise this screen to the top of the heap when selected.  */
  char auto_raise;

  /* Non-0 means lower this screen to the bottom of the stack when left.  */
  char auto_lower;

  /* True if screen's root window can't be split.  */
  char no_split;

  /* Storage for messages to this screen. */
  char *message_buf;

  /* Nonnegative if current redisplay should not do scroll computation
     for lines beyond a certain vpos.  This is the vpos.  */
  int scroll_bottom_vpos;
};

Jim Blandy's avatar
Jim Blandy committed
154 155
#ifdef MULTI_SCREEN

Jim Blandy's avatar
Jim Blandy committed
156 157 158 159 160 161 162
typedef struct screen *SCREEN_PTR;

#define XSCREEN(p) ((struct screen *) XPNTR (p))
#define XSETSCREEN(p, v) ((struct screen *) XSETPNTR (p, v))

#define WINDOW_SCREEN(w) (w)->screen

Jim Blandy's avatar
Jim Blandy committed
163 164
#define SCREENP(s) (XTYPE(s) == Lisp_Screen)
#define SCREEN_LIVE_P(s) ((s)->display.nothing != 0)
Jim Blandy's avatar
Jim Blandy committed
165 166
#define SCREEN_IS_TERMCAP(s) ((s)->output_method == output_termcap)
#define SCREEN_IS_X(s) ((s)->output_method == output_x_window)
Jim Blandy's avatar
Jim Blandy committed
167 168 169
#define SCREEN_MINIBUF_ONLY_P(s) \
  EQ (SCREEN_ROOT_WINDOW (s), SCREEN_MINIBUF_WINDOW (s))
#define SCREEN_HAS_MINIBUF(s) ((s)->has_minibuffer)
Jim Blandy's avatar
Jim Blandy committed
170 171 172 173 174 175 176 177 178 179
#define SCREEN_CURRENT_GLYPHS(s) (s)->current_glyphs
#define SCREEN_DESIRED_GLYPHS(s) (s)->desired_glyphs
#define SCREEN_TEMP_GLYPHS(s) (s)->temp_glyphs
#define SCREEN_HEIGHT(s) (s)->height
#define SCREEN_WIDTH(s) (s)->width
#define SCREEN_NEW_HEIGHT(s) (s)->new_height
#define SCREEN_NEW_WIDTH(s) (s)->new_width
#define SCREEN_CURSOR_X(s) (s)->cursor_x
#define SCREEN_CURSOR_Y(s) (s)->cursor_y
#define SCREEN_VISIBLE_P(s) (s)->visible
Jim Blandy's avatar
Jim Blandy committed
180
#define SET_SCREEN_GARBAGED(s) (screen_garbaged = 1, s->garbaged = 1)
Jim Blandy's avatar
Jim Blandy committed
181 182 183 184 185 186 187 188 189 190 191 192 193 194
#define SCREEN_GARBAGED_P(s) (s)->garbaged
#define SCREEN_NO_SPLIT_P(s) (s)->no_split
#define SCREEN_WANTS_MODELINE_P(s) (s)->wants_modeline
#define SCREEN_ICONIFIED_P(s) (s)->iconified
#define SCREEN_MINIBUF_WINDOW(s) (s)->minibuffer_window
#define SCREEN_ROOT_WINDOW(s) (s)->root_window
#define SCREEN_SELECTED_WINDOW(s) (s)->selected_window
#define SET_GLYPHS_SCREEN(glyphs,screen) ((glyphs)->screen = (screen))
#define SCREEN_INSERT_COST(s) (s)->insert_line_cost    
#define SCREEN_DELETE_COST(s) (s)->delete_line_cost    
#define SCREEN_INSERTN_COST(s) (s)->insert_n_lines_cost
#define SCREEN_DELETEN_COST(s) (s)->delete_n_lines_cost
#define SCREEN_MESSAGE_BUF(s) (s)->message_buf
#define SCREEN_SCROLL_BOTTOM_VPOS(s) (s)->scroll_bottom_vpos
Jim Blandy's avatar
Jim Blandy committed
195
#define SCREEN_FOCUS_SCREEN(s) (s)->focus_screen
Jim Blandy's avatar
Jim Blandy committed
196

Jim Blandy's avatar
Jim Blandy committed
197 198 199 200 201 202 203 204 205 206 207 208 209
#define CHECK_SCREEN(x, i)				\
  {							\
    if (! SCREENP (x))					\
      x = wrong_type_argument (Qscreenp, (x));		\
  }

#define CHECK_LIVE_SCREEN(x, i)				\
  {							\
    if (! SCREENP (x)					\
	|| ! SCREEN_LIVE_P (XSCREEN (x)))		\
      x = wrong_type_argument (Qlive_screen_p, (x));	\
  }

Jim Blandy's avatar
Jim Blandy committed
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225
/* FOR_EACH_SCREEN (LIST_VAR, SCREEN_VAR) followed by a statement is a
   `for' loop which iterates over the elements of Vscreen_list.  The
   loop will set SCREEN_VAR, a SCREEN_PTR, to each screen in
   Vscreen_list in succession and execute the statement.  LIST_VAR
   should be a Lisp_Object; it is used to iterate through the
   Vscreen_list.  

   If MULTI_SCREEN isn't defined, then this loop expands to something which 
   executes the statement once.  */
#define FOR_EACH_SCREEN(list_var, screen_var)			\
  for ((list_var) = Vscreen_list;				\
       (CONSP (list_var)					\
	&& (screen_var = XSCREEN (XCONS (list_var)->car), 1));	\
       list_var = XCONS (list_var)->cdr)


Jim Blandy's avatar
Jim Blandy committed
226
extern Lisp_Object Qscreenp, Qlive_screen_p;
Jim Blandy's avatar
Jim Blandy committed
227 228

extern struct screen *selected_screen;
Jim Blandy's avatar
Jim Blandy committed
229
extern struct screen *last_nonminibuf_screen;
Jim Blandy's avatar
Jim Blandy committed
230 231 232 233 234 235

extern struct screen *make_terminal_screen ();
extern struct screen *make_screen ();
extern struct screen *make_minibuffer_screen ();
extern struct screen *make_screen_without_minibuffer ();

Jim Blandy's avatar
Jim Blandy committed
236 237 238 239
/* Nonzero means SCREEN_MESSAGE_BUF (selected_screen) is being used by
   print.  */
extern int message_buf_print;

Jim Blandy's avatar
Jim Blandy committed
240
extern Lisp_Object Vscreen_list;
Jim Blandy's avatar
Jim Blandy committed
241
extern Lisp_Object Vdefault_screen_alist;
Jim Blandy's avatar
Jim Blandy committed
242 243 244 245 246 247 248 249 250

extern Lisp_Object Vterminal_screen;

#else /* not MULTI_SCREEN */

/* These definitions are used in a single-screen version of Emacs.  */

#define SCREEN_PTR int

Jim Blandy's avatar
Jim Blandy committed
251 252
extern struct screen the_only_screen;

Jim Blandy's avatar
Jim Blandy committed
253
extern int selected_screen;
Jim Blandy's avatar
Jim Blandy committed
254 255 256 257 258
extern int last_nonminibuf_screen;

/* Nonzero means SCREEN_MESSAGE_BUF (selected_screen) is being used by
   print.  */
extern int message_buf_print;
Jim Blandy's avatar
Jim Blandy committed
259 260 261 262

#define XSCREEN(s) selected_screen
#define WINDOW_SCREEN(w) selected_screen

Jim Blandy's avatar
Jim Blandy committed
263 264
#define SCREENP(s) (XTYPE(s) == Lisp_Screen)
#define SCREEN_LIVE_P(s) 1
Jim Blandy's avatar
Jim Blandy committed
265
#define SCREEN_IS_TERMCAP(s) 1
Jim Blandy's avatar
Jim Blandy committed
266
#define SCREEN_IS_X(s) 0
Jim Blandy's avatar
Jim Blandy committed
267
#define SCREEN_MINIBUF_ONLY_P(s) 0
Jim Blandy's avatar
Jim Blandy committed
268
#define SCREEN_HAS_MINIBUF(s) 1
Jim Blandy's avatar
Jim Blandy committed
269 270 271 272 273 274 275 276 277
#define SCREEN_CURRENT_GLYPHS(s) the_only_screen.current_glyphs
#define SCREEN_DESIRED_GLYPHS(s) the_only_screen.desired_glyphs
#define SCREEN_TEMP_GLYPHS(s) the_only_screen.temp_glyphs
#define SCREEN_HEIGHT(s) the_only_screen.height
#define SCREEN_WIDTH(s) the_only_screen.width
#define SCREEN_NEW_HEIGHT(s) the_only_screen.new_height
#define SCREEN_NEW_WIDTH(s) the_only_screen.new_width
#define SCREEN_CURSOR_X(s) the_only_screen.cursor_x
#define SCREEN_CURSOR_Y(s) the_only_screen.cursor_y
Jim Blandy's avatar
Jim Blandy committed
278
#define SCREEN_VISIBLE_P(s) 1
Jim Blandy's avatar
Jim Blandy committed
279
#define SET_SCREEN_GARBAGED(s) (screen_garbaged = 1)
Jim Blandy's avatar
Jim Blandy committed
280 281 282 283 284
#define SCREEN_GARBAGED_P(s) screen_garbaged
#define SCREEN_NO_SPLIT_P(s) 0
#define SCREEN_WANTS_MODELINE_P(s) 1
#define SCREEN_ICONIFIED_P(s) 0
#define SCREEN_MINIBUF_WINDOW(s) minibuf_window
Jim Blandy's avatar
Jim Blandy committed
285
#define SCREEN_ROOT_WINDOW(s) the_only_screen.root_window
Jim Blandy's avatar
Jim Blandy committed
286 287
#define SCREEN_SELECTED_WINDOW(s) selected_window
#define SET_GLYPHS_SCREEN(glyphs,screen)
Jim Blandy's avatar
Jim Blandy committed
288 289 290 291 292 293 294
#define SCREEN_INSERT_COST(screen)  the_only_screen.insert_line_cost    
#define SCREEN_DELETE_COST(screen)  the_only_screen.delete_line_cost    
#define SCREEN_INSERTN_COST(screen) the_only_screen.insert_n_lines_cost
#define SCREEN_DELETEN_COST(screen) the_only_screen.delete_n_lines_cost
#define SCREEN_MESSAGE_BUF(s) the_only_screen.message_buf
#define SCREEN_SCROLL_BOTTOM_VPOS(s) the_only_screen.scroll_bottom_vpos
#define SCREEN_FOCUS_SCREEN(s) 0
Jim Blandy's avatar
Jim Blandy committed
295 296

#define CHECK_SCREEN(x, i) { ; }
Jim Blandy's avatar
Jim Blandy committed
297 298 299 300 301 302 303 304 305 306 307 308 309 310
#define CHECK_LIVE_SCREEN(x, y) { ; }

/* FOR_EACH_SCREEN (LIST_VAR, SCREEN_VAR) followed by a statement is a
   `for' loop which iterates over the elements of Vscreen_list.  The
   loop will set SCREEN_VAR, a SCREEN_PTR, to each screen in
   Vscreen_list in succession and execute the statement.  LIST_VAR
   should be a Lisp_Object; it is used to iterate through the
   Vscreen_list.  

   If MULTI_SCREEN _is_ defined, then this loop expands to a real
   `for' loop which traverses Vscreen_list using LIST_VAR and
   SCREEN_VAR.  */
#define FOR_EACH_SCREEN(list_var, screen_var)			\
  for (screen_var = (SCREEN_PTR) 1; screen_var; screen_var = (SCREEN_PTR) 0)
Jim Blandy's avatar
Jim Blandy committed
311 312

#endif /* not MULTI_SCREEN */