Subversion Repositories Kolibri OS

Rev

Rev 7924 | Rev 7945 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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