comparison src/redisplay-msw.c @ 269:b2472a1930f2 r20-5b33

Import from CVS: tag r20-5b33
author cvs
date Mon, 13 Aug 2007 10:27:19 +0200
parents 966663fcf606
children c5d627a313b1
comparison
equal deleted inserted replaced
268:6ced69ccd85f 269:b2472a1930f2
311 Draw a normal or end-of-line cursor. The end-of-line cursor is 311 Draw a normal or end-of-line cursor. The end-of-line cursor is
312 narrower than the normal cursor. 312 narrower than the normal cursor.
313 ****************************************************************************/ 313 ****************************************************************************/
314 static void 314 static void
315 mswindows_output_cursor (struct window *w, struct display_line *dl, int xpos, 315 mswindows_output_cursor (struct window *w, struct display_line *dl, int xpos,
316 int width, struct rune *rb) 316 int width, face_index findex, Emchar ch, int image_p)
317 { 317 {
318 struct frame *f = XFRAME (w->frame); 318 struct frame *f = XFRAME (w->frame);
319 struct device *d = XDEVICE (f->device); 319 struct device *d = XDEVICE (f->device);
320 struct face_cachel *cachel; 320 struct face_cachel *cachel;
321 Lisp_Object font = Qnil; 321 Lisp_Object font = Qnil;
322 int focus = EQ (w->frame, DEVICE_FRAME_WITH_FOCUS_REAL (d)); 322 int focus = EQ (w->frame, DEVICE_FRAME_WITH_FOCUS_REAL (d));
323 HDC hdc = FRAME_MSWINDOWS_DC (f); 323 HDC hdc = FRAME_MSWINDOWS_DC (f);
324 int real_char_p = (rb->type == RUNE_CHAR && rb->object.chr.ch != '\n');
325 unsigned int face_index=0; 324 unsigned int face_index=0;
326 char *p_char = NULL; 325 char *p_char = NULL;
327 int n_char = 0; 326 int n_char = 0;
328 RECT rect = { xpos, 327 RECT rect = { xpos,
329 dl->ypos - dl->ascent, 328 dl->ypos - dl->ascent,
330 xpos + width, 329 xpos + width,
331 dl->ypos + dl->descent - dl->clip}; 330 dl->ypos + dl->descent - dl->clip};
332
333 Lisp_Object bar = symbol_value_in_buffer (Qbar_cursor, 331 Lisp_Object bar = symbol_value_in_buffer (Qbar_cursor,
334 WINDOW_BUFFER (w)); 332 WINDOW_BUFFER (w));
335 int bar_p = !NILP (bar); 333 int bar_p = image_p || !NILP (bar);
334 int cursor_p = !NILP (w->text_cursor_visible_p);
335 int real_char_p = ch != 0;
336 336
337 if (real_char_p) 337 if (real_char_p)
338 { 338 {
339 /* Use the font from the underlying character */ 339 /* Use the font from the underlying character */
340 cachel = WINDOW_FACE_CACHEL (w, rb->findex); 340 cachel = WINDOW_FACE_CACHEL (w, findex);
341 341
342 /* XXX MULE: Need to know the charset! */ 342 /* XXX MULE: Need to know the charset! */
343 font = FACE_CACHEL_FONT (cachel, Vcharset_ascii); 343 font = FACE_CACHEL_FONT (cachel, Vcharset_ascii);
344 } 344 }
345 345
346 if ((focus || bar_p) && real_char_p) 346 if ((focus || bar_p) && real_char_p)
347 { 347 {
348 p_char = (char*) &rb->object.chr.ch; 348 p_char = (char*) &ch;
349 n_char = 1; 349 n_char = 1;
350 } 350 }
351 351
352 /* Use cursor fg/bg for block cursor, or character fg/bg for the bar. 352 if (!image_p)
353 Output nothing at eol if bar cursor */ 353 {
354 face_index = get_builtin_face_cache_index (w, Vtext_cursor_face); 354 /* Use cursor fg/bg for block cursor, or character fg/bg for the bar
355 cachel = WINDOW_FACE_CACHEL (w, (bar_p ? rb->findex : face_index)); 355 or when we need to erase the cursor. Output nothing at eol if bar
356 mswindows_update_dc (hdc, font, cachel->foreground, 356 cursor */
357 cachel->background, Qnil); 357 face_index = get_builtin_face_cache_index (w, Vtext_cursor_face);
358 ExtTextOut (hdc, xpos, dl->ypos, ETO_OPAQUE|ETO_CLIPPED, &rect, p_char, n_char, NULL); 358 cachel = WINDOW_FACE_CACHEL (w, ((!cursor_p || bar_p)
359 ? findex : face_index));
360 mswindows_update_dc (hdc, font, cachel->foreground,
361 cachel->background, Qnil);
362 ExtTextOut (hdc, xpos, dl->ypos, ETO_OPAQUE|ETO_CLIPPED, &rect, p_char, n_char, NULL);
363 }
364
365 if (!cursor_p)
366 return;
359 367
360 if (focus && bar_p) 368 if (focus && bar_p)
361 { 369 {
362 rect.right = rect.left + (EQ (bar, Qt) ? 1 : 2); 370 rect.right = rect.left + (EQ (bar, Qt) ? 1 : min (2, width));
363 face_index = get_builtin_face_cache_index (w, Vtext_cursor_face); 371 face_index = get_builtin_face_cache_index (w, Vtext_cursor_face);
364 cachel = WINDOW_FACE_CACHEL (w, face_index); 372 cachel = WINDOW_FACE_CACHEL (w, face_index);
365 mswindows_update_dc (hdc, Qnil, Qnil, cachel->background, Qnil); 373 mswindows_update_dc (hdc, Qnil, Qnil, cachel->background, Qnil);
366 ExtTextOut (hdc, xpos, dl->ypos, ETO_OPAQUE, &rect, NULL, 0, NULL); 374 ExtTextOut (hdc, xpos, dl->ypos, ETO_OPAQUE, &rect, NULL, 0, NULL);
367 } 375 }
372 previously drawn cursor shape */ 380 previously drawn cursor shape */
373 InflateRect (&rect, -1, -1); 381 InflateRect (&rect, -1, -1);
374 382
375 if (real_char_p) 383 if (real_char_p)
376 { 384 {
377 p_char = (char*) &rb->object.chr.ch; 385 p_char = (char*) &ch;
378 n_char = 1; 386 n_char = 1;
379 } 387 }
380 388
381 face_index = get_builtin_face_cache_index (w, Vdefault_face); 389 face_index = get_builtin_face_cache_index (w, Vdefault_face);
382 cachel = WINDOW_FACE_CACHEL (w, (real_char_p ? rb->findex : face_index)); 390 cachel = WINDOW_FACE_CACHEL (w, (real_char_p ? findex : face_index));
383 mswindows_update_dc (hdc, Qnil, cachel->foreground, 391 mswindows_update_dc (hdc, Qnil, cachel->foreground,
384 cachel->background, Qnil); 392 cachel->background, Qnil);
385 ExtTextOut (hdc, xpos, dl->ypos, ETO_OPAQUE | ETO_CLIPPED, 393 ExtTextOut (hdc, xpos, dl->ypos, ETO_OPAQUE | ETO_CLIPPED,
386 &rect, p_char, n_char, NULL); 394 &rect, p_char, n_char, NULL);
387 } 395 }
512 XSetClipRectangles (dpy, gc, x, y, clip_box, 1, Unsorted); 520 XSetClipRectangles (dpy, gc, x, y, clip_box, 1, Unsorted);
513 #endif 521 #endif
514 } 522 }
515 523
516 /* Select the bitmaps into the compatible DC. */ 524 /* Select the bitmaps into the compatible DC. */
517 if ((old=SelectObject(IMAGE_INSTANCE_MSWINDOWS_DC(p), 525 if ((old=SelectObject(FRAME_MSWINDOWS_CDC(f),
518 IMAGE_INSTANCE_MSWINDOWS_BITMAP(p)))) 526 IMAGE_INSTANCE_MSWINDOWS_BITMAP(p))))
519 { 527 {
520 BitBlt(hdc, 528 BitBlt(hdc,
521 x,y, 529 x,y,
522 width, height, 530 width, height,
523 IMAGE_INSTANCE_MSWINDOWS_DC(p), 531 FRAME_MSWINDOWS_CDC(f),
524 0,0, 532 0,0,
525 SRCCOPY); 533 SRCCOPY);
526 SelectObject(IMAGE_INSTANCE_MSWINDOWS_DC(p),old); 534 SelectObject(FRAME_MSWINDOWS_CDC(f),old);
527 } 535 }
528 else 536 else
529 { 537 {
530 /* error */ 538 /* error */
531 } 539 }
650 mswindows_output_dibitmap (f, p, xpos - xoffset, dl->ypos - dl->ascent, 658 mswindows_output_dibitmap (f, p, xpos - xoffset, dl->ypos - dl->ascent,
651 clip_x, clip_y, clip_width, clip_height, 659 clip_x, clip_y, clip_width, clip_height,
652 pwidth, pheight, pixmap_offset); 660 pwidth, pheight, pixmap_offset);
653 } 661 }
654 662
663 #if 0
655 /* Draw a cursor over top of the pixmap. */ 664 /* Draw a cursor over top of the pixmap. */
656 if (cursor_width && cursor_height && (cursor_start >= xpos) 665 if (cursor_width && cursor_height && (cursor_start >= xpos)
657 && !NILP (w->text_cursor_visible_p) 666 && !NILP (w->text_cursor_visible_p)
658 && (cursor_start < xpos + pwidth)) 667 && (cursor_start < xpos + pwidth))
659 { 668 {
682 { 691 {
683 Rectangle (hdc, cursor_start, y, cursor_width, 692 Rectangle (hdc, cursor_start, y, cursor_width,
684 cursor_height); 693 cursor_height);
685 } 694 }
686 } 695 }
696 #endif
687 } 697 }
688 698
689 #ifdef HAVE_SCROLLBARS 699 #ifdef HAVE_SCROLLBARS
690 /* 700 /*
691 * This function paints window's deadbox, a rectangle between window 701 * This function paints window's deadbox, a rectangle between window
1050 1060
1051 if (rb->cursor_type == CURSOR_ON) 1061 if (rb->cursor_type == CURSOR_ON)
1052 { 1062 {
1053 if (rb->object.chr.ch == '\n') 1063 if (rb->object.chr.ch == '\n')
1054 { 1064 {
1055 mswindows_output_cursor (w, dl, xpos, cursor_width, rb); 1065 mswindows_output_cursor (w, dl, xpos, cursor_width,
1066 findex, 0, 0);
1056 } 1067 }
1057 else 1068 else
1058 { 1069 {
1059 Dynarr_add (buf, rb->object.chr.ch); 1070 Dynarr_add (buf, rb->object.chr.ch);
1060 mswindows_output_cursor (w, dl, xpos, cursor_width, rb); 1071 mswindows_output_cursor (w, dl, xpos, cursor_width,
1072 findex, rb->object.chr.ch, 0);
1061 Dynarr_reset (buf); 1073 Dynarr_reset (buf);
1062 } 1074 }
1063 1075
1064 xpos += rb->width; 1076 xpos += rb->width;
1065 elt++; 1077 elt++;
1090 w->shadow_thickness_changed = 1; 1102 w->shadow_thickness_changed = 1;
1091 mswindows_output_hline (w, dl, rb); 1103 mswindows_output_hline (w, dl, rb);
1092 } 1104 }
1093 1105
1094 if (rb->cursor_type == CURSOR_ON) 1106 if (rb->cursor_type == CURSOR_ON)
1095 mswindows_output_cursor (w, dl, xpos, cursor_width, rb); 1107 mswindows_output_cursor (w, dl, xpos, cursor_width, rb->findex, 0, 0);
1096 1108
1097 elt++; 1109 elt++;
1098 if (elt < end) 1110 if (elt < end)
1099 { 1111 {
1100 rb = Dynarr_atp (rba, elt); 1112 rb = Dynarr_atp (rba, elt);
1123 XIMAGE_INSTANCE_TEXT_STRING (instance); 1135 XIMAGE_INSTANCE_TEXT_STRING (instance);
1124 convert_bufbyte_string_into_emchar_dynarr 1136 convert_bufbyte_string_into_emchar_dynarr
1125 (XSTRING_DATA (string), XSTRING_LENGTH (string), buf); 1137 (XSTRING_DATA (string), XSTRING_LENGTH (string), buf);
1126 1138
1127 if (rb->cursor_type == CURSOR_ON) 1139 if (rb->cursor_type == CURSOR_ON)
1128 mswindows_output_cursor (w, dl, xpos, cursor_width, rb); 1140 mswindows_output_cursor (w, dl, xpos, cursor_width,
1141 findex, Dynarr_at (buf, 0), 0);
1129 else /* #### redisplay-x passes -1 as the width: why ? */ 1142 else /* #### redisplay-x passes -1 as the width: why ? */
1130 mswindows_output_string (w, dl, buf, xpos, 1143 mswindows_output_string (w, dl, buf, xpos,
1131 rb->object.dglyph.xoffset, 1144 rb->object.dglyph.xoffset,
1132 start_pixpos, rb->width, findex); 1145 start_pixpos, rb->width, findex);
1133 Dynarr_reset (buf); 1146 Dynarr_reset (buf);
1138 case IMAGE_COLOR_PIXMAP: 1151 case IMAGE_COLOR_PIXMAP:
1139 mswindows_output_pixmap (w, dl, instance, xpos, 1152 mswindows_output_pixmap (w, dl, instance, xpos,
1140 rb->object.dglyph.xoffset, start_pixpos, 1153 rb->object.dglyph.xoffset, start_pixpos,
1141 rb->width, findex, cursor_start, 1154 rb->width, findex, cursor_start,
1142 cursor_width, cursor_height); 1155 cursor_width, cursor_height);
1156 if (rb->cursor_type == CURSOR_ON)
1157 mswindows_output_cursor (w, dl, xpos, cursor_width,
1158 findex, 0, 1);
1143 break; 1159 break;
1144 1160
1145 case IMAGE_POINTER: 1161 case IMAGE_POINTER:
1146 abort (); 1162 abort ();
1147 1163
1174 || f->windows_structure_changed 1190 || f->windows_structure_changed
1175 || w->shadow_thickness_changed)) 1191 || w->shadow_thickness_changed))
1176 mswindows_bevel_modeline (w, dl); 1192 mswindows_bevel_modeline (w, dl);
1177 1193
1178 Dynarr_free (buf); 1194 Dynarr_free (buf);
1179
1180 } 1195 }
1181 1196
1182 1197
1183 /***************************************************************************** 1198 /*****************************************************************************
1184 mswindows_output_vertical_divider 1199 mswindows_output_vertical_divider