OOKNET                             [ /  search the index  ]  
──────────────────────────────────────────────────────────────────────────────────────
══════════════════════════════════════════════════════════════════════════════════════
OOKNET   [ /  search  ]  
────────────────────────────────────────────────
════════════════════════════════════════════════
 
 
master @ 27 LINES
 
[ HISTORY ]  [ UP ]
 

// Process steps: horizontal chain when it fits the frame, vertical
// spine otherwise. [x] done, [>] current, [ ] pending.
import { G, checkGrid, len } from "../../lib/ascii";

export interface Props {
  steps: string[];
  /** 0-based index of the current step. */
  current: number;
}

const mark = (i: number, current: number) =>
  i < current ? "[x]" : i === current ? "[>]" : "[ ]";

export function buildSteps(steps: string[], current: number, width: number): strin
g {
  const parts = steps.map((s, i) => `${mark(i, current)} ${s}`);

  const horizontal = parts.join(` ${G.H}${G.H} `);
  if (len(horizontal) <= width) return checkGrid(horizontal, width, "steps");

  const lines: string[] = [];
  parts.forEach((p, i) => {
    lines.push(p);
    if (i < parts.length - 1) lines.push(` ${G.V}`);
  });
  return checkGrid(lines.join("\n"), width, "steps");
}

// Process steps: horizontal chain when it f
its the frame, vertical
// spine otherwise. [x] done, [>] current, [
 ] pending.
import { G, checkGrid, len } from "../../lib
/ascii";

export interface Props {
  steps: string[];
  /** 0-based index of the current step. */
  current: number;
}

const mark = (i: number, current: number) =>
  i < current ? "[x]" : i === current ? "[>]
" : "[ ]";

export function buildSteps(steps: string[], 
current: number, width: number): string {
  const parts = steps.map((s, i) => `${mark(
i, current)} ${s}`);

  const horizontal = parts.join(` ${G.H}${G.
H} `);
  if (len(horizontal) <= width) return check
Grid(horizontal, width, "steps");

  const lines: string[] = [];
  parts.forEach((p, i) => {
    lines.push(p);
    if (i < parts.length - 1) lines.push(` $
{G.V}`);
  });
  return checkGrid(lines.join("\n"), width, 
"steps");
}
 
──────────────────────────────────────────────────────────────────────────────────────
OOKNET
────────────────────────────────────────────────
OOKNET