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

[cursor] some more fixes for the new cursor support

related to #1088
This commit is contained in:
Tim Stack 2023-06-15 21:28:20 -07:00
parent 6f0f66a418
commit f44e04d854
7 changed files with 12 additions and 51 deletions

View File

@ -220,6 +220,6 @@ while COUNTER < 5000:
fp.write(next(gen))
# if random.uniform(0.0, 1.0) < 0.010:
# fp.truncate(0)
# time.sleep(random.uniform(0.01, 0.02))
time.sleep(random.uniform(0.01, 0.02))
# if random.uniform(0.0, 1.0) < 0.001:
# os.remove(fname)

View File

@ -133,10 +133,9 @@ bottom_status_source::update_marks(listview_curses* lc)
bookmark_vector<vis_line_t>& bv = bm[&textview_curses::BM_SEARCH];
if (!bv.empty() || !tc->get_current_search().empty()) {
bookmark_vector<vis_line_t>::iterator lb;
lb = std::lower_bound(bv.begin(), bv.end(), tc->get_top());
if (lb != bv.end() && *lb == tc->get_top()) {
auto vl = tc->get_selection();
auto lb = std::lower_bound(bv.begin(), bv.end(), vl);
if (lb != bv.end() && *lb == vl) {
sf.set_value(" Hit %'d of %'d for ",
std::distance(bv.begin(), lb) + 1,
tc->get_match_count());

View File

@ -73,10 +73,10 @@
"command": ";UPDATE lnav_views SET movement = (CASE movement WHEN 'top' THEN 'cursor' ELSE 'top' END) WHERE name = (SELECT name FROM lnav_top_view)"
},
"x04": {
"command": ";UPDATE lnav_views SET top = top + (height / 2) WHERE name = (SELECT name FROM lnav_top_view)"
"command": ";UPDATE lnav_views SET top = top + (height / 2), selection = (CASE movement WHEN 'top' THEN selection ELSE top + (height / 2) + (selection - top) END) WHERE name = (SELECT name FROM lnav_top_view)"
},
"x15": {
"command": ";UPDATE lnav_views SET top = top - (height / 2) WHERE name = (SELECT name FROM lnav_top_view)"
"command": ";UPDATE lnav_views SET top = top - (height / 2), selection = (CASE movement WHEN 'top' THEN selection ELSE top - (height / 2) + (selection - top) END) WHERE name = (SELECT name FROM lnav_top_view)"
},
"x3d": {
"command": ";UPDATE lnav_views SET paused = 1 - paused"

View File

@ -508,6 +508,8 @@ public:
return *this;
}
vis_line_t get_tail_space() const { return this->lv_tail_space; }
void log_state()
{
log_debug("listview_curses=%p", this);

View File

@ -970,7 +970,7 @@ next_cluster(nonstd::optional<vis_line_t> (bookmark_vector<vis_line_t>::*f)(
int diff = new_top.value() - last_top;
hit_count += 1;
if (!top_is_marked || diff > 1) {
if (tc->is_selectable() || !top_is_marked || diff > 1) {
return new_top;
}
if (hit_count > 1 && std::abs(new_top.value() - top) >= tc_height) {
@ -1009,8 +1009,7 @@ moveto_cluster(nonstd::optional<vis_line_t> (bookmark_vector<vis_line_t>::*f)(
auto new_top = next_cluster(f, bt, top);
if (!new_top) {
new_top = next_cluster(
f, bt, tc->is_selectable() ? tc->get_selection() : tc->get_top());
new_top = next_cluster(f, bt, tc->get_selection());
}
if (new_top != -1) {
tc->get_sub_source()->get_location_history() |
@ -1029,48 +1028,10 @@ moveto_cluster(nonstd::optional<vis_line_t> (bookmark_vector<vis_line_t>::*f)(
return false;
}
void
previous_cluster(const bookmark_type_t* bt, textview_curses* tc)
{
key_repeat_history& krh = lnav_data.ld_key_repeat_history;
vis_line_t height, initial_top;
unsigned long width;
if (tc->is_selectable()) {
initial_top = tc->get_selection();
} else {
initial_top = tc->get_top();
}
auto new_top
= next_cluster(&bookmark_vector<vis_line_t>::prev, bt, initial_top);
tc->get_dimensions(height, width);
if (krh.krh_count > 1 && initial_top < (krh.krh_start_line - (1.5 * height))
&& (!new_top || ((initial_top - new_top.value()) < height)))
{
bookmark_vector<vis_line_t>& bv = tc->get_bookmarks()[bt];
new_top = bv.next(std::max(0_vl, initial_top - height));
}
if (new_top) {
tc->get_sub_source()->get_location_history() |
[new_top](auto lh) { lh->loc_history_append(new_top.value()); };
if (tc->is_selectable()) {
tc->set_selection(new_top.value());
} else {
tc->set_top(new_top.value());
}
} else {
alerter::singleton().chime("no previous bookmark");
}
}
vis_line_t
search_forward_from(textview_curses* tc)
{
vis_line_t height,
retval = tc->is_selectable() ? tc->get_selection() : tc->get_top();
vis_line_t height, retval = tc->get_selection();
auto& krh = lnav_data.ld_key_repeat_history;
unsigned long width;

View File

@ -95,7 +95,6 @@ bool moveto_cluster(nonstd::optional<vis_line_t> (
bookmark_vector<vis_line_t>::*f)(vis_line_t) const,
const bookmark_type_t* bt,
vis_line_t top);
void previous_cluster(const bookmark_type_t* bt, textview_curses* tc);
vis_line_t search_forward_from(textview_curses* tc);
textview_curses* get_textview_for_mode(ln_mode_t mode);

View File

@ -459,7 +459,7 @@ CREATE TABLE lnav_views (
auto cur_sel = tc.get_selection();
auto cur_top = tc.get_top();
auto cur_bot = tc.get_bottom();
auto cur_bot = tc.get_bottom() - tc.get_tail_space();
if (cur_sel < cur_top) {
tc.set_selection(cur_top);