Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
1457 IgorA 1
struct symbol
2125 IgorA 2
	c db ?    ; +0 символ
3
	col db ?  ; +1 цвет
4
	perv dd ? ; +2
5
	next dd ? ; +6 указатели
6
	tc dd ?   ;+10 врем. создания
7
	td dd ?   ;+14 врем. удаления
1457 IgorA 8
ends
9
 
10
bmp_icon dd 0
11
 
12
 
13
;input:
14
; al = код ошибки
1456 IgorA 15
align 4
1457 IgorA 16
ted_on_init_synt_err:
2855 IgorA 17
	mov byte[msgbox_3.err],'0'
18
	add byte[msgbox_3.err],al
1457 IgorA 19
	stdcall [mb_create],msgbox_3,thread ;message: Can-t open color options file!
20
	ret
21
 
22
 
23
align 4
24
ted_but_new_file:
4991 IgorA 25
	push eax ebx
26
	stdcall [ted_can_save], tedit0
27
	cmp al,1
28
	jne @f
29
		stdcall [mb_create],msgbox_2,thread ;message: save changes in file?
30
		stdcall [mb_setfunctions],msgbox_2N_funct
31
		jmp .ret_f
32
	@@:
33
	call On_NewFile
34
	.ret_f:
5643 leency 35
		mov byte[openfile_path],0
6086 IgorA 36
		mcall SF_SET_CAPTION,1,hed
4991 IgorA 37
	pop ebx eax
38
	ret
1338 IgorA 39
 
1456 IgorA 40
align 4
1338 IgorA 41
On_NewFile:
4991 IgorA 42
	stdcall [ted_clear], tedit0,1
43
	call draw_but_toolbar
44
	stdcall [ted_draw], tedit0
7570 IgorA 45
	mov dword[openfile_path],0
4991 IgorA 46
	ret
1338 IgorA 47
 
1456 IgorA 48
align 4
1338 IgorA 49
On_SaveAndNewFile:
4991 IgorA 50
	push edi
51
	mov edi, tedit0
1456 IgorA 52
 
4991 IgorA 53
	call ted_but_save_file
54
	cmp ted_err_save,0
55
	jne @f
56
		call On_NewFile
57
	@@:
58
	pop edi
59
	ret
1338 IgorA 60
 
4991 IgorA 61
align 4
62
On_SaveAndOpenFile:
63
	push edi
64
	mov edi, tedit0
65
 
66
	call ted_but_save_file
67
	cmp ted_err_save,0
68
	jne @f
69
		call ted_but_open_file.no_msg
70
	@@:
71
	pop edi
72
	ret
73
 
74
align 4
75
On_SaveAndExit:
76
	push edi
77
	mov edi, tedit0
78
 
79
	call ted_but_save_file
80
	cmp ted_err_save,0
81
	jne @f
82
		mov dword[exit_code],1
83
	@@:
84
	pop edi
85
	ret
86
 
87
align 4
88
On_Exit:
89
	mov dword[exit_code],1
90
	ret
91
 
1457 IgorA 92
;description:
2102 IgorA 93
; функция открытия файла без окна сообщения
1456 IgorA 94
align 4
7570 IgorA 95
proc but_no_msg_OpenFile uses eax ebx esi
4308 IgorA 96
	stdcall [ted_open_file], tedit0,run_file_70,openfile_path
1457 IgorA 97
	call ted_messages_after_open_file
7570 IgorA 98
 
99
	mov esi,openfile_path
100
	call strlen
101
	add esi,eax
102
	@@: ;цикл для поиска начала имени файла
103
		dec esi
104
		cmp byte[esi],'/'
105
		je @f
106
		cmp byte[esi],0x5c ;'\'
107
		je @f
108
		cmp esi,openfile_path
109
		jg @b
110
	@@:
111
	inc esi
112
	call strlen
113
	cmp eax,255
114
	jle @f
115
		mov eax,255
116
	@@:
117
	inc eax ;для 0 в конце строки
118
	stdcall mem_cpy, filename_area,esi,eax ;копируем имя файла в диалог сохранения
1457 IgorA 119
	ret
7570 IgorA 120
endp
1456 IgorA 121
 
1457 IgorA 122
;description:
123
; функция открытия файла с возможным окном сообщения (о возможности отменить открытие)
1456 IgorA 124
align 4
1457 IgorA 125
ted_but_open_file:
1467 IgorA 126
	pushad
127
 
1457 IgorA 128
	stdcall [ted_can_save], tedit0
129
	cmp al,1
130
	jne @f
4991 IgorA 131
		stdcall [mb_create],msgbox_2,thread ;message: save changes in file?
132
		stdcall [mb_setfunctions],msgbox_2O_funct
1457 IgorA 133
		jmp .ret_f
3366 IgorA 134
	.no_msg: ;метка для вызова функции через кнопку в сообщении msgbox_5
135
		pushad
1457 IgorA 136
	@@:
1467 IgorA 137
 
1468 IgorA 138
	copy_path open_dialog_name,communication_area_default_path,file_name,0
1467 IgorA 139
	mov [OpenDialog_data.type],0
1592 IgorA 140
	stdcall [OpenDialog_Start],OpenDialog_data
1467 IgorA 141
	cmp [OpenDialog_data.status],2
142
	jne @f
1468 IgorA 143
		stdcall mem_spac, msgbox_9.fdp,100
144
		mov esi,file_name
145
		call strlen
146
		cmp eax,100
147
		jle .no_crop
148
			mov eax,100
149
		.no_crop:
7570 IgorA 150
		stdcall mem_cpy, msgbox_9.fdp,esi,eax
1467 IgorA 151
		stdcall [mb_create],msgbox_9,thread ;message: error run 'open file dialog'
152
		jmp .ret_f
153
	@@:
2817 IgorA 154
	cmp [OpenDialog_data.status],1
2632 IgorA 155
	jne .ret_f
6086 IgorA 156
		stdcall auto_open_syntax,[OpenDialog_data.openfile_path]
4308 IgorA 157
		stdcall [ted_open_file], tedit0,run_file_70,openfile_path
2817 IgorA 158
		call ted_messages_after_open_file
1457 IgorA 159
	.ret_f:
1467 IgorA 160
	popad
1457 IgorA 161
	ret
1338 IgorA 162
 
6086 IgorA 163
proc auto_open_syntax, of_path:dword
164
pushad
165
	;ищем есть ли файл подсветки для открываемого текстового файла
166
	mov esi,[of_path]
167
	call strlen
168
	mov edx,[of_path]
169
	add edx,eax
170
	.f_beg:
171
	cmp byte[edx],'.'
172
	je .found
173
		dec edx
174
		cmp edx,[of_path]
175
		jg .f_beg
176
	.found:
177
	inc edx ;edx - указатель на расширение открытого файла
178
 
179
	mov ebx,synt_auto_open
180
	.cycle_0:
181
		add ebx,32
182
		stdcall strcmp,ebx,edx ;сравниваем расширение открытого файла со значениями открытыми с ini файла
183
		test eax,eax
184
		jz .ok
185
		add ebx,32
186
		cmp byte[ebx],0
187
		jne .cycle_0
188
	jmp .end_0
189
	.ok: ;открытие файла подсветки в зависимости от найденного расширения
190
		sub ebx,32
191
		stdcall open_unpac_synt_file,ebx
192
	.end_0:
193
popad
194
	ret
195
endp
196
 
7571 IgorA 197
;input:
198
; eax если равен: 0 - сохранение без диалога, 1 - сохранение с диалогом
2102 IgorA 199
;description:
7570 IgorA 200
; функция сохранения файла
4308 IgorA 201
align 4
202
proc ted_but_save_file
7571 IgorA 203
	or eax,eax
204
	jnz .init_dlg
205
		; сохраняем без вызова диалогового окна
206
		cmp byte[openfile_path],0
207
		jne @f
7570 IgorA 208
	.init_dlg:
7571 IgorA 209
		; вызов диалогового окна для сохранения файла
210
		copy_path open_dialog_name,communication_area_default_path,file_name,0
211
		mov [OpenDialog_data.type],1
212
		stdcall [OpenDialog_Start],OpenDialog_data
213
		cmp [OpenDialog_data.status],1 ;if status==1 then save
214
		jne .end_save
7570 IgorA 215
	@@:
5918 IgorA 216
		stdcall [ted_save_file],tedit0,run_file_70,openfile_path
7570 IgorA 217
	.end_save:
4308 IgorA 218
	ret
219
endp
220
 
221
;description:
2102 IgorA 222
; копирование памяти
1468 IgorA 223
align 4
7570 IgorA 224
proc mem_cpy uses ecx esi edi, destination:dword, source:dword, len:dword
5918 IgorA 225
	cld
7571 IgorA 226
	mov esi,[source]
227
	mov edi,[destination]
228
	mov ecx,[len]
5918 IgorA 229
	rep movsb
230
	ret
1468 IgorA 231
endp
232
 
2102 IgorA 233
;description:
234
; заполнение памяти пробелами
1468 IgorA 235
align 4
5918 IgorA 236
proc mem_spac uses eax ecx edi, mem:dword, len:dword
237
	cld
238
	mov al,' '
7571 IgorA 239
	mov edi,[mem]
240
	mov ecx,[len]
5918 IgorA 241
	repne stosb
242
	ret
1468 IgorA 243
endp
244
 
1457 IgorA 245
;input:
246
; eax = код ошибки
247
; ebx = колличество прочитанных байт
1456 IgorA 248
align 4
1457 IgorA 249
ted_messages_after_open_file:
2847 IgorA 250
	push ecx edi
1457 IgorA 251
	cmp eax,0
252
	je @f
253
	cmp eax,6
254
	je @f
255
		cmp ax,10
256
		jl .zifra_0_9
257
			mov al,'?'
258
			sub ax,48
259
		.zifra_0_9:
260
		add ax,48
1456 IgorA 261
 
1457 IgorA 262
		mov byte[msgbox_4.err],al
263
		stdcall [mb_create],msgbox_4,thread ;message: Can-t open text file!
264
		jmp .ret_f
265
	@@:
266
	cmp ebx,-1
267
	je .ret_f
268
		;if open file
2847 IgorA 269
		mov edi,tedit0
1457 IgorA 270
		mov ecx,ted_max_chars
271
		sub ecx,2 ;ecx = максимальное число байт, для которых была выделена память
272
		cmp ebx,ecx
273
		jl .ret_f
274
			stdcall [mb_create],msgbox_1,thread
275
	.ret_f:
2847 IgorA 276
	pop edi ecx
1457 IgorA 277
	ret
1338 IgorA 278
 
1456 IgorA 279
align 4
1457 IgorA 280
ted_save_err_msg:
281
	mov byte[msgbox_6.err],al
282
	stdcall [mb_create],msgbox_6,thread ;message: Can-t save text file!
283
	ret
1456 IgorA 284
 
2102 IgorA 285
;description:
286
; функция нажатия на кнопку [Применить] в панели синтаксиса
1456 IgorA 287
align 4
2707 IgorA 288
proc ted_but_open_syntax uses eax ebx ecx edi, edit:dword
289
	mov edi,dword[edit]
290
	cmp ted_panel_id,TED_PANEL_SYNTAX
291
	jne @f
292
		stdcall dword[tl_node_get_data], tree1
5911 IgorA 293
		mov [fn_col_option],eax
6086 IgorA 294
		stdcall open_unpac_synt_file,eax
2708 IgorA 295
		cmp ebx,-1
296
		je @f
297
 
2707 IgorA 298
		call [ted_text_colored]
299
		stdcall [ted_draw],edi
300
	@@:
301
	ret
1456 IgorA 302
endp
1338 IgorA 303
 
2708 IgorA 304
;открытие и распаковка файла подсветки синтаксиса
2855 IgorA 305
;input:
6086 IgorA 306
; f_name - указатель на имя открываемого файла синтаксиса (без пути и папки info)
2708 IgorA 307
;output:
308
; ebx - число прочитанных байт из файла
2855 IgorA 309
; ecx - разрушается
2708 IgorA 310
align 4
6086 IgorA 311
proc open_unpac_synt_file uses eax edi esi, f_name:dword
312
	mov ebx,[f_name]
2855 IgorA 313
	mov edi,last_open_synt_file
314
	stdcall strcmp,ebx,edi ;сравниваем имя подключенного файла с подключенным ранее файлом
315
	test eax,eax
316
	jz @f
317
 
318
	;копируем имя подключенного файла (для избежания повторных подключений)
319
	mov esi,ebx
6086 IgorA 320
	mov ecx,32/4
2855 IgorA 321
	cld
6086 IgorA 322
	rep movsd
2855 IgorA 323
 
4308 IgorA 324
	copy_path ebx,fn_syntax_dir,syntax_path,0
325
	copy_path syntax_path,sys_path,file_name,0
2708 IgorA 326
	mov edi, tedit0
6086 IgorA 327
	mov [run_file_70.Function], SSF_READ_FILE
2708 IgorA 328
	mov [run_file_70.Position], 0
329
	mov [run_file_70.Flags], 0
330
	mov ecx, ted_syntax_file_size
331
	mov dword[run_file_70.Count], ecx
332
	m2m dword[run_file_70.Buffer], ted_syntax_file
333
	mov byte[run_file_70+20], 0
334
	mov [run_file_70.FileName], file_name
6086 IgorA 335
	mcall SF_FILE, run_file_70
2708 IgorA 336
	cmp ebx,-1
337
	jne .end_0
338
		call ted_on_init_synt_err
339
		jmp @f
340
	.end_0:
341
		mov eax,ted_syntax_file
342
		cmp dword[eax],'KPCK'
343
		jne .end_unpack
344
		cmp dword[eax+4],ecx
345
		jg @f ;если для распакованого файла не хватает выделенной памяти
346
		cmp dword[unpac_mem],0
347
		jne .end_1
348
			;выделение памяти для распаковки файла
349
			stdcall mem.Alloc,ecx
350
			mov [unpac_mem],eax
351
		.end_1:
352
		stdcall unpack,ted_syntax_file,[unpac_mem]
353
		mov edi,ted_syntax_file
354
		mov esi,[unpac_mem]
355
		mov ecx,[edi+4]
356
		cld
357
		rep movsb
358
		.end_unpack:
359
		stdcall [ted_init_syntax_file], tedit0
360
	@@:
361
	ret
6086 IgorA 362
endp
2708 IgorA 363
 
2102 IgorA 364
;description:
365
; вызов/скрытие панели поиска
1456 IgorA 366
align 4
4308 IgorA 367
proc ted_but_find uses edi
368
	mov edi,tedit0
1456 IgorA 369
 
4308 IgorA 370
	cmp ted_panel_id,TED_PANEL_NULL
371
	je @f
372
		mov ted_panel_id,TED_PANEL_NULL
373
		mov ted_wnd_l,0
374
		jmp .e_if
375
	@@:
376
		mov ted_panel_id,TED_PANEL_FIND
377
		mov ted_wnd_l,TED_PANEL_WIDTH
378
	.e_if:
379
	call EvSize
380
	stdcall [ted_draw],edi
381
	ret
1449 IgorA 382
endp
1338 IgorA 383
 
1456 IgorA 384
align 4
4308 IgorA 385
tbl_1251_866:
386
rb 128
387
db   0,  0,  0,  0,  0,  0,  0,  0,  0,0,0,0,0,0,0,0 ;128
388
db   0,  0,  0,  0,  0,  0,  0,  0,  0,0,0,0,0,0,0,0 ;144
389
db   0,  0,  0,  0,  0,  0,  0,  0,240,0,0,0,0,0,0,0 ;160
390
db   0,  0,  0,  0,  0,  0,  0,  0,241,0,0,0,0,0,0,0 ;176
391
db 128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143 ;192
392
db 144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159 ;208
393
db 160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175 ;224
394
db 224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239 ;240
395
 
396
align 4
397
tbl_866_1251:
398
rb 128
399
db 192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207 ;128
400
db 208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223 ;144
401
db 224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239 ;160
402
db   0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ;176
403
db   0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ;192
404
db   0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ;208
405
db 240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255 ;224
406
db 168,184,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ;240
407
 
408
align 4
1457 IgorA 409
ted_on_find_err:
410
	stdcall [mb_create],msgbox_7,thread ;message: Can not find text
411
	ret
412
 
2102 IgorA 413
;description:
414
; кнопка [Заменить] на панели
1457 IgorA 415
align 4
1338 IgorA 416
but_replace:
2102 IgorA 417
	; пока не сделано
418
	ret
1338 IgorA 419
 
2102 IgorA 420
;description:
421
; функция поиска информации в списке ключевых слов
1456 IgorA 422
align 4
1338 IgorA 423
but_find_key_w:
7035 IgorA 424
	cmp dword[wnd_k_words_run],0
3244 IgorA 425
	jne @f
426
		pushad
6086 IgorA 427
		mcall SF_CREATE_THREAD,1,prop_start,thread_coords
7035 IgorA 428
		mov dword[wnd_k_words_run],eax
3244 IgorA 429
		popad
430
	@@:
2102 IgorA 431
	ret
1338 IgorA 432
 
2102 IgorA 433
;description:
434
; выделение/скрытие непечатаемых символов
1456 IgorA 435
align 4
6239 IgorA 436
proc but_sumb_invis uses edi, edit:dword
437
	mov edi,dword[edit]
1338 IgorA 438
 
6239 IgorA 439
	xor ted_mode_invis,1
440
	call draw_but_toolbar
441
	stdcall [ted_draw],edi
442
	ret
1456 IgorA 443
endp
1338 IgorA 444
 
2102 IgorA 445
;description:
446
; выделение/скрытие ключевых слов
1456 IgorA 447
align 4
6239 IgorA 448
proc but_k_words_show uses edi, edit:dword
449
	mov edi,dword[edit]
1338 IgorA 450
 
6239 IgorA 451
	xor ted_mode_color,1
452
	cmp ted_mode_color,0
453
	je @f
454
		call [ted_text_colored]
455
	@@:
456
	call draw_but_toolbar
457
	stdcall [ted_draw],edi
458
	ret
1456 IgorA 459
endp
1338 IgorA 460
 
2102 IgorA 461
;description:
462
; вызов/скрытие панели с файлами синтаксиса
1456 IgorA 463
align 4
6239 IgorA 464
proc but_synt_show uses edi, edit:dword
465
	mov edi,[edit]
1449 IgorA 466
 
6239 IgorA 467
	cmp ted_panel_id,TED_PANEL_NULL
468
	je @f
469
		mov ted_panel_id,TED_PANEL_NULL
470
		mov ted_wnd_l,0
471
		jmp .e_if
472
	@@:
473
		mov ted_panel_id,TED_PANEL_SYNTAX
474
		mov ted_wnd_l,TED_PANEL_WIDTH
475
	.e_if:
476
	call EvSize
477
	stdcall [ted_draw],edi
478
	ret
1449 IgorA 479
endp