edit-widget.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. #ifndef MC_EDIT_WIDGET_H
  2. #define MC_EDIT_WIDGET_H
  3. #include "../src/dialog.h" /* Widget */
  4. #include "edit.h"
  5. #define MAX_MACRO_LENGTH 1024
  6. #define N_LINE_CACHES 32
  7. #define BOOK_MARK_COLOR ((25 << 8) | 5)
  8. #define BOOK_MARK_FOUND_COLOR ((26 << 8) | 4)
  9. struct _book_mark {
  10. int line; /* line number */
  11. int c; /* color */
  12. struct _book_mark *next;
  13. struct _book_mark *prev;
  14. };
  15. struct syntax_rule {
  16. unsigned short keyword;
  17. unsigned char end;
  18. unsigned char context;
  19. unsigned char _context;
  20. unsigned char border;
  21. };
  22. typedef struct edit_key_map_type {
  23. long key;
  24. long command;
  25. } edit_key_map_type;
  26. struct action {
  27. mc_wchar_t ch;
  28. long flags;
  29. };
  30. struct WEdit {
  31. Widget widget;
  32. int num_widget_lines;
  33. int num_widget_columns;
  34. char *filename; /* Name of the file */
  35. char *dir; /* NULL if filename is absolute */
  36. /* dynamic buffers and cursor position for editor: */
  37. long curs1; /* position of the cursor from the beginning of the file. */
  38. long curs2; /* position from the end of the file */
  39. #ifndef UTF8
  40. unsigned char *buffers1[MAXBUFF + 1]; /* all data up to curs1 */
  41. unsigned char *buffers2[MAXBUFF + 1]; /* all data from end of file down to curs2 */
  42. #else /* UTF8 */
  43. mc_wchar_t *buffers1[MAXBUFF + 1]; /* all data up to curs1 */
  44. mc_wchar_t *buffers2[MAXBUFF + 1]; /* all data from end of file down to curs2 */
  45. unsigned char charbuf[MB_LEN_MAX];
  46. int charpoint;
  47. #endif /* UTF8 */
  48. /* search variables */
  49. long search_start; /* First character to start searching from */
  50. int found_len; /* Length of found string or 0 if none was found */
  51. long found_start; /* the found word from a search - start position */
  52. /* display information */
  53. long last_byte; /* Last byte of file */
  54. long start_display; /* First char displayed */
  55. long start_col; /* First displayed column, negative */
  56. long max_column; /* The maximum cursor position ever reached used to calc hori scroll bar */
  57. long curs_row; /* row position of cursor on the screen */
  58. long curs_col; /* column position on screen */
  59. int force; /* how much of the screen do we redraw? */
  60. unsigned int overwrite:1; /* Overwrite on type mode (as opposed to insert) */
  61. unsigned int modified:1; /* File has been modified and needs saving */
  62. unsigned int loading_done:1;/* File has been loaded into the editor */
  63. unsigned int locked:1; /* We hold lock on current file */
  64. unsigned int screen_modified:1; /* File has been changed since the last screen draw */
  65. unsigned int delete_file:1; /* New file, needs to be deleted unless modified */
  66. unsigned int highlight:1; /* There is a selected block */
  67. long prev_col; /* recent column position of the cursor - used when moving
  68. up or down past lines that are shorter than the current line */
  69. long curs_line; /* line number of the cursor. */
  70. long start_line; /* line number of the top of the page */
  71. /* file info */
  72. long total_lines; /* total lines in the file */
  73. long mark1; /* position of highlight start */
  74. long mark2; /* position of highlight end */
  75. int column1; /* position of column highlight start */
  76. int column2; /* position of column highlight end */
  77. long bracket; /* position of a matching bracket */
  78. /* cache speedup for line lookups */
  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. struct action *undo_stack;
  86. unsigned long stack_size;
  87. unsigned long stack_size_mask;
  88. unsigned long stack_bottom;
  89. unsigned int stack_disable:1; /* If not 0, don't save events in the undo stack */
  90. struct stat stat1; /* Result of mc_fstat() on the file */
  91. unsigned int skip_detach_prompt:1; /* Do not prompt whether to detach a file anymore */
  92. /* syntax higlighting */
  93. struct _syntax_marker *syntax_marker;
  94. struct context_rule **rules;
  95. long last_get_rule;
  96. struct syntax_rule rule;
  97. char *syntax_type; /* description of syntax highlighting type being used */
  98. GTree *defines; /* List of defines */
  99. /* macro stuff */
  100. int macro_i; /* index to macro[], -1 if not recording a macro */
  101. int macro_depth; /* depth of the macro recursion */
  102. struct macro macro[MAX_MACRO_LENGTH];
  103. /* user map stuff */
  104. const edit_key_map_type *user_map;
  105. const edit_key_map_type *ext_map;
  106. int extmod;
  107. char *labels[10];
  108. };
  109. #endif