Subversion Repositories Kolibri OS

Rev

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