Commit 9ed6bd9aee23fe8548ecb8095a2550cec85adc5e
1 parent
be38b135
Exists in
master
and in
5 other branches
Corrigindo tratamento de atributos na opção "cut"
Showing
3 changed files
with
59 additions
and
19 deletions
Show diff stats
src/include/lib3270.h
@@ -792,6 +792,8 @@ | @@ -792,6 +792,8 @@ | ||
792 | */ | 792 | */ |
793 | LIB3270_EXPORT int lib3270_field_addr(H3270 *h, int baddr); | 793 | LIB3270_EXPORT int lib3270_field_addr(H3270 *h, int baddr); |
794 | 794 | ||
795 | + LIB3270_EXPORT int lib3270_field_attribute(H3270 *hSession, int baddr); | ||
796 | + | ||
795 | /** | 797 | /** |
796 | * Get the length of the field at given buffer address. | 798 | * Get the length of the field at given buffer address. |
797 | * | 799 | * |
src/lib3270/ctlr.c
@@ -326,6 +326,27 @@ LIB3270_EXPORT int lib3270_field_addr(H3270 *hSession, int baddr) | @@ -326,6 +326,27 @@ LIB3270_EXPORT int lib3270_field_addr(H3270 *hSession, int baddr) | ||
326 | return -1; | 326 | return -1; |
327 | } | 327 | } |
328 | 328 | ||
329 | +LIB3270_EXPORT int lib3270_field_attribute(H3270 *hSession, int baddr) | ||
330 | +{ | ||
331 | + int sbaddr; | ||
332 | + | ||
333 | + CHECK_SESSION_HANDLE(hSession); | ||
334 | + | ||
335 | + if (!hSession->formatted) | ||
336 | + return -1; | ||
337 | + | ||
338 | + sbaddr = baddr; | ||
339 | + do | ||
340 | + { | ||
341 | + if(hSession->ea_buf[baddr].fa) | ||
342 | + return hSession->ea_buf[baddr].fa; | ||
343 | + DEC_BA(baddr); | ||
344 | + } while (baddr != sbaddr); | ||
345 | + | ||
346 | + return -1; | ||
347 | +} | ||
348 | + | ||
349 | + | ||
329 | /* | 350 | /* |
330 | * Get Field width | 351 | * Get Field width |
331 | */ | 352 | */ |
src/lib3270/selection.c
@@ -554,46 +554,63 @@ LIB3270_EXPORT char * lib3270_cut_selected(H3270 *hSession) | @@ -554,46 +554,63 @@ LIB3270_EXPORT char * lib3270_cut_selected(H3270 *hSession) | ||
554 | { | 554 | { |
555 | int end; | 555 | int end; |
556 | size_t szText; | 556 | size_t szText; |
557 | - int baddr; | ||
558 | - int saddr; | 557 | + int daddr; /* Destination addr */ |
558 | + int dattr; /* Destination addr attribute */ | ||
559 | + int saddr; /* Source addr (First field after the selected area) */ | ||
560 | + int sattr; /* Source addr attribute */ | ||
559 | char *text; | 561 | char *text; |
560 | int f; | 562 | int f; |
561 | 563 | ||
562 | - get_selected_addr(hSession,&baddr,&end); | 564 | + get_selected_addr(hSession,&daddr,&end); |
563 | 565 | ||
564 | - if(baddr >= end) | 566 | + if(daddr >= end) |
565 | return NULL; | 567 | return NULL; |
566 | 568 | ||
567 | - szText = (end-baddr)+1; | 569 | + dattr = lib3270_field_attribute(hSession,daddr); /* Get first attribute */ |
570 | + | ||
571 | + szText = (end-daddr)+1; | ||
568 | 572 | ||
569 | text = lib3270_malloc(szText+1); | 573 | text = lib3270_malloc(szText+1); |
570 | 574 | ||
571 | - saddr = baddr+szText; | 575 | + saddr = daddr+szText; |
576 | + sattr = lib3270_field_attribute(hSession,saddr); | ||
572 | 577 | ||
573 | for(f=0;f<szText;f++) | 578 | for(f=0;f<szText;f++) |
574 | { | 579 | { |
575 | - text[f] = hSession->text[baddr].chr; | 580 | + if(hSession->ea_buf[daddr].fa) |
581 | + dattr = hSession->ea_buf[daddr].fa; | ||
576 | 582 | ||
577 | - if(FA_IS_PROTECTED(hSession->ea_buf[saddr].fa)) | ||
578 | - saddr = lib3270_get_next_unprotected(hSession,saddr); | 583 | + text[f] = hSession->text[daddr].chr; |
579 | 584 | ||
580 | - if(!FA_IS_PROTECTED(hSession->ea_buf[saddr].fa)) | 585 | + if(!FA_IS_PROTECTED(dattr)) |
581 | { | 586 | { |
582 | - if(hSession->text[baddr].chr != hSession->text[saddr].chr) | 587 | + if(hSession->ea_buf[saddr].fa) |
588 | + sattr = hSession->ea_buf[saddr].fa; | ||
589 | + | ||
590 | + if(FA_IS_PROTECTED(sattr)) | ||
583 | { | 591 | { |
584 | - hSession->text[baddr].chr = hSession->text[saddr].chr; | ||
585 | - hSession->update(hSession,baddr,hSession->text[baddr].chr,hSession->text[baddr].attr,baddr == hSession->cursor_addr); | 592 | + saddr = lib3270_get_next_unprotected(hSession,saddr); |
593 | + sattr = lib3270_field_attribute(hSession,saddr); | ||
586 | } | 594 | } |
587 | 595 | ||
588 | - if(hSession->text[saddr].chr != ' ') | 596 | + if(!FA_IS_PROTECTED(sattr)) |
589 | { | 597 | { |
590 | - hSession->text[saddr].chr = ' '; | ||
591 | - hSession->update(hSession,saddr,hSession->text[saddr].chr,hSession->text[saddr].attr,saddr == hSession->cursor_addr); | 598 | + if(hSession->text[daddr].chr != hSession->text[saddr].chr) |
599 | + { | ||
600 | + hSession->text[daddr].chr = hSession->text[saddr].chr; | ||
601 | + hSession->update(hSession,daddr,hSession->text[daddr].chr,hSession->text[daddr].attr,daddr == hSession->cursor_addr); | ||
602 | + } | ||
603 | + | ||
604 | + if(hSession->text[saddr].chr != ' ') | ||
605 | + { | ||
606 | + hSession->text[saddr].chr = ' '; | ||
607 | + hSession->update(hSession,saddr,hSession->text[saddr].chr,hSession->text[saddr].attr,saddr == hSession->cursor_addr); | ||
608 | + } | ||
609 | + | ||
610 | + saddr++; | ||
592 | } | 611 | } |
593 | - | ||
594 | - saddr++; | ||
595 | } | 612 | } |
596 | - baddr++; | 613 | + daddr++; |
597 | } | 614 | } |
598 | 615 | ||
599 | lib3270_unselect(hSession); | 616 | lib3270_unselect(hSession); |