mirror of
https://github.com/tstack/lnav.git
synced 2024-09-11 13:05:51 +03:00
[pretty] use an attribute to draw the guidelines to keep copy & paste clean
This commit is contained in:
parent
be377dea27
commit
f3bdc50e70
@ -47,5 +47,6 @@ string_attr_type<role_t> VC_ROLE("role");
|
||||
string_attr_type<role_t> VC_ROLE_FG("role-fg");
|
||||
string_attr_type<text_attrs> VC_STYLE("style");
|
||||
string_attr_type<int64_t> VC_GRAPHIC("graphic");
|
||||
string_attr_type<block_elem_t> VC_BLOCK_ELEM("block-elem");
|
||||
string_attr_type<int64_t> VC_FOREGROUND("foreground");
|
||||
string_attr_type<int64_t> VC_BACKGROUND("background");
|
||||
|
@ -162,6 +162,10 @@ struct text_attrs {
|
||||
nonstd::optional<short> ta_bg_color;
|
||||
};
|
||||
|
||||
struct block_elem_t {
|
||||
wchar_t value;
|
||||
};
|
||||
|
||||
using string_attr_value = mapbox::util::variant<int64_t,
|
||||
role_t,
|
||||
text_attrs,
|
||||
@ -170,7 +174,8 @@ using string_attr_value = mapbox::util::variant<int64_t,
|
||||
std::shared_ptr<logfile>,
|
||||
bookmark_metadata*,
|
||||
timespec,
|
||||
string_fragment>;
|
||||
string_fragment,
|
||||
block_elem_t>;
|
||||
|
||||
class string_attr_type_base {
|
||||
public:
|
||||
@ -224,6 +229,7 @@ extern string_attr_type<role_t> VC_ROLE;
|
||||
extern string_attr_type<role_t> VC_ROLE_FG;
|
||||
extern string_attr_type<text_attrs> VC_STYLE;
|
||||
extern string_attr_type<int64_t> VC_GRAPHIC;
|
||||
extern string_attr_type<block_elem_t> VC_BLOCK_ELEM;
|
||||
extern string_attr_type<int64_t> VC_FOREGROUND;
|
||||
extern string_attr_type<int64_t> VC_BACKGROUND;
|
||||
|
||||
|
@ -150,7 +150,8 @@ to_json(yajlpp_gen& gen, const attr_line_t& al)
|
||||
},
|
||||
[&](const bookmark_metadata* bm) { elem_map.gen(""); },
|
||||
[&](const timespec& ts) { elem_map.gen(""); },
|
||||
[&](const string_fragment& sf) { elem_map.gen(sf); });
|
||||
[&](const string_fragment& sf) { elem_map.gen(sf); },
|
||||
[&](const block_elem_t& be) { elem_map.gen(""); });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -245,6 +245,8 @@ pretty_printer::write_element(const pretty_printer::element& el)
|
||||
void
|
||||
pretty_printer::append_indent()
|
||||
{
|
||||
static const auto INDENT_GUIDELINE = block_elem_t{L'\u258f'};
|
||||
|
||||
this->pp_stream << std::string(
|
||||
this->pp_leading_indent + this->pp_soft_indent, ' ');
|
||||
this->pp_soft_indent = 0;
|
||||
@ -255,10 +257,13 @@ pretty_printer::append_indent()
|
||||
if (lpc > 0) {
|
||||
int off = this->pp_stream.tellp();
|
||||
this->pp_post_attrs.emplace_back(
|
||||
line_range{off, off + 3},
|
||||
line_range{off, off + 1},
|
||||
VC_BLOCK_ELEM.value(INDENT_GUIDELINE));
|
||||
this->pp_post_attrs.emplace_back(
|
||||
line_range{off, off + 1},
|
||||
VC_ROLE.value(role_t::VCR_INDENT_GUIDE));
|
||||
}
|
||||
this->pp_stream << (lpc == 0 ? " " : "\u258f ");
|
||||
this->pp_stream << " ";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -260,7 +260,8 @@ view_curses::mvwattrline(WINDOW* window,
|
||||
if (!(iter->sa_type == &VC_ROLE || iter->sa_type == &VC_ROLE_FG
|
||||
|| iter->sa_type == &VC_STYLE || iter->sa_type == &VC_GRAPHIC
|
||||
|| iter->sa_type == &SA_LEVEL || iter->sa_type == &VC_FOREGROUND
|
||||
|| iter->sa_type == &VC_BACKGROUND))
|
||||
|| iter->sa_type == &VC_BACKGROUND
|
||||
|| iter->sa_type == &VC_BLOCK_ELEM))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -335,10 +336,13 @@ view_curses::mvwattrline(WINDOW* window,
|
||||
if (attr_range.lr_start < attr_range.lr_end) {
|
||||
int awidth = attr_range.length();
|
||||
nonstd::optional<char> graphic;
|
||||
nonstd::optional<wchar_t> block_elem;
|
||||
|
||||
if (iter->sa_type == &VC_GRAPHIC) {
|
||||
graphic = iter->sa_value.get<int64_t>();
|
||||
attrs = text_attrs{};
|
||||
} else if (iter->sa_type == &VC_BLOCK_ELEM) {
|
||||
block_elem = iter->sa_value.get<block_elem_t>().value;
|
||||
} else if (iter->sa_type == &VC_STYLE) {
|
||||
attrs = iter->sa_value.get<text_attrs>();
|
||||
} else if (iter->sa_type == &SA_LEVEL) {
|
||||
@ -353,7 +357,7 @@ view_curses::mvwattrline(WINDOW* window,
|
||||
attrs.ta_fg_color = role_attrs.ta_fg_color;
|
||||
}
|
||||
|
||||
if (graphic || !attrs.empty()) {
|
||||
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));
|
||||
@ -398,6 +402,9 @@ view_curses::mvwattrline(WINDOW* window,
|
||||
row_ch[lpc].chars[0] = graphic.value();
|
||||
row_ch[lpc].attr |= A_ALTCHARSET;
|
||||
}
|
||||
if (block_elem) {
|
||||
row_ch[lpc].chars[0] = block_elem.value();
|
||||
}
|
||||
if (row_ch[lpc].attr & A_REVERSE
|
||||
&& attrs.ta_attrs & A_REVERSE)
|
||||
{
|
||||
|
@ -2,13 +2,13 @@
|
||||
[35m{[0m
|
||||
[35m "fo[0mo bar" : [35mnull,[0m
|
||||
[35m [0m "array" : [
|
||||
[35m [0m▏ [35m 1,[0m
|
||||
[35m [0m ▏[35m 2,[0m
|
||||
▏ 3
|
||||
[35m [0m 1[35m,[0m
|
||||
[35m [0m 2[35m,[0m
|
||||
[35m [0m 3
|
||||
],
|
||||
"obj" : {
|
||||
▏ "one" : 1,
|
||||
▏ "two" : true
|
||||
"one" : 1,
|
||||
"two" : true
|
||||
}
|
||||
}
|
||||
''
|
||||
|
@ -9,29 +9,29 @@
|
||||
<value id="ipv4Enabled" actions="enabled">true</value>
|
||||
<value id="name" actions="enabled">nic1</value>
|
||||
<value id="v4config" actions="enabled">
|
||||
▏ <value id="defaultGateway" actions="enabled">0.0.0.0</value>
|
||||
▏ <value id="updateable" actions="enabled">True</value>
|
||||
▏ <value id="prefix" actions="enabled">22</value>
|
||||
▏ <value id="mode" actions="enabled">dhcp</value>
|
||||
▏ <value id="address" actions="enabled">198.51.100.110</value>
|
||||
▏ <value id="interface" actions="enabled">nic1</value>
|
||||
<value id="defaultGateway" actions="enabled">0.0.0.0</value>
|
||||
<value id="updateable" actions="enabled">True</value>
|
||||
<value id="prefix" actions="enabled">22</value>
|
||||
<value id="mode" actions="enabled">dhcp</value>
|
||||
<value id="address" actions="enabled">198.51.100.110</value>
|
||||
<value id="interface" actions="enabled">nic1</value>
|
||||
</value>
|
||||
<value id="v6config" actions="enabled">
|
||||
▏ <value id="defaultGateway" actions="enabled">fe80::214:f609:19f7:6bf1</value>
|
||||
▏ <value id="updateable" actions="enabled">True</value>
|
||||
▏ <value id="interface" actions="enabled">nic1</value>
|
||||
▏ <value id="dhcp" actions="enabled">False</value>
|
||||
▏ <value id="autoconf" actions="enabled">False</value>
|
||||
▏ <value id="addresses" actions="enabled">
|
||||
▏ ▏ <value id="origin" actions="enabled">other</value>
|
||||
▏ ▏ <value id="status" actions="enabled">preferred</value>
|
||||
▏ ▏ <value id="prefix" actions="enabled">64</value>
|
||||
▏ ▏ <value id="address" actions="enabled">fe80::250:56ff:feaa:5abf</value>
|
||||
▏ </value>
|
||||
<value id="defaultGateway" actions="enabled">fe80::214:f609:19f7:6bf1</value>
|
||||
<value id="updateable" actions="enabled">True</value>
|
||||
<value id="interface" actions="enabled">nic1</value>
|
||||
<value id="dhcp" actions="enabled">False</value>
|
||||
<value id="autoconf" actions="enabled">False</value>
|
||||
<value id="addresses" actions="enabled">
|
||||
<value id="origin" actions="enabled">other</value>
|
||||
<value id="status" actions="enabled">preferred</value>
|
||||
<value id="prefix" actions="enabled">64</value>
|
||||
<value id="address" actions="enabled">fe80::250:56ff:feaa:5abf</value>
|
||||
</value>
|
||||
</value>
|
||||
<value id="interfaceInfo" actions="enabled">
|
||||
▏ <value id="status" actions="enabled">up</value>
|
||||
▏ <value id="mac" actions="enabled">00:50:56:aa:5a:bf</value>
|
||||
▏ <value id="name" actions="enabled">nic1</value>
|
||||
<value id="status" actions="enabled">up</value>
|
||||
<value id="mac" actions="enabled">00:50:56:aa:5a:bf</value>
|
||||
<value id="name" actions="enabled">nic1</value>
|
||||
</value>
|
||||
</response>
|
||||
|
@ -18,11 +18,11 @@ Apr 7 05:49:53 Tim-Stacks-iMac.local GoogleSoftwareUpdateDaemon[17212]: -[KSUpd
|
||||
body=
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<o:gupdate xmlns:o="http://www.google.com/update2/request" protocol="2.0" version="KeystoneDaemon-1.2.0.7709" ismachine="1" requestid="{0DFDBCD1-5E29-4DFC-BD99-31A2397198FE}">
|
||||
▏ <o:os platform="mac" version="MacOSX" sp="10.10.2_x86_64h"></o:os>
|
||||
▏ <o:app appid="com.google.Keystone" version="1.2.0.7709" lang="en-us" installage="180" brand="GGLG">
|
||||
▏ ▏ <o:ping r="1" a="1"></o:ping>
|
||||
▏ ▏ <o:updatecheck></o:updatecheck>
|
||||
▏ </o:app>
|
||||
<o:os platform="mac" version="MacOSX" sp="10.10.2_x86_64h"></o:os>
|
||||
<o:app appid="com.google.Keystone" version="1.2.0.7709" lang="en-us" installage="180" brand="GGLG">
|
||||
<o:ping r="1" a="1"></o:ping>
|
||||
<o:updatecheck></o:updatecheck>
|
||||
</o:app>
|
||||
</o:gupdate>
|
||||
>
|
||||
[33mApr 7 07:31:56[0m[33m [0m[33mTim-Stacks-iMac.local[0m[33m [0m[33mVirtualBox[0m[33m[[0m[33m36403[0m[33m][0m[33m: [0m[33mWARNING: The Gestalt selector gestaltSystemVersion is returning 10.9.2 instead of 10.10.2. Use NSProcessInfo's operatingSystemVersion property to get correct system version number.[0m
|
||||
|
@ -1,12 +1,12 @@
|
||||
{
|
||||
[35m "foo [0mbar" : null,
|
||||
[35m "array" : [[0m
|
||||
[35m [0m[35mâ–Ź[0m[35m 1,[0m
|
||||
[35m [0m[35mâ–Ź[0m[35m 2,[0m
|
||||
[35m [0m[35mâ–Ź[0m[35m 3[0m
|
||||
[35m [0m[35m [0m[35m 1,[0m
|
||||
[35m [0m[35m [0m[35m 2,[0m
|
||||
[35m [0m[35m [0m[35m 3[0m
|
||||
[35m ],[0m
|
||||
[35m "obj" : {[0m
|
||||
[35m [0m â–Ź "one" [35m: 1,[0m
|
||||
â[35m–Ź[0m[35m [0m"two" [35m: tru[0me
|
||||
[35m "obj" : [0m{
|
||||
"one[35m" : 1[0m,
|
||||
[35m [0m[35m [0m[35m [0m"two" [35m: tru[0me
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
[35m "wra[0mpper": [
|
||||
▏ ▏ {[35m"message"[0m:[35m""[0m
|
||||
{[35m"message"[0m:[35m""[0m
|
||||
[35m select Id from Account where id = $sfid[0m
|
||||
[35m ^[0m
|
||||
[35m ERROR at Row:1:Column:34[0m
|
||||
|
Loading…
Reference in New Issue
Block a user