Subversion Repositories Kolibri OS

Rev

Rev 9602 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 9602 Rev 9635
1
/*
1
/*
2
	Quark Code Edit
2
	Quark Code Edit
3
	Author: Kiril Lipatov aka Leency
3
	Author: Kiril Lipatov aka Leency
4
	Licence: GPLv2
4
	Licence: GPLv2
5
 
5
 
6
	The core components of this app are:
6
	The core components of this app are:
7
		1. textbuf: page data
7
		1. textbuf: page data
8
		2. list: text grid with keyboard and mouse events
8
		2. list: text grid with keyboard and mouse events
9
		3. lines: the mas of pointers for each line start
9
		3. lines: the mas of pointers for each line start
10
		4. selection
10
		4. selection
11
*/
11
*/
12
 
12
 
13
#define MEMSIZE 50*1024
13
#define MEMSIZE 50*1024
14
 
14
 
15
//===================================================//
15
//===================================================//
16
//                                                   //
16
//                                                   //
17
//                       LIB                         //
17
//                       LIB                         //
18
//                                                   //
18
//                                                   //
19
//===================================================//
19
//===================================================//
20
 
20
 
21
#include "../lib/io.h"
21
#include "../lib/io.h"
22
#include "../lib/gui.h"
22
#include "../lib/gui.h"
23
#include "../lib/list_box.h"
23
#include "../lib/list_box.h"
24
#include "../lib/draw_buf.h"
24
#include "../lib/draw_buf.h"
25
#include "../lib/events.h"
25
#include "../lib/events.h"
26
#include "../lib/array.h"
-
 
27
#include "../lib/clipboard.h"
26
#include "../lib/clipboard.h"
28
#include "../lib/math.h"
27
#include "../lib/math.h"
29
 
28
 
30
#include "../lib/obj/box_lib.h"
29
#include "../lib/obj/box_lib.h"
31
#include "../lib/obj/libini.h"
30
#include "../lib/obj/libini.h"
32
#include "../lib/obj/iconv.h"
31
#include "../lib/obj/iconv.h"
33
#include "../lib/obj/proc_lib.h"
32
#include "../lib/obj/proc_lib.h"
34
 
33
 
35
#include "../lib/patterns/simple_open_dialog.h"
34
#include "../lib/patterns/simple_open_dialog.h"
36
#include "../lib/patterns/toolbar_button.h"
35
#include "../lib/patterns/toolbar_button.h"
37
 
36
 
38
//===================================================//
37
//===================================================//
39
//                                                   //
38
//                                                   //
40
//                 INTERNAL INCLUDES                 //
39
//                 INTERNAL INCLUDES                 //
41
//                                                   //
40
//                                                   //
42
//===================================================//
41
//===================================================//
43
 
42
 
44
proc_info Form;
43
proc_info Form;
45
llist list;
44
llist list;
46
scroll_bar scroll = { 15,200,398,44,0,2,115,15,0,0xeeeeee,
45
scroll_bar scroll = { 15,200,398,44,0,2,115,15,0,0xeeeeee,
47
	0xBBBbbb,0xeeeeee,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1};
46
	0xBBBbbb,0xeeeeee,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1};
48
 
47
 
49
#define TOOLBAR_H 38
48
#define TOOLBAR_H 38
50
#define TOOLBAR_ICON_WIDTH  24
49
#define TOOLBAR_ICON_WIDTH  24
51
#define TOOLBAR_ICON_HEIGHT 22
50
#define TOOLBAR_ICON_HEIGHT 22
52
#define STATUSBAR_H 15
51
#define STATUSBAR_H 15
53
#define TAB_H 20
52
#define TAB_H 20
54
 
53
 
55
int user_encoding;
54
int user_encoding;
56
int real_encoding = CH_CP866;
55
int real_encoding = CH_CP866;
57
int curcol_scheme;
56
int curcol_scheme;
58
int font_size;
57
int font_size;
59
 
58
 
60
bool search_next = false;
59
bool search_next = false;
61
 
60
 
62
#include "data.h"
61
#include "data.h"
63
#include "textbuf.h"
62
#include "textbuf.h"
64
#include "selection.h"
63
#include "selection.h"
65
#include "search.h"
64
#include "search.h"
66
#include "prepare_page.h"
65
#include "prepare_page.h"
67
 
66
 
68
//===================================================//
67
//===================================================//
69
//                                                   //
68
//                                                   //
70
//                       DATA                        //
69
//                       DATA                        //
71
//                                                   //
70
//                                                   //
72
//===================================================//
71
//===================================================//
73
 
72
 
74
char title[4196];
73
char title[4196];
75
 
74
 
76
int reopenin_mx,
75
int reopenin_mx,
77
    theme_mx,
76
    theme_mx,
78
    burger_mx,
77
    burger_mx,
79
    search_mx;
78
    search_mx;
80
 
79
 
81
enum {
80
enum {
82
	CHANGE_CHARSET=12,
81
	CHANGE_CHARSET=12,
83
	REOPEN_IN_APP=1,
82
	REOPEN_IN_APP=1,
84
	COLOR_SCHEME=8,
83
	COLOR_SCHEME=8,
85
	RMB_MENU,
84
	RMB_MENU,
86
	BTN_FIND_NEXT,
85
	BTN_FIND_NEXT,
87
	BTN_FIND_PREVIOUS,
86
	BTN_FIND_PREVIOUS,
88
	BTN_FIND_CLOSE,
87
	BTN_FIND_CLOSE,
89
	BTN_CHANGE_CHARSET
88
	BTN_CHANGE_CHARSET
90
};
89
};
91
 
90
 
92
dword menu_id;
91
dword menu_id;
93
 
92
 
94
EVENTS button;
93
EVENTS button;
95
EVENTS key;
94
EVENTS key;
96
 
95
 
97
//===================================================//
96
//===================================================//
98
//                                                   //
97
//                                                   //
99
//                       CODE                        //
98
//                       CODE                        //
100
//                                                   //
99
//                                                   //
101
//===================================================//
100
//===================================================//
102
 
101
 
103
void InitDlls()
102
void InitDlls()
104
{
103
{
105
	load_dll(boxlib,    #box_lib_init,   0);
104
	load_dll(boxlib,    #box_lib_init,   0);
106
	load_dll(libini,    #lib_init,       1);
105
	load_dll(libini,    #lib_init,       1);
107
	load_dll(iconv_lib, #iconv_open,     0);
106
	load_dll(iconv_lib, #iconv_open,     0);
108
	load_dll(Proc_lib,  #OpenDialog_init,0);
107
	load_dll(Proc_lib,  #OpenDialog_init,0);
109
	OpenDialog_init stdcall (#o_dialog);
108
	OpenDialog_init stdcall (#o_dialog);
110
}
109
}
111
 
110
 
112
void LoadFileFromDocPack()
111
void LoadFileFromDocPack()
113
{
112
{
114
	dword bufsize = atoi(#file_path + 1) + 20;
113
	dword bufsize = atoi(#file_path + 1) + 20;
115
	dword bufpointer = malloc(bufsize);
114
	dword bufpointer = malloc(bufsize);
116
 
115
 
117
	ESDWORD[bufpointer+0] = 0;
116
	ESDWORD[bufpointer+0] = 0;
118
	ESDWORD[bufpointer+4] = 8;
117
	ESDWORD[bufpointer+4] = 8;
119
	IpcSetArea(bufpointer, bufsize);
118
	IpcSetArea(bufpointer, bufsize);
120
 
119
 
121
	SetEventMask(EVM_IPC);
120
	SetEventMask(EVM_IPC);
122
	if (@WaitEventTimeout(200) != evIPC) {
121
	if (@WaitEventTimeout(200) != evIPC) {
123
		notify("'IPC FAIL'E");
122
		notify("'IPC FAIL'E");
124
	} else {
123
	} else {
125
		textbuf.set(bufpointer + 16, ESDWORD[bufpointer+12]);
124
		textbuf.set(bufpointer + 16, ESDWORD[bufpointer+12]);
126
	}
125
	}
127
	free(bufpointer);
126
	free(bufpointer);
128
	file_path[0]='\0';
127
	file_path[0]='\0';
129
	sprintf(#title, "#DOCPACK - %s", #short_app_name);
128
	sprintf(#title, "#DOCPACK - %s", #short_app_name);
130
}
129
}
131
 
130
 
132
void main()
131
void main()
133
{
132
{
134
	InitDlls();
133
	InitDlls();
135
	LoadIniSettings();
134
	LoadIniSettings();
136
	EventSetColorScheme(curcol_scheme);
135
	EventSetColorScheme(curcol_scheme);
137
	if (file_path[0] == '*') {
136
	if (file_path[0] == '*') {
138
		LoadFileFromDocPack();
137
		LoadFileFromDocPack();
139
	} else {
138
	} else {
140
		if (streq(#file_path,"-new")) {Form.left+=40;Form.top+=40;}
139
		if (streq(#file_path,"-new")) {Form.left+=40;Form.top+=40;}
141
		LoadFile(#file_path);
140
		LoadFile(#file_path);
142
	}
141
	}
143
	SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER);
142
	SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER);
144
	loop() switch(@WaitEventTimeout(400))
143
	loop() switch(@WaitEventTimeout(400))
145
	{
144
	{
146
		case evMouse:  HandleMouseEvent(); break;
145
		case evMouse:  HandleMouseEvent(); break;
147
		case evKey:    HandleKeyEvent(); break;
146
		case evKey:    HandleKeyEvent(); break;
148
		case evButton: HandleButtonEvent(); break;
147
		case evButton: HandleButtonEvent(); break;
149
		case evReDraw: draw_window(); break;
148
		case evReDraw: draw_window(); break;
150
		default:       DrawStatusBar(" "); //clean DrawStatusBar text with delay
149
		default:       DrawStatusBar(" "); //clean DrawStatusBar text with delay
151
	}
150
	}
152
}
151
}
153
 
152
 
154
//===================================================//
153
//===================================================//
155
//                                                   //
154
//                                                   //
156
//                  EVENT HANDLERS                   //
155
//                  EVENT HANDLERS                   //
157
//                                                   //
156
//                                                   //
158
//===================================================//
157
//===================================================//
159
 
158
 
160
void HandleButtonEvent()
159
void HandleButtonEvent()
161
{
160
{
162
	int btn = GetButtonID();
161
	int btn = GetButtonID();
163
	if (btn==1) {
162
	if (btn==1) {
164
		SaveIniSettings();
163
		SaveIniSettings();
165
		ExitProcess();
164
		ExitProcess();
166
	}
165
	}
167
	button.press(btn);
166
	button.press(btn);
168
	switch(btn-10)
167
	switch(btn-10)
169
	{
168
	{
170
		case BTN_FIND_NEXT:      EventSearchNext();       break;
169
		case BTN_FIND_NEXT:      EventSearchNext();       break;
171
		case BTN_FIND_PREVIOUS:  EventSearchPrevious();   break;
170
		case BTN_FIND_PREVIOUS:  EventSearchPrevious();   break;
172
		case BTN_FIND_CLOSE:     search.hide();           break;
171
		case BTN_FIND_CLOSE:     search.hide();           break;
173
		case BTN_CHANGE_CHARSET: EventShowCharsetsList(); break;
172
		case BTN_CHANGE_CHARSET: EventShowCharsetsList(); break;
174
	}
173
	}
175
}
174
}
176
 
175
 
177
void HandleKeyEvent()
176
void HandleKeyEvent()
178
{
177
{
179
	GetKeys();
178
	GetKeys();
180
 
179
 
181
	switch (key_scancode)
180
	switch (key_scancode)
182
	{
181
	{
183
		case SCAN_CODE_ESC:
182
		case SCAN_CODE_ESC:
184
			search.hide();
183
			search.hide();
185
			return;
184
			return;
186
		case SCAN_CODE_ENTER:
185
		case SCAN_CODE_ENTER:
187
			if (! search_box.flags & ed_focus) break;
186
			if (! search_box.flags & ed_focus) break;
188
		case SCAN_CODE_F3:
187
		case SCAN_CODE_F3:
189
			if (key_modifier & KEY_LSHIFT) {
188
			if (key_modifier & KEY_LSHIFT) {
190
				EventSearchPrevious();
189
				EventSearchPrevious();
191
			} else {
190
			} else {
192
				EventSearchNext();
191
				EventSearchNext();
193
			}
192
			}
194
			return;
193
			return;
195
	}
194
	}
196
 
195
 
197
	if (search.edit_key()) return;
196
	if (search.edit_key()) return;
198
 
197
 
199
	if (key_modifier & KEY_LCTRL) || (key_modifier & KEY_RCTRL) {
198
	if (key_modifier & KEY_LCTRL) || (key_modifier & KEY_RCTRL) {
200
		if (key.press(ECTRL + key_scancode)) return;
199
		if (key.press(ECTRL + key_scancode)) return;
201
		switch (key_scancode)
200
		switch (key_scancode)
202
		{
201
		{
203
			case SCAN_CODE_KEY_A: EventSelectAllText();    return;
202
			case SCAN_CODE_KEY_A: EventSelectAllText();    return;
204
			case SCAN_CODE_KEY_C: EventCopy();             return;
203
			case SCAN_CODE_KEY_C: EventCopy();             return;
205
			//case SCAN_CODE_KEY_X: EventCut();              return;
204
			//case SCAN_CODE_KEY_X: EventCut();              return;
206
			//case SCAN_CODE_KEY_V: EventPaste();            return;
205
			//case SCAN_CODE_KEY_V: EventPaste();            return;
207
			case SCAN_CODE_UP:    EventMagnifyPlus();      return;
206
			case SCAN_CODE_UP:    EventMagnifyPlus();      return;
208
			case SCAN_CODE_DOWN:  EventMagnifyMinus();     return;
207
			case SCAN_CODE_DOWN:  EventMagnifyMinus();     return;
209
			case SCAN_CODE_TAB:   EventShowCharsetsList(); return;
208
			case SCAN_CODE_TAB:   EventShowCharsetsList(); return;
210
			case SCAN_CODE_KEY_F: search.show();           return;
209
			case SCAN_CODE_KEY_F: search.show();           return;
211
		}
210
		}
212
	}
211
	}
213
 
212
 
214
	if (key_modifier & KEY_LSHIFT) || (key_modifier & KEY_RSHIFT) {
213
	if (key_modifier & KEY_LSHIFT) || (key_modifier & KEY_RSHIFT) {
215
		selection.set_start();
214
		selection.set_start();
216
	} else {
215
	} else {
217
		//EventInsertCharIntoText();
216
		//EventInsertCharIntoText();
218
		selection.cancel();
217
		selection.cancel();
219
	}
218
	}
220
 
219
 
221
	if (key_scancode == SCAN_CODE_LEFT) && (!list.cur_x) && (list.cur_y) list.column_max = lines.len(list.cur_y-1);
220
	if (key_scancode == SCAN_CODE_LEFT) && (!list.cur_x) && (list.cur_y) list.column_max = lines.len(list.cur_y-1);
222
	if (list.ProcessKey(key_scancode)) {
221
	if (list.ProcessKey(key_scancode)) {
223
		if (key_modifier & KEY_LSHIFT) || (key_modifier & KEY_RSHIFT) selection.set_end();
222
		if (key_modifier & KEY_LSHIFT) || (key_modifier & KEY_RSHIFT) selection.set_end();
224
		DrawPage();
223
		DrawPage();
225
		return;
224
		return;
226
	}
225
	}
227
}
226
}
228
 
227
 
229
void HandleMouseEvent()
228
void HandleMouseEvent()
230
{
229
{
231
	mouse.get();
230
	mouse.get();
232
	list.wheel_size = 7;
231
	list.wheel_size = 7;
233
	if (list.MouseScroll(mouse.vert)) {
232
	if (list.MouseScroll(mouse.vert)) {
234
		DrawPage();
233
		DrawPage();
235
		return;
234
		return;
236
	}
235
	}
237
	if (!scroll.delta2) && (list.MouseOver(mouse.x, mouse.y)) {
236
	if (!scroll.delta2) && (list.MouseOver(mouse.x, mouse.y)) {
238
		if (mouse.key&MOUSE_LEFT) {
237
		if (mouse.key&MOUSE_LEFT) {
239
 
238
 
240
			GetKeyModifier();
239
			GetKeyModifier();
241
			if (key_modifier & KEY_LSHIFT) || (key_modifier & KEY_RSHIFT) {
240
			if (key_modifier & KEY_LSHIFT) || (key_modifier & KEY_RSHIFT) {
242
				if (mouse.down) selection.set_start();
241
				if (mouse.down) selection.set_start();
243
				list.ProcessMouse(mouse.x, mouse.y);
242
				list.ProcessMouse(mouse.x, mouse.y);
244
				if (mouse.up) selection.set_end();
243
				if (mouse.up) selection.set_end();
245
				DrawPage();
244
				DrawPage();
246
				return;
245
				return;
247
			}
246
			}
248
 
247
 
249
			//as we have lines of variable width, we need to recalculate column_max
248
			//as we have lines of variable width, we need to recalculate column_max
250
			list.column_max = lines.len(mouse.y - list.y / list.item_h + list.first);
249
			list.column_max = lines.len(mouse.y - list.y / list.item_h + list.first);
251
 
250
 
252
			list.ProcessMouse(mouse.x, mouse.y);
251
			list.ProcessMouse(mouse.x, mouse.y);
253
 
252
 
254
			if (mouse.down) {
253
			if (mouse.down) {
255
				selection.cancel();
254
				selection.cancel();
256
				selection.set_start();
255
				selection.set_start();
257
			}
256
			}
258
			selection.set_end();
257
			selection.set_end();
259
			DrawPage();
258
			DrawPage();
260
		}
259
		}
261
		if (mouse.key&MOUSE_RIGHT) && (mouse.up) {
260
		if (mouse.key&MOUSE_RIGHT) && (mouse.up) {
262
			EventShowRmbMenu();
261
			EventShowRmbMenu();
263
		}
262
		}
264
		return;
263
		return;
265
	}
264
	}
266
	scrollbar_v_mouse (#scroll);
265
	scrollbar_v_mouse (#scroll);
267
	if (list.first != scroll.position) {
266
	if (list.first != scroll.position) {
268
		list.first = scroll.position;
267
		list.first = scroll.position;
269
		DrawPage();
268
		DrawPage();
270
	}
269
	}
271
	search.edit_mouse();
270
	search.edit_mouse();
272
}
271
}
273
 
272
 
274
//===================================================//
273
//===================================================//
275
//                                                   //
274
//                                                   //
276
//                      EVENTS                       //
275
//                      EVENTS                       //
277
//                                                   //
276
//                                                   //
278
//===================================================//
277
//===================================================//
279
 
278
 
280
bool EventSearchNext()
279
bool EventSearchNext()
281
{
280
{
282
	if (search.find_next(list.first+1)) {
281
	if (search.find_next(list.first+1)) {
283
		list.first = EAX;
282
		list.first = EAX;
284
		list.CheckDoesValuesOkey();
283
		list.CheckDoesValuesOkey();
285
		search_next = true;
284
		search_next = true;
286
		DrawPage();
285
		DrawPage();
287
	}
286
	}
288
}
287
}
289
 
288
 
290
bool EventSearchPrevious()
289
bool EventSearchPrevious()
291
{
290
{
292
	if (search.find_prior(list.first)) {
291
	if (search.find_prior(list.first)) {
293
		list.first = EAX;
292
		list.first = EAX;
294
		list.CheckDoesValuesOkey();
293
		list.CheckDoesValuesOkey();
295
		search_next = true;
294
		search_next = true;
296
		DrawPage();
295
		DrawPage();
297
	}
296
	}
298
}
297
}
299
 
298
 
300
void EventOpenDialog()
299
void EventOpenDialog()
301
{
300
{
302
	OpenDialog_start stdcall (#o_dialog);
301
	OpenDialog_start stdcall (#o_dialog);
303
	if (o_dialog.status) {
302
	if (o_dialog.status) {
304
		LoadFile(#openfile_path);
303
		LoadFile(#openfile_path);
305
		ParseAndPaint();
304
		ParseAndPaint();
306
	}
305
	}
307
}
306
}
308
 
307
 
309
void EventShowFileInfo()
308
void EventShowFileInfo()
310
{
309
{
311
	char ss_param[4096];
310
	char ss_param[4096];
312
	if (!file_path) return;
311
	if (!file_path) return;
313
	strcpy(#ss_param, "-p ");
312
	strcpy(#ss_param, "-p ");
314
	strcpy(#ss_param+3, #file_path);
313
	strcpy(#ss_param+3, #file_path);
315
	RunProgram("/sys/File managers/Eolite", #ss_param);
314
	RunProgram("/sys/File managers/Eolite", #ss_param);
316
}
315
}
317
 
316
 
318
void EventMagnifyMinus()
317
void EventMagnifyMinus()
319
{
318
{
320
	font_size = math.max(0, font_size-1);
319
	font_size = math.max(0, font_size-1);
321
	SetFontSize(font_size);
320
	SetFontSize(font_size);
322
	ParseAndPaint();
321
	ParseAndPaint();
323
}
322
}
324
 
323
 
325
void EventMagnifyPlus()
324
void EventMagnifyPlus()
326
{
325
{
327
	font_size = math.min(5, font_size+1);
326
	font_size = math.min(5, font_size+1);
328
	SetFontSize(font_size);
327
	SetFontSize(font_size);
329
	ParseAndPaint();
328
	ParseAndPaint();
330
}
329
}
331
 
330
 
332
void EventShowCharsetsList()
331
void EventShowCharsetsList()
333
{
332
{
334
	menu_id = CHANGE_CHARSET;
333
	menu_id = CHANGE_CHARSET;
335
	open_lmenu(Form.cwidth-4, Form.cheight - 6, MENU_BOT_RIGHT,
334
	open_lmenu(Form.cwidth-4, Form.cheight - 6, MENU_BOT_RIGHT,
336
		user_encoding+1,
335
		user_encoding+1,
337
		"UTF-8\nKOI8-RU\nCP1251\nCP1252\nISO8859-5\nCP866\nAUTO");
336
		"UTF-8\nKOI8-RU\nCP1251\nCP1252\nISO8859-5\nCP866\nAUTO");
338
}
337
}
339
 
338
 
340
void EventShowReopenMenu()
339
void EventShowReopenMenu()
341
{
340
{
342
	menu_id = REOPEN_IN_APP;
341
	menu_id = REOPEN_IN_APP;
343
	open_lmenu(reopenin_mx, 29, MENU_TOP_LEFT, NULL,
342
	open_lmenu(reopenin_mx, 29, MENU_TOP_LEFT, NULL,
344
		"Tinypad\nCodeEdit\nWebView\nFB2Read\nHexView\nOther");
343
		"Tinypad\nCodeEdit\nWebView\nFB2Read\nHexView\nOther");
345
}
344
}
346
 
345
 
347
void EventShowThemesList()
346
void EventShowThemesList()
348
{
347
{
349
	menu_id = COLOR_SCHEME;
348
	menu_id = COLOR_SCHEME;
350
	open_lmenu(theme_mx, 29, MENU_TOP_LEFT,
349
	open_lmenu(theme_mx, 29, MENU_TOP_LEFT,
351
		curcol_scheme+1, #color_scheme_names);
350
		curcol_scheme+1, #color_scheme_names);
352
}
351
}
353
 
352
 
354
void EventShowRmbMenu()
353
void EventShowRmbMenu()
355
{
354
{
356
	menu_id = RMB_MENU;
355
	menu_id = RMB_MENU;
357
	open_lmenu(mouse.x, mouse.y, MENU_TOP_LEFT, NULL, #rmb_menu);
356
	open_lmenu(mouse.x, mouse.y, MENU_TOP_LEFT, NULL, #rmb_menu);
358
}
357
}
359
 
358
 
360
 
359
 
361
void EventSetColorScheme(dword _setn)
360
void EventSetColorScheme(dword _setn)
362
{
361
{
363
	curcol_scheme = _setn;
362
	curcol_scheme = _setn;
364
	theme.bg      = color_schemes[curcol_scheme*6];
363
	theme.bg      = color_schemes[curcol_scheme*6];
365
	theme.text    = color_schemes[curcol_scheme*6+1];
364
	theme.text    = color_schemes[curcol_scheme*6+1];
366
	scroll.bckg_col = theme.bg;
365
	scroll.bckg_col = theme.bg;
367
	scroll.frnt_col = scroll.line_col = color_schemes[curcol_scheme*6+2];
366
	scroll.frnt_col = scroll.line_col = color_schemes[curcol_scheme*6+2];
368
	selection.color = color_schemes[curcol_scheme*6+3];
367
	selection.color = color_schemes[curcol_scheme*6+3];
369
	theme.cursor    = color_schemes[curcol_scheme*6+4];
368
	theme.cursor    = color_schemes[curcol_scheme*6+4];
370
	theme.found     = color_schemes[curcol_scheme*6+5];
369
	theme.found     = color_schemes[curcol_scheme*6+5];
371
	if (list.count) ParseAndPaint();
370
	if (list.count) ParseAndPaint();
372
}
371
}
373
 
372
 
374
void EventChangeCharset(dword id)
373
void EventChangeCharset(dword id)
375
{
374
{
376
	if (file_path[0]=='\0') return;
375
	if (file_path[0]=='\0') return;
377
	user_encoding = id;
376
	user_encoding = id;
378
	LoadFile(#file_path);
377
	LoadFile(#file_path);
379
	ParseAndPaint();
378
	ParseAndPaint();
380
	draw_window();
379
	draw_window();
381
}
380
}
382
 
381
 
383
void EventOpenFileInOtherApp(dword _id)
382
void EventOpenFileInOtherApp(dword _id)
384
{
383
{
385
	dword app;
384
	dword app;
386
	byte open_param[4096];
385
	byte open_param[4096];
387
	switch(_id) {
386
	switch(_id) {
388
		case 0: app = "/sys/tinypad"; break;
387
		case 0: app = "/sys/tinypad"; break;
389
		case 1: app = "/sys/develop/cedit"; break;
388
		case 1: app = "/sys/develop/cedit"; break;
390
		case 2: app = "/sys/network/webview"; break;
389
		case 2: app = "/sys/network/webview"; break;
391
		case 3: app = "/sys/fb2read"; break;
390
		case 3: app = "/sys/fb2read"; break;
392
		case 4: app = "/sys/develop/heed"; break;
391
		case 4: app = "/sys/develop/heed"; break;
393
		case 5: open_param[0]='~';
392
		case 5: open_param[0]='~';
394
			strcpy(#open_param+1,#file_path);
393
			strcpy(#open_param+1,#file_path);
395
			RunProgram("/sys/@open", #open_param);
394
			RunProgram("/sys/@open", #open_param);
396
			return;
395
			return;
397
	}
396
	}
398
	RunProgram(app, #file_path);
397
	RunProgram(app, #file_path);
399
}
398
}
400
 
399
 
401
void EventMenuClick()
400
void EventMenuClick()
402
{
401
{
403
	dword click_id = get_menu_click();
402
	dword click_id = get_menu_click();
404
 
403
 
405
	if (click_id) && (menu_id) switch(menu_id)
404
	if (click_id) && (menu_id) switch(menu_id)
406
	{
405
	{
407
		case CHANGE_CHARSET: EventChangeCharset(click_id-1); break;
406
		case CHANGE_CHARSET: EventChangeCharset(click_id-1); break;
408
		case REOPEN_IN_APP:  EventOpenFileInOtherApp(click_id-1); break;
407
		case REOPEN_IN_APP:  EventOpenFileInOtherApp(click_id-1); break;
409
		case COLOR_SCHEME:   EventSetColorScheme(click_id-1); break;
408
		case COLOR_SCHEME:   EventSetColorScheme(click_id-1); break;
410
		case RMB_MENU:       EventRbmMenuClick(click_id-1); break;
409
		case RMB_MENU:       EventRbmMenuClick(click_id-1); break;
411
		default: notify("'Error: wrong menu number'E");
410
		default: notify("'Error: wrong menu number'E");
412
	}
411
	}
413
	menu_id = NULL;
412
	menu_id = NULL;
414
}
413
}
415
 
414
 
416
void EventClickSearch()
415
void EventClickSearch()
417
{
416
{
418
	if (search.visible) {
417
	if (search.visible) {
419
		search.hide();
418
		search.hide();
420
	} else {
419
	} else {
421
		search.show();
420
		search.show();
422
	}
421
	}
423
}
422
}
424
 
423
 
425
/*
424
/*
426
void EventInsertCharIntoText()
425
void EventInsertCharIntoText()
427
{
426
{
428
	dword i;
427
	dword i;
429
	dword cursor_pos = lines.get(list.cur_y) + list.cur_x;
428
	dword cursor_pos = lines.get(list.cur_y) + list.cur_x;
430
 
429
 
431
	switch(key_scancode)
430
	switch(key_scancode)
432
	{
431
	{
433
		case SCAN_CODE_DOWN:
432
		case SCAN_CODE_DOWN:
434
		case SCAN_CODE_UP:
433
		case SCAN_CODE_UP:
435
		case SCAN_CODE_LEFT:
434
		case SCAN_CODE_LEFT:
436
		case SCAN_CODE_RIGHT:
435
		case SCAN_CODE_RIGHT:
437
		case SCAN_CODE_HOME:
436
		case SCAN_CODE_HOME:
438
		case SCAN_CODE_END:
437
		case SCAN_CODE_END:
439
		case SCAN_CODE_PGUP:
438
		case SCAN_CODE_PGUP:
440
		case SCAN_CODE_PGDN:
439
		case SCAN_CODE_PGDN:
441
			return;
440
			return;
442
		case SCAN_CODE_BS:
441
		case SCAN_CODE_BS:
443
			if (selection.is_active()) {
442
			if (selection.is_active()) {
444
				EventDeleteSelectedText();
443
				EventDeleteSelectedText();
445
			} else {
444
			} else {
446
				if (!list.cur_x) && (!list.cur_y) break;
445
				if (!list.cur_x) && (!list.cur_y) break;
447
				textbuf.del(cursor_pos-1, cursor_pos);
446
				textbuf.del(cursor_pos-1, cursor_pos);
448
				if (!list.cur_x) && (list.cur_y) {
447
				if (!list.cur_x) && (list.cur_y) {
449
					list.column_max = lines.len(list.cur_y-1);
448
					list.column_max = lines.len(list.cur_y-1);
450
					list.KeyLeft();
449
					list.KeyLeft();
451
				}
450
				}
452
				list.KeyLeft();
451
				list.KeyLeft();
453
			}
452
			}
454
			ParseAndPaint();
453
			ParseAndPaint();
455
			return;
454
			return;
456
		case SCAN_CODE_DEL:
455
		case SCAN_CODE_DEL:
457
			if (selection.is_active()) {
456
			if (selection.is_active()) {
458
				EventDeleteSelectedText();
457
				EventDeleteSelectedText();
459
			} else {
458
			} else {
460
				if (cursor_pos < textbuf.p + textbuf.len) textbuf.del(cursor_pos, cursor_pos+1);
459
				if (cursor_pos < textbuf.p + textbuf.len) textbuf.del(cursor_pos, cursor_pos+1);
461
			}
460
			}
462
			ParseAndPaint();
461
			ParseAndPaint();
463
			return;
462
			return;
464
		default:
463
		default:
465
			if (selection.is_active()) {
464
			if (selection.is_active()) {
466
				EventDeleteSelectedText();
465
				EventDeleteSelectedText();
467
				Parse();
466
				Parse();
468
			}
467
			}
469
			cursor_pos = lines.get(list.cur_y) + list.cur_x;
468
			cursor_pos = lines.get(list.cur_y) + list.cur_x;
470
			textbuf.insert_ch(cursor_pos, key_ascii);
469
			textbuf.insert_ch(cursor_pos, key_ascii);
471
			list.KeyRight();
470
			list.KeyRight();
472
			Parse();
471
			Parse();
473
			list.column_max = lines.len(list.cur_y);
472
			list.column_max = lines.len(list.cur_y);
474
			if (key_scancode == SCAN_CODE_ENTER) list.KeyRight();
473
			if (key_scancode == SCAN_CODE_ENTER) list.KeyRight();
475
			DrawPage();
474
			DrawPage();
476
	}
475
	}
477
}
476
}
478
*/
477
*/
479
 
478
 
480
void EventRbmMenuClick(dword id)
479
void EventRbmMenuClick(dword id)
481
{
480
{
482
	switch(id) {
481
	switch(id) {
483
		case 0: EventCopy(); break;
482
		case 0: EventCopy(); break;
484
		case 1: EventRevealInFolder(); break;
483
		case 1: EventRevealInFolder(); break;
485
		case 2: EventCopyFilePath(); break;
484
		case 2: EventCopyFilePath(); break;
486
	}
485
	}
487
}
486
}
488
 
487
 
489
void EventSelectAllText()
488
void EventSelectAllText()
490
{
489
{
491
	selection.select_all();
490
	selection.select_all();
492
	DrawPage();
491
	DrawPage();
493
}
492
}
494
 
493
 
495
void EventCopy()
494
void EventCopy()
496
{
495
{
497
	char copy_status_text[32];
496
	char copy_status_text[32];
498
 
497
 
499
	dword copy_buf;
498
	dword copy_buf;
500
	dword copy_len;
499
	dword copy_len;
501
	dword copy_start;
500
	dword copy_start;
502
	dword copy_end;
501
	dword copy_end;
503
 
502
 
504
	if (selection.is_active()) {
503
	if (selection.is_active()) {
505
		copy_start = selection.start_offset;
504
		copy_start = selection.start_offset;
506
		copy_end = selection.end_offset;
505
		copy_end = selection.end_offset;
507
		if (copy_start > copy_end) copy_start >< copy_end;
506
		if (copy_start > copy_end) copy_start >< copy_end;
508
	} else {
507
	} else {
509
		copy_start = lines.get(list.cur_y);
508
		copy_start = lines.get(list.cur_y);
510
		copy_end = lines.get(list.cur_y+1);
509
		copy_end = lines.get(list.cur_y+1);
511
	}
510
	}
512
	copy_len = copy_end - copy_start;
511
	copy_len = copy_end - copy_start;
513
	copy_buf = malloc(copy_len + 2);
512
	copy_buf = malloc(copy_len + 2);
514
	strncpy(copy_buf, copy_start, copy_len);
513
	strncpy(copy_buf, copy_start, copy_len);
515
	ESBYTE[copy_buf+copy_len] = '\0';
514
	ESBYTE[copy_buf+copy_len] = '\0';
516
	Clipboard__CopyText(copy_buf);
515
	Clipboard__CopyText(copy_buf);
517
	free(copy_buf);
516
	free(copy_buf);
518
 
517
 
519
	sprintf(#copy_status_text, #copied_chars, copy_len);
518
	sprintf(#copy_status_text, #copied_chars, copy_len);
520
	DrawStatusBar(#copy_status_text);
519
	DrawStatusBar(#copy_status_text);
521
}
520
}
522
 
521
 
523
/*
522
/*
524
void EventCut()
523
void EventCut()
525
{
524
{
526
	if (!selection.is_active()) {
525
	if (!selection.is_active()) {
527
		selection.start_offset = lines.get(list.cur_y);
526
		selection.start_offset = lines.get(list.cur_y);
528
		selection.end_offset = lines.get(list.cur_y+1);
527
		selection.end_offset = lines.get(list.cur_y+1);
529
	}
528
	}
530
	EventCopy();
529
	EventCopy();
531
	EventDeleteSelectedText();
530
	EventDeleteSelectedText();
532
	ParseAndPaint();
531
	ParseAndPaint();
533
}
532
}
534
 
533
 
535
void EventPaste()
534
void EventPaste()
536
{
535
{
537
	int i;
536
	int i;
538
	dword buf = Clipboard__GetSlotData(Clipboard__GetSlotCount()-1);
537
	dword buf = Clipboard__GetSlotData(Clipboard__GetSlotCount()-1);
539
	if (selection.is_active()) {
538
	if (selection.is_active()) {
540
		EventDeleteSelectedText();
539
		EventDeleteSelectedText();
541
	} 
540
	} 
542
	cursor_pos = lines.get(list.cur_y) + list.cur_x;
541
	cursor_pos = lines.get(list.cur_y) + list.cur_x;
543
	textbuf.insert_str(cursor_pos, buf+12, ESDWORD[buf]-12);
542
	textbuf.insert_str(cursor_pos, buf+12, ESDWORD[buf]-12);
544
	for (i=0; i
543
	for (i=0; i
545
	ParseAndPaint();
544
	ParseAndPaint();
546
}
545
}
547
 
546
 
548
void EventDeleteSelectedText()
547
void EventDeleteSelectedText()
549
{
548
{
550
	textbuf.del(selection.start_offset, selection.end_offset);
549
	textbuf.del(selection.start_offset, selection.end_offset);
551
	list.cur_x = math.min(selection.start_x, selection.end_x);
550
	list.cur_x = math.min(selection.start_x, selection.end_x);
552
	list.cur_y = math.min(selection.start_y, selection.end_y);
551
	list.cur_y = math.min(selection.start_y, selection.end_y);
553
	selection.cancel();
552
	selection.cancel();
554
}
553
}
555
*/
554
*/
556
 
555
 
557
void EventRevealInFolder()
556
void EventRevealInFolder()
558
{
557
{
559
	RunProgram("/sys/File managers/Eolite", #file_path);
558
	RunProgram("/sys/File managers/Eolite", #file_path);
560
}
559
}
561
 
560
 
562
void EventCopyFilePath()
561
void EventCopyFilePath()
563
{
562
{
564
	char copy_status_text[32];
563
	char copy_status_text[32];
565
	Clipboard__CopyText(#file_path);
564
	Clipboard__CopyText(#file_path);
566
	sprintf(#copy_status_text, #copied_chars, strlen(#file_path));
565
	sprintf(#copy_status_text, #copied_chars, strlen(#file_path));
567
	DrawStatusBar(#copy_status_text);
566
	DrawStatusBar(#copy_status_text);
568
}
567
}
569
 
568
 
570
//===================================================//
569
//===================================================//
571
//                                                   //
570
//                                                   //
572
//               DRAWS AND OTHER FUNCS               //
571
//               DRAWS AND OTHER FUNCS               //
573
//                                                   //
572
//                                                   //
574
//===================================================//
573
//===================================================//
575
 
574
 
576
void EncodeToDos()
575
void EncodeToDos()
577
{
576
{
578
	real_encoding = user_encoding;
577
	real_encoding = user_encoding;
579
 
578
 
580
	// Autodetecting charset
579
	// Autodetecting charset
581
	if (real_encoding == CH_AUTO) {
580
	if (real_encoding == CH_AUTO) {
582
		real_encoding = CH_CP866;
581
		real_encoding = CH_CP866;
583
		if (strstr(textbuf.p, "\208\190")) real_encoding = CH_UTF8;
582
		if (strstr(textbuf.p, "\208\190")) real_encoding = CH_UTF8;
584
		else {
583
		else {
585
			if (chrnum(textbuf.p, '\246')>5)
584
			if (chrnum(textbuf.p, '\246')>5)
586
			|| (strstr(textbuf.p, "\239\240")) real_encoding = CH_CP1251;
585
			|| (strstr(textbuf.p, "\239\240")) real_encoding = CH_CP1251;
587
		}
586
		}
588
	}
587
	}
589
	if (real_encoding != CH_CP866) {
588
	if (real_encoding != CH_CP866) {
590
		ChangeCharset(real_encoding, CH_CP866, textbuf.p);
589
		ChangeCharset(real_encoding, CH_CP866, textbuf.p);
591
	}
590
	}
592
}
591
}
593
 
592
 
594
void LoadFile(dword f_path)
593
void LoadFile(dword f_path)
595
{
594
{
596
	if (ESBYTE[f_path]) {
595
	if (ESBYTE[f_path]) {
597
		strcpy(#file_path, f_path);
596
		strcpy(#file_path, f_path);
598
		if (!io.read(#file_path)) goto NO_DATA;
597
		if (!io.read(#file_path)) goto NO_DATA;
599
		textbuf.set(io.buffer_data, io.FILES_SIZE);
598
		textbuf.set(io.buffer_data, io.FILES_SIZE);
600
		free(io.buffer_data);
599
		free(io.buffer_data);
601
		sprintf(#title, "%s - %s", #file_path, #short_app_name);
600
		sprintf(#title, "%s - %s", #file_path, #short_app_name);
602
		EncodeToDos();
601
		EncodeToDos();
603
	}
602
	}
604
	else {
603
	else {
605
		NO_DATA:
604
		NO_DATA:
606
		textbuf.set(#intro, sizeof(intro)-1);
605
		textbuf.set(#intro, sizeof(intro)-1);
607
		strcpy(#title, #short_app_name);
606
		strcpy(#title, #short_app_name);
608
	}
607
	}
609
	list.ClearList();
608
	list.ClearList();
610
}
609
}
611
 
610
 
612
int TopBarBt(dword _event, _hotkey, char image_id, int x, pressed) {
611
int TopBarBt(dword _event, _hotkey, char image_id, int x, pressed) {
613
	if (_hotkey) key.add_n(_hotkey, _event);
612
	if (_hotkey) key.add_n(_hotkey, _event);
614
	return DrawTopPanelButton(button.add(_event), x, 5, image_id, pressed);
613
	return DrawTopPanelButton(button.add(_event), x, 5, image_id, pressed);
615
}
614
}
616
 
615
 
617
 
616
 
618
void DrawToolbar()
617
void DrawToolbar()
619
{
618
{
620
	#define GAP_S 26+7
619
	#define GAP_S 26+7
621
	#define GAP_B 26+19
620
	#define GAP_B 26+19
622
	incn x;
621
	incn x;
623
	bool thema = false;
622
	bool thema = false;
624
	bool reopa = false;
623
	bool reopa = false;
625
 
624
 
626
	if (menu_id == COLOR_SCHEME) thema = true;
625
	if (menu_id == COLOR_SCHEME) thema = true;
627
	if (menu_id == REOPEN_IN_APP) reopa = true;
626
	if (menu_id == REOPEN_IN_APP) reopa = true;
628
 
627
 
629
	DrawBar(0, 0, Form.cwidth, TOOLBAR_H - 1, sc.work);
628
	DrawBar(0, 0, Form.cwidth, TOOLBAR_H - 1, sc.work);
630
	DrawBar(0, TOOLBAR_H - 1, Form.cwidth, 1, sc.line);
629
	DrawBar(0, TOOLBAR_H - 1, Form.cwidth, 1, sc.line);
631
 
630
 
632
	x.set(-GAP_S+8);
631
	x.set(-GAP_S+8);
633
	TopBarBt(#EventOpenDialog,     ECTRL+SCAN_CODE_KEY_O, 0,  x.inc(GAP_S), false);
632
	TopBarBt(#EventOpenDialog,     ECTRL+SCAN_CODE_KEY_O, 0,  x.inc(GAP_S), false);
634
	TopBarBt(#EventShowFileInfo,   ECTRL+SCAN_CODE_KEY_I, 10, x.inc(GAP_S), false);
633
	TopBarBt(#EventShowFileInfo,   ECTRL+SCAN_CODE_KEY_I, 10, x.inc(GAP_S), false);
635
	TopBarBt(#EventMagnifyMinus,   ECTRL+SCAN_CODE_MINUS, 33, x.inc(GAP_B),   false);
634
	TopBarBt(#EventMagnifyMinus,   ECTRL+SCAN_CODE_MINUS, 33, x.inc(GAP_B),   false);
636
	TopBarBt(#EventMagnifyPlus,    ECTRL+SCAN_CODE_PLUS,  32, x.inc(GAP_S), false);
635
	TopBarBt(#EventMagnifyPlus,    ECTRL+SCAN_CODE_PLUS,  32, x.inc(GAP_S), false);
637
	TopBarBt(#EventClickSearch,    ECTRL+SCAN_CODE_KEY_F, 49, x.inc(GAP_B),   search.visible);  search_mx = EAX;
636
	TopBarBt(#EventClickSearch,    ECTRL+SCAN_CODE_KEY_F, 49, x.inc(GAP_B),   search.visible);  search_mx = EAX;
638
	TopBarBt(#EventShowThemesList, NULL,                  40, x.inc(GAP_B), thema); theme_mx = EAX;
637
	TopBarBt(#EventShowThemesList, NULL,                  40, x.inc(GAP_B), thema); theme_mx = EAX;
639
	TopBarBt(#EventShowReopenMenu, ECTRL+SCAN_CODE_KEY_E, 16, x.inc(GAP_S), reopa); reopenin_mx = EAX;
638
	TopBarBt(#EventShowReopenMenu, ECTRL+SCAN_CODE_KEY_E, 16, x.inc(GAP_S), reopa); reopenin_mx = EAX;
640
}
639
}
641
 
640
 
642
void DrawStatusBar(dword _in_text)
641
void DrawStatusBar(dword _in_text)
643
{
642
{
644
	static char status_text[64];
643
	static char status_text[64];
645
	if (Form.status_window&ROLLED_UP) return;
644
	if (Form.status_window&ROLLED_UP) return;
646
	if (_in_text) strncpy(#status_text, _in_text, sizeof(status_text));
645
	if (_in_text) strncpy(#status_text, _in_text, sizeof(status_text));
647
	DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,1, sc.line);
646
	DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,1, sc.line);
648
	DrawBar(0,Form.cheight - STATUSBAR_H+1, Form.cwidth,STATUSBAR_H-1, sc.work);
647
	DrawBar(0,Form.cheight - STATUSBAR_H+1, Form.cwidth,STATUSBAR_H-1, sc.work);
649
	WriteText(5, Form.cheight - STATUSBAR_H + 4, 0x80, sc.work_text, #status_text);
648
	WriteText(5, Form.cheight - STATUSBAR_H + 4, 0x80, sc.work_text, #status_text);
650
	if (file_path[0]) {
649
	if (file_path[0]) {
651
		WriteTextCenter(Form.cwidth-70, Form.cheight - STATUSBAR_H + 4,
650
		WriteTextCenter(Form.cwidth-70, Form.cheight - STATUSBAR_H + 4,
652
			60, sc.work_text, real_encoding*10+#charsets);
651
			60, sc.work_text, real_encoding*10+#charsets);
653
		DefineHiddenButton(Form.cwidth-70, Form.cheight - STATUSBAR_H + 1,
652
		DefineHiddenButton(Form.cwidth-70, Form.cheight - STATUSBAR_H + 1,
654
			60, 12, BTN_CHANGE_CHARSET+10);
653
			60, 12, BTN_CHANGE_CHARSET+10);
655
	}
654
	}
656
}
655
}
657
 
656
 
658
void draw_window()
657
void draw_window()
659
{
658
{
660
	int old_w = list.w;
659
	int old_w = list.w;
661
	if (CheckActiveProcess(Form.ID)) EventMenuClick();
660
	if (CheckActiveProcess(Form.ID)) EventMenuClick();
662
	DefineAndDrawWindow(Form.left,Form.top,Form.width,Form.height,0x73,0,#title,0);
661
	DefineAndDrawWindow(Form.left,Form.top,Form.width,Form.height,0x73,0,#title,0);
663
	GetProcessInfo(#Form, SelfInfo);
662
	GetProcessInfo(#Form, SelfInfo);
664
	sc.get();
663
	sc.get();
665
	if (Form.status_window&ROLLED_UP) return;
664
	if (Form.status_window&ROLLED_UP) return;
666
	if (Form.width  < 450) { MoveSize(OLD,OLD,450,OLD); return; }
665
	if (Form.width  < 450) { MoveSize(OLD,OLD,450,OLD); return; }
667
	if (Form.height < 200) { MoveSize(OLD,OLD,OLD,200); return; }
666
	if (Form.height < 200) { MoveSize(OLD,OLD,OLD,200); return; }
668
 
667
 
669
	button.init(40);
668
	button.init(40);
670
	key.init(40);
669
	key.init(40);
671
 
670
 
672
	SetFontSize(font_size);
671
	SetFontSize(font_size);
673
 
672
 
674
	if ((list.w == old_w) && (list.count)) {
673
	if ((list.w == old_w) && (list.count)) {
675
		DrawPage();
674
		DrawPage();
676
	} else {
675
	} else {
677
		ParseAndPaint();
676
		ParseAndPaint();
678
	}
677
	}
679
 
678
 
680
	DrawToolbar();
679
	DrawToolbar();
681
	DrawSearch();
680
	DrawSearch();
682
	DrawStatusBar(NULL);
681
	DrawStatusBar(NULL);
683
}
682
}
684
 
683
 
685
bool DrawSearch()
684
bool DrawSearch()
686
{
685
{
687
	char matches[30];
686
	char matches[30];
688
	int _y = Form.cheight - SEARCH_H - STATUSBAR_H;
687
	int _y = Form.cheight - SEARCH_H - STATUSBAR_H;
689
	if (!search.visible) return false;
688
	if (!search.visible) return false;
690
	DrawBar(0, _y, Form.cwidth, 1, sc.line);
689
	DrawBar(0, _y, Form.cwidth, 1, sc.line);
691
	DrawBar(0, _y+1, Form.cwidth, SEARCH_H-1, sc.work);
690
	DrawBar(0, _y+1, Form.cwidth, SEARCH_H-1, sc.work);
692
 
691
 
693
	search_box.top = _y + 6;
692
	search_box.top = _y + 6;
694
	search_box.width = math.min(Form.width - 200, 150);
693
	search_box.width = math.min(Form.width - 200, 150);
695
 
694
 
696
	DrawRectangle(search_box.left-1, search_box.top-1, search_box.width+2, 23,sc.line);
695
	DrawRectangle(search_box.left-1, search_box.top-1, search_box.width+2, 23,sc.line);
697
 
696
 
698
	edit_box_draw stdcall(#search_box);
697
	edit_box_draw stdcall(#search_box);
699
 
698
 
700
	DrawCaptButton(search_box.left+search_box.width+14, search_box.top-1, 30,
699
	DrawCaptButton(search_box.left+search_box.width+14, search_box.top-1, 30,
701
		TOOLBAR_ICON_HEIGHT+1, BTN_FIND_PREVIOUS+10, sc.light, sc.work_text, "<");
700
		TOOLBAR_ICON_HEIGHT+1, BTN_FIND_PREVIOUS+10, sc.light, sc.work_text, "<");
702
	DrawCaptButton(search_box.left+search_box.width+44, search_box.top-1, 30,
701
	DrawCaptButton(search_box.left+search_box.width+44, search_box.top-1, 30,
703
		TOOLBAR_ICON_HEIGHT+1, BTN_FIND_NEXT+10, sc.light, sc.work_text, ">");
702
		TOOLBAR_ICON_HEIGHT+1, BTN_FIND_NEXT+10, sc.light, sc.work_text, ">");
704
 
703
 
705
	sprintf(#matches, T_MATCHES, search.found.count);
704
	sprintf(#matches, T_MATCHES, search.found.count);
706
	WriteTextWithBg(search_box.left+search_box.width+14+85,
705
	WriteTextWithBg(search_box.left+search_box.width+14+85,
707
		search_box.top+3, 0xD0, sc.work_text, #matches, sc.work);
706
		search_box.top+3, 0xD0, sc.work_text, #matches, sc.work);
708
 
707
 
709
	DefineHiddenButton(Form.cwidth-26, search_box.top-1, TOOLBAR_ICON_HEIGHT+1,
708
	DefineHiddenButton(Form.cwidth-26, search_box.top-1, TOOLBAR_ICON_HEIGHT+1,
710
		TOOLBAR_ICON_HEIGHT+1, BTN_FIND_CLOSE+10);
709
		TOOLBAR_ICON_HEIGHT+1, BTN_FIND_CLOSE+10);
711
	WriteText(Form.cwidth-26+7, search_box.top+2, 0x81, sc.line, "x");
710
	WriteText(Form.cwidth-26+7, search_box.top+2, 0x81, sc.line, "x");
712
	return true;
711
	return true;
713
}
712
}
714
 
713
 
715
void SetFontSize(char _size)
714
void SetFontSize(char _size)
716
{
715
{
717
	font_size = _size;
716
	font_size = _size;
718
	if (font_size == 0) list.SetFont(  6,      9, 00001000b);
717
	if (font_size == 0) list.SetFont(  6,      9, 00001000b);
719
	if (font_size == 1) list.SetFont(  8,     14, 00011000b);
718
	if (font_size == 1) list.SetFont(  8,     14, 00011000b);
720
	if (font_size == 2) list.SetFont(2*6,    2*9, 00001001b);
719
	if (font_size == 2) list.SetFont(2*6,    2*9, 00001001b);
721
	if (font_size == 3) list.SetFont(2*8, 2*14-2, 00011001b);
720
	if (font_size == 3) list.SetFont(2*8, 2*14-2, 00011001b);
722
	if (font_size == 4) list.SetFont(3*6,    3*9, 00001010b);
721
	if (font_size == 4) list.SetFont(3*6,    3*9, 00001010b);
723
	if (font_size == 5) list.SetFont(3*8, 3*14-2, 00011010b);
722
	if (font_size == 5) list.SetFont(3*8, 3*14-2, 00011010b);
724
	list.item_w = list.font_w;
723
	list.item_w = list.font_w;
725
	list.horisontal_selelection = true;
724
	list.horisontal_selelection = true;
726
	list.SetSizes(0, TOOLBAR_H, Form.cwidth-scroll.size_x-1,
725
	list.SetSizes(0, TOOLBAR_H, Form.cwidth-scroll.size_x-1,
727
		Form.cheight - TOOLBAR_H - calc(search.visible * SEARCH_H) - STATUSBAR_H /*- TAB_H*/,
726
		Form.cheight - TOOLBAR_H - calc(search.visible * SEARCH_H) - STATUSBAR_H /*- TAB_H*/,
728
		math.round(list.font_h * 1.3));
727
		math.round(list.font_h * 1.3));
729
}
728
}
730
>
729
>