| 1 |
/* |
| 2 |
* Copyright (c) 2003-2004 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 |
#ifndef DVI_SEARCH_H_ |
| 24 |
#define DVI_SEARCH_H_ |
| 25 |
|
| 26 |
#include "xdvi.h" |
| 27 |
|
| 28 |
#include "search-dialog.h" |
| 29 |
#include "dvisel.h" |
| 30 |
|
| 31 |
/* Widget names that are used in callbacks */ |
| 32 |
#define Xdvi_SEARCHBOX_INPUT_NAME "searchbox_input" |
| 33 |
#define Xdvi_SEARCH_POPUP_NAME "find_popup" |
| 34 |
|
| 35 |
/* A sorted dynamic array that maps text buffer (i.e. word) |
| 36 |
* positions to DVI file offsets. |
| 37 |
*/ |
| 38 |
|
| 39 |
struct pos_info { |
| 40 |
size_t buffer_pos; /* position in text buffer */ |
| 41 |
struct bbox bbox; /* bounding box of this word */ |
| 42 |
}; |
| 43 |
|
| 44 |
struct page_mapping { |
| 45 |
int pageno; |
| 46 |
int offset; |
| 47 |
}; |
| 48 |
|
| 49 |
struct word_info { |
| 50 |
char *txt_buf; /* contains scanned text as whitespace separated strings */ |
| 51 |
size_t txt_buf_size; /* size of above buffer */ |
| 52 |
size_t curr_buf_idx; /* current position in buffer */ |
| 53 |
struct bbox *bboxes; /* dynamic array of position infos */ |
| 54 |
size_t bboxes_size; /* size of above array */ |
| 55 |
size_t bboxes_idx; /* current position in buffer */ |
| 56 |
const struct page_mapping *page_mapping; /* list of page offsets, for bbox_pass */ |
| 57 |
struct search_settings *settings; /* pointer to search settings, for bbox_pass */ |
| 58 |
int buffer_offset; /* offset to start of buffer from text on previous pages */ |
| 59 |
Boolean bbox_pass; /* whether we're scanning for bounding boxes of match */ |
| 60 |
Boolean search_scan_pass; /* whether we're scanning for text in string search */ |
| 61 |
Boolean text_selection_pass; /* whether we're scanning for text selection */ |
| 62 |
}; |
| 63 |
|
| 64 |
struct save_or_print_info; /* forward declaration */ |
| 65 |
|
| 66 |
extern void isearch_start(void); |
| 67 |
extern void search_dvi(XtPointer settings); |
| 68 |
extern void search_restart(XtPointer settings); |
| 69 |
extern Boolean search_extract_text(struct save_or_print_info *info); |
| 70 |
extern Boolean search_have_match(int pageno); |
| 71 |
extern int search_inside_bbox_match(int x, int y); |
| 72 |
extern void search_draw_inverted_regions(void); |
| 73 |
extern void search_signal_page_changed(void); |
| 74 |
extern void search_reset_info(void); |
| 75 |
extern void search_erase_highlighting(Boolean flag); |
| 76 |
extern void search_putback_expose(void); |
| 77 |
extern char *get_text_selection(int *len, int x, int y, int w, int h); |
| 78 |
|
| 79 |
#if 0 |
| 80 |
#define TEST_DELAY(s) \ |
| 81 |
do { \ |
| 82 |
TRACE_FIND((stderr, s)); \ |
| 83 |
int i, j; \ |
| 84 |
XSync(DISP, False); \ |
| 85 |
for (i = 0; i < 10000; i++) \ |
| 86 |
for (j = 0; j < 20000; j++); \ |
| 87 |
} while (0) |
| 88 |
#else |
| 89 |
#define TEST_DELAY(s) /* as nothing */ |
| 90 |
#endif |
| 91 |
|
| 92 |
#endif /* DVI_SEARCH_H_ */ |
| 93 |
|