tasktree

package
v0.66.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 18, 2026 License: MIT Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package tasktree draws every task tree f10 prints. Skills relay this output verbatim instead of drawing the glyphs themselves, so a tree reads the same wherever it is shown.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cell

type Cell struct {
	Text   string
	Render func(text string) string
	// Fill cuts the cell to the columns Width leaves after the rest of its
	// row, and pads neither it nor the cells after it, so they follow it.
	Fill bool
}

A Cell is one column of a row: Text is measured and padded, Render prints in its place, so escape sequences never count as columns.

type Node

type Node struct {
	Depth int
	Cells []Cell // the first is the task's id
	Title string
	Notes []Note
}

A Node is one task. Depth 0 is the top level; a node one deeper than the node before it hangs under that node.

type Note

type Note struct {
	Label string
	Text  string
	Whole bool
	// Column starts the note under the row's second cell when the tree
	// aligns, so it reads as part of that column rather than per row.
	Column bool
}

A Note is a labelled line under a row, such as an ask, a halt or a url. Whole keeps it uncut, for text a reader acts on (a url, a question).

type Tree

type Tree struct {
	// Head prints first, alone, and the top-level nodes hang under it.
	Head string
	// Indent goes before every line but Head.
	Indent string
	// Hang draws glyphs on the top-level nodes too, as if under a Head.
	Hang bool
	// Align pads each column to its widest cell; otherwise the cells of a
	// row are joined by two spaces, empty ones skipped.
	Align bool
	// Width cuts titles and notes to fit it; 0 is no limit.
	Width int
	// Label renders a note's label; nil prints it as is.
	Label func(string) string
	// Columns are minimum column widths under Align, so trees written one
	// after another line up as one (Measure).
	Columns []int
}

A Tree is how the nodes print.

func (Tree) Measure added in v0.58.0

func (t Tree) Measure(nodes []Node) []int

Measure is the column widths Write pads nodes to, for trees written one after another that must line up (Columns).

func (Tree) Write

func (t Tree) Write(w io.Writer, nodes []Node) error

Write prints the nodes, an empty list printing nothing but Head.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL