home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_400 / 402_01 / cforms-2.2 / include / cforms.h < prev   
Encoding:
C/C++ Source or Header  |  1993-07-20  |  4.0 KB  |  184 lines

  1. #ifndef _CFORMS_H
  2. #define _CFORMS_H
  3.  
  4. #ifndef lint
  5. static volatile char sccs_cforms_h[] = "@(#) cforms.h,v 1.15 1993/07/21 01:15:16 lasse Exp";
  6. #endif
  7.  
  8. #ifndef OK
  9. #define OK    0
  10. #endif
  11.  
  12. #ifndef FAIL
  13. #define FAIL    -1
  14. #endif
  15.  
  16. #ifndef TRUE
  17. #define TRUE 1
  18. #endif
  19.  
  20. #ifndef FALSE
  21. #define FALSE 0
  22. #endif
  23.  
  24. #define KEY_ANY        07777
  25.  
  26. #ifndef KEY_ESC
  27. #define KEY_ESC        033
  28. #endif
  29.  
  30. #define EVENT_KEY    1
  31. #define EVENT_REFRESH    2
  32. #define EVENT_ENTRY    3
  33. #define EVENT_EXIT    4
  34. #define EVENT_DRAW    5
  35. #define EVENT_PREVIOUS    6
  36. #define EVENT_NEXT    7
  37.  
  38. #define FLD_TYPE    0x000F
  39. #define FLD_MODIFIER    0x0FF0
  40.  
  41. #define FLD_RIGHT    0x0010
  42. #define FLD_LEFT    0x0020
  43. #define FLD_UPPERCASE    0x0040
  44. #define FLD_PROTECTED    0x0080
  45. #define FLD_HIGHLIGHT    0x0100
  46. #define FLD_INVISIBLE    0x0200
  47. #define FLD_FORBIDDEN    0x0400
  48.  
  49. #define FLD_INT        0x0001
  50. #define FLD_CHAR    0x0002
  51. #define FLD_ALNUM    0x0003
  52.  
  53. #define PIC_FRAME    0x0001
  54.  
  55. #ifndef SLASH
  56. #define SLASH '/'
  57. #endif
  58.  
  59. struct xy {
  60.     int x, y;
  61. };
  62.  
  63. #ifndef _COMP_H
  64. struct event {
  65.     int type;
  66.     int code;
  67.     int global;
  68.     void (*func)(int event_code);
  69. };
  70.  
  71. struct field {
  72.     char *name;
  73.     int type;
  74.     int len;
  75.     char *data;
  76.     struct xy pos;
  77.     char *lvalue;
  78.     char *rvalue;
  79.     struct event *event;
  80.     int n_events;
  81.     unsigned long flags;
  82.     char modified;
  83.     struct picture *picture;
  84. };
  85.  
  86. struct literal {
  87.     struct xy pos;
  88.     char *value;
  89.     unsigned long flags;
  90. };
  91.  
  92. struct picture {
  93.     char *name;
  94.     struct field *field;
  95.     int n_fields;
  96.     struct literal *literal;
  97.     int n_literals;
  98.     struct event *event;
  99.     int n_events;
  100.     int x, y;
  101.     int width, height;
  102.     struct module *module;
  103.     unsigned long flags;
  104. };
  105.  
  106. struct module
  107. {
  108.     struct picture *picture;
  109.     int n_pictures;
  110.     struct event *event;
  111.     int n_events;
  112. };
  113.  
  114. struct global
  115. {
  116.     struct picture *picture;
  117.     struct field *field;
  118.     struct field *move_field;
  119.     int leave_picture;
  120.     char bs;        /* Normally backspace    */
  121.     char del1;        /* Normally DEL        */
  122.     char del2;        /* Normally CTRL-D    */
  123.     char kill;        /* Normally CTRL-K    */
  124.     char clear;        /* Normally CTRL-U    */
  125. };
  126.  
  127. /*
  128.  * Misc. functions.
  129.  */
  130. extern int cforms_init(void);
  131. extern int cforms_end(void);
  132. extern int cforms_system(const char *command, const char *prompt);
  133. extern void cforms_refresh();
  134.  
  135. /*
  136.  * Picture functions.
  137.  */
  138. extern struct picture *picture(const char *fmt, ...);
  139. extern int             pic_call(struct picture *pic, const char *fieldname);
  140. extern int             pic_leave(void);
  141. extern int             pic_clear(struct picture *pic);
  142.  
  143. /* 
  144.  * Field functons.
  145.  */
  146. extern struct field *field(const char *fmt, ...);
  147. extern struct field *fld_move(struct field *fld);
  148. extern struct field *fld_down(const struct field *fld);
  149. extern struct field *fld_up(const struct field *fld);
  150. extern struct field *fld_left(const struct field *fld);
  151. extern struct field *fld_right(const struct field *fld);
  152. extern struct field *fld_first(void);
  153. extern struct field *fld_last(void);
  154. extern struct field *fld_next(const struct field *fld);
  155. extern struct field *fld_previous(const struct field *fld);
  156. extern const char   *fld_get(const struct field *fld);
  157. extern char           *fld_get_trimmed(const struct field *fld);
  158. extern int           fld_set(struct field *fld, const char *value);
  159. extern int           fld_nset(struct field *fld, const char *value, int n);
  160. extern int           fld_len(const struct field *fld);
  161. extern const char   *fld_name(const struct field *fld);
  162. extern int           fld_isempty(const struct field *fld);
  163. extern int           fld_ismodified(const struct field *fld);
  164. extern void          fld_touch(struct field *fld);
  165. extern void         fld_sattr(struct field *fld, unsigned long attr);
  166. extern void         fld_cattr(struct field *fld, unsigned long attr);
  167.  
  168. /*
  169.  * General functions.
  170.  */
  171. extern                 get_fld(struct field *fld, int (*check)());
  172. extern int             strequ(const char *s1, const char *s2);
  173. extern int             message(const char *fmt, ...);
  174. extern int             message_nr(const char *fmt, ...);
  175.  
  176.  
  177. extern struct module *_cf_modules[];
  178. extern struct global _cf_globals;
  179.  
  180. #endif /* _COMP_H */
  181.  
  182. #endif /* _CFORMS_H */
  183.  
  184.