- Rearrange reactos.dff according to rosapps rearrange.
[reactos.git] / rosapps / mc / src / view.h
1 #ifndef __VIEW_H
2 #define __VIEW_H
3
4 #ifdef WANT_WIDGETS
5 /* The growing buffers data types */
6 typedef struct {
7 char *data;
8 int present; /* Unused, for DOS port maybe */
9 } block_ptr_t;
10
11 enum ViewSide {
12 view_side_left,
13 view_side_right
14 };
15
16 typedef struct {
17 Widget widget;
18
19 char *filename; /* Name of the file */
20 char *command; /* Command used to pipe data in */
21 char *localcopy;
22 int view_active;
23 int have_frame;
24
25 char *data; /* Memory area for the file to be viewed */
26
27 /* File information */
28 int file; /* File descriptor (for mmap and munmap) */
29 FILE *stdfile; /* Stdio struct for reading file in parts */
30 int reading_pipe; /* Flag: Reading from pipe(use popen/pclose) */
31 long bytes_read; /* How much of file is read */
32 int mmapping; /* Did we use mmap on the file? */
33
34 /* Display information */
35 long last; /* Last byte shown */
36 long last_byte; /* Last byte of file */
37 long first; /* First byte in file */
38 long bottom_first; /* First byte shown when very last page is displayed */
39 /* For the case of WINCH we should reset it to -1 */
40 long start_display; /* First char displayed */
41 int start_col; /* First displayed column, negative */
42 int edit_cursor; /* HexEdit cursor position in file */
43 char hexedit_mode; /* Hexidecimal editing mode flag */
44 char nib_shift; /* A flag for inserting nibbles into bytes */
45 enum ViewSide view_side; /* A flag for the active editing panel */
46 int file_dirty; /* Number of changes */
47 int start_save; /* Line start shift between Ascii and Hex */
48 int cursor_col; /* Cursor column */
49 int cursor_row; /* Cursor row */
50 struct hexedit_change_node *change_list; /* Linked list of changes */
51
52 int dirty; /* Number of skipped updates */
53 int wrap_mode; /* wrap_mode */
54
55 /* Mode variables */
56 int hex_mode; /* Hexadecimal mode flag */
57 int bytes_per_line; /* Number of bytes per line in hex mode */
58 int viewer_magic_flag; /* Selected viewer */
59 int viewer_nroff_flag; /* Do we do nroff style highlighting? */
60
61 /* Growing buffers information */
62 int growing_buffer; /* Use the growing buffers? */
63 block_ptr_t *block_ptr; /* Pointer to the block pointers */
64 int blocks; /* The number of blocks in *block_ptr */
65
66
67 /* Search variables */
68 int search_start; /* First character to start searching from */
69 int found_len; /* Length of found string or 0 if none was found */
70 char *search_exp; /* The search expression */
71 int direction; /* 1= forward; -1 backward */
72 void (*last_search)(void *, char *);
73 /* Pointer to the last search command */
74 int view_quit; /* Quit flag */
75
76 int monitor; /* Monitor file growth (like tail -f) */
77 /* Markers */
78 int marker; /* mark to use */
79 int marks [10]; /* 10 marks: 0..9 */
80
81 #ifdef HAVE_TK
82 /* Tk version, line cache */
83 int current_line; /* The current screen line cached */
84 char *cache; /* Current cache */
85 char *color_cache; /* Attributes: keep in sync with cache */
86 int dest; /* Index in the cache to write to */
87 int cache_len; /* Length of the cache buffer -1 */
88 int last_col; /* last column used */
89 int status_shown; /* Have we show the file information? */
90 #endif
91
92 #ifdef HAVE_GNOME
93 int current_x, current_y; /* Current x,y position */
94 int color; /* Current color */
95 void *gtk_fname; /* filename widget */
96 void *gtk_offset; /* offset widget */
97 void *gtk_bytes; /* bytes */
98 void *gtk_flags; /* flags (growing) */
99 void *gtk_percent; /* percent */
100 void *sadj; /* scrollbar adjustment */
101 #endif
102
103 int move_dir; /* return value from widget:
104 * 0 do nothing
105 * -1 view previous file
106 * 1 view next file
107 */
108 struct stat s; /* stat for file */
109 } WView;
110
111 #define vwidth (view->widget.cols - (view->have_frame ? 2 : 0))
112 #define vheight (view->widget.lines - (view->have_frame ? 2 : 0))
113
114 /* Creation/initialization of a new view widget */
115 WView *view_new (int y, int x, int cols, int lines, int is_panel);
116 int view_init (WView *view, char *_command, char *_file, int start_line);
117 int view_file (char *filename, int normal, int internal);
118
119 /* Internal view routines */
120 void view_status (WView *);
121 void view_percent (WView *, int, int);
122 void view_update (WView *view);
123 void view_labels (WView *view);
124 int view_event (WView *view, Gpm_Event *event,int *result);
125 void toggle_wrap_mode (WView *);
126 void toggle_hex_mode (WView *);
127 void goto_line (WView *);
128 void regexp_search_cmd (WView *);
129 void normal_search_cmd (WView *);
130 void continue_search (WView *);
131 void change_nroff (WView *view);
132 void set_monitor (WView *view, int set_on);
133 void view_move_forward (WView *view, int i);
134 void view_move_backward (WView *view, int i);
135 #endif
136
137 /* Command: view a file, if _command != NULL we use popen on _command */
138 /* move direction should be apointer that will hold the direction in which the user */
139 /* wants to move (-1 previous file, 1 next file, 0 do nothing) */
140 int view (char *_command, char *_file, int *move_direction, int start_line);
141
142 extern int mouse_move_pages_viewer;
143 extern int max_dirt_limit;
144 extern int global_wrap_mode;
145 extern int have_fast_cpu;
146 extern int default_hex_mode;
147 extern int default_magic_flag;
148 extern int default_nroff_flag;
149 extern int altered_hex_mode;
150 extern int altered_magic_flag;
151 extern int altered_nroff_flag;
152
153 void view_adjust_size ();
154
155 /* A node for building a change list on change_list */
156 struct hexedit_change_node {
157 struct hexedit_change_node *next;
158 long offset;
159 unsigned char value;
160 };
161
162 #ifdef HAVE_TK
163 #define DEF_COLOR 0
164 #define BOLD_COLOR 1
165 #define UNDERLINE_COLOR 2
166 #define MARK_COLOR 3
167 #endif
168
169 #ifdef HAVE_X
170 #ifdef WANT_WIDGETS
171 void view_add_character (WView *view, int c);
172 void view_add_string (WView *view, char *s);
173 void view_gotoyx (WView *view, int r, int c);
174 void view_set_color (WView *view, int font);
175 void view_display_clean (WView *view, int h, int w);
176
177 void x_destroy_view (WView *);
178 void x_create_viewer (WView *);
179 void x_focus_view (WView *);
180 void x_init_view (WView *);
181
182 #ifdef PORT_HAS_VIEW_FREEZE
183 void view_freeze (WView *view);
184 void view_thaw (WView *view);
185 #endif
186
187 #endif
188 #else
189 # define x_init_view(x)
190 # define x_destroy_view(x)
191 # define x_create_viewer(x)
192 # define x_focus_view(x)
193 #endif
194
195 #endif /* __VIEW_H */