Subversion Repositories Kolibri OS

Rev

Rev 8584 | Rev 8911 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 8584 Rev 8749
Line 8... Line 8...
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
*/
Line 12... Line 12...
12
 
12
 
Line 13... Line 13...
13
#define MEMSIZE 60*1024
13
#define MEMSIZE 50*1024
14
 
14
 
15
//===================================================//
15
//===================================================//
16
//                                                   //
16
//                                                   //
Line 180... Line 180...
180
{
180
{
181
	GetKeys();
181
	GetKeys();
Line 182... Line 182...
182
 
182
 
183
	switch (key_scancode)
183
	switch (key_scancode)
184
	{
-
 
185
		case SCAN_CODE_F1:
-
 
186
			EventShowInfo();
-
 
187
			return;
184
	{
188
		case SCAN_CODE_ESC:
185
		case SCAN_CODE_ESC:
189
			search.hide();
186
			search.hide();
190
			return;
187
			return;
191
		case SCAN_CODE_ENTER:
188
		case SCAN_CODE_ENTER:
Line 204... Line 201...
204
	if (key_modifier & KEY_LCTRL) || (key_modifier & KEY_RCTRL) {
201
	if (key_modifier & KEY_LCTRL) || (key_modifier & KEY_RCTRL) {
205
		if (key.press(ECTRL + key_scancode)) return;
202
		if (key.press(ECTRL + key_scancode)) return;
206
		switch (key_scancode)
203
		switch (key_scancode)
207
		{
204
		{
208
			case SCAN_CODE_KEY_A: EventSelectAllText();    return;
205
			case SCAN_CODE_KEY_A: EventSelectAllText();    return;
209
			case SCAN_CODE_KEY_X: EventCut();              return;
-
 
210
			case SCAN_CODE_KEY_C: EventCopy();             return;
206
			case SCAN_CODE_KEY_C: EventCopy();             return;
-
 
207
			//case SCAN_CODE_KEY_X: EventCut();              return;
211
			case SCAN_CODE_KEY_V: EventPaste();            return;
208
			//case SCAN_CODE_KEY_V: EventPaste();            return;
212
			case SCAN_CODE_UP:    EventMagnifyPlus();      return;
209
			case SCAN_CODE_UP:    EventMagnifyPlus();      return;
213
			case SCAN_CODE_DOWN:  EventMagnifyMinus();     return;
210
			case SCAN_CODE_DOWN:  EventMagnifyMinus();     return;
214
			case SCAN_CODE_TAB:   EventShowCharsetsList(); return;
211
			case SCAN_CODE_TAB:   EventShowCharsetsList(); return;
215
			case SCAN_CODE_KEY_F: search.show();           return;
212
			case SCAN_CODE_KEY_F: search.show();           return;
216
		}
213
		}
217
	}
214
	}
Line 218... Line 215...
218
 
215
 
219
	if (key_modifier & KEY_LSHIFT) || (key_modifier & KEY_RSHIFT) {
216
	if (key_modifier & KEY_LSHIFT) || (key_modifier & KEY_RSHIFT) {
220
		selection.set_start();
217
		selection.set_start();
221
	} else {
218
	} else {
222
		EventInsertCharIntoText();
219
		//EventInsertCharIntoText();
223
		selection.cancel();
220
		selection.cancel();
Line 224... Line 221...
224
	}
221
	}
225
 
222
 
Line 300... Line 297...
300
		search_next = true;
297
		search_next = true;
301
		DrawPage();
298
		DrawPage();
302
	}
299
	}
303
}
300
}
Line 304... Line -...
304
 
-
 
305
void EventNewFile()
-
 
306
{
-
 
307
	RunProgram(#program_path, "-new");
-
 
308
}
-
 
309
 
301
 
310
void EventOpenDialog()
302
void EventOpenDialog()
311
{
303
{
312
	OpenDialog_start stdcall (#o_dialog);
304
	OpenDialog_start stdcall (#o_dialog);
313
	if (o_dialog.status) {
305
	if (o_dialog.status) {
314
		LoadFile(#openfile_path);
306
		LoadFile(#openfile_path);
315
		ParseAndPaint();
307
		ParseAndPaint();
316
	}
308
	}
Line 317... Line -...
317
}
-
 
318
 
-
 
319
void EventSave()
-
 
320
{
-
 
321
	int res;
-
 
322
	char backy_param[4096];
-
 
323
	io.dir.make("/tmp0/1/quark_backups");
-
 
324
	sprintf(#backy_param, "%s -o /tmp0/1/quark_backups", #file_path);
-
 
325
	RunProgram("/sys/develop/backy", #backy_param);
-
 
326
	if (! WriteFile(0, textbuf.len, textbuf.p, #file_path) ) {
-
 
327
		notify(FILE_SAVED_WELL);
-
 
328
	} else {
-
 
329
		notify(FILE_NOT_SAVED);
-
 
330
	}
-
 
331
}
309
}
332
 
310
 
333
void EventShowFileInfo()
311
void EventShowFileInfo()
334
{
312
{
335
	char ss_param[4096];
313
	char ss_param[4096];
Line 362... Line 340...
362
}
340
}
Line 363... Line 341...
363
 
341
 
364
void EventShowReopenMenu()
342
void EventShowReopenMenu()
365
{
343
{
366
	menu_id = REOPEN_IN_APP;
344
	menu_id = REOPEN_IN_APP;
367
	open_lmenu(reopenin_mx + 23, 29, MENU_TOP_RIGHT, NULL,
345
	open_lmenu(reopenin_mx, 29, MENU_TOP_LEFT, NULL,
368
		"Tinypad\nTextEdit\nWebView\nFB2Read\nHexView\nOther");
346
		"Tinypad\nCodeEdit\nWebView\nFB2Read\nHexView\nOther");
Line 369... Line 347...
369
}
347
}
370
 
348
 
371
void EventShowThemesList()
349
void EventShowThemesList()
372
{
350
{
373
	menu_id = COLOR_SCHEME;
351
	menu_id = COLOR_SCHEME;
374
	open_lmenu(theme_mx + 23, 29, MENU_TOP_RIGHT,
352
	open_lmenu(theme_mx, 29, MENU_TOP_LEFT,
Line 375... Line 353...
375
		curcol_scheme+1, #color_scheme_names);
353
		curcol_scheme+1, #color_scheme_names);
376
}
354
}
Line 393... Line 371...
393
	theme.cursor    = color_schemes[curcol_scheme*6+4];
371
	theme.cursor    = color_schemes[curcol_scheme*6+4];
394
	theme.found     = color_schemes[curcol_scheme*6+5];
372
	theme.found     = color_schemes[curcol_scheme*6+5];
395
	if (list.count) ParseAndPaint();
373
	if (list.count) ParseAndPaint();
396
}
374
}
Line 397... Line -...
397
 
-
 
398
 
-
 
399
void EventShowInfo() {
-
 
400
	notify(#about);
-
 
401
}
-
 
402
 
375
 
403
void EventChangeCharset(dword id)
376
void EventChangeCharset(dword id)
404
{
377
{
405
	if (file_path[0]=='\0') return;
378
	if (file_path[0]=='\0') return;
406
	user_encoding = id;
379
	user_encoding = id;
Line 413... Line 386...
413
{
386
{
414
	dword app;
387
	dword app;
415
	byte open_param[4096];
388
	byte open_param[4096];
416
	switch(_id) {
389
	switch(_id) {
417
		case 0: app = "/sys/tinypad"; break;
390
		case 0: app = "/sys/tinypad"; break;
418
		case 1: app = "/sys/develop/t_edit"; break;
391
		case 1: app = "/sys/develop/cedit"; break;
419
		case 2: app = "/sys/network/webview"; break;
392
		case 2: app = "/sys/network/webview"; break;
420
		case 3: app = "/sys/fb2read"; break;
393
		case 3: app = "/sys/fb2read"; break;
421
		case 4: app = "/sys/develop/heed"; break;
394
		case 4: app = "/sys/develop/heed"; break;
422
		case 5: open_param[0]='~';
395
		case 5: open_param[0]='~';
423
			strcpy(#open_param+1,#file_path);
396
			strcpy(#open_param+1,#file_path);
Line 449... Line 422...
449
	} else {
422
	} else {
450
		search.show();
423
		search.show();
451
	}
424
	}
452
}
425
}
Line -... Line 426...
-
 
426
 
453
 
427
/*
454
void EventInsertCharIntoText()
428
void EventInsertCharIntoText()
455
{
429
{
456
	dword i;
430
	dword i;
Line 501... Line 475...
501
			list.column_max = lines.len(list.cur_y);
475
			list.column_max = lines.len(list.cur_y);
502
			if (key_scancode == SCAN_CODE_ENTER) list.KeyRight();
476
			if (key_scancode == SCAN_CODE_ENTER) list.KeyRight();
503
			DrawPage();
477
			DrawPage();
504
	}
478
	}
505
}
479
}
506
 
-
 
507
void EventOpenSysfuncs()
-
 
508
{
-
 
509
	if (RunProgram("/sys/docpack", "f") <= 0) {
-
 
510
		notify("'Can not open SysFunctions because\n/rd/1/docpack is not found!'E");
-
 
511
	}
480
*/
512
}
-
 
513
 
-
 
514
void EventOpenPipet()
-
 
515
{
-
 
516
	RunProgram("/sys/develop/pipet", NULL);
-
 
517
}
-
 
Line 518... Line 481...
518
 
481
 
519
void EventRbmMenuClick(dword id)
482
void EventRbmMenuClick(dword id)
520
{
483
{
521
	switch(id) {
-
 
522
		case 0: EventCut(); break;
484
	switch(id) {
523
		case 1: EventCopy(); break;
-
 
524
		case 2: EventPaste(); break;
485
		case 0: EventCopy(); break;
525
		case 3: EventRevealInFolder(); break;
486
		case 1: EventRevealInFolder(); break;
526
		case 4: EventCopyFilePath(); break;
487
		case 2: EventCopyFilePath(); break;
527
	}
488
	}
Line 528... Line 489...
528
}
489
}
529
 
490
 
Line 559... Line 520...
559
 
520
 
560
	sprintf(#copy_status_text, #copied_chars, copy_len);
521
	sprintf(#copy_status_text, #copied_chars, copy_len);
561
	DrawStatusBar(#copy_status_text);
522
	DrawStatusBar(#copy_status_text);
Line -... Line 523...
-
 
523
}
562
}
524
 
563
 
525
/*
564
void EventCut()
526
void EventCut()
565
{
527
{
566
	if (!selection.is_active()) {
528
	if (!selection.is_active()) {
Line 590... Line 552...
590
	textbuf.del(selection.start_offset, selection.end_offset);
552
	textbuf.del(selection.start_offset, selection.end_offset);
591
	list.cur_x = math.min(selection.start_x, selection.end_x);
553
	list.cur_x = math.min(selection.start_x, selection.end_x);
592
	list.cur_y = math.min(selection.start_y, selection.end_y);
554
	list.cur_y = math.min(selection.start_y, selection.end_y);
593
	selection.cancel();
555
	selection.cancel();
594
}
556
}
-
 
557
*/
Line 595... Line 558...
595
 
558
 
596
void EventRevealInFolder()
559
void EventRevealInFolder()
597
{
560
{
598
	RunProgram("/sys/File managers/Eolite", #file_path);
561
	RunProgram("/sys/File managers/Eolite", #file_path);
Line 667... Line 630...
667
 
630
 
668
	DrawBar(0, 0, Form.cwidth, TOOLBAR_H - 1, sc.work);
631
	DrawBar(0, 0, Form.cwidth, TOOLBAR_H - 1, sc.work);
Line 669... Line 632...
669
	DrawBar(0, TOOLBAR_H - 1, Form.cwidth, 1, sc.work_graph);
632
	DrawBar(0, TOOLBAR_H - 1, Form.cwidth, 1, sc.work_graph);
670
 
-
 
671
	x.set(-GAP_S+8);
633
 
672
	TopBarBt(#EventNewFile,        ECTRL+SCAN_CODE_KEY_N, 2,  x.inc(GAP_S), false);
-
 
673
	TopBarBt(#EventOpenDialog,     ECTRL+SCAN_CODE_KEY_O, 0,  x.inc(GAP_S), false);
634
	x.set(-GAP_S+8);
674
	TopBarBt(#EventSave,           ECTRL+SCAN_CODE_KEY_S, 5,  x.inc(GAP_S), false);
635
	TopBarBt(#EventOpenDialog,     ECTRL+SCAN_CODE_KEY_O, 0,  x.inc(GAP_S), false);
675
	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);
676
	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);
677
	TopBarBt(#EventMagnifyPlus,    ECTRL+SCAN_CODE_PLUS,  32, x.inc(GAP_S), false);
-
 
678
	TopBarBt(#EventClickSearch,    ECTRL+SCAN_CODE_KEY_F, 49, x.inc(GAP_B),   search.visible);  search_mx = EAX;
-
 
679
	x.set(Form.cwidth-4);
638
	TopBarBt(#EventMagnifyPlus,    ECTRL+SCAN_CODE_PLUS,  32, x.inc(GAP_S), false);
680
	TopBarBt(#EventShowInfo,       NULL,                  -1, x.inc(-GAP_S), false); burger_mx = EAX;
639
	TopBarBt(#EventClickSearch,    ECTRL+SCAN_CODE_KEY_F, 49, x.inc(GAP_B),   search.visible);  search_mx = EAX;
681
	TopBarBt(#EventShowThemesList, NULL,                  40, x.inc(-GAP_B), thema); theme_mx = EAX;
-
 
682
	TopBarBt(#EventShowReopenMenu, ECTRL+SCAN_CODE_KEY_E, 16, x.inc(-GAP_S), reopa); reopenin_mx = EAX;
-
 
683
	TopBarBt(#EventOpenSysfuncs,   NULL,                  18, x.inc(-GAP_S), false);
640
	TopBarBt(#EventShowThemesList, NULL,                  40, x.inc(GAP_B), thema); theme_mx = EAX;
Line 684... Line 641...
684
	TopBarBt(#EventOpenPipet,      NULL,                  39, x.inc(-GAP_S), false);
641
	TopBarBt(#EventShowReopenMenu, ECTRL+SCAN_CODE_KEY_E, 16, x.inc(GAP_S), reopa); reopenin_mx = EAX;
685
}
642
}
686
 
643