Closed dmknght closed 3 years ago
After quick grep, i only see Regex00 in glib
Checked. The error was using glib.Regex00Array
but Regex00Array
is an object of vte and it was defined in vte only. vte.nim
line 686 and 691 has this problem.
Thanks for testing. I don't know much about VTE, it was requested by someone long time ago, I added it and he vanished and never came back. The 00Array types are still an ugly point in gintro, they where used for functions which uses arrays and glib.gslists. These functions generally need manual intervention, we would have to convert from gslist to Nim seq and back. Not that hard, but we would need testing, and I generally I do not know what these functions do at all, so testing them is some effort. The 00Arrays have changed a lot in v0.7.8, most types are now generated automatically, while before I inserted that types manually. Automatic should help when new types arise, hope that new types work out of the box now. I considered for 0.7.8 to remove these 00Array types and go back to ptr or ptr ptr which may compile with less trouble but is not that meaningful for manual inspection. In the end all these 00Array types should be removed.
When it does not compile the simplest way is to add missing 00Array types manually in a file in ~/.nimble/pkgs/gintro-0.7.8/gintro/
For your concrete case, maybe you have to rename such a type to avoid name conflicts.
I will try to fix that soon. Is it for you with Linux or Windows? I assume GTK3, as VTE seems to be not yet available for GTK4? Can you provide some minimal code that I can compile? Note that we have already v0.7.9 available, there was a tiny error in 0.7.8 that made some code refuse to compile and I did not detect that while testing unfortunately.
Oh, just found my own VTE test in Nim forum:
https://forum.nim-lang.org/t/3583#22604
Sad that it never made it in the gintro tests/examples.
nim c t.nim
Hint: used config file '/home/salewski/Nim/config/nim.cfg' [Conf]
Hint: used config file '/home/salewski/Nim/config/config.nims' [Conf]
............................
/home/salewski/.nimble/pkgs/gintro-0.7.8/gintro/vte.nim(693, 23) Error: undeclared identifier: 'Regex00Array'
OK, here is a simple fix: From
https://developer.gnome.org/vte/unstable/VteTerminal.html#vte-terminal-event-check-gregex-simple
https://developer.gnome.org/vte/unstable/VteTerminal.html#vte-terminal-event-check-regex-simple
we learn that VTE uses its own VteRegex and also GRegex.
GRegexArray is missing from glib.nim, as it is not used in glib.nim directly. As I said previously, going back to plain ptr types would have fixed it automatically. You can fix it by just adding a
Regex00Array* = pointer
in the first type section in ~/.nimble/pkgs/gintro-0.7.8/gintro/glib.nim
Fix will be available in next gintro release, but please understand that I will not wast a release number for that small fix. If you should not be able to fix it yourself, then let me know, I can do a github push, but without release. Then you would have to install gintro@head.
I have unfortunately just discovered that VTE is really difficult, and found another bug: VTE uses very long cstringArrays, and when we convert them to seq[string] it can fail, because we assumed that seqs have not more then 16 entries. I dont know if other modules suffer from this also, we may have to fix it. This VTE code compiles and runs for me:
# https://vincent.bernat.im/en/blog/2017-write-own-terminal
import gintro/[gtk, glib, gobject, gio, vte]
proc appActivate(app: Application) =
let window = newApplicationWindow(app)
window.title = "GTK3 & Nim"
window.defaultSize = (600, 200)
let terminal = newTerminal()
var environ = getEnviron()
# echo environ # a really large seq!
environ.setLen(14) # Ugly bug in gintro <= 0.7.9, environGetenv can not handle really long seqs
var command = environ.environGetenv("SHELL")
echo command
var pid = 0
echo terminal.spawnSync({}, nil, ["/bin/bash"], [], {SpawnFlag.leaveDescriptorsOpen}, nil, nil, pid, nil)
window.add(terminal)
showAll(window)
proc main =
let app = newApplication("org.gtk.example")
connect(app, "activate", appActivate)
discard run(app)
main()
Please try
nimble install gintro@#head
that command should install latest fixes. I have added the Regex00Array type to glib.nim and I have also increased the temp variable allocated on stack for seq/array conversion from 16 to 256 entries. Each entry is a pointer, so it now occupies 8*256 bytes, that is 2k. Should be no problem for stack, if that is still too small we may use a global var?
VTE example is now in examples/gtk3/vte.nim
Hi! Sorry for lately reply. I am using Linux, gtk3 i believe. The gintro@head fixed the problem. I fixed the code by changing glib.Regex00Array
to Regex00Array
and this new installation worked too. IDK what is the best fix. Anyway it is fixed. Thank you :D
@StefanSalewski i've installed version 0.7.9 and the problem is still there. I don't know the full code but i tried edit regexes: ptr glib.Regex00Array
to regexes: ptr Regex00Array
in vte.nim and it worked for me because this object is defined in vte.nim
and not in glib.nim
as i mentioned above.
Have you really done
nimble install gintro@#head
There was a github problem when I was pushing the fixes, but it seems that the fixes have made it to github, see
https://github.com/StefanSalewski/gintro/blob/master/tests/gen.nim
elif namespace == "GLib": ... output.writeLine("type\n Regex00Array* = pointer")
I told you that this is the correct fix from GTK API docs, as that procs take a glib parameter. But your fix works also. I have added a note about this in the README, I think only few people are using VTE.
Have just tried threading with GTK and channels, will send a reply to your threading issue now.
Have just veryfied,
nimble install gintro@#head
works for me.
grep Regex00Array ~/.nimble/pkgs/gintro-#head/gintro/glib.nim
Regex00Array* = pointer
I generally do before
nimble unistall gintro
Maybe nimble let old versions alive, my .nimble is
tree .nimble/
.nimble/
├── nimbledata.json
├── packages_official.json
├── packages_temp.json
└── pkgs
└── gintro-#head
├── gintro
│ ├── atk.nim
│ ├── cairoimpl.nim
│ ├── cairo.nim
│ ├── fontconfig.nim
│ ├── freetype2.nim
│ ├── gdk4.nim
│ ├── gdk.nim
│ ├── gdkpixbuf.nim
│ ├── gdkx114.nim
│ ├── gdkx11.nim
│ ├── gimpl.nim
│ ├── gio.nim
│ ├── gisup3.nim
│ ├── gisup4.nim
│ ├── glib.nim
│ ├── gmodule.nim
│ ├── gobject.nim
│ ├── graphene.nim
│ ├── gsk.nim
│ ├── gst.nim
│ ├── gtk4.nim
│ ├── gtk.nim
│ ├── gtksource.nim
│ ├── harfbuzz.nim
│ ├── notify.nim
│ ├── pangocairo.nim
│ ├── pangoft2.nim
│ ├── pango.nim
│ ├── rsvg.nim
│ ├── vte.nim
│ └── xlib.nim
├── gintro.nimble
└── nimblemeta.json
Try to delete other older versions.
Oh i see so the fix is in #head
version and "stable" version like 0.7.9 doesn't work. Okay thank you!
Yes, I told you so. Makes not much sense to make a new release for such a tiny fix. Unfortunately I am already close to 0.99 with the tags, and most Nim GTK users do not use VTE at all.
I guess this is fixed in 0.9.4, closing.
I'm trying to create a new dialog with VTE to call
nyx
program. Nim show me this error while compiling:/home/dmknght/.nimble/pkgs/gintro-0.7.8/gintro/vte.nim(686, 23) Error: undeclared identifier: 'Regex00Array'
My code:The code in lib: