Skip to content

Commit

Permalink
refactor(cellbuf): rename Drawable to Screen
Browse files Browse the repository at this point in the history
  • Loading branch information
aymanbagabas committed Nov 8, 2024
1 parent eb0997d commit ed26f2f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
18 changes: 9 additions & 9 deletions cellbuf/screen.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (
// attributes and hyperlink.
type Segment = Cell

// Drawable represents a drawable grid of cells.
type Drawable interface {
// Screen represents a screen grid of cells.
type Screen interface {
// Width returns the width of the grid.
Width() int

Expand All @@ -30,7 +30,7 @@ type Drawable interface {

// Paint writes the given data to the canvas. If rect is not nil, it only
// writes to the rectangle. Otherwise, it writes to the whole canvas.
func Paint(d Drawable, m Method, content string, rect *Rectangle) []int {
func Paint(d Screen, m Method, content string, rect *Rectangle) []int {
if rect == nil {
rect = &Rectangle{0, 0, d.Width(), d.Height()}
}
Expand All @@ -54,7 +54,7 @@ func WithRenderProfile(p colorprofile.Profile) RenderOption {
}

// Render returns a string representation of the grid with ANSI escape sequences.
func Render(d Drawable, opts ...RenderOption) string {
func Render(d Screen, opts ...RenderOption) string {
var opt RenderOptions
for _, o := range opts {
o(&opt)
Expand All @@ -73,15 +73,15 @@ func Render(d Drawable, opts ...RenderOption) string {

// RenderLine returns a string representation of the yth line of the grid along
// with the width of the line.
func RenderLine(d Drawable, n int, opts ...RenderOption) (w int, line string) {
func RenderLine(d Screen, n int, opts ...RenderOption) (w int, line string) {
var opt RenderOptions
for _, o := range opts {
o(&opt)
}
return renderLine(d, n, opt)
}

func renderLine(d Drawable, n int, opt RenderOptions) (w int, line string) {
func renderLine(d Screen, n int, opt RenderOptions) (w int, line string) {
var pen Style
var link Link
var buf bytes.Buffer
Expand Down Expand Up @@ -151,7 +151,7 @@ func renderLine(d Drawable, n int, opt RenderOptions) (w int, line string) {

// Fill fills the canvas with the given cell. If rect is not nil, it only fills
// the rectangle. Otherwise, it fills the whole canvas.
func Fill(d Drawable, c Cell, rect *Rectangle) {
func Fill(d Screen, c Cell, rect *Rectangle) {
if rect == nil {
rect = &Rectangle{0, 0, d.Width(), d.Height()}
}
Expand All @@ -165,12 +165,12 @@ func Fill(d Drawable, c Cell, rect *Rectangle) {

// Clear clears the canvas with space cells. If rect is not nil, it only clears
// the rectangle. Otherwise, it clears the whole canvas.
func Clear(d Drawable, rect *Rectangle) {
func Clear(d Screen, rect *Rectangle) {
Fill(d, spaceCell, rect)
}

// Equal returns whether two grids are equal.
func Equal(a, b Drawable) bool {
func Equal(a, b Screen) bool {
if a.Width() != b.Width() || a.Height() != b.Height() {
return false
}
Expand Down
2 changes: 1 addition & 1 deletion cellbuf/screen_write.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
// setContent writes the given data to the buffer starting from the first cell.
// It accepts both string and []byte data types.
func setContent(
d Drawable,
d Screen,
data string,
method Method,
rect Rectangle,
Expand Down

0 comments on commit ed26f2f

Please sign in to comment.