mirror of https://github.com/tstack/lnav.git
[ui] update status on keypress and delay rescan/rebuild
This commit is contained in:
parent
d5d44e63b3
commit
75ead0eb60
|
@ -445,3 +445,36 @@ bool listview_curses::handle_mouse(mouse_event &me)
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
void listview_curses::set_top(vis_line_t top, bool suppress_flash)
|
||||
{
|
||||
auto inner_height = this->get_inner_height();
|
||||
|
||||
if (inner_height > 0 && top >= inner_height) {
|
||||
top = vis_line_t(inner_height - 1);
|
||||
}
|
||||
if (top < 0 || (top > 0 && top >= inner_height)) {
|
||||
if (suppress_flash == false) {
|
||||
alerter::singleton().chime();
|
||||
}
|
||||
}
|
||||
else if (this->lv_top != top) {
|
||||
this->lv_top = top;
|
||||
if (this->lv_selectable) {
|
||||
if (this->lv_selection < top) {
|
||||
this->lv_selection = top;
|
||||
} else {
|
||||
auto bot = this->get_bottom();
|
||||
|
||||
if (bot != -1_vl) {
|
||||
if (this->lv_selection > bot) {
|
||||
this->lv_selection = bot;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
log_debug("invoke");
|
||||
this->invoke_scroll();
|
||||
this->set_needs_update();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -321,37 +321,7 @@ public:
|
|||
* @param top The new value for top.
|
||||
* @param suppress_flash Don't call flash() if the top is out-of-bounds.
|
||||
*/
|
||||
void set_top(vis_line_t top, bool suppress_flash = false)
|
||||
{
|
||||
auto inner_height = this->get_inner_height();
|
||||
|
||||
if (inner_height > 0 && top >= inner_height) {
|
||||
top = vis_line_t(inner_height - 1);
|
||||
}
|
||||
if (top < 0 || (top > 0 && top >= inner_height)) {
|
||||
if (suppress_flash == false) {
|
||||
alerter::singleton().chime();
|
||||
}
|
||||
}
|
||||
else if (this->lv_top != top) {
|
||||
this->lv_top = top;
|
||||
if (this->lv_selectable) {
|
||||
if (this->lv_selection < top) {
|
||||
this->lv_selection = top;
|
||||
} else {
|
||||
auto bot = this->get_bottom();
|
||||
|
||||
if (bot != -1_vl) {
|
||||
if (this->lv_selection > bot) {
|
||||
this->lv_selection = bot;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
this->invoke_scroll();
|
||||
this->set_needs_update();
|
||||
}
|
||||
};
|
||||
void set_top(vis_line_t top, bool suppress_flash = false);
|
||||
|
||||
/** @return The line number that is displayed at the top. */
|
||||
vis_line_t get_top() const { return this->lv_top; };
|
||||
|
|
23
src/lnav.cc
23
src/lnav.cc
|
@ -1360,6 +1360,16 @@ static void looper()
|
|||
|
||||
lnav_data.ld_view_stack.vs_views.push_back(&lnav_data.ld_views[LNV_LOG]);
|
||||
|
||||
sb.push_back(clear_last_user_mark);
|
||||
sb.push_back(bind_mem(&top_status_source::update_filename, &lnav_data.ld_top_source));
|
||||
vsb.push_back(bind_mem(&top_status_source::update_view_name, &lnav_data.ld_top_source));
|
||||
sb.push_back(bind_mem(&bottom_status_source::update_line_number, &lnav_data.ld_bottom_source));
|
||||
sb.push_back(bind_mem(&bottom_status_source::update_percent, &lnav_data.ld_bottom_source));
|
||||
sb.push_back(bind_mem(&bottom_status_source::update_marks, &lnav_data.ld_bottom_source));
|
||||
sb.push_back(bind_mem(&term_extra::update_title, injector::get<term_extra*>()));
|
||||
|
||||
vsb.push_back(sb);
|
||||
|
||||
for (lpc = 0; lpc < LNV__MAX; lpc++) {
|
||||
lnav_data.ld_views[lpc].set_window(lnav_data.ld_window);
|
||||
lnav_data.ld_views[lpc].set_y(1);
|
||||
|
@ -1412,16 +1422,6 @@ static void looper()
|
|||
lnav_data.ld_status[LNS_PREVIEW].set_data_source(
|
||||
&lnav_data.ld_preview_status_source);
|
||||
|
||||
vsb.push_back(sb);
|
||||
|
||||
sb.push_back(clear_last_user_mark);
|
||||
sb.push_back(bind_mem(&top_status_source::update_filename, &lnav_data.ld_top_source));
|
||||
vsb.push_back(bind_mem(&top_status_source::update_view_name, &lnav_data.ld_top_source));
|
||||
sb.push_back(bind_mem(&bottom_status_source::update_line_number, &lnav_data.ld_bottom_source));
|
||||
sb.push_back(bind_mem(&bottom_status_source::update_percent, &lnav_data.ld_bottom_source));
|
||||
sb.push_back(bind_mem(&bottom_status_source::update_marks, &lnav_data.ld_bottom_source));
|
||||
sb.push_back(bind_mem(&term_extra::update_title, injector::get<term_extra*>()));
|
||||
|
||||
lnav_data.ld_match_view.set_show_bottom_border(true);
|
||||
|
||||
for (auto &sc : lnav_data.ld_status) {
|
||||
|
@ -1685,6 +1685,9 @@ static void looper()
|
|||
if (pollfd_ready(pollfds, STDIN_FILENO)) {
|
||||
int ch;
|
||||
|
||||
next_status_update_time = ui_clock::now();
|
||||
next_rescan_time = next_status_update_time + 1s;
|
||||
next_rebuild_time = next_rescan_time;
|
||||
while ((ch = getch()) != ERR) {
|
||||
alerter::singleton().new_input(ch);
|
||||
|
||||
|
|
Loading…
Reference in New Issue