Documentation
¶
Overview ¶
Package render is the output layer every command shares: the facts block, task links and hyperlinks, and the pager.
Index ¶
- Variables
- func FileLink(path string) string
- func FileURL(path string) string
- func Follow(ctx context.Context, w io.Writer, dir, url string, linkOnly bool) error
- func Hyperlink(url, text string) string
- func LabelWidth(rows []Fact) int
- func LinkFlag() cli.Flag
- func PadRight(s string, width int) string
- func PrintFlag() cli.Flag
- func VisibleWidth(s string) int
- func Wrap(text string, width int) []string
- func WriteDoc(ctx context.Context, w io.Writer, dir, doc string) error
- func WriteFacts(w io.Writer, rows []Fact, width, limit int) error
- func WriteReport(w io.Writer, rows []Fact, notes []string) error
- type Fact
- type LinkBuffer
- type TaskLinks
Constants ¶
This section is empty.
Variables ¶
var LinkTerminal = ui.IsTerminal
LinkTerminal is swapped in tests, which write to a buffer.
Functions ¶
func FileLink ¶
FileLink links a markdown path to its file:// url, its text left as the path since people copy it; other files stay plain, as only markdown has a handler to open it.
func LabelWidth ¶
LabelWidth is the label column rows need, the colon included.
func LinkFlag ¶
LinkFlag is the same flag on every verb that follows an address, so `open` keeps one meaning across nouns whose addresses are paths and urls alike.
func VisibleWidth ¶
VisibleWidth is the columns s takes on screen, its links' escapes not counted.
func Wrap ¶
Wrap breaks text at spaces; width 0 or below disables it, and a token longer than the width is hard-cut rather than overflowed.
func WriteDoc ¶
WriteDoc pages markdown on a terminal and writes it raw to a pipe: no renderer is bundled, since glow, bat or an editor compose for free.
func WriteFacts ¶
WriteFacts prints rows as `label: <marker> value`, labels padded to width, so rows printed apart with one width still share a value column.
Types ¶
type Fact ¶
type Fact struct {
Label string
Value string
URL bool
Path bool // a markdown file, linked on a terminal; the marker stays blank
// Run marks a run row: its value takes style and wraps at the page width.
// A facts value does neither, since its link escapes would be cut apart.
Run bool
Style lipgloss.Style
}
type LinkBuffer ¶
LinkBuffer holds output its caller copies on to another writer, so it links when that writer would.
func (*LinkBuffer) Terminal ¶
func (b *LinkBuffer) Terminal() bool
Terminal makes the buffer read as the writer it is copied on to.
type TaskLinks ¶
type TaskLinks struct {
On bool
// contains filtered or unexported fields
}
TaskLinks prints task ids for people: an id becomes a terminal link when linking is on and its url is known. Urls come from the ledger only, so no command waits on the tracker to print. A nil one prints every id plain.
func LinksFor ¶
LinksFor links only on a terminal: piped output, --plain and --json are parsed by agents and scripts, which escape codes would break.