1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-07-17 01:42:45 +02:00

get tcell to cleanup the terminal if we panic

This commit is contained in:
Jesse Duffield
2021-02-09 22:19:49 +11:00
parent 1fb2317bac
commit ecc5fe24a9
3 changed files with 19 additions and 18 deletions

View File

@ -8,7 +8,8 @@ import (
"github.com/gdamore/tcell/v2"
)
var screen tcell.Screen
// We probably don't want this being a global variable for YOLO for now
var Screen tcell.Screen
// tcellInit initializes tcell screen for use.
func tcellInit() error {
@ -17,7 +18,7 @@ func tcellInit() error {
} else if e = s.Init(); e != nil {
return e
} else {
screen = s
Screen = s
return nil
}
}
@ -26,7 +27,7 @@ func tcellInit() error {
// content (rune) and attributes using provided OutputMode
func tcellSetCell(x, y int, ch rune, fg, bg Attribute, omode OutputMode) {
st := getTcellStyle(fg, bg, omode)
screen.SetContent(x, y, ch, nil, st)
Screen.SetContent(x, y, ch, nil, st)
}
// getTcellStyle creates tcell.Style from Attributes
@ -120,7 +121,7 @@ var (
// pollEvent get tcell.Event and transform it into gocuiEvent
func pollEvent() GocuiEvent {
tev := screen.PollEvent()
tev := Screen.PollEvent()
switch tev := tev.(type) {
case *tcell.EventInterrupt:
return GocuiEvent{Type: eventInterrupt}