From 76ee2e0089a974ae15077c75e41f8ba3d9003698 Mon Sep 17 00:00:00 2001 From: Tomtom Date: Sat, 26 Mar 2022 10:43:23 +0100 Subject: [PATCH] adds Program.Write method --- tea.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tea.go b/tea.go index f5af6ad060..8ab8cb6d7f 100644 --- a/tea.go +++ b/tea.go @@ -111,6 +111,14 @@ type Program struct { windowsStdin *os.File //nolint:golint,structcheck,unused } +// Write gives direct access to the underlying Writer. Useful for an inline +// program that wants to print things to the terminal during its execution. +func (p Program) Write(b []byte) (n int, err error) { + p.mtx.Lock() + defer p.mtx.Unlock() + return p.output.Write(b) +} + // Batch performs a bunch of commands concurrently with no ordering guarantees // about the results. Use a Batch to return several commands. //