Closed ghost closed 4 years ago
thanks for your patch. i've forwarded it to roy smarples, the main author of the upstream sources.
i've seen through the site you linked that you sent a mail to https://www.openwall.com/lists/sabotage/2018/11/23/1 . i just want to let you know that that mailing list is currently unmaintained.
small nitpick: the code for the clean target is missing in the Makefile, but i'll tackle that after this gets merged upstream.
(BSD)Makefile: Yes, but I assumed that the (linux) port is based on your code in netbsd-curses/GNUMakefile. GNU make prefers GNUMakefile if it exists.
btw. we plan to use vis editor with netbsd-curses, but we have a problem with that.
just out of curiosity, what makes vis
so desirable ? sounds like just another vim to me.
and it seems to be the only program using these odd unibilium/libtermkey libs authored by the guys of ##perl
.
@rofl0r just out of curiosity, what makes vis so desirable ?
statically linked + lua + netbsd-curses + all lexers, plugins and themes (full installation):
# du -hs /tmp/ports/vis/image/
1.8M /tmp/ports/vis/image
# ls -lh /tmp/ports/vis/image/usr/bin/vis
-r-xr-xr-x 1 root bin 639.4k Nov 26 17:36 /tmp/ports/vis/image/usr/bin/vis
@rofl0r sounds like just another vim to me.
https://github.com/martanne/vis/wiki/Differences-from-Vi(m)
@rofl0r and it seems to be the only program using these odd unibilium/libtermkey libs authored by the guys of ##perl.
unibilium is optional - I want to use netbsd-curses instead.
btw. statically linked neat(vi)
# ls -lh /usr/bin/vi
-r-xr-xr-x 2 root root 90.8K Nov 11 21:49 /usr/bin/vi
After I posted that awk snippet, I realized it isn't quite correct. It matches too much (not only from TISTRS
enum), and doesn't match the last item in the enum (no trailing comma).
Some more work will need to go into names.awk
if it is to be merged upstream.
@michaelforney: and doesn't match the last item in the enum (no trailing comma).
Yes, I also had doubts whether this is correct.
diff -urN netbsd-curses.orig/libterminfo/names.awk netbsd-curses/libterminfo/names.awk
--- netbsd-curses.orig/libterminfo/names.awk Thu Jan 1 00:00:00 1970
+++ netbsd-curses/libterminfo/names.awk Mon Nov 26 15:26:54 2018
@@ -0,0 +1,21 @@
+/TICODE_[a-z]+,/ {
+ names[++numnames] = substr($1, 8, length($1) - 8)
+}
+
+/^#define t_[a-z]+(t)/ {
+ fnames[++numfnames] = substr($2, 3, length($2) - 5)
+}
+
+END {
+ print "\nconst char *const strnames[] = {"
+ for (i = 1; i <= numnames; ++i)
+ print("\t\"" names[i] "\",")
+ print "\t(void *)0,"
+ print "};"
+
+ print "\nconst char *const strfnames[] = {"
+ for (i = 1; i <= numfnames; ++i)
+ print("\t\"" fnames[i] "\",")
+ print "\t(void *)0,"
+ print "};"
+}
btw. MKnames from ncurses https://github.com/mirror/ncurses/blob/master/ncurses/tinfo/MKnames.awk
I don't see the point of returning a list of names terminfo provides like that. You can work out if a terminfo name exists at compile time and runtime like so:
/* runtime */
char *kdown1 = tigetstr("kcud1");
if (kdown1 == (char *)-1)
kdown1 = NULL;
/* compile time */
#ifdef key_down
const char *kdown1 = key_down;
#else
const char *kdown1 = NULL;
#endif
@rsmarples: I don't see the point of returning a list of names terminfo provides like that.
ncurses compatibility?
This means that will have to rewrite the load_terminfo() function in the driver-ti.c in libtermkey.
Even on NetBSD, you can't use (netbsd-)curses if you want to compile the vis editor:
@silentbits happy to be ncurses compatible when it makes sense, but this doesn't make sense to me when you can get the same functionality from portable functions and variables.
libtermkey was deprecated upstream over 5 years ago, they should really look into using something more .... portable.
I'll ask other NetBSD terminfo/curses devs and see if they want to consider this non standard function.
In the meantime, you can get a list of terminfo names by grabbing the output of this command:
infocmp -1 | sed -n -e '1,2d' -e 's/[[:space:]]*\([^,=#]*\).*$/\1/p'
That works with NetBSD curses and ncurses. As it's only used when libtermkey fires up, any performance hit would be negligable.
@rsmarples: I agree with your opinion. The problem is deprecated libtermkey and should be replaced (or removed). I will try to extract the minimum necessary code from libtermkey, and then check what will be necessary to replace this functionality directly in vis. Thank you for your help and advice.
I agree with @rsmarples. I would also note that after getting the capability name the code calls funcname2keysym
anyway and ignores the capability if it doesn't know about it. So I'd say iterating over strfnames[]
just to use only the names the code already knows about is a very roundabout way to do what the code is trying to do.
It looks like as of libtermkey-0.21, it no longer uses strnames
and strfnames
, so I think this issue can be closed.
libtermkey requires strfnames/strnames, which are not currently available in netbsd-curses. The patch was created thanks to the help of Michael Forney.
Best regards, Daniel