Skip to content

Commit 3e5049d

Browse files
committed
Merge branch 'master' into develop
2 parents 9b515b6 + 35e2f95 commit 3e5049d

58 files changed

Lines changed: 727 additions & 302 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

NEWS.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@ Features:
8484
- `⌘-X` to cut the current selection to the
8585
clipboard.
8686
- `⌘-Z` to undo the last change.
87+
* The multi-line prompt can now be resized with the
88+
keyboard: `ALT-=` grows the prompt by one line and
89+
`ALT--` shrinks it by one line. This complements
90+
the existing click-and-drag resize on the prompt's
91+
status bar.
8792
* Additional readline-style key bindings in the
8893
prompt (issue #1676):
8994
- `ALT-f` / `ALT-b` move forward/backward by word.
@@ -107,6 +112,29 @@ Features:
107112
* Added `disfavors` to `external-editor` configuration
108113
to express file names that the editor is not interested
109114
in handling.
115+
* The `lnav_views.view_details` column is now populated
116+
for every time-based view (log, histogram, spectro,
117+
timeline, db) with a JSON `zoom-level` field reflecting
118+
the current `:zoom-to` setting.
119+
* The `:zoom-to` command (and the `z`/`Z` hotkeys) now
120+
affects only the currently focused view; previously,
121+
zooming in either the histogram or the spectrogram
122+
view would change both views' zoom level in lockstep.
123+
Each view (log, histogram, spectro, timeline, db) now
124+
has its own independent zoom level.
125+
* The `:zoom-to` command now accepts `+` and `-` as
126+
shortcuts to step in or out by one level from the
127+
current view's zoom (the same behavior as the `z`/`Z`
128+
hotkeys).
129+
* SQL statements can now use `$zoom_level` to refer to
130+
the current zoom level in the DB view. Pressing
131+
`z`/`Z` in the DB view will now rerun the last query
132+
with the new zoom value. The `stats.hist` PRQL
133+
function now uses `$zoom_level` as the default value
134+
for the `slice` parameter.
135+
* A `stats.timeseries` PRQL function has been added to
136+
make it easier to perform an aggregation over buckets
137+
of time.
110138

111139
Breaking changes:
112140
* The `humanize_file_size()` SQLite function now

TESTS_ENVIRONMENT.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ run_cap_test() {
122122

123123
sed -ibak \
124124
-e "s;${prefix}/etc;{prefix}/etc;g" \
125-
-e 's;run_at\\":\\".*\\";;' \
125+
-e 's;run-at\\":\\".*\\";;' \
126126
-e "s;${LNAV_VERSION};{LNAV_VERSION};g" \
127127
-e "s;${test_dir};{test_dir};g" \
128128
-e "s;${builddir};{test_dir};g" \

docs/schemas/config-v1.schema.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1405,17 +1405,18 @@
14051405
},
14061406
"color": {
14071407
"title": "/color",
1408-
"description": "The foreground color value for this style. The value can be the name of an xterm color, the hexadecimal value, or a theme variable reference.",
1408+
"description": "The foreground color value for this style. The value can be the name of an xterm color, the hexadecimal value, a theme variable reference, or 'semantic()' to derive the color from a hash of the matched text.",
14091409
"type": "string",
14101410
"examples": [
14111411
"#fff",
14121412
"Green",
1413-
"$black"
1413+
"$black",
1414+
"semantic()"
14141415
]
14151416
},
14161417
"background-color": {
14171418
"title": "/background-color",
1418-
"description": "The background color value for this style. The value can be the name of an xterm color, the hexadecimal value, or a theme variable reference.",
1419+
"description": "The background color value for this style. The value can be the name of an xterm color, the hexadecimal value, a theme variable reference, or 'semantic()' to derive the color from a hash of the matched text.",
14191420
"type": "string",
14201421
"examples": [
14211422
"#2d2a2e",

docs/schemas/format-v1.schema.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -975,17 +975,18 @@
975975
},
976976
"color": {
977977
"title": "/color",
978-
"description": "The foreground color value for this style. The value can be the name of an xterm color, the hexadecimal value, or a theme variable reference.",
978+
"description": "The foreground color value for this style. The value can be the name of an xterm color, the hexadecimal value, a theme variable reference, or 'semantic()' to derive the color from a hash of the matched text.",
979979
"type": "string",
980980
"examples": [
981981
"#fff",
982982
"Green",
983-
"$black"
983+
"$black",
984+
"semantic()"
984985
]
985986
},
986987
"background-color": {
987988
"title": "/background-color",
988-
"description": "The background color value for this style. The value can be the name of an xterm color, the hexadecimal value, or a theme variable reference.",
989+
"description": "The background color value for this style. The value can be the name of an xterm color, the hexadecimal value, a theme variable reference, or 'semantic()' to derive the color from a hash of the matched text.",
989990
"type": "string",
990991
"examples": [
991992
"#2d2a2e",

docs/source/config.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,9 @@ the values from the :code:`styles/text` definition.
143143
picked based on the `CIEDE2000 <https://en.wikipedia.org/wiki/Color_difference#CIEDE2000>`_
144144
color difference algorithm.
145145

146+
The special value :code:`semantic()` can also be used in place of a color.
147+
The displayed color is derived from a hash of the text to create a stable,
148+
distinguishable color.
146149

147150

148151
Example

docs/source/hotkeys.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,13 @@ editing:
464464
-
465465
- In search mode, search for the previous occurrence. Otherwise,
466466
search history using current contents of the prompt
467+
* - :kbd:`Alt` + :kbd:`=`
468+
-
469+
- In multi-line mode, grow the prompt by one line. The prompt's
470+
status bar can also be dragged with the mouse to resize.
471+
* - :kbd:`Alt` + :kbd:`-`
472+
-
473+
- In multi-line mode, shrink the prompt by one line.
467474

468475
Customizing
469476
-----------

docs/source/sqlext.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,10 @@ The following variables are available in SQL statements:
239239

240240
* :code:`$LINES` - The number of lines in the terminal window.
241241
* :code:`$COLS` - The number of columns in the terminal window.
242+
* :code:`$zoom_level` - The current zoom level of the DB view as a
243+
duration string (e.g. :code:`5m`, :code:`1h`). Passing this
244+
value to the `timeslice`_ function can be useful for easily
245+
adjusting the time slice duration based on the zoom level.
242246

243247
Environment
244248
-----------

docs/source/ui.rst

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,16 @@ the view, how long ago it ran, and how long it took. Clicking the reload
434434
icon (↻) at the left of the bar — or pressing :kbd:`F5` — re-runs the
435435
query via the :code:`:reload-view` command.
436436

437+
Pressing :kbd:`z` / :kbd:`Shift` + :kbd:`z` (or running
438+
:code:`:zoom-to`) in the DB view changes the view's zoom level
439+
and re-runs the last query so that any references to the
440+
:code:`$zoom_level` SQL variable pick up the new value. Passing this
441+
value to the :code:`timeslice()` function can be useful for easily
442+
adjusting the time slice duration based on the zoom level.
443+
This is useful with the :ref:`stats_hist` and :ref:`stats_timeseries`
444+
PRQL functions, whose default :code:`slice` parameter is
445+
:code:`$zoom_level`.
446+
437447
If the query reads from log-backed tables (:code:`all_logs`,
438448
per-format tables like :code:`syslog_log`, :code:`all_opids`, etc.),
439449
the timing status also notes whether the results are based on
@@ -443,7 +453,8 @@ does not mention the log data freshness.
443453

444454
The same query metadata is exposed via the :code:`view_details`
445455
column on the :code:`lnav_views` vtable as a JSON object containing
446-
:code:`query`, :code:`run_at`, and :code:`duration_us`.
456+
:code:`zoom-level`, :code:`query`, :code:`run-at`, and
457+
:code:`duration-us`.
447458

448459
.. [#] lnav must be compiled in an environment with Rust/Cargo available
449460
for PRQL support.

src/all_logs_vtab.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ all_logs_vtab::extract(logfile* lf,
190190
= to_owned(sub_values.lvv_src_file_value, values.lvv_allocator);
191191
values.lvv_src_line_value
192192
= to_owned(sub_values.lvv_src_line_value, values.lvv_allocator);
193+
values.lvv_duration_value = sub_values.lvv_duration_value;
193194
}
194195

195196
bool

src/base/humanize.cc

Lines changed: 35 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,10 @@ try_from(const string_fragment& sf)
8484
| ( [\-\+]? \d+ \. \d+ (?: [eE] [\-\+] \d+ )? )
8585
# file size: 4KiB, 2 MB, 100B, 500KBps
8686
| ( [\-\+]? \d+ (?:\.\d+)? \s* (?:[KMGTPE] i?)? [Bb] (?:ps)? )
87-
# seconds with SI prefix: 1.2s, 1ms, 5us, 10ns
88-
| ( [\-\+]? \d+ (?:\.\d+)? \s* [munpf]? ) s
87+
# seconds: 1.2s, 1ms, 5us, 68 micros, 5 milliseconds
88+
| ( [\-\+]? \d+ (?:\.\d+)? \s*
89+
(?: milli | micro | nano | pico | femto | [munpf] )? )
90+
s (?: ec (?:ond)? s? )?
8991
# duration h:m:s
9092
| ( \d{1,2} : \d{2} : \d{2} (?: \. \d{1,6} )? )
9193
# duration m:s
@@ -173,21 +175,39 @@ try_from(const string_fragment& sf)
173175

174176
if (!unit_range.empty()) {
175177
size_t start = 0;
176-
while (isspace(unit_range[start])) {
178+
while (start < unit_range.size() && isspace(unit_range[start])) {
177179
start += 1;
178180
}
179-
switch (unit_range[start]) {
180-
case 'f':
181-
retval /= 1000.0;
182-
case 'p':
183-
retval /= 1000.0;
184-
case 'n':
185-
retval /= 1000.0;
186-
case 'u':
187-
retval /= 1000.0;
188-
case 'm':
189-
retval /= 1000.0;
190-
break;
181+
// The "micro" word form starts with 'm' but means /1e6, not
182+
// /1e3 like the single-letter "m" SI prefix. Match the word
183+
// forms before falling through to the SI-letter switch.
184+
auto starts_with = [&](std::string_view word) {
185+
if (start + word.size() > unit_range.size()) {
186+
return false;
187+
}
188+
for (size_t i = 0; i < word.size(); ++i) {
189+
if (unit_range[start + i] != word[i]) {
190+
return false;
191+
}
192+
}
193+
return true;
194+
};
195+
if (starts_with("micro")) {
196+
retval /= 1000000.0;
197+
} else if (start < unit_range.size()) {
198+
switch (unit_range[start]) {
199+
case 'f':
200+
retval /= 1000.0;
201+
case 'p':
202+
retval /= 1000.0;
203+
case 'n':
204+
retval /= 1000.0;
205+
case 'u':
206+
retval /= 1000.0;
207+
case 'm':
208+
retval /= 1000.0;
209+
break;
210+
}
191211
}
192212
}
193213

0 commit comments

Comments
 (0)