mirror of https://github.com/tstack/lnav.git
[attr_line] fixes for empty attributes
This commit is contained in:
parent
6c6d1cbf41
commit
64e7b78c6b
|
@ -130,6 +130,10 @@ consume(const string_fragment text)
|
|||
static void
|
||||
split_attrs(attr_line_t& al, const line_range& lr)
|
||||
{
|
||||
if (lr.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
string_attrs_t new_attrs;
|
||||
|
||||
for (auto& attr : al.al_attrs) {
|
||||
|
@ -201,7 +205,9 @@ attr_line_t::insert(size_t index,
|
|||
split_attrs(*this, indent_lr);
|
||||
indent_lr.lr_end += tws->tws_padding_indent;
|
||||
line_ch_count += tws->tws_padding_indent;
|
||||
this->al_attrs.emplace_back(indent_lr, SA_PREFORMATTED.value());
|
||||
if (!indent_lr.empty()) {
|
||||
this->al_attrs.emplace_back(indent_lr, SA_PREFORMATTED.value());
|
||||
}
|
||||
text_to_wrap = text_to_wrap.prepend(
|
||||
this->al_string.data(),
|
||||
tws->tws_indent + tws->tws_padding_indent);
|
||||
|
@ -229,8 +235,10 @@ attr_line_t::insert(size_t index,
|
|||
};
|
||||
split_attrs(*this, indent_lr);
|
||||
indent_lr.lr_end += tws->tws_padding_indent;
|
||||
this->al_attrs.emplace_back(indent_lr,
|
||||
SA_PREFORMATTED.value());
|
||||
if (!indent_lr.empty()) {
|
||||
this->al_attrs.emplace_back(indent_lr,
|
||||
SA_PREFORMATTED.value());
|
||||
}
|
||||
line_ch_count = tws->tws_padding_indent + ch_count;
|
||||
auto trailing_space_count = 0;
|
||||
if (!last_word.empty()) {
|
||||
|
@ -296,12 +304,8 @@ attr_line_t::insert(size_t index,
|
|||
|
||||
return space.s_remaining;
|
||||
},
|
||||
[](text_stream::corrupt corrupt) {
|
||||
return corrupt.c_remaining;
|
||||
},
|
||||
[](text_stream::eof eof) {
|
||||
return eof.e_remaining;
|
||||
});
|
||||
[](text_stream::corrupt corrupt) { return corrupt.c_remaining; },
|
||||
[](text_stream::eof eof) { return eof.e_remaining; });
|
||||
|
||||
if (chunk.is<text_stream::word>()) {
|
||||
last_word = text_to_wrap;
|
||||
|
@ -439,6 +443,11 @@ attr_line_t::erase(size_t pos, size_t len)
|
|||
this->al_string.erase(pos, len);
|
||||
|
||||
shift_string_attrs(this->al_attrs, pos, -((int32_t) len));
|
||||
auto new_end = std::remove_if(
|
||||
this->al_attrs.begin(), this->al_attrs.end(), [](const auto& attr) {
|
||||
return attr.sa_range.empty();
|
||||
});
|
||||
this->al_attrs.erase(new_end, this->al_attrs.end());
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
|
|
@ -81,8 +81,17 @@ struct line_range {
|
|||
|
||||
bool intersects(const struct line_range& other) const
|
||||
{
|
||||
return this->contains(other.lr_start) || this->contains(other.lr_end)
|
||||
|| other.contains(this->lr_start);
|
||||
if (this->contains(other.lr_start)) {
|
||||
return true;
|
||||
}
|
||||
if (other.lr_end > 0 && this->contains(other.lr_end - 1)) {
|
||||
return true;
|
||||
}
|
||||
if (other.contains(this->lr_start)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
line_range intersection(const struct line_range& other) const;
|
||||
|
|
|
@ -61,6 +61,11 @@ breadcrumb_curses::do_update()
|
|||
auto width = static_cast<size_t>(getmaxx(this->bc_window));
|
||||
auto crumbs = this->bc_focused_crumbs.empty() ? this->bc_line_source()
|
||||
: this->bc_focused_crumbs;
|
||||
if (this->bc_last_selected_crumb
|
||||
&& this->bc_last_selected_crumb.value() >= crumbs.size())
|
||||
{
|
||||
this->bc_last_selected_crumb = crumbs.size() - 1;
|
||||
}
|
||||
attr_line_t crumbs_line;
|
||||
for (const auto& crumb : crumbs) {
|
||||
auto accum_width
|
||||
|
@ -184,6 +189,12 @@ breadcrumb_curses::focus()
|
|||
}
|
||||
|
||||
this->bc_current_search.clear();
|
||||
if (this->bc_last_selected_crumb
|
||||
&& this->bc_last_selected_crumb.value()
|
||||
>= this->bc_focused_crumbs.size())
|
||||
{
|
||||
this->bc_last_selected_crumb = this->bc_focused_crumbs.size() - 1;
|
||||
}
|
||||
this->bc_selected_crumb = this->bc_last_selected_crumb.value_or(0);
|
||||
this->reload_data();
|
||||
}
|
||||
|
|
|
@ -106,7 +106,7 @@ db_label_source::text_attrs_for_line(textview_curses& tc,
|
|||
string_attrs_t& sa)
|
||||
{
|
||||
struct line_range lr(0, 0);
|
||||
struct line_range lr2(0, -1);
|
||||
const struct line_range lr2(0, -1);
|
||||
|
||||
if (row >= (int) this->dls_rows.size()) {
|
||||
return;
|
||||
|
|
|
@ -220,9 +220,8 @@ public:
|
|||
}
|
||||
lr.lr_end = left = lr.lr_start + amount;
|
||||
|
||||
if (ci.ci_attrs != 0) {
|
||||
value_out.emplace_back(
|
||||
lr, VC_STYLE.value(ci.ci_attrs | A_REVERSE));
|
||||
if (ci.ci_attrs != 0 && !lr.empty()) {
|
||||
value_out.emplace_back(lr, VC_STYLE.value(ci.ci_attrs | A_REVERSE));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -210,8 +210,10 @@ md2attr_line::leave_block(const md4cpp::event_handler::block& bl)
|
|||
.append(line)
|
||||
.append("\n");
|
||||
}
|
||||
padded_text.with_attr_for_all(SA_PREFORMATTED.value());
|
||||
last_block.append("\n").append(padded_text);
|
||||
if (!padded_text.empty()) {
|
||||
padded_text.with_attr_for_all(SA_PREFORMATTED.value());
|
||||
last_block.append("\n").append(padded_text);
|
||||
}
|
||||
} else if (bl.is<block_quote>()) {
|
||||
text_wrap_settings tws = {0, 60};
|
||||
attr_line_t wrapped_text;
|
||||
|
@ -231,8 +233,10 @@ md2attr_line::leave_block(const md4cpp::event_handler::block& bl)
|
|||
.append(line)
|
||||
.append("\n");
|
||||
}
|
||||
padded_text.with_attr_for_all(SA_PREFORMATTED.value());
|
||||
last_block.append("\n").append(padded_text);
|
||||
if (!padded_text.empty()) {
|
||||
padded_text.with_attr_for_all(SA_PREFORMATTED.value());
|
||||
last_block.append("\n").append(padded_text);
|
||||
}
|
||||
} else if (bl.is<MD_BLOCK_TABLE_DETAIL*>()) {
|
||||
auto* table_detail = bl.get<MD_BLOCK_TABLE_DETAIL*>();
|
||||
auto tab = std::move(this->ml_tables.back());
|
||||
|
@ -333,8 +337,10 @@ md2attr_line::leave_block(const md4cpp::event_handler::block& bl)
|
|||
block_text.append("\n");
|
||||
}
|
||||
}
|
||||
block_text.with_attr_for_all(SA_PREFORMATTED.value());
|
||||
last_block.append(block_text);
|
||||
if (!block_text.empty()) {
|
||||
block_text.with_attr_for_all(SA_PREFORMATTED.value());
|
||||
last_block.append(block_text);
|
||||
}
|
||||
} else if (bl.is<block_th>()) {
|
||||
this->ml_tables.back().t_headers.push_back(block_text);
|
||||
} else if (bl.is<MD_BLOCK_TD_DETAIL*>()) {
|
||||
|
|
|
@ -3978,7 +3978,7 @@ lnav@googlegroups.com[1] support@lnav.org[2]
|
|||
[4mParameters[0m
|
||||
|
||||
|
||||
[1m[4m[36mINSERT[0m[4m [0m[1m[4m[36mINTO[0m[4m [[0m[4mschema-name.[0m[4m] [0m[4mtable-name[0m[4m [[0m[1m[4m[36m([0m[4m [0m[4mcolumn-name[0m[4m1[0m[4m [, ...[0m[4m [0m[4mcolumn-name[0m[4mN[0m[4m] [0m[1m[4m[36m)[0m[4m] [0m[1m[4m[36mVALUES[0m[4m [0m[1m[4m[36m([0m[4m [0m[4mexpr[0m[4m1[0m[4m [, ...[0m[4m [0m[4mexpr[0m[4mN[0m[4m] [0m[1m[4m[36m)[0m
|
||||
[1m[4m[36mINSERT[0m[4m [0m[1m[4m[36mINTO[0m[4m [[0m[4mschema-name.[0m[4m] [0m[4mtable-name[0m[4m [[0m[1m[4m[36m([0m[4m [0m[4mcolumn-name[0m[4m1[0m[4m [, ... [0m[4mcolumn-name[0m[4mN[0m[4m] [0m[1m[4m[36m)[0m[4m] [0m[1m[4m[36mVALUES[0m[4m [0m[1m[4m[36m([0m[4m [0m[4mexpr[0m[4m1[0m[4m [, ... [0m[4mexpr[0m[4mN[0m[4m] [0m[1m[4m[36m)[0m
|
||||
══════════════════════════════════════════════════════════════════════
|
||||
Insert rows into a table
|
||||
[4mParameters[0m
|
||||
|
@ -3997,7 +3997,7 @@ lnav@googlegroups.com[1] support@lnav.org[2]
|
|||
[4mwindow-name[0m The name of the window definition
|
||||
|
||||
|
||||
[1m[4m[36mSELECT[0m[4m [0m[4mresult-column[0m[4m1[0m[4m [, ...[0m[4m [0m[4mresult-column[0m[4mN[0m[4m] [[0m[1m[4m[36mFROM[0m[4m [0m[4mtable[0m[4m1[0m[4m [, ...[0m[4m [0m[4mtable[0m[4mN[0m[4m]] [[0m[1m[4m[36mWHERE[0m[4m [0m[4mcond[0m[4m] [[0m[1m[4m[36mGROUP BY[0m[4m [0m[4mgrouping-expr[0m[4m1[0m[4m [, ...[0m[4m [0m[4mgrouping-expr[0m[4mN[0m[4m]] [[0m[1m[4m[36mORDER BY[0m[4m [0m[4mordering-term[0m[4m1[0m[4m [, ...[0m[4m [0m[4mordering-term[0m[4mN[0m[4m]] [[0m[1m[4m[36mLIMIT[0m[4m [0m[4mlimit-expr[0m[4m1[0m[4m [, ...[0m[4m [0m[4mlimit-expr[0m[4mN[0m[4m]][0m
|
||||
[1m[4m[36mSELECT[0m[4m [0m[4mresult-column[0m[4m1[0m[4m [, ... [0m[4mresult-column[0m[4mN[0m[4m] [[0m[1m[4m[36mFROM[0m[4m [0m[4mtable[0m[4m1[0m[4m [, ... [0m[4mtable[0m[4mN[0m[4m]] [[0m[1m[4m[36mWHERE[0m[4m [0m[4mcond[0m[4m] [[0m[1m[4m[36mGROUP BY[0m[4m [0m[4mgrouping-expr[0m[4m1[0m[4m [, ... [0m[4mgrouping-expr[0m[4mN[0m[4m]] [[0m[1m[4m[36mORDER BY[0m[4m [0m[4mordering-term[0m[4m1[0m[4m [, ... [0m[4mordering-term[0m[4mN[0m[4m]] [[0m[1m[4m[36mLIMIT[0m[4m [0m[4mlimit-expr[0m[4m1[0m[4m [, ... [0m[4mlimit-expr[0m[4mN[0m[4m]][0m
|
||||
══════════════════════════════════════════════════════════════════════
|
||||
Query the database and return zero or more rows of data.
|
||||
[4mParameters[0m
|
||||
|
@ -4019,7 +4019,7 @@ lnav@googlegroups.com[1] support@lnav.org[2]
|
|||
|
||||
|
||||
|
||||
[1m[4m[36mUPDATE[0m[4m [0m[4mtable[0m[4m [0m[1m[4m[36mSET[0m[4m [0m[4mcolumn-name[0m[4m1[0m[4m [0m[1m[4m[36m=[0m[4m [0m[4mexpr[0m[4m1[0m[4m [, ...[0m[4m [0m[4mcolumn-name[0m[4mN[0m[4m [0m[1m[4m[36m=[0m[4m [0m[4mexpr[0m[4mN[0m[4m] [[0m[1m[4m[36mWHERE[0m[4m [0m[4mcond[0m[4m][0m
|
||||
[1m[4m[36mUPDATE[0m[4m [0m[4mtable[0m[4m [0m[1m[4m[36mSET[0m[4m [0m[4mcolumn-name[0m[4m1[0m[4m [0m[1m[4m[36m=[0m[4m [0m[4mexpr[0m[4m1[0m[4m [, ... [0m[4mcolumn-name[0m[4mN[0m[4m [0m[1m[4m[36m=[0m[4m [0m[4mexpr[0m[4mN[0m[4m] [[0m[1m[4m[36mWHERE[0m[4m [0m[4mcond[0m[4m][0m
|
||||
══════════════════════════════════════════════════════════════════════
|
||||
Modify a subset of values in zero or more rows of the given table
|
||||
[4mParameters[0m
|
||||
|
|
|
@ -1,25 +1,25 @@
|
|||
|
||||
|
||||
[2013-09-06T20:00:48.124] TRACE trace testbork bork bork
|
||||
|
||||
|
||||
[2013-09-06T20:00:49.124] INFO Starting up servicebork bork bork
|
||||
|
||||
|
||||
[2013-09-06T22:00:49.124] INFO Shutting down servicebork bork bork
|
||||
user:mailto:steve@example.com
|
||||
|
||||
|
||||
[2013-09-06T22:00:59.124] DEBUG5 Details...bork bork bork
|
||||
|
||||
|
||||
[2013-09-06T22:00:59.124] DEBUG4 Details...bork bork bork
|
||||
|
||||
|
||||
[2013-09-06T22:00:59.124] DEBUG3 Details...bork bork bork
|
||||
|
||||
|
||||
[2013-09-06T22:00:59.124] DEBUG2 Details...bork bork bork
|
||||
|
||||
|
||||
[2013-09-06T22:00:59.124] DEBUG Details...bork bork bork
|
||||
|
||||
|
||||
[2013-09-06T22:01:49.124] STATS 1 beat per secondbork bork bork
|
||||
|
||||
|
||||
[33m[[0m[33m2013-09-06T22:01:49.124[0m[33m] WARNING not looking go[0m[33modbork bork bork[0m
|
||||
|
||||
|
||||
[31m[[0m[31m2013-09-06T22:01:49.124[0m[31m] ERROR looking badbor[0m[31mk bork bork[0m
|
||||
|
||||
|
||||
[31m[[0m[31m2013-09-06T22:01:49.124[0m[31m] CRITICAL sooo badbork b[0m[31mork bork[0m
|
||||
|
|
Loading…
Reference in New Issue