xuty преди 4 години
родител
ревизия
1037f5370c
променени са 2 файла, в които са добавени 20 реда и са изтрити 22 реда
  1. 3 3
      lib/buffer/buffer.dart
  2. 17 19
      lib/utli/circular_list.dart

+ 3 - 3
lib/buffer/buffer.dart

@@ -480,9 +480,9 @@ class Buffer {
 
   void resize(int newWidth, int newHeight) {
     if (newWidth > terminal.viewWidth) {
-      lines.forEach((item, index) {
-        item?.ensure(newWidth);
-      }, true);
+      for (var line in lines) {
+        line.ensure(newWidth);
+      }
     }
 
     if (newHeight > terminal.viewHeight) {

+ 17 - 19
lib/utli/circular_list.dart

@@ -1,12 +1,14 @@
-class CircularList<T> {
-  List<T?> _array;
-  int _length = 0;
-  int _startIndex = 0;
-
-  Function(int num)? onTrimmed;
+import 'dart:collection';
 
+class CircularList<T> with ListMixin<T> {
   CircularList(int maxLength) : _array = List<T?>.filled(maxLength, null);
 
+  late List<T?> _array;
+  var _length = 0;
+  var _startIndex = 0;
+
+  Function(int num)? onTrimmed;
+
   // Gets the cyclic index for the specified regular index. The cyclic index can then be used on the
   // backing array to get the element associated with the regular index.
   int _getCyclicIndex(int index) {
@@ -48,15 +50,15 @@ class CircularList<T> {
     _length = value;
   }
 
-  void forEach(
-    void Function(T? item, int index) callback, [
-    bool includeBuffer = false,
-  ]) {
-    final len = includeBuffer ? _array.length : _length;
-    for (int i = 0; i < len; i++) {
-      callback(_array[_getCyclicIndex(i)], i);
-    }
-  }
+  // void forEach(
+  //   void Function(T? item, int index) callback, [
+  //   bool includeBuffer = false,
+  // ]) {
+  //   final len = includeBuffer ? _array.length : _length;
+  //   for (int i = 0; i < len; i++) {
+  //     callback(_array[_getCyclicIndex(i)], i);
+  //   }
+  // }
 
   T operator [](int index) {
     if (index > length - 1) {
@@ -160,8 +162,4 @@ class CircularList<T> {
   }
 
   bool get isFull => length == maxLength;
-
-  List<T> toList() {
-    return List<T>.generate(length, (index) => this[index]!);
-  }
 }