{"modulePath":"github.com/nsgo-dev/nsgo","version":"v0.4.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package commitgraph\n\nPackage commitgraph lays out and draws a Git history's revision graph: the lanes commits sit in and the lines joining them to their parents. It has no look: the app gives Graph its colors and builds the rows around it.\n\n## Constants\n\n```go\nconst (\n\t// RowHeight is a row's height, which the lines span.\n\tRowHeight core.Points = 26\n\t// LaneWidth is a column's width.\n\tLaneWidth core.Points = 12\n)\n```\nThe graph's size by default, shared so the rows of a list line up.\n\n```go\nconst MaxLines = 64\n```\nMaxLines bounds a graph's open lines, so a history with very many open branches cannot widen it without limit.\n\n## Functions\n\n```go\nfunc Fold(commits []Commit, collapsed map[string]bool) map[string]string\n```\nFold returns the commits that each collapsed merge hides, mapped to that merge: those its later parents reach but its first parent does not. A commit stays shown when a shown commit other than the merge descends from it, so every shown line still reaches its parent.\n\n```go\nfunc FormatDate(cx *core.Scope, date time.Time) string\n```\nFormatDate writes a commit's date in local time, numerically in the language the app shows.\n\n## Types\n\n```go\ntype Commit struct {\n\tHash string\n\t// Parents are the commit's parents' hashes, the first parent first.\n\tParents []string\n}\n```\nCommit is what the graph knows of a commit. A history lists its commits newest first with each after its children, as \\`git log --date-order\\` does.\n\n```go\ntype Graph struct {\n\tHistory *History\n\t// Item is the row's commit, read as a signal.\n\tItem func() Item\n\t// Height is the row's, RowHeight when 0, and Lane a column's width,\n\t// LaneWidth when 0.\n\tHeight, Lane core.Points\n\t// Color returns a line's color, the text's when nil.\n\tColor func(line int) core.Color\n\t// Class, Style and StyleFunc are the graph's.\n\tClass     string\n\tStyle     core.Style\n\tStyleFunc func() core.Style\n\t// MergeClass, MergeStyle and MergeStyleFunc are the merge button's,\n\t// such as its hover.\n\tMergeClass     string\n\tMergeStyle     core.Style\n\tMergeStyleFunc func() core.Style\n}\n```\nGraph draws one commit's row of the revision graph: lines cross the row and curve into and out of the commit, a ring in its line's color. Its width is its own row's columns, so a busy stretch of history does not push every subject away from its graph; give each row of a list one Graph and no gap between them, so the lines meet.\n\nA commit the History knows as a merge is a disc with a chevron, pointing down while expanded and right, inside a ring, while collapsed, and a button that toggles it. What the graph cuts out of itself shows the row behind it, selected or not.\n\n```go\nfunc (g Graph) Render(cx *core.Scope) core.Node\n```\nRender implements core.Node.\n\n```go\ntype History struct {\n\t// contains filtered or unexported fields\n}\n```\nHistory is a list of commits with its merges collapsed or expanded, and the graph of the commits that leaves shown. The app makes it with NewHistory and lists its rows with At.\n\n```go\nfunc NewHistory(cx *core.Scope, commits func() []Commit, selection *base.Selection) *History\n```\nNewHistory returns the history of commits, which it reads as signals, with every merge expanded. With a selection, one a collapsing merge hides moves to the merge.\n\n```go\nfunc (h *History) At(i int) Item\n```\nAt returns the i-th shown commit, the zero Item past the end as a list's cell may read it while the history shrinks.\n\n```go\nfunc (h *History) Collapsed(hash string) bool\n```\nCollapsed reports whether the merge of hash hides the commits it brings in.\n\n```go\nfunc (h *History) Len() int\n```\nLen returns how many commits show.\n\n```go\nfunc (h *History) Toggle(hash string)\n```\nToggle collapses or expands the merge of hash.\n\n```go\ntype Item struct {\n\tIndex int\n\tHash  string\n\tRow   Row\n\t// Merge reports that the commit has commits to collapse.\n\tMerge bool\n}\n```\nItem is a shown commit of a History: its index in the history's commits and its graph.\n\n```go\ntype Line struct {\n\tID, Top, Column, Bottom int\n}\n```\nLine is one line crossing a commit's row: it enters the row's top edge in column Top, passes the row's middle in Column and leaves the bottom edge in Bottom. -1 means the line does not touch that edge, so it ends at the commit (no Bottom) or starts from it (no Top). ID keeps its color.\n\n```go\ntype Row struct {\n\tLines                 []Line\n\tColumn, Line, Columns int\n}\n```\nRow is the graph of one commit: the lines crossing its row, the column of the commit itself and of the line it belongs to, -1 for a commit past MaxLines, which shows no node, and the number of columns the row draws in.\n\n```go\nfunc Layout(commits []Commit) []Row\n```\nLayout lays out the revision graph of commits and returns a row per commit. It keeps a line open for each parent still to come and numbers a new line by the column it opens in, so a branch takes that column's color and keeps it while open, and a merge folds it back into its first parent.\n\n","path":"github.com/nsgo-dev/nsgo/base/commitgraph","name":"commitgraph","synopsis":"Package commitgraph lays out and draws a Git history's revision graph: the lanes commits sit in and the lines joining them to their parents.","isRedistributable":true}
