commit - 92ce02e268a0aab7b86c441c9c01299d3af83d1d
commit + 1040cc7fd1cf748a26766e65b2a2fde17e27310d
blob - d844b079644dcc343610c602e3b3195153dd665c
blob + 626acdd09c64f839c2167ded50fb825bc3689705
--- fs.c
+++ fs.c
static void handle_file_open(struct imsg*, size_t);
static void handle_session_start(struct imsg*, size_t);
static void handle_session_tab(struct imsg*, size_t);
+static void handle_session_tab_hist(struct imsg*, size_t);
static void handle_session_end(struct imsg*, size_t);
static void handle_dispatch_imsg(int, short, void*);
static int fs_send_ui(int, uint32_t, int, const void *, uint16_t);
[IMSG_FILE_OPEN] = handle_file_open,
[IMSG_SESSION_START] = handle_session_start,
[IMSG_SESSION_TAB] = handle_session_tab,
+ [IMSG_SESSION_TAB_HIST] = handle_session_tab_hist,
[IMSG_SESSION_END] = handle_session_end,
};
}
static void
+handle_session_tab_hist(struct imsg *imsg, size_t datalen)
+{
+ struct session_tab_hist th;
+
+ if (session == NULL)
+ die();
+
+ if (datalen != sizeof(th))
+ die();
+
+ memcpy(&th, imsg->data, sizeof(th));
+ if (th.uri[sizeof(th.uri)-1] != '\0')
+ die();
+
+ fprintf(session, "%s %s\n", th.future ? ">" : "<", th.uri);
+}
+
+static void
handle_session_end(struct imsg *imsg, size_t datalen)
{
if (session == NULL)
strlcpy(tab.title, title, sizeof(tab.title));
fs_send_ui(IMSG_SESSION_TAB, 0, -1, &tab, sizeof(tab));
+}
+
+static inline void
+sendhist(const char *uri, int future)
+{
+ struct session_tab_hist sth;
+
+ memset(&sth, 0, sizeof(sth));
+ sth.future = future;
+
+ if (strlcpy(sth.uri, uri, sizeof(sth.uri)) >= sizeof(sth.uri))
+ return;
+
+ fs_send_ui(IMSG_SESSION_TAB_HIST, 0, -1, &sth, sizeof(sth));
}
static void
size_t linesize = 0;
ssize_t linelen;
int first_time = 0;
+ int future;
const char *title;
- char *nl, *line = NULL;
+ char *nl, *s, *line = NULL;
if ((session = fopen(session_file, "r")) == NULL) {
/* first time? */
while ((linelen = getline(&line, &linesize, session)) != -1) {
if ((nl = strchr(line, '\n')) != NULL)
*nl = '\0';
- parse_session_line(line, &title, &flags);
- sendtab(flags, line, title);
+
+ if (*line == '<' || *line == '>') {
+ future = *line == '>';
+ s = line+1;
+ if (*s != ' ')
+ continue;
+ sendhist(++s, future);
+ } else {
+ parse_session_line(line, &title, &flags);
+ sendtab(flags, line, title);
+ }
}
fclose(session);
blob - ae4787379ee5e66cd0b232ed3091336387949b8d
blob + 5e48fbdecfc07b88e66e1a9d8d9e1db284fa8ffd
--- fs.h
+++ fs.h
char title[TITLE_MAX];
};
+struct session_tab_hist {
+ char uri[GEMINI_URL_LEN];
+ int future;
+};
+
extern char config_path_base[PATH_MAX];
extern char data_path_base[PATH_MAX];
extern char cache_path_base[PATH_MAX];
blob - 93e92fb9938e4e1c09423aaf5bfa4b9cbdde11e2
blob + 04488d125831333010987d9ada582bdd7f56f50c
--- hist.c
+++ hist.c
TAILQ_INSERT_TAIL(&head->head, h, entries);
}
+void
+hist_add_before(struct histhead *head, struct hist *curr, struct hist *h)
+{
+ head->len++;
+ TAILQ_INSERT_BEFORE(curr, h, entries);
+}
+
struct hist *
hist_pop(struct histhead *head)
{
blob - 79ebe209795f743920f3b58d88ece2df42401d8f
blob + c3b8bf4d957d13e5a94dc793b4a5a7a47613696d
--- session.c
+++ session.c
save_session(void)
{
struct session_tab st;
+ struct session_tab_hist sth;
struct tab *tab;
+ struct hist *h;
+ int future;
if (safe_mode)
return;
strlcpy(st.uri, tab->hist_cur->h, sizeof(st.uri));
strlcpy(st.title, tab->buffer.page.title, sizeof(st.title));
ui_send_fs(IMSG_SESSION_TAB, 0, &st, sizeof(st));
+
+ future = 0;
+ TAILQ_FOREACH(h, &tab->hist.head, entries) {
+ if (h == tab->hist_cur) {
+ future = 1;
+ continue;
+ }
+
+ memset(&sth, 0, sizeof(sth));
+ strlcpy(sth.uri, h->h, sizeof(sth.uri));
+ sth.future = future;
+ ui_send_fs(IMSG_SESSION_TAB_HIST, 0, &sth, sizeof(sth));
+ }
}
ui_send_fs(IMSG_SESSION_END, 0, NULL, 0);
blob - d884b8c2a8640baf5d73d7a9db615ddb4ca8c72e
blob + eed4139686565bc6aa1457e6ca0f8cb5feee90c2
--- telescope.c
+++ telescope.c
[IMSG_UPDATE_CERT_OK] = handle_imsg_update_cert_ok,
[IMSG_FILE_OPENED] = handle_imsg_file_opened,
[IMSG_SESSION_TAB] = handle_imsg_session,
+ [IMSG_SESSION_TAB_HIST] = handle_imsg_session,
[IMSG_SESSION_END] = handle_imsg_session,
};
handle_imsg_session(struct imsg *imsg, size_t datalen)
{
static struct tab *curr;
+ static struct tab *tab;
struct session_tab st;
- struct tab *tab;
+ struct session_tab_hist sth;
+ struct hist *h;
int first_time;
/*
curr = tab;
break;
+ case IMSG_SESSION_TAB_HIST:
+ if (tab == NULL || datalen != sizeof(sth))
+ die();
+
+ memcpy(&sth, imsg->data, sizeof(sth));
+ if (sth.uri[sizeof(sth.uri)-1] != '\0')
+ die();
+
+ if ((h = calloc(1, sizeof(*h))) == NULL)
+ die();
+ strlcpy(h->h, sth.uri, sizeof(h->h));
+
+ if (sth.future)
+ hist_push(&tab->hist, h);
+ else
+ hist_add_before(&tab->hist, tab->hist_cur, h);
+ break;
+
case IMSG_SESSION_END:
if (datalen != sizeof(first_time))
die();
blob - a0bd94a5f30f133c6a26a40186a686519816e0ec
blob + 8fda4e4d9bd99b892d3cc5a29d9a629e15bdc0db
--- telescope.h
+++ telescope.h
IMSG_SESSION_START,
IMSG_SESSION_TAB,
+ IMSG_SESSION_TAB_HIST,
IMSG_SESSION_END,
};
/* hist.c */
void hist_clear_forward(struct histhead*, struct hist*);
void hist_push(struct histhead*, struct hist*);
+void hist_add_before(struct histhead *, struct hist *, struct hist *);
struct hist *hist_pop(struct histhead *);
/* mime.c */