Fixed history handling.

- The wraparound handling when using the history with the 'back' button is actually depending on history_last being unsigned (which is the default for cc65) so define it explicitly as unsigned to make it work on other targets too.
- As there's no 'forward' button it doesn't make sense to keep history entries after using them with the 'back' button. Clearing them on use on the other hand avoids an "infinite history".
This commit is contained in:
Oliver Schmidt 2015-06-05 15:10:21 +02:00
parent e6903e4e7e
commit f6b315a17f

View File

@ -125,7 +125,7 @@ static struct ctk_button wgetyesbutton =
#if WWW_CONF_HISTORY_SIZE > 0
/* The char arrays that hold the history of visited URLs. */
static char history[WWW_CONF_HISTORY_SIZE][WWW_CONF_MAX_URLLEN];
static char history_last;
static unsigned char history_last;
#endif /* WWW_CONF_HISTORY_SIZE > 0 */
struct linkattrib {
@ -516,10 +516,12 @@ PROCESS_THREAD(www_process, ev, data)
firsty = 0;
start_loading();
--history_last;
/* Note: history_last is unsigned ! */
if(history_last > WWW_CONF_HISTORY_SIZE) {
history_last = WWW_CONF_HISTORY_SIZE - 1;
}
memcpy(url, history[(int)history_last], WWW_CONF_MAX_URLLEN);
*history[(int)history_last] = 0;
open_url();
CTK_WIDGET_FOCUS(&mainwindow, &backbutton);
#endif /* WWW_CONF_HISTORY_SIZE > 0 */