~emersion/goguma-dev

page/buffer: Make invisible compact message spacing unselectable v1 SUPERSEDED

delthas: 1
 page/buffer: Make invisible compact message spacing unselectable

 1 files changed, 17 insertions(+), 7 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~emersion/goguma-dev/patches/51321/mbox | git am -3
Learn more about email & git

[PATCH] page/buffer: Make invisible compact message spacing unselectable Export this patch

We're building compact message items by writing an invisible prefix
(stacked with an actual username), then the actual message, then
an invisible suffix (stack with an actual timestamp).

Currenty selecting a compact message text results in selecting the
invisible prefixes and suffixes as well, which results in unexpected
data being selected.

This patch makes these invisible hacky spacings unselectable so that
only the actual message can be selected and copied in the list.
---
 lib/page/buffer.dart | 24 +++++++++++++++++-------
 1 file changed, 17 insertions(+), 7 deletions(-)

diff --git a/lib/page/buffer.dart b/lib/page/buffer.dart
index 56cc234..a3c96aa 100644
--- a/lib/page/buffer.dart
+++ b/lib/page/buffer.dart
@@ -635,7 +635,7 @@ class _CompactMessageItem extends StatelessWidget {
		}).toList();

		List<Widget> stack = [];
		List<TextSpan> content = [];
		List<InlineSpan> content = [];

		if (!prevMsgSameSender) {
			var colorSwatch = Colors.primaries[sender.hashCode % Colors.primaries.length];
@@ -646,9 +646,14 @@ class _CompactMessageItem extends StatelessWidget {
				left: 0,
				child: Text(sender, style: senderStyle),
			));
			content.add(TextSpan(
				text: sender,
				style: senderStyle.apply(color: Color(0x00000000)),
			content.add(WidgetSpan(
				child: SelectionContainer.disabled(
					child: Text(
						sender,
						style: senderStyle.apply(color: Color(0x00000000)),
						semanticsLabel: '',  // Make screen reader quiet
					),
				),
			));
		}

@@ -665,9 +670,14 @@ class _CompactMessageItem extends StatelessWidget {
				right: 0,
				child: Text(timeText, style: timeStyle),
			));
			content.add(TextSpan(
				text: timeText,
				style: timeStyle.apply(color: Color(0x00000000)),
			content.add(WidgetSpan(
				child: SelectionContainer.disabled(
					child: Text(
						timeText,
						style: timeStyle.apply(color: Color(0x00000000)),
						semanticsLabel: '',  // Make screen reader quiet
					),
				),
			));
		}


base-commit: 38c1594530bf34129b3b20353ac614973a5b9d26
-- 
2.44.0