summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2021-06-07 11:21:53 +0200
committerYorhel <git@yorhel.nl>2021-06-07 11:21:55 +0200
commitd910ed8b9f2442db3453b59b490c7c528483b21a (patch)
tree06971eb01542587bdc5a3e3961088e6f78f60fab
parent40f9dff5d6dfb62935d37a6bfabdb9578bec4a2a (diff)
Add workaround for Zig bug on FreeBSD
The good news is: apart from this little thing, everything seems to just work(tm) on FreeBSD. Think I had more trouble with C because of minor header file differences.
-rw-r--r--src/ncurses_refs.c3
-rw-r--r--src/ui.zig3
2 files changed, 5 insertions, 1 deletions
diff --git a/src/ncurses_refs.c b/src/ncurses_refs.c
index ed1a4c3..bcaeb3d 100644
--- a/src/ncurses_refs.c
+++ b/src/ncurses_refs.c
@@ -21,3 +21,6 @@ chtype ncdu_acs_urcorner() { return ACS_URCORNER; }
chtype ncdu_acs_lrcorner() { return ACS_LRCORNER; }
chtype ncdu_acs_hline() { return ACS_VLINE ; }
chtype ncdu_acs_vline() { return ACS_HLINE ; }
+
+/* https://github.com/ziglang/zig/issues/8947 */
+void ncdu_init_pair(short a,b,c) { init_pair(a,b,c); }
diff --git a/src/ui.zig b/src/ui.zig
index 3f3129f..3c7e0ab 100644
--- a/src/ui.zig
+++ b/src/ui.zig
@@ -184,6 +184,7 @@ extern fn ncdu_acs_urcorner() c.chtype;
extern fn ncdu_acs_lrcorner() c.chtype;
extern fn ncdu_acs_hline() c.chtype;
extern fn ncdu_acs_vline() c.chtype;
+extern fn ncdu_init_pair(idx: c_short, fg: c_short, bg: c_short) void;
const StyleAttr = struct { fg: i16, bg: i16, attr: u32 };
const StyleDef = struct {
@@ -334,7 +335,7 @@ pub fn init() void {
_ = c.start_color();
_ = c.use_default_colors();
- for (styles) |s, i| _ = c.init_pair(@intCast(i16, i+1), s.style().fg, s.style().bg);
+ for (styles) |s, i| _ = ncdu_init_pair(@intCast(i16, i+1), s.style().fg, s.style().bg);
inited = true;
}