diff options
author | Valentin Rothberg <rothberg@redhat.com> | 2020-10-07 16:58:53 +0200 |
---|---|---|
committer | Valentin Rothberg <rothberg@redhat.com> | 2020-11-13 15:40:06 +0100 |
commit | 8e4a42aa429c6dec0d5face7c69554d8a0677e96 (patch) | |
tree | bbfff77e7b32a8b46af6f57d42965a7751bec18e /vendor/github.com/juju/ansiterm/tabwriter.go | |
parent | 0b1a60ec27928a40ac827148c1517098612616bd (diff) | |
download | podman-8e4a42aa429c6dec0d5face7c69554d8a0677e96.tar.gz podman-8e4a42aa429c6dec0d5face7c69554d8a0677e96.tar.bz2 podman-8e4a42aa429c6dec0d5face7c69554d8a0677e96.zip |
short-name aliasing
Add support for short-name aliasing.
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
Diffstat (limited to 'vendor/github.com/juju/ansiterm/tabwriter.go')
-rw-r--r-- | vendor/github.com/juju/ansiterm/tabwriter.go | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/vendor/github.com/juju/ansiterm/tabwriter.go b/vendor/github.com/juju/ansiterm/tabwriter.go new file mode 100644 index 000000000..1ff6faaaf --- /dev/null +++ b/vendor/github.com/juju/ansiterm/tabwriter.go @@ -0,0 +1,64 @@ +// Copyright 2016 Canonical Ltd. +// Licensed under the LGPLv3, see LICENCE file for details. + +package ansiterm + +import ( + "io" + + "github.com/juju/ansiterm/tabwriter" +) + +// NewTabWriter returns a writer that is able to set colors and styels. +// The ansi escape codes are stripped for width calculations. +func NewTabWriter(output io.Writer, minwidth, tabwidth, padding int, padchar byte, flags uint) *TabWriter { + return new(TabWriter).Init(output, minwidth, tabwidth, padding, padchar, flags) +} + +// TabWriter is a filter that inserts padding around tab-delimited +// columns in its input to align them in the output. +// +// It also setting of colors and styles over and above the standard +// tabwriter package. +type TabWriter struct { + Writer + tw tabwriter.Writer +} + +// Flush should be called after the last call to Write to ensure +// that any data buffered in the Writer is written to output. Any +// incomplete escape sequence at the end is considered +// complete for formatting purposes. +// +func (t *TabWriter) Flush() error { + return t.tw.Flush() +} + +// SetColumnAlignRight will mark a particular column as align right. +// This is reset on the next flush. +func (t *TabWriter) SetColumnAlignRight(column int) { + t.tw.SetColumnAlignRight(column) +} + +// A Writer must be initialized with a call to Init. The first parameter (output) +// specifies the filter output. The remaining parameters control the formatting: +// +// minwidth minimal cell width including any padding +// tabwidth width of tab characters (equivalent number of spaces) +// padding padding added to a cell before computing its width +// padchar ASCII char used for padding +// if padchar == '\t', the Writer will assume that the +// width of a '\t' in the formatted output is tabwidth, +// and cells are left-aligned independent of align_left +// (for correct-looking results, tabwidth must correspond +// to the tab width in the viewer displaying the result) +// flags formatting control +// +func (t *TabWriter) Init(output io.Writer, minwidth, tabwidth, padding int, padchar byte, flags uint) *TabWriter { + writer, colorCapable := colorEnabledWriter(output) + t.Writer = Writer{ + Writer: t.tw.Init(writer, minwidth, tabwidth, padding, padchar, flags), + noColor: !colorCapable, + } + return t +} |