comparison src/xdisp.c @ 11810:986414eefde0

(minmax): New macro. (redisplay, redisplay_window, try_window_id): Clip cursor hpos at both low and high extremes, in anticipation of a change to compute_motion.
author Karl Heuer <kwzh@gnu.org>
date Sat, 13 May 1995 01:44:04 +0000
parents 4166c8ea623d
children 637c5283e74b
comparison
equal deleted inserted replaced
11809:56ffc162094b 11810:986414eefde0
52 52
53 static int message_log_need_newline; 53 static int message_log_need_newline;
54 54
55 #define min(a, b) ((a) < (b) ? (a) : (b)) 55 #define min(a, b) ((a) < (b) ? (a) : (b))
56 #define max(a, b) ((a) > (b) ? (a) : (b)) 56 #define max(a, b) ((a) > (b) ? (a) : (b))
57 #define minmax(floor, val, ceil) \
58 ((val) < (floor) ? (floor) : (val) > (ceil) ? (ceil) : (val))
57 59
58 /* The buffer position of the first character appearing 60 /* The buffer position of the first character appearing
59 entirely or partially on the current frame line. 61 entirely or partially on the current frame line.
60 Or zero, which disables the optimization for the current frame line. */ 62 Or zero, which disables the optimization for the current frame line. */
61 static int this_line_bufpos; 63 static int this_line_bufpos;
934 window_internal_width (w) - 1, 936 window_internal_width (w) - 1,
935 XINT (w->hscroll), 937 XINT (w->hscroll),
936 pos_tab_offset (w, tlbufpos), w); 938 pos_tab_offset (w, tlbufpos), w);
937 if (pos.vpos < 1) 939 if (pos.vpos < 1)
938 { 940 {
941 int width = window_internal_width (w) - 1;
939 FRAME_CURSOR_X (selected_frame) 942 FRAME_CURSOR_X (selected_frame)
940 = XFASTINT (w->left) + max (pos.hpos, 0); 943 = XFASTINT (w->left) + minmax (0, pos.hpos, width);
941 FRAME_CURSOR_Y (selected_frame) = this_line_vpos; 944 FRAME_CURSOR_Y (selected_frame) = this_line_vpos;
942 goto update; 945 goto update;
943 } 946 }
944 else 947 else
945 goto cancel; 948 goto cancel;
1442 Fset_marker (w->pointm, make_number (PT), Qnil); 1445 Fset_marker (w->pointm, make_number (PT), Qnil);
1443 else 1446 else
1444 { 1447 {
1445 if (current_buffer == old) 1448 if (current_buffer == old)
1446 lpoint = PT; 1449 lpoint = PT;
1447 FRAME_CURSOR_X (f) = max (0, pos.hpos) + XFASTINT (w->left); 1450 FRAME_CURSOR_X (f) = (XFASTINT (w->left)
1451 + minmax (0, pos.hpos, width));
1448 FRAME_CURSOR_Y (f) = pos.vpos + XFASTINT (w->top); 1452 FRAME_CURSOR_Y (f) = pos.vpos + XFASTINT (w->top);
1449 } 1453 }
1450 /* If we are highlighting the region, 1454 /* If we are highlighting the region,
1451 then we just changed the region, so redisplay to show it. */ 1455 then we just changed the region, so redisplay to show it. */
1452 if (!NILP (Vtransient_mark_mode) 1456 if (!NILP (Vtransient_mark_mode)
1492 { 1496 {
1493 /* Ok, point is still on frame */ 1497 /* Ok, point is still on frame */
1494 if (w == XWINDOW (FRAME_SELECTED_WINDOW (f))) 1498 if (w == XWINDOW (FRAME_SELECTED_WINDOW (f)))
1495 { 1499 {
1496 /* These variables are supposed to be origin 1 */ 1500 /* These variables are supposed to be origin 1 */
1497 FRAME_CURSOR_X (f) = max (0, pos.hpos) + XFASTINT (w->left); 1501 FRAME_CURSOR_X (f) = (XFASTINT (w->left)
1502 + minmax (0, pos.hpos, width));
1498 FRAME_CURSOR_Y (f) = pos.vpos + XFASTINT (w->top); 1503 FRAME_CURSOR_Y (f) = pos.vpos + XFASTINT (w->top);
1499 } 1504 }
1500 /* This doesn't do the trick, because if a window to the right of 1505 /* This doesn't do the trick, because if a window to the right of
1501 this one must be redisplayed, this does nothing because there 1506 this one must be redisplayed, this does nothing because there
1502 is nothing in DesiredFrame yet, and then the other window is 1507 is nothing in DesiredFrame yet, and then the other window is
1575 1580
1576 if (scroll_step && !clip_changed) 1581 if (scroll_step && !clip_changed)
1577 { 1582 {
1578 if (PT > startp) 1583 if (PT > startp)
1579 { 1584 {
1580 pos = *vmotion (Z - XFASTINT (w->window_end_pos), 1585 pos = *vmotion (Z - XFASTINT (w->window_end_pos), scroll_step, w);
1581 scroll_step, width, hscroll, window);
1582 if (pos.vpos >= height) 1586 if (pos.vpos >= height)
1583 goto scroll_fail; 1587 goto scroll_fail;
1584 } 1588 }
1585 1589
1586 pos = *vmotion (startp, 1590 pos = *vmotion (startp, (PT < startp ? - scroll_step : scroll_step), w);
1587 (PT < startp ? - scroll_step : scroll_step),
1588 width, hscroll, window);
1589 1591
1590 if (PT >= pos.bufpos) 1592 if (PT >= pos.bufpos)
1591 { 1593 {
1592 try_window (window, pos.bufpos); 1594 try_window (window, pos.bufpos);
1593 if (cursor_vpos >= 0) 1595 if (cursor_vpos >= 0)
1607 1609
1608 recenter: 1610 recenter:
1609 /* Forget any previously recorded base line for line number display. */ 1611 /* Forget any previously recorded base line for line number display. */
1610 w->base_line_number = Qnil; 1612 w->base_line_number = Qnil;
1611 1613
1612 pos = *vmotion (PT, - (height / 2), width, hscroll, window); 1614 pos = *vmotion (PT, - (height / 2), w);
1613 try_window (window, pos.bufpos); 1615 try_window (window, pos.bufpos);
1614 1616
1615 startp = marker_position (w->start); 1617 startp = marker_position (w->start);
1616 w->start_at_line_beg 1618 w->start_at_line_beg
1617 = (startp == BEGV || FETCH_CHAR (startp - 1) == '\n') ? Qt : Qnil; 1619 = (startp == BEGV || FETCH_CHAR (startp - 1) == '\n') ? Qt : Qnil;
1819 } 1821 }
1820 1822
1821 vpos = bp.vpos; 1823 vpos = bp.vpos;
1822 1824
1823 /* Find beginning of that frame line. Must display from there. */ 1825 /* Find beginning of that frame line. Must display from there. */
1824 bp = *vmotion (bp.bufpos, 0, width, hscroll, window); 1826 bp = *vmotion (bp.bufpos, 0, w);
1825 1827
1826 pos = bp.bufpos; 1828 pos = bp.bufpos;
1827 val.hpos = lmargin; 1829 val.hpos = lmargin;
1828 if (pos < start) 1830 if (pos < start)
1829 return -1; 1831 return -1;
1834 if ((bp.contin && bp.bufpos - 1 == beg_unchanged && vpos > 0) 1836 if ((bp.contin && bp.bufpos - 1 == beg_unchanged && vpos > 0)
1835 || 1837 ||
1836 /* Likewise if we have to worry about selective display. */ 1838 /* Likewise if we have to worry about selective display. */
1837 (selective > 0 && bp.bufpos - 1 == beg_unchanged && vpos > 0)) 1839 (selective > 0 && bp.bufpos - 1 == beg_unchanged && vpos > 0))
1838 { 1840 {
1839 bp = *vmotion (bp.bufpos, -1, width, hscroll, window); 1841 bp = *vmotion (bp.bufpos, -1, w);
1840 --vpos; 1842 --vpos;
1841 pos = bp.bufpos; 1843 pos = bp.bufpos;
1842 } 1844 }
1843 1845
1844 if (bp.contin && bp.hpos != lmargin) 1846 if (bp.contin && bp.hpos != lmargin)
1923 pos_tab_offset (w, xp.bufpos), w); 1925 pos_tab_offset (w, xp.bufpos), w);
1924 } 1926 }
1925 if (pp.bufpos < PT || pp.vpos == height) 1927 if (pp.bufpos < PT || pp.vpos == height)
1926 return 0; 1928 return 0;
1927 cursor_vpos = pp.vpos + top; 1929 cursor_vpos = pp.vpos + top;
1928 cursor_hpos = pp.hpos + XFASTINT (w->left); 1930 cursor_hpos = XFASTINT (w->left) + minmax (0, pp.hpos, width);
1929 } 1931 }
1930 1932
1931 if (stop_vpos - scroll_amount >= height 1933 if (stop_vpos - scroll_amount >= height
1932 || ep.bufpos == xp.bufpos) 1934 || ep.bufpos == xp.bufpos)
1933 { 1935 {
2105 delta = height - xp.vpos; 2107 delta = height - xp.vpos;
2106 if (delta < 0 2108 if (delta < 0
2107 || (delta > 0 && xp.bufpos <= ZV) 2109 || (delta > 0 && xp.bufpos <= ZV)
2108 || (delta == 0 && xp.hpos)) 2110 || (delta == 0 && xp.hpos))
2109 { 2111 {
2110 val = *vmotion (Z - XFASTINT (w->window_end_pos), 2112 val = *vmotion (Z - XFASTINT (w->window_end_pos), delta, w);
2111 delta, width, hscroll, window);
2112 XSETFASTINT (w->window_end_pos, Z - val.bufpos); 2113 XSETFASTINT (w->window_end_pos, Z - val.bufpos);
2113 XSETFASTINT (w->window_end_vpos, 2114 XSETFASTINT (w->window_end_vpos,
2114 XFASTINT (w->window_end_vpos) + val.vpos); 2115 XFASTINT (w->window_end_vpos) + val.vpos);
2115 } 2116 }
2116 } 2117 }
2129 for (vpos = 0; vpos < height; vpos++) 2130 for (vpos = 0; vpos < height; vpos++)
2130 cancel_line (vpos + top, f); 2131 cancel_line (vpos + top, f);
2131 return 0; 2132 return 0;
2132 } 2133 }
2133 cursor_vpos = val.vpos + top; 2134 cursor_vpos = val.vpos + top;
2134 cursor_hpos = val.hpos + XFASTINT (w->left); 2135 cursor_hpos = XFASTINT (w->left) + minmax (0, val.hpos, width);
2135 } 2136 }
2136 2137
2137 FRAME_CURSOR_X (f) = max (0, cursor_hpos); 2138 FRAME_CURSOR_X (f) = cursor_hpos;
2138 FRAME_CURSOR_Y (f) = cursor_vpos; 2139 FRAME_CURSOR_Y (f) = cursor_vpos;
2139 2140
2140 if (debug_end_pos) 2141 if (debug_end_pos)
2141 { 2142 {
2142 val = *compute_motion (start, 0, lmargin, ZV, 2143 val = *compute_motion (start, 0, lmargin, ZV,