mjl- / duit Goto Github PK
View Code? Open in Web Editor NEWpure go, cross-platform, MIT-licensed ui toolkit for developers
License: MIT License
pure go, cross-platform, MIT-licensed ui toolkit for developers
License: MIT License
This is awesome.
The tab for mouse focus is a great way to solve a tough ux thing.
I am going to try to build a little bit with this.
It's using opengl under the hood or SDL ? I ask because I am trying to imagine how tough the Windows code will be :)
Anyway great stuff !!
9fans.net/[email protected]: invalid version: unknown revision 000000000000
liangzi@xuan 115 14:19 >./INSTALL
+ Mailing list: https://groups.google.com/group/plan9port-dev
+ Issue tracker: https://github.com/9fans/plan9port/issues/
+ Submitting changes: https://github.com/9fans/plan9port/pulls
* Resetting /config
* Compiler version:
gcc version 7.5.0 (SUSE Linux)
* Building mk...
* Building everything (be patient)...
* Installing everything in /home/xuan/src/plan9/plan9port-master/bin...
* Cleaning up...
* Renaming hard-coded /usr/local/plan9 paths...
* Building web manual...
* Done.
* Add these to your profile environment.
PLAN9=/home/xuan/src/plan9/plan9port-master export PLAN9
PATH=$PATH:$PLAN9/bin export PATH
liangzi@xuan 74 14:27 >PLAN9=/home/xuan/src/plan9/plan9port-master
~/nfs_share/golang/duit
liangzi@xuan 75 14:28 >export PLAN9
~/nfs_share/golang/duit
liangzi@xuan 76 14:28 >PATH=$PATH:$PLAN9/bin export PATH
liangzi@xuan 80 14:31 >vim basic.go
~/nfs_share/golang/duit
liangzi@xuan 81 14:32 >go run basic.go
go: finding module for package github.com/mjl-/duit
go: found github.com/mjl-/duit in github.com/mjl-/duit v0.0.0-20200330125617-580cb0b2843f
go: github.com/mjl-/[email protected] requires
9fans.net/[email protected]: invalid version: unknown revision 000000000000
I'm on windows, when i paste something it shows a square character.
I have a box filled with dinamically added fields.
Can i read them from box.Kids or something similar?
Its a bit confusing what with the repathing.
Cant find it expects "devdraw".. .. Is it in the 9fans.net/go/draw gopath ?
make build
cd /Users/apple/workspace/go/src/github.com/mjl-/duit/examples/basic/ && go build main.go && ./main
2018/04/19 10:04:54 new duit: drawfcall.New: exec: "devdraw": executable file not found in $PATH
make: *** [build] Error 1
My Make file:
# Duit is a Desktop Gui sysem for golang.
LIBPATH=github.com/mjl-/duit
LIBGOPATH=$(GOPATH)/src/$(LIBPATH)
PLAN9_LIBPATH=github.com/9fans/plan9
PLAN9_LIBGOPATH=$(GOPATH)/src/$(PLAN9_LIBPATH)
PLAN9A_LIBPATH=9fans.net/go/draw
PLAN9A_LIBGOPATH=$(GOPATH)/src/$(PLAN9A_LIBPATH)
print:
@echo LIBPATH $(LIBPATH)
@echo LIBGOPATH $(LIBGOPATH)
@echo PLAN9_LIBPATH $(PLAN9_LIBPATH)
@echo PLAN9_LIBGOPATH $(PLAN9_LIBGOPATH)
# check plan9 path is correct
stat $(PLAN9A_LIBGOPATH)
dep:
# duit
go get -u -d $(LIBPATH)
cd $(LIBGOPATH) && dep ensure
# plan9
mkdir -p $(PLAN9_LIBGOPATH)
cd $(PLAN9_LIBGOPATH)/../ && rm -rf plan9 && git clone https://github.com/9fans/plan9port plan9
dep-clean:
rm -rf $(LIBGOPATH)
rm -rf $(PLAN9_LIBGOPATH)
build-all:
cd $(LIBGOPATH) && make
build:
cd $(LIBGOPATH)/examples/basic/ && go build main.go && ./main
In Linux, and unix in general, it is considered quite rude to create a file or directory in $HOME which does not begin with a dot.
Hence you should use $HOME/.config instead of $HOME/lib for the AppDataDir. This would be consistent with Debian policy, the XDG Base Directory Specification, etc...
As I understand, all widgets that should be referenced in another one, e.g. to change the text of a label, have to be declared upfront:
label := &duit.Label{Text: "status: not logged in yet"}
further down, the UI is declared in a nested structure:
dui.Top.UI = &duit.Box{
...
Kids: duit.NewKids(
status,
&duit.Grid{...}
...
This is simple, but has the drawback, that you have to declare the widgets in a chaotic order.
lxn/walk uses a simple trick here in it's declarative package:
You can assign each widget to a pointer, and use this later as a reference.
If we implement something like that in duit, it would look like:
var label **duit.Label
duit.Top.UI = &duit.Box{
...
Kids: duit.NewKids(
&duit.Label{ // we declare the widget in it's usual place
Target: &label, // This get's evaluated later.
},
& duit.Button{
// here we can use the label pointer in the callback.
},
}
The needed change would be, that each UI element, needs a Target as a pointer to itself.
The variables holding the pointer, have to be assigned when building the Top.UI.
I don't know if we need to add another function for this, or use dui.Render
.
Each widget would check it's Target field and if it is not nil, set the pointer to itself.
What do you think? Is it worth it?
Hi.
I wasn't able to build your project, if using gollvm compiler.
~/golang_projects/duit$ go build -i -v -x
WORK=/tmp/go-build288395935get https://proxy.golang.org/github.com/mjl-/go/@v/v0.0.0-20180429123528-fafada5f286e.info
get https://proxy.golang.org/github.com/mjl-/go/@v/v0.0.0-20180429123528-fafada5f286e.info: 200 OK (0.832s)
9fans.net/go/draw/drawfcall
mkdir -p $WORK/b003/
cd $WORK
/home/oceanfish81/gollvm_dist/bin/llvm-goc -fgo-importcfg=/dev/null -c -x c - -o /dev/null || true
cd /home/oceanfish81/go/pkg/mod/github.com/mjl-/[email protected]/draw/drawfcall
/home/oceanfish81/gollvm_dist/bin/llvm-goc -c -O2 -g -m64 -fdebug-prefix-map=$WORK=/tmp/go-build -gno-record-gcc-switches -fgo-pkgpath=9fans.net/go/draw/drawfcall -o $WORK/b003/go.o -I $WORK/b003/importcfgroot ./bit.go ./msg.go ./mux.go9fans.net/go/draw/drawfcall
llvm-goc: /home/oceanfish81/workarea/llvm-project/llvm/tools/gollvm/gofrontend/go/names.cc:595: std::string Type::mangled_name(Gogo ) const: assertion 'c < '0' || c > '9'' failed.
#0 0x0000000000d765f3 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/oceanfish81/gollvm_dist/bin/llvm-goc+0xd765f3)
#1 0x0000000000d7468c llvm::sys::RunSignalHandlers() (/home/oceanfish81/gollvm_dist/bin/llvm-goc+0xd7468c)
#2 0x0000000000d76a85 SignalHandler(int) (/home/oceanfish81/gollvm_dist/bin/llvm-goc+0xd76a85)
#3 0x00007f73143713c0 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x153c0)
#4 0x00007f7313ea218b raise /build/glibc-ZN95T4/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1
#5 0x00007f7313e81859 abort /build/glibc-ZN95T4/glibc-2.31/stdlib/abort.c:81:7
#6 0x000000000051b662 (/home/oceanfish81/gollvm_dist/bin/llvm-goc+0x51b662)
#7 0x00000000004b1397 Type::mangled_name(Gogo) const (/home/oceanfish81/gollvm_dist/bin/llvm-goc+0x4b1397)
#8 0x00000000004b3ec8 Gogo::type_descriptor_name(Type const*, Named_type*) (/home/oceanfish81/gollvm_dist/bin/llvm-goc+0x4b3ec8)
#9 0x0000000000548101 Sort_types::operator()(Type const*, Type const*) const (/home/oceanfish81/gollvm_dist/bin/llvm-goc+0x548101)
#10 0x0000000000547fa9 void std::__1::__sort<Sort_types&, Type const**>(Type const**, Type const**, Sort_types&) (/home/oceanfish81/gollvm_dist/bin/llvm-goc+0x547fa9)
#11 0x0000000000542a1a Export::assign_type_indices(std::__1::vector<Named_object*, std::__1::allocator<Named_object*> > const&) (/home/oceanfish81/gollvm_dist/bin/llvm-goc+0x542a1a)
#12 0x0000000000542261 Export::export_globals(std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&, std::__1::map<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, Package*, std::__1::less<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const, Package*> > > const&, std::__1::map<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, Package*, std::__1::less<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const, Package*> > > const&, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&, Import_init_set const&, Bindings const*, std::__1::unordered_set<Named_object*, std::__1::hash<Named_object*>, std::__1::equal_to<Named_object*>, std::__1::allocator<Named_object*> >) (/home/oceanfish81/gollvm_dist/bin/llvm-goc+0x542261)
#13 0x000000000049253d Gogo::do_exports() (/home/oceanfish81/gollvm_dist/bin/llvm-goc+0x49253d)
#14 0x0000000000479b28 go_parse_input_files(char const**, unsigned int, bool, bool) (/home/oceanfish81/gollvm_dist/bin/llvm-goc+0x479b28)
#15 0x000000000046e933 gollvm::driver::CompileGoImpl::invokeFrontEnd() (/home/oceanfish81/gollvm_dist/bin/llvm-goc+0x46e933)
#16 0x000000000047118b gollvm::driver::CompileGo::performAction(gollvm::driver::Compilation&, gollvm::driver::Action const&, llvm::SmallVector<gollvm::driver::Artifact, 3u> const&, gollvm::driver::Artifact const&) (/home/oceanfish81/gollvm_dist/bin/llvm-goc+0x47118b)
#17 0x0000000000467b12 gollvm::driver::Driver::processAction(gollvm::driver::Action*, gollvm::driver::Compilation&, bool) (/home/oceanfish81/gollvm_dist/bin/llvm-goc+0x467b12)
#18 0x0000000000467c22 gollvm::driver::Driver::processActions(gollvm::driver::Compilation&) (/home/oceanfish81/gollvm_dist/bin/llvm-goc+0x467c22)
#19 0x0000000000460f07 main (/home/oceanfish81/gollvm_dist/bin/llvm-goc+0x460f07)
#20 0x00007f7313e830b3 __libc_start_main /build/glibc-ZN95T4/glibc-2.31/csu/../csu/libc-start.c:342:3
#21 0x000000000045fb2e _start (/home/oceanfish81/gollvm_dist/bin/llvm-goc+0x45fb2e)
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace.
Stack dump:
0. Program arguments: /home/oceanfish81/gollvm_dist/bin/llvm-goc -c -O2 -g -m64 -fdebug-prefix-map=/tmp/go-build288395935=/tmp/go-build -gno-record-gcc-switches -fgo-pkgpath=9fans.net/go/draw/drawfcall -o $WORK/b003/go.o -I $WORK/b003/importcfgroot ../../go/pkg/mod/github.com/mjl-/[email protected]/draw/drawfcall/bit.go ../../go/pkg/mod/github.com/mjl-/[email protected]/draw/drawfcall/msg.go ../../go/pkg/mod/github.com/mjl-/[email protected]/draw/drawfcall/mux.go
Reported that already.
llvm-goc could be installed by
$sudo cp -R * /usr/
after extracting this build.
CC @thanm @cherrymui
I started a replacement for draw
with a shiny backend:
https://github.com/ktye/duitdraw
.
It runs on Windows, but is very basic at the moment.
As I cannot test on other systems right now, I have no comparison. Please tell me if anything behaves differently.
That's just my two duits, there is still a long way to go...
It would be nice to search the currently selected text in Edit UIs with Button3, like in acme.
I implemented this in ktye/duit@b5e969b
This udates the cursor to the match and scrolls it into view.
What I couldn't work out is how to warp the mouse to the new selection.
image/png
and image/jpeg
aren't imported in examples/image/main.go
so the application can not show any image.
Hi,
how can i append a kid (ex: a field) to a box with the click of a button?
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 ???????
The cursor seems to go ~ 1 px too far when arrowing down off the edge of a scrolled List; focus is lost without manual intervention. This is clear in examples/fonts.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.