1
0
Fork 0
forked from len0rd/rockbox

Simplelist remove simplelist_set_line_count(n)

replace with simplelist_reset_lines(void)
there was one user saving one short string
remove the feature to simplify list code

fix scrolling in dircache debug item

Change-Id: I71f933f224c2de5f7a68feab904a2fe0b81e1362
This commit is contained in:
William Wilgus 2024-11-21 12:08:53 -05:00
parent d6e3514c0d
commit 00906647b4
4 changed files with 28 additions and 57 deletions

View file

@ -1278,7 +1278,7 @@ static int disk_callback(int btn, struct gui_synclist *lists)
} }
#endif #endif
simplelist_set_line_count(0); simplelist_reset_lines();
card = card_get_info(*cardnum); card = card_get_info(*cardnum);
@ -1408,7 +1408,7 @@ static int disk_callback(int btn, struct gui_synclist *lists)
bool timing_info_present = false; bool timing_info_present = false;
(void)btn; (void)btn;
simplelist_set_line_count(0); simplelist_reset_lines();
for (i=0; i < 20; i++) for (i=0; i < 20; i++)
((unsigned short*)buf)[i]=htobe16(identify_info[i+27]); ((unsigned short*)buf)[i]=htobe16(identify_info[i+27]);
@ -1750,7 +1750,7 @@ static int ata_smart_callback(int btn, struct gui_synclist *lists)
int rc; int rc;
memset(&smart_data, 0, sizeof(struct ata_smart_values)); memset(&smart_data, 0, sizeof(struct ata_smart_values));
rc = ata_read_smart(&smart_data); rc = ata_read_smart(&smart_data);
simplelist_set_line_count(0); simplelist_reset_lines();
if (rc == 0) if (rc == 0)
{ {
int i; int i;
@ -1887,7 +1887,7 @@ static int dircache_callback(int btn, struct gui_synclist *lists)
} }
} }
simplelist_set_line_count(0); simplelist_reset_lines();
simplelist_addline("Cache status: %s", info.statusdesc); simplelist_addline("Cache status: %s", info.statusdesc);
simplelist_addline("Last size: %zu B", info.last_size); simplelist_addline("Last size: %zu B", info.last_size);
@ -1902,9 +1902,6 @@ static int dircache_callback(int btn, struct gui_synclist *lists)
ticks / HZ, (ticks*10 / HZ) % 10); ticks / HZ, (ticks*10 / HZ) % 10);
simplelist_addline("Entry count: %u", info.entry_count); simplelist_addline("Entry count: %u", info.entry_count);
if (btn == ACTION_NONE)
btn = ACTION_REDRAW;
return btn; return btn;
} }
@ -1912,7 +1909,7 @@ static bool dbg_dircache_info(void)
{ {
struct simplelist_info info; struct simplelist_info info;
int syncbuild = 0; int syncbuild = 0;
simplelist_info_init(&info, "Dircache Info", 8, &syncbuild); simplelist_info_init(&info, "Dircache Info", 0, &syncbuild);
info.action_callback = dircache_callback; info.action_callback = dircache_callback;
info.scroll_all = true; info.scroll_all = true;
return simplelist_show_list(&info); return simplelist_show_list(&info);
@ -1928,7 +1925,7 @@ static int database_callback(int btn, struct gui_synclist *lists)
static bool synced = false; static bool synced = false;
static int update_entries = 0; static int update_entries = 0;
simplelist_set_line_count(0); simplelist_reset_lines();
simplelist_addline("Initialized: %s", simplelist_addline("Initialized: %s",
stat->initialized ? "Yes" : "No"); stat->initialized ? "Yes" : "No");
@ -1981,7 +1978,7 @@ static int database_callback(int btn, struct gui_synclist *lists)
static bool dbg_tagcache_info(void) static bool dbg_tagcache_info(void)
{ {
struct simplelist_info info; struct simplelist_info info;
simplelist_info_init(&info, "Database Info", 8, NULL); simplelist_info_init(&info, "Database Info", 0, NULL);
info.action_callback = database_callback; info.action_callback = database_callback;
info.scroll_all = true; info.scroll_all = true;
@ -2141,7 +2138,8 @@ static int radio_callback(int btn, struct gui_synclist *lists)
(void)lists; (void)lists;
if (btn == ACTION_STD_CANCEL) if (btn == ACTION_STD_CANCEL)
return btn; return btn;
simplelist_set_line_count(1); simplelist_reset_lines();
simplelist_setline("HW detected: yes");
#if (CONFIG_TUNER & LV24020LP) #if (CONFIG_TUNER & LV24020LP)
simplelist_addline( simplelist_addline(
@ -2249,10 +2247,9 @@ static bool dbg_fm_radio(void)
tuner_type = tuner_detect_type(); tuner_type = tuner_detect_type();
#endif #endif
info.scroll_all = true; info.scroll_all = true;
simplelist_info_init(&info, "FM Radio", 1, NULL); simplelist_info_init(&info, "FM Radio", 0, NULL);
simplelist_set_line_count(0); simplelist_reset_lines();
simplelist_addline("HW detected: %s", simplelist_setline("HW detected: no");
radio_hardware_present() ? "yes" : "no");
info.action_callback = radio_hardware_present()?radio_callback : NULL; info.action_callback = radio_hardware_present()?radio_callback : NULL;
return simplelist_show_list(&info); return simplelist_show_list(&info);
@ -2467,13 +2464,12 @@ static bool dbg_talk(void)
struct talk_debug_data data; struct talk_debug_data data;
talk_get_debug_data(&data); talk_get_debug_data(&data);
simplelist_info_init(&list, "Voice Information:", 1, NULL); simplelist_info_init(&list, "Voice Information:", 0, NULL);
list.scroll_all = true; list.scroll_all = true;
list.timeout = HZ; list.timeout = HZ;
//list.get_name = dbg_talk_get_name;
simplelist_set_line_count(0); simplelist_reset_lines();
simplelist_setline("Current voice file:"); simplelist_setline("Current voice file:");
if (data.status != TALK_STATUS_ERR_NOFILE) if (data.status != TALK_STATUS_ERR_NOFILE)
@ -2577,8 +2573,8 @@ static bool dbg_boot_data(void)
{ {
struct simplelist_info info; struct simplelist_info info;
info.scroll_all = true; info.scroll_all = true;
simplelist_info_init(&info, "Boot data", 1, NULL); simplelist_info_init(&info, "Boot data", 0, NULL);
simplelist_set_line_count(0); simplelist_reset_lines();
if (!boot_data_valid) if (!boot_data_valid)
{ {
@ -2622,8 +2618,8 @@ static bool dbg_device_data(void)
{ {
struct simplelist_info info; struct simplelist_info info;
info.scroll_all = true; info.scroll_all = true;
simplelist_info_init(&info, "Device data", 1, NULL); simplelist_info_init(&info, "Device data", 0, NULL);
simplelist_set_line_count(0); simplelist_reset_lines();
simplelist_setline("Device data"); simplelist_setline("Device data");
@ -2654,8 +2650,8 @@ static bool dbg_syscfg(void) {
size_t syscfg_entry_size = sizeof(struct SysCfgEntry); size_t syscfg_entry_size = sizeof(struct SysCfgEntry);
struct SysCfgEntry syscfg_entries[SYSCFG_MAX_ENTRIES]; struct SysCfgEntry syscfg_entries[SYSCFG_MAX_ENTRIES];
simplelist_info_init(&info, "SysCfg NOR contents", 1, NULL); simplelist_info_init(&info, "SysCfg NOR contents", 0, NULL);
simplelist_set_line_count(0); simplelist_reset_lines();
bootflash_init(SPI_PORT); bootflash_init(SPI_PORT);
bootflash_read(SPI_PORT, 0, syscfg_hdr_size, &syscfg_hdr); bootflash_read(SPI_PORT, 0, syscfg_hdr_size, &syscfg_hdr);

View file

@ -804,37 +804,12 @@ static int simplelist_line_pos;
/* buffer shared with bitmap/list code */ /* buffer shared with bitmap/list code */
char simplelist_buffer[SIMPLELIST_MAX_LINES * SIMPLELIST_MAX_LINELENGTH]; char simplelist_buffer[SIMPLELIST_MAX_LINES * SIMPLELIST_MAX_LINELENGTH];
static const char *simplelist_text[SIMPLELIST_MAX_LINES]; static const char *simplelist_text[SIMPLELIST_MAX_LINES];
/* set the amount of lines shown in the list */ /* reset the amount of lines shown in the list to 0 */
void simplelist_set_line_count(int lines) void simplelist_reset_lines(void)
{ {
if (lines <= 0) { simplelist_line_pos = 0;
simplelist_line_pos = 0; simplelist_line_remaining = sizeof(simplelist_buffer);
simplelist_line_remaining = sizeof(simplelist_buffer); simplelist_line_count = 0;
simplelist_line_count = 0;
}
else if (lines < simplelist_line_count) {
const char *end = simplelist_buffer;
int last_line = 0;
const char * const bufend = simplelist_buffer + sizeof(simplelist_buffer);
/* find the last item in the buffer we are still showing */
for (int line = 0; line <= lines; line++)
{
const char *first = simplelist_text[line];
if (first >= simplelist_buffer && first < bufend)
{
last_line = line;
end = first;
}
line++;
}
if (last_line < lines)
end += strlen(end) + 1; /* prior to the current line, save contents */
simplelist_line_pos = end - simplelist_buffer;
simplelist_line_remaining = sizeof(simplelist_buffer) - simplelist_line_pos;
simplelist_line_count = lines;
}
} }
/* get the current amount of lines shown */ /* get the current amount of lines shown */
int simplelist_get_line_count(void) int simplelist_get_line_count(void)

View file

@ -306,9 +306,9 @@ struct simplelist_info {
/** The next three functions are used if the text is mostly static. /** The next three functions are used if the text is mostly static.
These should be called in the action callback for the list. These should be called in the action callback for the list.
**/ **/
/* set the amount of lines shown in the list /* reset the amount of lines shown in the list to 0
Only needed if simplelist_info.get_name == NULL */ Only needed if simplelist_info.get_name == NULL */
void simplelist_set_line_count(int lines); void simplelist_reset_lines(void);
/* get the current amount of lines shown */ /* get the current amount of lines shown */
int simplelist_get_line_count(void); int simplelist_get_line_count(void);
/* add a line in the list. */ /* add a line in the list. */

View file

@ -342,7 +342,7 @@ bool dbg_skin_engine(void)
int path_prefix_len = strlen(ROCKBOX_DIR "/wps/"); int path_prefix_len = strlen(ROCKBOX_DIR "/wps/");
#endif #endif
simplelist_info_init(&info, "Skin engine usage", 0, NULL); simplelist_info_init(&info, "Skin engine usage", 0, NULL);
simplelist_set_line_count(0); simplelist_reset_lines();
FOR_NB_SCREENS(j) { FOR_NB_SCREENS(j) {
#if NB_SCREENS > 1 #if NB_SCREENS > 1
simplelist_addline("%s display:", simplelist_addline("%s display:",