Copy and paste: the desktop's universal copy key works; Ctrl+C at the terminal login keeps the terminal
Omarchy's Super+C sends Ctrl+C by setting the modifier state with no Ctrl key event while Super is held. Flutter's web engine only presses a modifier on its own key event, so the app saw a plain "c": the chat selection was not copied and the terminal typed the letter. A key modifier sync in front of the framework's key handler now presses the modifiers the browser event's flags hold (and outside Apple platforms lets go of a held Meta for Ctrl+C/V/X/A/ Insert), installed by the app's binding. The terminal copies a selection on Ctrl+C without sending ^C, treats the injected copy key as copy only, and pastes on Shift+Insert. A refused clipboard write or read now shows a message instead of failing silently. Server: before the login completes, Ctrl+C and Ctrl+\ erase the typed password (Ctrl+U) and Ctrl+Z is dropped, so su is not killed and the terminal no longer ends. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -7,11 +7,11 @@ bool _apple() =>
|
||||
defaultTargetPlatform == TargetPlatform.iOS;
|
||||
|
||||
/// The terminal's own key shortcuts. Cmd-C, Cmd-V and Cmd-A on Apple
|
||||
/// platforms; elsewhere Ctrl-V (and the terminal convention Ctrl-Shift-V)
|
||||
/// paste and Ctrl-Shift-C or Ctrl-Insert copies, so every other Ctrl key,
|
||||
/// Ctrl-A included, reaches the process. Ctrl-C copies too while text is
|
||||
/// selected (see [chatShellCopyKey]); a browser keeps Ctrl-Shift-C for its
|
||||
/// developer tools, so there it is the key that works.
|
||||
/// platforms; elsewhere Ctrl-V (and the terminal conventions Ctrl-Shift-V
|
||||
/// and Shift-Insert) paste and Ctrl-Shift-C or Ctrl-Insert copies, so every
|
||||
/// other Ctrl key, Ctrl-A included, reaches the process. Ctrl-C copies too
|
||||
/// while text is selected (see [chatShellCopyKey]); a browser keeps
|
||||
/// Ctrl-Shift-C for its developer tools, so there it is the key that works.
|
||||
Map<ShortcutActivator, Intent> chatShellTerminalShortcuts() {
|
||||
const paste = PasteTextIntent(SelectionChangedCause.keyboard);
|
||||
if (_apple()) {
|
||||
@@ -31,6 +31,7 @@ Map<ShortcutActivator, Intent> chatShellTerminalShortcuts() {
|
||||
CopySelectionTextIntent.copy,
|
||||
SingleActivator(LogicalKeyboardKey.keyV, control: true): paste,
|
||||
SingleActivator(LogicalKeyboardKey.keyV, control: true, shift: true): paste,
|
||||
SingleActivator(LogicalKeyboardKey.insert, shift: true): paste,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:xterm/xterm.dart';
|
||||
|
||||
import '../../../core/keyboard/key_modifier_sync.dart';
|
||||
import '../conversation/chat_composer_paste_focus.dart';
|
||||
import '../ui/transcript/chat_link_launcher.dart';
|
||||
import 'chat_shell_metrics.dart';
|
||||
@@ -127,14 +128,18 @@ class _ChatShellTerminalViewState extends State<ChatShellTerminalView>
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
/// Ctrl-C with a selection copies; the view's own keys (find, zoom,
|
||||
/// scrolling) are answered; the terminal's own shortcuts (copy, paste)
|
||||
/// are left to it; any other key xterm encodes differently from
|
||||
/// xterm.dart (Alt as Meta, Ctrl symbols, modified special keys) is sent
|
||||
/// here with its real character. The rest is the emulator's.
|
||||
/// Ctrl-C with a selection copies (and sends no ^C); a desktop's copy
|
||||
/// shortcut (Ctrl+C injected with no Ctrl key held, see
|
||||
/// [KeyModifierSync.injectedControl]) only ever copies; the view's own
|
||||
/// keys (find, zoom, scrolling) are answered; the terminal's own
|
||||
/// shortcuts (copy, paste) are left to it; any other key xterm encodes
|
||||
/// differently from xterm.dart (Alt as Meta, Ctrl symbols, modified
|
||||
/// special keys) is sent here with its real character. The rest is the
|
||||
/// emulator's.
|
||||
KeyEventResult _key(FocusNode node, KeyEvent event) {
|
||||
final keyboard = HardwareKeyboard.instance;
|
||||
if (chatShellCopyKey(event, keyboard) && actions.copySelection()) {
|
||||
if (chatShellCopyKey(event, keyboard) &&
|
||||
(actions.copySelection() || KeyModifierSync.injectedControl)) {
|
||||
return KeyEventResult.handled;
|
||||
}
|
||||
if (localKey(event)) return KeyEventResult.handled;
|
||||
|
||||
Reference in New Issue
Block a user