1
1
mirror of https://github.com/tstack/lnav.git synced 2024-09-11 13:05:51 +03:00

[filter] in the filter editor, use "t" to toggle the type of filter

Related to #423
This commit is contained in:
Timothy Stack 2018-12-14 07:10:50 -08:00
parent 814ad03ec9
commit a63b6a199c
7 changed files with 31 additions and 2 deletions

View File

@ -36,6 +36,7 @@ static auto TOGGLE_MSG = "Press " ANSI_BOLD("TAB") " to edit ";
static auto HOTKEY_HELP =
ANSI_BOLD("SPC") ": Enable/Disable | "
ANSI_BOLD("ENTER") ": Edit | "
ANSI_BOLD("t") ": Toggle type | "
ANSI_BOLD("i") "/" ANSI_BOLD("o") ": Create in/out | "
ANSI_BOLD("D") ": Delete ";
@ -56,7 +57,7 @@ filter_status_source::filter_status_source()
this->tss_fields[TSF_FILTERED].set_role(view_colors::VCR_BOLD_STATUS);
this->tss_fields[TSF_HELP].right_justify(true);
this->tss_fields[TSF_HELP].set_min_width(35);
this->tss_fields[TSF_HELP].set_min_width(80);
this->tss_fields[TSF_HELP].set_width(1024);
this->tss_fields[TSF_HELP].set_value(TOGGLE_MSG);
this->tss_fields[TSF_HELP].set_left_pad(1);

View File

@ -94,6 +94,27 @@ bool filter_sub_source::list_input_handle_key(listview_curses &lv, int ch)
lv.reload_data();
return true;
}
case 't': {
textview_curses *top_view = *lnav_data.ld_view_stack.top();
text_sub_source *tss = top_view->get_sub_source();
filter_stack &fs = tss->get_filters();
if (fs.empty()) {
return true;
}
shared_ptr<text_filter> tf = *(fs.begin() + lv.get_selection());
if (tf->get_type() == text_filter::INCLUDE) {
tf->set_type(text_filter::EXCLUDE);
} else {
tf->set_type(text_filter::INCLUDE);
}
tss->text_filters_changed();
lv.reload_data();
return true;
}
case 'D': {
textview_curses *top_view = *lnav_data.ld_view_stack.top();
text_sub_source *tss = top_view->get_sub_source();

View File

@ -455,6 +455,7 @@ editor. You can change the focus by pressing TAB.
i Create a new "in" filter .
SPACE Toggle the enabled/disabled state of the currently
selected filter.
t Toggle the type of filter between "in" and "out".
ENTER Edit the selected filter.
D Delete the selected filter.

View File

@ -924,6 +924,10 @@ logfile_sub_source::get_grepper()
void log_location_history::loc_history_append(vis_line_t top)
{
if (top >= this->llh_log_source.text_line_count()) {
return;
}
content_line_t cl = this->llh_log_source.at(top);
auto iter = this->llh_history.begin();

View File

@ -113,7 +113,7 @@ public:
*/
void set_value(const char *fmt, ...)
{
char buffer[128];
char buffer[256];
va_list args;
va_start(args, fmt);

View File

@ -118,6 +118,7 @@ public:
virtual ~text_filter() { };
type_t get_type() const { return this->lf_type; };
void set_type(type_t t) { this->lf_type = t; };
std::string get_id() const { return this->lf_id; };
size_t get_index() const { return this->lf_index; };

View File

@ -455,6 +455,7 @@ editor. You can change the focus by pressing TAB.
i Create a new "in" filter .
SPACE Toggle the enabled/disabled state of the currently
selected filter.
t Toggle the type of filter between "in" and "out".
ENTER Edit the selected filter.
D Delete the selected filter.