Skip to content

benvinegar/termdraw

Repository files navigation

termDRAW logo

termDRAW!

A terminal drawing editor for developers who want editable diagrams, UI mocks, and text graphics without leaving the terminal.

Packages

  • @termdraw/app — the standalone terminal app with the termdraw command
  • @termdraw/opentui — embeddable OpenTUI components and renderables
  • @termdraw/pi — Pi package that opens termDRAW in a Pi overlay

Install the app

Requirements:

  • Bun 1.3+
  • A terminal with mouse support
npm install --global @termdraw/app

Quick start

termdraw

Draw something, then press Enter or Ctrl+S to write the result to stdout.

App usage

# save plain text directly to a file
termdraw --output diagram.txt

# export a fenced Markdown code block
termdraw --fenced > diagram.md

# show CLI help
termdraw --help

termDRAW! outputs terminal text, not SVG or bitmap graphics.

Embed in an OpenTUI app

npm install @termdraw/opentui @opentui/core @opentui/react react
import { createCliRenderer } from "@opentui/core";
import { createRoot } from "@opentui/react";
import { TermDrawApp } from "@termdraw/opentui";

const renderer = await createCliRenderer({
  useMouse: true,
  enableMouseMovement: true,
  autoFocus: true,
  screenMode: "alternate-screen",
});

createRoot(renderer).render(
  <TermDrawApp
    width="100%"
    height="100%"
    autoFocus
    onSave={(art) => {
      console.log(art);
    }}
    onCancel={() => {
      renderer.destroy();
    }}
  />,
);

Also exported from @termdraw/opentui:

  • TermDrawApp
  • TermDrawEditor
  • TermDraw
  • TermDrawAppRenderable
  • TermDrawEditorRenderable
  • TermDrawRenderable
  • formatSavedOutput
  • buildHelpText

Use it in Pi

pi install npm:@termdraw/pi

Then inside Pi:

/termdraw

Docs

Contributing

Contributions are welcome.

Before opening a PR:

  • keep the change focused
  • run bun run check
  • add or update tests when editor behavior changes
  • open an issue first for larger UX or API changes

Security

Please report security issues privately through GitHub Security Advisories:

License

MIT. See LICENSE.

About

OpenTUI terminal drawing app

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors