ref: 0c44bd66e976d09c7aad8c6081d8b590832cea46
parent: 4ad4061b5cc8479f7adc5b22071fc851d6f8a30a
author: Philip Silva <philip.silva@protonmail.com>
date: Thu May 22 12:29:50 EDT 2025
more module path updates
--- a/anim/anim.go
+++ b/anim/anim.go
@@ -5,11 +5,11 @@
"9fans.net/go/draw/memdraw"
"image"
"time"
- "xui"
- "xui/events"
- "xui/internal/color"
- "xui/layout"
- "xui/space"
+ "github.com/psilva261/xui"
+ "github.com/psilva261/xui/events"
+ "github.com/psilva261/xui/internal/color"
+ "github.com/psilva261/xui/layout"
+ "github.com/psilva261/xui/space"
)
type Interface interface {
--- a/box/box.go
+++ b/box/box.go
@@ -7,12 +7,12 @@
//"log"
"runtime"
"sync"
- "xui/element"
- "xui/events"
- "xui/events/mouse"
- "xui/internal/color"
- "xui/layout"
- "xui/space"
+ "github.com/psilva261/xui/element"
+ "github.com/psilva261/xui/events"
+ "github.com/psilva261/xui/events/mouse"
+ "github.com/psilva261/xui/internal/color"
+ "github.com/psilva261/xui/layout"
+ "github.com/psilva261/xui/space"
)
type Interface = element.Interface
@@ -110,7 +110,7 @@
ims := make([]*memdraw.Image, len(b.Elements))
wg := sync.WaitGroup{}
for i, el := range b.Elements {
- if /* otherwise an error happens */false && runtime.GOARCH != "arm64" {
+ if false /* not working right now */ && runtime.GOARCH != "arm64" {
wg.Add(1)
go func(ii int) {
ims[ii] = el.Render() //b.boxImg, b.Rs[i].Min)
--- a/box/box_test.go
+++ b/box/box_test.go
@@ -6,11 +6,11 @@
"image"
imagecolor "image/color"
"testing"
- "xui/element"
- "xui/internal/color"
- "xui/label"
- "xui/space"
- "xui/xuitest"
+ "github.com/psilva261/xui/element"
+ "github.com/psilva261/xui/internal/color"
+ "github.com/psilva261/xui/label"
+ "github.com/psilva261/xui/space"
+ "github.com/psilva261/xui/xuitest"
)
func TestMarginPadding(t *testing.T) {
--- a/button/button.go
+++ b/button/button.go
@@ -4,14 +4,14 @@
"9fans.net/go/draw"
"9fans.net/go/draw/memdraw"
"image"
- "xui"
- "xui/events"
- "xui/events/mouse"
- "xui/internal/color"
- "xui/internal/font"
- "xui/internal/geom"
- "xui/space"
- "xui/layout"
+ "github.com/psilva261/xui"
+ "github.com/psilva261/xui/events"
+ "github.com/psilva261/xui/events/mouse"
+ "github.com/psilva261/xui/font"
+ "github.com/psilva261/xui/internal/color"
+ "github.com/psilva261/xui/internal/geom"
+ "github.com/psilva261/xui/space"
+ "github.com/psilva261/xui/layout"
)
type Interface interface {
--- a/cmd/hello/hello.go
+++ b/cmd/hello/hello.go
@@ -9,16 +9,16 @@
"image/gif"
"log"
"os"
- "xui"
- "xui/anim"
- "xui/box"
- "xui/button"
- "xui/element"
- "xui/events"
- "xui/events/mouse"
- "xui/field"
- "xui/label"
- "xui/space"
+ "github.com/psilva261/xui"
+ "github.com/psilva261/xui/anim"
+ "github.com/psilva261/xui/box"
+ "github.com/psilva261/xui/button"
+ "github.com/psilva261/xui/element"
+ "github.com/psilva261/xui/events"
+ "github.com/psilva261/xui/events/mouse"
+ "github.com/psilva261/xui/field"
+ "github.com/psilva261/xui/label"
+ "github.com/psilva261/xui/space"
)
func Main() (err error) {
--- a/element/element.go
+++ b/element/element.go
@@ -3,9 +3,9 @@
import (
"9fans.net/go/draw/memdraw"
"image"
- "xui/events"
- "xui/layout"
- "xui/space"
+ "github.com/psilva261/xui/events"
+ "github.com/psilva261/xui/layout"
+ "github.com/psilva261/xui/space"
)
type Interface interface {
--- a/field/field.go
+++ b/field/field.go
@@ -7,15 +7,15 @@
"image"
"log"
"sync"
- "xui"
- "xui/events"
- "xui/events/keyboard"
- "xui/events/mouse"
- "xui/internal/color"
- "xui/internal/font"
- "xui/internal/geom"
- "xui/layout"
- "xui/space"
+ "github.com/psilva261/xui"
+ "github.com/psilva261/xui/events"
+ "github.com/psilva261/xui/events/keyboard"
+ "github.com/psilva261/xui/events/mouse"
+ "github.com/psilva261/xui/font"
+ "github.com/psilva261/xui/internal/color"
+ "github.com/psilva261/xui/internal/geom"
+ "github.com/psilva261/xui/layout"
+ "github.com/psilva261/xui/space"
)
const (
--- a/field/field_test.go
+++ b/field/field_test.go
@@ -3,10 +3,10 @@
import (
"9fans.net/go/draw"
"9fans.net/go/draw/memdraw"
+ "github.com/psilva261/xui/events/keyboard"
+ "github.com/psilva261/xui/xuitest"
"image"
"testing"
- "xui/events/keyboard"
- "xui/xuitest"
)
func TestRender(t *testing.T) {
--- /dev/null
+++ b/font/font.go
@@ -1,0 +1,80 @@
+package font
+
+import (
+ "9fans.net/go/draw"
+ "9fans.net/go/draw/memdraw"
+ "fmt"
+ "golang.org/x/image/font"
+ "golang.org/x/image/font/plan9font"
+ "golang.org/x/image/math/fixed"
+ "image"
+ "io/ioutil"
+ "log"
+ "path"
+ "path/filepath"
+ imagedraw "image/draw"
+)
+
+func Open(name string) (face font.Face, err error) {
+ if name == "" {
+ name = FontFile()
+ }
+
+ readFile := func(name string) ([]byte, error) {
+ return ioutil.ReadFile(filepath.FromSlash(path.Join(FontDir(), name)))
+ }
+ fontData, err := readFile(name)
+ if err != nil {
+ log.Fatal(err)
+ }
+ face, err = plan9font.ParseFont(fontData, readFile)
+ if err != nil {
+ log.Fatal(err)
+ }
+ return
+}
+
+func String(text string) (textImg *memdraw.Image, err error) {
+ face, err := Open("")
+ if err != nil {
+ return nil, fmt.Errorf("open font: %w", err)
+ }
+ ascent := face.Metrics().Ascent.Ceil()
+
+ w := 0
+ for _, r := range text {
+ bounds, adv, _ := face.GlyphBounds(r)
+ _ = bounds
+ w += adv.Ceil()
+ }
+ r := image.Rect(0, 0, w, 2*ascent)
+ if r.Dx() == 0 {
+ r.Max.X = r.Min.X + 1
+ }
+ if r.Dy() == 0 {
+ r.Max.Y = r.Min.Y + 1
+ }
+ dst := image.NewRGBA(r)
+ imagedraw.Draw(dst, dst.Bounds(), image.White, image.Point{}, imagedraw.Src)
+ d := &font.Drawer{
+ Dst: dst,
+ Src: image.Black,
+ Face: face,
+ Dot: fixed.P(0, ascent),
+ }
+ d.DrawString(text)
+
+ log.Printf("String: dst.Bounds()=%+v", dst.Bounds())
+
+ textImg, err = memdraw.AllocImage(dst.Bounds(), draw.ABGR32)
+ if err != nil {
+ panic(fmt.Errorf("allocimage: %s", err).Error())
+ }
+
+ _, err = memdraw.Load(textImg, dst.Bounds(), dst.Pix, false)
+ if err != nil {
+ panic(err.Error())
+ }
+
+ return
+}
--- /dev/null
+++ b/font/font_plan9.go
@@ -1,0 +1,9 @@
+package font
+
+func FontDir() string {
+ return "/lib/font/bit/lucida"
+}
+
+func FontFile() string {
+ return "unicode.9.font"
+}
--- /dev/null
+++ b/font/font_test.go
@@ -1,0 +1,51 @@
+package font
+
+import (
+ //"9fans.net/go/draw"
+ "9fans.net/go/draw/memdraw"
+ "image"
+ "image/color"
+ "testing"
+ "github.com/psilva261/xui/xuitest"
+)
+
+func TestString(t *testing.T) {
+ memdraw.Init()
+ colors, dashBbox := testString(t, "----")
+ t.Logf("colors=%+v", colors)
+ t.Logf("dashBbox=%+v", dashBbox)
+ if dashBbox.Dx() < 5 || dashBbox.Dy() < 1 {
+ t.Fail()
+ }
+ colors, underBbox := testString(t, "____")
+ t.Logf("colors=%+v", colors)
+ t.Logf("underBbox=%+v", underBbox)
+ if underBbox.Dx() < 5 || underBbox.Dy() < 1 {
+ t.Fail()
+ }
+ if underBbox.Min.X >= dashBbox.Min.X {
+ t.Fail()
+ }
+}
+
+func TestStringEmpty(t *testing.T) {
+ memdraw.Init()
+ _, dashBbox := testString(t, "")
+ t.Logf("dashBbox=%v", dashBbox)
+}
+
+func testString(t *testing.T, text string) (map[color.Color]int, image.Rectangle) {
+ img, err := String(text)
+ if err != nil {
+ t.Fail()
+ }
+
+ info, err := xuitest.Analyze(img)
+ if err != nil {
+ panic(err.Error())
+ }
+ colors := info.Colors
+ bbox := info.Bbox
+
+ return colors, bbox
+}
\ No newline at end of file
--- /dev/null
+++ b/font/font_unix.go
@@ -1,0 +1,15 @@
+//go:build !plan9
+package font
+
+import (
+ "os"
+ "path"
+)
+
+func FontDir() string {
+ return path.Join(os.Getenv("PLAN9"), "/font/luc")
+}
+
+func FontFile() string {
+ return "unicode.18.font"
+}
--- a/internal/font/font.go
+++ /dev/null
@@ -1,68 +1,0 @@
-package font
-
-import (
- "9fans.net/go/draw"
- "9fans.net/go/draw/memdraw"
- "fmt"
- "golang.org/x/image/font"
- "golang.org/x/image/font/plan9font"
- "golang.org/x/image/math/fixed"
- "image"
- "io/ioutil"
- "log"
- "path"
- "path/filepath"
- imagedraw "image/draw"
-)
-
-func String(text string) (textImg *memdraw.Image, err error) {
- readFile := func(name string) ([]byte, error) {
- return ioutil.ReadFile(filepath.FromSlash(path.Join(FontDir(), name)))
- }
- fontData, err := readFile(FontFile())
- if err != nil {
- log.Fatal(err)
- }
- face, err := plan9font.ParseFont(fontData, readFile)
- if err != nil {
- log.Fatal(err)
- }
- ascent := face.Metrics().Ascent.Ceil()
-
- w := 0
- for _, r := range text {
- bounds, adv, _ := face.GlyphBounds(r)
- _ = bounds
- w += adv.Ceil()
- }
- r := image.Rect(0, 0, w, 2*ascent)
- if r.Dx() == 0 {
- r.Max.X = r.Min.X + 1
- }
- if r.Dy() == 0 {
- r.Max.Y = r.Min.Y + 1
- }
- dst := image.NewRGBA(r)
- imagedraw.Draw(dst, dst.Bounds(), image.White, image.Point{}, imagedraw.Src)
- d := &font.Drawer{
- Dst: dst,
- Src: image.Black,
- Face: face,
- Dot: fixed.P(0, ascent),
- }
- d.DrawString(text)
-
- log.Printf("String: dst.Bounds()=%+v", dst.Bounds())
-
- textImg, err = memdraw.AllocImage(dst.Bounds(), draw.ABGR32)
- if err != nil {
- panic(fmt.Errorf("allocimage: %s", err).Error())
- }
-
- _, err = memdraw.Load(textImg, dst.Bounds(), dst.Pix, false)
- if err != nil {
- panic(err.Error())
- }
-
- return
-}
--- a/internal/font/font_plan9.go
+++ /dev/null
@@ -1,9 +1,0 @@
-package font
-
-func FontDir() string {
- return "/lib/font/bit/lucida"
-}
-
-func FontFile() string {
- return "unicode.9.font"
-}
--- a/internal/font/font_test.go
+++ /dev/null
@@ -1,51 +1,0 @@
-package font
-
-import (
- //"9fans.net/go/draw"
- "9fans.net/go/draw/memdraw"
- "image"
- "image/color"
- "testing"
- "xui/xuitest"
-)
-
-func TestString(t *testing.T) {
- memdraw.Init()
- colors, dashBbox := testString(t, "----")
- t.Logf("colors=%+v", colors)
- t.Logf("dashBbox=%+v", dashBbox)
- if dashBbox.Dx() < 5 || dashBbox.Dy() < 1 {
- t.Fail()
- }
- colors, underBbox := testString(t, "____")
- t.Logf("colors=%+v", colors)
- t.Logf("underBbox=%+v", underBbox)
- if underBbox.Dx() < 5 || underBbox.Dy() < 1 {
- t.Fail()
- }
- if underBbox.Min.X >= dashBbox.Min.X {
- t.Fail()
- }
-}
-
-func TestStringEmpty(t *testing.T) {
- memdraw.Init()
- _, dashBbox := testString(t, "")
- t.Logf("dashBbox=%v", dashBbox)
-}
-
-func testString(t *testing.T, text string) (map[color.Color]int, image.Rectangle) {
- img, err := String(text)
- if err != nil {
- t.Fail()
- }
-
- info, err := xuitest.Analyze(img)
- if err != nil {
- panic(err.Error())
- }
- colors := info.Colors
- bbox := info.Bbox
-
- return colors, bbox
-}
\ No newline at end of file
--- a/internal/font/font_unix.go
+++ /dev/null
@@ -1,15 +1,0 @@
-//go:build !plan9
-package font
-
-import (
- "os"
- "path"
-)
-
-func FontDir() string {
- return path.Join(os.Getenv("PLAN9"), "/font/luc")
-}
-
-func FontFile() string {
- return "unicode.18.font"
-}
--- a/label/label.go
+++ b/label/label.go
@@ -3,10 +3,10 @@
import (
"9fans.net/go/draw/memdraw"
"image"
- "xui/events"
- "xui/internal/font"
- "xui/layout"
- "xui/space"
+ "github.com/psilva261/xui/events"
+ "github.com/psilva261/xui/font"
+ "github.com/psilva261/xui/layout"
+ "github.com/psilva261/xui/space"
)
type Interface interface {
--- a/label/label_test.go
+++ b/label/label_test.go
@@ -5,7 +5,7 @@
"image"
"image/color"
"testing"
- "xui/xuitest"
+ "github.com/psilva261/xui/xuitest"
)
func TestRender(t *testing.T) {
--- a/space/space.go
+++ b/space/space.go
@@ -2,7 +2,7 @@
import (
"image"
- "xui/space/offset"
+ "github.com/psilva261/xui/space/offset"
)
type Sp struct {
--- a/xui.go
+++ b/xui.go
@@ -1,7 +1,7 @@
package xui
import (
- "xui/element"
+ "github.com/psilva261/xui/element"
"9fans.net/go/draw"
"9fans.net/go/draw/memdraw"
"fmt"
@@ -10,10 +10,10 @@
"log"
"sync"
"time"
- "xui/events/keyboard"
- "xui/events/mouse"
- //"xui/internal/color"
- "xui/space"
+ "github.com/psilva261/xui/events/keyboard"
+ "github.com/psilva261/xui/events/mouse"
+ //"github.com/psilva261/xui/internal/color"
+ "github.com/psilva261/xui/space"
)
const (
--- a/xuitest/xuitest.go
+++ b/xuitest/xuitest.go
@@ -7,8 +7,8 @@
"image/color"
"image/png"
"os"
- "xui/element"
- "xui/space"
+ "github.com/psilva261/xui/element"
+ "github.com/psilva261/xui/space"
)
type Xui struct {
--
⑨