Skip to content

Commit

Permalink
chore: lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
aymanbagabas committed Nov 21, 2024
1 parent 3ea1ab9 commit 1b7743e
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 42 deletions.
8 changes: 4 additions & 4 deletions ferocious_renderer.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ func (c *ferociousRenderer) update(msg Msg) {

case enableModeMsg:
switch ansi.DECMode(msg) {
case ansi.AltScreenBufferMode:
case ansi.AltScreenSaveCursorMode:
if c.altScreen {
return
}
Expand All @@ -327,7 +327,7 @@ func (c *ferociousRenderer) update(msg Msg) {
// whenever we enter or leave AltScreen.
c.updateCursorVisibility()

case ansi.CursorEnableMode:
case ansi.TextCursorEnableMode:
if !c.cursorHidden {
return
}
Expand All @@ -337,7 +337,7 @@ func (c *ferociousRenderer) update(msg Msg) {

case disableModeMsg:
switch ansi.DECMode(msg) {
case ansi.AltScreenBufferMode:
case ansi.AltScreenSaveCursorMode:
if !c.altScreen {
return
}
Expand All @@ -350,7 +350,7 @@ func (c *ferociousRenderer) update(msg Msg) {
// whenever we enter or leave AltScreen.
c.updateCursorVisibility()

case ansi.CursorEnableMode:
case ansi.TextCursorEnableMode:
if c.cursorHidden {
return
}
Expand Down
22 changes: 11 additions & 11 deletions screen.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type clearScreenMsg struct{}
// model's Init function. To initialize your program with the altscreen enabled
// use the WithAltScreen ProgramOption instead.
func EnterAltScreen() Msg {
return enableMode(ansi.AltScreenBufferMode)
return enableMode(ansi.AltScreenSaveCursorMode)
}

// ExitAltScreen is a special command that tells the Bubble Tea program to exit
Expand All @@ -42,7 +42,7 @@ func EnterAltScreen() Msg {
// Note that the alternate screen buffer will be automatically exited when the
// program quits.
func ExitAltScreen() Msg {
return disableMode(ansi.AltScreenBufferMode)
return disableMode(ansi.AltScreenSaveCursorMode)
}

// EnableMouseCellMotion is a special command that enables mouse click,
Expand All @@ -53,8 +53,8 @@ func ExitAltScreen() Msg {
// model's Init function. Use the WithMouseCellMotion ProgramOption instead.
func EnableMouseCellMotion() Msg {
return sequenceMsg{
func() Msg { return enableMode(ansi.MouseCellMotionMode) },
func() Msg { return enableMode(ansi.MouseSgrExtMode) },
func() Msg { return enableMode(ansi.ButtonEventMouseMode) },
func() Msg { return enableMode(ansi.SgrExtMouseMode) },
}
}

Expand All @@ -69,17 +69,17 @@ func EnableMouseCellMotion() Msg {
// model's Init function. Use the WithMouseAllMotion ProgramOption instead.
func EnableMouseAllMotion() Msg {
return sequenceMsg{
func() Msg { return enableMode(ansi.MouseAllMotionMode) },
func() Msg { return enableMode(ansi.MouseSgrExtMode) },
func() Msg { return enableMode(ansi.AnyEventMouseMode) },
func() Msg { return enableMode(ansi.SgrExtMouseMode) },
}
}

// DisableMouse is a special command that stops listening for mouse events.
func DisableMouse() Msg {
return sequenceMsg{
func() Msg { return disableMode(ansi.MouseCellMotionMode) },
func() Msg { return disableMode(ansi.MouseAllMotionMode) },
func() Msg { return disableMode(ansi.MouseSgrExtMode) },
func() Msg { return disableMode(ansi.ButtonEventMouseMode) },
func() Msg { return disableMode(ansi.AnyEventMouseMode) },
func() Msg { return disableMode(ansi.SgrExtMouseMode) },
}
}

Expand All @@ -88,13 +88,13 @@ func DisableMouse() Msg {
// to show the cursor, which is normally hidden for the duration of a Bubble
// Tea program's lifetime. You will most likely not need to use this command.
func HideCursor() Msg {
return disableMode(ansi.CursorEnableMode)
return disableMode(ansi.TextCursorEnableMode)
}

// ShowCursor is a special command for manually instructing Bubble Tea to show
// the cursor.
func ShowCursor() Msg {
return enableMode(ansi.CursorEnableMode)
return enableMode(ansi.TextCursorEnableMode)
}

// EnableBracketedPaste is a special command that tells the Bubble Tea program
Expand Down
8 changes: 4 additions & 4 deletions standard_renderer.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,15 +277,15 @@ func (r *standardRenderer) update(msg Msg) {

case enableModeMsg:
switch ansi.DECMode(msg) {
case ansi.AltScreenBufferMode:
case ansi.AltScreenSaveCursorMode:
if r.altScreenActive {
return
}

r.setAltScreenBuffer(true)
r.altScreenActive = true
r.repaint()
case ansi.CursorEnableMode:
case ansi.TextCursorEnableMode:
if !r.cursorHidden {
return
}
Expand All @@ -295,15 +295,15 @@ func (r *standardRenderer) update(msg Msg) {

case disableModeMsg:
switch ansi.DECMode(msg) {
case ansi.AltScreenBufferMode:
case ansi.AltScreenSaveCursorMode:
if !r.altScreenActive {
return
}

r.setAltScreenBuffer(false)
r.altScreenActive = false
r.repaint()
case ansi.CursorEnableMode:
case ansi.TextCursorEnableMode:
if r.cursorHidden {
return
}
Expand Down
34 changes: 17 additions & 17 deletions tea.go
Original file line number Diff line number Diff line change
Expand Up @@ -739,18 +739,18 @@ func (p *Program) Run() (Model, error) {
}

// Hide the cursor before starting the renderer.
p.modes[ansi.CursorEnableMode] = false
p.modes[ansi.TextCursorEnableMode] = false
p.execute(ansi.HideCursor)
p.renderer.update(disableMode(ansi.CursorEnableMode))
p.renderer.update(disableMode(ansi.TextCursorEnableMode))

// Honor program startup options.
if p.startupTitle != "" {
p.execute(ansi.SetWindowTitle(p.startupTitle))
}
if p.startupOptions&withAltScreen != 0 {
p.execute(ansi.SetAltScreenBufferMode)
p.modes[ansi.AltScreenBufferMode] = true
p.renderer.update(enableMode(ansi.AltScreenBufferMode))
p.execute(ansi.SetAltScreenSaveCursorMode)
p.modes[ansi.AltScreenSaveCursorMode] = true
p.renderer.update(enableMode(ansi.AltScreenSaveCursorMode))
}
if p.startupOptions&withoutBracketedPaste == 0 {
p.execute(ansi.SetBracketedPasteMode)
Expand All @@ -763,15 +763,15 @@ func (p *Program) Run() (Model, error) {
// a response in the eventLoop.
}
if p.startupOptions&withMouseCellMotion != 0 {
p.execute(ansi.EnableMouseCellMotion)
p.execute(ansi.SetButtonEventMouseMode)
p.execute(ansi.SetSgrExtMouseMode)
p.modes[ansi.MouseCellMotionMode] = true
p.modes[ansi.MouseSgrExtMode] = true
p.modes[ansi.ButtonEventMouseMode] = true
p.modes[ansi.SgrExtMouseMode] = true
} else if p.startupOptions&withMouseAllMotion != 0 {
p.execute(ansi.EnableMouseAllMotion)
p.execute(ansi.SetAnyEventMouseMode)
p.execute(ansi.SetSgrExtMouseMode)
p.modes[ansi.MouseAllMotionMode] = true
p.modes[ansi.MouseSgrExtMode] = true
p.modes[ansi.AnyEventMouseMode] = true
p.modes[ansi.SgrExtMouseMode] = true
}

if p.startupOptions&withReportFocus != 0 {
Expand Down Expand Up @@ -949,15 +949,15 @@ func (p *Program) RestoreTerminal() error {
if err := p.initInputReader(); err != nil {
return err
}
if p.modes[ansi.AltScreenBufferMode] {
p.execute(ansi.SetAltScreenBufferMode)
if p.modes[ansi.AltScreenSaveCursorMode] {
p.execute(ansi.SetAltScreenSaveCursorMode)
} else {
// entering alt screen already causes a repaint.
go p.Send(repaintMsg{})
}

p.startRenderer()
if !p.modes[ansi.CursorEnableMode] {
if !p.modes[ansi.TextCursorEnableMode] {
p.execute(ansi.HideCursor)
} else {
p.execute(ansi.ShowCursor)
Expand All @@ -974,12 +974,12 @@ func (p *Program) RestoreTerminal() error {
if p.modes[ansi.FocusEventMode] {
p.execute(ansi.SetFocusEventMode)
}
if p.modes[ansi.MouseCellMotionMode] || p.modes[ansi.MouseAllMotionMode] {
if p.modes[ansi.ButtonEventMouseMode] || p.modes[ansi.AnyEventMouseMode] {
if p.startupOptions&withMouseCellMotion != 0 {
p.execute(ansi.EnableMouseCellMotion)
p.execute(ansi.SetButtonEventMouseMode)
p.execute(ansi.SetSgrExtMouseMode)
} else if p.startupOptions&withMouseAllMotion != 0 {
p.execute(ansi.EnableMouseAllMotion)
p.execute(ansi.SetAnyEventMouseMode)
p.execute(ansi.SetSgrExtMouseMode)
}
}
Expand Down
12 changes: 6 additions & 6 deletions tty.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ func (p *Program) restoreTerminalState() error {
if p.modes[ansi.BracketedPasteMode] {
p.execute(ansi.ResetBracketedPasteMode)
}
if !p.modes[ansi.CursorEnableMode] {
if !p.modes[ansi.TextCursorEnableMode] {
p.execute(ansi.ShowCursor)
}
if p.modes[ansi.MouseCellMotionMode] || p.modes[ansi.MouseAllMotionMode] {
p.execute(ansi.DisableMouseCellMotion)
p.execute(ansi.DisableMouseAllMotion)
if p.modes[ansi.ButtonEventMouseMode] || p.modes[ansi.AnyEventMouseMode] {
p.execute(ansi.ResetButtonEventMouseMode)
p.execute(ansi.ResetAnyEventMouseMode)
p.execute(ansi.ResetSgrExtMouseMode)
}
if p.keyboard.modifyOtherKeys != 0 {
Expand All @@ -59,8 +59,8 @@ func (p *Program) restoreTerminalState() error {
if p.modes[ansi.GraphemeClusteringMode] {
p.execute(ansi.ResetGraphemeClusteringMode)
}
if p.modes[ansi.AltScreenBufferMode] {
p.execute(ansi.ResetAltScreenBufferMode)
if p.modes[ansi.AltScreenSaveCursorMode] {
p.execute(ansi.ResetAltScreenSaveCursorMode)
// cmd.exe and other terminals keep separate cursor states for the AltScreen
// and the main buffer. We have to explicitly reset the cursor visibility
// whenever we exit AltScreen.
Expand Down

0 comments on commit 1b7743e

Please sign in to comment.