diff --git a/NEWS.md b/NEWS.md index 3a29ac4a..e5abda4e 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,13 @@ +## lnav v0.12.1 + +Interface changes: +* Changed the breadcrumb bar styling to space things out + more and make the divisions between items clearer. +* The `ESC` key can now be used to exit the files/filters + configuration panel instead of `q`. This should make + it easier to avoid accidentally exiting lnav. +* Added some default help text for the command prompt. + ## lnav v0.12.0 Features: diff --git a/src/base/attr_line.hh b/src/base/attr_line.hh index d888c41f..94c155bd 100644 --- a/src/base/attr_line.hh +++ b/src/base/attr_line.hh @@ -510,6 +510,11 @@ public: return utf8_string_length(this->al_string).unwrapOr(this->length()); } + size_t column_width() const + { + return string_fragment::from_str(this->al_string).column_width(); + } + std::string get_substring(const line_range& lr) const { if (!lr.is_valid()) { diff --git a/src/base/intern_string.cc b/src/base/intern_string.cc index ef4dc849..c465fe22 100644 --- a/src/base/intern_string.cc +++ b/src/base/intern_string.cc @@ -358,12 +358,12 @@ uint32_t string_fragment::front_codepoint() const { size_t index = 0; - try { - return ww898::utf::utf8::read( - [this, &index]() { return this->data()[index++]; }); - } catch (const std::runtime_error& e) { + auto read_res = ww898::utf::utf8::read( + [this, &index]() { return this->data()[index++]; }); + if (read_res.isErr()) { return this->data()[0]; } + return read_res.unwrap(); } Result @@ -386,3 +386,22 @@ string_fragment::codepoint_to_byte_index(ssize_t cp_index) const return Ok(retval); } + +size_t +string_fragment::column_width() const +{ + auto index = this->sf_begin; + size_t retval = 0; + + while (index < this->sf_end) { + auto read_res = ww898::utf::utf8::read( + [this, &index]() { return this->sf_string[index++]; }); + if (read_res.isErr()) { + retval += 1; + } else { + retval += wcwidth(read_res.unwrap()); + } + } + + return retval; +} diff --git a/src/base/intern_string.hh b/src/base/intern_string.hh index 4315c7d9..c88f518d 100644 --- a/src/base/intern_string.hh +++ b/src/base/intern_string.hh @@ -142,6 +142,8 @@ struct string_fragment { Result utf8_length() const; + size_t column_width() const; + const char* data() const { return &this->sf_string[this->sf_begin]; } const unsigned char* udata() const diff --git a/src/breadcrumb_curses.cc b/src/breadcrumb_curses.cc index 5097d312..99a49dc8 100644 --- a/src/breadcrumb_curses.cc +++ b/src/breadcrumb_curses.cc @@ -66,8 +66,7 @@ breadcrumb_curses::do_update() } attr_line_t crumbs_line; for (const auto& crumb : crumbs) { - auto accum_width - = utf8_string_length(crumbs_line.get_string()).template unwrap(); + auto accum_width = crumbs_line.column_width(); auto elem_width = utf8_string_length(crumb.c_display_value.get_string()) .template unwrap(); auto is_selected = this->bc_selected_crumb @@ -75,7 +74,7 @@ breadcrumb_curses::do_update() if (is_selected && ((accum_width + elem_width) > width)) { crumbs_line.clear(); - crumbs_line.append("\u22ef\u276d"_breadcrumb); + crumbs_line.append("\u22ef\uff1a"_breadcrumb); accum_width = 2; } @@ -91,7 +90,7 @@ breadcrumb_curses::do_update() VC_STYLE.template value(text_attrs{A_REVERSE})); } crumb_index += 1; - crumbs_line.append("\u276d"_breadcrumb); + crumbs_line.append(" \uff1a"_breadcrumb); } line_range lr{0, static_cast(width)}; diff --git a/src/filter_status_source.cc b/src/filter_status_source.cc index 3dcc238b..0f8b4f63 100644 --- a/src/filter_status_source.cc +++ b/src/filter_status_source.cc @@ -37,7 +37,7 @@ #include "lnav.hh" static auto TOGGLE_MSG = "Press " ANSI_BOLD("TAB") " to edit "; -static auto EXIT_MSG = "Press " ANSI_BOLD("q") " to exit "; +static auto EXIT_MSG = "Press " ANSI_BOLD("ESC") " to exit "; static auto CREATE_HELP = ANSI_BOLD("i") "/" ANSI_BOLD("o") ": Create in/out"; static auto ENABLE_HELP = ANSI_BOLD("SPC") ": "; diff --git a/src/lnav.cc b/src/lnav.cc index 28bb7d19..2ee06531 100644 --- a/src/lnav.cc +++ b/src/lnav.cc @@ -854,7 +854,7 @@ handle_config_ui_key(int ch) } else { new_mode = ln_mode_t::FILES; } - } else if (ch == 'q') { + } else if (ch == 'q' || ch == KEY_ESCAPE) { new_mode = ln_mode_t::PAGING; } diff --git a/src/lnav_commands.cc b/src/lnav_commands.cc index 1860a6a0..ec5371b0 100644 --- a/src/lnav_commands.cc +++ b/src/lnav_commands.cc @@ -5490,6 +5490,8 @@ command_prompt(std::vector& args) rollback_lnav_config = lnav_config; lnav_data.ld_doc_status_source.set_title("Command Help"); + lnav_data.ld_doc_status_source.set_description(" See " ANSI_BOLD( + "https://docs.lnav.org/en/latest/commands.html") " for more details"); add_view_text_possibilities(lnav_data.ld_rl_view, ln_mode_t::COMMAND, "filter", @@ -5520,6 +5522,8 @@ command_prompt(std::vector& args) lnav_data.ld_rl_view->focus(ln_mode_t::COMMAND, cget(args, 2).value_or(":"), cget(args, 3).value_or("")); + + rl_set_help(); } static void @@ -5560,6 +5564,7 @@ search_prompt(std::vector& args) cget(args, 2).value_or("/"), cget(args, 3).value_or("")); lnav_data.ld_doc_status_source.set_title("Syntax Help"); + lnav_data.ld_doc_status_source.set_description(""); rl_set_help(); lnav_data.ld_bottom_source.set_prompt( "Search for: " @@ -5639,6 +5644,8 @@ sql_prompt(std::vector& args) cget(args, 3).value_or("")); lnav_data.ld_doc_status_source.set_title("Query Help"); + lnav_data.ld_doc_status_source.set_description("See " ANSI_BOLD( + "https://docs.lnav.org/en/latest/sqlext.html") " for more details"); rl_set_help(); lnav_data.ld_bottom_source.update_loading(0, 0); lnav_data.ld_status[LNS_BOTTOM].do_update(); diff --git a/src/readline_callbacks.cc b/src/readline_callbacks.cc index 6fa4d5a1..c4ce3870 100644 --- a/src/readline_callbacks.cc +++ b/src/readline_callbacks.cc @@ -53,12 +53,13 @@ using namespace lnav::roles::literals; #define ABORT_MSG "(Press " ANSI_BOLD("CTRL+]") " to abort)" -#define STR_HELPER(x) #x -#define STR(x) STR_HELPER(x) - -#define ANSI_RE(msg) ANSI_CSI "1;3" STR(COLOR_CYAN) "m" msg ANSI_NORM -#define ANSI_CLS(msg) ANSI_CSI "1;3" STR(COLOR_MAGENTA) "m" msg ANSI_NORM -#define ANSI_KW(msg) ANSI_CSI "3" STR(COLOR_BLUE) "m" msg ANSI_NORM +#define ANSI_RE(msg) \ + ANSI_CSI ANSI_BOLD_PARAM ";" ANSI_COLOR_PARAM(COLOR_CYAN) "m" msg ANSI_NORM +#define ANSI_CLS(msg) \ + ANSI_CSI ANSI_BOLD_PARAM \ + ";" ANSI_COLOR_PARAM(COLOR_MAGENTA) "m" msg ANSI_NORM +#define ANSI_KW(msg) \ + ANSI_CSI ANSI_BOLD_PARAM ";" ANSI_COLOR_PARAM(COLOR_BLUE) "m" msg ANSI_NORM #define ANSI_REV(msg) ANSI_CSI "7m" msg ANSI_NORM #define ANSI_STR(msg) ANSI_CSI "32m" msg ANSI_NORM @@ -97,6 +98,18 @@ const char *RE_EXAMPLE = " " ANSI_RE("(?-i)") "ABC matches " ANSI_STR("'ABC'") " and " ANSI_UNDERLINE("not") " " ANSI_STR("'abc'") ; +const char* CMD_HELP = + " " ANSI_KW(":goto") " Go to a line #, timestamp, etc...\n" + " " ANSI_KW(":filter-out") " Filter out lines that match a pattern\n" + " " ANSI_KW(":hide-lines-before") " Hide lines before a timestamp\n" + " " ANSI_KW(":open") " Open another file/directory\n"; + +const char* CMD_EXAMPLE = + ANSI_UNDERLINE("Examples") "\n" + " " ANSI_KW(":goto") " 123\n" + " " ANSI_KW(":filter-out") " spam\n" + " " ANSI_KW(":hide-lines-before") " here\n"; + const char *SQL_HELP = " " ANSI_KW("SELECT") " Select rows from a table " " " ANSI_KW("DELETE") " Delete rows from a table\n" @@ -127,7 +140,7 @@ rl_set_help() break; } case ln_mode_t::SQL: { - textview_curses& log_view = lnav_data.ld_views[LNV_LOG]; + auto& log_view = lnav_data.ld_views[LNV_LOG]; auto* lss = (logfile_sub_source*) log_view.get_sub_source(); attr_line_t example_al; @@ -145,6 +158,11 @@ rl_set_help() lnav_data.ld_example_source.replace_with(example_al); break; } + case ln_mode_t::COMMAND: { + lnav_data.ld_doc_source.replace_with(CMD_HELP); + lnav_data.ld_example_source.replace_with(CMD_EXAMPLE); + break; + } default: break; } @@ -309,8 +327,8 @@ rl_change(readline_curses* rc) iter = lnav_commands.find(args[0]); } if (iter == lnav_commands.end()) { - lnav_data.ld_doc_source.clear(); - lnav_data.ld_example_source.clear(); + lnav_data.ld_doc_source.replace_with(CMD_HELP); + lnav_data.ld_example_source.replace_with(CMD_EXAMPLE); lnav_data.ld_preview_source.clear(); lnav_data.ld_preview_status_source.get_description() .set_cylon(false) diff --git a/src/themes/monocai.json b/src/themes/monocai.json index e784d60c..a87bbd42 100644 --- a/src/themes/monocai.json +++ b/src/themes/monocai.json @@ -12,6 +12,7 @@ "magenta": "#ae81ff", "cyan": "#66d9ee", "white": "#808080", + "orange": "#fc9867", "semantic_highlight_color": "semantic()" }, "styles": { @@ -115,7 +116,8 @@ "color": "$yellow" }, "breadcrumb": { - "color": "#99a" + "color": "$orange", + "bold": true }, "table-border": { "color": "#444" diff --git a/src/view_curses.cc b/src/view_curses.cc index 9922b221..b4a60f97 100644 --- a/src/view_curses.cc +++ b/src/view_curses.cc @@ -143,7 +143,7 @@ view_curses::awaiting_user_input() size_t view_curses::mvwattrline(WINDOW* window, int y, - int x, + const int x, attr_line_t& al, const struct line_range& lr_chars, role_t base_role) @@ -157,11 +157,6 @@ view_curses::mvwattrline(WINDOW* window, auto line_width_chars = lr_chars.length(); std::string expanded_line; - - short* fg_color = (short*) alloca(line_width_chars * sizeof(short)); - bool has_fg = false; - short* bg_color = (short*) alloca(line_width_chars * sizeof(short)); - bool has_bg = false; line_range lr_bytes; int char_index = 0; @@ -263,6 +258,13 @@ view_curses::mvwattrline(WINDOW* window, whline(window, ' ', lr_chars.lr_end - char_index); } + cchar_t row_ch[line_width_chars + 1]; + short fg_color[line_width_chars + 1]; + short bg_color[line_width_chars + 1]; + memset(fg_color, -1, sizeof(fg_color)); + memset(bg_color, -1, sizeof(bg_color)); + + mvwin_wchnstr(window, y, x, row_ch, line_width_chars); std::stable_sort(sa.begin(), sa.end()); for (auto iter = sa.cbegin(); iter != sa.cend(); ++iter) { auto attr_range = iter->sa_range; @@ -313,9 +315,6 @@ view_curses::mvwattrline(WINDOW* window, = std::min(line_width_chars, attr_range.lr_end - lr_chars.lr_start); if (iter->sa_type == &VC_FOREGROUND) { - if (!has_fg) { - memset(fg_color, -1, line_width_chars * sizeof(short)); - } short attr_fg = iter->sa_value.get(); if (attr_fg == view_colors::MATCH_COLOR_SEMANTIC) { attr_fg = vc.color_for_ident(al.to_string_fragment(iter)) @@ -326,14 +325,10 @@ view_curses::mvwattrline(WINDOW* window, std::fill(&fg_color[attr_range.lr_start], &fg_color[attr_range.lr_end], attr_fg); - has_fg = true; continue; } if (iter->sa_type == &VC_BACKGROUND) { - if (!has_bg) { - memset(bg_color, -1, line_width_chars * sizeof(short)); - } short attr_bg = iter->sa_value.get(); if (attr_bg == view_colors::MATCH_COLOR_SEMANTIC) { attr_bg = vc.color_for_ident(al.to_string_fragment(iter)) @@ -342,12 +337,10 @@ view_curses::mvwattrline(WINDOW* window, std::fill(bg_color + attr_range.lr_start, bg_color + attr_range.lr_end, attr_bg); - has_bg = true; continue; } if (attr_range.lr_start < attr_range.lr_end) { - int awidth = attr_range.length(); nonstd::optional graphic; nonstd::optional block_elem; @@ -373,11 +366,6 @@ view_curses::mvwattrline(WINDOW* window, } if (graphic || block_elem || !attrs.empty()) { - int x_pos = x + attr_range.lr_start; - int ch_width = std::min( - awidth, (line_width_chars - attr_range.lr_start)); - cchar_t row_ch[ch_width + 1]; - if (attrs.ta_attrs & (A_LEFT | A_RIGHT)) { if (attrs.ta_attrs & A_LEFT) { attrs.ta_fg_color @@ -391,26 +379,20 @@ view_curses::mvwattrline(WINDOW* window, } if (attrs.ta_fg_color) { - if (!has_fg) { - memset(fg_color, -1, line_width_chars * sizeof(short)); - } std::fill(&fg_color[attr_range.lr_start], &fg_color[attr_range.lr_end], attrs.ta_fg_color.value()); - has_fg = true; } if (attrs.ta_bg_color) { - if (!has_bg) { - memset(bg_color, -1, line_width_chars * sizeof(short)); - } std::fill(&bg_color[attr_range.lr_start], &bg_color[attr_range.lr_end], attrs.ta_bg_color.value()); - has_bg = true; } - mvwin_wchnstr(window, y, x_pos, row_ch, ch_width); - for (int lpc = 0; lpc < ch_width; lpc++) { + for (int lpc = attr_range.lr_start; + lpc < attr_range.lr_end && lpc < line_width_chars; + lpc++) + { bool clear_rev = false; if (graphic) { @@ -430,52 +412,38 @@ view_curses::mvwattrline(WINDOW* window, row_ch[lpc].attr &= ~A_REVERSE; } } - mvwadd_wchnstr(window, y, x_pos, row_ch, ch_width); } } } - if (has_fg || has_bg) { - if (!has_fg) { - memset(fg_color, -1, line_width_chars * sizeof(short)); - } - if (!has_bg) { - memset(bg_color, -1, line_width_chars * sizeof(short)); + for (int lpc = 0; lpc < line_width_chars; lpc++) { + if (fg_color[lpc] == -1 && bg_color[lpc] == -1) { + continue; } - - int ch_width = lr_chars.length(); - cchar_t row_ch[ch_width + 1]; - - mvwin_wchnstr(window, y, x, row_ch, ch_width); - for (int lpc = 0; lpc < ch_width; lpc++) { - if (fg_color[lpc] == -1 && bg_color[lpc] == -1) { - continue; - } #ifdef NCURSES_EXT_COLORS - auto cur_pair = row_ch[lpc].ext_color; + auto cur_pair = row_ch[lpc].ext_color; #else - auto cur_pair = PAIR_NUMBER(row_ch[lpc].attr); + auto cur_pair = PAIR_NUMBER(row_ch[lpc].attr); #endif - short cur_fg, cur_bg; - pair_content(cur_pair, &cur_fg, &cur_bg); - if (fg_color[lpc] == -1) { - fg_color[lpc] = cur_fg; - } - if (bg_color[lpc] == -1) { - bg_color[lpc] = cur_bg; - } + short cur_fg, cur_bg; + pair_content(cur_pair, &cur_fg, &cur_bg); + if (fg_color[lpc] == -1) { + fg_color[lpc] = cur_fg; + } + if (bg_color[lpc] == -1) { + bg_color[lpc] = cur_bg; + } - int color_pair = vc.ensure_color_pair(fg_color[lpc], bg_color[lpc]); + int color_pair = vc.ensure_color_pair(fg_color[lpc], bg_color[lpc]); - row_ch[lpc].attr = row_ch[lpc].attr & ~A_COLOR; + row_ch[lpc].attr = row_ch[lpc].attr & ~A_COLOR; #ifdef NCURSES_EXT_COLORS - row_ch[lpc].ext_color = color_pair; + row_ch[lpc].ext_color = color_pair; #else - row_ch[lpc].attr |= COLOR_PAIR(color_pair); + row_ch[lpc].attr |= COLOR_PAIR(color_pair); #endif - } - mvwadd_wchnstr(window, y, x, row_ch, ch_width); } + mvwadd_wchnstr(window, y, x, row_ch, line_width_chars); return retval; } diff --git a/src/ww898/cp_utf8.hpp b/src/ww898/cp_utf8.hpp index 8eaa1333..3ee1ecf3 100644 --- a/src/ww898/cp_utf8.hpp +++ b/src/ww898/cp_utf8.hpp @@ -1,18 +1,18 @@ /* * MIT License - * + * * Copyright (c) 2017-2019 Mikhail Pilin - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -25,8 +25,8 @@ #pragma once #include -#include #include +#include #include "base/result.h" @@ -40,8 +40,7 @@ namespace utf { // 1111_0xxx 10xx_xxxx 10xx_xxxx 10xx_xxxx // 1111_10xx 10xx_xxxx 10xx_xxxx 10xx_xxxx 10xx_xxxx // 1111_110x 10xx_xxxx 10xx_xxxx 10xx_xxxx 10xx_xxxx 10xx_xxxx -struct utf8 final -{ +struct utf8 final { static size_t const max_unicode_symbol_size = 4; static size_t const max_supported_symbol_size = 6; @@ -50,26 +49,29 @@ struct utf8 final using char_type = uint8_t; template - static Result char_size(PeekFn && peek_fn) + static Result char_size(PeekFn&& peek_fn) { - const std::pair peek_res = std::forward(peek_fn)(); + const std::pair peek_res + = std::forward(peek_fn)(); const auto ch0 = peek_res.first; const auto remaining = peek_res.second; size_t retval = 0; - if (ch0 < 0x80) { // 0xxx_xxxx + if (ch0 < 0x80) { // 0xxx_xxxx retval = 1; } else if (ch0 < 0xC0) { return Err("The utf8 first char in sequence is incorrect"); - } else if (ch0 < 0xE0) { // 110x_xxxx 10xx_xxxx + } else if (ch0 < 0xE0) { // 110x_xxxx 10xx_xxxx retval = 2; - } else if (ch0 < 0xF0) { // 1110_xxxx 10xx_xxxx 10xx_xxxx + } else if (ch0 < 0xF0) { // 1110_xxxx 10xx_xxxx 10xx_xxxx retval = 3; - } else if (ch0 < 0xF8) { // 1111_0xxx 10xx_xxxx 10xx_xxxx 10xx_xxxx + } else if (ch0 < 0xF8) { // 1111_0xxx 10xx_xxxx 10xx_xxxx 10xx_xxxx retval = 4; - } else if (ch0 < 0xFC) { // 1111_10xx 10xx_xxxx 10xx_xxxx 10xx_xxxx 10xx_xxxx + } else if (ch0 < 0xFC) + { // 1111_10xx 10xx_xxxx 10xx_xxxx 10xx_xxxx 10xx_xxxx retval = 5; - } else if (ch0 < 0xFE) { // 1111_110x 10xx_xxxx 10xx_xxxx 10xx_xxxx 10xx_xxxx 10xx_xxxx + } else if (ch0 < 0xFE) + { // 1111_110x 10xx_xxxx 10xx_xxxx 10xx_xxxx 10xx_xxxx 10xx_xxxx retval = 6; } else { return Err("The utf8 first char in sequence is incorrect"); @@ -81,91 +83,130 @@ struct utf8 final } template - static uint32_t read(ReadFn && read_fn) + static Result read(ReadFn&& read_fn) { char_type const ch0 = read_fn(); - if (ch0 < 0x80) // 0xxx_xxxx - return ch0; + if (ch0 < 0x80) // 0xxx_xxxx + return Ok((uint32_t) ch0); if (ch0 < 0xC0) - throw std::runtime_error("The utf8 first char in sequence is incorrect"); - if (ch0 < 0xE0) // 110x_xxxx 10xx_xxxx + throw std::runtime_error( + "The utf8 first char in sequence is incorrect"); + if (ch0 < 0xE0) // 110x_xxxx 10xx_xxxx { - char_type const ch1 = read_fn(); if (ch1 >> 6 != 2) goto _err; - return (ch0 << 6) + ch1 - 0x3080; + char_type const ch1 = read_fn(); + if (ch1 >> 6 != 2) + goto _err; + return Ok((((uint32_t) ch0) << 6) + ch1 - 0x3080); } - if (ch0 < 0xF0) // 1110_xxxx 10xx_xxxx 10xx_xxxx + if (ch0 < 0xF0) // 1110_xxxx 10xx_xxxx 10xx_xxxx { - char_type const ch1 = read_fn(); if (ch1 >> 6 != 2) goto _err; - char_type const ch2 = read_fn(); if (ch2 >> 6 != 2) goto _err; - return (ch0 << 12) + (ch1 << 6) + ch2 - 0xE2080; + char_type const ch1 = read_fn(); + if (ch1 >> 6 != 2) + goto _err; + char_type const ch2 = read_fn(); + if (ch2 >> 6 != 2) + goto _err; + return Ok((((uint32_t) ch0) << 12) + (ch1 << 6) + ch2 - 0xE2080); } - if (ch0 < 0xF8) // 1111_0xxx 10xx_xxxx 10xx_xxxx 10xx_xxxx + if (ch0 < 0xF8) // 1111_0xxx 10xx_xxxx 10xx_xxxx 10xx_xxxx { - char_type const ch1 = read_fn(); if (ch1 >> 6 != 2) goto _err; - char_type const ch2 = read_fn(); if (ch2 >> 6 != 2) goto _err; - char_type const ch3 = read_fn(); if (ch3 >> 6 != 2) goto _err; - return (ch0 << 18) + (ch1 << 12) + (ch2 << 6) + ch3 - 0x3C82080; + char_type const ch1 = read_fn(); + if (ch1 >> 6 != 2) + goto _err; + char_type const ch2 = read_fn(); + if (ch2 >> 6 != 2) + goto _err; + char_type const ch3 = read_fn(); + if (ch3 >> 6 != 2) + goto _err; + return Ok((((uint32_t) ch0) << 18) + (ch1 << 12) + (ch2 << 6) + ch3 + - 0x3C82080); } - if (ch0 < 0xFC) // 1111_10xx 10xx_xxxx 10xx_xxxx 10xx_xxxx 10xx_xxxx + if (ch0 < 0xFC) // 1111_10xx 10xx_xxxx 10xx_xxxx 10xx_xxxx 10xx_xxxx { - char_type const ch1 = read_fn(); if (ch1 >> 6 != 2) goto _err; - char_type const ch2 = read_fn(); if (ch2 >> 6 != 2) goto _err; - char_type const ch3 = read_fn(); if (ch3 >> 6 != 2) goto _err; - char_type const ch4 = read_fn(); if (ch4 >> 6 != 2) goto _err; - return (ch0 << 24) + (ch1 << 18) + (ch2 << 12) + (ch3 << 6) + ch4 - 0xFA082080; + char_type const ch1 = read_fn(); + if (ch1 >> 6 != 2) + goto _err; + char_type const ch2 = read_fn(); + if (ch2 >> 6 != 2) + goto _err; + char_type const ch3 = read_fn(); + if (ch3 >> 6 != 2) + goto _err; + char_type const ch4 = read_fn(); + if (ch4 >> 6 != 2) + goto _err; + return Ok((ch0 << 24) + (ch1 << 18) + (ch2 << 12) + (ch3 << 6) + ch4 + - 0xFA082080); } - if (ch0 < 0xFE) // 1111_110x 10xx_xxxx 10xx_xxxx 10xx_xxxx 10xx_xxxx 10xx_xxxx + if (ch0 < 0xFE) // 1111_110x 10xx_xxxx 10xx_xxxx 10xx_xxxx 10xx_xxxx + // 10xx_xxxx { - char_type const ch1 = read_fn(); if (ch1 >> 6 != 2) goto _err; - char_type const ch2 = read_fn(); if (ch2 >> 6 != 2) goto _err; - char_type const ch3 = read_fn(); if (ch3 >> 6 != 2) goto _err; - char_type const ch4 = read_fn(); if (ch4 >> 6 != 2) goto _err; - char_type const ch5 = read_fn(); if (ch5 >> 6 != 2) goto _err; - return (ch0 << 30) + (ch1 << 24) + (ch2 << 18) + (ch3 << 12) + (ch4 << 6) + ch5 - 0x82082080; + char_type const ch1 = read_fn(); + if (ch1 >> 6 != 2) + goto _err; + char_type const ch2 = read_fn(); + if (ch2 >> 6 != 2) + goto _err; + char_type const ch3 = read_fn(); + if (ch3 >> 6 != 2) + goto _err; + char_type const ch4 = read_fn(); + if (ch4 >> 6 != 2) + goto _err; + char_type const ch5 = read_fn(); + if (ch5 >> 6 != 2) + goto _err; + return Ok((ch0 << 30) + (ch1 << 24) + (ch2 << 18) + (ch3 << 12) + + (ch4 << 6) + ch5 - 0x82082080); } - throw std::runtime_error("The utf8 first char in sequence is incorrect"); - _err: throw std::runtime_error("The utf8 slave char in sequence is incorrect"); + return Err("The utf8 first char in sequence is incorrect"); + _err: + return Err("The utf8 slave char in sequence is incorrect"); } template - static void write(uint32_t const cp, WriteFn && write_fn) + static void write(uint32_t const cp, WriteFn&& write_fn) { - if (cp < 0x80) // 0xxx_xxxx + if (cp < 0x80) // 0xxx_xxxx write_fn(static_cast(cp)); - else if (cp < 0x800) // 110x_xxxx 10xx_xxxx + else if (cp < 0x800) // 110x_xxxx 10xx_xxxx { - write_fn(static_cast(0xC0 | cp >> 6)); + write_fn(static_cast(0xC0 | cp >> 6)); goto _1; - } - else if (cp < 0x10000) // 1110_xxxx 10xx_xxxx 10xx_xxxx + } else if (cp < 0x10000) // 1110_xxxx 10xx_xxxx 10xx_xxxx { write_fn(static_cast(0xE0 | cp >> 12)); goto _2; - } - else if (cp < 0x200000) // 1111_0xxx 10xx_xxxx 10xx_xxxx 10xx_xxxx + } else if (cp < 0x200000) // 1111_0xxx 10xx_xxxx 10xx_xxxx 10xx_xxxx { write_fn(static_cast(0xF0 | cp >> 18)); goto _3; - } - else if (cp < 0x4000000) // 1111_10xx 10xx_xxxx 10xx_xxxx 10xx_xxxx 10xx_xxxx + } else if (cp < 0x4000000) // 1111_10xx 10xx_xxxx 10xx_xxxx 10xx_xxxx + // 10xx_xxxx { write_fn(static_cast(0xF8 | cp >> 24)); goto _4; - } - else if (cp < 0x80000000) // 1111_110x 10xx_xxxx 10xx_xxxx 10xx_xxxx 10xx_xxxx 10xx_xxxx + } else if (cp < 0x80000000) // 1111_110x 10xx_xxxx 10xx_xxxx 10xx_xxxx + // 10xx_xxxx 10xx_xxxx { write_fn(static_cast(0xFC | cp >> 30)); goto _5; - } - else + } else throw std::runtime_error("Tool large UTF8 code point"); return; - _5: write_fn(static_cast(0x80 | (cp >> 24 & 0x3F))); - _4: write_fn(static_cast(0x80 | (cp >> 18 & 0x3F))); - _3: write_fn(static_cast(0x80 | (cp >> 12 & 0x3F))); - _2: write_fn(static_cast(0x80 | (cp >> 6 & 0x3F))); - _1: write_fn(static_cast(0x80 | (cp & 0x3F))); + _5: + write_fn(static_cast(0x80 | (cp >> 24 & 0x3F))); + _4: + write_fn(static_cast(0x80 | (cp >> 18 & 0x3F))); + _3: + write_fn(static_cast(0x80 | (cp >> 12 & 0x3F))); + _2: + write_fn(static_cast(0x80 | (cp >> 6 & 0x3F))); + _1: + write_fn(static_cast(0x80 | (cp & 0x3F))); } }; -}} +} // namespace utf +} // namespace ww898 diff --git a/test/expected/test_cli.sh_0b3639753916f71254e8c9cce4ebb8bfd9978d3e.out b/test/expected/test_cli.sh_0b3639753916f71254e8c9cce4ebb8bfd9978d3e.out index 6aa2ff5a..6af10341 100644 --- a/test/expected/test_cli.sh_0b3639753916f71254e8c9cce4ebb8bfd9978d3e.out +++ b/test/expected/test_cli.sh_0b3639753916f71254e8c9cce4ebb8bfd9978d3e.out @@ -2371,6 +2371,7 @@ "cyan": "#66d9ee", "green": "#a7e22e", "magenta": "#ae81ff", + "orange": "#fc9867", "red": "#f92772", "semantic_highlight_color": "semantic()", "white": "#808080", @@ -2546,10 +2547,10 @@ "bold": false }, "breadcrumb": { - "color": "#99a", + "color": "$orange", "background-color": "", "underline": false, - "bold": false + "bold": true }, "table-border": { "color": "#444", diff --git a/test/expected/test_cli.sh_cc06341dd560f927512e92c7c0985ed8b25827ae.out b/test/expected/test_cli.sh_cc06341dd560f927512e92c7c0985ed8b25827ae.out index 753f84d5..ef835bb0 100644 --- a/test/expected/test_cli.sh_cc06341dd560f927512e92c7c0985ed8b25827ae.out +++ b/test/expected/test_cli.sh_cc06341dd560f927512e92c7c0985ed8b25827ae.out @@ -655,130 +655,132 @@ /ui/theme-defs/grayscale/vars/red -> grayscale.json:8 /ui/theme-defs/grayscale/vars/white -> grayscale.json:14 /ui/theme-defs/grayscale/vars/yellow -> grayscale.json:10 -/ui/theme-defs/monocai/log-level-styles/critical/color -> monocai.json:292 -/ui/theme-defs/monocai/log-level-styles/error/color -> monocai.json:289 -/ui/theme-defs/monocai/log-level-styles/fatal/color -> monocai.json:295 -/ui/theme-defs/monocai/log-level-styles/warning/color -> monocai.json:286 -/ui/theme-defs/monocai/status-styles/active/background-color -> monocai.json:273 -/ui/theme-defs/monocai/status-styles/active/color -> monocai.json:272 -/ui/theme-defs/monocai/status-styles/alert/background-color -> monocai.json:269 -/ui/theme-defs/monocai/status-styles/alert/color -> monocai.json:268 -/ui/theme-defs/monocai/status-styles/disabled-title/background-color -> monocai.json:233 -/ui/theme-defs/monocai/status-styles/disabled-title/bold -> monocai.json:234 -/ui/theme-defs/monocai/status-styles/disabled-title/color -> monocai.json:232 -/ui/theme-defs/monocai/status-styles/hotkey/color -> monocai.json:256 -/ui/theme-defs/monocai/status-styles/hotkey/underline -> monocai.json:257 -/ui/theme-defs/monocai/status-styles/inactive-alert/background-color -> monocai.json:281 -/ui/theme-defs/monocai/status-styles/inactive-alert/color -> monocai.json:280 -/ui/theme-defs/monocai/status-styles/inactive/background-color -> monocai.json:277 -/ui/theme-defs/monocai/status-styles/inactive/color -> monocai.json:276 -/ui/theme-defs/monocai/status-styles/info/background-color -> monocai.json:248 -/ui/theme-defs/monocai/status-styles/info/color -> monocai.json:247 -/ui/theme-defs/monocai/status-styles/subtitle/background-color -> monocai.json:243 -/ui/theme-defs/monocai/status-styles/subtitle/bold -> monocai.json:244 -/ui/theme-defs/monocai/status-styles/subtitle/color -> monocai.json:242 -/ui/theme-defs/monocai/status-styles/text/background-color -> monocai.json:261 -/ui/theme-defs/monocai/status-styles/text/color -> monocai.json:260 -/ui/theme-defs/monocai/status-styles/title-hotkey/background-color -> monocai.json:252 -/ui/theme-defs/monocai/status-styles/title-hotkey/color -> monocai.json:251 -/ui/theme-defs/monocai/status-styles/title-hotkey/underline -> monocai.json:253 -/ui/theme-defs/monocai/status-styles/title/background-color -> monocai.json:238 -/ui/theme-defs/monocai/status-styles/title/bold -> monocai.json:239 -/ui/theme-defs/monocai/status-styles/title/color -> monocai.json:237 -/ui/theme-defs/monocai/status-styles/warn/background-color -> monocai.json:265 -/ui/theme-defs/monocai/status-styles/warn/color -> monocai.json:264 -/ui/theme-defs/monocai/styles/adjusted-time/color -> monocai.json:58 -/ui/theme-defs/monocai/styles/alt-text/background-color -> monocai.json:26 -/ui/theme-defs/monocai/styles/breadcrumb/color -> monocai.json:118 -/ui/theme-defs/monocai/styles/cursor-line/background-color -> monocai.json:50 -/ui/theme-defs/monocai/styles/cursor-line/bold -> monocai.json:51 -/ui/theme-defs/monocai/styles/cursor-line/color -> monocai.json:49 -/ui/theme-defs/monocai/styles/disabled-cursor-line/background-color -> monocai.json:55 -/ui/theme-defs/monocai/styles/disabled-cursor-line/color -> monocai.json:54 -/ui/theme-defs/monocai/styles/disabled-focused/background-color -> monocai.json:78 -/ui/theme-defs/monocai/styles/disabled-focused/color -> monocai.json:77 -/ui/theme-defs/monocai/styles/error/bold -> monocai.json:38 -/ui/theme-defs/monocai/styles/error/color -> monocai.json:37 -/ui/theme-defs/monocai/styles/file-offset/color -> monocai.json:67 -/ui/theme-defs/monocai/styles/focused/background-color -> monocai.json:74 -/ui/theme-defs/monocai/styles/focused/color -> monocai.json:73 -/ui/theme-defs/monocai/styles/footnote-border/background-color -> monocai.json:135 -/ui/theme-defs/monocai/styles/footnote-border/color -> monocai.json:134 -/ui/theme-defs/monocai/styles/footnote-text/background-color -> monocai.json:139 -/ui/theme-defs/monocai/styles/footnote-text/color -> monocai.json:138 -/ui/theme-defs/monocai/styles/h1/bold -> monocai.json:90 -/ui/theme-defs/monocai/styles/h1/color -> monocai.json:89 -/ui/theme-defs/monocai/styles/h2/color -> monocai.json:93 -/ui/theme-defs/monocai/styles/h2/underline -> monocai.json:94 -/ui/theme-defs/monocai/styles/h3/color -> monocai.json:97 -/ui/theme-defs/monocai/styles/h4/underline -> monocai.json:100 -/ui/theme-defs/monocai/styles/h5/underline -> monocai.json:103 -/ui/theme-defs/monocai/styles/h6/underline -> monocai.json:106 -/ui/theme-defs/monocai/styles/hidden/bold -> monocai.json:46 -/ui/theme-defs/monocai/styles/hidden/color -> monocai.json:45 -/ui/theme-defs/monocai/styles/hr/color -> monocai.json:109 -/ui/theme-defs/monocai/styles/hyperlink/underline -> monocai.json:112 -/ui/theme-defs/monocai/styles/identifier/color -> monocai.json:19 -/ui/theme-defs/monocai/styles/indent-guide/color -> monocai.json:145 -/ui/theme-defs/monocai/styles/info/bold -> monocai.json:34 -/ui/theme-defs/monocai/styles/info/color -> monocai.json:33 -/ui/theme-defs/monocai/styles/invalid-msg/color -> monocai.json:70 -/ui/theme-defs/monocai/styles/list-glyph/color -> monocai.json:115 -/ui/theme-defs/monocai/styles/offset-time/color -> monocai.json:64 -/ui/theme-defs/monocai/styles/ok/bold -> monocai.json:30 -/ui/theme-defs/monocai/styles/ok/color -> monocai.json:29 -/ui/theme-defs/monocai/styles/popup/background-color -> monocai.json:82 -/ui/theme-defs/monocai/styles/popup/color -> monocai.json:81 -/ui/theme-defs/monocai/styles/quote-border/background-color -> monocai.json:128 -/ui/theme-defs/monocai/styles/quote-border/color -> monocai.json:127 -/ui/theme-defs/monocai/styles/quoted-text/background-color -> monocai.json:131 -/ui/theme-defs/monocai/styles/scrollbar/background-color -> monocai.json:86 -/ui/theme-defs/monocai/styles/scrollbar/color -> monocai.json:85 -/ui/theme-defs/monocai/styles/skewed-time/color -> monocai.json:61 -/ui/theme-defs/monocai/styles/snippet-border/color -> monocai.json:142 -/ui/theme-defs/monocai/styles/table-border/color -> monocai.json:121 -/ui/theme-defs/monocai/styles/table-header/bold -> monocai.json:124 -/ui/theme-defs/monocai/styles/text/background-color -> monocai.json:23 -/ui/theme-defs/monocai/styles/text/color -> monocai.json:22 -/ui/theme-defs/monocai/styles/warning/bold -> monocai.json:42 -/ui/theme-defs/monocai/styles/warning/color -> monocai.json:41 -/ui/theme-defs/monocai/syntax-styles/ascii-control/color -> monocai.json:212 -/ui/theme-defs/monocai/syntax-styles/code-border/background-color -> monocai.json:159 -/ui/theme-defs/monocai/syntax-styles/code-border/color -> monocai.json:158 -/ui/theme-defs/monocai/syntax-styles/comment/color -> monocai.json:170 -/ui/theme-defs/monocai/syntax-styles/diff-add/color -> monocai.json:191 -/ui/theme-defs/monocai/syntax-styles/diff-delete/color -> monocai.json:188 -/ui/theme-defs/monocai/syntax-styles/diff-section/color -> monocai.json:194 -/ui/theme-defs/monocai/syntax-styles/doc-directive/color -> monocai.json:173 -/ui/theme-defs/monocai/syntax-styles/file/color -> monocai.json:206 -/ui/theme-defs/monocai/syntax-styles/function/color -> monocai.json:221 -/ui/theme-defs/monocai/syntax-styles/inline-code/background-color -> monocai.json:151 -/ui/theme-defs/monocai/syntax-styles/inline-code/color -> monocai.json:150 -/ui/theme-defs/monocai/syntax-styles/keyword/bold -> monocai.json:163 -/ui/theme-defs/monocai/syntax-styles/keyword/color -> monocai.json:162 -/ui/theme-defs/monocai/syntax-styles/non-ascii/color -> monocai.json:215 -/ui/theme-defs/monocai/syntax-styles/null/color -> monocai.json:209 -/ui/theme-defs/monocai/syntax-styles/number/bold -> monocai.json:218 -/ui/theme-defs/monocai/syntax-styles/quoted-code/background-color -> monocai.json:155 -/ui/theme-defs/monocai/syntax-styles/quoted-code/color -> monocai.json:154 -/ui/theme-defs/monocai/syntax-styles/re-repeat/color -> monocai.json:185 -/ui/theme-defs/monocai/syntax-styles/re-special/color -> monocai.json:182 -/ui/theme-defs/monocai/syntax-styles/separators-references-accessors/color -> monocai.json:224 -/ui/theme-defs/monocai/syntax-styles/spectrogram-high/background-color -> monocai.json:203 -/ui/theme-defs/monocai/syntax-styles/spectrogram-low/background-color -> monocai.json:197 -/ui/theme-defs/monocai/syntax-styles/spectrogram-medium/background-color -> monocai.json:200 -/ui/theme-defs/monocai/syntax-styles/string/bold -> monocai.json:167 -/ui/theme-defs/monocai/syntax-styles/string/color -> monocai.json:166 -/ui/theme-defs/monocai/syntax-styles/symbol/color -> monocai.json:179 -/ui/theme-defs/monocai/syntax-styles/type/color -> monocai.json:227 -/ui/theme-defs/monocai/syntax-styles/variable/color -> monocai.json:176 +/ui/theme-defs/monocai/log-level-styles/critical/color -> monocai.json:294 +/ui/theme-defs/monocai/log-level-styles/error/color -> monocai.json:291 +/ui/theme-defs/monocai/log-level-styles/fatal/color -> monocai.json:297 +/ui/theme-defs/monocai/log-level-styles/warning/color -> monocai.json:288 +/ui/theme-defs/monocai/status-styles/active/background-color -> monocai.json:275 +/ui/theme-defs/monocai/status-styles/active/color -> monocai.json:274 +/ui/theme-defs/monocai/status-styles/alert/background-color -> monocai.json:271 +/ui/theme-defs/monocai/status-styles/alert/color -> monocai.json:270 +/ui/theme-defs/monocai/status-styles/disabled-title/background-color -> monocai.json:235 +/ui/theme-defs/monocai/status-styles/disabled-title/bold -> monocai.json:236 +/ui/theme-defs/monocai/status-styles/disabled-title/color -> monocai.json:234 +/ui/theme-defs/monocai/status-styles/hotkey/color -> monocai.json:258 +/ui/theme-defs/monocai/status-styles/hotkey/underline -> monocai.json:259 +/ui/theme-defs/monocai/status-styles/inactive-alert/background-color -> monocai.json:283 +/ui/theme-defs/monocai/status-styles/inactive-alert/color -> monocai.json:282 +/ui/theme-defs/monocai/status-styles/inactive/background-color -> monocai.json:279 +/ui/theme-defs/monocai/status-styles/inactive/color -> monocai.json:278 +/ui/theme-defs/monocai/status-styles/info/background-color -> monocai.json:250 +/ui/theme-defs/monocai/status-styles/info/color -> monocai.json:249 +/ui/theme-defs/monocai/status-styles/subtitle/background-color -> monocai.json:245 +/ui/theme-defs/monocai/status-styles/subtitle/bold -> monocai.json:246 +/ui/theme-defs/monocai/status-styles/subtitle/color -> monocai.json:244 +/ui/theme-defs/monocai/status-styles/text/background-color -> monocai.json:263 +/ui/theme-defs/monocai/status-styles/text/color -> monocai.json:262 +/ui/theme-defs/monocai/status-styles/title-hotkey/background-color -> monocai.json:254 +/ui/theme-defs/monocai/status-styles/title-hotkey/color -> monocai.json:253 +/ui/theme-defs/monocai/status-styles/title-hotkey/underline -> monocai.json:255 +/ui/theme-defs/monocai/status-styles/title/background-color -> monocai.json:240 +/ui/theme-defs/monocai/status-styles/title/bold -> monocai.json:241 +/ui/theme-defs/monocai/status-styles/title/color -> monocai.json:239 +/ui/theme-defs/monocai/status-styles/warn/background-color -> monocai.json:267 +/ui/theme-defs/monocai/status-styles/warn/color -> monocai.json:266 +/ui/theme-defs/monocai/styles/adjusted-time/color -> monocai.json:59 +/ui/theme-defs/monocai/styles/alt-text/background-color -> monocai.json:27 +/ui/theme-defs/monocai/styles/breadcrumb/bold -> monocai.json:120 +/ui/theme-defs/monocai/styles/breadcrumb/color -> monocai.json:119 +/ui/theme-defs/monocai/styles/cursor-line/background-color -> monocai.json:51 +/ui/theme-defs/monocai/styles/cursor-line/bold -> monocai.json:52 +/ui/theme-defs/monocai/styles/cursor-line/color -> monocai.json:50 +/ui/theme-defs/monocai/styles/disabled-cursor-line/background-color -> monocai.json:56 +/ui/theme-defs/monocai/styles/disabled-cursor-line/color -> monocai.json:55 +/ui/theme-defs/monocai/styles/disabled-focused/background-color -> monocai.json:79 +/ui/theme-defs/monocai/styles/disabled-focused/color -> monocai.json:78 +/ui/theme-defs/monocai/styles/error/bold -> monocai.json:39 +/ui/theme-defs/monocai/styles/error/color -> monocai.json:38 +/ui/theme-defs/monocai/styles/file-offset/color -> monocai.json:68 +/ui/theme-defs/monocai/styles/focused/background-color -> monocai.json:75 +/ui/theme-defs/monocai/styles/focused/color -> monocai.json:74 +/ui/theme-defs/monocai/styles/footnote-border/background-color -> monocai.json:137 +/ui/theme-defs/monocai/styles/footnote-border/color -> monocai.json:136 +/ui/theme-defs/monocai/styles/footnote-text/background-color -> monocai.json:141 +/ui/theme-defs/monocai/styles/footnote-text/color -> monocai.json:140 +/ui/theme-defs/monocai/styles/h1/bold -> monocai.json:91 +/ui/theme-defs/monocai/styles/h1/color -> monocai.json:90 +/ui/theme-defs/monocai/styles/h2/color -> monocai.json:94 +/ui/theme-defs/monocai/styles/h2/underline -> monocai.json:95 +/ui/theme-defs/monocai/styles/h3/color -> monocai.json:98 +/ui/theme-defs/monocai/styles/h4/underline -> monocai.json:101 +/ui/theme-defs/monocai/styles/h5/underline -> monocai.json:104 +/ui/theme-defs/monocai/styles/h6/underline -> monocai.json:107 +/ui/theme-defs/monocai/styles/hidden/bold -> monocai.json:47 +/ui/theme-defs/monocai/styles/hidden/color -> monocai.json:46 +/ui/theme-defs/monocai/styles/hr/color -> monocai.json:110 +/ui/theme-defs/monocai/styles/hyperlink/underline -> monocai.json:113 +/ui/theme-defs/monocai/styles/identifier/color -> monocai.json:20 +/ui/theme-defs/monocai/styles/indent-guide/color -> monocai.json:147 +/ui/theme-defs/monocai/styles/info/bold -> monocai.json:35 +/ui/theme-defs/monocai/styles/info/color -> monocai.json:34 +/ui/theme-defs/monocai/styles/invalid-msg/color -> monocai.json:71 +/ui/theme-defs/monocai/styles/list-glyph/color -> monocai.json:116 +/ui/theme-defs/monocai/styles/offset-time/color -> monocai.json:65 +/ui/theme-defs/monocai/styles/ok/bold -> monocai.json:31 +/ui/theme-defs/monocai/styles/ok/color -> monocai.json:30 +/ui/theme-defs/monocai/styles/popup/background-color -> monocai.json:83 +/ui/theme-defs/monocai/styles/popup/color -> monocai.json:82 +/ui/theme-defs/monocai/styles/quote-border/background-color -> monocai.json:130 +/ui/theme-defs/monocai/styles/quote-border/color -> monocai.json:129 +/ui/theme-defs/monocai/styles/quoted-text/background-color -> monocai.json:133 +/ui/theme-defs/monocai/styles/scrollbar/background-color -> monocai.json:87 +/ui/theme-defs/monocai/styles/scrollbar/color -> monocai.json:86 +/ui/theme-defs/monocai/styles/skewed-time/color -> monocai.json:62 +/ui/theme-defs/monocai/styles/snippet-border/color -> monocai.json:144 +/ui/theme-defs/monocai/styles/table-border/color -> monocai.json:123 +/ui/theme-defs/monocai/styles/table-header/bold -> monocai.json:126 +/ui/theme-defs/monocai/styles/text/background-color -> monocai.json:24 +/ui/theme-defs/monocai/styles/text/color -> monocai.json:23 +/ui/theme-defs/monocai/styles/warning/bold -> monocai.json:43 +/ui/theme-defs/monocai/styles/warning/color -> monocai.json:42 +/ui/theme-defs/monocai/syntax-styles/ascii-control/color -> monocai.json:214 +/ui/theme-defs/monocai/syntax-styles/code-border/background-color -> monocai.json:161 +/ui/theme-defs/monocai/syntax-styles/code-border/color -> monocai.json:160 +/ui/theme-defs/monocai/syntax-styles/comment/color -> monocai.json:172 +/ui/theme-defs/monocai/syntax-styles/diff-add/color -> monocai.json:193 +/ui/theme-defs/monocai/syntax-styles/diff-delete/color -> monocai.json:190 +/ui/theme-defs/monocai/syntax-styles/diff-section/color -> monocai.json:196 +/ui/theme-defs/monocai/syntax-styles/doc-directive/color -> monocai.json:175 +/ui/theme-defs/monocai/syntax-styles/file/color -> monocai.json:208 +/ui/theme-defs/monocai/syntax-styles/function/color -> monocai.json:223 +/ui/theme-defs/monocai/syntax-styles/inline-code/background-color -> monocai.json:153 +/ui/theme-defs/monocai/syntax-styles/inline-code/color -> monocai.json:152 +/ui/theme-defs/monocai/syntax-styles/keyword/bold -> monocai.json:165 +/ui/theme-defs/monocai/syntax-styles/keyword/color -> monocai.json:164 +/ui/theme-defs/monocai/syntax-styles/non-ascii/color -> monocai.json:217 +/ui/theme-defs/monocai/syntax-styles/null/color -> monocai.json:211 +/ui/theme-defs/monocai/syntax-styles/number/bold -> monocai.json:220 +/ui/theme-defs/monocai/syntax-styles/quoted-code/background-color -> monocai.json:157 +/ui/theme-defs/monocai/syntax-styles/quoted-code/color -> monocai.json:156 +/ui/theme-defs/monocai/syntax-styles/re-repeat/color -> monocai.json:187 +/ui/theme-defs/monocai/syntax-styles/re-special/color -> monocai.json:184 +/ui/theme-defs/monocai/syntax-styles/separators-references-accessors/color -> monocai.json:226 +/ui/theme-defs/monocai/syntax-styles/spectrogram-high/background-color -> monocai.json:205 +/ui/theme-defs/monocai/syntax-styles/spectrogram-low/background-color -> monocai.json:199 +/ui/theme-defs/monocai/syntax-styles/spectrogram-medium/background-color -> monocai.json:202 +/ui/theme-defs/monocai/syntax-styles/string/bold -> monocai.json:169 +/ui/theme-defs/monocai/syntax-styles/string/color -> monocai.json:168 +/ui/theme-defs/monocai/syntax-styles/symbol/color -> monocai.json:181 +/ui/theme-defs/monocai/syntax-styles/type/color -> monocai.json:229 +/ui/theme-defs/monocai/syntax-styles/variable/color -> monocai.json:178 /ui/theme-defs/monocai/vars/black -> monocai.json:7 /ui/theme-defs/monocai/vars/blue -> monocai.json:11 /ui/theme-defs/monocai/vars/cyan -> monocai.json:13 /ui/theme-defs/monocai/vars/green -> monocai.json:9 /ui/theme-defs/monocai/vars/magenta -> monocai.json:12 +/ui/theme-defs/monocai/vars/orange -> monocai.json:15 /ui/theme-defs/monocai/vars/red -> monocai.json:8 -/ui/theme-defs/monocai/vars/semantic_highlight_color -> monocai.json:15 +/ui/theme-defs/monocai/vars/semantic_highlight_color -> monocai.json:16 /ui/theme-defs/monocai/vars/white -> monocai.json:14 /ui/theme-defs/monocai/vars/yellow -> monocai.json:10 /ui/theme-defs/night-owl/log-level-styles/critical/color -> night-owl.json:292 diff --git a/test/scripty.cc b/test/scripty.cc index 2f7bb940..23144d3e 100644 --- a/test/scripty.cc +++ b/test/scripty.cc @@ -108,7 +108,8 @@ public: memset(&ws, 0, sizeof(ws)); if (isatty(STDIN_FILENO) - && tcgetattr(STDIN_FILENO, &this->ct_termios) == -1) { + && tcgetattr(STDIN_FILENO, &this->ct_termios) == -1) + { throw error(errno); } @@ -122,7 +123,8 @@ public: ws.ws_row = 24; if (openpty(this->ct_master.out(), slave.out(), nullptr, nullptr, &ws) - < 0) { + < 0) + { throw error(errno); } @@ -174,20 +176,11 @@ public: return retval; }; - bool is_child() const - { - return this->ct_child == 0; - }; + bool is_child() const { return this->ct_child == 0; }; - pid_t get_child_pid() const - { - return this->ct_child; - }; + pid_t get_child_pid() const { return this->ct_child; }; - int get_fd() const - { - return this->ct_master; - }; + int get_fd() const { return this->ct_master; }; protected: pid_t ct_child; @@ -328,15 +321,9 @@ struct term_machine { std::vector ta_desc; }; - term_machine(child_term& ct) : tm_child_term(ct) - { - this->clear(); - } + term_machine(child_term& ct) : tm_child_term(ct) { this->clear(); } - ~term_machine() - { - this->flush_line(); - } + ~term_machine() { this->flush_line(); } void clear() { @@ -460,7 +447,8 @@ struct term_machine { line_len -= 4; } for (size_t lpc2 = lpc + 1; lpc2 < this->tm_line_attrs.size(); - lpc2++) { + lpc2++) + { auto bar_pos = 7 + this->tm_line_attrs[lpc2].ta_pos; if (bar_pos < line_len) { @@ -488,7 +476,8 @@ struct term_machine { int val, last; if (sscanf(&this->tm_escape_buffer[index], "%d%n", &val, &last) - == 1) { + == 1) + { retval.push_back(val); index += last; if (this->tm_escape_buffer[index] != ';') { @@ -503,10 +492,7 @@ struct term_machine { return retval; } - void new_user_input(char ch) - { - this->tm_user_input.push_back(ch); - } + void new_user_input(char ch) { this->tm_user_input.push_back(ch); } void new_input(char ch) { @@ -521,7 +507,7 @@ struct term_machine { this->tm_unicode_buffer.pop_front(); return retval; - }); + }).unwrap(); } return; } else { @@ -602,7 +588,8 @@ struct term_machine { case state::ESCAPE_FIXED_LENGTH: { this->tm_escape_buffer.push_back(ch); if (this->tm_escape_buffer.size() - == this->tm_escape_expected_size) { + == this->tm_escape_expected_size) + { auto iter = CSI_TO_DESC.find( std::string(this->tm_escape_buffer.data(), this->tm_escape_buffer.size())); @@ -1101,7 +1088,8 @@ main(int argc, char* argv[]) #endif tm.new_input(buffer[lpc]); if (scripty_data.sd_replay.size() - != last_replay_size) { + != last_replay_size) + { last = now; last_replay_size = scripty_data.sd_replay.size();