Subversion Repositories Kolibri OS

Rev

Rev 7975 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 7975 Rev 8584
Line 7... Line 7...
7
	int found_count;
7
	int found_count;
8
	collection_int found;
8
	collection_int found;
9
	void show();
9
	void show();
10
	void hide();
10
	void hide();
11
	bool draw();
11
	bool edit_key();
12
	bool edit_key();
-
 
13
	bool edit_mouse();
12
	bool edit_mouse();
14
	int find_all();
13
	int find_all();
15
	int find_next();
14
	int find_next();
16
} search;
15
	int find_prior();
-
 
16
} search;
17
 
17
 
Line 18... Line 18...
18
char found_text[64];
18
char found_text[64];
Line 19... Line 19...
19
 
19
 
Line 53... Line 53...
53
	}
53
	}
54
	return false;
54
	return false;
55
}
55
}
56
 
56
 
Line 57... Line -...
57
bool SEARCH::draw(dword _btn_find, _btn_hide, _y)
-
 
58
{
-
 
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
	search_box.top = _y + 6;
-
 
65
	search_box.width = math.min(Form.width - 200, 150);
-
 
66
 
-
 
67
	DrawRectangle(search_box.left-1, search_box.top-1, search_box.width+2, 23,sc.work_graph);
-
 
68
 
-
 
69
	edit_box_draw stdcall(#search_box);
-
 
70
 
-
 
71
	DrawCaptButton(search_box.left+search_box.width+14, search_box.top-1, 100, 
-
 
72
		TOOLBAR_ICON_HEIGHT+1, _btn_find, sc.work_light, sc.work_text, T_FIND_NEXT);
-
 
73
 
-
 
74
	sprintf(#matches, T_MATCHES, found.count);
-
 
75
	WriteTextWithBg(search_box.left+search_box.width+14+115, 
-
 
76
		search_box.top+3, 0xD0, sc.work_text, #matches, sc.work);
-
 
77
 
-
 
78
	DefineHiddenButton(Form.cwidth-26, search_box.top-1, TOOLBAR_ICON_HEIGHT+1, 
-
 
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
int SEARCH::find_all()
57
int SEARCH::find_all()
85
{
58
{
86
	dword haystack = io.buffer_data;
59
	dword haystack = textbuf.p;
87
	int needle_len = strlen(#found_text);
60
	int needle_len = strlen(#found_text);
88
	found.drop();
61
	found.drop();
89
	loop() {
62
	loop() {
90
		if (! haystack = strstri(haystack, #found_text)) break;
63
		if (! haystack = strstri(haystack, #found_text)) break;
91
		found.add(haystack - needle_len);
64
		found.add(haystack - needle_len);
92
		haystack += needle_len;
65
		haystack += needle_len;
93
	}
66
	}
94
}
67
}
Line 95... Line 68...
95
 
68
 
96
int SEARCH::find_next(int _cur_pos)
69
int SEARCH::find_next(int _first)
97
{
70
{
98
	int i;
-
 
99
	dword t1, t2;
71
	int i;
Line 100... Line 72...
100
	if (!search_text[0]) return false;
72
	if (!search_text[0]) return false;
101
 
73
 
102
	if (!streq(#found_text, #search_text)) {
74
	if (!streq(#found_text, #search_text)) {
103
		strcpy(#found_text, #search_text);
75
		strcpy(#found_text, #search_text);
104
		find_all();
76
		find_all();
Line 105... Line 77...
105
		draw_window();
77
		draw_window();
106
	}
78
	}
107
 
-
 
108
	for (i=0; i
79
 
109
		if (signed found.get(i) - lines.get(_cur_pos) > 0) {
80
	for (i=0; i
110
			t1 = found.get(i);
81
		if (signed found.get(i) - lines.get(_first) > 0) {
111
			while(t1 > lines.get(_cur_pos)) _cur_pos++;	
82
			while(signed found.get(i) - lines.get(_first) > 0) _first++;
112
			return _cur_pos-1;
83
			return _first-1;
113
		}
84
		}
Line -... Line 85...
-
 
85
	}
-
 
86
	return false;
-
 
87
}
-
 
88
 
-
 
89
int SEARCH::find_prior(int _first)
-
 
90
{
-
 
91
	int i;
-
 
92
	if (!search_text[0]) return false;
-
 
93
 
-
 
94
	if (!streq(#found_text, #search_text)) {
-
 
95
		strcpy(#found_text, #search_text);
-
 
96
		find_all();
-
 
97
		draw_window();
-
 
98
	}
-
 
99
 
-
 
100
	for (i=0; i
-
 
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;