Mercurial > emacs
comparison src/xdisp.c @ 1785:19755499df90
* window.c (window_internal_width): New function, which accounts
for scrollbars if present.
* lisp.h (window_internal_height, window_internal_width): Add
extern declarations for these.
* dispnew.c (direct_output_for_insert, direct_output_forward_char,
buffer_posn_from_coords): Use window_internal_width instead of
writing out its definition.
* indent.c (compute_motion): Doc fix; mention scrollbars and
window_internal_width.
(pos_tab_offset, Fvertical_motion): Use window_internal_width
instead of writing it out.
* window.c (Fpos_visible_in_window_p, Fwindow_width, Fscroll_left,
Fscroll_right): Same.
* xdisp.c (redisplay, try_window, try_window_id,
display_text_line): Same.
* xdisp.c (display_string): Add new variable `f', to be W's
frame. Use it to set desired_glyphs, and to get the frame's width
to decide whether or not to draw vertical bars.
* xdisp.c (display_text_line): If we're using vertical scrollbars,
don't draw the vertical bars separating side-by-side windows.
(display_string): Same thing. Draw spaces to fill in the part of
the mode line that is under the scrollbar in partial-width
windows.
* xdisp.c (display_text_line): Use the usable internal width of
the window, as calculated above, as the limit on the length of the
overlay arrow's image, rather than using the window's width field,
less one.
* xdisp.c (redisplay): Call condemn_scrollbars_hook and
judge_scrollbars_hook whenever they are set, not just when the
frame has vertical scrollbars.
* termhooks.h (mouse_position_hook): Doc fix.
(set_vertical_scrollbar_hook): This doesn't return anything any
more, and doesn't take a struct scrollbar * argument any more.
(condemn_scrollbars_hook, redeem_scrollbar_hook,
judge_scrollbars_hook): Doc fixes.
* term.c (mouse_position_hook): Doc fix.
(set_vertical_scrollbar_hook): This doesn't return
anything any more. Doc fixes.
* keyboard.c (kbd_buffer_get_event): Receive the scrollbar's
window from *mouse_position_hook and pass it to
make_lispy_movement, instead of working with a pointer to a struct
scrollbar.
(make_lispy_event): We don't need a window_from_scrollbar function
anymore; we are given the window directly in *EVENT.
Unify the code which generates
text-area mouse clicks and scrollbar clicks; use the same code to
distinguish clicks from drags on the scrollbar as in the text area.
Distinguish clicks from drags by storing a copy of the lispy
position list returned as part of the event.
(button_down_location): Make this a lisp vector, rather than an
array of random structures.
(struct mouse_position): Remove this; it's been replaced by a lisp
list.
(make_lispy_movement): Accept the scrollbar's window as a
parameter, rather than the scrollbar itself.
If FRAME is zero, assume that the other arguments are garbage.
(syms_of_keyboard): No need to staticpro each window of
button_down_location now; just initialize and staticpro it.
* window.c (window_from_scrollbar): Function deleted; no longer
needed.
* xdisp.c (redisplay_window): Just pass the window to
set_vertical_scrollbar hook; don't pass the scrollbar object too.
* xterm.c (XTmouse_position): Don't return a pointer to the
scrollbar for scrollbar motion; instead, return the scrollbar's
window.
* xdisp.c (echo_area_display): Move the assignment of f and the
check for visibility out of the "#ifdef MULTI_FRAME" clause; they
should work under any circumstances.
* xdisp.c (redisplay_window): If we're not going to redisplay this
window because it's a minibuffer whose contents have already been
updated, go ahead and jump to the scrollbar refreshing code
anyway; they still need to be updated. Initialize opoint, so it's
known to be valid when we jump. Calculate the scrollbar settings
properly for minibuffers, no matter what they are displaying at
the time.
* xdisp.c (redisplay_windows): Don't restore the current buffer
and its point before refreshing the scrollbars; we need the buffer
accurate.
author | Jim Blandy <jimb@redhat.com> |
---|---|
date | Thu, 14 Jan 1993 15:18:53 +0000 |
parents | f80c1f73f5b9 |
children | c5038f47c602 |
comparison
equal
deleted
inserted
replaced
1784:11f62e53acff | 1785:19755499df90 |
---|---|
1 /* Display generation from window structure and buffer text. | 1 /* Display generation from window structure and buffer text. |
2 Copyright (C) 1985, 1986, 1987, 1988, 1992 Free Software Foundation, Inc. | 2 Copyright (C) 1985, 1986, 1987, 1988, 1992, 1993 Free Software Foundation, Inc. |
3 | 3 |
4 This file is part of GNU Emacs. | 4 This file is part of GNU Emacs. |
5 | 5 |
6 GNU Emacs is free software; you can redistribute it and/or modify | 6 GNU Emacs is free software; you can redistribute it and/or modify |
7 it under the terms of the GNU General Public License as published by | 7 it under the terms of the GNU General Public License as published by |
8 the Free Software Foundation; either version 1, or (at your option) | 8 the Free Software Foundation; either version 2, or (at your option) |
9 any later version. | 9 any later version. |
10 | 10 |
11 GNU Emacs is distributed in the hope that it will be useful, | 11 GNU Emacs is distributed in the hope that it will be useful, |
12 but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
272 register int vpos; | 272 register int vpos; |
273 FRAME_PTR f; | 273 FRAME_PTR f; |
274 | 274 |
275 #ifdef MULTI_FRAME | 275 #ifdef MULTI_FRAME |
276 choose_minibuf_frame (); | 276 choose_minibuf_frame (); |
277 #endif | |
278 | |
277 f = XFRAME (WINDOW_FRAME (XWINDOW (minibuf_window))); | 279 f = XFRAME (WINDOW_FRAME (XWINDOW (minibuf_window))); |
278 | 280 |
279 if (! FRAME_VISIBLE_P (f)) | 281 if (! FRAME_VISIBLE_P (f)) |
280 return; | 282 return; |
281 #endif | |
282 | 283 |
283 if (frame_garbaged) | 284 if (frame_garbaged) |
284 { | 285 { |
285 Fredraw_display (); | 286 Fredraw_display (); |
286 frame_garbaged = 0; | 287 frame_garbaged = 0; |
463 else | 464 else |
464 { | 465 { |
465 pos = *compute_motion (tlbufpos, 0, | 466 pos = *compute_motion (tlbufpos, 0, |
466 XINT (w->hscroll) ? 1 - XINT (w->hscroll) : 0, | 467 XINT (w->hscroll) ? 1 - XINT (w->hscroll) : 0, |
467 point, 2, - (1 << (SHORTBITS - 1)), | 468 point, 2, - (1 << (SHORTBITS - 1)), |
468 XFASTINT (w->width) - 1 | 469 window_internal_width (w) - 1, |
469 - (XFASTINT (w->width) + XFASTINT (w->left) | |
470 != FRAME_WIDTH (selected_frame)), | |
471 XINT (w->hscroll), | 470 XINT (w->hscroll), |
472 pos_tab_offset (w, tlbufpos)); | 471 pos_tab_offset (w, tlbufpos)); |
473 if (pos.vpos < 1) | 472 if (pos.vpos < 1) |
474 { | 473 { |
475 FRAME_CURSOR_X (selected_frame) | 474 FRAME_CURSOR_X (selected_frame) |
499 | 498 |
500 FOR_EACH_FRAME (tail, f) | 499 FOR_EACH_FRAME (tail, f) |
501 { | 500 { |
502 /* Mark all the scrollbars to be removed; we'll redeem the ones | 501 /* Mark all the scrollbars to be removed; we'll redeem the ones |
503 we want when we redisplay their windows. */ | 502 we want when we redisplay their windows. */ |
504 if (FRAME_HAS_VERTICAL_SCROLLBARS (f)) | 503 if (condemn_scrollbars_hook) |
505 (*condemn_scrollbars_hook) (f); | 504 (*condemn_scrollbars_hook) (f); |
506 | 505 |
507 if (FRAME_VISIBLE_P (f)) | 506 if (FRAME_VISIBLE_P (f)) |
508 redisplay_windows (FRAME_ROOT_WINDOW (f)); | 507 redisplay_windows (FRAME_ROOT_WINDOW (f)); |
509 | 508 |
510 /* Any scrollbars which redisplay_windows should have nuked | 509 /* Any scrollbars which redisplay_windows should have nuked |
511 should now go away. */ | 510 should now go away. */ |
512 if (FRAME_HAS_VERTICAL_SCROLLBARS (f)) | 511 if (judge_scrollbars_hook) |
513 (*judge_scrollbars_hook) (f); | 512 (*judge_scrollbars_hook) (f); |
514 } | 513 } |
515 } | 514 } |
516 else if (FRAME_VISIBLE_P (selected_frame)) | 515 else if (FRAME_VISIBLE_P (selected_frame)) |
517 { | 516 { |
712 register struct window *w = XWINDOW (window); | 711 register struct window *w = XWINDOW (window); |
713 FRAME_PTR f = XFRAME (WINDOW_FRAME (w)); | 712 FRAME_PTR f = XFRAME (WINDOW_FRAME (w)); |
714 int height; | 713 int height; |
715 register int lpoint = point; | 714 register int lpoint = point; |
716 struct buffer *old = current_buffer; | 715 struct buffer *old = current_buffer; |
717 register int width = XFASTINT (w->width) - 1 | 716 register int width = window_internal_width (w) - 1; |
718 - (XFASTINT (w->width) + XFASTINT (w->left) != FRAME_WIDTH (f)); | |
719 register int startp; | 717 register int startp; |
720 register int hscroll = XINT (w->hscroll); | 718 register int hscroll = XINT (w->hscroll); |
721 struct position pos; | 719 struct position pos; |
722 int opoint; | 720 int opoint = point; |
723 int tem; | 721 int tem; |
724 int window_needs_modeline; | 722 int window_needs_modeline; |
725 | 723 |
726 if (FRAME_HEIGHT (f) == 0) abort (); /* Some bug zeros some core */ | 724 if (FRAME_HEIGHT (f) == 0) abort (); /* Some bug zeros some core */ |
727 | 725 |
746 { | 744 { |
747 if (w == XWINDOW (minibuf_window)) | 745 if (w == XWINDOW (minibuf_window)) |
748 { | 746 { |
749 if (echo_area_glyphs) | 747 if (echo_area_glyphs) |
750 /* We've already displayed the echo area glyphs, if any. */ | 748 /* We've already displayed the echo area glyphs, if any. */ |
751 return; | 749 goto finish_scrollbars; |
752 } | 750 } |
753 else | 751 else |
754 { | 752 { |
755 /* This is a minibuffer, but it's not the currently active one, so | 753 /* This is a minibuffer, but it's not the currently active one, so |
756 clear it. */ | 754 clear it. */ |
761 { | 759 { |
762 get_display_line (f, vpos + i, 0); | 760 get_display_line (f, vpos + i, 0); |
763 display_string (w, vpos + i, "", 0, 0, 0, width); | 761 display_string (w, vpos + i, "", 0, 0, 0, width); |
764 } | 762 } |
765 | 763 |
766 return; | 764 goto finish_scrollbars; |
767 } | 765 } |
768 } | 766 } |
769 | 767 |
770 if (update_mode_lines) | 768 if (update_mode_lines) |
771 w->update_mode_line = Qt; | 769 w->update_mode_line = Qt; |
965 if ((!NILP (w->update_mode_line) | 963 if ((!NILP (w->update_mode_line) |
966 || (!just_this_one && width < FRAME_WIDTH (f) - 1)) | 964 || (!just_this_one && width < FRAME_WIDTH (f) - 1)) |
967 && height != XFASTINT (w->height)) | 965 && height != XFASTINT (w->height)) |
968 display_mode_line (w); | 966 display_mode_line (w); |
969 | 967 |
968 finish_scrollbars: | |
969 if (FRAME_HAS_VERTICAL_SCROLLBARS (f)) | |
970 { | |
971 int start, end, whole; | |
972 | |
973 /* Calculate the start and end positions for the current window. | |
974 Note that minibuffers sometimes aren't displaying any text. */ | |
975 if (! MINI_WINDOW_P (w) | |
976 || (w == XWINDOW (minibuf_window) && ! echo_area_glyphs)) | |
977 { | |
978 start = startp; | |
979 /* I don't think this is guaranteed to be right. For the | |
980 moment, we'll pretend it is. */ | |
981 end = Z - XINT (w->window_end_pos); | |
982 whole = Z - BEG; | |
983 } | |
984 else | |
985 start = end = whole = 0; | |
986 | |
987 /* Indicate what this scrollbar ought to be displaying now. */ | |
988 (*set_vertical_scrollbar_hook) (w, end - start, whole, start - 1); | |
989 | |
990 /* Note that we actually used the scrollbar attached to this window, | |
991 so it shouldn't be deleted at the end of redisplay. */ | |
992 (*redeem_scrollbar_hook) (w); | |
993 } | |
994 | |
970 SET_PT (opoint); | 995 SET_PT (opoint); |
971 current_buffer = old; | 996 current_buffer = old; |
972 SET_PT (lpoint); | 997 SET_PT (lpoint); |
973 | |
974 if (FRAME_HAS_VERTICAL_SCROLLBARS (f)) | |
975 { | |
976 struct scrollbar *bar = WINDOW_VERTICAL_SCROLLBAR (w); | |
977 | |
978 /* This isn't guaranteed to be right. For the moment, we'll pretend | |
979 it is. */ | |
980 int endp = Z - XINT (w->window_end_pos); | |
981 | |
982 /* Indicate what this scrollbar ought to be displaying now. */ | |
983 bar = ((*set_vertical_scrollbar_hook) | |
984 (bar, w, endp - startp, Z - BEG, startp)); | |
985 | |
986 /* Note that we actually used the scrollbar attached to this window, | |
987 so it shouldn't be deleted at the end of redisplay. */ | |
988 (*redeem_scrollbar_hook) (bar); | |
989 | |
990 XSET (w->vertical_scrollbar, Lisp_Int, bar); | |
991 } | |
992 } | 998 } |
993 | 999 |
994 /* Do full redisplay on one window, starting at position `pos'. */ | 1000 /* Do full redisplay on one window, starting at position `pos'. */ |
995 | 1001 |
996 static void | 1002 static void |
1002 register int height = window_internal_height (w); | 1008 register int height = window_internal_height (w); |
1003 register int vpos = XFASTINT (w->top); | 1009 register int vpos = XFASTINT (w->top); |
1004 register int last_text_vpos = vpos; | 1010 register int last_text_vpos = vpos; |
1005 int tab_offset = pos_tab_offset (w, pos); | 1011 int tab_offset = pos_tab_offset (w, pos); |
1006 FRAME_PTR f = XFRAME (w->frame); | 1012 FRAME_PTR f = XFRAME (w->frame); |
1007 int width = XFASTINT (w->width) - 1 | 1013 int width = window_internal_width (w) - 1; |
1008 - (XFASTINT (w->width) + XFASTINT (w->left) != FRAME_WIDTH (f)); | |
1009 struct position val; | 1014 struct position val; |
1010 | 1015 |
1011 Fset_marker (w->start, make_number (pos), Qnil); | 1016 Fset_marker (w->start, make_number (pos), Qnil); |
1012 cursor_vpos = -1; | 1017 cursor_vpos = -1; |
1013 overlay_arrow_seen = 0; | 1018 overlay_arrow_seen = 0; |
1058 register struct window *w = XWINDOW (window); | 1063 register struct window *w = XWINDOW (window); |
1059 register int height = window_internal_height (w); | 1064 register int height = window_internal_height (w); |
1060 FRAME_PTR f = XFRAME (w->frame); | 1065 FRAME_PTR f = XFRAME (w->frame); |
1061 int top = XFASTINT (w->top); | 1066 int top = XFASTINT (w->top); |
1062 int start = marker_position (w->start); | 1067 int start = marker_position (w->start); |
1063 int width = XFASTINT (w->width) - 1 | 1068 int width = window_internal_width (w) - 1; |
1064 - (XFASTINT (w->width) + XFASTINT (w->left) != FRAME_WIDTH (f)); | |
1065 int hscroll = XINT (w->hscroll); | 1069 int hscroll = XINT (w->hscroll); |
1066 int lmargin = hscroll > 0 ? 1 - hscroll : 0; | 1070 int lmargin = hscroll > 0 ? 1 - hscroll : 0; |
1067 register int vpos; | 1071 register int vpos; |
1068 register int i, tem; | 1072 register int i, tem; |
1069 int last_text_vpos = 0; | 1073 int last_text_vpos = 0; |
1474 register GLYPH *startp; | 1478 register GLYPH *startp; |
1475 register GLYPH *p1prev; | 1479 register GLYPH *p1prev; |
1476 FRAME_PTR f = XFRAME (w->frame); | 1480 FRAME_PTR f = XFRAME (w->frame); |
1477 int tab_width = XINT (current_buffer->tab_width); | 1481 int tab_width = XINT (current_buffer->tab_width); |
1478 int ctl_arrow = !NILP (current_buffer->ctl_arrow); | 1482 int ctl_arrow = !NILP (current_buffer->ctl_arrow); |
1479 int width = XFASTINT (w->width) - 1 | 1483 int width = window_internal_width (w) - 1; |
1480 - (XFASTINT (w->width) + XFASTINT (w->left) != FRAME_WIDTH (f)); | |
1481 struct position val; | 1484 struct position val; |
1482 int lastpos; | 1485 int lastpos; |
1483 int invis; | 1486 int invis; |
1484 int hscroll = XINT (w->hscroll); | 1487 int hscroll = XINT (w->hscroll); |
1485 int truncate = hscroll | 1488 int truncate = hscroll |
1741 if (XFASTINT (w->width) + XFASTINT (w->left) != FRAME_WIDTH (f)) | 1744 if (XFASTINT (w->width) + XFASTINT (w->left) != FRAME_WIDTH (f)) |
1742 { | 1745 { |
1743 endp++; | 1746 endp++; |
1744 if (p1 < startp) p1 = startp; | 1747 if (p1 < startp) p1 = startp; |
1745 while (p1 < endp) *p1++ = SPACEGLYPH; | 1748 while (p1 < endp) *p1++ = SPACEGLYPH; |
1746 *p1++ = '|'; | 1749 |
1750 /* Don't draw vertical bars if we're using scrollbars. They're | |
1751 covered up by the scrollbars, and it's distracting to see | |
1752 them when the scrollbar windows are flickering around to be | |
1753 reconfigured. */ | |
1754 *p1++ = (FRAME_HAS_VERTICAL_SCROLLBARS (f) | |
1755 ? ' ' : '|'); | |
1747 } | 1756 } |
1748 desired_glyphs->used[vpos] = max (desired_glyphs->used[vpos], | 1757 desired_glyphs->used[vpos] = max (desired_glyphs->used[vpos], |
1749 p1 - desired_glyphs->glyphs[vpos]); | 1758 p1 - desired_glyphs->glyphs[vpos]); |
1750 desired_glyphs->glyphs[vpos][desired_glyphs->used[vpos]] = 0; | 1759 desired_glyphs->glyphs[vpos][desired_glyphs->used[vpos]] = 0; |
1751 | 1760 |
1760 { | 1769 { |
1761 unsigned char *p = XSTRING (Voverlay_arrow_string)->data; | 1770 unsigned char *p = XSTRING (Voverlay_arrow_string)->data; |
1762 int i; | 1771 int i; |
1763 int len = XSTRING (Voverlay_arrow_string)->size; | 1772 int len = XSTRING (Voverlay_arrow_string)->size; |
1764 | 1773 |
1765 if (len > XFASTINT (w->width) - 1) | 1774 if (len > width) |
1766 len = XFASTINT (w->width) - 1; | 1775 len = width; |
1767 for (i = 0; i < len; i++) | 1776 for (i = 0; i < len; i++) |
1768 startp[i] = p[i]; | 1777 startp[i] = p[i]; |
1769 if (desired_glyphs->used[vpos] < | 1778 if (desired_glyphs->used[vpos] < |
1770 (len + startp - desired_glyphs->glyphs[vpos])) | 1779 (len + startp - desired_glyphs->glyphs[vpos])) |
1771 desired_glyphs->used[vpos] = len + startp - desired_glyphs->glyphs[vpos]; | 1780 desired_glyphs->used[vpos] = len + startp - desired_glyphs->glyphs[vpos]; |
2212 register GLYPH *p1; | 2221 register GLYPH *p1; |
2213 int hscroll = XINT (w->hscroll); | 2222 int hscroll = XINT (w->hscroll); |
2214 int tab_width = XINT (XBUFFER (w->buffer)->tab_width); | 2223 int tab_width = XINT (XBUFFER (w->buffer)->tab_width); |
2215 register GLYPH *start; | 2224 register GLYPH *start; |
2216 register GLYPH *end; | 2225 register GLYPH *end; |
2217 struct frame_glyphs *desired_glyphs = FRAME_DESIRED_GLYPHS (XFRAME (w->frame)); | 2226 FRAME_PTR f = XFRAME (WINDOW_FRAME (w)); |
2227 struct frame_glyphs *desired_glyphs = FRAME_DESIRED_GLYPHS (f); | |
2218 GLYPH *p1start = desired_glyphs->glyphs[vpos] + hpos; | 2228 GLYPH *p1start = desired_glyphs->glyphs[vpos] + hpos; |
2219 int window_width = XFASTINT (w->width); | 2229 int window_width = XFASTINT (w->width); |
2220 | 2230 |
2221 /* Use the standard display table, not the window's display table. | 2231 /* Use the standard display table, not the window's display table. |
2222 We don't want the mode line in rot13. */ | 2232 We don't want the mode line in rot13. */ |
2230 | 2240 |
2231 p1 = p1start; | 2241 p1 = p1start; |
2232 start = desired_glyphs->glyphs[vpos] + XFASTINT (w->left); | 2242 start = desired_glyphs->glyphs[vpos] + XFASTINT (w->left); |
2233 end = start + window_width - (truncate != 0); | 2243 end = start + window_width - (truncate != 0); |
2234 | 2244 |
2235 if ((window_width + XFASTINT (w->left)) | 2245 if ((window_width + XFASTINT (w->left)) != FRAME_WIDTH (f)) |
2236 != FRAME_WIDTH (XFRAME (WINDOW_FRAME (w)))) | 2246 { |
2237 *end-- = '|'; | 2247 if (FRAME_HAS_VERTICAL_SCROLLBARS (f)) |
2248 { | |
2249 int i; | |
2250 | |
2251 for (i = 0; i < VERTICAL_SCROLLBAR_WIDTH; i++) | |
2252 *end-- = ' '; | |
2253 } | |
2254 else | |
2255 *end-- = '|'; | |
2256 } | |
2238 | 2257 |
2239 if (maxcol >= 0 && end - desired_glyphs->glyphs[vpos] > maxcol) | 2258 if (maxcol >= 0 && end - desired_glyphs->glyphs[vpos] > maxcol) |
2240 end = desired_glyphs->glyphs[vpos] + maxcol; | 2259 end = desired_glyphs->glyphs[vpos] + maxcol; |
2241 if (maxcol >= 0 && mincol > maxcol) | 2260 if (maxcol >= 0 && mincol > maxcol) |
2242 mincol = maxcol; | 2261 mincol = maxcol; |