0

I want to get back the value list from an ncurses FIELD with type TYPE_ENUM. The value list has been set with this code:

const char* val_lst[] = { "type 1", "type 2", "type 3", NULL };
set_field_type(fields[OPT_VAL_FLD], TYPE_ENUM, val_lst, 0, 1);

Is this possible, and if so, how? I have seen the function

char *field_arg(FIELD *field);

but could not interpret the pointer it returns.

HJP
  • 67
  • 1
  • 6

1 Answers1

0

That

char *field_arg(FIELD *field);

doesn't look like ncurses. It's been void* since the initial version in 1995. SVr4 used char*.

Either way, the result from field_arg is a pointer to an opaque structure called the argument block. That is because each field-type has a different set of arguments which are copied into the argument block.

If you need to know the layout of the argument block, you would have to look at the source code (which differs between implementations):

typedef struct
  {
    char **kwds;
    int count;
    bool checkcase;
    bool checkunique;
  }
enumARG;
typedef struct 
{
    char **choices;
    unsigned num_choices;
    bool ignore_case;
    bool exact;
} enum_args;
typedef struct {

    char ** list;
    int checkcase;
    int checkuniq;
    int count;
} ENUM;
Thomas Dickey
  • 51,086
  • 7
  • 70
  • 105
  • I must have seen it here https://docs.oracle.com/cd/E23824_01/html/821-1471/field-arg-3curses.html – HJP Dec 14 '20 at 05:54