Comments (1)
Would something like the following fix it?
modified lib/src/console.dart
@@ -545,7 +545,61 @@ class Console {
}
escapeSequence.add(String.fromCharCode(charCode));
if (escapeSequence[2] != '~') {
- key.controlChar = ControlCharacter.unknown;
+ if (escapeSequence[2].codeUnits[0] >= '0'.codeUnits[0] &&
+ escapeSequence[2].codeUnits[0] <= '9'.codeUnits[0]) {
+ charCode = stdin.readByteSync();
+ if (charCode == -1) {
+ rawMode = false;
+ return key;
+ }
+ escapeSequence.add(String.fromCharCode(charCode));
+ if (escapeSequence[3] != '~') {
+ key.controlChar = ControlCharacter.unknown;
+ } else {
+ switch (escapeSequence[1]) {
+ case '1':
+ switch (escapeSequence[2]) {
+ case '5':
+ key.controlChar = ControlCharacter.F5;
+ break;
+ case '7':
+ key.controlChar = ControlCharacter.F6;
+ break;
+ case '8':
+ key.controlChar = ControlCharacter.F7;
+ break;
+ case '9':
+ key.controlChar = ControlCharacter.F8;
+ break;
+ default:
+ key.controlChar = ControlCharacter.unknown;
+ }
+ break;
+ case '2':
+ switch (escapeSequence[2]) {
+ case '0':
+ key.controlChar = ControlCharacter.F9;
+ break;
+ case '1':
+ key.controlChar = ControlCharacter.F10;
+ break;
+ case '3':
+ key.controlChar = ControlCharacter.F11;
+ break;
+ case '4':
+ key.controlChar = ControlCharacter.F12;
+ break;
+ default:
+ key.controlChar = ControlCharacter.unknown;
+ }
+ break;
+ default:
+ key.controlChar = ControlCharacter.unknown;
+ }
+ }
+ } else {
+ key.controlChar = ControlCharacter.unknown;
+ }
} else {
switch (escapeSequence[1]) {
case '1':
modified lib/src/key.dart
@@ -53,6 +53,14 @@ enum ControlCharacter {
F2,
F3,
F4,
+ F5,
+ F6,
+ F7,
+ F8,
+ F9,
+ F10,
+ F11,
+ F12,
unknown
}
Works here in Terminal.app on macOS. The mappings agree with those found at the following link:
You can also check these in terminal like Ctrl+v F5
or with showkey
or cat
.
I wonder if there's an issue I'm missing with reading ahead too many bytes?
from dart_console.
Related Issues (20)
- Ctrl+M is mapping to enter HOT 1
- 'NoSuchMethodError: The getter 'col' was called on null.' when running readLine() with writeLine() in while loop while holding enter.
- windowWidth and windowHeight do not update on window resize (linux)
- Is it possibile to use Console on different CMD window? HOT 1
- Last symbol cannot be deleted with delete key or Ctrl-D when using Console().readLine()
- If stdin is closed cursorPosition throws a RangeError HOT 4
- usage with not standard streams (not stdin/stdout)
- Is there a way to check whether a key has been pressed without blocking the flow of the program? HOT 4
- Regression in 1.1: RangeError in `Console.cursorPosition`
- Console.writeLine does not align correctly with characters that do not have width 1
- `Console.readLine()` doesn't allow users to paste text into terminal HOT 2
- Extend `Console.readLine()` API to allow tab-completion of commands in a prompt HOT 1
- Versionbump win32 to 3.0.0 HOT 1
- Accessing `cursorPosition` may print debugging information
- Do not work
- Game: Run Console in Flutter Web? HOT 1
- The getter 'CONSOLE_MODE' isn't defined for the class 'TermLibWindows'. HOT 2
- Pasting clipboard content to readLine pastes only first character HOT 9
- NOTE: New issues should be raised against: https://onepub-dev/dart_console
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dart_console.