v0.1.1 true color extracted to a standalone package, lut256 lazy build
This commit is contained in:
+8
-6
@@ -1,12 +1,15 @@
|
||||
package tui
|
||||
|
||||
import "github.com/lixenwraith/terminal"
|
||||
import (
|
||||
"github.com/lixenwraith/color"
|
||||
"github.com/lixenwraith/terminal"
|
||||
)
|
||||
|
||||
// Default spinner frames for Region.Spinner
|
||||
var spinnerFrames = spinnerSets[SpinnerBraille]
|
||||
|
||||
// Text renders text at position, truncates at region edge
|
||||
func (r Region) Text(x, y int, s string, fg, bg terminal.RGB, attr terminal.Attr) {
|
||||
func (r Region) Text(x, y int, s string, fg, bg color.RGB, attr terminal.Attr) {
|
||||
if y < 0 || y >= r.H {
|
||||
return
|
||||
}
|
||||
@@ -40,19 +43,19 @@ func (r Region) TextStyled(x, y int, s string, style Style) {
|
||||
}
|
||||
|
||||
// TextRight renders text right-aligned on row
|
||||
func (r Region) TextRight(y int, s string, fg, bg terminal.RGB, attr terminal.Attr) {
|
||||
func (r Region) TextRight(y int, s string, fg, bg color.RGB, attr terminal.Attr) {
|
||||
x := r.W - RuneLen(s)
|
||||
r.Text(x, y, s, fg, bg, attr)
|
||||
}
|
||||
|
||||
// TextCenter renders text centered on row
|
||||
func (r Region) TextCenter(y int, s string, fg, bg terminal.RGB, attr terminal.Attr) {
|
||||
func (r Region) TextCenter(y int, s string, fg, bg color.RGB, attr terminal.Attr) {
|
||||
x := (r.W - RuneLen(s)) / 2
|
||||
r.Text(x, y, s, fg, bg, attr)
|
||||
}
|
||||
|
||||
// TextBlock renders wrapped text within region bounds, returns number of lines rendered
|
||||
func (r Region) TextBlock(x, y int, text string, fg, bg terminal.RGB, attr terminal.Attr) int {
|
||||
func (r Region) TextBlock(x, y int, text string, fg, bg color.RGB, attr terminal.Attr) int {
|
||||
if x >= r.W || y >= r.H || text == "" {
|
||||
return 0
|
||||
}
|
||||
@@ -81,4 +84,3 @@ func (r Region) TextBlock(x, y int, text string, fg, bg terminal.RGB, attr termi
|
||||
func (r Region) TextBlockStyled(x, y int, text string, style Style) int {
|
||||
return r.TextBlock(x, y, text, style.Fg, style.Bg, style.Attr)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user