Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update renederer name to 'cursed' #1296

Merged
merged 1 commit into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 19 additions & 19 deletions ferocious_renderer.go → cursed_renderer.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/charmbracelet/x/cellbuf"
)

type screenRenderer struct {
type cursedRenderer struct {
w io.Writer
scr *cellbuf.Screen
lastFrame *string
Expand All @@ -22,10 +22,10 @@ type screenRenderer struct {
hardTabs bool // whether to use hard tabs to optimize cursor movements
}

var _ renderer = &screenRenderer{}
var _ renderer = &cursedRenderer{}

func newScreenRenderer(w io.Writer, term string, hardTabs bool) (s *screenRenderer) {
s = new(screenRenderer)
func newCursedRenderer(w io.Writer, term string, hardTabs bool) (s *cursedRenderer) {
s = new(cursedRenderer)
s.w = w
s.term = term
s.hardTabs = hardTabs
Expand All @@ -34,22 +34,22 @@ func newScreenRenderer(w io.Writer, term string, hardTabs bool) (s *screenRender
}

// close implements renderer.
func (s *screenRenderer) close() (err error) {
func (s *cursedRenderer) close() (err error) {
s.mu.Lock()
defer s.mu.Unlock()
return s.scr.Close()
}

// flush implements renderer.
func (s *screenRenderer) flush() error {
func (s *cursedRenderer) flush() error {
s.mu.Lock()
defer s.mu.Unlock()
s.scr.Render()
return nil
}

// render implements renderer.
func (s *screenRenderer) render(frame string) {
func (s *cursedRenderer) render(frame string) {
s.mu.Lock()
defer s.mu.Unlock()

Expand All @@ -75,7 +75,7 @@ func (s *screenRenderer) render(frame string) {
}

// reset implements renderer.
func (s *screenRenderer) reset() {
func (s *cursedRenderer) reset() {
s.mu.Lock()
s.scr = cellbuf.NewScreen(s.w, &cellbuf.ScreenOptions{
Term: s.term,
Expand All @@ -91,15 +91,15 @@ func (s *screenRenderer) reset() {
}

// setColorProfile implements renderer.
func (s *screenRenderer) setColorProfile(p colorprofile.Profile) {
func (s *cursedRenderer) setColorProfile(p colorprofile.Profile) {
s.mu.Lock()
s.profile = p
s.scr.SetColorProfile(p)
s.mu.Unlock()
}

// resize implements renderer.
func (s *screenRenderer) resize(w, h int) {
func (s *cursedRenderer) resize(w, h int) {
s.mu.Lock()
s.width, s.height = w, h
if s.altScreen {
Expand All @@ -114,15 +114,15 @@ func (s *screenRenderer) resize(w, h int) {
}

// clearScreen implements renderer.
func (s *screenRenderer) clearScreen() {
func (s *cursedRenderer) clearScreen() {
s.mu.Lock()
s.scr.Clear()
repaint(s)
s.mu.Unlock()
}

// enterAltScreen implements renderer.
func (s *screenRenderer) enterAltScreen() {
func (s *cursedRenderer) enterAltScreen() {
s.mu.Lock()
s.altScreen = true
s.scr.EnterAltScreen()
Expand All @@ -133,7 +133,7 @@ func (s *screenRenderer) enterAltScreen() {
}

// exitAltScreen implements renderer.
func (s *screenRenderer) exitAltScreen() {
func (s *cursedRenderer) exitAltScreen() {
s.mu.Lock()
s.altScreen = false
s.scr.ExitAltScreen()
Expand All @@ -144,41 +144,41 @@ func (s *screenRenderer) exitAltScreen() {
}

// showCursor implements renderer.
func (s *screenRenderer) showCursor() {
func (s *cursedRenderer) showCursor() {
s.mu.Lock()
s.cursorHidden = false
s.scr.ShowCursor()
s.mu.Unlock()
}

// hideCursor implements renderer.
func (s *screenRenderer) hideCursor() {
func (s *cursedRenderer) hideCursor() {
s.mu.Lock()
s.cursorHidden = true
s.scr.HideCursor()
s.mu.Unlock()
}

// insertAbove implements renderer.
func (s *screenRenderer) insertAbove(lines string) {
func (s *cursedRenderer) insertAbove(lines string) {
s.mu.Lock()
s.scr.InsertAbove(lines)
s.mu.Unlock()
}

// moveTo implements renderer.
func (s *screenRenderer) moveTo(x, y int) {
func (s *cursedRenderer) moveTo(x, y int) {
s.mu.Lock()
s.scr.MoveTo(x, y)
s.mu.Unlock()
}

func (s *screenRenderer) repaint() {
func (s *cursedRenderer) repaint() {
s.mu.Lock()
repaint(s)
s.mu.Unlock()
}

func repaint(s *screenRenderer) {
func repaint(s *cursedRenderer) {
s.lastFrame = nil
}
2 changes: 1 addition & 1 deletion tea.go
Original file line number Diff line number Diff line change
Expand Up @@ -764,7 +764,7 @@ func (p *Program) Run() (Model, error) {
}
if p.renderer == nil {
// If no renderer is set use the ferocious one.
p.renderer = newScreenRenderer(p.output, p.getenv("TERM"), p.useHardTabs)
p.renderer = newCursedRenderer(p.output, p.getenv("TERM"), p.useHardTabs)
}

// Get the color profile and send it to the program.
Expand Down
Loading