mirror of
https://github.com/tmux/tmux.git
synced 2025-09-03 06:17:04 +00:00
Sync OpenBSD patchset 1017:
Give each window a unique id, like panes but prefixed with @. Based on work from George Nachman.
This commit is contained in:
32
window.c
32
window.c
@ -55,7 +55,8 @@ struct windows windows;
|
||||
|
||||
/* Global panes tree. */
|
||||
struct window_pane_tree all_window_panes;
|
||||
u_int next_window_pane;
|
||||
u_int next_window_pane_id;
|
||||
u_int next_window_id;
|
||||
|
||||
void window_pane_read_callback(struct bufferevent *, void *);
|
||||
void window_pane_error_callback(struct bufferevent *, short, void *);
|
||||
@ -101,6 +102,18 @@ winlink_find_by_index(struct winlinks *wwl, int idx)
|
||||
return (RB_FIND(winlinks, wwl, &wl));
|
||||
}
|
||||
|
||||
struct winlink *
|
||||
winlink_find_by_window_id(struct winlinks *wwl, u_int id)
|
||||
{
|
||||
struct winlink *wl;
|
||||
|
||||
RB_FOREACH(wl, winlinks, wwl) {
|
||||
if (wl->window->id == id)
|
||||
return (wl);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int
|
||||
winlink_next_index(struct winlinks *wwl, int idx)
|
||||
{
|
||||
@ -245,6 +258,20 @@ window_index(struct window *s, u_int *i)
|
||||
return (-1);
|
||||
}
|
||||
|
||||
struct window *
|
||||
window_find_by_id(u_int id)
|
||||
{
|
||||
struct window *w;
|
||||
u_int i;
|
||||
|
||||
for (i = 0; i < ARRAY_LENGTH(&windows); i++) {
|
||||
w = ARRAY_ITEM(&windows, i);
|
||||
if (w->id == id)
|
||||
return (w);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct window *
|
||||
window_create1(u_int sx, u_int sy)
|
||||
{
|
||||
@ -252,6 +279,7 @@ window_create1(u_int sx, u_int sy)
|
||||
u_int i;
|
||||
|
||||
w = xcalloc(1, sizeof *w);
|
||||
w->id = next_window_id++;
|
||||
w->name = NULL;
|
||||
w->flags = 0;
|
||||
|
||||
@ -568,7 +596,7 @@ window_pane_create(struct window *w, u_int sx, u_int sy, u_int hlimit)
|
||||
wp = xcalloc(1, sizeof *wp);
|
||||
wp->window = w;
|
||||
|
||||
wp->id = next_window_pane++;
|
||||
wp->id = next_window_pane_id++;
|
||||
RB_INSERT(window_pane_tree, &all_window_panes, wp);
|
||||
|
||||
wp->cmd = NULL;
|
||||
|
Reference in New Issue
Block a user