Subversion Repositories Kolibri OS

Rev

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

Rev 7921 Rev 7924
Line 2... Line 2...
2
	Quark Code Edit v0.2
2
	Quark Code Edit v0.2
3
	Author: Kiril Lipatov aka Leency
3
	Author: Kiril Lipatov aka Leency
4
	Licence: GPLv2
4
	Licence: GPLv2
Line 5... Line 5...
5
 
5
 
6
	The core components of this app are:
6
	The core components of this app are:
7
		1. list: text grid with keyboard and mouse proceed
7
		1. list: text grid with keyboard and mouse events
8
		2. lines: the mas of pointers for each line start
8
		2. lines: the mas of pointers for each line start
9
		3. selection
9
		3. selection
Line 10... Line 10...
10
*/
10
*/
Line 83... Line 83...
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_CLOSE
88
	BTN_FIND_CLOSE,
-
 
89
	BTN_CHANGE_CHARSET
89
};
90
};
Line 90... Line 91...
90
 
91
 
Line 91... Line 92...
91
dword menu_id;
92
dword menu_id;
Line 112... Line 113...
112
 
113
 
113
void LoadFileFromDocPack()
114
void LoadFileFromDocPack()
114
{
115
{
115
	dword bufsize = atoi(#param + 1) + 20;
116
	dword bufsize = atoi(#param + 1) + 20;
116
	dword bufpointer = malloc(bufsize);
-
 
Line 117... Line 117...
117
	dword filesize;
117
	dword bufpointer = malloc(bufsize);
118
 
118
 
119
	ESDWORD[bufpointer+0] = 0;
-
 
120
	ESDWORD[bufpointer+4] = 8;
119
	ESDWORD[bufpointer+0] = 0;
121
 
-
 
Line -... Line 120...
-
 
120
	ESDWORD[bufpointer+4] = 8;
122
	IpcSetArea(bufpointer, bufsize);
121
	IpcSetArea(bufpointer, bufsize);
123
	SetEventMask(EVM_IPC);
122
 
124
 
123
	SetEventMask(EVM_IPC);
125
	if (@WaitEventTimeout(200) != evIPC) {
124
	if (@WaitEventTimeout(200) != evIPC) {
Line 188... Line 187...
188
			EventSearchNext();
187
			EventSearchNext();
189
			break;
188
			break;
190
		case BTN_FIND_CLOSE:
189
		case BTN_FIND_CLOSE:
191
			search.hide();
190
			search.hide();
192
			break;
191
			break;
-
 
192
		case BTN_CHANGE_CHARSET:
-
 
193
			EventShowCharsetsList();
-
 
194
			break;
193
	}
195
	}
194
}
196
}
Line 195... Line 197...
195
 
197
 
196
void HandleKeyEvent()
198
void HandleKeyEvent()
Line 226... Line 228...
226
				EventShowCharsetsList();
228
				EventShowCharsetsList();
227
				return;
229
				return;
228
			case SCAN_CODE_KEY_F:
230
			case SCAN_CODE_KEY_F:
229
				search.show();
231
				search.show();
230
				return;
232
				return;
231
			case SCAN_CODE_HOME:
-
 
232
				list.KeyHome();
-
 
233
				list.KeyHomeHor();
-
 
234
				DrawPage();
-
 
235
				return;
-
 
236
			case SCAN_CODE_END:
-
 
237
				list.KeyEnd();
-
 
238
				list.column_max = strlen(lines.get(list.cur_y));
-
 
239
				list.KeyEndHor();
-
 
240
				DrawPage();
-
 
241
				return;
-
 
242
			case SCAN_CODE_KEY_A:
233
			case SCAN_CODE_KEY_A:
243
				selection.select_all();
234
				selection.select_all();
244
				DrawPage();
235
				DrawPage();
245
				return;
236
				return;
246
		}
237
		}
Line 259... Line 250...
259
			EventSearchNext();
250
			EventSearchNext();
260
			return;
251
			return;
261
	}
252
	}
262
	if (search.edit_key()) {
253
	if (search.edit_key()) {
263
		return;
254
		return;
-
 
255
	} else {
-
 
256
		if (key_modifier & KEY_LSHIFT) || (key_modifier & KEY_RSHIFT) selection.set_start();
-
 
257
		else selection.cancel();
264
	} else if (list.ProcessKey(key_scancode)) {
258
		if (list.ProcessKey(key_scancode)) {
-
 
259
			if (key_modifier & KEY_LSHIFT) || (key_modifier & KEY_RSHIFT) selection.set_end();
265
		DrawPage();
260
			DrawPage();
-
 
261
		}
266
		return;
262
		return;
267
	}
263
	}
268
	EventInsertCharIntoText();
264
	//EventInsertCharIntoText();
269
}
265
}
Line 270... Line 266...
270
 
266
 
271
void HandleMouseEvent()
267
void HandleMouseEvent()
272
{
268
{
Line 279... Line 275...
279
	if (!scroll.delta2) && (list.MouseOver(mouse.x, mouse.y)) {
275
	if (!scroll.delta2) && (list.MouseOver(mouse.x, mouse.y)) {
280
		if (mouse.key&MOUSE_LEFT) {
276
		if (mouse.key&MOUSE_LEFT) {
Line 281... Line 277...
281
 
277
 
282
			GetKeyModifier();
278
			GetKeyModifier();
283
			if (key_modifier & KEY_LSHIFT) || (key_modifier & KEY_RSHIFT) {
279
			if (key_modifier & KEY_LSHIFT) || (key_modifier & KEY_RSHIFT) {
284
				if (mouse.down) && (!selection.is_active()) selection.set_start();
280
				if (mouse.down) selection.set_start();
285
				list.ProcessMouse(mouse.x, mouse.y);
281
				list.ProcessMouse(mouse.x, mouse.y);
286
				if (mouse.up) selection.set_end();
282
				if (mouse.up) selection.set_end();
287
				DrawPage();
283
				DrawPage();
288
				return;
284
				return;
Line 289... Line 285...
289
			}
285
			}
290
 
286
 
-
 
287
			list.ProcessMouse(mouse.x, mouse.y);
291
			list.ProcessMouse(mouse.x, mouse.y);
288
			if (mouse.down) {
292
			if (mouse.down) {
289
				selection.cancel();
293
				selection.set_start();
290
				selection.set_start();
294
			} 
291
			} 
295
			selection.set_end();
292
			selection.set_end();
Line 384... Line 381...
384
}
381
}
Line 385... Line 382...
385
 
382
 
386
void EventShowReopenMenu()
383
void EventShowReopenMenu()
387
{
384
{
388
	menu_id = REOPEN_IN_APP;
385
	menu_id = REOPEN_IN_APP;
389
	open_lmenu(Form.left+5 + reopenin_mx, Form.top+29+skin_height, 
386
	open_lmenu(Form.left+5 + reopenin_mx + 23, Form.top+29+skin_height, 
390
		MENU_ALIGN_TOP_LEFT, NULL,
387
		MENU_ALIGN_TOP_RIGHT, NULL,
391
		"Tinypad\nTextEdit\nWebView\nFB2Read\nHexView\nOther");
388
		"Tinypad\nTextEdit\nWebView\nFB2Read\nHexView\nOther");
Line 392... Line 389...
392
}
389
}
393
 
390
 
394
void EventShowThemesList()
391
void EventShowThemesList()
395
{
392
{
396
	menu_id = COLOR_SCHEME;
393
	menu_id = COLOR_SCHEME;
397
	open_lmenu(Form.left+2 + theme_mx + 26, 
394
	open_lmenu(Form.left+5 + theme_mx + 23, 
398
		Form.top+29+skin_height, MENU_ALIGN_TOP_RIGHT, 
395
		Form.top+29+skin_height, MENU_ALIGN_TOP_RIGHT, 
Line 399... Line 396...
399
		curcol_scheme+1, #color_scheme_names);
396
		curcol_scheme+1, #color_scheme_names);
Line 644... Line 641...
644
	
641
	
645
	//AddTopBarButton(#EventNewFile,        ECTRL+SCAN_CODE_KEY_N, 2,  x.set(8),         false);
642
	//AddTopBarButton(#EventNewFile,        ECTRL+SCAN_CODE_KEY_N, 2,  x.set(8),         false);
646
	AddTopBarButton(#EventOpenDialog,     ECTRL+SCAN_CODE_KEY_O, 0,  x.set(8), false);
643
	AddTopBarButton(#EventOpenDialog,     ECTRL+SCAN_CODE_KEY_O, 0,  x.set(8), false);
647
	//AddTopBarButton(#EventSave,           ECTRL+SCAN_CODE_KEY_S, 5,  x.inc(SMALL_GAP), false);
644
	//AddTopBarButton(#EventSave,           ECTRL+SCAN_CODE_KEY_S, 5,  x.inc(SMALL_GAP), false);
648
	AddTopBarButton(#EventShowFileInfo,   ECTRL+SCAN_CODE_KEY_I, 10, x.inc(SMALL_GAP), false);
645
	AddTopBarButton(#EventShowFileInfo,   ECTRL+SCAN_CODE_KEY_I, 10, x.inc(SMALL_GAP), false);
649
	AddTopBarButton(#EventMagnifyMinus,   ECTRL+SCAN_CODE_MINUS, 32, x.inc(BIG_GAP),   false);
646
	AddTopBarButton(#EventMagnifyMinus,   ECTRL+SCAN_CODE_MINUS, 33, x.inc(BIG_GAP),   false);
650
	AddTopBarButton(#EventMagnifyPlus,    ECTRL+SCAN_CODE_PLUS,  33, x.inc(SMALL_GAP), false);
647
	AddTopBarButton(#EventMagnifyPlus,    ECTRL+SCAN_CODE_PLUS,  32, x.inc(SMALL_GAP), false);
651
	AddTopBarButton(#EventClickSearch,    ECTRL+SCAN_CODE_KEY_F, 49, x.inc(BIG_GAP),   serha);  search_mx = EAX;
648
	AddTopBarButton(#EventClickSearch,    ECTRL+SCAN_CODE_KEY_F, 49, x.inc(BIG_GAP),   serha);  search_mx = EAX;
652
	x.set(Form.cwidth-4);
649
	x.set(Form.cwidth-4);
653
	AddTopBarButton(#EventShowInfo,       NULL,                  -1, x.inc(-SMALL_GAP), false); burger_mx = EAX;
650
	//AddTopBarButton(#EventShowInfo,       NULL,                  -1, x.inc(-SMALL_GAP), false); burger_mx = EAX;
654
	AddTopBarButton(#EventShowThemesList, NULL,                  40, x.inc(-BIG_GAP), thema); theme_mx = EAX;
651
	AddTopBarButton(#EventShowThemesList, NULL,                  40, x.inc(-SMALL_GAP), thema); theme_mx = EAX;
655
	AddTopBarButton(#EventShowReopenMenu, ECTRL+SCAN_CODE_KEY_E, 16, x.inc(-SMALL_GAP),   reopa); reopenin_mx = EAX;
652
	AddTopBarButton(#EventShowReopenMenu, ECTRL+SCAN_CODE_KEY_E, 16, x.inc(-SMALL_GAP),   reopa); reopenin_mx = EAX;
656
	//AddTopBarButton(#EventOpenSysfuncs,   NULL,                  18, x.inc(-SMALL_GAP), false);
653
	//AddTopBarButton(#EventOpenSysfuncs,   NULL,                  18, x.inc(-SMALL_GAP), false);
657
	//AddTopBarButton(#EventOpenPipet,      NULL,                  39, x.inc(-SMALL_GAP), false);
-
 
658
	DefineHiddenButton(Form.cwidth-70, Form.cheight - STATUSBAR_H + 1,
-
 
659
		60, 12, button.add(#EventShowCharsetsList));
654
	//AddTopBarButton(#EventOpenPipet,      NULL,                  39, x.inc(-SMALL_GAP), false);
Line 660... Line 655...
660
}
655
}
661
 
656
 
662
void DrawStatusBar(dword _in_text)
657
void DrawStatusBar(dword _in_text)
663
{
658
{
664
	static char status_text[64];
659
	static char status_text[64];
665
	if (Form.status_window>2) return;
660
	if (Form.status_window>2) return;
666
	if (_in_text) strncpy(#status_text, _in_text, sizeof(status_text));
661
	if (_in_text) strncpy(#status_text, _in_text, sizeof(status_text));
-
 
662
	DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,1, sc.work_graph);
-
 
663
	DrawBar(0,Form.cheight - STATUSBAR_H+1, Form.cwidth,STATUSBAR_H-1, sc.work);
667
	DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,1, sc.work_graph);
664
	WriteText(5, Form.cheight - STATUSBAR_H + 4, 0x80, sc.work_text, #status_text);
668
	DrawBar(0,Form.cheight - STATUSBAR_H+1, Form.cwidth,STATUSBAR_H-1, sc.work);
665
	if (param[0]) {
669
	WriteTextCenter(Form.cwidth-70, Form.cheight - STATUSBAR_H + 4,
666
		WriteTextCenter(Form.cwidth-70, Form.cheight - STATUSBAR_H + 4,
-
 
667
			60, sc.work_text, real_encoding*10+#charsets);
-
 
668
		DefineHiddenButton(Form.cwidth-70, Form.cheight - STATUSBAR_H + 1,
670
		60, sc.work_text, real_encoding*10+#charsets);
669
			60, 12, BTN_CHANGE_CHARSET+10);
Line 671... Line 670...
671
	WriteText(5, Form.cheight - STATUSBAR_H + 4, 0x80, sc.work_text, #status_text);
670
	}
672
}
671
}
673
 
672