[misc] fix a few random issues

circleci-project-setup
Tim Stack 2 months ago
parent 3c4a93cca6
commit 45b7a6c33f

@ -163,3 +163,14 @@ lab_color::operator!=(const lab_color& rhs) const
{
return !(rhs == *this);
}
bool
lab_color::sufficient_contrast(const lab_color& other) const
{
if (std::abs(this->lc_l - other.lc_l) > 15) {
return true;
}
return (std::signbit(this->lc_a) != std::signbit(other.lc_a)
|| std::signbit(this->lc_b) != std::signbit(other.lc_b));
}

@ -65,6 +65,8 @@ struct lab_color {
double deltaE(const lab_color& other) const;
bool sufficient_contrast(const lab_color& other) const;
lab_color& operator=(const lab_color& other)
{
this->lc_l = other.lc_l;

@ -1226,7 +1226,7 @@ extract(*str*)
Automatically Parse and extract data from a string
**PRQL Name**: text.extract
**PRQL Name**: text.discover
**Parameters**
* **str\*** --- The string to parse

@ -875,6 +875,7 @@ listview_curses::set_top(vis_line_t top, bool suppress_flash)
this->lv_focused_overlay_selection = 0_vl;
if (this->lv_selectable) {
if (this->lv_selection < 0_vl) {
this->set_selection(top);
} else if (this->lv_selection < top) {
auto sel_diff = this->lv_selection - old_top;
this->set_selection(top + sel_diff);

@ -202,7 +202,7 @@ private:
const char* rc_quote_chars;
readline_highlighter_t rc_highlighter;
std::vector<readline_var> rc_vars;
splitter_func_t rc_splitter;
splitter_func_t rc_splitter{nullptr};
};
#endif

@ -898,6 +898,7 @@ static const typed_json_path_container<session_data_t> view_info_handlers = {
void
load_session()
{
log_info("BEGIN load_session");
load_time_bookmarks();
scan_sessions() | [](const auto pair) {
lnav_data.ld_session_load_time = pair.first.second;
@ -979,6 +980,8 @@ load_session()
lnav::events::publish(lnav_data.ld_db.in(),
lnav::events::session::loaded{});
log_info("END load_session");
}
static void

@ -1011,7 +1011,7 @@ string_extension_functions(struct FuncDef** basic_funcs,
help_text("extract",
"Automatically Parse and extract data from a string")
.sql_function()
.with_prql_path({"text", "extract"})
.with_prql_path({"text", "discover"})
.with_parameter({"str", "The string to parse"})
.with_tags({"string"})
.with_example({

@ -197,7 +197,7 @@ term_color_palette::term_color_palette(const char* name,
}
short
term_color_palette::match_color(const lab_color& to_match)
term_color_palette::match_color(const lab_color& to_match) const
{
double lowest = 1000.0;
short lowest_id = -1;
@ -221,7 +221,6 @@ term_color_palette::match_color(const lab_color& to_match)
}
namespace styling {
Result<color_unit, std::string>
color_unit::from_str(const string_fragment& sf)
{

@ -54,7 +54,7 @@ struct term_color {
struct term_color_palette {
term_color_palette(const char* name, const string_fragment& json);
short match_color(const lab_color& to_match);
short match_color(const lab_color& to_match) const;
std::vector<term_color> tc_palette;
};

@ -107,7 +107,8 @@
"color": "Yellow"
},
"breadcrumb": {
"color": "Teal"
"color": "Teal",
"bold": true
},
"table-border": {
"color": "#444"

@ -118,7 +118,8 @@
"color": "$cyan"
},
"breadcrumb": {
"color": "#99a"
"color": "#99a",
"bold": true
},
"table-border": {
"color": "#444"

@ -12,6 +12,7 @@
"cyan": "#34e2e2",
"green": "#8ae234",
"white": "#ffffff",
"orange": "#ef8c29",
"semantic_highlight_color": "semantic()"
},
"styles": {
@ -115,7 +116,8 @@
"color": "$yellow"
},
"breadcrumb": {
"color": "#99a"
"color": "#448",
"bold": true
},
"table-border": {
"color": "#444"

@ -116,7 +116,8 @@
"color": "#444"
},
"breadcrumb": {
"color": "#999"
"color": "#999",
"bold": true
},
"table-border": {
"color": "#444"

@ -115,7 +115,8 @@
"color": "$yellow"
},
"breadcrumb": {
"color": "#99a"
"color": "#2d5a80",
"bold": true
},
"table-border": {
"color": "#444"

@ -124,7 +124,8 @@
"color": "$yellow"
},
"breadcrumb": {
"color": "#99a"
"color": "#99a",
"bold": true
},
"table-border": {
"color": "#444"

@ -10,7 +10,7 @@
"base00": "#657b83",
"base0": "#839496",
"base1": "#93a1a1",
"base2": "#eee8d5",
"base2": "#ededb0",
"base3": "#fdf6e3",
"black": "#002b36",
"yellow": "#b58900",
@ -25,7 +25,6 @@
},
"styles": {
"identifier": {
"background-color": "$base3",
"color": "semantic()"
},
"text": {
@ -52,11 +51,15 @@
"bold": true
},
"cursor-line": {
"color": "$cyan",
"background-color": "$red",
"color": "$base0",
"background-color": "#fafa4a",
"bold": true,
"underline": true
},
"disabled-cursor-line": {
"color": "$cyan",
"background-color": "$yellow"
},
"adjusted-time": {
"color": "$magenta"
},
@ -71,7 +74,7 @@
},
"popup": {
"color": "$base00",
"background-color": "$base3"
"background-color": "$base2"
},
"scrollbar": {
"color": "$base3",
@ -103,8 +106,45 @@
"h6": {
"underline": true
},
"indent-guide": {
"hr": {
"color": "#444"
},
"hyperlink": {
"underline": true
},
"list-glyph": {
"color": "$yellow"
},
"breadcrumb": {
"color": "#99a",
"bold": true
},
"table-border": {
"color": "#444"
},
"table-header": {
"bold": true
},
"quote-border": {
"color": "#666",
"background-color": "#444"
},
"quoted-text": {
"background-color": "#444"
},
"footnote-border": {
"color": "$blue",
"background-color": "#444"
},
"footnote-text": {
"color": "#eee",
"background-color": "#444"
},
"snippet-border": {
"color": "$cyan"
},
"indent-guide": {
"color": "$base1"
}
},
"syntax-styles": {
@ -158,7 +198,12 @@
"status-styles": {
"title": {
"color": "$base2",
"background-color": "$base0",
"background-color": "$base00",
"bold": true
},
"disabled-title": {
"color": "$base2",
"background-color": "$base02",
"bold": true
},
"subtitle": {
@ -195,7 +240,7 @@
"background-color": "$base03"
},
"suggestion": {
"color": "$base03"
"color": "$base1"
}
},
"log-level-styles": {

@ -244,12 +244,13 @@ view_curses::mvwattrline(WINDOW* window,
auto& vc = view_colors::singleton();
auto text_role_attrs = vc.attrs_for_role(role_t::VCR_TEXT);
auto attrs = vc.attrs_for_role(base_role);
auto base_attrs = vc.attrs_for_role(base_role);
wmove(window, y, x);
wattr_set(window,
attrs.ta_attrs,
vc.ensure_color_pair(attrs.ta_fg_color, attrs.ta_bg_color),
nullptr);
wattr_set(
window,
base_attrs.ta_attrs,
vc.ensure_color_pair(base_attrs.ta_fg_color, base_attrs.ta_bg_color),
nullptr);
if (lr_bytes.lr_start < (int) full_line.size()) {
waddnstr(
window, &full_line.c_str()[lr_bytes.lr_start], lr_bytes.length());
@ -341,6 +342,7 @@ view_curses::mvwattrline(WINDOW* window,
}
if (attr_range.lr_start < attr_range.lr_end) {
auto attrs = text_attrs{};
nonstd::optional<char> graphic;
nonstd::optional<wchar_t> block_elem;
@ -427,6 +429,30 @@ view_curses::mvwattrline(WINDOW* window,
#endif
short cur_fg, cur_bg;
pair_content(cur_pair, &cur_fg, &cur_bg);
if (fg_color[lpc] != -1 && bg_color[lpc] == -1) {
const auto& fg_color_info
= view_colors::vc_active_palette->tc_palette[fg_color[lpc]];
const auto& bg_color_info
= view_colors::vc_active_palette
->tc_palette[base_attrs.ta_bg_color.value_or(0)];
if (!fg_color_info.xc_lab_color.sufficient_contrast(
bg_color_info.xc_lab_color))
{
auto adjusted_color = bg_color_info.xc_lab_color;
adjusted_color.lc_l -= 40.0;
auto new_bg = view_colors::vc_active_palette->match_color(
adjusted_color);
for (int lpc2 = lpc; lpc2 < line_width_chars; lpc2++) {
if (fg_color[lpc2] == fg_color[lpc] && bg_color[lpc2] == -1)
{
bg_color[lpc2] = new_bg;
}
}
}
}
if (fg_color[lpc] == -1) {
fg_color[lpc] = cur_fg;
}
@ -475,7 +501,7 @@ view_colors::view_colors() : vc_dyn_pairs(0)
bool view_colors::initialized = false;
static std::string COLOR_NAMES[] = {
static const std::string COLOR_NAMES[] = {
"black",
"red",
"green",

@ -303,7 +303,7 @@
"color": "Teal",
"background-color": "",
"underline": false,
"bold": false
"bold": true
},
"table-border": {
"color": "#444",
@ -899,7 +899,7 @@
"color": "#99a",
"background-color": "",
"underline": false,
"bold": false
"bold": true
},
"table-border": {
"color": "#444",
@ -1279,6 +1279,7 @@
"cyan": "#34e2e2",
"green": "#8ae234",
"magenta": "#ad7fa8",
"orange": "#ef8c29",
"red": "#ef2929",
"semantic_highlight_color": "semantic()",
"white": "#ffffff",
@ -1454,10 +1455,10 @@
"bold": false
},
"breadcrumb": {
"color": "#99a",
"color": "#448",
"background-color": "",
"underline": false,
"bold": false
"bold": true
},
"table-border": {
"color": "#444",
@ -2015,7 +2016,7 @@
"color": "#999",
"background-color": "",
"underline": false,
"bold": false
"bold": true
},
"table-border": {
"color": "#444",
@ -3129,10 +3130,10 @@
"bold": false
},
"breadcrumb": {
"color": "#99a",
"color": "#2d5a80",
"background-color": "",
"underline": false,
"bold": false
"bold": true
},
"table-border": {
"color": "#444",
@ -3699,7 +3700,7 @@
"color": "#99a",
"background-color": "",
"underline": false,
"bold": false
"bold": true
},
"table-border": {
"color": "#444",
@ -4080,7 +4081,7 @@
"base02": "#073642",
"base03": "#002b36",
"base1": "#93a1a1",
"base2": "#eee8d5",
"base2": "#ededb0",
"base3": "#fdf6e3",
"black": "#002b36",
"blue": "#268bd2",
@ -4096,7 +4097,7 @@
"styles": {
"identifier": {
"color": "semantic()",
"background-color": "$base3",
"background-color": "",
"underline": false,
"bold": false
},
@ -4143,14 +4144,14 @@
"bold": true
},
"cursor-line": {
"color": "$cyan",
"background-color": "$red",
"color": "$base0",
"background-color": "#fafa4a",
"underline": true,
"bold": true
},
"disabled-cursor-line": {
"color": "",
"background-color": "",
"color": "$cyan",
"background-color": "$yellow",
"underline": false,
"bold": false
},
@ -4186,7 +4187,7 @@
},
"popup": {
"color": "$base00",
"background-color": "$base3",
"background-color": "$base2",
"underline": false,
"bold": false
},
@ -4245,7 +4246,7 @@
"bold": false
},
"hr": {
"color": "",
"color": "#444",
"background-color": "",
"underline": false,
"bold": false
@ -4253,23 +4254,23 @@
"hyperlink": {
"color": "",
"background-color": "",
"underline": false,
"underline": true,
"bold": false
},
"list-glyph": {
"color": "",
"color": "$yellow",
"background-color": "",
"underline": false,
"bold": false
},
"breadcrumb": {
"color": "",
"color": "#99a",
"background-color": "",
"underline": false,
"bold": false
"bold": true
},
"table-border": {
"color": "",
"color": "#444",
"background-color": "",
"underline": false,
"bold": false
@ -4278,40 +4279,40 @@
"color": "",
"background-color": "",
"underline": false,
"bold": false
"bold": true
},
"quote-border": {
"color": "",
"background-color": "",
"color": "#666",
"background-color": "#444",
"underline": false,
"bold": false
},
"quoted-text": {
"color": "",
"background-color": "",
"background-color": "#444",
"underline": false,
"bold": false
},
"footnote-border": {
"color": "",
"background-color": "",
"color": "$blue",
"background-color": "#444",
"underline": false,
"bold": false
},
"footnote-text": {
"color": "",
"background-color": "",
"color": "#eee",
"background-color": "#444",
"underline": false,
"bold": false
},
"snippet-border": {
"color": "",
"color": "$cyan",
"background-color": "",
"underline": false,
"bold": false
},
"indent-guide": {
"color": "#444",
"color": "$base1",
"background-color": "",
"underline": false,
"bold": false
@ -4514,15 +4515,15 @@
},
"title": {
"color": "$base2",
"background-color": "$base0",
"background-color": "$base00",
"underline": false,
"bold": true
},
"disabled-title": {
"color": "",
"background-color": "",
"color": "$base2",
"background-color": "$base02",
"underline": false,
"bold": false
"bold": true
},
"subtitle": {
"color": "$base2",
@ -4543,7 +4544,7 @@
"bold": false
},
"suggestion": {
"color": "$base03",
"color": "$base1",
"background-color": "",
"underline": false,
"bold": false

Loading…
Cancel
Save