Sfoglia il codice sorgente

don't bind mac behavior to Platform.isMacOS

it is now configurable at Terminal Level so that it can be activated on a Mac when a local shell is started but can be disabled when e.g. a ssh connection is made to a Linux host
devmil 4 anni fa
parent
commit
a8b2933a42

+ 1 - 3
lib/frontend/input_behavior_default.dart

@@ -1,5 +1,3 @@
-import 'dart:io';
-
 import 'package:flutter/services.dart';
 import 'package:flutter/widgets.dart';
 import 'package:xterm/frontend/input_behavior.dart';
@@ -28,7 +26,7 @@ class InputBehaviorDefault extends InputBehavior {
           ctrl: event.isControlPressed,
           alt: event.isAltPressed,
           shift: event.isShiftPressed,
-          mac: Platform.isMacOS);
+          mac: terminal.platform.useMacInputBehavior);
     }
   }
 

+ 11 - 4
lib/input/keytab/keytab_default.dart

@@ -74,11 +74,18 @@ key Left  -Shift-AnyMod+Ansi-AppCuKeys : "\E[D"
 
 key Up    -Shift+AnyMod+Ansi           : "\E[1;5A"
 key Down  -Shift+AnyMod+Ansi           : "\E[1;5B"
-key Right -Shift+AnyMod+Ansi-Mac       : "\E[1;5C"
-key Left  -Shift+AnyMod+Ansi-Mac       : "\E[1;5D"
 
-key Right -Shift+AnyMod+Ansi+Mac       : "\Ef"
-key Left  -Shift+AnyMod+Ansi+Mac       : "\Eb"
+# Right / Left with Control
+key Right -Shift-Alt+Control+Ansi      : "\E[1;5C"
+key Left  -Shift-Alt+Control+Ansi      : "\E[1;5D"
+
+# Right / Left with Alt not on a Mac
+key Right -Shift+Alt-Control+Ansi-Mac  : "\E[1;5C"
+key Left  -Shift+Alt-Control+Ansi-Mac  : "\E[1;5D"
+
+# Right / Left with Alt on a Mac
+key Right -Shift+Alt-Control+Ansi+Mac  : "\Ef"
+key Left  -Shift+Alt-Control+Ansi+Mac  : "\Eb"
 
 key Up    +Shift+AppScreen             : "\E[1;*A"
 key Down  +Shift+AppScreen             : "\E[1;*B"

+ 9 - 3
lib/terminal/platform.dart

@@ -1,10 +1,16 @@
 class PlatformBehavior {
-  const PlatformBehavior({required this.oscTerminators});
+  const PlatformBehavior(
+      {required this.oscTerminators, required this.useMacInputBehavior});
 
   final Set<int> oscTerminators;
+  final bool useMacInputBehavior;
 }
 
 class PlatformBehaviors {
-  static const unix = PlatformBehavior(oscTerminators: {0x07, 0x5c});
-  static const windows = PlatformBehavior(oscTerminators: {0x07, 0x00});
+  static const mac =
+      PlatformBehavior(oscTerminators: {0x07, 0x5c}, useMacInputBehavior: true);
+  static const unix = PlatformBehavior(
+      oscTerminators: {0x07, 0x5c}, useMacInputBehavior: false);
+  static const windows = PlatformBehavior(
+      oscTerminators: {0x07, 0x00}, useMacInputBehavior: false);
 }