Lazydraw: Terminal ASCII editor for drawing diagrams and sketches

原始链接: https://github.com/mpospirit/lazydraw

**lazydraw** 是一款基于终端的 ASCII 编辑器,旨在快速创建图表和草图。它借鉴了 ASCIIFlow 和 termDRAW 等工具的理念,利用 OpenTUI 框架在终端内提供响应式且支持鼠标操作的界面。 **主要功能:** * **直观工具:** 包含矩形、线条、箭头、文本和橡皮擦等选项,并支持撤销/重做及自由缩放平移。 * **灵活导出:** 可将图表导出为多种格式的文本文件(包括 Markdown 代码块和多种注释风格),或直接复制到剪贴板。 * **可定制界面:** 支持多种主题(包括终端原生色或 IDE 风格调色板)及网格配置。 * **无缝集成:** 既可作为独立命令运行,也可集成到 *herdr* 多路复用器中作为侧边栏插件使用。绘图会自动保存到本地以确保数据持久化。 **安装与要求:** 基于 Bun 运行时构建,可通过 `bun install -g lazydraw` 或 `npm` 安装。为获得最佳体验,终端需支持鼠标操作。所有绘图工具均配有全面的键盘快捷键,确保高效的导航与编辑。

Hacker News 最新 | 往期 | 评论 | 提问 | 展示 | 招聘 | 提交 登录 Lazydraw:用于绘制图表和草图的终端 ASCII 编辑器 ( github.com/mpospirit ) 16 点 由 masterpos 2 小时前 | 隐藏 | 往期 | 收藏 | 3 条评论 帮助 xlii 7 分钟前 | 下一条 [–] 竞争对手!:)(虽然我的是带有自定义渲染器的 GUI 版本) https://github.com/exlee/ascdraw 回复 rvz 1 小时前 | 上一条 [–] 现在的 GitHub 上到处都是这种“氛围编码”(vibe-coded)产生的垃圾。我们都知道这些工具在 6 个月后就会被废弃。 回复 fathermarz 13 分钟前 | 父评论 [–] 这是我几周来在 HN 上看到的看起来最不像“氛围编码”的作品。不确定你是看过了代码仓库,还是仅仅因为太多的垃圾内容而感到疲惫。提交记录看起来很简单,README 也简短且目标明确。 回复 准则 | 常见问题 | 列表 | API | 安全 | 法律 | 申请 YC | 联系 搜索:
相关文章

原文

lazydraw is a terminal ASCII editor for drawing quick diagrams and sketches, with options to export to text files or copy to the clipboard.

npm license

demo.mp4
  • ASCIIFlow by Lewis Hemens: the original, and the thing lazydraw is trying to be in a terminal.
  • termDRAW by Ben Vinegar: showed that this class of editor is possible in the terminal, and shaped how the rendering loop is approached.
  • OpenTUI by SST: the terminal UI engine the whole front end is built on.

lazydraw runs on the Bun runtime, so Bun 1.3 or later has to be installed. You also want a terminal with mouse support.

bun install -g lazydraw
lazydraw

If the lazydraw command isn't found afterwards, Bun's global bin directory isn't on your PATH. Add it to your shell profile:

export PATH="$HOME/.bun/bin:$PATH"

npm installs it just as well, and usually lands somewhere already on your PATH:

Or skip installing altogether:

lazydraw ships a herdr plugin manifest, so it can live in your multiplexer as a pane split to the right of whatever you're working on:

herdr plugin install mpospirit/lazydraw

The install step runs bun install --production in the clone, so Bun still has to be on your PATH.

Plugin manifests can't declare their own keybindings — herdr owns that surface — so add this to your own config.toml (opened via herdr's settings, or ~/.config/herdr/config.toml) and run herdr server reload-config:

[[keys.command]]
key = "prefix+ctrl+d"
type = "plugin_action"
command = "mpospirit.lazydraw.open"
description = "open lazydraw"

Ctrl+B Ctrl+D then opens the canvas as a right-hand split. Rebind it by changing key above.

lazydraw                     # open the last drawing
lazydraw architecture        # open or create a drawing by name
lazydraw ./diagram.ld.json
lazydraw --import notes.txt

Export a drawing without opening the UI:

lazydraw export architecture --basic --comment hashes --fenced -o diagram.txt
lazydraw list

≡ │ box select arrow line text eraser │ export │ ⟲ ⟳ │ ⚙ │ help

switch drawings; new, rename, fork, import, clear, delete
box drag corner to corner
select drag a box's inside to move it with its arrows attached, drag a line to resize, drag a line end to reshape, drag empty space to select
arrow / line drag start to end; hold Shift or press f mid-drag to flip the elbow
text click and type; Enter starts a new line, Esc finishes
eraser drag to erase; detaches from lines it touches
export extended or basic characters, 11 comment styles, Markdown fence, preview, copy, save
/ undo / redo
grid style (lattice, checker, dots, off), theme (terminal + 10 IDE themes), copy on select, recenter
help help for the active tool, plus the shortcut list
Key Action
16, Alt+1Alt+6 switch tool
r v a l t e switch tool: box, select, arrow, line, text, eraser
Ctrl+Z / Ctrl+Y undo / redo (Ctrl+Shift+Z also redoes on terminals with the kitty keyboard protocol)
Ctrl+C Ctrl+X Ctrl+V copy, cut, paste the selection (bracketed paste works too)
Del / arrow keys erase or nudge the selection
wheel, Shift+wheel pan vertically / horizontally
Space+drag, middle-drag pan freely
Ctrl+O Ctrl+E Ctrl+S files / export / save now
?, Esc help; close a popover, cancel a drag, deselect
Ctrl+Q twice quit; the first press prompts, a second within 3 s exits (drawings autosave)

In text mode, printable keys (including digits, q and ?) type text.

Selecting can also copy to the clipboard by itself — settings → copy on select, off by default.

  • Drawings: ${XDG_DATA_HOME:-~/.local/share}/lazydraw/drawings/<name>.ld.json
  • Config: ${XDG_CONFIG_HOME:-~/.config}/lazydraw/config.json

Drawings autosave 500 ms after each change, and again on quit.

  • tmux: needs set -g mouse on. Copying via OSC 52 needs set -g set-clipboard on.
  • macOS: Alt+digit needs "Option as Meta" (or use the bare digits).
  • Colors: the default terminal theme reads your terminal's own palette (OSC 10/11/4) and wears it — background, text and ANSI colors — so lazydraw is see-through and matches whatever your terminal looks like. settings → theme also offers ten IDE themes, which paint their own background: dracula, nord, tokyo-night, catppuccin, one-dark, gruvbox, monokai, night-owl, solarized-dark, github-light. Terminals that don't answer the color query fall back to nord.
  • Grid: the default lattice style draws 🭼 (U+1FB7C) in each empty cell, tinted 7% from your background toward the text color so it stays faint. If your terminal doesn't render it as cell-edge hairlines, switch to checker in settings.
bun install
bun start           # run from source
bun test            # unit, fixture, and end-to-end tests
bun run typecheck
bun run build       # standalone binary at dist/lazydraw
  • src/core is pure TypeScript with no terminal code. Its drawing logic (glyph connection, snapping, line routing, box/line/select/move tools, export wrappers) is ported from ASCIIFlow's client/.

  • src/tui is the OpenTUI front end: one full-screen surface that paints the canvas, toolbar, popovers and dialogs.

  • test/fixtures/asciiflow holds golden outputs captured by replaying test/scenarios/asciiflow.json through ASCIIFlow's own code. To regenerate them:

    git clone https://github.com/lewish/asciiflow /tmp/asciiflow && (cd /tmp/asciiflow && bun install)
    bun run fixtures /tmp/asciiflow
  • test/upstream runs ASCIIFlow's own spec files against lazydraw's core, through a small compatibility shim.

联系我们 contact @ memedata.com