aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDmitry Antipov2013-08-14 08:09:37 +0400
committerDmitry Antipov2013-08-14 08:09:37 +0400
commit25554267037ced56fdaed17e3a09d8926b70f978 (patch)
tree82f7ab94ebd3967737e4dd2e2dec0cd24b9467d3 /src
parent38a2c91021a5d5405438ba291b60f7ccdaa99862 (diff)
downloademacs-25554267037ced56fdaed17e3a09d8926b70f978.tar.gz
emacs-25554267037ced56fdaed17e3a09d8926b70f978.zip
Cleanup window fringes, margins and scroll bars adjustments.
* window.c (set_window_fringes, set_window_margins) (set_window_scroll_bars, apply_window_adjustment): New functions. (set_window_buffer, Fset_window_margins, Fset_window_fringes) (Fset_window_scroll_bars): Use them.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog8
-rw-r--r--src/window.c199
2 files changed, 112 insertions, 95 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 7081236ec65..af088340e3b 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,13 @@
12013-08-14 Dmitry Antipov <dmantipov@yandex.ru> 12013-08-14 Dmitry Antipov <dmantipov@yandex.ru>
2 2
3 Cleanup window fringes, margins and scroll bars adjustments.
4 * window.c (set_window_fringes, set_window_margins)
5 (set_window_scroll_bars, apply_window_adjustment): New functions.
6 (set_window_buffer, Fset_window_margins, Fset_window_fringes)
7 (Fset_window_scroll_bars): Use them.
8
92013-08-14 Dmitry Antipov <dmantipov@yandex.ru>
10
3 * window.h (struct window): Convert scroll_bar_width 11 * window.h (struct window): Convert scroll_bar_width
4 from Lisp_Object to integer. Adjust comment. 12 from Lisp_Object to integer. Adjust comment.
5 (WINDOW_CONFIG_SCROLL_BAR_WIDTH, WINDOW_CONFIG_SCROLL_BAR_COLS): 13 (WINDOW_CONFIG_SCROLL_BAR_WIDTH, WINDOW_CONFIG_SCROLL_BAR_COLS):
diff --git a/src/window.c b/src/window.c
index 7b2e9b08881..d07eed86a1c 100644
--- a/src/window.c
+++ b/src/window.c
@@ -87,6 +87,14 @@ static void window_resize_apply (struct window *, bool);
87static Lisp_Object select_window (Lisp_Object, Lisp_Object, int); 87static Lisp_Object select_window (Lisp_Object, Lisp_Object, int);
88static void select_window_1 (Lisp_Object, bool); 88static void select_window_1 (Lisp_Object, bool);
89 89
90static struct window *set_window_fringes (struct window *, Lisp_Object,
91 Lisp_Object, Lisp_Object);
92static struct window *set_window_margins (struct window *, Lisp_Object,
93 Lisp_Object);
94static struct window *set_window_scroll_bars (struct window *, Lisp_Object,
95 Lisp_Object, Lisp_Object);
96static void apply_window_adjustment (struct window *);
97
90/* This is the window in which the terminal's cursor should 98/* This is the window in which the terminal's cursor should
91 be left when nothing is being done with it. This must 99 be left when nothing is being done with it. This must
92 always be a leaf window, and its buffer is selected by 100 always be a leaf window, and its buffer is selected by
@@ -3202,28 +3210,14 @@ set_window_buffer (Lisp_Object window, Lisp_Object buffer,
3202 if (!keep_margins_p) 3210 if (!keep_margins_p)
3203 { 3211 {
3204 /* Set left and right marginal area width etc. from buffer. */ 3212 /* Set left and right marginal area width etc. from buffer. */
3205 3213 set_window_fringes (w, BVAR (b, left_fringe_width),
3206 /* This may call adjust_window_margins three times, so 3214 BVAR (b, right_fringe_width),
3207 temporarily disable window margins. */ 3215 BVAR (b, fringes_outside_margins));
3208 int save_left = w->left_margin_cols; 3216 set_window_scroll_bars (w, BVAR (b, scroll_bar_width),
3209 int save_right = w->right_margin_cols; 3217 BVAR (b, vertical_scroll_bar_type), Qnil);
3210 3218 set_window_margins (w, BVAR (b, left_margin_cols),
3211 w->left_margin_cols = 0; 3219 BVAR (b, right_margin_cols));
3212 w->right_margin_cols = 0; 3220 apply_window_adjustment (w);
3213
3214 Fset_window_fringes (window,
3215 BVAR (b, left_fringe_width), BVAR (b, right_fringe_width),
3216 BVAR (b, fringes_outside_margins));
3217
3218 Fset_window_scroll_bars (window,
3219 BVAR (b, scroll_bar_width),
3220 BVAR (b, vertical_scroll_bar_type), Qnil);
3221
3222 w->left_margin_cols = save_left;
3223 w->right_margin_cols = save_right;
3224
3225 Fset_window_margins (window,
3226 BVAR (b, left_margin_cols), BVAR (b, right_margin_cols));
3227 } 3221 }
3228 3222
3229 if (run_hooks_p) 3223 if (run_hooks_p)
@@ -6112,29 +6106,32 @@ saved by this function. */)
6112 XSETWINDOW_CONFIGURATION (tem, data); 6106 XSETWINDOW_CONFIGURATION (tem, data);
6113 return (tem); 6107 return (tem);
6114} 6108}
6109
6110/* Called after W's margins, fringes or scroll bars was adjusted. */
6111
6112static void
6113apply_window_adjustment (struct window *w)
6114{
6115 eassert (w);
6116 adjust_window_margins (w);
6117 clear_glyph_matrix (w->current_matrix);
6118 w->window_end_valid = 0;
6119 windows_or_buffers_changed++;
6120 adjust_glyphs (XFRAME (WINDOW_FRAME (w)));
6121}
6122
6115 6123
6116/*********************************************************************** 6124/***********************************************************************
6117 Marginal Areas 6125 Marginal Areas
6118 ***********************************************************************/ 6126 ***********************************************************************/
6119 6127
6120DEFUN ("set-window-margins", Fset_window_margins, Sset_window_margins, 6128static struct window *
6121 2, 3, 0, 6129set_window_margins (struct window *w, Lisp_Object left_width,
6122 doc: /* Set width of marginal areas of window WINDOW. 6130 Lisp_Object right_width)
6123WINDOW must be a live window and defaults to the selected one.
6124
6125Second arg LEFT-WIDTH specifies the number of character cells to
6126reserve for the left marginal area. Optional third arg RIGHT-WIDTH
6127does the same for the right marginal area. A nil width parameter
6128means no margin.
6129
6130Return t if any margin was actually changed and nil otherwise. */)
6131 (Lisp_Object window, Lisp_Object left_width, Lisp_Object right_width)
6132{ 6131{
6133 struct window *w = decode_live_window (window);
6134 int left, right; 6132 int left, right;
6135 6133
6136 /* FIXME: what about margins that are too wide? */ 6134 /* FIXME: what about margins that are too wide? */
6137
6138 left = (NILP (left_width) ? 0 6135 left = (NILP (left_width) ? 0
6139 : (CHECK_NATNUM (left_width), XINT (left_width))); 6136 : (CHECK_NATNUM (left_width), XINT (left_width)));
6140 right = (NILP (right_width) ? 0 6137 right = (NILP (right_width) ? 0
@@ -6144,15 +6141,27 @@ Return t if any margin was actually changed and nil otherwise. */)
6144 { 6141 {
6145 w->left_margin_cols = left; 6142 w->left_margin_cols = left;
6146 w->right_margin_cols = right; 6143 w->right_margin_cols = right;
6144 return w;
6145 }
6146 return NULL;
6147}
6147 6148
6148 adjust_window_margins (w); 6149DEFUN ("set-window-margins", Fset_window_margins, Sset_window_margins,
6150 2, 3, 0,
6151 doc: /* Set width of marginal areas of window WINDOW.
6152WINDOW must be a live window and defaults to the selected one.
6149 6153
6150 ++windows_or_buffers_changed; 6154Second arg LEFT-WIDTH specifies the number of character cells to
6151 adjust_glyphs (XFRAME (WINDOW_FRAME (w))); 6155reserve for the left marginal area. Optional third arg RIGHT-WIDTH
6152 return Qt; 6156does the same for the right marginal area. A nil width parameter
6153 } 6157means no margin.
6154 6158
6155 return Qnil; 6159Return t if any margin was actually changed and nil otherwise. */)
6160 (Lisp_Object window, Lisp_Object left_width, Lisp_Object right_width)
6161{
6162 struct window *w = set_window_margins (decode_live_window (window),
6163 left_width, right_width);
6164 return w ? (apply_window_adjustment (w), Qt) : Qnil;
6156} 6165}
6157 6166
6158 6167
@@ -6177,25 +6186,10 @@ as nil. */)
6177 Fringes 6186 Fringes
6178 ***********************************************************************/ 6187 ***********************************************************************/
6179 6188
6180DEFUN ("set-window-fringes", Fset_window_fringes, Sset_window_fringes, 6189static struct window *
6181 2, 4, 0, 6190set_window_fringes (struct window *w, Lisp_Object left_width,
6182 doc: /* Set the fringe widths of window WINDOW. 6191 Lisp_Object right_width, Lisp_Object outside_margins)
6183WINDOW must be a live window and defaults to the selected one.
6184
6185Second arg LEFT-WIDTH specifies the number of pixels to reserve for
6186the left fringe. Optional third arg RIGHT-WIDTH specifies the right
6187fringe width. If a fringe width arg is nil, that means to use the
6188frame's default fringe width. Default fringe widths can be set with
6189the command `set-fringe-style'.
6190If optional fourth arg OUTSIDE-MARGINS is non-nil, draw the fringes
6191outside of the display margins. By default, fringes are drawn between
6192display marginal areas and the text area.
6193
6194Return t if any fringe was actually changed and nil otherwise. */)
6195 (Lisp_Object window, Lisp_Object left_width,
6196 Lisp_Object right_width, Lisp_Object outside_margins)
6197{ 6192{
6198 struct window *w = decode_live_window (window);
6199 int left, right, outside = !NILP (outside_margins); 6193 int left, right, outside = !NILP (outside_margins);
6200 6194
6201 left = (NILP (left_width) ? -1 6195 left = (NILP (left_width) ? -1
@@ -6212,18 +6206,33 @@ Return t if any fringe was actually changed and nil otherwise. */)
6212 w->left_fringe_width = left; 6206 w->left_fringe_width = left;
6213 w->right_fringe_width = right; 6207 w->right_fringe_width = right;
6214 w->fringes_outside_margins = outside; 6208 w->fringes_outside_margins = outside;
6209 return w;
6210 }
6211 return NULL;
6212}
6215 6213
6216 adjust_window_margins (w); 6214DEFUN ("set-window-fringes", Fset_window_fringes, Sset_window_fringes,
6217 6215 2, 4, 0,
6218 clear_glyph_matrix (w->current_matrix); 6216 doc: /* Set the fringe widths of window WINDOW.
6219 w->window_end_valid = 0; 6217WINDOW must be a live window and defaults to the selected one.
6220 6218
6221 ++windows_or_buffers_changed; 6219Second arg LEFT-WIDTH specifies the number of pixels to reserve for
6222 adjust_glyphs (XFRAME (WINDOW_FRAME (w))); 6220the left fringe. Optional third arg RIGHT-WIDTH specifies the right
6223 return Qt; 6221fringe width. If a fringe width arg is nil, that means to use the
6224 } 6222frame's default fringe width. Default fringe widths can be set with
6223the command `set-fringe-style'.
6224If optional fourth arg OUTSIDE-MARGINS is non-nil, draw the fringes
6225outside of the display margins. By default, fringes are drawn between
6226display marginal areas and the text area.
6225 6227
6226 return Qnil; 6228Return t if any fringe was actually changed and nil otherwise. */)
6229 (Lisp_Object window, Lisp_Object left_width,
6230 Lisp_Object right_width, Lisp_Object outside_margins)
6231{
6232 struct window *w
6233 = set_window_fringes (decode_live_window (window),
6234 left_width, right_width, outside_margins);
6235 return w ? (apply_window_adjustment (w), Qt) : Qnil;
6227} 6236}
6228 6237
6229 6238
@@ -6248,24 +6257,10 @@ Value is a list of the form (LEFT-WIDTH RIGHT-WIDTH OUTSIDE-MARGINS). */)
6248 Scroll bars 6257 Scroll bars
6249 ***********************************************************************/ 6258 ***********************************************************************/
6250 6259
6251DEFUN ("set-window-scroll-bars", Fset_window_scroll_bars, 6260static struct window *
6252 Sset_window_scroll_bars, 2, 4, 0, 6261set_window_scroll_bars (struct window *w, Lisp_Object width,
6253 doc: /* Set width and type of scroll bars of window WINDOW. 6262 Lisp_Object vertical_type, Lisp_Object horizontal_type)
6254WINDOW must be a live window and defaults to the selected one.
6255
6256Second parameter WIDTH specifies the pixel width for the scroll bar;
6257this is automatically adjusted to a multiple of the frame column width.
6258Third parameter VERTICAL-TYPE specifies the type of the vertical scroll
6259bar: left, right, or nil.
6260If WIDTH is nil, use the frame's scroll-bar width.
6261If VERTICAL-TYPE is t, use the frame's scroll-bar type.
6262Fourth parameter HORIZONTAL-TYPE is currently unused.
6263
6264Return t if scroll bars was actually changed and nil otherwise. */)
6265 (Lisp_Object window, Lisp_Object width,
6266 Lisp_Object vertical_type, Lisp_Object horizontal_type)
6267{ 6263{
6268 struct window *w = decode_live_window (window);
6269 int iwidth = (NILP (width) ? -1 : (CHECK_NATNUM (width), XINT (width))); 6264 int iwidth = (NILP (width) ? -1 : (CHECK_NATNUM (width), XINT (width)));
6270 6265
6271 if (iwidth == 0) 6266 if (iwidth == 0)
@@ -6282,18 +6277,32 @@ Return t if scroll bars was actually changed and nil otherwise. */)
6282 { 6277 {
6283 w->scroll_bar_width = iwidth; 6278 w->scroll_bar_width = iwidth;
6284 wset_vertical_scroll_bar_type (w, vertical_type); 6279 wset_vertical_scroll_bar_type (w, vertical_type);
6280 return w;
6281 }
6282 return NULL;
6283}
6285 6284
6286 adjust_window_margins (w); 6285DEFUN ("set-window-scroll-bars", Fset_window_scroll_bars,
6287 6286 Sset_window_scroll_bars, 2, 4, 0,
6288 clear_glyph_matrix (w->current_matrix); 6287 doc: /* Set width and type of scroll bars of window WINDOW.
6289 w->window_end_valid = 0; 6288WINDOW must be a live window and defaults to the selected one.
6290 6289
6291 ++windows_or_buffers_changed; 6290Second parameter WIDTH specifies the pixel width for the scroll bar;
6292 adjust_glyphs (XFRAME (WINDOW_FRAME (w))); 6291this is automatically adjusted to a multiple of the frame column width.
6293 return Qt; 6292Third parameter VERTICAL-TYPE specifies the type of the vertical scroll
6294 } 6293bar: left, right, or nil.
6294If WIDTH is nil, use the frame's scroll-bar width.
6295If VERTICAL-TYPE is t, use the frame's scroll-bar type.
6296Fourth parameter HORIZONTAL-TYPE is currently unused.
6295 6297
6296 return Qnil; 6298Return t if scroll bars was actually changed and nil otherwise. */)
6299 (Lisp_Object window, Lisp_Object width,
6300 Lisp_Object vertical_type, Lisp_Object horizontal_type)
6301{
6302 struct window *w
6303 = set_window_scroll_bars (decode_live_window (window),
6304 width, vertical_type, horizontal_type);
6305 return w ? (apply_window_adjustment (w), Qt) : Qnil;
6297} 6306}
6298 6307
6299 6308