Subversion Repositories Kolibri OS

Rev

Rev 6788 | Rev 6968 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 6788 Rev 6965
Line 356... Line 356...
356
        mov     ed_pos,eax
356
        mov     ed_pos,eax
357
        call    edit_box.draw_bg
357
        call    edit_box.draw_bg
358
        call    edit_box.draw_shift
358
        call    edit_box.draw_shift
359
        call    edit_box_key.sh_home_end
359
        call    edit_box_key.sh_home_end
360
        jmp     edit_box.draw_cursor_text
360
        jmp     edit_box.draw_cursor_text
-
 
361
;----------------------------------------
361
 
362
StrInsert:
-
 
363
; SizeOf(TmpBuf) >= StrLen(Src) + StrLen(Dst) + 1              
-
 
364
Dst    equ [esp + 20] ; - destination buffer
-
 
365
Src    equ [esp + 16] ; - source to insert from
-
 
366
Pos    equ [esp + 12] ; - position for insert
-
 
367
DstMax equ [esp + 8]  ; - maximum Dst length(exclude terminating null)
-
 
368
TmpBuf equ [esp + 4]  ; - temporary buffer              
-
 
369
        xor    edx, edx
-
 
370
        mov    esi, Dst
-
 
371
        mov    edi, TmpBuf
-
 
372
        mov    ecx, Pos
-
 
373
        add    edx, ecx
-
 
374
        rep movsb 
-
 
375
        mov    edi, Src
-
 
376
        mov    ecx, -1
-
 
377
        xor    eax, eax
-
 
378
        repne scasb 
-
 
379
        mov    eax, -2
-
 
380
        sub    eax, ecx
-
 
381
        add    edx, eax
-
 
382
        mov    esi, Src
-
 
383
        mov    edi, TmpBuf
-
 
384
        add    edi, Pos
-
 
385
        mov    ecx, eax
-
 
386
        rep movsb 
-
 
387
        mov    ebx, edi
-
 
388
        mov    edi, Dst
-
 
389
        add    edi, Pos
-
 
390
        mov    ecx, -1
-
 
391
        xor    eax, eax
-
 
392
        repne scasb 
-
 
393
        mov    eax, -2
-
 
394
        sub    eax, ecx
-
 
395
        inc    eax
-
 
396
        add    edx, eax
-
 
397
        mov    edi, ebx
-
 
398
        mov    esi, Pos
-
 
399
        add    esi, Dst
-
 
400
        mov    ecx, eax
-
 
401
        rep movsb 
-
 
402
        mov    esi, TmpBuf
-
 
403
        mov    edi, Dst
-
 
404
; ecx = MIN(edx, DstSize)        
-
 
405
        cmp    edx, DstMax
-
 
406
        sbb    ecx, ecx                                   
-
 
407
        and    edx, ecx
-
 
408
        not    ecx
-
 
409
        and    ecx, DstMax
-
 
410
        add    ecx, edx                                   
-
 
411
        mov    eax, ecx ; return total length
-
 
412
        rep movsb
-
 
413
        ret    20
-
 
414
restore Dst    
-
 
415
restore Src      
-
 
416
restore Pos    
-
 
417
restore DstSize
-
 
418
restore TmpBuf 
-
 
419
;----------------------------------------                
362
edit_box_key.ctrl_c:
420
edit_box_key.ctrl_c:
363
; add memory area
421
; add memory area
364
        mov     ecx,ed_size
422
        mov     ecx,ed_size
365
        add     ecx,3*4
423
        add     ecx,3*4
366
        mcall   SF_SYS_MISC,SSF_MEM_ALLOC
424
        mcall   SF_SYS_MISC,SSF_MEM_ALLOC
367
; building the clipboard slot header
425
; building the clipboard slot header
368
        xor     ecx,ecx
426
        xor     ecx,ecx
369
        mov     [eax+4],ecx ; type 'text'
427
        mov     [eax+4],ecx ; type 'text'
370
        inc     ecx
428
        inc     ecx
371
        mov     [eax+8],ecx ; cp866 text encoding
429
        mov     [eax+8],ecx ; cp866 text encoding
372
        mov     ecx,ed_size
430
        mov     ecx,ed_pos       
-
 
431
        movzx   ebx,word ed_shift_pos
-
 
432
        sub     ecx,ebx
-
 
433
.abs: ; make ecx = abs(ecx)
-
 
434
	       neg     ecx
-
 
435
	       jl	     .abs
373
        add     ecx,3*4
436
        add     ecx,3*4
374
        mov     [eax],ecx
437
        mov     [eax],ecx
375
        sub     ecx,3*4
438
        sub     ecx,3*4        
-
 
439
        mov     edx,ed_pos
-
 
440
        movzx   ebx,word ed_shift_pos
-
 
441
        cmp     edx,ebx
-
 
442
        jle     @f
-
 
443
        mov     edx,ebx
-
 
444
@@:        
376
; copy data
445
; copy data
377
        mov     esi,ed_text
446
        mov     esi,ed_text
-
 
447
        add     esi,edx
378
        push    edi
448
        push    edi
379
        mov     edi,eax
449
        mov     edi,eax
380
        add     edi,3*4
450
        add     edi,3*4
381
        cld
451
        cld
382
        rep     movsb
452
        rep     movsb
Line 422... Line 492...
422
; check for cp866
492
; check for cp866
423
        cmp     bl,1
493
        cmp     bl,1
424
        jnz     .no_valid_text
494
        jnz     .no_valid_text
425
        mov     ecx,[eax]
495
        mov     ecx,[eax]
426
        sub     ecx,3*4
496
        sub     ecx,3*4
-
 
497
; in ecx size of string to insert   
-
 
498
        add     ecx,ed_size
-
 
499
        mov     edx,ed_max
-
 
500
        sub     edx,2 ; 2 reserved for edit_box
427
        cmp     ecx,ed_max
501
        cmp     ecx,edx
428
        jb      @f
502
        jb      @f
429
        mov     ecx,ed_max
503
        mov     ecx,edx
430
@@:
504
@@:
431
        mov     esi,eax
505
        mov     esi,eax
432
        add     esi,3*4
506
        add     esi,3*4
433
        mov     ed_size,ecx
-
 
434
        mov     ed_pos,ecx
-
 
435
        push    eax edi
507
        push    eax edi
-
 
508
;---------------------------------------;         
-
 
509
        mov     ed_size,ecx
-
 
510
        inc     ecx        
-
 
511
        mcall   SF_SYS_MISC,SSF_MEM_ALLOC
-
 
512
        push    eax ; save mem pointer
-
 
513
                
-
 
514
        mov     edx, ed_max
-
 
515
        sub     edx, 3 ; +1 for StrInsert, +2 as reserved for edit_box
-
 
516
        
-
 
517
        push   dword ed_text ; Dst   
-
 
518
        push   esi           ; Src   
-
 
519
        push   dword ed_pos  ; Pos in Dst
-
 
520
        push   edx           ; DstMax
-
 
521
        push   eax           ; TmpBuf
-
 
522
        call   StrInsert  
-
 
523
        
-
 
524
        pop    eax ; restore mem pointer
-
 
525
        mcall   SF_SYS_MISC,SSF_MEM_FREE
-
 
526
;---------------------------------------;        
436
        mov     edi,ed_text
527
;        mov     edi,ed_text
437
        cld
528
;        cld
438
@@:
529
;@@:
439
        lodsb
530
;        lodsb
440
        cmp     al,0x0d ; EOS (end of string)
531
;        cmp     al,0x0d ; EOS (end of string)
441
        je      .replace
532
;        je      .replace
442
        cmp     al,0x0a ; EOS (end of string)
533
;        cmp     al,0x0a ; EOS (end of string)
443
        jne     .continue
534
;        jne     .continue
444
.replace:
535
;.replace:
445
        mov     al,0x20 ; space
536
;        mov     al,0x20 ; space
446
.continue:
537
;.continue:
447
        stosb
538
;        stosb
448
        dec     ecx
539
;        dec     ecx
449
        jnz     @b
540
;        jnz     @b
450
        pop     edi eax
541
        pop     edi eax
451
.no_valid_text:
542
.no_valid_text:
452
; remove unnecessary memory area
543
; remove unnecessary memory area
453
        mov     ecx,eax
544
        mov     ecx,eax
454
        mcall   SF_SYS_MISC,SSF_MEM_FREE
545
        mcall   SF_SYS_MISC,SSF_MEM_FREE