xuty 5 gadi atpakaļ
vecāks
revīzija
372bee252f

+ 4 - 0
CHANGELOG.md

@@ -1,3 +1,7 @@
+## [0.1.0] - 2020-8-9
+
+* Bug fixes
+
 ## [0.0.4] - 2020-8-1
 
 * Revert version constrain

+ 40 - 40
example/pubspec.lock

@@ -5,65 +5,65 @@ packages:
     dependency: transitive
     description:
       name: async
-      url: "https://pub.flutter-io.cn"
+      url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
     source: hosted
-    version: "2.4.2"
+    version: "2.5.0-nullsafety"
   boolean_selector:
     dependency: transitive
     description:
       name: boolean_selector
-      url: "https://pub.flutter-io.cn"
+      url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
     source: hosted
-    version: "2.0.0"
+    version: "2.1.0-nullsafety"
   characters:
     dependency: transitive
     description:
       name: characters
-      url: "https://pub.flutter-io.cn"
+      url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
     source: hosted
-    version: "1.0.0"
+    version: "1.1.0-nullsafety.2"
   charcode:
     dependency: transitive
     description:
       name: charcode
-      url: "https://pub.flutter-io.cn"
+      url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
     source: hosted
-    version: "1.1.3"
+    version: "1.2.0-nullsafety"
   clock:
     dependency: transitive
     description:
       name: clock
-      url: "https://pub.flutter-io.cn"
+      url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
     source: hosted
-    version: "1.0.1"
+    version: "1.1.0-nullsafety"
   collection:
     dependency: transitive
     description:
       name: collection
-      url: "https://pub.flutter-io.cn"
+      url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
     source: hosted
-    version: "1.14.13"
+    version: "1.15.0-nullsafety.2"
   convert:
     dependency: transitive
     description:
       name: convert
-      url: "https://pub.flutter-io.cn"
+      url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
     source: hosted
     version: "2.1.1"
   cupertino_icons:
     dependency: "direct main"
     description:
       name: cupertino_icons
-      url: "https://pub.flutter-io.cn"
+      url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
     source: hosted
     version: "0.1.3"
   fake_async:
     dependency: transitive
     description:
       name: fake_async
-      url: "https://pub.flutter-io.cn"
+      url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
     source: hosted
-    version: "1.1.0"
+    version: "1.1.0-nullsafety"
   flutter:
     dependency: "direct main"
     description: flutter
@@ -78,28 +78,28 @@ packages:
     dependency: transitive
     description:
       name: matcher
-      url: "https://pub.flutter-io.cn"
+      url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
     source: hosted
-    version: "0.12.8"
+    version: "0.12.10-nullsafety"
   meta:
     dependency: transitive
     description:
       name: meta
-      url: "https://pub.flutter-io.cn"
+      url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
     source: hosted
-    version: "1.1.8"
+    version: "1.3.0-nullsafety.2"
   path:
     dependency: transitive
     description:
       name: path
-      url: "https://pub.flutter-io.cn"
+      url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
     source: hosted
-    version: "1.7.0"
+    version: "1.8.0-nullsafety"
   quiver:
     dependency: transitive
     description:
       name: quiver
-      url: "https://pub.flutter-io.cn"
+      url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
     source: hosted
     version: "2.1.3"
   sky_engine:
@@ -111,58 +111,58 @@ packages:
     dependency: transitive
     description:
       name: source_span
-      url: "https://pub.flutter-io.cn"
+      url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
     source: hosted
-    version: "1.7.0"
+    version: "1.8.0-nullsafety"
   stack_trace:
     dependency: transitive
     description:
       name: stack_trace
-      url: "https://pub.flutter-io.cn"
+      url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
     source: hosted
-    version: "1.9.5"
+    version: "1.10.0-nullsafety"
   stream_channel:
     dependency: transitive
     description:
       name: stream_channel
-      url: "https://pub.flutter-io.cn"
+      url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
     source: hosted
-    version: "2.0.0"
+    version: "2.1.0-nullsafety"
   string_scanner:
     dependency: transitive
     description:
       name: string_scanner
-      url: "https://pub.flutter-io.cn"
+      url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
     source: hosted
-    version: "1.0.5"
+    version: "1.1.0-nullsafety"
   term_glyph:
     dependency: transitive
     description:
       name: term_glyph
-      url: "https://pub.flutter-io.cn"
+      url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
     source: hosted
-    version: "1.1.0"
+    version: "1.2.0-nullsafety"
   test_api:
     dependency: transitive
     description:
       name: test_api
-      url: "https://pub.flutter-io.cn"
+      url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
     source: hosted
-    version: "0.2.17"
+    version: "0.2.19-nullsafety"
   typed_data:
     dependency: transitive
     description:
       name: typed_data
-      url: "https://pub.flutter-io.cn"
+      url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
     source: hosted
-    version: "1.2.0"
+    version: "1.3.0-nullsafety.2"
   vector_math:
     dependency: transitive
     description:
       name: vector_math
-      url: "https://pub.flutter-io.cn"
+      url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
     source: hosted
-    version: "2.0.8"
+    version: "2.1.0-nullsafety.2"
   xterm:
     dependency: "direct main"
     description:
@@ -171,5 +171,5 @@ packages:
     source: path
     version: "0.0.4"
 sdks:
-  dart: ">=2.9.0-14.0.dev <3.0.0"
+  dart: ">=2.10.0-0.0.dev <2.10.0"
   flutter: ">=1.17.0 <2.0.0"

+ 1 - 1
lib/buffer/buffer.dart

@@ -417,7 +417,7 @@ class Buffer {
       final newLine = BufferLine();
       lines.insert(index, newLine);
 
-      if (lines.length > terminal.maxLines) {
+      if (terminal.maxLines != null && lines.length > terminal.maxLines) {
         lines.removeRange(0, lines.length - terminal.maxLines);
       }
     } else {

+ 23 - 8
lib/frontend/input_listener.dart

@@ -33,10 +33,21 @@ class InputListenerState extends State<InputListener> {
 
   @override
   void initState() {
+    focused = widget.focusNode.hasFocus;
     widget.focusNode.addListener(onFocus);
     super.initState();
   }
 
+  @override
+  void didUpdateWidget(InputListener oldWidget) {
+    oldWidget.focusNode.removeListener(onFocus);
+    widget.focusNode.addListener(onFocus);
+
+    onFocus();
+
+    super.didUpdateWidget(oldWidget);
+  }
+
   @override
   Widget build(BuildContext context) {
     return RawKeyboardListener(
@@ -58,7 +69,9 @@ class InputListenerState extends State<InputListener> {
       widget.onFocus(focused);
     }
 
-    openTextInput();
+    if (focused) {
+      openTextInput();
+    }
   }
 
   void openTextInput() {
@@ -100,14 +113,16 @@ class TerminalTextInputClient extends TextInputClient {
   }
 
   void updateEditingValue(TextEditingValue value) {
-    // print('updateEditingValue $value');
+    print('updateEditingValue $value');
 
-    if (_savedValue == null) {
-      onInput(value.text);
-    } else if (_savedValue.text.length < value.text.length) {
-      final diff = value.text.substring(_savedValue.text.length);
-      onInput(diff);
-    }
+    onInput(value.text);
+
+    // if (_savedValue == null || _savedValue.text == '') {
+    //   onInput(value.text);
+    // } else if (_savedValue.text.length < value.text.length) {
+    //   final diff = value.text.substring(_savedValue.text.length);
+    //   onInput(diff);
+    // }
 
     _savedValue = value;
     // print('updateEditingValue $value');

+ 18 - 12
lib/frontend/terminal_view.dart

@@ -4,6 +4,7 @@ import 'dart:ui';
 import 'package:flutter/gestures.dart';
 import 'package:flutter/material.dart';
 import 'package:flutter/rendering.dart';
+import 'package:flutter/scheduler.dart';
 import 'package:flutter/services.dart';
 import 'package:meta/meta.dart';
 import 'package:xterm/buffer/cell.dart';
@@ -51,11 +52,14 @@ class TerminalView extends StatefulWidget {
     this.fontFamily = _kDefaultFontFamily,
     this.fontWidthScaleFactor = 1.0,
     this.fontHeightScaleFactor = 1.1,
+    FocusNode focusNode,
   })  : assert(terminal != null),
+        focusNode = focusNode ?? FocusNode(),
         super(key: key ?? ValueKey(terminal));
 
   final Terminal terminal;
   final ResizeHandler onResize;
+  final FocusNode focusNode;
 
   final double fontSize;
   final double fontWidthScaleFactor;
@@ -97,8 +101,10 @@ class TerminalView extends StatefulWidget {
 
 class _TerminalViewState extends State<TerminalView> {
   final oscillator = Oscillator.ms(600);
-  final focusNode = FocusNode();
-  var focused = false;
+
+  bool get focused {
+    return widget.focusNode.hasFocus;
+  }
 
   int _lastTerminalWidth;
   int _lastTerminalHeight;
@@ -160,7 +166,7 @@ class _TerminalViewState extends State<TerminalView> {
       behavior: HitTestBehavior.deferToChild,
       dragStartBehavior: DragStartBehavior.down,
       onTapDown: (detail) {
-        focusNode.requestFocus();
+        widget.focusNode.requestFocus();
         final pos = detail.localPosition;
         final offset = getMouseOffset(pos.dx, pos.dy);
         widget.terminal.mouseMode.onTap(widget.terminal, offset);
@@ -184,7 +190,7 @@ class _TerminalViewState extends State<TerminalView> {
       onKeyStroke: onKeyStroke,
       onInput: onInput,
       onFocus: onFocus,
-      focusNode: focusNode,
+      focusNode: widget.focusNode,
       autofocus: true,
       child: MouseRegion(
         cursor: SystemMouseCursors.text,
@@ -224,13 +230,13 @@ class _TerminalViewState extends State<TerminalView> {
         widget.onResize(termWidth, termHeight);
       }
 
-      // SchedulerBinding.instance.addPostFrameCallback((_) {
-      //   widget.terminal.resize(termWidth, termHeight);
-      // });
-
-      Future.delayed(Duration.zero).then((_) {
+      SchedulerBinding.instance.addPostFrameCallback((_) {
         widget.terminal.resize(termWidth, termHeight);
       });
+
+      // Future.delayed(Duration.zero).then((_) {
+      //   widget.terminal.resize(termWidth, termHeight);
+      // });
     }
   }
 
@@ -258,9 +264,9 @@ class _TerminalViewState extends State<TerminalView> {
   }
 
   void onFocus(bool focused) {
-    this.focused = focused;
-    widget.terminal.debug.onMsg('focused $focused');
-    widget.terminal.refresh();
+    SchedulerBinding.instance.addPostFrameCallback((_) {
+      widget.terminal.refresh();
+    });
   }
 
   void onScroll(Offset offset) {

+ 2 - 2
lib/terminal/terminal.dart

@@ -248,6 +248,8 @@ class Terminal with Observable {
   }
 
   void resize(int width, int heigth) {
+    buffer.resetVerticalMargins();
+
     final cursorY = buffer.convertViewLineToRawLine(buffer.cursorY);
 
     _viewWidth = max(width, 1);
@@ -255,8 +257,6 @@ class Terminal with Observable {
 
     buffer.setCursorY(buffer.convertRawLineToViewLine(cursorY));
 
-    buffer.resetVerticalMargins();
-
     if (buffer == _altBuffer) {
       buffer.clearScrollback();
     }

+ 39 - 39
pubspec.lock

@@ -5,58 +5,58 @@ packages:
     dependency: "direct main"
     description:
       name: async
-      url: "https://pub.flutter-io.cn"
+      url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
     source: hosted
-    version: "2.4.2"
+    version: "2.5.0-nullsafety"
   boolean_selector:
     dependency: transitive
     description:
       name: boolean_selector
-      url: "https://pub.flutter-io.cn"
+      url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
     source: hosted
-    version: "2.0.0"
+    version: "2.1.0-nullsafety"
   characters:
     dependency: transitive
     description:
       name: characters
-      url: "https://pub.flutter-io.cn"
+      url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
     source: hosted
-    version: "1.0.0"
+    version: "1.1.0-nullsafety.2"
   charcode:
     dependency: transitive
     description:
       name: charcode
-      url: "https://pub.flutter-io.cn"
+      url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
     source: hosted
-    version: "1.1.3"
+    version: "1.2.0-nullsafety"
   clock:
     dependency: transitive
     description:
       name: clock
-      url: "https://pub.flutter-io.cn"
+      url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
     source: hosted
-    version: "1.0.1"
+    version: "1.1.0-nullsafety"
   collection:
     dependency: transitive
     description:
       name: collection
-      url: "https://pub.flutter-io.cn"
+      url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
     source: hosted
-    version: "1.14.13"
+    version: "1.15.0-nullsafety.2"
   convert:
     dependency: "direct main"
     description:
       name: convert
-      url: "https://pub.flutter-io.cn"
+      url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
     source: hosted
     version: "2.1.1"
   fake_async:
     dependency: transitive
     description:
       name: fake_async
-      url: "https://pub.flutter-io.cn"
+      url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
     source: hosted
-    version: "1.1.0"
+    version: "1.1.0-nullsafety"
   flutter:
     dependency: "direct main"
     description: flutter
@@ -71,28 +71,28 @@ packages:
     dependency: transitive
     description:
       name: matcher
-      url: "https://pub.flutter-io.cn"
+      url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
     source: hosted
-    version: "0.12.8"
+    version: "0.12.10-nullsafety"
   meta:
     dependency: "direct main"
     description:
       name: meta
-      url: "https://pub.flutter-io.cn"
+      url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
     source: hosted
-    version: "1.1.8"
+    version: "1.3.0-nullsafety.2"
   path:
     dependency: transitive
     description:
       name: path
-      url: "https://pub.flutter-io.cn"
+      url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
     source: hosted
-    version: "1.7.0"
+    version: "1.8.0-nullsafety"
   quiver:
     dependency: "direct main"
     description:
       name: quiver
-      url: "https://pub.flutter-io.cn"
+      url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
     source: hosted
     version: "2.1.3"
   sky_engine:
@@ -104,58 +104,58 @@ packages:
     dependency: transitive
     description:
       name: source_span
-      url: "https://pub.flutter-io.cn"
+      url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
     source: hosted
-    version: "1.7.0"
+    version: "1.8.0-nullsafety"
   stack_trace:
     dependency: transitive
     description:
       name: stack_trace
-      url: "https://pub.flutter-io.cn"
+      url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
     source: hosted
-    version: "1.9.5"
+    version: "1.10.0-nullsafety"
   stream_channel:
     dependency: transitive
     description:
       name: stream_channel
-      url: "https://pub.flutter-io.cn"
+      url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
     source: hosted
-    version: "2.0.0"
+    version: "2.1.0-nullsafety"
   string_scanner:
     dependency: transitive
     description:
       name: string_scanner
-      url: "https://pub.flutter-io.cn"
+      url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
     source: hosted
-    version: "1.0.5"
+    version: "1.1.0-nullsafety"
   term_glyph:
     dependency: transitive
     description:
       name: term_glyph
-      url: "https://pub.flutter-io.cn"
+      url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
     source: hosted
-    version: "1.1.0"
+    version: "1.2.0-nullsafety"
   test_api:
     dependency: transitive
     description:
       name: test_api
-      url: "https://pub.flutter-io.cn"
+      url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
     source: hosted
-    version: "0.2.17"
+    version: "0.2.19-nullsafety"
   typed_data:
     dependency: transitive
     description:
       name: typed_data
-      url: "https://pub.flutter-io.cn"
+      url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
     source: hosted
-    version: "1.2.0"
+    version: "1.3.0-nullsafety.2"
   vector_math:
     dependency: transitive
     description:
       name: vector_math
-      url: "https://pub.flutter-io.cn"
+      url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
     source: hosted
-    version: "2.0.8"
+    version: "2.1.0-nullsafety.2"
 sdks:
-  dart: ">=2.9.0-14.0.dev <3.0.0"
+  dart: ">=2.10.0-0.0.dev <2.10.0"
   flutter: ">=1.17.0 <2.0.0"

+ 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: 0.0.4
+version: 0.1.0
 homepage: https://github.com/TerminalStudio/xterm.dart
 
 environment: