Subversion Repositories Kolibri OS

Rev

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