diff --git a/gui/gui_app_web.c b/gui/gui_app_web.c index 36d9d68..2c6f645 100644 --- a/gui/gui_app_web.c +++ b/gui/gui_app_web.c @@ -28,21 +28,48 @@ #define WEB_FETCH_CAP 16384 // response bytes retained #define WEB_MAX_LINES 2048 // rendered display lines retained +#define WEB_MAX_LINKS 400 // hyperlinks tracked per page +#define WEB_HREF_POOL 6144 // bytes of href strings per page +#define WEB_HISTORY 16 // back-stack depth #define WEB_URL_FIELD 1 +// A hyperlink: the [start,end) span it occupies in the processed text, and the +// offset of its href string in the pool. +typedef struct { + int start; + int end; + int href; +} web_link_t; + typedef struct { char url[256]; http_fetch_t* job; bool reader; // strip markup and reflow int scroll; // first visible display line - // Rendered line index, cached against the inputs that determine it. + // Rendered text and its line index, cached against the inputs that + // determine them. char* text; // processed text being displayed int text_len; int offsets[WEB_MAX_LINES]; int lengths[WEB_MAX_LINES]; int nlines; + // Links found while stripping markup (reader view only). + web_link_t links[WEB_MAX_LINKS]; + int nlinks; + char hrefs[WEB_HREF_POOL]; + int href_used; + + // The page's own address, used to resolve relative links. + char base_host[128]; + uint16_t base_port; + char base_path[256]; + + // Back stack of previously-visited URLs. + char hist[WEB_HISTORY][256]; + int hist_len; + const char* cache_src; // job->buf the cache was built from int cache_len; bool cache_reader; @@ -91,14 +118,58 @@ static char decode_entity(const char* e, int len) { return 0; } -// Strip markup from `src` into `out` (bounded by cap), collapsing runs of -// whitespace and turning block tags into single newlines.