Expand description
Pure line-selection helpers behind ct-view’s bounded, context-aware reads:
parsing a --range spec, expanding --match hits into context windows, and
grouping the kept line indices into contiguous runs for display.
Functions§
- expand_
and_ merge - Expand each hit index by
ctxlines and merge overlapping/adjacent windows into a sorted, de-duplicated list of line indices, clamped tototallines. - parse_
range - Parse a
--rangespec into a 0-based inclusive[start, end], clamped to a file oftotallines. ReturnsNonewhen the range selects nothing. - segments
- Group sorted indices into contiguous
[start, end]runs (the display groups separated by--in text output).