mirror of
https://github.com/gdamore/tcell.git
synced 2025-04-24 13:48:51 +08:00
screen: extend interface with Tty method
Extend the Screen interface with a new Tty method, which returns the underlying tty when the screen is a terminal. This enables direct drawing to the Tty. Implement the interface for the three screen implementatinos included in the library.
This commit is contained in:
parent
ae2c4a8044
commit
fa6cd3ec5b
@ -259,6 +259,11 @@ type Screen interface {
|
|||||||
// LockRegion sets or unsets a lock on a region of cells. A lock on a
|
// LockRegion sets or unsets a lock on a region of cells. A lock on a
|
||||||
// cell prevents the cell from being redrawn.
|
// cell prevents the cell from being redrawn.
|
||||||
LockRegion(x, y, width, height int, lock bool)
|
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
|
// NewScreen returns a default Screen suitable for the user's terminal
|
||||||
|
@ -568,3 +568,7 @@ func (s *simscreen) LockRegion(x, y, width, height int, lock bool) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *simscreen) Tty() (Tty, bool) {
|
||||||
|
return nil, false
|
||||||
|
}
|
||||||
|
@ -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.
|
// 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
|
// Think of this is as tcell "engaging" the clutch, as it's going to be driving the
|
||||||
// terminal interface.
|
// terminal interface.
|
||||||
|
@ -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
|
// WebKeyNames maps string names reported from HTML
|
||||||
// (KeyboardEvent.key) to tcell accepted keys.
|
// (KeyboardEvent.key) to tcell accepted keys.
|
||||||
var WebKeyNames = map[string]Key{
|
var WebKeyNames = map[string]Key{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user