[hotkey] the "P" hotkey was not toggling the view

Fixes #522
pull/524/head
Timothy Stack 6 years ago
parent d1da7b800c
commit bc8e51914a

@ -99,6 +99,7 @@ Display
top left and right sides of the view, respectively.
* switch-to-view <name> - Switch to the given view name (e.g. log, text, ...)
* toggle-view <name> - Toggle the display of the given view (e.g. log, text, ...)
* zoom-to <zoom-level> - Set the zoom level for the histogram view.

@ -921,10 +921,6 @@ void handle_paging_key(int ch)
}
break;
case 'P':
toggle_view(&lnav_data.ld_views[LNV_PRETTY]);
break;
case 't':
if (lnav_data.ld_text_source.current_file() == NULL) {
alerter::singleton().chime();
@ -980,14 +976,6 @@ void handle_paging_key(int ch)
}
break;
case '?':
toggle_view(&lnav_data.ld_views[LNV_HELP]);
break;
case 'v':
toggle_view(&lnav_data.ld_views[LNV_DB]);
break;
case 'V':
{
textview_curses *db_tc = &lnav_data.ld_views[LNV_DB];

@ -36,7 +36,9 @@
":eval :alt-msg ${keymap_def_scroll_horiz}"
],
"x50": [":switch-to-view pretty"],
"x3f": [":toggle-view help"],
"x50": [":toggle-view pretty"],
"x76": [":toggle-view db"],
"x71": ["|lnav-pop-view ${keyseq}"],
"x51": ["|lnav-pop-view ${keyseq}"]

@ -938,6 +938,9 @@ bool toggle_view(textview_curses *toggle_tc)
require(toggle_tc < &lnav_data.ld_views[LNV__MAX]);
if (tc == toggle_tc) {
if (lnav_data.ld_view_stack.size() == 1) {
return false;
}
lnav_data.ld_last_view = tc;
lnav_data.ld_view_stack.pop_back();
}

@ -2437,7 +2437,11 @@ static string com_switch_to_view(exec_context &ec, string cmdline, vector<string
for (int lpc = 0; lnav_view_strings[lpc] && !found; lpc++) {
if (strcasecmp(args[1].c_str(), lnav_view_strings[lpc]) == 0) {
if (!ec.ec_dry_run) {
ensure_view(&lnav_data.ld_views[lpc]);
if (args[0] == "switch-to-view") {
ensure_view(&lnav_data.ld_views[lpc]);
} else {
toggle_view(&lnav_data.ld_views[lpc]);
}
}
found = true;
}
@ -4000,6 +4004,16 @@ readline_context::command_t STD_COMMANDS[] = {
.with_parameter(help_text("view-name", "The name of the view to switch to."))
.with_example({"schema"})
},
{
"toggle-view",
com_switch_to_view,
help_text(":toggle-view")
.with_summary("Switch to the given view or, if it is already displayed, "
"switch to the previous view")
.with_parameter(help_text("view-name", "The name of the view to toggle the display of."))
.with_example({"schema"})
},
{
"reset-session",
com_reset_session,

Loading…
Cancel
Save