Subversion Repositories Kolibri OS

Rev

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

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