Skip to content

Commit

Permalink
Allow use of TCELL_ALTSCREEN=disable to disable alternate screen.
Browse files Browse the repository at this point in the history
This hack will also prevent the clearing of the screen at disengage
time.  This may be useful for certain kinds of applications that
want to draw the screen, then place the cursor at a specific location.
(The application will need to do a TGoto on it's own first.)
  • Loading branch information
gdamore committed Mar 2, 2024
1 parent 552bf3c commit 6984e25
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions tscreen.go
Original file line number Diff line number Diff line change
Expand Up @@ -1822,7 +1822,14 @@ func (t *tScreen) engage() error {
}

ti := t.ti
t.TPuts(ti.EnterCA)
if os.Getenv("TCELL_ALTSCREEN") != "disable" {
// Technically this may not be right, but every terminal we know about
// (even Wyse 60) uses this to enter the alternate screen buffer, and
// possibly save and restore the window title and/or icon.
// (In theory there could be terminals that don't support X,Y cursor
// positions without a setup command, but we don't support them.)
t.TPuts(ti.EnterCA)
}
t.TPuts(ti.EnterKeypad)
t.TPuts(ti.HideCursor)
t.TPuts(ti.EnableAcs)
Expand Down Expand Up @@ -1865,10 +1872,12 @@ func (t *tScreen) disengage() {
}
t.TPuts(ti.ResetFgBg)
t.TPuts(ti.AttrOff)
t.TPuts(ti.Clear)
t.TPuts(ti.ExitCA)
t.TPuts(ti.ExitKeypad)
t.TPuts(ti.EnableAutoMargin)
if os.Getenv("TCELL_ALTSCREEN") != "disable" {
t.TPuts(ti.Clear) // only needed if ExitCA is empty
t.TPuts(ti.ExitCA)
}
t.enableMouse(0)
t.enablePasting(false)
t.disableFocusReporting()
Expand Down

0 comments on commit 6984e25

Please sign in to comment.