File: task.go

package info (click to toggle)
golang-github-charmbracelet-glamour 0.8.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 7,064 kB
  • sloc: sh: 25; makefile: 6
file content (26 lines) | stat: -rw-r--r-- 444 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package ansi

import (
	"io"
)

// A TaskElement is used to render tasks inside a todo-list.
type TaskElement struct {
	Checked bool
}

func (e *TaskElement) Render(w io.Writer, ctx RenderContext) error {
	var el *BaseElement

	pre := ctx.options.Styles.Task.Unticked
	if e.Checked {
		pre = ctx.options.Styles.Task.Ticked
	}

	el = &BaseElement{
		Prefix: pre,
		Style:  ctx.options.Styles.Task.StylePrimitive,
	}

	return el.Render(w, ctx)
}