mjl- / duit

pure go, cross-platform, MIT-licensed ui toolkit for developers
MIT License
951 stars 38 forks source link

new dui: drawfcall.New: exec: "devdraw": executable file not found in $PATH #20

Open hellojukay opened 4 years ago

hellojukay commented 4 years ago
hellojukay@local test $ go env
GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/hellojukay/.cache/go-build"
GOENV="/home/hellojukay/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
package main

import (
    "flag"
    "io"
    "log"
    "os"

    "github.com/mjl-/duit"
)

func check(err error, msg string) {
    if err != nil {
        log.Fatalf("%s: %s\n", msg, err)
    }
}

func main() {
    log.SetFlags(0)
    flag.Usage = func() {
        log.Println("usage: duitedit file")
        flag.PrintDefaults()
    }
    flag.Parse()
    args := flag.Args()
    if len(args) != 1 {
        flag.Usage()
        os.Exit(2)
    }

    f, err := os.Open(args[0])
    check(err, "open")

    dui, err := duit.NewDUI("ex/edit", nil)
    check(err, "new dui")

    edit, err := duit.NewEdit(f)
    check(err, "new edit")

    print := &duit.Button{
        Text: "print",
        Click: func() (e duit.Event) {
            rd := edit.Reader()
            n, err := io.Copy(os.Stdout, rd)
            if err != nil {
                log.Printf("error copying text: %s\n", err)
            }
            log.Printf("copied %d bytes\n", n)
            return
        },
    }

    dui.Top.UI = &duit.Box{Kids: duit.NewKids(print, edit)}
    dui.Render()

    for {
        select {
        case e := <-dui.Inputs:
            dui.Input(e)

        case err, ok := <-dui.Error:
            if !ok {
                return
            }
            log.Printf("duit: %s\n", err)
        }
    }
}
hellojukay@local test $ go build main.go 
hellojukay@local test $ ./main 
usage: duitedit file
hellojukay@local test $ ./main main.go 
new dui: drawfcall.New: exec: "devdraw": executable file not found in $PATH

pure golang ???????

mjl- commented 3 years ago

true, you need devdraw. that's why it is "pure go (*)" with the asterisk explained. quite some time ago i attempted to replace devdraw with pure go native ui code. clearly i didn't finish it... it seems possible to do so on win32, x11, wayland, plan9. i didn't find a way to do so on macos. i think my plan was to use pure go native ui code when available, and still fall back to devdraw otherwise (eg macos).