static void doc_init(struct doc *d safe)
{
- d->self = d;
INIT_HLIST_HEAD(&d->marks);
INIT_TLIST_HEAD(&d->points, 0);
d->views = NULL;
DEF_CMD(doc_set)
{
- struct doc *d = ci->home->_data;
+ struct doc *d = &ci->home->doc;
const char *val = ksuffix(ci, "doc:set:");
if (!*val)
DEF_CMD(doc_get_attr)
{
- struct doc *d = ci->home->_data;
+ struct doc *d = &ci->home->doc;
char pathbuf[PATH_MAX];
char *a;
DEF_CMD(doc_set_name)
{
- struct doc *d = ci->home->_data;
+ struct doc *d = &ci->home->doc;
if (!ci->str)
return Enoarg;
DEF_CMD(doc_delview)
{
- struct doc *d = ci->home->_data;
+ struct doc *d = &ci->home->doc;
return do_del_view(d, ci->num, ci->focus);
}
DEF_CMD(doc_addview)
{
- struct doc *d = ci->home->_data;
+ struct doc *d = &ci->home->doc;
struct docview *g;
int ret;
int i;
DEF_CMD_CLOSED(doc_close_doc)
{
- struct doc *d = ci->home->_data;
+ struct doc *d = &ci->home->doc;
doc_free(d, ci->home);
return 1;
}
/* A pane which once held a view is closing. We must discard
* that view if it still exists.
*/
- struct doc *d = ci->home->_data;
+ struct doc *d = &ci->home->doc;
int v;
for (v = 0 ; d->views && v < d->nviews; v++)
DEF_CMD(doc_vmarkget)
{
struct mark *m, *m2;
- m = do_vmark_first(ci->home->_data, ci->num, ci->focus);
- m2 = do_vmark_last(ci->home->_data, ci->num, ci->focus);
+ m = do_vmark_first(&ci->home->doc, ci->num, ci->focus);
+ m2 = do_vmark_last(&ci->home->doc, ci->num, ci->focus);
return comm_call(ci->comm2, "callback:vmark", ci->focus,
0, m, NULL, 0, m2) ?: 1;
}
{
struct mark *m = NULL;
if (ci->mark)
- m = do_vmark_at_or_before(ci->home->_data, ci->mark,
+ m = do_vmark_at_or_before(&ci->home->doc, ci->mark,
ci->num, ci->focus);
comm_call(ci->comm2, "callback:vmark", ci->focus, 0, m);
return 1;
DEF_CMD(doc_drop_cache)
{
struct pane *p = ci->home;
- struct doc *d = p->_data;
+ struct doc *d = &p->doc;
if (d->autoclose)
pane_close(p);
DEF_CMD(doc_push_point)
{
- struct doc *d = ci->home->_data;
+ struct doc *d = &ci->home->doc;
int n = ARRAY_SIZE(d->recent_points);
struct mark *m;
if (!ci->mark)
DEF_CMD(doc_pop_point)
{
- struct doc *d = ci->home->_data;
+ struct doc *d = &ci->home->doc;
int n = ARRAY_SIZE(d->recent_points);
if (!ci->mark)
#include <stdlib.h>
#include <memory.h>
+#define DOC_DATA_TYPE struct doc
#include "core.h"
+#include "core-pane.h"
#include "internal.h"
#include "misc.h"
static void mark_refcnt(struct mark *m safe, int inc)
{
- struct doc *d = m->owner->data;
+ struct doc *d = &m->owner->doc;
if (d->refcnt)
d->refcnt(m, inc);
/* if 'end', move mark after all other marks, else move before all others */
void mark_to_end(struct pane *p safe, struct mark *m safe, int end)
{
- struct doc *d = p->data;
+ struct doc *d = &p->doc;
unsigned int i;
struct point_links *lnk;
{
/* FIXME view is >= -1 */
struct mark *ret;
- struct doc *d = p->data;
+ struct doc *d = &p->doc;
if (view >= d->nviews ||
view < MARK_UNGROUPED ||
if (m && dodebug && count++ >= dodebug) {
count = 0;
- doc_check_consistent(m->owner->data);
+ doc_check_consistent(&m->owner->doc);
}
if (move)
if (!mark_valid(m))
return NULL;
- if (m->owner->data != d) {
+ if (&m->owner->doc != d) {
LOG("vmark_at_or_before called with incorrect mark");
return NULL;
}
hlist_for_each_entry(m, &d->marks, all) {
ASSERT(m->seq >= seq);
- ASSERT(m->owner->data == d);
+ ASSERT(&m->owner->doc == d);
seq = m->seq + 1;
if (m2 && !marks_validate(m2, m) && !warned) {
LOG_BT();
bool marks_validate(struct mark *m1 safe, struct mark *m2 safe)
{
struct mark *m;
- struct doc *d = m1->owner->data;
+ struct doc *d = &m1->owner->doc;
int found = 0;
int ret;
int max = 1000;
void edlib_init(struct pane *ed safe);
struct doc {
- /* This pointer always points to itelf. It allows
- * a pane to have a pointer to a doc, or an embedded doc,
- * and following the pointer at that location will always
- * lead to the doc.
- */
- struct doc *self;
struct hlist_head marks;
struct tlist_head points;
struct docview {
static void check_name(struct docs *docs safe, struct pane *pane safe)
{
- struct doc *d = pane->data;
+ struct doc *d = &pane->doc;
char *nname;
int unique = 1;
int conflict = 1;
else
strcpy(nname, d->name);
list_for_each_entry(p, &docs->collection->children, siblings) {
- struct doc *d2 = p->data;
+ struct doc *d2 = &p->doc;
if (d != d2 && d2->name &&
strcmp(nname, d2->name) == 0) {
conflict = 1;
return comm_call(ci->comm2, "callback:doc",
ci->home);
list_for_each_entry(p, &doc->collection->children, siblings) {
- struct doc *dc = p->data;
+ struct doc *dc = &p->doc;
char *n = dc->name;
if (n && strcmp(ci->str, n) == 0)
return comm_call(ci->comm2, "callback:doc", p);
*/
list_for_each_entry(p, &doc->collection->children, siblings) {
- struct doc *d = p->data;
+ struct doc *d = &p->doc;
if (p->damaged & DAMAGED_CLOSED)
continue;
DEF_CMD(text_readonly)
{
- struct doc *d = ci->home->data;
struct text *t = ci->home->doc_data;
- if (t->file_changed && !d->readonly && ci->num)
+ if (t->file_changed && !t->doc.readonly && ci->num)
t->file_changed = 2;
/* Use default handling */
return Efallthrough;
DEF_CMD(text_autosave_delete)
{
struct pane *home = ci->home;
- struct text *t = home->data;
+ struct text *t = home->doc_data;
const char *name = ci->str;
int ret = 1;
DEF_CMD(text_autosave_tick)
{
struct pane *home = ci->home;
- struct text *t = home->data;
+ struct text *t = home->doc_data;
t->as.timer_started = 0;
if (!t->fname)
DEF_CMD(text_save_file)
{
- struct doc *d = ci->home->data;
struct text *t = ci->home->doc_data;
int ret;
char *msg;
int change_status = 0;
if (!t->fname) {
- asprintf(&msg, "** No file name known for %s ***", d->name);
+ asprintf(&msg, "** No file name known for %s ***", t->doc.name);
ret = Efail;
} else {
ret = do_text_write_file(ci->home, NULL, NULL, t->fname);
static bool check_readonly(const struct cmd_info *ci safe)
{
- struct doc *d = ci->home->data;
struct text *t = ci->home->doc_data;
if (t->undo == t->saved &&
check_file_changed(ci->home) &&
- !d->readonly) {
+ !t->doc.readonly) {
call("doc:notify:doc:status-changed", ci->home);
- d->readonly = 1;
+ t->doc.readonly = 1;
}
- if (!d->readonly)
+ if (!t->doc.readonly)
return False;
call("Message", ci->focus, 0, NULL, "Document is read-only");
return True;
PyErr_SetString(PyExc_TypeError, "Mark is NULL");
return NULL;
}
- d = m->mark->owner->data;
+ d = &m->mark->owner->doc;
if (d->refcnt == mark_refcnt)
return PyLong_FromLong(m->mark->ref.o);
return PyLong_FromLong(0);
val = PyLong_AsLong(v);
if (val == -1 && PyErr_Occurred())
return -1;
- d = m->mark->owner->data;
+ d = &m->mark->owner->doc;
if (d->refcnt == mark_refcnt)
m->mark->ref.o = val;
else {
PyErr_SetString(PyExc_TypeError, "Mark is NULL");
return NULL;
}
- d = m->mark->owner->data;
+ d = &m->mark->owner->doc;
if (d->refcnt == mark_refcnt && m->mark->ref.c) {
Py_INCREF(m->mark->ref.c);
return m->mark->ref.c;
PyErr_SetString(PyExc_TypeError, "Mark is NULL");
return -1;
}
- d = m->mark->owner->data;
+ d = &m->mark->owner->doc;
if (d->refcnt != mark_refcnt) {
PyErr_SetString(PyExc_TypeError, "Cannot set ref for non-local mark");
return -1;
* use that instead, so that mark_same() works.
*/
if ((m2 = mark_next(m->mark)) != NULL &&
- ((struct doc *safe)m2->owner->data)->refcnt == mark_refcnt &&
+ m2->owner->doc.refcnt == mark_refcnt &&
m2->ref.c != NULL && v != NULL &&
PyObject_RichCompareBool(v, m2->ref.c, Py_EQ) == 1)
m->mark->ref.c = m2->ref.c;
else if ((m2 = mark_prev(m->mark)) != NULL &&
- ((struct doc *safe)m2->owner->data)->refcnt == mark_refcnt &&
+ m2->owner->doc.refcnt == mark_refcnt &&
m2->ref.c != NULL && v != NULL &&
PyObject_RichCompareBool(v, m2->ref.c, Py_EQ) == 1)
m->mark->ref.c = m2->ref.c;