Skip to main content

termui_pty 0.8.2 copy "termui_pty: ^0.8.2" to clipboard
termui_pty: ^0.8.2 copied to clipboard

A custom ANSI terminal emulator and PTY view for termui.

example/termui_pty.dart

import 'dart:io';
import 'package:termui/terminal/terminal.dart' as term;
import 'package:termui/termui.dart';
import 'package:pty2/pty2.dart';
import 'package:termui_pty/termui_pty.dart';

void main() async {
  // Start a bash shell that launches top, with a valid TERM environment
  final pty = PseudoTerminal.start(
    'bash',
    ['-c', 'top'],
    environment: {'TERM': 'xterm-256color'},
  );

  await term.Terminal.runGuarded((terminal) async {
    terminal.enterAlternateScreen();
    terminal.hideCursor();

    try {
      final runner = PromptRunner<Object?>(
        terminal: terminal,
        alternateScreen: true,
        widget: SizedBox.expand(child: PseudoTerminalView(pty: pty)),
      );

      await runner.run();
    } finally {
      pty.kill();
      terminal.showCursor();
      terminal.exitAlternateScreen();
    }
  });

  print('Exited cleanly.');
  exit(0);
}
2
likes
150
points
1.28k
downloads

Documentation

API reference

Publisher

verified publishermcdole.org

Weekly Downloads

A custom ANSI terminal emulator and PTY view for termui.

Repository (GitHub)
View/report issues

Topics

#cli #tui #terminal #console #pty

License

MIT (license)

Dependencies

characters, pty2, termui

More

Packages that depend on termui_pty