- [X] give every pane a link to root/editor main and use that
instead of statics. Then maybe times_up() can use pane_too_long()
-- [ ] mark DEF_CMD structs as const
+- [X] mark DEF_CMD structs as const- NO, ->refcnt is not constant.
- [X] rexel: don't abort if something looks wrong, just fail.
### Small
- [ ] emacs: :C-q to recognise names of Unicode chars: e.g. WASTEBASKET
Possibly matches a list which continued :C-q cycles through
- [ ] linecount 'view' mode improvements
+- [ ] allocate pane->data together with pane. A single allocation so
+ that we can avoid the cost of a dereference.
### Medium
- [ ] LOG_BT() doesn't see TYPE_pane and TYPE_comm calls.
- [ ] give every pane a link to root/editor main and use that
instead of statics. Then maybe times_up() can use pane_too_long()
-- [ ] mark DEF_CMD structs as const
+- [ ] allocate pane->data together with pane. A single allocation so
+ that we can avoid the cost of a dereference.
+- [X] mark DEF_CMD structs as const - doesn't work due to refcount
- [ ] teach input to allow a repeat command to be registered so that e.g.
search/replace and do a bit of work, then ask to be called again.
input can cancel this on suitable input.
d->refcnt = NULL;
}
-struct pane *__doc_register(struct pane *parent,
- struct command *handle safe,
- struct doc *doc safe,
- void *data safe,
- short data_size)
+struct pane *__doc_register(struct pane *parent safe,
+ struct command *handle safe,
+ struct doc *doc safe,
+ void *data safe,
+ short data_size)
{
struct pane *p;
ASSERT(data_size == 0 || data == (void*)doc);
/* Documents are always registered against the root */
- if (parent)
- parent = pane_root(parent);
+ parent = pane_root(parent);
doc_init(doc);
p = __pane_register(parent, 0, handle, doc, data_size);
return p;
key_add_chain(ei->map, ed_map);
ei->cmd = ed_handle;
ei->cmd.m = &ei->map;
- ed = pane_register(NULL, 0, &ei->cmd.c, ei);
+ ed = pane_register_root(&ei->cmd.c, ei, sizeof(ei));
if (ed) {
doc_setup(ed);
}
}
-struct pane *__pane_register(struct pane *parent, short z,
- struct command *handle safe,
- void *data, short data_size)
+static struct pane *__do_pane_register(struct pane *parent, short z,
+ struct command *handle safe,
+ void *data, short data_size)
{
struct pane *p;
return p;
}
+struct pane *__pane_register(struct pane *parent safe, short z,
+ struct command *handle safe,
+ void *data, short data_size)
+{
+ return __do_pane_register(parent, z, handle, data, data_size);
+}
+
+struct pane *pane_register_root(struct command *handle safe,
+ void *data, short data_size)
+{
+ return __do_pane_register(NULL, 0, handle, data, data_size);
+}
+
/* 'abs_z' is a global z-depth number (->z is relative to parent)
* 'abs_z' of root is 0, and abs_z of every other pane with z<=0 is 1 more than
* abs_z or parent, and abs_z of pane with z>0 is 1 more than max abs_z
#define DAMAGED_NEED_CALL (DAMAGED_SIZE | DAMAGED_REFRESH)
struct xy {short x,y;};
-struct pane * __pane_register(struct pane *parent, short z,
+struct pane * __pane_register(struct pane *parent safe, short z,
struct command *handle safe, void *data,
short data_size);
#define pane_register(...) VFUNC(pane_register, __VA_ARGS__)
#define pane_register4(p,z,h,d) __pane_register(p,z,h,d,sizeof((d)[0]))
#define pane_register3(p,z,h) __pane_register(p,z,h,NULL, 0)
-struct pane *__doc_register(struct pane *parent,
+struct pane *__doc_register(struct pane *parent safe,
struct command *handle safe,
struct doc *doc safe,
void *data safe,
pane_resize(p, 0, 0, cols, rows);
}
-static struct pane *ncurses_init(struct pane *ed,
+static struct pane *ncurses_init(struct pane *ed safe,
const char *tty, const char *term)
{
SCREEN *scr;
struct mark *do_mark_at_point(struct mark *pt safe, int view);
void __mark_free(struct mark *m);
+struct pane *pane_register_root(struct command *handle safe,
+ void *data, short data_size);
+
void editor_delayed_free(struct pane *ed safe, struct pane *p safe);
void editor_delayed_mark_free(struct mark *m safe);
void doc_setup(struct pane *ed safe);
Pane **parentp safe,
int *zp safe)
{
- Pane *parent = NULL;
int ret;
static const char *keywords[] = {"parent", "z", NULL};
return 0;
/* Pane(parent=None, z=0) */
- ret = PyArg_ParseTupleAndKeywords(args, kwds, "|Oi", (char**)keywords,
- &parent, zp);
+ ret = PyArg_ParseTupleAndKeywords(args, kwds, "O!|i", (char**)keywords,
+ &PaneType, parentp, zp);
if (ret <= 0)
return -1;
- if ((PyObject*)parent == Py_None)
- parent = NULL;
-
- if (parent && !PyObject_TypeCheck(parent, &PaneType)) {
- PyErr_SetString(PyExc_TypeError, "First arg must be edlib.Pane or None");
- return -1;
- }
-
- *parentp = parent;
-
self->map = key_alloc();
key_add(self->map, "Close:mark", &python_close_mark);
self->cmd = python_pane_call;
if (ret <= 0)
return ret;
+ if (!parent || !parent->pane)
+ return -1;
/* The pane holds a reference to the Pane through the ->handle
* function
*/
Py_INCREF(self);
- self->pane = pane_register(parent ? parent->pane : NULL,
- z, &self->cmd, self);
+ self->pane = pane_register(parent->pane, z, &self->cmd, self);
if (self->pane)
pane_get(self->pane);
return 0;
int z = 0;
int ret = __Pane_init((Pane*safe)self, args, kwds, &parent, &z);
- if (ret <= 0 || !self)
+ if (ret <= 0)
return ret;
+ if (!self || !parent || !parent->pane)
+ return -1;
self->cmd.func = python_doc_call_func;
- self->pane = __doc_register(parent ? parent->pane : NULL,
- &self->cmd, &self->doc, self, 0);
+ self->pane = __doc_register(parent->pane, &self->cmd, &self->doc, self, 0);
if (self->pane)
pane_get(self->pane);
self->doc.refcnt = mark_refcnt;
struct command *globalcmd;
};
-static struct pane *safe do_keymap_attach(struct pane *p);
+static struct pane *safe do_keymap_attach(struct pane *p safe);
DEF_CMD(keymap_handle)
{
return Efallthrough;
}
-static struct pane *safe do_keymap_attach(struct pane *p)
+static struct pane *safe do_keymap_attach(struct pane *p safe)
{
struct key_data *kd = malloc(sizeof(*kd));
struct pane *p;
alloc(cli, pane);
- p = pane_register(NULL, 0, &handle_count_lines.c, cli);
+ p = pane_register(pane_root(ci->focus), 0,
+ &handle_count_lines.c, cli);
if (!p)
return Efail;
cli->view_num = home_call(ci->focus, "doc:add-view", p) - 1;
static struct map *view_map safe;
DEF_LOOKUP_CMD(view_handle, view_map);
-static struct pane *do_view_attach(struct pane *par, int border);
+static struct pane *do_view_attach(struct pane *par safe, int border);
static int calc_border(struct pane *p safe);
static const char default_status[] =
return Efallthrough;
}
-static struct pane *do_view_attach(struct pane *par, int border)
+static struct pane *do_view_attach(struct pane *par safe, int border)
{
struct view_data *vd;
struct pane *p;
bool active;
};
-static struct pane *safe do_viewer_attach(struct pane *par)
+static struct pane *safe do_viewer_attach(struct pane *par safe)
{
struct viewer_data *vd;
call("doc:set-name", p, 0, NULL, "Shell Command", -1);
p = call_ret(pane, "attach-history", p, 0, NULL, "*Shell History*",
0, NULL, "popup:close");
- p = pane_register(p, 0, &find_handle.c, "shellcmd");
+ if (p)
+ p = pane_register(p, 0, &find_handle.c, "shellcmd");
if (p && ci->comm2)
comm_call(ci->comm2, "cb", p);
return 1;
call("doc:set-name", p, 0, NULL, "K:Ax command", -1);
p = call_ret(pane, "attach-history", p, 0, NULL, "*Command History*",
0, NULL, "popup:close");
- pane_register(p, 0, &find_handle.c, "cmd");
+ if (p)
+ pane_register(p, 0, &find_handle.c, "cmd");
return 1;
}
return 1;
}
-static struct pane *complete_pane(struct pane *focus)
+static struct pane *complete_pane(struct pane *focus safe)
{
struct pane *complete;
struct complete_data *cd;
rl->target_y = -1;
rl->do_wrap = 1;
p = ci->focus;
- if (strcmp(ci->key, "attach-render-text") == 0)
+ if (strcmp(ci->key, "attach-render-text") == 0) {
p = call_ret(pane, "attach-markup", p);
+ if (!p)
+ p = ci->focus;
+ }
p = pane_register(p, 0, &render_lines_handle.c, rl);
if (!p) {
free(rl);