src: Support strikethrough faces
This commit is contained in:
parent
cbd0dc571b
commit
5d497dc46e
|
@ -40,6 +40,8 @@ following format:
|
||||||
dim
|
dim
|
||||||
*i*:::
|
*i*:::
|
||||||
italic
|
italic
|
||||||
|
*s*:::
|
||||||
|
strikethrough
|
||||||
*F*:::
|
*F*:::
|
||||||
final, override the previous face instead of merging with it,
|
final, override the previous face instead of merging with it,
|
||||||
and this face will only be replaced if another face with
|
and this face will only be replaced if another face with
|
||||||
|
|
23
src/face.hh
23
src/face.hh
|
@ -9,17 +9,18 @@ namespace Kakoune
|
||||||
|
|
||||||
enum class Attribute : int
|
enum class Attribute : int
|
||||||
{
|
{
|
||||||
Normal = 0,
|
Normal = 0,
|
||||||
Underline = 1 << 1,
|
Underline = 1 << 1,
|
||||||
Reverse = 1 << 2,
|
Reverse = 1 << 2,
|
||||||
Blink = 1 << 3,
|
Blink = 1 << 3,
|
||||||
Bold = 1 << 4,
|
Bold = 1 << 4,
|
||||||
Dim = 1 << 5,
|
Dim = 1 << 5,
|
||||||
Italic = 1 << 6,
|
Italic = 1 << 6,
|
||||||
FinalFg = 1 << 7,
|
Strikethrough = 1 << 7,
|
||||||
FinalBg = 1 << 8,
|
FinalFg = 1 << 8,
|
||||||
FinalAttr = 1 << 9,
|
FinalBg = 1 << 9,
|
||||||
Final = FinalFg | FinalBg | FinalAttr
|
FinalAttr = 1 << 10,
|
||||||
|
Final = FinalFg | FinalBg | FinalAttr
|
||||||
};
|
};
|
||||||
|
|
||||||
constexpr bool with_bit_ops(Meta::Type<Attribute>) { return true; }
|
constexpr bool with_bit_ops(Meta::Type<Attribute>) { return true; }
|
||||||
|
|
|
@ -43,6 +43,7 @@ static FaceRegistry::FaceSpec parse_face(StringView facedesc)
|
||||||
case 'B': face.attributes |= Attribute::Blink; break;
|
case 'B': face.attributes |= Attribute::Blink; break;
|
||||||
case 'd': face.attributes |= Attribute::Dim; break;
|
case 'd': face.attributes |= Attribute::Dim; break;
|
||||||
case 'i': face.attributes |= Attribute::Italic; break;
|
case 'i': face.attributes |= Attribute::Italic; break;
|
||||||
|
case 's': face.attributes |= Attribute::Strikethrough; break;
|
||||||
case 'f': face.attributes |= Attribute::FinalFg; break;
|
case 'f': face.attributes |= Attribute::FinalFg; break;
|
||||||
case 'g': face.attributes |= Attribute::FinalBg; break;
|
case 'g': face.attributes |= Attribute::FinalBg; break;
|
||||||
case 'a': face.attributes |= Attribute::FinalAttr; break;
|
case 'a': face.attributes |= Attribute::FinalAttr; break;
|
||||||
|
|
|
@ -46,6 +46,7 @@ String to_json(Attribute attributes)
|
||||||
{ Attribute::FinalFg, "final_fg" },
|
{ Attribute::FinalFg, "final_fg" },
|
||||||
{ Attribute::FinalBg, "final_bg" },
|
{ Attribute::FinalBg, "final_bg" },
|
||||||
{ Attribute::FinalAttr, "final_attr" },
|
{ Attribute::FinalAttr, "final_attr" },
|
||||||
|
{ Attribute::Strikethrough, "strikethrough" },
|
||||||
};
|
};
|
||||||
|
|
||||||
return "[" + join(attrs |
|
return "[" + join(attrs |
|
||||||
|
|
|
@ -183,7 +183,7 @@ void TerminalUI::Screen::set_face(const Face& face)
|
||||||
{
|
{
|
||||||
static constexpr int fg_table[]{ 39, 30, 31, 32, 33, 34, 35, 36, 37, 90, 91, 92, 93, 94, 95, 96, 97 };
|
static constexpr int fg_table[]{ 39, 30, 31, 32, 33, 34, 35, 36, 37, 90, 91, 92, 93, 94, 95, 96, 97 };
|
||||||
static constexpr int bg_table[]{ 49, 40, 41, 42, 43, 44, 45, 46, 47, 100, 101, 102, 103, 104, 105, 106, 107 };
|
static constexpr int bg_table[]{ 49, 40, 41, 42, 43, 44, 45, 46, 47, 100, 101, 102, 103, 104, 105, 106, 107 };
|
||||||
static constexpr int attr_table[]{ 0, 4, 7, 5, 1, 2, 3 };
|
static constexpr int attr_table[]{ 0, 4, 7, 5, 1, 2, 3, 9 };
|
||||||
|
|
||||||
auto set_color = [](bool fg, const Color& color, bool join) {
|
auto set_color = [](bool fg, const Color& color, bool join) {
|
||||||
if (join)
|
if (join)
|
||||||
|
@ -201,7 +201,7 @@ void TerminalUI::Screen::set_face(const Face& face)
|
||||||
bool join = false;
|
bool join = false;
|
||||||
if (face.attributes != m_active_face.attributes)
|
if (face.attributes != m_active_face.attributes)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < sizeof(attr_table) / sizeof(int); ++i)
|
for (int i = 0; i < std::size(attr_table); ++i)
|
||||||
{
|
{
|
||||||
if (face.attributes & (Attribute)(1 << i))
|
if (face.attributes & (Attribute)(1 << i))
|
||||||
printf(";%d", attr_table[i]);
|
printf(";%d", attr_table[i]);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user