diff options
| author | Xue Fuqiao | 2013-09-04 08:39:34 +0800 |
|---|---|---|
| committer | Xue Fuqiao | 2013-09-04 08:39:34 +0800 |
| commit | adf2fc4a01efe77d73cd52bc9173914ed56ff531 (patch) | |
| tree | a5a280a5554a7bffeaf94fccae29fa3ac1a5d066 /src/window.c | |
| parent | 63191d9f2043d2e67657e85a7b3842805dd1dad6 (diff) | |
| parent | 38726039b77db432989fed106c88e9f1aa463281 (diff) | |
| download | emacs-adf2fc4a01efe77d73cd52bc9173914ed56ff531.tar.gz emacs-adf2fc4a01efe77d73cd52bc9173914ed56ff531.zip | |
Merge from mainline.
Diffstat (limited to 'src/window.c')
| -rw-r--r-- | src/window.c | 468 |
1 files changed, 187 insertions, 281 deletions
diff --git a/src/window.c b/src/window.c index 1b288368884..ef96861dc71 100644 --- a/src/window.c +++ b/src/window.c | |||
| @@ -66,10 +66,9 @@ static Lisp_Object Qsafe, Qabove, Qbelow, Qwindow_size, Qclone_of; | |||
| 66 | static int displayed_window_lines (struct window *); | 66 | static int displayed_window_lines (struct window *); |
| 67 | static int count_windows (struct window *); | 67 | static int count_windows (struct window *); |
| 68 | static int get_leaf_windows (struct window *, struct window **, int); | 68 | static int get_leaf_windows (struct window *, struct window **, int); |
| 69 | static void window_scroll (Lisp_Object, EMACS_INT, int, int); | 69 | static void window_scroll (Lisp_Object, EMACS_INT, bool, int); |
| 70 | static void window_scroll_pixel_based (Lisp_Object, int, int, int); | 70 | static void window_scroll_pixel_based (Lisp_Object, int, bool, int); |
| 71 | static void window_scroll_line_based (Lisp_Object, int, int, int); | 71 | static void window_scroll_line_based (Lisp_Object, int, bool, int); |
| 72 | static int freeze_window_start (struct window *, void *); | ||
| 73 | static Lisp_Object window_list (void); | 72 | static Lisp_Object window_list (void); |
| 74 | static int add_window_to_list (struct window *, void *); | 73 | static int add_window_to_list (struct window *, void *); |
| 75 | static Lisp_Object next_window (Lisp_Object, Lisp_Object, | 74 | static Lisp_Object next_window (Lisp_Object, Lisp_Object, |
| @@ -88,6 +87,14 @@ static void window_resize_apply (struct window *, bool); | |||
| 88 | static Lisp_Object select_window (Lisp_Object, Lisp_Object, int); | 87 | static Lisp_Object select_window (Lisp_Object, Lisp_Object, int); |
| 89 | static void select_window_1 (Lisp_Object, bool); | 88 | static void select_window_1 (Lisp_Object, bool); |
| 90 | 89 | ||
| 90 | static struct window *set_window_fringes (struct window *, Lisp_Object, | ||
| 91 | Lisp_Object, Lisp_Object); | ||
| 92 | static struct window *set_window_margins (struct window *, Lisp_Object, | ||
| 93 | Lisp_Object); | ||
| 94 | static struct window *set_window_scroll_bars (struct window *, Lisp_Object, | ||
| 95 | Lisp_Object, Lisp_Object); | ||
| 96 | static void apply_window_adjustment (struct window *); | ||
| 97 | |||
| 91 | /* This is the window in which the terminal's cursor should | 98 | /* This is the window in which the terminal's cursor should |
| 92 | be left when nothing is being done with it. This must | 99 | be left when nothing is being done with it. This must |
| 93 | always be a leaf window, and its buffer is selected by | 100 | always be a leaf window, and its buffer is selected by |
| @@ -152,16 +159,6 @@ wset_display_table (struct window *w, Lisp_Object val) | |||
| 152 | w->display_table = val; | 159 | w->display_table = val; |
| 153 | } | 160 | } |
| 154 | static void | 161 | static void |
| 155 | wset_left_fringe_width (struct window *w, Lisp_Object val) | ||
| 156 | { | ||
| 157 | w->left_fringe_width = val; | ||
| 158 | } | ||
| 159 | static void | ||
| 160 | wset_left_margin_cols (struct window *w, Lisp_Object val) | ||
| 161 | { | ||
| 162 | w->left_margin_cols = val; | ||
| 163 | } | ||
| 164 | static void | ||
| 165 | wset_new_normal (struct window *w, Lisp_Object val) | 162 | wset_new_normal (struct window *w, Lisp_Object val) |
| 166 | { | 163 | { |
| 167 | w->new_normal = val; | 164 | w->new_normal = val; |
| @@ -192,21 +189,6 @@ wset_pointm (struct window *w, Lisp_Object val) | |||
| 192 | w->pointm = val; | 189 | w->pointm = val; |
| 193 | } | 190 | } |
| 194 | static void | 191 | static void |
| 195 | wset_right_fringe_width (struct window *w, Lisp_Object val) | ||
| 196 | { | ||
| 197 | w->right_fringe_width = val; | ||
| 198 | } | ||
| 199 | static void | ||
| 200 | wset_right_margin_cols (struct window *w, Lisp_Object val) | ||
| 201 | { | ||
| 202 | w->right_margin_cols = val; | ||
| 203 | } | ||
| 204 | static void | ||
| 205 | wset_scroll_bar_width (struct window *w, Lisp_Object val) | ||
| 206 | { | ||
| 207 | w->scroll_bar_width = val; | ||
| 208 | } | ||
| 209 | static void | ||
| 210 | wset_start (struct window *w, Lisp_Object val) | 192 | wset_start (struct window *w, Lisp_Object val) |
| 211 | { | 193 | { |
| 212 | w->start = val; | 194 | w->start = val; |
| @@ -239,6 +221,17 @@ wset_combination (struct window *w, bool horflag, Lisp_Object val) | |||
| 239 | w->horizontal = horflag; | 221 | w->horizontal = horflag; |
| 240 | } | 222 | } |
| 241 | 223 | ||
| 224 | /* Nonzero if leaf window W doesn't reflect the actual state | ||
| 225 | of displayed buffer due to its text or overlays change. */ | ||
| 226 | |||
| 227 | bool | ||
| 228 | window_outdated (struct window *w) | ||
| 229 | { | ||
| 230 | struct buffer *b = XBUFFER (w->contents); | ||
| 231 | return (w->last_modified < BUF_MODIFF (b) | ||
| 232 | || w->last_overlay_modified < BUF_OVERLAY_MODIFF (b)); | ||
| 233 | } | ||
| 234 | |||
| 242 | struct window * | 235 | struct window * |
| 243 | decode_live_window (register Lisp_Object window) | 236 | decode_live_window (register Lisp_Object window) |
| 244 | { | 237 | { |
| @@ -488,7 +481,6 @@ select_window (Lisp_Object window, Lisp_Object norecord, int inhibit_point_swap) | |||
| 488 | CHECK_LIVE_WINDOW (window); | 481 | CHECK_LIVE_WINDOW (window); |
| 489 | 482 | ||
| 490 | w = XWINDOW (window); | 483 | w = XWINDOW (window); |
| 491 | w->frozen_window_start_p = 0; | ||
| 492 | 484 | ||
| 493 | /* Make the selected window's buffer current. */ | 485 | /* Make the selected window's buffer current. */ |
| 494 | Fset_buffer (w->contents); | 486 | Fset_buffer (w->contents); |
| @@ -557,15 +549,7 @@ select_window_1 (Lisp_Object window, bool inhibit_point_swap) | |||
| 557 | than one window. It also matters when | 549 | than one window. It also matters when |
| 558 | redisplay_window has altered point after scrolling, | 550 | redisplay_window has altered point after scrolling, |
| 559 | because it makes the change only in the window. */ | 551 | because it makes the change only in the window. */ |
| 560 | { | 552 | set_point_from_marker (XWINDOW (window)->pointm); |
| 561 | register ptrdiff_t new_point = marker_position (XWINDOW (window)->pointm); | ||
| 562 | if (new_point < BEGV) | ||
| 563 | SET_PT (BEGV); | ||
| 564 | else if (new_point > ZV) | ||
| 565 | SET_PT (ZV); | ||
| 566 | else | ||
| 567 | SET_PT (new_point); | ||
| 568 | } | ||
| 569 | } | 553 | } |
| 570 | 554 | ||
| 571 | DEFUN ("select-window", Fselect_window, Sselect_window, 1, 2, 0, | 555 | DEFUN ("select-window", Fselect_window, Sselect_window, 1, 2, 0, |
| @@ -1353,7 +1337,7 @@ struct check_window_data | |||
| 1353 | static int | 1337 | static int |
| 1354 | check_window_containing (struct window *w, void *user_data) | 1338 | check_window_containing (struct window *w, void *user_data) |
| 1355 | { | 1339 | { |
| 1356 | struct check_window_data *cw = (struct check_window_data *) user_data; | 1340 | struct check_window_data *cw = user_data; |
| 1357 | enum window_part found; | 1341 | enum window_part found; |
| 1358 | int continue_p = 1; | 1342 | int continue_p = 1; |
| 1359 | 1343 | ||
| @@ -1506,12 +1490,10 @@ if it isn't already recorded. */) | |||
| 1506 | || !w->window_end_valid | 1490 | || !w->window_end_valid |
| 1507 | || b->clip_changed | 1491 | || b->clip_changed |
| 1508 | || b->prevent_redisplay_optimizations_p | 1492 | || b->prevent_redisplay_optimizations_p |
| 1509 | || w->last_modified < BUF_MODIFF (b) | 1493 | || window_outdated (w)) |
| 1510 | || w->last_overlay_modified < BUF_OVERLAY_MODIFF (b)) | ||
| 1511 | && !noninteractive) | 1494 | && !noninteractive) |
| 1512 | { | 1495 | { |
| 1513 | struct text_pos startp; | 1496 | struct text_pos startp; |
| 1514 | ptrdiff_t charpos = marker_position (w->start); | ||
| 1515 | struct it it; | 1497 | struct it it; |
| 1516 | struct buffer *old_buffer = NULL; | 1498 | struct buffer *old_buffer = NULL; |
| 1517 | void *itdata = NULL; | 1499 | void *itdata = NULL; |
| @@ -1529,12 +1511,7 @@ if it isn't already recorded. */) | |||
| 1529 | `-l' containing a call to `rmail' with subsequent other | 1511 | `-l' containing a call to `rmail' with subsequent other |
| 1530 | commands. At the end, W->start happened to be BEG, while | 1512 | commands. At the end, W->start happened to be BEG, while |
| 1531 | rmail had already narrowed the buffer. */ | 1513 | rmail had already narrowed the buffer. */ |
| 1532 | if (charpos < BEGV) | 1514 | CLIP_TEXT_POS_FROM_MARKER (startp, w->start); |
| 1533 | SET_TEXT_POS (startp, BEGV, BEGV_BYTE); | ||
| 1534 | else if (charpos > ZV) | ||
| 1535 | SET_TEXT_POS (startp, ZV, ZV_BYTE); | ||
| 1536 | else | ||
| 1537 | SET_TEXT_POS_FROM_MARKER (startp, w->start); | ||
| 1538 | 1515 | ||
| 1539 | itdata = bidi_shelve_cache (); | 1516 | itdata = bidi_shelve_cache (); |
| 1540 | start_display (&it, w, startp); | 1517 | start_display (&it, w, startp); |
| @@ -1548,7 +1525,7 @@ if it isn't already recorded. */) | |||
| 1548 | set_buffer_internal (old_buffer); | 1525 | set_buffer_internal (old_buffer); |
| 1549 | } | 1526 | } |
| 1550 | else | 1527 | else |
| 1551 | XSETINT (value, BUF_Z (b) - XFASTINT (w->window_end_pos)); | 1528 | XSETINT (value, BUF_Z (b) - w->window_end_pos); |
| 1552 | 1529 | ||
| 1553 | return value; | 1530 | return value; |
| 1554 | } | 1531 | } |
| @@ -1604,9 +1581,8 @@ overriding motion of point in order to display at this exact start. */) | |||
| 1604 | if (NILP (noforce)) | 1581 | if (NILP (noforce)) |
| 1605 | w->force_start = 1; | 1582 | w->force_start = 1; |
| 1606 | w->update_mode_line = 1; | 1583 | w->update_mode_line = 1; |
| 1607 | w->last_modified = 0; | 1584 | if (w != XWINDOW (selected_window)) |
| 1608 | w->last_overlay_modified = 0; | 1585 | /* Enforce full redisplay. FIXME: make it more selective. */ |
| 1609 | if (!EQ (window, selected_window)) | ||
| 1610 | windows_or_buffers_changed++; | 1586 | windows_or_buffers_changed++; |
| 1611 | 1587 | ||
| 1612 | return pos; | 1588 | return pos; |
| @@ -1720,8 +1696,7 @@ Return nil if window display is not up-to-date. In that case, use | |||
| 1720 | || windows_or_buffers_changed | 1696 | || windows_or_buffers_changed |
| 1721 | || b->clip_changed | 1697 | || b->clip_changed |
| 1722 | || b->prevent_redisplay_optimizations_p | 1698 | || b->prevent_redisplay_optimizations_p |
| 1723 | || w->last_modified < BUF_MODIFF (b) | 1699 | || window_outdated (w)) |
| 1724 | || w->last_overlay_modified < BUF_OVERLAY_MODIFF (b)) | ||
| 1725 | return Qnil; | 1700 | return Qnil; |
| 1726 | 1701 | ||
| 1727 | if (NILP (line)) | 1702 | if (NILP (line)) |
| @@ -2038,16 +2013,15 @@ replace_window (Lisp_Object old, Lisp_Object new, int setflag) | |||
| 2038 | n->desired_matrix = n->current_matrix = 0; | 2013 | n->desired_matrix = n->current_matrix = 0; |
| 2039 | n->vscroll = 0; | 2014 | n->vscroll = 0; |
| 2040 | memset (&n->cursor, 0, sizeof (n->cursor)); | 2015 | memset (&n->cursor, 0, sizeof (n->cursor)); |
| 2041 | memset (&n->last_cursor, 0, sizeof (n->last_cursor)); | ||
| 2042 | memset (&n->phys_cursor, 0, sizeof (n->phys_cursor)); | 2016 | memset (&n->phys_cursor, 0, sizeof (n->phys_cursor)); |
| 2017 | n->last_cursor_vpos = 0; | ||
| 2043 | n->phys_cursor_type = -1; | 2018 | n->phys_cursor_type = -1; |
| 2044 | n->phys_cursor_width = -1; | 2019 | n->phys_cursor_width = -1; |
| 2045 | n->must_be_updated_p = 0; | 2020 | n->must_be_updated_p = 0; |
| 2046 | n->pseudo_window_p = 0; | 2021 | n->pseudo_window_p = 0; |
| 2047 | wset_window_end_vpos (n, make_number (0)); | 2022 | n->window_end_vpos = 0; |
| 2048 | wset_window_end_pos (n, make_number (0)); | 2023 | n->window_end_pos = 0; |
| 2049 | n->window_end_valid = 0; | 2024 | n->window_end_valid = 0; |
| 2050 | n->frozen_window_start_p = 0; | ||
| 2051 | } | 2025 | } |
| 2052 | 2026 | ||
| 2053 | tem = o->next; | 2027 | tem = o->next; |
| @@ -2156,7 +2130,7 @@ delete_deletable_window (Lisp_Object window) | |||
| 2156 | static int | 2130 | static int |
| 2157 | add_window_to_list (struct window *w, void *user_data) | 2131 | add_window_to_list (struct window *w, void *user_data) |
| 2158 | { | 2132 | { |
| 2159 | Lisp_Object *list = (Lisp_Object *) user_data; | 2133 | Lisp_Object *list = user_data; |
| 2160 | Lisp_Object window; | 2134 | Lisp_Object window; |
| 2161 | XSETWINDOW (window, w); | 2135 | XSETWINDOW (window, w); |
| 2162 | *list = Fcons (window, *list); | 2136 | *list = Fcons (window, *list); |
| @@ -2854,7 +2828,7 @@ window-start value is reasonable when this function is called. */) | |||
| 2854 | block_input (); | 2828 | block_input (); |
| 2855 | if (!FRAME_INITIAL_P (f)) | 2829 | if (!FRAME_INITIAL_P (f)) |
| 2856 | { | 2830 | { |
| 2857 | Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f); | 2831 | Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f); |
| 2858 | 2832 | ||
| 2859 | /* We are going to free the glyph matrices of WINDOW, and with | 2833 | /* We are going to free the glyph matrices of WINDOW, and with |
| 2860 | that we might lose any information about glyph rows that have | 2834 | that we might lose any information about glyph rows that have |
| @@ -2864,11 +2838,7 @@ window-start value is reasonable when this function is called. */) | |||
| 2864 | frame's up-to-date hook that mouse highlight was overwritten, | 2838 | frame's up-to-date hook that mouse highlight was overwritten, |
| 2865 | so that it will arrange for redisplaying the highlight. */ | 2839 | so that it will arrange for redisplaying the highlight. */ |
| 2866 | if (EQ (hlinfo->mouse_face_window, window)) | 2840 | if (EQ (hlinfo->mouse_face_window, window)) |
| 2867 | { | 2841 | reset_mouse_highlight (hlinfo); |
| 2868 | hlinfo->mouse_face_beg_row = hlinfo->mouse_face_beg_col = -1; | ||
| 2869 | hlinfo->mouse_face_end_row = hlinfo->mouse_face_end_col = -1; | ||
| 2870 | hlinfo->mouse_face_window = Qnil; | ||
| 2871 | } | ||
| 2872 | } | 2842 | } |
| 2873 | free_window_matrices (r); | 2843 | free_window_matrices (r); |
| 2874 | 2844 | ||
| @@ -3063,15 +3033,12 @@ adjust_window_margins (struct window *w) | |||
| 3063 | if (WINDOW_RIGHT_MARGIN_COLS (w) > 0) | 3033 | if (WINDOW_RIGHT_MARGIN_COLS (w) > 0) |
| 3064 | { | 3034 | { |
| 3065 | if (WINDOW_LEFT_MARGIN_COLS (w) > 0) | 3035 | if (WINDOW_LEFT_MARGIN_COLS (w) > 0) |
| 3066 | { | 3036 | w->left_margin_cols = w->right_margin_cols = margin_cols / 2; |
| 3067 | wset_left_margin_cols (w, make_number (margin_cols / 2)); | ||
| 3068 | wset_right_margin_cols (w, make_number (margin_cols / 2)); | ||
| 3069 | } | ||
| 3070 | else | 3037 | else |
| 3071 | wset_right_margin_cols (w, make_number (margin_cols)); | 3038 | w->right_margin_cols = margin_cols; |
| 3072 | } | 3039 | } |
| 3073 | else | 3040 | else |
| 3074 | wset_left_margin_cols (w, make_number (margin_cols)); | 3041 | w->left_margin_cols = margin_cols; |
| 3075 | return 1; | 3042 | return 1; |
| 3076 | } | 3043 | } |
| 3077 | 3044 | ||
| @@ -3119,7 +3086,7 @@ run_window_configuration_change_hook (struct frame *f) | |||
| 3119 | 3086 | ||
| 3120 | if (SELECTED_FRAME () != f) | 3087 | if (SELECTED_FRAME () != f) |
| 3121 | { | 3088 | { |
| 3122 | record_unwind_protect (select_frame_norecord, Fselected_frame ()); | 3089 | record_unwind_protect (select_frame_norecord, selected_frame); |
| 3123 | select_frame_norecord (frame); | 3090 | select_frame_norecord (frame); |
| 3124 | } | 3091 | } |
| 3125 | 3092 | ||
| @@ -3134,7 +3101,7 @@ run_window_configuration_change_hook (struct frame *f) | |||
| 3134 | buffer))) | 3101 | buffer))) |
| 3135 | { | 3102 | { |
| 3136 | ptrdiff_t inner_count = SPECPDL_INDEX (); | 3103 | ptrdiff_t inner_count = SPECPDL_INDEX (); |
| 3137 | record_unwind_protect (select_window_norecord, Fselected_window ()); | 3104 | record_unwind_protect (select_window_norecord, selected_window); |
| 3138 | select_window_norecord (window); | 3105 | select_window_norecord (window); |
| 3139 | run_funs (Fbuffer_local_value (Qwindow_configuration_change_hook, | 3106 | run_funs (Fbuffer_local_value (Qwindow_configuration_change_hook, |
| 3140 | buffer)); | 3107 | buffer)); |
| @@ -3185,9 +3152,9 @@ set_window_buffer (Lisp_Object window, Lisp_Object buffer, | |||
| 3185 | bset_display_count (b, make_number (XINT (BVAR (b, display_count)) + 1)); | 3152 | bset_display_count (b, make_number (XINT (BVAR (b, display_count)) + 1)); |
| 3186 | bset_display_time (b, Fcurrent_time ()); | 3153 | bset_display_time (b, Fcurrent_time ()); |
| 3187 | 3154 | ||
| 3188 | wset_window_end_pos (w, make_number (0)); | 3155 | w->window_end_pos = 0; |
| 3189 | wset_window_end_vpos (w, make_number (0)); | 3156 | w->window_end_vpos = 0; |
| 3190 | memset (&w->last_cursor, 0, sizeof w->last_cursor); | 3157 | w->last_cursor_vpos = 0; |
| 3191 | 3158 | ||
| 3192 | if (!(keep_margins_p && samebuf)) | 3159 | if (!(keep_margins_p && samebuf)) |
| 3193 | { /* If we're not actually changing the buffer, don't reset hscroll and | 3160 | { /* If we're not actually changing the buffer, don't reset hscroll and |
| @@ -3206,8 +3173,6 @@ set_window_buffer (Lisp_Object window, Lisp_Object buffer, | |||
| 3206 | buffer); | 3173 | buffer); |
| 3207 | w->start_at_line_beg = 0; | 3174 | w->start_at_line_beg = 0; |
| 3208 | w->force_start = 0; | 3175 | w->force_start = 0; |
| 3209 | w->last_modified = 0; | ||
| 3210 | w->last_overlay_modified = 0; | ||
| 3211 | } | 3176 | } |
| 3212 | /* Maybe we could move this into the `if' but it's not obviously safe and | 3177 | /* Maybe we could move this into the `if' but it's not obviously safe and |
| 3213 | I doubt it's worth the trouble. */ | 3178 | I doubt it's worth the trouble. */ |
| @@ -3227,28 +3192,14 @@ set_window_buffer (Lisp_Object window, Lisp_Object buffer, | |||
| 3227 | if (!keep_margins_p) | 3192 | if (!keep_margins_p) |
| 3228 | { | 3193 | { |
| 3229 | /* Set left and right marginal area width etc. from buffer. */ | 3194 | /* Set left and right marginal area width etc. from buffer. */ |
| 3230 | 3195 | set_window_fringes (w, BVAR (b, left_fringe_width), | |
| 3231 | /* This may call adjust_window_margins three times, so | 3196 | BVAR (b, right_fringe_width), |
| 3232 | temporarily disable window margins. */ | 3197 | BVAR (b, fringes_outside_margins)); |
| 3233 | Lisp_Object save_left = w->left_margin_cols; | 3198 | set_window_scroll_bars (w, BVAR (b, scroll_bar_width), |
| 3234 | Lisp_Object save_right = w->right_margin_cols; | 3199 | BVAR (b, vertical_scroll_bar_type), Qnil); |
| 3235 | 3200 | set_window_margins (w, BVAR (b, left_margin_cols), | |
| 3236 | wset_left_margin_cols (w, Qnil); | 3201 | BVAR (b, right_margin_cols)); |
| 3237 | wset_right_margin_cols (w, Qnil); | 3202 | apply_window_adjustment (w); |
| 3238 | |||
| 3239 | Fset_window_fringes (window, | ||
| 3240 | BVAR (b, left_fringe_width), BVAR (b, right_fringe_width), | ||
| 3241 | BVAR (b, fringes_outside_margins)); | ||
| 3242 | |||
| 3243 | Fset_window_scroll_bars (window, | ||
| 3244 | BVAR (b, scroll_bar_width), | ||
| 3245 | BVAR (b, vertical_scroll_bar_type), Qnil); | ||
| 3246 | |||
| 3247 | wset_left_margin_cols (w, save_left); | ||
| 3248 | wset_right_margin_cols (w, save_right); | ||
| 3249 | |||
| 3250 | Fset_window_margins (window, | ||
| 3251 | BVAR (b, left_margin_cols), BVAR (b, right_margin_cols)); | ||
| 3252 | } | 3203 | } |
| 3253 | 3204 | ||
| 3254 | if (run_hooks_p) | 3205 | if (run_hooks_p) |
| @@ -3384,10 +3335,8 @@ temp_output_buffer_show (register Lisp_Object buf) | |||
| 3384 | 3335 | ||
| 3385 | if (!NILP (Vtemp_buffer_show_function)) | 3336 | if (!NILP (Vtemp_buffer_show_function)) |
| 3386 | call1 (Vtemp_buffer_show_function, buf); | 3337 | call1 (Vtemp_buffer_show_function, buf); |
| 3387 | else | 3338 | else if (WINDOW_LIVE_P (window = display_buffer (buf, Qnil, Qnil))) |
| 3388 | { | 3339 | { |
| 3389 | window = display_buffer (buf, Qnil, Qnil); | ||
| 3390 | |||
| 3391 | if (!EQ (XWINDOW (window)->frame, selected_frame)) | 3340 | if (!EQ (XWINDOW (window)->frame, selected_frame)) |
| 3392 | Fmake_frame_visible (WINDOW_FRAME (XWINDOW (window))); | 3341 | Fmake_frame_visible (WINDOW_FRAME (XWINDOW (window))); |
| 3393 | Vminibuf_scroll_window = window; | 3342 | Vminibuf_scroll_window = window; |
| @@ -3468,8 +3417,6 @@ make_window (void) | |||
| 3468 | wset_start (w, Fmake_marker ()); | 3417 | wset_start (w, Fmake_marker ()); |
| 3469 | wset_pointm (w, Fmake_marker ()); | 3418 | wset_pointm (w, Fmake_marker ()); |
| 3470 | wset_vertical_scroll_bar_type (w, Qt); | 3419 | wset_vertical_scroll_bar_type (w, Qt); |
| 3471 | wset_window_end_pos (w, make_number (0)); | ||
| 3472 | wset_window_end_vpos (w, make_number (0)); | ||
| 3473 | /* These Lisp fields are marked specially so they're not set to nil by | 3420 | /* These Lisp fields are marked specially so they're not set to nil by |
| 3474 | allocate_window. */ | 3421 | allocate_window. */ |
| 3475 | wset_prev_buffers (w, Qnil); | 3422 | wset_prev_buffers (w, Qnil); |
| @@ -3478,8 +3425,10 @@ make_window (void) | |||
| 3478 | /* Initialize non-Lisp data. Note that allocate_window zeroes out all | 3425 | /* Initialize non-Lisp data. Note that allocate_window zeroes out all |
| 3479 | non-Lisp data, so do it only for slots which should not be zero. */ | 3426 | non-Lisp data, so do it only for slots which should not be zero. */ |
| 3480 | w->nrows_scale_factor = w->ncols_scale_factor = 1; | 3427 | w->nrows_scale_factor = w->ncols_scale_factor = 1; |
| 3428 | w->left_fringe_width = w->right_fringe_width = -1; | ||
| 3481 | w->phys_cursor_type = -1; | 3429 | w->phys_cursor_type = -1; |
| 3482 | w->phys_cursor_width = -1; | 3430 | w->phys_cursor_width = -1; |
| 3431 | w->scroll_bar_width = -1; | ||
| 3483 | w->column_number_displayed = -1; | 3432 | w->column_number_displayed = -1; |
| 3484 | 3433 | ||
| 3485 | /* Reset window_list. */ | 3434 | /* Reset window_list. */ |
| @@ -3668,10 +3617,6 @@ window_resize_apply (struct window *w, bool horflag) | |||
| 3668 | c = NILP (c->next) ? 0 : XWINDOW (c->next); | 3617 | c = NILP (c->next) ? 0 : XWINDOW (c->next); |
| 3669 | } | 3618 | } |
| 3670 | } | 3619 | } |
| 3671 | |||
| 3672 | /* Clear out some redisplay caches. */ | ||
| 3673 | w->last_modified = 0; | ||
| 3674 | w->last_overlay_modified = 0; | ||
| 3675 | } | 3620 | } |
| 3676 | 3621 | ||
| 3677 | 3622 | ||
| @@ -3946,15 +3891,15 @@ set correctly. See the code of `split-window' for how this is done. */) | |||
| 3946 | } | 3891 | } |
| 3947 | 3892 | ||
| 3948 | n->window_end_valid = 0; | 3893 | n->window_end_valid = 0; |
| 3949 | memset (&n->last_cursor, 0, sizeof n->last_cursor); | 3894 | n->last_cursor_vpos = 0; |
| 3950 | 3895 | ||
| 3951 | /* Get special geometry settings from reference window. */ | 3896 | /* Get special geometry settings from reference window. */ |
| 3952 | wset_left_margin_cols (n, r->left_margin_cols); | 3897 | n->left_margin_cols = r->left_margin_cols; |
| 3953 | wset_right_margin_cols (n, r->right_margin_cols); | 3898 | n->right_margin_cols = r->right_margin_cols; |
| 3954 | wset_left_fringe_width (n, r->left_fringe_width); | 3899 | n->left_fringe_width = r->left_fringe_width; |
| 3955 | wset_right_fringe_width (n, r->right_fringe_width); | 3900 | n->right_fringe_width = r->right_fringe_width; |
| 3956 | n->fringes_outside_margins = r->fringes_outside_margins; | 3901 | n->fringes_outside_margins = r->fringes_outside_margins; |
| 3957 | wset_scroll_bar_width (n, r->scroll_bar_width); | 3902 | n->scroll_bar_width = r->scroll_bar_width; |
| 3958 | wset_vertical_scroll_bar_type (n, r->vertical_scroll_bar_type); | 3903 | wset_vertical_scroll_bar_type (n, r->vertical_scroll_bar_type); |
| 3959 | 3904 | ||
| 3960 | /* Directly assign orthogonal coordinates and sizes. */ | 3905 | /* Directly assign orthogonal coordinates and sizes. */ |
| @@ -4190,9 +4135,7 @@ grow_mini_window (struct window *w, int delta) | |||
| 4190 | /* Grow the mini-window. */ | 4135 | /* Grow the mini-window. */ |
| 4191 | w->top_line = r->top_line + r->total_lines; | 4136 | w->top_line = r->top_line + r->total_lines; |
| 4192 | w->total_lines -= XINT (value); | 4137 | w->total_lines -= XINT (value); |
| 4193 | w->last_modified = 0; | 4138 | /* Enforce full redisplay. FIXME: make it more selective. */ |
| 4194 | w->last_overlay_modified = 0; | ||
| 4195 | |||
| 4196 | windows_or_buffers_changed++; | 4139 | windows_or_buffers_changed++; |
| 4197 | adjust_glyphs (f); | 4140 | adjust_glyphs (f); |
| 4198 | unblock_input (); | 4141 | unblock_input (); |
| @@ -4226,10 +4169,7 @@ shrink_mini_window (struct window *w) | |||
| 4226 | /* Shrink the mini-window. */ | 4169 | /* Shrink the mini-window. */ |
| 4227 | w->top_line = r->top_line + r->total_lines; | 4170 | w->top_line = r->top_line + r->total_lines; |
| 4228 | w->total_lines = 1; | 4171 | w->total_lines = 1; |
| 4229 | 4172 | /* Enforce full redisplay. FIXME: make it more selective. */ | |
| 4230 | w->last_modified = 0; | ||
| 4231 | w->last_overlay_modified = 0; | ||
| 4232 | |||
| 4233 | windows_or_buffers_changed++; | 4173 | windows_or_buffers_changed++; |
| 4234 | adjust_glyphs (f); | 4174 | adjust_glyphs (f); |
| 4235 | unblock_input (); | 4175 | unblock_input (); |
| @@ -4336,7 +4276,7 @@ window_internal_height (struct window *w) | |||
| 4336 | respectively. */ | 4276 | respectively. */ |
| 4337 | 4277 | ||
| 4338 | static void | 4278 | static void |
| 4339 | window_scroll (Lisp_Object window, EMACS_INT n, int whole, int noerror) | 4279 | window_scroll (Lisp_Object window, EMACS_INT n, bool whole, int noerror) |
| 4340 | { | 4280 | { |
| 4341 | immediate_quit = 1; | 4281 | immediate_quit = 1; |
| 4342 | n = clip_to_bounds (INT_MIN, n, INT_MAX); | 4282 | n = clip_to_bounds (INT_MIN, n, INT_MAX); |
| @@ -4357,7 +4297,7 @@ window_scroll (Lisp_Object window, EMACS_INT n, int whole, int noerror) | |||
| 4357 | descriptions. */ | 4297 | descriptions. */ |
| 4358 | 4298 | ||
| 4359 | static void | 4299 | static void |
| 4360 | window_scroll_pixel_based (Lisp_Object window, int n, int whole, int noerror) | 4300 | window_scroll_pixel_based (Lisp_Object window, int n, bool whole, int noerror) |
| 4361 | { | 4301 | { |
| 4362 | struct it it; | 4302 | struct it it; |
| 4363 | struct window *w = XWINDOW (window); | 4303 | struct window *w = XWINDOW (window); |
| @@ -4455,8 +4395,6 @@ window_scroll_pixel_based (Lisp_Object window, int n, int whole, int noerror) | |||
| 4455 | w->contents); | 4395 | w->contents); |
| 4456 | w->start_at_line_beg = 1; | 4396 | w->start_at_line_beg = 1; |
| 4457 | w->update_mode_line = 1; | 4397 | w->update_mode_line = 1; |
| 4458 | w->last_modified = 0; | ||
| 4459 | w->last_overlay_modified = 0; | ||
| 4460 | /* Set force_start so that redisplay_window will run the | 4398 | /* Set force_start so that redisplay_window will run the |
| 4461 | window-scroll-functions. */ | 4399 | window-scroll-functions. */ |
| 4462 | w->force_start = 1; | 4400 | w->force_start = 1; |
| @@ -4601,8 +4539,6 @@ window_scroll_pixel_based (Lisp_Object window, int n, int whole, int noerror) | |||
| 4601 | bytepos = marker_byte_position (w->start); | 4539 | bytepos = marker_byte_position (w->start); |
| 4602 | w->start_at_line_beg = (pos == BEGV || FETCH_BYTE (bytepos - 1) == '\n'); | 4540 | w->start_at_line_beg = (pos == BEGV || FETCH_BYTE (bytepos - 1) == '\n'); |
| 4603 | w->update_mode_line = 1; | 4541 | w->update_mode_line = 1; |
| 4604 | w->last_modified = 0; | ||
| 4605 | w->last_overlay_modified = 0; | ||
| 4606 | /* Set force_start so that redisplay_window will run the | 4542 | /* Set force_start so that redisplay_window will run the |
| 4607 | window-scroll-functions. */ | 4543 | window-scroll-functions. */ |
| 4608 | w->force_start = 1; | 4544 | w->force_start = 1; |
| @@ -4725,7 +4661,7 @@ window_scroll_pixel_based (Lisp_Object window, int n, int whole, int noerror) | |||
| 4725 | See the comment of window_scroll for parameter descriptions. */ | 4661 | See the comment of window_scroll for parameter descriptions. */ |
| 4726 | 4662 | ||
| 4727 | static void | 4663 | static void |
| 4728 | window_scroll_line_based (Lisp_Object window, int n, int whole, int noerror) | 4664 | window_scroll_line_based (Lisp_Object window, int n, bool whole, int noerror) |
| 4729 | { | 4665 | { |
| 4730 | register struct window *w = XWINDOW (window); | 4666 | register struct window *w = XWINDOW (window); |
| 4731 | /* Fvertical_motion enters redisplay, which can trigger | 4667 | /* Fvertical_motion enters redisplay, which can trigger |
| @@ -4737,7 +4673,7 @@ window_scroll_line_based (Lisp_Object window, int n, int whole, int noerror) | |||
| 4737 | register ptrdiff_t pos, pos_byte; | 4673 | register ptrdiff_t pos, pos_byte; |
| 4738 | register int ht = window_internal_height (w); | 4674 | register int ht = window_internal_height (w); |
| 4739 | register Lisp_Object tem; | 4675 | register Lisp_Object tem; |
| 4740 | int lose; | 4676 | bool lose; |
| 4741 | Lisp_Object bolp; | 4677 | Lisp_Object bolp; |
| 4742 | ptrdiff_t startpos = marker_position (w->start); | 4678 | ptrdiff_t startpos = marker_position (w->start); |
| 4743 | ptrdiff_t startbyte = marker_byte_position (w->start); | 4679 | ptrdiff_t startbyte = marker_byte_position (w->start); |
| @@ -4801,8 +4737,6 @@ window_scroll_line_based (Lisp_Object window, int n, int whole, int noerror) | |||
| 4801 | set_marker_restricted_both (w->start, w->contents, pos, pos_byte); | 4737 | set_marker_restricted_both (w->start, w->contents, pos, pos_byte); |
| 4802 | w->start_at_line_beg = !NILP (bolp); | 4738 | w->start_at_line_beg = !NILP (bolp); |
| 4803 | w->update_mode_line = 1; | 4739 | w->update_mode_line = 1; |
| 4804 | w->last_modified = 0; | ||
| 4805 | w->last_overlay_modified = 0; | ||
| 4806 | /* Set force_start so that redisplay_window will run | 4740 | /* Set force_start so that redisplay_window will run |
| 4807 | the window-scroll-functions. */ | 4741 | the window-scroll-functions. */ |
| 4808 | w->force_start = 1; | 4742 | w->force_start = 1; |
| @@ -5098,7 +5032,6 @@ displayed_window_lines (struct window *w) | |||
| 5098 | { | 5032 | { |
| 5099 | struct it it; | 5033 | struct it it; |
| 5100 | struct text_pos start; | 5034 | struct text_pos start; |
| 5101 | ptrdiff_t charpos = marker_position (w->start); | ||
| 5102 | int height = window_box_height (w); | 5035 | int height = window_box_height (w); |
| 5103 | struct buffer *old_buffer; | 5036 | struct buffer *old_buffer; |
| 5104 | int bottom_y; | 5037 | int bottom_y; |
| @@ -5115,12 +5048,7 @@ displayed_window_lines (struct window *w) | |||
| 5115 | /* In case W->start is out of the accessible range, do something | 5048 | /* In case W->start is out of the accessible range, do something |
| 5116 | reasonable. This happens in Info mode when Info-scroll-down | 5049 | reasonable. This happens in Info mode when Info-scroll-down |
| 5117 | calls (recenter -1) while W->start is 1. */ | 5050 | calls (recenter -1) while W->start is 1. */ |
| 5118 | if (charpos < BEGV) | 5051 | CLIP_TEXT_POS_FROM_MARKER (start, w->start); |
| 5119 | SET_TEXT_POS (start, BEGV, BEGV_BYTE); | ||
| 5120 | else if (charpos > ZV) | ||
| 5121 | SET_TEXT_POS (start, ZV, ZV_BYTE); | ||
| 5122 | else | ||
| 5123 | SET_TEXT_POS_FROM_MARKER (start, w->start); | ||
| 5124 | 5052 | ||
| 5125 | itdata = bidi_shelve_cache (); | 5053 | itdata = bidi_shelve_cache (); |
| 5126 | start_display (&it, w, start); | 5054 | start_display (&it, w, start); |
| @@ -5454,7 +5382,7 @@ struct save_window_data | |||
| 5454 | Lisp_Object saved_windows; | 5382 | Lisp_Object saved_windows; |
| 5455 | 5383 | ||
| 5456 | /* All fields above are traced by the GC. | 5384 | /* All fields above are traced by the GC. |
| 5457 | From `fame-cols' down, the fields are ignored by the GC. */ | 5385 | From `frame-cols' down, the fields are ignored by the GC. */ |
| 5458 | 5386 | ||
| 5459 | int frame_cols, frame_lines, frame_menu_bar_lines; | 5387 | int frame_cols, frame_lines, frame_menu_bar_lines; |
| 5460 | int frame_tool_bar_lines; | 5388 | int frame_tool_bar_lines; |
| @@ -5703,12 +5631,12 @@ the return value is nil. Otherwise the value is t. */) | |||
| 5703 | w->hscroll = XFASTINT (p->hscroll); | 5631 | w->hscroll = XFASTINT (p->hscroll); |
| 5704 | w->min_hscroll = XFASTINT (p->min_hscroll); | 5632 | w->min_hscroll = XFASTINT (p->min_hscroll); |
| 5705 | wset_display_table (w, p->display_table); | 5633 | wset_display_table (w, p->display_table); |
| 5706 | wset_left_margin_cols (w, p->left_margin_cols); | 5634 | w->left_margin_cols = XINT (p->left_margin_cols); |
| 5707 | wset_right_margin_cols (w, p->right_margin_cols); | 5635 | w->right_margin_cols = XINT (p->right_margin_cols); |
| 5708 | wset_left_fringe_width (w, p->left_fringe_width); | 5636 | w->left_fringe_width = XINT (p->left_fringe_width); |
| 5709 | wset_right_fringe_width (w, p->right_fringe_width); | 5637 | w->right_fringe_width = XINT (p->right_fringe_width); |
| 5710 | w->fringes_outside_margins = !NILP (p->fringes_outside_margins); | 5638 | w->fringes_outside_margins = !NILP (p->fringes_outside_margins); |
| 5711 | wset_scroll_bar_width (w, p->scroll_bar_width); | 5639 | w->scroll_bar_width = XINT (p->scroll_bar_width); |
| 5712 | wset_vertical_scroll_bar_type (w, p->vertical_scroll_bar_type); | 5640 | wset_vertical_scroll_bar_type (w, p->vertical_scroll_bar_type); |
| 5713 | wset_dedicated (w, p->dedicated); | 5641 | wset_dedicated (w, p->dedicated); |
| 5714 | wset_combination_limit (w, p->combination_limit); | 5642 | wset_combination_limit (w, p->combination_limit); |
| @@ -5734,9 +5662,6 @@ the return value is nil. Otherwise the value is t. */) | |||
| 5734 | } | 5662 | } |
| 5735 | } | 5663 | } |
| 5736 | 5664 | ||
| 5737 | w->last_modified = 0; | ||
| 5738 | w->last_overlay_modified = 0; | ||
| 5739 | |||
| 5740 | if (BUFFERP (p->buffer) && BUFFER_LIVE_P (XBUFFER (p->buffer))) | 5665 | if (BUFFERP (p->buffer) && BUFFER_LIVE_P (XBUFFER (p->buffer))) |
| 5741 | /* If saved buffer is alive, install it. */ | 5666 | /* If saved buffer is alive, install it. */ |
| 5742 | { | 5667 | { |
| @@ -6007,12 +5932,12 @@ save_window_save (Lisp_Object window, struct Lisp_Vector *vector, int i) | |||
| 6007 | XSETFASTINT (p->hscroll, w->hscroll); | 5932 | XSETFASTINT (p->hscroll, w->hscroll); |
| 6008 | XSETFASTINT (p->min_hscroll, w->min_hscroll); | 5933 | XSETFASTINT (p->min_hscroll, w->min_hscroll); |
| 6009 | p->display_table = w->display_table; | 5934 | p->display_table = w->display_table; |
| 6010 | p->left_margin_cols = w->left_margin_cols; | 5935 | p->left_margin_cols = make_number (w->left_margin_cols); |
| 6011 | p->right_margin_cols = w->right_margin_cols; | 5936 | p->right_margin_cols = make_number (w->right_margin_cols); |
| 6012 | p->left_fringe_width = w->left_fringe_width; | 5937 | p->left_fringe_width = make_number (w->left_fringe_width); |
| 6013 | p->right_fringe_width = w->right_fringe_width; | 5938 | p->right_fringe_width = make_number (w->right_fringe_width); |
| 6014 | p->fringes_outside_margins = w->fringes_outside_margins ? Qt : Qnil; | 5939 | p->fringes_outside_margins = w->fringes_outside_margins ? Qt : Qnil; |
| 6015 | p->scroll_bar_width = w->scroll_bar_width; | 5940 | p->scroll_bar_width = make_number (w->scroll_bar_width); |
| 6016 | p->vertical_scroll_bar_type = w->vertical_scroll_bar_type; | 5941 | p->vertical_scroll_bar_type = w->vertical_scroll_bar_type; |
| 6017 | p->dedicated = w->dedicated; | 5942 | p->dedicated = w->dedicated; |
| 6018 | p->combination_limit = w->combination_limit; | 5943 | p->combination_limit = w->combination_limit; |
| @@ -6153,11 +6078,46 @@ saved by this function. */) | |||
| 6153 | XSETWINDOW_CONFIGURATION (tem, data); | 6078 | XSETWINDOW_CONFIGURATION (tem, data); |
| 6154 | return (tem); | 6079 | return (tem); |
| 6155 | } | 6080 | } |
| 6081 | |||
| 6082 | /* Called after W's margins, fringes or scroll bars was adjusted. */ | ||
| 6083 | |||
| 6084 | static void | ||
| 6085 | apply_window_adjustment (struct window *w) | ||
| 6086 | { | ||
| 6087 | eassert (w); | ||
| 6088 | adjust_window_margins (w); | ||
| 6089 | clear_glyph_matrix (w->current_matrix); | ||
| 6090 | w->window_end_valid = 0; | ||
| 6091 | windows_or_buffers_changed++; | ||
| 6092 | adjust_glyphs (XFRAME (WINDOW_FRAME (w))); | ||
| 6093 | } | ||
| 6094 | |||
| 6156 | 6095 | ||
| 6157 | /*********************************************************************** | 6096 | /*********************************************************************** |
| 6158 | Marginal Areas | 6097 | Marginal Areas |
| 6159 | ***********************************************************************/ | 6098 | ***********************************************************************/ |
| 6160 | 6099 | ||
| 6100 | static struct window * | ||
| 6101 | set_window_margins (struct window *w, Lisp_Object left_width, | ||
| 6102 | Lisp_Object right_width) | ||
| 6103 | { | ||
| 6104 | int left, right; | ||
| 6105 | |||
| 6106 | /* FIXME: what about margins that are too wide? */ | ||
| 6107 | left = (NILP (left_width) ? 0 | ||
| 6108 | : (CHECK_NATNUM (left_width), XINT (left_width))); | ||
| 6109 | right = (NILP (right_width) ? 0 | ||
| 6110 | : (CHECK_NATNUM (right_width), XINT (right_width))); | ||
| 6111 | |||
| 6112 | if (w->left_margin_cols != left || w->right_margin_cols != right) | ||
| 6113 | { | ||
| 6114 | w->left_margin_cols = left; | ||
| 6115 | w->right_margin_cols = right; | ||
| 6116 | return w; | ||
| 6117 | } | ||
| 6118 | return NULL; | ||
| 6119 | } | ||
| 6120 | |||
| 6161 | DEFUN ("set-window-margins", Fset_window_margins, Sset_window_margins, | 6121 | DEFUN ("set-window-margins", Fset_window_margins, Sset_window_margins, |
| 6162 | 2, 3, 0, | 6122 | 2, 3, 0, |
| 6163 | doc: /* Set width of marginal areas of window WINDOW. | 6123 | doc: /* Set width of marginal areas of window WINDOW. |
| @@ -6166,41 +6126,14 @@ WINDOW must be a live window and defaults to the selected one. | |||
| 6166 | Second arg LEFT-WIDTH specifies the number of character cells to | 6126 | Second arg LEFT-WIDTH specifies the number of character cells to |
| 6167 | reserve for the left marginal area. Optional third arg RIGHT-WIDTH | 6127 | reserve for the left marginal area. Optional third arg RIGHT-WIDTH |
| 6168 | does the same for the right marginal area. A nil width parameter | 6128 | does the same for the right marginal area. A nil width parameter |
| 6169 | means no margin. */) | 6129 | means no margin. |
| 6130 | |||
| 6131 | Return t if any margin was actually changed and nil otherwise. */) | ||
| 6170 | (Lisp_Object window, Lisp_Object left_width, Lisp_Object right_width) | 6132 | (Lisp_Object window, Lisp_Object left_width, Lisp_Object right_width) |
| 6171 | { | 6133 | { |
| 6172 | struct window *w = decode_live_window (window); | 6134 | struct window *w = set_window_margins (decode_live_window (window), |
| 6173 | 6135 | left_width, right_width); | |
| 6174 | /* Translate negative or zero widths to nil. | 6136 | return w ? (apply_window_adjustment (w), Qt) : Qnil; |
| 6175 | Margins that are too wide have to be checked elsewhere. */ | ||
| 6176 | |||
| 6177 | if (!NILP (left_width)) | ||
| 6178 | { | ||
| 6179 | CHECK_NUMBER (left_width); | ||
| 6180 | if (XINT (left_width) <= 0) | ||
| 6181 | left_width = Qnil; | ||
| 6182 | } | ||
| 6183 | |||
| 6184 | if (!NILP (right_width)) | ||
| 6185 | { | ||
| 6186 | CHECK_NUMBER (right_width); | ||
| 6187 | if (XINT (right_width) <= 0) | ||
| 6188 | right_width = Qnil; | ||
| 6189 | } | ||
| 6190 | |||
| 6191 | if (!EQ (w->left_margin_cols, left_width) | ||
| 6192 | || !EQ (w->right_margin_cols, right_width)) | ||
| 6193 | { | ||
| 6194 | wset_left_margin_cols (w, left_width); | ||
| 6195 | wset_right_margin_cols (w, right_width); | ||
| 6196 | |||
| 6197 | adjust_window_margins (w); | ||
| 6198 | |||
| 6199 | ++windows_or_buffers_changed; | ||
| 6200 | adjust_glyphs (XFRAME (WINDOW_FRAME (w))); | ||
| 6201 | } | ||
| 6202 | |||
| 6203 | return Qnil; | ||
| 6204 | } | 6137 | } |
| 6205 | 6138 | ||
| 6206 | 6139 | ||
| @@ -6215,7 +6148,8 @@ as nil. */) | |||
| 6215 | (Lisp_Object window) | 6148 | (Lisp_Object window) |
| 6216 | { | 6149 | { |
| 6217 | struct window *w = decode_live_window (window); | 6150 | struct window *w = decode_live_window (window); |
| 6218 | return Fcons (w->left_margin_cols, w->right_margin_cols); | 6151 | return Fcons (w->left_margin_cols ? make_number (w->left_margin_cols) : Qnil, |
| 6152 | w->right_margin_cols ? make_number (w->right_margin_cols) : Qnil); | ||
| 6219 | } | 6153 | } |
| 6220 | 6154 | ||
| 6221 | 6155 | ||
| @@ -6224,6 +6158,31 @@ as nil. */) | |||
| 6224 | Fringes | 6158 | Fringes |
| 6225 | ***********************************************************************/ | 6159 | ***********************************************************************/ |
| 6226 | 6160 | ||
| 6161 | static struct window * | ||
| 6162 | set_window_fringes (struct window *w, Lisp_Object left_width, | ||
| 6163 | Lisp_Object right_width, Lisp_Object outside_margins) | ||
| 6164 | { | ||
| 6165 | int left, right, outside = !NILP (outside_margins); | ||
| 6166 | |||
| 6167 | left = (NILP (left_width) ? -1 | ||
| 6168 | : (CHECK_NATNUM (left_width), XINT (left_width))); | ||
| 6169 | right = (NILP (right_width) ? -1 | ||
| 6170 | : (CHECK_NATNUM (right_width), XINT (right_width))); | ||
| 6171 | |||
| 6172 | /* Do nothing on a tty or if nothing to actually change. */ | ||
| 6173 | if (FRAME_WINDOW_P (WINDOW_XFRAME (w)) | ||
| 6174 | && (w->left_fringe_width != left | ||
| 6175 | || w->right_fringe_width != right | ||
| 6176 | || w->fringes_outside_margins != outside)) | ||
| 6177 | { | ||
| 6178 | w->left_fringe_width = left; | ||
| 6179 | w->right_fringe_width = right; | ||
| 6180 | w->fringes_outside_margins = outside; | ||
| 6181 | return w; | ||
| 6182 | } | ||
| 6183 | return NULL; | ||
| 6184 | } | ||
| 6185 | |||
| 6227 | DEFUN ("set-window-fringes", Fset_window_fringes, Sset_window_fringes, | 6186 | DEFUN ("set-window-fringes", Fset_window_fringes, Sset_window_fringes, |
| 6228 | 2, 4, 0, | 6187 | 2, 4, 0, |
| 6229 | doc: /* Set the fringe widths of window WINDOW. | 6188 | doc: /* Set the fringe widths of window WINDOW. |
| @@ -6236,37 +6195,16 @@ frame's default fringe width. Default fringe widths can be set with | |||
| 6236 | the command `set-fringe-style'. | 6195 | the command `set-fringe-style'. |
| 6237 | If optional fourth arg OUTSIDE-MARGINS is non-nil, draw the fringes | 6196 | If optional fourth arg OUTSIDE-MARGINS is non-nil, draw the fringes |
| 6238 | outside of the display margins. By default, fringes are drawn between | 6197 | outside of the display margins. By default, fringes are drawn between |
| 6239 | display marginal areas and the text area. */) | 6198 | display marginal areas and the text area. |
| 6240 | (Lisp_Object window, Lisp_Object left_width, Lisp_Object right_width, Lisp_Object outside_margins) | ||
| 6241 | { | ||
| 6242 | struct window *w = decode_live_window (window); | ||
| 6243 | int outside = !NILP (outside_margins); | ||
| 6244 | |||
| 6245 | if (!NILP (left_width)) | ||
| 6246 | CHECK_NATNUM (left_width); | ||
| 6247 | if (!NILP (right_width)) | ||
| 6248 | CHECK_NATNUM (right_width); | ||
| 6249 | |||
| 6250 | /* Do nothing on a tty. */ | ||
| 6251 | if (FRAME_WINDOW_P (WINDOW_XFRAME (w)) | ||
| 6252 | && (!EQ (w->left_fringe_width, left_width) | ||
| 6253 | || !EQ (w->right_fringe_width, right_width) | ||
| 6254 | || w->fringes_outside_margins != outside)) | ||
| 6255 | { | ||
| 6256 | wset_left_fringe_width (w, left_width); | ||
| 6257 | wset_right_fringe_width (w, right_width); | ||
| 6258 | w->fringes_outside_margins = outside; | ||
| 6259 | 6199 | ||
| 6260 | adjust_window_margins (w); | 6200 | Return t if any fringe was actually changed and nil otherwise. */) |
| 6261 | 6201 | (Lisp_Object window, Lisp_Object left_width, | |
| 6262 | clear_glyph_matrix (w->current_matrix); | 6202 | Lisp_Object right_width, Lisp_Object outside_margins) |
| 6263 | w->window_end_valid = 0; | 6203 | { |
| 6264 | 6204 | struct window *w | |
| 6265 | ++windows_or_buffers_changed; | 6205 | = set_window_fringes (decode_live_window (window), |
| 6266 | adjust_glyphs (XFRAME (WINDOW_FRAME (w))); | 6206 | left_width, right_width, outside_margins); |
| 6267 | } | 6207 | return w ? (apply_window_adjustment (w), Qt) : Qnil; |
| 6268 | |||
| 6269 | return Qnil; | ||
| 6270 | } | 6208 | } |
| 6271 | 6209 | ||
| 6272 | 6210 | ||
| @@ -6291,29 +6229,14 @@ Value is a list of the form (LEFT-WIDTH RIGHT-WIDTH OUTSIDE-MARGINS). */) | |||
| 6291 | Scroll bars | 6229 | Scroll bars |
| 6292 | ***********************************************************************/ | 6230 | ***********************************************************************/ |
| 6293 | 6231 | ||
| 6294 | DEFUN ("set-window-scroll-bars", Fset_window_scroll_bars, | 6232 | static struct window * |
| 6295 | Sset_window_scroll_bars, 2, 4, 0, | 6233 | set_window_scroll_bars (struct window *w, Lisp_Object width, |
| 6296 | doc: /* Set width and type of scroll bars of window WINDOW. | 6234 | Lisp_Object vertical_type, Lisp_Object horizontal_type) |
| 6297 | WINDOW must be a live window and defaults to the selected one. | ||
| 6298 | |||
| 6299 | Second parameter WIDTH specifies the pixel width for the scroll bar; | ||
| 6300 | this is automatically adjusted to a multiple of the frame column width. | ||
| 6301 | Third parameter VERTICAL-TYPE specifies the type of the vertical scroll | ||
| 6302 | bar: left, right, or nil. | ||
| 6303 | If WIDTH is nil, use the frame's scroll-bar width. | ||
| 6304 | If VERTICAL-TYPE is t, use the frame's scroll-bar type. | ||
| 6305 | Fourth parameter HORIZONTAL-TYPE is currently unused. */) | ||
| 6306 | (Lisp_Object window, Lisp_Object width, Lisp_Object vertical_type, Lisp_Object horizontal_type) | ||
| 6307 | { | 6235 | { |
| 6308 | struct window *w = decode_live_window (window); | 6236 | int iwidth = (NILP (width) ? -1 : (CHECK_NATNUM (width), XINT (width))); |
| 6309 | 6237 | ||
| 6310 | if (!NILP (width)) | 6238 | if (iwidth == 0) |
| 6311 | { | 6239 | vertical_type = Qnil; |
| 6312 | CHECK_RANGED_INTEGER (width, 0, INT_MAX); | ||
| 6313 | |||
| 6314 | if (XINT (width) == 0) | ||
| 6315 | vertical_type = Qnil; | ||
| 6316 | } | ||
| 6317 | 6240 | ||
| 6318 | if (!(NILP (vertical_type) | 6241 | if (!(NILP (vertical_type) |
| 6319 | || EQ (vertical_type, Qleft) | 6242 | || EQ (vertical_type, Qleft) |
| @@ -6321,22 +6244,37 @@ Fourth parameter HORIZONTAL-TYPE is currently unused. */) | |||
| 6321 | || EQ (vertical_type, Qt))) | 6244 | || EQ (vertical_type, Qt))) |
| 6322 | error ("Invalid type of vertical scroll bar"); | 6245 | error ("Invalid type of vertical scroll bar"); |
| 6323 | 6246 | ||
| 6324 | if (!EQ (w->scroll_bar_width, width) | 6247 | if (w->scroll_bar_width != iwidth |
| 6325 | || !EQ (w->vertical_scroll_bar_type, vertical_type)) | 6248 | || !EQ (w->vertical_scroll_bar_type, vertical_type)) |
| 6326 | { | 6249 | { |
| 6327 | wset_scroll_bar_width (w, width); | 6250 | w->scroll_bar_width = iwidth; |
| 6328 | wset_vertical_scroll_bar_type (w, vertical_type); | 6251 | wset_vertical_scroll_bar_type (w, vertical_type); |
| 6252 | return w; | ||
| 6253 | } | ||
| 6254 | return NULL; | ||
| 6255 | } | ||
| 6329 | 6256 | ||
| 6330 | adjust_window_margins (w); | 6257 | DEFUN ("set-window-scroll-bars", Fset_window_scroll_bars, |
| 6331 | 6258 | Sset_window_scroll_bars, 2, 4, 0, | |
| 6332 | clear_glyph_matrix (w->current_matrix); | 6259 | doc: /* Set width and type of scroll bars of window WINDOW. |
| 6333 | w->window_end_valid = 0; | 6260 | WINDOW must be a live window and defaults to the selected one. |
| 6334 | 6261 | ||
| 6335 | ++windows_or_buffers_changed; | 6262 | Second parameter WIDTH specifies the pixel width for the scroll bar; |
| 6336 | adjust_glyphs (XFRAME (WINDOW_FRAME (w))); | 6263 | this is automatically adjusted to a multiple of the frame column width. |
| 6337 | } | 6264 | Third parameter VERTICAL-TYPE specifies the type of the vertical scroll |
| 6265 | bar: left, right, or nil. | ||
| 6266 | If WIDTH is nil, use the frame's scroll-bar width. | ||
| 6267 | If VERTICAL-TYPE is t, use the frame's scroll-bar type. | ||
| 6268 | Fourth parameter HORIZONTAL-TYPE is currently unused. | ||
| 6338 | 6269 | ||
| 6339 | return Qnil; | 6270 | Return t if scroll bars was actually changed and nil otherwise. */) |
| 6271 | (Lisp_Object window, Lisp_Object width, | ||
| 6272 | Lisp_Object vertical_type, Lisp_Object horizontal_type) | ||
| 6273 | { | ||
| 6274 | struct window *w | ||
| 6275 | = set_window_scroll_bars (decode_live_window (window), | ||
| 6276 | width, vertical_type, horizontal_type); | ||
| 6277 | return w ? (apply_window_adjustment (w), Qt) : Qnil; | ||
| 6340 | } | 6278 | } |
| 6341 | 6279 | ||
| 6342 | 6280 | ||
| @@ -6465,38 +6403,6 @@ foreach_window_1 (struct window *w, int (*fn) (struct window *, void *), void *u | |||
| 6465 | return cont; | 6403 | return cont; |
| 6466 | } | 6404 | } |
| 6467 | 6405 | ||
| 6468 | |||
| 6469 | /* Freeze or unfreeze the window start of W unless it is a | ||
| 6470 | mini-window or the selected window. FREEZE_P non-null means freeze | ||
| 6471 | the window start. */ | ||
| 6472 | |||
| 6473 | static int | ||
| 6474 | freeze_window_start (struct window *w, void *freeze_p) | ||
| 6475 | { | ||
| 6476 | if (MINI_WINDOW_P (w) | ||
| 6477 | || (WINDOWP (selected_window) /* Can be nil in corner cases. */ | ||
| 6478 | && (w == XWINDOW (selected_window) | ||
| 6479 | || (MINI_WINDOW_P (XWINDOW (selected_window)) | ||
| 6480 | && ! NILP (Vminibuf_scroll_window) | ||
| 6481 | && w == XWINDOW (Vminibuf_scroll_window))))) | ||
| 6482 | freeze_p = NULL; | ||
| 6483 | |||
| 6484 | w->frozen_window_start_p = freeze_p != NULL; | ||
| 6485 | return 1; | ||
| 6486 | } | ||
| 6487 | |||
| 6488 | |||
| 6489 | /* Freeze or unfreeze the window starts of all leaf windows on frame | ||
| 6490 | F, except the selected window and a mini-window. FREEZE_P non-zero | ||
| 6491 | means freeze the window start. */ | ||
| 6492 | |||
| 6493 | void | ||
| 6494 | freeze_window_starts (struct frame *f, bool freeze_p) | ||
| 6495 | { | ||
| 6496 | foreach_window (f, freeze_window_start, (void *) (freeze_p ? f : 0)); | ||
| 6497 | } | ||
| 6498 | |||
| 6499 | |||
| 6500 | /*********************************************************************** | 6406 | /*********************************************************************** |
| 6501 | Initialization | 6407 | Initialization |
| 6502 | ***********************************************************************/ | 6408 | ***********************************************************************/ |