1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
#include "owl.h"
#include <assert.h>
bool owl_is_editcontext(const owl_context *ctx)
{
return owl_context_matches(ctx, OWL_CTX_TYPWIN);
}
CALLER_OWN owl_context *owl_editcontext_new(int mode, owl_editwin *e, const char *keymap, void (*deactivate_cb)(owl_context*), void *cbdata)
{
owl_context *ctx = owl_context_new(mode, owl_editwin_ref(e), keymap,
owl_editwin_get_window(e));
ctx->deactivate_cb = deactivate_cb;
ctx->delete_cb = owl_editcontext_delete_cb;
ctx->cbdata = cbdata;
/* TODO: the flags are really screwy. */
assert(owl_is_editcontext(ctx));
return ctx;
}
owl_editwin *owl_editcontext_get_editwin(const owl_context *ctx)
{
if (!owl_is_editcontext(ctx)) return NULL;
return ctx->data;
}
void owl_editcontext_delete_cb(owl_context *ctx)
{
if (owl_is_editcontext(ctx) && ctx->data) {
owl_editwin_unref(ctx->data);
ctx->data = NULL;
}
}
|