comparison src/window.c @ 263:727739f917cb r20-5b30

Import from CVS: tag r20-5b30
author cvs
date Mon, 13 Aug 2007 10:24:41 +0200
parents 11cf20601dec
children 8efd647ea9ca
comparison
equal deleted inserted replaced
262:9d8607af9e13 263:727739f917cb
64 int pixel_height, 64 int pixel_height,
65 int include_gutters_p); 65 int include_gutters_p);
66 static int window_char_height_to_pixel_height (struct window *w, 66 static int window_char_height_to_pixel_height (struct window *w,
67 int char_height, 67 int char_height,
68 int include_gutters_p); 68 int include_gutters_p);
69 static void change_window_height (struct window *w, int delta, int widthflag); 69 static void change_window_height (struct window *w, int delta, int widthflag,
70 int inpixels);
71 static int window_displayed_pixel_height (struct window *);
70 72
71 73
72 /* Thickness of shadow border around 3d modelines. */ 74 /* Thickness of shadow border around 3d modelines. */
73 Lisp_Object Vmodeline_shadow_thickness; 75 Lisp_Object Vmodeline_shadow_thickness;
74 76
1327 (window)) 1329 (window))
1328 { 1330 {
1329 return make_int (decode_window (window)->pixel_height); 1331 return make_int (decode_window (window)->pixel_height);
1330 } 1332 }
1331 1333
1334 DEFUN ("window-displayed-pixel-height", Fwindow_displayed_pixel_height, 0, 1, 0, /*
1335 Return the height in pixels of the buffer-displaying portion of WINDOW.
1336 Unlike `window-pixel-height', the space occupied by the gutters
1337 (modeline, horizontal scrollbar, ...) is not counted.
1338 */
1339 (window))
1340 {
1341 return make_int (window_displayed_pixel_height (decode_window (window)));
1342 }
1343
1332 DEFUN ("window-width", Fwindow_width, 0, 1, 0, /* 1344 DEFUN ("window-width", Fwindow_width, 0, 1, 0, /*
1333 Return the number of display columns in WINDOW. 1345 Return the number of display columns in WINDOW.
1334 This is the width that is usable columns available for text in WINDOW. 1346 This is the width that is usable columns available for text in WINDOW.
1335 */ 1347 */
1336 (window)) 1348 (window))
3398 */ 3410 */
3399 (n, side, window)) 3411 (n, side, window))
3400 { 3412 {
3401 struct window *w = decode_window (window); 3413 struct window *w = decode_window (window);
3402 CHECK_INT (n); 3414 CHECK_INT (n);
3403 change_window_height (w, XINT (n), !NILP (side)); 3415 change_window_height (w, XINT (n), !NILP (side), /* inpixels */ 0);
3416 return Qnil;
3417 }
3418
3419 DEFUN ("enlarge-window-pixels", Fenlarge_window_pixels, 1, 3, "_p", /*
3420 Make the selected window ARG pixels bigger.
3421 From program, optional second arg non-nil means grow sideways ARG pixels,
3422 and optional third ARG specifies the window to change instead of the
3423 selected window.
3424 */
3425 (n, side, window))
3426 {
3427 struct window *w = decode_window (window);
3428 CHECK_INT (n);
3429 change_window_height (w, XINT (n), !NILP (side), /* inpixels */ 1);
3404 return Qnil; 3430 return Qnil;
3405 } 3431 }
3406 3432
3407 DEFUN ("shrink-window", Fshrink_window, 1, 3, "_p", /* 3433 DEFUN ("shrink-window", Fshrink_window, 1, 3, "_p", /*
3408 Make the selected window ARG lines smaller. 3434 Make the selected window ARG lines smaller.
3411 selected window. 3437 selected window.
3412 */ 3438 */
3413 (n, side, window)) 3439 (n, side, window))
3414 { 3440 {
3415 CHECK_INT (n); 3441 CHECK_INT (n);
3416 change_window_height (decode_window (window), -XINT (n), !NILP (side)); 3442 change_window_height (decode_window (window), -XINT (n), !NILP (side),
3443 /* inpixels */ 0);
3444 return Qnil;
3445 }
3446
3447 DEFUN ("shrink-window-pixels", Fshrink_window_pixels, 1, 3, "_p", /*
3448 Make the selected window ARG pixels smaller.
3449 From program, optional second arg non-nil means shrink sideways ARG pixels,
3450 and optional third ARG specifies the window to change instead of the
3451 selected window.
3452 */
3453 (n, side, window))
3454 {
3455 CHECK_INT (n);
3456 change_window_height (decode_window (window), -XINT (n), !NILP (side),
3457 /* inpixels */ 1);
3417 return Qnil; 3458 return Qnil;
3418 } 3459 }
3419 3460
3420 static int 3461 static int
3421 window_pixel_height (Lisp_Object window) 3462 window_pixel_height (Lisp_Object window)
3564 } 3605 }
3565 3606
3566 return num_lines; 3607 return num_lines;
3567 } 3608 }
3568 3609
3610 /*
3611 * Return height in pixels of buffer-displaying portion of window w.
3612 * Does not include the gutters (modeline, scrollbars, ...)
3613 */
3614 int
3615 window_displayed_pixel_height (struct window *w)
3616 {
3617 return (WINDOW_HEIGHT (w)
3618 - window_top_gutter_height (w)
3619 - window_bottom_gutter_height (w));
3620 }
3621
3569 static int 3622 static int
3570 window_pixel_width (Lisp_Object window) 3623 window_pixel_width (Lisp_Object window)
3571 { 3624 {
3572 return WINDOW_WIDTH (XWINDOW (window)); 3625 return WINDOW_WIDTH (XWINDOW (window));
3573 } 3626 }
3665 /* Unlike set_window_pixheight, this function 3718 /* Unlike set_window_pixheight, this function
3666 also changes the heights of the siblings so as to 3719 also changes the heights of the siblings so as to
3667 keep everything consistent. */ 3720 keep everything consistent. */
3668 3721
3669 static void 3722 static void
3670 change_window_height (struct window *win, int delta, int widthflag) 3723 change_window_height (struct window *win, int delta, int widthflag,
3724 int inpixels)
3671 { 3725 {
3672 Lisp_Object parent; 3726 Lisp_Object parent;
3673 Lisp_Object window = Qnil; 3727 Lisp_Object window = Qnil;
3674 struct window *w; 3728 struct window *w;
3675 struct frame *f; 3729 struct frame *f;
3715 } 3769 }
3716 3770
3717 sizep = &CURSIZE (w); 3771 sizep = &CURSIZE (w);
3718 dim = CURCHARSIZE (w); 3772 dim = CURCHARSIZE (w);
3719 3773
3720 if ((dim + delta) < MINCHARSIZE (window)) 3774 if ((inpixels && (*sizep + delta) < MINSIZE (window)) ||
3775 (!inpixels && (dim + delta) < MINCHARSIZE (window)))
3721 { 3776 {
3722 if (MINI_WINDOW_P (XWINDOW (window))) 3777 if (MINI_WINDOW_P (XWINDOW (window)))
3723 return; 3778 return;
3724 else if (!NILP (parent)) 3779 else if (!NILP (parent))
3725 { 3780 {
3726 Fdelete_window (window, Qnil); 3781 Fdelete_window (window, Qnil);
3727 return; 3782 return;
3728 } 3783 }
3729 } 3784 }
3730 3785
3731 delta *= (widthflag ? defwidth : defheight); 3786 if (!inpixels)
3787 delta *= (widthflag ? defwidth : defheight);
3732 3788
3733 { 3789 {
3734 int maxdelta; 3790 int maxdelta;
3735 3791
3736 maxdelta = ((!NILP (parent)) 3792 maxdelta = ((!NILP (parent))
5001 } 5057 }
5002 } 5058 }
5003 w->toolbar_buttons_captioned_p = p->toolbar_buttons_captioned_p; 5059 w->toolbar_buttons_captioned_p = p->toolbar_buttons_captioned_p;
5004 w->default_toolbar = p->default_toolbar; 5060 w->default_toolbar = p->default_toolbar;
5005 w->default_toolbar_width = p->default_toolbar_width; 5061 w->default_toolbar_width = p->default_toolbar_width;
5062 w->default_toolbar_height = p->default_toolbar_height;
5006 w->default_toolbar_visible_p = p->default_toolbar_visible_p; 5063 w->default_toolbar_visible_p = p->default_toolbar_visible_p;
5007 w->default_toolbar_border_width = p->default_toolbar_border_width; 5064 w->default_toolbar_border_width = p->default_toolbar_border_width;
5008 #endif /* HAVE_TOOLBARS */ 5065 #endif /* HAVE_TOOLBARS */
5009 w->left_margin_width = p->left_margin_width; 5066 w->left_margin_width = p->left_margin_width;
5010 w->right_margin_width = p->right_margin_width; 5067 w->right_margin_width = p->right_margin_width;
5269 } 5326 }
5270 } 5327 }
5271 p->toolbar_buttons_captioned_p = w->toolbar_buttons_captioned_p; 5328 p->toolbar_buttons_captioned_p = w->toolbar_buttons_captioned_p;
5272 p->default_toolbar = w->default_toolbar; 5329 p->default_toolbar = w->default_toolbar;
5273 p->default_toolbar_width = w->default_toolbar_width; 5330 p->default_toolbar_width = w->default_toolbar_width;
5331 p->default_toolbar_height = w->default_toolbar_height;
5274 p->default_toolbar_visible_p = w->default_toolbar_visible_p; 5332 p->default_toolbar_visible_p = w->default_toolbar_visible_p;
5275 p->default_toolbar_border_width = w->default_toolbar_border_width; 5333 p->default_toolbar_border_width = w->default_toolbar_border_width;
5276 #endif /* HAVE_TOOLBARS */ 5334 #endif /* HAVE_TOOLBARS */
5277 p->left_margin_width = w->left_margin_width; 5335 p->left_margin_width = w->left_margin_width;
5278 p->right_margin_width = w->right_margin_width; 5336 p->right_margin_width = w->right_margin_width;
5501 DEFSUBR (Fpos_visible_in_window_p); 5559 DEFSUBR (Fpos_visible_in_window_p);
5502 DEFSUBR (Fwindow_buffer); 5560 DEFSUBR (Fwindow_buffer);
5503 DEFSUBR (Fwindow_frame); 5561 DEFSUBR (Fwindow_frame);
5504 DEFSUBR (Fwindow_height); 5562 DEFSUBR (Fwindow_height);
5505 DEFSUBR (Fwindow_displayed_height); 5563 DEFSUBR (Fwindow_displayed_height);
5564 DEFSUBR (Fwindow_displayed_pixel_height);
5506 DEFSUBR (Fwindow_width); 5565 DEFSUBR (Fwindow_width);
5507 DEFSUBR (Fwindow_pixel_height); 5566 DEFSUBR (Fwindow_pixel_height);
5508 DEFSUBR (Fwindow_pixel_width); 5567 DEFSUBR (Fwindow_pixel_width);
5509 DEFSUBR (Fwindow_hscroll); 5568 DEFSUBR (Fwindow_hscroll);
5510 DEFSUBR (Fmodeline_hscroll); 5569 DEFSUBR (Fmodeline_hscroll);
5537 DEFSUBR (Fdelete_window); 5596 DEFSUBR (Fdelete_window);
5538 DEFSUBR (Fset_window_buffer); 5597 DEFSUBR (Fset_window_buffer);
5539 DEFSUBR (Fselect_window); 5598 DEFSUBR (Fselect_window);
5540 DEFSUBR (Fsplit_window); 5599 DEFSUBR (Fsplit_window);
5541 DEFSUBR (Fenlarge_window); 5600 DEFSUBR (Fenlarge_window);
5601 DEFSUBR (Fenlarge_window_pixels);
5542 DEFSUBR (Fshrink_window); 5602 DEFSUBR (Fshrink_window);
5603 DEFSUBR (Fshrink_window_pixels);
5543 DEFSUBR (Fscroll_up); 5604 DEFSUBR (Fscroll_up);
5544 DEFSUBR (Fscroll_down); 5605 DEFSUBR (Fscroll_down);
5545 DEFSUBR (Fscroll_left); 5606 DEFSUBR (Fscroll_left);
5546 DEFSUBR (Fscroll_right); 5607 DEFSUBR (Fscroll_right);
5547 DEFSUBR (Fother_window_for_scrolling); 5608 DEFSUBR (Fother_window_for_scrolling);