source: context.c @ 3c7d007a

barnowl_perlaimdebianowlrelease-1.10release-1.4release-1.5release-1.6release-1.7release-1.8release-1.9
Last change on this file since 3c7d007a was cf83b7a, checked in by James M. Kretchmar <kretch@mit.edu>, 21 years ago
Started adding code to do question/response stuff
  • Property mode set to 100644
File size: 2.1 KB
Line 
1#include <string.h>
2#include "owl.h"
3
4static const char fileIdent[] = "$Id$";
5
6#define SET_ACTIVE(ctx, new) ctx->mode = ((ctx->mode)&~OWL_CTX_ACTIVE_BITS)|new
7#define SET_MODE(ctx, new) ctx->mode = ((ctx->mode)&~OWL_CTX_MODE_BITS)|new
8
9int owl_context_init(owl_context *ctx)
10{
11  ctx->mode = OWL_CTX_STARTUP;
12  ctx->data = NULL;
13  return 0;
14}
15
16
17/* returns whether test matches the current context */
18int owl_context_matches(owl_context *ctx, int test)
19{
20  /*owl_function_debugmsg(", current: 0x%04x test: 0x%04x\n", ctx->mode, test);*/
21  if ((((ctx->mode&OWL_CTX_MODE_BITS) & test)
22       || !(test&OWL_CTX_MODE_BITS))
23      && 
24      (((ctx->mode&OWL_CTX_ACTIVE_BITS) & test) 
25       || !(test&OWL_CTX_ACTIVE_BITS))) {
26    return 1;
27  } else {
28    return 0;
29  }
30}
31
32void *owl_context_get_data(owl_context *ctx)
33{
34  return ctx->data;
35}
36
37int owl_context_get_mode(owl_context *ctx)
38{
39  return ctx->mode & OWL_CTX_MODE_BITS;
40}
41
42int owl_context_get_active(owl_context *ctx)
43{
44  return ctx->mode & OWL_CTX_ACTIVE_BITS;
45}
46
47int owl_context_is_startup(owl_context *ctx)
48{
49  return (ctx->mode & OWL_CTX_STARTUP)?1:0;
50}
51
52int owl_context_is_interactive(owl_context *ctx)
53{
54  return(ctx->mode & OWL_CTX_INTERACTIVE)?1:0;
55}
56
57void owl_context_set_startup(owl_context *ctx)
58{
59  SET_MODE(ctx, OWL_CTX_STARTUP);
60}
61
62void owl_context_set_readconfig(owl_context *ctx)
63{
64  SET_MODE(ctx, OWL_CTX_READCONFIG);
65}
66
67void owl_context_set_interactive(owl_context *ctx)
68{
69  SET_MODE(ctx, OWL_CTX_INTERACTIVE);
70}
71
72void owl_context_set_popless(owl_context *ctx, owl_viewwin *vw)
73{
74  ctx->data = (void*)vw;
75  SET_ACTIVE(ctx, OWL_CTX_POPLESS);
76}
77
78void owl_context_set_recv(owl_context *ctx)
79{
80  SET_ACTIVE(ctx, OWL_CTX_RECV);
81}
82
83void owl_context_set_editmulti(owl_context *ctx, owl_editwin *ew)
84{
85  ctx->data = (void*)ew;
86  SET_ACTIVE(ctx, OWL_CTX_EDITMULTI);
87}
88
89void owl_context_set_editline(owl_context *ctx, owl_editwin *ew)
90{
91  ctx->data = (void*)ew;
92  SET_ACTIVE(ctx, OWL_CTX_EDITLINE);
93}
94
95void owl_context_set_editresponse(owl_context *ctx, owl_editwin *ew)
96{
97  ctx->data = (void*)ew;
98  SET_ACTIVE(ctx, OWL_CTX_EDITRESPONSE);
99}
100
Note: See TracBrowser for help on using the repository browser.