comparison src/redisplay.c @ 404:2f8bb876ab1d r21-2-32

Import from CVS: tag r21-2-32
author cvs
date Mon, 13 Aug 2007 11:16:07 +0200
parents a86b2b5e0111
children b8cc9ab3f761
comparison
equal deleted inserted replaced
403:9f011ab08d48 404:2f8bb876ab1d
362 hscroll, control-arrow, etc) is in need of updating 362 hscroll, control-arrow, etc) is in need of updating
363 somewhere. */ 363 somewhere. */
364 int glyphs_changed; 364 int glyphs_changed;
365 int glyphs_changed_set; 365 int glyphs_changed_set;
366 366
367 /* non-zero if any displayed subwindow is in need of updating 367 /* non-zero if any subwindow has been deleted. */
368 somewhere. */
369 int subwindows_changed; 368 int subwindows_changed;
370 int subwindows_changed_set; 369 int subwindows_changed_set;
371 370
372 /* non-zero if any displayed subwindow is in need of updating 371 /* non-zero if any displayed subwindow is in need of updating
373 somewhere. */ 372 somewhere. */
417 416
418 /* If non-nil, use vertical bar cursor. */ 417 /* If non-nil, use vertical bar cursor. */
419 Lisp_Object Vbar_cursor; 418 Lisp_Object Vbar_cursor;
420 Lisp_Object Qbar_cursor; 419 Lisp_Object Qbar_cursor;
421 420
422 int visible_bell; /* If true and the terminal will support it 421 Lisp_Object Vvisible_bell; /* If true and the terminal will support it
423 then the frame will flash instead of 422 then the frame will flash instead of
424 beeping when an error occurs */ 423 beeping when an error occurs */
425 424
426 /* Nonzero means no need to redraw the entire frame on resuming 425 /* Nonzero means no need to redraw the entire frame on resuming
427 a suspended Emacs. This is useful on terminals with multiple pages, 426 a suspended Emacs. This is useful on terminals with multiple pages,
428 where one page is used for Emacs and another for all else. */ 427 where one page is used for Emacs and another for all else. */
429 int no_redraw_on_reenter; 428 int no_redraw_on_reenter;
468 Lisp_Object Vminimum_line_ascent, Vminimum_line_descent; 467 Lisp_Object Vminimum_line_ascent, Vminimum_line_descent;
469 Lisp_Object Vuse_left_overflow, Vuse_right_overflow; 468 Lisp_Object Vuse_left_overflow, Vuse_right_overflow;
470 Lisp_Object Vtext_cursor_visible_p; 469 Lisp_Object Vtext_cursor_visible_p;
471 470
472 int column_number_start_at_one; 471 int column_number_start_at_one;
472
473 Lisp_Object Qtop_bottom;
473 474
474 #define WINDOW_SCROLLED(w) \ 475 #define WINDOW_SCROLLED(w) \
475 (w->hscroll > 0 || w->left_xoffset) 476 (w->hscroll > 0 || w->left_xoffset)
476 477
477 478
1526 1527
1527 /* If window faces changed, and glyph instance is text, then 1528 /* If window faces changed, and glyph instance is text, then
1528 glyph sizes might have changed too */ 1529 glyph sizes might have changed too */
1529 invalidate_glyph_geometry_maybe (gb->glyph, w); 1530 invalidate_glyph_geometry_maybe (gb->glyph, w);
1530 1531
1531 /* This makes sure the glyph is in the cachels. 1532 /* This makes sure the glyph is in the cachels.
1532 1533
1533 #### We need to change this so that we hold onto the glyph_index 1534 #### We do this to make sure the glyph is in the glyph cachels,
1534 here, not the glyph itself. */ 1535 so that the dirty flag can be reset after redisplay has
1536 finished. We should do this some other way, maybe by iterating
1537 over the window cache of subwindows. */
1535 get_glyph_cachel_index (w, gb->glyph); 1538 get_glyph_cachel_index (w, gb->glyph);
1536 1539
1537 /* A nil extent indicates a special glyph (ex. truncator). */ 1540 /* A nil extent indicates a special glyph (ex. truncator). */
1538 if (NILP (gb->extent) 1541 if (NILP (gb->extent)
1539 || (pos_type == BEGIN_GLYPHS && 1542 || (pos_type == BEGIN_GLYPHS &&
3630 dl->ascent = DEVMETH (d, divider_height, ()); 3633 dl->ascent = DEVMETH (d, divider_height, ());
3631 dl->descent = 0; 3634 dl->descent = 0;
3632 /* The modeline is at the bottom of the gutters. */ 3635 /* The modeline is at the bottom of the gutters. */
3633 dl->ypos = WINDOW_BOTTOM (w); 3636 dl->ypos = WINDOW_BOTTOM (w);
3634 3637
3635 /* adjust for the bottom gutter */
3636 if (window_is_lowest (w))
3637 dl->ypos -= FRAME_BOTTOM_GUTTER_BOUNDS (f);
3638
3639 rb.findex = MODELINE_INDEX; 3638 rb.findex = MODELINE_INDEX;
3640 rb.xpos = dl->bounds.left_out; 3639 rb.xpos = dl->bounds.left_out;
3641 rb.width = dl->bounds.right_out - dl->bounds.left_out; 3640 rb.width = dl->bounds.right_out - dl->bounds.left_out;
3642 rb.bufpos = 0; 3641 rb.bufpos = 0;
3643 rb.endpos = 0; 3642 rb.endpos = 0;
3687 3686
3688 /* The modeline is at the bottom of the gutters. We have to wait to 3687 /* The modeline is at the bottom of the gutters. We have to wait to
3689 set this until we've generated the modeline in order to account 3688 set this until we've generated the modeline in order to account
3690 for any embedded faces. */ 3689 for any embedded faces. */
3691 dl->ypos = WINDOW_BOTTOM (w) - dl->descent - ypos_adj; 3690 dl->ypos = WINDOW_BOTTOM (w) - dl->descent - ypos_adj;
3692 /* adjust for the bottom gutter */
3693 if (window_is_lowest (w))
3694 dl->ypos -= FRAME_BOTTOM_GUTTER_BOUNDS (f);
3695 } 3691 }
3696 3692
3697 static Charcount 3693 static Charcount
3698 add_string_to_fstring_db_runes (pos_data *data, const Bufbyte *str, 3694 add_string_to_fstring_db_runes (pos_data *data, const Bufbyte *str,
3699 Charcount pos, Charcount min_pos, Charcount max_pos) 3695 Charcount pos, Charcount min_pos, Charcount max_pos)
5155 Dynarr_add (prop, pb); 5151 Dynarr_add (prop, pb);
5156 } 5152 }
5157 else 5153 else
5158 prop = 0; 5154 prop = 0;
5159 5155
5156 /* Make sure this is set always */
5157 /* Note the conversion at end */
5158 w->window_end_pos[type] = start_pos;
5160 while (ypos < yend) 5159 while (ypos < yend)
5161 { 5160 {
5162 struct display_line dl; 5161 struct display_line dl;
5163 struct display_line *dlp; 5162 struct display_line *dlp;
5164 int local; 5163 int local;
5258 5257
5259 if (prop) 5258 if (prop)
5260 Dynarr_free (prop); 5259 Dynarr_free (prop);
5261 5260
5262 /* #### More not quite right, but close enough. */ 5261 /* #### More not quite right, but close enough. */
5263 /* #### Ben sez: apparently window_end_pos[] is measured 5262 /* Ben sez: apparently window_end_pos[] is measured
5264 as the number of characters between the window end and the 5263 as the number of characters between the window end and the
5265 end of the buffer? This seems rather weirdo. What's 5264 end of the buffer? This seems rather weirdo. What's
5266 the justification for this? */ 5265 the justification for this?
5266
5267 JV sez: Because BUF_Z (b) would be a good initial value, however
5268 that can change. This representation allows initalizing with 0.
5269 */
5267 w->window_end_pos[type] = BUF_Z (b) - w->window_end_pos[type]; 5270 w->window_end_pos[type] = BUF_Z (b) - w->window_end_pos[type];
5268 5271
5269 if (need_modeline) 5272 if (need_modeline)
5270 { 5273 {
5271 /* We know that this is the right thing to use because we put it 5274 /* We know that this is the right thing to use because we put it
6288 return 0; 6291 return 0;
6289 } 6292 }
6290 6293
6291 /* Ensure that all windows on the given frame are correctly displayed. */ 6294 /* Ensure that all windows on the given frame are correctly displayed. */
6292 6295
6293 static int 6296 int
6294 redisplay_frame (struct frame *f, int preemption_check) 6297 redisplay_frame (struct frame *f, int preemption_check)
6295 { 6298 {
6296 struct device *d = XDEVICE (f->device); 6299 struct device *d = XDEVICE (f->device);
6297 6300
6298 if (preemption_check) 6301 if (preemption_check)
6330 the menubar's visibility. This way we avoid having flashing 6333 the menubar's visibility. This way we avoid having flashing
6331 caused by an Expose event generated by the visibility change 6334 caused by an Expose event generated by the visibility change
6332 being handled. */ 6335 being handled. */
6333 update_frame_menubars (f); 6336 update_frame_menubars (f);
6334 #endif /* HAVE_MENUBARS */ 6337 #endif /* HAVE_MENUBARS */
6335 /* widgets are similar to menus in that they can call lisp to
6336 determine activation etc. Therefore update them before we get
6337 into redisplay. This is primarily for connected widgets such as
6338 radio buttons. */
6339 update_frame_subwindows (f);
6340 #ifdef HAVE_TOOLBARS 6338 #ifdef HAVE_TOOLBARS
6341 /* Update the toolbars. */ 6339 /* Update the toolbars. */
6342 update_frame_toolbars (f); 6340 update_frame_toolbars (f);
6343 #endif /* HAVE_TOOLBARS */ 6341 #endif /* HAVE_TOOLBARS */
6342 /* Gutter update proper has to be done inside display when no frame
6343 size changes can occur, thus we separately update the gutter
6344 geometry here if it needs it. */
6345 update_frame_gutter_geometry (f);
6344 6346
6345 /* If we clear the frame we have to force its contents to be redrawn. */ 6347 /* If we clear the frame we have to force its contents to be redrawn. */
6346 if (f->clear) 6348 if (f->clear)
6347 f->frame_changed = 1; 6349 f->frame_changed = 1;
6348 6350
6349 /* invalidate the subwindow cache. We use subwindows_changed here to 6351 /* Invalidate the subwindow cache. We use subwindows_changed here to
6350 cause subwindows to get instantiated. This is because 6352 cause subwindows to get instantiated. This is because
6351 subwindows_state_changed is less strict - dealing with things 6353 subwindows_state_changed is less strict - dealing with things
6352 like the clicked state of button. We have to do this before 6354 like the clicked state of button. We have to do this before
6353 redisplaying the gutters as subwindows get unmapped in the 6355 redisplaying the gutters as subwindows get unmapped in the
6354 process.*/ 6356 process.*/
6355 if (!Dynarr_length (f->subwindow_cachels) 6357 if (f->frame_changed || f->subwindows_changed)
6356 || f->subwindows_changed
6357 || f->faces_changed
6358 || f->frame_changed)
6359 { 6358 {
6360 reset_subwindow_cachels (f); 6359 reset_subwindow_cachels (f);
6361 /* we have to do this so the gutter gets regenerated. */ 6360 /* we have to do this so the gutter gets regenerated. */
6362 reset_gutter_display_lines (f); 6361 reset_gutter_display_lines (f);
6363 } 6362 }
6364 else 6363 else
6365 mark_subwindow_cachels_as_not_updated (f); 6364 mark_subwindow_cachels_as_not_updated (f);
6366
6367 /* We can now update the gutters, safe in the knowledge that our
6368 efforts won't get undone. */
6369
6370 /* #### This can call lisp, it may be that if the subwindow cachels
6371 have been reset there are no remaining references to the
6372 displayed glyphs and so they get garbage collected. We should
6373 consider putting this call inside the critical redisplay
6374 section. */
6375 update_frame_gutters (f);
6376 6365
6377 hold_frame_size_changes (); 6366 hold_frame_size_changes ();
6378 6367
6379 /* ----------------- BEGIN CRITICAL REDISPLAY SECTION ---------------- */ 6368 /* ----------------- BEGIN CRITICAL REDISPLAY SECTION ---------------- */
6380 /* Within this section, we are defenseless and assume that the 6369 /* Within this section, we are defenseless and assume that the
6397 If garbage collection is called during this critical section, 6386 If garbage collection is called during this critical section,
6398 we simply return. #### We should abort instead. 6387 we simply return. #### We should abort instead.
6399 6388
6400 #### If a frame-size change does occur we should probably 6389 #### If a frame-size change does occur we should probably
6401 actually be preempting redisplay. */ 6390 actually be preempting redisplay. */
6391
6392 /* We can now update the gutters, safe in the knowledge that our
6393 efforts won't get undone. */
6394
6395 /* This can call lisp, but redisplay is protected by binding
6396 inhibit_quit. More importantly the code involving display lines
6397 *assumes* that GC will not happen and so does not GCPRO
6398 anything. Since we use this code the whole time with the gutters
6399 we cannot allow GC to happen when manipulating the gutters. */
6400 update_frame_gutters (f);
6402 6401
6403 /* Erase the frame before outputting its contents. */ 6402 /* Erase the frame before outputting its contents. */
6404 if (f->clear) 6403 if (f->clear)
6405 { 6404 {
6406 DEVMETH (d, clear_frame, (f)); 6405 DEVMETH (d, clear_frame, (f));
7551 /* For the given window W, if display starts at STARTP, what will be 7550 /* For the given window W, if display starts at STARTP, what will be
7552 the buffer position at the beginning or end of the last line 7551 the buffer position at the beginning or end of the last line
7553 displayed. The end of the last line is also know as the window end 7552 displayed. The end of the last line is also know as the window end
7554 position. 7553 position.
7555 7554
7555 WARNING: It is possible that rediplay failed to layout any lines for the
7556 windows. Under normal circumstances this is rare. However it seems that it
7557 does occur in the following situation: A mouse event has come in and we
7558 need to compute its location in a window. That code (in
7559 pixel_to_glyph_translation) already can handle 0 as an error return value.
7560
7556 #### With a little work this could probably be reworked as just a 7561 #### With a little work this could probably be reworked as just a
7557 call to start_with_line_at_pixpos. */ 7562 call to start_with_line_at_pixpos. */
7558 7563
7559 static Bufpos 7564 static Bufpos
7560 start_end_of_last_line (struct window *w, Bufpos startp, int end) 7565 start_end_of_last_line (struct window *w, Bufpos startp, int end,
7566 int may_error)
7561 { 7567 {
7562 struct buffer *b = XBUFFER (w->buffer); 7568 struct buffer *b = XBUFFER (w->buffer);
7563 line_start_cache_dynarr *cache = w->line_start_cache; 7569 line_start_cache_dynarr *cache = w->line_start_cache;
7564 int pixpos = 0; 7570 int pixpos = 0;
7565 int bottom = WINDOW_TEXT_HEIGHT (w); 7571 int bottom = WINDOW_TEXT_HEIGHT (w);
7575 startp = BUF_ZV (b); 7581 startp = BUF_ZV (b);
7576 cur_start = startp; 7582 cur_start = startp;
7577 7583
7578 start_elt = point_in_line_start_cache (w, cur_start, 0); 7584 start_elt = point_in_line_start_cache (w, cur_start, 0);
7579 if (start_elt == -1) 7585 if (start_elt == -1)
7580 abort (); /* this had better never happen */ 7586 return may_error ? 0 : startp;
7581 7587
7582 while (1) 7588 while (1)
7583 { 7589 {
7584 int height = Dynarr_atp (cache, start_elt)->height; 7590 int height = Dynarr_atp (cache, start_elt)->height;
7585 7591
7639 the buffer position at the beginning of the last line displayed. */ 7645 the buffer position at the beginning of the last line displayed. */
7640 7646
7641 Bufpos 7647 Bufpos
7642 start_of_last_line (struct window *w, Bufpos startp) 7648 start_of_last_line (struct window *w, Bufpos startp)
7643 { 7649 {
7644 return start_end_of_last_line (w, startp, 0); 7650 return start_end_of_last_line (w, startp, 0 , 0);
7645 } 7651 }
7646 7652
7647 /* For the given window W, if display starts at STARTP, what will be 7653 /* For the given window W, if display starts at STARTP, what will be
7648 the buffer position at the end of the last line displayed. This is 7654 the buffer position at the end of the last line displayed. This is
7649 also know as the window end position. */ 7655 also know as the window end position. */
7650 7656
7651 Bufpos 7657 Bufpos
7652 end_of_last_line (struct window *w, Bufpos startp) 7658 end_of_last_line (struct window *w, Bufpos startp)
7653 { 7659 {
7654 return start_end_of_last_line (w, startp, 1); 7660 return start_end_of_last_line (w, startp, 1, 0);
7655 } 7661 }
7662
7663 static Bufpos
7664 end_of_last_line_may_error (struct window *w, Bufpos startp)
7665 {
7666 return start_end_of_last_line (w, startp, 1, 1);
7667 }
7668
7656 7669
7657 /* For window W, what does the starting position have to be so that 7670 /* For window W, what does the starting position have to be so that
7658 the line containing POINT will cover pixel position PIXPOS. */ 7671 the line containing POINT will cover pixel position PIXPOS. */
7659 7672
7660 Bufpos 7673 Bufpos
8805 /* #### This should be checked out some more to determine what 8818 /* #### This should be checked out some more to determine what
8806 should really be going on. */ 8819 should really be going on. */
8807 if (!MARKERP ((*w)->start[CURRENT_DISP])) 8820 if (!MARKERP ((*w)->start[CURRENT_DISP]))
8808 *closest = 0; 8821 *closest = 0;
8809 else 8822 else
8810 *closest = end_of_last_line (*w, 8823 *closest = end_of_last_line_may_error (*w,
8811 marker_position ((*w)->start[CURRENT_DISP])); 8824 marker_position ((*w)->start[CURRENT_DISP]));
8812 *col = 0; 8825 *col = 0;
8813 UPDATE_CACHE_RETURN; 8826 UPDATE_CACHE_RETURN;
8814 } 8827 }
8815 #undef UPDATE_CACHE_RETURN 8828 #undef UPDATE_CACHE_RETURN
8893 } 8906 }
8894 8907
8895 f->clear = 1; 8908 f->clear = 1;
8896 redisplay_frame (f, 1); 8909 redisplay_frame (f, 1);
8897 8910
8911 /* See the comment in Fredisplay_frame. */
8912 RESET_CHANGED_SET_FLAGS;
8913
8898 return unbind_to (count, Qnil); 8914 return unbind_to (count, Qnil);
8899 } 8915 }
8900 8916
8901 DEFUN ("redisplay-frame", Fredisplay_frame, 0, 2, 0, /* 8917 DEFUN ("redisplay-frame", Fredisplay_frame, 0, 2, 0, /*
8902 Ensure that FRAME's contents are correctly displayed. 8918 Ensure that FRAME's contents are correctly displayed.
8920 disable_preemption++; 8936 disable_preemption++;
8921 } 8937 }
8922 8938
8923 redisplay_frame (f, 1); 8939 redisplay_frame (f, 1);
8924 8940
8941 /* If we don't reset the global redisplay flafs here, subsequent
8942 changes to the display will not get registered by redisplay
8943 because it thinks it already has registered changes. If you
8944 really knew what you were doing you could confuse redisplay by
8945 calling Fredisplay_frame while updating another frame. We assume
8946 that if you know what you are doing you will not be that
8947 stupid. */
8948 RESET_CHANGED_SET_FLAGS;
8949
8925 return unbind_to (count, Qnil); 8950 return unbind_to (count, Qnil);
8926 } 8951 }
8927 8952
8928 DEFUN ("redraw-device", Fredraw_device, 0, 2, 0, /* 8953 DEFUN ("redraw-device", Fredraw_device, 0, 2, 0, /*
8929 Clear device DEVICE and output again what is supposed to appear on it. 8954 Clear device DEVICE and output again what is supposed to appear on it.
8948 DEVICE_FRAME_LOOP (frmcons, d) 8973 DEVICE_FRAME_LOOP (frmcons, d)
8949 { 8974 {
8950 XFRAME (XCAR (frmcons))->clear = 1; 8975 XFRAME (XCAR (frmcons))->clear = 1;
8951 } 8976 }
8952 redisplay_device (d, 0); 8977 redisplay_device (d, 0);
8978
8979 /* See the comment in Fredisplay_frame. */
8980 RESET_CHANGED_SET_FLAGS;
8953 8981
8954 return unbind_to (count, Qnil); 8982 return unbind_to (count, Qnil);
8955 } 8983 }
8956 8984
8957 DEFUN ("redisplay-device", Fredisplay_device, 0, 2, 0, /* 8985 DEFUN ("redisplay-device", Fredisplay_device, 0, 2, 0, /*
8975 make_int (disable_preemption)); 9003 make_int (disable_preemption));
8976 disable_preemption++; 9004 disable_preemption++;
8977 } 9005 }
8978 9006
8979 redisplay_device (d, 0); 9007 redisplay_device (d, 0);
9008
9009 /* See the comment in Fredisplay_frame. */
9010 RESET_CHANGED_SET_FLAGS;
8980 9011
8981 return unbind_to (count, Qnil); 9012 return unbind_to (count, Qnil);
8982 } 9013 }
8983 9014
8984 /* Big lie. Big lie. This will force all modelines to be updated 9015 /* Big lie. Big lie. This will force all modelines to be updated
9238 #endif /* INHIBIT_REDISPLAY_HOOKS */ 9269 #endif /* INHIBIT_REDISPLAY_HOOKS */
9239 defsymbol (&Qdisplay_warning_buffer, "display-warning-buffer"); 9270 defsymbol (&Qdisplay_warning_buffer, "display-warning-buffer");
9240 defsymbol (&Qbar_cursor, "bar-cursor"); 9271 defsymbol (&Qbar_cursor, "bar-cursor");
9241 defsymbol (&Qredisplay_end_trigger_functions, 9272 defsymbol (&Qredisplay_end_trigger_functions,
9242 "redisplay-end-trigger-functions"); 9273 "redisplay-end-trigger-functions");
9274 defsymbol (&Qtop_bottom, "top-bottom");
9243 9275
9244 DEFSUBR (Fredisplay_echo_area); 9276 DEFSUBR (Fredisplay_echo_area);
9245 DEFSUBR (Fredraw_frame); 9277 DEFSUBR (Fredraw_frame);
9246 DEFSUBR (Fredisplay_frame); 9278 DEFSUBR (Fredisplay_frame);
9247 DEFSUBR (Fredraw_device); 9279 DEFSUBR (Fredraw_device);
9326 *Non-nil means truncate lines in all windows less than full frame wide. 9358 *Non-nil means truncate lines in all windows less than full frame wide.
9327 */ , 9359 */ ,
9328 redisplay_variable_changed); 9360 redisplay_variable_changed);
9329 truncate_partial_width_windows = 1; 9361 truncate_partial_width_windows = 1;
9330 9362
9331 DEFVAR_BOOL ("visible-bell", &visible_bell /* 9363 DEFVAR_LISP ("visible-bell", &Vvisible_bell /*
9332 *Non-nil means try to flash the frame to represent a bell. 9364 *Non-nil substitutes a visual signal for the audible bell.
9365
9366 Default behavior is to flash the whole screen. On some platforms,
9367 special effects are available using the following values:
9368
9369 'display Flash the whole screen (ie, the default behavior).
9370 'top-bottom Flash only the top and bottom lines of the selected frame.
9371
9372 When effects are unavailable on a platform, the visual bell is the
9373 default, whole screen. (Currently only X supports any special effects.)
9333 */ ); 9374 */ );
9334 visible_bell = 0; 9375 Vvisible_bell = Qnil;
9335 9376
9336 DEFVAR_BOOL ("no-redraw-on-reenter", &no_redraw_on_reenter /* 9377 DEFVAR_BOOL ("no-redraw-on-reenter", &no_redraw_on_reenter /*
9337 *Non-nil means no need to redraw entire frame after suspending. 9378 *Non-nil means no need to redraw entire frame after suspending.
9338 A non-nil value is useful if the terminal can automatically preserve 9379 A non-nil value is useful if the terminal can automatically preserve
9339 Emacs's frame display when you reenter Emacs. 9380 Emacs's frame display when you reenter Emacs.