mirror of
https://github.com/tstack/lnav.git
synced 2024-08-16 16:30:25 +03:00
[sql] support doing an UPDATE on the lnav_top_view SQL view
This commit is contained in:
parent
984e133292
commit
54b391e53f
3
NEWS.md
3
NEWS.md
@ -25,6 +25,9 @@ Bug Fixes:
|
||||
overlay for log messages.
|
||||
|
||||
Maintenance:
|
||||
* You can now do an `UPDATE` on the `lnav_top_view` SQL view.
|
||||
This makes it easier to write queries that manipulate the
|
||||
current view.
|
||||
* Upgrade to C++17
|
||||
|
||||
|
||||
|
16
src/init.sql
16
src/init.sql
@ -93,6 +93,22 @@ SELECT *
|
||||
FROM lnav_views
|
||||
WHERE name = (SELECT name FROM lnav_view_stack ORDER BY rowid DESC LIMIT 1);
|
||||
|
||||
CREATE TRIGGER lnav_top_view_update
|
||||
INSTEAD OF UPDATE ON lnav_top_view
|
||||
BEGIN
|
||||
UPDATE lnav_views
|
||||
SET top = NEW.top,
|
||||
left = NEW.left,
|
||||
top_time = NEW.top_time,
|
||||
paused = NEW.paused,
|
||||
search = NEW.search,
|
||||
filtering = NEW.filtering,
|
||||
movement = NEW.movement,
|
||||
selection = NEW.selection,
|
||||
options = NEW.options
|
||||
WHERE name = NEW.name;
|
||||
END;
|
||||
|
||||
CREATE VIEW lnav_file_demux_metadata AS
|
||||
SELECT filepath, jget(content, '/demux_meta') AS metadata
|
||||
FROM lnav_file_metadata
|
||||
|
@ -71,13 +71,13 @@
|
||||
"command": ":reset-session"
|
||||
},
|
||||
"x18": {
|
||||
"command": ";UPDATE lnav_views SET movement = (CASE movement WHEN 'top' THEN 'cursor' ELSE 'top' END) WHERE name = (SELECT name FROM lnav_top_view)"
|
||||
"command": ";UPDATE lnav_top_view SET movement = (CASE movement WHEN 'top' THEN 'cursor' ELSE 'top' END)"
|
||||
},
|
||||
"x04": {
|
||||
"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)"
|
||||
"command": ";UPDATE lnav_top_view SET top = top + (height / 2), selection = (CASE movement WHEN 'top' THEN selection ELSE top + (height / 2) + (selection - top) END)"
|
||||
},
|
||||
"x15": {
|
||||
"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)"
|
||||
"command": ";UPDATE lnav_top_view SET top = max(0, top - (height / 2)), selection = (CASE movement WHEN 'top' THEN selection ELSE max(0, top - (height / 2) + (selection - top)) END)"
|
||||
},
|
||||
"x3d": {
|
||||
"command": ";UPDATE lnav_views SET paused = 1 - paused"
|
||||
@ -130,17 +130,17 @@
|
||||
"alt-msg": "${keymap_def_scroll_horiz}"
|
||||
},
|
||||
"x54": {
|
||||
"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)",
|
||||
"command": ";UPDATE lnav_top_view SET options = json_set(options, '$.row-time-offset', CASE jget(options, '/row-time-offset', 'hide') WHEN 'hide' THEN 'show' ELSE 'hide' END)",
|
||||
"alt-msg": "${keymap_def_time_offset}"
|
||||
},
|
||||
"x70": {
|
||||
"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)"
|
||||
"command": ";UPDATE lnav_top_view SET options = json_set(options, '$.row-details', CASE jget(options, '/row-details', 'hide') WHEN 'hide' THEN 'show' ELSE 'hide' END)"
|
||||
},
|
||||
"x78": {
|
||||
"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)"
|
||||
"command": ";UPDATE lnav_top_view SET options = json_set(options, '$.hidden-fields', CASE jget(options, '/hidden-fields', 'hide') WHEN 'hide' THEN 'show' ELSE 'hide' END)"
|
||||
},
|
||||
"x17": {
|
||||
"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)"
|
||||
"command": ";UPDATE lnav_top_view SET options = json_set(options, '$.word-wrap', CASE jget(options, '/word-wrap', 'none') WHEN 'none' THEN 'normal' ELSE 'none' END)"
|
||||
},
|
||||
"x75": {
|
||||
"command": ":next-mark",
|
||||
|
@ -4774,7 +4774,7 @@
|
||||
"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)",
|
||||
"command": ";UPDATE lnav_top_view SET top = top + (height / 2), selection = (CASE movement WHEN 'top' THEN selection ELSE top + (height / 2) + (selection - top) END)",
|
||||
"alt-msg": ""
|
||||
},
|
||||
"x06": {
|
||||
@ -4794,17 +4794,17 @@
|
||||
},
|
||||
"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)",
|
||||
"command": ";UPDATE lnav_top_view SET top = max(0, top - (height / 2)), selection = (CASE movement WHEN 'top' THEN selection ELSE max(0, top - (height / 2) + (selection - top)) END)",
|
||||
"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)",
|
||||
"command": ";UPDATE lnav_top_view SET options = json_set(options, '$.word-wrap', CASE jget(options, '/word-wrap', 'none') WHEN 'none' THEN 'normal' ELSE 'none' END)",
|
||||
"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)",
|
||||
"command": ";UPDATE lnav_top_view SET movement = (CASE movement WHEN 'top' THEN 'cursor' ELSE 'top' END)",
|
||||
"alt-msg": ""
|
||||
},
|
||||
"x21": {
|
||||
@ -4919,7 +4919,7 @@
|
||||
},
|
||||
"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)",
|
||||
"command": ";UPDATE lnav_top_view SET options = json_set(options, '$.row-time-offset', CASE jget(options, '/row-time-offset', 'hide') WHEN 'hide' THEN 'show' ELSE 'hide' END)",
|
||||
"alt-msg": "${keymap_def_time_offset}"
|
||||
},
|
||||
"x55": {
|
||||
@ -4974,7 +4974,7 @@
|
||||
},
|
||||
"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)",
|
||||
"command": ";UPDATE lnav_top_view SET options = json_set(options, '$.row-details', CASE jget(options, '/row-details', 'hide') WHEN 'hide' THEN 'show' ELSE 'hide' END)",
|
||||
"alt-msg": ""
|
||||
},
|
||||
"x71": {
|
||||
@ -4999,7 +4999,7 @@
|
||||
},
|
||||
"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)",
|
||||
"command": ";UPDATE lnav_top_view SET options = json_set(options, '$.hidden-fields', CASE jget(options, '/hidden-fields', 'hide') WHEN 'hide' THEN 'show' ELSE 'hide' END)",
|
||||
"alt-msg": ""
|
||||
},
|
||||
"x7b": {
|
||||
|
Loading…
Reference in New Issue
Block a user