File: editcontext.c

package info (click to toggle)
barnowl 1.10-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 5,472 kB
  • sloc: ansic: 36,670; perl: 20,938; sh: 1,598; makefile: 181
file content (33 lines) | stat: -rw-r--r-- 890 bytes parent folder | download | duplicates (4)
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;
  }
}