ansiSgrParams method

String ansiSgrParams({
  1. required bool background,
})

Returns the SGR parameter segment for an isAnsiIndexed color (30..37, 90..97, 38;5;n for foreground; 40..47, 100..107, 48;5;n for background).

Implementation

String ansiSgrParams({required bool background}) {
  final idx = ansiIndex;
  final offset = background ? 10 : 0;
  if (idx < 8) return '${30 + offset + idx}';
  if (idx < 16) return '${90 + offset + idx - 8}';
  return '${38 + offset};5;$idx';
}