Subversion Repositories Kolibri OS

Rev

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