diff -ur slang-pre2.3.0-110.orig/src/slang.h slang-pre2.3.0-110/src/slang.h
old
|
new
|
|
1652 | 1652 | SL_EXTERN unsigned long SLtt_Num_Chars_Output; |
1653 | 1653 | SL_EXTERN int SLtt_Baud_Rate; |
1654 | 1654 | |
1655 | | typedef unsigned long SLtt_Char_Type; |
| 1655 | typedef unsigned long long SLtt_Char_Type; |
1656 | 1656 | |
1657 | | #define SLTT_BOLD_MASK 0x01000000UL |
1658 | | #define SLTT_BLINK_MASK 0x02000000UL |
1659 | | #define SLTT_ULINE_MASK 0x04000000UL |
1660 | | #define SLTT_REV_MASK 0x08000000UL |
1661 | | #define SLTT_ALTC_MASK 0x10000000UL |
1662 | | #define SLTT_ITALIC_MASK 0x20000000UL |
| 1657 | #define SLTT_BOLD_MASK 0x0000000001000000ULL |
| 1658 | #define SLTT_BLINK_MASK 0x0000000002000000ULL |
| 1659 | #define SLTT_ULINE_MASK 0x0000000004000000ULL |
| 1660 | #define SLTT_REV_MASK 0x0000000008000000ULL |
| 1661 | #define SLTT_ALTC_MASK 0x0000000010000000ULL |
| 1662 | #define SLTT_ITALIC_MASK 0x0000000020000000ULL |
1663 | 1663 | |
1664 | 1664 | SL_EXTERN int SLtt_Screen_Rows; |
1665 | 1665 | SL_EXTERN int SLtt_Screen_Cols; |
diff -ur slang-pre2.3.0-110.orig/src/sldisply.c slang-pre2.3.0-110/src/sldisply.c
old
|
new
|
|
89 | 89 | /* Colors: These definitions are used for the display. However, the |
90 | 90 | * application only uses object handles which get mapped to this |
91 | 91 | * internal representation. The mapping is performed by the Color_Map |
92 | | * structure below. */ |
| 92 | * structure below. |
| 93 | * |
| 94 | * Colors are encoded in 25 bits as follows: |
| 95 | * - Values 0-255 for standard palette |
| 96 | * - 256 for terminal's default color |
| 97 | * - 0x1RRGGBB for true colors |
| 98 | * |
| 99 | * The bits are split so we can maintain ABI compatibility on 64 bit machines. |
| 100 | */ |
93 | 101 | |
94 | | #define CHAR_MASK 0x000000FF |
95 | | #define FG_MASK 0x0000FF00 |
96 | | #define BG_MASK 0x00FF0000 |
97 | | #define ATTR_MASK 0x3F000000 |
98 | | #define BGALL_MASK 0x0FFF0000 |
| 102 | // FIXME: are the CHAR_MASK bits used at all? If not then the color bits can be |
| 103 | // spread out a little bit more nicely, see the #else branch. |
| 104 | #if 1 |
| 105 | |
| 106 | #define CHAR_MASK 0x00000000000000FFULL |
| 107 | #define FG_MASK_LOW 0x0000000000FFFF00ULL |
| 108 | #define FG_MASK_HIGH 0x0000007FC0000000ULL |
| 109 | #define BG_MASK 0xFFFFFF8000000000ULL |
| 110 | #define ATTR_MASK 0x000000003F000000ULL |
| 111 | #define CHAR_INVALID 0x4000000000000000ULL |
| 112 | |
| 113 | #define GET_FG(fgbg) ((((fgbg) & FG_MASK_HIGH) >> 14) | (((fgbg) & FG_MASK_LOW) >> 8)) |
| 114 | #define GET_BG(fgbg) (((fgbg) & BG_MASK) >> 39) |
| 115 | #define MAKE_COLOR(fg, bg) ((((fg) << 14) & FG_MASK_HIGH) | (((fg) << 8) & FG_MASK_LOW) | (((bg) << 39) & BG_MASK)) |
99 | 116 | |
100 | | /* The 0x10000000 bit represents the alternate character set. BGALL_MASK does |
101 | | * not include this attribute. |
102 | | */ |
| 117 | #else |
103 | 118 | |
104 | | #define GET_FG(fgbg) (((fgbg) & FG_MASK) >> 8) |
105 | | #define GET_BG(fgbg) (((fgbg) & BG_MASK) >> 16) |
106 | | #define MAKE_COLOR(fg, bg) (((fg) | ((bg) << 8)) << 8) |
| 119 | #define FG_MASK_LOW 0x0000000000FFFFFFULL |
| 120 | #define FG_MASK_HIGH 0x0200000000000000ULL |
| 121 | #define BG_MASK 0x01FFFFFF00000000ULL |
| 122 | #define ATTR_MASK 0x000000003F000000ULL |
| 123 | #define CHAR_INVALID 0xFFFFFFFFFFFFFFFFULL |
| 124 | |
| 125 | #define GET_FG(fgbg) ((((fgbg) & FG_MASK_HIGH) >> 33) | ((fgbg) & FG_MASK_LOW)) |
| 126 | #define GET_BG(fgbg) (((fgbg) & BG_MASK) >> 32) |
| 127 | #define MAKE_COLOR(fg, bg) ((((fg) << 33) & FG_MASK_HIGH) | ((fg) & FG_MASK_LOW) | (((bg) << 32) & BG_MASK)) |
| 128 | |
| 129 | #endif |
107 | 130 | |
108 | 131 | int SLtt_Screen_Cols = 80; |
109 | 132 | int SLtt_Screen_Rows = 24; |
… |
… |
|
180 | 203 | |
181 | 204 | static SLCONST char *Color_Fg_Str = "\033[3%dm"; |
182 | 205 | static SLCONST char *Color_Bg_Str = "\033[4%dm"; |
| 206 | static SLCONST char *Color_RGB_Fg_Str = "\033[38;2;%d;%d;%dm"; |
| 207 | static SLCONST char *Color_RGB_Bg_Str = "\033[48;2;%d;%d;%dm"; |
183 | 208 | static SLCONST char *Default_Color_Fg_Str = "\033[39m"; |
184 | 209 | static SLCONST char *Default_Color_Bg_Str = "\033[49m"; |
185 | 210 | |
… |
… |
|
247 | 272 | static int Cursor_r, Cursor_c; /* 0 based */ |
248 | 273 | |
249 | 274 | /* current attributes --- initialized to impossible value */ |
250 | | static SLtt_Char_Type Current_Fgbg = 0xFFFFFFFFU; |
| 275 | static SLtt_Char_Type Current_Fgbg = CHAR_INVALID; |
251 | 276 | |
252 | 277 | static int Cursor_Set; /* 1 if cursor position known, 0 |
253 | 278 | * if not. -1 if only row is known |
… |
… |
|
1045 | 1070 | } |
1046 | 1071 | |
1047 | 1072 | if ((Del_Eol_Str != NULL) |
1048 | | && (Can_Background_Color_Erase || ((Current_Fgbg & ~0xFFU) == 0))) |
| 1073 | && (Can_Background_Color_Erase || ((Current_Fgbg & ~0xFFU) == 0))) // FIXME: do we use CHAR_MASK's bits here? |
1049 | 1074 | { |
1050 | 1075 | tt_write_string(Del_Eol_Str); |
1051 | 1076 | return; |
… |
… |
|
1062 | 1087 | |
1063 | 1088 | void SLtt_del_eol (void) |
1064 | 1089 | { |
1065 | | if (Current_Fgbg != 0xFFFFFFFFU) SLtt_normal_video (); |
| 1090 | if (Current_Fgbg != CHAR_INVALID) SLtt_normal_video (); |
1066 | 1091 | del_eol (); |
1067 | 1092 | } |
1068 | 1093 | |
… |
… |
|
1092 | 1117 | {"brightmagenta", SLSMG_COLOR_BRIGHT_CYAN}, |
1093 | 1118 | {"brightcyan", SLSMG_COLOR_BRIGHT_MAGENTA}, |
1094 | 1119 | {"white", SLSMG_COLOR_BRIGHT_WHITE}, |
1095 | | #define SLSMG_COLOR_DEFAULT 0xFF |
| 1120 | #define SLSMG_COLOR_DEFAULT 0x100 |
1096 | 1121 | {"default", SLSMG_COLOR_DEFAULT} |
1097 | 1122 | }; |
1098 | 1123 | |
… |
… |
|
1150 | 1175 | Brush_Info_Type *b; |
1151 | 1176 | |
1152 | 1177 | if (NULL == (b = get_brush_info (color))) |
1153 | | return (SLtt_Char_Type)-1; |
| 1178 | return CHAR_INVALID; |
1154 | 1179 | |
1155 | 1180 | if (SLtt_Use_Ansi_Colors) |
1156 | 1181 | return b->fgbg; |
… |
… |
|
1307 | 1332 | |
1308 | 1333 | if (Max_Terminfo_Colors != 8) |
1309 | 1334 | { |
1310 | | if (f != SLSMG_COLOR_DEFAULT) f %= Max_Terminfo_Colors; |
1311 | | if (b != SLSMG_COLOR_DEFAULT) b %= Max_Terminfo_Colors; |
1312 | | return ((f << 8) | (b << 16)); |
| 1335 | if (f != SLSMG_COLOR_DEFAULT && !(f & (1 << 24))) f %= Max_Terminfo_Colors; |
| 1336 | if (b != SLSMG_COLOR_DEFAULT && !(b & (1 << 24))) b %= Max_Terminfo_Colors; |
| 1337 | return MAKE_COLOR(f,b); |
1313 | 1338 | } |
1314 | 1339 | |
1315 | 1340 | /* Otherwise we have 8 ansi colors. Try to get bright versions |
… |
… |
|
1331 | 1356 | b &= 0x7; |
1332 | 1357 | } |
1333 | 1358 | |
1334 | | return ((f << 8) | (b << 16) | attr); |
| 1359 | return MAKE_COLOR(f,b) | attr; |
| 1360 | } |
| 1361 | |
| 1362 | static int parse_hex_digit (char ch) |
| 1363 | { |
| 1364 | if ('0' <= ch && ch <= '9') return ch - '0'; |
| 1365 | if ('A' <= ch && ch <= 'F') return 10 + ch - 'A'; |
| 1366 | if ('a' <= ch && ch <= 'f') return 10 + ch - 'a'; |
| 1367 | return -1; |
1335 | 1368 | } |
1336 | 1369 | |
1337 | 1370 | /* This looks for colors with name form 'colorN'. If color is of this |
… |
… |
|
1342 | 1375 | unsigned int i; |
1343 | 1376 | unsigned char ch; |
1344 | 1377 | |
| 1378 | if (color[0] == '#') |
| 1379 | { |
| 1380 | int h[6]; |
| 1381 | SLtt_Char_Type rgb; |
| 1382 | color++; |
| 1383 | if (strlen(color) != 3 && strlen(color) != 6) |
| 1384 | return -1; |
| 1385 | for (i = 0; color[i] != '\0'; i++) |
| 1386 | { |
| 1387 | h[i] = parse_hex_digit (color[i]); |
| 1388 | if (h[i] == -1) |
| 1389 | return -1; |
| 1390 | } |
| 1391 | if (i == 3) |
| 1392 | rgb = (h[0] << 20) | (h[0] << 16) | (h[1] << 12) | (h[1] << 8) | (h[2] << 4) | h[2]; |
| 1393 | else |
| 1394 | rgb = (h[0] << 20) | (h[1] << 16) | (h[2] << 12) | (h[3] << 8) | (h[4] << 4) | h[5]; |
| 1395 | *f = (1 << 24) | rgb; |
| 1396 | return 0; |
| 1397 | } |
| 1398 | |
1345 | 1399 | if (strncmp (color, "color", 5)) |
1346 | 1400 | return -1; |
1347 | 1401 | |
… |
… |
|
1420 | 1474 | |
1421 | 1475 | static int make_color_fgbg (SLCONST char *fg, SLCONST char *bg, SLtt_Char_Type *fgbg) |
1422 | 1476 | { |
1423 | | SLtt_Char_Type f = 0xFFFFFFFFU, b = 0xFFFFFFFFU; |
| 1477 | SLtt_Char_Type f = CHAR_INVALID, b = CHAR_INVALID; |
1424 | 1478 | SLCONST char *dfg, *dbg; |
1425 | 1479 | unsigned int i; |
1426 | 1480 | char bgbuf[16], fgbuf[16]; |
… |
… |
|
1464 | 1518 | } |
1465 | 1519 | } |
1466 | 1520 | |
1467 | | if ((f == 0xFFFFFFFFU) || (b == 0xFFFFFFFFU)) |
| 1521 | if ((f == CHAR_INVALID) || (b == CHAR_INVALID)) |
1468 | 1522 | return -1; |
1469 | 1523 | |
1470 | 1524 | *fgbg = fb_to_fgbg (f, b) | fattr | battr; |
… |
… |
|
1509 | 1563 | { |
1510 | 1564 | int bg0, fg0; |
1511 | 1565 | int unknown_attributes; |
| 1566 | char tmpbuf[32]; |
1512 | 1567 | |
1513 | 1568 | if (Worthless_Highlight) return; |
1514 | 1569 | if (fgbg == Current_Fgbg) return; |
… |
… |
|
1557 | 1612 | { |
1558 | 1613 | if (fg0 == SLSMG_COLOR_DEFAULT) |
1559 | 1614 | tt_write_string (Default_Color_Fg_Str); |
| 1615 | else if (fg0 & (1 << 24)) |
| 1616 | { |
| 1617 | sprintf (tmpbuf, Color_RGB_Fg_Str, |
| 1618 | (int) ((fg0 >> 16) & 0xFF), |
| 1619 | (int) ((fg0 >> 8) & 0xFF), |
| 1620 | (int) (fg0 & 0xFF)); |
| 1621 | tt_write_string (tmpbuf); |
| 1622 | } |
1560 | 1623 | else |
1561 | 1624 | tt_printf (Color_Fg_Str, COLOR_ARG(fg0, Is_Fg_BGR), 0); |
1562 | 1625 | } |
… |
… |
|
1566 | 1629 | { |
1567 | 1630 | if (bg0 == SLSMG_COLOR_DEFAULT) |
1568 | 1631 | tt_write_string (Default_Color_Bg_Str); |
| 1632 | else if (bg0 & (1 << 24)) |
| 1633 | { |
| 1634 | sprintf (tmpbuf, Color_RGB_Bg_Str, |
| 1635 | (int) ((bg0 >> 16) & 0xFF), |
| 1636 | (int) ((bg0 >> 8) & 0xFF), |
| 1637 | (int) (bg0 & 0xFF)); |
| 1638 | tt_write_string (tmpbuf); |
| 1639 | } |
1569 | 1640 | else |
1570 | 1641 | tt_printf (Color_Bg_Str, COLOR_ARG(bg0, Is_Bg_BGR), 0); |
1571 | 1642 | } |
… |
… |
|
1589 | 1660 | tt_write_string (Norm_Vid_Str); |
1590 | 1661 | } |
1591 | 1662 | else tt_write_string (Rev_Vid_Str); |
1592 | | Current_Fgbg = 0xFFFFFFFFU; |
| 1663 | Current_Fgbg = CHAR_INVALID; |
1593 | 1664 | return; |
1594 | 1665 | } |
1595 | 1666 | |
… |
… |
|
3028 | 3099 | SLtt_normal_video (); /* MSKermit requires this */ |
3029 | 3100 | tt_write_string(Norm_Vid_Str); |
3030 | 3101 | |
3031 | | Current_Fgbg = 0xFFFFFFFFU; |
| 3102 | Current_Fgbg = CHAR_INVALID; |
3032 | 3103 | SLtt_set_alt_char_set (0); |
3033 | 3104 | if (SLtt_Use_Ansi_Colors) |
3034 | 3105 | { |
… |
… |
|
3040 | 3111 | else tt_write_string ("\033[0m\033[m"); |
3041 | 3112 | } |
3042 | 3113 | else tt_write_string (Reset_Color_String); |
3043 | | Current_Fgbg = 0xFFFFFFFFU; |
| 3114 | Current_Fgbg = CHAR_INVALID; |
3044 | 3115 | } |
3045 | 3116 | SLtt_erase_line (); |
3046 | 3117 | SLtt_deinit_keypad (); |