16 rowinit(Row *row, Rectangle r)
21 draw(screen, r, display->white, nil, ZP);
26 r1.max.y = r1.min.y + font->height;
28 textinit(t, screen, r1, font, tagcols);
35 draw(screen, r1, display->black, nil, ZP);
36 textinsert(t, 0, L"Newcol Google Exit ", 19);
37 textsetselect(t, t->rs.nr, t->rs.nr);
41 rowadd(Row *row, Column *c, int x)
49 r.min.y = row->tag.r.max.y+Border;
50 if(x<r.min.x && row->ncol>0){ /*steal 40% of last column by default */
51 d = row->col[row->ncol-1];
52 x = d->r.min.x + 3*Dx(d->r)/5;
54 /* look for column we'll land on */
55 for(i=0; i<row->ncol; i++){
62 i++; /* new column will go after d */
66 draw(screen, r, display->white, nil, ZP);
68 r1.max.x = min(x, r.max.x-50);
70 r1.max.x = r1.min.x+50;
73 r1.max.x = r1.min.x+Border;
74 draw(screen, r1, display->black, nil, ZP);
78 c = emalloc(sizeof(Column));
84 row->col = realloc(row->col, (row->ncol+1)*sizeof(Column*));
85 memmove(row->col+i+1, row->col+i, (row->ncol-i)*sizeof(Column*));
93 rowresize(Row *row, Rectangle r)
103 r1.max.y = r1.min.y + font->height;
104 textresize(&row->tag, screen, r1);
107 draw(screen, r1, display->black, nil, ZP);
111 for(i=0; i<row->ncol; i++){
117 r1.max.x = r1.min.x+Dx(c->r)*dx/odx;
120 r2.max.x = r2.min.x+Border;
121 draw(screen, r2, display->black, nil, ZP);
129 rowdragcol(Row *row, Column *c, int)
137 setcursor(mousectl, &boxcursor);
140 while(mouse->buttons == b)
142 setcursor(mousectl, nil);
144 while(mouse->buttons)
149 for(i=0; i<row->ncol; i++)
152 error("can't find column");
158 if((abs(p.x-op.x)<5 && abs(p.y-op.y)<5))
160 if((i>0 && p.x<row->col[i-1]->r.min.x) || (i<row->ncol-1 && p.x>c->r.max.x)){
163 rowclose(row, c, FALSE);
164 if(rowadd(row, c, p.x) == nil) /* whoops! */
165 if(rowadd(row, c, x) == nil) /* WHOOPS! */
166 if(rowadd(row, c, -1)==nil){ /* shit! */
167 rowclose(row, c, TRUE);
174 if(p.x < d->r.min.x+80+Scrollsize)
175 p.x = d->r.min.x+80+Scrollsize;
176 if(p.x > c->r.max.x-80-Scrollsize)
177 p.x = c->r.max.x-80-Scrollsize;
179 r.max.x = c->r.max.x;
180 draw(screen, r, display->white, nil, ZP);
187 draw(screen, r, display->black, nil, ZP);
189 r.max.x = c->r.max.x;
195 rowclose(Row *row, Column *c, int dofree)
200 for(i=0; i<row->ncol; i++)
203 error("can't find column");
208 memmove(row->col+i, row->col+i+1, (row->ncol-i)*sizeof(Column*));
210 row->col = realloc(row->col, row->ncol*sizeof(Column*));
212 draw(screen, r, display->white, nil, ZP);
215 if(i == row->ncol){ /* extend last column right */
217 r.min.x = c->r.min.x;
218 r.max.x = row->r.max.x;
219 }else{ /* extend next window left */
221 r.max.x = c->r.max.x;
223 draw(screen, r, display->white, nil, ZP);
228 rowwhichcol(Row *row, Point p)
233 for(i=0; i<row->ncol; i++){
235 if(ptinrect(p, c->r))
242 rowwhich(Row *row, Point p, Rune r, int key)
246 if(ptinrect(p, row->tag.all))
248 c = rowwhichcol(row, p);
250 return colwhich(c, p, r, key);