[:prompt] add breadcrumb as an option

Related to #1258
pull/1265/head
Tim Stack 1 month ago
parent 1e348993f9
commit 99c6aabfdd

@ -73,6 +73,8 @@ Features:
reports information about text that was selected with a mouse.
This makes it possible to script operations that use the
selected text as an input.
* Added `breadcrumb` as an option to the `:prompt` command so
that the breadcrumb hotkey can be configured.
Interface changes:
* The bar charts in the DB view have now been moved to their

@ -794,6 +794,11 @@
"title": "/ui/keymap-defs/<keymap_name>/<key_seq>",
"type": "object",
"properties": {
"id": {
"title": "/ui/keymap-defs/<keymap_name>/<key_seq>/id",
"description": "The identifier that can be used to refer to this key",
"type": "string"
},
"command": {
"title": "/ui/keymap-defs/<keymap_name>/<key_seq>/command",
"description": "The command to execute for the given key sequence. Use a script to execute more complicated operations.",

@ -145,8 +145,7 @@ key_sql_callback(exec_context& ec, sqlite3_stmt* stmt)
bool
handle_keyseq(const char* keyseq)
{
key_map& km = lnav_config.lc_active_keymap;
const auto& km = lnav_config.lc_active_keymap;
const auto& iter = km.km_seq_to_cmd.find(keyseq);
if (iter == km.km_seq_to_cmd.end()) {
return false;

@ -129,7 +129,7 @@ CREATE TABLE lnav_user_notifications
INSERT INTO lnav_user_notifications (id, priority, expiration, message)
VALUES ('org.lnav.breadcrumb.focus', -1, DATETIME('now', '+2 minute'),
'Press <span class="-lnav_status-styles_hotkey">`</span> to focus on the breadcrumb bar');
'Press <span class="-lnav_status-styles_hotkey">${org.lnav.key.breadcrumb.focus}</span> to focus on the breadcrumb bar');
CREATE TABLE lnav_views_echo AS
SELECT name, top, "left", height, inner_height, top_time, search

@ -171,6 +171,10 @@
"command": ":toggle-view pretty",
"alt-msg": "${keymap_def_pop_view}"
},
"x60": {
"id": "org.lnav.key.breadcrumb.focus",
"command": ":prompt breadcrumb"
},
"x76": {
"command": ":toggle-view db"
},

@ -20,6 +20,13 @@
},
"x2b": {
"command": ";UPDATE lnav_views SET paused = 1 - paused"
},
"x60": {
"id": ""
},
"xc2xa7": {
"id": "org.lnav.key.breadcrumb.focus",
"command": ":prompt breadcrumb"
}
}
}

@ -219,6 +219,9 @@ static auto bound_lnav_flags
= injector::bind<unsigned long, lnav_flags_tag>::to_instance(
&lnav_data.ld_flags);
static auto bound_lnav_exec_context
= injector::bind<exec_context>::to_instance(&lnav_data.ld_exec_context);
static auto bound_last_rel_time
= injector::bind<relative_time, last_relative_time_tag>::to_singleton();
@ -746,12 +749,6 @@ handle_key(int ch)
default: {
switch (lnav_data.ld_mode) {
case ln_mode_t::PAGING:
if (ch == '`') {
breadcrumb_view->focus();
lnav_data.ld_mode = ln_mode_t::BREADCRUMBS;
return true;
}
return handle_paging_key(ch);
case ln_mode_t::BREADCRUMBS:

@ -52,6 +52,7 @@
#include "base/paths.hh"
#include "base/string_util.hh"
#include "bound_tags.hh"
#include "breadcrumb_curses.hh"
#include "command_executor.hh"
#include "config.h"
#include "curl_looper.hh"
@ -5590,6 +5591,12 @@ com_quit(exec_context& ec, std::string cmdline, std::vector<std::string>& args)
return Ok(std::string());
}
static void
breadcrumb_prompt(std::vector<std::string>& args)
{
set_view_mode(ln_mode_t::BREADCRUMBS);
}
static void
command_prompt(std::vector<std::string>& args)
{
@ -5885,6 +5892,7 @@ com_prompt(exec_context& ec,
{
static std::map<std::string, std::function<void(std::vector<std::string>&)>>
PROMPT_TYPES = {
{"breadcrumb", breadcrumb_prompt},
{"command", command_prompt},
{"script", script_prompt},
{"search", search_prompt},
@ -5949,8 +5957,15 @@ readline_context::command_t STD_COMMANDS[] = {
"Perform the alternate action "
"for this prompt by default")
.optional())
.with_parameter(
help_text("prompt", "The prompt to display").optional())
.with_parameter(help_text("prompt", "The prompt to display")
.with_enum_values({
"breadcrumb",
"command",
"script",
"search",
"sql",
})
.optional())
.with_parameter(
help_text("initial-value",
"The initial value to fill in for the prompt")

@ -56,8 +56,10 @@
#include "base/paths.hh"
#include "base/string_util.hh"
#include "bin2c.hh"
#include "command_executor.hh"
#include "config.h"
#include "default-config.h"
#include "scn/scn.h"
#include "styling.hh"
#include "view_curses.hh"
#include "yajlpp/yajlpp.hh"
@ -486,6 +488,11 @@ config_error_reporter(const yajlpp_parse_context& ypc,
}
static const struct json_path_container key_command_handlers = {
yajlpp::property_handler("id")
.with_synopsis("<id>")
.with_description(
"The identifier that can be used to refer to this key")
.for_field(&key_command::kc_id),
yajlpp::property_handler("command")
.with_synopsis("<command>")
.with_description(
@ -1566,6 +1573,39 @@ public:
lnav_config.lc_active_keymap.km_seq_to_cmd[pair.first]
= pair.second;
}
auto& ec = injector::get<exec_context&>();
for (const auto& pair : lnav_config.lc_active_keymap.km_seq_to_cmd) {
if (pair.second.kc_id.empty()) {
continue;
}
std::string keystr;
auto sv = string_fragment::from_str(pair.first).to_string_view();
while (!sv.empty()) {
int32_t value;
auto scan_res = scn::scan(sv, "x{:2x}", value);
if (!scan_res) {
throw "invalid hex input";
}
auto ch = (char) (value & 0xff);
switch (ch) {
case '\t':
keystr.append("TAB");
break;
case '\r':
keystr.append("ENTER");
break;
default:
keystr.push_back(ch);
break;
}
sv = scan_res.range_as_string_view();
}
ec.ec_global_vars[pair.second.kc_id] = keystr;
}
}
};

@ -80,6 +80,7 @@ bool update_installs_from_git();
void install_extra_formats();
struct key_command {
std::string kc_id;
std::string kc_cmd;
std::string kc_alt_msg;
};

@ -1421,6 +1421,10 @@ clear_preview()
void
set_view_mode(ln_mode_t mode)
{
if (mode == lnav_data.ld_mode) {
return;
}
static auto* breadcrumb_view = injector::get<breadcrumb_curses*>();
switch (lnav_data.ld_mode) {
@ -1431,6 +1435,14 @@ set_view_mode(ln_mode_t mode)
default:
break;
}
switch (mode) {
case ln_mode_t::BREADCRUMBS: {
breadcrumb_view->focus();
break;
}
default:
break;
}
lnav_data.ld_mode = mode;
}

@ -4701,408 +4701,522 @@
"keymap-defs": {
"de": {
"x21": {
"id": "",
"command": ":goto last 10 minutes after the hour",
"alt-msg": ""
},
"x22": {
"id": "",
"command": ":goto last 20 minutes after the hour",
"alt-msg": ""
},
"x24": {
"id": "",
"command": ":goto last 40 minutes after the hour",
"alt-msg": ""
},
"x25": {
"id": "",
"command": ":goto last 50 minutes after the hour",
"alt-msg": ""
},
"x26": {
"id": "",
"command": ":goto last hour",
"alt-msg": ""
},
"x31": {
"id": "",
"command": ":goto next 10 minutes after the hour",
"alt-msg": ""
},
"x32": {
"id": "",
"command": ":goto next 20 minutes after the hour",
"alt-msg": ""
},
"x33": {
"id": "",
"command": ":goto next 30 minutes after the hour",
"alt-msg": ""
},
"x34": {
"id": "",
"command": ":goto next 40 minutes after the hour",
"alt-msg": ""
},
"x35": {
"id": "",
"command": ":goto next 50 minutes after the hour",
"alt-msg": ""
},
"x36": {
"id": "",
"command": ":goto next hour",
"alt-msg": ""
},
"x37": {
"id": "",
"command": ":goto previous minute",
"alt-msg": ""
},
"x38": {
"id": "",
"command": ":goto next minute",
"alt-msg": ""
},
"xc2xa7": {
"id": "",
"command": ":goto last 30 minutes after the hour",
"alt-msg": ""
}
},
"default": {
"x04": {
"id": "",
"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)",
"alt-msg": ""
},
"x06": {
"id": "",
"command": ";UPDATE lnav_view_filters SET enabled = 1 - enabled WHERE view_name = (SELECT name FROM lnav_view_stack WHERE name in ('log', 'text') ORDER BY rowid DESC LIMIT 1)",
"alt-msg": ""
},
"x0c": {
"id": "",
"command": ":write-screen-to -",
"alt-msg": ""
},
"x12": {
"id": "",
"command": ":reset-session",
"alt-msg": ""
},
"x15": {
"id": "",
"command": ";UPDATE lnav_views SET top = max(0, top - (height / 2)), selection = (CASE movement WHEN 'top' THEN selection ELSE max(0, top - (height / 2) + (selection - top)) END) WHERE name = (SELECT name FROM lnav_top_view)",
"alt-msg": ""
},
"x17": {
"id": "",
"command": ";UPDATE lnav_views SET options = json_set(options, '$.word-wrap', CASE jget(options, '/word-wrap', 'none') WHEN 'none' THEN 'normal' ELSE 'none' END) WHERE name = (SELECT name FROM lnav_top_view)",
"alt-msg": ""
},
"x18": {
"id": "",
"command": ";UPDATE lnav_views SET movement = (CASE movement WHEN 'top' THEN 'cursor' ELSE 'top' END) WHERE name = (SELECT name FROM lnav_top_view)",
"alt-msg": ""
},
"x21": {
"id": "",
"command": ":goto last 10 minutes after the hour",
"alt-msg": ""
},
"x23": {
"id": "",
"command": ":goto last 30 minutes after the hour",
"alt-msg": ""
},
"x24": {
"id": "",
"command": ":goto last 40 minutes after the hour",
"alt-msg": ""
},
"x25": {
"id": "",
"command": ":goto last 50 minutes after the hour",
"alt-msg": ""
},
"x2f": {
"id": "",
"command": ":prompt search",
"alt-msg": ""
},
"x31": {
"id": "",
"command": ":goto next 10 minutes after the hour",
"alt-msg": ""
},
"x32": {
"id": "",
"command": ":goto next 20 minutes after the hour",
"alt-msg": ""
},
"x33": {
"id": "",
"command": ":goto next 30 minutes after the hour",
"alt-msg": ""
},
"x34": {
"id": "",
"command": ":goto next 40 minutes after the hour",
"alt-msg": ""
},
"x35": {
"id": "",
"command": ":goto next 50 minutes after the hour",
"alt-msg": ""
},
"x36": {
"id": "",
"command": ":goto next hour",
"alt-msg": ""
},
"x37": {
"id": "",
"command": ":goto previous minute",
"alt-msg": ""
},
"x38": {
"id": "",
"command": ":goto next minute",
"alt-msg": ""
},
"x3a": {
"id": "",
"command": ":prompt command",
"alt-msg": ""
},
"x3b": {
"id": "",
"command": ":prompt sql",
"alt-msg": ""
},
"x3d": {
"id": "",
"command": ";UPDATE lnav_views SET paused = 1 - paused",
"alt-msg": ""
},
"x3f": {
"id": "",
"command": ":toggle-view help",
"alt-msg": ""
},
"x40": {
"id": "",
"command": ":goto last 20 minutes after the hour",
"alt-msg": ""
},
"x45": {
"id": "",
"command": ":prev-mark error",
"alt-msg": "${keymap_def_alt_warning}"
},
"x4e": {
"id": "",
"command": ":prev-mark search",
"alt-msg": "${keymap_def_scroll_horiz}"
},
"x50": {
"id": "",
"command": ":toggle-view pretty",
"alt-msg": "${keymap_def_pop_view}"
},
"x51": {
"id": "",
"command": "|lnav-pop-view ${keyseq}",
"alt-msg": ""
},
"x54": {
"id": "",
"command": ";UPDATE lnav_views SET options = json_set(options, '$.row-time-offset', CASE jget(options, '/row-time-offset', 'hide') WHEN 'hide' THEN 'show' ELSE 'hide' END) WHERE name = (SELECT name FROM lnav_top_view)",
"alt-msg": "${keymap_def_time_offset}"
},
"x55": {
"id": "",
"command": ":prev-mark",
"alt-msg": ""
},
"x57": {
"id": "",
"command": ":prev-mark warning",
"alt-msg": "${keymap_def_alt_hour_boundary}"
},
"x58": {
"id": "",
"command": ":close",
"alt-msg": ""
},
"x5e": {
"id": "",
"command": ":goto last hour",
"alt-msg": ""
},
"x60": {
"id": "org.lnav.key.breadcrumb.focus",
"command": ":prompt breadcrumb",
"alt-msg": ""
},
"x63": {
"id": "",
"command": "|lnav-copy-text",
"alt-msg": "${keymap_def_clear}"
},
"x65": {
"id": "",
"command": ":next-mark error",
"alt-msg": "${keymap_def_alt_warning}"
},
"x67": {
"id": "",
"command": ":goto 0",
"alt-msg": ""
},
"x69": {
"id": "",
"command": ":toggle-view histogram",
"alt-msg": "${keymap_def_zoom}"
},
"x6d": {
"id": "",
"command": ":mark",
"alt-msg": "${keymap_def_next_user_mark}"
},
"x6e": {
"id": "",
"command": ":next-mark search",
"alt-msg": "${keymap_def_scroll_horiz}"
},
"x70": {
"id": "",
"command": ";UPDATE lnav_views SET options = json_set(options, '$.row-details', CASE jget(options, '/row-details', 'hide') WHEN 'hide' THEN 'show' ELSE 'hide' END) WHERE name = (SELECT name FROM lnav_top_view)",
"alt-msg": ""
},
"x71": {
"id": "",
"command": "|lnav-pop-view ${keyseq}",
"alt-msg": ""
},
"x75": {
"id": "",
"command": ":next-mark",
"alt-msg": "${keymap_def_next_mark}"
},
"x76": {
"id": "",
"command": ":toggle-view db",
"alt-msg": ""
},
"x77": {
"id": "",
"command": ":next-mark warning",
"alt-msg": "${keymap_def_alt_hour_boundary}"
},
"x78": {
"id": "",
"command": ";UPDATE lnav_views SET options = json_set(options, '$.hidden-fields', CASE jget(options, '/hidden-fields', 'hide') WHEN 'hide' THEN 'show' ELSE 'hide' END) WHERE name = (SELECT name FROM lnav_top_view)",
"alt-msg": ""
},
"x7b": {
"id": "",
"command": ":prev-section",
"alt-msg": "${keymap_def_next_location}"
},
"x7c": {
"id": "",
"command": ":prompt script",
"alt-msg": ""
},
"x7d": {
"id": "",
"command": ":next-section",
"alt-msg": "${keymap_def_prev_location}"
}
},
"fr": {
"x22": {
"id": "",
"command": ":goto next 30 minutes after the hour",
"alt-msg": ""
},
"x26": {
"id": "",
"command": ":goto next 10 minutes after the hour",
"alt-msg": ""
},
"x27": {
"id": "",
"command": ":goto next 40 minutes after the hour",
"alt-msg": ""
},
"x28": {
"id": "",
"command": ":goto next 50 minutes after the hour",
"alt-msg": ""
},
"x2d": {
"id": "",
"command": ":goto next hour",
"alt-msg": ""
},
"x31": {
"id": "",
"command": ":goto last 10 minutes after the hour",
"alt-msg": ""
},
"x32": {
"id": "",
"command": ":goto last 20 minutes after the hour",
"alt-msg": ""
},
"x33": {
"id": "",
"command": ":goto last 30 minutes after the hour",
"alt-msg": ""
},
"x34": {
"id": "",
"command": ":goto last 40 minutes after the hour",
"alt-msg": ""
},
"x35": {
"id": "",
"command": ":goto last 50 minutes after the hour",
"alt-msg": ""
},
"x36": {
"id": "",
"command": ":goto last hour",
"alt-msg": ""
},
"x37": {
"id": "",
"command": ":goto previous minute",
"alt-msg": ""
},
"xc3xa8": {
"id": "",
"command": ":goto next minute",
"alt-msg": ""
},
"xc3xa9": {
"id": "",
"command": ":goto next 20 minutes after the hour",
"alt-msg": ""
}
},
"sv": {
"x22": {
"id": "",
"command": ":goto last 20 minutes after the hour",
"alt-msg": ""
},
"x26": {
"id": "",
"command": ":goto last hour",
"alt-msg": ""
},
"x2b": {
"id": "",
"command": ";UPDATE lnav_views SET paused = 1 - paused",
"alt-msg": ""
},
"x3d": {
"id": "",
"command": ":goto last day",
"alt-msg": ""
},
"x60": {
"id": "",
"command": "",
"alt-msg": ""
},
"xc2xa4": {
"id": "",
"command": ":goto last 40 minutes after the hour",
"alt-msg": ""
},
"xc2xa7": {
"id": "org.lnav.key.breadcrumb.focus",
"command": ":prompt breadcrumb",
"alt-msg": ""
},
"xe2x82xac": {
"id": "",
"command": ":goto last 40 minutes after the hour",
"alt-msg": ""
}
},
"uk": {
"x22": {
"id": "",
"command": ":goto last 20 minutes after the hour",
"alt-msg": ""
},
"xc2xa3": {
"id": "",
"command": ":goto last 30 minutes after the hour",
"alt-msg": ""
}
},
"us": {
"x21": {
"id": "",
"command": ":goto last 10 minutes after the hour",
"alt-msg": ""
},
"x23": {
"id": "",
"command": ":goto last 30 minutes after the hour",
"alt-msg": ""
},
"x24": {
"id": "",
"command": ":goto last 40 minutes after the hour",
"alt-msg": ""
},
"x25": {
"id": "",
"command": ":goto last 50 minutes after the hour",
"alt-msg": ""
},
"x31": {
"id": "",
"command": ":goto next 10 minutes after the hour",
"alt-msg": ""
},
"x32": {
"id": "",
"command": ":goto next 20 minutes after the hour",
"alt-msg": ""
},
"x33": {
"id": "",
"command": ":goto next 30 minutes after the hour",
"alt-msg": ""
},
"x34": {
"id": "",
"command": ":goto next 40 minutes after the hour",
"alt-msg": ""
},
"x35": {
"id": "",
"command": ":goto next 50 minutes after the hour",
"alt-msg": ""
},
"x36": {
"id": "",
"command": ":goto next hour",
"alt-msg": ""
},
"x37": {
"id": "",
"command": ":goto previous minute",
"alt-msg": ""
},
"x38": {
"id": "",
"command": ":goto next minute",
"alt-msg": ""
},
"x40": {
"id": "",
"command": ":goto last 20 minutes after the hour",
"alt-msg": ""
},
"x5e": {
"id": "",
"command": ":goto last hour",
"alt-msg": ""
}

@ -103,7 +103,7 @@
/ui/keymap-defs/default/x4e/command -> default-keymap.json:128
/ui/keymap-defs/default/x50/alt-msg -> default-keymap.json:172
/ui/keymap-defs/default/x50/command -> default-keymap.json:171
/ui/keymap-defs/default/x51/command -> default-keymap.json:181
/ui/keymap-defs/default/x51/command -> default-keymap.json:185
/ui/keymap-defs/default/x54/alt-msg -> default-keymap.json:137
/ui/keymap-defs/default/x54/command -> default-keymap.json:136
/ui/keymap-defs/default/x55/command -> default-keymap.json:153
@ -111,6 +111,8 @@
/ui/keymap-defs/default/x57/command -> default-keymap.json:109
/ui/keymap-defs/default/x58/command -> default-keymap.json:86
/ui/keymap-defs/default/x5e/command -> default-keymap.json:62
/ui/keymap-defs/default/x60/command -> default-keymap.json:176
/ui/keymap-defs/default/x60/id -> default-keymap.json:175
/ui/keymap-defs/default/x63/alt-msg -> default-keymap.json:118
/ui/keymap-defs/default/x63/command -> default-keymap.json:117
/ui/keymap-defs/default/x65/alt-msg -> default-keymap.json:106
@ -123,10 +125,10 @@
/ui/keymap-defs/default/x6e/alt-msg -> default-keymap.json:133
/ui/keymap-defs/default/x6e/command -> default-keymap.json:132
/ui/keymap-defs/default/x70/command -> default-keymap.json:140
/ui/keymap-defs/default/x71/command -> default-keymap.json:178
/ui/keymap-defs/default/x71/command -> default-keymap.json:182
/ui/keymap-defs/default/x75/alt-msg -> default-keymap.json:150
/ui/keymap-defs/default/x75/command -> default-keymap.json:149
/ui/keymap-defs/default/x76/command -> default-keymap.json:175
/ui/keymap-defs/default/x76/command -> default-keymap.json:179
/ui/keymap-defs/default/x77/alt-msg -> default-keymap.json:114
/ui/keymap-defs/default/x77/command -> default-keymap.json:113
/ui/keymap-defs/default/x78/command -> default-keymap.json:143
@ -153,7 +155,10 @@
/ui/keymap-defs/sv/x26/command -> sv-keymap.json:16
/ui/keymap-defs/sv/x2b/command -> sv-keymap.json:22
/ui/keymap-defs/sv/x3d/command -> sv-keymap.json:19
/ui/keymap-defs/sv/x60/id -> sv-keymap.json:25
/ui/keymap-defs/sv/xc2xa4/command -> sv-keymap.json:10
/ui/keymap-defs/sv/xc2xa7/command -> sv-keymap.json:29
/ui/keymap-defs/sv/xc2xa7/id -> sv-keymap.json:28
/ui/keymap-defs/sv/xe2x82xac/command -> sv-keymap.json:13
/ui/keymap-defs/uk/x22/command -> uk-keymap.json:7
/ui/keymap-defs/uk/xc2xa3/command -> uk-keymap.json:10

@ -1394,6 +1394,7 @@ For support questions, email:
--alt Perform the alternate action for
this prompt by default
prompt The prompt to display
Values: breadcrumb|command|script|search|sql
initial-value The initial value to fill in for
the prompt

Loading…
Cancel
Save