diff --git a/screen.go b/screen.go index 75a71e0..4088574 100644 --- a/screen.go +++ b/screen.go @@ -259,6 +259,11 @@ type Screen interface { // LockRegion sets or unsets a lock on a region of cells. A lock on a // cell prevents the cell from being redrawn. LockRegion(x, y, width, height int, lock bool) + + // Tty returns the underlying Tty. If the screen is not a terminal, the + // returned bool will be false + Tty() (Tty, bool) + } // NewScreen returns a default Screen suitable for the user's terminal diff --git a/simulation.go b/simulation.go index 98ae6f8..9620b6a 100644 --- a/simulation.go +++ b/simulation.go @@ -568,3 +568,7 @@ func (s *simscreen) LockRegion(x, y, width, height int, lock bool) { } } } + +func (s *simscreen) Tty() (Tty, bool) { + return nil, false +} diff --git a/tscreen.go b/tscreen.go index 127c47b..e1d0126 100644 --- a/tscreen.go +++ b/tscreen.go @@ -1868,6 +1868,10 @@ func (t *tScreen) LockRegion(x, y, width, height int, lock bool) { } } +func (t *tScreen) Tty() (Tty, bool) { + return t.tty, true +} + // engage is used to place the terminal in raw mode and establish screen size, etc. // Think of this is as tcell "engaging" the clutch, as it's going to be driving the // terminal interface. diff --git a/wscreen.go b/wscreen.go index 4c398aa..bfdce43 100644 --- a/wscreen.go +++ b/wscreen.go @@ -577,6 +577,10 @@ func (t *wScreen) LockRegion(x, y, width, height int, lock bool) { } } +func (t *wScreen) Tty() (Tty, bool) { + return nil, false +} + // WebKeyNames maps string names reported from HTML // (KeyboardEvent.key) to tcell accepted keys. var WebKeyNames = map[string]Key{