[meta] highlight comments/tags in searches

This commit is contained in:
Tim Stack 2022-08-15 22:32:28 -07:00
parent a1de8f1fc1
commit d020168860
2 changed files with 19 additions and 1 deletions

View File

@ -443,6 +443,7 @@ field_overlay_source::build_meta_line(const listview_curses& lv,
if (iter != bm.end()) {
const bookmark_metadata& line_meta = iter->second;
size_t filename_width = this->fos_lss.get_filename_offset();
auto* tc = dynamic_cast<const textview_curses*>(&lv);
if (!line_meta.bm_comment.empty()) {
const auto* lead = line_meta.bm_tags.empty() ? " \u2514 "
@ -452,6 +453,15 @@ field_overlay_source::build_meta_line(const listview_curses& lv,
al.with_string(lead).append(
lnav::roles::comment(line_meta.bm_comment));
al.insert(0, filename_width, ' ');
if (tc != nullptr) {
auto hl = tc->get_highlights();
auto hl_iter = hl.find({highlight_source_t::PREVIEW, "search"});
if (hl_iter != hl.end()) {
hl_iter->second.annotate(al, filename_width);
}
}
dst.emplace_back(al);
}
if (!line_meta.bm_tags.empty()) {
@ -473,6 +483,14 @@ field_overlay_source::build_meta_line(const listview_curses& lv,
}
}
al.insert(0, filename_width, ' ');
if (tc != nullptr) {
auto hl = tc->get_highlights();
auto hl_iter = hl.find({highlight_source_t::PREVIEW, "search"});
if (hl_iter != hl.end()) {
hl_iter->second.annotate(al, filename_width);
}
}
dst.emplace_back(al);
}
}

View File

@ -1,2 +1,2 @@
192.168.202.254 - - [20/Jul/2009:22:59:29 +0000] "GET /vmw/vSphere/default/vmkernel.gz HTTP/1.0" 200 78929 "-" "gPXE/0.9.7"
└ #foo
└ #foo