File: cursor.go

package info (click to toggle)
golang-github-atomicgo-cursor 0.2.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 184 kB
  • sloc: makefile: 2
file content (26 lines) | stat: -rw-r--r-- 516 bytes parent folder | download
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 cursor

import (
	"os"
)

// Cursor displays content which can be updated on the fly.
// You can use this to create live output, charts, dropdowns, etc.
type Cursor struct {
	writer Writer
}

// NewCursor creates a new Cursor instance writing to os.Stdout.
func NewCursor() *Cursor {
	return &Cursor{writer: os.Stdout}
}

// WithWriter allows for any arbitrary Writer to be used
// for cursor movement abstracted.
func (c *Cursor) WithWriter(w Writer) *Cursor {
	if w != nil {
		c.writer = w
	}

	return c
}