mirror of
https://github.com/flutter/flutter
synced 2024-10-13 03:32:55 +00:00
This reverts commit 0ba2f6a87f
.
This commit is contained in:
parent
0ba2f6a87f
commit
a637fcd344
|
@ -670,6 +670,10 @@ class RenderEditable extends RenderBox with RelayoutWhenSystemFontsChangeMixin {
|
|||
// _handleShortcuts depends on being started in the same stack invocation
|
||||
// as the _handleKeyEvent method
|
||||
_handleShortcuts(key);
|
||||
} else if (key == LogicalKeyboardKey.delete) {
|
||||
_handleDelete(forward: true);
|
||||
} else if (key == LogicalKeyboardKey.backspace) {
|
||||
_handleDelete(forward: false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1011,381 +1015,16 @@ class RenderEditable extends RenderBox with RelayoutWhenSystemFontsChangeMixin {
|
|||
return _getTextPositionVertical(offset, verticalOffset);
|
||||
}
|
||||
|
||||
// Deletes the current uncollapsed selection.
|
||||
void _deleteSelection(TextSelection selection, SelectionChangedCause cause) {
|
||||
assert(selection.isCollapsed == false);
|
||||
|
||||
if (_readOnly || !selection.isValid || selection.isCollapsed) {
|
||||
return;
|
||||
}
|
||||
|
||||
final String text = textSelectionDelegate.textEditingValue.text;
|
||||
final String textBefore = selection.textBefore(text);
|
||||
final String textAfter = selection.textAfter(text);
|
||||
final int cursorPosition = math.min(selection.start, selection.end);
|
||||
|
||||
final TextSelection newSelection = TextSelection.collapsed(offset: cursorPosition);
|
||||
_setTextEditingValue(
|
||||
TextEditingValue(text: textBefore + textAfter, selection: newSelection),
|
||||
cause,
|
||||
);
|
||||
}
|
||||
|
||||
// Deletes the from the current collapsed selection to the start of the field.
|
||||
//
|
||||
// The given SelectionChangedCause indicates the cause of this change and
|
||||
// will be passed to onSelectionChanged.
|
||||
//
|
||||
// See also:
|
||||
// * _deleteToEnd
|
||||
void _deleteToStart(TextSelection selection, SelectionChangedCause cause) {
|
||||
assert(selection.isCollapsed);
|
||||
|
||||
if (_readOnly || !selection.isValid) {
|
||||
return;
|
||||
}
|
||||
|
||||
final String text = textSelectionDelegate.textEditingValue.text;
|
||||
final String textBefore = selection.textBefore(text);
|
||||
|
||||
if (textBefore.isEmpty) {
|
||||
return;
|
||||
}
|
||||
|
||||
final String textAfter = selection.textAfter(text);
|
||||
const TextSelection newSelection = TextSelection.collapsed(offset: 0);
|
||||
_setTextEditingValue(
|
||||
TextEditingValue(text: textAfter, selection: newSelection),
|
||||
cause,
|
||||
);
|
||||
}
|
||||
|
||||
// Deletes the from the current collapsed selection to the end of the field.
|
||||
//
|
||||
// The given SelectionChangedCause indicates the cause of this change and
|
||||
// will be passed to onSelectionChanged.
|
||||
//
|
||||
// See also:
|
||||
// * _deleteToStart
|
||||
void _deleteToEnd(TextSelection selection, SelectionChangedCause cause) {
|
||||
assert(selection.isCollapsed);
|
||||
|
||||
if (_readOnly || !selection.isValid) {
|
||||
return;
|
||||
}
|
||||
|
||||
final String text = textSelectionDelegate.textEditingValue.text;
|
||||
final String textAfter = selection.textAfter(text);
|
||||
|
||||
if (textAfter.isEmpty) {
|
||||
return;
|
||||
}
|
||||
|
||||
final String textBefore = selection.textBefore(text);
|
||||
final TextSelection newSelection = TextSelection.collapsed(offset: textBefore.length);
|
||||
_setTextEditingValue(
|
||||
TextEditingValue(text: textBefore, selection: newSelection),
|
||||
cause,
|
||||
);
|
||||
}
|
||||
|
||||
/// Deletes backwards from the current selection.
|
||||
///
|
||||
/// If the [selection] is collapsed, deletes a single character before the
|
||||
/// cursor.
|
||||
///
|
||||
/// If the [selection] is not collapsed, deletes the selection.
|
||||
///
|
||||
/// {@template flutter.rendering.RenderEditable.cause}
|
||||
/// The given [SelectionChangedCause] indicates the cause of this change and
|
||||
/// will be passed to [onSelectionChanged].
|
||||
/// {@endtemplate}
|
||||
///
|
||||
/// See also:
|
||||
///
|
||||
/// * [deleteForward], which is same but in the opposite direction.
|
||||
void delete(SelectionChangedCause cause) {
|
||||
assert(_selection != null);
|
||||
|
||||
if (_readOnly || !_selection!.isValid) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_selection!.isCollapsed) {
|
||||
return _deleteSelection(_selection!, cause);
|
||||
}
|
||||
|
||||
final String text = textSelectionDelegate.textEditingValue.text;
|
||||
String textBefore = _selection!.textBefore(text);
|
||||
if (textBefore.isEmpty) {
|
||||
return;
|
||||
}
|
||||
|
||||
final int characterBoundary = previousCharacter(textBefore.length, textBefore);
|
||||
textBefore = textBefore.substring(0, characterBoundary);
|
||||
|
||||
final String textAfter = _selection!.textAfter(text);
|
||||
final TextSelection newSelection = TextSelection.collapsed(offset: characterBoundary);
|
||||
_setTextEditingValue(
|
||||
TextEditingValue(text: textBefore + textAfter, selection: newSelection),
|
||||
cause,
|
||||
);
|
||||
}
|
||||
|
||||
/// Deletes a word backwards from the current selection.
|
||||
///
|
||||
/// If the [selection] is collapsed, deletes a word before the cursor.
|
||||
///
|
||||
/// If the [selection] is not collapsed, deletes the selection.
|
||||
///
|
||||
/// If [obscureText] is true, it treats the whole text content as
|
||||
/// a single word.
|
||||
///
|
||||
/// {@macro flutter.rendering.RenderEditable.cause}
|
||||
///
|
||||
/// {@template flutter.rendering.RenderEditable.whiteSpace}
|
||||
/// By default, includeWhitespace is set to true, meaning that whitespace can
|
||||
/// be considered a word in itself. If set to false, the selection will be
|
||||
/// extended past any whitespace and the first word following the whitespace.
|
||||
/// {@endtemplate}
|
||||
///
|
||||
/// See also:
|
||||
///
|
||||
/// * [deleteForwardByWord], which is same but in the opposite direction.
|
||||
void deleteByWord(SelectionChangedCause cause, [bool includeWhitespace = true]) {
|
||||
assert(_selection != null);
|
||||
|
||||
if (_readOnly || !_selection!.isValid) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_selection!.isCollapsed) {
|
||||
return _deleteSelection(_selection!, cause);
|
||||
}
|
||||
|
||||
// When the text is obscured, the whole thing is treated as one big line.
|
||||
if (obscureText) {
|
||||
return _deleteToStart(_selection!, cause);
|
||||
}
|
||||
|
||||
final String text = textSelectionDelegate.textEditingValue.text;
|
||||
String textBefore = _selection!.textBefore(text);
|
||||
if (textBefore.isEmpty) {
|
||||
return;
|
||||
}
|
||||
|
||||
final int characterBoundary = _getLeftByWord(_textPainter, textBefore.length, includeWhitespace);
|
||||
textBefore = textBefore.trimRight().substring(0, characterBoundary);
|
||||
|
||||
final String textAfter = _selection!.textAfter(text);
|
||||
final TextSelection newSelection = TextSelection.collapsed(offset: characterBoundary);
|
||||
_setTextEditingValue(
|
||||
TextEditingValue(text: textBefore + textAfter, selection: newSelection),
|
||||
cause,
|
||||
);
|
||||
}
|
||||
|
||||
/// Deletes a line backwards from the current selection.
|
||||
///
|
||||
/// If the [selection] is collapsed, deletes a line before the cursor.
|
||||
///
|
||||
/// If the [selection] is not collapsed, deletes the selection.
|
||||
///
|
||||
/// If [obscureText] is true, it treats the whole text content as
|
||||
/// a single word.
|
||||
///
|
||||
/// {@macro flutter.rendering.RenderEditable.cause}
|
||||
///
|
||||
/// See also:
|
||||
///
|
||||
/// * [deleteForwardByLine], which is same but in the opposite direction.
|
||||
void deleteByLine(SelectionChangedCause cause) {
|
||||
assert(_selection != null);
|
||||
|
||||
if (_readOnly || !_selection!.isValid) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_selection!.isCollapsed) {
|
||||
return _deleteSelection(_selection!, cause);
|
||||
}
|
||||
|
||||
// When the text is obscured, the whole thing is treated as one big line.
|
||||
if (obscureText) {
|
||||
return _deleteToStart(_selection!, cause);
|
||||
}
|
||||
|
||||
final String text = textSelectionDelegate.textEditingValue.text;
|
||||
String textBefore = _selection!.textBefore(text);
|
||||
if (textBefore.isEmpty) {
|
||||
return;
|
||||
}
|
||||
|
||||
// When there is a line break, line delete shouldn't do anything
|
||||
final bool isPreviousCharacterBreakLine = textBefore.codeUnitAt(textBefore.length - 1) == 0x0A;
|
||||
if (isPreviousCharacterBreakLine) {
|
||||
return;
|
||||
}
|
||||
|
||||
final TextSelection line = _getLineAtOffset(TextPosition(offset: textBefore.length - 1));
|
||||
textBefore = textBefore.substring(0, line.start);
|
||||
|
||||
final String textAfter = _selection!.textAfter(text);
|
||||
final TextSelection newSelection = TextSelection.collapsed(offset: textBefore.length);
|
||||
_setTextEditingValue(
|
||||
TextEditingValue(text: textBefore + textAfter, selection: newSelection),
|
||||
cause,
|
||||
);
|
||||
}
|
||||
|
||||
/// Deletes in the foward direction from the current selection.
|
||||
///
|
||||
/// If the [selection] is collapsed, deletes a single character after the
|
||||
/// cursor.
|
||||
///
|
||||
/// If the [selection] is not collapsed, deletes the selection.
|
||||
///
|
||||
/// {@macro flutter.rendering.RenderEditable.cause}
|
||||
///
|
||||
/// See also:
|
||||
///
|
||||
/// * [delete], which is same but in the opposite direction.
|
||||
void deleteForward(SelectionChangedCause cause) {
|
||||
assert(_selection != null);
|
||||
|
||||
if (_readOnly || !_selection!.isValid) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_selection!.isCollapsed) {
|
||||
return _deleteSelection(_selection!, cause);
|
||||
}
|
||||
|
||||
final String text = textSelectionDelegate.textEditingValue.text;
|
||||
final String textBefore = _selection!.textBefore(text);
|
||||
String textAfter = _selection!.textAfter(text);
|
||||
|
||||
if (textAfter.isEmpty) {
|
||||
return;
|
||||
}
|
||||
|
||||
final int deleteCount = nextCharacter(0, textAfter);
|
||||
textAfter = textAfter.substring(deleteCount);
|
||||
|
||||
_setTextEditingValue(
|
||||
TextEditingValue(text: textBefore + textAfter, selection: _selection!),
|
||||
cause,
|
||||
);
|
||||
}
|
||||
|
||||
/// Deletes a word in the foward direction from the current selection.
|
||||
///
|
||||
/// If the [selection] is collapsed, deletes a word after the cursor.
|
||||
///
|
||||
/// If the [selection] is not collapsed, deletes the selection.
|
||||
///
|
||||
/// If [obscureText] is true, it treats the whole text content as
|
||||
/// a single word.
|
||||
///
|
||||
/// {@macro flutter.rendering.RenderEditable.cause}
|
||||
///
|
||||
/// {@macro flutter.rendering.RenderEditable.whiteSpace}
|
||||
///
|
||||
/// See also:
|
||||
///
|
||||
/// * [deleteByWord], which is same but in the opposite direction.
|
||||
void deleteForwardByWord(SelectionChangedCause cause, [bool includeWhitespace = true]) {
|
||||
assert(_selection != null);
|
||||
|
||||
if (_readOnly || !_selection!.isValid) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_selection!.isCollapsed) {
|
||||
return _deleteSelection(_selection!, cause);
|
||||
}
|
||||
|
||||
// When the text is obscured, the whole thing is treated as one big word.
|
||||
if (obscureText) {
|
||||
return _deleteToEnd(_selection!, cause);
|
||||
}
|
||||
|
||||
final String text = textSelectionDelegate.textEditingValue.text;
|
||||
String textAfter = _selection!.textAfter(text);
|
||||
|
||||
if (textAfter.isEmpty) {
|
||||
return;
|
||||
}
|
||||
|
||||
final String textBefore = _selection!.textBefore(text);
|
||||
final int characterBoundary = _getRightByWord(_textPainter, textBefore.length, includeWhitespace);
|
||||
textAfter = textAfter.substring(characterBoundary - textBefore.length);
|
||||
|
||||
_setTextEditingValue(
|
||||
TextEditingValue(text: textBefore + textAfter, selection: _selection!),
|
||||
cause,
|
||||
);
|
||||
}
|
||||
|
||||
/// Deletes a line in the foward direction from the current selection.
|
||||
///
|
||||
/// If the [selection] is collapsed, deletes a line after the cursor.
|
||||
///
|
||||
/// If the [selection] is not collapsed, deletes the selection.
|
||||
///
|
||||
/// If [obscureText] is true, it treats the whole text content as
|
||||
/// a single word.
|
||||
///
|
||||
/// {@macro flutter.rendering.RenderEditable.cause}
|
||||
///
|
||||
/// See also:
|
||||
///
|
||||
/// * [deleteByLine], which is same but in the opposite direction.
|
||||
void deleteForwardByLine(SelectionChangedCause cause) {
|
||||
assert(_selection != null);
|
||||
|
||||
if (_readOnly || !_selection!.isValid) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_selection!.isCollapsed) {
|
||||
return _deleteSelection(_selection!, cause);
|
||||
}
|
||||
|
||||
// When the text is obscured, the whole thing is treated as one big line.
|
||||
if (obscureText) {
|
||||
return _deleteToEnd(_selection!, cause);
|
||||
}
|
||||
|
||||
final String text = textSelectionDelegate.textEditingValue.text;
|
||||
String textAfter = _selection!.textAfter(text);
|
||||
if (textAfter.isEmpty) {
|
||||
return;
|
||||
}
|
||||
|
||||
// When there is a line break, it shouldn't do anything.
|
||||
final bool isNextCharacterBreakLine = textAfter.codeUnitAt(0) == 0x0A;
|
||||
if (isNextCharacterBreakLine) {
|
||||
return;
|
||||
}
|
||||
|
||||
final String textBefore = _selection!.textBefore(text);
|
||||
final TextSelection line = _getLineAtOffset(TextPosition(offset: textBefore.length));
|
||||
textAfter = textAfter.substring(line.end - textBefore.length, textAfter.length);
|
||||
|
||||
_setTextEditingValue(
|
||||
TextEditingValue(text: textBefore + textAfter, selection: _selection!),
|
||||
cause,
|
||||
);
|
||||
}
|
||||
|
||||
/// Keeping [selection]'s [TextSelection.baseOffset] fixed, move the
|
||||
/// [TextSelection.extentOffset] down by one line.
|
||||
///
|
||||
/// If [selectionEnabled] is false, keeps the selection collapsed and just
|
||||
/// moves it down.
|
||||
///
|
||||
/// {@macro flutter.rendering.RenderEditable.cause}
|
||||
/// {@template flutter.rendering.RenderEditable.cause}
|
||||
/// The given [SelectionChangedCause] indicates the cause of this change and
|
||||
/// will be passed to [onSelectionChanged].
|
||||
/// {@endtemplate}
|
||||
///
|
||||
/// See also:
|
||||
///
|
||||
|
@ -1736,7 +1375,10 @@ class RenderEditable extends RenderBox with RelayoutWhenSystemFontsChangeMixin {
|
|||
///
|
||||
/// {@macro flutter.rendering.RenderEditable.cause}
|
||||
///
|
||||
/// {@macro flutter.rendering.RenderEditable.whiteSpace}
|
||||
/// By default, `includeWhitespace` is set to true, meaning that whitespace
|
||||
/// can be considered a word in itself. If set to false, the selection will
|
||||
/// be extended past any whitespace and the first word following the
|
||||
/// whitespace.
|
||||
///
|
||||
/// {@template flutter.rendering.RenderEditable.stopAtReversal}
|
||||
/// The `stopAtReversal` parameter is false by default, meaning that it's
|
||||
|
@ -1778,11 +1420,13 @@ class RenderEditable extends RenderBox with RelayoutWhenSystemFontsChangeMixin {
|
|||
///
|
||||
/// {@macro flutter.rendering.RenderEditable.cause}
|
||||
///
|
||||
/// {@macro flutter.rendering.RenderEditable.whiteSpace}
|
||||
/// By default, `includeWhitespace` is set to true, meaning that whitespace
|
||||
/// can be considered a word in itself. If set to false, the selection will
|
||||
/// be extended past any whitespace and the first word following the
|
||||
/// whitespace.
|
||||
///
|
||||
/// {@macro flutter.rendering.RenderEditable.stopAtReversal}
|
||||
///
|
||||
///
|
||||
/// See also:
|
||||
///
|
||||
/// * [extendSelectionLeftByWord], which is the same but in the opposite
|
||||
|
@ -1941,7 +1585,9 @@ class RenderEditable extends RenderBox with RelayoutWhenSystemFontsChangeMixin {
|
|||
///
|
||||
/// {@macro flutter.rendering.RenderEditable.cause}
|
||||
///
|
||||
/// {@macro flutter.rendering.RenderEditable.whiteSpace}
|
||||
/// By default, includeWhitespace is set to true, meaning that whitespace can
|
||||
/// be considered a word in itself. If set to false, the selection will be
|
||||
/// moved past any whitespace and the first word following the whitespace.
|
||||
///
|
||||
/// See also:
|
||||
///
|
||||
|
@ -2027,7 +1673,9 @@ class RenderEditable extends RenderBox with RelayoutWhenSystemFontsChangeMixin {
|
|||
///
|
||||
/// {@macro flutter.rendering.RenderEditable.cause}
|
||||
///
|
||||
/// {@macro flutter.rendering.RenderEditable.whiteSpace}
|
||||
/// By default, includeWhitespace is set to true, meaning that whitespace can
|
||||
/// be considered a word in itself. If set to false, the selection will be
|
||||
/// moved past any whitespace and the first word following the whitespace.
|
||||
///
|
||||
/// See also:
|
||||
///
|
||||
|
@ -2177,6 +1825,38 @@ class RenderEditable extends RenderBox with RelayoutWhenSystemFontsChangeMixin {
|
|||
}
|
||||
}
|
||||
|
||||
void _handleDelete({ required bool forward }) {
|
||||
final TextSelection selection = textSelectionDelegate.textEditingValue.selection;
|
||||
final String text = textSelectionDelegate.textEditingValue.text;
|
||||
assert(_selection != null);
|
||||
if (_readOnly || !selection.isValid) {
|
||||
return;
|
||||
}
|
||||
String textBefore = selection.textBefore(text);
|
||||
String textAfter = selection.textAfter(text);
|
||||
int cursorPosition = math.min(selection.start, selection.end);
|
||||
// If not deleting a selection, delete the next/previous character.
|
||||
if (selection.isCollapsed) {
|
||||
if (!forward && textBefore.isNotEmpty) {
|
||||
final int characterBoundary = previousCharacter(textBefore.length, textBefore);
|
||||
textBefore = textBefore.substring(0, characterBoundary);
|
||||
cursorPosition = characterBoundary;
|
||||
}
|
||||
if (forward && textAfter.isNotEmpty) {
|
||||
final int deleteCount = nextCharacter(0, textAfter);
|
||||
textAfter = textAfter.substring(deleteCount);
|
||||
}
|
||||
}
|
||||
final TextSelection newSelection = TextSelection.collapsed(offset: cursorPosition);
|
||||
_setTextEditingValue(
|
||||
TextEditingValue(
|
||||
text: textBefore + textAfter,
|
||||
selection: newSelection,
|
||||
),
|
||||
SelectionChangedCause.keyboard,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void markNeedsPaint() {
|
||||
super.markNeedsPaint();
|
||||
|
|
|
@ -36,12 +36,6 @@ class DefaultTextEditingActions extends Actions{
|
|||
// are called on which platform.
|
||||
static final Map<Type, Action<Intent>> _shortcutsActions = <Type, Action<Intent>>{
|
||||
DoNothingAndStopPropagationTextIntent: _DoNothingAndStopPropagationTextAction(),
|
||||
DeleteTextIntent: _DeleteTextAction(),
|
||||
DeleteByWordTextIntent: _DeleteByWordTextAction(),
|
||||
DeleteByLineTextIntent: _DeleteByLineTextAction(),
|
||||
DeleteForwardTextIntent: _DeleteForwardTextAction(),
|
||||
DeleteForwardByWordTextIntent: _DeleteForwardByWordTextAction(),
|
||||
DeleteForwardByLineTextIntent: _DeleteForwardByLineTextAction(),
|
||||
ExtendSelectionDownTextIntent: _ExtendSelectionDownTextAction(),
|
||||
ExtendSelectionLeftByLineTextIntent: _ExtendSelectionLeftByLineTextAction(),
|
||||
ExtendSelectionLeftByWordTextIntent: _ExtendSelectionLeftByWordTextAction(),
|
||||
|
@ -82,48 +76,6 @@ class _DoNothingAndStopPropagationTextAction extends TextEditingAction<DoNothing
|
|||
void invoke(DoNothingAndStopPropagationTextIntent intent, [BuildContext? context]) {}
|
||||
}
|
||||
|
||||
class _DeleteTextAction extends TextEditingAction<DeleteTextIntent> {
|
||||
@override
|
||||
Object? invoke(DeleteTextIntent intent, [BuildContext? context]) {
|
||||
textEditingActionTarget!.renderEditable.delete(SelectionChangedCause.keyboard);
|
||||
}
|
||||
}
|
||||
|
||||
class _DeleteByWordTextAction extends TextEditingAction<DeleteByWordTextIntent> {
|
||||
@override
|
||||
Object? invoke(DeleteByWordTextIntent intent, [BuildContext? context]) {
|
||||
textEditingActionTarget!.renderEditable.deleteByWord(SelectionChangedCause.keyboard, false);
|
||||
}
|
||||
}
|
||||
|
||||
class _DeleteByLineTextAction extends TextEditingAction<DeleteByLineTextIntent> {
|
||||
@override
|
||||
Object? invoke(DeleteByLineTextIntent intent, [BuildContext? context]) {
|
||||
textEditingActionTarget!.renderEditable.deleteByLine(SelectionChangedCause.keyboard);
|
||||
}
|
||||
}
|
||||
|
||||
class _DeleteForwardTextAction extends TextEditingAction<DeleteForwardTextIntent> {
|
||||
@override
|
||||
Object? invoke(DeleteForwardTextIntent intent, [BuildContext? context]) {
|
||||
textEditingActionTarget!.renderEditable.deleteForward(SelectionChangedCause.keyboard);
|
||||
}
|
||||
}
|
||||
|
||||
class _DeleteForwardByWordTextAction extends TextEditingAction<DeleteForwardByWordTextIntent> {
|
||||
@override
|
||||
Object? invoke(DeleteForwardByWordTextIntent intent, [BuildContext? context]) {
|
||||
textEditingActionTarget!.renderEditable.deleteForwardByWord(SelectionChangedCause.keyboard, false);
|
||||
}
|
||||
}
|
||||
|
||||
class _DeleteForwardByLineTextAction extends TextEditingAction<DeleteForwardByLineTextIntent> {
|
||||
@override
|
||||
Object? invoke(DeleteForwardByLineTextIntent intent, [BuildContext? context]) {
|
||||
textEditingActionTarget!.renderEditable.deleteForwardByLine(SelectionChangedCause.keyboard);
|
||||
}
|
||||
}
|
||||
|
||||
class _ExpandSelectionLeftByLineTextAction extends TextEditingAction<ExpandSelectionLeftByLineTextIntent> {
|
||||
@override
|
||||
Object? invoke(ExpandSelectionLeftByLineTextIntent intent, [BuildContext? context]) {
|
||||
|
|
|
@ -161,12 +161,6 @@ class DefaultTextEditingShortcuts extends Shortcuts {
|
|||
);
|
||||
|
||||
static final Map<LogicalKeySet, Intent> _androidShortcuts = <LogicalKeySet, Intent>{
|
||||
LogicalKeySet(LogicalKeyboardKey.backspace): const DeleteTextIntent(),
|
||||
LogicalKeySet(LogicalKeyboardKey.control, LogicalKeyboardKey.backspace): const DeleteByWordTextIntent(),
|
||||
LogicalKeySet(LogicalKeyboardKey.alt, LogicalKeyboardKey.backspace): const DeleteByLineTextIntent(),
|
||||
LogicalKeySet(LogicalKeyboardKey.delete): const DeleteForwardTextIntent(),
|
||||
LogicalKeySet(LogicalKeyboardKey.control, LogicalKeyboardKey.delete): const DeleteForwardByWordTextIntent(),
|
||||
LogicalKeySet(LogicalKeyboardKey.alt, LogicalKeyboardKey.delete): const DeleteForwardByLineTextIntent(),
|
||||
LogicalKeySet(LogicalKeyboardKey.alt, LogicalKeyboardKey.arrowDown): const MoveSelectionToEndTextIntent(),
|
||||
LogicalKeySet(LogicalKeyboardKey.alt, LogicalKeyboardKey.arrowLeft): const MoveSelectionLeftByLineTextIntent(),
|
||||
LogicalKeySet(LogicalKeyboardKey.alt, LogicalKeyboardKey.arrowRight): const MoveSelectionRightByLineTextIntent(),
|
||||
|
@ -201,17 +195,9 @@ class DefaultTextEditingShortcuts extends Shortcuts {
|
|||
// * Meta + shift + arrow up
|
||||
// * Shift + end
|
||||
// * Shift + home
|
||||
// * Meta + delete
|
||||
// * Meta + backspace
|
||||
};
|
||||
|
||||
static final Map<LogicalKeySet, Intent> _fuchsiaShortcuts = <LogicalKeySet, Intent>{
|
||||
LogicalKeySet(LogicalKeyboardKey.backspace): const DeleteTextIntent(),
|
||||
LogicalKeySet(LogicalKeyboardKey.control, LogicalKeyboardKey.backspace): const DeleteByWordTextIntent(),
|
||||
LogicalKeySet(LogicalKeyboardKey.alt, LogicalKeyboardKey.backspace): const DeleteByLineTextIntent(),
|
||||
LogicalKeySet(LogicalKeyboardKey.delete): const DeleteForwardTextIntent(),
|
||||
LogicalKeySet(LogicalKeyboardKey.control, LogicalKeyboardKey.delete): const DeleteForwardByWordTextIntent(),
|
||||
LogicalKeySet(LogicalKeyboardKey.alt, LogicalKeyboardKey.delete): const DeleteForwardByLineTextIntent(),
|
||||
LogicalKeySet(LogicalKeyboardKey.alt, LogicalKeyboardKey.arrowDown): const MoveSelectionToEndTextIntent(),
|
||||
LogicalKeySet(LogicalKeyboardKey.alt, LogicalKeyboardKey.arrowLeft): const MoveSelectionLeftByLineTextIntent(),
|
||||
LogicalKeySet(LogicalKeyboardKey.alt, LogicalKeyboardKey.arrowRight): const MoveSelectionRightByLineTextIntent(),
|
||||
|
@ -246,17 +232,9 @@ class DefaultTextEditingShortcuts extends Shortcuts {
|
|||
// * Meta + shift + arrow up
|
||||
// * Shift + end
|
||||
// * Shift + home
|
||||
// * Meta + delete
|
||||
// * Meta + backspace
|
||||
};
|
||||
|
||||
static final Map<LogicalKeySet, Intent> _iOSShortcuts = <LogicalKeySet, Intent>{
|
||||
LogicalKeySet(LogicalKeyboardKey.backspace): const DeleteTextIntent(),
|
||||
LogicalKeySet(LogicalKeyboardKey.control, LogicalKeyboardKey.backspace): const DeleteByWordTextIntent(),
|
||||
LogicalKeySet(LogicalKeyboardKey.alt, LogicalKeyboardKey.backspace): const DeleteByLineTextIntent(),
|
||||
LogicalKeySet(LogicalKeyboardKey.delete): const DeleteForwardTextIntent(),
|
||||
LogicalKeySet(LogicalKeyboardKey.control, LogicalKeyboardKey.delete): const DeleteForwardByWordTextIntent(),
|
||||
LogicalKeySet(LogicalKeyboardKey.alt, LogicalKeyboardKey.delete): const DeleteForwardByLineTextIntent(),
|
||||
LogicalKeySet(LogicalKeyboardKey.alt, LogicalKeyboardKey.arrowDown): const MoveSelectionToEndTextIntent(),
|
||||
LogicalKeySet(LogicalKeyboardKey.alt, LogicalKeyboardKey.arrowLeft): const MoveSelectionLeftByLineTextIntent(),
|
||||
LogicalKeySet(LogicalKeyboardKey.alt, LogicalKeyboardKey.arrowRight): const MoveSelectionRightByLineTextIntent(),
|
||||
|
@ -291,17 +269,9 @@ class DefaultTextEditingShortcuts extends Shortcuts {
|
|||
// * Meta + shift + arrow up
|
||||
// * Shift + end
|
||||
// * Shift + home
|
||||
// * Meta + delete
|
||||
// * Meta + backspace
|
||||
};
|
||||
|
||||
static final Map<LogicalKeySet, Intent> _linuxShortcuts = <LogicalKeySet, Intent>{
|
||||
LogicalKeySet(LogicalKeyboardKey.backspace): const DeleteTextIntent(),
|
||||
LogicalKeySet(LogicalKeyboardKey.control, LogicalKeyboardKey.backspace): const DeleteByWordTextIntent(),
|
||||
LogicalKeySet(LogicalKeyboardKey.alt, LogicalKeyboardKey.backspace): const DeleteByLineTextIntent(),
|
||||
LogicalKeySet(LogicalKeyboardKey.delete): const DeleteForwardTextIntent(),
|
||||
LogicalKeySet(LogicalKeyboardKey.control, LogicalKeyboardKey.delete): const DeleteForwardByWordTextIntent(),
|
||||
LogicalKeySet(LogicalKeyboardKey.alt, LogicalKeyboardKey.delete): const DeleteForwardByLineTextIntent(),
|
||||
LogicalKeySet(LogicalKeyboardKey.alt, LogicalKeyboardKey.arrowDown): const MoveSelectionToEndTextIntent(),
|
||||
LogicalKeySet(LogicalKeyboardKey.alt, LogicalKeyboardKey.arrowLeft): const MoveSelectionLeftByLineTextIntent(),
|
||||
LogicalKeySet(LogicalKeyboardKey.alt, LogicalKeyboardKey.arrowRight): const MoveSelectionRightByLineTextIntent(),
|
||||
|
@ -336,17 +306,9 @@ class DefaultTextEditingShortcuts extends Shortcuts {
|
|||
// * Meta + shift + arrow up
|
||||
// * Shift + end
|
||||
// * Shift + home
|
||||
// * Meta + delete
|
||||
// * Meta + backspace
|
||||
};
|
||||
|
||||
static final Map<LogicalKeySet, Intent> _macShortcuts = <LogicalKeySet, Intent>{
|
||||
LogicalKeySet(LogicalKeyboardKey.backspace): const DeleteTextIntent(),
|
||||
LogicalKeySet(LogicalKeyboardKey.alt, LogicalKeyboardKey.backspace): const DeleteByWordTextIntent(),
|
||||
LogicalKeySet(LogicalKeyboardKey.meta, LogicalKeyboardKey.backspace): const DeleteByLineTextIntent(),
|
||||
LogicalKeySet(LogicalKeyboardKey.delete): const DeleteForwardTextIntent(),
|
||||
LogicalKeySet(LogicalKeyboardKey.alt, LogicalKeyboardKey.delete): const DeleteForwardByWordTextIntent(),
|
||||
LogicalKeySet(LogicalKeyboardKey.meta, LogicalKeyboardKey.delete): const DeleteForwardByLineTextIntent(),
|
||||
LogicalKeySet(LogicalKeyboardKey.alt, LogicalKeyboardKey.arrowDown): const MoveSelectionRightByLineTextIntent(),
|
||||
LogicalKeySet(LogicalKeyboardKey.alt, LogicalKeyboardKey.arrowLeft): const MoveSelectionLeftByWordTextIntent(),
|
||||
LogicalKeySet(LogicalKeyboardKey.alt, LogicalKeyboardKey.arrowRight): const MoveSelectionRightByWordTextIntent(),
|
||||
|
@ -381,17 +343,9 @@ class DefaultTextEditingShortcuts extends Shortcuts {
|
|||
// * Home
|
||||
// * Shift + end
|
||||
// * Shift + home
|
||||
// * Control + delete
|
||||
// * Control + backspace
|
||||
};
|
||||
|
||||
static final Map<LogicalKeySet, Intent> _windowsShortcuts = <LogicalKeySet, Intent>{
|
||||
LogicalKeySet(LogicalKeyboardKey.backspace): const DeleteTextIntent(),
|
||||
LogicalKeySet(LogicalKeyboardKey.control, LogicalKeyboardKey.backspace): const DeleteByWordTextIntent(),
|
||||
LogicalKeySet(LogicalKeyboardKey.alt, LogicalKeyboardKey.backspace): const DeleteByLineTextIntent(),
|
||||
LogicalKeySet(LogicalKeyboardKey.delete): const DeleteForwardTextIntent(),
|
||||
LogicalKeySet(LogicalKeyboardKey.control, LogicalKeyboardKey.delete): const DeleteForwardByWordTextIntent(),
|
||||
LogicalKeySet(LogicalKeyboardKey.alt, LogicalKeyboardKey.delete): const DeleteForwardByLineTextIntent(),
|
||||
LogicalKeySet(LogicalKeyboardKey.alt, LogicalKeyboardKey.arrowDown): const MoveSelectionToEndTextIntent(),
|
||||
LogicalKeySet(LogicalKeyboardKey.alt, LogicalKeyboardKey.arrowLeft): const MoveSelectionLeftByLineTextIntent(),
|
||||
LogicalKeySet(LogicalKeyboardKey.alt, LogicalKeyboardKey.arrowRight): const MoveSelectionRightByLineTextIntent(),
|
||||
|
@ -426,21 +380,11 @@ class DefaultTextEditingShortcuts extends Shortcuts {
|
|||
// * Meta + shift + arrow left
|
||||
// * Meta + shift + arrow right
|
||||
// * Meta + shift + arrow up
|
||||
// * Meta + delete
|
||||
// * Meta + backspace
|
||||
};
|
||||
|
||||
// Web handles its text selection natively and doesn't use any of these
|
||||
// shortcuts in Flutter.
|
||||
static final Map<LogicalKeySet, Intent> _webShortcuts = <LogicalKeySet, Intent>{
|
||||
LogicalKeySet(LogicalKeyboardKey.backspace): const DoNothingAndStopPropagationTextIntent(),
|
||||
LogicalKeySet(LogicalKeyboardKey.delete): const DoNothingAndStopPropagationTextIntent(),
|
||||
LogicalKeySet(LogicalKeyboardKey.alt, LogicalKeyboardKey.backspace): const DoNothingAndStopPropagationTextIntent(),
|
||||
LogicalKeySet(LogicalKeyboardKey.alt, LogicalKeyboardKey.delete): const DoNothingAndStopPropagationTextIntent(),
|
||||
LogicalKeySet(LogicalKeyboardKey.control, LogicalKeyboardKey.backspace): const DoNothingAndStopPropagationTextIntent(),
|
||||
LogicalKeySet(LogicalKeyboardKey.control, LogicalKeyboardKey.delete): const DoNothingAndStopPropagationTextIntent(),
|
||||
LogicalKeySet(LogicalKeyboardKey.meta, LogicalKeyboardKey.backspace): const DoNothingAndStopPropagationTextIntent(),
|
||||
LogicalKeySet(LogicalKeyboardKey.meta, LogicalKeyboardKey.delete): const DoNothingAndStopPropagationTextIntent(),
|
||||
LogicalKeySet(LogicalKeyboardKey.alt, LogicalKeyboardKey.arrowDown): const DoNothingAndStopPropagationTextIntent(),
|
||||
LogicalKeySet(LogicalKeyboardKey.alt, LogicalKeyboardKey.arrowLeft): const DoNothingAndStopPropagationTextIntent(),
|
||||
LogicalKeySet(LogicalKeyboardKey.alt, LogicalKeyboardKey.arrowRight): const DoNothingAndStopPropagationTextIntent(),
|
||||
|
|
|
@ -4,54 +4,6 @@
|
|||
|
||||
import 'actions.dart';
|
||||
|
||||
/// An [Intent] to delete a character in the backwards direction.
|
||||
///
|
||||
/// {@macro flutter.widgets.TextEditingIntents.seeAlso}
|
||||
class DeleteTextIntent extends Intent{
|
||||
/// Creates an instance of DeleteTextIntent.
|
||||
const DeleteTextIntent();
|
||||
}
|
||||
|
||||
/// An [Intent] to delete a word in the backwards direction.
|
||||
///
|
||||
/// {@macro flutter.widgets.TextEditingIntents.seeAlso}
|
||||
class DeleteByWordTextIntent extends Intent{
|
||||
/// Creates an instance of DeleteByWordTextIntent.
|
||||
const DeleteByWordTextIntent();
|
||||
}
|
||||
|
||||
/// An [Intent] to delete a line in the backwards direction.
|
||||
///
|
||||
/// {@macro flutter.widgets.TextEditingIntents.seeAlso}
|
||||
class DeleteByLineTextIntent extends Intent{
|
||||
/// Creates an instance of DeleteByLineTextIntent.
|
||||
const DeleteByLineTextIntent();
|
||||
}
|
||||
|
||||
/// An [Intent] to delete in the forward direction.
|
||||
///
|
||||
/// {@macro flutter.widgets.TextEditingIntents.seeAlso}
|
||||
class DeleteForwardTextIntent extends Intent{
|
||||
/// Creates an instance of DeleteForwardTextIntent.
|
||||
const DeleteForwardTextIntent();
|
||||
}
|
||||
|
||||
/// An [Intent] to delete a word in the forward direction.
|
||||
///
|
||||
/// {@macro flutter.widgets.TextEditingIntents.seeAlso}
|
||||
class DeleteForwardByWordTextIntent extends Intent{
|
||||
/// Creates an instance of DeleteByWordTextIntent.
|
||||
const DeleteForwardByWordTextIntent();
|
||||
}
|
||||
|
||||
/// An [Intent] to delete a line in the forward direction.
|
||||
///
|
||||
/// {@macro flutter.widgets.TextEditingIntents.seeAlso}
|
||||
class DeleteForwardByLineTextIntent extends Intent{
|
||||
/// Creates an instance of DeleteByLineTextIntent.
|
||||
const DeleteForwardByLineTextIntent();
|
||||
}
|
||||
|
||||
/// An [Intent] to send the event straight to the engine, but only if a
|
||||
/// TextEditingTarget is focused.
|
||||
///
|
||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue