Fix support for the Tencent QQPinyin IME (#19046)

This commit is contained in:
Leonard Hecker 2025-06-17 01:52:26 +02:00 committed by GitHub
parent f28bb42979
commit b47fdfc7e6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 24 additions and 12 deletions

View File

@ -24,8 +24,8 @@ dze
dzhe
Emacspeak
Fitt
FTCS
flac
FTCS
gantt
gfm
ghe
@ -61,8 +61,8 @@ Powerline
ptys
pwn
pwshw
QOL
qof
QOL
qps
quickfix
rclt
@ -82,6 +82,7 @@ stakeholders
subpage
sustainability
sxn
Tencent
TLDR
tonos
toolset

View File

@ -711,6 +711,16 @@ TextAttribute Implementation::_textAttributeFromAtom(TfGuidAtom atom) const
TF_DISPLAYATTRIBUTE da;
THROW_IF_FAILED(dai->GetAttributeInfo(&da));
// The Tencent QQPinyin IME creates TF_CT_COLORREF attributes with a color of 0x000000 (black).
// We respect their wish, which results in the preview text being invisible.
// (Note that sending this COLORREF is incorrect, and not a bug in our handling.)
//
// After some discussion, we realized that an IME which sets only one color but not
// the others is likely not properly tested anyway, so we reject those cases.
// After all, what behavior do we expect, if the IME sends e.g. foreground=blue,
// without knowing whether our terminal theme already uses a blue background?
if (da.crText.type == da.crBk.type && da.crText.type == da.crLine.type)
{
if (da.crText.type != TF_CT_NONE)
{
attr.SetForeground(_colorFromDisplayAttribute(da.crText));
@ -719,6 +729,11 @@ TextAttribute Implementation::_textAttributeFromAtom(TfGuidAtom atom) const
{
attr.SetBackground(_colorFromDisplayAttribute(da.crBk));
}
if (da.crLine.type != TF_CT_NONE)
{
attr.SetUnderlineColor(_colorFromDisplayAttribute(da.crLine));
}
}
if (da.lsStyle >= TF_LS_NONE && da.lsStyle <= TF_LS_SQUIGGLE)
{
static constexpr UnderlineStyle lut[] = {
@ -737,10 +752,6 @@ TextAttribute Implementation::_textAttributeFromAtom(TfGuidAtom atom) const
{
attr.SetUnderlineStyle(UnderlineStyle::DoublyUnderlined);
}
if (da.crLine.type != TF_CT_NONE)
{
attr.SetUnderlineColor(_colorFromDisplayAttribute(da.crLine));
}
return attr;
}