Эх сурвалжийг харах

Insert pressed modifier keys code instead of '*' in KeytabInputHandler and check for keyPad state in keytab finder

nuc134r 2 жил өмнө
parent
commit
7ef01a28c3

+ 30 - 2
lib/src/core/input/handler.dart

@@ -1,7 +1,7 @@
 import 'package:xterm/src/core/input/keys.dart';
 import 'package:xterm/src/core/input/keytab/keytab.dart';
-import 'package:xterm/src/utils/platform.dart';
 import 'package:xterm/src/core/state.dart';
+import 'package:xterm/src/utils/platform.dart';
 
 /// The key event received from the keyboard, along with the state of the
 /// modifier keys and state of the terminal. Typically consumed by the
@@ -124,7 +124,35 @@ class KeytabInputHandler implements TerminalInputHandler {
       return null;
     }
 
-    return action.action.unescapedValue();
+    var result = action.action.unescapedValue();
+    result = insertModifiers(event, result);
+    return result;
+  }
+
+  String insertModifiers(TerminalKeyboardEvent event, String action) {
+    String? code;
+
+    if (event.shift && event.alt && event.ctrl) {
+      code = '8';
+    } else if (event.ctrl && event.alt) {
+      code = '7';
+    } else if (event.shift && event.ctrl) {
+      code = '6';
+    } else if (event.ctrl) {
+      code = '5';
+    } else if (event.shift && event.alt) {
+      code = '4';
+    } else if (event.alt) {
+      code = '3';
+    } else if (event.shift) {
+      code = '2';
+    }
+
+    if (code != null) {
+      return action.replaceAll('*', code);
+    }
+
+    return action;
   }
 }
 

+ 5 - 0
lib/src/core/input/keytab/keytab.dart

@@ -32,6 +32,7 @@ class Keytab {
     bool newLineMode = false,
     bool appCursorKeys = false,
     bool appKeyPad = false,
+    bool keyPad = false,
     bool appScreen = false,
     bool macos = false,
     // bool meta,
@@ -76,6 +77,10 @@ class Keytab {
         continue;
       }
 
+      if (record.keyPad != null && record.keyPad != keyPad) {
+        continue;
+      }
+
       if (record.appScreen != null && record.appScreen != appScreen) {
         continue;
       }