Skip to content

Commit

Permalink
Rename to rz_core_get_themes()
Browse files Browse the repository at this point in the history
  • Loading branch information
pelijah committed May 12, 2024
1 parent a46d6cc commit cc860f0
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
18 changes: 9 additions & 9 deletions librz/core/cmd/cmd_eval.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,12 @@ static int compare_strings(const char *s1, const char *s2, RZ_UNUSED void *user)
}

/**
* \brief Returns the list of the rizin themes.
* \brief Get names of available rizin themes.
*
* \param core The RzCore struct to use
* \return On success, an RzPVector pointer, otherwise NULL.
* \param core The RzCore struct to use
* \return On success, an RzPVector pointer, otherwise NULL.
*/
RZ_API RZ_OWN RzPVector /*<char *>*/ *rz_core_theme_list(RZ_NONNULL RzCore *core) {
RZ_API RZ_OWN RzPVector /*<char *>*/ *rz_core_get_themes(RZ_NONNULL RzCore *core) {
rz_return_val_if_fail(core, NULL);

SetS *themes = set_s_new(HT_STR_DUP);
Expand Down Expand Up @@ -143,7 +143,7 @@ RZ_API void rz_core_theme_nextpal(RzCore *core, RzConsPalSeekMode mode) {

void **iter;
size_t idx;
RzPVector *files = rz_core_theme_list(core);
RzPVector *files = rz_core_get_themes(core);
rz_pvector_enumerate (files, iter, idx) {
const char *fn = *iter;
if (strcmp(fn, core->curtheme)) {
Expand Down Expand Up @@ -243,15 +243,15 @@ RZ_IPI RzCmdStatus rz_cmd_eval_color_load_theme_handler(RzCore *core, int argc,
if (argc == 2) {
return bool2status(rz_core_theme_load(core, argv[1]));
}
RzPVector *themes_list = rz_core_theme_list(core);
if (!themes_list) {
RzPVector *themes = rz_core_get_themes(core);
if (!themes) {
return RZ_CMD_STATUS_ERROR;
}
if (state->mode == RZ_OUTPUT_MODE_JSON) {
pj_a(pj);
}
void **iter;
rz_pvector_foreach (themes_list, iter) {
rz_pvector_foreach (themes, iter) {
const char *th = *iter;
switch (state->mode) {
case RZ_OUTPUT_MODE_JSON: {
Expand All @@ -272,7 +272,7 @@ RZ_IPI RzCmdStatus rz_cmd_eval_color_load_theme_handler(RzCore *core, int argc,
if (state->mode == RZ_OUTPUT_MODE_JSON) {
pj_end(pj);
}
rz_pvector_free(themes_list);
rz_pvector_free(themes);
return RZ_CMD_STATUS_OK;
}

Expand Down
2 changes: 1 addition & 1 deletion librz/core/core_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ typedef struct rz_panels_root_t {
RzPVector /*<RzPanelsTab *>*/ tabs;
RzPanelsTab *active_tab; // Seems redudant since we have cur_tab index
RzPanelsRootState root_state;
RzPVector /*<char *>*/ *theme_list; ///< List of themes
RzPVector /*<char *>*/ *themes; ///< Available rizin themes
bool from_visual;
} RzPanelsRoot;

Expand Down
6 changes: 3 additions & 3 deletions librz/core/tui/panels.c
Original file line number Diff line number Diff line change
Expand Up @@ -4377,7 +4377,7 @@ void __init_menu_color_settings_layout(void *_core, const char *parent) {
RzStrBuf *buf = rz_strbuf_new(NULL);
RzCoreVisual *visual = core->visual;
void **iter;
rz_pvector_foreach (visual->panels_root->theme_list, iter) {
rz_pvector_foreach (visual->panels_root->themes, iter) {
const char *pos = *iter;
if (pos && !strcmp(now, pos)) {
rz_strbuf_setf(buf, "%s%s", color, pos);
Expand Down Expand Up @@ -6145,7 +6145,7 @@ RZ_IPI void rz_panels_root_free(RZ_NULLABLE RzPanelsRoot *panels_root) {
return;
}
rz_pvector_fini(&panels_root->tabs);
rz_pvector_free(panels_root->theme_list);
rz_pvector_free(panels_root->themes);
free(panels_root);
}

Expand All @@ -6161,7 +6161,7 @@ RZ_IPI bool rz_core_visual_panels_root(RzCore *core, RzPanelsRoot *panels_root)
rz_pvector_reserve(&panels_root->tabs, PANEL_NUM_LIMIT);
panels_root->cur_tab = 0;
__set_root_state(core, DEFAULT);
panels_root->theme_list = rz_core_theme_list(core);
panels_root->themes = rz_core_get_themes(core);
__init_new_panels_root(core);
} else {
if (rz_pvector_len(&panels_root->tabs) == 0) {
Expand Down
2 changes: 1 addition & 1 deletion librz/include/rz_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ RZ_API bool rz_core_plugin_del(RzCore *core, RZ_NONNULL RzCorePlugin *plugin);
RZ_API bool rz_core_plugin_fini(RzCore *core);

// #define rz_core_ncast(x) (RzCore*)(size_t)(x)
RZ_API RZ_OWN RzPVector /*<char *>*/ *rz_core_theme_list(RZ_NONNULL RzCore *core);
RZ_API RZ_OWN RzPVector /*<char *>*/ *rz_core_get_themes(RZ_NONNULL RzCore *core);
RZ_API char *rz_core_theme_get(RzCore *core);
RZ_API bool rz_core_theme_load(RzCore *core, const char *name);
RZ_API void rz_core_theme_nextpal(RzCore *core, RzConsPalSeekMode mode);
Expand Down

0 comments on commit cc860f0

Please sign in to comment.