comparison src/redisplay.c @ 380:8626e4521993 r21-2-5

Import from CVS: tag r21-2-5
author cvs
date Mon, 13 Aug 2007 11:07:10 +0200
parents 6240c7796c7a
children bbff43aa5eb7
comparison
equal deleted inserted replaced
379:76b7d63099ad 380:8626e4521993
44 44
45 #include "buffer.h" 45 #include "buffer.h"
46 #include "commands.h" 46 #include "commands.h"
47 #include "debug.h" 47 #include "debug.h"
48 #include "device.h" 48 #include "device.h"
49 #include "elhash.h"
49 #include "extents.h" 50 #include "extents.h"
50 #include "faces.h" 51 #include "faces.h"
51 #include "frame.h" 52 #include "frame.h"
52 #include "glyphs.h" 53 #include "glyphs.h"
53 #include "insdel.h" 54 #include "insdel.h"
1803 of what a display table is. Currently it's only allowed 1804 of what a display table is. Currently it's only allowed
1804 to be a 256-entry vector. Instead, it should be something 1805 to be a 256-entry vector. Instead, it should be something
1805 like: 1806 like:
1806 1807
1807 a) A 256-entry vector, for backward compatibility 1808 a) A 256-entry vector, for backward compatibility
1808 b) Some sort of hashtable, mapping characters to values 1809 b) Some sort of hash table, mapping characters to values
1809 c) A list that specifies a range of values and the 1810 c) A list that specifies a range of values and the
1810 mapping to provide for those values. 1811 mapping to provide for those values.
1811 1812
1812 Also, extend the concept of "mapping" to include a 1813 Also, extend the concept of "mapping" to include a
1813 printf-like spec. Then, you could make all extended 1814 printf-like spec. Then, you could make all extended
2336 position. */ 2337 position. */
2337 if (data.ch == '\n') 2338 if (data.ch == '\n')
2338 { 2339 {
2339 /* If data.start_col_enabled is still true, then the window is 2340 /* If data.start_col_enabled is still true, then the window is
2340 scrolled far enough so that nothing on this line is visible. 2341 scrolled far enough so that nothing on this line is visible.
2341 We need to stick a trunctation glyph at the beginning of the 2342 We need to stick a truncation glyph at the beginning of the
2342 line in that case unless the line is completely blank. */ 2343 line in that case unless the line is completely blank. */
2343 if (data.bi_start_col_enabled) 2344 if (data.bi_start_col_enabled)
2344 { 2345 {
2345 if (data.cursor_type == CURSOR_ON) 2346 if (data.cursor_type == CURSOR_ON)
2346 { 2347 {
2869 2870
2870 /* Determine how many inside margin glyphs we can display and where 2871 /* Determine how many inside margin glyphs we can display and where
2871 they should start. The inside margin glyphs get whatever space 2872 they should start. The inside margin glyphs get whatever space
2872 is left after the whitespace glyphs have been displayed. These 2873 is left after the whitespace glyphs have been displayed. These
2873 are tricky to calculate since if we decide to use the overflow 2874 are tricky to calculate since if we decide to use the overflow
2874 area we basicaly have to start over. So for these we build up a 2875 area we basically have to start over. So for these we build up a
2875 list of just the inside margin glyphs and manipulate it to 2876 list of just the inside margin glyphs and manipulate it to
2876 determine the needed info. */ 2877 determine the needed info. */
2877 { 2878 {
2878 glyph_block_dynarr *ib; 2879 glyph_block_dynarr *ib;
2879 int avail_in, avail_out; 2880 int avail_in, avail_out;
2998 while (elt < Dynarr_length (dl->left_glyphs)) 2999 while (elt < Dynarr_length (dl->left_glyphs))
2999 { 3000 {
3000 struct glyph_block *gb = Dynarr_atp (dl->left_glyphs, elt); 3001 struct glyph_block *gb = Dynarr_atp (dl->left_glyphs, elt);
3001 3002
3002 if (NILP (gb->extent)) 3003 if (NILP (gb->extent))
3003 abort (); /* these should have beeb handled in add_glyph_rune */ 3004 abort (); /* these should have been handled in add_glyph_rune */
3004 3005
3005 if (extent_begin_glyph_layout (XEXTENT (gb->extent)) == 3006 if (extent_begin_glyph_layout (XEXTENT (gb->extent)) ==
3006 GL_OUTSIDE_MARGIN) 3007 GL_OUTSIDE_MARGIN)
3007 { 3008 {
3008 int width = glyph_width (gb->glyph, Qnil, gb->findex, window); 3009 int width = glyph_width (gb->glyph, Qnil, gb->findex, window);
3188 3189
3189 /* Determine how many inside margin glyphs we can display and where 3190 /* Determine how many inside margin glyphs we can display and where
3190 they should start. The inside margin glyphs get whatever space 3191 they should start. The inside margin glyphs get whatever space
3191 is left after the whitespace glyphs have been displayed. These 3192 is left after the whitespace glyphs have been displayed. These
3192 are tricky to calculate since if we decide to use the overflow 3193 are tricky to calculate since if we decide to use the overflow
3193 area we basicaly have to start over. So for these we build up a 3194 area we basically have to start over. So for these we build up a
3194 list of just the inside margin glyphs and manipulate it to 3195 list of just the inside margin glyphs and manipulate it to
3195 determine the needed info. */ 3196 determine the needed info. */
3196 { 3197 {
3197 glyph_block_dynarr *ib; 3198 glyph_block_dynarr *ib;
3198 int avail_in, avail_out; 3199 int avail_in, avail_out;
3311 while (elt < Dynarr_length (dl->right_glyphs)) 3312 while (elt < Dynarr_length (dl->right_glyphs))
3312 { 3313 {
3313 struct glyph_block *gb = Dynarr_atp (dl->right_glyphs, elt); 3314 struct glyph_block *gb = Dynarr_atp (dl->right_glyphs, elt);
3314 3315
3315 if (NILP (gb->extent)) 3316 if (NILP (gb->extent))
3316 abort (); /* these should have beeb handled in add_glyph_rune */ 3317 abort (); /* these should have been handled in add_glyph_rune */
3317 3318
3318 if (extent_end_glyph_layout (XEXTENT (gb->extent)) == GL_OUTSIDE_MARGIN) 3319 if (extent_end_glyph_layout (XEXTENT (gb->extent)) == GL_OUTSIDE_MARGIN)
3319 { 3320 {
3320 int width = glyph_width (gb->glyph, Qnil, gb->findex, window); 3321 int width = glyph_width (gb->glyph, Qnil, gb->findex, window);
3321 3322
3522 generate_formatted_string_db (b->modeline_format, 3523 generate_formatted_string_db (b->modeline_format,
3523 b->generated_modeline_string, w, dl, db, 3524 b->generated_modeline_string, w, dl, db,
3524 MODELINE_INDEX, min_pixpos, max_pixpos, type); 3525 MODELINE_INDEX, min_pixpos, max_pixpos, type);
3525 3526
3526 /* The modeline is at the bottom of the gutters. We have to wait to 3527 /* The modeline is at the bottom of the gutters. We have to wait to
3527 set this until we've generated teh modeline in order to account 3528 set this until we've generated the modeline in order to account
3528 for any embedded faces. */ 3529 for any embedded faces. */
3529 dl->ypos = WINDOW_BOTTOM (w) - dl->descent - ypos_adj; 3530 dl->ypos = WINDOW_BOTTOM (w) - dl->descent - ypos_adj;
3530 } 3531 }
3531 3532
3532 static void 3533 static void
5047 BUF_SET_PT (b, pointm); 5048 BUF_SET_PT (b, pointm);
5048 5049
5049 Fset_marker (w->pointm[DESIRED_DISP], make_int (pointm), 5050 Fset_marker (w->pointm[DESIRED_DISP], make_int (pointm),
5050 the_buffer); 5051 the_buffer);
5051 5052
5052 /* #### BUFU amounts of overkil just to get the cursor 5053 /* #### BUFU amounts of overkill just to get the cursor
5053 location marked properly. FIX ME FIX ME FIX ME */ 5054 location marked properly. FIX ME FIX ME FIX ME */
5054 regenerate_window (w, startp, pointm, DESIRED_DISP); 5055 regenerate_window (w, startp, pointm, DESIRED_DISP);
5055 } 5056 }
5056 5057
5057 goto regeneration_done; 5058 goto regeneration_done;
5239 5240
5240 update_line_start_cache (w, start, end, pointm, 1); 5241 update_line_start_cache (w, start, end, pointm, 1);
5241 redisplay_output_window (w); 5242 redisplay_output_window (w);
5242 /* 5243 /*
5243 * If we just displayed the echo area, the line start cache is 5244 * If we just displayed the echo area, the line start cache is
5244 * no longer valid, because the minibuffer window is assocaited 5245 * no longer valid, because the minibuffer window is associated
5245 * with the window now. 5246 * with the window now.
5246 */ 5247 */
5247 if (echo_active) 5248 if (echo_active)
5248 w->line_cache_last_updated = make_int (-1); 5249 w->line_cache_last_updated = make_int (-1);
5249 } 5250 }
5352 any which are already pending. */ 5353 any which are already pending. */
5353 if (f->size_change_pending) 5354 if (f->size_change_pending)
5354 change_frame_size (f, f->new_height, f->new_width, 0); 5355 change_frame_size (f, f->new_height, f->new_width, 0);
5355 5356
5356 /* If frame size might need to be changed, due to changed size 5357 /* If frame size might need to be changed, due to changed size
5357 of toolbars, scroolabrs etc, change it now */ 5358 of toolbars, scrollbars etc, change it now */
5358 if (f->size_slipped) 5359 if (f->size_slipped)
5359 { 5360 {
5360 adjust_frame_size (f); 5361 adjust_frame_size (f);
5361 assert (!f->size_slipped); 5362 assert (!f->size_slipped);
5362 } 5363 }
5363 5364
5364 /* The menubar, toolbar, and icon updates must be done before 5365 /* The menubar, toolbar, and icon updates must be done before
5365 hold_frame_size_changes is called and we are officially 5366 hold_frame_size_changes is called and we are officially
5366 'in_display'. They may eval lisp code which may call Fsignal. 5367 'in_display'. They may eval lisp code which may call Fsignal.
5367 If in_display is set Fsignal will abort. */ 5368 If in_display is set Fsignal will abort. */
5368 5369
5701 static char * 5702 static char *
5702 window_line_number (struct window *w, int type) 5703 window_line_number (struct window *w, int type)
5703 { 5704 {
5704 struct device *d = XDEVICE (XFRAME (w->frame)->device); 5705 struct device *d = XDEVICE (XFRAME (w->frame)->device);
5705 struct buffer *b = XBUFFER (w->buffer); 5706 struct buffer *b = XBUFFER (w->buffer);
5706 /* Be careful in the order of these tests. The first clasue will 5707 /* Be careful in the order of these tests. The first clause will
5707 fail if DEVICE_SELECTED_FRAME == Qnil (since w->frame cannot be). 5708 fail if DEVICE_SELECTED_FRAME == Qnil (since w->frame cannot be).
5708 This can occur when the frame title is computed really early */ 5709 This can occur when the frame title is computed really early */
5709 Bufpos pos = 5710 Bufpos pos =
5710 ((EQ(DEVICE_SELECTED_FRAME(d), w->frame) && 5711 ((EQ(DEVICE_SELECTED_FRAME(d), w->frame) &&
5711 (w == XWINDOW (FRAME_SELECTED_WINDOW (device_selected_frame(d)))) && 5712 (w == XWINDOW (FRAME_SELECTED_WINDOW (device_selected_frame(d)))) &&
5712 EQ(DEVICE_CONSOLE(d), Vselected_console) && 5713 EQ(DEVICE_CONSOLE(d), Vselected_console) &&
5713 XDEVICE(CONSOLE_SELECTED_DEVICE(XCONSOLE(DEVICE_CONSOLE(d)))) == d ) 5714 XDEVICE(CONSOLE_SELECTED_DEVICE(XCONSOLE(DEVICE_CONSOLE(d)))) == d )
6087 glyph_block *gb = Dynarr_atp (gba, 0); 6088 glyph_block *gb = Dynarr_atp (gba, 0);
6088 glyph_block *gb_last = Dynarr_atp (gba, Dynarr_length (gba)); 6089 glyph_block *gb_last = Dynarr_atp (gba, Dynarr_length (gba));
6089 6090
6090 for (; gb < gb_last; gb++) 6091 for (; gb < gb_last; gb++)
6091 { 6092 {
6092 if (!NILP (gb->glyph)) ((markobj) (gb->glyph)); 6093 if (!NILP (gb->glyph))
6093 if (!NILP (gb->extent)) ((markobj) (gb->extent)); 6094 markobj (gb->glyph);
6095 if (!NILP (gb->extent))
6096 markobj (gb->extent);
6094 } 6097 }
6095 } 6098 }
6096 } 6099 }
6097 6100
6098 static void 6101 static void
6116 for (; r < r_last; r++) 6119 for (; r < r_last; r++)
6117 { 6120 {
6118 if (r->type == RUNE_DGLYPH) 6121 if (r->type == RUNE_DGLYPH)
6119 { 6122 {
6120 if (!NILP (r->object.dglyph.glyph)) 6123 if (!NILP (r->object.dglyph.glyph))
6121 ((markobj) (r->object.dglyph.glyph)); 6124 markobj (r->object.dglyph.glyph);
6122 if (!NILP (r->object.dglyph.extent)) 6125 if (!NILP (r->object.dglyph.extent))
6123 ((markobj) (r->object.dglyph.extent)); 6126 markobj (r->object.dglyph.extent);
6124 } 6127 }
6125 } 6128 }
6126 } 6129 }
6127 6130
6128 mark_glyph_block_dynarr (dl->left_glyphs, markobj); 6131 mark_glyph_block_dynarr (dl->left_glyphs, markobj);
6262 { 6265 {
6263 /* f->extents_changed used to be in here because extent face and 6266 /* f->extents_changed used to be in here because extent face and
6264 size changes can cause text shifting. However, the extent 6267 size changes can cause text shifting. However, the extent
6265 covering the region is constantly having its face set and 6268 covering the region is constantly having its face set and
6266 priority altered by the mouse code. This means that the line 6269 priority altered by the mouse code. This means that the line
6267 start cache is constanty being invalidated. This is bad 6270 start cache is constantly being invalidated. This is bad
6268 since the mouse code also triggers heavy usage of the cache. 6271 since the mouse code also triggers heavy usage of the cache.
6269 Since it is an unlikely that f->extents being changed 6272 Since it is an unlikely that f->extents being changed
6270 indicates that the cache really needs to be updated and if it 6273 indicates that the cache really needs to be updated and if it
6271 does redisplay will catch it pretty quickly we no longer 6274 does redisplay will catch it pretty quickly we no longer
6272 invalidate the cache if it is set. This greatly speeds up 6275 invalidate the cache if it is set. This greatly speeds up
7062 7065
7063 new_startp = Dynarr_atp (internal_cache, ic_elt)->end + 1; 7066 new_startp = Dynarr_atp (internal_cache, ic_elt)->end + 1;
7064 7067
7065 /* 7068 /*
7066 * Handle invisible text properly: 7069 * Handle invisible text properly:
7067 * If the last line we're inserting has the same end as the 7070 * If the last line we're inserting has the same end as the
7068 * line before which it will be added, merge the two lines. 7071 * line before which it will be added, merge the two lines.
7069 */ 7072 */
7070 if (Dynarr_length (cache) && 7073 if (Dynarr_length (cache) &&
7071 Dynarr_atp (internal_cache, ic_elt)->end == 7074 Dynarr_atp (internal_cache, ic_elt)->end ==
7072 Dynarr_atp (cache, marker)->end) 7075 Dynarr_atp (cache, marker)->end)
7298 d->pixel_to_glyph_cache.closest = *closest; \ 7301 d->pixel_to_glyph_cache.closest = *closest; \
7299 d->pixel_to_glyph_cache.modeline_closest = *modeline_closest; \ 7302 d->pixel_to_glyph_cache.modeline_closest = *modeline_closest; \
7300 d->pixel_to_glyph_cache.obj1 = *obj1; \ 7303 d->pixel_to_glyph_cache.obj1 = *obj1; \
7301 d->pixel_to_glyph_cache.obj2 = *obj2; \ 7304 d->pixel_to_glyph_cache.obj2 = *obj2; \
7302 d->pixel_to_glyph_cache.retval = position; \ 7305 d->pixel_to_glyph_cache.retval = position; \
7303 RETURN__ position; \ 7306 RETURN_SANS_WARNINGS position; \
7304 } while (0) 7307 } while (0)
7305 7308
7306 /* Given x and y coordinates in pixels relative to a frame, return 7309 /* Given x and y coordinates in pixels relative to a frame, return
7307 information about what is located under those coordinates. 7310 information about what is located under those coordinates.
7308 7311
8057 redisplay_glyph_changed (Lisp_Object glyph, Lisp_Object property, 8060 redisplay_glyph_changed (Lisp_Object glyph, Lisp_Object property,
8058 Lisp_Object locale) 8061 Lisp_Object locale)
8059 { 8062 {
8060 if (WINDOWP (locale)) 8063 if (WINDOWP (locale))
8061 { 8064 {
8062 struct frame *f = XFRAME (WINDOW_FRAME (XWINDOW (locale))); 8065 MARK_FRAME_GLYPHS_CHANGED (XFRAME (WINDOW_FRAME (XWINDOW (locale))));
8063 MARK_FRAME_GLYPHS_CHANGED (f);
8064 } 8066 }
8065 else if (FRAMEP (locale)) 8067 else if (FRAMEP (locale))
8066 { 8068 {
8067 struct frame *f = XFRAME (locale); 8069 MARK_FRAME_GLYPHS_CHANGED (XFRAME (locale));
8068 MARK_FRAME_GLYPHS_CHANGED (f);
8069 } 8070 }
8070 else if (DEVICEP (locale)) 8071 else if (DEVICEP (locale))
8071 { 8072 {
8072 Lisp_Object frmcons; 8073 Lisp_Object frmcons;
8073 DEVICE_FRAME_LOOP (frmcons, XDEVICE (locale)) 8074 DEVICE_FRAME_LOOP (frmcons, XDEVICE (locale))
8074 { 8075 MARK_FRAME_GLYPHS_CHANGED (XFRAME (XCAR (frmcons)));
8075 struct frame *f = XFRAME (XCAR (frmcons));
8076 MARK_FRAME_GLYPHS_CHANGED (f);
8077 }
8078 } 8076 }
8079 else if (CONSOLEP (locale)) 8077 else if (CONSOLEP (locale))
8080 { 8078 {
8081 Lisp_Object frmcons, devcons; 8079 Lisp_Object frmcons, devcons;
8082 CONSOLE_FRAME_LOOP_NO_BREAK (frmcons, devcons, XCONSOLE (locale)) 8080 CONSOLE_FRAME_LOOP_NO_BREAK (frmcons, devcons, XCONSOLE (locale))
8083 { 8081 MARK_FRAME_GLYPHS_CHANGED (XFRAME (XCAR (frmcons)));
8084 struct frame *f = XFRAME (XCAR (frmcons));
8085 MARK_FRAME_GLYPHS_CHANGED (f);
8086 }
8087 } 8082 }
8088 else /* global or buffer */ 8083 else /* global or buffer */
8089 { 8084 {
8090 Lisp_Object frmcons, devcons, concons; 8085 Lisp_Object frmcons, devcons, concons;
8091 FRAME_LOOP_NO_BREAK (frmcons, devcons, concons) 8086 FRAME_LOOP_NO_BREAK (frmcons, devcons, concons)
8092 { 8087 MARK_FRAME_GLYPHS_CHANGED (XFRAME (XCAR (frmcons)));
8093 struct frame *f = XFRAME (XCAR (frmcons));
8094 MARK_FRAME_GLYPHS_CHANGED (f);
8095 }
8096 } 8088 }
8097 } 8089 }
8098 8090
8099 static void 8091 static void
8100 text_cursor_visible_p_changed (Lisp_Object specifier, struct window *w, 8092 text_cursor_visible_p_changed (Lisp_Object specifier, struct window *w,
8300 8292
8301 DEFVAR_INT_MAGIC ("pixel-vertical-clip-threshold", &vertical_clip /* 8293 DEFVAR_INT_MAGIC ("pixel-vertical-clip-threshold", &vertical_clip /*
8302 Minimum pixel height for clipped bottom display line. 8294 Minimum pixel height for clipped bottom display line.
8303 A clipped line shorter than this won't be displayed. 8295 A clipped line shorter than this won't be displayed.
8304 */ , 8296 */ ,
8305 redisplay_variable_changed); 8297 redisplay_variable_changed);
8306 vertical_clip = 5; 8298 vertical_clip = 5;
8307 8299
8308 DEFVAR_INT_MAGIC ("pixel-horizontal-clip-threshold", &horizontal_clip /* 8300 DEFVAR_INT_MAGIC ("pixel-horizontal-clip-threshold", &horizontal_clip /*
8309 Minimum visible area for clipped glyphs at right boundary. 8301 Minimum visible area for clipped glyphs at right boundary.
8310 Clipped glyphs shorter than this won't be displayed. 8302 Clipped glyphs shorter than this won't be displayed.
8311 Only pixmap glyph instances are currently allowed to be clipped. 8303 Only pixmap glyph instances are currently allowed to be clipped.
8312 */ , 8304 */ ,
8313 redisplay_variable_changed); 8305 redisplay_variable_changed);
8314 horizontal_clip = 5; 8306 horizontal_clip = 5;
8315 8307
8316 DEFVAR_LISP ("global-mode-string", &Vglobal_mode_string /* 8308 DEFVAR_LISP ("global-mode-string", &Vglobal_mode_string /*
8317 String displayed by modeline-format's "%m" specification. 8309 String displayed by modeline-format's "%m" specification.
8318 */ ); 8310 */ );
8320 8312
8321 DEFVAR_LISP_MAGIC ("overlay-arrow-position", &Voverlay_arrow_position /* 8313 DEFVAR_LISP_MAGIC ("overlay-arrow-position", &Voverlay_arrow_position /*
8322 Marker for where to display an arrow on top of the buffer text. 8314 Marker for where to display an arrow on top of the buffer text.
8323 This must be the beginning of a line in order to work. 8315 This must be the beginning of a line in order to work.
8324 See also `overlay-arrow-string'. 8316 See also `overlay-arrow-string'.
8325 */ , redisplay_variable_changed); 8317 */ ,
8318 redisplay_variable_changed);
8326 Voverlay_arrow_position = Qnil; 8319 Voverlay_arrow_position = Qnil;
8327 8320
8328 DEFVAR_LISP_MAGIC ("overlay-arrow-string", &Voverlay_arrow_string /* 8321 DEFVAR_LISP_MAGIC ("overlay-arrow-string", &Voverlay_arrow_string /*
8329 String to display as an arrow. See also `overlay-arrow-position'. 8322 String to display as an arrow. See also `overlay-arrow-position'.
8330 */ , 8323 */ ,
8331 redisplay_variable_changed); 8324 redisplay_variable_changed);
8332 Voverlay_arrow_string = Qnil; 8325 Voverlay_arrow_string = Qnil;
8333 8326
8334 DEFVAR_INT ("scroll-step", &scroll_step /* 8327 DEFVAR_INT ("scroll-step", &scroll_step /*
8335 *The number of lines to try scrolling a window by when point moves out. 8328 *The number of lines to try scrolling a window by when point moves out.
8336 If that fails to bring point back on frame, point is centered instead. 8329 If that fails to bring point back on frame, point is centered instead.
8345 8338
8346 DEFVAR_BOOL_MAGIC ("truncate-partial-width-windows", 8339 DEFVAR_BOOL_MAGIC ("truncate-partial-width-windows",
8347 &truncate_partial_width_windows /* 8340 &truncate_partial_width_windows /*
8348 *Non-nil means truncate lines in all windows less than full frame wide. 8341 *Non-nil means truncate lines in all windows less than full frame wide.
8349 */ , 8342 */ ,
8350 redisplay_variable_changed); 8343 redisplay_variable_changed);
8351 truncate_partial_width_windows = 1; 8344 truncate_partial_width_windows = 1;
8352 8345
8353 DEFVAR_BOOL ("visible-bell", &visible_bell /* 8346 DEFVAR_BOOL ("visible-bell", &visible_bell /*
8354 *Non-nil means try to flash the frame to represent a bell. 8347 *Non-nil means try to flash the frame to represent a bell.
8355 */ ); 8348 */ );