-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcolumn.c
66 lines (53 loc) · 1.08 KB
/
column.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
#include "extern.h"
#include <stdio.h>
struct column *
find_column_by_hpos(int x, struct column *head)
{
struct column *c;
for (c = head; c != NULL; c = c->next)
if (x >= c->x && (x - c->x) <
(c->width + head->layout->hspacing))
return c;
return head;
}
/*
* Set focus to a column (c) in a layout (l).
*/
void
focus_column(struct column *c, struct layout *l)
{
assert(c != NULL && l != NULL);
TRACE("focus column, c->x = %d", c->x);
l->column = c;
/*
if (l->focus != NULL)
l->focus->column = c;
*/
}
/*
* Returns previous/next column relative to source column (s).
* Can return empty/non-empty columns based on a number of panes target (n).
* Returns NULL if there was no columns that matched the target.
*/
struct column *
get_column(struct column *s, int n, int direction)
{
struct column *d;
assert(s != NULL);
d = s;
do {
if (direction == Forward)
d = d->next;
else
d = d->prev;
if (d == NULL) {
if (direction == Forward)
d = s->layout->head;
else
d = s->layout->tail;
}
if (d->n >= n)
return d;
} while (d != s);
return NULL;
}