Commit 987608c619781ed7de3b34a86ab15bb8fdeeb927
1 parent
0abc5003
Exists in
master
and in
3 other branches
Iniciando implementação do recurso "copy" com atributos
Showing
1 changed file
with
30 additions
and
14 deletions
Show diff stats
selection.c
| @@ -372,12 +372,13 @@ LIB3270_ACTION( reselect ) | @@ -372,12 +372,13 @@ LIB3270_ACTION( reselect ) | ||
| 372 | return 0; | 372 | return 0; |
| 373 | } | 373 | } |
| 374 | 374 | ||
| 375 | -static char * get_text(H3270 *hSession,unsigned char all) | 375 | +static char * get_text(H3270 *hSession,unsigned char all, unsigned char tok) |
| 376 | { | 376 | { |
| 377 | - int row, col, baddr; | ||
| 378 | - char *ret; | ||
| 379 | - size_t buflen = (hSession->rows * (hSession->cols+1))+1; | ||
| 380 | - size_t sz = 0; | 377 | + int row, col, baddr; |
| 378 | + char * ret; | ||
| 379 | + size_t buflen = (hSession->rows * (hSession->cols+1))+1; | ||
| 380 | + size_t sz = 0; | ||
| 381 | + unsigned short attr = 0; | ||
| 381 | 382 | ||
| 382 | if(!(lib3270_connected(hSession) && hSession->text)) | 383 | if(!(lib3270_connected(hSession) && hSession->text)) |
| 383 | { | 384 | { |
| @@ -388,6 +389,15 @@ static char * get_text(H3270 *hSession,unsigned char all) | @@ -388,6 +389,15 @@ static char * get_text(H3270 *hSession,unsigned char all) | ||
| 388 | ret = lib3270_malloc(buflen); | 389 | ret = lib3270_malloc(buflen); |
| 389 | 390 | ||
| 390 | baddr = 0; | 391 | baddr = 0; |
| 392 | + | ||
| 393 | + if(tok) | ||
| 394 | + { | ||
| 395 | + attr = hSession->text[baddr].attr; | ||
| 396 | + ret[sz++] = tok; | ||
| 397 | + ret[sz++] = (attr & 0x0F); | ||
| 398 | + ret[sz++] = ((attr & 0xF0) >> 4); | ||
| 399 | + } | ||
| 400 | + | ||
| 391 | for(row=0;row < hSession->rows;row++) | 401 | for(row=0;row < hSession->rows;row++) |
| 392 | { | 402 | { |
| 393 | int cr = 0; | 403 | int cr = 0; |
| @@ -396,6 +406,14 @@ static char * get_text(H3270 *hSession,unsigned char all) | @@ -396,6 +406,14 @@ static char * get_text(H3270 *hSession,unsigned char all) | ||
| 396 | { | 406 | { |
| 397 | if(all || hSession->text[baddr].attr & LIB3270_ATTR_SELECTED) | 407 | if(all || hSession->text[baddr].attr & LIB3270_ATTR_SELECTED) |
| 398 | { | 408 | { |
| 409 | + if(tok && attr != hSession->text[baddr].attr) | ||
| 410 | + { | ||
| 411 | + attr = hSession->text[baddr].attr; | ||
| 412 | + ret[sz++] = tok; | ||
| 413 | + ret[sz++] = (attr & 0x0F); | ||
| 414 | + ret[sz++] = ((attr & 0xF0) >> 4); | ||
| 415 | + } | ||
| 416 | + | ||
| 399 | cr++; | 417 | cr++; |
| 400 | ret[sz++] = hSession->text[baddr].chr; | 418 | ret[sz++] = hSession->text[baddr].chr; |
| 401 | } | 419 | } |
| @@ -404,6 +422,12 @@ static char * get_text(H3270 *hSession,unsigned char all) | @@ -404,6 +422,12 @@ static char * get_text(H3270 *hSession,unsigned char all) | ||
| 404 | 422 | ||
| 405 | if(cr) | 423 | if(cr) |
| 406 | ret[sz++] = '\n'; | 424 | ret[sz++] = '\n'; |
| 425 | + | ||
| 426 | + if((sz+10) > buflen) | ||
| 427 | + { | ||
| 428 | + buflen += 100; | ||
| 429 | + ret = lib3270_realloc(ret,buflen); | ||
| 430 | + } | ||
| 407 | } | 431 | } |
| 408 | 432 | ||
| 409 | if(!sz) | 433 | if(!sz) |
| @@ -563,7 +587,7 @@ LIB3270_EXPORT char * lib3270_get_selected(H3270 *hSession) | @@ -563,7 +587,7 @@ LIB3270_EXPORT char * lib3270_get_selected(H3270 *hSession) | ||
| 563 | return NULL; | 587 | return NULL; |
| 564 | 588 | ||
| 565 | 589 | ||
| 566 | - return get_text(hSession,0); | 590 | + return get_text(hSession,0,0); |
| 567 | } | 591 | } |
| 568 | 592 | ||
| 569 | static void copy_chr(H3270 *hSession, int from, int to) | 593 | static void copy_chr(H3270 *hSession, int from, int to) |
| @@ -602,14 +626,6 @@ int cut_addr(H3270 *hSession, int daddr, int saddr, int maxlen, int *sattr) | @@ -602,14 +626,6 @@ int cut_addr(H3270 *hSession, int daddr, int saddr, int maxlen, int *sattr) | ||
| 602 | if(hSession->ea_buf[saddr].fa) | 626 | if(hSession->ea_buf[saddr].fa) |
| 603 | *sattr = hSession->ea_buf[saddr++].fa; | 627 | *sattr = hSession->ea_buf[saddr++].fa; |
| 604 | 628 | ||
| 605 | -/* | ||
| 606 | - if(FA_IS_PROTECTED(*sattr)) | ||
| 607 | - { | ||
| 608 | - saddr = lib3270_get_next_unprotected(hSession,saddr); | ||
| 609 | - *sattr = lib3270_field_attribute(hSession,saddr); | ||
| 610 | - } | ||
| 611 | -*/ | ||
| 612 | - | ||
| 613 | if(FA_IS_PROTECTED(*sattr) || saddr >= maxlen) | 629 | if(FA_IS_PROTECTED(*sattr) || saddr >= maxlen) |
| 614 | clear_chr(hSession,daddr); | 630 | clear_chr(hSession,daddr); |
| 615 | else | 631 | else |