commit - cc298130d72e43af1ec12f939125dde55405c8bf
commit + 83dce83d3c37cc7b9ef292fb4cbba6031bbd9405
blob - 70acbd22185d661a0566f611b2cb93f710248751
blob + 1948ec501f1f9a143e3e54f00afa4d47b7c4f2fd
--- cmd.c
+++ cmd.c
vl = buffer->current_line;
switch (vl->parent->type) {
case LINE_LINK:
- load_url_in_tab(current_tab(), vl->parent->alt);
+ load_url_in_tab(current_tab, vl->parent->alt);
break;
case LINE_PRE_START:
l = TAILQ_NEXT(vl->parent, lines);
void
cmd_previous_page(struct buffer *buffer)
{
- struct tab *tab = current_tab();
-
- if (!load_previous_page(tab))
+ if (!load_previous_page(current_tab))
message("No previous page");
else
- start_loading_anim(tab);
+ start_loading_anim(current_tab);
}
void
cmd_next_page(struct buffer *buffer)
{
- struct tab *tab = current_tab();
-
- if (!load_next_page(tab))
+ if (!load_next_page(current_tab))
message("No next page");
else
- start_loading_anim(tab);
+ start_loading_anim(current_tab);
}
void
{
struct tab *tab, *t;
- tab = current_tab();
+ tab = current_tab;
if (TAILQ_PREV(tab, tabshead, tabs) == NULL &&
TAILQ_NEXT(tab, tabs) == NULL) {
message("Can't close the only tab.");
struct tab *t, *i;
TAILQ_FOREACH_SAFE(t, &tabshead, tabs, i) {
- if (t->flags & TAB_CURRENT)
+ if (t == current_tab)
continue;
stop_tab(t);
void
cmd_tab_next(struct buffer *buffer)
{
- struct tab *tab, *t;
+ struct tab *t;
- tab = current_tab();
- tab->flags &= ~TAB_CURRENT;
-
- if ((t = TAILQ_NEXT(tab, tabs)) == NULL)
+ if ((t = TAILQ_NEXT(current_tab, tabs)) == NULL)
t = TAILQ_FIRST(&tabshead);
- t->flags |= TAB_CURRENT;
t->flags &= ~TAB_URGENT;
+ current_tab = t;
}
void
cmd_tab_previous(struct buffer *buffer)
{
- struct tab *tab, *t;
+ struct tab *t;
- tab = current_tab();
- tab->flags &= ~TAB_CURRENT;
-
- if ((t = TAILQ_PREV(tab, tabshead, tabs)) == NULL)
+ if ((t = TAILQ_PREV(current_tab, tabshead, tabs)) == NULL)
t = TAILQ_LAST(&tabshead, tabshead);
- t->flags |= TAB_CURRENT;
t->flags &= ~TAB_URGENT;
+ current_tab = t;
}
void
cmd_tab_move(struct buffer *buffer)
{
- struct tab *tab, *t;
+ struct tab *t;
- tab = current_tab();
- t = TAILQ_NEXT(tab, tabs);
- TAILQ_REMOVE(&tabshead, tab, tabs);
+ t = TAILQ_NEXT(current_tab, tabs);
+ TAILQ_REMOVE(&tabshead, current_tab, tabs);
if (t == NULL)
- TAILQ_INSERT_HEAD(&tabshead, tab, tabs);
+ TAILQ_INSERT_HEAD(&tabshead, current_tab, tabs);
else
- TAILQ_INSERT_AFTER(&tabshead, t, tab, tabs);
+ TAILQ_INSERT_AFTER(&tabshead, t, current_tab, tabs);
}
void
cmd_tab_move_to(struct buffer *buffer)
{
- struct tab *tab, *t;
+ struct tab *t;
- tab = current_tab();
- t = TAILQ_PREV(tab, tabshead, tabs);
- TAILQ_REMOVE(&tabshead, tab, tabs);
+ t = TAILQ_PREV(current_tab, tabshead, tabs);
+ TAILQ_REMOVE(&tabshead, current_tab, tabs);
if (t == NULL) {
if (TAILQ_EMPTY(&tabshead))
- TAILQ_INSERT_HEAD(&tabshead, tab, tabs);
+ TAILQ_INSERT_HEAD(&tabshead, current_tab, tabs);
else
- TAILQ_INSERT_TAIL(&tabshead, tab, tabs);
+ TAILQ_INSERT_TAIL(&tabshead, current_tab, tabs);
} else
- TAILQ_INSERT_BEFORE(t, tab, tabs);
+ TAILQ_INSERT_BEFORE(t, current_tab, tabs);
}
void
void
cmd_load_current_url(struct buffer *buffer)
{
- struct tab *tab = current_tab();
-
GUARD_RECURSIVE_MINIBUFFER();
enter_minibuffer(sensible_self_insert, lu_select, exit_minibuffer,
&lu_history, NULL, NULL);
strlcpy(ministate.prompt, "Load URL: ", sizeof(ministate.prompt));
- strlcpy(ministate.buf, tab->hist_cur->h, sizeof(ministate.buf));
+ strlcpy(ministate.buf, current_tab->hist_cur->h, sizeof(ministate.buf));
ministate.buffer.cpoff = utf8_cplen(ministate.buf);
}
void
cmd_reload_page(struct buffer *buffer)
{
- struct tab *tab;
-
- tab = current_tab();
- load_url_in_tab(tab, tab->hist_cur->h);
+ load_url_in_tab(current_tab, current_tab->hist_cur->h);
}
void
cmd_bookmark_page(struct buffer *buffer)
{
- struct tab *tab = current_tab();
-
GUARD_RECURSIVE_MINIBUFFER();
enter_minibuffer(sensible_self_insert, bp_select, exit_minibuffer, NULL,
NULL, NULL);
strlcpy(ministate.prompt, "Bookmark URL: ", sizeof(ministate.prompt));
- strlcpy(ministate.buf, tab->hist_cur->h, sizeof(ministate.buf));
+ strlcpy(ministate.buf, current_tab->hist_cur->h, sizeof(ministate.buf));
ministate.buffer.cpoff = utf8_cplen(ministate.buf);
}
void
cmd_list_bookmarks(struct buffer *buffer)
{
- load_url_in_tab(current_tab(), "about:bookmarks");
+ load_url_in_tab(current_tab, "about:bookmarks");
}
void
blob - c9515efc092ba97dacf2be9558f0b2c30d6b5a84
blob + 070b0eb02e2d41e1e4177b0f99faff43cb889232
--- minibuffer.c
+++ minibuffer.c
{
char buf[1025] = {0};
struct phos_uri uri;
- struct tab *tab;
+ struct tab *tab = current_tab;
- tab = current_tab();
-
exit_minibuffer();
minibuffer_hist_save_entry();
{
exit_minibuffer();
minibuffer_hist_save_entry();
- load_url_in_tab(current_tab(), ministate.buf);
+ load_url_in_tab(current_tab, ministate.buf);
}
void
}
exit_minibuffer();
- load_url_in_tab(current_tab(), l->alt);
+ load_url_in_tab(current_tab, l->alt);
}
static inline void
jump_to_line(struct line *l)
{
struct vline *vl;
- struct tab *tab;
+ struct tab *tab = current_tab;
- tab = current_tab();
-
TAILQ_FOREACH(vl, &tab->buffer.head, vlines) {
if (vl->parent == l)
break;
blob - e48bb64b22125b338476d7be7e34cddae2690c24
blob + b4b1612f8f89dd857875b9ce9f5c3cbff6e58329
--- telescope.h
+++ telescope.h
TAILQ_HEAD(vhead, vline) head;
};
-#define TAB_CURRENT 0x1
-#define TAB_URGENT 0x2
+#define TAB_URGENT 0x1
#define NEW_TAB_URL "about:new"
blob - 673c032bc3787b04c3d9f06b164008b1a1aa1f13
blob + c4ea0103e6abc4a94279880058fbe8be2bd691e7
--- ui.c
+++ ui.c
static int too_small;
static int x_offset;
-struct thiskey thiskey;
+struct thiskey thiskey;
+struct tab *current_tab;
static struct event resizeev;
static struct timeval resize_timer = { 0, 250000 };
if (i == n)
return vl;
i++;
- }
-
- /* unreachable */
- abort();
-}
-
-struct tab *
-current_tab(void)
-{
- struct tab *t;
-
- TAILQ_FOREACH(t, &tabshead, tabs) {
- if (t->flags & TAB_CURRENT)
- return t;
}
/* unreachable */
{
if (in_minibuffer)
return &ministate.buffer;
- return ¤t_tab()->buffer;
+ return ¤t_tab->buffer;
}
static int
if (should_rearrange_windows)
rearrange_windows();
- redraw_tab(current_tab());
+ redraw_tab(current_tab);
}
static void
static void
rearrange_windows(void)
{
- struct tab *tab;
int lines;
should_rearrange_windows = 0;
wresize(tabline, 1, COLS);
- tab = current_tab();
-
- wrap_page(&tab->buffer, body_cols);
- redraw_tab(tab);
+ wrap_page(¤t_tab->buffer, body_cols);
+ redraw_tab(current_tab);
}
static int
toskip = 0;
TAILQ_FOREACH(tab, &tabshead, tabs) {
toskip++;
- if (tab->flags & TAB_CURRENT)
+ if (tab == current_tab)
break;
}
if (x + sizeof(buf)+2 >= (size_t)COLS)
truncated = 1;
- current = tab->flags & TAB_CURRENT;
+ current = tab == current_tab;
if (*(title = tab->buffer.page.title) == '\0')
title = tab->hist_cur->h;
static void
do_redraw_echoarea(void)
{
- struct tab *tab;
+ struct vline *vl;
if (ministate.curmesg != NULL)
wprintw(echoarea, "%s", ministate.curmesg);
waddstr(echoarea, keybuf);
else {
/* If nothing else, show the URL at point */
- tab = current_tab();
- if (tab->buffer.current_line != NULL &&
- tab->buffer.current_line->parent->type == LINE_LINK)
- waddstr(echoarea,
- tab->buffer.current_line->parent->alt);
+ vl = current_tab->buffer.current_line;
+ if (vl != NULL && vl->parent->type == LINE_LINK)
+ waddstr(echoarea, vl->parent->alt);
}
}
tab->loading_anim_step = (tab->loading_anim_step+1)%4;
- if (tab->flags & TAB_CURRENT) {
+ if (tab == current_tab) {
redraw_modeline(tab);
wrefresh(modeline);
wrefresh(body);
tab->loading_anim = 0;
tab->loading_anim_step = 0;
- if (!(tab->flags & TAB_CURRENT))
+ if (tab != current_tab)
return;
redraw_modeline(tab);
void
switch_to_tab(struct tab *tab)
{
- struct tab *t;
-
- TAILQ_FOREACH(t, &tabshead, tabs) {
- t->flags &= ~TAB_CURRENT;
- }
-
- tab->flags |= TAB_CURRENT;
+ current_tab = tab;
tab->flags &= ~TAB_URGENT;
}
ui_on_tab_refresh(struct tab *tab)
{
wrap_page(&tab->buffer, body_cols);
- if (tab->flags & TAB_CURRENT)
+ if (tab == current_tab)
redraw_tab(tab);
else
tab->flags |= TAB_URGENT;
struct tab *data)
{
yornp(prompt, fn, data);
- redraw_tab(current_tab());
+ redraw_tab(current_tab);
}
void
struct tab *data)
{
completing_read(prompt, fn, data);
- redraw_tab(current_tab());
+ redraw_tab(current_tab);
}
void
blob - d5244262d5a1a313f8fa64fa09647437b3a67a89
blob + fd2b1d1e28eb18527ee22fd67f4e3e457267215d
--- ui.h
+++ ui.h
lu_history,
read_history;
+extern struct tab *current_tab;
+
void save_excursion(struct excursion *, struct buffer *);
void restore_excursion(struct excursion *, struct buffer *);
void global_key_unbound(void);
void start_loading_anim(struct tab *);
void load_url_in_tab(struct tab *, const char *);
void switch_to_tab(struct tab *);
-struct tab *current_tab(void);
struct buffer *current_buffer(void);
struct tab *new_tab(const char *);
unsigned int tab_new_id(void);