2332143e5b
Finished terminals are sized synchronously from their rows at the view's width (the post-frame fit made the transcript re-anchor forever); blank rows xterm.dart keeps when rewrapping are dropped; desktop typing uses key events; the composer leaves Cmd/Ctrl-V to a focused terminal; Ctrl-A reaches the process. The probe fixture gains coloured terminal runs and an interactive login. Notes record behaviour, protocol, security and verification.
34 lines
1.3 KiB
Dart
34 lines
1.3 KiB
Dart
import 'package:flutter/widgets.dart';
|
|
|
|
/// Flutter shares a single web editing element across fields. DOM identity
|
|
/// alone cannot tell a chat composer from search, rename or another editor.
|
|
abstract final class ChatComposerPasteFocus {
|
|
static final Set<FocusNode> _composers = {};
|
|
|
|
static final Set<FocusNode> _inputs = {};
|
|
|
|
static void register(FocusNode focus) => _composers.add(focus);
|
|
static void unregister(FocusNode focus) => _composers.remove(focus);
|
|
|
|
/// An input that is not an [EditableText] (a shell command's terminal)
|
|
/// registers its focus here: a paste while it has focus is its own.
|
|
static void registerInput(FocusNode focus) => _inputs.add(focus);
|
|
static void unregisterInput(FocusNode focus) => _inputs.remove(focus);
|
|
|
|
static bool get anotherEditableHasFocus {
|
|
final primary = FocusManager.instance.primaryFocus;
|
|
if (primary == null || _composers.any((focus) => focus.hasFocus)) {
|
|
return false;
|
|
}
|
|
if (_inputs.any((focus) => focus.hasFocus)) return true;
|
|
final context = primary.context;
|
|
if (context == null) return false;
|
|
var editable = context.widget is EditableText;
|
|
context.visitAncestorElements((element) {
|
|
if (element.widget is EditableText) editable = true;
|
|
return !editable;
|
|
});
|
|
return editable;
|
|
}
|
|
}
|