diff options
Diffstat (limited to 'src/window.c')
| -rw-r--r-- | src/window.c | 221 |
1 files changed, 113 insertions, 108 deletions
diff --git a/src/window.c b/src/window.c index d5f872125fa..c61a02aeb01 100644 --- a/src/window.c +++ b/src/window.c | |||
| @@ -90,6 +90,14 @@ static void window_resize_apply (struct window *, bool); | |||
| 90 | static Lisp_Object select_window (Lisp_Object, Lisp_Object, int); | 90 | static Lisp_Object select_window (Lisp_Object, Lisp_Object, int); |
| 91 | static void select_window_1 (Lisp_Object, bool); | 91 | static void select_window_1 (Lisp_Object, bool); |
| 92 | 92 | ||
| 93 | static struct window *set_window_fringes (struct window *, Lisp_Object, | ||
| 94 | Lisp_Object, Lisp_Object); | ||
| 95 | static struct window *set_window_margins (struct window *, Lisp_Object, | ||
| 96 | Lisp_Object); | ||
| 97 | static struct window *set_window_scroll_bars (struct window *, Lisp_Object, | ||
| 98 | Lisp_Object, Lisp_Object); | ||
| 99 | static void apply_window_adjustment (struct window *); | ||
| 100 | |||
| 93 | /* This is the window in which the terminal's cursor should | 101 | /* This is the window in which the terminal's cursor should |
| 94 | be left when nothing is being done with it. This must | 102 | be left when nothing is being done with it. This must |
| 95 | always be a leaf window, and its buffer is selected by | 103 | always be a leaf window, and its buffer is selected by |
| @@ -184,11 +192,6 @@ wset_pointm (struct window *w, Lisp_Object val) | |||
| 184 | w->pointm = val; | 192 | w->pointm = val; |
| 185 | } | 193 | } |
| 186 | static void | 194 | static void |
| 187 | wset_scroll_bar_width (struct window *w, Lisp_Object val) | ||
| 188 | { | ||
| 189 | w->scroll_bar_width = val; | ||
| 190 | } | ||
| 191 | static void | ||
| 192 | wset_start (struct window *w, Lisp_Object val) | 195 | wset_start (struct window *w, Lisp_Object val) |
| 193 | { | 196 | { |
| 194 | w->start = val; | 197 | w->start = val; |
| @@ -3210,28 +3213,14 @@ set_window_buffer (Lisp_Object window, Lisp_Object buffer, | |||
| 3210 | if (!keep_margins_p) | 3213 | if (!keep_margins_p) |
| 3211 | { | 3214 | { |
| 3212 | /* Set left and right marginal area width etc. from buffer. */ | 3215 | /* Set left and right marginal area width etc. from buffer. */ |
| 3213 | 3216 | set_window_fringes (w, BVAR (b, left_fringe_width), | |
| 3214 | /* This may call adjust_window_margins three times, so | 3217 | BVAR (b, right_fringe_width), |
| 3215 | temporarily disable window margins. */ | 3218 | BVAR (b, fringes_outside_margins)); |
| 3216 | int save_left = w->left_margin_cols; | 3219 | set_window_scroll_bars (w, BVAR (b, scroll_bar_width), |
| 3217 | int save_right = w->right_margin_cols; | 3220 | BVAR (b, vertical_scroll_bar_type), Qnil); |
| 3218 | 3221 | set_window_margins (w, BVAR (b, left_margin_cols), | |
| 3219 | w->left_margin_cols = 0; | 3222 | BVAR (b, right_margin_cols)); |
| 3220 | w->right_margin_cols = 0; | 3223 | apply_window_adjustment (w); |
| 3221 | |||
| 3222 | Fset_window_fringes (window, | ||
| 3223 | BVAR (b, left_fringe_width), BVAR (b, right_fringe_width), | ||
| 3224 | BVAR (b, fringes_outside_margins)); | ||
| 3225 | |||
| 3226 | Fset_window_scroll_bars (window, | ||
| 3227 | BVAR (b, scroll_bar_width), | ||
| 3228 | BVAR (b, vertical_scroll_bar_type), Qnil); | ||
| 3229 | |||
| 3230 | w->left_margin_cols = save_left; | ||
| 3231 | w->right_margin_cols = save_right; | ||
| 3232 | |||
| 3233 | Fset_window_margins (window, | ||
| 3234 | BVAR (b, left_margin_cols), BVAR (b, right_margin_cols)); | ||
| 3235 | } | 3224 | } |
| 3236 | 3225 | ||
| 3237 | if (run_hooks_p) | 3226 | if (run_hooks_p) |
| @@ -3464,6 +3453,7 @@ make_window (void) | |||
| 3464 | w->left_fringe_width = w->right_fringe_width = -1; | 3453 | w->left_fringe_width = w->right_fringe_width = -1; |
| 3465 | w->phys_cursor_type = -1; | 3454 | w->phys_cursor_type = -1; |
| 3466 | w->phys_cursor_width = -1; | 3455 | w->phys_cursor_width = -1; |
| 3456 | w->scroll_bar_width = -1; | ||
| 3467 | w->column_number_displayed = -1; | 3457 | w->column_number_displayed = -1; |
| 3468 | 3458 | ||
| 3469 | /* Reset window_list. */ | 3459 | /* Reset window_list. */ |
| @@ -3934,7 +3924,7 @@ set correctly. See the code of `split-window' for how this is done. */) | |||
| 3934 | n->left_fringe_width = r->left_fringe_width; | 3924 | n->left_fringe_width = r->left_fringe_width; |
| 3935 | n->right_fringe_width = r->right_fringe_width; | 3925 | n->right_fringe_width = r->right_fringe_width; |
| 3936 | n->fringes_outside_margins = r->fringes_outside_margins; | 3926 | n->fringes_outside_margins = r->fringes_outside_margins; |
| 3937 | wset_scroll_bar_width (n, r->scroll_bar_width); | 3927 | n->scroll_bar_width = r->scroll_bar_width; |
| 3938 | wset_vertical_scroll_bar_type (n, r->vertical_scroll_bar_type); | 3928 | wset_vertical_scroll_bar_type (n, r->vertical_scroll_bar_type); |
| 3939 | 3929 | ||
| 3940 | /* Directly assign orthogonal coordinates and sizes. */ | 3930 | /* Directly assign orthogonal coordinates and sizes. */ |
| @@ -5680,7 +5670,7 @@ the return value is nil. Otherwise the value is t. */) | |||
| 5680 | w->left_fringe_width = XINT (p->left_fringe_width); | 5670 | w->left_fringe_width = XINT (p->left_fringe_width); |
| 5681 | w->right_fringe_width = XINT (p->right_fringe_width); | 5671 | w->right_fringe_width = XINT (p->right_fringe_width); |
| 5682 | w->fringes_outside_margins = !NILP (p->fringes_outside_margins); | 5672 | w->fringes_outside_margins = !NILP (p->fringes_outside_margins); |
| 5683 | wset_scroll_bar_width (w, p->scroll_bar_width); | 5673 | w->scroll_bar_width = XINT (p->scroll_bar_width); |
| 5684 | wset_vertical_scroll_bar_type (w, p->vertical_scroll_bar_type); | 5674 | wset_vertical_scroll_bar_type (w, p->vertical_scroll_bar_type); |
| 5685 | wset_dedicated (w, p->dedicated); | 5675 | wset_dedicated (w, p->dedicated); |
| 5686 | wset_combination_limit (w, p->combination_limit); | 5676 | wset_combination_limit (w, p->combination_limit); |
| @@ -5981,7 +5971,7 @@ save_window_save (Lisp_Object window, struct Lisp_Vector *vector, int i) | |||
| 5981 | p->left_fringe_width = make_number (w->left_fringe_width); | 5971 | p->left_fringe_width = make_number (w->left_fringe_width); |
| 5982 | p->right_fringe_width = make_number (w->right_fringe_width); | 5972 | p->right_fringe_width = make_number (w->right_fringe_width); |
| 5983 | p->fringes_outside_margins = w->fringes_outside_margins ? Qt : Qnil; | 5973 | p->fringes_outside_margins = w->fringes_outside_margins ? Qt : Qnil; |
| 5984 | p->scroll_bar_width = w->scroll_bar_width; | 5974 | p->scroll_bar_width = make_number (w->scroll_bar_width); |
| 5985 | p->vertical_scroll_bar_type = w->vertical_scroll_bar_type; | 5975 | p->vertical_scroll_bar_type = w->vertical_scroll_bar_type; |
| 5986 | p->dedicated = w->dedicated; | 5976 | p->dedicated = w->dedicated; |
| 5987 | p->combination_limit = w->combination_limit; | 5977 | p->combination_limit = w->combination_limit; |
| @@ -6122,29 +6112,32 @@ saved by this function. */) | |||
| 6122 | XSETWINDOW_CONFIGURATION (tem, data); | 6112 | XSETWINDOW_CONFIGURATION (tem, data); |
| 6123 | return (tem); | 6113 | return (tem); |
| 6124 | } | 6114 | } |
| 6115 | |||
| 6116 | /* Called after W's margins, fringes or scroll bars was adjusted. */ | ||
| 6117 | |||
| 6118 | static void | ||
| 6119 | apply_window_adjustment (struct window *w) | ||
| 6120 | { | ||
| 6121 | eassert (w); | ||
| 6122 | adjust_window_margins (w); | ||
| 6123 | clear_glyph_matrix (w->current_matrix); | ||
| 6124 | w->window_end_valid = 0; | ||
| 6125 | windows_or_buffers_changed++; | ||
| 6126 | adjust_glyphs (XFRAME (WINDOW_FRAME (w))); | ||
| 6127 | } | ||
| 6128 | |||
| 6125 | 6129 | ||
| 6126 | /*********************************************************************** | 6130 | /*********************************************************************** |
| 6127 | Marginal Areas | 6131 | Marginal Areas |
| 6128 | ***********************************************************************/ | 6132 | ***********************************************************************/ |
| 6129 | 6133 | ||
| 6130 | DEFUN ("set-window-margins", Fset_window_margins, Sset_window_margins, | 6134 | static struct window * |
| 6131 | 2, 3, 0, | 6135 | set_window_margins (struct window *w, Lisp_Object left_width, |
| 6132 | doc: /* Set width of marginal areas of window WINDOW. | 6136 | Lisp_Object right_width) |
| 6133 | WINDOW must be a live window and defaults to the selected one. | ||
| 6134 | |||
| 6135 | Second arg LEFT-WIDTH specifies the number of character cells to | ||
| 6136 | reserve for the left marginal area. Optional third arg RIGHT-WIDTH | ||
| 6137 | does the same for the right marginal area. A nil width parameter | ||
| 6138 | means no margin. | ||
| 6139 | |||
| 6140 | Return t if any margin was actually changed and nil otherwise. */) | ||
| 6141 | (Lisp_Object window, Lisp_Object left_width, Lisp_Object right_width) | ||
| 6142 | { | 6137 | { |
| 6143 | struct window *w = decode_live_window (window); | ||
| 6144 | int left, right; | 6138 | int left, right; |
| 6145 | 6139 | ||
| 6146 | /* FIXME: what about margins that are too wide? */ | 6140 | /* FIXME: what about margins that are too wide? */ |
| 6147 | |||
| 6148 | left = (NILP (left_width) ? 0 | 6141 | left = (NILP (left_width) ? 0 |
| 6149 | : (CHECK_NATNUM (left_width), XINT (left_width))); | 6142 | : (CHECK_NATNUM (left_width), XINT (left_width))); |
| 6150 | right = (NILP (right_width) ? 0 | 6143 | right = (NILP (right_width) ? 0 |
| @@ -6154,15 +6147,27 @@ Return t if any margin was actually changed and nil otherwise. */) | |||
| 6154 | { | 6147 | { |
| 6155 | w->left_margin_cols = left; | 6148 | w->left_margin_cols = left; |
| 6156 | w->right_margin_cols = right; | 6149 | w->right_margin_cols = right; |
| 6150 | return w; | ||
| 6151 | } | ||
| 6152 | return NULL; | ||
| 6153 | } | ||
| 6157 | 6154 | ||
| 6158 | adjust_window_margins (w); | 6155 | DEFUN ("set-window-margins", Fset_window_margins, Sset_window_margins, |
| 6156 | 2, 3, 0, | ||
| 6157 | doc: /* Set width of marginal areas of window WINDOW. | ||
| 6158 | WINDOW must be a live window and defaults to the selected one. | ||
| 6159 | 6159 | ||
| 6160 | ++windows_or_buffers_changed; | 6160 | Second arg LEFT-WIDTH specifies the number of character cells to |
| 6161 | adjust_glyphs (XFRAME (WINDOW_FRAME (w))); | 6161 | reserve for the left marginal area. Optional third arg RIGHT-WIDTH |
| 6162 | return Qt; | 6162 | does the same for the right marginal area. A nil width parameter |
| 6163 | } | 6163 | means no margin. |
| 6164 | 6164 | ||
| 6165 | return Qnil; | 6165 | Return t if any margin was actually changed and nil otherwise. */) |
| 6166 | (Lisp_Object window, Lisp_Object left_width, Lisp_Object right_width) | ||
| 6167 | { | ||
| 6168 | struct window *w = set_window_margins (decode_live_window (window), | ||
| 6169 | left_width, right_width); | ||
| 6170 | return w ? (apply_window_adjustment (w), Qt) : Qnil; | ||
| 6166 | } | 6171 | } |
| 6167 | 6172 | ||
| 6168 | 6173 | ||
| @@ -6187,25 +6192,10 @@ as nil. */) | |||
| 6187 | Fringes | 6192 | Fringes |
| 6188 | ***********************************************************************/ | 6193 | ***********************************************************************/ |
| 6189 | 6194 | ||
| 6190 | DEFUN ("set-window-fringes", Fset_window_fringes, Sset_window_fringes, | 6195 | static struct window * |
| 6191 | 2, 4, 0, | 6196 | set_window_fringes (struct window *w, Lisp_Object left_width, |
| 6192 | doc: /* Set the fringe widths of window WINDOW. | 6197 | Lisp_Object right_width, Lisp_Object outside_margins) |
| 6193 | WINDOW must be a live window and defaults to the selected one. | ||
| 6194 | |||
| 6195 | Second arg LEFT-WIDTH specifies the number of pixels to reserve for | ||
| 6196 | the left fringe. Optional third arg RIGHT-WIDTH specifies the right | ||
| 6197 | fringe width. If a fringe width arg is nil, that means to use the | ||
| 6198 | frame's default fringe width. Default fringe widths can be set with | ||
| 6199 | the command `set-fringe-style'. | ||
| 6200 | If optional fourth arg OUTSIDE-MARGINS is non-nil, draw the fringes | ||
| 6201 | outside of the display margins. By default, fringes are drawn between | ||
| 6202 | display marginal areas and the text area. | ||
| 6203 | |||
| 6204 | Return t if any fringe was actually changed and nil otherwise. */) | ||
| 6205 | (Lisp_Object window, Lisp_Object left_width, | ||
| 6206 | Lisp_Object right_width, Lisp_Object outside_margins) | ||
| 6207 | { | 6198 | { |
| 6208 | struct window *w = decode_live_window (window); | ||
| 6209 | int left, right, outside = !NILP (outside_margins); | 6199 | int left, right, outside = !NILP (outside_margins); |
| 6210 | 6200 | ||
| 6211 | left = (NILP (left_width) ? -1 | 6201 | left = (NILP (left_width) ? -1 |
| @@ -6222,18 +6212,33 @@ Return t if any fringe was actually changed and nil otherwise. */) | |||
| 6222 | w->left_fringe_width = left; | 6212 | w->left_fringe_width = left; |
| 6223 | w->right_fringe_width = right; | 6213 | w->right_fringe_width = right; |
| 6224 | w->fringes_outside_margins = outside; | 6214 | w->fringes_outside_margins = outside; |
| 6215 | return w; | ||
| 6216 | } | ||
| 6217 | return NULL; | ||
| 6218 | } | ||
| 6225 | 6219 | ||
| 6226 | adjust_window_margins (w); | 6220 | DEFUN ("set-window-fringes", Fset_window_fringes, Sset_window_fringes, |
| 6227 | 6221 | 2, 4, 0, | |
| 6228 | clear_glyph_matrix (w->current_matrix); | 6222 | doc: /* Set the fringe widths of window WINDOW. |
| 6229 | w->window_end_valid = 0; | 6223 | WINDOW must be a live window and defaults to the selected one. |
| 6230 | 6224 | ||
| 6231 | ++windows_or_buffers_changed; | 6225 | Second arg LEFT-WIDTH specifies the number of pixels to reserve for |
| 6232 | adjust_glyphs (XFRAME (WINDOW_FRAME (w))); | 6226 | the left fringe. Optional third arg RIGHT-WIDTH specifies the right |
| 6233 | return Qt; | 6227 | fringe width. If a fringe width arg is nil, that means to use the |
| 6234 | } | 6228 | frame's default fringe width. Default fringe widths can be set with |
| 6229 | the command `set-fringe-style'. | ||
| 6230 | If optional fourth arg OUTSIDE-MARGINS is non-nil, draw the fringes | ||
| 6231 | outside of the display margins. By default, fringes are drawn between | ||
| 6232 | display marginal areas and the text area. | ||
| 6235 | 6233 | ||
| 6236 | return Qnil; | 6234 | Return t if any fringe was actually changed and nil otherwise. */) |
| 6235 | (Lisp_Object window, Lisp_Object left_width, | ||
| 6236 | Lisp_Object right_width, Lisp_Object outside_margins) | ||
| 6237 | { | ||
| 6238 | struct window *w | ||
| 6239 | = set_window_fringes (decode_live_window (window), | ||
| 6240 | left_width, right_width, outside_margins); | ||
| 6241 | return w ? (apply_window_adjustment (w), Qt) : Qnil; | ||
| 6237 | } | 6242 | } |
| 6238 | 6243 | ||
| 6239 | 6244 | ||
| @@ -6258,29 +6263,14 @@ Value is a list of the form (LEFT-WIDTH RIGHT-WIDTH OUTSIDE-MARGINS). */) | |||
| 6258 | Scroll bars | 6263 | Scroll bars |
| 6259 | ***********************************************************************/ | 6264 | ***********************************************************************/ |
| 6260 | 6265 | ||
| 6261 | DEFUN ("set-window-scroll-bars", Fset_window_scroll_bars, | 6266 | static struct window * |
| 6262 | Sset_window_scroll_bars, 2, 4, 0, | 6267 | set_window_scroll_bars (struct window *w, Lisp_Object width, |
| 6263 | doc: /* Set width and type of scroll bars of window WINDOW. | 6268 | Lisp_Object vertical_type, Lisp_Object horizontal_type) |
| 6264 | WINDOW must be a live window and defaults to the selected one. | ||
| 6265 | |||
| 6266 | Second parameter WIDTH specifies the pixel width for the scroll bar; | ||
| 6267 | this is automatically adjusted to a multiple of the frame column width. | ||
| 6268 | Third parameter VERTICAL-TYPE specifies the type of the vertical scroll | ||
| 6269 | bar: left, right, or nil. | ||
| 6270 | If WIDTH is nil, use the frame's scroll-bar width. | ||
| 6271 | If VERTICAL-TYPE is t, use the frame's scroll-bar type. | ||
| 6272 | Fourth parameter HORIZONTAL-TYPE is currently unused. */) | ||
| 6273 | (Lisp_Object window, Lisp_Object width, Lisp_Object vertical_type, Lisp_Object horizontal_type) | ||
| 6274 | { | 6269 | { |
| 6275 | struct window *w = decode_live_window (window); | 6270 | int iwidth = (NILP (width) ? -1 : (CHECK_NATNUM (width), XINT (width))); |
| 6276 | |||
| 6277 | if (!NILP (width)) | ||
| 6278 | { | ||
| 6279 | CHECK_RANGED_INTEGER (width, 0, INT_MAX); | ||
| 6280 | 6271 | ||
| 6281 | if (XINT (width) == 0) | 6272 | if (iwidth == 0) |
| 6282 | vertical_type = Qnil; | 6273 | vertical_type = Qnil; |
| 6283 | } | ||
| 6284 | 6274 | ||
| 6285 | if (!(NILP (vertical_type) | 6275 | if (!(NILP (vertical_type) |
| 6286 | || EQ (vertical_type, Qleft) | 6276 | || EQ (vertical_type, Qleft) |
| @@ -6288,22 +6278,37 @@ Fourth parameter HORIZONTAL-TYPE is currently unused. */) | |||
| 6288 | || EQ (vertical_type, Qt))) | 6278 | || EQ (vertical_type, Qt))) |
| 6289 | error ("Invalid type of vertical scroll bar"); | 6279 | error ("Invalid type of vertical scroll bar"); |
| 6290 | 6280 | ||
| 6291 | if (!EQ (w->scroll_bar_width, width) | 6281 | if (w->scroll_bar_width != iwidth |
| 6292 | || !EQ (w->vertical_scroll_bar_type, vertical_type)) | 6282 | || !EQ (w->vertical_scroll_bar_type, vertical_type)) |
| 6293 | { | 6283 | { |
| 6294 | wset_scroll_bar_width (w, width); | 6284 | w->scroll_bar_width = iwidth; |
| 6295 | wset_vertical_scroll_bar_type (w, vertical_type); | 6285 | wset_vertical_scroll_bar_type (w, vertical_type); |
| 6286 | return w; | ||
| 6287 | } | ||
| 6288 | return NULL; | ||
| 6289 | } | ||
| 6296 | 6290 | ||
| 6297 | adjust_window_margins (w); | 6291 | DEFUN ("set-window-scroll-bars", Fset_window_scroll_bars, |
| 6298 | 6292 | Sset_window_scroll_bars, 2, 4, 0, | |
| 6299 | clear_glyph_matrix (w->current_matrix); | 6293 | doc: /* Set width and type of scroll bars of window WINDOW. |
| 6300 | w->window_end_valid = 0; | 6294 | WINDOW must be a live window and defaults to the selected one. |
| 6301 | 6295 | ||
| 6302 | ++windows_or_buffers_changed; | 6296 | Second parameter WIDTH specifies the pixel width for the scroll bar; |
| 6303 | adjust_glyphs (XFRAME (WINDOW_FRAME (w))); | 6297 | this is automatically adjusted to a multiple of the frame column width. |
| 6304 | } | 6298 | Third parameter VERTICAL-TYPE specifies the type of the vertical scroll |
| 6299 | bar: left, right, or nil. | ||
| 6300 | If WIDTH is nil, use the frame's scroll-bar width. | ||
| 6301 | If VERTICAL-TYPE is t, use the frame's scroll-bar type. | ||
| 6302 | Fourth parameter HORIZONTAL-TYPE is currently unused. | ||
| 6305 | 6303 | ||
| 6306 | return Qnil; | 6304 | Return t if scroll bars was actually changed and nil otherwise. */) |
| 6305 | (Lisp_Object window, Lisp_Object width, | ||
| 6306 | Lisp_Object vertical_type, Lisp_Object horizontal_type) | ||
| 6307 | { | ||
| 6308 | struct window *w | ||
| 6309 | = set_window_scroll_bars (decode_live_window (window), | ||
| 6310 | width, vertical_type, horizontal_type); | ||
| 6311 | return w ? (apply_window_adjustment (w), Qt) : Qnil; | ||
| 6307 | } | 6312 | } |
| 6308 | 6313 | ||
| 6309 | 6314 | ||