Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions lib/src/console.dart
Original file line number Diff line number Diff line change
Expand Up @@ -358,13 +358,12 @@ class Console {
int? width,
TextAlignment alignment = TextAlignment.left,
]) {
final textAsString = text.toString();
stdout.write(
textAsString.alignText(
width: width ?? textAsString.length,
alignment: alignment,
),
var textAsString = text.toString();
textAsString = textAsString.alignText(
width: width ?? textAsString.displayWidth,
alignment: alignment,
);
stdout.write(textAsString);
}

/// Reads a single key from the input, including a variety of control
Expand Down Expand Up @@ -715,8 +714,7 @@ class Console {
// invalid UTF-8, wait for more characters
continue;
}
if (buffer.getRenderWidth() + text.getRenderWidth() <=
bufferMaxLength) {
if (buffer.displayWidth + text.displayWidth <= bufferMaxLength) {
buffer = buffer.substring(0, index) + text + buffer.substring(index);
index += text.length;
}
Expand All @@ -727,7 +725,7 @@ class Console {
write(buffer); // allow for backspace condition
cursorPosition = Coordinate(
screenRow,
screenColOffset + buffer.substring(0, index).getRenderWidth(),
screenColOffset + buffer.substring(0, index).displayWidth,
);

if (callback != null) callback(buffer, key);
Expand Down
Loading