Skip to content

Commit 23f7320

Browse files
committed
[layout] hide help if window is small
Also, when focusing the SQL prompt, select the overlay so the user can scroll within it.
1 parent e41ece6 commit 23f7320

File tree

4 files changed

+16
-11
lines changed

4 files changed

+16
-11
lines changed

src/listview_curses.cc

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,6 @@ listview_curses::reload_data()
185185
if (curr_sel == -1_vl) {
186186
curr_sel = 0_vl;
187187
}
188-
this->lv_selection = -1_vl;
189188
this->set_selection_without_context(curr_sel);
190189
}
191190

@@ -969,6 +968,13 @@ listview_curses::handle_mouse(mouse_event& me)
969968
{
970969
this->lv_mouse_time = me.me_time;
971970
this->lv_focused_overlay_top -= 1_vl;
971+
if (this->lv_focused_overlay_selection
972+
>= this->lv_focused_overlay_top + (oc.oc_height - 1_vl))
973+
{
974+
this->lv_focused_overlay_selection
975+
= this->lv_focused_overlay_top
976+
+ oc.oc_height - 2_vl;
977+
}
972978
this->set_needs_update();
973979
}
974980

@@ -986,8 +992,8 @@ listview_curses::handle_mouse(mouse_event& me)
986992
}
987993
this->set_needs_update();
988994
}
989-
return true;
990995
}
996+
return true;
991997
}
992998
}
993999
this->shift_top(vis_line_t(scroll_polarity(me.me_button) * 2_vl),

src/lnav.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1850,12 +1850,13 @@ VALUES ('org.lnav.mouse-support', -1, DATETIME('now', '+1 minute'),
18501850
lnav_data.ld_view_stack.set_needs_update();
18511851
}
18521852
ncplane_resize_maximize(sc.get_std_plane());
1853-
if (lnav_data.ld_view_stack.do_update()) {
1854-
breadcrumb_view->set_needs_update();
1855-
}
18561853
if (prompt.p_editor.get_needs_update()) {
18571854
lnav_data.ld_doc_view.set_needs_update();
18581855
lnav_data.ld_example_view.set_needs_update();
1856+
lnav_data.ld_view_stack.set_needs_update();
1857+
}
1858+
if (lnav_data.ld_view_stack.do_update()) {
1859+
breadcrumb_view->set_needs_update();
18591860
}
18601861
lnav_data.ld_doc_view.do_update();
18611862
lnav_data.ld_example_view.do_update();

src/lnav_commands.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3628,6 +3628,7 @@ sql_prompt(std::vector<std::string>& args)
36283628
fos->fos_contexts.top().c_show = true;
36293629
tc->set_sync_selection_and_top(true);
36303630
tc->reload_data();
3631+
tc->set_overlay_selection(3_vl);
36313632
lnav_data.ld_bottom_source.set_prompt(
36323633
"Enter an SQL query: (Press "
36333634
ANSI_BOLD("CTRL+L") " for multi-line mode and "

src/view_helpers.cc

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -778,11 +778,10 @@ layout_views()
778778

779779
bool breadcrumb_open = (lnav_data.ld_mode == ln_mode_t::BREADCRUMBS);
780780

781-
auto bottom_min = std::min(2U + 3U, height);
782-
auto bottom = clamped<int>::from(height, bottom_min, height);
783-
784781
auto prompt_height = prompt.p_editor.vc_enabled ? prompt.p_editor.tc_height
785782
: 1;
783+
auto min_height = std::min(prompt_height + 1U + 10 + 2U, height);
784+
auto bottom = clamped<int>::from(height, min_height, height);
786785

787786
bottom -= prompt_height;
788787
prompt.p_editor.set_y(bottom);
@@ -791,9 +790,7 @@ layout_views()
791790

792791
breadcrumb_view->set_width(width);
793792

794-
bool vis;
795-
796-
vis = bottom.try_consume(um_height);
793+
auto vis = bottom.try_consume(um_height);
797794
lnav_data.ld_user_message_view.set_y(bottom);
798795
lnav_data.ld_user_message_view.set_visible(vis);
799796

0 commit comments

Comments
 (0)