mirror of https://github.com/gdamore/tcell.git
windows: Use alt screen by default (supress with TCELL_ALTSCREEN=disable)
The alternate screen buffer right now only works in VT mode.
This commit is contained in:
parent
5a591d4275
commit
552bf3cec1
|
@ -41,6 +41,7 @@ type cScreen struct {
|
||||||
vten bool
|
vten bool
|
||||||
truecolor bool
|
truecolor bool
|
||||||
running bool
|
running bool
|
||||||
|
disableAlt bool // disable the alternate screen
|
||||||
|
|
||||||
w int
|
w int
|
||||||
h int
|
h int
|
||||||
|
@ -161,6 +162,8 @@ const (
|
||||||
vtCursorSteadyBar = "\x1b[6 q"
|
vtCursorSteadyBar = "\x1b[6 q"
|
||||||
vtDisableAm = "\x1b[?7l"
|
vtDisableAm = "\x1b[?7l"
|
||||||
vtEnableAm = "\x1b[?7h"
|
vtEnableAm = "\x1b[?7h"
|
||||||
|
vtEnterCA = "\x1b[?1049h\x1b[22;0;0t"
|
||||||
|
vtExitCA = "\x1b[?1049l\x1b[23;0;0t"
|
||||||
)
|
)
|
||||||
|
|
||||||
var vtCursorStyles = map[CursorStyle]string{
|
var vtCursorStyles = map[CursorStyle]string{
|
||||||
|
@ -239,6 +242,12 @@ func (s *cScreen) Init() error {
|
||||||
case "enable":
|
case "enable":
|
||||||
tryVt = true
|
tryVt = true
|
||||||
}
|
}
|
||||||
|
switch os.Getenv("TCELL_ALTSCREEN") {
|
||||||
|
case "enable":
|
||||||
|
s.disableAlt = false // also the default
|
||||||
|
case "disable":
|
||||||
|
s.disableAlt = true
|
||||||
|
}
|
||||||
if tryVt {
|
if tryVt {
|
||||||
s.setOutMode(modeVtOutput | modeNoAutoNL | modeCookedOut | modeUnderline)
|
s.setOutMode(modeVtOutput | modeNoAutoNL | modeCookedOut | modeUnderline)
|
||||||
var om uint32
|
var om uint32
|
||||||
|
@ -337,6 +346,9 @@ func (s *cScreen) disengage() {
|
||||||
_, _, _ = procSetConsoleTextAttribute.Call(
|
_, _, _ = procSetConsoleTextAttribute.Call(
|
||||||
uintptr(s.out),
|
uintptr(s.out),
|
||||||
uintptr(s.mapStyle(StyleDefault)))
|
uintptr(s.mapStyle(StyleDefault)))
|
||||||
|
if s.vten && !s.disableAlt {
|
||||||
|
s.emitVtString(vtExitCA)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *cScreen) engage() error {
|
func (s *cScreen) engage() error {
|
||||||
|
@ -360,6 +372,9 @@ func (s *cScreen) engage() error {
|
||||||
|
|
||||||
if s.vten {
|
if s.vten {
|
||||||
s.setOutMode(modeVtOutput | modeNoAutoNL | modeCookedOut | modeUnderline)
|
s.setOutMode(modeVtOutput | modeNoAutoNL | modeCookedOut | modeUnderline)
|
||||||
|
if !s.disableAlt {
|
||||||
|
s.emitVtString(vtEnterCA)
|
||||||
|
}
|
||||||
s.emitVtString(vtDisableAm)
|
s.emitVtString(vtDisableAm)
|
||||||
} else {
|
} else {
|
||||||
s.setOutMode(0)
|
s.setOutMode(0)
|
||||||
|
|
Loading…
Reference in New Issue