Diagram editor built with ETAF: shapes, text and orthogonal connectors with SVG and Markdown export
- Emacs Lisp 72%
- Python 27.2%
- Makefile 0.7%
|
Some checks failed
Repository structure / structure (push) Has been cancelled
Resizing used to leave rows wider than the window, so the buffer scrolled sideways and the edges of the drawing were cut off. - Measure the window in character columns and register the runtime viewport as a dependency, so a resize re-renders every panel that reads the width. - Drop the rail below 70 columns and the inspector below 46: the rail's tools have keys, while the inspector holds the label field, so it goes second. - Keep the canvas at 12 columns and let it clip, instead of demanding more than the window has. - Let the status bar drop its key caps and shorten its hint before it can overflow. - Clip the rail, the inspector and the panel row instead of letting their content grow the row and push the status bar out of the frame. Validation: make check (structure, compilation, 14 acceptance scenarios, 29 API declarations); a live frame at 130, 100, 80, 70, 60, 50 and 40 columns rendered no line wider than the window, kept the inspector from 46 up, and kept the rail from 70 up. |
||
|---|---|---|
| .githooks | ||
| .github/workflows | ||
| docs | ||
| lisp | ||
| scripts | ||
| tests | ||
| .editorconfig | ||
| .gitignore | ||
| CHANGELOG.md | ||
| etaf-diagram.el | ||
| LICENSE | ||
| Makefile | ||
| README.md | ||
ETAF Diagram
A diagram editor for Emacs built as an ETAF application. Shapes, text and orthogonal connectors live in one ordinary buffer: drag them with the mouse or move them with the keyboard, then export the drawing as SVG or Markdown.
Capabilities
M-x etaf-diagram-openopens a new diagram;M-x etaf-diagram-open-fileedits a saved one. The framework owns the buffer, the default face and the close hook throughetaf-app-open.- Four shape kinds — rectangle, rounded rectangle, diamond and text — plus orthogonal connectors between them, each with an optional label.
- Drag a shape to move it, drag a corner handle to resize it, drag from a shape edge to another shape to connect them; the canvas pans by dragging empty space and follows the arrow keys.
- Keyboard work:
vselect,rrectangle,orounded,ddiamond,ttext,aarrow,uundo,yredo,ssave,C-ddelete,eedit the label,gtoggle the grid,ffit the drawing into the window. - The document saves as JSON (
*.etaf-diagram) and exports as SVG (etaf-diagram-export-svg) or as a Markdown document that carries both the character drawing and a list of every node (etaf-diagram-export-markdown). - The canvas paints with faces, not images: box-drawing characters for the grid and the connectors, so the drawing stays readable in any theme and in plain text.
- The palette comes from the appearance the host provides and the Emacs theme otherwise, so the editor follows a theme switch without a reload.
Prerequisites
| Requirement | Why | Check |
|---|---|---|
| Emacs 29.1 or newer | the ETAF runtime and Ebox | emacs --version |
ETAF, ETAF UI, Ebox and ECSS on load-path |
rendering and the component catalog | see Installation |
Installation
Checkout users add the repository roots to load-path and require the entry:
(add-to-list 'load-path "/path/to/etaf-diagram")
(add-to-list 'load-path "/path/to/etaf") ; plus etaf-ui, ebox, ecss
(require 'etaf-diagram)
The package installs from the ETAF archive with
M-x etaf-install RET etaf-diagram RET.
A minimal example
(let* ((session (etaf-diagram-create :name "架构图"))
(client (etaf-diagram-add-shape session 'rect
:x 3 :y 2 :width 18 :height 4
:label "客户端"))
(model (etaf-diagram-add-shape session 'rounded
:x 30 :y 2 :width 17 :height 4
:label "模型")))
(etaf-diagram-connect session client model :label "编辑")
(etaf-app-open "*diagram*" (etaf-diagram-view session) :state session :display t))
etaf-diagram-shapes and etaf-diagram-edges return plain plists, so the same
session also drives exports and tests without a buffer:
(etaf-diagram-export-svg session "/tmp/arch.svg")
(princ (etaf-diagram-markdown session))
Documentation
- The supported interface inventory is the Commentary of
etaf-diagram.el. docs/manual.mdcovers the workflows: drawing, connecting, editing labels, saving, exporting and recovering from a failed load.docs/architecture.mdexplains how a session, the canvas renderer and the ETAF views fit together.
Checks
make check # structure, byte compilation, acceptance tests, API signatures
make test # behavioural scenarios only
License
GPL-3.0-or-later.