You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was having problems with extended chars in a linux terminal.
When I typed "è" I got "Ã".
Running the rawkeys example I got the following output:
c3 (Ã)
a8 (¨)
Giving a look at the Key.readKey function I saw this comment:
/// ... , certain keys may
/// be represented by multiple control key sequences. An example showing
/// basic key handling can be found in the `example/command_line.dart`
/// file in the package source code.
But I could not find the example "command_line"
So I did the following:
I copied the readKey function into an extension function and I did the following changes: Original:
Key readKey() {
Key key;
int charCode;
int codeUnit = 0;
rawMode = true;
while (codeUnit <= 0) {
codeUnit = stdin.readByteSync();
}
if (codeUnit >= 0x01 && codeUnit <= 0x1a) {
....
Modified:
Key readSystemKey() {
Key key;
int charCode;
var codeUnit;
var bytes = <int>[];
rawMode = true;
while (key == null) {
codeUnit = 0;
while (codeUnit <= 0) {
codeUnit = stdin.readByteSync();
}
if (codeUnit >= 0x01 && codeUnit <= 0x1a) {
...
Original end of method:
} else {
// assume other characters are printable
key = Key.printable(String.fromCharCode(codeUnit));
}
rawMode = false;
return key;
}
Modified end of method:
} else {
// assume other characters are printable
try {
bytes.add(codeUnit);
key = Key.printable(systemEncoding.decode(bytes));
bytes.clear();
} on FormatException catch (_) {
if (bytes.length > 4) {
rethrow;
}
}
}
}
rawMode = false;
return key;
}
It works for my needs, but probably this logic should be added in other points of the package and tested with different OSs.
Another option would be to let the user set a specific encoding, if needed.
Let me know what do you think about.
The text was updated successfully, but these errors were encountered:
I was having problems with extended chars in a linux terminal.
When I typed "è" I got "Ã".
Running the rawkeys example I got the following output:
c3 (Ã)
a8 (¨)
Giving a look at the Key.readKey function I saw this comment:
But I could not find the example "command_line"
So I did the following:
I copied the readKey function into an extension function and I did the following changes:
Original:
Modified:
Original end of method:
Modified end of method:
It works for my needs, but probably this logic should be added in other points of the package and tested with different OSs.
Another option would be to let the user set a specific encoding, if needed.
Let me know what do you think about.
The text was updated successfully, but these errors were encountered: