-
Notifications
You must be signed in to change notification settings - Fork 0
/
tab.c
70 lines (56 loc) · 920 Bytes
/
tab.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include "tab.h"
#include "tabs.h"
#include "mem.h"
#include "pos.h"
#include "region.h"
#include "list.h"
#include "buffer.h"
#include "window.h"
#include "windows.h"
tab *tab_new(window *win)
{
tab *t = umalloc(sizeof *t);
t->win = win;
t->next = NULL;
return t;
}
void tab_free(tab *t)
{
if(t->win){
window_free(t->win);
t->win = NULL;
}
if(t == tabs_first())
tabs_set_first(t->next);
free(t);
}
void tab_set_focus(tab *tab, window *focus)
{
tab->win = focus;
}
void tab_evict(tab *t)
{
tab *i;
for(i = tabs_first(); i; i = i->next){
if(i->next == t){
i->next = t->next;
break;
}
}
t->next = NULL;
}
tab *tab_next(tab *t)
{
return t->next ? t->next : tabs_first();
}
bool tab_contains_buffer(tab *t, buffer_t *b)
{
window *win;
ITER_WINDOWS_FROM(win, t->win)
if(win->buf == b)
return true;
return false;
}