right_margin_cols from Lisp_Objects to integers. Adjust comment.
(WINDOW_LEFT_MARGIN_COLS, WINDOW_RIGHT_MARGIN_COLS)
(WINDOW_LEFT_MARGIN_WIDTH, WINDOW_RIGHT_MARGIN_WIDTH):
Adjust users.
* dispnew.c (margin_glyphs_to_reserve): Convert 3rd arg to int.
Adjust comment.
(showing_window_margins_p, update_window_line, update_frame_1):
* fringe.c (draw_fringe_bitmap_1):
* xdisp.c (window_box_width): Adjust users.
* window.c (wset_left_margin_cols, wset_right_margin_cols): Remove.
(adjust_window_margins, set_window_buffer, Fsplit_window_internal):
Use direct assignment.
(Fset_window_configuration, save_window_save, Fwindow_margins):
Convert Lisp_Object to integer and back where appropriate.
(Fset_window_margins): Adjust user. Return t if any margin
was actually changed, and mention this in docstring.
+2013-08-13 Dmitry Antipov <dmantipov@yandex.ru>
+
+ * window.h (struct window): Convert left_margin_cols and
+ right_margin_cols from Lisp_Objects to integers. Adjust comment.
+ (WINDOW_LEFT_MARGIN_COLS, WINDOW_RIGHT_MARGIN_COLS)
+ (WINDOW_LEFT_MARGIN_WIDTH, WINDOW_RIGHT_MARGIN_WIDTH):
+ Adjust users.
+ * dispnew.c (margin_glyphs_to_reserve): Convert 3rd arg to int.
+ Adjust comment.
+ (showing_window_margins_p, update_window_line, update_frame_1):
+ * fringe.c (draw_fringe_bitmap_1):
+ * xdisp.c (window_box_width): Adjust users.
+ * window.c (wset_left_margin_cols, wset_right_margin_cols): Remove.
+ (adjust_window_margins, set_window_buffer, Fsplit_window_internal):
+ Use direct assignment.
+ (Fset_window_configuration, save_window_save, Fwindow_margins):
+ Convert Lisp_Object to integer and back where appropriate.
+ (Fset_window_margins): Adjust user. Return t if any margin
+ was actually changed, and mention this in docstring.
+
2013-08-13 Xue Fuqiao <xfq.free@gmail.com>
* syntax.c (forward_word):
/* Return the number of glyphs to reserve for a marginal area of
window W. TOTAL_GLYPHS is the number of glyphs in a complete
display line of window W. MARGIN gives the width of the marginal
- area in canonical character units. MARGIN should be an integer
- or a float. */
+ area in canonical character units. */
static int
-margin_glyphs_to_reserve (struct window *w, int total_glyphs, Lisp_Object margin)
+margin_glyphs_to_reserve (struct window *w, int total_glyphs, int margin)
{
- int n;
-
- if (NUMBERP (margin))
+ if (margin > 0)
{
int width = w->total_cols;
- double d = max (0, XFLOATINT (margin));
+ double d = max (0, margin);
d = min (width / 2 - 1, d);
- n = (int) ((double) total_glyphs / width * d);
+ return (int) ((double) total_glyphs / width * d);
}
- else
- n = 0;
-
- return n;
+ return 0;
}
/* Return true if ROW's hash value is correct.
if (showing_window_margins_p (XWINDOW (w->contents)))
return 1;
}
- else if (!NILP (w->left_margin_cols) || !NILP (w->right_margin_cols))
+ else if (w->left_margin_cols > 0 || w->right_margin_cols > 0)
return 1;
w = NILP (w->next) ? 0 : XWINDOW (w->next);
eassert (desired_row->enabled_p);
/* Update display of the left margin area, if there is one. */
- if (!desired_row->full_width_p
- && !NILP (w->left_margin_cols))
+ if (!desired_row->full_width_p && w->left_margin_cols > 0)
{
changed_p = 1;
update_marginal_area (w, LEFT_MARGIN_AREA, vpos);
}
/* Update display of the right margin area, if there is one. */
- if (!desired_row->full_width_p
- && !NILP (w->right_margin_cols))
+ if (!desired_row->full_width_p && w->right_margin_cols > 0)
{
changed_p = 1;
update_marginal_area (w, RIGHT_MARGIN_AREA, vpos);
int x = WINDOW_TO_FRAME_HPOS (w, w->cursor.hpos);
int y = WINDOW_TO_FRAME_VPOS (w, w->cursor.vpos);
- if (INTEGERP (w->left_margin_cols))
- x += XFASTINT (w->left_margin_cols);
-
- /* x = max (min (x, FRAME_TOTAL_COLS (f) - 1), 0); */
+ x += max (0, w->left_margin_cols);
cursor_to (f, y, x);
}
}
and OTOH leaving out that one pixel leaves behind
traces of the cursor, if it was in column zero
before drawing non-empty margin area. */
- && NILP (w->left_margin_cols))
+ && w->left_margin_cols == 0)
? 1 : 0);
p.bx = x - wd;
p.nx = wd;
w->display_table = val;
}
static void
-wset_left_margin_cols (struct window *w, Lisp_Object val)
-{
- w->left_margin_cols = val;
-}
-static void
wset_new_normal (struct window *w, Lisp_Object val)
{
w->new_normal = val;
w->pointm = val;
}
static void
-wset_right_margin_cols (struct window *w, Lisp_Object val)
-{
- w->right_margin_cols = val;
-}
-static void
wset_scroll_bar_width (struct window *w, Lisp_Object val)
{
w->scroll_bar_width = val;
if (WINDOW_RIGHT_MARGIN_COLS (w) > 0)
{
if (WINDOW_LEFT_MARGIN_COLS (w) > 0)
- {
- wset_left_margin_cols (w, make_number (margin_cols / 2));
- wset_right_margin_cols (w, make_number (margin_cols / 2));
- }
+ w->left_margin_cols = w->right_margin_cols = margin_cols / 2;
else
- wset_right_margin_cols (w, make_number (margin_cols));
+ w->right_margin_cols = margin_cols;
}
else
- wset_left_margin_cols (w, make_number (margin_cols));
+ w->left_margin_cols = margin_cols;
return 1;
}
\f
/* This may call adjust_window_margins three times, so
temporarily disable window margins. */
- Lisp_Object save_left = w->left_margin_cols;
- Lisp_Object save_right = w->right_margin_cols;
+ int save_left = w->left_margin_cols;
+ int save_right = w->right_margin_cols;
- wset_left_margin_cols (w, Qnil);
- wset_right_margin_cols (w, Qnil);
+ w->left_margin_cols = 0;
+ w->right_margin_cols = 0;
Fset_window_fringes (window,
BVAR (b, left_fringe_width), BVAR (b, right_fringe_width),
BVAR (b, scroll_bar_width),
BVAR (b, vertical_scroll_bar_type), Qnil);
- wset_left_margin_cols (w, save_left);
- wset_right_margin_cols (w, save_right);
+ w->left_margin_cols = save_left;
+ w->right_margin_cols = save_right;
Fset_window_margins (window,
BVAR (b, left_margin_cols), BVAR (b, right_margin_cols));
memset (&n->last_cursor, 0, sizeof n->last_cursor);
/* Get special geometry settings from reference window. */
- wset_left_margin_cols (n, r->left_margin_cols);
- wset_right_margin_cols (n, r->right_margin_cols);
+ n->left_margin_cols = r->left_margin_cols;
+ n->right_margin_cols = r->right_margin_cols;
n->left_fringe_width = r->left_fringe_width;
n->right_fringe_width = r->right_fringe_width;
n->fringes_outside_margins = r->fringes_outside_margins;
w->hscroll = XFASTINT (p->hscroll);
w->min_hscroll = XFASTINT (p->min_hscroll);
wset_display_table (w, p->display_table);
- wset_left_margin_cols (w, p->left_margin_cols);
- wset_right_margin_cols (w, p->right_margin_cols);
+ w->left_margin_cols = XINT (p->left_margin_cols);
+ w->right_margin_cols = XINT (p->right_margin_cols);
w->left_fringe_width = XINT (p->left_fringe_width);
w->right_fringe_width = XINT (p->right_fringe_width);
w->fringes_outside_margins = !NILP (p->fringes_outside_margins);
XSETFASTINT (p->hscroll, w->hscroll);
XSETFASTINT (p->min_hscroll, w->min_hscroll);
p->display_table = w->display_table;
- p->left_margin_cols = w->left_margin_cols;
- p->right_margin_cols = w->right_margin_cols;
+ p->left_margin_cols = make_number (w->left_margin_cols);
+ p->right_margin_cols = make_number (w->right_margin_cols);
p->left_fringe_width = make_number (w->left_fringe_width);
p->right_fringe_width = make_number (w->right_fringe_width);
p->fringes_outside_margins = w->fringes_outside_margins ? Qt : Qnil;
Second arg LEFT-WIDTH specifies the number of character cells to
reserve for the left marginal area. Optional third arg RIGHT-WIDTH
does the same for the right marginal area. A nil width parameter
-means no margin. */)
+means no margin.
+
+Return t if any margin was actually changed and nil otherwise. */)
(Lisp_Object window, Lisp_Object left_width, Lisp_Object right_width)
{
struct window *w = decode_live_window (window);
+ int left, right;
- /* Translate negative or zero widths to nil.
- Margins that are too wide have to be checked elsewhere. */
+ /* FIXME: what about margins that are too wide? */
- if (!NILP (left_width))
- {
- CHECK_NUMBER (left_width);
- if (XINT (left_width) <= 0)
- left_width = Qnil;
- }
-
- if (!NILP (right_width))
- {
- CHECK_NUMBER (right_width);
- if (XINT (right_width) <= 0)
- right_width = Qnil;
- }
+ left = (NILP (left_width) ? 0
+ : (CHECK_NATNUM (left_width), XINT (left_width)));
+ right = (NILP (right_width) ? 0
+ : (CHECK_NATNUM (right_width), XINT (right_width)));
- if (!EQ (w->left_margin_cols, left_width)
- || !EQ (w->right_margin_cols, right_width))
+ if (w->left_margin_cols != left || w->right_margin_cols != right)
{
- wset_left_margin_cols (w, left_width);
- wset_right_margin_cols (w, right_width);
+ w->left_margin_cols = left;
+ w->right_margin_cols = right;
adjust_window_margins (w);
++windows_or_buffers_changed;
adjust_glyphs (XFRAME (WINDOW_FRAME (w)));
+ return Qt;
}
return Qnil;
(Lisp_Object window)
{
struct window *w = decode_live_window (window);
- return Fcons (w->left_margin_cols, w->right_margin_cols);
+ return Fcons (make_number (w->left_margin_cols),
+ make_number (w->right_margin_cols));
}
it yet, or if the frame doesn't have any scroll bars, this is nil. */
Lisp_Object vertical_scroll_bar;
- /* Width of left and right marginal areas. A value of nil means
- no margin. */
- Lisp_Object left_margin_cols;
- Lisp_Object right_margin_cols;
-
/* Pixel width of scroll bars.
A value of nil or t means use frame values. */
Lisp_Object scroll_bar_width;
int left_fringe_width;
int right_fringe_width;
+ /* Width of left and right marginal areas in columns.
+ A value of 0 means no margin. */
+ int left_margin_cols;
+ int right_margin_cols;
+
/* Non-zero if this window is a minibuffer window. */
unsigned mini : 1;
/* Width of left margin area in columns. */
-#define WINDOW_LEFT_MARGIN_COLS(W) \
- (NILP (W->left_margin_cols) \
- ? 0 \
- : XINT (W->left_margin_cols))
+#define WINDOW_LEFT_MARGIN_COLS(W) (W->left_margin_cols)
/* Width of right marginal area in columns. */
-#define WINDOW_RIGHT_MARGIN_COLS(W) \
- (NILP (W->right_margin_cols) \
- ? 0 \
- : XINT (W->right_margin_cols))
+#define WINDOW_RIGHT_MARGIN_COLS(W) (W->right_margin_cols)
/* Width of left margin area in pixels. */
-#define WINDOW_LEFT_MARGIN_WIDTH(W) \
- (NILP (W->left_margin_cols) \
- ? 0 \
- : (XINT (W->left_margin_cols) \
- * WINDOW_FRAME_COLUMN_WIDTH (W)))
+#define WINDOW_LEFT_MARGIN_WIDTH(W) \
+ (W->left_margin_cols * WINDOW_FRAME_COLUMN_WIDTH (W))
/* Width of right marginal area in pixels. */
-#define WINDOW_RIGHT_MARGIN_WIDTH(W) \
- (NILP (W->right_margin_cols) \
- ? 0 \
- : (XINT (W->right_margin_cols) \
- * WINDOW_FRAME_COLUMN_WIDTH (W)))
+#define WINDOW_RIGHT_MARGIN_WIDTH(W) \
+ (W->right_margin_cols * WINDOW_FRAME_COLUMN_WIDTH (W))
/* Total width of fringes reserved for drawing truncation bitmaps,
continuation bitmaps and alike. The width is in canonical char
if (area == TEXT_AREA)
{
- if (INTEGERP (w->left_margin_cols))
- cols -= XFASTINT (w->left_margin_cols);
- if (INTEGERP (w->right_margin_cols))
- cols -= XFASTINT (w->right_margin_cols);
+ cols -= max (0, w->left_margin_cols);
+ cols -= max (0, w->right_margin_cols);
pixels = -WINDOW_TOTAL_FRINGE_WIDTH (w);
}
else if (area == LEFT_MARGIN_AREA)
{
- cols = (INTEGERP (w->left_margin_cols)
- ? XFASTINT (w->left_margin_cols) : 0);
+ cols = max (0, w->left_margin_cols);
pixels = 0;
}
else if (area == RIGHT_MARGIN_AREA)
{
- cols = (INTEGERP (w->right_margin_cols)
- ? XFASTINT (w->right_margin_cols) : 0);
+ cols = max (0, w->right_margin_cols);
pixels = 0;
}
}