Kaynağa Gözat

Merge pull request #62 from devmil/bugfix/opt_keys_mac_activate_special_functionality

Fixes ALT + L for a Mac (German Layout)
xuty 4 yıl önce
ebeveyn
işleme
9f4e3122e0

+ 1 - 0
lib/frontend/input_behavior_default.dart

@@ -28,6 +28,7 @@ class InputBehaviorDefault extends InputBehavior {
         alt: event.isAltPressed,
         shift: event.isShiftPressed,
         mac: terminal.platform.useMacInputBehavior,
+        character: event.character,
       );
     }
   }

+ 11 - 2
lib/terminal/terminal.dart

@@ -412,6 +412,7 @@ class Terminal
     bool shift = false,
     bool mac = false,
     // bool meta,
+    String? character,
   }) {
     debug.onMsg(key);
 
@@ -484,8 +485,16 @@ class Terminal
     if (alt) {
       if (key.index >= TerminalKey.keyA.index &&
           key.index <= TerminalKey.keyZ.index) {
-        final input = [0x1b, key.index - TerminalKey.keyA.index + 65];
-        backend?.write(String.fromCharCodes(input));
+        final charCode = key.index - TerminalKey.keyA.index + 65;
+
+        // only process ALT + Key when this combination has no other meaning
+        // (reflected in the given character argument
+        if (character == null ||
+            character.toLowerCase() ==
+                String.fromCharCode(charCode).toLowerCase()) {
+          final input = [0x1b, charCode];
+          backend?.write(String.fromCharCodes(input));
+        }
         return;
       }
     }

+ 11 - 3
lib/terminal/terminal_isolate.dart

@@ -124,8 +124,14 @@ void terminalMain(SendPort port) async {
         _terminal?.backend?.write(msg[1]);
         break;
       case _IsolateCommand.keyInput:
-        _terminal?.keyInput(msg[1],
-            ctrl: msg[2], alt: msg[3], shift: msg[4], mac: msg[5]);
+        _terminal?.keyInput(
+          msg[1],
+          ctrl: msg[2],
+          alt: msg[3],
+          shift: msg[4],
+          mac: msg[5],
+          character: msg[6],
+        );
         break;
       case _IsolateCommand.requestNewStateWhenDirty:
         if (_terminal == null) {
@@ -530,8 +536,10 @@ class TerminalIsolate with Observable implements TerminalUiInteraction {
     bool shift = false,
     bool mac = false,
     // bool meta,
+    String? character,
   }) {
-    _sendPort?.send([_IsolateCommand.keyInput, key, ctrl, alt, shift, mac]);
+    _sendPort?.send(
+        [_IsolateCommand.keyInput, key, ctrl, alt, shift, mac, character]);
   }
 
   var _isTerminated = false;

+ 1 - 0
lib/terminal/terminal_ui_interaction.dart

@@ -117,6 +117,7 @@ abstract class TerminalUiInteraction with Observable {
     bool shift = false,
     bool mac = false,
     // bool meta,
+    String? character,
   });
 
   /// Future that fires when the backend has exited

+ 11 - 3
test/frontend/input_test.mocks.dart

@@ -209,10 +209,18 @@ class MockTerminalUiInteraction extends _i1.Mock
           {bool? ctrl = false,
           bool? alt = false,
           bool? shift = false,
-          bool? mac = false}) =>
+          bool? mac = false,
+          String? character}) =>
       super.noSuchMethod(
-          Invocation.method(#keyInput, [key],
-              {#ctrl: ctrl, #alt: alt, #shift: shift, #mac: mac}),
+          Invocation.method(#keyInput, [
+            key
+          ], {
+            #ctrl: ctrl,
+            #alt: alt,
+            #shift: shift,
+            #mac: mac,
+            #character: character
+          }),
           returnValueForMissingStub: null);
   @override
   void terminateBackend() =>