Compare commits
18 Commits
Author | SHA1 | Date |
---|---|---|
Sasha Koshka | 45278fbb8b | |
Sasha Koshka | ef5a811140 | |
Sasha Koshka | e753fc11ca | |
Sasha Koshka | e4c7dcb2e1 | |
Sasha Koshka | f51f9ae5c5 | |
Sasha Koshka | 0462afdf11 | |
Sasha Koshka | 2fa4cc8da4 | |
Sasha Koshka | 5ea5a302bf | |
Sasha Koshka | 1435c02354 | |
Sasha Koshka | 19895e6049 | |
Sasha Koshka | 73ae475a7d | |
Sasha Koshka | 639e43cfa7 | |
Sasha Koshka | 46b2ca3d43 | |
Sasha Koshka | 3cfe8be7bb | |
Sasha Koshka | 863e415310 | |
Sasha Koshka | 05ddfef584 | |
Sasha Koshka | e60a990d10 | |
Sasha Koshka | a42dd60a16 |
|
@ -49,11 +49,25 @@ func (backend *Backend) drawCells (forceRedraw bool) (areas []image.Rectangle) {
|
|||
|
||||
cell := backend.application.GetForRendering(x, y)
|
||||
content := cell.Rune()
|
||||
style := cell.Style()
|
||||
|
||||
if forceRedraw && content < 32 { continue }
|
||||
if
|
||||
forceRedraw &&
|
||||
content < 32 &&
|
||||
style & (
|
||||
stone.StyleHighlight |
|
||||
stone.StyleUnderline) == 0 {
|
||||
|
||||
continue
|
||||
}
|
||||
|
||||
areas = append(areas, backend.boundsOfCell(x, y))
|
||||
backend.drawRune(x, y, content, cell.Color(), !forceRedraw)
|
||||
backend.drawRune (
|
||||
x, y,
|
||||
content,
|
||||
cell.Color(),
|
||||
cell.Style(),
|
||||
!forceRedraw)
|
||||
}}
|
||||
|
||||
if backend.drawBufferBounds && forceRedraw {
|
||||
|
@ -74,115 +88,205 @@ func (backend *Backend) drawRune (
|
|||
x, y int,
|
||||
character rune,
|
||||
runeColor stone.Color,
|
||||
runeStyle stone.Style,
|
||||
drawBackground bool,
|
||||
) {
|
||||
// TODO: cache these draws as non-transparent buffers with the
|
||||
// application background color as the background. that way, we won't
|
||||
// need to redraw the characters *or* composite them.
|
||||
|
||||
if drawBackground {
|
||||
face := backend.font.normal
|
||||
|
||||
highlight := runeStyle & stone.StyleHighlight > 0
|
||||
bold := runeStyle & stone.StyleBold > 0
|
||||
italic := runeStyle & stone.StyleItalic > 0
|
||||
|
||||
boldTransform := false
|
||||
italicTransform := false
|
||||
|
||||
switch {
|
||||
case bold && italic:
|
||||
if backend.font.boldItalic == nil {
|
||||
switch {
|
||||
case
|
||||
backend.font.bold == nil && backend.font.italic != nil,
|
||||
backend.font.bold != nil && backend.font.italic != nil:
|
||||
|
||||
boldTransform = true
|
||||
face = backend.font.italic
|
||||
case backend.font.italic == nil && backend.font.bold != nil:
|
||||
italicTransform = true
|
||||
face = backend.font.bold
|
||||
default:
|
||||
boldTransform = true
|
||||
italicTransform = true
|
||||
}
|
||||
} else {
|
||||
face = backend.font.boldItalic
|
||||
}
|
||||
case bold:
|
||||
if backend.font.bold == nil {
|
||||
boldTransform = true
|
||||
} else {
|
||||
face = backend.font.bold
|
||||
}
|
||||
case italic:
|
||||
if backend.font.italic == nil {
|
||||
italicTransform = true
|
||||
} else {
|
||||
face = backend.font.italic
|
||||
}
|
||||
}
|
||||
|
||||
var background xgraphics.BGRA
|
||||
var foreground xgraphics.BGRA
|
||||
|
||||
if highlight {
|
||||
background = backend.colors[runeColor]
|
||||
foreground = backend.colors[stone.ColorBackground]
|
||||
} else {
|
||||
background = backend.colors[stone.ColorBackground]
|
||||
foreground = backend.colors[runeColor]
|
||||
}
|
||||
|
||||
if drawBackground || highlight {
|
||||
fillRectangle (
|
||||
&image.Uniform {
|
||||
C: backend.config.Color(stone.ColorBackground),
|
||||
},
|
||||
&image.Uniform { C: background },
|
||||
backend.canvas,
|
||||
backend.boundsOfCell(x, y))
|
||||
}
|
||||
|
||||
if character < 32 { return }
|
||||
|
||||
origin := backend.originOfCell(x, y + 1)
|
||||
destinationRectangle, mask, maskPoint, _, ok := backend.font.face.Glyph (
|
||||
fixed.Point26_6 {
|
||||
X: fixed.I(origin.X),
|
||||
Y: fixed.I(origin.Y),
|
||||
},
|
||||
character)
|
||||
|
||||
if !ok {
|
||||
strokeRectangle (
|
||||
&image.Uniform {
|
||||
C: backend.config.Color(stone.ColorForeground),
|
||||
if character >= 32 {
|
||||
destinationRectangle, mask, maskPoint, _, ok := face.Glyph (
|
||||
fixed.Point26_6 {
|
||||
X: fixed.I(origin.X),
|
||||
Y: fixed.I(origin.Y),
|
||||
},
|
||||
backend.canvas,
|
||||
backend.boundsOfCell(x, y))
|
||||
return
|
||||
character)
|
||||
|
||||
if !ok {
|
||||
strokeRectangle (
|
||||
&image.Uniform { C: foreground },
|
||||
backend.canvas,
|
||||
backend.boundsOfCell(x, y))
|
||||
return
|
||||
}
|
||||
|
||||
if backend.drawCellBounds {
|
||||
strokeRectangle (
|
||||
&image.Uniform { C: foreground },
|
||||
backend.canvas,
|
||||
backend.boundsOfCell(x, y))
|
||||
}
|
||||
|
||||
// alphaMask, isAlpha := mask.(*image.Alpha)
|
||||
// if isAlpha {
|
||||
// backend.sprayRuneMaskAlpha (
|
||||
// alphaMask, destinationRectangle,
|
||||
// maskPoint, foreground, background)
|
||||
// } else {
|
||||
backend.sprayRuneMask (
|
||||
mask, destinationRectangle,
|
||||
maskPoint, foreground, background,
|
||||
italicTransform, boldTransform)
|
||||
// }
|
||||
}
|
||||
|
||||
if backend.drawCellBounds {
|
||||
strokeRectangle (
|
||||
&image.Uniform {
|
||||
C: backend.config.Color(stone.ColorForeground),
|
||||
},
|
||||
backend.canvas,
|
||||
backend.boundsOfCell(x, y))
|
||||
}
|
||||
|
||||
// cue a series of pointless optimizations
|
||||
alphaMask, isAlpha := mask.(*image.Alpha)
|
||||
if isAlpha {
|
||||
backend.sprayRuneMaskAlpha (
|
||||
alphaMask, destinationRectangle,
|
||||
maskPoint, backend.colors[runeColor])
|
||||
} else {
|
||||
backend.sprayRuneMask (
|
||||
mask, destinationRectangle,
|
||||
maskPoint, backend.colors[runeColor])
|
||||
// underline
|
||||
if runeStyle & stone.StyleUnderline > 0 {
|
||||
maxX := origin.X + backend.metrics.cellWidth
|
||||
y :=
|
||||
origin.Y -
|
||||
backend.metrics.descent
|
||||
for x := origin.X; x < maxX; x ++ {
|
||||
backend.canvas.SetBGRA(x, y, foreground)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (backend *Backend) sprayRuneMask (
|
||||
mask image.Image,
|
||||
bounds image.Rectangle,
|
||||
maskPoint image.Point,
|
||||
fill xgraphics.BGRA,
|
||||
mask image.Image,
|
||||
bounds image.Rectangle,
|
||||
maskPoint image.Point,
|
||||
fill xgraphics.BGRA,
|
||||
background xgraphics.BGRA,
|
||||
italic bool,
|
||||
bold bool,
|
||||
) {
|
||||
maxX := bounds.Max.X - bounds.Min.X
|
||||
maxY := bounds.Max.Y - bounds.Min.Y
|
||||
|
||||
for y := 0; y < maxY; y ++ {
|
||||
for x := 0; x < maxX; x ++ {
|
||||
_, _, _,
|
||||
alpha := mask.At(x + maskPoint.X, y + maskPoint.Y).RGBA()
|
||||
backend.canvas.SetBGRA (
|
||||
x + bounds.Min.X,
|
||||
y + bounds.Min.Y - backend.metrics.descent,
|
||||
xgraphics.BlendBGRA (
|
||||
backend.colors[stone.ColorBackground],
|
||||
xgraphics.BGRA {
|
||||
R: fill.R,
|
||||
G: fill.G,
|
||||
B: fill.B,
|
||||
A: uint8(alpha >> 8),
|
||||
}))
|
||||
}}
|
||||
var previousAlpha uint32
|
||||
offset := 0
|
||||
if italic {
|
||||
offset = (maxY - y) / 4
|
||||
}
|
||||
for x := 0; x < maxX; x ++ {
|
||||
_, _, _,
|
||||
alpha := mask.At(x + maskPoint.X, y + maskPoint.Y).RGBA()
|
||||
currentAlpha := alpha
|
||||
if bold && previousAlpha > alpha {
|
||||
alpha = previousAlpha
|
||||
}
|
||||
backend.canvas.SetBGRA (
|
||||
x + bounds.Min.X + offset,
|
||||
y + bounds.Min.Y - backend.metrics.descent,
|
||||
xgraphics.BlendBGRA (
|
||||
background,
|
||||
xgraphics.BGRA {
|
||||
R: fill.R,
|
||||
G: fill.G,
|
||||
B: fill.B,
|
||||
A: uint8(alpha >> 8),
|
||||
}))
|
||||
previousAlpha = currentAlpha
|
||||
}
|
||||
|
||||
if bold {
|
||||
backend.canvas.SetBGRA (
|
||||
bounds.Max.X + offset,
|
||||
y + bounds.Min.Y - backend.metrics.descent,
|
||||
xgraphics.BlendBGRA (
|
||||
background,
|
||||
xgraphics.BGRA {
|
||||
R: fill.R,
|
||||
G: fill.G,
|
||||
B: fill.B,
|
||||
A: uint8(previousAlpha >> 8),
|
||||
}))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (backend *Backend) sprayRuneMaskAlpha (
|
||||
mask *image.Alpha,
|
||||
bounds image.Rectangle,
|
||||
maskPoint image.Point,
|
||||
fill xgraphics.BGRA,
|
||||
) {
|
||||
maxX := bounds.Max.X - bounds.Min.X
|
||||
maxY := bounds.Max.Y - bounds.Min.Y
|
||||
|
||||
for y := 0; y < maxY; y ++ {
|
||||
for x := 0; x < maxX; x ++ {
|
||||
alpha := mask.AlphaAt(x + maskPoint.X, y + maskPoint.Y).A
|
||||
backend.canvas.SetBGRA (
|
||||
x + bounds.Min.X,
|
||||
y + bounds.Min.Y - backend.metrics.descent,
|
||||
xgraphics.BlendBGRA (
|
||||
backend.colors[stone.ColorBackground],
|
||||
xgraphics.BGRA {
|
||||
R: fill.R,
|
||||
G: fill.G,
|
||||
B: fill.B,
|
||||
A: alpha,
|
||||
}))
|
||||
}}
|
||||
}
|
||||
// func (backend *Backend) sprayRuneMaskAlpha (
|
||||
// mask *image.Alpha,
|
||||
// bounds image.Rectangle,
|
||||
// maskPoint image.Point,
|
||||
// fill xgraphics.BGRA,
|
||||
// background xgraphics.BGRA,
|
||||
// ) {
|
||||
// maxX := bounds.Max.X - bounds.Min.X
|
||||
// maxY := bounds.Max.Y - bounds.Min.Y
|
||||
//
|
||||
// for y := 0; y < maxY; y ++ {
|
||||
// for x := 0; x < maxX; x ++ {
|
||||
// alpha := mask.AlphaAt(x + maskPoint.X, y + maskPoint.Y).A
|
||||
// backend.canvas.SetBGRA (
|
||||
// x + bounds.Min.X,
|
||||
// y + bounds.Min.Y - backend.metrics.descent,
|
||||
// xgraphics.BlendBGRA (
|
||||
// background,
|
||||
// xgraphics.BGRA {
|
||||
// R: fill.R,
|
||||
// G: fill.G,
|
||||
// B: fill.B,
|
||||
// A: alpha,
|
||||
// }))
|
||||
// }}
|
||||
// }
|
||||
|
||||
func fillRectangle (
|
||||
source image.Image,
|
||||
|
|
|
@ -32,11 +32,20 @@ func factory (
|
|||
}
|
||||
|
||||
// load font
|
||||
backend.font.face = findAndLoadFont (
|
||||
backend.config.FontName(),
|
||||
backend.font.normal = findAndLoadFont (
|
||||
backend.config.FontNameNormal(),
|
||||
float64(backend.config.FontSize()))
|
||||
if backend.font.face == nil {
|
||||
backend.font.face = basicfont.Face7x13
|
||||
backend.font.bold = findAndLoadFont (
|
||||
backend.config.FontNameBold(),
|
||||
float64(backend.config.FontSize()))
|
||||
backend.font.italic = findAndLoadFont (
|
||||
backend.config.FontNameItalic(),
|
||||
float64(backend.config.FontSize()))
|
||||
backend.font.boldItalic = findAndLoadFont (
|
||||
backend.config.FontNameBoldItalic(),
|
||||
float64(backend.config.FontSize()))
|
||||
if backend.font.normal == nil {
|
||||
backend.font.normal = basicfont.Face7x13
|
||||
}
|
||||
|
||||
// pre-calculate colors
|
||||
|
@ -56,8 +65,8 @@ func factory (
|
|||
}
|
||||
|
||||
// calculate metrics
|
||||
metrics := backend.font.face.Metrics()
|
||||
glyphAdvance, _ := backend.font.face.GlyphAdvance('M')
|
||||
metrics := backend.font.normal.Metrics()
|
||||
glyphAdvance, _ := backend.font.normal.GlyphAdvance('M')
|
||||
backend.metrics.cellWidth = glyphAdvance.Round()
|
||||
backend.metrics.cellHeight = metrics.Height.Round()
|
||||
backend.metrics.descent = metrics.Descent.Round()
|
||||
|
|
|
@ -27,7 +27,10 @@ type Backend struct {
|
|||
lock sync.Mutex
|
||||
|
||||
font struct {
|
||||
face font.Face
|
||||
normal font.Face
|
||||
bold font.Face
|
||||
italic font.Face
|
||||
boldItalic font.Face
|
||||
}
|
||||
|
||||
colors [8]xgraphics.BGRA
|
||||
|
|
22
buffer.go
22
buffer.go
|
@ -21,11 +21,11 @@ const (
|
|||
type Style uint8
|
||||
|
||||
const (
|
||||
StyleNormal Style = iota
|
||||
StyleBold Style = iota >> 1
|
||||
StyleItalic
|
||||
StyleUnderline
|
||||
StyleHighlight
|
||||
StyleNormal Style = 0
|
||||
StyleBold Style = 1
|
||||
StyleItalic Style = 2
|
||||
StyleUnderline Style = 4
|
||||
StyleHighlight Style = 8
|
||||
StyleBoldItalic Style = StyleBold | StyleItalic
|
||||
)
|
||||
|
||||
|
@ -44,7 +44,7 @@ func (cell Cell) Color () (color Color) {
|
|||
}
|
||||
|
||||
// Style returns the styling information associated with the cell
|
||||
func (cell Cell) Style (style Style) {
|
||||
func (cell Cell) Style () (style Style) {
|
||||
style = cell.style
|
||||
return
|
||||
}
|
||||
|
@ -192,9 +192,13 @@ func (buffer *DamageBuffer) Write (bytes []byte) (bytesWritten int, err error) {
|
|||
bytesWritten = len(bytes)
|
||||
|
||||
for _, character := range text {
|
||||
buffer.setRune(buffer.dot.x, buffer.dot.y, character)
|
||||
buffer.dot.x ++
|
||||
if buffer.dot.x > buffer.width { break }
|
||||
if character == '\n' {
|
||||
buffer.dot.x = 0
|
||||
buffer.dot.y ++
|
||||
} else {
|
||||
buffer.setRune(buffer.dot.x, buffer.dot.y, character)
|
||||
buffer.dot.x ++
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
|
|
236
config.go
236
config.go
|
@ -1,171 +1,139 @@
|
|||
package stone
|
||||
|
||||
import "os"
|
||||
import "bufio"
|
||||
import "strings"
|
||||
import "strconv"
|
||||
import "image/color"
|
||||
import "path/filepath"
|
||||
|
||||
// Config stores configuration parameters. Backends only should honor parameters
|
||||
// that they can support.
|
||||
import "git.tebibyte.media/sashakoshka/stone/config"
|
||||
|
||||
// Config stores global, read-only configuration parameters that apply to all
|
||||
// applications. Backends only should honor parameters that they can support.
|
||||
type Config struct {
|
||||
private config.Config
|
||||
colors [8]color.Color
|
||||
padding int
|
||||
center bool
|
||||
fontSize int
|
||||
fontName string
|
||||
fontNameNormal string
|
||||
fontNameBold string
|
||||
fontNameItalic string
|
||||
fontNameBoldItalic string
|
||||
}
|
||||
|
||||
// Color returns the color value at the specified index.
|
||||
func (config *Config) Color (index Color) (value color.Color) {
|
||||
value = config.colors[index]
|
||||
func (public *Config) Color (index Color) (value color.Color) {
|
||||
value = public.colors[index]
|
||||
return
|
||||
}
|
||||
|
||||
// Padding specifies how many cell's worth of padding should be on all sides of
|
||||
// the buffer.
|
||||
func (config *Config) Padding () (padding int) {
|
||||
padding = config.padding
|
||||
func (public *Config) Padding () (padding int) {
|
||||
padding = public.padding
|
||||
return
|
||||
}
|
||||
|
||||
// Center returns whether the buffer should be displayed in the center of the
|
||||
// window like in kitty, or aligned to one corner like in gnome-terminal.
|
||||
func (config *Config) Center () (center bool) {
|
||||
center = config.center
|
||||
func (public *Config) Center () (center bool) {
|
||||
center = public.center
|
||||
return
|
||||
}
|
||||
|
||||
// FontSize specifies how big the font should be.
|
||||
func (config *Config) FontSize () (fontSize int) {
|
||||
fontSize = config.fontSize
|
||||
func (public *Config) FontSize () (fontSize int) {
|
||||
fontSize = public.fontSize
|
||||
return
|
||||
}
|
||||
|
||||
// FontName specifies the name of the font to use.
|
||||
func (config *Config) FontName () (fontName string) {
|
||||
fontName = config.fontName
|
||||
// FontNameNormal specifies the name of the font to use for normal text.
|
||||
func (public *Config) FontNameNormal () (fontName string) {
|
||||
fontName = public.fontNameNormal
|
||||
return
|
||||
}
|
||||
|
||||
func (config *Config) load () {
|
||||
config.colors = [8]color.Color {
|
||||
// background
|
||||
color.RGBA { R: 0, G: 0, B: 0, A: 0 },
|
||||
// foreground
|
||||
color.RGBA { R: 0xFF, G: 0xFF, B: 0xFF, A: 0xFF },
|
||||
// dim
|
||||
color.RGBA { R: 0x80, G: 0x80, B: 0x80, A: 0xFF },
|
||||
// red
|
||||
color.RGBA { R: 0xFF, G: 0x00, B: 0x00, A: 0xFF },
|
||||
// yellow
|
||||
color.RGBA { R: 0xFF, G: 0xFF, B: 0x00, A: 0xFF },
|
||||
// green
|
||||
color.RGBA { R: 0x00, G: 0xFF, B: 0x00, A: 0xFF },
|
||||
// blue
|
||||
color.RGBA { R: 0x00, G: 0x80, B: 0xFF, A: 0xFF },
|
||||
// purple
|
||||
color.RGBA { R: 0x80, G: 0x40, B: 0xFF, A: 0xFF },
|
||||
// FontNameBold specifies the name of the font to use for bold text.
|
||||
func (public *Config) FontNameBold () (fontName string) {
|
||||
fontName = public.fontNameBold
|
||||
return
|
||||
}
|
||||
|
||||
// FontName specifies the name of the font to use for text.
|
||||
func (public *Config) FontNameItalic () (fontName string) {
|
||||
fontName = public.fontNameItalic
|
||||
return
|
||||
}
|
||||
|
||||
// FontName specifies the name of the font to use for text.
|
||||
func (public *Config) FontNameBoldItalic () (fontName string) {
|
||||
fontName = public.fontNameBoldItalic
|
||||
return
|
||||
}
|
||||
|
||||
func (public *Config) load () {
|
||||
public.private = config.Config {
|
||||
LegalParameters: map[string] config.Type {
|
||||
"fontNormal": config.TypeString,
|
||||
"fontBold": config.TypeString,
|
||||
"fontItalic": config.TypeString,
|
||||
"fontBoldItalic": config.TypeString,
|
||||
"fontSize": config.TypeInteger,
|
||||
"padding": config.TypeInteger,
|
||||
"center": config.TypeBoolean,
|
||||
"colorBackground": config.TypeColor,
|
||||
"colorForeground": config.TypeColor,
|
||||
"colorDim": config.TypeColor,
|
||||
"colorRed": config.TypeColor,
|
||||
"colorYellow": config.TypeColor,
|
||||
"colorGreen": config.TypeColor,
|
||||
"colorBlue": config.TypeColor,
|
||||
"colorPurple": config.TypeColor,
|
||||
},
|
||||
|
||||
Parameters: map[string] any {
|
||||
"fontNormal": "",
|
||||
"fontBold": "",
|
||||
"fontItalic": "",
|
||||
"fontBoldItalic": "",
|
||||
"fontSize": 11,
|
||||
"padding": 2,
|
||||
"center": false,
|
||||
"colorBackground":
|
||||
color.RGBA { R: 0, G: 0, B: 0, A: 0 },
|
||||
"colorForeground":
|
||||
color.RGBA { R: 0xFF, G: 0xFF, B: 0xFF, A: 0xFF },
|
||||
"colorDim":
|
||||
color.RGBA { R: 0x80, G: 0x80, B: 0x80, A: 0xFF },
|
||||
"colorRed":
|
||||
color.RGBA { R: 0xFF, G: 0x00, B: 0x00, A: 0xFF },
|
||||
"colorYellow":
|
||||
color.RGBA { R: 0xFF, G: 0xFF, B: 0x00, A: 0xFF },
|
||||
"colorGreen":
|
||||
color.RGBA { R: 0x00, G: 0xFF, B: 0x00, A: 0xFF },
|
||||
"colorBlue":
|
||||
color.RGBA { R: 0x00, G: 0x80, B: 0xFF, A: 0xFF },
|
||||
"colorPurple":
|
||||
color.RGBA { R: 0x80, G: 0x40, B: 0xFF, A: 0xFF },
|
||||
},
|
||||
}
|
||||
config.fontName = ""
|
||||
config.fontSize = 11
|
||||
config.padding = 2
|
||||
|
||||
config.loadFile("/etc/stone/stone.conf")
|
||||
homeDirectory, err := os.UserHomeDir()
|
||||
if err != nil { return }
|
||||
config.loadFile(filepath.Join(homeDirectory, "/.config/stone/stone.conf"))
|
||||
public.private.Load("stone")
|
||||
params := public.private.Parameters
|
||||
|
||||
public.fontNameNormal = params["fontNormal"].(string)
|
||||
public.fontNameBold = params["fontBold"].(string)
|
||||
public.fontNameItalic = params["fontItalic"].(string)
|
||||
public.fontNameBoldItalic = params["fontBoldItalic"].(string)
|
||||
public.fontSize = params["fontSize"].(int)
|
||||
public.padding = params["padding"].(int)
|
||||
public.center = params["center"].(bool)
|
||||
|
||||
public.colors[ColorBackground] = params["colorBackground"].(color.RGBA)
|
||||
public.colors[ColorForeground] = params["colorForeground"].(color.RGBA)
|
||||
public.colors[ColorDim] = params["colorDim" ].(color.RGBA)
|
||||
public.colors[ColorRed] = params["colorRed" ].(color.RGBA)
|
||||
public.colors[ColorYellow] = params["colorYellow" ].(color.RGBA)
|
||||
public.colors[ColorGreen] = params["colorGreen" ].(color.RGBA)
|
||||
public.colors[ColorBlue] = params["colorBlue" ].(color.RGBA)
|
||||
public.colors[ColorPurple] = params["colorPurple" ].(color.RGBA)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (config *Config) loadFile (path string) {
|
||||
file, err := os.Open(path)
|
||||
if err != nil { return }
|
||||
|
||||
scanner := bufio.NewScanner(file)
|
||||
for scanner.Scan() {
|
||||
line := strings.TrimSpace(scanner.Text())
|
||||
|
||||
if len(line) == 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
if line[0] == '#' {
|
||||
continue
|
||||
}
|
||||
|
||||
key, value, found := strings.Cut(scanner.Text(), ":")
|
||||
if !found {
|
||||
println (
|
||||
"config: error in file", path +
|
||||
": key-value separator missing")
|
||||
println(scanner.Text())
|
||||
continue
|
||||
}
|
||||
key = strings.TrimSpace(key)
|
||||
value = strings.TrimSpace(value)
|
||||
|
||||
var valueInt int
|
||||
var valueColor color.Color
|
||||
var valueBoolean bool
|
||||
|
||||
if value == "true" {
|
||||
valueBoolean = true
|
||||
}
|
||||
|
||||
if value[0] == '#' {
|
||||
if len(value) != 7 {
|
||||
println (
|
||||
"config: error in file", path +
|
||||
": malformed color literal")
|
||||
continue
|
||||
}
|
||||
|
||||
colorInt, err := strconv.ParseUint(value[1:7], 16, 24)
|
||||
if err != nil {
|
||||
println (
|
||||
"config: error in file", path +
|
||||
": malformed color literal")
|
||||
continue
|
||||
}
|
||||
|
||||
valueColor = color.RGBA {
|
||||
R: uint8(colorInt >> 16),
|
||||
G: uint8(colorInt >> 8),
|
||||
B: uint8(colorInt),
|
||||
A: 0xFF,
|
||||
}
|
||||
} else {
|
||||
valueInt, _ = strconv.Atoi(value)
|
||||
}
|
||||
|
||||
switch key {
|
||||
case "fontNormal":
|
||||
config.fontName = value
|
||||
case "fontSize":
|
||||
config.fontSize = valueInt
|
||||
case "padding":
|
||||
config.padding = valueInt
|
||||
case "center":
|
||||
config.center = valueBoolean
|
||||
case "colorBackground":
|
||||
config.colors[ColorBackground] = valueColor
|
||||
case "colorForeground":
|
||||
config.colors[ColorForeground] = valueColor
|
||||
case "colorDim":
|
||||
config.colors[ColorDim] = valueColor
|
||||
case "colorRed":
|
||||
config.colors[ColorRed] = valueColor
|
||||
case "colorYellow":
|
||||
config.colors[ColorYellow] = valueColor
|
||||
case "colorGreen":
|
||||
config.colors[ColorGreen] = valueColor
|
||||
case "colorBlue":
|
||||
config.colors[ColorBlue] = valueColor
|
||||
case "colorPurple":
|
||||
config.colors[ColorPurple] = valueColor
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,324 @@
|
|||
package config
|
||||
|
||||
import "io"
|
||||
import "os"
|
||||
import "fmt"
|
||||
import "sort"
|
||||
import "bufio"
|
||||
import "strings"
|
||||
import "strconv"
|
||||
import "image/color"
|
||||
import "path/filepath"
|
||||
|
||||
// when making changes to this file, look at
|
||||
// https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
|
||||
|
||||
// Error represents an error that can be returned by functions or methods in
|
||||
// this module.
|
||||
type Error int
|
||||
|
||||
const (
|
||||
// ErrorIllegalName is thrown when an application name contains illegal
|
||||
// characters such as a slash.
|
||||
ErrorIllegalName Error = iota
|
||||
|
||||
// ErrorNoSeparator is thrown when a configuration file has an
|
||||
// incorrectly formatted key-value pair.
|
||||
ErrorNoSeparator
|
||||
|
||||
// ErrorUnknownParameter is thrown when an unknown key is encountered in
|
||||
// a configuration file.
|
||||
ErrorUnknownParameter
|
||||
|
||||
// ErrorWrongColorLength is thrown when a configuration file has a color
|
||||
// literal with a total length unequal to 7.
|
||||
ErrorWrongColorLength
|
||||
|
||||
// ErrorMalformedColorLiteral is thrown when a configuration file has an
|
||||
// improperly formatted color literal, or a color literal was expected
|
||||
// and something else was encountered.
|
||||
ErrorMalformedColorLiteral
|
||||
|
||||
// ErrorMalformedIntegerLiteral is thrown when a configuration file has
|
||||
// an improperly formatted integer literal, or an integer literal was
|
||||
// expected and something else was encountered.
|
||||
ErrorMalformedIntegerLiteral
|
||||
|
||||
// ErrorMalformedFloatLiteral is thrown when a configuration file has
|
||||
// an improperly formatted float literal, or a float literal was
|
||||
// expected and something else was encountered.
|
||||
ErrorMalformedFloatLiteral
|
||||
)
|
||||
|
||||
// Error returns a description of the error.
|
||||
func (err Error) Error () (description string) {
|
||||
switch err {
|
||||
case ErrorIllegalName:
|
||||
description = "name contains illegal characters"
|
||||
case ErrorNoSeparator:
|
||||
description = "key:value pair has no separator"
|
||||
case ErrorUnknownParameter:
|
||||
description = "unknown parameter"
|
||||
case ErrorWrongColorLength:
|
||||
description = "color literal has the wrong length"
|
||||
case ErrorMalformedColorLiteral:
|
||||
description = "malformed color literal"
|
||||
case ErrorMalformedIntegerLiteral:
|
||||
description = "malformed integer literal"
|
||||
case ErrorMalformedFloatLiteral:
|
||||
description = "malformed float literal"
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// Type represents the data type of a configuration parameter.
|
||||
type Type int
|
||||
|
||||
const (
|
||||
// string
|
||||
// It is just a basic string with inner whitespace preserved. No quotes
|
||||
// should be used in the file.
|
||||
TypeString Type = iota
|
||||
|
||||
// Type: image/color.RGBA
|
||||
// Represented as a 24 bit hexadecimal number (case insensitive)
|
||||
// preceded with a # sign where the first two digits represent the red
|
||||
// channel, the middle two digits represent the green channel, and the
|
||||
// last two digits represent the blue channel.
|
||||
TypeColor
|
||||
|
||||
// Type: int
|
||||
// An integer literal, like 123456789
|
||||
TypeInteger
|
||||
|
||||
// Type: float64
|
||||
// A floating point literal, like 1234.56789
|
||||
TypeFloat
|
||||
|
||||
// Type: bool
|
||||
// Values true, yes, on, and 1 are all truthy (case insensitive) and
|
||||
// anything else is falsy.
|
||||
TypeBoolean
|
||||
)
|
||||
|
||||
// Config holds a list of configuration parameters.
|
||||
type Config struct {
|
||||
// LegalParameters holds the names and types of all parameters that can
|
||||
// be parsed. If the parser runs into a parameter that is not listed
|
||||
// here, it will print out an error message and keep on parsing.
|
||||
LegalParameters map[string] Type
|
||||
|
||||
// Parameters holds the names and values of all parsed parameters. If a
|
||||
// value is non-nil, it can be safely type asserted into whatever type
|
||||
// was requested.
|
||||
Parameters map[string] any
|
||||
}
|
||||
|
||||
// Load loads and parses the files /etc/xdg/<name>/<name>.conf and
|
||||
// <home>/.config/<name>/<name>.conf, unless the corresponding XDG environment
|
||||
// variables are set - then it uses those.
|
||||
func (config *Config) Load (name string) (err error) {
|
||||
if nameIsIllegal(name) {
|
||||
err = ErrorIllegalName
|
||||
return
|
||||
}
|
||||
|
||||
for _, directory := range configDirs {
|
||||
path := filepath.Join(directory, name, name + ".conf")
|
||||
|
||||
file, fileErr := os.Open(path)
|
||||
if fileErr != nil { continue }
|
||||
parseErr := config.LoadFrom(file)
|
||||
defer file.Close()
|
||||
|
||||
if parseErr != nil {
|
||||
println (
|
||||
"config: error in file", path +
|
||||
":", parseErr.Error())
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// LoadFrom parses a configuration file from an io.Reader. Configuration files
|
||||
// are divided into lines where each line may be blank, a comment, or a
|
||||
// key-value pair. If the line is blank or begins with a # character, it is
|
||||
// ignored. Else, the line must have a key and a value separated by a colon.
|
||||
// Before they are processed, leading and trailing whitespace is trimmed from
|
||||
// the key and the value. Keys are case sensitive.
|
||||
func (config *Config) LoadFrom (reader io.Reader) (err error) {
|
||||
if config.LegalParameters == nil {
|
||||
config.LegalParameters = make(map[string] Type)
|
||||
}
|
||||
|
||||
if config.Parameters == nil {
|
||||
config.Parameters = make(map[string] any)
|
||||
}
|
||||
|
||||
scanner := bufio.NewScanner(reader)
|
||||
for scanner.Scan() {
|
||||
line := strings.TrimSpace(scanner.Text())
|
||||
|
||||
if len(line) == 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
if line[0] == '#' {
|
||||
continue
|
||||
}
|
||||
|
||||
key, value, found := strings.Cut(scanner.Text(), ":")
|
||||
if !found {
|
||||
err = ErrorNoSeparator
|
||||
return
|
||||
}
|
||||
key = strings.TrimSpace(key)
|
||||
value = strings.TrimSpace(value)
|
||||
|
||||
what, isKnown := config.LegalParameters[key]
|
||||
if !isKnown {
|
||||
err = ErrorUnknownParameter
|
||||
return
|
||||
}
|
||||
|
||||
switch what {
|
||||
case TypeString:
|
||||
config.Parameters[key] = value
|
||||
|
||||
case TypeColor:
|
||||
var valueColor color.Color
|
||||
valueColor, err = parseColor(value)
|
||||
if err != nil { return }
|
||||
config.Parameters[key] = valueColor
|
||||
|
||||
case TypeInteger:
|
||||
var valueInt int
|
||||
valueInt, err = strconv.Atoi(value)
|
||||
if err != nil {
|
||||
err = ErrorMalformedIntegerLiteral
|
||||
return
|
||||
}
|
||||
config.Parameters[key] = valueInt
|
||||
|
||||
case TypeFloat:
|
||||
var valueFloat float64
|
||||
valueFloat, err = strconv.ParseFloat(value, 64)
|
||||
if err != nil {
|
||||
err = ErrorMalformedFloatLiteral
|
||||
return
|
||||
}
|
||||
config.Parameters[key] = valueFloat
|
||||
|
||||
case TypeBoolean:
|
||||
value = strings.ToLower(value)
|
||||
truthy :=
|
||||
value == "true" ||
|
||||
value == "yes" ||
|
||||
value == "on" ||
|
||||
value == "1"
|
||||
config.Parameters[key] = truthy
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// Save overwrites the main user configuration file, which is located at
|
||||
// <home>/.config/<name>/<name>.conf unless $XDG_CONFIG_HOME has been set, in
|
||||
// which case the value of that variable is used instead.
|
||||
func (config *Config) Save (name string) (err error) {
|
||||
if nameIsIllegal(name) {
|
||||
err = ErrorIllegalName
|
||||
return
|
||||
}
|
||||
|
||||
err = os.MkdirAll(configHome, 0755)
|
||||
if err != nil { return }
|
||||
|
||||
file, err := os.OpenFile (
|
||||
filepath.Join(configHome, name, name + ".conf"),
|
||||
os.O_WRONLY | os.O_CREATE | os.O_TRUNC, 0744)
|
||||
if err != nil { return }
|
||||
defer file.Close()
|
||||
|
||||
err = config.SaveTo(file)
|
||||
if err != nil { return }
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// SaveTo writes the configuration data to the specified io.Writer. Keys are
|
||||
// alphabetically sorted.
|
||||
func (config *Config) SaveTo (writer io.Writer) (err error) {
|
||||
keys := make([]string, len(config.Parameters))
|
||||
index := 0
|
||||
for key, _ := range config.Parameters {
|
||||
keys[index] = key
|
||||
index ++
|
||||
}
|
||||
sort.Strings(keys)
|
||||
|
||||
for _, key := range keys {
|
||||
value := config.Parameters[key]
|
||||
switch value.(type) {
|
||||
case string:
|
||||
fmt.Fprintf(writer,"%s: %s\n", key, value.(string))
|
||||
|
||||
case color.RGBA:
|
||||
colorValue := value.(color.RGBA)
|
||||
colorInt :=
|
||||
uint64(colorValue.R) << 16 |
|
||||
uint64(colorValue.G) << 8 |
|
||||
uint64(colorValue.B)
|
||||
fmt.Fprintf(writer,"%s: #%06x\n", key, colorInt)
|
||||
|
||||
case int:
|
||||
fmt.Fprintf(writer,"%s: %d\n", key, value.(int))
|
||||
|
||||
case float64:
|
||||
fmt.Fprintf(writer,"%s: %f\n", key, value.(float64))
|
||||
|
||||
case bool:
|
||||
fmt.Fprintf(writer,"%s: %t\n", key, value.(bool))
|
||||
default:
|
||||
fmt.Fprintf(writer,"# %s: unknown type\n", key)
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func parseColor (value string) (valueColor color.Color, err error) {
|
||||
if value[0] == '#' {
|
||||
if len(value) != 7 {
|
||||
err = ErrorWrongColorLength
|
||||
return
|
||||
}
|
||||
|
||||
var colorInt uint64
|
||||
colorInt, err = strconv.ParseUint(value[1:7], 16, 24)
|
||||
if err != nil {
|
||||
err = ErrorMalformedColorLiteral
|
||||
return
|
||||
}
|
||||
|
||||
valueColor = color.RGBA {
|
||||
R: uint8(colorInt >> 16),
|
||||
G: uint8(colorInt >> 8),
|
||||
B: uint8(colorInt),
|
||||
A: 0xFF,
|
||||
}
|
||||
} else {
|
||||
err = ErrorMalformedColorLiteral
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func nameIsIllegal (name string) (legal bool) {
|
||||
legal = strings.ContainsAny(name, "/\\|:.%")
|
||||
return
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
package config
|
||||
|
||||
import "os"
|
||||
import "strings"
|
||||
import "path/filepath"
|
||||
|
||||
var homeDirectory string
|
||||
var configHome string
|
||||
var configDirs []string
|
||||
var dataHome string
|
||||
var cacheHome string
|
||||
|
||||
func init () {
|
||||
var err error
|
||||
homeDirectory, err = os.UserHomeDir()
|
||||
if err != nil {
|
||||
panic("could not get user home directory: " + err.Error())
|
||||
}
|
||||
|
||||
configHome = os.Getenv("XDG_CONFIG_HOME")
|
||||
if configHome == "" {
|
||||
configHome = filepath.Join(homeDirectory, "/.config/")
|
||||
}
|
||||
|
||||
configDirsString := os.Getenv("XDG_CONFIG_DIRS")
|
||||
if configDirsString == "" {
|
||||
configDirsString = "/etc/xdg/"
|
||||
}
|
||||
|
||||
configDirs = append(strings.Split(configDirsString, ":"), configHome)
|
||||
|
||||
dataHome = os.Getenv("XDG_DATA_HOME")
|
||||
if dataHome == "" {
|
||||
dataHome = filepath.Join(homeDirectory, "/.local/share/")
|
||||
}
|
||||
|
||||
cacheHome = os.Getenv("XDG_CACHE_HOME")
|
||||
if cacheHome == "" {
|
||||
cacheHome = filepath.Join(homeDirectory, "/.cache/")
|
||||
}
|
||||
}
|
||||
|
||||
// DataHome returns the path to the directory where user data should be stored.
|
||||
func DataHome (name string) (home string) {
|
||||
home = filepath.Join(dataHome, name)
|
||||
return
|
||||
}
|
||||
|
||||
// CacheHome returns the path to the directory where cache files should be
|
||||
// stored.
|
||||
func CacheHome (name string) (home string) {
|
||||
home = filepath.Join(cacheHome, name)
|
||||
return
|
||||
}
|
|
@ -0,0 +1,106 @@
|
|||
package main
|
||||
|
||||
import "os"
|
||||
import "image"
|
||||
import "image/color"
|
||||
import _ "image/png"
|
||||
import "git.tebibyte.media/sashakoshka/stone"
|
||||
import "git.tebibyte.media/sashakoshka/stone/config"
|
||||
import _ "git.tebibyte.media/sashakoshka/stone/backends/x"
|
||||
|
||||
var application = &stone.Application { }
|
||||
var inputState struct {
|
||||
x int
|
||||
y int
|
||||
}
|
||||
var globalConfig config.Config
|
||||
|
||||
func main () {
|
||||
application.SetTitle("configuration viewer")
|
||||
application.SetSize(32, 16)
|
||||
|
||||
iconFile16, err := os.Open("assets/scaffold16.png")
|
||||
if err != nil { panic(err) }
|
||||
icon16, _, err := image.Decode(iconFile16)
|
||||
if err != nil { panic(err) }
|
||||
iconFile16.Close()
|
||||
iconFile32, err := os.Open("assets/scaffold32.png")
|
||||
if err != nil { panic(err) }
|
||||
icon32, _, err := image.Decode(iconFile32)
|
||||
if err != nil { panic(err) }
|
||||
iconFile16.Close()
|
||||
|
||||
application.SetIcon([]image.Image { icon16, icon32 })
|
||||
|
||||
application.OnPress(onPress)
|
||||
application.OnRelease(onRelease)
|
||||
application.OnMouseMove(onMouseMove)
|
||||
application.OnStart(onStart)
|
||||
application.OnResize(redraw)
|
||||
|
||||
err = application.Run()
|
||||
if err != nil { panic(err) }
|
||||
}
|
||||
|
||||
func onStart () {
|
||||
// this is just copy pasted from config.go
|
||||
globalConfig = config.Config {
|
||||
LegalParameters: map[string] config.Type {
|
||||
"fontNormal": config.TypeString,
|
||||
"fontSize": config.TypeInteger,
|
||||
"padding": config.TypeInteger,
|
||||
"center": config.TypeBoolean,
|
||||
"colorBackground": config.TypeColor,
|
||||
"colorForeground": config.TypeColor,
|
||||
"colorDim": config.TypeColor,
|
||||
"colorRed": config.TypeColor,
|
||||
"colorYellow": config.TypeColor,
|
||||
"colorGreen": config.TypeColor,
|
||||
"colorBlue": config.TypeColor,
|
||||
"colorPurple": config.TypeColor,
|
||||
},
|
||||
|
||||
Parameters: map[string] any {
|
||||
"fontNormal": "",
|
||||
"fontSize": 11,
|
||||
"padding": 2,
|
||||
"center": false,
|
||||
"colorBackground":
|
||||
color.RGBA { R: 0, G: 0, B: 0, A: 0 },
|
||||
"colorForeground":
|
||||
color.RGBA { R: 0xFF, G: 0xFF, B: 0xFF, A: 0xFF },
|
||||
"colorDim":
|
||||
color.RGBA { R: 0x80, G: 0x80, B: 0x80, A: 0xFF },
|
||||
"colorRed":
|
||||
color.RGBA { R: 0xFF, G: 0x00, B: 0x00, A: 0xFF },
|
||||
"colorYellow":
|
||||
color.RGBA { R: 0xFF, G: 0xFF, B: 0x00, A: 0xFF },
|
||||
"colorGreen":
|
||||
color.RGBA { R: 0x00, G: 0xFF, B: 0x00, A: 0xFF },
|
||||
"colorBlue":
|
||||
color.RGBA { R: 0x00, G: 0x80, B: 0xFF, A: 0xFF },
|
||||
"colorPurple":
|
||||
color.RGBA { R: 0x80, G: 0x40, B: 0xFF, A: 0xFF },
|
||||
},
|
||||
}
|
||||
globalConfig.Load("stone")
|
||||
redraw()
|
||||
}
|
||||
|
||||
func redraw () {
|
||||
// i fucking love go interfaces
|
||||
application.Clear()
|
||||
application.SetDot(0, 0)
|
||||
globalConfig.SaveTo(application)
|
||||
}
|
||||
|
||||
func onPress (button stone.Button, modifiers stone.Modifiers) {
|
||||
}
|
||||
|
||||
func onRelease (button stone.Button) {
|
||||
}
|
||||
|
||||
func onMouseMove (x, y int) {
|
||||
inputState.x = x
|
||||
inputState.y = y
|
||||
}
|
|
@ -50,7 +50,8 @@ func onRelease (button stone.Button) {
|
|||
}
|
||||
}
|
||||
|
||||
func onMouseMove (x, y int) { if mousePressed {
|
||||
func onMouseMove (x, y int) {
|
||||
if mousePressed {
|
||||
application.SetRune(x, y, '#')
|
||||
application.Draw()
|
||||
}
|
||||
|
|
|
@ -0,0 +1,77 @@
|
|||
package main
|
||||
|
||||
import "os"
|
||||
import "fmt"
|
||||
import "image"
|
||||
import "math/rand"
|
||||
import _ "image/png"
|
||||
import "git.tebibyte.media/sashakoshka/stone"
|
||||
import _ "git.tebibyte.media/sashakoshka/stone/backends/x"
|
||||
|
||||
var application = &stone.Application { }
|
||||
|
||||
func main () {
|
||||
application.SetTitle("style demo")
|
||||
application.SetSize(11, 8)
|
||||
|
||||
iconFile16, err := os.Open("assets/scaffold16.png")
|
||||
if err != nil { panic(err) }
|
||||
icon16, _, err := image.Decode(iconFile16)
|
||||
if err != nil { panic(err) }
|
||||
iconFile16.Close()
|
||||
iconFile32, err := os.Open("assets/scaffold32.png")
|
||||
if err != nil { panic(err) }
|
||||
icon32, _, err := image.Decode(iconFile32)
|
||||
if err != nil { panic(err) }
|
||||
iconFile16.Close()
|
||||
|
||||
application.SetIcon([]image.Image { icon16, icon32 })
|
||||
|
||||
application.OnStart(redraw)
|
||||
application.OnResize(redraw)
|
||||
application.OnPress(onPress)
|
||||
|
||||
err = application.Run()
|
||||
if err != nil { panic(err) }
|
||||
}
|
||||
|
||||
func onPress (button stone.Button, modifiers stone.Modifiers) {
|
||||
redraw()
|
||||
application.Draw()
|
||||
}
|
||||
|
||||
func redraw () {
|
||||
width, _ := application.Size()
|
||||
application.SetDot(0, 0)
|
||||
fmt.Fprint (
|
||||
application,
|
||||
"normal\n",
|
||||
"bold\n",
|
||||
"italic\n",
|
||||
"underline\n",
|
||||
"all 3\n",
|
||||
"highlighted\n",
|
||||
"all 4\n",
|
||||
"highlight?")
|
||||
fillStyle(0, width, stone.StyleNormal)
|
||||
fillStyle(1, width, stone.StyleBold)
|
||||
fillStyle(2, width, stone.StyleItalic)
|
||||
fillStyle(3, width, stone.StyleUnderline)
|
||||
fillStyle(4, width, stone.StyleBoldItalic | stone.StyleUnderline)
|
||||
fillStyle(5, width, stone.StyleHighlight)
|
||||
fillStyle(6, width, stone.StyleBoldItalic | stone.StyleUnderline |
|
||||
stone.StyleHighlight)
|
||||
|
||||
if rand.Int() % 2 == 0 {
|
||||
fillStyle(7, width, stone.StyleNormal)
|
||||
} else {
|
||||
fillStyle(7, width, stone.StyleHighlight)
|
||||
}
|
||||
}
|
||||
|
||||
func fillStyle (yOffset, width int, style stone.Style) {
|
||||
for x := 0; x < width; x ++ {
|
||||
application.SetStyle(x, yOffset, style)
|
||||
application.SetColor(x, yOffset, stone.Color(x % 7 + 1))
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue