Subversion Repositories Kolibri OS

Rev

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