streamer

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 8, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Ocean

type Ocean struct {
	// contains filtered or unexported fields
}

Ocean is a streaming table renderer that writes ASCII tables with fixed column widths.

func NewOcean

func NewOcean(w io.Writer, debug bool, config OceanConfig) (*Ocean, error)

NewOcean initializes an Ocean renderer with the given writer, debug setting, and configuration. It validates column widths and applies defaults for unset fields.

func (*Ocean) Config

func (s *Ocean) Config() tw.RendererConfig

Config returns a RendererConfig representation of the current configuration.

func (*Ocean) Debug

func (s *Ocean) Debug() []string

Debug returns the accumulated debug trace messages.

func (*Ocean) End

func (s *Ocean) End(w io.Writer) error

End finalizes the table stream, rendering the bottom border if enabled.

func (*Ocean) Footer

func (s *Ocean) Footer(w io.Writer, footerRow []string) error

Footer renders the footer row with an optional preceding separator line.

func (*Ocean) Header

func (s *Ocean) Header(w io.Writer, headerRow []string) error

Header renders the header row and an optional separator line.

func (*Ocean) Reset

func (s *Ocean) Reset()

Reset clears the renderer's internal state, including debug traces.

func (*Ocean) Row

func (s *Ocean) Row(w io.Writer, row []string) error

Row renders a data row.

func (*Ocean) Start

func (s *Ocean) Start(w io.Writer) error

Start begins the table stream, rendering the top border if enabled. The provided writer is ignored in favor of the instance's writer.

type OceanConfig

type OceanConfig struct {
	ColumnWidths   []int      // Widths for each column
	Symbols        tw.Symbols // Symbols for table borders and separators
	Borders        tw.Border  // Border visibility settings
	ColumnAligns   []tw.Align // Per-column alignment overrides
	HeaderAlign    tw.Align   // Default alignment for header cells
	RowAlign       tw.Align   // Default alignment for row cells
	FooterAlign    tw.Align   // Default alignment for footer cells
	Padding        tw.Padding // Padding characters for cells
	TrimWhitespace tw.State   // Whether to trim whitespace from cell content
	ShowHeaderLine bool       // Whether to render a separator line after the header
	ShowFooterLine bool       // Whether to render a separator line before the footer
}

OceanConfig defines the configuration for the Ocean table renderer.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL