renderStatusLineSpans function

List<StatusSpan> renderStatusLineSpans(
  1. StatusLineSnapshot snapshot,
  2. StatusLineSpec spec,
  3. int width
)

Renders one status-bar frame as role-keyed spans.

Layout algorithm (omp component.ts ladder):

  1. Lay out both groups from the snapshot (absent data → hidden segments dropped).
  2. session_name → right pops → path shrink → left drops: shrink session_name (8 → 4 → drop), then drop right-group members right-to-left, then re-render path at shrinking maxLengths (stepwise −10 down to 10), then drop left-group members — until the bar fits width.
  3. Fill the middle with the embedded context gauge when the context window is known and the gap fits it (labels at the edges, a ━ scale between; 50 % warn / 90 % error levels); narrower gaps show the bare percent, and an irreducible overflow collapses to left + ' ' + right.

spec.transparent (omp's band-less mode) drops the pure gap fill: content — segments, separators, gauge — still renders, but no dim space run pads the line out to width, so the terminal bg shows through and the returned line may be shorter than width.

Pure: reads the snapshot, measures raw strings, returns raw spans — colors are applied at write time via statusLineStyle / kStatusLineRoles (the FaThemeController emitter seam).

Implementation

List<StatusSpan> renderStatusLineSpans(
  StatusLineSnapshot snapshot,
  StatusLineSpec spec,
  int width,
) {
  if (width <= 0) return [];
  final leftIn = _layoutGroup(spec.left, snapshot, spec);
  final rightIn = _layoutGroup(spec.right, snapshot, spec);
  if (leftIn.isEmpty && rightIn.isEmpty) return [];

  final sep = getSeparator(spec.separator, nerd: spec.nerdSymbols);
  final squeezed = _squeezeGroups(leftIn, rightIn, snapshot, spec, sep, width);
  final leftW = squeezed.left.width;
  final rightW = squeezed.right.width;
  final gap = width - leftW - rightW;

  // Irreducible overflow: collapse to `left + ' ' + right` (omp).
  if (gap < 1) {
    return [
      ...squeezed.left.spans,
      if (leftW > 0 && rightW > 0) (' ', StatusLineRoleKey.dim),
      ...squeezed.right.spans,
    ];
  }

  final pct = snapshot.contextPercent;
  if (pct == null || snapshot.contextWindow <= 0) {
    return [
      ...squeezed.left.spans,
      // Transparent: no band fill — the terminal bg shows through.
      if (!spec.transparent) (' ' * gap, StatusLineRoleKey.dim),
      ...squeezed.right.spans,
    ];
  }

  final gauge = _gaugeSpans(
    gap,
    pct,
    snapshot.contextWindow,
    transparent: spec.transparent,
  );
  return [...squeezed.left.spans, ...gauge, ...squeezed.right.spans];
}