home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / library / dos / edit / edutils / edutils.h next >
Encoding:
C/C++ Source or Header  |  1994-03-06  |  9.2 KB  |  257 lines

  1. /*
  2. ** ED-UTILS Editor Utilities
  3. ** (c) Copyright 1994  Kenneth J. Macke
  4. **
  5. ** For information write:
  6. **
  7. ** Kenneth J. Macke
  8. ** P.O. Box 11313
  9. ** Cincinnati, OH  45211
  10. */
  11.  
  12. #ifndef  EDITOR_SYMBOLS
  13.  
  14.     #define  EDITOR_SYMBOLS
  15.  
  16.        /*  Status Type Definitions (Parameters for displaying status)  */
  17.     #define  STATUS_NONE        0
  18.     #define  STATUS_COL         1
  19.     #define  STATUS_LINE        2
  20.     #define  STATUS_ALL         3
  21.  
  22.        /*  File Load Type Definitions (Parameters for initializing the edit buffer  */
  23.     #define  LOAD_NONE          0     // Do not initalize the edit buffer
  24.     #define  LOAD_ARRAY         1     // Fill the edit buffer with the contents of the passed array
  25.     #define  LOAD_FILE          2     // Fill the edit buffer with the contents of the specified file
  26.     #define  LOAD_BOTH          3     // Load the file if specified, otherwise, load the array
  27.  
  28.        /*  File Save Type Definitions (Parameters for storing the edit buffer  */
  29.     #define  SAVE_NONE          0     // Do not automatically save the edit buffer
  30.     #define  SAVE_ARRAY         1     // Store the edit buffer in the passed array when done editing
  31.     #define  SAVE_FILE          2     // Store the edit buffer in the specified file
  32.     #define  SAVE_BOTH          3     // Store the edit buffer in the passed array AND the specified file
  33.  
  34.        /*  Function Type Definitions  */
  35.     #define  FN_INVALID         0
  36.     #define  FN_REGULAR         1
  37.     #define  FN_QUIT            2
  38.     #define  FN_BACKSPACE       3
  39.  
  40.     #define  FN_LEFT            4
  41.     #define  FN_RIGHT           5
  42.     #define  FN_UP              6
  43.     #define  FN_DOWN            7
  44.  
  45.     #define  FN_PAGE_UP         8
  46.     #define  FN_PAGE_DOWN       9
  47.  
  48.     #define  FN_START_OF_LINE   10
  49.     #define  FN_END_OF_LINE     11
  50.     #define  FN_DELETE_CHAR     12
  51.     #define  FN_NEW_LINE_AFTER  13     /* Insert new line after current line */
  52.     #define  FN_NEW_LINE_BEFORE 14     /* Insert new line before current line */
  53.  
  54.     #define  FN_DELETE_LINE     15
  55.  
  56.     #define  FN_SAVE_FILE       16
  57.     #define  FN_LOAD_FILE       17
  58.     #define  FN_SAVE_AND_QUIT   18
  59.  
  60.     #define  FN_INSERT_MODE     19
  61.  
  62.     #define  FN_MARK_LINES      20
  63.     #define  FN_UNMARK_LINES    21
  64.     #define  FN_COPY_LINES      22
  65.     #define  FN_MOVE_LINES      23
  66.     #define  FN_DELETE_LINES    24
  67.  
  68.     #define  MODE_OVERTYPE      0      /*  Characters overwrite existing chars */
  69.     #define  MODE_INSERT        1      /*  Characters inserted in the line  */
  70.  
  71.     #define  CURSOR_LINE        0      /*  Defines the cursor as a line  */
  72.     #define  CURSOR_BLOCK       1      /*  Defines the cursor as a block  */
  73.  
  74.     #define  BELL     7                /*  ASCII code for BELL signal to console  */
  75.  
  76.     typedef struct
  77.     {
  78.         int    max_num_lines;           /*  Max Num lines for this buffer  */
  79.         int    min_num_lines;           /*  Min Num lines for this buffer  */
  80.         int    max_line_length;         /*  Max Length of each line in the buffer  */
  81.         int    screen_top;
  82.         int    screen_bottom;
  83.         int    screen_left;
  84.         int    screen_right;
  85.         int    editing_background;      /*  Editing Window Background Color  */
  86.         int    editing_foreground;      /*  Editing Window Foreground Color  */
  87.         int    highlight_background;    /*  Background Color for highlighted text  */
  88.         int    highlight_foreground;    /*  Foreground Color for highlighted text  */
  89.         int    overtype_cursor;         /*  CURSOR_LINE or CURSOR_BLOCK  */
  90.         int    insert_cursor;           /*  CURSOR_LINE or CURSOR_BLOCK  */
  91.         int    wrap_line;               /*  TRUE-words wrap to next line  */
  92.         int    remove_ending_spaces;    /*  TRUE-Spaces removed from ends of lines  */
  93.         int    remove_ending_chars;     /*  TRUE-Chars removed at end if others inserted in middle of line  */
  94.  
  95.         int    status_allowed;          /*  TRUE-Status will be displayed  */
  96.         int    status_x;                /*  X position of status on screen */
  97.         int    status_y;                /*  Y position of status on screen */
  98.         int    status_type;             /*  STATUS_ALL, STATUS_COL, STATUS_LINE, or STATUS_NONE  */
  99.  
  100.         int    message_allowed;         /*  TRUE-Message will be displayed in position  */
  101.         int    message_x;               /*  X position of message on screen  */
  102.         int    message_y;               /*  Y position of message on screen  */
  103.         int    message_max_len;         /*  Maximum length of message to be displayed  */
  104.  
  105.         int    error_on_borders;        /*  TRUE-Displays error msgs at top and bottom of files */
  106.         int    load_automatically;      /*  LOAD_NONE, LOAD_ARRAY, LOAD_FILE, LOAD_BOTH */
  107.         int    save_automatically;      /*  SAVE_NONE, SAVE_ARRAY, SAVE_FILE, SAVE_BOTH */
  108.         int    restore_window;          /*  TRUE-Edit window will be replaced with previous contents on exit  */
  109.  
  110.         int    vertical_scrolling;      /*  TRUE-Page Up & Down will be active  */
  111.         int    editing_allowed;         /*  TRUE-user will be allowed to modify buffer */
  112.         int    exit_after_display;      /*  TRUE-Function will exit right after window is displayed  */
  113.         char   default_filename [50];   /*  Default File to load if no file specified  */
  114.         char   char_types [256];        /*  Regular Character Types  */
  115.         char   esc_char_types [256];    /*  Escape Character Types   */
  116.     } ED_PARMS;
  117.  
  118.     typedef struct
  119.     {
  120.         int   num_lines;
  121.         int   cur_line;
  122.         int   line_offset;
  123.         int   num_bytes;
  124.         int   mode;
  125.         int   x;
  126.         int   y;
  127.         int   offset;
  128.         int   pos;
  129.         char  filename [100];        // The name of the file which was edited
  130.         int   rc;                    // Return Code of the last operation.  TRUE = Success, FALSE = Failure
  131.         char  last_char;
  132.         char  last_char_extended;
  133.         char  last_function;
  134.         char  term_reason [100];     // String indicating reason for last termination
  135.         char  last_message [81];     // Last Message that would have been displayed by 'print_message'
  136.     } ED_RESULTS;
  137.  
  138. #endif
  139.  
  140.  
  141.  
  142. #ifndef  KEY_SYMBOLS
  143.  
  144.     #define   KEY_SYMBOLS
  145.  
  146.     #define   FALSE  0
  147.     #define   TRUE   1
  148.  
  149.     #define   F1         59
  150.     #define   SHIFT_F1   84
  151.     #define   CTRL_F1    94
  152.     #define   ALT_F1     104
  153.  
  154.     #define   F2         60
  155.     #define   SHIFT_F2   85
  156.     #define   CTRL_F2    95
  157.     #define   ALT_F2     105
  158.  
  159.     #define   F3         61
  160.     #define   SHIFT_F3   86
  161.     #define   CTRL_F3    96
  162.     #define   ALT_F3     106
  163.  
  164.     #define   F4         62
  165.     #define   SHIFT_F4   87
  166.     #define   CTRL_F4    97
  167.     #define   ALT_F4     107
  168.  
  169.     #define   F5         63
  170.     #define   SHIFT_F5   88
  171.     #define   CTRL_F5    98
  172.     #define   ALT_F5     108
  173.  
  174.     #define   F6         64
  175.     #define   SHIFT_F6   89
  176.     #define   CTRL_F6    99
  177.     #define   ALT_F6     109
  178.  
  179.     #define   F7         65
  180.     #define   SHIFT_F7   90
  181.     #define   CTRL_F7    100
  182.     #define   ALT_F7     110
  183.  
  184.     #define   F8         66
  185.     #define   SHIFT_F8   91
  186.     #define   CTRL_F8    101
  187.     #define   ALT_F8     111
  188.  
  189.     #define   F9         67
  190.     #define   SHIFT_F9   92
  191.     #define   CTRL_F9    102
  192.     #define   ALT_F9     112
  193.  
  194.     #define   F10        68
  195.     #define   SHIFT_F10  93
  196.     #define   CTRL_F10   103
  197.     #define   ALT_F10    113
  198.  
  199.     #define   INSERT_KEY  82
  200.     #define   DELETE      83
  201.     #define   PAGE_UP     73
  202.     #define   PAGE_DOWN   81
  203.  
  204.     #define   LEFT        75
  205.     #define   RIGHT       77
  206.     #define   UP          72
  207.     #define   DOWN        80
  208.  
  209.     #define   HOME        71
  210.     #define   END_KEY     79
  211.     #define   ESC         27
  212.     #define   ENTER_KEY   13
  213.     #define   BACKSPACE   8
  214.     #define   TAB_KEY     9
  215.  
  216.     #define   SMALLEST    32
  217.     #define   LARGEST     126
  218.  
  219.     #define   ALT_KEY     0x08
  220.     #define   CTRL_KEY    0x04
  221.     #define   SHIFT_KEYS  0x03
  222.  
  223.     #define   ALT_A       30
  224.     #define   ALT_S       31
  225.     #define   ALT_D       32
  226.     #define   ALT_F       33
  227.  
  228.     #define   ALT_G       34
  229.     #define   ALT_H       35
  230.  
  231.     #define   ALT_J       36
  232.     #define   ALT_K       37
  233.     #define   ALT_L       38
  234.  
  235. #endif
  236.  
  237.  
  238.  
  239. #ifndef  ED_FUNCTIONS
  240.  
  241.     #define   ED_FUNCTIONS
  242.  
  243.       /*  ED-UTILS External Functions  */
  244.     extern int    ed_display_string (char * str, int screen_len, int max_len);
  245.     extern int    ed_display_string_xy (int x, int y, char * str, int screen_len, int max_len);
  246.     extern int    ed_edit_file_field (ED_PARMS * inparms, char * filename);
  247.     extern int    ed_edit_string (char * str, int screen_len, int max_len);
  248.     extern int    ed_edit_string_xy (int x, int y, char * str, int screen_len, int max_len);
  249.     extern int    ed_edit_text_field (ED_PARMS * inparms, void * store_lines, int max_lines, int max_chars);
  250.     extern int    ed_editor (ED_PARMS * inparms, char * filename, void * store_lines, int max_lines, int max_chars);
  251.     extern void   ed_set_default_parameters (ED_PARMS * inparms);
  252.  
  253.     extern ED_RESULTS ed_results;
  254.  
  255. #endif
  256.  
  257.