sgr property

String get sgr

The full SGR escape that realises this style on the terminal, starting from a reset (\x1b[0;…m) so it is self-contained and never inherits a previous cell's attributes.

Implementation

String get sgr {
  final params = <String>['0'];
  if (bold) params.add('1');
  if (dim) params.add('2');
  if (italic) params.add('3');
  if (underline) params.add('4');
  if (reverse) params.add('7');
  if (fg != null) params.addAll(fg!._fgParams);
  if (bg != null) params.addAll(bg!._bgParams);
  return '\x1b[${params.join(';')}m';
}