Back to index

tetex-bin  3.0
search-internal.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2003-2004 the xdvik development team
00003  * 
00004  * Permission is hereby granted, free of charge, to any person obtaining a copy
00005  * of this software and associated documentation files (the "Software"), to
00006  * deal in the Software without restriction, including without limitation the
00007  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
00008  * sell copies of the Software, and to permit persons to whom the Software is
00009  * furnished to do so, subject to the following conditions:
00010  * 
00011  * The above copyright notice and this permission notice shall be included in
00012  * all copies or substantial portions of the Software.
00013  * 
00014  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00015  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00016  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
00017  * PAUL VOJTA OR ANY OTHER AUTHOR OF THIS SOFTWARE BE LIABLE FOR ANY CLAIM,
00018  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
00019  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
00020  * OTHER DEALINGS IN THE SOFTWARE.
00021  */
00022 
00023 #ifndef DVI_SEARCH_H_
00024 #define DVI_SEARCH_H_
00025 
00026 #include "xdvi-config.h"
00027 #include "xdvi.h"
00028 
00029 #include "search-dialog.h"
00030 #include "dvisel.h"
00031 
00032 /* Widget names that are used in callbacks */
00033 #define Xdvi_SEARCHBOX_INPUT_NAME "searchbox_input"
00034 #define Xdvi_SEARCH_POPUP_NAME "find_popup"
00035 
00036 /* A sorted dynamic array that maps text buffer (i.e. word)
00037  * positions to DVI file offsets.
00038  */
00039 
00040 struct pos_info {
00041     size_t buffer_pos;      /* position in text buffer */
00042     struct bbox bbox;       /* bounding box of this word */
00043 };
00044 
00045 struct page_mapping {
00046     int pageno;
00047     int offset;
00048 };
00049 
00050 struct word_info {
00051     char *txt_buf;    /* contains scanned text as whitespace separated strings */
00052     size_t txt_buf_size; /* size of above buffer */
00053     size_t curr_buf_idx;     /* current position in buffer */
00054     struct bbox *bboxes;    /* dynamic array of position infos */
00055     size_t bboxes_size;     /* size of above array */
00056     size_t bboxes_idx;       /* current position in buffer */
00057     const struct page_mapping *page_mapping;            /* list of page offsets, for bbox_pass */
00058     struct search_settings *settings;     /* pointer to search settings, for bbox_pass */
00059     int buffer_offset;      /* offset to start of buffer from text on previous pages */
00060     Boolean bbox_pass;             /* whether we're scanning for bounding boxes of match */
00061     Boolean search_scan_pass;      /* whether we're scanning for text in string search */
00062     Boolean text_selection_pass; /* whether we're scanning for text selection */
00063 };
00064 
00065 extern void search_dvi(XtPointer settings);
00066 extern void search_restart(XtPointer settings);
00067 extern Boolean search_extract_text(outputFormatT fmt, struct select_pages_info *pinfo);
00068 extern Boolean search_have_match(int pageno);
00069 extern int search_inside_bbox_match(int x, int y);
00070 extern void search_draw_inverted_regions(void);
00071 extern void search_signal_page_changed(void);
00072 extern void search_reset_info(void);
00073 extern void search_erase_highlighting(Boolean flag);
00074 extern void search_putback_expose(void);
00075 extern char *get_text_selection(int *len, int x, int y, int w, int h);
00076 
00077 #if 0
00078 #define TEST_DELAY(s)                            \
00079     do {                                  \
00080        TRACE_FIND((stderr, s));           \
00081        int i, j;                          \
00082        XSync(DISP, False);                \
00083        for (i = 0; i < 10000; i++)        \
00084            for (j = 0; j < 20000; j++);   \
00085     } while (0)
00086 #else
00087 #define TEST_DELAY(s) /* as nothing */
00088 #endif
00089 
00090 #endif /* DVI_SEARCH_H_ */
00091