|
|
|
@ -342,40 +342,40 @@ class BasicTextInputClientState extends State<BasicTextInputClient>
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// These actions have yet to be implemented for this sample.
|
|
|
|
// These actions have yet to be implemented for this sample.
|
|
|
|
static final Map<Type, Action<Intent>>
|
|
|
|
static final Map<Type, Action<Intent>> _unsupportedActions =
|
|
|
|
_unsupportedActions = <Type, Action<Intent>>{
|
|
|
|
<Type, Action<Intent>>{
|
|
|
|
DeleteToNextWordBoundaryIntent: DoNothingAction(consumesKey: false),
|
|
|
|
DeleteToNextWordBoundaryIntent: DoNothingAction(consumesKey: false),
|
|
|
|
DeleteToLineBreakIntent: DoNothingAction(consumesKey: false),
|
|
|
|
DeleteToLineBreakIntent: DoNothingAction(consumesKey: false),
|
|
|
|
ExtendSelectionToNextWordBoundaryIntent: DoNothingAction(
|
|
|
|
ExtendSelectionToNextWordBoundaryIntent: DoNothingAction(
|
|
|
|
consumesKey: false,
|
|
|
|
consumesKey: false,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
ExtendSelectionToNextParagraphBoundaryOrCaretLocationIntent:
|
|
|
|
ExtendSelectionToNextParagraphBoundaryOrCaretLocationIntent:
|
|
|
|
DoNothingAction(consumesKey: false),
|
|
|
|
DoNothingAction(consumesKey: false),
|
|
|
|
ExtendSelectionToLineBreakIntent: DoNothingAction(consumesKey: false),
|
|
|
|
ExtendSelectionToLineBreakIntent: DoNothingAction(consumesKey: false),
|
|
|
|
ExtendSelectionVerticallyToAdjacentLineIntent: DoNothingAction(
|
|
|
|
ExtendSelectionVerticallyToAdjacentLineIntent: DoNothingAction(
|
|
|
|
consumesKey: false,
|
|
|
|
consumesKey: false,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
ExtendSelectionVerticallyToAdjacentPageIntent: DoNothingAction(
|
|
|
|
ExtendSelectionVerticallyToAdjacentPageIntent: DoNothingAction(
|
|
|
|
consumesKey: false,
|
|
|
|
consumesKey: false,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
ExtendSelectionToNextParagraphBoundaryIntent: DoNothingAction(
|
|
|
|
ExtendSelectionToNextParagraphBoundaryIntent: DoNothingAction(
|
|
|
|
consumesKey: false,
|
|
|
|
consumesKey: false,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
ExtendSelectionToDocumentBoundaryIntent: DoNothingAction(
|
|
|
|
ExtendSelectionToDocumentBoundaryIntent: DoNothingAction(
|
|
|
|
consumesKey: false,
|
|
|
|
consumesKey: false,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
ExtendSelectionByPageIntent: DoNothingAction(consumesKey: false),
|
|
|
|
ExtendSelectionByPageIntent: DoNothingAction(consumesKey: false),
|
|
|
|
ExpandSelectionToDocumentBoundaryIntent: DoNothingAction(
|
|
|
|
ExpandSelectionToDocumentBoundaryIntent: DoNothingAction(
|
|
|
|
consumesKey: false,
|
|
|
|
consumesKey: false,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
ExpandSelectionToLineBreakIntent: DoNothingAction(consumesKey: false),
|
|
|
|
ExpandSelectionToLineBreakIntent: DoNothingAction(consumesKey: false),
|
|
|
|
ScrollToDocumentBoundaryIntent: DoNothingAction(consumesKey: false),
|
|
|
|
ScrollToDocumentBoundaryIntent: DoNothingAction(consumesKey: false),
|
|
|
|
RedoTextIntent: DoNothingAction(consumesKey: false),
|
|
|
|
RedoTextIntent: DoNothingAction(consumesKey: false),
|
|
|
|
ReplaceTextIntent: DoNothingAction(consumesKey: false),
|
|
|
|
ReplaceTextIntent: DoNothingAction(consumesKey: false),
|
|
|
|
UndoTextIntent: DoNothingAction(consumesKey: false),
|
|
|
|
UndoTextIntent: DoNothingAction(consumesKey: false),
|
|
|
|
UpdateSelectionIntent: DoNothingAction(consumesKey: false),
|
|
|
|
UpdateSelectionIntent: DoNothingAction(consumesKey: false),
|
|
|
|
TransposeCharactersIntent: DoNothingAction(consumesKey: false),
|
|
|
|
TransposeCharactersIntent: DoNothingAction(consumesKey: false),
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/// Keyboard text editing actions.
|
|
|
|
/// Keyboard text editing actions.
|
|
|
|
// The Handling of the default text editing shortcuts with deltas
|
|
|
|
// The Handling of the default text editing shortcuts with deltas
|
|
|
|
@ -582,9 +582,7 @@ class BasicTextInputClientState extends State<BasicTextInputClient>
|
|
|
|
|
|
|
|
|
|
|
|
void _updateCaretRectIfNeeded() {
|
|
|
|
void _updateCaretRectIfNeeded() {
|
|
|
|
final TextSelection? selection = renderEditable.selection;
|
|
|
|
final TextSelection? selection = renderEditable.selection;
|
|
|
|
if (selection == null ||
|
|
|
|
if (selection == null || !selection.isValid || !selection.isCollapsed) {
|
|
|
|
!selection.isValid ||
|
|
|
|
|
|
|
|
!selection.isCollapsed) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
final TextPosition currentTextPosition = TextPosition(
|
|
|
|
final TextPosition currentTextPosition = TextPosition(
|
|
|
|
@ -982,9 +980,7 @@ class BasicTextInputClientState extends State<BasicTextInputClient>
|
|
|
|
final InlineSpan span = renderEditable.text!;
|
|
|
|
final InlineSpan span = renderEditable.text!;
|
|
|
|
final String prevText = span.toPlainText();
|
|
|
|
final String prevText = span.toPlainText();
|
|
|
|
final String currText = textEditingValue.text;
|
|
|
|
final String currText = textEditingValue.text;
|
|
|
|
if (prevText != currText ||
|
|
|
|
if (prevText != currText || !selection.isValid || selection.isCollapsed) {
|
|
|
|
!selection.isValid ||
|
|
|
|
|
|
|
|
selection.isCollapsed) {
|
|
|
|
|
|
|
|
return _GlyphHeights(
|
|
|
|
return _GlyphHeights(
|
|
|
|
start: renderEditable.preferredLineHeight,
|
|
|
|
start: renderEditable.preferredLineHeight,
|
|
|
|
end: renderEditable.preferredLineHeight,
|
|
|
|
end: renderEditable.preferredLineHeight,
|
|
|
|
@ -994,13 +990,12 @@ class BasicTextInputClientState extends State<BasicTextInputClient>
|
|
|
|
final String selectedGraphemes = selection.textInside(currText);
|
|
|
|
final String selectedGraphemes = selection.textInside(currText);
|
|
|
|
final int firstSelectedGraphemeExtent =
|
|
|
|
final int firstSelectedGraphemeExtent =
|
|
|
|
selectedGraphemes.characters.first.length;
|
|
|
|
selectedGraphemes.characters.first.length;
|
|
|
|
final Rect? startCharacterRect = renderEditable
|
|
|
|
final Rect? startCharacterRect = renderEditable.getRectForComposingRange(
|
|
|
|
.getRectForComposingRange(
|
|
|
|
TextRange(
|
|
|
|
TextRange(
|
|
|
|
start: selection.start,
|
|
|
|
start: selection.start,
|
|
|
|
end: selection.start + firstSelectedGraphemeExtent,
|
|
|
|
end: selection.start + firstSelectedGraphemeExtent,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
final int lastSelectedGraphemeExtent =
|
|
|
|
final int lastSelectedGraphemeExtent =
|
|
|
|
selectedGraphemes.characters.last.length;
|
|
|
|
selectedGraphemes.characters.last.length;
|
|
|
|
final Rect? endCharacterRect = renderEditable.getRectForComposingRange(
|
|
|
|
final Rect? endCharacterRect = renderEditable.getRectForComposingRange(
|
|
|
|
@ -1010,8 +1005,7 @@ class BasicTextInputClientState extends State<BasicTextInputClient>
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
);
|
|
|
|
return _GlyphHeights(
|
|
|
|
return _GlyphHeights(
|
|
|
|
start:
|
|
|
|
start: startCharacterRect?.height ?? renderEditable.preferredLineHeight,
|
|
|
|
startCharacterRect?.height ?? renderEditable.preferredLineHeight,
|
|
|
|
|
|
|
|
end: endCharacterRect?.height ?? renderEditable.preferredLineHeight,
|
|
|
|
end: endCharacterRect?.height ?? renderEditable.preferredLineHeight,
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -1095,9 +1089,7 @@ class BasicTextInputClientState extends State<BasicTextInputClient>
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return !textEditingValue.selection.isCollapsed &&
|
|
|
|
return !textEditingValue.selection.isCollapsed &&
|
|
|
|
textEditingValue.selection
|
|
|
|
textEditingValue.selection.textInside(textEditingValue.text).trim() !=
|
|
|
|
.textInside(textEditingValue.text)
|
|
|
|
|
|
|
|
.trim() !=
|
|
|
|
|
|
|
|
'';
|
|
|
|
'';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -1160,8 +1152,7 @@ class BasicTextInputClientState extends State<BasicTextInputClient>
|
|
|
|
startHandleLayerLink: _startHandleLayerLink,
|
|
|
|
startHandleLayerLink: _startHandleLayerLink,
|
|
|
|
endHandleLayerLink: _endHandleLayerLink,
|
|
|
|
endHandleLayerLink: _endHandleLayerLink,
|
|
|
|
inlineSpan: _buildTextSpan(),
|
|
|
|
inlineSpan: _buildTextSpan(),
|
|
|
|
value:
|
|
|
|
value: _value, // We pass value.selection to RenderEditable.
|
|
|
|
_value, // We pass value.selection to RenderEditable.
|
|
|
|
|
|
|
|
cursorColor: Colors.blue,
|
|
|
|
cursorColor: Colors.blue,
|
|
|
|
backgroundCursorColor: Colors.grey[100],
|
|
|
|
backgroundCursorColor: Colors.grey[100],
|
|
|
|
showCursor: ValueNotifier<bool>(_hasFocus),
|
|
|
|
showCursor: ValueNotifier<bool>(_hasFocus),
|
|
|
|
|