source: context.c @ 7d4fbcd

barnowl_perlaimdebianowlrelease-1.10release-1.4release-1.5release-1.6release-1.7release-1.8release-1.9
Last change on this file since 7d4fbcd was 7d4fbcd, checked in by James M. Kretchmar <kretch@mit.edu>, 22 years ago
Initial check in
  • Property mode set to 100644
File size: 1.8 KB
Line 
1#include "owl.h"
2#include <string.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  ctx->mode = OWL_CTX_STARTUP;
9  ctx->data = NULL;
10  return 0;
11}
12
13
14/* returns whether test matches the current context */
15int owl_context_matches(owl_context *ctx, int test) {
16  owl_function_debugmsg(", current: 0x%04x test: 0x%04x\n", ctx->mode, test);
17  if ((((ctx->mode&OWL_CTX_MODE_BITS) & test)
18       || !(test&OWL_CTX_MODE_BITS))
19      && 
20      (((ctx->mode&OWL_CTX_ACTIVE_BITS) & test) 
21       || !(test&OWL_CTX_ACTIVE_BITS))) {
22    return 1;
23  } else {
24    return 0;
25  }
26}
27
28void *owl_context_get_data(owl_context *ctx) {
29  return ctx->data;
30}
31
32int owl_context_get_mode(owl_context *ctx) {
33  return ctx->mode & OWL_CTX_MODE_BITS;
34}
35
36int owl_context_get_active(owl_context *ctx) {
37  return ctx->mode & OWL_CTX_ACTIVE_BITS;
38}
39
40int owl_context_is_startup(owl_context *ctx) {
41  return (ctx->mode & OWL_CTX_STARTUP)?1:0;
42}
43
44
45void owl_context_set_startup(owl_context *ctx) {
46  SET_MODE(ctx, OWL_CTX_STARTUP);
47}
48
49void owl_context_set_readconfig(owl_context *ctx) {
50  SET_MODE(ctx, OWL_CTX_READCONFIG);
51}
52
53void owl_context_set_interactive(owl_context *ctx) {
54  SET_MODE(ctx, OWL_CTX_INTERACTIVE);
55}
56
57void owl_context_set_popless(owl_context *ctx, owl_viewwin *vw) {
58  ctx->data = (void*)vw;
59  SET_ACTIVE(ctx, OWL_CTX_POPLESS);
60}
61
62void owl_context_set_recv(owl_context *ctx) {
63  SET_ACTIVE(ctx, OWL_CTX_RECV);
64}
65
66void owl_context_set_editmulti(owl_context *ctx, owl_editwin *ew) {
67  ctx->data = (void*)ew;
68  SET_ACTIVE(ctx, OWL_CTX_EDITMULTI);
69}
70
71void owl_context_set_editline(owl_context *ctx, owl_editwin *ew) {
72  ctx->data = (void*)ew;
73  SET_ACTIVE(ctx, OWL_CTX_EDITLINE);
74}
75
Note: See TracBrowser for help on using the repository browser.