0

I am trying to use janet c api on ncurses and I am not getting what I expected.

I tried to define the function as such on the c file

static Janet jgetyx(int32_t argc, Janet *argv){
  janet_fixarity(argc, 1);
  WINDOW *win = (WINDOW *) janet_getpointer(argv, 0);
  int y, x; 
  getyx(win, y, x);
  int *yxpos[2] = {y, x};
  return janet_wrap_array((JanetArray *) &yxpos);
}

And I called the defined function like so

(nc/mvwprintw win 2 2 (string (get info 1) " " (get info 0)))

But my result was

          this is the header─┐
          │this is a box     │
          │ 4.64148e-310 3.458
          46e-323            │
          │                  │
          │                  │
          │                  │
          │                  │
          │                  │
          └──────────────────┘

I expected to have the values on the second line of the box, but instead I got the memory address for what it seems... My rusty knowledge of c cannot bring me any closer to the solution...

Could anyone help me?

The code can be found here on test/term-info.janet.

Thx!

1 Answers1

0

I also asked on the repository issues. A way that works is:

int y, x;
getyx(win, y, x);
JanetArray *arr = janet_array(2);
janet_array_push(arr, janet_wrap_integer(y));
janet_array_push(arr, janet_wrap_integer(x));
return janet_wrap_array(arr);