瀏覽代碼

performance optimization

xuty 4 年之前
父節點
當前提交
bb1ade5953
共有 2 個文件被更改,包括 3 次插入13 次删除
  1. 0 4
      lib/buffer/buffer.dart
  2. 3 9
      lib/terminal/terminal.dart

+ 0 - 4
lib/buffer/buffer.dart

@@ -272,17 +272,14 @@ class Buffer {
 
   void cursorGoForward() {
     setCursorX(_cursorX + 1);
-    terminal.refresh();
   }
 
   void setCursorX(int cursorX) {
     _cursorX = cursorX.clamp(0, terminal.viewWidth - 1);
-    terminal.refresh();
   }
 
   void setCursorY(int cursorY) {
     _cursorY = cursorY.clamp(0, terminal.viewHeight - 1);
-    terminal.refresh();
   }
 
   void moveCursorX(int offset) {
@@ -323,7 +320,6 @@ class Buffer {
     if (height < terminal.viewHeight) return;
     final maxOffset = height - terminal.viewHeight;
     _scrollLinesFromBottom = offset.clamp(0, maxOffset);
-    terminal.refresh();
   }
 
   void setScrollOffsetFromTop(int offset) {

+ 3 - 9
lib/terminal/terminal.dart

@@ -160,19 +160,16 @@ class Terminal with Observable {
   int get cursorY => buffer.cursorY;
   int get scrollOffset => buffer.scrollOffsetFromBottom;
 
-  void write(String text) async {
+  void write(String text) {
     _queue.addAll(text.runes);
     _processInput();
-  }
-
-  void writeBytes(Iterable<int> data) async {
-    _queue.addAll(data);
-    _processInput();
+    refresh();
   }
 
   void writeChar(int codePoint) {
     _queue.addLast(codePoint);
     _processInput();
+    refresh();
   }
 
   List<BufferLine> getVisibleLines() {
@@ -190,7 +187,6 @@ class Terminal with Observable {
 
       if (char == esc) {
         ansiHandler(_queue, this);
-        refresh();
         continue;
       }
 
@@ -208,8 +204,6 @@ class Terminal with Observable {
       debug.onChar(codePoint);
       _buffer.writeChar(codePoint);
     }
-
-    refresh();
   }
 
   void refresh() {