Subversion Repositories Kolibri OS

Rev

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