aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEli Zaretskii1999-07-30 08:05:13 +0000
committerEli Zaretskii1999-07-30 08:05:13 +0000
commitc77f6f1b96decd9ee777a9b2a66f6b72718dab68 (patch)
tree316f8a6d600445bd8955a32745e7137335f6d1ab /src
parent700c3b7c33cc22bd96ae9d556f6cd73733ad77fe (diff)
downloademacs-c77f6f1b96decd9ee777a9b2a66f6b72718dab68.tar.gz
emacs-c77f6f1b96decd9ee777a9b2a66f6b72718dab68.zip
(IT_set_face): Rewritten for the new redisplay engine.
Use default frame colors if the face doesn't specify them; invert the colors if highlight is ON. (IT_write_glyphs): Rewritten for the new redisplay engine. (IT_change_line_highlight): Add (unused) parameter Y, since that's how the hook is called by term.c. (IT_copy_glyphs): New function, copies an area of the display in video RAM. (IT_insert_glyphs): Rewritten to DTRT instead of aborting, since redisplay now calls it even if char_ins_del_ok is zero. (IT_set_frame_parameters): Prototype changed. Calls the new load_color. Puts the new fore/background colors into the default face on current frame. (IT_menu_display): Rewritten to handle the new struct glyph instead of a char array. (XMenuActivate): Call lookup_derived_face to create and use special faces for the pop-up and drop-down menus.
Diffstat (limited to 'src')
-rw-r--r--src/msdos.c200
1 files changed, 140 insertions, 60 deletions
diff --git a/src/msdos.c b/src/msdos.c
index d43ce1ac798..b73b8e7a5f7 100644
--- a/src/msdos.c
+++ b/src/msdos.c
@@ -46,12 +46,12 @@ Boston, MA 02111-1307, USA. */
46#include <conio.h> /* for cputs */ 46#include <conio.h> /* for cputs */
47#endif 47#endif
48 48
49#include "dosfns.h"
50#include "msdos.h" 49#include "msdos.h"
51#include "systime.h" 50#include "systime.h"
52#include "termhooks.h" 51#include "termhooks.h"
53#include "termchar.h" 52#include "termchar.h"
54#include "dispextern.h" 53#include "dispextern.h"
54#include "dosfns.h"
55#include "termopts.h" 55#include "termopts.h"
56#include "charset.h" 56#include "charset.h"
57#include "coding.h" 57#include "coding.h"
@@ -658,29 +658,54 @@ IT_ring_bell (void)
658 } 658 }
659} 659}
660 660
661/* Given a face id FACE, extract the face parameters to be used for
662 display until the face changes. The face parameters (actually, its
663 color) are used to construct the video attribute byte for each
664 glyph during the construction of the buffer that is then blitted to
665 the video RAM. */
661static void 666static void
662IT_set_face (int face) 667IT_set_face (int face)
663{ 668{
664 struct face *fp; 669 struct face *fp = FACE_FROM_ID (selected_frame, face);
665 extern struct face *intern_face (/* FRAME_PTR, struct face * */); 670 unsigned long fg, bg;
666 671
667 if (face == 1 || (face == 0 && highlight)) 672 if (!fp)
668 fp = FRAME_MODE_LINE_FACE (foo); 673 fp = FACE_FROM_ID (selected_frame, DEFAULT_FACE_ID);
669 else if (face <= 0 || face >= FRAME_N_COMPUTED_FACES (foo))
670 fp = FRAME_DEFAULT_FACE (foo);
671 else
672 fp = intern_face (selected_frame, FRAME_COMPUTED_FACES (foo)[face]);
673 if (termscript)
674 fprintf (termscript, "<FACE %d: %d/%d>",
675 face, FACE_FOREGROUND (fp), FACE_BACKGROUND (fp));
676 screen_face = face; 674 screen_face = face;
677 ScreenAttrib = (FACE_BACKGROUND (fp) << 4) | FACE_FOREGROUND (fp); 675 fg = fp->foreground;
676 bg = fp->background;
677
678 /* Don't use invalid colors. In particular, a color of -1 means use
679 the colors of the default face, except that if highlight is on,
680 invert the foreground and the background. Note that we assume
681 all 16 colors to be available for the background, since Emacs
682 switches on this mode (and loses the blinking attribute) at
683 startup. */
684 if (fg == (unsigned long)-1)
685 fg = highlight ? FRAME_BACKGROUND_PIXEL (selected_frame)
686 : FRAME_FOREGROUND_PIXEL (selected_frame);
687 if (bg == (unsigned long)-1)
688 bg = highlight ? FRAME_FOREGROUND_PIXEL (selected_frame)
689 : FRAME_BACKGROUND_PIXEL (selected_frame);
690 if (termscript)
691 fprintf (termscript, "<FACE %d%s: %d/%d>",
692 face, highlight ? "H" : "", fp->foreground, fp->background);
693 if (fg >= 0 && fg < 16)
694 {
695 ScreenAttrib &= 0xf0;
696 ScreenAttrib |= fg;
697 }
698 if (bg >= 0 && bg < 16)
699 {
700 ScreenAttrib &= 0x0f;
701 ScreenAttrib |= ((bg & 0x0f) << 4);
702 }
678} 703}
679 704
680Lisp_Object Vdos_unsupported_char_glyph; 705Lisp_Object Vdos_unsupported_char_glyph;
681 706
682static void 707static void
683IT_write_glyphs (GLYPH *str, int str_len) 708IT_write_glyphs (struct glyph *str, int str_len)
684{ 709{
685 unsigned char *screen_buf, *screen_bp, *screen_buf_end, *bp; 710 unsigned char *screen_buf, *screen_bp, *screen_buf_end, *bp;
686 int unsupported_face = FAST_GLYPH_FACE (Vdos_unsupported_char_glyph); 711 int unsupported_face = FAST_GLYPH_FACE (Vdos_unsupported_char_glyph);
@@ -710,9 +735,10 @@ IT_write_glyphs (GLYPH *str, int str_len)
710 terminal_coding.mode &= ~CODING_MODE_LAST_BLOCK; 735 terminal_coding.mode &= ~CODING_MODE_LAST_BLOCK;
711 while (sl) 736 while (sl)
712 { 737 {
713 int cf, ch, chlen, enclen; 738 int cf, chlen, enclen;
714 unsigned char workbuf[4], *buf; 739 unsigned char workbuf[4], *buf;
715 register GLYPH g = *str; 740 unsigned ch;
741 register GLYPH g = GLYPH_FROM_CHAR_GLYPH (*str);
716 742
717 /* Find the actual glyph to display by traversing the entire 743 /* Find the actual glyph to display by traversing the entire
718 aliases chain for this glyph. */ 744 aliases chain for this glyph. */
@@ -721,7 +747,7 @@ IT_write_glyphs (GLYPH *str, int str_len)
721 /* Glyphs with GLYPH_MASK_PADDING bit set are actually there 747 /* Glyphs with GLYPH_MASK_PADDING bit set are actually there
722 only for the redisplay code to know how many columns does 748 only for the redisplay code to know how many columns does
723 this character occupy on the screen. Skip padding glyphs. */ 749 this character occupy on the screen. Skip padding glyphs. */
724 if ((g & GLYPH_MASK_PADDING)) 750 if (CHAR_GLYPH_PADDING_P (*str))
725 { 751 {
726 str++; 752 str++;
727 sl--; 753 sl--;
@@ -740,7 +766,7 @@ IT_write_glyphs (GLYPH *str, int str_len)
740 ch = unibyte_char_to_multibyte (ch); 766 ch = unibyte_char_to_multibyte (ch);
741 767
742 /* Invalid characters are displayed with a special glyph. */ 768 /* Invalid characters are displayed with a special glyph. */
743 if (ch > MAX_CHAR) 769 if (! GLYPH_CHAR_VALID_P (ch))
744 { 770 {
745 g = !NILP (Vdos_unsupported_char_glyph) 771 g = !NILP (Vdos_unsupported_char_glyph)
746 ? Vdos_unsupported_char_glyph 772 ? Vdos_unsupported_char_glyph
@@ -773,8 +799,7 @@ IT_write_glyphs (GLYPH *str, int str_len)
773 buf = GLYPH_STRING (tbase, g); 799 buf = GLYPH_STRING (tbase, g);
774 } 800 }
775 801
776 /* If the character is not multibyte, don't bother converting it. 802 /* If the character is not multibyte, don't bother converting it. */
777 FIXME: what about "emacs --unibyte" */
778 if (chlen == 1) 803 if (chlen == 1)
779 { 804 {
780 *conversion_buffer = (unsigned char)ch; 805 *conversion_buffer = (unsigned char)ch;
@@ -1054,7 +1079,7 @@ IT_reassert_line_highlight (int new, int vpos)
1054} 1079}
1055 1080
1056static void 1081static void
1057IT_change_line_highlight (int new_highlight, int vpos, int first_unused_hpos) 1082IT_change_line_highlight (int new_highlight, int y, int vpos, int first_unused_hpos)
1058{ 1083{
1059 highlight = new_highlight; 1084 highlight = new_highlight;
1060 IT_set_face (0); /* To possibly clear the highlighting. */ 1085 IT_set_face (0); /* To possibly clear the highlighting. */
@@ -1075,15 +1100,55 @@ IT_update_end (struct frame *foo)
1075{ 1100{
1076} 1101}
1077 1102
1078/* Insert and delete characters. These are not supposed to be used 1103/* Copy LEN glyphs displayed on a single line whose vertical position
1079 because we are supposed to turn off the feature of using them by 1104 is YPOS, beginning at horizontal position XFROM to horizontal
1080 setting char_ins_del_ok to zero (see internal_terminal_init). */ 1105 position XTO, by moving blocks in the video memory. Used by
1106 functions that insert and delete glyphs. */
1107static void
1108IT_copy_glyphs (int xfrom, int xto, size_t len, int ypos)
1109{
1110 /* The offsets of source and destination relative to the
1111 conventional memorty selector. */
1112 int from = 2 * (xfrom + screen_size_X * ypos) + ScreenPrimary;
1113 int to = 2 * (xto + screen_size_X * ypos) + ScreenPrimary;
1114
1115 if (from == to || len <= 0)
1116 return;
1117
1118 _farsetsel (_dos_ds);
1119
1120 /* The source and destination might overlap, so we need to move
1121 glyphs non-destructively. */
1122 if (from > to)
1123 {
1124 for ( ; len; from += 2, to += 2, len--)
1125 _farnspokew (to, _farnspeekw (from));
1126 }
1127 else
1128 {
1129 from += (len - 1) * 2;
1130 to += (len - 1) * 2;
1131 for ( ; len; from -= 2, to -= 2, len--)
1132 _farnspokew (to, _farnspeekw (from));
1133 }
1134 if (screen_virtual_segment)
1135 dosv_refresh_virtual_screen (ypos * screen_size_X * 2, screen_size_X);
1136}
1137
1138/* Insert and delete glyphs. */
1081static void 1139static void
1082IT_insert_glyphs (start, len) 1140IT_insert_glyphs (start, len)
1083 register char *start; 1141 register struct glyph *start;
1084 register int len; 1142 register int len;
1085{ 1143{
1086 abort (); 1144 int shift_by_width = screen_size_X - (new_pos_X + len);
1145
1146 /* Shift right the glyphs from the nominal cursor position to the
1147 end of this line. */
1148 IT_copy_glyphs (new_pos_X, new_pos_X + len, shift_by_width, new_pos_Y);
1149
1150 /* Now write the glyphs to be inserted. */
1151 IT_write_glyphs (start, len);
1087} 1152}
1088 1153
1089static void 1154static void
@@ -1265,7 +1330,7 @@ IT_set_terminal_window (int foo)
1265 1330
1266void 1331void
1267IT_set_frame_parameters (f, alist) 1332IT_set_frame_parameters (f, alist)
1268 FRAME_PTR f; 1333 struct frame *f;
1269 Lisp_Object alist; 1334 Lisp_Object alist;
1270{ 1335{
1271 Lisp_Object tail; 1336 Lisp_Object tail;
@@ -1276,7 +1341,10 @@ IT_set_frame_parameters (f, alist)
1276 Lisp_Object *values 1341 Lisp_Object *values
1277 = (Lisp_Object *) alloca (length * sizeof (Lisp_Object)); 1342 = (Lisp_Object *) alloca (length * sizeof (Lisp_Object));
1278 int redraw; 1343 int redraw;
1279 extern unsigned long load_color (); 1344 struct face *dflt = NULL;
1345
1346 if (FRAME_FACE_CACHE (f))
1347 dflt = FACE_FROM_ID (f, DEFAULT_FACE_ID);
1280 1348
1281 redraw = 0; 1349 redraw = 0;
1282 1350
@@ -1302,10 +1370,14 @@ IT_set_frame_parameters (f, alist)
1302 1370
1303 if (EQ (prop, Qforeground_color)) 1371 if (EQ (prop, Qforeground_color))
1304 { 1372 {
1305 unsigned long new_color = load_color (f, val); 1373 unsigned long new_color = load_color (f, NULL, val,
1374 LFACE_FOREGROUND_INDEX);
1306 if (new_color != ~0) 1375 if (new_color != ~0)
1307 { 1376 {
1377 if (!dflt)
1378 abort ();
1308 FRAME_FOREGROUND_PIXEL (f) = new_color; 1379 FRAME_FOREGROUND_PIXEL (f) = new_color;
1380 dflt->foreground = new_color;
1309 redraw = 1; 1381 redraw = 1;
1310 if (termscript) 1382 if (termscript)
1311 fprintf (termscript, "<FGCOLOR %lu>\n", new_color); 1383 fprintf (termscript, "<FGCOLOR %lu>\n", new_color);
@@ -1313,10 +1385,14 @@ IT_set_frame_parameters (f, alist)
1313 } 1385 }
1314 else if (EQ (prop, Qbackground_color)) 1386 else if (EQ (prop, Qbackground_color))
1315 { 1387 {
1316 unsigned long new_color = load_color (f, val); 1388 unsigned long new_color = load_color (f, NULL, val,
1389 LFACE_BACKGROUND_INDEX);
1317 if (new_color != ~0) 1390 if (new_color != ~0)
1318 { 1391 {
1392 if (!dflt)
1393 abort ();
1319 FRAME_BACKGROUND_PIXEL (f) = new_color; 1394 FRAME_BACKGROUND_PIXEL (f) = new_color;
1395 dflt->background = new_color;
1320 redraw = 1; 1396 redraw = 1;
1321 if (termscript) 1397 if (termscript)
1322 fprintf (termscript, "<BGCOLOR %lu>\n", new_color); 1398 fprintf (termscript, "<BGCOLOR %lu>\n", new_color);
@@ -1332,8 +1408,12 @@ IT_set_frame_parameters (f, alist)
1332 { 1408 {
1333 unsigned long fg = FRAME_FOREGROUND_PIXEL (f); 1409 unsigned long fg = FRAME_FOREGROUND_PIXEL (f);
1334 1410
1335 FRAME_FOREGROUND_PIXEL (f) = FRAME_BACKGROUND_PIXEL (f); 1411 if (!dflt)
1412 abort ();
1413 FRAME_FOREGROUND_PIXEL (f) = FRAME_BACKGROUND_PIXEL (f); /* FIXME! */
1336 FRAME_BACKGROUND_PIXEL (f) = fg; 1414 FRAME_BACKGROUND_PIXEL (f) = fg;
1415 dflt->foreground = FRAME_FOREGROUND_PIXEL (f);
1416 dflt->foreground = fg;
1337 if (termscript) 1417 if (termscript)
1338 fprintf (termscript, "<INVERSE-VIDEO>\n"); 1418 fprintf (termscript, "<INVERSE-VIDEO>\n");
1339 } 1419 }
@@ -1343,9 +1423,6 @@ IT_set_frame_parameters (f, alist)
1343 1423
1344 if (redraw) 1424 if (redraw)
1345 { 1425 {
1346 extern void recompute_basic_faces (FRAME_PTR);
1347 extern void redraw_frame (FRAME_PTR);
1348
1349 recompute_basic_faces (f); 1426 recompute_basic_faces (f);
1350 if (f == selected_frame) 1427 if (f == selected_frame)
1351 redraw_frame (f); 1428 redraw_frame (f);
@@ -1433,8 +1510,7 @@ internal_terminal_init ()
1433 set_terminal_modes_hook = IT_set_terminal_modes; 1510 set_terminal_modes_hook = IT_set_terminal_modes;
1434 reset_terminal_modes_hook = IT_reset_terminal_modes; 1511 reset_terminal_modes_hook = IT_reset_terminal_modes;
1435 set_terminal_window_hook = IT_set_terminal_window; 1512 set_terminal_window_hook = IT_set_terminal_window;
1436 1513 char_ins_del_ok = 0;
1437 char_ins_del_ok = 0; /* just as fast to write the line */
1438#endif 1514#endif
1439} 1515}
1440 1516
@@ -2409,14 +2485,14 @@ static void
2409IT_menu_display (XMenu *menu, int y, int x, int *faces) 2485IT_menu_display (XMenu *menu, int y, int x, int *faces)
2410{ 2486{
2411 int i, j, face, width; 2487 int i, j, face, width;
2412 GLYPH *text, *p; 2488 struct glyph *text, *p;
2413 char *q; 2489 char *q;
2414 int mx, my; 2490 int mx, my;
2415 int enabled, mousehere; 2491 int enabled, mousehere;
2416 int row, col; 2492 int row, col;
2417 2493
2418 width = menu->width; 2494 width = menu->width;
2419 text = (GLYPH *) xmalloc ((width + 2) * sizeof (GLYPH)); 2495 text = (struct glyph *) xmalloc ((width + 2) * sizeof (struct glyph));
2420 ScreenGetCursor (&row, &col); 2496 ScreenGetCursor (&row, &col);
2421 mouse_get_xy (&mx, &my); 2497 mouse_get_xy (&mx, &my);
2422 IT_update_begin (selected_frame); 2498 IT_update_begin (selected_frame);
@@ -2428,22 +2504,30 @@ IT_menu_display (XMenu *menu, int y, int x, int *faces)
2428 mousehere = (y + i == my && x <= mx && mx < x + width + 2); 2504 mousehere = (y + i == my && x <= mx && mx < x + width + 2);
2429 face = faces[enabled + mousehere * 2]; 2505 face = faces[enabled + mousehere * 2];
2430 p = text; 2506 p = text;
2431 *p++ = FAST_MAKE_GLYPH (' ', face); 2507 SET_CHAR_GLYPH (*p, ' ', face, 0);
2508 p++;
2432 for (j = 0, q = menu->text[i]; *q; j++) 2509 for (j = 0, q = menu->text[i]; *q; j++)
2433 { 2510 {
2434 if (*q > 26) 2511 if (*q > 26)
2435 *p++ = FAST_MAKE_GLYPH (*q++, face); 2512 {
2513 SET_CHAR_GLYPH (*p, *q++, face, 0);
2514 p++;
2515 }
2436 else /* make '^x' */ 2516 else /* make '^x' */
2437 { 2517 {
2438 *p++ = FAST_MAKE_GLYPH ('^', face); 2518 SET_CHAR_GLYPH (*p, '^', face, 0);
2519 p++;
2439 j++; 2520 j++;
2440 *p++ = FAST_MAKE_GLYPH (*q++ + 64, face); 2521 SET_CHAR_GLYPH (*p, *q++ + 64, face, 0);
2522 p++;
2441 } 2523 }
2442 } 2524 }
2443 2525
2444 for (; j < width; j++) 2526 for (; j < width; j++, p++)
2445 *p++ = FAST_MAKE_GLYPH (' ', face); 2527 SET_CHAR_GLYPH (*p, ' ', face, 0);
2446 *p++ = FAST_MAKE_GLYPH (menu->submenu[i] ? 16 : ' ', face); 2528
2529 SET_CHAR_GLYPH (*p, menu->submenu[i] ? 16 : ' ', face, 0);
2530 p++;
2447 IT_write_glyphs (text, width + 2); 2531 IT_write_glyphs (text, width + 2);
2448 } 2532 }
2449 IT_update_end (selected_frame); 2533 IT_update_end (selected_frame);
@@ -2561,7 +2645,8 @@ XMenuActivate (Display *foo, XMenu *menu, int *pane, int *selidx,
2561 int statecount; 2645 int statecount;
2562 int x, y, i, b; 2646 int x, y, i, b;
2563 int screensize; 2647 int screensize;
2564 int faces[4], selectface; 2648 int faces[4];
2649 Lisp_Object selectface;
2565 int leave, result, onepane; 2650 int leave, result, onepane;
2566 int title_faces[4]; /* face to display the menu title */ 2651 int title_faces[4]; /* face to display the menu title */
2567 int buffers_num_deleted = 0; 2652 int buffers_num_deleted = 0;
@@ -2583,21 +2668,16 @@ XMenuActivate (Display *foo, XMenu *menu, int *pane, int *selidx,
2583 state = alloca (menu->panecount * sizeof (struct IT_menu_state)); 2668 state = alloca (menu->panecount * sizeof (struct IT_menu_state));
2584 screensize = screen_size * 2; 2669 screensize = screen_size * 2;
2585 faces[0] 2670 faces[0]
2586 = compute_glyph_face (selected_frame, 2671 = lookup_derived_face (selected_frame, intern ("msdos-menu-passive-face"),
2587 face_name_id_number 2672 CHARSET_ASCII, DEFAULT_FACE_ID);
2588 (selected_frame,
2589 intern ("msdos-menu-passive-face")),
2590 0);
2591 faces[1] 2673 faces[1]
2592 = compute_glyph_face (selected_frame, 2674 = lookup_derived_face (selected_frame, intern ("msdos-menu-active-face"),
2593 face_name_id_number 2675 CHARSET_ASCII, DEFAULT_FACE_ID);
2594 (selected_frame, 2676 selectface = intern ("msdos-menu-select-face");
2595 intern ("msdos-menu-active-face")), 2677 faces[2] = lookup_derived_face (selected_frame, selectface,
2596 0); 2678 CHARSET_ASCII, faces[0]);
2597 selectface 2679 faces[3] = lookup_derived_face (selected_frame, selectface,
2598 = face_name_id_number (selected_frame, intern ("msdos-menu-select-face")); 2680 CHARSET_ASCII, faces[1]);
2599 faces[2] = compute_glyph_face (selected_frame, selectface, faces[0]);
2600 faces[3] = compute_glyph_face (selected_frame, selectface, faces[1]);
2601 2681
2602 /* Make sure the menu title is always displayed with 2682 /* Make sure the menu title is always displayed with
2603 `msdos-menu-active-face', no matter where the mouse pointer is. */ 2683 `msdos-menu-active-face', no matter where the mouse pointer is. */