[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); 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; double deltaE(const lab_color& other) const;
bool sufficient_contrast(const lab_color& other) const;
lab_color& operator=(const lab_color& other) lab_color& operator=(const lab_color& other)
{ {
this->lc_l = other.lc_l; this->lc_l = other.lc_l;

@ -1226,7 +1226,7 @@ extract(*str*)
Automatically Parse and extract data from a string Automatically Parse and extract data from a string
**PRQL Name**: text.extract **PRQL Name**: text.discover
**Parameters** **Parameters**
* **str\*** --- The string to parse * **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; this->lv_focused_overlay_selection = 0_vl;
if (this->lv_selectable) { if (this->lv_selectable) {
if (this->lv_selection < 0_vl) { if (this->lv_selection < 0_vl) {
this->set_selection(top);
} else if (this->lv_selection < top) { } else if (this->lv_selection < top) {
auto sel_diff = this->lv_selection - old_top; auto sel_diff = this->lv_selection - old_top;
this->set_selection(top + sel_diff); this->set_selection(top + sel_diff);

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

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

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

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

@ -54,7 +54,7 @@ struct term_color {
struct term_color_palette { struct term_color_palette {
term_color_palette(const char* name, const string_fragment& json); 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; std::vector<term_color> tc_palette;
}; };

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

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

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

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

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

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

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

@ -244,12 +244,13 @@ view_curses::mvwattrline(WINDOW* window,
auto& vc = view_colors::singleton(); auto& vc = view_colors::singleton();
auto text_role_attrs = vc.attrs_for_role(role_t::VCR_TEXT); 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); wmove(window, y, x);
wattr_set(window, wattr_set(
attrs.ta_attrs, window,
vc.ensure_color_pair(attrs.ta_fg_color, attrs.ta_bg_color), base_attrs.ta_attrs,
nullptr); vc.ensure_color_pair(base_attrs.ta_fg_color, base_attrs.ta_bg_color),
nullptr);
if (lr_bytes.lr_start < (int) full_line.size()) { if (lr_bytes.lr_start < (int) full_line.size()) {
waddnstr( waddnstr(
window, &full_line.c_str()[lr_bytes.lr_start], lr_bytes.length()); 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) { if (attr_range.lr_start < attr_range.lr_end) {
auto attrs = text_attrs{};
nonstd::optional<char> graphic; nonstd::optional<char> graphic;
nonstd::optional<wchar_t> block_elem; nonstd::optional<wchar_t> block_elem;
@ -427,6 +429,30 @@ view_curses::mvwattrline(WINDOW* window,
#endif #endif
short cur_fg, cur_bg; short cur_fg, cur_bg;
pair_content(cur_pair, &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) { if (fg_color[lpc] == -1) {
fg_color[lpc] = cur_fg; fg_color[lpc] = cur_fg;
} }
@ -475,7 +501,7 @@ view_colors::view_colors() : vc_dyn_pairs(0)
bool view_colors::initialized = false; bool view_colors::initialized = false;
static std::string COLOR_NAMES[] = { static const std::string COLOR_NAMES[] = {
"black", "black",
"red", "red",
"green", "green",

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

Loading…
Cancel
Save