edit-widget.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. #ifndef __EDIT_WIDGET_H
  2. #define __EDIT_WIDGET_H
  3. struct macro {
  4. short command;
  5. short ch;
  6. };
  7. struct syntax_rule {
  8. unsigned short keyword;
  9. unsigned char end;
  10. unsigned char context;
  11. unsigned char _context;
  12. #define RULE_ON_LEFT_BORDER 1
  13. #define RULE_ON_RIGHT_BORDER 2
  14. unsigned char border;
  15. };
  16. /*there are a maximum of ... */
  17. #define MAXBUFF 1024
  18. #define MAX_MACRO_LENGTH 1024
  19. struct _syntax_marker {
  20. long offset;
  21. struct syntax_rule rule;
  22. struct _syntax_marker *next;
  23. };
  24. struct _book_mark {
  25. int line; /* line number */
  26. /* #define BOOK_MARK_COLOR ((0 << 8) | 26) */ /* black on white */
  27. #define BOOK_MARK_COLOR ((25 << 8) | 5)
  28. #define BOOK_MARK_FOUND_COLOR ((26 << 8) | 4)
  29. int c; /* colour */
  30. struct _book_mark *next;
  31. struct _book_mark *prev;
  32. };
  33. struct editor_widget {
  34. Widget widget;
  35. #define from_here num_widget_lines
  36. int num_widget_lines;
  37. int num_widget_columns;
  38. int have_frame;
  39. char *filename; /* Name of the file */
  40. char *dir; /* current directory */
  41. /* dynamic buffers and cursor position for editor: */
  42. long curs1; /*position of the cursor from the beginning of the file. */
  43. long curs2; /*position from the end of the file */
  44. unsigned char *buffers1[MAXBUFF + 1]; /*all data up to curs1 */
  45. unsigned char *buffers2[MAXBUFF + 1]; /*all data from end of file down to curs2 */
  46. /* search variables */
  47. long search_start; /* First character to start searching from */
  48. int found_len; /* Length of found string or 0 if none was found */
  49. long found_start; /* the found word from a search - start position */
  50. /* display information */
  51. long last_byte; /* Last byte of file */
  52. long start_display; /* First char displayed */
  53. long start_col; /* First displayed column, negative */
  54. long max_column; /* The maximum cursor position ever reached used to calc hori scroll bar */
  55. long curs_row; /*row position of cursor on the screen */
  56. long curs_col; /*column position on screen */
  57. int force; /* how much of the screen do we redraw? */
  58. unsigned char overwrite;
  59. unsigned char modified; /*has the file been changed?: 1 if char inserted or
  60. deleted at all since last load or save */
  61. unsigned char screen_modified; /* has the file been changed since the last screen draw? */
  62. int delete_file; /* has the file been created in edit_load_file? Delete
  63. it at end of editing when it hasn't been modified
  64. or saved */
  65. unsigned char highlight;
  66. long prev_col; /*recent column position of the cursor - used when moving
  67. up or down past lines that are shorter than the current line */
  68. long curs_line; /*line number of the cursor. */
  69. long start_line; /*line nummber of the top of the page */
  70. /* file info */
  71. long total_lines; /*total lines in the file */
  72. long mark1; /*position of highlight start */
  73. long mark2; /*position of highlight end */
  74. int column1; /*position of column highlight start */
  75. int column2; /*position of column highlight end */
  76. long bracket; /*position of a matching bracket */
  77. /* cache speedup for line lookups */
  78. #define N_LINE_CACHES 32
  79. int caches_valid;
  80. int line_numbers[N_LINE_CACHES];
  81. long line_offsets[N_LINE_CACHES];
  82. struct _book_mark *book_mark;
  83. /* undo stack and pointers */
  84. unsigned long stack_pointer;
  85. long *undo_stack;
  86. unsigned long stack_size;
  87. unsigned long stack_size_mask;
  88. unsigned long stack_bottom;
  89. struct stat stat1;
  90. /* syntax higlighting */
  91. struct _syntax_marker *syntax_marker;
  92. struct context_rule **rules;
  93. long last_get_rule;
  94. struct syntax_rule rule;
  95. char *syntax_type; /* description of syntax highlighting type being used */
  96. int explicit_syntax; /* have we forced the syntax hi. type in spite of the filename? */
  97. int to_here; /* dummy marker */
  98. /* macro stuff */
  99. int macro_i; /* -1 if not recording index to macro[] otherwise */
  100. struct macro macro[MAX_MACRO_LENGTH];
  101. };
  102. typedef struct editor_widget WEdit;
  103. #define EDIT_DIR PATH_SEP_STR ".mc" PATH_SEP_STR "cedit"
  104. #define SYNTAX_FILE EDIT_DIR PATH_SEP_STR "Syntax"
  105. #define CLIP_FILE EDIT_DIR PATH_SEP_STR "cooledit.clip"
  106. #define MACRO_FILE EDIT_DIR PATH_SEP_STR "cooledit.macros"
  107. #define BLOCK_FILE EDIT_DIR PATH_SEP_STR "cooledit.block"
  108. #define TEMP_FILE EDIT_DIR PATH_SEP_STR "cooledit.temp"
  109. #endif /* !__EDIT_WIDGET_H */