Fix Border Instability
This commit is contained in:
parent
01eb1e24b1
commit
96e4f0e32c
|
@ -89,11 +89,9 @@ class CursorProvider extends ChangeNotifier {
|
||||||
clearSelection();
|
clearSelection();
|
||||||
}
|
}
|
||||||
publishCursor(backingLines);
|
publishCursor(backingLines);
|
||||||
notifyListeners();
|
|
||||||
} else if (inMouseSelection == false) {
|
} else if (inMouseSelection == false) {
|
||||||
clearSelection();
|
clearSelection();
|
||||||
publishCursor(backingLines);
|
publishCursor(backingLines);
|
||||||
notifyListeners();
|
|
||||||
}
|
}
|
||||||
inMouseSelection = true;
|
inMouseSelection = true;
|
||||||
}
|
}
|
||||||
|
@ -107,11 +105,9 @@ class CursorProvider extends ChangeNotifier {
|
||||||
clearSelection();
|
clearSelection();
|
||||||
}
|
}
|
||||||
publishCursor(backingLines);
|
publishCursor(backingLines);
|
||||||
notifyListeners();
|
|
||||||
} else if (inMouseSelection == false) {
|
} else if (inMouseSelection == false) {
|
||||||
clearSelection();
|
clearSelection();
|
||||||
publishCursor(backingLines);
|
publishCursor(backingLines);
|
||||||
notifyListeners();
|
|
||||||
}
|
}
|
||||||
inMouseSelection = true;
|
inMouseSelection = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,7 @@ class LineInfo extends ChangeNotifier {
|
||||||
|
|
||||||
return LayoutBuilder(
|
return LayoutBuilder(
|
||||||
builder: (context, constraints) {
|
builder: (context, constraints) {
|
||||||
|
|
||||||
var highlightedLine = RichText(
|
var highlightedLine = RichText(
|
||||||
text: TextSpan(
|
text: TextSpan(
|
||||||
children: spans,
|
children: spans,
|
||||||
|
@ -48,7 +49,7 @@ class LineInfo extends ChangeNotifier {
|
||||||
|
|
||||||
var charWidth = (fontSize / 2.0);
|
var charWidth = (fontSize / 2.0);
|
||||||
var lineHeight = (fontSize * 1.2);
|
var lineHeight = (fontSize * 1.2);
|
||||||
var usableSize = (constraints.maxWidth - gutterWidth - rightMargin - leftMargin);
|
var usableSize = (constraints.maxWidth.floorToDouble() - gutterWidth - rightMargin - leftMargin).floorToDouble();
|
||||||
|
|
||||||
var sidebarContent = List<Widget>.empty(growable: true);
|
var sidebarContent = List<Widget>.empty(growable: true);
|
||||||
sidebarContent.add(Text('$lineNumber'.padLeft(5), style: gutterStyle));
|
sidebarContent.add(Text('$lineNumber'.padLeft(5), style: gutterStyle));
|
||||||
|
@ -75,7 +76,7 @@ class LineInfo extends ChangeNotifier {
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: backgroundStyle.backgroundColor,
|
color: backgroundStyle.backgroundColor,
|
||||||
),
|
),
|
||||||
width: constraints.maxWidth - rightMargin - gutterWidth - leftMargin,
|
width: usableSize,
|
||||||
height: idealHeight,
|
height: idealHeight,
|
||||||
child: highlightedLine,
|
child: highlightedLine,
|
||||||
);
|
);
|
||||||
|
@ -84,15 +85,16 @@ class LineInfo extends ChangeNotifier {
|
||||||
|
|
||||||
if (cursorStart != null) {
|
if (cursorStart != null) {
|
||||||
var maxCharsBeforeWrapping = (usableSize / charWidth).floorToDouble();
|
var maxCharsBeforeWrapping = (usableSize / charWidth).floorToDouble();
|
||||||
var cursorPosTop = (cursorStart! / maxCharsBeforeWrapping).floorToDouble() * lineHeight;
|
var cursorPosTop = ((cursorStart! / maxCharsBeforeWrapping).floorToDouble() * lineHeight).roundToDouble();
|
||||||
var cursorPosLeft = ((cursorStart! % maxCharsBeforeWrapping) * charWidth) - charWidth / 2.0;
|
var cursorPosLeft = max(0, (((cursorStart! % maxCharsBeforeWrapping) * charWidth) - charWidth / 2.0).roundToDouble());
|
||||||
TextStyle cursorStyle = TextStyle(fontFamily: 'Iosevka', fontSize: fontSize, color: foreground, backgroundColor: Colors.transparent, letterSpacing: -2.0);
|
TextStyle cursorStyle = TextStyle(fontFamily: 'Iosevka', fontSize: fontSize, color: foreground, backgroundColor: Colors.transparent, letterSpacing: -2.0);
|
||||||
var cursorPos =
|
var cursorPos = Positioned(top: cursorPosTop.toDouble(), left: leftMargin + cursorPosLeft.toDouble(), child: FadeTransition(opacity: animationController, child: Text("|", style: cursorStyle)));
|
||||||
Positioned(top: cursorPosTop.toDouble(), left: leftMargin + cursorPosLeft.toDouble(), child: FadeTransition(opacity: animationController, child: Text("|", style: cursorStyle)));
|
|
||||||
stackElements.add(cursorPos);
|
stackElements.add(cursorPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
var cursorOverlay = Stack(children: stackElements);
|
var cursorOverlay = Stack(children: stackElements);
|
||||||
|
print("rebuilding line $lineNumber $idealHeight");
|
||||||
|
// print("$charWidth $lineHeight $usableSize $idealHeight ${constraints.maxWidth}");
|
||||||
|
|
||||||
return Listener(
|
return Listener(
|
||||||
onPointerDown: (event) {
|
onPointerDown: (event) {
|
||||||
|
@ -135,23 +137,22 @@ class LineInfo extends ChangeNotifier {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onExit: (event) {
|
onExit: (event) {
|
||||||
notifyListeners();
|
|
||||||
},
|
},
|
||||||
child: Container(
|
child: Container(
|
||||||
color: backgroundStyle.backgroundColor,
|
color: backgroundStyle.backgroundColor,
|
||||||
padding: EdgeInsets.zero,
|
padding: EdgeInsets.zero,
|
||||||
margin: EdgeInsets.zero,
|
margin: EdgeInsets.zero,
|
||||||
height: idealHeight,
|
height: idealHeight,
|
||||||
width: constraints.maxWidth,
|
width: (usableSize + gutterWidth + rightMargin + leftMargin).floorToDouble(),
|
||||||
child: Row(mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [
|
child: Row(mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [
|
||||||
Container(
|
Container(
|
||||||
padding: EdgeInsets.zero,
|
padding: EdgeInsets.zero,
|
||||||
decoration: BoxDecoration(color: sidebarAlt, border: Border(right: BorderSide(width: 1, color: border))),
|
decoration: BoxDecoration(color: sidebarAlt),
|
||||||
width: gutterWidth - 1,
|
width: (gutterWidth - 2).floorToDouble(),
|
||||||
height: idealHeight,
|
height: idealHeight,
|
||||||
margin: EdgeInsets.only(right: 1, top: 0, bottom: 0, left: 0),
|
|
||||||
alignment: Alignment.centerLeft,
|
alignment: Alignment.centerLeft,
|
||||||
child: Flex(direction: Axis.horizontal, mainAxisAlignment: MainAxisAlignment.start, children: sidebarContent)),
|
margin: EdgeInsets.only(right: 1, top: 0, bottom: 0, left: 0),
|
||||||
|
child: Row(mainAxisAlignment: MainAxisAlignment.start, children: sidebarContent)),
|
||||||
cursorOverlay,
|
cursorOverlay,
|
||||||
]))));
|
]))));
|
||||||
},
|
},
|
||||||
|
|
|
@ -50,7 +50,7 @@ class _SarahDownApp extends State<SarahDownApp> {
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Material(
|
return Material(
|
||||||
color: sidebarAlt,
|
color: sidebarAlt,
|
||||||
child: Column(crossAxisAlignment: CrossAxisAlignment.stretch, children: [
|
child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
|
|
@ -79,12 +79,14 @@ class _View extends State<View> with SingleTickerProviderStateMixin {
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
return ScrollablePositionedList.builder(
|
return ScrollablePositionedList.builder(
|
||||||
physics: const AlwaysScrollableScrollPhysics(),
|
physics: const AlwaysScrollableScrollPhysics(),
|
||||||
itemScrollController: doc.scrollController,
|
itemScrollController: doc.scrollController,
|
||||||
itemCount: doc.lines(),
|
itemCount: doc.lines(),
|
||||||
padding: EdgeInsets.zero,
|
padding: EdgeInsets.zero,
|
||||||
shrinkWrap: true,
|
minCacheExtent: 10,
|
||||||
|
addRepaintBoundaries: true,
|
||||||
itemBuilder: (BuildContext bcontext, int index) {
|
itemBuilder: (BuildContext bcontext, int index) {
|
||||||
return ChangeNotifierProvider.value(
|
return ChangeNotifierProvider.value(
|
||||||
value: doc.backingLines[index],
|
value: doc.backingLines[index],
|
||||||
|
|
Loading…
Reference in New Issue