Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
1476 IgorA 1
use32
7575 IgorA 2
  org 0
1476 IgorA 3
  db 'MENUET01' ;идентиф. исполняемого файла всегда 8 байт
7575 IgorA 4
  dd 1, start, i_end, mem, stacktop, file_name, sys_path
1476 IgorA 5
 
6
MAX_COLOR_WORD_LEN equ 40
2819 IgorA 7
BUF_SIZE equ 4096 ;buffer for copy|paste
2086 IgorA 8
CAPT_PATH_WIDTH equ 50 ;ширина подписи перед текстовым полем
1476 IgorA 9
 
10
include '../../macros.inc'
11
include '../../proc32.inc'
7575 IgorA 12
include '../../KOSfuncs.inc'
13
include '../../load_img.inc'
1476 IgorA 14
include '../../develop/libraries/box_lib/trunk/box_lib.mac'
7575 IgorA 15
include '../../system/skincfg/trunk/kglobals.inc'
16
include '../../system/skincfg/trunk/unpacker.inc'
1476 IgorA 17
include 'te_data.inc'
18
include 'te_work.inc' ;text work functions
19
 
4990 IgorA 20
@use_library_mem mem.Alloc,mem.Free,mem.ReAlloc,dll.Load
1476 IgorA 21
 
4990 IgorA 22
icon_tl_sys dd 0 ;указатель на память для хранения системных иконок
23
 
1476 IgorA 24
align 4
25
start:
7575 IgorA 26
	mcall SF_STYLE_SETTINGS,SSF_GET_COLORS,sc,sizeof.system_colors
1476 IgorA 27
 
7575 IgorA 28
	mcall SF_SYS_MISC,SSF_HEAP_INIT
2819 IgorA 29
	or eax,eax
30
	jz button.exit
1476 IgorA 31
 
7575 IgorA 32
	mcall SF_KEYBOARD,SSF_SET_INPUT_MODE,1 ;scan code
33
	mcall SF_SET_EVENTS_MASK,0xC0000027
1476 IgorA 34
 
7575 IgorA 35
	load_libraries l_libs_start,load_lib_end
1476 IgorA 36
 
7575 IgorA 37
	;проверка на сколько удачно загузилась библиотека
38
	cmp dword[lib0+ll_struc_size-4],0
5911 IgorA 39
	jz @f
40
		mcall -1 ;exit not correct
41
	@@:
1476 IgorA 42
 
43
;---------------------------------------------------------------------
7575 IgorA 44
	stdcall [tl_data_init], tree1
1476 IgorA 45
 
4990 IgorA 46
; читаем файл с курсорами и линиями
7575 IgorA 47
	include_image_file '..\..\media\log_el\trunk\tl_sys_16.png', icon_tl_sys
48
	mov eax,[icon_tl_sys]
49
	mov [tree1.data_img_sys],eax
1476 IgorA 50
;---------------------------------------------------------------------
51
; читаем bmp файл с иконками узлов
7575 IgorA 52
	include_image_file '..\t_edit\tl_nod_16.png', icon_tl_sys
53
	mov eax,[icon_tl_sys]
54
	mov [tree1.data_img],eax
1476 IgorA 55
;------------------------------------------------------------------------------
7575 IgorA 56
	copy_path fn_syntax_dir,sys_path,file_name,0 ;берем путь к папке с файлами синтаксиса
57
	mcall SF_FILE,tree_file_struct
1476 IgorA 58
 
7577 IgorA 59
	cmp ebx,0
60
	jle .end_dir_init
61
		mov eax,dir_mem+32+40
7575 IgorA 62
		mov ecx,ebx
63
		@@:
64
			cmp byte[eax],'.' ;фильтруем файлы с именами '.' и '..'
65
			je .filter
66
			stdcall [tl_node_add],tree1,0x10000,eax ;1*2^16 - где 1 номер иконки с книгой
67
			stdcall [tl_cur_next],tree1
68
		.filter:
69
			add eax,304
70
		loop @b
71
		stdcall [tl_cur_beg],tree1 ;ставим курсор на начало списка
72
		or dword[tree1.style], tl_cursor_pos_limited ;ограничиваем движение курсора в пределах списка
73
	.end_dir_init:
1476 IgorA 74
 
7577 IgorA 75
	xor eax,eax
76
	inc eax
77
	mov [scrol_w1.type],eax
78
	mov [scrol_h1.type],eax
79
	mov [ws_dir_lbox.type],eax
80
 
1476 IgorA 81
;--- load color option file ---
82
stdcall [ted_init], tedit0
2086 IgorA 83
mov byte[file_name],0
1476 IgorA 84
 
85
align 4
86
red_win:
2086 IgorA 87
	call draw_window
1476 IgorA 88
 
89
align 4
90
still:
7575 IgorA 91
  mcall SF_WAIT_EVENT
1476 IgorA 92
 
93
  cmp al,1 ;изм. положение окна
94
  jz red_win
95
  cmp al,2
96
  jz key
97
  cmp al,3
98
  jz button
99
  cmp al,6
100
  jz mouse
101
 
102
  jmp still
103
 
104
 
105
align 4
2086 IgorA 106
draw_window:
107
	pushad
7575 IgorA 108
	mcall SF_REDRAW,SSF_BEGIN_DRAW
2086 IgorA 109
 
110
	mov edx,[sc.work]
111
	or  edx,0x33000000
112
	mov edi,hed
7575 IgorA 113
	mcall SF_CREATE_WINDOW,<10,555>,<10,333>
2086 IgorA 114
 
7575 IgorA 115
	mcall SF_THREAD_INFO,procinfo,-1
116
	mov edi,tedit0 ;значение edi нужно для EvSize и ted_wnd_t
117
	call EvSize
2086 IgorA 118
 
119
	mov esi,[sc.work_button];0xd0
7575 IgorA 120
	mcall SF_DEFINE_BUTTON,5*65536+90,195*65536+20,200
2086 IgorA 121
 
122
	mov ebx,100*65536+85
123
	mov ecx,195*65536+20
124
	mov edx,201
125
	mov esi,0xd00000
126
	mcall
127
 
128
	mov ecx,[sc.work_button_text]
129
	or  ecx,0x80000000
7575 IgorA 130
	mcall SF_DRAW_TEXT,10*65536+200,,txt_load_f
2086 IgorA 131
 
132
	mov ecx,0xffff00
133
	or  ecx,0x80000000
7575 IgorA 134
	mcall ,105*65536+200,,txt_save_f
2086 IgorA 135
 
136
	mov ecx,[sc.work_text]
137
	or  ecx,0x80000000
7575 IgorA 138
	mcall ,195*65536+10,,txt_inp_file
2086 IgorA 139
 
140
	add ebx,20
141
	mov edx,txt_out_file
142
	int 0x40
143
 
7577 IgorA 144
	stdcall [PathShow_draw], PathShow_data_1
2125 IgorA 145
 
7577 IgorA 146
	stdcall [edit_box_draw], edit1
147
	stdcall [tl_draw], tree1
2086 IgorA 148
 
149
	;scroll 1
150
	mov [ws_dir_lbox.all_redraw],1
7577 IgorA 151
	stdcall [scrollbar_ver_draw],ws_dir_lbox
2086 IgorA 152
	stdcall [ted_draw], tedit0
153
 
7575 IgorA 154
	mcall SF_REDRAW,SSF_END_DRAW
2086 IgorA 155
	popad
156
	ret
157
 
7575 IgorA 158
MIN_M_WND_H equ 100 ;минимальная высота главного окна
159
;input:
160
; edi = pointer to tedit struct
2086 IgorA 161
align 4
7575 IgorA 162
EvSize:
163
	pushad
164
	mov ebx,ted_scr_h
165
	mov esi,ted_scr_w
166
 
167
	m2m ted_wnd_w,[procinfo.client_box.width] ;ставим ширину окна редактора равной ширине всего окна
168
	mov eax,ted_wnd_l
169
	sub ted_wnd_w,eax ;отнимаем отступ слева
170
	movzx eax,word[esi+sb_offs_size_x]
171
	sub ted_wnd_w,eax ;отнимаем ширину верт. скроллинга
172
 
173
	m2m ted_wnd_h,[procinfo.client_box.height] ;ставим высоту окна редактора равной высоте всего окна
174
	cmp ted_wnd_h,MIN_M_WND_H
175
	jg @f
176
		mov ted_wnd_h,MIN_M_WND_H
177
	@@:
178
 
179
	movzx eax,word[ebx+sb_offs_size_y]
180
	sub ted_wnd_h,eax	      ;отнимаем высоту гориз. скроллинга
181
	mov eax,ted_wnd_t
182
	sub ted_wnd_h,eax	      ;отнимаем отступ сверху
183
 
184
	stdcall [ted_init_scroll_bars], tedit0,2
185
	popad
186
	ret
187
 
188
align 4
1476 IgorA 189
mouse:
190
	stdcall [tl_mouse],tree1
191
	stdcall [edit_box_mouse],edit1
192
	stdcall [ted_mouse], tedit0
193
	jmp still
194
 
2819 IgorA 195
;output:
196
; ah = symbol
197
align 4
198
proc KeyConvertToASCII, table:dword
199
	push ebx
200
	mov ebx,dword[table] ;convert scan to ascii
7579 IgorA 201
	shr ax,8
2819 IgorA 202
	add bx,ax
203
	mov ah,byte[ebx]
204
	pop ebx
205
	ret
206
endp
1476 IgorA 207
 
208
align 4
209
key:
7575 IgorA 210
	mcall SF_KEYBOARD,SSF_GET_CONTROL_KEYS ;66.3 получить состояние управляющих клавиш
2819 IgorA 211
	xor esi,esi
212
	mov ecx,1
7575 IgorA 213
	test al,3 ;[Shift]
2819 IgorA 214
	jz @f
215
		mov cl,2
216
		or esi,KM_SHIFT
217
	@@:
218
	test al,0x0c ;[Ctrl]
219
	jz @f
220
		or esi,KM_CTRL
221
	@@:
222
	test al,0x30 ;[Alt]
223
	jz @f
224
		mov cl,3
225
		or esi,KM_ALT
226
	@@:
227
	test al,0x80 ;[NumLock]
228
	jz @f
229
		or esi,KM_NUMLOCK
230
	@@:
231
 
7575 IgorA 232
	mcall SF_SYSTEM_GET,SSF_KEYBOARD_LAYOUT,,conv_tabl ;26.2 получить раскладку клавиатуры
233
	mcall SF_GET_KEY
1476 IgorA 234
	stdcall [tl_key],tree1
2819 IgorA 235
 
236
	test word [edit1.flags],10b;ed_focus ; если не в фокусе, выходим
237
	je @f
238
		cmp ah,0x80 ;if key up
239
		ja still
240
		cmp ah,42 ;[Shift] (left)
241
		je still
242
		cmp ah,54 ;[Shift] (right)
243
		je still
244
		cmp ah,56 ;[Alt]
245
		je still
246
		cmp ah,29 ;[Ctrl]
247
		je still
248
		cmp ah,69 ;[Pause Break]
249
		je still
250
 
7575 IgorA 251
		stdcall KeyConvertToASCII, conv_tabl
2819 IgorA 252
		stdcall [edit_box_key],edit1
253
		jmp still
254
	@@:
255
 
256
	stdcall [ted_key], tedit0, conv_tabl,esi
1476 IgorA 257
	jmp still
258
 
259
align 4
260
button:
7575 IgorA 261
	mcall SF_GET_BUTTON
1476 IgorA 262
 
7575 IgorA 263
	cmp ah,200
264
	jne @f
265
		call but_OpenSyntax
266
	@@:
267
	cmp ah,201
268
	jne @f
269
		call but_SaveSyntax
270
	@@:
1476 IgorA 271
 
7575 IgorA 272
	cmp ah,1
273
	jne still
1476 IgorA 274
.exit:
7575 IgorA 275
	stdcall mem.Free,[options_file]
276
	stdcall mem.Free,[unpac_mem]
1476 IgorA 277
 
7575 IgorA 278
	stdcall [tl_data_clear], tree1
279
	stdcall [ted_delete], tedit0
280
	mcall SF_TERMINATE_PROCESS ;выход из программы
1476 IgorA 281
 
282
align 4
283
but_OpenSyntax:
5911 IgorA 284
push eax
285
	stdcall [tl_node_get_data],tree1
286
	mov [fn_col_option],eax
287
	call InitColText
288
pop eax
289
	ret
1476 IgorA 290
 
291
align 4
292
but_SaveSyntax:
4990 IgorA 293
	stdcall [ted_save_file], tedit0,run_file_70,[edit1.text]
1476 IgorA 294
	ret
295
 
7579 IgorA 296
;description:
297
; функция вызываемую при нажатии Ctrl+N,O,F,S,H,G
1476 IgorA 298
align 4
7579 IgorA 299
proc ted_but_ctrl_all uses eax, opt_key:dword
300
	mov eax,[opt_key]
301
	cmp al,'N' ;Ctrl+N
302
	jne @f
303
		call but_ctrl_n
304
		jmp .end0
305
	@@:
306
	cmp al,'O' ;Ctrl+O
307
	jne @f
308
		call but_ctrl_o
309
	@@:
310
	;cmp al,'S' ;Ctrl+S
311
	;cmp al,'F' ;Ctrl+F
312
	;cmp al,'G' ;Ctrl+G
313
	;cmp al,'H' ;Ctrl+H
314
	.end0:
315
	ret
316
endp
317
 
318
align 4
1476 IgorA 319
but_ctrl_o:
320
	push eax
321
	call get_wnd_in_focus
322
	cmp eax,0
323
	je @f
324
		stdcall [ted_open_file], eax,str_file_70,[edit1.text]
325
	@@:
326
	pop eax
327
	ret
328
 
329
;создание нового файла
330
align 4
331
but_ctrl_n:
332
	push eax
333
	call get_wnd_in_focus
334
	cmp eax,0
335
	je @f
336
		stdcall [ted_clear], eax,1
337
		stdcall [ted_draw], eax
338
	@@:
339
	pop eax
340
	ret
341
 
342
;определяем какое из окон редактора в фокусе
343
align 4
344
get_wnd_in_focus:
345
	xor eax,eax
346
	cmp dword[el_focus],tedit0
347
	jne @f
348
		mov eax,tedit0
349
	@@:
350
	;cmp dword[el_focus],tedit1
351
	;jne @f
352
	;       mov eax,tedit1
353
	;@@:
354
	ret
355
 
7579 IgorA 356
hed db 'TextEditor syntax file converter 29.01.19',0 ;подпись окна
2819 IgorA 357
conv_tabl rb 128 ; таблица для конвертирования scan-кода в ascii-код
1476 IgorA 358
 
7575 IgorA 359
txt_load_f db 'Загр. файл',0
360
txt_save_f db 'Сохр. файл',0
2086 IgorA 361
txt_inp_file db 'Исх. файл:',0
1476 IgorA 362
txt_out_file db 'Вых. файл:',0
363
 
4990 IgorA 364
head_f_i:
7577 IgorA 365
head_f_l db '"System error',0
366
err_message_found_lib_0 db 'Sorry I cannot found library ',39,'box_lib.obj',39,'" -tE',0
367
err_message_import_0 db 'Error on load import library ',39,'box_lib.obj',39,'" -tW',0
368
err_message_found_lib_1 db 'Sorry I cannot found library ',39,'libimg.obj',39,'" -tE',0
369
err_message_import_1 db 'Error on load import library ',39,'libimg.obj',39,'" -tW',0
4990 IgorA 370
 
1476 IgorA 371
;library structures
372
l_libs_start:
4990 IgorA 373
	lib0 l_libs lib_name_0, sys_path, file_name, system_dir_0, err_message_found_lib_0, head_f_l, import_box_lib,err_message_import_0, head_f_i
374
	lib1 l_libs lib_name_1, sys_path, file_name, system_dir_1, err_message_found_lib_1, head_f_l, import_libimg,err_message_import_1, head_f_i
1476 IgorA 375
load_lib_end:
376
 
7575 IgorA 377
IncludeIGlobals
1476 IgorA 378
 
5911 IgorA 379
align 16
1476 IgorA 380
i_end:
7575 IgorA 381
IncludeUGlobals
1476 IgorA 382
	procinfo process_information
5911 IgorA 383
		rb 1024
1476 IgorA 384
	thread:
385
		rb 1024
386
stacktop:
387
  sys_path:
388
    rb 4096
389
  file_name:
390
    rb 4096
391
  file_name_rez:
392
    rb 4096
393
mem: