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

v3 #87

Draft
wants to merge 52 commits into
base: master
Choose a base branch
from
Draft

v3 #87

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
6cf69db
initial commit for v3
xtyxtyx Feb 6, 2022
0fc4169
Support parse OSC
xtyxtyx Feb 6, 2022
a76ce54
make consumeOsc private
xtyxtyx Feb 6, 2022
4d76933
rewrite Terminal
xtyxtyx Feb 8, 2022
5cdca6d
clean up
xtyxtyx Feb 8, 2022
3834ad9
prepare for TerminalView
xtyxtyx Feb 9, 2022
1ca0a3e
foreground painting
xtyxtyx Feb 10, 2022
db9fc88
paint cursor
xtyxtyx Feb 10, 2022
9847386
TerminalView for v3
xtyxtyx Mar 26, 2022
df928d3
Regenerate example
xtyxtyx Mar 26, 2022
f88330d
implement stick-to-bottom scrolling
xtyxtyx Mar 26, 2022
44caa02
comment xterm_dump for a while
xtyxtyx Mar 26, 2022
1516bb4
Update SSH example
xtyxtyx Mar 26, 2022
35a9364
Bump version
xtyxtyx Mar 26, 2022
05cf7e6
Add KeyboardVisibilty
xtyxtyx Mar 27, 2022
fdd7cf0
Fix lint error
xtyxtyx Mar 27, 2022
f2adaae
Fix lint errors
xtyxtyx Mar 27, 2022
de53db2
Bump version
xtyxtyx Mar 27, 2022
9bdb69c
Remove KeyboardVisibilty
xtyxtyx Mar 28, 2022
4e2b131
Re-design KeyboardVisibilty
xtyxtyx Mar 28, 2022
b1a6291
Remove debug print
xtyxtyx Mar 28, 2022
5ccb4dc
Fix empty title
xtyxtyx Mar 28, 2022
01a4968
Bump version
xtyxtyx Mar 28, 2022
8e56689
Fix focus listening
xtyxtyx Mar 28, 2022
57cf8fb
Fix resize; Add alwaysShowCursor
xtyxtyx Mar 28, 2022
2e662f0
Remove debug print
xtyxtyx Mar 28, 2022
b6e09f8
Rework scrolling
xtyxtyx Mar 28, 2022
e4766db
Bump version
xtyxtyx Mar 28, 2022
74bd3e1
Remove debug print
xtyxtyx Mar 31, 2022
2683205
Improved text input handling
xtyxtyx Mar 31, 2022
42b0070
Aware of MediaQuery
xtyxtyx Mar 31, 2022
f011ba7
Pop one more line in buffer shrink
xtyxtyx Mar 31, 2022
f988742
Better input handling and composing painting
xtyxtyx Apr 1, 2022
b433c90
Add deleteDetection option
xtyxtyx Apr 1, 2022
964e6f1
Update ssh example
xtyxtyx Apr 1, 2022
39268f5
Bump version
xtyxtyx Apr 1, 2022
da13d37
Export KeyboardVisibilty
xtyxtyx Apr 4, 2022
31dec4d
Expose requestKeyboard and closeKeyboard
xtyxtyx Apr 4, 2022
2d6c3d4
Add hasInputConnection
xtyxtyx Apr 4, 2022
5e1d367
Add charInput and textInput
xtyxtyx Apr 4, 2022
26a40c6
Fix special case when RenderBox.size is zero
xtyxtyx Apr 4, 2022
d4fd2db
Bump version
xtyxtyx Apr 4, 2022
f636473
Export TerminalViewState, add onTap
xtyxtyx Apr 4, 2022
83911d3
Bump version
xtyxtyx Apr 4, 2022
a344fd9
Update ssh example
xtyxtyx Apr 5, 2022
2c6648b
Add onResize to constructor
xtyxtyx Apr 5, 2022
38051fb
fix: clamp mouse position into the terminal dimension
tauu Aug 21, 2022
5fd07ac
fix: backport resize logic
tauu Aug 25, 2022
50e26ec
Merge pull request #118 from tauu/backport-resize-logic
xtyxtyx Sep 3, 2022
2fc2c6a
Merge pull request #116 from tauu/clamp-mouse-position
xtyxtyx Sep 3, 2022
b52764b
v3.1.0-pre
xtyxtyx Sep 4, 2022
4b38372
Remove unused files
xtyxtyx Sep 4, 2022
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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,7 @@ build/
!**/ios/**/default.pbxuser
!**/ios/**/default.perspectivev3
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages

example/lib/ssh2.dart

.vscode
32 changes: 32 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "xterm.dart",
"request": "launch",
"type": "dart"
},
{
"name": "xterm.dart (profile mode)",
"request": "launch",
"type": "dart",
"flutterMode": "profile"
},
{
"name": "example",
"cwd": "example",
"request": "launch",
"type": "dart"
},
{
"name": "example (profile mode)",
"cwd": "example",
"request": "launch",
"type": "dart",
"flutterMode": "profile"
}
]
}
29 changes: 29 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,32 @@
## [3.0.6-alpha] - 2022-4-4
* Export `TerminalViewState`
* Added `onTap` callback to `TerminalView`

## [3.0.5-alpha] - 2022-4-4
* Avoid resize when `RenderBox.size` is zero.
* Added `charInput` and `textInput`method.
* Added `requestKeyboard`, `closeKeyboard` and `hasInputConnection`method.
* Export `KeyboardVisibilty`

## [3.0.4-alpha] - 2022-4-1
* Improved text editing
* Added composing state painting
* Adapt to `MediaQuery.padding`

## [3.0.3-alpha] - 2022-3-28
* Improved scroll handing
* Improved resize handing
* Fix focus repaint
* Fix OSC title update

## [3.0.2-alpha] - 2022-3-28
* Re-design `KeyboardVisibilty`

## [3.0.1-alpha] - 2022-3-27
* Add `KeyboardVisibilty`

## [3.0.0-alpha] - 2022-3-26
* Initial release of v3.

## [2.6.0] - 2021-12-28
* Add scrollBehavior field to the TerminalView class [#55].
Expand Down
29 changes: 29 additions & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
include: package:lints/recommended.yaml

linter:
rules:
prefer_function_declarations_over_variables: false
prefer_conditional_assignment: false

analyzer:
plugins:
- dart_code_metrics

dart_code_metrics:
anti-patterns:
# - long-method
# - long-parameter-list
metrics:
cyclomatic-complexity: 20
maximum-nesting-level: 5
number-of-parameters: 4
source-lines-of-code: 50
metrics-exclude:
- test/**
rules:
# - no-boolean-literal-compare
# - no-empty-block
- prefer-trailing-comma
- no-equal-then-else
rules-exclude:
- prefer-conditional-expressions
57 changes: 57 additions & 0 deletions bin/xterm_bench.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
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');
}
116 changes: 116 additions & 0 deletions bin/xterm_dump.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
// import 'dart:convert';
// import 'dart:io';
// import 'dart:typed_data';

// import 'package:xterm/core/escape/handler.dart';
// import 'package:xterm/core/escape/parser.dart';

// final handler = DebugTerminalHandler();
// final protocol = EscapeParser(handler);
// final input = BytesBuilder(copy: true);

// void main(List<String> args) async {
// final inputStream = args.isNotEmpty ? File(args.first).openRead() : stdin;

// await for (var chunk in inputStream.transform(Utf8Decoder())) {
// input.add(chunk);
// protocol.write(chunk);
// }

// handler.flush();
// }

// extension StringEscape on String {
// String escapeInvisible() {
// return this.replaceAllMapped(RegExp('[\x00-\x1F]'), (match) {
// return '\\x${match.group(0)!.codeUnitAt(0).toRadixString(16).padLeft(2, '0')}';
// });
// }
// }

// class DebugTerminalHandler implements EscapeHandler {
// final stringBuffer = StringBuffer();

// void flush() {
// if (stringBuffer.isEmpty) return;
// print(Color.green('TXT') + "'$stringBuffer'");
// stringBuffer.clear();
// }

// void recordCommand(String description) {
// flush();
// final raw = input.toBytes().sublist(protocol.tokenBegin, protocol.tokenEnd);
// final token = utf8.decode(raw).replaceAll('\x1b', 'ESC').escapeInvisible();
// print(Color.magenta('CMD ') + token.padRight(40) + '$description');
// }

// @override
// void writeChar(int char) {
// stringBuffer.writeCharCode(char);
// }

// @override
// void setCursor(int x, int y) {
// recordCommand('setCursor $x, $y');
// }

// @override
// void designateCharset(int charset) {
// recordCommand('designateCharset $charset');
// }

// @override
// void unkownEscape(int char) {
// recordCommand('unkownEscape ${String.fromCharCode(char)}');
// }

// @override
// void backspaceReturn() {
// recordCommand('backspaceReturn');
// }

// @override
// void carriageReturn() {
// recordCommand('carriageReturn');
// }

// @override
// void setCursorX(int x) {
// recordCommand('setCursorX $x');
// }

// @override
// void setCursorY(int y) {
// recordCommand('setCursorY $y');
// }

// @override
// void unkownCSI(int finalByte) {
// recordCommand('unkownCSI ${String.fromCharCode(finalByte)}');
// }

// @override
// void unkownSBC(int char) {
// recordCommand('unkownSBC ${String.fromCharCode(char)}');
// }

// @override
// noSuchMethod(Invocation invocation) {
// final name = invocation.memberName;
// final args = invocation.positionalArguments;
// recordCommand('noSuchMethod: $name $args');
// }
// }

// abstract class Color {
// static String red(String s) => '\u001b[31m$s\u001b[0m';
// static String green(String s) => '\u001b[32m$s\u001b[0m';
// static String yellow(String s) => '\u001b[33m$s\u001b[0m';
// static String blue(String s) => '\u001b[34m$s\u001b[0m';
// static String magenta(String s) => '\u001b[35m$s\u001b[0m';
// static String cyan(String s) => '\u001b[36m$s\u001b[0m';
// }

// abstract class Labels {
// static final txt = Color.green('TXT');
// }
41 changes: 38 additions & 3 deletions example/.metadata
Original file line number Diff line number Diff line change
@@ -1,10 +1,45 @@
# This file tracks properties of this Flutter project.
# Used by Flutter tool to assess capabilities and perform upgrades etc.
#
# This file should be version controlled and should not be manually edited.
# This file should be version controlled.

version:
revision: a5fa083906fcaf88b039a717c6e78b9814f3a77c
channel: master
revision: f1875d570e39de09040c8f79aa13cc56baab8db1
channel: stable

project_type: app

# Tracks metadata for the flutter migrate command
migration:
platforms:
- platform: root
create_revision: f1875d570e39de09040c8f79aa13cc56baab8db1
base_revision: f1875d570e39de09040c8f79aa13cc56baab8db1
- platform: android
create_revision: f1875d570e39de09040c8f79aa13cc56baab8db1
base_revision: f1875d570e39de09040c8f79aa13cc56baab8db1
- platform: ios
create_revision: f1875d570e39de09040c8f79aa13cc56baab8db1
base_revision: f1875d570e39de09040c8f79aa13cc56baab8db1
- platform: linux
create_revision: f1875d570e39de09040c8f79aa13cc56baab8db1
base_revision: f1875d570e39de09040c8f79aa13cc56baab8db1
- platform: macos
create_revision: f1875d570e39de09040c8f79aa13cc56baab8db1
base_revision: f1875d570e39de09040c8f79aa13cc56baab8db1
- platform: web
create_revision: f1875d570e39de09040c8f79aa13cc56baab8db1
base_revision: f1875d570e39de09040c8f79aa13cc56baab8db1
- platform: windows
create_revision: f1875d570e39de09040c8f79aa13cc56baab8db1
base_revision: f1875d570e39de09040c8f79aa13cc56baab8db1

# User provided section

# List of Local paths (relative to this file) that should be
# ignored by the migrate tool.
#
# Files that are not part of the templates will be ignored by default.
unmanaged_files:
- 'lib/main.dart'
- 'ios/Runner.xcodeproj/project.pbxproj'
48 changes: 23 additions & 25 deletions example/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,29 +1,27 @@
# This file configures the analyzer, which statically analyzes Dart code to
# check for errors, warnings, and lints.
#
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
# invoked from the command line by running `flutter analyze`.

# The following line activates a set of recommended lints for Flutter apps,
# packages, and plugins designed to encourage good coding practices.
include: package:flutter_lints/flutter.yaml
include: package:lints/recommended.yaml

linter:
# The lint rules applied to this project can be customized in the
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
# included above or to enable additional rules. A list of all available lints
# and their documentation is published at
# https://dart-lang.github.io/linter/lints/index.html.
#
# Instead of disabling a lint rule for the entire project in the
# section below, it can also be suppressed for a single line of code
# or a specific dart file by using the `// ignore: name_of_lint` and
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
# producing the lint.
rules:
# avoid_print: false # Uncomment to disable the `avoid_print` rule
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
prefer_function_declarations_over_variables: false

analyzer:
plugins:
- dart_code_metrics

# Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options
dart_code_metrics:
anti-patterns:
# - long-method
# - long-parameter-list
metrics:
cyclomatic-complexity: 20
maximum-nesting-level: 5
number-of-parameters: 4
source-lines-of-code: 50
metrics-exclude:
- test/**
rules:
# - no-boolean-literal-compare
# - no-empty-block
- prefer-trailing-comma
- prefer-conditional-expressions
- no-equal-then-else
2 changes: 2 additions & 0 deletions example/android/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ GeneratedPluginRegistrant.java
# Remember to never publicly share your keystore.
# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app
key.properties
**/*.keystore
**/*.jks
Loading