diff options
author | wrmr | 2024-11-03 02:48:05 -0500 |
---|---|---|
committer | wrmr | 2024-11-03 02:48:05 -0500 |
commit | 3e9c75318b0eb1114fb7361dbc467990674804b6 (patch) | |
tree | 504efbb2fe56c4700055ec584170cb77237c732a /nav.c | |
parent | 610808a5902adad751a4acdbcc310803a51fed5d (diff) |
start working on fetching
Diffstat (limited to 'nav.c')
-rw-r--r-- | nav.c | 42 |
1 files changed, 40 insertions, 2 deletions
diff --git a/nav.c b/nav.c index 82cf71a..3a1d095 100644 --- a/nav.c +++ b/nav.c @@ -1,12 +1,17 @@ #include <string.h> #include <stdio.h> + #include "nav.h" +#include "net.h" + +/* history */ void nav_init(struct nav_state *ns) { memset(ns, 0, sizeof *ns); ns->histc = 1; - doc_init(&ns->histv[0]); - doc_add_text(&ns->histv[0], "Type ? for command help."); + doc_init(ns->histv); + doc_add_text(ns->histv, "Type ? for command help."); + ns->prot_default = PROT_FILE; /* change to PROT_GOPHER later */ } void nav_fini(struct nav_state *ns) { @@ -15,6 +20,16 @@ void nav_fini(struct nav_state *ns) { } } +void nav_new(struct nav_state *ns) { + if (ns->histc == HIST_MAX) { + doc_fini(ns->histv); + memmove(ns->histv, &ns->histv[1], sizeof(struct doc) * (HIST_MAX - 1)); + ns->histc--; + } +} + +/* paging */ + size_t pg_lines(void) { return 24; } @@ -59,4 +74,27 @@ void nav_pg_down(struct nav_state *ns) { } void nav_redraw(struct nav_state *ns) { + size_t lines = pg_lines(); + while (lines-- && nav_line_up(ns)); + nav_pg_down(ns); +} + +/* network */ + +int nav_to(struct nav_state *ns, const char *url) { + struct addr adr; + buf_t buf; + if (net_addr(url, &adr, ns->prot_default)) { + return -1; + } + ns->prot_default = adr.prot; + if (net_fetch(&adr, &buf)) { + return -1; + } + buf_free(&buf); + return 0; +} + +int nav_link_nr(struct nav_state *ns, unsigned long link_nr) { + return 0; } |