Преглед изворни кода

Merge pull request #31 from devmil/bugfix/example_fixes

Adds missing required maxLines parameter
xuty пре 4 година
родитељ
комит
0015480bfd
1 измењених фајлова са 13 додато и 1 уклоњено
  1. 13 1
      example/lib/main.dart

+ 13 - 1
example/lib/main.dart

@@ -33,16 +33,28 @@ class _MyHomePageState extends State<MyHomePage> {
   @override
   void initState() {
     super.initState();
-    terminal = Terminal(onInput: onInput);
+    terminal = Terminal(
+      onInput: onInput,
+      maxLines: 10000,
+    );
     terminal.write('xterm.dart demo');
     terminal.write('\r\n');
     terminal.write('\$ ');
   }
 
   void onInput(String input) {
+    // in a "real" terminal emulation you would connect onInput to the backend
+    // (like a pty or ssh connection) that then handles the changes in the
+    // terminal.
+    // As we don't have a connected backend here we simulate the changes by
+    // directly writing to the terminal.
     if (input == '\r') {
       terminal.write('\r\n');
       terminal.write('\$ ');
+    } else if (input.codeUnitAt(0) == 127) {
+      terminal.buffer.eraseCharacters(1);
+      terminal.buffer.backspace();
+      terminal.refresh();
     } else {
       terminal.write(input);
     }