xuty 4 anni fa
parent
commit
d6d8cdea1d

+ 0 - 1
lib/frontend/input_listener.dart

@@ -2,7 +2,6 @@ import 'package:flutter/foundation.dart';
 import 'package:flutter/material.dart';
 import 'package:flutter/scheduler.dart';
 import 'package:flutter/services.dart';
-import 'package:meta/meta.dart';
 
 typedef KeyStrokeHandler = void Function(RawKeyEvent);
 typedef InputHandler = TextEditingValue? Function(TextEditingValue);

+ 1 - 1
lib/frontend/mouse_listener.dart

@@ -21,7 +21,7 @@ class MouseListener extends StatelessWidget {
   }
 
   void onPointerSignal(PointerSignalEvent event) {
-    if (event is PointerScrollEvent && onScroll != null) {
+    if (event is PointerScrollEvent) {
       onScroll(event.scrollDelta);
     }
   }

+ 0 - 1
lib/frontend/terminal_view.dart

@@ -6,7 +6,6 @@ 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';
 import 'package:xterm/frontend/char_size.dart';
 import 'package:xterm/frontend/helpers.dart';

+ 0 - 1
lib/input/keytab/keytab_record.dart

@@ -1,4 +1,3 @@
-import 'package:meta/meta.dart';
 import 'package:xterm/input/keys.dart';
 
 enum KeytabActionType {

+ 1 - 4
lib/mouse/mouse_mode.dart

@@ -49,9 +49,6 @@ class MouseModeX10 extends MouseMode {
     buffer.writeCharCode(btn + 32);
     buffer.writeCharCode(px + 32);
     buffer.writeCharCode(py + 32);
-
-    if (terminal.onInput != null) {
-      terminal.onInput(buffer.toString());
-    }
+    terminal.onInput(buffer.toString());
   }
 }

+ 0 - 16
lib/mouse/position.dart

@@ -5,34 +5,18 @@ class Position {
   final int y;
 
   bool isBefore(Position another) {
-    if (another == null) {
-      return false;
-    }
-
     return another.y > y || (another.y == y && another.x > x);
   }
 
   bool isAfter(Position another) {
-    if (another == null) {
-      return false;
-    }
-
     return another.y < y || (another.y == y && another.x < x);
   }
 
   bool isBeforeOrSame(Position another) {
-    if (another == null) {
-      return false;
-    }
-
     return another.y > y || (another.y == y && another.x >= x);
   }
 
   bool isAfterOrSame(Position another) {
-    if (another == null) {
-      return false;
-    }
-
     return another.y < y || (another.y == y && another.x <= x);
   }
 

+ 2 - 2
lib/terminal/charset.dart

@@ -41,8 +41,8 @@ class Charset {
   }
 
   void restore() {
-    _charsetMap = _savedCharsetMap ?? _charsetMap;
-    _currentIndex = _savedIndex ?? _currentIndex;
+    _charsetMap = _savedCharsetMap;
+    _currentIndex = _savedIndex;
     _updateCache();
   }
 }

+ 2 - 6
lib/terminal/osc.dart

@@ -52,14 +52,10 @@ void oscHandler(Queue<int> queue, Terminal terminal) {
   switch (ps) {
     case '0':
     case '2':
-      if (terminal.onTitleChange != null) {
-        terminal.onTitleChange(pt);
-      }
+      terminal.onTitleChange(pt);
       break;
     case '1':
-      if (terminal.onIconChange != null) {
-        terminal.onIconChange(pt);
-      }
+      terminal.onIconChange(pt);
       break;
     default:
       terminal.debug.onError('unknown osc ps: $ps');

+ 1 - 3
lib/terminal/sbc.dart

@@ -16,9 +16,7 @@ final sbcHandlers = <int, SbcHandler>{
 };
 
 void _bellHandler(int code, Terminal terminal) {
-  if (terminal.onBell != null) {
-    terminal.onBell();
-  }
+  terminal.onBell();
 }
 
 void _voidHandler(int code, Terminal terminal) {

+ 8 - 16
lib/terminal/terminal.dart

@@ -76,17 +76,16 @@ class Terminal with Observable {
   int get invisibleHeight => buffer.height - visibleHeight;
 
   /// Insert/Replace Mode (IRM)
-  /// 
+  ///
   /// The terminal displays received characters at the cursor position.
   /// Insert/Replace mode determines how the terminal adds characters to the
   /// screen. Insert mode displays the new character and moves previously
   /// displayed characters to the right. Replace mode adds characters by
-  /// replacing the character at the cursor position. 
+  /// replacing the character at the cursor position.
   ///
   /// You can set or reset insert/replace mode as follows.
   bool _replaceMode = true;
 
-
   bool _lineFeed = true;
   bool _screenMode = false; // DECSCNM (black on white background)
   bool _autoWrapMode = true;
@@ -219,11 +218,11 @@ class Terminal with Observable {
   }
 
   void setSlowMotion(bool enabled) {
-    _slowMotion = enabled ?? _slowMotion;
+    _slowMotion = enabled;
   }
 
   void setOriginMode(bool enabled) {
-    _originMode = enabled ?? _originMode;
+    _originMode = enabled;
     buffer.setPosition(0, 0);
   }
 
@@ -232,15 +231,15 @@ class Terminal with Observable {
   }
 
   void setApplicationCursorKeys(bool enabled) {
-    _applicationCursorKeys = enabled ?? _applicationCursorKeys;
+    _applicationCursorKeys = enabled;
   }
 
   void setShowCursor(bool showCursor) {
-    _showCursor = showCursor ?? _showCursor;
+    _showCursor = showCursor;
   }
 
   void setBlinkingCursor(bool enabled) {
-    _blinkingCursor = enabled ?? _blinkingCursor;
+    _blinkingCursor = enabled;
   }
 
   void setAutoWrapMode(bool enabled) {
@@ -268,7 +267,7 @@ class Terminal with Observable {
   }
 
   void setMouseMode(MouseMode mode) {
-    _mouseMode = mode ?? _mouseMode;
+    _mouseMode = mode;
   }
 
   void useMainBuffer() {
@@ -311,13 +310,6 @@ class Terminal with Observable {
   }) {
     debug.onMsg(key);
 
-    // keep a local reference to bypass nnbd checks.
-    final onInput = this.onInput;
-
-    if (onInput == null) {
-      return;
-    }
-
     for (var record in keytab.records) {
       if (record.key != key) {
         continue;

+ 1 - 1
lib/utli/debug_handler.dart

@@ -8,7 +8,7 @@ class DebugHandler {
   var _enabled = false;
 
   void enable([bool enabled = true]) {
-    _enabled = enabled ?? _enabled;
+    _enabled = enabled;
   }
 
   void _checkBuffer() {

+ 2 - 3
lib/utli/hash_values.dart

@@ -104,9 +104,8 @@ int hashValues(
 
 int hashList(Iterable<Object> arguments) {
   int result = 0;
-  if (arguments != null) {
-    for (Object argument in arguments)
-      result = _Jenkins.combine(result, argument);
+  for (Object argument in arguments) {
+    result = _Jenkins.combine(result, argument);
   }
   return _Jenkins.finish(result);
 }