(enter): use GString instead of hand-made memory (re)allocation.
[midnight-commander.git] / src / diffviewer / internal.h
blob778ce14c1e3385e3836eedf804436c822caba605
1 #ifndef MC__DIFFVIEW_INTERNAL_H
2 #define MC__DIFFVIEW_INTERNAL_H
4 #include "lib/global.h"
5 #include "lib/mcconfig.h"
6 #include "lib/search.h"
7 #include "lib/tty/color.h"
8 #include "lib/widget.h"
10 /*** typedefs(not structures) and defined constants **********************************************/
12 typedef int (*DFUNC) (void *ctx, int ch, int line, off_t off, size_t sz, const char *str);
13 typedef int PAIR[2];
15 #define error_dialog(h, s) query_dialog(h, s, D_ERROR, 1, _("&Dismiss"))
17 /*** enums ***************************************************************************************/
19 typedef enum
21 DATA_SRC_MEM = 0,
22 DATA_SRC_TMP = 1,
23 DATA_SRC_ORG = 2
24 } DSRC;
26 typedef enum
28 DIFF_LEFT = 0,
29 DIFF_RIGHT = 1,
30 DIFF_COUNT = 2
31 } diff_place_t;
33 typedef enum
35 DIFF_NONE = 0,
36 DIFF_ADD = 1,
37 DIFF_DEL = 2,
38 DIFF_CHG = 3
39 } DiffState;
41 /*** structures declarations (and typedefs of structures)*****************************************/
43 typedef struct
45 int fd;
46 int pos;
47 int len;
48 char *buf;
49 int flags;
50 void *data;
51 } FBUF;
53 typedef struct
55 int a[2][2];
56 int cmd;
57 } DIFFCMD;
60 typedef struct
62 int off;
63 int len;
64 } BRACKET[DIFF_COUNT];
66 typedef struct
68 int ch;
69 int line;
70 union
72 off_t off;
73 size_t len;
74 } u;
75 void *p;
76 } DIFFLN;
78 typedef struct
80 FBUF *f;
81 GArray *a;
82 DSRC dsrc;
83 } PRINTER_CTX;
85 typedef struct WDiff
87 Widget widget;
89 const char *args; /* Args passed to diff */
90 const char *file[DIFF_COUNT]; /* filenames */
91 char *label[DIFF_COUNT];
92 FBUF *f[DIFF_COUNT];
93 const char *backup_sufix;
94 gboolean merged[DIFF_COUNT];
95 GArray *a[DIFF_COUNT];
96 GPtrArray *hdiff;
97 int ndiff; /* number of hunks */
98 DSRC dsrc; /* data source: memory or temporary file */
100 int view_quit:1; /* Quit flag */
102 int height;
103 int half1;
104 int half2;
105 int width1;
106 int width2;
107 int bias;
108 int new_frame;
109 int skip_rows;
110 int skip_cols;
111 int display_symbols;
112 int display_numbers;
113 int show_cr;
114 int tab_size;
115 diff_place_t ord;
116 int full;
117 gboolean utf8;
118 /* converter for translation of text */
119 GIConv converter;
120 struct
122 int quality;
123 gboolean strip_trailing_cr;
124 gboolean ignore_tab_expansion;
125 gboolean ignore_space_change;
126 gboolean ignore_all_space;
127 gboolean ignore_case;
128 } opt;
130 /* Search variables */
131 struct
133 mc_search_t *handle;
134 gchar *last_string;
136 ssize_t last_found_line;
137 ssize_t last_accessed_num_line;
138 } search;
139 } WDiff;
141 /*** global variables defined in .c file *********************************************************/
143 /*** declarations of public functions ************************************************************/
145 /* search.c */
146 void dview_search_cmd (WDiff * dview);
147 void dview_continue_search_cmd (WDiff * dview);
149 #endif /* MC__DIFFVIEW_INTERNAL_H */