1 /* 2 * Copyright (c) 1990-2013 Paul Vojta and the xdvik development team 3 * 4 * Permission is hereby granted, free of charge, to any person obtaining a copy 5 * of this software and associated documentation files (the "Software"), to 6 * deal in the Software without restriction, including without limitation the 7 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 8 * sell copies of the Software, and to permit persons to whom the Software is 9 * furnished to do so, subject to the following conditions: 10 * 11 * The above copyright notice and this permission notice shall be included in 12 * all copies or substantial portions of the Software. 13 * 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 * PAUL VOJTA OR ANY OTHER AUTHOR OF THIS SOFTWARE BE LIABLE FOR ANY CLAIM, 18 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20 * OTHER DEALINGS IN THE SOFTWARE. 21 * 22 */ 23 24 #ifndef DVI_DRAW_H_ 25 #define DVI_DRAW_H_ 26 27 #include "xdvi-config.h" 28 #include "xdvi.h" 29 30 31 extern void prescan(FILE *fp); 32 33 34 /* forward declarations */ 35 struct font; 36 struct tn; 37 38 /* this information is saved when using virtual fonts */ 39 struct drawinf { 40 struct framedata data; 41 struct font *fontp; 42 set_char_proc set_char_p; 43 unsigned long tn_table_len; 44 struct font **tn_table; 45 struct tn *tn_head; 46 ubyte *pos, *end; /* pointers to a scan buffer defined in dvi-draw.c */ 47 struct font *virtual; 48 #ifdef TEXXET 49 int dir; 50 #endif 51 }; 52 53 struct src_parsed_special { 54 int line; 55 int col; 56 char *filename; 57 size_t filename_len; 58 }; 59 extern void src_parse(const char *str, int str_len, struct src_parsed_special *parsed); 60 61 /* 62 * pixel_conv is currently used only for converting absolute positions 63 * to pixel values; although normally it should be 64 * 65 * ((int) ((x) / currwin.shrinkfactor + (1 << 15) >> 16)), 66 * 67 * the rounding is achieved instead by moving the constant 1 << 15 to 68 * PAGE_OFFSET in dvi-draw.c. 69 */ 70 71 #define pixel_conv(x) ((int) ((x) / currwin.shrinkfactor >> 16)) 72 #define pixel_round(x) ((int) ROUNDUP(x, currwin.shrinkfactor << 16)) 73 74 /* entries below with the characters 'dvi' in them are actually stored in 75 scaled pixel units */ 76 77 #define DVI_H currinf.data.dvi_h 78 #define PXL_H pixel_conv(currinf.data.dvi_h) 79 #define DVI_V currinf.data.dvi_v 80 #define PXL_V currinf.data.pxl_v 81 #define WW currinf.data.w 82 #define XX currinf.data.x 83 #define YY currinf.data.y 84 #define ZZ currinf.data.z 85 #ifdef PTEX 86 #define TATE currinf.data.tdir 87 #else /* !PTEX */ 88 #define TATE False 89 #endif /* !PTEX */ 90 91 extern void draw_page(void); 92 extern void source_reverse_search(int, int, wide_bool); 93 extern void source_special_show(wide_bool); 94 extern void source_forward_search(const char *); 95 96 extern void anchor_search(const char *str); 97 98 99 /* 100 this is needed by any program that wants to use spcl_scan, 101 since the buffer is supposed to be of that length. 102 */ 103 #ifndef DVI_BUFFER_LEN 104 #define DVI_BUFFER_LEN 2048 105 #endif 106 107 extern void open_font_file(struct font *fontp); 108 extern long text_do_char(FILE *fp, struct scan_info *info, wide_ubyte ch); 109 extern Boolean spcl_scan(Boolean(*spcl_proc) (char *str, int str_len, void *data), void *data, Boolean return_if_found, FILE *fp); 110 111 extern void geom_scan_part(long(*char_proc)(FILE *, struct scan_info *, wide_ubyte), 112 FILE *fp, struct scan_info *info, struct frame *min_frame, double current_dimconv); 113 114 extern void geom_scan(long(*char_proc)(FILE *, struct scan_info *, wide_ubyte), 115 FILE *fp, struct scan_info *info, int pageno); 116 117 extern off_t save_file_status(FILE *fp, struct drawinf *currinf_save, ubyte *maxchar_save); 118 extern void reinit_text_scan(void); 119 extern void restore_file_status(FILE *fp, struct drawinf currinf_save, ubyte maxchar_save, off_t pos_save); 120 121 void htex_do_special(const char *str, size_t len); 122 123 extern setcharRetvalT set_char( 124 #ifdef TEXXET 125 wide_ubyte cmd, 126 #endif 127 wide_ubyte ch); 128 #ifdef PTEX 129 extern setcharRetvalT set_char2( 130 #ifdef TEXXET 131 wide_ubyte cmd, 132 #endif 133 wide_ubyte ch); 134 #endif /* PTEX */ 135 extern setcharRetvalT load_n_set_char( 136 #ifdef TEXXET 137 wide_ubyte cmd, 138 #endif 139 wide_ubyte ch); 140 extern setcharRetvalT set_vf_char( 141 #ifdef TEXXET 142 wide_ubyte cmd, 143 #endif 144 wide_ubyte ch); 145 146 extern setcharRetvalT set_ft_char( 147 #if TEXXET 148 wide_ubyte cmd, 149 #endif 150 wide_ubyte ch); 151 152 #ifdef GREY 153 void init_plane_masks(void); 154 #endif 155 156 #if COLOR 157 struct rgb; /* forward declaration */ 158 159 Pixel alloc_color(const struct rgb *, Pixel); 160 void do_color_change(void); 161 #elif GREY 162 void init_pix(void); 163 #endif 164 165 void dvi_fmt_error(const char *message, ...); 166 167 #endif /* DVI_DRAW_H_ */ 168