Compare commits
28 Commits
b0672ec8ee
...
v0.11.0
| Author | SHA1 | Date | |
|---|---|---|---|
| f676c2855e | |||
| 269d302453 | |||
| fbdc285f2e | |||
| 696460f323 | |||
| ece3a3e2a0 | |||
| 18b928acf6 | |||
| 7f0c34760d | |||
| 8810e88422 | |||
| bc09a01aa7 | |||
| a03eab9898 | |||
| e0f90f8305 | |||
| e46d66885d | |||
| 7c5de5a370 | |||
| 7da00e990e | |||
| bc26e78024 | |||
| 5dcfdda5f1 | |||
| 77e335a238 | |||
| 24357bf19f | |||
| 3ed8b70895 | |||
| 7db4c95592 | |||
| c29abe0cb1 | |||
| 4b53a5a019 | |||
| ecfb90957a | |||
| 16584abb42 | |||
| 3e597404ac | |||
| fa91b4f415 | |||
| 3a4038dad9 | |||
| a8bc074aad |
107
application.go
@@ -15,8 +15,9 @@ type Application interface {
|
||||
// Describe returns a description of the application.
|
||||
Describe () ApplicationDescription
|
||||
|
||||
// Init performs the initial setup of the application.
|
||||
Init () error
|
||||
// Init performs the initial setup of the application. This behavior
|
||||
// should return a window if it creates one.
|
||||
Init () (tomo.Window, error)
|
||||
}
|
||||
|
||||
// ApplicationURLOpener is an application that can open a URL.
|
||||
@@ -29,12 +30,15 @@ type ApplicationURLOpener interface {
|
||||
//
|
||||
// Applications should support the file:// scheme at the very least, and
|
||||
// should also support others like http:// and https:// if possible.
|
||||
OpenURL (*url.URL) error
|
||||
//
|
||||
// This behavior should return a window if it creates one.
|
||||
OpenURL (*url.URL) (tomo.Window, error)
|
||||
|
||||
// OpenNone is called when the application is launched without any URLs
|
||||
// to open. The application may create some sort of default starting
|
||||
// window, or call tomo.Stop().
|
||||
OpenNone ()
|
||||
// window, or do nothing. This behavior should return a window if it
|
||||
// creates one.
|
||||
OpenNone () (tomo.Window, error)
|
||||
}
|
||||
|
||||
// ApplicationFlagAdder is an application that supports reading command line
|
||||
@@ -128,8 +132,9 @@ func (role ApplicationRole) Icon () tomo.Icon {
|
||||
}
|
||||
}
|
||||
|
||||
// RunApplication is like tomo.Run, but runs an application. If something fails
|
||||
// to initialize, an error is written to the standard logger.
|
||||
// RunApplication is like tomo.Run, but runs an application. It automatically
|
||||
// sets up a backend. If something fails to initialize, an error is written to
|
||||
// the standard logger.
|
||||
func RunApplication (application Application) {
|
||||
// TODO: see #4
|
||||
|
||||
@@ -138,21 +143,27 @@ func RunApplication (application Application) {
|
||||
}
|
||||
flag.Parse()
|
||||
|
||||
err := registrar.RegisterBackend()
|
||||
reg := new(registrar.Registrar)
|
||||
backend, err := reg.SetBackend()
|
||||
if err != nil { log.Fatalln("nasin: could not register backend:", err) }
|
||||
err = tomo.Run(func () {
|
||||
err := registrar.SetTheme()
|
||||
err = reg.SetTheme()
|
||||
if err != nil { log.Fatalln("nasin: could not set theme:", err) }
|
||||
err = registrar.SetIconSet()
|
||||
err = reg.SetIconSet()
|
||||
if err != nil { log.Fatalln("nasin: could not set icon set:", err) }
|
||||
err = application.Init()
|
||||
err = reg.SetFaceSet()
|
||||
if err != nil { log.Fatalln("nasin: could not set face set:", err) }
|
||||
window, err := application.Init()
|
||||
if err != nil { log.Fatalln("nasin: could not run application:", err) }
|
||||
manageWindow(window)
|
||||
|
||||
// open URLs
|
||||
args := flag.Args()
|
||||
applicationOpenUrls(application, args...)
|
||||
})
|
||||
|
||||
if windows > 0 {
|
||||
err = backend.Run()
|
||||
if err != nil { log.Fatalln("nasin: could not run application:", err) }
|
||||
}
|
||||
}
|
||||
|
||||
// NewApplicationWindow creates a window for an application. It will
|
||||
@@ -170,10 +181,54 @@ func NewApplicationWindow (application Application, bounds image.Rectangle) (tom
|
||||
return window, nil
|
||||
}
|
||||
|
||||
func applicationOpenUrls (application Application, args ...string) {
|
||||
if application, ok := application.(ApplicationURLOpener); ok {
|
||||
var windows int
|
||||
|
||||
func manageWindow (window tomo.Window) {
|
||||
if window == nil { return }
|
||||
windows ++
|
||||
window.OnClose(func () {
|
||||
windows --
|
||||
if windows < 1 {
|
||||
tomo.Stop()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func errorPopupf (title, format string, v ...any) func (func ()) {
|
||||
return func (callback func ()) {
|
||||
dialog, err := objects.NewDialogOk (
|
||||
objects.DialogError, nil,
|
||||
title,
|
||||
fmt.Sprintf(format, v...),
|
||||
callback)
|
||||
if err != nil { log.Fatal(err) }
|
||||
dialog.SetVisible(true)
|
||||
manageWindow(dialog)
|
||||
}
|
||||
}
|
||||
|
||||
func applicationOpenUrls (app Application, args ...string) {
|
||||
application, ok := app.(ApplicationURLOpener)
|
||||
if !ok {
|
||||
if len(args) > 0 {
|
||||
log.Fatal("nasin: this application cannot open URLs")
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
openNone := func () bool {
|
||||
window, err := application.OpenNone()
|
||||
if err != nil {
|
||||
log.Fatalf("nasin: could not open main window: %v", err)
|
||||
return false
|
||||
}
|
||||
manageWindow(window)
|
||||
return true
|
||||
}
|
||||
|
||||
if len(args) <= 0 {
|
||||
application.OpenNone()
|
||||
openNone()
|
||||
return
|
||||
}
|
||||
|
||||
openedAny := false
|
||||
@@ -187,27 +242,19 @@ func applicationOpenUrls (application Application, args ...string) {
|
||||
if ur.Scheme == "" {
|
||||
ur.Scheme = "file"
|
||||
}
|
||||
err = application.OpenURL(ur)
|
||||
window, err := application.OpenURL(ur)
|
||||
if err != nil {
|
||||
dialog, err := objects.NewDialogOk (
|
||||
objects.DialogError, nil,
|
||||
errorPopupf(
|
||||
"Could Not Open URL",
|
||||
fmt.Sprintf (
|
||||
"Could not open %v: %v",
|
||||
arg, err),
|
||||
func () {
|
||||
arg, err,
|
||||
)(func () {
|
||||
if !openedAny {
|
||||
application.OpenNone()
|
||||
openNone()
|
||||
}
|
||||
})
|
||||
if err != nil { log.Fatal(err) }
|
||||
dialog.SetVisible(true)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if len(args) > 0 {
|
||||
log.Fatal("nasin: this application cannot open URLs")
|
||||
}
|
||||
manageWindow(window)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
10
go.mod
@@ -4,16 +4,13 @@ go 1.22.2
|
||||
|
||||
require (
|
||||
git.tebibyte.media/sashakoshka/goparse v0.2.0
|
||||
git.tebibyte.media/tomo/backend v0.5.1
|
||||
git.tebibyte.media/tomo/objects v0.20.1
|
||||
git.tebibyte.media/tomo/tomo v0.41.1
|
||||
git.tebibyte.media/tomo/backend v0.7.0
|
||||
git.tebibyte.media/tomo/objects v0.22.0
|
||||
git.tebibyte.media/tomo/tomo v0.46.1
|
||||
git.tebibyte.media/tomo/xdg v0.1.0
|
||||
github.com/flopp/go-findfont v0.1.0
|
||||
golang.org/x/image v0.11.0
|
||||
)
|
||||
|
||||
replace git.tebibyte.media/tomo/tomo => /home/sashakoshka/Repos/tebibyte/tomo/tomo
|
||||
|
||||
require (
|
||||
git.tebibyte.media/tomo/typeset v0.7.1 // indirect
|
||||
git.tebibyte.media/tomo/xgbkb v1.0.1 // indirect
|
||||
@@ -21,5 +18,4 @@ require (
|
||||
github.com/BurntSushi/graphics-go v0.0.0-20160129215708-b43f31a4a966 // indirect
|
||||
github.com/jezek/xgb v1.1.1 // indirect
|
||||
github.com/jezek/xgbutil v0.0.0-20231116234834-47f30c120111 // indirect
|
||||
golang.org/x/text v0.12.0 // indirect
|
||||
)
|
||||
|
||||
13
go.sum
@@ -1,10 +1,12 @@
|
||||
git.tebibyte.media/sashakoshka/goparse v0.2.0 h1:uQmKvOCV2AOlCHEDjg9uclZCXQZzq2PxaXfZ1aIMiQI=
|
||||
git.tebibyte.media/sashakoshka/goparse v0.2.0/go.mod h1:tSQwfuD+EujRoKr6Y1oaRy74ZynatzkRLxjE3sbpCmk=
|
||||
git.tebibyte.media/sashakoshka/xgbkb v1.0.0/go.mod h1:pNcE6TRO93vHd6q42SdwLSTTj25L0Yzggz7yLe0JV6Q=
|
||||
git.tebibyte.media/tomo/backend v0.5.1 h1:u3DLVcNWNdQsIxAEGcZ+kGG7zuew8tpPbyEFBx8ehjM=
|
||||
git.tebibyte.media/tomo/backend v0.5.1/go.mod h1:urnfu+D56Q9AOCZ/qp5YqkmlRRTIB5p9RbzBN7yIibQ=
|
||||
git.tebibyte.media/tomo/objects v0.20.1 h1:dCMMzaHmj7w016XtTb8QWvKMHVK2Fru/2a70NqApzHQ=
|
||||
git.tebibyte.media/tomo/objects v0.20.1/go.mod h1:hbBlQem9cNOt/G2rBvH/C94FT1oWgbtEftwg6ield9U=
|
||||
git.tebibyte.media/tomo/backend v0.7.0 h1:12A+IsbwIKCmg4jKjD9xCDz+o7R3X6Yp8cZup+wOGIM=
|
||||
git.tebibyte.media/tomo/backend v0.7.0/go.mod h1:G3Kh6N2MuiAwsnuPe3h9CwWL65vmmsaqgapA38MPyhk=
|
||||
git.tebibyte.media/tomo/objects v0.22.0 h1:2t21W32HW2xvPBICqmArVMVWxg9ohhTJw6ChZ0DcdYY=
|
||||
git.tebibyte.media/tomo/objects v0.22.0/go.mod h1:f5J5tAhO+eN5glVbCJLPSopIeTylXqLgKLVAIg8iAPQ=
|
||||
git.tebibyte.media/tomo/tomo v0.46.1 h1:/8fT6I9l4TK529zokrThbNDHGRvUsNgif1Zs++0PBSQ=
|
||||
git.tebibyte.media/tomo/tomo v0.46.1/go.mod h1:WrtilgKB1y8O2Yu7X4mYcRiqOlPR8NuUnoA/ynkQWrs=
|
||||
git.tebibyte.media/tomo/typeset v0.7.1 h1:aZrsHwCG5ZB4f5CruRFsxLv5ezJUCFUFsQJJso2sXQ8=
|
||||
git.tebibyte.media/tomo/typeset v0.7.1/go.mod h1:PwDpSdBF3l/EzoIsa2ME7QffVVajnTHZN6l3MHEGe1g=
|
||||
git.tebibyte.media/tomo/xdg v0.1.0 h1:6G2WYPPiM2IXleCpKKHuJA34BxumwNWuLsUoX3yu5zA=
|
||||
@@ -15,8 +17,6 @@ github.com/BurntSushi/freetype-go v0.0.0-20160129220410-b763ddbfe298 h1:1qlsVAQJ
|
||||
github.com/BurntSushi/freetype-go v0.0.0-20160129220410-b763ddbfe298/go.mod h1:D+QujdIlUNfa0igpNMk6UIvlb6C252URs4yupRUV4lQ=
|
||||
github.com/BurntSushi/graphics-go v0.0.0-20160129215708-b43f31a4a966 h1:lTG4HQym5oPKjL7nGs+csTgiDna685ZXjxijkne828g=
|
||||
github.com/BurntSushi/graphics-go v0.0.0-20160129215708-b43f31a4a966/go.mod h1:Mid70uvE93zn9wgF92A/r5ixgnvX8Lh68fxp9KQBaI0=
|
||||
github.com/flopp/go-findfont v0.1.0 h1:lPn0BymDUtJo+ZkV01VS3661HL6F4qFlkhcJN55u6mU=
|
||||
github.com/flopp/go-findfont v0.1.0/go.mod h1:wKKxRDjD024Rh7VMwoU90i6ikQRCr+JTHB5n4Ejkqvw=
|
||||
github.com/jezek/xgb v1.1.0/go.mod h1:nrhwO0FX/enq75I7Y7G8iN1ubpSGZEiA3v9e9GyRFlk=
|
||||
github.com/jezek/xgb v1.1.1 h1:bE/r8ZZtSv7l9gk6nU0mYx51aXrvnyb44892TwSaqS4=
|
||||
github.com/jezek/xgb v1.1.1/go.mod h1:nrhwO0FX/enq75I7Y7G8iN1ubpSGZEiA3v9e9GyRFlk=
|
||||
@@ -50,7 +50,6 @@ golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||
golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc=
|
||||
golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
|
||||
|
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 27 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
@@ -111,9 +111,14 @@ func generateSource (data []byte, width int) map[tomo.Icon] canvas.Texture {
|
||||
col(tomo.IconInsertLink)
|
||||
col(tomo.IconInsertObject)
|
||||
col(tomo.IconInsertText)
|
||||
|
||||
row()
|
||||
// actions: list
|
||||
col(tomo.IconListAdd)
|
||||
col(tomo.IconListRemove)
|
||||
col(tomo.IconListChoose)
|
||||
col(tomo.IconListExpand)
|
||||
col(tomo.IconListContract)
|
||||
|
||||
row()
|
||||
// actions: mail
|
||||
@@ -311,9 +316,6 @@ func generateSource (data []byte, width int) map[tomo.Icon] canvas.Texture {
|
||||
col(tomo.IconPlacePreferences)
|
||||
|
||||
row()
|
||||
// status: checkbox
|
||||
col(tomo.IconCheckboxChecked)
|
||||
col(tomo.IconCheckboxUnchecked)
|
||||
// status: appointments
|
||||
col(tomo.IconAppointmentMissed)
|
||||
col(tomo.IconAppointmentSoon)
|
||||
|
||||
@@ -7,23 +7,29 @@ import "git.tebibyte.media/tomo/tomo"
|
||||
import "git.tebibyte.media/tomo/backend/x"
|
||||
import "git.tebibyte.media/sashakoshka/goparse"
|
||||
import "git.tebibyte.media/tomo/nasin/internal/icons/xdg"
|
||||
import "git.tebibyte.media/tomo/nasin/internal/style/tss"
|
||||
import "git.tebibyte.media/tomo/nasin/internal/styles/tss"
|
||||
import "git.tebibyte.media/tomo/nasin/internal/icons/fallback"
|
||||
import "git.tebibyte.media/tomo/nasin/internal/style/fallback"
|
||||
import "git.tebibyte.media/tomo/nasin/internal/styles/fallback"
|
||||
import "git.tebibyte.media/tomo/nasin/internal/faces/fallback"
|
||||
|
||||
func RegisterBackend () error {
|
||||
tomo.Register(1, x.New)
|
||||
return nil
|
||||
type Registrar struct {
|
||||
backend *x.Backend
|
||||
}
|
||||
|
||||
func SetTheme () error {
|
||||
// TODO eventually get rid of this when we make a file format for
|
||||
// storing visual styles
|
||||
func (this *Registrar) SetBackend () (tomo.Backend, error) {
|
||||
backend, err := x.New()
|
||||
if err != nil { return nil, err }
|
||||
this.backend = backend.(*x.Backend)
|
||||
tomo.SetBackend(backend)
|
||||
return backend, nil
|
||||
}
|
||||
|
||||
func (this *Registrar) SetTheme () error {
|
||||
styleSheetName := os.Getenv("TOMO_STYLE_SHEET")
|
||||
if styleSheetName != "" {
|
||||
styl, _, err := tss.LoadFile(styleSheetName)
|
||||
if err == nil {
|
||||
tomo.SetStyle(styl)
|
||||
this.backend.SetStyle(styl)
|
||||
return nil
|
||||
} else {
|
||||
log.Printf (
|
||||
@@ -33,11 +39,11 @@ func SetTheme () error {
|
||||
}
|
||||
|
||||
styl, _ := fallbackStyle.New()
|
||||
tomo.SetStyle(styl)
|
||||
this.backend.SetStyle(styl)
|
||||
return nil
|
||||
}
|
||||
|
||||
func SetIconSet () error {
|
||||
func (this *Registrar) SetIconSet () error {
|
||||
iconSet := fallbackIcons.New()
|
||||
iconSetName := os.Getenv("TOMO_XDG_ICON_THEME")
|
||||
if iconSetName != "" {
|
||||
@@ -49,6 +55,14 @@ func SetIconSet () error {
|
||||
}
|
||||
}
|
||||
|
||||
tomo.SetIconSet(iconSet)
|
||||
this.backend.SetIconSet(iconSet)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (this *Registrar) SetFaceSet () error {
|
||||
// TODO replace this with something that uses findfont, and caches and
|
||||
// refcounts the faces
|
||||
faceSet := fallbackFaces.New()
|
||||
this.backend.SetFaceSet(faceSet)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -1,211 +0,0 @@
|
||||
// Colors
|
||||
$ColorDot = #7391c0;
|
||||
$ColorAccent = #5f8bc4;
|
||||
$ColorHighlight = #5f8bc4;
|
||||
$ColorBackground = #d4d4d4;
|
||||
$ColorForeground = #000;
|
||||
$ColorOutline = $ColorForeground;
|
||||
$ColorGutter = #bfc6d1;
|
||||
$ColorGutterHovered = #c5cbd6;
|
||||
$ColorRaised = #e9eaea;
|
||||
$ColorRaisedPressed = #ccd4dd;
|
||||
$ColorRaisedFocused = #cfd6dd;
|
||||
$ColorRaisedHovered = #f1f3f5;
|
||||
$ColorSunken = #e9eaea;
|
||||
$ColorSunkenFocused = #e0e6ee;
|
||||
$ColorSunkenPressed = #e0e6ee;
|
||||
$ColorCalendarWeekdayHeader = #d3cac2;
|
||||
$ColorCalendarWeekend = #c2d3c4;
|
||||
$ColorCalendarDay = #d6dae2;
|
||||
|
||||
// Borders
|
||||
$BorderOutline = $ColorOutline / 1;
|
||||
$BorderEngraved = #c3c3c5 #e3e3e3 #e9e9e9 #c2c2c2 / 1;
|
||||
$BorderGap = #697c7c #566767 #566767 #697c7c / 1;
|
||||
$BorderLifted = #f9fafc #c2c8d3 #a4afc0 #f5f6f8 / 1;
|
||||
$BorderLiftedFocused = #f0f4f9 #b1baca #9aa6b7 #e4e9ee / 1;
|
||||
$BorderFocused = #5f8bc4 #5f8bc4 #5f8bc4 #5f8bc4 / 1;
|
||||
$BorderTear = $BorderEngraved;
|
||||
$BorderTearFocused = #7f94b5 #ced7e4 #ced7e4 #7f94b5 / 1;
|
||||
$BorderTearPad = #0000 / 3;
|
||||
$BorderTearPadFocused = #7391c080 / 3;
|
||||
$BorderInnerShadow = #a4afc0 / 1 0 0 1;
|
||||
$BorderOuterShadow = #a4afc0 / 0 1 1 0;
|
||||
|
||||
*.* {
|
||||
TextColor: $ColorForeground;
|
||||
DotColor: $ColorDot;
|
||||
Gap: 8;
|
||||
Face: "DMMono-Regular.ttf" 11;
|
||||
}
|
||||
|
||||
*.Button {
|
||||
Border: $BorderEngraved, $BorderGap, $BorderLifted;
|
||||
Padding: 4 8;
|
||||
Color: $ColorRaised;
|
||||
}
|
||||
|
||||
*.Button[focused] {
|
||||
Border: $BorderEngraved, $BorderGap, $BorderLiftedFocused;
|
||||
Padding: 4 8;
|
||||
Color: $ColorRaisedFocused;
|
||||
}
|
||||
|
||||
*.Button[hovered] {
|
||||
Color: $ColorRaisedHovered;
|
||||
}
|
||||
|
||||
*.Button[pressed] {
|
||||
Border: $BorderEngraved, $BorderGap, $BorderInnerShadow;
|
||||
Padding: 5 8 4 9;
|
||||
Color: $ColorRaisedPressed;
|
||||
}
|
||||
|
||||
*.TextInput {
|
||||
Border: $BorderEngraved, $BorderGap, $BorderInnerShadow;
|
||||
Padding: 5 4 4 5;
|
||||
Color: $ColorSunken;
|
||||
}
|
||||
|
||||
*.TextInput[focused] {
|
||||
Border: $BorderEngraved, $BorderFocused, $BorderInnerShadow;
|
||||
}
|
||||
|
||||
*.TextView {
|
||||
Border: $BorderEngraved, $BorderGap, $BorderInnerShadow;
|
||||
Padding: 5 4 4 5;
|
||||
Color: $ColorSunken;
|
||||
}
|
||||
|
||||
*.NumberInput {
|
||||
Gap: 0;
|
||||
}
|
||||
|
||||
*.Container[sunken] {
|
||||
Border: $BorderEngraved, $BorderGap, $BorderInnerShadow;
|
||||
Padding: 5 4 4 5;
|
||||
Color: $ColorSunken;
|
||||
}
|
||||
|
||||
*.Container[outer] {
|
||||
Color: $ColorBackground;
|
||||
Padding: 8;
|
||||
}
|
||||
|
||||
*.Container[menu] {
|
||||
Border: $BorderGap, $BorderLifted;
|
||||
Color: $ColorBackground;
|
||||
Gap: 0;
|
||||
}
|
||||
|
||||
*.Heading {
|
||||
Align: middle middle;
|
||||
}
|
||||
|
||||
*.Separator {
|
||||
Border: $BorderEngraved;
|
||||
}
|
||||
|
||||
*.Slider {
|
||||
Border: $BorderEngraved, $BorderGap, $BorderInnerShadow;
|
||||
Color: $ColorGutter;
|
||||
}
|
||||
|
||||
*.Slider[focused] {
|
||||
Border: $BorderEngraved, $BorderFocused, $BorderInnerShadow;
|
||||
}
|
||||
|
||||
*.Slider[hovered] {
|
||||
Color: $ColorGutterHovered;
|
||||
}
|
||||
|
||||
*.Slider[horizontal] {
|
||||
MinimumSize: 48 0;
|
||||
}
|
||||
|
||||
*.Slider[vertical] {
|
||||
MinimumSize: 0 48;
|
||||
}
|
||||
|
||||
*.SliderHandle {
|
||||
Border: $BorderOuterShadow, $BorderGap, $BorderLifted;
|
||||
Color: $ColorRaised;
|
||||
MinimumSize: 12;
|
||||
}
|
||||
|
||||
*.ScrollContainer {
|
||||
Gap: 0;
|
||||
}
|
||||
|
||||
*.Checkbox {
|
||||
Border: $BorderEngraved, $BorderGap, $BorderInnerShadow;
|
||||
Color: $ColorSunken;
|
||||
Padding: 0 1 1 0;
|
||||
MinimumSize: 19;
|
||||
}
|
||||
|
||||
*.Checkbox[focused] {
|
||||
Border: $BorderEngraved, $BorderFocused, $BorderInnerShadow;
|
||||
Color: $ColorSunkenFocused;
|
||||
Padding: 0;
|
||||
}
|
||||
|
||||
*.MenuItem {
|
||||
Padding: 4;
|
||||
Gap: 4;
|
||||
Color: #0000;
|
||||
}
|
||||
|
||||
*.MenuItem[hovered] {
|
||||
Color: $ColorDot;
|
||||
}
|
||||
|
||||
*.MenuItem[focused] {
|
||||
Color: $ColorDot;
|
||||
}
|
||||
|
||||
*.File {
|
||||
Color: #0000;
|
||||
}
|
||||
|
||||
*.File[focused] {
|
||||
Color: $ColorDot;
|
||||
}
|
||||
|
||||
*.TearLine {
|
||||
Border: $BorderTearPad, $BorderTear;
|
||||
}
|
||||
|
||||
*.TearLine[hovered] {
|
||||
Border: $BorderTearPadFocused, $BorderTearFocused;
|
||||
}
|
||||
|
||||
*.TearLine[focused] {
|
||||
Border: $BorderTearPadFocused, $BorderTearFocused;
|
||||
}
|
||||
|
||||
*.Calendar {
|
||||
Border: $BorderOuterShadow, $BorderGap;
|
||||
Color: $ColorRaised;
|
||||
Padding: 2;
|
||||
Gap: 2;
|
||||
}
|
||||
|
||||
*.CalendarGrid {
|
||||
Gap: 2 2;
|
||||
}
|
||||
|
||||
*.CalendarWeekdayHeader {
|
||||
Color: $ColorCalendarWeekdayHeader;
|
||||
Padding: 2;
|
||||
}
|
||||
|
||||
*.CalendarDay {
|
||||
Color: $ColorCalendarDay;
|
||||
Padding: 2;
|
||||
MinimumSize: 32;
|
||||
}
|
||||
|
||||
*.CalendarDay[weekend] {
|
||||
Color: $ColorCalendarWeekend;
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
package aluminumStyle
|
||||
|
||||
import "image/color"
|
||||
import "git.tebibyte.media/tomo/tomo"
|
||||
|
||||
// New returns Aluminum, a futuristic, bluish-white style.
|
||||
func New () *style.Style {
|
||||
return &style.Style {
|
||||
Colors: map[tomo.Color] color.Color {
|
||||
tomo.ColorBackground: colorBackground,
|
||||
tomo.ColorForeground: colorForeground,
|
||||
tomo.ColorRaised: colorRaised,
|
||||
tomo.ColorSunken: colorSunken,
|
||||
tomo.ColorAccent: colorFocus,
|
||||
},
|
||||
Rules: rules,
|
||||
}
|
||||
}
|
||||
@@ -1,391 +0,0 @@
|
||||
package aluminumStyle
|
||||
|
||||
import "image/color"
|
||||
import "git.tebibyte.media/tomo/tomo"
|
||||
import "golang.org/x/image/font/basicfont"
|
||||
|
||||
func hex (color uint32) (c color.RGBA) {
|
||||
c.A = uint8(color)
|
||||
c.B = uint8(color >> 8)
|
||||
c.G = uint8(color >> 16)
|
||||
c.R = uint8(color >> 24)
|
||||
return
|
||||
}
|
||||
|
||||
func border (top, right, bottom, left uint32, width ...int) tomo.Border {
|
||||
return tomo.Border {
|
||||
Width: tomo.I(width...),
|
||||
Color: [4]color.Color {
|
||||
hex(top), hex(right),
|
||||
hex(bottom), hex(left),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
var colorDot = hex(0x7391c080)
|
||||
var colorFocus = hex(0x5f8bc4FF)
|
||||
var colorHighlight = hex(0x5f8bc4FF)
|
||||
var colorBackground = hex(0xd4d4d4FF)
|
||||
var colorForeground = color.Black
|
||||
|
||||
var colorOutline = color.Black
|
||||
var colorGutter = hex(0xbfc6d1FF)
|
||||
var colorGutterHovered = hex(0xc5cbd6FF)
|
||||
var colorRaised = hex(0xe9eaeaFF)
|
||||
var colorRaisedPressed = hex(0xccd4ddFF)
|
||||
var colorRaisedFocused = hex(0xcfd6ddFF)
|
||||
var colorRaisedHovered = hex(0xf1f3f5FF)
|
||||
var colorSunken = hex(0xe9eaeaFF)
|
||||
var colorSunkenFocused = hex(0xe0e6eeFF)
|
||||
var colorSunkenPressed = hex(0xe0e6eeFF)
|
||||
var colorCalendarWeekdayHeader = hex(0xd3cac2FF)
|
||||
var colorCalendarWeekend = hex(0xc2d3c4FF)
|
||||
var colorCalendarDay = hex(0xd6dae2FF)
|
||||
|
||||
var outline = tomo.Border {
|
||||
Width: tomo.I(1),
|
||||
Color: [4]color.Color {
|
||||
colorOutline,
|
||||
colorOutline,
|
||||
colorOutline,
|
||||
colorOutline,
|
||||
},
|
||||
}
|
||||
|
||||
var borderEngraved = border(0xc3c3c5FF, 0xe3e3e3FF, 0xe9e9e9ff, 0xc2c2c2ff, 1)
|
||||
var borderGap = border(0x697c7cFF, 0x566767FF, 0x566767ff, 0x697c7cff, 1)
|
||||
var borderLifted = border(0xf9fafcFF, 0xc2c8d3FF, 0xa4afc0ff, 0xf5f6f8ff, 1)
|
||||
var borderLiftedFocused = border(0xf0f4f9FF, 0xb1bacaFF, 0x9aa6b7ff, 0xe4e9eeff, 1)
|
||||
var borderFocused = border(0x5f8bc4FF, 0x5f8bc4FF, 0x5f8bc4ff, 0x5f8bc4ff, 1)
|
||||
var borderTear = borderEngraved
|
||||
var borderTearFocused = border(0x7f94b5FF, 0xced7e4FF, 0xced7e4FF, 0x7f94b5FF, 1)
|
||||
var borderTearPad = border(0x00000000, 0x00000000, 0x00000000, 0x00000000, 3)
|
||||
var borderTearPadFocused = border(0x7391c080, 0x7391c080, 0x7391c080, 0x7391c080, 3)
|
||||
var borderInnerShadow = border(0xa4afc0FF, 0xa4afc0FF, 0xa4afc0ff, 0xa4afc0ff, 1, 0, 0, 1)
|
||||
var borderOuterShadow = border(0xa4afc0FF, 0xa4afc0FF, 0xa4afc0ff, 0xa4afc0ff, 0, 1, 1, 0)
|
||||
|
||||
var rules = []style.Rule {
|
||||
// *.*[*]
|
||||
style.Rule {
|
||||
Default: style.AS (
|
||||
style.AttrFace { Face: basicfont.Face7x13 },
|
||||
style.AttrTextColor { Color: tomo.ColorForeground },
|
||||
style.AttrDotColor { Color: colorDot },
|
||||
style.AttrGap { X: 8, Y: 8 },
|
||||
),
|
||||
},
|
||||
|
||||
// *.Button[*]
|
||||
style.Rule {
|
||||
Role: tomo.R("", "Button", ""),
|
||||
Default: style.AS (
|
||||
style.AttrBorder {
|
||||
borderEngraved,
|
||||
borderGap,
|
||||
borderLifted,
|
||||
},
|
||||
style.AttrPadding(tomo.I(4, 8)),
|
||||
style.AttrColor { Color: tomo.ColorRaised },
|
||||
),
|
||||
Pressed: style.AS (
|
||||
style.AttrBorder {
|
||||
borderEngraved,
|
||||
borderGap,
|
||||
borderInnerShadow,
|
||||
},
|
||||
style.AttrPadding(tomo.I(5, 8, 4, 9)),
|
||||
style.AttrColor { Color: colorRaisedPressed },
|
||||
),
|
||||
Focused: style.AS (
|
||||
style.AttrBorder {
|
||||
borderEngraved,
|
||||
borderGap,
|
||||
borderLiftedFocused,
|
||||
},
|
||||
style.AttrPadding(tomo.I(4, 8)),
|
||||
style.AttrColor { Color: colorRaisedFocused },
|
||||
),
|
||||
Hovered: style.AS (
|
||||
style.AttrColor { Color: colorRaisedHovered },
|
||||
),
|
||||
},
|
||||
|
||||
// *.TextInput[*]
|
||||
style.Rule {
|
||||
Role: tomo.R("", "TextInput", ""),
|
||||
Default: style.AS (
|
||||
style.AttrBorder {
|
||||
borderEngraved,
|
||||
borderGap,
|
||||
borderInnerShadow,
|
||||
},
|
||||
style.AttrColor { Color: tomo.ColorSunken },
|
||||
style.AttrPadding(tomo.I(5, 4, 4, 5)),
|
||||
),
|
||||
Focused: style.AS (
|
||||
style.AttrBorder {
|
||||
borderEngraved,
|
||||
borderFocused,
|
||||
borderInnerShadow,
|
||||
},
|
||||
),
|
||||
},
|
||||
|
||||
// *.TextView[*]
|
||||
style.Rule {
|
||||
Role: tomo.R("", "TextView", ""),
|
||||
Default: style.AS (
|
||||
style.AttrBorder {
|
||||
borderEngraved,
|
||||
borderGap,
|
||||
borderInnerShadow,
|
||||
},
|
||||
style.AttrColor { Color: tomo.ColorSunken },
|
||||
style.AttrPadding(tomo.I(8)),
|
||||
),
|
||||
},
|
||||
|
||||
// *.NumberInput[*]
|
||||
style.Rule {
|
||||
Role: tomo.R("", "NumberInput", ""),
|
||||
Default: style.AS (
|
||||
style.AttrGap { },
|
||||
),
|
||||
},
|
||||
|
||||
// *.Container[sunken]
|
||||
style.Rule {
|
||||
Role: tomo.R("", "Container", "sunken"),
|
||||
Default: style.AS (
|
||||
style.AttrBorder {
|
||||
borderEngraved,
|
||||
borderGap,
|
||||
borderInnerShadow,
|
||||
},
|
||||
style.AttrColor { Color: tomo.ColorSunken },
|
||||
style.AttrPadding(tomo.I(8)),
|
||||
),
|
||||
},
|
||||
|
||||
// *.Container[outer]
|
||||
style.Rule {
|
||||
Role: tomo.R("", "Container", "outer"),
|
||||
Default: style.AS (
|
||||
style.AttrColor { Color: tomo.ColorBackground },
|
||||
style.AttrPadding(tomo.I(8)),
|
||||
),
|
||||
},
|
||||
|
||||
// *.Container[menu]
|
||||
style.Rule {
|
||||
Role: tomo.R("", "Container", "menu"),
|
||||
Default: style.AS (
|
||||
style.AttrBorder {
|
||||
borderGap,
|
||||
borderLifted,
|
||||
},
|
||||
style.AttrColor { Color: tomo.ColorBackground },
|
||||
style.AttrGap { },
|
||||
),
|
||||
},
|
||||
|
||||
// *.Heading[*]
|
||||
style.Rule {
|
||||
Role: tomo.R("", "Heading", ""),
|
||||
Default: style.AS (
|
||||
style.AttrAlign { X: tomo.AlignMiddle, Y: tomo.AlignMiddle },
|
||||
),
|
||||
},
|
||||
|
||||
// *.Separator[*]
|
||||
style.Rule {
|
||||
Role: tomo.R("", "Separator", ""),
|
||||
Default: style.AS (
|
||||
style.AttrBorder {
|
||||
borderEngraved,
|
||||
},
|
||||
),
|
||||
},
|
||||
|
||||
// *.Slider[*]
|
||||
style.Rule {
|
||||
Role: tomo.R("", "Slider", ""),
|
||||
Default: style.AS (
|
||||
style.AttrBorder {
|
||||
borderEngraved,
|
||||
borderGap,
|
||||
borderInnerShadow,
|
||||
},
|
||||
style.AttrColor { Color: colorGutter },
|
||||
),
|
||||
Focused: style.AS (
|
||||
style.AttrBorder {
|
||||
borderEngraved,
|
||||
borderFocused,
|
||||
borderInnerShadow,
|
||||
},
|
||||
),
|
||||
Hovered: style.AS (
|
||||
style.AttrColor { Color: colorGutterHovered },
|
||||
),
|
||||
},
|
||||
|
||||
// *.Slider[horizontal]
|
||||
style.Rule {
|
||||
Role: tomo.R("", "Slider", "horizontal"),
|
||||
Default: style.AS(style.AttrMinimumSize { X: 48 }),
|
||||
},
|
||||
|
||||
// *.Slider[vertical]
|
||||
style.Rule {
|
||||
Role: tomo.R("", "Slider", "vertical"),
|
||||
Default: style.AS(style.AttrMinimumSize { Y: 48 }),
|
||||
},
|
||||
|
||||
// *.SliderHandle[*]
|
||||
style.Rule {
|
||||
Role: tomo.R("", "SliderHandle", ""),
|
||||
Default: style.AS (
|
||||
style.AttrBorder {
|
||||
borderOuterShadow,
|
||||
borderGap,
|
||||
borderLifted,
|
||||
},
|
||||
style.AttrColor { Color: tomo.ColorRaised },
|
||||
style.AttrMinimumSize { X: 12, Y: 12, },
|
||||
),
|
||||
},
|
||||
|
||||
// *.Checkbox[*]
|
||||
style.Rule {
|
||||
Role: tomo.R("", "Checkbox", ""),
|
||||
Default: style.AS (
|
||||
style.AttrBorder {
|
||||
borderEngraved,
|
||||
borderGap,
|
||||
borderInnerShadow,
|
||||
},
|
||||
style.AttrColor { Color: tomo.ColorSunken },
|
||||
style.AttrPadding(tomo.I(0, 1, 1, 0)),
|
||||
style.AttrMinimumSize { X: 19, Y: 19 },
|
||||
),
|
||||
Focused: style.AS (
|
||||
style.AttrBorder {
|
||||
borderEngraved,
|
||||
borderFocused,
|
||||
borderInnerShadow,
|
||||
},
|
||||
style.AttrPadding(tomo.I(0)),
|
||||
style.AttrColor { Color: colorSunkenFocused },
|
||||
),
|
||||
},
|
||||
|
||||
// *.LabelCheckbox[*]
|
||||
style.Rule {
|
||||
Role: tomo.R("", "LabelCheckbox", ""),
|
||||
Default: style.AS (
|
||||
style.AttrGap { X: 8, Y: 8 },
|
||||
),
|
||||
},
|
||||
|
||||
// *.MenuItem[*]
|
||||
style.Rule {
|
||||
Role: tomo.R("", "MenuItem", ""),
|
||||
Default: style.AS (
|
||||
style.AttrPadding(tomo.I(4)),
|
||||
style.AttrGap { X: 4, Y: 4 },
|
||||
style.AttrColor { Color: color.Transparent },
|
||||
),
|
||||
Hovered: style.AS (
|
||||
style.AttrColor { Color: colorDot },
|
||||
),
|
||||
Focused: style.AS (
|
||||
style.AttrColor { Color: colorDot },
|
||||
),
|
||||
},
|
||||
|
||||
// *.File[*]
|
||||
style.Rule {
|
||||
Role: tomo.R("", "File", ""),
|
||||
Default: style.AS (
|
||||
style.AttrColor { Color: color.Transparent },
|
||||
),
|
||||
Focused: style.AS (
|
||||
style.AttrColor { Color: colorDot },
|
||||
),
|
||||
},
|
||||
|
||||
// *.TearLine[*]
|
||||
style.Rule {
|
||||
Role: tomo.R("", "TearLine", ""),
|
||||
Default: style.AS (
|
||||
style.AttrBorder {
|
||||
borderTearPad,
|
||||
borderTear,
|
||||
},
|
||||
),
|
||||
Hovered: style.AS (
|
||||
style.AttrBorder {
|
||||
borderTearPadFocused,
|
||||
borderTearFocused,
|
||||
},
|
||||
),
|
||||
Focused: style.AS (
|
||||
style.AttrBorder {
|
||||
borderTearPadFocused,
|
||||
borderTearFocused,
|
||||
},
|
||||
),
|
||||
},
|
||||
|
||||
// *.Calendar[*]
|
||||
style.Rule {
|
||||
Role: tomo.R("", "Calendar", ""),
|
||||
Default: style.AS (
|
||||
style.AttrBorder {
|
||||
borderOuterShadow,
|
||||
borderGap,
|
||||
},
|
||||
style.AttrColor { Color: tomo.ColorRaised },
|
||||
style.AttrPadding(tomo.I(2)),
|
||||
style.AttrGap { X: 2, Y: 2 },
|
||||
),
|
||||
},
|
||||
|
||||
// *.CalendarGrid[*]
|
||||
style.Rule {
|
||||
Role: tomo.R("", "CalendarGrid", ""),
|
||||
Default: style.AS (
|
||||
style.AttrGap { X: 2, Y: 2 },
|
||||
),
|
||||
},
|
||||
|
||||
// *.CalendarWeekdayHeader[*]
|
||||
style.Rule {
|
||||
Role: tomo.R("", "CalendarWeekdayHeader", ""),
|
||||
Default: style.AS (
|
||||
style.AttrPadding(tomo.I(2)),
|
||||
style.AttrColor { Color: colorCalendarWeekdayHeader },
|
||||
),
|
||||
},
|
||||
|
||||
// *.CalendarDay[weekday]
|
||||
style.Rule {
|
||||
Role: tomo.R("", "CalendarDay", "weekday"),
|
||||
Default: style.AS (
|
||||
style.AttrPadding(tomo.I(2)),
|
||||
style.AttrMinimumSize { X: 32, Y: 32 },
|
||||
style.AttrColor { Color: colorCalendarDay },
|
||||
),
|
||||
},
|
||||
|
||||
// *.CalendarDay[weekend]
|
||||
style.Rule {
|
||||
Role: tomo.R("", "CalendarDay", "weekend"),
|
||||
Default: style.AS (
|
||||
style.AttrPadding(tomo.I(2)),
|
||||
style.AttrMinimumSize { X: 32, Y: 32 },
|
||||
style.AttrColor { Color: colorCalendarWeekend },
|
||||
),
|
||||
},
|
||||
}
|
||||
319
internal/styles/aluminum/aluminum.tss
Normal file
@@ -0,0 +1,319 @@
|
||||
// Colors
|
||||
$ColorDot = #7391c080;
|
||||
$ColorAccent = #5f8bc4;
|
||||
$ColorHighlight = #5f8bc4;
|
||||
$ColorBackground = #d4d4d4;
|
||||
$ColorForeground = #000;
|
||||
$ColorOutline = $ColorForeground;
|
||||
$ColorGutter = #bfc6d1;
|
||||
$ColorGutterHovered = #c5cbd6;
|
||||
$ColorRaised = #e9eaea;
|
||||
$ColorRaisedPressed = #ccd4dd;
|
||||
$ColorRaisedFocused = #cfd6dd;
|
||||
$ColorRaisedHovered = #f1f3f5;
|
||||
$ColorSunken = #e9eaea;
|
||||
$ColorSunkenFocused = #e0e6ee;
|
||||
$ColorSunkenPressed = #e0e6ee;
|
||||
$ColorCalendarWeekdayHeader = #d3cac2;
|
||||
$ColorCalendarWeekend = #c2d3c4;
|
||||
$ColorCalendarDay = #d6dae2;
|
||||
|
||||
// Borders
|
||||
$BorderOutline = $ColorOutline ;
|
||||
$BorderEngraved = #c3c3c5 #e3e3e3 #e9e9e9 #c2c2c2;
|
||||
$BorderGap = #697c7c #566767 #566767 #697c7c;
|
||||
$BorderLifted = #f9fafc #c2c8d3 #a4afc0 #f5f6f8;
|
||||
$BorderLiftedFocused = #f0f4f9 #b1baca #9aa6b7 #e4e9ee;
|
||||
$BorderFocused = #5f8bc4 #5f8bc4 #5f8bc4 #5f8bc4;
|
||||
$BorderTear = $BorderEngraved ;
|
||||
$BorderTearFocused = #7f94b5 #ced7e4 #ced7e4 #7f94b5;
|
||||
$BorderTearPad = #0000 ;
|
||||
$BorderTearPadFocused = #7391c080 ;
|
||||
$BorderInnerShadow = #a4afc0 ;
|
||||
$BorderOuterShadow = #a4afc0 ;
|
||||
|
||||
*.* {
|
||||
TextColor: $ColorForeground;
|
||||
DotColor: $ColorDot;
|
||||
Gap: 8;
|
||||
}
|
||||
|
||||
*.Button {
|
||||
Border: $BorderEngraved / 1, $BorderGap / 1, $BorderLifted / 1;
|
||||
Padding: 4 8;
|
||||
Color: $ColorRaised;
|
||||
}
|
||||
|
||||
*.Button[focused] {
|
||||
Border: $BorderEngraved / 1, $BorderGap / 1, $BorderLiftedFocused / 1;
|
||||
Padding: 4 8;
|
||||
Color: $ColorRaisedFocused;
|
||||
}
|
||||
|
||||
*.Button[hovered] {
|
||||
Color: $ColorRaisedHovered;
|
||||
}
|
||||
|
||||
*.Button[pressed] {
|
||||
Border: $BorderEngraved / 1, $BorderGap / 1, $BorderInnerShadow / 1 0 0 1;
|
||||
Padding: 5 8 4 9;
|
||||
Color: $ColorRaisedPressed;
|
||||
}
|
||||
|
||||
*.TextInput {
|
||||
Border: $BorderEngraved / 1, $BorderGap / 1, $BorderInnerShadow / 1 0 0 1;
|
||||
Padding: 5 4 4 5;
|
||||
Color: $ColorSunken;
|
||||
}
|
||||
|
||||
*.TextInput[focused] {
|
||||
Border: $BorderEngraved / 1, $BorderFocused / 1, $BorderInnerShadow / 1 0 0 1;
|
||||
}
|
||||
|
||||
*.TextView {
|
||||
Border: $BorderEngraved / 1, $BorderGap / 1, $BorderInnerShadow / 1 0 0 1;
|
||||
Padding: 5 4 4 5;
|
||||
Color: $ColorSunken;
|
||||
}
|
||||
|
||||
*.NumberInput {
|
||||
Gap: 0;
|
||||
}
|
||||
|
||||
*.Container[sunken] {
|
||||
Border: $BorderEngraved / 1, $BorderGap / 1, $BorderInnerShadow / 1 0 0 1;
|
||||
Padding: 5 4 4 5;
|
||||
Color: $ColorSunken;
|
||||
}
|
||||
|
||||
*.Container[outer] {
|
||||
Color: $ColorBackground;
|
||||
Padding: 8;
|
||||
}
|
||||
|
||||
*.Container[menu] {
|
||||
Border: $BorderGap / 1, $BorderLifted / 1;
|
||||
Color: $ColorBackground;
|
||||
Gap: 0;
|
||||
}
|
||||
|
||||
*.Container[menu, torn] {
|
||||
Border: ;
|
||||
Color: $ColorBackground;
|
||||
Gap: 0;
|
||||
}
|
||||
|
||||
*.Heading {
|
||||
Align: middle middle;
|
||||
}
|
||||
|
||||
*.Heading[menu] {
|
||||
Align: middle middle;
|
||||
Padding: 4 8;
|
||||
}
|
||||
|
||||
*.Separator {
|
||||
Border: $BorderEngraved / 1;
|
||||
}
|
||||
|
||||
*.Slider {
|
||||
Border: $BorderEngraved / 1, $BorderGap / 1, $BorderInnerShadow / 1 0 0 1;
|
||||
Color: $ColorGutter;
|
||||
}
|
||||
|
||||
*.Slider[focused] {
|
||||
Border: $BorderEngraved / 1, $BorderFocused / 1, $BorderInnerShadow / 1 0 0 1;
|
||||
}
|
||||
|
||||
*.Slider[hovered] {
|
||||
Color: $ColorGutterHovered;
|
||||
}
|
||||
|
||||
*.Slider[horizontal] {
|
||||
MinimumSize: 48 0;
|
||||
}
|
||||
|
||||
*.Slider[vertical] {
|
||||
MinimumSize: 0 48;
|
||||
}
|
||||
|
||||
*.SliderHandle {
|
||||
Border: $BorderOuterShadow / 0 1 1 0, $BorderGap / 1, $BorderLifted / 1;
|
||||
Color: $ColorRaised;
|
||||
MinimumSize: 12;
|
||||
}
|
||||
|
||||
*.Scrollbar {
|
||||
Border: $BorderEngraved / 1, $BorderGap / 1, $BorderInnerShadow / 1 0 0 1;
|
||||
Color: $ColorGutter;
|
||||
}
|
||||
|
||||
*.Scrollbar[focused] {
|
||||
Border: $BorderEngraved / 1, $BorderFocused / 1, $BorderInnerShadow / 1 0 0 1;
|
||||
}
|
||||
|
||||
*.Scrollbar[hovered] {
|
||||
Color: $ColorGutterHovered;
|
||||
}
|
||||
|
||||
*.Scrollbar[horizontal] {
|
||||
MinimumSize: 48 0;
|
||||
}
|
||||
|
||||
*.Scrollbar[vertical] {
|
||||
MinimumSize: 0 48;
|
||||
}
|
||||
|
||||
*.ScrollbarHandle {
|
||||
Border: $BorderOuterShadow / 0 1 1 0, $BorderGap / 1, $BorderLifted / 1;
|
||||
Color: $ColorRaised;
|
||||
MinimumSize: 12;
|
||||
}
|
||||
|
||||
*.ScrollContainer {
|
||||
Gap: 0;
|
||||
}
|
||||
|
||||
*.Checkbox {
|
||||
Border: $BorderEngraved / 1, $BorderGap / 1, $BorderInnerShadow / 1 0 0 1;
|
||||
Color: $ColorSunken;
|
||||
Padding: 0 1 1 0;
|
||||
MinimumSize: 19;
|
||||
}
|
||||
|
||||
*.Checkbox[focused] {
|
||||
Border: $BorderEngraved / 1, $BorderFocused / 1, $BorderInnerShadow / 1 0 0 1;
|
||||
Color: $ColorSunkenFocused;
|
||||
Padding: 0;
|
||||
}
|
||||
|
||||
*.Checkbox[checked] {
|
||||
Texture: "assets/checkbox-checked.png";
|
||||
TextureMode: center;
|
||||
}
|
||||
|
||||
*.MenuItem {
|
||||
Padding: 4;
|
||||
Gap: 4;
|
||||
Color: #0000;
|
||||
}
|
||||
|
||||
*.MenuItem[hovered] {
|
||||
Color: $ColorDot;
|
||||
}
|
||||
|
||||
*.MenuItem[focused] {
|
||||
Color: $ColorDot;
|
||||
}
|
||||
|
||||
*.File {
|
||||
Color: #0000;
|
||||
}
|
||||
|
||||
*.File[focused] {
|
||||
Color: $ColorDot;
|
||||
}
|
||||
|
||||
*.TearLine {
|
||||
Border: $BorderTearPad / 3, $BorderTear / 1;
|
||||
}
|
||||
|
||||
*.TearLine[hovered] {
|
||||
Border: $BorderTearPadFocused / 3, $BorderTearFocused / 1;
|
||||
}
|
||||
|
||||
*.TearLine[focused] {
|
||||
Border: $BorderTearPadFocused / 3, $BorderTearFocused / 1;
|
||||
}
|
||||
|
||||
*.Calendar {
|
||||
Border: $BorderOuterShadow / 0 1 1 0, $BorderGap / 1;
|
||||
Color: $ColorRaised;
|
||||
Padding: 2;
|
||||
Gap: 2;
|
||||
}
|
||||
|
||||
*.CalendarGrid {
|
||||
Gap: 2 2;
|
||||
}
|
||||
|
||||
*.CalendarWeekdayHeader {
|
||||
Color: $ColorCalendarWeekdayHeader;
|
||||
Padding: 2;
|
||||
}
|
||||
|
||||
*.CalendarDay {
|
||||
Color: $ColorCalendarDay;
|
||||
Padding: 2;
|
||||
MinimumSize: 32;
|
||||
}
|
||||
|
||||
*.CalendarDay[weekend] {
|
||||
Color: $ColorCalendarWeekend;
|
||||
}
|
||||
|
||||
*.TabbedContainer {
|
||||
Gap: 0;
|
||||
}
|
||||
|
||||
*.TabRow {
|
||||
Border: $BorderEngraved / 1 1 0 1, $BorderGap / 1 1 0 1, $BorderInnerShadow / 1 0 0 1;
|
||||
Color: $ColorSunken;
|
||||
Gap: 0;
|
||||
Padding: 1 0 0 0;
|
||||
}
|
||||
|
||||
*.Tab {
|
||||
Border: #0000 / 1 0 0 0, $BorderOuterShadow / 0 1 0 0, $BorderGap / 1 1 0 1, $BorderLifted / 1;
|
||||
Color: $ColorSunken;
|
||||
Padding: 4 8 2 8;
|
||||
}
|
||||
|
||||
*.Tab[active] {
|
||||
Border: $BorderOuterShadow / 0 1 0 0, $BorderGap / 1 1 0 1, $BorderLifted / 1 1 0 1;
|
||||
Color: $ColorBackground;
|
||||
Padding: 4 8;
|
||||
}
|
||||
|
||||
*.TabSpacer {
|
||||
Border: $BorderLifted / 0 0 1 0;
|
||||
MinimumSize: 1 0;
|
||||
}
|
||||
|
||||
*.Swatch {
|
||||
Border: $BorderEngraved / 1, $BorderGap / 1;
|
||||
Color: #FFF;
|
||||
MinimumSize: 19;
|
||||
}
|
||||
|
||||
*.Swatch[focused] {
|
||||
Border: $BorderEngraved / 1, $BorderFocused / 1;
|
||||
}
|
||||
|
||||
*.ColorPickerMap {
|
||||
Border: $BorderEngraved / 1, $BorderGap / 1;
|
||||
Color: $ColorSunken;
|
||||
MinimumSize: 128;
|
||||
}
|
||||
|
||||
*.Dropdown {
|
||||
Border: $BorderEngraved / 1, $BorderGap / 1, $BorderLifted / 1;
|
||||
Padding: 4 8;
|
||||
Color: $ColorRaised;
|
||||
}
|
||||
|
||||
*.Dropdown[focused] {
|
||||
Border: $BorderEngraved / 1, $BorderGap / 1, $BorderLiftedFocused / 1;
|
||||
Padding: 4 8;
|
||||
Color: $ColorRaisedFocused;
|
||||
}
|
||||
|
||||
*.Dropdown[hovered] {
|
||||
Color: $ColorRaisedHovered;
|
||||
}
|
||||
|
||||
*.Dropdown[pressed] {
|
||||
Border: $BorderEngraved / 1, $BorderGap / 1, $BorderInnerShadow / 1 0 0 1;
|
||||
Padding: 5 8 4 9;
|
||||
Color: $ColorRaisedPressed;
|
||||
}
|
||||
BIN
internal/styles/aluminum/assets/checkbox-checked.png
Normal file
|
After Width: | Height: | Size: 105 B |
|
Before Width: | Height: | Size: 409 B After Width: | Height: | Size: 409 B |
@@ -61,7 +61,7 @@ func New () (*style.Style, event.Cookie) {
|
||||
atlasTexture := tomo.NewTexture(atlasImage)
|
||||
|
||||
textureCheckboxChecked := atlasTexture.SubTexture(image.Rect( 0, 0, 12, 11))
|
||||
textureCorkboard := atlasTexture.SubTexture(image.Rect(16, 0, 28, 12))
|
||||
// textureCorkboard := atlasTexture.SubTexture(image.Rect(16, 0, 28, 12))
|
||||
textureTearLine := atlasTexture.SubTexture(image.Rect(16, 12, 18, 13))
|
||||
textureHandleVertical := atlasTexture.SubTexture(image.Rect(28, 0, 29, 2))
|
||||
textureHandleHorizontal := atlasTexture.SubTexture(image.Rect(28, 0, 30, 1))
|
||||
@@ -160,8 +160,8 @@ rules := []style.Rule {
|
||||
Width: tomo.I(1, 0, 0, 1),
|
||||
Color: borderColorEngraved,
|
||||
}),
|
||||
tomo.AColor(nil),
|
||||
tomo.ATexture(textureCorkboard),
|
||||
tomo.AColor(tomo.ColorSunken),
|
||||
// tomo.ATexture(textureCorkboard),
|
||||
tomo.APadding(8),
|
||||
), tomo.R("", "Container"), "sunken"),
|
||||
|
||||
@@ -189,6 +189,11 @@ rules := []style.Rule {
|
||||
tomo.AAlign(tomo.AlignMiddle, tomo.AlignMiddle),
|
||||
), tomo.R("", "Heading")),
|
||||
|
||||
// *.Heading
|
||||
style.Ru(style.AS (
|
||||
tomo.APadding(4, 8),
|
||||
), tomo.R("", "Heading"), "menu"),
|
||||
|
||||
// *.Separator
|
||||
style.Ru(style.AS (
|
||||
tomo.AttrBorder {
|
||||
@@ -258,6 +263,65 @@ rules := []style.Rule {
|
||||
tomo.ATexture(textureHandleHorizontal),
|
||||
), tomo.R("", "SliderHandle"), "horizontal"),
|
||||
|
||||
// *.Scrollbar
|
||||
style.Ru(style.AS (
|
||||
tomo.AttrBorder {
|
||||
outline,
|
||||
tomo.Border {
|
||||
Width: tomo.I(1, 0, 0, 1),
|
||||
Color: borderColorEngraved,
|
||||
},
|
||||
},
|
||||
tomo.AttrColor { Color: colorGutter },
|
||||
tomo.AttrPadding(tomo.I(0, 1, 1, 0)),
|
||||
), tomo.R("", "Scrollbar")),
|
||||
|
||||
// *.Scrollbar[focused]
|
||||
style.Ru(style.AS (
|
||||
tomo.ABorder (
|
||||
outline,
|
||||
tomo.Border {
|
||||
Width: tomo.I(1),
|
||||
Color: borderColorFocused,
|
||||
}),
|
||||
tomo.APadding(0),
|
||||
), tomo.R("", "Scrollbar"), "focused"),
|
||||
|
||||
// *.Scrollbar[horizontal]
|
||||
style.Ru(style.AS (
|
||||
tomo.AMinimumSize(48, 0),
|
||||
), tomo.R("", "Scrollbar"), "horizontal"),
|
||||
|
||||
// *.Scrollbar[vertical]
|
||||
style.Ru(style.AS (
|
||||
tomo.AMinimumSize(0, 48),
|
||||
), tomo.R("", "Scrollbar"), "vertical"),
|
||||
|
||||
// *.ScrollbarHandle
|
||||
style.Ru(style.AS (
|
||||
tomo.ABorder (
|
||||
outline,
|
||||
tomo.Border {
|
||||
Width: tomo.I(1),
|
||||
Color: borderColorLifted,
|
||||
},
|
||||
tomo.Border {
|
||||
Width: tomo.I(1),
|
||||
Color: [4]color.Color {
|
||||
tomo.ColorRaised, tomo.ColorRaised,
|
||||
tomo.ColorRaised, tomo.ColorRaised,
|
||||
},
|
||||
}),
|
||||
tomo.AColor(nil),
|
||||
tomo.ATexture(textureHandleVertical),
|
||||
tomo.AMinimumSize(12, 12),
|
||||
), tomo.R("", "ScrollbarHandle")),
|
||||
|
||||
// *.ScrollbarHandle[horizontal]
|
||||
style.Ru(style.AS (
|
||||
tomo.ATexture(textureHandleHorizontal),
|
||||
), tomo.R("", "ScrollbarHandle"), "horizontal"),
|
||||
|
||||
// *.ScrollContainer
|
||||
style.Ru(style.AS (
|
||||
tomo.AGap(0, 0),
|
||||
@@ -498,7 +562,7 @@ rules := []style.Rule {
|
||||
Color: borderColorLifted,
|
||||
},
|
||||
},
|
||||
tomo.AttrPadding(tomo.I(4, 8, 4, 8)),
|
||||
tomo.AttrPadding(tomo.I(4, 8, 7, 8)),
|
||||
tomo.AttrColor { Color: tomo.ColorBackground },
|
||||
), tomo.R("", "Tab"), "active"),
|
||||
|
||||
@@ -533,6 +597,43 @@ rules := []style.Rule {
|
||||
tomo.AttrColor { Color: tomo.ColorSunken },
|
||||
tomo.AttrMinimumSize { X: 128, Y: 128 },
|
||||
), tomo.R("", "ColorPickerMap")),
|
||||
|
||||
// *.Dropdown
|
||||
style.Ru(style.AS (
|
||||
tomo.AttrBorder {
|
||||
outline,
|
||||
tomo.Border {
|
||||
Width: tomo.I(1),
|
||||
Color: borderColorLifted,
|
||||
},
|
||||
},
|
||||
tomo.AttrPadding(tomo.I(4, 8)),
|
||||
tomo.AttrColor { Color: tomo.ColorRaised },
|
||||
), tomo.R("", "Dropdown")),
|
||||
|
||||
// *.Dropdown[focused]
|
||||
style.Ru(style.AS (
|
||||
tomo.AttrBorder {
|
||||
outline,
|
||||
tomo.Border {
|
||||
Width: tomo.I(1),
|
||||
Color: borderColorFocused,
|
||||
},
|
||||
},
|
||||
), tomo.R("", "Dropdown"), "focused"),
|
||||
|
||||
// *.Dropdown[pressed]
|
||||
style.Ru(style.AS (
|
||||
tomo.AttrBorder {
|
||||
outline,
|
||||
tomo.Border {
|
||||
Width: tomo.I(1, 0, 0, 1),
|
||||
Color: borderColorEngraved,
|
||||
},
|
||||
},
|
||||
tomo.AttrPadding(tomo.I(5, 8, 4, 9)),
|
||||
tomo.AttrColor { Color: colorCarvedPressed },
|
||||
), tomo.R("", "Dropdown"), "pressed"),
|
||||
}
|
||||
|
||||
return &style.Style {
|
||||
@@ -1,39 +1,36 @@
|
||||
package tss
|
||||
|
||||
import "os"
|
||||
import "io"
|
||||
import "fmt"
|
||||
import "image"
|
||||
import "errors"
|
||||
import "image/color"
|
||||
import "golang.org/x/image/font"
|
||||
import "github.com/flopp/go-findfont"
|
||||
import _ "image/png"
|
||||
import "path/filepath"
|
||||
import "git.tebibyte.media/tomo/tomo"
|
||||
import "golang.org/x/image/font/opentype"
|
||||
import "git.tebibyte.media/tomo/tomo/event"
|
||||
import "git.tebibyte.media/tomo/tomo/canvas"
|
||||
import "git.tebibyte.media/tomo/backend/style"
|
||||
|
||||
type styleBuilder struct {
|
||||
sheet Sheet
|
||||
fonts map[string] *opentype.Font
|
||||
faces map[faceKey] font.Face
|
||||
}
|
||||
|
||||
type faceKey struct {
|
||||
name string
|
||||
size int
|
||||
workingDir string
|
||||
textures map[string] canvas.TextureCloser
|
||||
}
|
||||
|
||||
// BuildStyle builds a Tomo style from the specified sheet. Resources associated
|
||||
// with it (such as textures) can be freed by closing the returned cookie.
|
||||
func BuildStyle (sheet Sheet) (*tomo.Style, event.Cookie, error) {
|
||||
func BuildStyle (sheet Sheet) (*style.Style, event.Cookie, error) {
|
||||
builder := &styleBuilder {
|
||||
sheet: sheet,
|
||||
fonts: make(map[string] *opentype.Font),
|
||||
faces: make(map[faceKey] font.Face),
|
||||
workingDir: filepath.Dir(sheet.Path),
|
||||
}
|
||||
return builder.build()
|
||||
}
|
||||
|
||||
func (this *styleBuilder) build () (*tomo.Style, event.Cookie, error) {
|
||||
func (this *styleBuilder) build () (*style.Style, event.Cookie, error) {
|
||||
// ensure the sheet is flattened (all vars are resolved)
|
||||
err := this.sheet.Flatten()
|
||||
if err != nil { return nil, nil, err }
|
||||
|
||||
@@ -48,9 +45,10 @@ func (this *styleBuilder) build () (*tomo.Style, event.Cookie, error) {
|
||||
return color.RGBA { R: 255, B: 255, A: 255 }
|
||||
}
|
||||
|
||||
// construct style and get colors
|
||||
cookies := []event.Cookie { }
|
||||
style := &tomo.Style {
|
||||
Rules: make([]tomo.Rule, len(this.sheet.Rules)),
|
||||
sty := &style.Style {
|
||||
Rules: make([]style.Rule, len(this.sheet.Rules)),
|
||||
Colors: map[tomo.Color] color.Color {
|
||||
tomo.ColorBackground: getColor("ColorBackground"),
|
||||
tomo.ColorForeground: getColor("ColorForeground"),
|
||||
@@ -60,14 +58,15 @@ func (this *styleBuilder) build () (*tomo.Style, event.Cookie, error) {
|
||||
},
|
||||
}
|
||||
|
||||
// build style rules from the sheet's rule slice
|
||||
for index, rule := range this.sheet.Rules {
|
||||
styleRule := tomo.Rule {
|
||||
styleRule := style.Rule {
|
||||
Role: tomo.Role {
|
||||
Package: rule.Selector.Package,
|
||||
Object: rule.Selector.Object,
|
||||
},
|
||||
Tags: rule.Selector.Tags,
|
||||
Set: make(tomo.AttrSet),
|
||||
Set: make(style.AttrSet),
|
||||
}
|
||||
for name, attr := range rule.Attrs {
|
||||
styleAttr, cookie, err := this.buildAttr(name, attr)
|
||||
@@ -77,13 +76,15 @@ func (this *styleBuilder) build () (*tomo.Style, event.Cookie, error) {
|
||||
cookies = append(cookies, cookie)
|
||||
}
|
||||
}
|
||||
style.Rules[index] = styleRule
|
||||
sty.Rules[index] = styleRule
|
||||
}
|
||||
|
||||
// TODO include all the faces in this.faces (ONCE EACH) in the
|
||||
// multicookie
|
||||
// add each texture to the cookies list
|
||||
for _, texture := range this.textures {
|
||||
cookies = append(cookies, closerCookie { Closer: texture })
|
||||
}
|
||||
|
||||
return style, event.MultiCookie(cookies...), nil
|
||||
return sty, event.MultiCookie(cookies...), nil
|
||||
}
|
||||
|
||||
func (this *styleBuilder) buildAttr (name string, attr []ValueList) (tomo.Attr, event.Cookie, error) {
|
||||
@@ -173,7 +174,14 @@ func (this *styleBuilder) buildAttr (name string, attr []ValueList) (tomo.Attr,
|
||||
return nil, nil, errWrongType()
|
||||
|
||||
case "Texture":
|
||||
// TODO load image from file
|
||||
err := expectSingleSingle()
|
||||
if err != nil { return nil, nil, err }
|
||||
if name, ok := attr[0][0].(ValueString); ok {
|
||||
texture, err := this.texture(string(name))
|
||||
if err != nil { return nil, nil, err }
|
||||
return tomo.ATexture(texture), nil, nil
|
||||
}
|
||||
return nil, nil, errWrongType()
|
||||
|
||||
case "TextureMode":
|
||||
err := expectSingleSingle()
|
||||
@@ -238,6 +246,7 @@ func (this *styleBuilder) buildAttr (name string, attr []ValueList) (tomo.Attr,
|
||||
return nil, nil, errWrongType()
|
||||
|
||||
case "Face":
|
||||
// TODO support weight, italic, slant
|
||||
err := expectSingle()
|
||||
if err != nil { return nil, nil, err }
|
||||
list := attr[0]
|
||||
@@ -250,9 +259,10 @@ func (this *styleBuilder) buildAttr (name string, attr []ValueList) (tomo.Attr,
|
||||
if !ok { return nil, nil, errWrongType() }
|
||||
size, ok := list[1].(ValueNumber)
|
||||
if !ok { return nil, nil, errWrongType() }
|
||||
face, err := this.face(string(name), int(size))
|
||||
if err != nil { return nil, nil, err }
|
||||
return tomo.AFace(face), nil, nil
|
||||
return tomo.AFace(tomo.Face {
|
||||
Font: string(name),
|
||||
Size: float64(size),
|
||||
}), nil, nil
|
||||
|
||||
case "Wrap":
|
||||
err := expectSingleSingle()
|
||||
@@ -311,34 +321,17 @@ func (this *styleBuilder) buildAttr (name string, attr []ValueList) (tomo.Attr,
|
||||
return nil, nil, errors.New(fmt.Sprintf("unimplemented attribute name %s", name))
|
||||
}
|
||||
|
||||
func (this *styleBuilder) face (name string, size int) (font.Face, error) {
|
||||
key := faceKey { name: name, size: size }
|
||||
face, ok := this.faces[key]
|
||||
if ok { return face, nil }
|
||||
|
||||
font, ok := this.fonts[name]
|
||||
if !ok {
|
||||
path, err := findfont.Find(name)
|
||||
if err != nil { return nil, err }
|
||||
func (this *styleBuilder) texture (path string) (canvas.TextureCloser, error) {
|
||||
path = filepath.Join(this.workingDir, path)
|
||||
if texture, ok := this.textures[path]; ok {
|
||||
return texture, nil
|
||||
}
|
||||
file, err := os.Open(path)
|
||||
if err != nil { return nil, err }
|
||||
defer file.Close()
|
||||
fnt, err := opentype.ParseReaderAt(file)
|
||||
if err != nil {
|
||||
return nil, errors.New(fmt.Sprintf (
|
||||
"could not load font %s: %v", path, err))
|
||||
}
|
||||
font = fnt
|
||||
this.fonts[name] = font
|
||||
}
|
||||
|
||||
face, err := opentype.NewFace(font, &opentype.FaceOptions {
|
||||
Size: float64(size),
|
||||
DPI: 96, // TODO: replace this with the actual DPI
|
||||
})
|
||||
rawImage, _, err := image.Decode(file)
|
||||
if err != nil { return nil, err }
|
||||
this.faces[key] = face
|
||||
return face, nil
|
||||
return tomo.NewTexture(rawImage), nil
|
||||
}
|
||||
|
||||
func buildAttrBorder (attr []ValueList) (tomo.Attr, error) {
|
||||
@@ -406,3 +399,9 @@ func copyBorderValue[T any, U ~[]T] (destination, source U) bool {
|
||||
}
|
||||
}
|
||||
|
||||
type closerCookie struct {
|
||||
io.Closer
|
||||
}
|
||||
func (cookie closerCookie) Close () {
|
||||
cookie.Closer.Close()
|
||||
}
|
||||
@@ -133,8 +133,8 @@ func (this *parser) parseSelector () (Selector, error) {
|
||||
// tags
|
||||
err = this.ExpectNext(LBracket)
|
||||
if err == nil {
|
||||
this.Next()
|
||||
for {
|
||||
this.Next()
|
||||
err := this.Expect(Ident, String, RBracket)
|
||||
if err != nil { return Selector { }, err }
|
||||
if this.Is(RBracket) { break }
|
||||
@@ -142,6 +142,7 @@ func (this *parser) parseSelector () (Selector, error) {
|
||||
selector.Tags = append(selector.Tags, this.Value())
|
||||
err = this.ExpectNext(Comma, RBracket)
|
||||
if err != nil { return Selector { }, err }
|
||||
if this.Is(RBracket) { break }
|
||||
}
|
||||
this.Next()
|
||||
}
|
||||
@@ -1,10 +1,11 @@
|
||||
package tss
|
||||
|
||||
import "os"
|
||||
import "git.tebibyte.media/tomo/tomo"
|
||||
import "git.tebibyte.media/tomo/tomo/event"
|
||||
import "git.tebibyte.media/tomo/backend/style"
|
||||
|
||||
type Sheet struct {
|
||||
Path string
|
||||
Variables map[string] ValueList
|
||||
Rules []Rule
|
||||
flat bool
|
||||
@@ -65,7 +66,7 @@ func (ValueCut) value () { }
|
||||
|
||||
// LoadFile loads the stylesheet from the specified file. This may return a
|
||||
// parse.Error, so use parse.Format to print it.
|
||||
func LoadFile (name string) (*tomo.Style, event.Cookie, error) {
|
||||
func LoadFile (name string) (*style.Style, event.Cookie, error) {
|
||||
// TODO check cache for gobbed sheet. if the cache is nonexistent or
|
||||
// invalid, then open/load/cache.
|
||||
|
||||
@@ -75,5 +76,6 @@ func LoadFile (name string) (*tomo.Style, event.Cookie, error) {
|
||||
|
||||
sheet, err := Parse(Lex(name, file))
|
||||
if err != nil { return nil, nil, err }
|
||||
sheet.Path = name
|
||||
return BuildStyle(sheet)
|
||||
}
|
||||
35
internal/styles/tss/tss.yaml
Normal file
@@ -0,0 +1,35 @@
|
||||
# Happen to use Micro to edit text?
|
||||
# Drop this in ~/.config/micro/syntax and get syntax highlighting for TSS files!
|
||||
|
||||
filetype: tss
|
||||
|
||||
detect:
|
||||
filename: "\\.tss$"
|
||||
|
||||
rules:
|
||||
- type: "\\b([A-Z][a-zA-Z0-9]*).*:"
|
||||
- identifier.var: "\\$[a-zA-Z0-9]*\\b"
|
||||
- identifier.class: "(\\*|[a-z][a-zA-Z0-9]*)\\.(\\*|[A-Z][a-zA-Z0-9]*)"
|
||||
- constant: "\\b(tile|center)\\b"
|
||||
- constant: "\\b(start|middle|end|even)\\b"
|
||||
- constant.bool: "\\b(true|false)\\b"
|
||||
- special: "(\\/|,|\\;|:|\\.)"
|
||||
- symbol.operator: "(=|\\*)"
|
||||
- symbol.brackets: "(\\{\\[|\\}\\])"
|
||||
|
||||
- comment:
|
||||
start: "//"
|
||||
end: "$"
|
||||
rules:
|
||||
- todo: "(TODO|XXX|FIXME|BUG):?"
|
||||
|
||||
- constant.string:
|
||||
start: "\""
|
||||
end: "\""
|
||||
skip: "\\\\."
|
||||
rules:
|
||||
- constant.specialChar: "\\\\[abfnrtv'\\\"\\\\]"
|
||||
- constant.specialChar: "\\\\([0-7]{3})"
|
||||
|
||||
- constant.number: "\\b[0-9][0-9.]*\\b"
|
||||
- constant.string: "\\B#[0-9a-fA-F]*"
|
||||