home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / magazine / progjour / 1991 / 06 / editor.h < prev    next >
C/C++ Source or Header  |  1991-10-02  |  3KB  |  86 lines

  1. /* editor.h-- Workhorse Functions Required by Editor */
  2.  
  3. #ifndef __EDITOR_H
  4. #define __EDITOR_H
  5.  
  6. #ifndef ETYP            /* If no user definition, it's void */
  7. #define ETYP void
  8. #endif
  9.                 /* These are the functions that are required
  10.                  * by the editor to manipulate the screen.
  11.                  */
  12.  
  13. void e_attention(ETYP *const p, int horiz);  /* Misc. functions. */
  14. int  e_error    (ETYP *const p);
  15. int  e_close    (ETYP *const p);
  16. int  e_open     (ETYP *const p);
  17.  
  18. int  e_vncols   (ETYP *const p);        /* Viewport functions   */
  19. int  e_vnrows   (ETYP *const p);
  20. int  e_vcol     (ETYP *const p);
  21. int  e_vrow     (ETYP *const p);
  22. int  e_draw     (ETYP *const p);
  23.  
  24. int  e_cur      (ETYP *const this);     /* Line-examination     */
  25. int  e_find_c   (ETYP *const this, int c, int forward, int incl);
  26. int  e_first    (ETYP *const this);
  27. int  e_isword   (ETYP *const this, int c);
  28. int  e_last     (ETYP *const this);
  29.  
  30. int  e_closeline(ETYP *const this);     /* Window functions     */
  31. void e_cleartoeol(ETYP *const this );
  32. int  e_col      (ETYP *const this);
  33. void e_del      (ETYP *const this);
  34. int  e_gotorc   (ETYP *const this, int r, int c );
  35. void e_ins      (ETYP *const this, int c);
  36. int  e_maxcol   (ETYP *const this);
  37. int  e_maxrow   (ETYP *const this);
  38. int  e_openline (ETYP *const this, int below );
  39. int  e_row      (ETYP *const this);
  40. void e_replace  (ETYP *const this, int c);
  41. int  e_update   (ETYP *const this, int enable );
  42. int  e_vscroll  (ETYP *const this, int up, int import);
  43.  
  44.                         /* Special row arguments to e_gotorc()    */
  45.  
  46. #define E_HOME 0x8001   /* home   row (row 0 of viewport), col. 0 */
  47. #define E_MID  0x8002   /* middle row (of viewport), column 0     */
  48. #define E_LAST 0x8003   /* last   row (of viewport), column 0     */
  49.  
  50. #define E_LINEMAX 256   /* Maximum line length.                   */
  51.  
  52.  
  53. #define E_MARKMAX   ((26+10)-1) /* Largest index into mark array */
  54. #define E_DEFMARK    0          /* Default mark, must be zero    */
  55. #define E_MARKNUM(c)(   isdigit(c) ? ( (c)-'0'           ): \
  56.                         isalpha(c) ? ( tolower(c)-'a'+10 ): E_DEFMARK \
  57.                     )
  58. #define E_BUFMAX    ((26+10)-1) /* letters + numbers + default */
  59. #define E_BUFNUM(c) (   isdigit(c) ? ( (c)-'0'           ): \
  60.                         isalpha(c) ? ( tolower(c)-'a'+10 ): 0 \
  61.                     )
  62.  
  63. /*---------------------------------------------------------------*/
  64. /* The editor structure, used by an editor to keep track of      */
  65. /* local variables.                                              */
  66. /* In a C++ class, this would be an editor class of which all    */
  67. /* the workhorse functions would be protected virtual functions. */
  68. /* The engine() itself would be a public staticly-bound          */
  69. /* functions, and all other functions in engine.c would be       */
  70. /* private member functions. engine_open() and engine_close()    */
  71. /* are the constructor and destructor.                           */
  72.  
  73. typedef struct editor
  74. {
  75.     /* add data neede by editor to keep track of its state here */
  76. }
  77. editor;
  78.  
  79. /* These are the interface functions to the engine */
  80.  
  81. extern int      engine           (void *const p, int c);
  82. extern int      engine_open      (void *const p);
  83. extern int      engine_close     (void *const p);
  84. #endif /* __EDITOR_H */
  85.  
  86.