source: context.c @ 853f397

release-1.10release-1.7release-1.8release-1.9
Last change on this file since 853f397 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
RevLine 
[7d4fbcd]1#include <string.h>
[1aee7d9]2#include "owl.h"
3
[7d4fbcd]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
[53f421b]7int owl_context_init(owl_context *ctx)
8{
[7d4fbcd]9  ctx->mode = OWL_CTX_STARTUP;
10  ctx->data = NULL;
[07b59ea]11  ctx->cursor = NULL;
[7d4fbcd]12  return 0;
13}
14
15
16/* returns whether test matches the current context */
[3f8514b]17int owl_context_matches(const owl_context *ctx, int test)
[53f421b]18{
[10b866d]19  /*owl_function_debugmsg(", current: 0x%04x test: 0x%04x\n", ctx->mode, test);*/
[7d4fbcd]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
[3f8514b]31void *owl_context_get_data(const owl_context *ctx)
[53f421b]32{
[7d4fbcd]33  return ctx->data;
34}
35
[3f8514b]36int owl_context_get_mode(const owl_context *ctx)
[53f421b]37{
[7d4fbcd]38  return ctx->mode & OWL_CTX_MODE_BITS;
39}
40
[3f8514b]41int owl_context_get_active(const owl_context *ctx)
[53f421b]42{
[7d4fbcd]43  return ctx->mode & OWL_CTX_ACTIVE_BITS;
44}
45
[3f8514b]46int owl_context_is_startup(const owl_context *ctx)
[53f421b]47{
[7d4fbcd]48  return (ctx->mode & OWL_CTX_STARTUP)?1:0;
49}
50
[3f8514b]51int owl_context_is_interactive(const owl_context *ctx)
[53f421b]52{
[ecd5dc5]53  return(ctx->mode & OWL_CTX_INTERACTIVE)?1:0;
54}
Note: See TracBrowser for help on using the repository browser.