diff --git a/frontend/menu/menu_common.c b/frontend/menu/menu_common.c index 560cc770be..591d5bc7cb 100644 --- a/frontend/menu/menu_common.c +++ b/frontend/menu/menu_common.c @@ -545,70 +545,6 @@ bool menu_save_new_config(void) return ret; } -static inline int menu_list_get_first_char(file_list_t *buf, - unsigned offset) -{ - int ret; - const char *path = NULL; - - file_list_get_alt_at_offset(buf, offset, &path); - ret = tolower(*path); - - /* "Normalize" non-alphabetical entries so they - * are lumped together for purposes of jumping. */ - if (ret < 'a') - ret = 'a' - 1; - else if (ret > 'z') - ret = 'z' + 1; - return ret; -} - -static inline bool menu_list_elem_is_dir(file_list_t *buf, - unsigned offset) -{ - const char *path = NULL; - const char *label = NULL; - unsigned type = 0; - - file_list_get_at_offset(buf, offset, &path, &label, &type); - - return type != MENU_FILE_PLAIN; -} - -void menu_build_scroll_indices(file_list_t *buf) -{ - size_t i; - int current; - bool current_is_dir; - - if (!driver.menu || !buf) - return; - - driver.menu->scroll_indices_size = 0; - if (!buf->size) - return; - - driver.menu->scroll_indices[driver.menu->scroll_indices_size++] = 0; - - current = menu_list_get_first_char(buf, 0); - current_is_dir = menu_list_elem_is_dir(buf, 0); - - for (i = 1; i < buf->size; i++) - { - int first = menu_list_get_first_char(buf, i); - bool is_dir = menu_list_elem_is_dir(buf, i); - - if ((current_is_dir && !is_dir) || (first > current)) - driver.menu->scroll_indices[driver.menu->scroll_indices_size++] = i; - - current = first; - current_is_dir = is_dir; - } - - driver.menu->scroll_indices[driver.menu->scroll_indices_size++] = - buf->size - 1; -} - unsigned menu_common_type_is(const char *label, unsigned type) { if ( diff --git a/frontend/menu/menu_common.h b/frontend/menu/menu_common.h index a440eb702e..465ca14c65 100644 --- a/frontend/menu/menu_common.h +++ b/frontend/menu/menu_common.h @@ -141,8 +141,6 @@ bool menu_save_new_config(void); void menu_update_system_info(menu_handle_t *menu, bool *load_no_content); -void menu_build_scroll_indices(file_list_t *buf); - unsigned menu_common_type_is(const char *label, unsigned type); #ifdef __cplusplus diff --git a/frontend/menu/menu_entries.c b/frontend/menu/menu_entries.c index e4c536dff4..a9059247ae 100644 --- a/frontend/menu/menu_entries.c +++ b/frontend/menu/menu_entries.c @@ -44,6 +44,70 @@ static inline struct gfx_shader *shader_manager_get_current_shader( return NULL; } +static inline bool menu_list_elem_is_dir(file_list_t *buf, + unsigned offset) +{ + const char *path = NULL; + const char *label = NULL; + unsigned type = 0; + + file_list_get_at_offset(buf, offset, &path, &label, &type); + + return type != MENU_FILE_PLAIN; +} + +static inline int menu_list_get_first_char(file_list_t *buf, + unsigned offset) +{ + int ret; + const char *path = NULL; + + file_list_get_alt_at_offset(buf, offset, &path); + ret = tolower(*path); + + /* "Normalize" non-alphabetical entries so they + * are lumped together for purposes of jumping. */ + if (ret < 'a') + ret = 'a' - 1; + else if (ret > 'z') + ret = 'z' + 1; + return ret; +} + +static void menu_build_scroll_indices(file_list_t *buf) +{ + size_t i; + int current; + bool current_is_dir; + + if (!driver.menu || !buf) + return; + + driver.menu->scroll_indices_size = 0; + if (!buf->size) + return; + + driver.menu->scroll_indices[driver.menu->scroll_indices_size++] = 0; + + current = menu_list_get_first_char(buf, 0); + current_is_dir = menu_list_elem_is_dir(buf, 0); + + for (i = 1; i < buf->size; i++) + { + int first = menu_list_get_first_char(buf, i); + bool is_dir = menu_list_elem_is_dir(buf, i); + + if ((current_is_dir && !is_dir) || (first > current)) + driver.menu->scroll_indices[driver.menu->scroll_indices_size++] = i; + + current = first; + current_is_dir = is_dir; + } + + driver.menu->scroll_indices[driver.menu->scroll_indices_size++] = + buf->size - 1; +} + static void add_setting_entry(menu_handle_t *menu, file_list_t *list, const char *label, unsigned id,