edit-widget.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. /** \file
  2. * \brief Header: editor widget WEdit
  3. */
  4. #ifndef MC_EDIT_WIDGET_H
  5. #define MC_EDIT_WIDGET_H
  6. #include "../src/dialog.h" /* Widget */
  7. #include "../src/search/search.h" /* mc_search_t */
  8. #include "edit-impl.h"
  9. #include "../src/keybind.h"
  10. #define MAX_MACRO_LENGTH 1024
  11. #define N_LINE_CACHES 32
  12. struct _book_mark {
  13. int line; /* line number */
  14. int c; /* color */
  15. struct _book_mark *next;
  16. struct _book_mark *prev;
  17. };
  18. struct syntax_rule {
  19. unsigned short keyword;
  20. unsigned char end;
  21. unsigned char context;
  22. unsigned char _context;
  23. unsigned char border;
  24. };
  25. struct WEdit {
  26. Widget widget;
  27. int num_widget_lines;
  28. int num_widget_columns;
  29. char *filename; /* Name of the file */
  30. char *dir; /* NULL if filename is absolute */
  31. /* dynamic buffers and cursor position for editor: */
  32. long curs1; /* position of the cursor from the beginning of the file. */
  33. long curs2; /* position from the end of the file */
  34. unsigned char *buffers1[MAXBUFF + 1]; /* all data up to curs1 */
  35. unsigned char *buffers2[MAXBUFF + 1]; /* all data from end of file down to curs2 */
  36. /* UTF8 */
  37. char charbuf[4 + 1];
  38. int charpoint;
  39. /* search variables */
  40. mc_search_t *search;
  41. unsigned int search_type;
  42. int replace_mode;
  43. int replace_backwards;
  44. int replace_case;
  45. int only_in_selection;
  46. int whole_words;
  47. int all_codepages;
  48. long search_start; /* First character to start searching from */
  49. int found_len; /* Length of found string or 0 if none was found */
  50. long found_start; /* the found word from a search - start position */
  51. /* display information */
  52. long last_byte; /* Last byte of file */
  53. long start_display; /* First char displayed */
  54. long start_col; /* First displayed column, negative */
  55. long max_column; /* The maximum cursor position ever reached used to calc hori scroll bar */
  56. long curs_row; /* row position of cursor on the screen */
  57. long curs_col; /* column position on screen */
  58. long over_col; /* pos after '\n' */
  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. unsigned int utf8:1; /* It's multibyte file codeset */
  68. long prev_col; /* recent column position of the cursor - used when moving
  69. up or down past lines that are shorter than the current line */
  70. long curs_line; /* line number of the cursor. */
  71. long start_line; /* line number of the top of the page */
  72. /* file info */
  73. long total_lines; /* total lines in the file */
  74. long mark1; /* position of highlight start */
  75. long mark2; /* position of highlight end */
  76. int column1; /* position of column highlight start */
  77. int column2; /* position of column highlight end */
  78. long bracket; /* position of a matching bracket */
  79. /* cache speedup for line lookups */
  80. int caches_valid;
  81. int line_numbers[N_LINE_CACHES];
  82. long line_offsets[N_LINE_CACHES];
  83. struct _book_mark *book_mark;
  84. /* undo stack and pointers */
  85. unsigned long stack_pointer;
  86. long *undo_stack;
  87. unsigned long stack_size;
  88. unsigned long stack_size_mask;
  89. unsigned long stack_bottom;
  90. unsigned int stack_disable:1; /* If not 0, don't save events in the undo stack */
  91. struct stat stat1; /* Result of mc_fstat() on the file */
  92. unsigned int skip_detach_prompt:1; /* Do not prompt whether to detach a file anymore */
  93. /* syntax higlighting */
  94. struct _syntax_marker *syntax_marker;
  95. struct context_rule **rules;
  96. long last_get_rule;
  97. struct syntax_rule rule;
  98. char *syntax_type; /* description of syntax highlighting type being used */
  99. GTree *defines; /* List of defines */
  100. /* macro stuff */
  101. int macro_i; /* index to macro[], -1 if not recording a macro */
  102. int macro_depth; /* depth of the macro recursion */
  103. struct macro macro[MAX_MACRO_LENGTH];
  104. /* user map stuff */
  105. GIConv converter;
  106. /* line break */
  107. LineBreaks lb;
  108. int extmod;
  109. char *labels[10];
  110. };
  111. #endif /* MC_EDIT_WIDGET_H */