mark method
Wraps content with zone markers.
The markers are zero-width ANSI sequences that don't affect layout calculations when using proper width functions.
When the manager is disabled, returns content unchanged.
Example
final button = zone.mark('submit', style.render('Submit'));
final cancel = zone.mark('cancel', style.render('Cancel'));
return '$button $cancel';
Implementation
String mark(String id, String content) {
if (!_enabled || id.isEmpty || content.isEmpty) {
return content;
}
// Check if we already have a generated ID for this user ID
var gid = _ids[id];
if (gid != null) {
return '$gid$content$gid';
}
// Generate a new marker ID
gid = '\x1B[${++_markerCounter}z';
_ids[id] = gid;
_rids[gid] = id;
return '$gid$content$gid';
}