Subversion Repositories Kolibri OS

Rev

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