diff options
| author | Karl Heuer | 1995-05-13 01:44:04 +0000 |
|---|---|---|
| committer | Karl Heuer | 1995-05-13 01:44:04 +0000 |
| commit | 210e752ffa1842aa04bc566482aaf67ed9563328 (patch) | |
| tree | 90031487e0aa2eac564358c54c01d9c29e429f68 /src | |
| parent | 0383eb57dfd078de37c1871aad14c918e706fd7d (diff) | |
| download | emacs-210e752ffa1842aa04bc566482aaf67ed9563328.tar.gz emacs-210e752ffa1842aa04bc566482aaf67ed9563328.zip | |
(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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/xdisp.c | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/src/xdisp.c b/src/xdisp.c index cd5ec937217..1cf979bd6cc 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -54,6 +54,8 @@ 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. |
| @@ -936,8 +938,9 @@ redisplay () | |||
| 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 | } |
| @@ -1444,7 +1447,8 @@ redisplay_window (window, just_this_one) | |||
| 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, |
| @@ -1494,7 +1498,8 @@ redisplay_window (window, just_this_one) | |||
| 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 |
| @@ -1577,15 +1582,12 @@ redisplay_window (window, just_this_one) | |||
| 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 | { |
| @@ -1609,7 +1611,7 @@ 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); |
| @@ -1821,7 +1823,7 @@ try_window_id (window) | |||
| 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; |
| @@ -1836,7 +1838,7 @@ try_window_id (window) | |||
| 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 | } |
| @@ -1925,7 +1927,7 @@ try_window_id (window) | |||
| 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 |
| @@ -2107,8 +2109,7 @@ try_window_id (window) | |||
| 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); |
| @@ -2131,10 +2132,10 @@ try_window_id (window) | |||
| 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) |