aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKim F. Storm2003-03-12 12:11:00 +0000
committerKim F. Storm2003-03-12 12:11:00 +0000
commitffbbc941e006dabe65cef31f120768677d285dbd (patch)
tree64eef22be08bf4350a85d3d8687639218fad89c4 /src
parent5958f265902d913b2aec3ee51a26227ebe5e4ab4 (diff)
downloademacs-ffbbc941e006dabe65cef31f120768677d285dbd.tar.gz
emacs-ffbbc941e006dabe65cef31f120768677d285dbd.zip
The following changes consolidates the fringe handling from
xterm.c, w32term.c, and macterm.c into xdisp.c. * xdisp.c: Consolidate fringe handling code here. (left_bits, right_bits, continued_bits, continuation_bits) (ov_bits, zv_bits): Define fringe bitmaps. (fringe_bitmaps): New array holding fringe bitmaps. (draw_fringe_bitmap): Draw a specific bitmap; call display specific drawing routine via rif->draw_fringe_bitmap. (draw_row_fringe_bitmaps): Generic replacement for x_draw_row_fringe_bitmaps; all callers changed. (compute_fringe_widths): Generic replacement for x_compute_fringe_widths; all callers changed.
Diffstat (limited to 'src')
-rw-r--r--src/xdisp.c275
1 files changed, 275 insertions, 0 deletions
diff --git a/src/xdisp.c b/src/xdisp.c
index 457b3dd0ac9..84bc12ca1ad 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -8136,6 +8136,281 @@ tool_bar_item_info (f, glyph, prop_idx)
8136 8136
8137 8137
8138 8138
8139/***********************************************************************
8140 Fringes
8141 ***********************************************************************/
8142
8143#ifdef HAVE_WINDOW_SYSTEM
8144
8145/* An arrow like this: `<-'. */
8146static unsigned char left_bits[] = {
8147 0x18, 0x0c, 0x06, 0x3f, 0x3f, 0x06, 0x0c, 0x18};
8148
8149/* Right truncation arrow bitmap `->'. */
8150static unsigned char right_bits[] = {
8151 0x18, 0x30, 0x60, 0xfc, 0xfc, 0x60, 0x30, 0x18};
8152
8153/* Marker for continued lines. */
8154static unsigned char continued_bits[] = {
8155 0x3c, 0x7c, 0xc0, 0xe4, 0xfc, 0x7c, 0x3c, 0x7c};
8156
8157/* Marker for continuation lines. */
8158static unsigned char continuation_bits[] = {
8159 0x3c, 0x3e, 0x03, 0x27, 0x3f, 0x3e, 0x3c, 0x3e};
8160
8161/* Overlay arrow bitmap. A triangular arrow. */
8162static unsigned char ov_bits[] = {
8163 0x03, 0x0f, 0x1f, 0x3f, 0x3f, 0x1f, 0x0f, 0x03};
8164
8165/* Bitmap drawn to indicate lines not displaying text if
8166 `indicate-empty-lines' is non-nil. */
8167static unsigned char zv_bits[] = {
8168 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00,
8169 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00,
8170 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00,
8171 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00,
8172 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00,
8173 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00,
8174 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00,
8175 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x3c, 0x00};
8176
8177struct fringe_bitmap fringe_bitmaps[MAX_FRINGE_BITMAPS] =
8178{
8179 { 0, 0, 0, NULL /* NO_FRINGE_BITMAP */ },
8180 { 8, sizeof (left_bits), 0, left_bits },
8181 { 8, sizeof (right_bits), 0, right_bits },
8182 { 8, sizeof (continued_bits), 0, continued_bits },
8183 { 8, sizeof (continuation_bits), 0, continuation_bits },
8184 { 8, sizeof (ov_bits), 0, ov_bits },
8185 { 8, sizeof (zv_bits), 3, zv_bits }
8186};
8187
8188
8189/* Draw the bitmap WHICH in one of the left or right fringes of
8190 window W. ROW is the glyph row for which to display the bitmap; it
8191 determines the vertical position at which the bitmap has to be
8192 drawn. */
8193
8194static void
8195draw_fringe_bitmap (w, row, which, left_p)
8196 struct window *w;
8197 struct glyph_row *row;
8198 enum fringe_bitmap_type which;
8199 int left_p;
8200{
8201 struct frame *f = XFRAME (WINDOW_FRAME (w));
8202 struct draw_fringe_bitmap_params p;
8203
8204 /* Convert row to frame coordinates. */
8205 p.y = WINDOW_TO_FRAME_PIXEL_Y (w, row->y);
8206
8207 p.which = which;
8208 p.wd = fringe_bitmaps[which].width;
8209
8210 p.h = fringe_bitmaps[which].height;
8211 p.dh = (fringe_bitmaps[which].period
8212 ? (p.y % fringe_bitmaps[which].period)
8213 : 0);
8214 p.h -= p.dh;
8215 /* Clip bitmap if too high. */
8216 if (p.h > row->height)
8217 p.h = row->height;
8218
8219 p.face = FACE_FROM_ID (f, FRINGE_FACE_ID);
8220 PREPARE_FACE_FOR_DISPLAY (f, p.face);
8221
8222 /* Clear left fringe if no bitmap to draw or if bitmap doesn't fill
8223 the fringe. */
8224 p.bx = -1;
8225 if (left_p)
8226 {
8227 if (p.wd > FRAME_X_LEFT_FRINGE_WIDTH (f))
8228 p.wd = FRAME_X_LEFT_FRINGE_WIDTH (f);
8229 p.x = (WINDOW_TO_FRAME_PIXEL_X (w, 0)
8230 - p.wd
8231 - (FRAME_X_LEFT_FRINGE_WIDTH (f) - p.wd) / 2);
8232 if (p.wd < FRAME_X_LEFT_FRINGE_WIDTH (f) || row->height > p.h)
8233 {
8234 /* If W has a vertical border to its left, don't draw over it. */
8235 int border = ((XFASTINT (w->left) > 0
8236 && !FRAME_HAS_VERTICAL_SCROLL_BARS (f))
8237 ? 1 : 0);
8238 p.bx = (window_box_left (w, -1)
8239 - FRAME_X_LEFT_FRINGE_WIDTH (f)
8240 + border);
8241 p.nx = (FRAME_X_LEFT_FRINGE_WIDTH (f) - border);
8242 }
8243 }
8244 else
8245 {
8246 if (p.wd > FRAME_X_RIGHT_FRINGE_WIDTH (f))
8247 p.wd = FRAME_X_RIGHT_FRINGE_WIDTH (f);
8248 p.x = (window_box_right (w, -1)
8249 + (FRAME_X_RIGHT_FRINGE_WIDTH (f) - p.wd) / 2);
8250 /* Clear right fringe if no bitmap to draw of if bitmap doesn't fill
8251 the fringe. */
8252 if (p.wd < FRAME_X_RIGHT_FRINGE_WIDTH (f) || row->height > p.h)
8253 {
8254 p.bx = window_box_right (w, -1);
8255 p.nx = FRAME_X_RIGHT_FRINGE_WIDTH (f);
8256 }
8257 }
8258
8259 if (p.bx >= 0)
8260 {
8261 int header_line_height = WINDOW_DISPLAY_HEADER_LINE_HEIGHT (w);
8262
8263 p.by = WINDOW_TO_FRAME_PIXEL_Y (w, max (header_line_height, row->y));
8264 p.ny = row->visible_height;
8265 }
8266
8267 /* Adjust y to the offset in the row to start drawing the bitmap. */
8268 p.y += (row->height - p.h) / 2;
8269
8270 rif->draw_fringe_bitmap (w, row, &p);
8271}
8272
8273/* Draw fringe bitmaps for glyph row ROW on window W. Call this
8274 function with input blocked. */
8275
8276void
8277draw_row_fringe_bitmaps (w, row)
8278 struct window *w;
8279 struct glyph_row *row;
8280{
8281 struct frame *f = XFRAME (w->frame);
8282 enum fringe_bitmap_type bitmap;
8283
8284 xassert (interrupt_input_blocked);
8285
8286 /* If row is completely invisible, because of vscrolling, we
8287 don't have to draw anything. */
8288 if (row->visible_height <= 0)
8289 return;
8290
8291 if (FRAME_X_LEFT_FRINGE_WIDTH (f) != 0)
8292 {
8293 /* Decide which bitmap to draw in the left fringe. */
8294 if (row->overlay_arrow_p)
8295 bitmap = OVERLAY_ARROW_BITMAP;
8296 else if (row->truncated_on_left_p)
8297 bitmap = LEFT_TRUNCATION_BITMAP;
8298 else if (MATRIX_ROW_CONTINUATION_LINE_P (row))
8299 bitmap = CONTINUATION_LINE_BITMAP;
8300 else if (row->indicate_empty_line_p)
8301 bitmap = ZV_LINE_BITMAP;
8302 else
8303 bitmap = NO_FRINGE_BITMAP;
8304
8305 draw_fringe_bitmap (w, row, bitmap, 1);
8306 }
8307
8308 if (FRAME_X_RIGHT_FRINGE_WIDTH (f) != 0)
8309 {
8310 /* Decide which bitmap to draw in the right fringe. */
8311 if (row->truncated_on_right_p)
8312 bitmap = RIGHT_TRUNCATION_BITMAP;
8313 else if (row->continued_p)
8314 bitmap = CONTINUED_LINE_BITMAP;
8315 else if (row->indicate_empty_line_p && FRAME_X_LEFT_FRINGE_WIDTH (f) == 0)
8316 bitmap = ZV_LINE_BITMAP;
8317 else
8318 bitmap = NO_FRINGE_BITMAP;
8319
8320 draw_fringe_bitmap (w, row, bitmap, 0);
8321 }
8322}
8323
8324
8325/* Compute actual fringe widths */
8326
8327void
8328compute_fringe_widths (f, redraw)
8329 struct frame *f;
8330 int redraw;
8331{
8332 int o_left = FRAME_X_LEFT_FRINGE_WIDTH (f);
8333 int o_right = FRAME_X_RIGHT_FRINGE_WIDTH (f);
8334 int o_cols = FRAME_X_FRINGE_COLS (f);
8335
8336 Lisp_Object left_fringe = Fassq (Qleft_fringe, f->param_alist);
8337 Lisp_Object right_fringe = Fassq (Qright_fringe, f->param_alist);
8338 int left_fringe_width, right_fringe_width;
8339
8340 if (!NILP (left_fringe))
8341 left_fringe = Fcdr (left_fringe);
8342 if (!NILP (right_fringe))
8343 right_fringe = Fcdr (right_fringe);
8344
8345 left_fringe_width = ((NILP (left_fringe) || !INTEGERP (left_fringe)) ? 8 :
8346 XINT (left_fringe));
8347 right_fringe_width = ((NILP (right_fringe) || !INTEGERP (right_fringe)) ? 8 :
8348 XINT (right_fringe));
8349
8350 if (left_fringe_width || right_fringe_width)
8351 {
8352 int left_wid = left_fringe_width >= 0 ? left_fringe_width : -left_fringe_width;
8353 int right_wid = right_fringe_width >= 0 ? right_fringe_width : -right_fringe_width;
8354 int conf_wid = left_wid + right_wid;
8355 int font_wid = FONT_WIDTH (f->output_data.x->font);
8356 int cols = (left_wid + right_wid + font_wid-1) / font_wid;
8357 int real_wid = cols * font_wid;
8358 if (left_wid && right_wid)
8359 {
8360 if (left_fringe_width < 0)
8361 {
8362 /* Left fringe width is fixed, adjust right fringe if necessary */
8363 FRAME_X_LEFT_FRINGE_WIDTH (f) = left_wid;
8364 FRAME_X_RIGHT_FRINGE_WIDTH (f) = real_wid - left_wid;
8365 }
8366 else if (right_fringe_width < 0)
8367 {
8368 /* Right fringe width is fixed, adjust left fringe if necessary */
8369 FRAME_X_LEFT_FRINGE_WIDTH (f) = real_wid - right_wid;
8370 FRAME_X_RIGHT_FRINGE_WIDTH (f) = right_wid;
8371 }
8372 else
8373 {
8374 /* Adjust both fringes with an equal amount.
8375 Note that we are doing integer arithmetic here, so don't
8376 lose a pixel if the total width is an odd number. */
8377 int fill = real_wid - conf_wid;
8378 FRAME_X_LEFT_FRINGE_WIDTH (f) = left_wid + fill/2;
8379 FRAME_X_RIGHT_FRINGE_WIDTH (f) = right_wid + fill - fill/2;
8380 }
8381 }
8382 else if (left_fringe_width)
8383 {
8384 FRAME_X_LEFT_FRINGE_WIDTH (f) = real_wid;
8385 FRAME_X_RIGHT_FRINGE_WIDTH (f) = 0;
8386 }
8387 else
8388 {
8389 FRAME_X_LEFT_FRINGE_WIDTH (f) = 0;
8390 FRAME_X_RIGHT_FRINGE_WIDTH (f) = real_wid;
8391 }
8392 FRAME_X_FRINGE_COLS (f) = cols;
8393 FRAME_X_FRINGE_WIDTH (f) = real_wid;
8394 }
8395 else
8396 {
8397 FRAME_X_LEFT_FRINGE_WIDTH (f) = 0;
8398 FRAME_X_RIGHT_FRINGE_WIDTH (f) = 0;
8399 FRAME_X_FRINGE_COLS (f) = 0;
8400 FRAME_X_FRINGE_WIDTH (f) = 0;
8401 }
8402
8403 if (redraw && FRAME_VISIBLE_P (f))
8404 if (o_left != FRAME_X_LEFT_FRINGE_WIDTH (f) ||
8405 o_right != FRAME_X_RIGHT_FRINGE_WIDTH (f) ||
8406 o_cols != FRAME_X_FRINGE_COLS (f))
8407 redraw_frame (f);
8408}
8409
8410#endif /* HAVE_WINDOW_SYSTEM */
8411
8412
8413
8139/************************************************************************ 8414/************************************************************************
8140 Horizontal scrolling 8415 Horizontal scrolling
8141 ************************************************************************/ 8416 ************************************************************************/