| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- import 'package:flutter/material.dart';
- import 'package:xterm/core/terminal.dart';
- class Test extends StatelessWidget {
- const Test({Key? key}) : super(key: key);
- @override
- Widget build(BuildContext context) {
- return TextSelectionToolbar(
- anchorAbove: Offset(50, 50),
- anchorBelow: Offset(50, 50),
- children: [
- TextSelectionToolbarTextButton(
- child: Text('Copy'),
- onPressed: () {},
- padding: TextSelectionToolbarTextButton.getPadding(0, 1),
- ),
- TextSelectionToolbarTextButton(
- child: Text('Paste'),
- onPressed: () {},
- padding: TextSelectionToolbarTextButton.getPadding(1, 1),
- ),
- ],
- );
- }
- }
- void main(List<String> args) async {
- final lines = 1000;
- final terminal = Terminal(maxLines: lines);
- bench('write $lines lines', () {
- for (var i = 0; i < lines; i++) {
- terminal.write('https://github.com/TerminalStudio/dartssh2\r\n');
- }
- });
- final regexp = RegExp(
- r'[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)',
- );
- bench('search $lines line', () {
- var count = 0;
- for (var line in terminal.lines.toList()) {
- final matches = regexp.allMatches(line.toString());
- count += matches.length;
- }
- print('count: $count');
- });
- }
- void bench(String description, void Function() f) {
- final sw = Stopwatch()..start();
- f();
- print('$description took ${sw.elapsedMilliseconds}ms');
- }
|