Subversion Repositories Kolibri OS

Rev

Rev 2632 | Rev 2708 | 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
2707 IgorA 172
	mov edi, tedit0
173
	mov ebx,run_file_70
174
	mov dword[ebx], 0
175
	mov dword[ebx+4], 0
176
	mov dword[ebx+8], 0
177
	mov ecx, ted_syntax_file_size
178
	mov dword[ebx+12], ecx
179
	m2m dword[ebx+16], ted_syntax_file
180
	mov  byte[ebx+20], 0
181
	m2m dword[ebx+21], file_name
182
	mcall 70
183
	cmp eax,0
184
	jne .end_0
185
		call ted_on_init_synt_err
186
		jmp @f
187
	.end_0:
188
	stdcall [ted_init_syntax_file], edi
1338 IgorA 189
 
190
;--- get cmd line ---
1467 IgorA 191
  cmp byte[openfile_path+3],0 ;openfile_path
1338 IgorA 192
  je @f ;if file names exist
1467 IgorA 193
    mov esi,openfile_path
1338 IgorA 194
    call strlen ;eax=strlen
195
    mov [edit1.size],eax
1456 IgorA 196
    call but_no_msg_OpenFile
1338 IgorA 197
  @@:
198
 
1456 IgorA 199
align 4
1338 IgorA 200
red_win:
1467 IgorA 201
  call draw_window
202
 
203
align 4
204
still:
2125 IgorA 205
	mcall 10
1467 IgorA 206
 
2125 IgorA 207
	cmp al,1 ;изменилось положение окна
208
	jz red_win
209
	cmp al,2
210
	jz key
211
	cmp al,3
212
	jz button
213
	cmp al,6 ;мышь
214
	jne @f
215
		mcall 9,procinfo,-1
216
		cmp ax,word[procinfo+4]
217
		jne @f ;окно не активно
218
		jmp mouse
219
	@@:
220
	jmp still
1467 IgorA 221
 
222
align 4
223
draw_window:
2125 IgorA 224
	mcall 12,1
1338 IgorA 225
 
2125 IgorA 226
	mov edx,[sc.work]
227
	or  edx,0x73000000
228
	mov edi,hed
229
	mcall 0,(10 shl 16)+485,(10 shl 16)+320
1338 IgorA 230
 
2125 IgorA 231
	mcall 9,procinfo,-1
232
	mov edi,tedit0 ;значение edi нужно для EvSize и ted_wnd_t
233
	call EvSize
1449 IgorA 234
 
2125 IgorA 235
	mov eax,13 ;верхний прямоугольник, для очистки верхней панели
236
	xor ebx,ebx
237
	mov ecx,ted_wnd_t
238
	mov bx,word[procinfo.client_box.width]
239
	inc bx
240
	int 0x40
1338 IgorA 241
 
1467 IgorA 242
	mov eax,4
243
	mov ebx,185*65536+9
244
	mov ecx,[sc.work_text]
245
	or  ecx,0x80000000
246
	mov edx,txtFile
247
	int 0x40
248
 
1449 IgorA 249
  stdcall [edit_box_draw], dword edit1
250
  stdcall [menu_bar_draw], dword menu_data_1
1338 IgorA 251
 
252
  call draw_but_toolbar
253
 
2632 IgorA 254
  stdcall [ted_draw], tedit0
1338 IgorA 255
 
1343 IgorA 256
  mcall 12,2
1467 IgorA 257
  ret
1338 IgorA 258
 
1456 IgorA 259
align 4
1338 IgorA 260
mouse:
2125 IgorA 261
	stdcall [edit_box_mouse], dword edit1
1338 IgorA 262
 
2125 IgorA 263
	test word [edit1.flags],10b ;ed_focus ;если не в фокусе, выходим
264
	jne still
1338 IgorA 265
 
2125 IgorA 266
	stdcall [ted_mouse], tedit0
1338 IgorA 267
 
2125 IgorA 268
	cmp byte[tedit0.panel_id],TED_PANEL_FIND ;if not panel
269
	jne @f
270
		stdcall [edit_box_mouse], dword edit2
271
	@@:
272
	cmp byte[tedit0.panel_id],TED_PANEL_SYNTAX ;if not panel
273
	jne .menu_bar_1 ;@f
274
	stdcall [tl_mouse], tree1
1338 IgorA 275
;-----------------------------------------------
276
.menu_bar_1:
2125 IgorA 277
	mov [menu_data_1.get_mouse_flag],1
1338 IgorA 278
; mouse event for Menu 1
2125 IgorA 279
	stdcall [menu_bar_mouse],dword menu_data_1
280
	cmp dword[menu_data_1.click],1
281
	jne .mnu_1
282
	cmp dword[menu_data_1.cursor_out],4
283
	je button.exit
284
	cmp dword[menu_data_1.cursor_out],3
285
	jne @f
286
		stdcall [ted_but_save_file], tedit0,run_file_70,[edit1.text]
287
	@@:
288
	cmp dword[menu_data_1.cursor_out],2
289
	jne @f
290
		call ted_but_open_file
291
	@@:
292
	cmp dword[menu_data_1.cursor_out],1
293
	jne @f
294
		call ted_but_new_file
295
	@@:
1338 IgorA 296
.mnu_1:
2125 IgorA 297
	jmp still
1338 IgorA 298
;---------------------------------------------------------------------
299
 
1456 IgorA 300
;output:
301
; ah = symbol
302
align 4
303
proc KeyConvertToASCII, table:dword
304
  push ebx
305
  mov ebx,dword[table] ;convert scan to ascii
1338 IgorA 306
  ror ax,8
307
  xor ah,ah
308
  add bx,ax
309
  mov ah,byte[ebx]
1456 IgorA 310
  pop ebx
1338 IgorA 311
  ret
1456 IgorA 312
endp
1338 IgorA 313
 
1456 IgorA 314
align 4
1338 IgorA 315
key:
1456 IgorA 316
  mcall 66,3 ;66.3 получить состояние управляющих клавиш
1457 IgorA 317
  xor esi,esi
1338 IgorA 318
  mov ecx,1
319
  test al,0x03 ;[Shift]
320
  jz @f
1456 IgorA 321
    mov cl,2
1457 IgorA 322
    or esi,KM_SHIFT
1338 IgorA 323
  @@:
324
  test al,0x0c ;[Ctrl]
325
  jz @f
1457 IgorA 326
    or esi,KM_CTRL
1338 IgorA 327
  @@:
328
  test al,0x30 ;[Alt]
329
  jz @f
1456 IgorA 330
    mov cl,3
1457 IgorA 331
    or esi,KM_ALT
1338 IgorA 332
  @@:
333
  test al,0x80 ;[NumLock]
334
  jz @f
1457 IgorA 335
    or esi,KM_NUMLOCK
1338 IgorA 336
  @@:
1457 IgorA 337
 
1456 IgorA 338
  mcall 26,2,,conv_tabl ;26.2 получить раскладку клавиатуры
339
  mcall 2 ;получаем код нажатой клавиши
1458 IgorA 340
  stdcall [tl_key], tree1
1338 IgorA 341
 
342
  test word [edit1.flags],10b;ed_focus ; если не в фокусе, выходим
343
  je @f
344
    cmp ah,0x80 ;if key up
345
    ja still
346
    cmp ah,42 ;[Shift] (left)
347
    je still
348
    cmp ah,54 ;[Shift] (right)
349
    je still
350
    cmp ah,56 ;[Alt]
351
    je still
352
    cmp ah,29 ;[Ctrl]
353
    je still
354
    cmp ah,69 ;[Pause Break]
355
    je still
356
 
1456 IgorA 357
    stdcall KeyConvertToASCII, dword conv_tabl
358
    stdcall [edit_box_key], dword edit1
1338 IgorA 359
    jmp still
360
  @@:
361
 
362
  test word [edit2.flags],10b;ed_focus ; если не в фокусе, выходим
363
  je @f
364
    cmp ah,0x80 ;if key up
365
    ja still
366
    cmp ah,42 ;[Shift] (left)
367
    je still
368
    cmp ah,54 ;[Shift] (right)
369
    je still
370
    cmp ah,56 ;[Alt]
371
    je still
372
    cmp ah,29 ;[Ctrl]
373
    je still
374
    cmp ah,69 ;[Pause Break]
375
    je still
376
 
1456 IgorA 377
    stdcall KeyConvertToASCII, dword conv_tabl
1449 IgorA 378
    stdcall [edit_box_key], dword edit2
1338 IgorA 379
    jmp still
380
  @@:
381
 
1457 IgorA 382
  stdcall [ted_key], tedit0, conv_tabl,esi
1338 IgorA 383
  jmp still
384
 
1457 IgorA 385
align 4
1338 IgorA 386
button:
1449 IgorA 387
;  cmp [menu_active],1 ;если нажали меню, то сначала реакция на меню
1338 IgorA 388
;  jne @f ;mouse.menu_bar_1
389
;    mov [menu_active],0
390
;    jmp still
391
;  @@:
392
 
1449 IgorA 393
  mcall 17 ;получить код нажатой кнопки
1338 IgorA 394
  cmp ah,3
395
  jne @f
1457 IgorA 396
    call ted_but_new_file
1338 IgorA 397
  @@:
398
  cmp ah,4
399
  jne @f
1457 IgorA 400
    call ted_but_open_file
1338 IgorA 401
  @@:
402
  cmp ah,5
403
  jne @f
1457 IgorA 404
    stdcall [ted_but_save_file], tedit0,run_file_70,[edit1.text]
1338 IgorA 405
  @@:
406
  cmp ah,6
1456 IgorA 407
  jne @f
1457 IgorA 408
    stdcall [ted_but_select_word], tedit0
1456 IgorA 409
  @@:
1338 IgorA 410
  cmp ah,7
1456 IgorA 411
  jne @f
1457 IgorA 412
    stdcall [ted_but_cut], tedit0
1456 IgorA 413
  @@:
1338 IgorA 414
  cmp ah,8
415
  jne @f
1457 IgorA 416
    stdcall [ted_but_copy], tedit0
1338 IgorA 417
  @@:
418
  cmp ah,9
1456 IgorA 419
  jne @f
1457 IgorA 420
    stdcall [ted_but_paste], tedit0
1456 IgorA 421
  @@:
1338 IgorA 422
  cmp ah,10
1449 IgorA 423
  jne @f
1457 IgorA 424
    call ted_but_find
1449 IgorA 425
  @@:
1338 IgorA 426
  cmp ah,11
1456 IgorA 427
  jne @f
428
    call but_replace
429
  @@:
1338 IgorA 430
  cmp ah,12
1456 IgorA 431
  jne @f
432
    call but_find_key_w
433
  @@:
1338 IgorA 434
  cmp ah,13
1456 IgorA 435
  jne @f
1457 IgorA 436
    stdcall [ted_but_sumb_upper], tedit0
1456 IgorA 437
  @@:
1338 IgorA 438
  cmp ah,14
1456 IgorA 439
  jne @f
1457 IgorA 440
    stdcall [ted_but_sumb_lover], tedit0
1456 IgorA 441
  @@:
1338 IgorA 442
  cmp ah,15
1456 IgorA 443
  jne @f
1457 IgorA 444
    stdcall [ted_but_reverse], tedit0
1456 IgorA 445
  @@:
1338 IgorA 446
  cmp ah,16
1456 IgorA 447
  jne @f
1457 IgorA 448
    stdcall [ted_but_undo], tedit0
1456 IgorA 449
  @@:
1338 IgorA 450
  cmp ah,17
1456 IgorA 451
  jne @f
1457 IgorA 452
    stdcall [ted_but_redo], tedit0
1456 IgorA 453
  @@:
1338 IgorA 454
  cmp ah,18
1456 IgorA 455
  jne @f
456
    stdcall but_sumb_invis, tedit0
457
  @@:
1338 IgorA 458
  cmp ah,19
1456 IgorA 459
  jne @f
460
    stdcall but_k_words_show, tedit0
461
  @@:
1338 IgorA 462
  cmp ah,20
1449 IgorA 463
  jne @f
464
    stdcall but_synt_show, tedit0
465
  @@:
1338 IgorA 466
 
467
  cmp ah,200
468
  jne @f
1456 IgorA 469
    stdcall ted_but_open_syntax, tedit0
1338 IgorA 470
  @@:
471
  cmp ah,201
472
  jne @f
1457 IgorA 473
    stdcall [ted_but_find_next], tedit0
1338 IgorA 474
  @@:
475
 
476
  cmp ah,1
477
  jne still
478
.exit:
1457 IgorA 479
  stdcall [ted_can_save], tedit0
1338 IgorA 480
  cmp al,1
481
  jne @f
1456 IgorA 482
    stdcall [mb_create],msgbox_8,thread ;message: save changes in file?
1338 IgorA 483
    jmp still
484
  @@:
1489 IgorA 485
  stdcall mem.Free,[bmp_icon]
1456 IgorA 486
 
1457 IgorA 487
  stdcall [ted_delete], tedit0
1456 IgorA 488
  stdcall dword[tl_data_clear], tree1
1449 IgorA 489
  mcall -1 ;выход из программы
1338 IgorA 490
 
491
 
1467 IgorA 492
edit1 edit_box 250, 220, 5, 0xffffff, 0xff80, 0xff0000, 0xff, 0x4080, 4090, openfile_path, mouse_dd, 0
1457 IgorA 493
edit2 edit_box TED_PANEL_WIDTH-1, 0, 20, 0xffffff, 0xff80, 0xff0000, 0xff, 0x4080, 300, buf_find, mouse_dd, 0
1338 IgorA 494
 
495
buf_find db 302 dup(0)
496
 
1343 IgorA 497
if lang eq ru
2632 IgorA 498
  head_f_i:
499
  head_f_l db 'Системная ошибка',0
1592 IgorA 500
  err_message_found_lib0 db 'Не найдена библиотека ',39,'box_lib.obj',39,0
501
  err_message_import0 db 'Ошибка при импорте библиотеки ',39,'box_lib.obj',39,0
502
  err_message_found_lib1 db 'Не найдена библиотека ',39,'msgbox.obj',39,0
503
  err_message_import1 db 'Ошибка при импорте библиотеки ',39,'msgbox.obj',39,0
504
  err_message_found_lib2 db 'Не найдена библиотека ',39,'proc_lib.obj',39,0
505
  err_message_import2 db 'Ошибка при импорте библиотеки ',39,'proc_lib.obj',39,0
2632 IgorA 506
  err_message_found_lib_3 db 'Не найдена библиотека ',39,'libimg.obj',39,0
507
  err_message_import_3 db 'Ошибка при импорте библиотеки ',39,'libimg.obj',39,0
1343 IgorA 508
else
2632 IgorA 509
  head_f_i:
510
  head_f_l db 'System error',0
1592 IgorA 511
  err_message_found_lib0 db 'Sorry I cannot found library ',39,'box_lib.obj',39,0
512
  err_message_import0 db 'Error on load import library ',39,'box_lib.obj',39,0
513
  err_message_found_lib1 db 'Sorry I cannot found library ',39,'msgbox.obj',39,0
514
  err_message_import1 db 'Error on load import library ',39,'msgbox.obj',39,0
515
  err_message_found_lib2 db 'Sorry I cannot found library ',39,'proc_lib.obj',39,0
516
  err_message_import2 db 'Error on load import library ',39,'proc_lib.obj',39,0
2632 IgorA 517
  err_message_found_lib_3 db 'Sorry I cannot found library ',39,'libimg.obj',39,0
518
  err_message_import_3 db 'Error on load import library ',39,'libimg.obj',39,0
1343 IgorA 519
end if
1338 IgorA 520
 
521
;library structures
522
l_libs_start:
2632 IgorA 523
	lib0 l_libs lib_name_0, sys_path, file_name, system_dir_0,\
524
		err_message_found_lib0, head_f_l, import_box_lib,err_message_import0, head_f_i
525
	lib1 l_libs lib_name_1, sys_path, file_name, system_dir_1,\
526
		err_message_found_lib1, head_f_l, import_msgbox_lib, err_message_import1, head_f_i
527
	lib2 l_libs lib_name_2, sys_path, file_name, system_dir_2,\
528
		err_message_found_lib2, head_f_l, import_proclib, err_message_import2, head_f_i
529
	lib3 l_libs lib_name_3, sys_path, file_name, system_dir_3,\
530
		err_message_found_lib_3, head_f_l, import_libimg, err_message_import_3, head_f_i
1338 IgorA 531
load_lib_end:
532
 
533
 
534
i_end:
1467 IgorA 535
	rb 1024
536
	align 16
537
	procinfo process_information
1705 IgorA 538
		rb 1024
1467 IgorA 539
	thread:
1705 IgorA 540
	rb 1024
1338 IgorA 541
stacktop:
1705 IgorA 542
	sys_path:
543
		rb 4096
544
	file_name:
545
		rb 4096
546
	file_name_rez:
547
		rb 4096
548
	plugin_path:
549
		rb 4096
550
	openfile_path:
551
		rb 4096
552
	filename_area:
553
		rb 256
554
	file_info:
555
		rb 40
1338 IgorA 556
mem: