Tea and termenv do not honor WithOutput properly
There's a mismatch in API semantics:
- termenv relies on the output going to
os.Stdout - bubbletea makes this configurable (via
WithOutput)
When bubbletea WithOutput is used with a different file, termenv does not recognize color profiles properly any more.
Generally, the mistake being made is the assumption that stdout is the file descriptor connected to the terminal. generally, the terminal is to be found on stdin, not stdout (and neither stderr!)
This mismatch is the cause of the following issues:
- https://github.com/charmbracelet/bubbletea/issues/172
- https://github.com/charmbracelet/bubbletea/issues/206
- https://github.com/charmbracelet/bubbletea/issues/302
- https://github.com/charmbracelet/bubbletea/discussions/386
I understand that the "next generation termenv" at https://github.com/muesli/termenv/tree/termenv-next would help with this, but I don't seem to see a timeline to get this moving forward?
FWIW, BSD libedit and readline treat the input and output file descriptors separately:
- the input raw mode is set on the input file descriptor
- the output escape codes, incl term initialization etc are sent on the output file descriptor
Oh and both query the terminal size using ioctl / TIOCGWINSZ on the input file desc, not output. Unsure why.
Yep, the termenv-next branch of termenv, as well as the termenv-output branch of bubbletea and the next branch of lipgloss address this issue. No timeline, but it's one of the things I'm currently working on.
Oh and both query the terminal size using ioctl / TIOCGWINSZ on the input file desc, not output. Unsure why.
We should look into that, I see more apps doing that.