Subversion Repositories Kolibri OS

Rev

Rev 8911 | Rev 9473 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

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