mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-04-20 11:08:03 +08:00
@@ -145,17 +145,13 @@ class VerticalCaretMovementRun implements Iterator<TextPosition> {
|
||||
}
|
||||
assert(lineNumber != _currentLine);
|
||||
|
||||
final Offset newOffset = Offset(
|
||||
final newOffset = Offset(
|
||||
_currentOffset.dx,
|
||||
_lineMetrics[lineNumber].baseline,
|
||||
);
|
||||
final TextPosition closestPosition = _editable._textPainter
|
||||
.getPositionForOffset(newOffset);
|
||||
final MapEntry<Offset, TextPosition> position =
|
||||
MapEntry<Offset, TextPosition>(
|
||||
newOffset,
|
||||
closestPosition,
|
||||
);
|
||||
final position = MapEntry<Offset, TextPosition>(newOffset, closestPosition);
|
||||
_positionCache[lineNumber] = position;
|
||||
return position;
|
||||
}
|
||||
@@ -419,8 +415,9 @@ class RenderEditable extends RenderBox
|
||||
);
|
||||
|
||||
if (_foregroundRenderObject == null) {
|
||||
final _RenderEditableCustomPaint foregroundRenderObject =
|
||||
_RenderEditableCustomPaint(painter: effectivePainter);
|
||||
final foregroundRenderObject = _RenderEditableCustomPaint(
|
||||
painter: effectivePainter,
|
||||
);
|
||||
adoptChild(foregroundRenderObject);
|
||||
_foregroundRenderObject = foregroundRenderObject;
|
||||
} else {
|
||||
@@ -452,8 +449,9 @@ class RenderEditable extends RenderBox
|
||||
);
|
||||
|
||||
if (_backgroundRenderObject == null) {
|
||||
final _RenderEditableCustomPaint backgroundRenderObject =
|
||||
_RenderEditableCustomPaint(painter: effectivePainter);
|
||||
final backgroundRenderObject = _RenderEditableCustomPaint(
|
||||
painter: effectivePainter,
|
||||
);
|
||||
adoptChild(backgroundRenderObject);
|
||||
_backgroundRenderObject = backgroundRenderObject;
|
||||
} else {
|
||||
@@ -714,7 +712,7 @@ class RenderEditable extends RenderBox
|
||||
// happens in paragraph.cc's layout and TextPainter's
|
||||
// _applyFloatingPointHack. Ideally, the rounding mismatch will be fixed and
|
||||
// this can be changed to be a strict check instead of an approximation.
|
||||
const double visibleRegionSlop = 0.5;
|
||||
const visibleRegionSlop = 0.5;
|
||||
_selectionStartInViewport.value = visibleRegion
|
||||
.inflate(visibleRegionSlop)
|
||||
.contains(startOffset + effectiveOffset);
|
||||
@@ -1356,9 +1354,9 @@ class RenderEditable extends RenderBox
|
||||
obscuringCharacter * plainText.length,
|
||||
);
|
||||
} else {
|
||||
final StringBuffer buffer = StringBuffer();
|
||||
int offset = 0;
|
||||
final List<StringAttribute> attributes = <StringAttribute>[];
|
||||
final buffer = StringBuffer();
|
||||
var offset = 0;
|
||||
final attributes = <StringAttribute>[];
|
||||
for (final InlineSpanSemanticsInformation info in _semanticsInfo!) {
|
||||
final String label = info.semanticsLabel ?? info.text;
|
||||
for (final StringAttribute infoAttribute in info.stringAttributes) {
|
||||
@@ -1436,19 +1434,19 @@ class RenderEditable extends RenderBox
|
||||
Iterable<SemanticsNode> children,
|
||||
) {
|
||||
assert(_semanticsInfo != null && _semanticsInfo!.isNotEmpty);
|
||||
final List<SemanticsNode> newChildren = <SemanticsNode>[];
|
||||
final newChildren = <SemanticsNode>[];
|
||||
TextDirection currentDirection = textDirection;
|
||||
Rect currentRect;
|
||||
double ordinal = 0.0;
|
||||
int start = 0;
|
||||
int placeholderIndex = 0;
|
||||
int childIndex = 0;
|
||||
var ordinal = 0.0;
|
||||
var start = 0;
|
||||
var placeholderIndex = 0;
|
||||
var childIndex = 0;
|
||||
RenderBox? child = firstChild;
|
||||
final Map<Key, SemanticsNode> newChildCache = <Key, SemanticsNode>{};
|
||||
final newChildCache = <Key, SemanticsNode>{};
|
||||
_cachedCombinedSemanticsInfos ??= combineSemanticsInfo(_semanticsInfo!);
|
||||
for (final InlineSpanSemanticsInformation info
|
||||
in _cachedCombinedSemanticsInfos!) {
|
||||
final TextSelection selection = TextSelection(
|
||||
final selection = TextSelection(
|
||||
baseOffset: start,
|
||||
extentOffset: start + info.text.length,
|
||||
);
|
||||
@@ -1462,8 +1460,7 @@ class RenderEditable extends RenderBox
|
||||
.elementAt(childIndex)
|
||||
.isTagged(PlaceholderSpanIndexSemanticsTag(placeholderIndex))) {
|
||||
final SemanticsNode childNode = children.elementAt(childIndex);
|
||||
final TextParentData parentData =
|
||||
child!.parentData! as TextParentData;
|
||||
final parentData = child!.parentData! as TextParentData;
|
||||
assert(parentData.offset != null);
|
||||
newChildren.add(childNode);
|
||||
childIndex += 1;
|
||||
@@ -1471,7 +1468,7 @@ class RenderEditable extends RenderBox
|
||||
child = childAfter(child!);
|
||||
placeholderIndex += 1;
|
||||
} else {
|
||||
final TextDirection initialDirection = currentDirection;
|
||||
final initialDirection = currentDirection;
|
||||
final List<ui.TextBox> rects = _textPainter.getBoxesForSelection(
|
||||
selection,
|
||||
);
|
||||
@@ -1500,7 +1497,7 @@ class RenderEditable extends RenderBox
|
||||
rect.right.ceilToDouble() + 4.0,
|
||||
rect.bottom.ceilToDouble() + 4.0,
|
||||
);
|
||||
final SemanticsConfiguration configuration = SemanticsConfiguration()
|
||||
final configuration = SemanticsConfiguration()
|
||||
..sortKey = OrdinalSortKey(ordinal++)
|
||||
..textDirection = initialDirection
|
||||
..attributedLabel = AttributedString(
|
||||
@@ -1538,7 +1535,7 @@ class RenderEditable extends RenderBox
|
||||
if (_cachedChildNodes?.isNotEmpty ?? false) {
|
||||
newChild = _cachedChildNodes!.remove(_cachedChildNodes!.keys.first)!;
|
||||
} else {
|
||||
final UniqueKey key = UniqueKey();
|
||||
final key = UniqueKey();
|
||||
newChild = SemanticsNode(
|
||||
key: key,
|
||||
showOnScreen: _createShowOnScreenFor(key),
|
||||
@@ -1980,8 +1977,8 @@ class RenderEditable extends RenderBox
|
||||
if (cachedValue != null) {
|
||||
return cachedValue;
|
||||
}
|
||||
int count = 0;
|
||||
for (int index = 0; index < text.length; index += 1) {
|
||||
var count = 0;
|
||||
for (var index = 0; index < text.length; index += 1) {
|
||||
switch (text.codeUnitAt(index)) {
|
||||
case 0x000A: // LF
|
||||
case 0x0085: // NEL
|
||||
@@ -2242,7 +2239,7 @@ class RenderEditable extends RenderBox
|
||||
extentOffset = isNormalized ? newOffset.endOffset : newOffset.startOffset;
|
||||
}
|
||||
|
||||
final TextSelection newSelection = TextSelection(
|
||||
final newSelection = TextSelection(
|
||||
baseOffset: baseOffset,
|
||||
extentOffset: extentOffset,
|
||||
affinity: fromPosition.affinity,
|
||||
@@ -2591,12 +2588,12 @@ class RenderEditable extends RenderBox
|
||||
};
|
||||
|
||||
size = Size(width, constraints.constrainHeight(preferredHeight));
|
||||
final Size contentSize = Size(
|
||||
final contentSize = Size(
|
||||
_textPainter.width + _caretMargin,
|
||||
_textPainter.height,
|
||||
);
|
||||
|
||||
final BoxConstraints painterConstraints = BoxConstraints.tight(contentSize);
|
||||
final painterConstraints = BoxConstraints.tight(contentSize);
|
||||
|
||||
_foregroundRenderObject?.layout(painterConstraints);
|
||||
_backgroundRenderObject?.layout(painterConstraints);
|
||||
@@ -2656,7 +2653,7 @@ class RenderEditable extends RenderBox
|
||||
final double rightBound =
|
||||
math.min(size.width, _textPainter.width) +
|
||||
floatingCursorAddedMargin.right;
|
||||
final Rect boundingRects = Rect.fromLTRB(
|
||||
final boundingRects = Rect.fromLTRB(
|
||||
leftBound,
|
||||
topBound,
|
||||
rightBound,
|
||||
@@ -2780,7 +2777,7 @@ class RenderEditable extends RenderBox
|
||||
startPosition,
|
||||
Rect.zero,
|
||||
);
|
||||
for (final ui.LineMetrics lineMetrics in metrics) {
|
||||
for (final lineMetrics in metrics) {
|
||||
if (lineMetrics.baseline > offset.dy) {
|
||||
return MapEntry<int, Offset>(
|
||||
lineMetrics.lineNumber,
|
||||
@@ -3163,7 +3160,7 @@ class _TextHighlightPainter extends RenderEditablePainter {
|
||||
)
|
||||
.toSet();
|
||||
|
||||
for (final TextBox box in boxes) {
|
||||
for (final box in boxes) {
|
||||
canvas.drawRect(
|
||||
box
|
||||
.toRect()
|
||||
@@ -3290,7 +3287,7 @@ class _CaretPainter extends RenderEditablePainter {
|
||||
if (radius == null) {
|
||||
canvas.drawRect(integralRect, caretPaint);
|
||||
} else {
|
||||
final RRect caretRRect = RRect.fromRectAndRadius(integralRect, radius);
|
||||
final caretRRect = RRect.fromRectAndRadius(integralRect, radius);
|
||||
canvas.drawRRect(caretRRect, caretPaint);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user