Rev 7975 | 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 edit_key(); |
||
12 | bool edit_mouse(); |
||
13 | int find_all(); |
||
7960 | leency | 14 | int find_next(); |
7941 | leency | 15 | int find_prior(); |
8584 | leency | 16 | } search; |
7941 | leency | 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; |
||
8584 | leency | 42 | edit_box_key stdcall(#search_box); |
7941 | leency | 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 | |||
7960 | leency | 58 | { |
7941 | leency | 59 | dword haystack = textbuf.p; |
8584 | leency | 60 | int needle_len = strlen(#found_text); |
7960 | leency | 61 | found.drop(); |
62 | loop() { |
||
63 | if (! haystack = strstri(haystack, #found_text)) break; |
||
64 | found.add(haystack - needle_len); |
||
65 | haystack += needle_len; |
||
66 | } |
||
67 | } |
||
7941 | leency | 68 | |
69 | |||
8584 | leency | 70 | { |
7941 | leency | 71 | int i; |
72 | if (!search_text[0]) return false; |
||
73 | |||
74 | |||
7960 | leency | 75 | strcpy(#found_text, #search_text); |
76 | find_all(); |
||
77 | draw_window(); |
||
7975 | leency | 78 | } |
7960 | leency | 79 | |
7941 | leency | 80 | |
7975 | leency | 81 | if (signed found.get(i) - lines.get(_first) > 0) { |
8584 | leency | 82 | while(signed found.get(i) - lines.get(_first) > 0) _first++; |
83 | return _first-1; |
||
84 | } |
||
7975 | leency | 85 | } |
86 | return false; |
||
7941 | leency | 87 | } |
88 | |||
89 | |||
8584 | leency | 90 | { |
91 | int i; |
||
92 | if (!search_text[0]) return false; |
||
93 | |||
94 | |||
95 | strcpy(#found_text, #search_text); |
||
96 | find_all(); |
||
97 | draw_window(); |
||
98 | } |
||
99 | |||
100 | |||
101 | if (signed found.get(i) - lines.get(_first) > 0) { |
||
102 | while(signed lines.get(_first) - found.get(i-1) > 0) _first--; |
||
103 | return _first; |
||
104 | } |
||
105 | } |
||
106 | return false; |
||
107 | } |
||
108 |