Remove Travis CI configuration
[dvtm.git] / fibonacci.c
blob70555f4c4c0f58e937065532107a61a66e3a3471
1 static void fibonacci(int s)
3 unsigned int nx, ny, nw, nnw, nh, nnh, i, n, mod;
4 Client *c;
6 for (n = 0, c = nextvisible(clients); c; c = nextvisible(c->next))
7 if (!c->minimized)
8 n++;
10 /* initial position and dimensions */
11 nx = wax;
12 ny = way;
13 nw = (n == 1) ? waw : screen.mfact * waw;
14 /* don't waste space dviding by 2 doesn't work for odd numbers
15 * plus we need space for the border too. therefore set up these
16 * variables for the next new width/height
18 nnw = waw - nw - 1;
19 nnh = nh = wah;
21 /* set the mod factor, 2 for dwindle, 4 for spiral */
22 mod = s ? 4 : 2;
24 for (i = 0, c = nextvisible(clients); c; c = nextvisible(c->next)) {
25 if (c->minimized)
26 continue;
27 /* dwindle: even case, spiral: case 0 */
28 if (i % mod == 0) {
29 if (i) {
30 if (s) {
31 nh = nnh;
32 ny -= nh;
33 } else {
34 ny += nh;
35 nh = nnh;
37 /* don't adjust the width for the last client */
38 if (i < n - 1) {
39 nw /= 2;
40 nnw -= nw + 1;
42 mvaddch(ny, nx - 1, ACS_LTEE);
44 } else if (i % mod == 1) { /* dwindle: odd case, spiral: case 1 */
45 nx += nw;
46 mvvline(ny, nx, ACS_VLINE, nh);
47 mvaddch(ny, nx, ACS_TTEE);
48 ++nx;
49 nw = nnw;
50 /* don't adjust the height for the last client */
51 if (i < n - 1) {
52 nh /= 2;
53 nnh -= nh;
55 } else if (i % mod == 2 && s) { /* spiral: case 2 */
56 ny += nh;
57 nh = nnh;
58 /* don't adjust the width for the last client */
59 if (i < n - 1) {
60 nw /= 2;
61 nnw -= nw + 1;
62 nx += nnw;
63 mvvline(ny, nx, ACS_VLINE, nh);
64 mvaddch(ny, nx, ACS_TTEE);
65 ++nx;
66 } else {
67 mvaddch(ny, nx - 1, ACS_LTEE);
69 } else if (s) { /* spiral: case 3 */
70 nw = nnw;
71 nx -= nw + 1; /* border */
72 /* don't adjust the height for the last client */
73 if (i < n - 1) {
74 nh /= 2;
75 nnh -= nh;
76 ny += nnh;
78 mvaddch(ny, nx - 1, ACS_LTEE);
81 resize(c, nx, ny, nw, nh);
82 i++;
86 static void spiral(void)
88 fibonacci(1);
91 static void dwindle(void)
93 fibonacci(0);