boxDrawingMask function
The line segments grapheme draws, as an OR of boxSegmentNorth etc., or
null if it is not a box-drawing line/corner/junction. Double-line glyphs are
mapped to their single-weight segment set (good enough for crisp borders).
Implementation
int? boxDrawingMask(String grapheme) {
switch (grapheme) {
case '│':
case '║':
return boxSegmentNorth | boxSegmentSouth;
case '─':
case '═':
return boxSegmentEast | boxSegmentWest;
case '╭':
case '┌':
case '╔':
return boxSegmentSouth | boxSegmentEast;
case '╮':
case '┐':
case '╗':
return boxSegmentSouth | boxSegmentWest;
case '╰':
case '└':
case '╚':
return boxSegmentNorth | boxSegmentEast;
case '╯':
case '┘':
case '╝':
return boxSegmentNorth | boxSegmentWest;
case '├':
case '╠':
return boxSegmentNorth | boxSegmentSouth | boxSegmentEast;
case '┤':
case '╣':
return boxSegmentNorth | boxSegmentSouth | boxSegmentWest;
case '┬':
case '╦':
return boxSegmentSouth | boxSegmentEast | boxSegmentWest;
case '┴':
case '╩':
return boxSegmentNorth | boxSegmentEast | boxSegmentWest;
case '┼':
case '╬':
return boxSegmentNorth |
boxSegmentSouth |
boxSegmentEast |
boxSegmentWest;
default:
return null;
}
}