home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / utils / file / managers / mc-3.2 / mc-3 / mc-3.2.1 / src / view.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-05-17  |  4.2 KB  |  122 lines

  1. #ifndef __VIEW_H
  2. #define __VIEW_H
  3.  
  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;
  10.  
  11. typedef struct {
  12.     Widget widget;
  13.  
  14.     char *filename;        /* Name of the file */
  15.     char *command;        /* Command used to pipe data in */
  16.     int view_active;
  17.     int have_frame;
  18.     
  19.     unsigned char *data;    /* Memory area for the file to be viewed */
  20.  
  21.     /* File information */
  22.     int file;            /* File descriptor (for mmap and munmap) */
  23.     FILE *stdfile;        /* Stdio struct for reading file in parts */
  24.     int reading_pipe;        /* Flag: Reading from pipe(use popen/pclose) */
  25.     long bytes_read;        /* How much of file is read */
  26.     int mmaping;        /* Did we use mmap on the file? */
  27.  
  28.     /* Display information */
  29.     long last;            /* Last byte shown */
  30.     long last_byte;        /* Last byte of file */
  31.     long first;            /* First byte in file */
  32.     long bottom_first;    /* First byte shown when very last page is displayed */
  33.                 /* For the case of WINCH we should reset it to -1 */
  34.     long start_display;        /* First char displayed */
  35.     int  start_col;        /* First displayed column, negative */
  36.  
  37.     int dirty;            /* Number of skipped updates */
  38.  
  39.     /* Mode variables */
  40.     int hex_mode;        /* Hexadecimal mode flag */
  41.     int bytes_per_line;        /* Number of bytes per line in hex mode */
  42.     int viewer_magic_flag;    /* Selected viewer */
  43.     int viewer_nroff_flag;    /* Do we do nroff style highlighting? */
  44.     
  45.     /* Growing buffers information */
  46.     int growing_buffer;        /* Use the growing buffers? */
  47.     block_ptr_t *block_ptr;    /* Pointer to the block pointers */
  48.     int          blocks;    /* The number of blocks in *block_ptr */
  49.  
  50.     
  51.     /* Search variables */
  52.     int search_start;        /* First character to start searching from */
  53.     int found_len;        /* Length of found string or 0 if none was found */
  54.     char *search_exp;        /* The search expression */
  55.     int  direction;        /* 1= forward; -1 backward */
  56.     void (*last_search)(void *, char *);
  57.                                 /* Pointer to the last search command */
  58.     int view_quit;        /* Quit flag */
  59.  
  60.     int monitor;        /* Monitor file growth (like tail -f) */
  61.     /* Markers */
  62.     int marker;            /* mark to use */
  63.     int marks [10];        /* 10 marks: 0..9 */
  64.     
  65. #ifdef HAVE_TK
  66.     /* Tk version, line cache */
  67.     int  current_line;        /* The current screen line cached */
  68.     char *cache;        /* Current cache */
  69.     char *color_cache;        /* Attributes: keep in sync with cache */
  70.     int  dest;            /* Index in the cache to write to */
  71.     int  cache_len;        /* Length of the cache buffer -1 */
  72.     int  last_col;        /* last column used */
  73.     int  status_shown;        /* Have we show the file information? */
  74. #endif
  75.  
  76.     int  move_dir;        /* return value from widget:  
  77.                  * 0 do nothing
  78.                  * -1 view previous file
  79.                  * 1 view next file
  80.                  */
  81.     struct stat s;        /* stat for file */
  82. } WView;
  83.  
  84. #define vwidth (view->widget.cols - (view->have_frame ? 2 : 0))
  85. #define vheight (view->widget.lines - (view->have_frame ? 2 : 0))
  86.  
  87. /* Creation/initialization of a new view widget */
  88. WView *view_new (int y, int x, int cols, int lines, int is_panel);
  89. int view_init (WView *view, char *_command, char *_file);
  90. int view_file (char *filename, int normal, int internal);
  91.  
  92. /* Internal view routines */
  93. void view_update (WView *view);
  94. void view_labels (WView *view);
  95. int view_event (WView *view, Gpm_Event *event,int *result);
  96. void toggle_wrap_mode (WView *);
  97. void toggle_hex_mode (WView *);
  98. void goto_line (WView *);
  99. void regexp_search_cmd (WView *);
  100. void normal_search_cmd (WView *);
  101.  
  102. #endif
  103.  
  104. /* Command: view a file, if _command != NULL we use popen on _command */
  105. /* move direction should be apointer that will hold the direction in which the user */
  106. /* wants to move (-1 previous file, 1 next file, 0 do nothing) */
  107. int view (char *_command, char *_file, int *move_direction);
  108.  
  109. extern int mouse_move_pages_viewer;
  110. extern int max_dirt_limit;
  111. extern int wrap_mode;
  112. extern int have_fast_cpu;
  113. extern int default_hex_mode;
  114. extern int default_magic_flag;
  115. extern int default_nroff_flag;
  116. extern int altered_hex_mode;
  117. extern int altered_magic_flag;
  118. extern int altered_nroff_flag;
  119.  
  120. void view_adjust_size ();
  121. #endif    /* __VIEW_H */
  122.