Mercurial > emacs
comparison src/xdisp.c @ 25362:4b8bf7aa0497
(resize_mini_window): Do it for truncate-lines t as
well.
(redisplay_internal): Resize mini-window only if text might
have changed.
(display_echo_area): Reset displayed echo_area_buffer to nil
at the end if we're displaying a nil message.
author | Gerd Moellmann <gerd@gnu.org> |
---|---|
date | Sat, 21 Aug 1999 21:47:57 +0000 |
parents | 9747bbf3e480 |
children | d32d09a601e8 |
comparison
equal
deleted
inserted
replaced
25361:bf9932dab556 | 25362:4b8bf7aa0497 |
---|---|
5368 /* Someone switched buffers between print requests. */ | 5368 /* Someone switched buffers between print requests. */ |
5369 set_buffer_internal (XBUFFER (echo_area_buffer[0])); | 5369 set_buffer_internal (XBUFFER (echo_area_buffer[0])); |
5370 } | 5370 } |
5371 | 5371 |
5372 | 5372 |
5373 /* Display the current echo area message in window W. Value is | 5373 /* Display an echo area message in window W. Value is non-zero if W's |
5374 non-zero if W's height is changed. */ | 5374 height is changed. If display_last_displayed_message_p is |
5375 non-zero, display the message that was last displayed, otherwise | |
5376 display the current message. */ | |
5375 | 5377 |
5376 static int | 5378 static int |
5377 display_echo_area (w) | 5379 display_echo_area (w) |
5378 struct window *w; | 5380 struct window *w; |
5379 { | 5381 { |
5380 return with_echo_area_buffer (w, display_last_displayed_message_p, | 5382 int i, no_message_p, window_height_changed_p; |
5381 (int (*) ()) display_echo_area_1, w); | 5383 |
5384 /* If there is no message, we must call display_echo_area_1 | |
5385 nevertheless because it resizes the window. But we will have to | |
5386 reset the echo_area_buffer in question to nil at the end because | |
5387 with_echo_area_buffer will sets it to an empty buffer. */ | |
5388 i = display_last_displayed_message_p ? 1 : 0; | |
5389 no_message_p = NILP (echo_area_buffer[i]); | |
5390 | |
5391 window_height_changed_p | |
5392 = with_echo_area_buffer (w, display_last_displayed_message_p, | |
5393 (int (*) ()) display_echo_area_1, w); | |
5394 | |
5395 if (no_message_p) | |
5396 echo_area_buffer[i] = Qnil; | |
5397 | |
5398 return window_height_changed_p; | |
5382 } | 5399 } |
5383 | 5400 |
5384 | 5401 |
5385 /* Helper for display_echo_area. Display the current buffer which | 5402 /* Helper for display_echo_area. Display the current buffer which |
5386 contains the current echo area message in window W, a mini-window. | 5403 contains the current echo area message in window W, a mini-window. |
5404 clear_glyph_matrix (w->desired_matrix); | 5421 clear_glyph_matrix (w->desired_matrix); |
5405 XSETWINDOW (window, w); | 5422 XSETWINDOW (window, w); |
5406 SET_TEXT_POS (start, BEG, BEG_BYTE); | 5423 SET_TEXT_POS (start, BEG, BEG_BYTE); |
5407 try_window (window, start); | 5424 try_window (window, start); |
5408 | 5425 |
5409 /* The current buffer is the one containing the last displayed | |
5410 echo area message. */ | |
5411 XSETBUFFER (echo_area_buffer[1], current_buffer); | |
5412 | |
5413 return window_height_changed_p; | 5426 return window_height_changed_p; |
5414 } | 5427 } |
5415 | 5428 |
5416 | 5429 |
5417 /* Resize mini-window W to fit the size of its contents. Value is | 5430 /* Resize mini-window W to fit the size of its contents. Value is |
5427 xassert (MINI_WINDOW_P (w)); | 5440 xassert (MINI_WINDOW_P (w)); |
5428 | 5441 |
5429 if (!FRAME_MINIBUF_ONLY_P (f)) | 5442 if (!FRAME_MINIBUF_ONLY_P (f)) |
5430 { | 5443 { |
5431 struct it it; | 5444 struct it it; |
5445 struct window *root = XWINDOW (FRAME_ROOT_WINDOW (f)); | |
5446 int total_height = XFASTINT (root->height) + XFASTINT (w->height); | |
5447 int height, max_height; | |
5448 int unit = CANON_Y_UNIT (f); | |
5449 struct text_pos start; | |
5432 | 5450 |
5433 init_iterator (&it, w, BEGV, BEGV_BYTE, NULL, DEFAULT_FACE_ID); | 5451 init_iterator (&it, w, BEGV, BEGV_BYTE, NULL, DEFAULT_FACE_ID); |
5434 if (!it.truncate_lines_p) | 5452 |
5435 { | 5453 /* Compute the max. number of lines specified by the user. */ |
5436 struct window *root = XWINDOW (FRAME_ROOT_WINDOW (f)); | 5454 if (FLOATP (Vmax_mini_window_height)) |
5437 int total_height = XFASTINT (root->height) + XFASTINT (w->height); | 5455 max_height = XFLOATINT (Vmax_mini_window_height) * total_height; |
5438 int height, max_height; | 5456 else if (INTEGERP (Vmax_mini_window_height)) |
5439 int unit = CANON_Y_UNIT (f); | 5457 max_height = XINT (Vmax_mini_window_height); |
5440 struct text_pos start; | 5458 |
5441 | 5459 /* Correct that max. height if it's bogus. */ |
5442 /* Compute the max. number of lines specified by the user. */ | 5460 max_height = max (1, max_height); |
5443 if (FLOATP (Vmax_mini_window_height)) | 5461 max_height = min (total_height, max_height); |
5444 max_height = XFLOATINT (Vmax_mini_window_height) * total_height; | 5462 |
5445 else if (INTEGERP (Vmax_mini_window_height)) | 5463 /* Find out the height of the text in the window. */ |
5446 max_height = XINT (Vmax_mini_window_height); | 5464 move_it_to (&it, ZV, -1, -1, -1, MOVE_TO_POS); |
5447 | 5465 height = (unit - 1 + it.current_y + last_height) / unit; |
5448 /* Correct that max. height if it's bogus. */ | 5466 height = max (1, height); |
5449 max_height = max (1, max_height); | 5467 |
5450 max_height = min (total_height, max_height); | 5468 /* Compute a suitable window start. */ |
5451 | 5469 if (height > max_height) |
5452 /* Find out the height of the text in the window. */ | 5470 { |
5453 move_it_to (&it, ZV, -1, -1, -1, MOVE_TO_POS); | 5471 height = max_height; |
5454 height = (unit - 1 + it.current_y + last_height) / unit; | 5472 init_iterator (&it, w, PT, PT_BYTE, NULL, DEFAULT_FACE_ID); |
5455 height = max (1, height); | 5473 move_it_vertically_backward (&it, (height - 1) * unit); |
5456 | 5474 start = it.current.pos; |
5457 /* Compute a suitable window start. */ | 5475 } |
5458 if (height > max_height) | 5476 else |
5459 { | 5477 SET_TEXT_POS (start, BEGV, BEGV_BYTE); |
5460 height = max_height; | 5478 SET_MARKER_FROM_TEXT_POS (w->start, start); |
5461 init_iterator (&it, w, PT, PT_BYTE, NULL, DEFAULT_FACE_ID); | 5479 |
5462 move_it_vertically_backward (&it, (height - 1) * unit); | 5480 /* Change window's height, if necessary. */ |
5463 start = it.current.pos; | 5481 if (height != XFASTINT (w->height)) |
5464 } | 5482 { |
5465 else | 5483 Lisp_Object old_selected_window; |
5466 SET_TEXT_POS (start, BEGV, BEGV_BYTE); | 5484 |
5467 SET_MARKER_FROM_TEXT_POS (w->start, start); | 5485 old_selected_window = selected_window; |
5468 | 5486 XSETWINDOW (selected_window, w); |
5469 /* Change window's height, if necessary. */ | 5487 change_window_height (height - XFASTINT (w->height), 0); |
5470 if (height != XFASTINT (w->height)) | 5488 selected_window = old_selected_window; |
5471 { | 5489 window_height_changed_p = 1; |
5472 Lisp_Object old_selected_window; | |
5473 | |
5474 old_selected_window = selected_window; | |
5475 XSETWINDOW (selected_window, w); | |
5476 change_window_height (height - XFASTINT (w->height), 0); | |
5477 selected_window = old_selected_window; | |
5478 window_height_changed_p = 1; | |
5479 } | |
5480 } | 5490 } |
5481 } | 5491 } |
5482 | 5492 |
5483 return window_height_changed_p; | 5493 return window_height_changed_p; |
5484 } | 5494 } |
5811 update_frame (f, 1, 1); | 5821 update_frame (f, 1, 1); |
5812 } | 5822 } |
5813 } | 5823 } |
5814 else if (!EQ (mini_window, selected_window)) | 5824 else if (!EQ (mini_window, selected_window)) |
5815 windows_or_buffers_changed++; | 5825 windows_or_buffers_changed++; |
5816 | 5826 |
5817 if (NILP (echo_area_buffer[0])) | 5827 echo_area_buffer[1] = echo_area_buffer[0]; |
5818 clear_message (0, 1); | 5828 |
5819 | |
5820 /* Prevent redisplay optimization in redisplay_internal by resetting | 5829 /* Prevent redisplay optimization in redisplay_internal by resetting |
5821 this_line_start_pos. This is done because the mini-buffer now | 5830 this_line_start_pos. This is done because the mini-buffer now |
5822 displays the message instead of its buffer text. */ | 5831 displays the message instead of its buffer text. */ |
5823 if (EQ (mini_window, selected_window)) | 5832 if (EQ (mini_window, selected_window)) |
5824 CHARPOS (this_line_start_pos) = 0; | 5833 CHARPOS (this_line_start_pos) = 0; |
7005 the echo area should be cleared. */ | 7014 the echo area should be cleared. */ |
7006 if (!NILP (echo_area_buffer[0]) || !NILP (echo_area_buffer[1])) | 7015 if (!NILP (echo_area_buffer[0]) || !NILP (echo_area_buffer[1])) |
7007 { | 7016 { |
7008 int window_height_changed_p = echo_area_display (0); | 7017 int window_height_changed_p = echo_area_display (0); |
7009 must_finish = 1; | 7018 must_finish = 1; |
7019 | |
7010 if (fonts_changed_p) | 7020 if (fonts_changed_p) |
7011 goto retry; | 7021 goto retry; |
7012 else if (window_height_changed_p) | 7022 else if (window_height_changed_p) |
7013 { | 7023 { |
7014 consider_all_windows_p = 1; | 7024 consider_all_windows_p = 1; |
7015 ++update_mode_lines; | 7025 ++update_mode_lines; |
7016 ++windows_or_buffers_changed; | 7026 ++windows_or_buffers_changed; |
7017 } | 7027 } |
7018 } | 7028 } |
7019 else if (w == XWINDOW (minibuf_window) && resize_mini_window (w)) | 7029 else if (w == XWINDOW (minibuf_window) |
7030 && (current_buffer->clip_changed | |
7031 || XFASTINT (w->last_modified) < MODIFF | |
7032 || XFASTINT (w->last_overlay_modified) < OVERLAY_MODIFF) | |
7033 && resize_mini_window (w)) | |
7020 { | 7034 { |
7021 /* Resized active mini-window to fit the size of what it is | 7035 /* Resized active mini-window to fit the size of what it is |
7022 showing. */ | 7036 showing if its contents might have changed. */ |
7037 must_finish = 1; | |
7038 consider_all_windows_p = 1; | |
7023 ++windows_or_buffers_changed; | 7039 ++windows_or_buffers_changed; |
7024 goto retry; | 7040 ++update_mode_lines; |
7025 } | 7041 } |
7026 | 7042 |
7027 | 7043 |
7028 /* If showing the region, and mark has changed, we must redisplay | 7044 /* If showing the region, and mark has changed, we must redisplay |
7029 the whole window. The assignment to this_line_start_pos prevents | 7045 the whole window. The assignment to this_line_start_pos prevents |