Mercurial > hg > xemacs-beta
comparison src/window.c @ 5126:2a462149bd6a ben-lisp-object
merge
author | Ben Wing <ben@xemacs.org> |
---|---|
date | Wed, 24 Feb 2010 19:04:27 -0600 |
parents | b5df3737028a 92dc90c0bb40 |
children | a9c41067dd88 |
comparison
equal
deleted
inserted
replaced
5125:b5df3737028a | 5126:2a462149bd6a |
---|---|
1 /* Window creation, deletion and examination for XEmacs. | 1 /* Window creation, deletion and examination for XEmacs. |
2 Copyright (C) 1985-1987, 1992-1995 Free Software Foundation, Inc. | 2 Copyright (C) 1985-1987, 1992-1995 Free Software Foundation, Inc. |
3 Copyright (C) 1994, 1995 Board of Trustees, University of Illinois. | 3 Copyright (C) 1994, 1995 Board of Trustees, University of Illinois. |
4 Copyright (C) 1995, 1996, 2002 Ben Wing. | 4 Copyright (C) 1995, 1996, 2002, 2010 Ben Wing. |
5 Copyright (C) 1996 Chuck Thompson. | 5 Copyright (C) 1996 Chuck Thompson. |
6 | 6 |
7 This file is part of XEmacs. | 7 This file is part of XEmacs. |
8 | 8 |
9 XEmacs is free software; you can redistribute it and/or modify it | 9 XEmacs is free software; you can redistribute it and/or modify it |
691 real_window (struct window_mirror *mir, int no_abort) | 691 real_window (struct window_mirror *mir, int no_abort) |
692 { | 692 { |
693 Lisp_Object retval = | 693 Lisp_Object retval = |
694 real_window_internal (mir->frame->root_window, | 694 real_window_internal (mir->frame->root_window, |
695 XWINDOW_MIRROR (mir->frame->root_mirror), mir); | 695 XWINDOW_MIRROR (mir->frame->root_mirror), mir); |
696 if (NILP (retval) && !no_abort) | 696 assert (!NILP (retval) || no_abort); |
697 ABORT (); | |
698 | 697 |
699 return retval; | 698 return retval; |
700 } | 699 } |
701 | 700 |
702 /* Given a real window, return its mirror structure. Calls | 701 /* Given a real window, return its mirror structure. Calls |
754 struct window_mirror *t; | 753 struct window_mirror *t; |
755 | 754 |
756 if (XFRAME (w->frame)->mirror_dirty) | 755 if (XFRAME (w->frame)->mirror_dirty) |
757 update_frame_window_mirror (XFRAME (w->frame)); | 756 update_frame_window_mirror (XFRAME (w->frame)); |
758 t = find_window_mirror (w); | 757 t = find_window_mirror (w); |
759 if (!t) | 758 assert (t); |
760 ABORT (); | |
761 | 759 |
762 if (which == CURRENT_DISP) | 760 if (which == CURRENT_DISP) |
763 return t->current_display_lines; | 761 return t->current_display_lines; |
764 else if (which == DESIRED_DISP) | 762 else if (which == DESIRED_DISP) |
765 return t->desired_display_lines; | 763 return t->desired_display_lines; |
778 struct window_mirror *t; | 776 struct window_mirror *t; |
779 | 777 |
780 if (XFRAME (w->frame)->mirror_dirty) | 778 if (XFRAME (w->frame)->mirror_dirty) |
781 update_frame_window_mirror (XFRAME (w->frame)); | 779 update_frame_window_mirror (XFRAME (w->frame)); |
782 t = find_window_mirror (w); | 780 t = find_window_mirror (w); |
783 if (!t) | 781 assert (t); |
784 ABORT (); | |
785 | 782 |
786 return t->buffer; | 783 return t->buffer; |
787 } | 784 } |
788 | 785 |
789 void | 786 void |
792 struct window_mirror *t; | 789 struct window_mirror *t; |
793 | 790 |
794 if (XFRAME (w->frame)->mirror_dirty) | 791 if (XFRAME (w->frame)->mirror_dirty) |
795 update_frame_window_mirror (XFRAME (w->frame)); | 792 update_frame_window_mirror (XFRAME (w->frame)); |
796 t = find_window_mirror (w); | 793 t = find_window_mirror (w); |
797 if (!t) | 794 assert (t); |
798 ABORT (); | |
799 | 795 |
800 t->buffer = b; | 796 t->buffer = b; |
801 } | 797 } |
802 | 798 |
803 | 799 |
1168 | 1164 |
1169 window = wrap_window (w); | 1165 window = wrap_window (w); |
1170 margin_cwidth = (left_margin ? XINT (w->left_margin_width) : | 1166 margin_cwidth = (left_margin ? XINT (w->left_margin_width) : |
1171 XINT (w->right_margin_width)); | 1167 XINT (w->right_margin_width)); |
1172 | 1168 |
1173 default_face_height_and_width (window, 0, &font_width); | 1169 default_face_width_and_height (window, &font_width, 0); |
1174 | 1170 |
1175 /* The left margin takes precedence over the right margin so we | 1171 /* The left margin takes precedence over the right margin so we |
1176 subtract its width from the space available for the right | 1172 subtract its width from the space available for the right |
1177 margin. */ | 1173 margin. */ |
1178 if (!left_margin) | 1174 if (!left_margin) |
1651 | 1647 |
1652 start = marker_position (w->start[CURRENT_DISP]); | 1648 start = marker_position (w->start[CURRENT_DISP]); |
1653 hlimit = WINDOW_TEXT_HEIGHT (w); | 1649 hlimit = WINDOW_TEXT_HEIGHT (w); |
1654 eobuf = BUF_ZV (XBUFFER (w->buffer)); | 1650 eobuf = BUF_ZV (XBUFFER (w->buffer)); |
1655 | 1651 |
1656 default_face_height_and_width (window, &defheight, NULL); | 1652 default_face_width_and_height (window, NULL, &defheight); |
1657 | 1653 |
1658 /* guess lines needed in line start cache + a few extra */ | 1654 /* guess lines needed in line start cache + a few extra */ |
1659 needed = (hlimit + defheight-1) / defheight + 3; | 1655 needed = (hlimit + defheight-1) / defheight + 3; |
1660 | 1656 |
1661 while (1) { | 1657 while (1) { |
2013 unshow_buffer (struct window *w) | 2009 unshow_buffer (struct window *w) |
2014 { | 2010 { |
2015 Lisp_Object buf = w->buffer; | 2011 Lisp_Object buf = w->buffer; |
2016 struct buffer *b = XBUFFER (buf); | 2012 struct buffer *b = XBUFFER (buf); |
2017 | 2013 |
2018 if (b != XMARKER (w->pointm[CURRENT_DISP])->buffer) | 2014 assert (b == XMARKER (w->pointm[CURRENT_DISP])->buffer); |
2019 ABORT (); | |
2020 | 2015 |
2021 /* FSF disables this check, so I'll do it too. I hope it won't | 2016 /* FSF disables this check, so I'll do it too. I hope it won't |
2022 break things. --ben */ | 2017 break things. --ben */ |
2023 #if 0 | 2018 #if 0 |
2024 if (w == XWINDOW (Fselected_window (Qnil)) | 2019 if (w == XWINDOW (Fselected_window (Qnil)) |
3127 | 3122 |
3128 /* If none of them, then all windows, dedicated or not. */ | 3123 /* If none of them, then all windows, dedicated or not. */ |
3129 w = window_loop (GET_LRU_WINDOW, Qnil, 0, which_frames, 1, which_devices); | 3124 w = window_loop (GET_LRU_WINDOW, Qnil, 0, which_frames, 1, which_devices); |
3130 | 3125 |
3131 /* At this point we damn well better have found something. */ | 3126 /* At this point we damn well better have found something. */ |
3132 if (NILP (w)) ABORT (); | 3127 assert (!NILP (w)); |
3133 #endif | 3128 #endif |
3134 | 3129 |
3135 return w; | 3130 return w; |
3136 } | 3131 } |
3137 | 3132 |
3471 : 2 * MIN_SAFE_WINDOW_HEIGHT - 1); | 3466 : 2 * MIN_SAFE_WINDOW_HEIGHT - 1); |
3472 } | 3467 } |
3473 | 3468 |
3474 /* Return non-zero if both frame sizes are less than or equal to | 3469 /* Return non-zero if both frame sizes are less than or equal to |
3475 minimal allowed values. ROWS and COLS are in characters */ | 3470 minimal allowed values. ROWS and COLS are in characters */ |
3476 int | 3471 static int |
3477 frame_size_valid_p (struct frame *frame, int rows, int cols) | 3472 frame_size_valid_p (struct frame *frame, int cols, int rows) |
3478 { | 3473 { |
3479 return (rows >= frame_min_height (frame) | 3474 return (rows >= frame_min_height (frame) |
3480 && cols >= MIN_SAFE_WINDOW_WIDTH); | 3475 && cols >= MIN_SAFE_WINDOW_WIDTH); |
3481 } | 3476 } |
3482 | 3477 |
3484 minimal allowed values. WIDTH and HEIGHT are in pixels */ | 3479 minimal allowed values. WIDTH and HEIGHT are in pixels */ |
3485 int | 3480 int |
3486 frame_pixsize_valid_p (struct frame *frame, int width, int height) | 3481 frame_pixsize_valid_p (struct frame *frame, int width, int height) |
3487 { | 3482 { |
3488 int rows, cols; | 3483 int rows, cols; |
3489 pixel_to_real_char_size (frame, width, height, &cols, &rows); | 3484 pixel_to_char_size (frame, width, height, &cols, &rows); |
3490 return frame_size_valid_p (frame, rows, cols); | 3485 return frame_size_valid_p (frame, cols, rows); |
3491 } | 3486 } |
3492 | 3487 |
3493 /* If *ROWS or *COLS are too small a size for FRAME, set them to the | 3488 /* If *ROWS or *COLS are too small a size for FRAME, set them to the |
3494 minimum allowable size. */ | 3489 minimum allowable size. */ |
3495 void | 3490 void |
3496 check_frame_size (struct frame *frame, int *rows, int *cols) | 3491 check_frame_size (struct frame *frame, int *cols, int *rows) |
3497 { | 3492 { |
3498 int min_height = frame_min_height (frame); | 3493 int min_height = frame_min_height (frame); |
3499 | 3494 int min_pixwidth, min_pixheight; |
3500 if (*rows < min_height) | 3495 int min_geomwidth, min_geomheight; |
3501 *rows = min_height; | 3496 |
3502 if (*cols < MIN_SAFE_WINDOW_WIDTH) | 3497 /* There is no char_to_frame_unit_size(). This can be done with |
3503 *cols = MIN_SAFE_WINDOW_WIDTH; | 3498 frame_conversion_internal(), but that's currently static, and we can |
3499 do it fine with two steps, as follows. */ | |
3500 char_to_pixel_size (frame, MIN_SAFE_WINDOW_WIDTH, min_height, | |
3501 &min_pixwidth, &min_pixheight); | |
3502 pixel_to_frame_unit_size (frame, min_pixwidth, min_pixheight, | |
3503 &min_geomwidth, &min_geomheight); | |
3504 if (*rows < min_geomheight) | |
3505 *rows = min_geomheight; | |
3506 if (*cols < min_geomwidth) | |
3507 *cols = min_geomwidth; | |
3504 } | 3508 } |
3505 | 3509 |
3506 /* Normally the window is deleted if it gets too small. | 3510 /* Normally the window is deleted if it gets too small. |
3507 nodelete nonzero means do not do this. | 3511 nodelete nonzero means do not do this. |
3508 (The caller should check later and do so if appropriate) */ | 3512 (The caller should check later and do so if appropriate) */ |
3517 Lisp_Object child, minor_kid, major_kid; | 3521 Lisp_Object child, minor_kid, major_kid; |
3518 int minsize; | 3522 int minsize; |
3519 int line_size; | 3523 int line_size; |
3520 int defheight, defwidth; | 3524 int defheight, defwidth; |
3521 | 3525 |
3522 default_face_height_and_width (window, &defheight, &defwidth); | 3526 default_face_width_and_height (window, &defwidth, &defheight); |
3523 line_size = (set_height ? defheight : defwidth); | 3527 line_size = (set_height ? defheight : defwidth); |
3524 | 3528 |
3525 check_min_window_sizes (); | 3529 check_min_window_sizes (); |
3526 | 3530 |
3527 minsize = (set_height ? window_min_height : window_min_width); | 3531 minsize = (set_height ? window_min_height : window_min_width); |
4120 avail_height = (pixel_height - | 4124 avail_height = (pixel_height - |
4121 (include_gutters_p ? 0 : | 4125 (include_gutters_p ? 0 : |
4122 window_top_window_gutter_height (w) + | 4126 window_top_window_gutter_height (w) + |
4123 window_bottom_window_gutter_height (w))); | 4127 window_bottom_window_gutter_height (w))); |
4124 | 4128 |
4125 default_face_height_and_width (window, &defheight, &defwidth); | 4129 default_face_width_and_height (window, &defwidth, &defheight); |
4126 | 4130 |
4127 if (defheight) | 4131 if (defheight) |
4128 char_height = avail_height / defheight; | 4132 char_height = avail_height / defheight; |
4129 | 4133 |
4130 /* It's the calling function's responsibility to check these values | 4134 /* It's the calling function's responsibility to check these values |
4144 int pixel_height; | 4148 int pixel_height; |
4145 | 4149 |
4146 Lisp_Object window = wrap_window (w); | 4150 Lisp_Object window = wrap_window (w); |
4147 | 4151 |
4148 | 4152 |
4149 default_face_height_and_width (window, &defheight, &defwidth); | 4153 default_face_width_and_height (window, &defwidth, &defheight); |
4150 | 4154 |
4151 avail_height = char_height * defheight; | 4155 avail_height = char_height * defheight; |
4152 pixel_height = (avail_height + | 4156 pixel_height = (avail_height + |
4153 (include_gutters_p ? 0 : | 4157 (include_gutters_p ? 0 : |
4154 window_top_window_gutter_height (w) + | 4158 window_top_window_gutter_height (w) + |
4224 return num_lines - 1; | 4228 return num_lines - 1; |
4225 ypos1 = dl->ypos + dl->descent - dl->clip; | 4229 ypos1 = dl->ypos + dl->descent - dl->clip; |
4226 } | 4230 } |
4227 } | 4231 } |
4228 | 4232 |
4229 default_face_height_and_width (window, &defheight, &defwidth); | 4233 default_face_width_and_height (window, &defwidth, &defheight); |
4230 /* #### This probably needs to know about the clipping area once a | 4234 /* #### This probably needs to know about the clipping area once a |
4231 final definition is decided on. */ | 4235 final definition is decided on. */ |
4232 if (defheight) | 4236 if (defheight) |
4233 num_lines += ((ypos2 - ypos1) / defheight); | 4237 num_lines += ((ypos2 - ypos1) / defheight); |
4234 } | 4238 } |
4267 window_left_gutter_width (w, 0) - | 4271 window_left_gutter_width (w, 0) - |
4268 window_right_gutter_width (w, 0) - | 4272 window_right_gutter_width (w, 0) - |
4269 (include_margins_p ? 0 : window_left_margin_width (w)) - | 4273 (include_margins_p ? 0 : window_left_margin_width (w)) - |
4270 (include_margins_p ? 0 : window_right_margin_width (w))); | 4274 (include_margins_p ? 0 : window_right_margin_width (w))); |
4271 | 4275 |
4272 default_face_height_and_width (window, &defheight, &defwidth); | 4276 default_face_width_and_height (window, &defwidth, &defheight); |
4273 | 4277 |
4274 if (defwidth) | 4278 if (defwidth) |
4275 char_width = (avail_width / defwidth); | 4279 char_width = (avail_width / defwidth); |
4276 | 4280 |
4277 /* It's the calling function's responsibility to check these values | 4281 /* It's the calling function's responsibility to check these values |
4290 int pixel_width; | 4294 int pixel_width; |
4291 int defheight, defwidth; | 4295 int defheight, defwidth; |
4292 Lisp_Object window = wrap_window (w); | 4296 Lisp_Object window = wrap_window (w); |
4293 | 4297 |
4294 | 4298 |
4295 default_face_height_and_width (window, &defheight, &defwidth); | 4299 default_face_width_and_height (window, &defwidth, &defheight); |
4296 | 4300 |
4297 avail_width = char_width * defwidth; | 4301 avail_width = char_width * defwidth; |
4298 pixel_width = (avail_width + | 4302 pixel_width = (avail_width + |
4299 window_left_window_gutter_width (w, 0) + | 4303 window_left_window_gutter_width (w, 0) + |
4300 window_right_window_gutter_width (w, 0) + | 4304 window_right_window_gutter_width (w, 0) + |
4373 window = wrap_window (win); | 4377 window = wrap_window (win); |
4374 f = XFRAME (win->frame); | 4378 f = XFRAME (win->frame); |
4375 if (EQ (window, FRAME_ROOT_WINDOW (f))) | 4379 if (EQ (window, FRAME_ROOT_WINDOW (f))) |
4376 invalid_operation ("Won't change only window", Qunbound); | 4380 invalid_operation ("Won't change only window", Qunbound); |
4377 | 4381 |
4378 default_face_height_and_width (window, &defheight, &defwidth); | 4382 default_face_width_and_height (window, &defwidth, &defheight); |
4379 | 4383 |
4380 while (1) | 4384 while (1) |
4381 { | 4385 { |
4382 w = XWINDOW (window); | 4386 w = XWINDOW (window); |
4383 parent = w->parent; | 4387 parent = w->parent; |
4602 dla = window_display_lines (w, CURRENT_DISP); | 4606 dla = window_display_lines (w, CURRENT_DISP); |
4603 | 4607 |
4604 if (INTP (Vwindow_pixel_scroll_increment)) | 4608 if (INTP (Vwindow_pixel_scroll_increment)) |
4605 fheight = XINT (Vwindow_pixel_scroll_increment); | 4609 fheight = XINT (Vwindow_pixel_scroll_increment); |
4606 else if (!NILP (Vwindow_pixel_scroll_increment)) | 4610 else if (!NILP (Vwindow_pixel_scroll_increment)) |
4607 default_face_height_and_width (window, &fheight, &fwidth); | 4611 default_face_width_and_height (window, &fwidth, &fheight); |
4608 | 4612 |
4609 if (Dynarr_length (dla) >= 1) | 4613 if (Dynarr_length (dla) >= 1) |
4610 modeline = Dynarr_begin (dla)->modeline; | 4614 modeline = Dynarr_begin (dla)->modeline; |
4611 | 4615 |
4612 dl = Dynarr_atp (dla, modeline); | 4616 dl = Dynarr_atp (dla, modeline); |