From 00fb486f6a5f90e92c60600103398553297fcd1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vlastimil=20Ov=C4=8D=C3=A1=C4=8D=C3=ADk?= Date: Sun, 19 Sep 2021 21:37:37 +0200 Subject: [tests] Add testing of keyboard events in FullscreenRenderer.GetChar() This contains one test case of each tcell.Key* event type that can be sent to and subsequently processed in fzf's GetChar(). The test cases describe status quo, and all of them PASS. Small function util.ToTty() was added. It is similar to util.IsTty(), but for stdout (hence the To preposition). --- src/util/util.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/util') diff --git a/src/util/util.go b/src/util/util.go index b3c32970..c16f1af0 100644 --- a/src/util/util.go +++ b/src/util/util.go @@ -117,11 +117,16 @@ func DurWithin( return val } -// IsTty returns true is stdin is a terminal +// IsTty returns true if stdin is a terminal func IsTty() bool { return isatty.IsTerminal(os.Stdin.Fd()) } +// ToTty returns true if stdout is a terminal +func ToTty() bool { + return isatty.IsTerminal(os.Stdout.Fd()) +} + // Once returns a function that returns the specified boolean value only once func Once(nextResponse bool) func() bool { state := nextResponse -- cgit v1.2.3