artisanal_pty 0.1.0 copy "artisanal_pty: ^0.1.0" to clipboard
artisanal_pty: ^0.1.0 copied to clipboard

An embeddable ANSI terminal emulator and pty2 widget for Artisanal.

artisanal_pty #

Embeddable terminal emulation for Artisanal applications, backed by pty2 for local processes.

Widget applications #

import 'dart:io';

import 'package:artisanal/runtime.dart' as runtime;
import 'package:artisanal_pty/widgets.dart';
import 'package:artisanal_widgets/app.dart';
import 'package:pty2/pty2.dart';

final pty = PseudoTerminal.start(
  Platform.isWindows ? 'pwsh.exe' : 'bash',
  [],
  environment: {'TERM': 'xterm-256color'},
  raw: true,
);

try {
  await runWidgetApp(
    ArtisanalApp(
      title: 'Artisanal PTY',
      home: PseudoTerminalView(pty: pty),
    ),
    options: runtime.ProgramOptions().withFilter(
      (_, message) =>
          message is runtime.InterruptMsg
              ? const runtime.QuitMsg()
              : message,
    ),
  );
} finally {
  pty.kill();
}

For SSH and other transports, feed output to VirtualTerminal and use TerminalView(onInput: transport.write).

Plain Artisanal applications #

Plain TEA applications can import the terminal model without importing the widget API:

import 'package:artisanal_pty/artisanal_pty.dart';

final terminal = VirtualTerminal(width: 80, height: 24);
terminal.write(serverOutput);

// Return this from a Model's view method.
final view = terminal.render();

The caller always owns the process or remote transport. Terminate a local PTY after the application exits.

PseudoTerminalView quits the widget application when the child process exits by default. Set quitOnExit: false when the surrounding application should remain open after the terminal session ends.

0
likes
150
points
98
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

An embeddable ANSI terminal emulator and pty2 widget for Artisanal.

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

artisanal, artisanal_widgets, characters, pty2

More

Packages that depend on artisanal_pty