0
0
mirror of https://github.com/vim/vim.git synced 2025-09-30 04:44:14 -04:00

patch 8.2.4894: MS-Windows: not using italics

Problem:    MS-Windows: not using italics.
Solution:   Use italics.  Simplify the code. (closes #10359)
This commit is contained in:
LemonBoy
2022-05-06 18:38:41 +01:00
committed by Bram Moolenaar
parent 44433da534
commit 5a7b6dc23c
2 changed files with 35 additions and 65 deletions

View File

@@ -6605,25 +6605,31 @@ update_tcap(int attr)
# ifdef FEAT_TERMGUICOLORS
# define KSSIZE 20
struct ks_tbl_s
typedef enum
{
CMODE_INDEXED = 0, // Use cmd.exe 4bit palette.
CMODE_RGB, // Use 24bit RGB colors using VTP.
CMODE_256COL, // Emulate xterm's 256-color palette using VTP.
CMODE_LAST,
} cmode_T;
struct ks_tbl_S
{
int code; // value of KS_
char *vtp; // code in vtp mode
char *vtp2; // code in vtp2 mode
char buf[KSSIZE]; // save buffer in non-vtp mode
char vbuf[KSSIZE]; // save buffer in vtp mode
char v2buf[KSSIZE]; // save buffer in vtp2 mode
char arr[KSSIZE]; // real buffer
char *vtp; // code in RGB mode
char *vtp2; // code in 256color mode
char buf[CMODE_LAST][KSSIZE]; // real buffer
};
static struct ks_tbl_s ks_tbl[] =
static struct ks_tbl_S ks_tbl[] =
{
{(int)KS_ME, "\033|0m", "\033|0m"}, // normal
{(int)KS_MR, "\033|7m", "\033|7m"}, // reverse
{(int)KS_MD, "\033|1m", "\033|1m"}, // bold
{(int)KS_SO, "\033|91m", "\033|91m"}, // standout: bright red text
{(int)KS_SE, "\033|39m", "\033|39m"}, // standout end: default color
{(int)KS_CZH, "\033|95m", "\033|95m"}, // italic: bright magenta text
{(int)KS_CZH, "\033|3m", "\033|3m"}, // italic
{(int)KS_CZR, "\033|0m", "\033|0m"}, // italic end
{(int)KS_US, "\033|4m", "\033|4m"}, // underscore
{(int)KS_UE, "\033|24m", "\033|24m"}, // underscore end
@@ -6664,18 +6670,11 @@ swap_tcap(void)
{
# ifdef FEAT_TERMGUICOLORS
static int init_done = FALSE;
static int curr_mode;
struct ks_tbl_s *ks;
static cmode_T curr_mode;
struct ks_tbl_S *ks;
struct builtin_term *bt;
int mode;
enum
{
CMODEINDEX,
CMODE24,
CMODE256
};
cmode_T mode;
// buffer initialization
if (!init_done)
{
for (ks = ks_tbl; ks->code != (int)KS_NAME; ks++)
@@ -6683,67 +6682,36 @@ swap_tcap(void)
bt = find_first_tcap(DEFAULT_TERM, ks->code);
if (bt != NULL)
{
STRNCPY(ks->buf, bt->bt_string, KSSIZE);
STRNCPY(ks->vbuf, ks->vtp, KSSIZE);
STRNCPY(ks->v2buf, ks->vtp2, KSSIZE);
// Preserve the original value.
STRNCPY(ks->buf[CMODE_INDEXED], bt->bt_string, KSSIZE);
STRNCPY(ks->buf[CMODE_RGB], ks->vtp, KSSIZE);
STRNCPY(ks->buf[CMODE_256COL], ks->vtp2, KSSIZE);
STRNCPY(ks->arr, bt->bt_string, KSSIZE);
bt->bt_string = &ks->arr[0];
bt->bt_string = ks->buf[CMODE_INDEXED];
}
}
init_done = TRUE;
curr_mode = CMODEINDEX;
curr_mode = CMODE_INDEXED;
}
if (p_tgc)
mode = CMODE24;
mode = CMODE_RGB;
else if (t_colors >= 256)
mode = CMODE256;
mode = CMODE_256COL;
else
mode = CMODEINDEX;
mode = CMODE_INDEXED;
if (mode == curr_mode)
return;
for (ks = ks_tbl; ks->code != (int)KS_NAME; ks++)
{
bt = find_first_tcap(DEFAULT_TERM, ks->code);
if (bt != NULL)
{
switch (curr_mode)
{
case CMODEINDEX:
STRNCPY(&ks->buf[0], bt->bt_string, KSSIZE);
break;
case CMODE24:
STRNCPY(&ks->vbuf[0], bt->bt_string, KSSIZE);
break;
default:
STRNCPY(&ks->v2buf[0], bt->bt_string, KSSIZE);
}
}
}
if (mode != curr_mode)
{
for (ks = ks_tbl; ks->code != (int)KS_NAME; ks++)
{
bt = find_first_tcap(DEFAULT_TERM, ks->code);
if (bt != NULL)
{
switch (mode)
{
case CMODEINDEX:
STRNCPY(bt->bt_string, &ks->buf[0], KSSIZE);
break;
case CMODE24:
STRNCPY(bt->bt_string, &ks->vbuf[0], KSSIZE);
break;
default:
STRNCPY(bt->bt_string, &ks->v2buf[0], KSSIZE);
}
}
bt->bt_string = ks->buf[mode];
}
curr_mode = mode;
}
# endif
}

View File

@@ -746,6 +746,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
4894,
/**/
4893,
/**/