writeChar method
Writes a single character to the _terminal. Escape sequences or special characters are not interpreted and directly added to the buffer.
See also: Terminal.writeChar
Implementation
void writeChar(int codePoint) {
codePoint = charset.translate(codePoint);
final cellWidth = codePoint < 128 ? 1 : unicodeV11.wcwidth(codePoint);
if (_cursorX >= terminal.viewWidth) {
if (terminal.autoWrapMode) {
index();
setCursorX(0);
currentLine.isWrapped = true;
} else {
// Auto-wrap is off: keep the cursor clamped at the last column so
// the character overwrites the cell there.
_cursorX = viewWidth - 1;
}
}
final line = currentLine;
if (terminal.insertMode) {
line.insertCells(_cursorX, 1, terminal.cursor);
}
line.setCell(_cursorX, codePoint, cellWidth, terminal.cursor);
if (_cursorX < viewWidth) {
_cursorX++;
}
if (cellWidth == 2) {
writeChar(0);
}
}