mirror of
https://codeberg.org/scip/tablizer.git
synced 2025-12-17 12:31:06 +01:00
use stdout if it is a tty
This commit is contained in:
@@ -25,6 +25,7 @@ import (
|
|||||||
tea "github.com/charmbracelet/bubbletea"
|
tea "github.com/charmbracelet/bubbletea"
|
||||||
"github.com/charmbracelet/lipgloss"
|
"github.com/charmbracelet/lipgloss"
|
||||||
"github.com/evertras/bubble-table/table"
|
"github.com/evertras/bubble-table/table"
|
||||||
|
"github.com/mattn/go-isatty"
|
||||||
"github.com/tlinden/tablizer/cfg"
|
"github.com/tlinden/tablizer/cfg"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -468,7 +469,14 @@ func tableEditor(conf *cfg.Config, data *Tabdata) (*Tabdata, error) {
|
|||||||
// see https://github.com/charmbracelet/bubbletea/issues/860
|
// see https://github.com/charmbracelet/bubbletea/issues/860
|
||||||
//
|
//
|
||||||
// TODO: doesn't work with libgloss v2 anymore!
|
// TODO: doesn't work with libgloss v2 anymore!
|
||||||
lipgloss.SetDefaultRenderer(lipgloss.NewRenderer(os.Stderr))
|
|
||||||
|
out := os.Stderr
|
||||||
|
|
||||||
|
if isatty.IsTerminal(os.Stdout.Fd()) {
|
||||||
|
out = os.Stdout
|
||||||
|
}
|
||||||
|
|
||||||
|
lipgloss.SetDefaultRenderer(lipgloss.NewRenderer(out))
|
||||||
|
|
||||||
ctx := &Context{data: data}
|
ctx := &Context{data: data}
|
||||||
|
|
||||||
@@ -479,7 +487,7 @@ func tableEditor(conf *cfg.Config, data *Tabdata) (*Tabdata, error) {
|
|||||||
// still be used inside pipes.
|
// still be used inside pipes.
|
||||||
program := tea.NewProgram(
|
program := tea.NewProgram(
|
||||||
NewModel(data, ctx),
|
NewModel(data, ctx),
|
||||||
tea.WithOutput(os.Stderr),
|
tea.WithOutput(out),
|
||||||
tea.WithAltScreen())
|
tea.WithAltScreen())
|
||||||
|
|
||||||
m, err := program.Run()
|
m, err := program.Run()
|
||||||
|
|||||||
Reference in New Issue
Block a user