toString method

  1. @override
String toString()
override

Allow pen colors to be used in a string.

Note: Once the pen is down, its attributes remain in effect till they are changed by another pen or up.

Implementation

@override
String toString() {
  if (ansiColorDisabled) return '';
  if (!_dirty) return _pen;

  final sb = StringBuffer();
  if (_fcolor != -1) {
    sb.write('${ansiEscape}38;5;${_fcolor}m');
  }

  if (_bcolor != -1) {
    sb.write('${ansiEscape}48;5;${_bcolor}m');
  }

  _dirty = false;
  _pen = sb.toString();
  return _pen;
}