From 02f3d3565602146bbbfce85b2719246f24036cb9 Mon Sep 17 00:00:00 2001 From: Andrew Opalach Date: Tue, 9 Apr 2024 11:24:01 -0400 Subject: Massive restructure and many changes - The server-side list concept is still a wip Signed-off-by: Andrew Opalach --- src/fruits/cap/cap.c | 267 --------------------------------------- src/fruits/cap/cap.h | 55 -------- src/fruits/cap/meson.build | 8 -- src/fruits/cmc/cmc.c | 6 +- src/fruits/cmc/meson.build | 1 + src/fruits/cmc/tui/pager.c | 2 +- src/fruits/cmc/tui/pane_lists.c | 93 ++++++++++++++ src/fruits/cmc/tui/pane_lists.h | 20 +++ src/fruits/cmc/tui/pane_search.c | 27 ++-- src/fruits/cmc/tui/ui.c | 47 ++++--- src/fruits/cmc/tui/ui.h | 2 + src/fruits/sink/sink.c | 9 +- 12 files changed, 172 insertions(+), 365 deletions(-) delete mode 100644 src/fruits/cap/cap.c delete mode 100644 src/fruits/cap/cap.h delete mode 100644 src/fruits/cap/meson.build create mode 100644 src/fruits/cmc/tui/pane_lists.c create mode 100644 src/fruits/cmc/tui/pane_lists.h (limited to 'src/fruits') diff --git a/src/fruits/cap/cap.c b/src/fruits/cap/cap.c deleted file mode 100644 index 3f5f5e8..0000000 --- a/src/fruits/cap/cap.c +++ /dev/null @@ -1,267 +0,0 @@ -#include - -#include "../../cache/handlers/file.h" -#ifdef AKIYO_HAS_CURL -#include "../../cache/handlers/http.h" -#endif - -#include "cap.h" - -void cap_init(struct cap_runner *cap, bool (*callback)(void *, u8, str *, str *, void *), void *userdata) -{ - cap->callback = callback; - cap->userdata = userdata; - al_array_init(cap->lists); -#if CAP_USE_PYTHON - sho_client_init(&cap->search, NULL); -#endif -} - -static struct cap_list *list_from_name(struct cap_runner *cap, str *name) -{ - struct cap_list *list; - al_array_foreach_ptr(cap->lists, i, list) { - if (al_str_eq(&list->name, name)) { - return list; - } - } - return NULL; -} - -static struct cch_entry *entry_for_unique_id(struct cap_runner *cap, str *unique_id) -{ - struct cch_entry *entry = NULL; -#ifdef AKIYO_HAS_CURL - bool is_search = al_str_at(unique_id, 0) == ';'; - if (is_search || al_str_cmp(unique_id, al_str_c("https://"), 0, 8) == 0 || - al_str_cmp(unique_id, al_str_c("http://"), 0, 7) == 0) { -#if CAP_USE_PYTHON - str provider; - str query; - al_str_from(&provider, ""); - al_str_from(&query, ""); - if (al_str_cmp(unique_id, al_str_c("https://twitter.com"), 0, 19) == 0 || - al_str_cmp(unique_id, al_str_c("https://x.com"), 0, 13) == 0) { - al_str_cat(&query, al_str_c("tweet:")); - al_str_cat(&query, unique_id); - al_str_cat(&provider, al_str_c("twitter")); - } else if (al_str_cmp(unique_id, al_str_c("https://instagram.com"), 0, 21) == 0) { - s32 slash = al_str_rfind(unique_id, '/'); - if (slash >= 0) { - al_str_cat(&query, al_str_substr(unique_id, slash + 1, unique_id->len)); - } - al_str_cat(&provider, al_str_c("instagram")); - } else { - if (is_search) { - al_str_cat(&query, al_str_substr(unique_id, 1, unique_id->len)); - } else { - al_str_cat(&query, al_str_c("link:")); - al_str_cat(&query, unique_id); - } - al_str_cat(&provider, al_str_c("youtube")); - } - s32 id = sho_client_create_search(&cap->search, &provider, &query); - al_str_free(&provider); - al_str_free(&query); - if (id < 0) return NULL; - struct sho_search *search = sho_client_get_search(&cap->search, id); - if (!search || !sho_search_from_page(search, 0)) return NULL; - struct sho_result_page *page = &al_array_at(search->pages, 0); - struct sho_post *post; - al_array_foreach_ptr(page->posts, i, post) { - struct sho_post_media *media; - al_array_foreach_ptr(post->media, j, media) { - if (media->url.len > 0) { - entry = cch_handler_http_create(&media->url); - break; - } - } - if (entry) break; - } - sho_client_discard_search(&cap->search, id); -#else - if (!is_search) entry = cch_handler_http_create(unique_id); -#endif - if (entry) entry->handler->maybe_spawn_worker(entry->handler, 0); - } else // { -#endif - entry = cch_handler_file_create(unique_id); - // } - return entry; -} - -static bool buffer_entry(struct cap_runner *cap, struct cap_list *list, struct cap_list_entry *entry) -{ - if (entry->errored) return false; - if (entry->buffer_requested) return true; - entry->entry = entry_for_unique_id(cap, &entry->unique_id); - if (!entry->entry || !cap->callback(cap->userdata, CAP_BUFFER, &list->name, &entry->unique_id, entry->entry)) { - entry->errored = true; - return false; - } - entry->buffer_requested = true; - return true; -} - -static void maybe_cleanup_entries(struct cap_runner *cap, struct cap_list *list) -{ - struct cap_list_entry *entry; - al_array_foreach_ptr(list->entries, i, entry) { - if (entry->buffer_requested && abs(list->current - (s32)i) >= 3) { - cap->callback(cap->userdata, CAP_UNLOAD, &list->name, &entry->unique_id, NULL); - entry->buffer_requested = false; - } - } -} - -static bool list_skip_internal(struct cap_runner *cap, struct cap_list *list, s32 n); - -static void list_pump_internal(struct cap_runner *cap, struct cap_list *list, bool buffer) -{ - s32 size = (s32)list->entries.size; - if (size <= list->current) return; - if (buffer) list->buffer = true; - if (list->set != list->current) { - struct cap_list_entry *entry = &al_array_at(list->entries, list->current); - if (list->swap && !entry->buffer_requested) { - list->swap = false; - return; - } - if (!buffer_entry(cap, list, entry)) { - list_skip_internal(cap, list, list->forward ? 1 : -1); - return; - } - cap->callback(cap->userdata, list->swap ? CAP_SWAP : CAP_SET, &list->name, &entry->unique_id, NULL); - list->set = list->current; - } - if (list->buffer) { - for (s32 i = 1; i <= 2; i++) { - if (list->current + i < size) { - buffer_entry(cap, list, &al_array_at(list->entries, list->current + i)); - list->buffer = false; - } - if (list->current - i >= 0) { - buffer_entry(cap, list, &al_array_at(list->entries, list->current - i)); - } - } - } - maybe_cleanup_entries(cap, list); -} - -bool list_skip_internal(struct cap_runner *cap, struct cap_list *list, s32 n) -{ - s32 size = (s32)list->entries.size; - if (list->current + n < 0 || list->current + n >= size) { - return false; - } - list->current += n; - list->forward = n >= 0; - list_pump_internal(cap, list, false); - return true; -} - -void cap_make_list(struct cap_runner *cap, str *name) -{ - struct cap_list list; - al_str_clone(&list.name, name); - list.current = 0; - list.forward = true; - list.set = -1; - list.idle = false; - list.buffer = false; - list.swap = false; - aki_mutex_init(&list.mutex); - al_array_init(list.entries); - al_array_push(cap->lists, list); -} - -void cap_list_add(struct cap_runner *cap, str *name, str *unique_id) -{ - struct cap_list *list = list_from_name(cap, name); - if (!list) return; - aki_mutex_lock(&list->mutex); - struct cap_list_entry entry; - al_str_clone(&entry.unique_id, unique_id); - entry.entry = NULL; - entry.errored = false; - entry.buffer_requested = false; - al_array_push(list->entries, entry); - if (list->idle && list_skip_internal(cap, list, 1)) { - list->idle = false; - } else { - list_pump_internal(cap, list, false); - } - aki_mutex_unlock(&list->mutex); -} - -bool cap_list_skip(struct cap_runner *cap, str *name, s32 n) -{ - struct cap_list *list = list_from_name(cap, name); - if (!list) return false; - aki_mutex_lock(&list->mutex); - bool ret = list_skip_internal(cap, list, n); - aki_mutex_unlock(&list->mutex); - return ret; -} - -void cap_list_pump(struct cap_runner *cap, str *name, bool buffer) -{ - struct cap_list *list = list_from_name(cap, name); - if (!list) return; - aki_mutex_lock(&list->mutex); - list_pump_internal(cap, list, buffer); - aki_mutex_unlock(&list->mutex); -} - -bool cap_list_set_completed(struct cap_runner *cap, str *name) -{ - struct cap_list *list = list_from_name(cap, name); - if (!list) return false; - aki_mutex_lock(&list->mutex); - list->swap = true; - list->idle = !list_skip_internal(cap, list, 1); - bool ret = !list->idle && list->swap; - list->swap = false; - aki_mutex_unlock(&list->mutex); - return ret; -} - -// https://benpfaff.org/writings/clc/shuffle.html -void cap_list_shuffle(struct cap_runner *cap, str *name) -{ - struct cap_list *list = list_from_name(cap, name); - if (!list) return; - aki_mutex_lock(&list->mutex); - u32 size = list->entries.size; - if (size > 0) { - for (u32 i = 0; i < size - 1; i++) { - u32 j = i + al_rand() / (AL_RAND_MAX / (size - i) + 1); - struct cap_list_entry tmp = al_array_at(list->entries, j); - al_array_at(list->entries, j) = al_array_at(list->entries, i); - al_array_at(list->entries, i) = tmp; - } - list->set = -1; - list_pump_internal(cap, list, false); - } - aki_mutex_unlock(&list->mutex); -} - -static void list_close_internal(struct cap_list *list) -{ - struct cap_list_entry *entry; - al_array_foreach_ptr(list->entries, i, entry) { - al_str_free(&entry->unique_id); - } - al_array_free(list->entries); - aki_mutex_destroy(&list->mutex); - al_str_free(&list->name); -} - -void cap_close(struct cap_runner *cap) -{ - struct cap_list *list; - al_array_foreach_ptr(cap->lists, i, list) { - list_close_internal(list); - } - al_array_free(cap->lists); -} diff --git a/src/fruits/cap/cap.h b/src/fruits/cap/cap.h deleted file mode 100644 index 69d4d6d..0000000 --- a/src/fruits/cap/cap.h +++ /dev/null @@ -1,55 +0,0 @@ -#pragma once - -#define CAP_USE_PYTHON 0 - -#include -#include -#include - -#if CAP_USE_PYTHON -#include "../../shoki/src/search.h" -#endif - -struct cap_list_entry { - str unique_id; - struct cch_entry *entry; - bool buffer_requested; - bool errored; -}; - -struct cap_list { - str name; - s32 current; - bool forward; - s32 set; - bool idle; - bool buffer; - bool swap; - struct aki_mutex mutex; - array(struct cap_list_entry) entries; -}; - -enum { - CAP_BUFFER = 0, - CAP_SET, - CAP_SWAP, - CAP_UNLOAD -}; - -struct cap_runner { - array(struct cap_list) lists; -#if CAP_USE_PYTHON - struct sho_client search; -#endif - bool (*callback)(void *, u8, str *, str *, void *); - void *userdata; -}; - -void cap_init(struct cap_runner *cap, bool (*callback)(void *, u8, str *, str *, void *), void *userdata); -void cap_make_list(struct cap_runner *cap, str *name); -void cap_list_add(struct cap_runner *cap, str *name, str *unique_id); -bool cap_list_skip(struct cap_runner *cap, str *name, s32 n); -void cap_list_pump(struct cap_runner *cap, str *name, bool buffer); -bool cap_list_set_completed(struct cap_runner *cap, str *name); -void cap_list_shuffle(struct cap_runner *cap, str *name); -void cap_close(struct cap_runner *cap); diff --git a/src/fruits/cap/meson.build b/src/fruits/cap/meson.build deleted file mode 100644 index f85ab00..0000000 --- a/src/fruits/cap/meson.build +++ /dev/null @@ -1,8 +0,0 @@ -cap_src = ['cap.c'] -cap_deps = [common_deps] -use_python = true -if use_python - cap_deps += [shoki] -endif -cap = declare_dependency(sources: cap_src, - dependencies: cap_deps) diff --git a/src/fruits/cmc/cmc.c b/src/fruits/cmc/cmc.c index 97ae15d..5bbdb0b 100644 --- a/src/fruits/cmc/cmc.c +++ b/src/fruits/cmc/cmc.c @@ -5,7 +5,7 @@ #include #include -#include "../../tree/common.h" +#include "../../server/common.h" #include "cmc.h" @@ -78,7 +78,7 @@ s32 main(s32 argc, char *argv[]) str module; str query; - str *cmd = al_str_c(argv[1]); + str *cmd = al_str_cr(argv[1]); if (al_str_eq(cmd, al_str_c("search"))) { c.type = CMC_SEARCH; if (argc == 2) { @@ -104,7 +104,7 @@ s32 main(s32 argc, char *argv[]) aki_event_loop_init(&c.loop); camu_client_init(&c.client, &c.loop, client_callback, &c); - if (!camu_client_login(&c.client, al_str_c("andrew"), TREE_SERVER_IP, TREE_PORT)) { + if (!camu_client_login(&c.client, al_str_c("andrew"), CAMU_SERVER_IP, CAMU_PORT)) { goto err; } diff --git a/src/fruits/cmc/meson.build b/src/fruits/cmc/meson.build index 6dd3960..57ded9c 100644 --- a/src/fruits/cmc/meson.build +++ b/src/fruits/cmc/meson.build @@ -4,6 +4,7 @@ cmc_src = [ 'tui/resources.c', 'tui/pager.c', 'tui/view_twitter.c', + 'tui/pane_lists.c', 'tui/pane_search.c' ] cmc_deps = [common_deps, libclient, subproject('stb').get_variable('stb')] diff --git a/src/fruits/cmc/tui/pager.c b/src/fruits/cmc/tui/pager.c index 00c5665..a672315 100644 --- a/src/fruits/cmc/tui/pager.c +++ b/src/fruits/cmc/tui/pager.c @@ -70,7 +70,7 @@ bool cmc_pager_iterate_to_height(struct cmc_pager *pager, u32 height, u32 anchor { u32 y = 0, offset; struct cmc_view_page *page = cmc_pager_page_containing_index(pager, anchor, &offset); - al_assert(page); + if (!page) return false; struct cmc_view *view; do { // If the page is not processed, return out of space as to not display a discontinuity. diff --git a/src/fruits/cmc/tui/pane_lists.c b/src/fruits/cmc/tui/pane_lists.c new file mode 100644 index 0000000..6367e57 --- /dev/null +++ b/src/fruits/cmc/tui/pane_lists.c @@ -0,0 +1,93 @@ +#include "../cmc.h" + +#include "pane_lists.h" +#include "ui.h" + +void cmc_pane_lists_init(struct cmc_pane_lists *pane, struct cmc_ui *ui) +{ + pane->offset = 0; + pane->selected = 0; + pane->list = al_array_at(ui->c->client.state.lists, 0); + pane->ui = ui; +} + +bool cmc_pane_lists_handle_input(struct cmc_pane_lists *pane, struct ncinput *input) +{ + if (!(input->evtype == NCTYPE_PRESS || input->evtype == NCTYPE_UNKNOWN)) return false; + s32 rows = pane->ui->rows - 1; + s32 size = (s32)pane->list->entries.size; + if (input->id == 'j') { + if (pane->selected + 1 < size) { + pane->selected++; + if (pane->selected - pane->offset >= rows) { + pane->offset += rows; + } + return true; + } + } else if (input->id == 'k') { + if (pane->selected - 1 >= 0) { + pane->selected--; + if (pane->selected - pane->offset < 0) { + pane->offset -= rows; + } + return true; + } + } else if (input->id == 'n') { + if (pane->offset + rows < size) { + pane->offset += rows; + pane->selected += rows; + if (pane->selected >= size) { + pane->selected = size - 1; + } + return true; + } + } else if (input->id == 'p') { + if (pane->offset - rows >= 0) { + pane->offset -= rows; + pane->selected -= rows; + return true; + } + } else if (input->id == NCKEY_RETURN) { + camu_client_skipto(&pane->ui->c->client, pane->selected); + } + return false; +} + +bool cmc_pane_lists_handle_input_overlay(struct cmc_pane_lists *pane, struct ncinput *input) +{ + (void)pane; + (void)input; + return false; +} + +void cmc_pane_lists_draw_overlay(struct cmc_pane_lists *pane) +{ + (void)pane; +} + +void cmc_pane_lists_refresh(struct cmc_pane_lists *pane) +{ + struct cmc_ui *ui = pane->ui; + + ncplane_cursor_move_yx(ui->p, 0, 0); + ncplane_erase(ui->p); + notcurses_refresh(ui->nc, NULL, NULL); + notcurses_render(ui->nc); + + str *unique_id; + u32 rows = AL_MIN(pane->list->entries.size - pane->offset, ui->rows - 1); + for (u32 i = pane->offset; i < pane->offset + rows; i++) { + unique_id = &al_array_at(pane->list->entries, i); + if ((s32)i == pane->selected) { + ncplane_set_fg_palindex(ui->p, 4); + } else { + ncplane_set_fg_default(ui->p); + } + u32 cols = AL_MIN(unique_id->len, ui->cols); + for (u32 j = 0; j < cols; j++) { + ncplane_putchar_yx(ui->p, i - pane->offset, j + 1, al_str_at(unique_id, j)); + } + } + + notcurses_render(ui->nc); +} diff --git a/src/fruits/cmc/tui/pane_lists.h b/src/fruits/cmc/tui/pane_lists.h new file mode 100644 index 0000000..323eb52 --- /dev/null +++ b/src/fruits/cmc/tui/pane_lists.h @@ -0,0 +1,20 @@ +#pragma once + +#include +#include + +#include "../../libclient/client.h" + +struct cmc_ui; +struct cmc_pane_lists { + s32 offset; + s32 selected; + struct camu_list *list; + struct cmc_ui *ui; +}; + +void cmc_pane_lists_init(struct cmc_pane_lists *pane, struct cmc_ui *ui); +bool cmc_pane_lists_handle_input(struct cmc_pane_lists *pane, struct ncinput *input); +bool cmc_pane_lists_handle_input_overlay(struct cmc_pane_lists *pane, struct ncinput *input); +void cmc_pane_lists_draw_overlay(struct cmc_pane_lists *pane); +void cmc_pane_lists_refresh(struct cmc_pane_lists *pane); diff --git a/src/fruits/cmc/tui/pane_search.c b/src/fruits/cmc/tui/pane_search.c index 4c14939..002a4d1 100644 --- a/src/fruits/cmc/tui/pane_search.c +++ b/src/fruits/cmc/tui/pane_search.c @@ -27,7 +27,6 @@ void cmc_pane_search_init(struct cmc_pane_search *pane, struct cmc_ui *ui) } if (pane->searches.size > 0) { pane->search = al_array_at(pane->searches, 0); - request_page_internal(pane->ui->c, pane->search, pane->search->search->page); } } @@ -55,8 +54,7 @@ static void add_selected_from_index(struct cmc *c, struct cmc_pager *pager, u32 { struct cmc_view *view = get_view_by_visual_index(pager, pager->selected); if (view && view->post->media.size > index) { - camu_client_add(&c->client, &view->post->unique_id, index); - camu_client_skip(&c->client, 1); + camu_client_add(&c->client, &view->post->unique_id, index, true); } } @@ -71,6 +69,7 @@ bool cmc_pane_search_handle_input(struct cmc_pane_search *pane, struct ncinput * if (pager->selected + 1 >= (s32)pager->count) { if (pager->pending_requests > 0 || pager->find_anchor != PAGE_NONE) return false; if (ON_LAST_PAGE(pager)) return false; + if (pager->count == 0) pager->count = 1; u32 index = pager->anchor + pager->count; pager->find_anchor = PAGE_DOWN; struct cmc_view_page *page = cmc_pager_page_containing_index(pager, index, NULL); @@ -116,7 +115,9 @@ bool cmc_pane_search_handle_input_overlay(struct cmc_pane_search *pane, struct n if (!(input->evtype == NCTYPE_PRESS || input->evtype == NCTYPE_UNKNOWN)) return false; struct cmc_ui *ui = pane->ui; struct cmc_pager *pager = &pane->search->pager; - if (input->id == 'j') { + if (input->id == NCKEY_TAB) { + pager->redraw = true; + } else if (input->id == 'j') { if (ui->overlay.selected + 1 < (s32)pane->searches.size) { ui->overlay.selected++; return true; @@ -137,12 +138,7 @@ bool cmc_pane_search_handle_input_overlay(struct cmc_pane_search *pane, struct n pane->search = al_array_at(pane->searches, ui->overlay.selected); pager = &pane->search->pager; pager->redraw = true; - u32 page = pane->search->search->page; - if (!cmc_get_page_from_num(pager, page)) { - request_page_internal(ui->c, pane->search, page); - } else { - return true; - } + return true; } return false; } @@ -197,6 +193,14 @@ static void draw_selection_line(struct cmc_view *view, u32 y, u32 rows) void cmc_pane_search_refresh(struct cmc_pane_search *pane) { struct cmc_pager *pager = &pane->search->pager; + if (pager->pending_requests > 0) return; + + u32 page = pane->search->search->page; + if (!cmc_get_page_from_num(pager, page)) { + request_page_internal(pane->ui->c, pane->search, page); + return; + } + if (pager->find_anchor == PAGE_UP) { u32 count; // If find_anchor = PAGE_UP, search->anchor is index of the requested view. @@ -204,6 +208,7 @@ void cmc_pane_search_refresh(struct cmc_pane_search *pane) while (anchor >= 0) { count = 0; cmc_pager_iterate_to_height(pager, pane->ui->rows, anchor, &count, NULL, NULL); + // TODO: Handle count == 0. // Is the requested view still visible? if ((s32)(anchor + count) - 1 < pager->anchor) break; anchor--; @@ -249,7 +254,7 @@ void cmc_pane_search_refresh(struct cmc_pane_search *pane) notcurses_refresh(pane->ui->nc, NULL, NULL); } notcurses_render(pane->ui->nc); - if (pager->pending_requests == 0 && pager->count > 0 && !out_of_space && pager->end_of_page == -1) { + if (pager->count > 0 && !out_of_space && pager->end_of_page == -1) { request_page_at_page_offset(pane, pager, (pager->anchor + pager->count) - 1, 1); } } diff --git a/src/fruits/cmc/tui/ui.c b/src/fruits/cmc/tui/ui.c index dac84a7..2c406bd 100644 --- a/src/fruits/cmc/tui/ui.c +++ b/src/fruits/cmc/tui/ui.c @@ -1,4 +1,4 @@ -#include "../../tree/common.h" +#include "../../server/common.h" #include "../cmc.h" @@ -31,6 +31,22 @@ void cmc_ui_toggle_overlay(struct cmc_ui *ui) ui->overlay.active = !ui->overlay.active; } +static void refresh_internal(struct cmc_ui *ui) +{ + switch (ui->pane) { + case CMC_PANE_LIBRARY: + break; + case CMC_PANE_LISTS: + cmc_pane_lists_refresh(&ui->lists); + break; + case CMC_PANE_BROWSE: + break; + case CMC_PANE_SEARCH: + cmc_pane_search_refresh(&ui->search); + break; + } +} + static void input_poll_callback(void *userdata, s32 revents) { struct cmc_ui *ui = (struct cmc_ui *)userdata; @@ -48,13 +64,16 @@ static void input_poll_callback(void *userdata, s32 revents) } else if (input.id == NCKEY_TAB) { cmc_ui_toggle_overlay(ui); do_refresh = true; - ui->search.search->pager.redraw = true; - continue; } switch (ui->pane) { case CMC_PANE_LIBRARY: break; case CMC_PANE_LISTS: + if (ui->overlay.active) { + do_refresh |= cmc_pane_lists_handle_input_overlay(&ui->lists, &input); + } else { + do_refresh |= cmc_pane_lists_handle_input(&ui->lists, &input); + } break; case CMC_PANE_BROWSE: break; @@ -68,18 +87,7 @@ static void input_poll_callback(void *userdata, s32 revents) } } } while (1); - if (!do_refresh) return; - switch (ui->pane) { - case CMC_PANE_LIBRARY: - break; - case CMC_PANE_LISTS: - break; - case CMC_PANE_BROWSE: - break; - case CMC_PANE_SEARCH: - cmc_pane_search_refresh(&ui->search); - break; - } + if (do_refresh) refresh_internal(ui); } static s32 resize_cb(struct ncplane *p) @@ -110,11 +118,12 @@ bool cmc_ui_open(struct cmc_ui *ui, struct cmc *c) ui->c = c; + cmc_pane_lists_init(&ui->lists, ui); cmc_pane_search_init(&ui->search, ui); - if (!cmc_resources_connect(&ui->resources, ui->nc, &ui->c->loop, TREE_SERVER_IP, TREE_RESOURCE_PORT)) { - return false; - } + //if (!cmc_resources_connect(&ui->resources, ui->nc, &ui->c->loop, CAMU_SERVER_IP, CAMU_RESOURCE_PORT)) { + // return false; + //} cmc_resources_set_callback(&ui->resources, cmc_ui_resources_callback, &ui->search); aki_poll_init(&ui->input, input_poll_callback, ui); @@ -129,5 +138,7 @@ bool cmc_ui_open(struct cmc_ui *ui, struct cmc *c) ncplane_set_userptr(stdplane, ui); resize_cb(stdplane); + refresh_internal(ui); + return true; } diff --git a/src/fruits/cmc/tui/ui.h b/src/fruits/cmc/tui/ui.h index 2f81392..76ea353 100644 --- a/src/fruits/cmc/tui/ui.h +++ b/src/fruits/cmc/tui/ui.h @@ -4,6 +4,7 @@ #include #include "resources.h" +#include "pane_lists.h" #include "pane_search.h" enum { @@ -29,6 +30,7 @@ struct cmc_ui { } overlay; struct aki_poll input; struct cmc_resources resources; + struct cmc_pane_lists lists; struct cmc_pane_search search; struct cmc *c; }; diff --git a/src/fruits/sink/sink.c b/src/fruits/sink/sink.c index 08d2886..cbd82bd 100644 --- a/src/fruits/sink/sink.c +++ b/src/fruits/sink/sink.c @@ -8,7 +8,7 @@ //#include "../../render/renderer_tiger.h" #include "../../libsink/sink.h" -#include "../../tree/common.h" +#include "../../server/common.h" struct cmv { s32 quit; @@ -117,6 +117,9 @@ static void screen_callback(void *userdata, u8 op, f64 float0) case CAMU_SCREEN_SEEK: camu_sink_seek(&c->sink, float0); break; + case CAMU_SCREEN_RESEEK: + camu_sink_reseek(&c->sink); + break; case CAMU_SCREEN_CLOSE: c->quit = 1; break; @@ -145,6 +148,8 @@ s32 main(s32 argc, char *argv[]) s32 wmain(s32 argc, wchar_t **argv) #endif { + (void)argc; + (void)argv; if (!aki_common_init()) return EXIT_FAILURE; signal(SIGINT, sigint_handler); @@ -170,7 +175,7 @@ s32 wmain(s32 argc, wchar_t **argv) camu_sink_init(&c.sink, &c.loop, &c.mixer, c.renderer); c.sink.callback = sink_callback; c.sink.userdata = &c; - if (!camu_sink_connect(&c.sink, TREE_SERVER_IP, TREE_PORT)) { + if (!camu_sink_connect(&c.sink, CAMU_SERVER_IP, CAMU_PORT)) { goto err; } -- cgit v1.2.3-101-g0448