Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
1449 IgorA 1
;Огромная благодарность Maxxxx32, Diamond, Heavyiron
2
;и другим программистам, а также
3
;Теплову Алексею ( www.lrz.land.ru)
1338 IgorA 4
 
5
 
6
use32
7
  org 0x0
1449 IgorA 8
  db 'MENUET01' ;идентиф. исполняемого файла всегда 8 байт
1338 IgorA 9
  dd 0x01
10
  dd start
1449 IgorA 11
  dd i_end ; размер приложения
1338 IgorA 12
  dd mem
13
  dd stacktop
1449 IgorA 14
  dd file_name ; command line
1338 IgorA 15
  dd sys_path
16
 
17
MAX_COLOR_WORD_LEN equ 40
18
maxChars equ 100002 ;(...+2)
1457 IgorA 19
BUF_SIZE equ 1000 ;buffer for copy|paste
20
maxSyntaxFileSize equ 410000
1338 IgorA 21
 
1449 IgorA 22
include '../../proc32.inc'
1338 IgorA 23
include '../../macros.inc'
1489 IgorA 24
include 'mem.inc'
2632 IgorA 25
include 'dll.inc'
1390 IgorA 26
include '../../develop/libraries/box_lib/load_lib.mac'
1449 IgorA 27
include '../../develop/libraries/box_lib/trunk/box_lib.mac'
1343 IgorA 28
include 'lang.inc'
1467 IgorA 29
 
1338 IgorA 30
include 't_data.inc'
31
include 'strlen.inc'
32
include 't_draw.inc' ;draw main window functions
1457 IgorA 33
include 't_button.inc' ;text work functions
1338 IgorA 34
 
2632 IgorA 35
@use_library_mem mem.Alloc,mem.Free,mem.ReAlloc,dll.Load
1338 IgorA 36
 
2632 IgorA 37
 
38
;Макрос для загрузки изображений с использованием библиотеки libimg.obj
39
;для использования макроса нужны переменные:
40
; - run_file_70 FileInfoBlock
41
; - image_data dd 0
42
macro load_image_file path,buf,size
43
{
44
	;path - может быть переменной или строковым параметром
45
	if path eqtype '' ;проверяем задан ли строкой параметр path
46
		jmp @f
47
			local .path_str
48
			.path_str db path ;формируем локальную переменную
49
			db 0
50
		@@:
51
		;32 - стандартный адрес по которому должен быть буфер с системным путем
52
		copy_path .path_str,[32],file_name,0x0
53
	else
54
		copy_path path,[32],file_name,0x0 ;формируем полный путь к файлу изображения, подразумеваем что он в одной папке с программой
55
	end if
56
 
57
	stdcall mem.Alloc, dword size ;выделяем память для изображения
58
	mov [buf],eax
59
 
60
	mov eax,70 ;70-я функция работа с файлами
61
	mov [run_file_70.Function], 0
62
	mov [run_file_70.Position], 0
63
	mov [run_file_70.Flags], 0
64
	mov [run_file_70.Count], dword size
65
	m2m [run_file_70.Buffer], [buf]
66
	mov byte[run_file_70+20], 0
67
	mov [run_file_70.FileName], file_name
68
	mov ebx,run_file_70
69
	int 0x40 ;загружаем файл изображения
70
	cmp ebx,0xffffffff
71
	je @f
72
		;определяем вид изображения и переводим его во временный буфер image_data
73
		stdcall dword[img_decode], dword[buf],ebx,0
74
		mov dword[image_data],eax
75
		;преобразуем изображение к формату rgb
76
		stdcall dword[img_to_rgb2], dword[image_data],dword[buf]
77
		;удаляем временный буфер image_data
78
		stdcall dword[img_destroy], dword[image_data]
79
	@@:
80
}
81
 
82
image_data dd 0 ;указатель на временную память. для нужен преобразования изображения
83
icon_tl_sys dd 0 ;указатель на память для хранения системных иконок
84
 
1456 IgorA 85
align 4
1338 IgorA 86
start:
1456 IgorA 87
  mcall 48,3,sc,sizeof.system_colors
1338 IgorA 88
 
89
  mcall 68,11
90
  or eax,eax
91
  jz button.exit
92
 
93
  mcall 66,1,1 ;scan code
94
  ;mcall 26,2,1,conv_tabl
1456 IgorA 95
  mcall 40,0x27
1338 IgorA 96
 
1456 IgorA 97
  mov esi,file_name
98
  call strlen
99
  mov ecx,eax
1467 IgorA 100
  mov edi,openfile_path
2632 IgorA 101
  cld
1456 IgorA 102
  rep movsb ;копируем имя файла в буфер edit1
1338 IgorA 103
 
1456 IgorA 104
load_libraries l_libs_start,load_lib_end
1338 IgorA 105
 
2102 IgorA 106
;проверка на сколько удачно загузились библиотеки
1456 IgorA 107
	mov	ebp,lib0
108
	cmp	dword [ebp+ll_struc_size-4],0
109
	jz	@f
110
	mcall -1 ;exit not correct
111
@@:
112
	mov	ebp,lib1 ;
113
	cmp	dword [ebp+ll_struc_size-4],0
114
	jz	@f
115
	mcall -1 ;exit not correct
116
@@:
1338 IgorA 117
 
2102 IgorA 118
	cmp dword[version_text_edit],3
119
	jge @f
120
		stdcall [mb_create],msgbox_10,thread
121
		mcall -1
122
	@@:
123
 
1456 IgorA 124
;---------------------------------------------------------------------
1592 IgorA 125
	stdcall [ted_init], tedit0
126
	stdcall dword[tl_data_init], tree1
1338 IgorA 127
 
1467 IgorA 128
; OpenDialog initialisation
1592 IgorA 129
	stdcall [OpenDialog_Init],OpenDialog_data
1467 IgorA 130
 
2632 IgorA 131
; init toolbar file
132
	load_image_file 'te_icon.png', bmp_icon,1200*18
1338 IgorA 133
;---------------------------------------------------------------------
2632 IgorA 134
; читаем файл с курсорами и линиями
135
	load_image_file 'tl_sys_16.png', icon_tl_sys,54+3*256*13
136
	mov eax,dword[icon_tl_sys]
137
	mov dword[tree1.data_img_sys],eax
1338 IgorA 138
;---------------------------------------------------------------------
2632 IgorA 139
; читаем файл с иконками узлов
140
	load_image_file 'tl_nod_16.png', icon_tl_sys,54+3*256*2
141
	mov eax,dword[icon_tl_sys]
142
	mov dword[tree1.data_img],eax
1338 IgorA 143
;------------------------------------------------------------------------------
1449 IgorA 144
  copy_path fn_syntax_dir,sys_path,file_name,0x0 ;берем путь к папке с файлами синтаксиса
1338 IgorA 145
  mov eax,70
146
  mov ebx,tree_file_struct
147
  int 0x40
148
 
149
cmp ebx,-1
150
je .end_dir_init
151
 
152
  mov eax,dir_mem
153
  add eax,32+4+1+3+4*6+8
154
mov ecx,ebx
155
@@:
1449 IgorA 156
  cmp byte[eax],'.' ;фильтруем файлы с именами '.' и '..'
1338 IgorA 157
  je .filter
1456 IgorA 158
    ;0x10000 ;1*2^16 - где 1 номер иконки с книгой
159
    stdcall dword[tl_node_add], eax,0x10000, tree1
1338 IgorA 160
 
1456 IgorA 161
    stdcall dword[tl_cur_next], tree1
1338 IgorA 162
  .filter:
163
  add eax,304
164
  loop @b
2102 IgorA 165
  stdcall dword[tl_cur_beg],tree1 ;ставим курсор на начало списка
1338 IgorA 166
.end_dir_init:
167
 
168
;--- load color option file ---
1457 IgorA 169
	mov ebx,dword[fn_col_option]
170
	copy_path ebx,fn_syntax_dir,file_name_rez,0x0
171
	copy_path file_name_rez,sys_path,file_name,0x0
172
	stdcall [ted_init_syntax_file], tedit0,run_file_70,file_name
1338 IgorA 173
 
174
;--- get cmd line ---
1467 IgorA 175
  cmp byte[openfile_path+3],0 ;openfile_path
1338 IgorA 176
  je @f ;if file names exist
1467 IgorA 177
    mov esi,openfile_path
1338 IgorA 178
    call strlen ;eax=strlen
179
    mov [edit1.size],eax
1456 IgorA 180
    call but_no_msg_OpenFile
1338 IgorA 181
  @@:
182
 
1456 IgorA 183
align 4
1338 IgorA 184
red_win:
1467 IgorA 185
  call draw_window
186
 
187
align 4
188
still:
2125 IgorA 189
	mcall 10
1467 IgorA 190
 
2125 IgorA 191
	cmp al,1 ;изменилось положение окна
192
	jz red_win
193
	cmp al,2
194
	jz key
195
	cmp al,3
196
	jz button
197
	cmp al,6 ;мышь
198
	jne @f
199
		mcall 9,procinfo,-1
200
		cmp ax,word[procinfo+4]
201
		jne @f ;окно не активно
202
		jmp mouse
203
	@@:
204
	jmp still
1467 IgorA 205
 
206
align 4
207
draw_window:
2125 IgorA 208
	mcall 12,1
1338 IgorA 209
 
2125 IgorA 210
	mov edx,[sc.work]
211
	or  edx,0x73000000
212
	mov edi,hed
213
	mcall 0,(10 shl 16)+485,(10 shl 16)+320
1338 IgorA 214
 
2125 IgorA 215
	mcall 9,procinfo,-1
216
	mov edi,tedit0 ;значение edi нужно для EvSize и ted_wnd_t
217
	call EvSize
1449 IgorA 218
 
2125 IgorA 219
	mov eax,13 ;верхний прямоугольник, для очистки верхней панели
220
	xor ebx,ebx
221
	mov ecx,ted_wnd_t
222
	mov bx,word[procinfo.client_box.width]
223
	inc bx
224
	int 0x40
1338 IgorA 225
 
1467 IgorA 226
	mov eax,4
227
	mov ebx,185*65536+9
228
	mov ecx,[sc.work_text]
229
	or  ecx,0x80000000
230
	mov edx,txtFile
231
	int 0x40
232
 
1449 IgorA 233
  stdcall [edit_box_draw], dword edit1
234
  stdcall [menu_bar_draw], dword menu_data_1
1338 IgorA 235
 
236
  call draw_but_toolbar
237
 
2632 IgorA 238
  stdcall [ted_draw], tedit0
1338 IgorA 239
 
1343 IgorA 240
  mcall 12,2
1467 IgorA 241
  ret
1338 IgorA 242
 
1456 IgorA 243
align 4
1338 IgorA 244
mouse:
2125 IgorA 245
	stdcall [edit_box_mouse], dword edit1
1338 IgorA 246
 
2125 IgorA 247
	test word [edit1.flags],10b ;ed_focus ;если не в фокусе, выходим
248
	jne still
1338 IgorA 249
 
2125 IgorA 250
	stdcall [ted_mouse], tedit0
1338 IgorA 251
 
2125 IgorA 252
	cmp byte[tedit0.panel_id],TED_PANEL_FIND ;if not panel
253
	jne @f
254
		stdcall [edit_box_mouse], dword edit2
255
	@@:
256
	cmp byte[tedit0.panel_id],TED_PANEL_SYNTAX ;if not panel
257
	jne .menu_bar_1 ;@f
258
	stdcall [tl_mouse], tree1
1338 IgorA 259
;-----------------------------------------------
260
.menu_bar_1:
2125 IgorA 261
	mov [menu_data_1.get_mouse_flag],1
1338 IgorA 262
; mouse event for Menu 1
2125 IgorA 263
	stdcall [menu_bar_mouse],dword menu_data_1
264
	cmp dword[menu_data_1.click],1
265
	jne .mnu_1
266
	cmp dword[menu_data_1.cursor_out],4
267
	je button.exit
268
	cmp dword[menu_data_1.cursor_out],3
269
	jne @f
270
		stdcall [ted_but_save_file], tedit0,run_file_70,[edit1.text]
271
	@@:
272
	cmp dword[menu_data_1.cursor_out],2
273
	jne @f
274
		call ted_but_open_file
275
	@@:
276
	cmp dword[menu_data_1.cursor_out],1
277
	jne @f
278
		call ted_but_new_file
279
	@@:
1338 IgorA 280
.mnu_1:
2125 IgorA 281
	jmp still
1338 IgorA 282
;---------------------------------------------------------------------
283
 
1456 IgorA 284
;output:
285
; ah = symbol
286
align 4
287
proc KeyConvertToASCII, table:dword
288
  push ebx
289
  mov ebx,dword[table] ;convert scan to ascii
1338 IgorA 290
  ror ax,8
291
  xor ah,ah
292
  add bx,ax
293
  mov ah,byte[ebx]
1456 IgorA 294
  pop ebx
1338 IgorA 295
  ret
1456 IgorA 296
endp
1338 IgorA 297
 
1456 IgorA 298
align 4
1338 IgorA 299
key:
1456 IgorA 300
  mcall 66,3 ;66.3 получить состояние управляющих клавиш
1457 IgorA 301
  xor esi,esi
1338 IgorA 302
  mov ecx,1
303
  test al,0x03 ;[Shift]
304
  jz @f
1456 IgorA 305
    mov cl,2
1457 IgorA 306
    or esi,KM_SHIFT
1338 IgorA 307
  @@:
308
  test al,0x0c ;[Ctrl]
309
  jz @f
1457 IgorA 310
    or esi,KM_CTRL
1338 IgorA 311
  @@:
312
  test al,0x30 ;[Alt]
313
  jz @f
1456 IgorA 314
    mov cl,3
1457 IgorA 315
    or esi,KM_ALT
1338 IgorA 316
  @@:
317
  test al,0x80 ;[NumLock]
318
  jz @f
1457 IgorA 319
    or esi,KM_NUMLOCK
1338 IgorA 320
  @@:
1457 IgorA 321
 
1456 IgorA 322
  mcall 26,2,,conv_tabl ;26.2 получить раскладку клавиатуры
323
  mcall 2 ;получаем код нажатой клавиши
1458 IgorA 324
  stdcall [tl_key], tree1
1338 IgorA 325
 
326
  test word [edit1.flags],10b;ed_focus ; если не в фокусе, выходим
327
  je @f
328
    cmp ah,0x80 ;if key up
329
    ja still
330
    cmp ah,42 ;[Shift] (left)
331
    je still
332
    cmp ah,54 ;[Shift] (right)
333
    je still
334
    cmp ah,56 ;[Alt]
335
    je still
336
    cmp ah,29 ;[Ctrl]
337
    je still
338
    cmp ah,69 ;[Pause Break]
339
    je still
340
 
1456 IgorA 341
    stdcall KeyConvertToASCII, dword conv_tabl
342
    stdcall [edit_box_key], dword edit1
1338 IgorA 343
    jmp still
344
  @@:
345
 
346
  test word [edit2.flags],10b;ed_focus ; если не в фокусе, выходим
347
  je @f
348
    cmp ah,0x80 ;if key up
349
    ja still
350
    cmp ah,42 ;[Shift] (left)
351
    je still
352
    cmp ah,54 ;[Shift] (right)
353
    je still
354
    cmp ah,56 ;[Alt]
355
    je still
356
    cmp ah,29 ;[Ctrl]
357
    je still
358
    cmp ah,69 ;[Pause Break]
359
    je still
360
 
1456 IgorA 361
    stdcall KeyConvertToASCII, dword conv_tabl
1449 IgorA 362
    stdcall [edit_box_key], dword edit2
1338 IgorA 363
    jmp still
364
  @@:
365
 
1457 IgorA 366
  stdcall [ted_key], tedit0, conv_tabl,esi
1338 IgorA 367
  jmp still
368
 
1457 IgorA 369
align 4
1338 IgorA 370
button:
1449 IgorA 371
;  cmp [menu_active],1 ;если нажали меню, то сначала реакция на меню
1338 IgorA 372
;  jne @f ;mouse.menu_bar_1
373
;    mov [menu_active],0
374
;    jmp still
375
;  @@:
376
 
1449 IgorA 377
  mcall 17 ;получить код нажатой кнопки
1338 IgorA 378
  cmp ah,3
379
  jne @f
1457 IgorA 380
    call ted_but_new_file
1338 IgorA 381
  @@:
382
  cmp ah,4
383
  jne @f
1457 IgorA 384
    call ted_but_open_file
1338 IgorA 385
  @@:
386
  cmp ah,5
387
  jne @f
1457 IgorA 388
    stdcall [ted_but_save_file], tedit0,run_file_70,[edit1.text]
1338 IgorA 389
  @@:
390
  cmp ah,6
1456 IgorA 391
  jne @f
1457 IgorA 392
    stdcall [ted_but_select_word], tedit0
1456 IgorA 393
  @@:
1338 IgorA 394
  cmp ah,7
1456 IgorA 395
  jne @f
1457 IgorA 396
    stdcall [ted_but_cut], tedit0
1456 IgorA 397
  @@:
1338 IgorA 398
  cmp ah,8
399
  jne @f
1457 IgorA 400
    stdcall [ted_but_copy], tedit0
1338 IgorA 401
  @@:
402
  cmp ah,9
1456 IgorA 403
  jne @f
1457 IgorA 404
    stdcall [ted_but_paste], tedit0
1456 IgorA 405
  @@:
1338 IgorA 406
  cmp ah,10
1449 IgorA 407
  jne @f
1457 IgorA 408
    call ted_but_find
1449 IgorA 409
  @@:
1338 IgorA 410
  cmp ah,11
1456 IgorA 411
  jne @f
412
    call but_replace
413
  @@:
1338 IgorA 414
  cmp ah,12
1456 IgorA 415
  jne @f
416
    call but_find_key_w
417
  @@:
1338 IgorA 418
  cmp ah,13
1456 IgorA 419
  jne @f
1457 IgorA 420
    stdcall [ted_but_sumb_upper], tedit0
1456 IgorA 421
  @@:
1338 IgorA 422
  cmp ah,14
1456 IgorA 423
  jne @f
1457 IgorA 424
    stdcall [ted_but_sumb_lover], tedit0
1456 IgorA 425
  @@:
1338 IgorA 426
  cmp ah,15
1456 IgorA 427
  jne @f
1457 IgorA 428
    stdcall [ted_but_reverse], tedit0
1456 IgorA 429
  @@:
1338 IgorA 430
  cmp ah,16
1456 IgorA 431
  jne @f
1457 IgorA 432
    stdcall [ted_but_undo], tedit0
1456 IgorA 433
  @@:
1338 IgorA 434
  cmp ah,17
1456 IgorA 435
  jne @f
1457 IgorA 436
    stdcall [ted_but_redo], tedit0
1456 IgorA 437
  @@:
1338 IgorA 438
  cmp ah,18
1456 IgorA 439
  jne @f
440
    stdcall but_sumb_invis, tedit0
441
  @@:
1338 IgorA 442
  cmp ah,19
1456 IgorA 443
  jne @f
444
    stdcall but_k_words_show, tedit0
445
  @@:
1338 IgorA 446
  cmp ah,20
1449 IgorA 447
  jne @f
448
    stdcall but_synt_show, tedit0
449
  @@:
1338 IgorA 450
 
451
  cmp ah,200
452
  jne @f
1456 IgorA 453
    stdcall ted_but_open_syntax, tedit0
1338 IgorA 454
  @@:
455
  cmp ah,201
456
  jne @f
1457 IgorA 457
    stdcall [ted_but_find_next], tedit0
1338 IgorA 458
  @@:
459
 
460
  cmp ah,1
461
  jne still
462
.exit:
1457 IgorA 463
  stdcall [ted_can_save], tedit0
1338 IgorA 464
  cmp al,1
465
  jne @f
1456 IgorA 466
    stdcall [mb_create],msgbox_8,thread ;message: save changes in file?
1338 IgorA 467
    jmp still
468
  @@:
1489 IgorA 469
  stdcall mem.Free,[bmp_icon]
1456 IgorA 470
 
1457 IgorA 471
  stdcall [ted_delete], tedit0
1456 IgorA 472
  stdcall dword[tl_data_clear], tree1
1449 IgorA 473
  mcall -1 ;выход из программы
1338 IgorA 474
 
475
 
1467 IgorA 476
edit1 edit_box 250, 220, 5, 0xffffff, 0xff80, 0xff0000, 0xff, 0x4080, 4090, openfile_path, mouse_dd, 0
1457 IgorA 477
edit2 edit_box TED_PANEL_WIDTH-1, 0, 20, 0xffffff, 0xff80, 0xff0000, 0xff, 0x4080, 300, buf_find, mouse_dd, 0
1338 IgorA 478
 
479
buf_find db 302 dup(0)
480
 
1343 IgorA 481
if lang eq ru
2632 IgorA 482
  head_f_i:
483
  head_f_l db 'Системная ошибка',0
1592 IgorA 484
  err_message_found_lib0 db 'Не найдена библиотека ',39,'box_lib.obj',39,0
485
  err_message_import0 db 'Ошибка при импорте библиотеки ',39,'box_lib.obj',39,0
486
  err_message_found_lib1 db 'Не найдена библиотека ',39,'msgbox.obj',39,0
487
  err_message_import1 db 'Ошибка при импорте библиотеки ',39,'msgbox.obj',39,0
488
  err_message_found_lib2 db 'Не найдена библиотека ',39,'proc_lib.obj',39,0
489
  err_message_import2 db 'Ошибка при импорте библиотеки ',39,'proc_lib.obj',39,0
2632 IgorA 490
  err_message_found_lib_3 db 'Не найдена библиотека ',39,'libimg.obj',39,0
491
  err_message_import_3 db 'Ошибка при импорте библиотеки ',39,'libimg.obj',39,0
1343 IgorA 492
else
2632 IgorA 493
  head_f_i:
494
  head_f_l db 'System error',0
1592 IgorA 495
  err_message_found_lib0 db 'Sorry I cannot found library ',39,'box_lib.obj',39,0
496
  err_message_import0 db 'Error on load import library ',39,'box_lib.obj',39,0
497
  err_message_found_lib1 db 'Sorry I cannot found library ',39,'msgbox.obj',39,0
498
  err_message_import1 db 'Error on load import library ',39,'msgbox.obj',39,0
499
  err_message_found_lib2 db 'Sorry I cannot found library ',39,'proc_lib.obj',39,0
500
  err_message_import2 db 'Error on load import library ',39,'proc_lib.obj',39,0
2632 IgorA 501
  err_message_found_lib_3 db 'Sorry I cannot found library ',39,'libimg.obj',39,0
502
  err_message_import_3 db 'Error on load import library ',39,'libimg.obj',39,0
1343 IgorA 503
end if
1338 IgorA 504
 
505
;library structures
506
l_libs_start:
2632 IgorA 507
	lib0 l_libs lib_name_0, sys_path, file_name, system_dir_0,\
508
		err_message_found_lib0, head_f_l, import_box_lib,err_message_import0, head_f_i
509
	lib1 l_libs lib_name_1, sys_path, file_name, system_dir_1,\
510
		err_message_found_lib1, head_f_l, import_msgbox_lib, err_message_import1, head_f_i
511
	lib2 l_libs lib_name_2, sys_path, file_name, system_dir_2,\
512
		err_message_found_lib2, head_f_l, import_proclib, err_message_import2, head_f_i
513
	lib3 l_libs lib_name_3, sys_path, file_name, system_dir_3,\
514
		err_message_found_lib_3, head_f_l, import_libimg, err_message_import_3, head_f_i
1338 IgorA 515
load_lib_end:
516
 
517
 
518
i_end:
1467 IgorA 519
	rb 1024
520
	align 16
521
	procinfo process_information
1705 IgorA 522
		rb 1024
1467 IgorA 523
	thread:
1705 IgorA 524
	rb 1024
1338 IgorA 525
stacktop:
1705 IgorA 526
	sys_path:
527
		rb 4096
528
	file_name:
529
		rb 4096
530
	file_name_rez:
531
		rb 4096
532
	plugin_path:
533
		rb 4096
534
	openfile_path:
535
		rb 4096
536
	filename_area:
537
		rb 256
538
	file_info:
539
		rb 40
1338 IgorA 540
mem: