Mercurial > hg > xemacs-beta
comparison src/window.c @ 5052:92dc90c0bb40
merge
author | Ben Wing <ben@xemacs.org> |
---|---|
date | Sat, 20 Feb 2010 23:56:01 -0600 |
parents | 6f2158fa75ed 07dcc7000bbf |
children | 0ca81354c4c7 2a462149bd6a 8b2f75cecb89 |
comparison
equal
deleted
inserted
replaced
5051:c3d372419e09 | 5052:92dc90c0bb40 |
---|---|
1173 | 1173 |
1174 window = wrap_window (w); | 1174 window = wrap_window (w); |
1175 margin_cwidth = (left_margin ? XINT (w->left_margin_width) : | 1175 margin_cwidth = (left_margin ? XINT (w->left_margin_width) : |
1176 XINT (w->right_margin_width)); | 1176 XINT (w->right_margin_width)); |
1177 | 1177 |
1178 default_face_height_and_width (window, 0, &font_width); | 1178 default_face_width_and_height (window, &font_width, 0); |
1179 | 1179 |
1180 /* The left margin takes precedence over the right margin so we | 1180 /* The left margin takes precedence over the right margin so we |
1181 subtract its width from the space available for the right | 1181 subtract its width from the space available for the right |
1182 margin. */ | 1182 margin. */ |
1183 if (!left_margin) | 1183 if (!left_margin) |
1656 | 1656 |
1657 start = marker_position (w->start[CURRENT_DISP]); | 1657 start = marker_position (w->start[CURRENT_DISP]); |
1658 hlimit = WINDOW_TEXT_HEIGHT (w); | 1658 hlimit = WINDOW_TEXT_HEIGHT (w); |
1659 eobuf = BUF_ZV (XBUFFER (w->buffer)); | 1659 eobuf = BUF_ZV (XBUFFER (w->buffer)); |
1660 | 1660 |
1661 default_face_height_and_width (window, &defheight, NULL); | 1661 default_face_width_and_height (window, NULL, &defheight); |
1662 | 1662 |
1663 /* guess lines needed in line start cache + a few extra */ | 1663 /* guess lines needed in line start cache + a few extra */ |
1664 needed = (hlimit + defheight-1) / defheight + 3; | 1664 needed = (hlimit + defheight-1) / defheight + 3; |
1665 | 1665 |
1666 while (1) { | 1666 while (1) { |
3475 : 2 * MIN_SAFE_WINDOW_HEIGHT - 1); | 3475 : 2 * MIN_SAFE_WINDOW_HEIGHT - 1); |
3476 } | 3476 } |
3477 | 3477 |
3478 /* Return non-zero if both frame sizes are less than or equal to | 3478 /* Return non-zero if both frame sizes are less than or equal to |
3479 minimal allowed values. ROWS and COLS are in characters */ | 3479 minimal allowed values. ROWS and COLS are in characters */ |
3480 int | 3480 static int |
3481 frame_size_valid_p (struct frame *frame, int rows, int cols) | 3481 frame_size_valid_p (struct frame *frame, int cols, int rows) |
3482 { | 3482 { |
3483 return (rows >= frame_min_height (frame) | 3483 return (rows >= frame_min_height (frame) |
3484 && cols >= MIN_SAFE_WINDOW_WIDTH); | 3484 && cols >= MIN_SAFE_WINDOW_WIDTH); |
3485 } | 3485 } |
3486 | 3486 |
3488 minimal allowed values. WIDTH and HEIGHT are in pixels */ | 3488 minimal allowed values. WIDTH and HEIGHT are in pixels */ |
3489 int | 3489 int |
3490 frame_pixsize_valid_p (struct frame *frame, int width, int height) | 3490 frame_pixsize_valid_p (struct frame *frame, int width, int height) |
3491 { | 3491 { |
3492 int rows, cols; | 3492 int rows, cols; |
3493 pixel_to_real_char_size (frame, width, height, &cols, &rows); | 3493 pixel_to_char_size (frame, width, height, &cols, &rows); |
3494 return frame_size_valid_p (frame, rows, cols); | 3494 return frame_size_valid_p (frame, cols, rows); |
3495 } | 3495 } |
3496 | 3496 |
3497 /* If *ROWS or *COLS are too small a size for FRAME, set them to the | 3497 /* If *ROWS or *COLS are too small a size for FRAME, set them to the |
3498 minimum allowable size. */ | 3498 minimum allowable size. */ |
3499 void | 3499 void |
3500 check_frame_size (struct frame *frame, int *rows, int *cols) | 3500 check_frame_size (struct frame *frame, int *cols, int *rows) |
3501 { | 3501 { |
3502 int min_height = frame_min_height (frame); | 3502 int min_height = frame_min_height (frame); |
3503 | 3503 int min_pixwidth, min_pixheight; |
3504 if (*rows < min_height) | 3504 int min_geomwidth, min_geomheight; |
3505 *rows = min_height; | 3505 |
3506 if (*cols < MIN_SAFE_WINDOW_WIDTH) | 3506 /* There is no char_to_frame_unit_size(). This can be done with |
3507 *cols = MIN_SAFE_WINDOW_WIDTH; | 3507 frame_conversion_internal(), but that's currently static, and we can |
3508 do it fine with two steps, as follows. */ | |
3509 char_to_pixel_size (frame, MIN_SAFE_WINDOW_WIDTH, min_height, | |
3510 &min_pixwidth, &min_pixheight); | |
3511 pixel_to_frame_unit_size (frame, min_pixwidth, min_pixheight, | |
3512 &min_geomwidth, &min_geomheight); | |
3513 if (*rows < min_geomheight) | |
3514 *rows = min_geomheight; | |
3515 if (*cols < min_geomwidth) | |
3516 *cols = min_geomwidth; | |
3508 } | 3517 } |
3509 | 3518 |
3510 /* Normally the window is deleted if it gets too small. | 3519 /* Normally the window is deleted if it gets too small. |
3511 nodelete nonzero means do not do this. | 3520 nodelete nonzero means do not do this. |
3512 (The caller should check later and do so if appropriate) */ | 3521 (The caller should check later and do so if appropriate) */ |
3521 Lisp_Object child, minor_kid, major_kid; | 3530 Lisp_Object child, minor_kid, major_kid; |
3522 int minsize; | 3531 int minsize; |
3523 int line_size; | 3532 int line_size; |
3524 int defheight, defwidth; | 3533 int defheight, defwidth; |
3525 | 3534 |
3526 default_face_height_and_width (window, &defheight, &defwidth); | 3535 default_face_width_and_height (window, &defwidth, &defheight); |
3527 line_size = (set_height ? defheight : defwidth); | 3536 line_size = (set_height ? defheight : defwidth); |
3528 | 3537 |
3529 check_min_window_sizes (); | 3538 check_min_window_sizes (); |
3530 | 3539 |
3531 minsize = (set_height ? window_min_height : window_min_width); | 3540 minsize = (set_height ? window_min_height : window_min_width); |
4125 avail_height = (pixel_height - | 4134 avail_height = (pixel_height - |
4126 (include_gutters_p ? 0 : | 4135 (include_gutters_p ? 0 : |
4127 window_top_window_gutter_height (w) + | 4136 window_top_window_gutter_height (w) + |
4128 window_bottom_window_gutter_height (w))); | 4137 window_bottom_window_gutter_height (w))); |
4129 | 4138 |
4130 default_face_height_and_width (window, &defheight, &defwidth); | 4139 default_face_width_and_height (window, &defwidth, &defheight); |
4131 | 4140 |
4132 if (defheight) | 4141 if (defheight) |
4133 char_height = avail_height / defheight; | 4142 char_height = avail_height / defheight; |
4134 | 4143 |
4135 /* It's the calling function's responsibility to check these values | 4144 /* It's the calling function's responsibility to check these values |
4149 int pixel_height; | 4158 int pixel_height; |
4150 | 4159 |
4151 Lisp_Object window = wrap_window (w); | 4160 Lisp_Object window = wrap_window (w); |
4152 | 4161 |
4153 | 4162 |
4154 default_face_height_and_width (window, &defheight, &defwidth); | 4163 default_face_width_and_height (window, &defwidth, &defheight); |
4155 | 4164 |
4156 avail_height = char_height * defheight; | 4165 avail_height = char_height * defheight; |
4157 pixel_height = (avail_height + | 4166 pixel_height = (avail_height + |
4158 (include_gutters_p ? 0 : | 4167 (include_gutters_p ? 0 : |
4159 window_top_window_gutter_height (w) + | 4168 window_top_window_gutter_height (w) + |
4229 return num_lines - 1; | 4238 return num_lines - 1; |
4230 ypos1 = dl->ypos + dl->descent - dl->clip; | 4239 ypos1 = dl->ypos + dl->descent - dl->clip; |
4231 } | 4240 } |
4232 } | 4241 } |
4233 | 4242 |
4234 default_face_height_and_width (window, &defheight, &defwidth); | 4243 default_face_width_and_height (window, &defwidth, &defheight); |
4235 /* #### This probably needs to know about the clipping area once a | 4244 /* #### This probably needs to know about the clipping area once a |
4236 final definition is decided on. */ | 4245 final definition is decided on. */ |
4237 if (defheight) | 4246 if (defheight) |
4238 num_lines += ((ypos2 - ypos1) / defheight); | 4247 num_lines += ((ypos2 - ypos1) / defheight); |
4239 } | 4248 } |
4272 window_left_gutter_width (w, 0) - | 4281 window_left_gutter_width (w, 0) - |
4273 window_right_gutter_width (w, 0) - | 4282 window_right_gutter_width (w, 0) - |
4274 (include_margins_p ? 0 : window_left_margin_width (w)) - | 4283 (include_margins_p ? 0 : window_left_margin_width (w)) - |
4275 (include_margins_p ? 0 : window_right_margin_width (w))); | 4284 (include_margins_p ? 0 : window_right_margin_width (w))); |
4276 | 4285 |
4277 default_face_height_and_width (window, &defheight, &defwidth); | 4286 default_face_width_and_height (window, &defwidth, &defheight); |
4278 | 4287 |
4279 if (defwidth) | 4288 if (defwidth) |
4280 char_width = (avail_width / defwidth); | 4289 char_width = (avail_width / defwidth); |
4281 | 4290 |
4282 /* It's the calling function's responsibility to check these values | 4291 /* It's the calling function's responsibility to check these values |
4295 int pixel_width; | 4304 int pixel_width; |
4296 int defheight, defwidth; | 4305 int defheight, defwidth; |
4297 Lisp_Object window = wrap_window (w); | 4306 Lisp_Object window = wrap_window (w); |
4298 | 4307 |
4299 | 4308 |
4300 default_face_height_and_width (window, &defheight, &defwidth); | 4309 default_face_width_and_height (window, &defwidth, &defheight); |
4301 | 4310 |
4302 avail_width = char_width * defwidth; | 4311 avail_width = char_width * defwidth; |
4303 pixel_width = (avail_width + | 4312 pixel_width = (avail_width + |
4304 window_left_window_gutter_width (w, 0) + | 4313 window_left_window_gutter_width (w, 0) + |
4305 window_right_window_gutter_width (w, 0) + | 4314 window_right_window_gutter_width (w, 0) + |
4378 window = wrap_window (win); | 4387 window = wrap_window (win); |
4379 f = XFRAME (win->frame); | 4388 f = XFRAME (win->frame); |
4380 if (EQ (window, FRAME_ROOT_WINDOW (f))) | 4389 if (EQ (window, FRAME_ROOT_WINDOW (f))) |
4381 invalid_operation ("Won't change only window", Qunbound); | 4390 invalid_operation ("Won't change only window", Qunbound); |
4382 | 4391 |
4383 default_face_height_and_width (window, &defheight, &defwidth); | 4392 default_face_width_and_height (window, &defwidth, &defheight); |
4384 | 4393 |
4385 while (1) | 4394 while (1) |
4386 { | 4395 { |
4387 w = XWINDOW (window); | 4396 w = XWINDOW (window); |
4388 parent = w->parent; | 4397 parent = w->parent; |
4607 dla = window_display_lines (w, CURRENT_DISP); | 4616 dla = window_display_lines (w, CURRENT_DISP); |
4608 | 4617 |
4609 if (INTP (Vwindow_pixel_scroll_increment)) | 4618 if (INTP (Vwindow_pixel_scroll_increment)) |
4610 fheight = XINT (Vwindow_pixel_scroll_increment); | 4619 fheight = XINT (Vwindow_pixel_scroll_increment); |
4611 else if (!NILP (Vwindow_pixel_scroll_increment)) | 4620 else if (!NILP (Vwindow_pixel_scroll_increment)) |
4612 default_face_height_and_width (window, &fheight, &fwidth); | 4621 default_face_width_and_height (window, &fwidth, &fheight); |
4613 | 4622 |
4614 if (Dynarr_length (dla) >= 1) | 4623 if (Dynarr_length (dla) >= 1) |
4615 modeline = Dynarr_begin (dla)->modeline; | 4624 modeline = Dynarr_begin (dla)->modeline; |
4616 | 4625 |
4617 dl = Dynarr_atp (dla, modeline); | 4626 dl = Dynarr_atp (dla, modeline); |