source: context.c @ 601733d

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