feat: shift key in ssh term (#819)
This commit is contained in:
@@ -21,6 +21,7 @@ enum VirtKey {
|
||||
right,
|
||||
clipboard,
|
||||
ime,
|
||||
shift,
|
||||
pgup,
|
||||
pgdn,
|
||||
slash,
|
||||
@@ -105,6 +106,7 @@ extension VirtKeyX on VirtKey {
|
||||
VirtKey.right,
|
||||
VirtKey.clipboard,
|
||||
VirtKey.ime,
|
||||
VirtKey.shift,
|
||||
];
|
||||
|
||||
/// Corresponding [TerminalKey]
|
||||
@@ -119,6 +121,7 @@ extension VirtKeyX on VirtKey {
|
||||
VirtKey.left => TerminalKey.arrowLeft,
|
||||
VirtKey.down => TerminalKey.arrowDown,
|
||||
VirtKey.right => TerminalKey.arrowRight,
|
||||
VirtKey.shift => TerminalKey.shift,
|
||||
VirtKey.pgup => TerminalKey.pageUp,
|
||||
VirtKey.pgdn => TerminalKey.pageDown,
|
||||
VirtKey.f1 => TerminalKey.f1,
|
||||
@@ -161,7 +164,7 @@ extension VirtKeyX on VirtKey {
|
||||
};
|
||||
|
||||
bool get toggleable => switch (this) {
|
||||
VirtKey.alt || VirtKey.ctrl => true,
|
||||
VirtKey.alt || VirtKey.ctrl || VirtKey.shift => true,
|
||||
_ => false,
|
||||
};
|
||||
|
||||
|
||||
@@ -23,6 +23,15 @@ class VirtKeyProvider extends TerminalInputHandler with ChangeNotifier {
|
||||
}
|
||||
}
|
||||
|
||||
bool _shift = false;
|
||||
bool get shift => _shift;
|
||||
set shift(bool value) {
|
||||
if (value != _shift) {
|
||||
_shift = value;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
void reset(TerminalKeyboardEvent e) {
|
||||
if (e.ctrl) {
|
||||
ctrl = false;
|
||||
@@ -30,6 +39,9 @@ class VirtKeyProvider extends TerminalInputHandler with ChangeNotifier {
|
||||
if (e.alt) {
|
||||
alt = false;
|
||||
}
|
||||
if (e.shift) {
|
||||
shift = false;
|
||||
}
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
@@ -38,6 +50,7 @@ class VirtKeyProvider extends TerminalInputHandler with ChangeNotifier {
|
||||
final e = event.copyWith(
|
||||
ctrl: event.ctrl || ctrl,
|
||||
alt: event.alt || alt,
|
||||
shift: event.shift || shift,
|
||||
);
|
||||
if (Stores.setting.sshVirtualKeyAutoOff.fetch()) {
|
||||
reset(e);
|
||||
|
||||
@@ -3,6 +3,6 @@
|
||||
|
||||
abstract class BuildData {
|
||||
static const String name = "ServerBox";
|
||||
static const int build = 1189;
|
||||
static const int build = 1195;
|
||||
static const int script = 64;
|
||||
}
|
||||
|
||||
@@ -254,6 +254,8 @@ class VirtKeyAdapter extends TypeAdapter<VirtKey> {
|
||||
return VirtKey.f11;
|
||||
case 43:
|
||||
return VirtKey.f12;
|
||||
case 44:
|
||||
return VirtKey.shift;
|
||||
default:
|
||||
return VirtKey.esc;
|
||||
}
|
||||
@@ -350,6 +352,8 @@ class VirtKeyAdapter extends TypeAdapter<VirtKey> {
|
||||
writer.writeByte(42);
|
||||
case VirtKey.f12:
|
||||
writer.writeByte(43);
|
||||
case VirtKey.shift:
|
||||
writer.writeByte(44);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ types:
|
||||
index: 13
|
||||
VirtKey:
|
||||
typeId: 4
|
||||
nextIndex: 44
|
||||
nextIndex: 45
|
||||
fields:
|
||||
esc:
|
||||
index: 0
|
||||
@@ -149,6 +149,8 @@ types:
|
||||
index: 42
|
||||
f12:
|
||||
index: 43
|
||||
shift:
|
||||
index: 44
|
||||
NetViewType:
|
||||
typeId: 5
|
||||
nextIndex: 3
|
||||
|
||||
@@ -13,6 +13,13 @@ extension _Keyboard on SSHPageState {
|
||||
_handleEscKeyOrBackButton();
|
||||
return true; // Mark as handled so it doesn't propagate
|
||||
}
|
||||
if (event.logicalKey == LogicalKeyboardKey.shiftLeft ||
|
||||
event.logicalKey == LogicalKeyboardKey.shiftRight) {
|
||||
// Handle shift key press
|
||||
_terminal.keyInput(TerminalKey.shift);
|
||||
HapticFeedback.lightImpact();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false; // Let other handlers process this event
|
||||
}
|
||||
|
||||
@@ -291,6 +291,9 @@ class SSHPageState extends State<SSHPage>
|
||||
case TerminalKey.alt:
|
||||
selected = _keyboard.alt;
|
||||
break;
|
||||
case TerminalKey.shift:
|
||||
selected = _keyboard.shift;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -26,6 +26,9 @@ extension _VirtKey on SSHPageState {
|
||||
case TerminalKey.alt:
|
||||
_keyboard.alt = !_keyboard.alt;
|
||||
break;
|
||||
case TerminalKey.shift:
|
||||
_keyboard.shift = !_keyboard.shift;
|
||||
break;
|
||||
default:
|
||||
_terminal.keyInput(key);
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user