diff options
Diffstat (limited to 'go/src/lib/statusline')
-rw-r--r-- | go/src/lib/statusline/statuslinue.go | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/go/src/lib/statusline/statuslinue.go b/go/src/lib/statusline/statuslinue.go new file mode 100644 index 0000000..90ec1af --- /dev/null +++ b/go/src/lib/statusline/statuslinue.go @@ -0,0 +1,24 @@ +package statusline + +import ( + "fmt" + "io" +) + +type StatusLine struct { + out io.Writer + prevLen int +} + +func NewStatusLine(out io.Writer) *StatusLine { + return &StatusLine{out: out} +} + +func (sl *StatusLine) Put(line string) { + fmt.Fprintf(sl.out, "\r%-[1]*[2]s", sl.prevLen, line) + sl.prevLen = len(line) +} + +func (sl *StatusLine) End() { + fmt.Fprintf(sl.out, "\r%-[1]*[2]s\r", sl.prevLen, "") +} |