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
1456 IgorA 1
align 4
1338 IgorA 2
but_NewFile:
3
  push eax ebx
1456 IgorA 4
  stdcall ted_can_save, tedit0
1338 IgorA 5
  cmp al,1
6
  jne @f
1456 IgorA 7
    stdcall [mb_create],msgbox_2,thread ;message: save changes in file?
1338 IgorA 8
    ;mov eax,5
9
    ;mov ebx,50
10
    ;int 0x40
1456 IgorA 11
    stdcall [mb_setfunctions],msgbox_2_funct
1338 IgorA 12
    jmp .ret_f
13
  @@:
14
  call On_NewFile
15
  .ret_f:
16
  pop ebx eax
17
  ret
18
 
1456 IgorA 19
align 4
1338 IgorA 20
On_NewFile:
1456 IgorA 21
  stdcall ted_clear, tedit0,1
1338 IgorA 22
  call draw_but_toolbar
1449 IgorA 23
  stdcall draw_main_win, tedit0
1338 IgorA 24
  ret
25
 
1456 IgorA 26
align 4
1338 IgorA 27
On_SaveAndNewFile:
1456 IgorA 28
  push edi
29
  mov edi, tedit0
30
 
31
  stdcall but_SaveFile,edi
32
  cmp ted_err_save,0
1338 IgorA 33
  jne @f
34
    call On_NewFile
35
  @@:
1456 IgorA 36
  pop edi
1338 IgorA 37
  ret
38
 
1456 IgorA 39
align 4
40
but_no_msg_OpenFile: ;функция открытия файла через без окона сообщения
41
  stdcall ted_on_open_file, tedit0
42
  ret
43
 
44
 
45
;функция открытия файла с возможным окном сообщения (о возможности отменить открытие)
46
align 4
1338 IgorA 47
but_OpenFile:
48
  push eax
1456 IgorA 49
  stdcall ted_can_save, tedit0
1338 IgorA 50
  cmp al,1
51
  jne @f
1456 IgorA 52
    stdcall [mb_create],msgbox_5,thread ;message: save changes in file?
53
    stdcall [mb_setfunctions],msgbox_5_funct
1338 IgorA 54
    jmp .ret_f
55
  @@:
1456 IgorA 56
  stdcall ted_on_open_file, tedit0
1338 IgorA 57
  .ret_f:
58
  pop eax
59
  ret
60
 
1456 IgorA 61
align 4
62
proc ted_on_open_file, edit:dword ;функция открытия файла
63
  push eax ebx edi
64
  mov edi,dword[edit]
65
 
1338 IgorA 66
  mov eax,70
67
  mov [run_file_70.func_n], 0
68
  mov [run_file_70.param1], 0
69
  mov [run_file_70.param2], 0
70
  mov [run_file_70.param3], maxChars-2 ;sizeof.symbol
1456 IgorA 71
  m2m [run_file_70.param4], ted_tex
1338 IgorA 72
  mov [run_file_70.rezerv], 0
73
  push dword[edit1.text]
74
  pop dword[run_file_70.name]
75
  mov ebx,run_file_70
76
  int 0x40
77
 
78
  cmp eax,0
79
  je @f
80
  cmp eax,6
81
  je @f
82
    cmp ax,10
83
    jl .zifra_0_9
84
      mov al,'?'
85
      sub ax,48
86
    .zifra_0_9:
87
    add ax,48
88
 
89
    mov byte[msgbox_4.err],al
1456 IgorA 90
    stdcall [mb_create],msgbox_4,thread ;message: Can-t open text file!
1338 IgorA 91
    jmp .ret_f
92
  @@:
93
  cmp ebx,-1
94
  je .ret_f
95
    ;if open file
96
    call OpenFile
97
    cmp ebx,maxChars-2
98
    jl .ret_f
1456 IgorA 99
    stdcall [mb_create],msgbox_1,thread
1338 IgorA 100
  .ret_f:
1456 IgorA 101
  pop edi ebx eax
1338 IgorA 102
  ret
1456 IgorA 103
endp
1338 IgorA 104
 
1456 IgorA 105
 
106
align 4
107
proc but_SaveFile, edit:dword
108
  pushad
109
 
110
  stdcall ted_can_save,edi
1338 IgorA 111
  cmp al,0
112
  je .no_save
113
 
1456 IgorA 114
  mov edi,dword[edit]
115
 
116
  mov ecx,maxChars
1338 IgorA 117
  call mem_Alloc
118
  push eax
119
 
1456 IgorA 120
  mov edx,ted_tex
1338 IgorA 121
  xor ecx,ecx
122
  @@:
123
    call IteratNext
1456 IgorA 124
    cmp edx,ted_tex_1
125
    jle @f ;edx = ted_tex or edx = ted_tex+sizeof.symbol
1338 IgorA 126
    mov bl,[edx]
127
    mov byte[eax],bl
128
    inc eax
129
    inc ecx
130
    jmp @b
131
  @@:
132
 
133
  cmp ecx,0
134
  je @f
135
    pop eax
136
    mov [run_file_70.param4],eax
137
    push eax
138
    mov eax,70
139
    mov [run_file_70.func_n], 2
140
    mov [run_file_70.param1], 0
141
    mov [run_file_70.param2], 0
142
    mov [run_file_70.param3], ecx
143
    mov [run_file_70.rezerv], 0
144
    push [edit1.text]
145
    pop [run_file_70.name]
146
    mov ebx,run_file_70
147
    int 0x40
148
 
1456 IgorA 149
    mov ted_err_save,ax
1338 IgorA 150
 
151
    cmp eax,0
152
    je .no_msg
153
;    cmp eax,6
154
;    je @f
155
      cmp ax,10
156
      jl .zifra_0_9
157
	mov al,'?'
158
	sub ax,48
159
      .zifra_0_9:
160
      add ax,48
161
 
162
      mov byte[msgbox_6.err],al
1456 IgorA 163
      stdcall [mb_create],msgbox_6,thread ;message: Can-t save text file!
1338 IgorA 164
      jmp @f
165
    .no_msg:
1456 IgorA 166
    m2m ted_tim_ls,ted_tim_ch
1338 IgorA 167
  @@:
168
 
169
  pop ecx
170
  call mem_Free
171
  .no_save:
1456 IgorA 172
  popad
1338 IgorA 173
  ret
1456 IgorA 174
endp
1338 IgorA 175
 
1456 IgorA 176
 
177
align 4
178
proc but_FindText, edit:dword
179
  pushad
180
    mov edi,dword[edit]
181
 
1338 IgorA 182
    call GetPos
183
    mov eax,[edit2.text]
184
    mov bl,byte[eax]
185
    @@:
186
      call GetFindRezult
187
      cmp bh,1
188
      je @f ; find
189
 
190
      call IteratNext
1456 IgorA 191
      cmp edx,ted_tex_1
1338 IgorA 192
      jle @f
193
      jmp @b
194
    @@:
195
    cmp bh,0
196
    je @f
197
      call GetTexCoords
198
      inc ebx ;move cursor right
1456 IgorA 199
      mov ted_sel_x1,ebx
200
      mov ted_sel_y1,eax
1338 IgorA 201
      mov edx,eax
202
      mov ecx,ebx
203
      call GoToPos
1456 IgorA 204
      mov edx,esi ;esi было установлео в GetFindRezult
1338 IgorA 205
      call GetTexCoords
1456 IgorA 206
      mov ted_sel_x0,ebx
207
      mov ted_sel_y0,eax
208
      stdcall draw_main_win,edi
1338 IgorA 209
      jmp .end_find
210
    @@:
1456 IgorA 211
      stdcall [mb_create],msgbox_7,thread ;message: Can not find text
1338 IgorA 212
    .end_find:
1456 IgorA 213
  popad
1338 IgorA 214
  ret
1456 IgorA 215
endp
1338 IgorA 216
 
217
;input:
218
; eax - text need find
219
; bl - first symbol to find
220
; edx - first symbol pointer
1456 IgorA 221
; edi - pointer to tedit struct
1338 IgorA 222
;output:
223
; bh - rezult
224
; edx - last text position (if find sucess)
1456 IgorA 225
; esi - first symbol pointer
226
;description:
227
; Функция проверяет совпадает ли текст в буфере eax
228
; с текстом редактора по указателю edx.
229
; Стандартные функции (напр. strcmp) тут не подойдут, потому что
230
; в памяти редактора текст содержится не в виде ascii строк.
231
align 4
1338 IgorA 232
GetFindRezult:
233
  push eax
234
    mov bh,1
1456 IgorA 235
    mov esi,edx ;copy edx
1338 IgorA 236
    @@:
237
      cmp byte[edx],bl
238
      jne .no_text
239
 
240
      inc eax ;*** get next symbol (in find text) ***
241
      mov bl,byte[eax]
242
      cmp bl,0
243
      je @f ;end of find text
244
 
245
      call IteratNext ;*** get next symbol (in editor text) ***
1456 IgorA 246
      cmp edx,ted_tex_1
1338 IgorA 247
      jle @f ;end of editor text
248
 
249
      jmp @b
250
      .no_text:
251
	xor bh,bh
1456 IgorA 252
	mov edx,esi ;restore edx
1338 IgorA 253
    @@:
254
  pop eax
255
  mov bl,byte[eax] ;restore bl
256
  ret
257
 
1456 IgorA 258
align 4
259
proc ted_but_open_syntax, edit:dword
260
  push edi
261
  mov edi,dword[edit]
262
 
263
  cmp ted_panel_id,TE_PANEL_SYNTAX
1338 IgorA 264
  jne @f
1456 IgorA 265
    stdcall dword[tl_node_get_data], tree1
1449 IgorA 266
    pop dword[fn_col_option]
1456 IgorA 267
    stdcall InitColText,edi
1338 IgorA 268
    call CmColored
1456 IgorA 269
    stdcall draw_main_win,edi
1338 IgorA 270
  @@:
1456 IgorA 271
  pop edi
1338 IgorA 272
  ret
1456 IgorA 273
endp
1338 IgorA 274
 
1456 IgorA 275
align 4
276
proc ted_but_select_word, edit:dword
277
  pushad
278
  mov edi,dword[edit]
1338 IgorA 279
 
280
  call GetPos
281
  push edx
282
    call ItPervColorTag
1456 IgorA 283
    cmp edx,ted_tex_1
1338 IgorA 284
    jle @f
285
      call GetTexCoords
1456 IgorA 286
      mov ted_sel_x0,ebx
287
      mov ted_sel_y0,eax
1338 IgorA 288
    @@:
289
  pop edx
290
    call ItNextColorTag
1456 IgorA 291
    cmp edx,ted_tex_1
1338 IgorA 292
    jle @f
293
      call GetTexCoords
1456 IgorA 294
      mov ted_sel_x1,ebx
295
      mov ted_sel_y1,eax
1338 IgorA 296
    @@:
1456 IgorA 297
 
1338 IgorA 298
  call draw_but_toolbar
1456 IgorA 299
  stdcall draw_main_win,edi
300
  popad
301
  ret
302
endp
1338 IgorA 303
 
1456 IgorA 304
align 4
305
proc ted_but_cut, edit:dword
306
  push edi
307
  mov edi,dword[edit]
308
 
309
  stdcall ted_but_copy,edi
310
  stdcall ted_set_undo,edi
311
  stdcall SelTextDel,ted_opt_ed_change_time
312
 
1338 IgorA 313
  cmp al,1
314
  jne @f
315
    call draw_but_toolbar
1456 IgorA 316
    stdcall draw_main_win,edi
1338 IgorA 317
  @@:
1456 IgorA 318
  pop edi
319
  ret
320
endp
1338 IgorA 321
 
322
;output:
323
; al = 1 if copy text
1456 IgorA 324
align 4
325
proc ted_but_copy, edit:dword
326
  pushad
327
  mov edi,dword[edit]
328
 
329
  stdcall IsSel,edi
1338 IgorA 330
  cmp al,0
1456 IgorA 331
  je .end_f ;if not selected text
332
  stdcall SelNormalize,edi
1338 IgorA 333
 
1456 IgorA 334
  mov esi,ted_seln_x1
335
  mov ecx,ted_seln_y1
1338 IgorA 336
  call GetPosByParam
337
  mov ebx,edx
1456 IgorA 338
  mov esi,ted_seln_x0
339
  mov ecx,ted_seln_y0
1338 IgorA 340
  call GetPosByParam
341
  mov esi,ebx
342
 
343
  xor ecx,ecx
344
  mov ebx,buf
1456 IgorA 345
  ;mov edx,ted_tex
1338 IgorA 346
  @@:
1456 IgorA 347
    cmp edx,ted_tex_1 ;end of file
1338 IgorA 348
    jle @f
349
    cmp edx,esi ;end of select
350
    je @f
351
    inc ecx
352
    cmp ecx,BUF_SIZE ;owerflow bufer
353
    je @f
354
 
355
    mov al,byte[edx]
356
    mov byte[ebx],al
357
    inc ebx
358
 
359
    call IteratNext
360
    jmp @b
361
  @@:
362
  add ecx,buf
363
  mov byte[ebx],0
364
 
365
  cmp ecx,0
1456 IgorA 366
  je .end_f
1338 IgorA 367
    call draw_but_toolbar
1456 IgorA 368
    stdcall draw_bufer,edi
369
  .end_f:
370
  popad
1338 IgorA 371
  ret
1456 IgorA 372
endp
1338 IgorA 373
 
1456 IgorA 374
 
375
align 4
376
proc ted_but_paste, edit:dword
377
  push eax ebx esi edi
378
  mov edi,dword[edit]
379
 
1338 IgorA 380
    mov esi,buf
381
    call strlen
382
    cmp eax,1
383
    jl @f
1456 IgorA 384
      stdcall ted_set_undo,edi
1338 IgorA 385
      mov esi,eax
1456 IgorA 386
      mov ebx,ted_opt_ed_change_time+ted_opt_ed_move_cursor
387
      stdcall SelTextDel,ebx
388
	  cmp al,1
389
	  jne .del
390
	    mov ebx,ted_opt_ed_move_cursor
391
	  .del:
392
      stdcall ted_text_add,edi,buf,esi,ebx
1338 IgorA 393
      call draw_but_toolbar
1456 IgorA 394
      stdcall draw_main_win,edi
1338 IgorA 395
    @@:
1456 IgorA 396
  pop edi esi ebx eax
397
  ret
398
endp
1338 IgorA 399
 
1456 IgorA 400
align 4
1449 IgorA 401
proc but_find, edit:dword ;вызов/скрытие панели поиска
402
  push edi
1456 IgorA 403
  mov edi,dword[edit]
1449 IgorA 404
 
1456 IgorA 405
  cmp ted_panel_id,TE_PANEL_NULL
1338 IgorA 406
  je @f
1456 IgorA 407
    mov ted_panel_id,TE_PANEL_NULL
1449 IgorA 408
    mov ted_wnd_l,0
1338 IgorA 409
    jmp .e_if
410
  @@:
1456 IgorA 411
    mov ted_panel_id,TE_PANEL_FIND
1449 IgorA 412
    mov ted_wnd_l,TE_PANEL_WIDTH
1338 IgorA 413
  .e_if:
1449 IgorA 414
  stdcall EvSize,edi
415
  stdcall draw_main_win,edi
416
  pop edi
417
  ret
418
endp
1338 IgorA 419
 
1456 IgorA 420
align 4
1338 IgorA 421
but_replace:
1456 IgorA 422
  ret
1338 IgorA 423
 
1456 IgorA 424
align 4
1338 IgorA 425
but_find_key_w:
1456 IgorA 426
  ret
1338 IgorA 427
 
1456 IgorA 428
align 4
429
proc but_sumb_upper, edit:dword
430
  push edi esi
431
  mov edi,dword[edit]
432
 
1338 IgorA 433
  mov [conv_table],EvUpper
434
  call ConvertSelText
1456 IgorA 435
  cmp esi,0
1338 IgorA 436
  je @f
1456 IgorA 437
    stdcall draw_main_win,edi
1338 IgorA 438
  @@:
1456 IgorA 439
  pop esi edi
440
  ret
441
endp
1338 IgorA 442
 
1456 IgorA 443
align 4
444
proc but_sumb_lover, edit:dword
445
  push edi esi
446
  mov edi,dword[edit]
447
 
1338 IgorA 448
  mov [conv_table],EvLover
449
  call ConvertSelText
1456 IgorA 450
  cmp esi,0
1338 IgorA 451
  je @f
1456 IgorA 452
    stdcall draw_main_win,edi
1338 IgorA 453
  @@:
1456 IgorA 454
  pop esi edi
455
  ret
456
endp
1338 IgorA 457
 
1456 IgorA 458
align 4
459
proc but_reverse, edit:dword
460
  push eax ebx edi
461
  mov edi,dword[edit]
462
 
463
  stdcall IsSel,edi
1338 IgorA 464
  cmp al,0
465
  je @f
1456 IgorA 466
    stdcall SelNormalize,edi
1338 IgorA 467
    push esi ecx edx
1456 IgorA 468
      mov esi,ted_seln_x0
469
      mov ecx,ted_seln_y0
1338 IgorA 470
      call GetPosByParam
471
      mov eax,edx
1456 IgorA 472
      mov esi,ted_seln_x1
1338 IgorA 473
      cmp esi,0
474
      je .beg_str
475
	dec esi
476
      .beg_str:
1456 IgorA 477
      mov ecx,ted_seln_y1
1338 IgorA 478
      call GetPosByParam
479
      ;call GetTexPervPos
480
      mov ebx,edx
481
    pop edx ecx esi
482
    ;cmp eax,...
483
    ;je @f
484
    call Revers
485
  @@:
1456 IgorA 486
  stdcall draw_main_win,edi
487
  pop edi ebx eax
488
  ret
489
endp
1338 IgorA 490
 
1456 IgorA 491
align 4
492
proc ted_but_undo, edit:dword
493
  push eax edi
494
  mov edi,dword[edit]
1338 IgorA 495
 
1456 IgorA 496
  mov eax,ted_tim_undo
497
  cmp ted_tim_ch,eax
498
  jbe @f
499
    inc ted_tim_undo
500
    ;call CmColored
501
	stdcall draw_main_win,edi
502
	call draw_but_toolbar
503
  @@:
504
  pop edi eax
505
  ret
506
endp
1338 IgorA 507
 
1456 IgorA 508
align 4
509
proc ted_but_redo, edit:dword
510
  push edi
511
  mov edi,dword[edit]
1338 IgorA 512
 
1456 IgorA 513
  cmp ted_tim_undo,1
514
  jb @f
515
    dec ted_tim_undo
516
    ;call CmColored
517
	stdcall draw_main_win,edi
518
	call draw_but_toolbar
519
  @@:
520
  pop edi
521
  ret
522
endp
1338 IgorA 523
 
1456 IgorA 524
align 4
525
proc but_sumb_invis, edit:dword
526
  push edi
527
  mov edi,dword[edit]
1338 IgorA 528
 
1456 IgorA 529
  xor ted_mode_invis,1
530
  call draw_but_toolbar
531
  stdcall draw_main_win,edi
532
  pop edi
533
  ret
534
endp
1338 IgorA 535
 
1456 IgorA 536
align 4
537
proc but_k_words_show, edit:dword
538
  push edi
539
  mov edi,dword[edit]
1338 IgorA 540
 
1456 IgorA 541
  xor ted_mode_color,1
542
  cmp ted_mode_color,0
543
  je @f
544
    call CmColored
545
  @@:
1338 IgorA 546
  call draw_but_toolbar
1456 IgorA 547
  stdcall draw_main_win,edi
548
  pop edi
1338 IgorA 549
  ret
1456 IgorA 550
endp
1338 IgorA 551
 
1456 IgorA 552
 
553
;input:
554
; edi = pointer to tedit struct
555
align 4
556
but_CtrlHome:
557
	mov ted_cur_x,0
558
	mov ted_cur_y,0
559
	push eax
560
		mov eax,ted_scr_w
561
		mov dword[eax+sb_offs_position],0
562
		mov eax,ted_scr_h
563
		mov dword[eax+sb_offs_position],0
564
	pop eax
565
	call draw_but_toolbar
566
	stdcall draw_main_win,edi
567
	ret
568
 
569
align 4
1449 IgorA 570
proc but_synt_show, edit:dword
571
  push edi
572
  mov edi,[edit]
573
 
1456 IgorA 574
  cmp ted_panel_id,TE_PANEL_NULL
1338 IgorA 575
  je @f
1456 IgorA 576
    mov ted_panel_id,TE_PANEL_NULL
1449 IgorA 577
    mov ted_wnd_l,0
1338 IgorA 578
    jmp .e_if
579
  @@:
1456 IgorA 580
    mov ted_panel_id,TE_PANEL_SYNTAX
1449 IgorA 581
    mov ted_wnd_l,TE_PANEL_WIDTH
1338 IgorA 582
  .e_if:
1449 IgorA 583
  stdcall EvSize,edi
584
  stdcall draw_main_win,edi
585
  pop edi
586
  ret
587
endp
1338 IgorA 588
 
1456 IgorA 589
align 4
590
proc ted_sel_key_up, edit:dword
591
  push edi
592
  mov edi,dword[edit]
593
 
594
  cmp ted_drag_k,1
1338 IgorA 595
  je @f
1456 IgorA 596
    stdcall SelStart,edi
597
    mov ted_drag_k,1
1338 IgorA 598
  @@:
599
  push dx
600
    call CurMoveUp
601
    cmp dl,8
602
    jne @f
603
      call OnInitialUpdate
604
    @@:
605
  pop dx
1456 IgorA 606
  stdcall SelMove,edi
607
  stdcall draw_main_win,edi
608
  pop edi
1338 IgorA 609
  ret
1456 IgorA 610
endp
1338 IgorA 611
 
1456 IgorA 612
align 4
613
proc ted_sel_key_down, edit:dword
614
  push edi
615
  mov edi,dword[edit]
616
 
617
  cmp ted_drag_k,1
1338 IgorA 618
  je @f
1456 IgorA 619
    stdcall SelStart,edi
620
    mov ted_drag_k,1
1338 IgorA 621
  @@:
622
  push dx
623
    call CurMoveDown
624
    cmp dl,8
625
    jne @f
626
      call OnInitialUpdate
627
    @@:
628
  pop dx
1456 IgorA 629
  stdcall SelMove,edi
630
  stdcall draw_main_win,edi
631
  pop edi
1338 IgorA 632
  ret
1456 IgorA 633
endp
1338 IgorA 634
 
1456 IgorA 635
align 4
636
proc ted_sel_key_left, edit:dword
637
  push edi
638
  mov edi,dword[edit]
639
 
640
  cmp ted_drag_k,1
1338 IgorA 641
  je @f
1456 IgorA 642
    stdcall SelStart,edi
1338 IgorA 643
  @@:
644
  push dx
645
    call CurMoveLeft
1456 IgorA 646
    stdcall SelMove,edi
647
    cmp ted_drag_k,1
1338 IgorA 648
    je @f
1456 IgorA 649
      mov ted_drag_k,1
1338 IgorA 650
      mov dl,8
651
    @@:
652
    cmp dl,8
653
    jne @f
654
      call OnInitialUpdate
1456 IgorA 655
      stdcall draw_main_win,edi
1338 IgorA 656
      jmp .end_f
657
    @@:
1456 IgorA 658
      stdcall draw_cur_line,edi
1338 IgorA 659
    .end_f:
660
  pop dx
1456 IgorA 661
  pop edi
1338 IgorA 662
  ret
1456 IgorA 663
endp
1338 IgorA 664
 
1456 IgorA 665
align 4
666
proc ted_sel_key_right, edit:dword
667
  push edi
668
  mov edi,dword[edit]
669
 
670
  cmp ted_drag_k,1
1338 IgorA 671
  je @f
1456 IgorA 672
    stdcall SelStart,edi
1338 IgorA 673
  @@:
674
  push dx
675
    call CurMoveRight
1456 IgorA 676
    stdcall SelMove,edi
677
    cmp ted_drag_k,1
1338 IgorA 678
    je @f
1456 IgorA 679
      mov ted_drag_k,1
1338 IgorA 680
      mov dl,8
681
    @@:
682
    cmp dl,8
683
    jne @f
684
      call OnInitialUpdate
1456 IgorA 685
      stdcall draw_main_win,edi
1338 IgorA 686
      jmp .end_f
687
    @@:
1456 IgorA 688
      stdcall draw_cur_line,edi
1338 IgorA 689
    .end_f:
690
  pop dx
1456 IgorA 691
  pop edi
692
  ret
693
endp