Giter VIP home page Giter VIP logo

Comments (1)

bradyt avatar bradyt commented on June 20, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.