Rev 7960 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
7941 | leency | 1 | |
2 | |||
3 | |||
4 | |||
5 | { |
||
6 | bool visible; |
||
7 | int found_count; |
||
8 | collection_int found; |
||
7960 | leency | 9 | void show(); |
7941 | leency | 10 | void hide(); |
11 | bool draw(); |
||
12 | bool edit_key(); |
||
13 | bool edit_mouse(); |
||
14 | int find_all(); |
||
7960 | leency | 15 | int find_next(); |
7941 | leency | 16 | } search; |
17 | |||
18 | |||
19 | |||
20 | |||
21 | edit_box search_box = {250, 10, NULL, 0xffffff, |
||
22 | 0x94AECE, 0xffffff, 0xffffff,0x10000000,sizeof(search_text)-1,#search_text}; |
||
23 | |||
24 | |||
25 | |||
26 | { |
||
27 | visible = true; |
||
28 | search_box.flags = ed_focus; |
||
29 | draw_window(); |
||
30 | } |
||
31 | |||
32 | |||
33 | { |
||
34 | visible = false; |
||
35 | draw_window(); |
||
36 | } |
||
37 | |||
38 | |||
39 | { |
||
40 | if (visible) && (search_box.flags & ed_focus) { |
||
41 | EAX = key_editbox; |
||
42 | edit_box_key stdcall(#search_box); |
||
43 | return true; |
||
44 | } |
||
45 | return false; |
||
46 | } |
||
47 | |||
48 | |||
49 | { |
||
50 | if (visible) { |
||
51 | edit_box_mouse stdcall(#search_box); |
||
52 | if (search_box.flags & ed_focus) return true; |
||
53 | } |
||
54 | return false; |
||
55 | } |
||
56 | |||
57 | |||
7945 | leency | 58 | { |
7941 | leency | 59 | char matches[30]; |
60 | if (!visible) return false; |
||
61 | DrawBar(0, _y, Form.cwidth, 1, sc.work_graph); |
||
62 | DrawBar(0, _y+1, Form.cwidth, SEARCH_H-1, sc.work); |
||
63 | |||
64 | |||
65 | search_box.width = math.min(Form.width - 200, 150); |
||
7975 | leency | 66 | |
7941 | leency | 67 | |
68 | |||
69 | |||
70 | |||
71 | |||
7975 | leency | 72 | TOOLBAR_ICON_HEIGHT+1, _btn_find, sc.work_light, sc.work_text, T_FIND_NEXT); |
7941 | leency | 73 | |
74 | |||
7960 | leency | 75 | WriteTextWithBg(search_box.left+search_box.width+14+115, |
7975 | leency | 76 | search_box.top+3, 0xD0, sc.work_text, #matches, sc.work); |
7945 | leency | 77 | |
7941 | leency | 78 | |
79 | TOOLBAR_ICON_HEIGHT+1, _btn_hide); |
||
80 | WriteText(Form.cwidth-26+7, search_box.top+2, 0x81, sc.work_graph, "x"); |
||
81 | return true; |
||
82 | } |
||
83 | |||
84 | |||
7960 | leency | 85 | { |
7941 | leency | 86 | dword haystack = io.buffer_data; |
7960 | leency | 87 | int needle_len = strlen(#found_text); |
88 | found.drop(); |
||
89 | loop() { |
||
90 | if (! haystack = strstri(haystack, #found_text)) break; |
||
91 | found.add(haystack - needle_len); |
||
92 | haystack += needle_len; |
||
93 | } |
||
94 | } |
||
7941 | leency | 95 | |
96 | |||
97 | { |
||
98 | int i; |
||
99 | dword t1, t2; |
||
7975 | leency | 100 | if (!search_text[0]) return false; |
7941 | leency | 101 | |
102 | |||
7960 | leency | 103 | strcpy(#found_text, #search_text); |
104 | find_all(); |
||
105 | draw_window(); |
||
7975 | leency | 106 | } |
7960 | leency | 107 | |
7941 | leency | 108 | |
7975 | leency | 109 | if (signed found.get(i) - lines.get(_cur_pos) > 0) { |
110 | t1 = found.get(i); |
||
111 | while(t1 > lines.get(_cur_pos)) _cur_pos++; |
||
112 | return _cur_pos-1; |
||
113 | } |
||
114 | } |
||
115 | return false; |
||
7941 | leency | 116 | } |
117 |