mirror of https://github.com/tstack/lnav.git
[ui] move filter editor help to separate status bar
The help is unreadable when the terminal width is small.
This commit is contained in:
parent
4a7d116f37
commit
1e795c1e4a
|
@ -33,11 +33,13 @@
|
|||
#include "filter_status_source.hh"
|
||||
|
||||
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 | "
|
||||
static auto EXIT_MSG = "Press " ANSI_BOLD("TAB") " to exit ";
|
||||
|
||||
static auto HOTKEY_HELP = " "
|
||||
ANSI_BOLD("SPC") ": Enable/Disable "
|
||||
ANSI_BOLD("i") "/" ANSI_BOLD("o") ": Create in/out "
|
||||
ANSI_BOLD("ENTER") ": Edit "
|
||||
ANSI_BOLD("t") ": Toggle type "
|
||||
ANSI_BOLD("D") ": Delete ";
|
||||
|
||||
filter_status_source::filter_status_source()
|
||||
|
@ -50,18 +52,18 @@ filter_status_source::filter_status_source()
|
|||
this->tss_fields[TSF_STITCH_TITLE].set_stitch_value(
|
||||
view_colors::ansi_color_pair_index(COLOR_BLUE, COLOR_WHITE));
|
||||
|
||||
this->tss_fields[TSF_COUNT].set_width(22);
|
||||
this->tss_fields[TSF_COUNT].set_min_width(16);
|
||||
this->tss_fields[TSF_COUNT].set_share(1);
|
||||
this->tss_fields[TSF_COUNT].set_role(view_colors::VCR_STATUS);
|
||||
|
||||
this->tss_fields[TSF_FILTERED].set_width(30);
|
||||
this->tss_fields[TSF_FILTERED].set_min_width(20);
|
||||
this->tss_fields[TSF_FILTERED].set_share(1);
|
||||
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(40);
|
||||
this->tss_fields[TSF_HELP].set_width(1024);
|
||||
this->tss_fields[TSF_HELP].set_width(20);
|
||||
this->tss_fields[TSF_HELP].set_value(TOGGLE_MSG);
|
||||
this->tss_fields[TSF_HELP].set_left_pad(1);
|
||||
this->tss_fields[TSF_HELP].set_share(1);
|
||||
|
||||
this->tss_prompt.set_left_pad(1);
|
||||
this->tss_prompt.set_min_width(35);
|
||||
|
@ -74,7 +76,7 @@ filter_status_source::filter_status_source()
|
|||
size_t filter_status_source::statusview_fields()
|
||||
{
|
||||
if (lnav_data.ld_mode == LNM_FILTER) {
|
||||
this->tss_fields[TSF_HELP].set_value(HOTKEY_HELP);
|
||||
this->tss_fields[TSF_HELP].set_value(EXIT_MSG);
|
||||
} else {
|
||||
this->tss_fields[TSF_HELP].set_value(TOGGLE_MSG);
|
||||
}
|
||||
|
@ -154,3 +156,20 @@ void filter_status_source::update_filtered(text_sub_source *tss)
|
|||
sf.set_value("%'9d Lines not shown", tss->get_filtered_count());
|
||||
}
|
||||
}
|
||||
|
||||
filter_help_status_source::filter_help_status_source()
|
||||
{
|
||||
this->fss_help.set_min_width(10);
|
||||
this->fss_help.set_share(1);
|
||||
this->fss_help.set_value(HOTKEY_HELP);
|
||||
}
|
||||
|
||||
size_t filter_help_status_source::statusview_fields()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
status_field &filter_help_status_source::statusview_value_for_field(int field)
|
||||
{
|
||||
return this->fss_help;
|
||||
}
|
||||
|
|
|
@ -64,4 +64,16 @@ private:
|
|||
sig_atomic_t bss_filter_counter{0};
|
||||
};
|
||||
|
||||
class filter_help_status_source
|
||||
: public status_data_source {
|
||||
public:
|
||||
filter_help_status_source();
|
||||
|
||||
size_t statusview_fields() override;
|
||||
|
||||
status_field &statusview_value_for_field(int field) override;
|
||||
private:
|
||||
status_field fss_help;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1466,6 +1466,8 @@ static void looper()
|
|||
&lnav_data.ld_bottom_source);
|
||||
lnav_data.ld_status[LNS_FILTER].set_data_source(
|
||||
&lnav_data.ld_filter_status_source);
|
||||
lnav_data.ld_status[LNS_FILTER_HELP].set_data_source(
|
||||
&lnav_data.ld_filter_help_status_source);
|
||||
lnav_data.ld_status[LNS_DOC].set_data_source(
|
||||
&lnav_data.ld_doc_status_source);
|
||||
lnav_data.ld_status[LNS_PREVIEW].set_data_source(
|
||||
|
|
|
@ -138,6 +138,7 @@ typedef enum {
|
|||
LNS_TOP,
|
||||
LNS_BOTTOM,
|
||||
LNS_FILTER,
|
||||
LNS_FILTER_HELP,
|
||||
LNS_DOC,
|
||||
LNS_PREVIEW,
|
||||
|
||||
|
@ -243,6 +244,7 @@ struct _lnav_data {
|
|||
top_status_source ld_top_source;
|
||||
bottom_status_source ld_bottom_source;
|
||||
filter_status_source ld_filter_status_source;
|
||||
filter_help_status_source ld_filter_help_status_source;
|
||||
doc_status_source ld_doc_status_source;
|
||||
preview_status_source ld_preview_status_source;
|
||||
bool ld_preview_hidden;
|
||||
|
|
|
@ -117,7 +117,7 @@ void statusview_curses::do_update()
|
|||
}
|
||||
|
||||
if (val.length() > sf.get_width() && val.length() > 11) {
|
||||
static const std::string MIDSUB = " .. ";
|
||||
static const string MIDSUB = " .. ";
|
||||
|
||||
size_t half_width = sf.get_width() / 2 - MIDSUB.size() / 2;
|
||||
|
||||
|
@ -174,9 +174,11 @@ void statusview_curses::window_change()
|
|||
int available = remaining / divisor;
|
||||
int actual_width;
|
||||
|
||||
if (sf->get_value().length() < (sf->get_min_width() + available)) {
|
||||
if ((sf->get_left_pad() + sf->get_value().length()) <
|
||||
(sf->get_min_width() + available)) {
|
||||
actual_width = std::max((int) sf->get_min_width(),
|
||||
(int) sf->get_value().length());
|
||||
(int) (sf->get_left_pad() +
|
||||
sf->get_value().length()));
|
||||
} else {
|
||||
actual_width = sf->get_min_width() + available;
|
||||
}
|
||||
|
|
|
@ -271,12 +271,16 @@ void layout_views()
|
|||
for (auto &tc : lnav_data.ld_views) {
|
||||
tc.set_height(vis_line_t(-(bottom_height
|
||||
+ (filter_status_open ? 1 : 0)
|
||||
+ (filters_open ? 1 : 0)
|
||||
+ filter_height)));
|
||||
}
|
||||
lnav_data.ld_status[LNS_TOP].set_enabled(!filters_open);
|
||||
lnav_data.ld_status[LNS_FILTER].set_visible(filter_status_open);
|
||||
lnav_data.ld_status[LNS_FILTER].set_enabled(filters_open);
|
||||
lnav_data.ld_status[LNS_FILTER].set_top(-(bottom_height + filter_height + 1));
|
||||
lnav_data.ld_status[LNS_FILTER].set_top(
|
||||
-(bottom_height + filter_height + 1 + (filters_open ? 1 : 0)));
|
||||
lnav_data.ld_status[LNS_FILTER_HELP].set_visible(filters_open);
|
||||
lnav_data.ld_status[LNS_FILTER_HELP].set_top(-(bottom_height + filter_height + 1));
|
||||
lnav_data.ld_status[LNS_BOTTOM].set_top(-(match_height + 2));
|
||||
lnav_data.ld_status[LNS_DOC].set_top(height - bottom_height);
|
||||
lnav_data.ld_status[LNS_DOC].set_visible(doc_open);
|
||||
|
|
Loading…
Reference in New Issue