Add strikethrough support
This commit is contained in:
@@ -123,6 +123,7 @@ void render() {
|
||||
uint32_t current_ul_color = 0;
|
||||
bool current_italic = false;
|
||||
bool current_bold = false;
|
||||
bool current_strikethrough = false;
|
||||
bool current_underline = false;
|
||||
std::lock_guard<std::mutex> lock(screen_mutex);
|
||||
std::string out;
|
||||
@@ -218,6 +219,11 @@ void render() {
|
||||
out += bold ? "\x1b[1m" : "\x1b[22m";
|
||||
current_bold = bold;
|
||||
}
|
||||
bool strikethrough = (new_cell.flags & CF_STRIKETHROUGH) != 0;
|
||||
if (strikethrough != current_strikethrough) {
|
||||
out += strikethrough ? "\x1b[9m" : "\x1b[29m";
|
||||
current_strikethrough = strikethrough;
|
||||
}
|
||||
bool underline = (new_cell.flags & CF_UNDERLINE) != 0;
|
||||
if (underline) {
|
||||
if (new_cell.ul_color != current_ul_color) {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "config.h"
|
||||
#include "io/ui.h"
|
||||
#include "ts/ts.h"
|
||||
|
||||
std::unordered_map<std::string, pcre2_code *> regex_cache;
|
||||
@@ -40,7 +41,7 @@ TSQuery *load_query(const char *query_path, TSSetBase *set) {
|
||||
int errornumber = 0;
|
||||
PCRE2_SIZE erroroffset = 0;
|
||||
pcre2_code *re = pcre2_compile(
|
||||
(PCRE2_SPTR) R"((@[A-Za-z0-9_.]+)|(;; \#[0-9a-fA-F]{6} \#[0-9a-fA-F]{6} [01] [01] [01] \d+)|(;; !(\w+)))",
|
||||
(PCRE2_SPTR) R"((@[A-Za-z0-9_.]+)|(;; \#[0-9a-fA-F]{6} \#[0-9a-fA-F]{6} [01] [01] [01] [01] \d+)|(;; !(\w+)))",
|
||||
PCRE2_ZERO_TERMINATED, 0, &errornumber, &erroroffset, nullptr);
|
||||
if (!re)
|
||||
return nullptr;
|
||||
@@ -84,9 +85,11 @@ TSQuery *load_query(const char *query_path, TSSetBase *set) {
|
||||
int bold = std::stoi(mct.substr(19, 1));
|
||||
int italic = std::stoi(mct.substr(21, 1));
|
||||
int underline = std::stoi(mct.substr(23, 1));
|
||||
c_hl->priority = std::stoi(mct.substr(25));
|
||||
int strike = std::stoi(mct.substr(25, 1));
|
||||
c_hl->priority = std::stoi(mct.substr(27));
|
||||
c_hl->flags = (bold ? CF_BOLD : 0) | (italic ? CF_ITALIC : 0) |
|
||||
(underline ? CF_UNDERLINE : 0);
|
||||
(underline ? CF_UNDERLINE : 0) |
|
||||
(strike ? CF_STRIKETHROUGH : 0);
|
||||
} else if (mct.substr(0, 4) == ";; !") {
|
||||
auto it = kLanguages.find(mct.substr(4));
|
||||
if (it != kLanguages.end())
|
||||
|
||||
Reference in New Issue
Block a user