Răsfoiți Sursa

Merge remote-tracking branch 'origin/master' into feature/reflow

devmil 4 ani în urmă
părinte
comite
2683be44ee

+ 4 - 0
CHANGELOG.md

@@ -1,3 +1,7 @@
+## [2.1.0-pre] - 2021-3-20
+* Better support for resizing and scrolling.
+* Reflow support (in progress [#13](https://github.com/TerminalStudio/xterm.dart/pull/13)), thanks [@devmil](https://github.com/devmil).
+
 ## [2.0.0] - 2021-3-7
 * Clean up for release
 

+ 1 - 13
example/macos/Runner.xcodeproj/project.pbxproj

@@ -26,10 +26,6 @@
 		33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F22044A3C60003C045 /* Assets.xcassets */; };
 		33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F42044A3C60003C045 /* MainMenu.xib */; };
 		33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */; };
-		33D1A10422148B71006C7A3E /* FlutterMacOS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 33D1A10322148B71006C7A3E /* FlutterMacOS.framework */; };
-		33D1A10522148B93006C7A3E /* FlutterMacOS.framework in Bundle Framework */ = {isa = PBXBuildFile; fileRef = 33D1A10322148B71006C7A3E /* FlutterMacOS.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
-		D73912F022F37F9E000D13A0 /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D73912EF22F37F9E000D13A0 /* App.framework */; };
-		D73912F222F3801D000D13A0 /* App.framework in Bundle Framework */ = {isa = PBXBuildFile; fileRef = D73912EF22F37F9E000D13A0 /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
 /* End PBXBuildFile section */
 
 /* Begin PBXContainerItemProxy section */
@@ -49,8 +45,6 @@
 			dstPath = "";
 			dstSubfolderSpec = 10;
 			files = (
-				D73912F222F3801D000D13A0 /* App.framework in Bundle Framework */,
-				33D1A10522148B93006C7A3E /* FlutterMacOS.framework in Bundle Framework */,
 			);
 			name = "Bundle Framework";
 			runOnlyForDeploymentPostprocessing = 0;
@@ -69,13 +63,11 @@
 		33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Debug.xcconfig"; sourceTree = "<group>"; };
 		33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Release.xcconfig"; sourceTree = "<group>"; };
 		33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = "Flutter-Generated.xcconfig"; path = "ephemeral/Flutter-Generated.xcconfig"; sourceTree = "<group>"; };
-		33D1A10322148B71006C7A3E /* FlutterMacOS.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = FlutterMacOS.framework; path = Flutter/ephemeral/FlutterMacOS.framework; sourceTree = SOURCE_ROOT; };
 		33E51913231747F40026EE4D /* DebugProfile.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = DebugProfile.entitlements; sourceTree = "<group>"; };
 		33E51914231749380026EE4D /* Release.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = Release.entitlements; sourceTree = "<group>"; };
 		33E5194F232828860026EE4D /* AppInfo.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = AppInfo.xcconfig; sourceTree = "<group>"; };
 		7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Release.xcconfig; sourceTree = "<group>"; };
 		9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Debug.xcconfig; sourceTree = "<group>"; };
-		D73912EF22F37F9E000D13A0 /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/ephemeral/App.framework; sourceTree = SOURCE_ROOT; };
 /* End PBXFileReference section */
 
 /* Begin PBXFrameworksBuildPhase section */
@@ -83,8 +75,6 @@
 			isa = PBXFrameworksBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
-				D73912F022F37F9E000D13A0 /* App.framework in Frameworks */,
-				33D1A10422148B71006C7A3E /* FlutterMacOS.framework in Frameworks */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -138,8 +128,6 @@
 				33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */,
 				33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */,
 				33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */,
-				D73912EF22F37F9E000D13A0 /* App.framework */,
-				33D1A10322148B71006C7A3E /* FlutterMacOS.framework */,
 			);
 			path = Flutter;
 			sourceTree = "<group>";
@@ -260,7 +248,7 @@
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 			shellPath = /bin/sh;
-			shellScript = "echo \"$PRODUCT_NAME.app\" > \"$PROJECT_DIR\"/Flutter/ephemeral/.app_filename\n";
+			shellScript = "echo \"$PRODUCT_NAME.app\" > \"$PROJECT_DIR\"/Flutter/ephemeral/.app_filename && \"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh embed\n";
 		};
 		33CC111E2044C6BF0003C045 /* ShellScript */ = {
 			isa = PBXShellScriptBuildPhase;

+ 35 - 31
example/pubspec.lock

@@ -14,49 +14,49 @@ packages:
       name: async
       url: "https://pub.dartlang.org"
     source: hosted
-    version: "2.5.0-nullsafety"
+    version: "2.5.0"
   boolean_selector:
     dependency: transitive
     description:
       name: boolean_selector
       url: "https://pub.dartlang.org"
     source: hosted
-    version: "2.1.0-nullsafety"
+    version: "2.1.0"
   characters:
     dependency: transitive
     description:
       name: characters
       url: "https://pub.dartlang.org"
     source: hosted
-    version: "1.1.0-nullsafety.2"
+    version: "1.1.0"
   charcode:
     dependency: transitive
     description:
       name: charcode
       url: "https://pub.dartlang.org"
     source: hosted
-    version: "1.2.0-nullsafety"
+    version: "1.2.0"
   clock:
     dependency: transitive
     description:
       name: clock
       url: "https://pub.dartlang.org"
     source: hosted
-    version: "1.1.0-nullsafety"
+    version: "1.1.0"
   collection:
     dependency: transitive
     description:
       name: collection
       url: "https://pub.dartlang.org"
     source: hosted
-    version: "1.15.0-nullsafety.2"
+    version: "1.15.0"
   convert:
     dependency: transitive
     description:
       name: convert
       url: "https://pub.dartlang.org"
     source: hosted
-    version: "2.1.1"
+    version: "3.0.0"
   cupertino_icons:
     dependency: "direct main"
     description:
@@ -67,17 +67,19 @@ packages:
   dartssh:
     dependency: "direct main"
     description:
-      name: dartssh
-      url: "https://pub.dartlang.org"
-    source: hosted
-    version: "1.0.3+3"
+      path: "."
+      ref: HEAD
+      resolved-ref: "1c2244db550a56e2d53754864b8ce3da525a4b7d"
+      url: "https://github.com/TerminalStudio/dartssh"
+    source: git
+    version: "1.0.4+4"
   fake_async:
     dependency: transitive
     description:
       name: fake_async
       url: "https://pub.dartlang.org"
     source: hosted
-    version: "1.1.0-nullsafety"
+    version: "1.2.0"
   fixnum:
     dependency: transitive
     description:
@@ -115,21 +117,21 @@ packages:
       name: matcher
       url: "https://pub.dartlang.org"
     source: hosted
-    version: "0.12.10-nullsafety"
+    version: "0.12.10"
   meta:
     dependency: transitive
     description:
       name: meta
       url: "https://pub.dartlang.org"
     source: hosted
-    version: "1.3.0-nullsafety.2"
+    version: "1.3.0"
   path:
     dependency: transitive
     description:
       name: path
       url: "https://pub.dartlang.org"
     source: hosted
-    version: "1.8.0-nullsafety"
+    version: "1.8.0"
   pedantic:
     dependency: transitive
     description:
@@ -143,7 +145,7 @@ packages:
       name: platform_info
       url: "https://pub.dartlang.org"
     source: hosted
-    version: "2.0.1"
+    version: "3.0.0-nullsafety.1"
   pointycastle:
     dependency: transitive
     description:
@@ -157,7 +159,7 @@ packages:
       name: quiver
       url: "https://pub.dartlang.org"
     source: hosted
-    version: "2.1.3"
+    version: "3.0.0"
   sky_engine:
     dependency: transitive
     description: flutter
@@ -169,48 +171,50 @@ packages:
       name: source_span
       url: "https://pub.dartlang.org"
     source: hosted
-    version: "1.8.0-nullsafety.2"
+    version: "1.8.0"
   stack_trace:
     dependency: transitive
     description:
       name: stack_trace
       url: "https://pub.dartlang.org"
     source: hosted
-    version: "1.10.0-nullsafety"
+    version: "1.10.0"
   stream_channel:
     dependency: transitive
     description:
       name: stream_channel
       url: "https://pub.dartlang.org"
     source: hosted
-    version: "2.1.0-nullsafety"
+    version: "2.1.0"
   string_scanner:
     dependency: transitive
     description:
       name: string_scanner
       url: "https://pub.dartlang.org"
     source: hosted
-    version: "1.1.0-nullsafety"
+    version: "1.1.0"
   term_glyph:
     dependency: transitive
     description:
       name: term_glyph
       url: "https://pub.dartlang.org"
     source: hosted
-    version: "1.2.0-nullsafety"
+    version: "1.2.0"
   test_api:
     dependency: transitive
     description:
       name: test_api
       url: "https://pub.dartlang.org"
     source: hosted
-    version: "0.2.19-nullsafety"
+    version: "0.2.19"
   tweetnacl:
     dependency: transitive
     description:
-      name: tweetnacl
-      url: "https://pub.dartlang.org"
-    source: hosted
+      path: "."
+      ref: HEAD
+      resolved-ref: "028b09a31805c648df1db695f7a58f9fcd4099d9"
+      url: "https://github.com/TerminalStudio/tweetnacl-dart"
+    source: git
     version: "0.3.2"
   typed_data:
     dependency: transitive
@@ -218,7 +222,7 @@ packages:
       name: typed_data
       url: "https://pub.dartlang.org"
     source: hosted
-    version: "1.3.0-nullsafety.2"
+    version: "1.3.0"
   validators:
     dependency: transitive
     description:
@@ -232,14 +236,14 @@ packages:
       name: vector_math
       url: "https://pub.dartlang.org"
     source: hosted
-    version: "2.1.0-nullsafety.2"
+    version: "2.1.0"
   xterm:
     dependency: "direct main"
     description:
       path: ".."
       relative: true
     source: path
-    version: "1.1.0"
+    version: "2.0.0"
 sdks:
-  dart: ">=2.10.0-0.0.dev <2.10.0"
-  flutter: ">=1.17.0 <2.0.0"
+  dart: ">=2.12.0 <3.0.0"
+  flutter: ">=2.0.0"

+ 4 - 2
example/pubspec.yaml

@@ -24,8 +24,10 @@ dependencies:
   xterm:
     path: ../
 
-  dartssh: ^1.0.3+3
-    
+  dartssh:
+    git:
+      url: https://github.com/TerminalStudio/dartssh
+
   flutter:
     sdk: flutter
 

+ 13 - 41
lib/frontend/cache.dart

@@ -3,53 +3,25 @@ import 'package:quiver/collection.dart';
 
 class TextLayoutCache {
   TextLayoutCache(this.textDirection, int maximumSize)
-      : _cache = LruMap<TextSpan, TextPainter>(maximumSize: maximumSize);
-
-  final LruMap<TextSpan, TextPainter> _cache;
-  final TextDirection textDirection;
-
-  TextPainter getOrPerformLayout(TextSpan text) {
-    final cachedPainter = _cache[text];
-    if (cachedPainter != null) {
-      return cachedPainter;
-    } else {
-      return _performAndCacheLayout(text);
-    }
-  }
-
-  TextPainter _performAndCacheLayout(TextSpan text) {
-    final textPainter = TextPainter(text: text, textDirection: textDirection);
-    textPainter.layout();
-
-    _cache[text] = textPainter;
-
-    return textPainter;
-  }
-
-  int get length {
-    return _cache.length;
-  }
-}
-
-final textLayoutCache = TextLayoutCache(TextDirection.ltr, 1024);
-
-class TextLayoutCacheV2 {
-  TextLayoutCacheV2(this.textDirection, int maximumSize)
       : _cache = LruMap<int, TextPainter>(maximumSize: maximumSize);
 
   final LruMap<int, TextPainter> _cache;
   final TextDirection textDirection;
 
-  TextPainter getOrPerformLayout(TextSpan text, int key) {
-    final cachedPainter = _cache[key];
-    if (cachedPainter != null) {
-      return cachedPainter;
-    } else {
-      return _performAndCacheLayout(text, key);
-    }
+  TextPainter? getLayoutFromCache(int key) {
+    return _cache[key];
   }
 
-  TextPainter _performAndCacheLayout(TextSpan text, int key) {
+  // TextPainter getOrPerformLayout(TextSpan text, int key) {
+  //   final cachedPainter = _cache[key];
+  //   if (cachedPainter != null) {
+  //     return cachedPainter;
+  //   } else {
+  //     return performAndCacheLayout(text, key);
+  //   }
+  // }
+
+  TextPainter performAndCacheLayout(TextSpan text, int key) {
     final textPainter = TextPainter(text: text, textDirection: textDirection);
     textPainter.layout();
 
@@ -63,7 +35,7 @@ class TextLayoutCacheV2 {
   }
 }
 
-final textLayoutCacheV2 = TextLayoutCacheV2(TextDirection.ltr, 1024);
+final textLayoutCache = TextLayoutCache(TextDirection.ltr, 10240);
 
 // class CodePointCache {
 //   CodePointCache(int maximumSize)

+ 10 - 3
lib/frontend/terminal_view.dart

@@ -427,6 +427,13 @@ class TerminalPainter extends CustomPainter {
       return;
     }
 
+    final cellHash = hashValues(cell.codePoint, attr);
+    var tp = textLayoutCache.getLayoutFromCache(cellHash);
+    if (tp != null) {
+      tp.paint(canvas, Offset(offsetX, offsetY));
+      return;
+    }
+
     final cellColor = attr.inverse
         ? attr.bgColor ?? terminal.theme.background
         : attr.fgColor ?? terminal.theme.foreground;
@@ -454,7 +461,8 @@ class TerminalPainter extends CustomPainter {
             decoration:
                 attr.underline ? TextDecoration.underline : TextDecoration.none,
             fontFamily: 'monospace',
-            fontFamilyFallback: view.style.fontFamily);
+            fontFamilyFallback: view.style.fontFamily,
+          );
 
     final span = TextSpan(
       text: String.fromCharCode(cell.codePoint!),
@@ -463,8 +471,7 @@ class TerminalPainter extends CustomPainter {
     );
 
     // final tp = textLayoutCache.getOrPerformLayout(span);
-    final tp = textLayoutCacheV2.getOrPerformLayout(
-        span, hashValues(cell.codePoint, attr));
+    tp = textLayoutCache.performAndCacheLayout(span, cellHash);
 
     tp.paint(canvas, Offset(offsetX, offsetY));
   }

+ 1 - 1
lib/terminal/ansi.dart

@@ -60,7 +60,7 @@ void _ansiRestoreCursorHandler(Queue<int> queue, Terminal terminal) {
 
 /// https://vt100.net/docs/vt100-ug/chapter3.html#IND IND – Index
 ///
-/// ESC D  
+/// ESC D
 ///
 /// This sequence causes the active position to move downward one line without
 /// changing the column position. If the active position is at the bottom

+ 1 - 1
pubspec.yaml

@@ -1,6 +1,6 @@
 name: xterm
 description: xterm.dart is a fast and fully-featured terminal emulator for Flutter applications, with support for mobile and desktop platforms.
-version: 2.0.0
+version: 2.1.0-pre
 homepage: https://github.com/TerminalStudio/xterm.dart
 
 environment: