]> git.ipfire.org Git - thirdparty/util-linux.git/commit
libsmartcols: add scols_table_calculate(), pager: add less --header support
authorkurok <22548029+kurok@users.noreply.github.com>
Fri, 13 Mar 2026 11:31:33 +0000 (11:31 +0000)
committerkurok <22548029+kurok@users.noreply.github.com>
Fri, 13 Mar 2026 11:32:30 +0000 (11:32 +0000)
commit049aef854ecf80879d9ef6f2f484383cf16fa16e
treed01dbe838867b4130135cc8dcbcc35961e73b16f
parent9a9ce4074b2e3a9afe73f06e49ae12e593bf397d
libsmartcols: add scols_table_calculate(), pager: add less --header support

Add scols_table_calculate() public API to allow column width calculation
without printing. This enables callers to query column widths (via
scols_column_get_width()) before starting output, which is needed to
set up "less --header" for freezing table headers and the first column.

The new function runs __scols_initialize_printing() (which includes
__scols_calculate()) and sets an is_calculated flag so that subsequent
scols_print_table() calls skip redundant recalculation.

Add pager_open_header() to lib/pager.c that sets the LESS environment
variable with "--header N,M" options before spawning the pager process.
This freezes the first N lines (header row) and first M character columns
(first table column) when scrolling in less.

Addresses: https://github.com/util-linux/util-linux/issues/3542
include/pager.h
lib/pager.c
libsmartcols/src/libsmartcols.h.in
libsmartcols/src/libsmartcols.sym
libsmartcols/src/print-api.c
libsmartcols/src/print.c
libsmartcols/src/smartcolsP.h