source: context.c @ 75be7c0

barnowl_perlaimdebianowlrelease-1.10release-1.4release-1.5release-1.6release-1.7release-1.8release-1.9
Last change on this file since 75be7c0 was 10b866d, checked in by Erik Nygren <nygren@mit.edu>, 22 years ago
* Fixed preservation of e->dotsend across owl_editwin_clear(). * Added history for multiline edit windows (eg, for zephyr composition). The M-n and M-p keys will cycle through the history ring. In particular, it is now possible to edit the command line of a zephyr being composed: C-c it and restart it and then M-p to get the aborted composition back.
  • Property mode set to 100644
File size: 1.8 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  ctx->mode = OWL_CTX_STARTUP;
11  ctx->data = NULL;
12  return 0;
13}
14
15
16/* returns whether test matches the current context */
17int owl_context_matches(owl_context *ctx, int test) {
18  /*owl_function_debugmsg(", current: 0x%04x test: 0x%04x\n", ctx->mode, test);*/
19  if ((((ctx->mode&OWL_CTX_MODE_BITS) & test)
20       || !(test&OWL_CTX_MODE_BITS))
21      && 
22      (((ctx->mode&OWL_CTX_ACTIVE_BITS) & test) 
23       || !(test&OWL_CTX_ACTIVE_BITS))) {
24    return 1;
25  } else {
26    return 0;
27  }
28}
29
30void *owl_context_get_data(owl_context *ctx) {
31  return ctx->data;
32}
33
34int owl_context_get_mode(owl_context *ctx) {
35  return ctx->mode & OWL_CTX_MODE_BITS;
36}
37
38int owl_context_get_active(owl_context *ctx) {
39  return ctx->mode & OWL_CTX_ACTIVE_BITS;
40}
41
42int owl_context_is_startup(owl_context *ctx) {
43  return (ctx->mode & OWL_CTX_STARTUP)?1:0;
44}
45
46
47void owl_context_set_startup(owl_context *ctx) {
48  SET_MODE(ctx, OWL_CTX_STARTUP);
49}
50
51void owl_context_set_readconfig(owl_context *ctx) {
52  SET_MODE(ctx, OWL_CTX_READCONFIG);
53}
54
55void owl_context_set_interactive(owl_context *ctx) {
56  SET_MODE(ctx, OWL_CTX_INTERACTIVE);
57}
58
59void owl_context_set_popless(owl_context *ctx, owl_viewwin *vw) {
60  ctx->data = (void*)vw;
61  SET_ACTIVE(ctx, OWL_CTX_POPLESS);
62}
63
64void owl_context_set_recv(owl_context *ctx) {
65  SET_ACTIVE(ctx, OWL_CTX_RECV);
66}
67
68void owl_context_set_editmulti(owl_context *ctx, owl_editwin *ew) {
69  ctx->data = (void*)ew;
70  SET_ACTIVE(ctx, OWL_CTX_EDITMULTI);
71}
72
73void owl_context_set_editline(owl_context *ctx, owl_editwin *ew) {
74  ctx->data = (void*)ew;
75  SET_ACTIVE(ctx, OWL_CTX_EDITLINE);
76}
77
Note: See TracBrowser for help on using the repository browser.