Patch 8.2.4894
Problem: MS-Windows: not using italics.
Solution: Use italics. Simplify the code. (closes #10359)
Files: src/term.c
*** ../vim-8.2.4893/src/term.c 2022-05-05 20:46:41.407274630 +0100
--- src/term.c 2022-05-06 18:34:28.671785477 +0100
***************
*** 6605,6629 ****
# ifdef FEAT_TERMGUICOLORS
# define KSSIZE 20
! 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
};
! 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_CZR, "\033|0m", "\033|0m"}, // italic end
{(int)KS_US, "\033|4m", "\033|4m"}, // underscore
{(int)KS_UE, "\033|24m", "\033|24m"}, // underscore end
--- 6605,6635 ----
# ifdef FEAT_TERMGUICOLORS
# define KSSIZE 20
!
! 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 RGB mode
! char *vtp2; // code in 256color mode
! char buf[CMODE_LAST][KSSIZE]; // real buffer
};
! 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|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,6681 ****
{
# ifdef FEAT_TERMGUICOLORS
static int init_done = FALSE;
! static int curr_mode;
! struct ks_tbl_s *ks;
struct builtin_term *bt;
! int mode;
! enum
! {
! CMODEINDEX,
! CMODE24,
! CMODE256
! };
- // buffer initialization
if (!init_done)
{
for (ks = ks_tbl; ks->code != (int)KS_NAME; ks++)
--- 6670,6680 ----
{
# ifdef FEAT_TERMGUICOLORS
static int init_done = FALSE;
! static cmode_T curr_mode;
! struct ks_tbl_S *ks;
struct builtin_term *bt;
! cmode_T mode;
if (!init_done)
{
for (ks = ks_tbl; ks->code != (int)KS_NAME; ks++)
***************
*** 6683,6749 ****
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);
! STRNCPY(ks->arr, bt->bt_string, KSSIZE);
! bt->bt_string = &ks->arr[0];
}
}
init_done = TRUE;
! curr_mode = CMODEINDEX;
}
if (p_tgc)
! mode = CMODE24;
else if (t_colors >= 256)
! mode = CMODE256;
else
! mode = CMODEINDEX;
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);
! }
! }
! }
!
! curr_mode = mode;
! }
# endif
}
--- 6682,6717 ----
bt = find_first_tcap(DEFAULT_TERM, ks->code);
if (bt != NULL)
{
! // 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);
! bt->bt_string = ks->buf[CMODE_INDEXED];
}
}
init_done = TRUE;
! curr_mode = CMODE_INDEXED;
}
if (p_tgc)
! mode = CMODE_RGB;
else if (t_colors >= 256)
! mode = CMODE_256COL;
else
! 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)
! bt->bt_string = ks->buf[mode];
}
! curr_mode = mode;
# endif
}
*** ../vim-8.2.4893/src/version.c 2022-05-06 18:08:48.548683486 +0100
--- src/version.c 2022-05-06 18:38:11.399621201 +0100
***************
*** 748,749 ****
--- 748,751 ----
{ /* Add new patch number below this line */
+ /**/
+ 4894,
/**/
--
hundred-and-one symptoms of being an internet addict:
120. You ask a friend, "What's that big shiny thing?" He says, "It's the sun."
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/20220506173914.E3E591C03B1%40moolenaar.net.