* global.h: Move fcntl.h inclusion here. Define O_BINARY.
[midnight-commander.git] / src / view.h
blobf076f47ec3334aa786472e21f09efab9b9974875
1 #ifndef __VIEW_H
2 #define __VIEW_H
4 #ifdef WANT_WIDGETS
5 /* The growing buffers data types */
6 typedef struct {
7 unsigned char *data;
8 int present; /* Unused, for DOS port maybe */
9 } block_ptr_t;
11 enum ViewSide {
12 view_side_left,
13 view_side_right
16 typedef struct {
17 Widget widget;
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;
25 unsigned char *data; /* Memory area for the file to be viewed */
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 unsigned long bytes_read; /* How much of file is read */
32 int mmapping; /* Did we use mmap on the file? */
34 /* Display information */
35 unsigned long last; /* Last byte shown */
36 unsigned 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 unsigned long start_display;/* First char displayed */
41 int start_col; /* First displayed column, negative */
42 unsigned long 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 */
52 int dirty; /* Number of skipped updates */
53 int wrap_mode; /* wrap_mode */
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? */
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 */
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 */
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 */
82 int move_dir; /* return value from widget:
83 * 0 do nothing
84 * -1 view previous file
85 * 1 view next file
87 struct stat s; /* stat for file */
88 } WView;
90 #define vwidth (view->widget.cols - (view->have_frame ? 2 : 0))
91 #define vheight (view->widget.lines - (view->have_frame ? 2 : 0))
93 /* Creation/initialization of a new view widget */
94 WView *view_new (int y, int x, int cols, int lines, int is_panel);
95 int view_init (WView *view, char *_command, const char *_file, int start_line);
96 void view_update_bytes_per_line(WView *view);
97 int view_file (char *filename, int normal, int internal);
99 #endif /* WANT_WIDGETS */
101 /* Command: view a file, if _command != NULL we use popen on _command */
102 /* move direction should be apointer that will hold the direction in which the user */
103 /* wants to move (-1 previous file, 1 next file, 0 do nothing) */
104 int view (char *_command, const char *_file, int *move_direction, int start_line);
106 extern int mouse_move_pages_viewer;
107 extern int max_dirt_limit;
108 extern int global_wrap_mode;
109 extern int have_fast_cpu;
110 extern int default_hex_mode;
111 extern int default_magic_flag;
112 extern int default_nroff_flag;
113 extern int altered_hex_mode;
114 extern int altered_magic_flag;
115 extern int altered_nroff_flag;
116 extern Dlg_head *view_dlg;
118 void view_adjust_size (Dlg_head *);
120 /* A node for building a change list on change_list */
121 struct hexedit_change_node {
122 struct hexedit_change_node *next;
123 long offset;
124 unsigned char value;
127 #endif /* __VIEW_H */