feat: add status FIFO and parse status line in client
This commit is contained in:
committed by
Loic Coenen (aider)
parent
791744beeb
commit
5341cb676a
@@ -4,7 +4,7 @@ CFLAGS = -Wall -Wextra -Wpedantic -std=c11
|
||||
all: test_status_parse
|
||||
|
||||
test_status_parse: tests/test_status_parse.c
|
||||
$(CC) $(CFLAGS) -I../src -o test_status_parse tests/test_status_parse.c ../src/tui.c -lncurses
|
||||
$(CC) $(CFLAGS) -Isrc -o test_status_parse tests/test_status_parse.c src/tui.c -lncurses
|
||||
|
||||
test: test_status_parse
|
||||
./test_status_parse
|
||||
|
||||
@@ -63,6 +63,28 @@ typedef struct {
|
||||
} FuzzySearch;
|
||||
static FuzzySearch fuzzy_search = {0};
|
||||
|
||||
/* ---------- Parse status line from engine status FIFO ---------- */
|
||||
typedef enum { STATE_IDLE, STATE_RECORD, STATE_LOOPING, STATE_PAUSED } ChannelState;
|
||||
|
||||
bool parse_status_line(const char *line, int *ch, int *scene, ChannelState *state) {
|
||||
int sta;
|
||||
if (sscanf(line, "CH=%d SC=%d STATE=%d", ch, scene, &sta) == 3) {
|
||||
if (sta >= 0 && sta <= 3) {
|
||||
*state = (ChannelState)sta;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
/* try text-based format */
|
||||
char state_str[32];
|
||||
if (sscanf(line, "CH=%d SC=%d STATE=%31s", ch, scene, state_str) != 3)
|
||||
return false;
|
||||
if (strcmp(state_str, "IDLE") == 0) { *state = STATE_IDLE; return true; }
|
||||
if (strcmp(state_str, "RECORD") == 0) { *state = STATE_RECORD; return true; }
|
||||
if (strcmp(state_str, "LOOPING") == 0) { *state = STATE_LOOPING; return true; }
|
||||
if (strcmp(state_str, "PAUSED") == 0) { *state = STATE_PAUSED; return true; }
|
||||
return false;
|
||||
}
|
||||
|
||||
/* ---------- State to color (dummy: all white) ---------- */
|
||||
static int state_to_color(ClipState s) { (void)s; return COLOR_EMPTY; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user