newCell static method
Creates a new cell from a grapheme, computing its display width.
Implementation
static Cell newCell(WidthMethod method, String grapheme) {
if (grapheme.isEmpty) return Cell.zeroCell();
if (grapheme == ' ') return Cell.emptyCell();
final width = method.stringWidth(grapheme);
final scalar = _trySingleScalar(grapheme);
if (scalar != null) {
return Cell._packed(
style: const UvStyle(),
link: const Link(),
width: width,
contentKind: _CellContentKind.singleScalar,
contentValue: scalar,
styleId: 0,
linkId: 0,
);
}
return Cell._packed(
style: const UvStyle(),
link: const Link(),
width: width,
contentKind: _CellContentKind.complex,
contentValue: _graphemePool.intern(grapheme, width),
styleId: 0,
linkId: 0,
);
}