Skip to content

Commit

Permalink
wip: rework output buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
bashbunni committed Sep 28, 2023
1 parent 4730c03 commit ae36c86
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions ansi/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type TableElement struct {
lipgloss *table.Table
styleWriter *StyleWriter
headers []string
row []string
row []string
}

// A TableRowElement is used to render a single row in a table.
Expand Down Expand Up @@ -62,13 +62,19 @@ func (e *TableElement) Finish(w io.Writer, ctx RenderContext) error {
ctx.table.lipgloss.Border(lipgloss.NormalBorder())

// TODO remove styleWriter dep; not needed with lipgloss
ctx.table.styleWriter.Write([]byte(ctx.table.lipgloss.Render()))
// ctx.table.styleWriter.Write([]byte(ctx.table.lipgloss.Render()))

ctx.table.lipgloss = nil

renderText(ctx.table.styleWriter, ctx.options.ColorProfile, ctx.blockStack.With(rules.StylePrimitive), rules.Suffix)
renderText(ctx.table.styleWriter, ctx.options.ColorProfile, ctx.blockStack.Current().Style.StylePrimitive, rules.BlockSuffix)
return ctx.table.styleWriter.Close()
ow := ctx.blockStack.Current().Block

// TODO these might not be necessary? although, I don't think they'll break anything
renderText(ow, ctx.options.ColorProfile, ctx.blockStack.With(rules.StylePrimitive), rules.Suffix)
renderText(ow, ctx.options.ColorProfile, ctx.blockStack.Current().Style.StylePrimitive, rules.BlockSuffix)
ow.Write([]byte(ctx.table.lipgloss.Render()))

ctx.table.lipgloss = nil
// return ctx.table.styleWriter.Close()
return nil
}

func (e *TableRowElement) Finish(w io.Writer, ctx RenderContext) error {
Expand Down

0 comments on commit ae36c86

Please sign in to comment.