1 #ifndef MC__DIFFVIEW_INTERNAL_H
2 #define MC__DIFFVIEW_INTERNAL_H
3 
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"
9 
10 /*** typedefs(not structures) and defined constants **********************************************/
11 
12 typedef int (*DFUNC) (void *ctx, int ch, int line, off_t off, size_t sz, const char *str);
13 typedef int PAIR[2];
14 
15 #define error_dialog(h, s) query_dialog(h, s, D_ERROR, 1, _("&Dismiss"))
16 
17 /*** enums ***************************************************************************************/
18 
19 typedef enum
20 {
21     DATA_SRC_MEM = 0,
22     DATA_SRC_TMP = 1,
23     DATA_SRC_ORG = 2
24 } DSRC;
25 
26 typedef enum
27 {
28     DIFF_LEFT = 0,
29     DIFF_RIGHT = 1,
30     DIFF_COUNT = 2
31 } diff_place_t;
32 
33 typedef enum
34 {
35     DIFF_NONE = 0,
36     DIFF_ADD = 1,
37     DIFF_DEL = 2,
38     DIFF_CHG = 3
39 } DiffState;
40 
41 /*** structures declarations (and typedefs of structures)*****************************************/
42 
43 typedef struct
44 {
45     int fd;
46     int pos;
47     int len;
48     char *buf;
49     int flags;
50     void *data;
51 } FBUF;
52 
53 typedef struct
54 {
55     int a[2][2];
56     int cmd;
57 } DIFFCMD;
58 
59 
60 typedef struct
61 {
62     int off;
63     int len;
64 } BRACKET[DIFF_COUNT];
65 
66 typedef struct
67 {
68     int ch;
69     int line;
70     union
71     {
72         off_t off;
73         size_t len;
74     } u;
75     void *p;
76 } DIFFLN;
77 
78 typedef struct
79 {
80     FBUF *f;
81     GArray *a;
82     DSRC dsrc;
83 } PRINTER_CTX;
84 
85 typedef struct WDiff
86 {
87     Widget widget;
88 
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 */
99 
100     gboolean view_quit;         /* Quit flag */
101 
102     int height;
103     int half1;
104     int half2;
105     int width1;
106     int width2;
107     int bias;
108     gboolean new_frame;
109     int skip_rows;
110     int skip_cols;
111     int display_symbols;
112     int display_numbers;
113     gboolean show_cr;
114     int tab_size;
115     diff_place_t ord;
116     gboolean full;
117 
118 #ifdef HAVE_CHARSET
119     gboolean utf8;
120     /* converter for translation of text */
121     GIConv converter;
122 #endif                          /* HAVE_CHARSET */
123 
124     struct
125     {
126         int quality;
127         gboolean strip_trailing_cr;
128         gboolean ignore_tab_expansion;
129         gboolean ignore_space_change;
130         gboolean ignore_all_space;
131         gboolean ignore_case;
132     } opt;
133 
134     /* Search variables */
135     struct
136     {
137         mc_search_t *handle;
138         gchar *last_string;
139 
140         ssize_t last_found_line;
141         ssize_t last_accessed_num_line;
142     } search;
143 } WDiff;
144 
145 /*** global variables defined in .c file *********************************************************/
146 
147 /*** declarations of public functions ************************************************************/
148 
149 /* search.c */
150 void dview_search_cmd (WDiff * dview);
151 void dview_continue_search_cmd (WDiff * dview);
152 
153 #endif /* MC__DIFFVIEW_INTERNAL_H */
154