CUI

Components / Developer tools

Commit graph

Version history with its branch lanes.

Functions: cui_commit_graph

Commit graph

Usage

/* newest first; each commit names its parents by row */
static const cui_commit log[] = {
    { "a91f3c2", "Merge branch 'feature'", "Maya", "2 hours ago", "main, origin/main", { 1, 2 } },
    { "7be04d1", "Docs", "Maya", "3 hours ago", NULL, { 3, -1 } },
    ...
};
cui_commit_graph(ui, "history", log, count, .selected = &selected, .height = 320);

Each commit's dot sits in its lane, curves join branches and merges, and a merge commit is drawn as a ring. Refs show as badges: local branches green, remote branches gray, and tags violet. The lanes are worked out once when the history changes, so fifty thousand commits take a few milliseconds to lay out and then cost nothing more. Up and Down move the selection, and Enter or a double click reports activated. Below 560 points the author and date are left out.

Keyboard

  • Up and Down move the selection, and Enter or a double click reports activated.

Options of cui_commit_graph

OptionTypeDefaultDescription
.widthcui_sizeWidth: CUI_FILL, CUI_FIT, CUI_PX(n) or CUI_PCT(n); unset uses the component's own.
.heightfloatHeight in points; 0 uses the component's own.
.selectedint *the selected row or -1, kept by you; NULL keeps it in the component

cui_commit

FieldTypeDescription
hashconst char *the commit id; its first 7 characters are shown
messageconst char *the first line is shown
authorconst char *shown in its own column, which a narrow panel leaves out
dateconst char *already formatted: "2 hours ago", "Mar 3"
refsconst char *"main, origin/main, tag: v1.2", may be NULL
parentint[2]row of each parent, -1 for none

cui_commit_graph_result

FieldTypeDescription
clickedintrow clicked this frame, or -1
activatedintrow double-clicked or chosen with Enter this frame, or -1
hoveredintrow under the pointer, or -1

Related

  • Dependency graph: Nodes and directed edges laid out in layers, for build targets, packages, services or call graphs.
  • Keymap: A keyboard with the shortcuts on it.
  • Network waterfall: HTTP requests as a table with a timing bar each.
  • Schedule picker: A cron schedule edited through plain choices instead of the expression, with the next runs listed.