5 /* The growing buffers data types */
8 int present
; /* Unused, for DOS port maybe */
19 char *filename
; /* Name of the file */
20 char *command
; /* Command used to pipe data in */
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 long bytes_read
; /* How much of file is read */
32 int mmapping
; /* Did we use mmap on the file? */
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 */
52 int dirty
; /* Number of skipped updates */
53 int wrap_mode
; /* wrap_mode */
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) */
78 int marker
; /* mark to use */
79 int marks
[10]; /* 10 marks: 0..9 */
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? */
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 */
103 int move_dir
; /* return value from widget:
105 * -1 view previous file
108 struct stat s
; /* stat for file */
111 #define vwidth (view->widget.cols - (view->have_frame ? 2 : 0))
112 #define vheight (view->widget.lines - (view->have_frame ? 2 : 0))
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
);
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 void view_add_one_vline (void);
138 /* Command: view a file, if _command != NULL we use popen on _command */
139 /* move direction should be apointer that will hold the direction in which the user */
140 /* wants to move (-1 previous file, 1 next file, 0 do nothing) */
141 int view (char *_command
, char *_file
, int *move_direction
, int start_line
);
143 extern int mouse_move_pages_viewer
;
144 extern int max_dirt_limit
;
145 extern int global_wrap_mode
;
146 extern int have_fast_cpu
;
147 extern int default_hex_mode
;
148 extern int default_magic_flag
;
149 extern int default_nroff_flag
;
150 extern int altered_hex_mode
;
151 extern int altered_magic_flag
;
152 extern int altered_nroff_flag
;
154 void view_adjust_size (Dlg_head
*);
156 /* A node for building a change list on change_list */
157 struct hexedit_change_node
{
158 struct hexedit_change_node
*next
;
166 #define UNDERLINE_COLOR 2
172 void view_add_character (WView
*view
, int c
);
173 void view_add_string (WView
*view
, char *s
);
174 void view_gotoyx (WView
*view
, int r
, int c
);
175 void view_set_color (WView
*view
, int font
);
176 void view_display_clean (WView
*view
, int h
, int w
);
178 void x_destroy_view (WView
*);
179 void x_create_viewer (WView
*);
180 void x_focus_view (WView
*);
181 void x_init_view (WView
*);
183 #ifdef PORT_HAS_VIEW_FREEZE
184 void view_freeze (WView
*view
);
185 void view_thaw (WView
*view
);
190 # define x_init_view(x)
191 # define x_destroy_view(x)
192 # define x_create_viewer(x)
193 # define x_focus_view(x)
196 #endif /* __VIEW_H */