mirror of
https://github.com/tmate-io/tmate.git
synced 2024-11-29 19:43:41 +01:00
Add session_set_current helper function, extracted from a diff from Aaron
Jensen.
This commit is contained in:
parent
6fc96978c2
commit
8c50f625b0
38
session.c
38
session.c
@ -345,13 +345,7 @@ session_next(struct session *s, int alert)
|
|||||||
if (alert && ((wl = session_next_alert(wl)) == NULL))
|
if (alert && ((wl = session_next_alert(wl)) == NULL))
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
if (wl == s->curw)
|
return (session_set_current(s, wl));
|
||||||
return (1);
|
|
||||||
winlink_stack_remove(&s->lastw, wl);
|
|
||||||
winlink_stack_push(&s->lastw, s->curw);
|
|
||||||
s->curw = wl;
|
|
||||||
winlink_clear_flags(wl);
|
|
||||||
return (0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct winlink *
|
struct winlink *
|
||||||
@ -382,13 +376,7 @@ session_previous(struct session *s, int alert)
|
|||||||
if (alert && (wl = session_previous_alert(wl)) == NULL)
|
if (alert && (wl = session_previous_alert(wl)) == NULL)
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
if (wl == s->curw)
|
return (session_set_current(s, wl));
|
||||||
return (1);
|
|
||||||
winlink_stack_remove(&s->lastw, wl);
|
|
||||||
winlink_stack_push(&s->lastw, s->curw);
|
|
||||||
s->curw = wl;
|
|
||||||
winlink_clear_flags(wl);
|
|
||||||
return (0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Move session to specific window. */
|
/* Move session to specific window. */
|
||||||
@ -398,15 +386,7 @@ session_select(struct session *s, int idx)
|
|||||||
struct winlink *wl;
|
struct winlink *wl;
|
||||||
|
|
||||||
wl = winlink_find_by_index(&s->windows, idx);
|
wl = winlink_find_by_index(&s->windows, idx);
|
||||||
if (wl == NULL)
|
return (session_set_current(s, wl));
|
||||||
return (-1);
|
|
||||||
if (wl == s->curw)
|
|
||||||
return (1);
|
|
||||||
winlink_stack_remove(&s->lastw, wl);
|
|
||||||
winlink_stack_push(&s->lastw, s->curw);
|
|
||||||
s->curw = wl;
|
|
||||||
winlink_clear_flags(wl);
|
|
||||||
return (0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Move session to last used window. */
|
/* Move session to last used window. */
|
||||||
@ -421,6 +401,18 @@ session_last(struct session *s)
|
|||||||
if (wl == s->curw)
|
if (wl == s->curw)
|
||||||
return (1);
|
return (1);
|
||||||
|
|
||||||
|
return (session_set_current(s, wl));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Set current winlink to wl .*/
|
||||||
|
int
|
||||||
|
session_set_current(struct session *s, struct winlink *wl)
|
||||||
|
{
|
||||||
|
if (wl == NULL)
|
||||||
|
return (-1);
|
||||||
|
if (wl == s->curw)
|
||||||
|
return (1);
|
||||||
|
|
||||||
winlink_stack_remove(&s->lastw, wl);
|
winlink_stack_remove(&s->lastw, wl);
|
||||||
winlink_stack_push(&s->lastw, s->curw);
|
winlink_stack_push(&s->lastw, s->curw);
|
||||||
s->curw = wl;
|
s->curw = wl;
|
||||||
|
1
tmux.h
1
tmux.h
@ -2276,6 +2276,7 @@ int session_next(struct session *, int);
|
|||||||
int session_previous(struct session *, int);
|
int session_previous(struct session *, int);
|
||||||
int session_select(struct session *, int);
|
int session_select(struct session *, int);
|
||||||
int session_last(struct session *);
|
int session_last(struct session *);
|
||||||
|
int session_set_current(struct session *, struct winlink *);
|
||||||
struct session_group *session_group_find(struct session *);
|
struct session_group *session_group_find(struct session *);
|
||||||
u_int session_group_index(struct session_group *);
|
u_int session_group_index(struct session_group *);
|
||||||
void session_group_add(struct session *, struct session *);
|
void session_group_add(struct session *, struct session *);
|
||||||
|
Loading…
Reference in New Issue
Block a user