comparison src/redisplay.c @ 408:501cfd01ee6d r21-2-34

Import from CVS: tag r21-2-34
author cvs
date Mon, 13 Aug 2007 11:18:11 +0200
parents b8cc9ab3f761
children de805c49cfc1
comparison
equal deleted inserted replaced
407:ed6218a7d4d3 408:501cfd01ee6d
85 #define BEGIN_GLYPHS 0 85 #define BEGIN_GLYPHS 0
86 #define END_GLYPHS 1 86 #define END_GLYPHS 1
87 #define LEFT_GLYPHS 2 87 #define LEFT_GLYPHS 2
88 #define RIGHT_GLYPHS 3 88 #define RIGHT_GLYPHS 3
89 89
90 /* Set the vertical clip to 0 if we are currently updating the line
91 start cache. Otherwise for buffers of line height 1 it may fail to
92 be able to work properly because regenerate_window will not layout
93 a single line. */
94 #define VERTICAL_CLIP(w, display) \ 90 #define VERTICAL_CLIP(w, display) \
95 (updating_line_start_cache \ 91 ((WINDOW_TTY_P (w) | (!display && scroll_on_clipped_lines)) \
96 ? 0 \
97 : ((WINDOW_TTY_P (w) | (!display && scroll_on_clipped_lines)) \
98 ? INT_MAX \ 92 ? INT_MAX \
99 : vertical_clip)) 93 : vertical_clip)
100 94
101 /* The following structures are completely private to redisplay.c so 95 /* The following structures are completely private to redisplay.c so
102 we put them here instead of in a header file, for modularity. */ 96 we put them here instead of in a header file, for modularity. */
103 97
104 /* NOTE: Bytinds not Bufpos's in this structure. */ 98 /* NOTE: Bytinds not Bufpos's in this structure. */
326 int vertical_clip; 320 int vertical_clip;
327 321
328 /* Minimum visible pixel width of clipped glyphs at right margin. */ 322 /* Minimum visible pixel width of clipped glyphs at right margin. */
329 int horizontal_clip; 323 int horizontal_clip;
330 324
331 /* Set if currently inside update_line_start_cache. */
332 static int updating_line_start_cache;
333
334 /* Nonzero means reading single-character input with prompt 325 /* Nonzero means reading single-character input with prompt
335 so put cursor on minibuffer after the prompt. */ 326 so put cursor on minibuffer after the prompt. */
336 int cursor_in_echo_area; 327 int cursor_in_echo_area;
337 Lisp_Object Qcursor_in_echo_area; 328 Lisp_Object Qcursor_in_echo_area;
338 329
1320 dst += long_to_string_base ((char *)dst, data->ch, 16); 1311 dst += long_to_string_base ((char *)dst, data->ch, 16);
1321 break;*/ 1312 break;*/
1322 case '%': 1313 case '%':
1323 dst += set_charptr_emchar (dst, '%'); 1314 dst += set_charptr_emchar (dst, '%');
1324 break; 1315 break;
1316 /* #### unimplemented */
1325 } 1317 }
1326 } 1318 }
1327 } 1319 }
1328 prop = add_bufbyte_string_runes (data, result, dst - result, 0); 1320 prop = add_bufbyte_string_runes (data, result, dst - result, 0);
1329 } 1321 }
3978 * at most that many characters. If positive, pad (with spaces) 3970 * at most that many characters. If positive, pad (with spaces)
3979 * to at least that many characters. 3971 * to at least that many characters.
3980 * - If first element is another symbol, process the cadr or caddr 3972 * - If first element is another symbol, process the cadr or caddr
3981 * recursively according to whether the symbol's value is non-nil or 3973 * recursively according to whether the symbol's value is non-nil or
3982 * nil. 3974 * nil.
3983 * - If first element is a face, process the cdr recursively 3975 * - If first element is an extent, process the cdr recursively
3984 * without altering the depth. 3976 * and handle the extent's face.
3985 */ 3977 */
3986 3978
3987 Lisp_Object car, tem; 3979 Lisp_Object car, tem;
3988 3980
3989 car = XCAR (elt); 3981 car = XCAR (elt);
5095 struct frame *f = XFRAME (w->frame); 5087 struct frame *f = XFRAME (w->frame);
5096 struct buffer *b = XBUFFER (w->buffer); 5088 struct buffer *b = XBUFFER (w->buffer);
5097 int ypos = WINDOW_TEXT_TOP (w); 5089 int ypos = WINDOW_TEXT_TOP (w);
5098 int yend; /* set farther down */ 5090 int yend; /* set farther down */
5099 int yclip = WINDOW_TEXT_TOP_CLIP (w); 5091 int yclip = WINDOW_TEXT_TOP_CLIP (w);
5092 int force;
5100 5093
5101 prop_block_dynarr *prop; 5094 prop_block_dynarr *prop;
5102 layout_bounds bounds; 5095 layout_bounds bounds;
5103 display_line_dynarr *dla; 5096 display_line_dynarr *dla;
5104 int need_modeline; 5097 int need_modeline;
5148 Dynarr_add (prop, pb); 5141 Dynarr_add (prop, pb);
5149 } 5142 }
5150 else 5143 else
5151 prop = 0; 5144 prop = 0;
5152 5145
5146 /* When we are computing things for scrolling purposes, make
5147 sure at least one line is always generated */
5148 force = (type == CMOTION_DISP);
5149
5153 /* Make sure this is set always */ 5150 /* Make sure this is set always */
5154 /* Note the conversion at end */ 5151 /* Note the conversion at end */
5155 w->window_end_pos[type] = start_pos; 5152 w->window_end_pos[type] = start_pos;
5156 while (ypos < yend) 5153 while (ypos < yend || force)
5157 { 5154 {
5158 struct display_line dl; 5155 struct display_line dl;
5159 struct display_line *dlp; 5156 struct display_line *dlp;
5160 int local; 5157 int local;
5161 5158
5204 /* Although this seems strange we could have a single very 5201 /* Although this seems strange we could have a single very
5205 tall line visible for which we need to account for both 5202 tall line visible for which we need to account for both
5206 the top clip and the bottom clip. */ 5203 the top clip and the bottom clip. */
5207 visible_height -= (dlp->clip + dlp->top_clip); 5204 visible_height -= (dlp->clip + dlp->top_clip);
5208 5205
5209 if (visible_height < VERTICAL_CLIP (w, 1)) 5206 if (visible_height < VERTICAL_CLIP (w, 1) && !force)
5210 { 5207 {
5211 if (local) 5208 if (local)
5212 free_display_line (dlp); 5209 free_display_line (dlp);
5213 break; 5210 break;
5214 } 5211 }
5248 5245
5249 /* #### This type of check needs to be done down in the 5246 /* #### This type of check needs to be done down in the
5250 generate_display_line call. */ 5247 generate_display_line call. */
5251 if (start_pos > BUF_ZV (b)) 5248 if (start_pos > BUF_ZV (b))
5252 break; 5249 break;
5250
5251 force = 0;
5253 } 5252 }
5254 5253
5255 if (prop) 5254 if (prop)
5256 Dynarr_free (prop); 5255 Dynarr_free (prop);
5257 5256
6340 like the clicked state of button. We have to do this before 6339 like the clicked state of button. We have to do this before
6341 redisplaying the gutters as subwindows get unmapped in the 6340 redisplaying the gutters as subwindows get unmapped in the
6342 process.*/ 6341 process.*/
6343 if (f->frame_changed || f->subwindows_changed) 6342 if (f->frame_changed || f->subwindows_changed)
6344 { 6343 {
6345 reset_subwindow_cachels (f);
6346 /* we have to do this so the gutter gets regenerated. */ 6344 /* we have to do this so the gutter gets regenerated. */
6347 reset_gutter_display_lines (f); 6345 reset_gutter_display_lines (f);
6348 } 6346 }
6349 else
6350 mark_subwindow_cachels_as_not_updated (f);
6351 6347
6352 hold_frame_size_changes (); 6348 hold_frame_size_changes ();
6353 6349
6354 /* ----------------- BEGIN CRITICAL REDISPLAY SECTION ---------------- */ 6350 /* ----------------- BEGIN CRITICAL REDISPLAY SECTION ---------------- */
6355 /* Within this section, we are defenseless and assume that the 6351 /* Within this section, we are defenseless and assume that the
6373 we simply return. #### We should abort instead. 6369 we simply return. #### We should abort instead.
6374 6370
6375 #### If a frame-size change does occur we should probably 6371 #### If a frame-size change does occur we should probably
6376 actually be preempting redisplay. */ 6372 actually be preempting redisplay. */
6377 6373
6374 MAYBE_DEVMETH (d, frame_output_begin, (f));
6375
6378 /* We can now update the gutters, safe in the knowledge that our 6376 /* We can now update the gutters, safe in the knowledge that our
6379 efforts won't get undone. */ 6377 efforts won't get undone. */
6380 6378
6381 /* This can call lisp, but redisplay is protected by binding 6379 /* This can call lisp, but redisplay is protected by binding
6382 inhibit_quit. More importantly the code involving display lines 6380 inhibit_quit. More importantly the code involving display lines
6386 update_frame_gutters (f); 6384 update_frame_gutters (f);
6387 6385
6388 /* Erase the frame before outputting its contents. */ 6386 /* Erase the frame before outputting its contents. */
6389 if (f->clear) 6387 if (f->clear)
6390 { 6388 {
6391 DEVMETH (d, clear_frame, (f)); 6389 MAYBE_DEVMETH (d, clear_frame, (f));
6392 } 6390 }
6393 6391
6394 /* Do the selected window first. */ 6392 /* Do the selected window first. */
6395 redisplay_window (FRAME_SELECTED_WINDOW (f), 0); 6393 redisplay_window (FRAME_SELECTED_WINDOW (f), 0);
6396 6394
6397 /* Then do the rest. */ 6395 /* Then do the rest. */
6398 redisplay_windows (f->root_window, 1); 6396 redisplay_windows (f->root_window, 1);
6399 6397
6400 /* We now call the output_end routine for tty frames. We delay 6398 MAYBE_DEVMETH (d, frame_output_end, (f));
6401 doing so in order to avoid cursor flicker. So much for 100%
6402 encapsulation. */
6403 if (FRAME_TTY_P (f))
6404 DEVMETH (d, output_end, (d));
6405 6399
6406 update_frame_title (f); 6400 update_frame_title (f);
6407 6401
6408 CLASS_RESET_CHANGED_FLAGS (f); 6402 CLASS_RESET_CHANGED_FLAGS (f);
6409 f->window_face_cache_reset = 0; 6403 f->window_face_cache_reset = 0;
7834 line_start_cache_dynarr *cache = w->line_start_cache; 7828 line_start_cache_dynarr *cache = w->line_start_cache;
7835 Bufpos low_bound, high_bound; 7829 Bufpos low_bound, high_bound;
7836 7830
7837 validate_line_start_cache (w); 7831 validate_line_start_cache (w);
7838 w->line_cache_validation_override++; 7832 w->line_cache_validation_override++;
7839 updating_line_start_cache = 1;
7840 7833
7841 if (from < BUF_BEGV (b)) 7834 if (from < BUF_BEGV (b))
7842 from = BUF_BEGV (b); 7835 from = BUF_BEGV (b);
7843 if (to > BUF_ZV (b)) 7836 if (to > BUF_ZV (b))
7844 to = BUF_ZV (b); 7837 to = BUF_ZV (b);
7845 7838
7846 if (from > to) 7839 if (from > to)
7847 { 7840 {
7848 updating_line_start_cache = 0;
7849 w->line_cache_validation_override--; 7841 w->line_cache_validation_override--;
7850 return; 7842 return;
7851 } 7843 }
7852 7844
7853 if (Dynarr_length (cache)) 7845 if (Dynarr_length (cache))
7856 high_bound = line_start_cache_end (w); 7848 high_bound = line_start_cache_end (w);
7857 7849
7858 /* Check to see if the desired range is already in the cache. */ 7850 /* Check to see if the desired range is already in the cache. */
7859 if (from >= low_bound && to <= high_bound) 7851 if (from >= low_bound && to <= high_bound)
7860 { 7852 {
7861 updating_line_start_cache = 0;
7862 w->line_cache_validation_override--; 7853 w->line_cache_validation_override--;
7863 return; 7854 return;
7864 } 7855 }
7865 7856
7866 /* Check to make sure that the desired range is adjacent to the 7857 /* Check to make sure that the desired range is adjacent to the
7885 Bufpos start, end; 7876 Bufpos start, end;
7886 7877
7887 update_internal_cache_list (w, DESIRED_DISP); 7878 update_internal_cache_list (w, DESIRED_DISP);
7888 if (!Dynarr_length (internal_cache)) 7879 if (!Dynarr_length (internal_cache))
7889 { 7880 {
7890 updating_line_start_cache = 0;
7891 w->line_cache_validation_override--; 7881 w->line_cache_validation_override--;
7892 return; 7882 return;
7893 } 7883 }
7894 7884
7895 start = Dynarr_atp (internal_cache, 0)->start; 7885 start = Dynarr_atp (internal_cache, 0)->start;
7913 7903
7914 if (!Dynarr_length (cache)) 7904 if (!Dynarr_length (cache))
7915 { 7905 {
7916 Dynarr_add_many (cache, Dynarr_atp (internal_cache, 0), 7906 Dynarr_add_many (cache, Dynarr_atp (internal_cache, 0),
7917 Dynarr_length (internal_cache)); 7907 Dynarr_length (internal_cache));
7918 updating_line_start_cache = 0;
7919 w->line_cache_validation_override--; 7908 w->line_cache_validation_override--;
7920 return; 7909 return;
7921 } 7910 }
7922 7911
7923 /* An extra check just in case the calling function didn't pass in 7912 /* An extra check just in case the calling function didn't pass in
7924 the bounds of the DESIRED structs in the first place. */ 7913 the bounds of the DESIRED structs in the first place. */
7925 if (start >= low_bound && end <= high_bound) 7914 if (start >= low_bound && end <= high_bound)
7926 { 7915 {
7927 updating_line_start_cache = 0;
7928 w->line_cache_validation_override--; 7916 w->line_cache_validation_override--;
7929 return; 7917 return;
7930 } 7918 }
7931 7919
7932 /* At this point we know that the internal cache partially overlaps 7920 /* At this point we know that the internal cache partially overlaps
7945 if (!(ic_elt >= 0)) 7933 if (!(ic_elt >= 0))
7946 { 7934 {
7947 Dynarr_reset (cache); 7935 Dynarr_reset (cache);
7948 Dynarr_add_many (cache, Dynarr_atp (internal_cache, 0), 7936 Dynarr_add_many (cache, Dynarr_atp (internal_cache, 0),
7949 Dynarr_length (internal_cache)); 7937 Dynarr_length (internal_cache));
7950 updating_line_start_cache = 0;
7951 w->line_cache_validation_override--; 7938 w->line_cache_validation_override--;
7952 return; 7939 return;
7953 } 7940 }
7954 7941
7955 Dynarr_insert_many_at_start (cache, Dynarr_atp (internal_cache, 0), 7942 Dynarr_insert_many_at_start (cache, Dynarr_atp (internal_cache, 0),
7971 if (!(ic_elt < Dynarr_length (internal_cache))) 7958 if (!(ic_elt < Dynarr_length (internal_cache)))
7972 { 7959 {
7973 Dynarr_reset (cache); 7960 Dynarr_reset (cache);
7974 Dynarr_add_many (cache, Dynarr_atp (internal_cache, 0), 7961 Dynarr_add_many (cache, Dynarr_atp (internal_cache, 0),
7975 Dynarr_length (internal_cache)); 7962 Dynarr_length (internal_cache));
7976 updating_line_start_cache = 0;
7977 w->line_cache_validation_override--; 7963 w->line_cache_validation_override--;
7978 return; 7964 return;
7979 } 7965 }
7980 7966
7981 Dynarr_add_many (cache, Dynarr_atp (internal_cache, ic_elt), 7967 Dynarr_add_many (cache, Dynarr_atp (internal_cache, ic_elt),
7982 Dynarr_length (internal_cache) - ic_elt); 7968 Dynarr_length (internal_cache) - ic_elt);
7983 } 7969 }
7984 7970
7985 updating_line_start_cache = 0;
7986 w->line_cache_validation_override--; 7971 w->line_cache_validation_override--;
7987 return; 7972 return;
7988 } 7973 }
7989 7974
7990 if (!Dynarr_length (cache) || from < low_bound) 7975 if (!Dynarr_length (cache) || from < low_bound)
8000 7985
8001 regenerate_window (w, startp, point, CMOTION_DISP); 7986 regenerate_window (w, startp, point, CMOTION_DISP);
8002 update_internal_cache_list (w, CMOTION_DISP); 7987 update_internal_cache_list (w, CMOTION_DISP);
8003 7988
8004 /* If this assert is triggered then regenerate_window failed 7989 /* If this assert is triggered then regenerate_window failed
8005 to layout a single line. That is not supposed to be 7990 to layout a single line. This is not possible since we
8006 possible because we impose a minimum height on the buffer 7991 force at least a single line to be layout for CMOTION_DISP */
8007 and override vertical clip when we are in here. */ 7992 assert (Dynarr_length (internal_cache));
8008 /* #### Ah, but it is because the window may temporarily
8009 exist but not have any lines at all if the minibuffer is
8010 real big. Look into that situation better. */
8011 if (!Dynarr_length (internal_cache))
8012 {
8013 if (old_lb == -1 && low_bound == -1)
8014 {
8015 updating_line_start_cache = 0;
8016 w->line_cache_validation_override--;
8017 return;
8018 }
8019
8020 assert (Dynarr_length (internal_cache));
8021 }
8022 assert (startp == Dynarr_atp (internal_cache, 0)->start); 7993 assert (startp == Dynarr_atp (internal_cache, 0)->start);
8023 7994
8024 ic_elt = Dynarr_length (internal_cache) - 1; 7995 ic_elt = Dynarr_length (internal_cache) - 1;
8025 if (low_bound != -1) 7996 if (low_bound != -1)
8026 { 7997 {
8062 if (startp < low_bound || low_bound == -1) 8033 if (startp < low_bound || low_bound == -1)
8063 low_bound = startp; 8034 low_bound = startp;
8064 startp = new_startp; 8035 startp = new_startp;
8065 if (startp > BUF_ZV (b)) 8036 if (startp > BUF_ZV (b))
8066 { 8037 {
8067 updating_line_start_cache = 0;
8068 w->line_cache_validation_override--; 8038 w->line_cache_validation_override--;
8069 return; 8039 return;
8070 } 8040 }
8071 } 8041 }
8072 } 8042 }
8096 startp = high_bound + 1; 8066 startp = high_bound + 1;
8097 } 8067 }
8098 while (to > high_bound); 8068 while (to > high_bound);
8099 } 8069 }
8100 8070
8101 updating_line_start_cache = 0;
8102 w->line_cache_validation_override--; 8071 w->line_cache_validation_override--;
8103 assert (to <= high_bound); 8072 assert (to <= high_bound);
8104 } 8073 }
8105 8074
8106 8075
8837 struct frame *f = XFRAME (XCAR (frmcons)); 8806 struct frame *f = XFRAME (XCAR (frmcons));
8838 8807
8839 if (FRAME_REPAINT_P (f) && FRAME_HAS_MINIBUF_P (f)) 8808 if (FRAME_REPAINT_P (f) && FRAME_HAS_MINIBUF_P (f))
8840 { 8809 {
8841 Lisp_Object window = FRAME_MINIBUF_WINDOW (f); 8810 Lisp_Object window = FRAME_MINIBUF_WINDOW (f);
8811
8812 MAYBE_DEVMETH (d, frame_output_begin, (f));
8813
8842 /* 8814 /*
8843 * If the frame size has changed, there may be random 8815 * If the frame size has changed, there may be random
8844 * chud on the screen left from previous messages 8816 * chud on the screen left from previous messages
8845 * because redisplay_frame hasn't been called yet. 8817 * because redisplay_frame hasn't been called yet.
8846 * Clear the screen to get rid of the potential mess. 8818 * Clear the screen to get rid of the potential mess.
8847 */ 8819 */
8848 if (f->echo_area_garbaged) 8820 if (f->echo_area_garbaged)
8849 { 8821 {
8850 DEVMETH (d, clear_frame, (f)); 8822 MAYBE_DEVMETH (d, clear_frame, (f));
8851 f->echo_area_garbaged = 0; 8823 f->echo_area_garbaged = 0;
8852 } 8824 }
8853 redisplay_window (window, 0); 8825 redisplay_window (window, 0);
8826 MAYBE_DEVMETH (d, frame_output_end, (f));
8827
8854 call_redisplay_end_triggers (XWINDOW (window), 0); 8828 call_redisplay_end_triggers (XWINDOW (window), 0);
8855 } 8829 }
8856 } 8830 }
8857
8858 /* We now call the output_end routine for tty frames. We delay
8859 doing so in order to avoid cursor flicker. So much for 100%
8860 encapsulation. */
8861 if (DEVICE_TTY_P (d))
8862 DEVMETH (d, output_end, (d));
8863 } 8831 }
8864 8832
8865 return Qnil; 8833 return Qnil;
8866 } 8834 }
8867 8835
9268 DEFSUBR (Fredraw_modeline); 9236 DEFSUBR (Fredraw_modeline);
9269 DEFSUBR (Fforce_cursor_redisplay); 9237 DEFSUBR (Fforce_cursor_redisplay);
9270 } 9238 }
9271 9239
9272 void 9240 void
9273 reinit_vars_of_redisplay (void)
9274 {
9275 updating_line_start_cache = 0;
9276 }
9277
9278 void
9279 vars_of_redisplay (void) 9241 vars_of_redisplay (void)
9280 { 9242 {
9281 reinit_vars_of_redisplay ();
9282 9243
9283 #if 0 9244 #if 0
9284 staticpro (&last_arrow_position); 9245 staticpro (&last_arrow_position);
9285 staticpro (&last_arrow_string); 9246 staticpro (&last_arrow_string);
9286 last_arrow_position = Qnil; 9247 last_arrow_position = Qnil;
9321 */ , 9282 */ ,
9322 redisplay_variable_changed); 9283 redisplay_variable_changed);
9323 Voverlay_arrow_position = Qnil; 9284 Voverlay_arrow_position = Qnil;
9324 9285
9325 DEFVAR_LISP_MAGIC ("overlay-arrow-string", &Voverlay_arrow_string /* 9286 DEFVAR_LISP_MAGIC ("overlay-arrow-string", &Voverlay_arrow_string /*
9326 String to display as an arrow. See also `overlay-arrow-position'. 9287 String or glyph to display as an arrow. See also `overlay-arrow-position'.
9288 (Note that despite the name of this variable, it can be set to a glyph as
9289 well as a string.)
9327 */ , 9290 */ ,
9328 redisplay_variable_changed); 9291 redisplay_variable_changed);
9329 Voverlay_arrow_string = Qnil; 9292 Voverlay_arrow_string = Qnil;
9330 9293
9331 DEFVAR_INT ("scroll-step", &scroll_step /* 9294 DEFVAR_INT ("scroll-step", &scroll_step /*