mirror of
https://github.com/tstack/lnav
synced 2024-11-03 23:15:38 +00:00
[search-table] highlight the captured text for preview
Defect Number: Reviewed By: Testing Done:
This commit is contained in:
parent
aae3cf4d14
commit
bbf8bdc4ec
@ -55,7 +55,13 @@ void format_help_text_for_term(const help_text &ht, int width, attr_line_t &out)
|
||||
.append(ht.ht_name, &view_curses::VC_STYLE, A_BOLD);
|
||||
for (auto ¶m : ht.ht_parameters) {
|
||||
out.append(" ");
|
||||
if (param.ht_nargs == HN_OPTIONAL) {
|
||||
out.append("[");
|
||||
}
|
||||
out.append(param.ht_name, &view_curses::VC_STYLE, A_UNDERLINE);
|
||||
if (param.ht_nargs == HN_OPTIONAL) {
|
||||
out.append("]");
|
||||
}
|
||||
if (param.ht_nargs == HN_ONE_OR_MORE) {
|
||||
out.append("1", &view_curses::VC_STYLE, A_UNDERLINE);
|
||||
out.append(" [");
|
||||
|
@ -1319,7 +1319,10 @@ static string com_create_search_table(exec_context &ec, string cmdline, vector<s
|
||||
}
|
||||
else if (args.size() >= 2) {
|
||||
log_search_table *lst;
|
||||
auto_mem<pcre> code;
|
||||
const char *errptr;
|
||||
string regex;
|
||||
int eoff;
|
||||
|
||||
if (args.size() >= 3) {
|
||||
regex = remaining_args(cmdline, args, 2);
|
||||
@ -1328,6 +1331,14 @@ static string com_create_search_table(exec_context &ec, string cmdline, vector<s
|
||||
regex = lnav_data.ld_last_search[LNV_LOG];
|
||||
}
|
||||
|
||||
if ((code = pcre_compile(regex.c_str(),
|
||||
PCRE_CASELESS,
|
||||
&errptr,
|
||||
&eoff,
|
||||
NULL)) == NULL) {
|
||||
return "error: " + string(errptr);
|
||||
}
|
||||
|
||||
try {
|
||||
lst = new log_search_table(regex.c_str(),
|
||||
intern_string::lookup(args[1]));
|
||||
@ -1336,6 +1347,17 @@ static string com_create_search_table(exec_context &ec, string cmdline, vector<s
|
||||
}
|
||||
|
||||
if (ec.ec_dry_run) {
|
||||
textview_curses *tc = &lnav_data.ld_views[LNV_LOG];
|
||||
textview_curses::highlight_map_t &hm = tc->get_highlights();
|
||||
view_colors &vc = view_colors::singleton();
|
||||
highlighter hl(code.release());
|
||||
|
||||
hl.with_attrs(
|
||||
vc.ansi_color_pair(COLOR_BLACK, COLOR_CYAN) | A_BLINK);
|
||||
|
||||
hm["$bodypreview"] = hl;
|
||||
tc->reload_data();
|
||||
|
||||
attr_line_t al(lst->get_table_statement());
|
||||
|
||||
lnav_data.ld_preview_status_source.get_description()
|
||||
|
@ -174,7 +174,6 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
private:
|
||||
std::string lst_regex_string;
|
||||
pcrepp lst_regex;
|
||||
shared_buffer_ref lst_current_line;
|
||||
|
@ -53,6 +53,7 @@ void rl_change(void *dummy, readline_curses *rc)
|
||||
textview_curses *tc = lnav_data.ld_view_stack.back();
|
||||
|
||||
tc->get_highlights().erase("$preview");
|
||||
tc->get_highlights().erase("$bodypreview");
|
||||
tc->reload_data();
|
||||
lnav_data.ld_preview_source.clear();
|
||||
lnav_data.ld_preview_status_source.get_description().clear();
|
||||
@ -167,6 +168,7 @@ static void rl_search_internal(void *dummy, readline_curses *rc, bool complete =
|
||||
string name;
|
||||
|
||||
tc->get_highlights().erase("$preview");
|
||||
tc->get_highlights().erase("$bodypreview");
|
||||
tc->reload_data();
|
||||
|
||||
switch (lnav_data.ld_mode) {
|
||||
@ -364,6 +366,7 @@ void rl_abort(void *dummy, readline_curses *rc)
|
||||
lnav_data.ld_preview_status_source.get_description().clear();
|
||||
lnav_data.ld_preview_source.clear();
|
||||
tc->get_highlights().erase("$preview");
|
||||
tc->get_highlights().erase("$bodypreview");
|
||||
|
||||
lnav_data.ld_bottom_source.grep_error("");
|
||||
switch (lnav_data.ld_mode) {
|
||||
@ -393,6 +396,7 @@ void rl_callback(void *dummy, readline_curses *rc)
|
||||
lnav_data.ld_preview_status_source.get_description().clear();
|
||||
lnav_data.ld_preview_source.clear();
|
||||
tc->get_highlights().erase("$preview");
|
||||
tc->get_highlights().erase("$bodypreview");
|
||||
switch (lnav_data.ld_mode) {
|
||||
case LNM_PAGING:
|
||||
require(0);
|
||||
|
Loading…
Reference in New Issue
Block a user