Comments (14)
Aha, played a bit with the generator and it turns out I just needed to add the namespace:
{Name: "vte-2.91-gtk4", Namespaces: []string{"Vte-3"}},
No idea what the difference between Vte-2 and Vte-3 is though
from gotk4.
I almost got it working (repo), but the most important function vte_pty_spawn_async
is missing, making it rather useless 😄
Debug output gives a hint, it's because Glib.Pid
is skipped
girgen: debug: package vte/v3: filtering type GLib.Pid (C.GPid) using filter types.absoluteFilter, trace: github.com/diamondburned/gotk4/gir/cmd/gir-generate/gendata.init @ gendata.go:348
girgen: debug: package vte/v3: ignored type GLib.Pid
girgen: debug: package vte/v3: callback TerminalSpawnAsyncCallback (C.): C arg2 -> Go _pid (in): can't resolve C.GPid
girgen: debug: package vte/v3: callback TerminalSpawnAsyncCallback (C.): C arg2 -> Go _pid (in): cannot resolve type
girgen: debug: package vte/v3: callback TerminalSpawnAsyncCallback (C.): C arg2 -> Go _pid (in): no conversion
girgen: debug: package vte/v3: callback TerminalSpawnAsyncCallback (C.): has no conversion
gotk4/gir/cmd/gir-generate/gendata/gendata.go
Line 348 in 132b31b
Pid is an int on Linux and a process handle on Windows h
gtk-rs supports this: https://github.com/gi-rust/glib-sys/blob/cd5bf488b32b01cff76da88100ab9c7d2478fe9d/lib.rs#L86-L90
We could probably do something similar with go tags if we extend the generator. Thoughts? I'll probably try once I find the time, but perhaps you have some pointers
from gotk4.
The easiest way to do this is to add GPID
in as a built-in for core/glib
. You can then add special code for this in types
, typeconv
and the callable
generators. It's kind of a pain to do it, but it's the easiest way.
from gotk4.
It might be best to declare the built-in as type PID C.GPid
rather than using build tags.
from gotk4.
Out of curiosity, have you tried combining vte.Pty
with os/exec.Command
? It looks like you could allocate a new Pty
and use its fd
as the value for cmd.Stdout
?
Also, Pty
should be strcased to be PTY
.
from gotk4.
Potentially this...
Code
package main
import (
"context"
"os/exec"
"github.com/creack/pty"
"github.com/diamondburned/gotk4/pkg/core/glib"
"github.com/diamondburned/gotk4/pkg/gio/v2"
"github.com/diamondburned/gotk4/pkg/gtk/v4"
"github.com/jgillich/gotk4-vte/pkg/vte/v3"
)
func main() {
app := gtk.NewApplication("so.libdb.gotk4-vte-test", gio.ApplicationFlagsNone)
app.ConnectActivate(func() { activate(app) })
app.Run(nil)
}
func activate(app *gtk.Application) {
terminal := vte.NewTerminal()
terminal.SetSize(80, 24)
go func() {
tty, err := pty.Start(exec.Command("bash"))
if err != nil {
panic(err)
}
pty, err := vte.NewPtyForeignSync(context.Background(), int(tty.Fd()))
if err != nil {
panic(err)
}
glib.IdleAdd(func() {
terminal.SetPty(pty)
})
}()
win := gtk.NewApplicationWindow(app)
win.SetTitle("VTE Example")
win.SetChild(terminal)
win.Show()
}
from gotk4.
strcases:
Pty
->PTY
Tty
->TTY
Icu
->ICU
Cjk
->CJK
Sixel
->SIXEL
from gotk4.
How's this!
from gotk4.
Windows compatibility will need to be tested... Note that (*os.File).Fd()
on Windows returns a uintptr
! Our NewPtyForeignSync
is not portable because it still takes in an int
there...
It might be a good idea to manually create a vte_windows.go
file with a type Fd = uintptr
, then generate NewPtyForeignSync
to use Fd
instead of int
.
from gotk4.
Haha nice! Looks like I could've saved myself a lot of pain. creack/pty doesn't support Windows at all, but VTE's pty should work too...
#129 does at least compile now, but it's likely going to explode at runtime 😄
from gotk4.
but VTE's pty should work too...
You might still want to get its functions working then... I can pick up the glib.PID
PR in a few days likely. It seems to be a fairly important type.
Does glib have an Fd
type already as well? We could add that in also.
from gotk4.
terminal.PtyNewSync
already works, it's only the spawn function that's missing. At first I couldn't figure out how to hook it up, but after some Unix 101 I realized I needed a tty from the pty. Copied a few lines from creack/pty for now as I couldn't find it in VTE. https://github.com/getseabird/seabird/blob/535cce58b5d1919c5bc04b04d3e2cb54c9c52b8c/ui/terminal_page_unix.go#L43
But it appears that VTE doesn't support Windows at all. Bummer for my cross-platform app
from gotk4.
But it appears that VTE doesn't support Windows at all.
Oh, I actually didn't know that at all...
from gotk4.
But it appears that VTE doesn't support Windows at all.
Yes, there's a 5 year old issue, https://gitlab.gnome.org/GNOME/vte/-/issues/86. And it doesn't look likely that it'll be addressed any time soon.
from gotk4.
Related Issues (20)
- SetShowArrow seems to be missing on gtk.DropDown HOT 1
- Widget memory is not freed when removed HOT 14
- Add core/glib.PID built-in
- Panic in ListBox.ConnectRowSelected HOT 10
- Error compiling using mingw HOT 6
- Add a definition for GTK_INVALID_LIST_POSITION HOT 2
- GtkListView scroll_to missing HOT 1
- Segmentation fault when calling widget functions inside a goroutine HOT 4
- DragEnd on DragSource not being fired when dragged outside of app HOT 1
- Error when initializing listview with empty list HOT 2
- ConnectCommandLine, how to close remote application? HOT 1
- Missing: Information trees HOT 14
- gtk.Picture memory leak HOT 1
- gioutil.ListModel.Item() not returning concrete Go type anymore HOT 2
- Error Building For Windows HOT 1
- errors when trying to build with GH Actions HOT 3
- PHP Warning: Undefined array key "menudirection" in log HOT 2
- could not determine kind of name for C.g_date_time_new_from_unix_local_usec HOT 3
- Investigate new `unique` package to replace `intern`
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gotk4.