commit: 8957ea66ba0f027b9e810dab7725341f07359e37
parent eebd8aa52002de6977bc72a1213a2e93cd3a5f00
Author: Michael Forney <mforney@mforney.org>
Date: Sun, 30 May 2021 00:47:43 -0700
Add netbsd-curses
Diffstat:
10 files changed, 324 insertions(+), 0 deletions(-)
diff --git a/.gitmodules b/.gitmodules
@@ -206,6 +206,10 @@
[submodule "pkg/ncompress/src"]
path = pkg/ncompress/src
url = https://github.com/vapier/ncompress.git
+[submodule "pkg/netbsd-curses/src"]
+ path = pkg/netbsd-curses/src
+ url = https://github.com/oasislinux/netbsd-curses.git
+ ignore = all
[submodule "pkg/netsurf/src"]
path = pkg/netsurf/src
url = https://github.com/oasislinux/netsurf
diff --git a/pkg/gen.lua b/pkg/gen.lua
@@ -77,6 +77,7 @@ subgen 'mtdev'
subgen 'mupdf'
subgen 'musl'
subgen 'nasm'
+subgen 'netbsd-curses'
subgen 'ncompress'
subgen 'ncurses'
subgen 'netsurf'
diff --git a/pkg/netbsd-curses/.gitignore b/pkg/netbsd-curses/.gitignore
@@ -0,0 +1 @@
+/tools.ninja
diff --git a/pkg/netbsd-curses/gen.lua b/pkg/netbsd-curses/gen.lua
@@ -0,0 +1,140 @@
+cflags{
+ '-Wall', '-Wpedantic',
+ '-D _XOPEN_SOURCE=700',
+ '-D TERMINFO_DB',
+ ([[-D '_PATH_TERMINFO="%s/share/misc/terminfo"']]):format(config.prefix),
+ '-I $srcdir/compat',
+ '-I $srcdir/lib/libcurses',
+ '-I $srcdir/lib/libterminfo',
+ '-I $srcdir/lib/libform',
+ '-I $srcdir/lib/libmenu',
+ '-I $srcdir/lib/libpanel',
+ '-I $outdir',
+}
+
+sub('tools.ninja', function()
+ toolchain(config.host)
+ cflags{
+ '-I $srcdir/compat',
+ '-I $srcdir/lib/libterminfo',
+ }
+ set('outdir', '$outdir/host')
+
+ cc('compat/mi_vector_hash.c')
+ build('cc', '$outdir/hash.c.o', '$outdir/../hash.c')
+
+ exe('nbperf', [[
+ usr.bin/nbperf/(
+ nbperf.c
+ nbperf-bdz.c nbperf-chm.c nbperf-chm3.c
+ graph2.c graph3.c
+ )
+ compat/mi_vector_hash.c.o
+ ]])
+
+ exe('tic', [[
+ usr.bin/tic/tic.c
+ lib/libterminfo/compile.c
+ compat/cdbw.c
+ compat/mi_vector_hash.c.o
+ hash.c.o
+ ]])
+end)
+
+pkg.hdrs = {
+ copy('$outdir/include', '$srcdir/lib/libcurses', {'curses.h', 'unctrl.h'}),
+ copy('$outdir/include', '$srcdir/lib/libterminfo', {'term.h', 'termcap.h'}),
+ copy('$outdir/include', '$srcdir/lib/libpanel', {'panel.h'}),
+ install=true,
+}
+pkg.deps = {
+ '$outdir/compiled_terms.c',
+ '$outdir/termcap_hash.c',
+ '$outdir/hash.c',
+}
+
+rule('tic', '$outdir/host/tic $ticflags -o $out $in $terms')
+build('tic', '$outdir/compiled_terms.c', {'$srcdir/share/terminfo/terminfo', '|', '$outdir/host/tic'}, {
+ ticflags='-Sx',
+ terms='dumb',
+})
+build('tic', '$outdir/terminfo.cdb', {'$srcdir/share/terminfo/terminfo', '|', '$outdir/host/tic'}, {
+ ticflags='-x',
+ terms='ansi dumb vt100 vt220 xterm xterm-256color st st-256color',
+})
+file('share/misc/terminfo.cdb', '644', '$outdir/terminfo.cdb')
+
+rule('genhash', 'TOOL_NBPERF=$outdir/host/nbperf $srcdir/lib/libterminfo/genhash $in >$out')
+build('genhash', '$outdir/hash.c', {
+ '$srcdir/lib/libterminfo/term.h',
+ '|', '$srcdir/lib/libterminfo/genhash', '$outdir/host/nbperf',
+})
+
+rule('genthash', 'TOOL_NBPERF=$outdir/host/nbperf $srcdir/lib/libterminfo/genthash $in >$out')
+build('genthash', '$outdir/termcap_hash.c', {
+ '$srcdir/lib/libterminfo/termcap_map.c',
+ '|', '$srcdir/lib/libterminfo/genthash', '$outdir/host/nbperf',
+})
+
+lib('libcurses.a', [[
+ lib/libcurses/(
+ acs.c addbytes.c addch.c addchnstr.c addnstr.c attributes.c
+ background.c bell.c border.c box.c chgat.c clear.c clearok.c
+ clrtobot.c clrtoeol.c color.c copywin.c cr_put.c
+ ctrace.c cur_hash.c curs_set.c
+ curses.c delch.c deleteln.c delwin.c echochar.c erase.c fileio.c
+ flushok.c fullname.c getch.c getstr.c getyx.c id_subwins.c idlok.c
+ idcok.c immedok.c inch.c inchstr.c initscr.c insch.c insdelln.c
+ insertln.c insstr.c instr.c keypad.c keyname.c leaveok.c line.c
+ meta.c mouse.c move.c
+ mvwin.c newwin.c nodelay.c notimeout.c overlay.c overwrite.c pause.c
+ printw.c putchar.c refresh.c resize.c ripoffline.c scanw.c screen.c
+ scroll.c scrollok.c setterm.c slk.c standout.c syncok.c timeout.c
+ toucholap.c touchwin.c tstp.c tty.c unctrl.c underscore.c version.c
+
+ cchar.c add_wch.c add_wchstr.c addwstr.c echo_wchar.c ins_wch.c
+ ins_wstr.c get_wch.c get_wstr.c in_wch.c in_wchstr.c
+ inwstr.c
+ )
+ libterminfo.a
+]])
+
+lib('libterminfo.a', [[
+ lib/libterminfo/(
+ term.c ti.c setupterm.c curterm.c tparm.c tputs.c
+ compile.c
+ termcap.c
+ )
+ compat/cdbr.c
+ compat/mi_vector_hash.c
+ $outdir/hash.c
+]])
+
+lib('libpanel.a', [[
+ lib/libpanel/(
+ _deck.c above.c below.c bottom.c del.c getuser.c hidden.c hide.c move.c
+ new.c replace.c setuser.c show.c top.c update.c window.c
+ )
+ libcurses.a.d
+]])
+
+exe('infocmp', [[usr.bin/infocmp/infocmp.c libterminfo.a]])
+file('bin/infocmp', '755', '$outdir/infocmp')
+exe('tabs', [[usr.bin/tabs/tabs.c libterminfo.a]])
+file('bin/tabs', '755', '$outdir/tabs')
+exe('tic', [[usr.bin/tic/tic.c compat/cdbw.c libterminfo.a]])
+file('bin/tic', '755', '$outdir/tic')
+exe('tput', [[usr.bin/tput/tput.c libterminfo.a]])
+file('bin/tput', '755', '$outdir/tput')
+exe('tset', [[usr.bin/tset/(map.c misc.c set.c term.c tset.c) libterminfo.a]])
+file('bin/tset', '755', '$outdir/tset')
+
+man{
+ 'usr.bin/infocmp/infocmp.1',
+ 'usr.bin/tabs/tabs.1',
+ 'usr.bin/tic/tic.1',
+ 'usr.bin/tput/tput.1',
+ 'usr.bin/tset/tset.1',
+}
+
+fetch 'git'
diff --git a/pkg/netbsd-curses/patch/0001-Use-__fpurge-from-stdio_ext.h.patch b/pkg/netbsd-curses/patch/0001-Use-__fpurge-from-stdio_ext.h.patch
@@ -0,0 +1,33 @@
+From 9c2c3bd4d21bf5f55c2e8a41c8253d152f7ba2f5 Mon Sep 17 00:00:00 2001
+From: Michael Forney <mforney@mforney.org>
+Date: Sat, 29 May 2021 21:45:58 -0700
+Subject: [PATCH] Use __fpurge from stdio_ext.h
+
+---
+ lib/libcurses/tty.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/lib/libcurses/tty.c b/lib/libcurses/tty.c
+index b022ba6..b5e4506 100644
+--- a/lib/libcurses/tty.c
++++ b/lib/libcurses/tty.c
+@@ -34,6 +34,7 @@
+ #include <sys/types.h>
+
+ #include <fcntl.h>
++#include <stdio_ext.h>
+ #include <stdlib.h>
+ #include <termios.h>
+ #include <unistd.h>
+@@ -597,7 +598,7 @@ int
+ flushinp(void)
+ {
+
+- (void)fpurge(_cursesi_screen->infd);
++ (void)__fpurge(_cursesi_screen->infd);
+ return OK;
+ }
+
+--
+2.31.1
+
diff --git a/pkg/netbsd-curses/patch/0002-Remove-duplicate-keymap-sequences-from-st-terminfo.patch b/pkg/netbsd-curses/patch/0002-Remove-duplicate-keymap-sequences-from-st-terminfo.patch
@@ -0,0 +1,50 @@
+From a6d5710b0fa7d79da7addc1ba2f58b28d6823396 Mon Sep 17 00:00:00 2001
+From: Michael Forney <mforney@mforney.org>
+Date: Tue, 1 Jun 2021 00:24:45 -0700
+Subject: [PATCH] Remove duplicate keymap sequences from st terminfo
+
+Otherwise, curses has to make an arbitrary decision about which key
+to use when that sequence is detected.
+---
+ share/terminfo/terminfo | 10 +++++-----
+ 1 file changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/share/terminfo/terminfo b/share/terminfo/terminfo
+index b70fa1c..6e1f3bb 100644
+--- a/share/terminfo/terminfo
++++ b/share/terminfo/terminfo
+@@ -1398,7 +1398,7 @@ qansi-g|QNX ANSI,
+ ind=\E[S, invis=\E[9m,
+ is2=\E>\E[?1l\E[?7h\E[0;10;39;49m, is3=\E(B\E)0,
+ kBEG=\ENn, kCAN=\E[s, kCMD=\E[t, kCPY=\ENs, kCRT=\ENt,
+- kDL=\ENv, kEXT=\ENw, kFND=\ENx, kHLP=\ENy, kHOM=\E[h,
++ kEXT=\ENw, kFND=\ENx, kHLP=\ENy, kHOM=\E[h,
+ kLFT=\E[d, kNXT=\E[u, kOPT=\ENz, kPRV=\E[v, kRIT=\E[c,
+ kbs=^H, kcan=\E[S, kcbt=\E[Z, kclo=\ENc, kclr=\ENa,
+ kcmd=\E[G, kcpy=\E[g, kctab=\E[z, kcub1=\E[D, kcud1=\E[B,
+@@ -6701,10 +6701,10 @@ st-0.6|simpleterm 0.6,
+ il=\E[%p1%dL, il1=\E[L, ind=\n, invis=\E[8m,
+ is2=\E[4l\E>\E[?1034l, kDC=\E[3;2~, kEND=\E[1;2F,
+ kHOM=\E[1;2H, kIC=\E[2;2~, kLFT=\E[1;2D, kNXT=\E[6;2~,
+- kPRV=\E[5;2~, kRIT=\E[1;2C, ka1=\E[1~, ka3=\E[5~, kb2=\EOu,
+- kbs=^?, kc1=\E[4~, kc3=\E[6~, kcbt=\E[Z, kclr=\E[3;5~,
++ kPRV=\E[5;2~, kRIT=\E[1;2C, kb2=\EOu,
++ kbs=^?, kcbt=\E[Z, kclr=\E[3;5~,
+ kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA,
+- kdch1=\E[3~, kdl1=\E[3;2~, ked=\E[1;5F, kel=\E[1;2F,
++ kdch1=\E[3~, kdl1=\E[3;2~, ked=\E[1;5F,
+ kend=\E[4~, kent=\EOM, kf1=\EOP, kf10=\E[21~, kf11=\E[23~,
+ kf12=\E[24~, kf13=\E[1;2P, kf14=\E[1;2Q, kf15=\E[1;2R,
+ kf16=\E[1;2S, kf17=\E[15;2~, kf18=\E[17;2~,
+@@ -6724,7 +6724,7 @@ st-0.6|simpleterm 0.6,
+ kf61=\E[1;4P, kf62=\E[1;4Q, kf63=\E[1;4R, kf7=\E[18~,
+ kf8=\E[19~, kf9=\E[20~, khome=\E[1~, kich1=\E[2~,
+ kil1=\E[2;5~, kind=\E[1;2B, kmous=\E[M, knp=\E[6~,
+- kpp=\E[5~, kri=\E[1;2A, krmir=\E[2;2~, mc0=\E[i, mc4=\E[4i,
++ kpp=\E[5~, kri=\E[1;2A, mc0=\E[i, mc4=\E[4i,
+ mc5=\E[5i, op=\E[39;49m, rc=\E8, rev=\E[7m, ri=\EM,
+ rmacs=\E(B, rmir=\E[4l, rmkx=\E[?1l\E>, rmso=\E[27m,
+ rmul=\E[24m, rs1=\Ec, rs2=\E[4l\E>\E[?1034l, sc=\E7,
+--
+2.31.1
+
diff --git a/pkg/netbsd-curses/patch/0003-Don-t-wrap-when-adding-past-last-line-in-non-scrolli.patch b/pkg/netbsd-curses/patch/0003-Don-t-wrap-when-adding-past-last-line-in-non-scrolli.patch
@@ -0,0 +1,65 @@
+From 5b5cbce58a6ff85174abbdf57ba56db501fe816d Mon Sep 17 00:00:00 2001
+From: Michael Forney <mforney@mforney.org>
+Date: Thu, 3 Jun 2021 00:32:57 -0700
+Subject: [PATCH] Don't wrap when adding past last line in non-scrolling window
+
+X/Open curses says
+
+> If scrolling is disabled, any characters that would extend beyond
+> the last column of the last line are truncated.
+
+However, currently libcurses wraps the cursor back to the beginning
+of the last line.
+
+To fix this, when we try to add a character that would go past the
+end of the last line, leave the cursor where it is. If the character
+goes exactly to the end of the last line, add the character but set
+the cursor to the last column (to match ncurses behavior).
+
+[0] https://pubs.opengroup.org/onlinepubs/7908799/xcurses/intov.html#tag_001_004_002_002
+---
+ lib/libcurses/addbytes.c | 8 +++++---
+ 1 file changed, 5 insertions(+), 3 deletions(-)
+
+diff --git a/lib/libcurses/addbytes.c b/lib/libcurses/addbytes.c
+index 9fd917c..7f88487 100644
+--- a/lib/libcurses/addbytes.c
++++ b/lib/libcurses/addbytes.c
+@@ -459,7 +459,6 @@ _cursesi_addwchar(WINDOW *win, __LINE **lnp, int *y, int *x,
+ if (newx > *(*lnp)->lastchp)
+ *(*lnp)->lastchp = newx;
+ __touchline(win, *y, sx, (int) win->maxx - 1);
+- sx = *x = 0;
+ if (*y == win->scr_b) {
+ if (!(win->flags & __SCROLLOK))
+ return ERR;
+@@ -467,6 +466,7 @@ _cursesi_addwchar(WINDOW *win, __LINE **lnp, int *y, int *x,
+ } else {
+ (*y)++;
+ }
++ sx = *x = 0;
+ lp = &win->alines[*y]->line[0];
+ (*lnp) = win->alines[*y];
+ }
+@@ -547,14 +547,16 @@ _cursesi_addwchar(WINDOW *win, __LINE **lnp, int *y, int *x,
+ if (newx > *(*lnp)->lastchp)
+ *(*lnp)->lastchp = newx;
+ __touchline(win, *y, sx, (int) win->maxx - 1);
+- *x = sx = 0;
+ if (*y == win->scr_b) {
+- if (!(win->flags & __SCROLLOK))
++ if (!(win->flags & __SCROLLOK)) {
++ *x = win->maxx - 1;
+ return ERR;
++ }
+ scroll(win);
+ } else {
+ (*y)++;
+ }
++ *x = sx = 0;
+ lp = &win->alines[*y]->line[0];
+ (*lnp) = win->alines[*y];
+ } else {
+--
+2.31.1
+
diff --git a/pkg/netbsd-curses/patch/0004-Return-early-from-_cursesi_waddbytes-if-_cursesi_add.patch b/pkg/netbsd-curses/patch/0004-Return-early-from-_cursesi_waddbytes-if-_cursesi_add.patch
@@ -0,0 +1,28 @@
+From afe19e9450015024e51f3e694c866fc1e1c20c8f Mon Sep 17 00:00:00 2001
+From: Michael Forney <mforney@mforney.org>
+Date: Thu, 3 Jun 2021 00:42:45 -0700
+Subject: [PATCH] Return early from _cursesi_waddbytes if _cursesi_addwchar
+ fails
+
+This error may indicate that scrolling was required in a non-scrolling
+window, in which case the rest of the string should be truncated.
+---
+ lib/libcurses/addbytes.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/lib/libcurses/addbytes.c b/lib/libcurses/addbytes.c
+index 7f88487..6d50bdf 100644
+--- a/lib/libcurses/addbytes.c
++++ b/lib/libcurses/addbytes.c
+@@ -132,7 +132,7 @@ _cursesi_waddbytes(WINDOW *win, const char *bytes, int count, attr_t attr,
+ #ifdef HAVE_WCHAR
+ (void)memset(&st, 0, sizeof(st));
+ #endif
+- while (count > 0) {
++ while (count > 0 && err == OK) {
+ #ifndef HAVE_WCHAR
+ c = *bytes++;
+ #ifdef DEBUG
+--
+2.31.1
+
diff --git a/pkg/netbsd-curses/src b/pkg/netbsd-curses/src
@@ -0,0 +1 @@
+Subproject commit 5868087773a32f9b3120f01a271b3f8c5e6d2824
diff --git a/pkg/netbsd-curses/ver b/pkg/netbsd-curses/ver
@@ -0,0 +1 @@
+05dcddbb5c r0