source: context.c @ 6425d43

release-1.10release-1.7release-1.8release-1.9
Last change on this file since 6425d43 was 07b59ea, checked in by David Benjamin <davidben@mit.edu>, 14 years ago
Maintain the cursor location with the context stack
  • Property mode set to 100644
File size: 1.2 KB
Line 
1#include <string.h>
2#include "owl.h"
3
4#define SET_ACTIVE(ctx, new) ctx->mode = ((ctx->mode)&~OWL_CTX_ACTIVE_BITS)|new
5#define SET_MODE(ctx, new) ctx->mode = ((ctx->mode)&~OWL_CTX_MODE_BITS)|new
6
7int owl_context_init(owl_context *ctx)
8{
9  ctx->mode = OWL_CTX_STARTUP;
10  ctx->data = NULL;
11  ctx->cursor = NULL;
12  return 0;
13}
14
15
16/* returns whether test matches the current context */
17int owl_context_matches(const owl_context *ctx, int test)
18{
19  /*owl_function_debugmsg(", current: 0x%04x test: 0x%04x\n", ctx->mode, test);*/
20  if ((((ctx->mode&OWL_CTX_MODE_BITS) & test)
21       || !(test&OWL_CTX_MODE_BITS))
22      && 
23      (((ctx->mode&OWL_CTX_ACTIVE_BITS) & test) 
24       || !(test&OWL_CTX_ACTIVE_BITS))) {
25    return 1;
26  } else {
27    return 0;
28  }
29}
30
31void *owl_context_get_data(const owl_context *ctx)
32{
33  return ctx->data;
34}
35
36int owl_context_get_mode(const owl_context *ctx)
37{
38  return ctx->mode & OWL_CTX_MODE_BITS;
39}
40
41int owl_context_get_active(const owl_context *ctx)
42{
43  return ctx->mode & OWL_CTX_ACTIVE_BITS;
44}
45
46int owl_context_is_startup(const owl_context *ctx)
47{
48  return (ctx->mode & OWL_CTX_STARTUP)?1:0;
49}
50
51int owl_context_is_interactive(const owl_context *ctx)
52{
53  return(ctx->mode & OWL_CTX_INTERACTIVE)?1:0;
54}
Note: See TracBrowser for help on using the repository browser.