/* The model picker's lines (modelpanel.c), in the settings panel's frame (panel.h): a box over the
* transcript, the rows above the footer, or one line. A view with no storage, as panel.c is: the caller
* loads the models (pic models --json), filters and orders them, and says what Enter does; this lays
* them out in aligned columns under a heading per provider, and maps a click back to a row. */
#ifndef PIC_TUI_MODELPANEL_H
#define PIC_TUI_MODELPANEL_H
#include <stddef.h>
#include "width.h"
/* One row: a model, or one of the picker's own actions (model starts with \x01). */
typedef struct {
const char *model; /* provider/id */
const char *name; /* its display name ("" or the id: none shown) */
const char *price; /* "$3/$15" per million tokens in/out, "" when unknown */
const char *status; /* "default", "no key", "key refused", "from proxy", ... joined, or "" */
const char *key; /* which key the model uses (#73); NULL in every row: no column */
const char *about; /* an action row's description */
long window; /* its context window in tokens, 0 when unknown */
int avail; /* its provider has a key */
int warn; /* the status is a problem with the key (refused, no credit, rate-limited) */
} tui_mrow;
/* What is shown: ORDER[0..N) index ROWS, SEL is the selected one of them. */
typedef struct {
const tui_mrow *rows;
const size_t *order;
size_t n, sel;
int grouped; /* a heading where the provider changes, and ids without it */
const char *filter; /* what is typed */
const char *current; /* the model in use: ticked */
const char *enter; /* the description's last line: what Enter does now */
const char *hints; /* the keys; wrapped, never cut */
const char *more; /* a dim line at the end of the list ("" or NULL: none) */
} tui_mlist;
typedef struct {
size_t top; /* the first list line shown */
size_t page; /* list lines last drawn */
int form; /* TUI_PANEL_* last drawn */
} tui_mview;
/* List lines for M: its rows, a heading per provider when grouped, the "more" line. */
size_t tui_mpanel_list_len(const tui_mlist *m);
/* The box's lines other than the list at WIDTH: borders, filter, separator, description, wrapped keys. */
size_t tui_mpanel_chrome(const tui_mlist *m, size_t width);
/* The lines, appended to OUT, as tui_panel_lines gives the settings panel's: BOX (WIDTH at least 24) is
* LIST + tui_mpanel_chrome lines; DOCK a title, the filter, LIST lines, the description and the keys;
* LINE the selected model and the keys. The cursor in the filter at *crow, *ccol (-1: hidden). 0 or -1. */
int tui_mpanel_lines(tui_mview *v, const tui_mlist *m, int form, size_t width, size_t list, tui_lines *out, int *crow,
int *ccol);
/* Line LINE of the lines last drawn: the index into ORDER of the row there, or -1 (a heading, a border,
* the filter, a "more" line). */
long tui_mpanel_click(const tui_mview *v, const tui_mlist *m, size_t line);
#endif