comparison src/dispnew.c @ 42835:38f2be5a65fd

(update_frame): Move the variable `tem' to the block where it is used. Fix typos in comments.
author Pavel Janík <Pavel@Janik.cz>
date Sat, 19 Jan 2002 13:54:57 +0000
parents e669966d496e
children f92c4d87863a aac41b50c875
comparison
equal deleted inserted replaced
42834:b0a1a85677ce 42835:38f2be5a65fd
236 /* Display table to use for vectors that don't specify their own. */ 236 /* Display table to use for vectors that don't specify their own. */
237 237
238 Lisp_Object Vstandard_display_table; 238 Lisp_Object Vstandard_display_table;
239 239
240 /* Nonzero means reading single-character input with prompt so put 240 /* Nonzero means reading single-character input with prompt so put
241 cursor on mini-buffer after the prompt. positive means at end of 241 cursor on mini-buffer after the prompt. Positive means at end of
242 text in echo area; negative means at beginning of line. */ 242 text in echo area; negative means at beginning of line. */
243 243
244 int cursor_in_echo_area; 244 int cursor_in_echo_area;
245 245
246 Lisp_Object Qdisplay_table, Qredisplay_dont_pause; 246 Lisp_Object Qdisplay_table, Qredisplay_dont_pause;
356 static void add_window_display_history P_ ((struct window *, char *, int)); 356 static void add_window_display_history P_ ((struct window *, char *, int));
357 357
358 358
359 /* Add to the redisplay history how window W has been displayed. 359 /* Add to the redisplay history how window W has been displayed.
360 MSG is a trace containing the information how W's glyph matrix 360 MSG is a trace containing the information how W's glyph matrix
361 has been contructed. PAUSED_P non-zero means that the update 361 has been constructed. PAUSED_P non-zero means that the update
362 has been interrupted for pending input. */ 362 has been interrupted for pending input. */
363 363
364 static void 364 static void
365 add_window_display_history (w, msg, paused_p) 365 add_window_display_history (w, msg, paused_p)
366 struct window *w; 366 struct window *w;
622 int header_line_changed_p = 0; 622 int header_line_changed_p = 0;
623 int header_line_p = 0; 623 int header_line_p = 0;
624 int left = -1, right = -1; 624 int left = -1, right = -1;
625 int window_x, window_y, window_width = -1, window_height; 625 int window_x, window_y, window_width = -1, window_height;
626 626
627 /* See if W had a top line that has disappeared now, or vice versa. */ 627 /* See if W had a header line that has disappeared now, or vice versa. */
628 if (w) 628 if (w)
629 { 629 {
630 header_line_p = WINDOW_WANTS_HEADER_LINE_P (w); 630 header_line_p = WINDOW_WANTS_HEADER_LINE_P (w);
631 header_line_changed_p = header_line_p != matrix->header_line_p; 631 header_line_changed_p = header_line_p != matrix->header_line_p;
632 } 632 }
1122 #if 0 /* At some point, some bit-fields of struct glyph were not set, 1122 #if 0 /* At some point, some bit-fields of struct glyph were not set,
1123 which made glyphs unequal when compared with GLYPH_EQUAL_P. 1123 which made glyphs unequal when compared with GLYPH_EQUAL_P.
1124 Redisplay outputs such glyphs, and flickering effects were 1124 Redisplay outputs such glyphs, and flickering effects were
1125 the result. This also depended on the contents of memory 1125 the result. This also depended on the contents of memory
1126 returned by xmalloc. If flickering happens again, activate 1126 returned by xmalloc. If flickering happens again, activate
1127 the code below If the flickering is gone with that, chances 1127 the code below. If the flickering is gone with that, chances
1128 are that the flickering has the same reason as here. */ 1128 are that the flickering has the same reason as here. */
1129 bzero (p[0], (char *) p[LAST_AREA] - (char *) p[0]); 1129 bzero (p[0], (char *) p[LAST_AREA] - (char *) p[0]);
1130 #endif 1130 #endif
1131 } 1131 }
1132 1132
1405 1405
1406 return hash; 1406 return hash;
1407 } 1407 }
1408 1408
1409 1409
1410 /* Return the cost of drawing line VPOS In MATRIX. The cost equals 1410 /* Return the cost of drawing line VPOS in MATRIX. The cost equals
1411 the number of characters in the line. If must_write_spaces is 1411 the number of characters in the line. If must_write_spaces is
1412 zero, leading and trailing spaces are ignored. */ 1412 zero, leading and trailing spaces are ignored. */
1413 1413
1414 static unsigned int 1414 static unsigned int
1415 line_draw_cost (matrix, vpos) 1415 line_draw_cost (matrix, vpos)
1569 free_glyph_pool (pool) 1569 free_glyph_pool (pool)
1570 struct glyph_pool *pool; 1570 struct glyph_pool *pool;
1571 { 1571 {
1572 if (pool) 1572 if (pool)
1573 { 1573 {
1574 /* More freed than allocated? */ 1574 /* More freed than allocated? */
1575 --glyph_pool_count; 1575 --glyph_pool_count;
1576 xassert (glyph_pool_count >= 0); 1576 xassert (glyph_pool_count >= 0);
1577 1577
1578 xfree (pool->glyphs); 1578 xfree (pool->glyphs);
1579 xfree (pool); 1579 xfree (pool);
1617 } 1617 }
1618 1618
1619 pool->nglyphs = needed; 1619 pool->nglyphs = needed;
1620 } 1620 }
1621 1621
1622 /* Remember the number of rows and columns because (a) we use then 1622 /* Remember the number of rows and columns because (a) we use them
1623 to do sanity checks, and (b) the number of columns determines 1623 to do sanity checks, and (b) the number of columns determines
1624 where rows in the frame matrix start---this must be available to 1624 where rows in the frame matrix start---this must be available to
1625 determine pointers to rows of window sub-matrices. */ 1625 determine pointers to rows of window sub-matrices. */
1626 pool->nrows = matrix_dim.height; 1626 pool->nrows = matrix_dim.height;
1627 pool->ncolumns = matrix_dim.width; 1627 pool->ncolumns = matrix_dim.width;
1780 NEW_LEAF_MATRIX set if any window in the tree did not have a 1780 NEW_LEAF_MATRIX set if any window in the tree did not have a
1781 glyph matrices yet, and 1781 glyph matrices yet, and
1782 1782
1783 CHANGED_LEAF_MATRIX set if the dimension or location of a matrix of 1783 CHANGED_LEAF_MATRIX set if the dimension or location of a matrix of
1784 any window in the tree will be changed or have been changed (see 1784 any window in the tree will be changed or have been changed (see
1785 DIM_ONLY_P). 1785 DIM_ONLY_P)
1786 1786
1787 *WINDOW_CHANGE_FLAGS must be initialized by the caller of this 1787 *WINDOW_CHANGE_FLAGS must be initialized by the caller of this
1788 function. 1788 function.
1789 1789
1790 Windows are arranged into chains of windows on the same level 1790 Windows are arranged into chains of windows on the same level
1872 do 1872 do
1873 { 1873 {
1874 w = XWINDOW (window); 1874 w = XWINDOW (window);
1875 1875
1876 /* Get the dimension of the window sub-matrix for W, depending 1876 /* Get the dimension of the window sub-matrix for W, depending
1877 on whether this a combination or a leaf window. */ 1877 on whether this is a combination or a leaf window. */
1878 if (!NILP (w->hchild)) 1878 if (!NILP (w->hchild))
1879 dim = allocate_matrices_for_frame_redisplay (w->hchild, x, y, 1879 dim = allocate_matrices_for_frame_redisplay (w->hchild, x, y,
1880 dim_only_p, 1880 dim_only_p,
1881 window_change_flags); 1881 window_change_flags);
1882 else if (!NILP (w->vchild)) 1882 else if (!NILP (w->vchild))
1977 return (((window_pixel_height + ch_height - 1) 1977 return (((window_pixel_height + ch_height - 1)
1978 / ch_height) 1978 / ch_height)
1979 /* One partially visible line at the top and 1979 /* One partially visible line at the top and
1980 bottom of the window. */ 1980 bottom of the window. */
1981 + 2 1981 + 2
1982 /* 2 for top and mode line. */ 1982 /* 2 for header and mode line. */
1983 + 2); 1983 + 2);
1984 } 1984 }
1985 #endif /* HAVE_WINDOW_SYSTEM */ 1985 #endif /* HAVE_WINDOW_SYSTEM */
1986 1986
1987 return XINT (w->height); 1987 return XINT (w->height);
2186 } 2186 }
2187 } 2187 }
2188 2188
2189 2189
2190 /* Save away the contents of frame F's current frame matrix. Value is 2190 /* Save away the contents of frame F's current frame matrix. Value is
2191 a glyph matrix holding the contents of F's current frame matrix. '*/ 2191 a glyph matrix holding the contents of F's current frame matrix. */
2192 2192
2193 static struct glyph_matrix * 2193 static struct glyph_matrix *
2194 save_current_matrix (f) 2194 save_current_matrix (f)
2195 struct frame *f; 2195 struct frame *f;
2196 { 2196 {
2995 /* RETAINED_P is zero for empty lines. */ 2995 /* RETAINED_P is zero for empty lines. */
2996 if (!retained_p[copy_from[i]]) 2996 if (!retained_p[copy_from[i]])
2997 new_rows[i].enabled_p = 0; 2997 new_rows[i].enabled_p = 0;
2998 } 2998 }
2999 2999
3000 /* Do the same for window matrices, if MATRIX Is a frame matrix. */ 3000 /* Do the same for window matrices, if MATRIX is a frame matrix. */
3001 if (frame_matrix_frame) 3001 if (frame_matrix_frame)
3002 mirror_line_dance (XWINDOW (frame_matrix_frame->root_window), 3002 mirror_line_dance (XWINDOW (frame_matrix_frame->root_window),
3003 unchanged_at_top, nlines, copy_from, retained_p); 3003 unchanged_at_top, nlines, copy_from, retained_p);
3004 } 3004 }
3005 3005
3269 return vpos; 3269 return vpos;
3270 } 3270 }
3271 3271
3272 3272
3273 /* Translate horizontal position HPOS which is relative to window W to 3273 /* Translate horizontal position HPOS which is relative to window W to
3274 a vertical position relative to W's frame. */ 3274 a horizontal position relative to W's frame. */
3275 3275
3276 static int 3276 static int
3277 window_to_frame_hpos (w, hpos) 3277 window_to_frame_hpos (w, hpos)
3278 struct window *w; 3278 struct window *w;
3279 int hpos; 3279 int hpos;
3395 struct window *w = XWINDOW (selected_window); 3395 struct window *w = XWINDOW (selected_window);
3396 struct it it, it2; 3396 struct it it, it2;
3397 struct glyph_row *glyph_row; 3397 struct glyph_row *glyph_row;
3398 struct glyph *glyphs, *glyph, *end; 3398 struct glyph *glyphs, *glyph, *end;
3399 int n; 3399 int n;
3400 /* Non-null means that Redisplay of W is based on window matrices. */ 3400 /* Non-null means that redisplay of W is based on window matrices. */
3401 int window_redisplay_p = FRAME_WINDOW_P (f); 3401 int window_redisplay_p = FRAME_WINDOW_P (f);
3402 /* Non-null means we are in overwrite mode. */ 3402 /* Non-null means we are in overwrite mode. */
3403 int overwrite_p = !NILP (current_buffer->overwrite_mode); 3403 int overwrite_p = !NILP (current_buffer->overwrite_mode);
3404 int added_width; 3404 int added_width;
3405 struct text_pos pos; 3405 struct text_pos pos;
3797 update_window (XWINDOW (f->menu_bar_window), 1); 3797 update_window (XWINDOW (f->menu_bar_window), 1);
3798 3798
3799 /* Update the tool-bar window, if present. */ 3799 /* Update the tool-bar window, if present. */
3800 if (WINDOWP (f->tool_bar_window)) 3800 if (WINDOWP (f->tool_bar_window))
3801 { 3801 {
3802 Lisp_Object tem;
3803 struct window *w = XWINDOW (f->tool_bar_window); 3802 struct window *w = XWINDOW (f->tool_bar_window);
3804 3803
3805 /* Update tool-bar window. */ 3804 /* Update tool-bar window. */
3806 if (w->must_be_updated_p) 3805 if (w->must_be_updated_p)
3807 { 3806 {
3807 Lisp_Object tem;
3808
3808 update_window (w, 1); 3809 update_window (w, 1);
3809 w->must_be_updated_p = 0; 3810 w->must_be_updated_p = 0;
3810 3811
3811 /* Swap tool-bar strings. We swap because we want to 3812 /* Swap tool-bar strings. We swap because we want to
3812 reuse strings. */ 3813 reuse strings. */
3994 rif->fix_overlapping_area (w, row, TEXT_AREA); 3995 rif->fix_overlapping_area (w, row, TEXT_AREA);
3995 3996
3996 if (row->used[RIGHT_MARGIN_AREA]) 3997 if (row->used[RIGHT_MARGIN_AREA])
3997 rif->fix_overlapping_area (w, row, RIGHT_MARGIN_AREA); 3998 rif->fix_overlapping_area (w, row, RIGHT_MARGIN_AREA);
3998 3999
3999 /* Record in neighbor rows that ROW overwrites part of their 4000 /* Record in neighbour rows that ROW overwrites part of their
4000 display. */ 4001 display. */
4001 if (row->phys_ascent > row->ascent && i > 0) 4002 if (row->phys_ascent > row->ascent && i > 0)
4002 MATRIX_ROW (w->current_matrix, i - 1)->overlapped_p = 1; 4003 MATRIX_ROW (w->current_matrix, i - 1)->overlapped_p = 1;
4003 if ((row->phys_height - row->phys_ascent 4004 if ((row->phys_height - row->phys_ascent
4004 > row->height - row->ascent) 4005 > row->height - row->ascent)
4075 int yb, changed_p = 0, mouse_face_overwritten_p = 0, n_updated; 4076 int yb, changed_p = 0, mouse_face_overwritten_p = 0, n_updated;
4076 4077
4077 rif->update_window_begin_hook (w); 4078 rif->update_window_begin_hook (w);
4078 yb = window_text_bottom_y (w); 4079 yb = window_text_bottom_y (w);
4079 4080
4080 /* If window has a top line, update it before everything else. 4081 /* If window has a header line, update it before everything else.
4081 Adjust y-positions of other rows by the top line height. */ 4082 Adjust y-positions of other rows by the header line height. */
4082 row = desired_matrix->rows; 4083 row = desired_matrix->rows;
4083 end = row + desired_matrix->nrows - 1; 4084 end = row + desired_matrix->nrows - 1;
4084 4085
4085 if (row->mode_line_p) 4086 if (row->mode_line_p)
4086 { 4087 {
4121 /* We've scrolled the display. */ 4122 /* We've scrolled the display. */
4122 force_p = 1; 4123 force_p = 1;
4123 changed_p = 1; 4124 changed_p = 1;
4124 } 4125 }
4125 4126
4126 /* Update the top mode line after scrolling because a new top 4127 /* Update the header line after scrolling because a new header
4127 line would otherwise overwrite lines at the top of the window 4128 line would otherwise overwrite lines at the top of the window
4128 that can be scrolled. */ 4129 that can be scrolled. */
4129 if (header_line_row && header_line_row->enabled_p) 4130 if (header_line_row && header_line_row->enabled_p)
4130 { 4131 {
4131 header_line_row->y = 0; 4132 header_line_row->y = 0;
4138 if (row->enabled_p) 4139 if (row->enabled_p)
4139 { 4140 {
4140 int vpos = MATRIX_ROW_VPOS (row, desired_matrix); 4141 int vpos = MATRIX_ROW_VPOS (row, desired_matrix);
4141 int i; 4142 int i;
4142 4143
4143 /* We'll Have to play a little bit with when to 4144 /* We'll have to play a little bit with when to
4144 detect_input_pending. If it's done too often, 4145 detect_input_pending. If it's done too often,
4145 scrolling large windows with repeated scroll-up 4146 scrolling large windows with repeated scroll-up
4146 commands will too quickly pause redisplay. */ 4147 commands will too quickly pause redisplay. */
4147 if (!force_p && ++n_updated % preempt_count == 0) 4148 if (!force_p && ++n_updated % preempt_count == 0)
4148 detect_input_pending (); 4149 detect_input_pending ();
4167 /* Was display preempted? */ 4168 /* Was display preempted? */
4168 paused_p = row < end; 4169 paused_p = row < end;
4169 4170
4170 set_cursor: 4171 set_cursor:
4171 4172
4172 /* Fix the appearance of overlapping(overlapped rows. */ 4173 /* Fix the appearance of overlapping/overlapped rows. */
4173 if (!paused_p && !w->pseudo_window_p) 4174 if (!paused_p && !w->pseudo_window_p)
4174 { 4175 {
4175 if (changed_p && rif->fix_overlapping_area) 4176 if (changed_p && rif->fix_overlapping_area)
4176 { 4177 {
4177 redraw_overlapped_rows (w, yb); 4178 redraw_overlapped_rows (w, yb);
4681 4682
4682 /* A vector of runs of lines found during scrolling. */ 4683 /* A vector of runs of lines found during scrolling. */
4683 4684
4684 static struct run **runs; 4685 static struct run **runs;
4685 4686
4686 static struct row_entry *add_row_entry P_ ((struct window *,
4687 struct glyph_row *));
4688
4689
4690 /* Add glyph row ROW to the scrolling hash table during the scrolling 4687 /* Add glyph row ROW to the scrolling hash table during the scrolling
4691 of window W. */ 4688 of window W. */
4692 4689
4693 static INLINE struct row_entry * 4690 static INLINE struct row_entry *
4694 add_row_entry (w, row) 4691 add_row_entry (w, row)
4716 return entry; 4713 return entry;
4717 } 4714 }
4718 4715
4719 4716
4720 /* Try to reuse part of the current display of W by scrolling lines. 4717 /* Try to reuse part of the current display of W by scrolling lines.
4721 HEADER_LINE_P non-zero means W has a top mode line. 4718 HEADER_LINE_P non-zero means W has a header line.
4722 4719
4723 The algorithm is taken from Communications of the ACM, Apr78 "A 4720 The algorithm is taken from Communications of the ACM, Apr78 "A
4724 Technique for Isolating Differences Between Files." It should take 4721 Technique for Isolating Differences Between Files." It should take
4725 O(N) time. 4722 O(N) time.
4726 4723
5105 if (preempt_count == 1) 5102 if (preempt_count == 1)
5106 { 5103 {
5107 #ifdef EMACS_OUTQSIZE 5104 #ifdef EMACS_OUTQSIZE
5108 if (EMACS_OUTQSIZE (0, &outq) < 0) 5105 if (EMACS_OUTQSIZE (0, &outq) < 0)
5109 /* Probably not a tty. Ignore the error and reset 5106 /* Probably not a tty. Ignore the error and reset
5110 * the outq count. */ 5107 the outq count. */
5111 outq = PENDING_OUTPUT_COUNT (stdout); 5108 outq = PENDING_OUTPUT_COUNT (stdout);
5112 #endif 5109 #endif
5113 outq *= 10; 5110 outq *= 10;
5114 if (baud_rate <= outq && baud_rate > 0) 5111 if (baud_rate <= outq && baud_rate > 0)
5115 sleep (outq / baud_rate); 5112 sleep (outq / baud_rate);
5715 *pos = it.current; 5712 *pos = it.current;
5716 } 5713 }
5717 5714
5718 5715
5719 /* Value is the string under window-relative coordinates X/Y in the 5716 /* Value is the string under window-relative coordinates X/Y in the
5720 mode or top line of window W, or nil if none. MODE_LINE_P non-zero 5717 mode or header line of window W, or nil if none. MODE_LINE_P non-zero
5721 means look at the mode line. *CHARPOS is set to the position in 5718 means look at the mode line. *CHARPOS is set to the position in
5722 the string returned. */ 5719 the string returned. */
5723 5720
5724 Lisp_Object 5721 Lisp_Object
5725 mode_line_string (w, x, y, mode_line_p, charpos) 5722 mode_line_string (w, x, y, mode_line_p, charpos)
6105 #endif 6102 #endif
6106 6103
6107 /* Assure that 0 <= usec < 1000000. */ 6104 /* Assure that 0 <= usec < 1000000. */
6108 if (usec < 0) 6105 if (usec < 0)
6109 { 6106 {
6110 /* We can't rely on the rounding being correct if user is negative. */ 6107 /* We can't rely on the rounding being correct if usec is negative. */
6111 if (-1000000 < usec) 6108 if (-1000000 < usec)
6112 sec--, usec += 1000000; 6109 sec--, usec += 1000000;
6113 else 6110 else
6114 sec -= -usec / 1000000, usec = 1000000 - (-usec % 1000000); 6111 sec -= -usec / 1000000, usec = 1000000 - (-usec % 1000000);
6115 } 6112 }
6136 #ifdef VMS 6133 #ifdef VMS
6137 sys_sleep (sec); 6134 sys_sleep (sec);
6138 #else /* not VMS */ 6135 #else /* not VMS */
6139 /* The reason this is done this way 6136 /* The reason this is done this way
6140 (rather than defined (H_S) && defined (H_T)) 6137 (rather than defined (H_S) && defined (H_T))
6141 is because the VMS preprocessor doesn't grok `defined' */ 6138 is because the VMS preprocessor doesn't grok `defined'. */
6142 #ifdef HAVE_SELECT 6139 #ifdef HAVE_SELECT
6143 EMACS_GET_TIME (end_time); 6140 EMACS_GET_TIME (end_time);
6144 EMACS_SET_SECS_USECS (timeout, sec, usec); 6141 EMACS_SET_SECS_USECS (timeout, sec, usec);
6145 EMACS_ADD_TIME (end_time, end_time, timeout); 6142 EMACS_ADD_TIME (end_time, end_time, timeout);
6146 6143
6433 { 6430 {
6434 fatal ("standard input is not a tty"); 6431 fatal ("standard input is not a tty");
6435 exit (1); 6432 exit (1);
6436 } 6433 }
6437 6434
6438 /* Look at the TERM variable */ 6435 /* Look at the TERM variable. */
6439 terminal_type = (char *) getenv ("TERM"); 6436 terminal_type = (char *) getenv ("TERM");
6440 if (!terminal_type) 6437 if (!terminal_type)
6441 { 6438 {
6442 #ifdef VMS 6439 #ifdef VMS
6443 fprintf (stderr, "Please specify your terminal type.\n\ 6440 fprintf (stderr, "Please specify your terminal type.\n\