#include <stdlib.h>
#include <string.h>
-/* Note that we don't use PANE_DATA_TYPE because the tileinfo
- * moves between panes sometimes.
- */
+/* The data can move between panes, so we must use a PTR type */
+#define PANE_DATA_PTR_TYPE struct tileinfo *
+struct tileinfo;
#include "core.h"
struct tileinfo {
char *group; /* only allocate for root, other share */
char *name; /* name in group for this leaf */
};
+#include "core-pane.h"
static struct map *tile_map safe;
static void tile_adjust(struct pane *p safe);
DEF_CMD_CLOSED(tile_close)
{
- struct tileinfo *ti = ci->home->_data;
+ struct tileinfo *ti = ci->home->data;
tile_destroy(ci->home);
free(ti->name);
DEF_CMD(tile_refresh_size)
{
struct pane *p = ci->home;
- struct tileinfo *ti = p->_data;
+ struct tileinfo *ti = p->data;
if (ti->direction == Neither) {
tile_avail(p, NULL);
* create a single tile, cloned from the focus pane
*/
child = ci->home;
- cti = child->_data;
+ cti = child->data;
alloc(ti, pane);
ti->leaf = 1;
ti->direction = Neither;
attr_set_str(&p2->attrs, "borders", "BL");
while (!cti->leaf && child->focus) {
child = child->focus;
- cti = child->_data;
+ cti = child->data;
}
cti = list_next_entry(cti, tiles);
- while (cti != child->_data &&
+ while (cti != child->data &&
(cti->name == NULL || strcmp(cti->name, "main") != 0))
cti = list_next_entry(cti, tiles);
child = cti->p;
int space, new_space;
struct pane *p = safe_cast *pp;
struct pane *ret;
- struct tileinfo *ti = p->_data;
+ struct tileinfo *ti = p->data;
struct tileinfo *ti2;
if (horiz)
space = p->w;
ti2->direction = ti->direction;
ti2->group = ti->group;
INIT_LIST_HEAD(&ti2->tiles);
- p->_data = ti2;
+ p->data = ti2;
ti2->p = p;
p2 = pane_register(p, 0, &tile_handle.c, ti);
if (!p2)
static int tile_destroy(struct pane *p safe)
{
- struct tileinfo *ti = p->_data;
+ struct tileinfo *ti = p->data;
struct pane *prev = NULL, *next = NULL;
struct pane *t, *remain = NULL;
int pos, prevpos, nextpos;
* Cannot destroy the parent, so bring child into parent */
p = remain->parent;
- ti = remain->_data;
- ti2 = p->_data;
+ ti = remain->data;
+ ti2 = p->data;
tmp = ti2->direction;
ti2->direction = ti->direction;
* if stacking direction doesn't match 'horiz', find minimum.
* If only one child, assume min of 4.
*/
- struct tileinfo *ti = p->_data;
+ struct tileinfo *ti = p->data;
struct pane *t;
if (ti->leaf) {
if (t == ignore || !mine(t))
continue;
tile_avail(t, NULL);
- ti2 = t->_data;
+ ti2 = t->data;
if (min < 0 || min > ti2->avail_perp)
min = ti2->avail_perp;
sum += ti2->avail_inline;
int avail_cnt = 0;
int pos;
int size = 0;
- struct tileinfo *ti = p->_data;
+ struct tileinfo *ti = p->data;
if (ti->leaf)
/* Children are responsible for themselves. */
if (!mine(t))
continue;
- ti = t->_data;
+ ti = t->data;
if (ti->direction == Horiz) {
pane_resize(t, t->x, 0, t->w, p->h);
used += t->w;
cnt = avail_cnt;
avail_cnt = 0;
list_for_each_entry(t, &p->children, siblings) {
- struct tileinfo *ti2 = t->_data;
+ struct tileinfo *ti2 = t->data;
int diff;
int mysize;
if (!mine(t))
}
pos = 0;
list_for_each_entry(t, &p->children, siblings) {
- struct tileinfo *ti2 = t->_data;
+ struct tileinfo *ti2 = t->data;
if (!mine(t))
continue;
if (ti2->direction == Horiz) {
* Then that propagates back down. Size of this pane is adjusted
* first to catch the propagations, then corrected after.
*/
- struct tileinfo *ti = p->_data;
+ struct tileinfo *ti = p->data;
struct tileinfo *tip;
int avail;
/* Hoping to grow if there is room for others to shrink */
tile_avail(p->parent, p);
- tip = p->parent->_data;
+ tip = p->parent->data;
if (ti->direction == (horiz ? Horiz : Vert))
avail = tip->avail_inline;
else
struct pane *p = next_child(ti->p, NULL, 0);
if (!p)
return NULL;
- ti = p->_data;
+ ti = p->data;
}
return ti;
}
while (ti->direction != Neither) {
if (ti->p != next_child(ti->p->parent, NULL, 0))
return False;
- ti = ti->p->parent->_data;
+ ti = ti->p->parent->data;
}
return True;
}
static struct pane *tile_root_popup(struct tileinfo *ti safe)
{
while (ti->direction != Neither)
- ti = ti->p->parent->_data;
+ ti = ti->p->parent->data;
return next_child(ti->p, NULL, 1);
}
static bool wrong_pane(struct cmd_info const *ci safe)
{
- struct tileinfo *ti = ci->home->_data;
+ struct tileinfo *ti = ci->home->data;
if (ci->str || ti->group) {
if (!ci->str || !ti->group)
*/
struct pane *p = ci->home;
struct pane *p2;
- struct tileinfo *ti = p->_data;
+ struct tileinfo *ti = p->data;
struct tileinfo *t2;
if (wrong_pane(ci))
DEF_CMD(tile_window_prev)
{
struct pane *p = ci->home;
- struct tileinfo *ti = p->_data;
+ struct tileinfo *ti = p->data;
struct tileinfo *t2;
if (wrong_pane(ci))
DEF_CMD(tile_window_close)
{
struct pane *p = ci->home;
- struct tileinfo *ti = p->_data;
+ struct tileinfo *ti = p->data;
if (wrong_pane(ci))
return Efallthrough;
{
struct pane *p = ci->home;
struct pane *parent = p->parent;
- struct tileinfo *ti = p->_data;
+ struct tileinfo *ti = p->data;
bool found = True;
if (wrong_pane(ci))
*/
struct pane *p = ci->home;
struct pane *p2;
- struct tileinfo *ti = p->_data;
+ struct tileinfo *ti = p->data;
struct tileinfo *ti2;
int horiz, after;
DEF_CMD(tile_this)
{
- struct tileinfo *ti = ci->home->_data;
+ struct tileinfo *ti = ci->home->data;
if (ci->str || ti->group) {
if (!ci->str || !ti->group)
/* Find the pane displaying given document, preferrably not
* this pane
*/
- struct tileinfo *ti = ci->home->_data;
+ struct tileinfo *ti = ci->home->data;
struct tileinfo *t;
char *name;
DEF_CMD(tile_root)
{
struct pane *p = ci->home;
- struct tileinfo *ti = p->_data;
+ struct tileinfo *ti = p->data;
if (ti->direction != Neither)
return Efallthrough;
DEF_CMD(tile_child_notify)
{
struct pane *p = ci->home;
- struct tileinfo *ti = p->_data;
+ struct tileinfo *ti = p->data;
struct pane *c = ci->focus;
if (c->z)