Unverified Commit fa98a522 authored by Justin McCandless's avatar Justin McCandless Committed by GitHub

Undo/redo (#96968)

parent 93a1b7a5
...@@ -205,6 +205,8 @@ class DefaultTextEditingShortcuts extends Shortcuts { ...@@ -205,6 +205,8 @@ class DefaultTextEditingShortcuts extends Shortcuts {
const SingleActivator(LogicalKeyboardKey.keyC, control: true): CopySelectionTextIntent.copy, const SingleActivator(LogicalKeyboardKey.keyC, control: true): CopySelectionTextIntent.copy,
const SingleActivator(LogicalKeyboardKey.keyV, control: true): const PasteTextIntent(SelectionChangedCause.keyboard), const SingleActivator(LogicalKeyboardKey.keyV, control: true): const PasteTextIntent(SelectionChangedCause.keyboard),
const SingleActivator(LogicalKeyboardKey.keyA, control: true): const SelectAllTextIntent(SelectionChangedCause.keyboard), const SingleActivator(LogicalKeyboardKey.keyA, control: true): const SelectAllTextIntent(SelectionChangedCause.keyboard),
const SingleActivator(LogicalKeyboardKey.keyZ, control: true): const UndoTextIntent(SelectionChangedCause.keyboard),
const SingleActivator(LogicalKeyboardKey.keyZ, shift: true, control: true): const RedoTextIntent(SelectionChangedCause.keyboard),
}; };
// The following key combinations have no effect on text editing on this // The following key combinations have no effect on text editing on this
...@@ -215,6 +217,7 @@ class DefaultTextEditingShortcuts extends Shortcuts { ...@@ -215,6 +217,7 @@ class DefaultTextEditingShortcuts extends Shortcuts {
// * Meta + C // * Meta + C
// * Meta + V // * Meta + V
// * Meta + A // * Meta + A
// * Meta + shift? + Z
// * Meta + shift? + arrow down // * Meta + shift? + arrow down
// * Meta + shift? + arrow left // * Meta + shift? + arrow left
// * Meta + shift? + arrow right // * Meta + shift? + arrow right
...@@ -235,6 +238,7 @@ class DefaultTextEditingShortcuts extends Shortcuts { ...@@ -235,6 +238,7 @@ class DefaultTextEditingShortcuts extends Shortcuts {
// * Meta + C // * Meta + C
// * Meta + V // * Meta + V
// * Meta + A // * Meta + A
// * Meta + shift? + Z
// * Meta + shift? + arrow down // * Meta + shift? + arrow down
// * Meta + shift? + arrow left // * Meta + shift? + arrow left
// * Meta + shift? + arrow right // * Meta + shift? + arrow right
...@@ -259,6 +263,7 @@ class DefaultTextEditingShortcuts extends Shortcuts { ...@@ -259,6 +263,7 @@ class DefaultTextEditingShortcuts extends Shortcuts {
// * Meta + C // * Meta + C
// * Meta + V // * Meta + V
// * Meta + A // * Meta + A
// * Meta + shift? + Z
// * Meta + shift? + arrow down // * Meta + shift? + arrow down
// * Meta + shift? + arrow left // * Meta + shift? + arrow left
// * Meta + shift? + arrow right // * Meta + shift? + arrow right
...@@ -319,12 +324,15 @@ class DefaultTextEditingShortcuts extends Shortcuts { ...@@ -319,12 +324,15 @@ class DefaultTextEditingShortcuts extends Shortcuts {
const SingleActivator(LogicalKeyboardKey.keyC, meta: true): CopySelectionTextIntent.copy, const SingleActivator(LogicalKeyboardKey.keyC, meta: true): CopySelectionTextIntent.copy,
const SingleActivator(LogicalKeyboardKey.keyV, meta: true): const PasteTextIntent(SelectionChangedCause.keyboard), const SingleActivator(LogicalKeyboardKey.keyV, meta: true): const PasteTextIntent(SelectionChangedCause.keyboard),
const SingleActivator(LogicalKeyboardKey.keyA, meta: true): const SelectAllTextIntent(SelectionChangedCause.keyboard), const SingleActivator(LogicalKeyboardKey.keyA, meta: true): const SelectAllTextIntent(SelectionChangedCause.keyboard),
const SingleActivator(LogicalKeyboardKey.keyZ, meta: true): const UndoTextIntent(SelectionChangedCause.keyboard),
const SingleActivator(LogicalKeyboardKey.keyZ, shift: true, meta: true): const RedoTextIntent(SelectionChangedCause.keyboard),
// The following key combinations have no effect on text editing on this // The following key combinations have no effect on text editing on this
// platform: // platform:
// * End // * End
// * Home // * Home
// * Control + shift? + end // * Control + shift? + end
// * Control + shift? + home // * Control + shift? + home
// * Control + shift? + Z
}; };
// The following key combinations have no effect on text editing on this // The following key combinations have no effect on text editing on this
......
...@@ -231,6 +231,16 @@ class PasteTextIntent extends Intent { ...@@ -231,6 +231,16 @@ class PasteTextIntent extends Intent {
final SelectionChangedCause cause; final SelectionChangedCause cause;
} }
/// An [Intent] that represents a user interaction that attempts to go back to
/// the previous editing state.
class RedoTextIntent extends Intent {
/// Creates a [RedoTextIntent].
const RedoTextIntent(this.cause);
/// {@macro flutter.widgets.TextEditingIntents.cause}
final SelectionChangedCause cause;
}
/// An [Intent] that represents a user interaction that attempts to modify the /// An [Intent] that represents a user interaction that attempts to modify the
/// current [TextEditingValue] in an input field. /// current [TextEditingValue] in an input field.
class ReplaceTextIntent extends Intent { class ReplaceTextIntent extends Intent {
...@@ -250,10 +260,20 @@ class ReplaceTextIntent extends Intent { ...@@ -250,10 +260,20 @@ class ReplaceTextIntent extends Intent {
final SelectionChangedCause cause; final SelectionChangedCause cause;
} }
/// An [Intent] that represents a user interaction that attempts to go back to
/// the previous editing state.
class UndoTextIntent extends Intent {
/// Creates an [UndoTextIntent].
const UndoTextIntent(this.cause);
/// {@macro flutter.widgets.TextEditingIntents.cause}
final SelectionChangedCause cause;
}
/// An [Intent] that represents a user interaction that attempts to change the /// An [Intent] that represents a user interaction that attempts to change the
/// selection in an input field. /// selection in an input field.
class UpdateSelectionIntent extends Intent { class UpdateSelectionIntent extends Intent {
/// Creates a [UpdateSelectionIntent]. /// Creates an [UpdateSelectionIntent].
const UpdateSelectionIntent(this.currentTextEditingValue, this.newSelection, this.cause); const UpdateSelectionIntent(this.currentTextEditingValue, this.newSelection, this.cause);
/// The [TextEditingValue] that this [Intent]'s action should perform on. /// The [TextEditingValue] that this [Intent]'s action should perform on.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment