Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kev/768_text_page_auto_copy #794

Merged
merged 3 commits into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions lib/providers/pty.dart
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,21 @@ final ptyProvider = StateProvider<Pty>((ref) {
/// Linux and MacOS desktops initiate R simply through the R command. Windows
/// does an R.exe.

// Rewrite code to remove nesting to pass the DCM test.

String get shell {
return Platform.isWindows
? 'R.exe'
: Platform.isMacOS
? '/usr/local/bin/R'
: Platform.isAndroid
// 20250113 gjw Trying a UserLand install of R on Android.
? '/data/data/tech.ula/files/support/busybox run-parts /data/data/tech.ula/files/support/executables -- /usr/bin/R'
: '/usr/bin/R';
if (Platform.isWindows) {
return 'R.exe';
}

if (Platform.isMacOS) {
return '/usr/local/bin/R';
}

if (Platform.isAndroid) {
// 20250113 gjw Trying a UserLand install of R on Android.
return '/data/data/tech.ula/files/support/busybox run-parts /data/data/tech.ula/files/support/executables -- /usr/bin/R';
}

return '/usr/bin/R';
}
22 changes: 22 additions & 0 deletions lib/widgets/text_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,28 @@ class TextPage extends StatelessWidget {
content,
style: monoTextStyle,
textAlign: TextAlign.left,
// Handle text selection changes in the content.

onSelectionChanged: (selection, cause) {
// Only copy text when user long presses or drags to select.

if (cause == SelectionChangedCause.longPress ||
cause == SelectionChangedCause.drag) {
// Extract the selected text using the selection range.

final selectedText = content.substring(
selection.start,
selection.end,
);
// If text was actually selected, copy it to clipboard.

if (selectedText.isNotEmpty) {
Clipboard.setData(
ClipboardData(text: selectedText),
);
}
}
},
),
),
),
Expand Down
Loading