Commit 7b3a48204f9716bcf5c777ee1f39c1d7fbb36eb1
1 parent
d0ffcc12
Exists in
master
and in
3 other branches
Changing "cut" methods to use the same code for "get".
Showing
2 changed files
with
53 additions
and
27 deletions
Show diff stats
src/lib3270/selection/actions.c
| ... | ... | @@ -18,7 +18,7 @@ |
| 18 | 18 | * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin |
| 19 | 19 | * St, Fifth Floor, Boston, MA 02110-1301 USA |
| 20 | 20 | * |
| 21 | - * Este programa está nomeado como selection.c e possui - linhas de código. | |
| 21 | + * Este programa está nomeado como - e possui - linhas de código. | |
| 22 | 22 | * |
| 23 | 23 | * Contatos: |
| 24 | 24 | * | ... | ... |
src/lib3270/selection/selection.c
| ... | ... | @@ -241,7 +241,21 @@ LIB3270_EXPORT unsigned char lib3270_get_selection_flags(H3270 *hSession, int ba |
| 241 | 241 | return rc; |
| 242 | 242 | } |
| 243 | 243 | |
| 244 | -static char * get_text(H3270 *hSession,unsigned char all, unsigned char tok) | |
| 244 | +static void clear_chr(H3270 *hSession, int baddr) | |
| 245 | +{ | |
| 246 | + hSession->text[baddr].chr = ' '; | |
| 247 | + | |
| 248 | + hSession->ea_buf[baddr].cc = EBC_null; | |
| 249 | + hSession->ea_buf[baddr].cs = 0; | |
| 250 | + | |
| 251 | + hSession->cbk.update( hSession, | |
| 252 | + baddr, | |
| 253 | + hSession->text[baddr].chr, | |
| 254 | + hSession->text[baddr].attr, | |
| 255 | + baddr == hSession->cursor_addr ); | |
| 256 | +} | |
| 257 | + | |
| 258 | +static char * get_text(H3270 *hSession,unsigned char all, unsigned char tok, Boolean cut) | |
| 245 | 259 | { |
| 246 | 260 | int row, col, baddr; |
| 247 | 261 | char * ret; |
| ... | ... | @@ -258,6 +272,7 @@ static char * get_text(H3270 *hSession,unsigned char all, unsigned char tok) |
| 258 | 272 | ret = lib3270_malloc(buflen); |
| 259 | 273 | |
| 260 | 274 | baddr = 0; |
| 275 | + unsigned char fa = 0; | |
| 261 | 276 | |
| 262 | 277 | for(row=0;row < hSession->rows;row++) |
| 263 | 278 | { |
| ... | ... | @@ -265,6 +280,10 @@ static char * get_text(H3270 *hSession,unsigned char all, unsigned char tok) |
| 265 | 280 | |
| 266 | 281 | for(col = 0; col < hSession->cols;col++) |
| 267 | 282 | { |
| 283 | + if(hSession->ea_buf[baddr].fa) { | |
| 284 | + fa = hSession->ea_buf[baddr].fa; | |
| 285 | + } | |
| 286 | + | |
| 268 | 287 | if(all || hSession->text[baddr].attr & LIB3270_ATTR_SELECTED) |
| 269 | 288 | { |
| 270 | 289 | if(tok && attr != hSession->text[baddr].attr) |
| ... | ... | @@ -273,10 +292,16 @@ static char * get_text(H3270 *hSession,unsigned char all, unsigned char tok) |
| 273 | 292 | ret[sz++] = tok; |
| 274 | 293 | ret[sz++] = (attr & 0x0F); |
| 275 | 294 | ret[sz++] = ((attr & 0xF0) >> 4); |
| 295 | + | |
| 276 | 296 | } |
| 277 | 297 | |
| 278 | 298 | cr++; |
| 279 | 299 | ret[sz++] = hSession->text[baddr].chr; |
| 300 | + | |
| 301 | + if(cut && !FA_IS_PROTECTED(fa)) { | |
| 302 | + clear_chr(hSession,baddr); | |
| 303 | + } | |
| 304 | + | |
| 280 | 305 | } |
| 281 | 306 | baddr++; |
| 282 | 307 | } |
| ... | ... | @@ -455,8 +480,27 @@ LIB3270_EXPORT char * lib3270_get_selected(H3270 *hSession) |
| 455 | 480 | if(!lib3270_connected(hSession)) |
| 456 | 481 | return NULL; |
| 457 | 482 | |
| 483 | + return get_text(hSession,0,0,0); | |
| 484 | +} | |
| 485 | + | |
| 486 | +LIB3270_EXPORT char * lib3270_cut_selected(H3270 *hSession) | |
| 487 | +{ | |
| 488 | + CHECK_SESSION_HANDLE(hSession); | |
| 458 | 489 | |
| 459 | - return get_text(hSession,0,0); | |
| 490 | + if(!hSession->selected || hSession->select.start == hSession->select.end) | |
| 491 | + return NULL; | |
| 492 | + | |
| 493 | + if(!lib3270_connected(hSession)) | |
| 494 | + return NULL; | |
| 495 | + | |
| 496 | + return get_text(hSession,0,0,1); | |
| 497 | +} | |
| 498 | + | |
| 499 | +/* | |
| 500 | + | |
| 501 | +LIB3270_EXPORT char * lib3270_cut_selected(H3270 *hSession) | |
| 502 | +{ | |
| 503 | + return cut_text(hSession,0); | |
| 460 | 504 | } |
| 461 | 505 | |
| 462 | 506 | static void copy_chr(H3270 *hSession, int from, int to) |
| ... | ... | @@ -476,20 +520,6 @@ static void copy_chr(H3270 *hSession, int from, int to) |
| 476 | 520 | to == hSession->cursor_addr ); |
| 477 | 521 | } |
| 478 | 522 | |
| 479 | -static void clear_chr(H3270 *hSession, int baddr) | |
| 480 | -{ | |
| 481 | - hSession->text[baddr].chr = ' '; | |
| 482 | - | |
| 483 | - hSession->ea_buf[baddr].cc = EBC_null; | |
| 484 | - hSession->ea_buf[baddr].cs = 0; | |
| 485 | - | |
| 486 | - hSession->cbk.update( hSession, | |
| 487 | - baddr, | |
| 488 | - hSession->text[baddr].chr, | |
| 489 | - hSession->text[baddr].attr, | |
| 490 | - baddr == hSession->cursor_addr ); | |
| 491 | -} | |
| 492 | - | |
| 493 | 523 | int cut_addr(H3270 *hSession, int daddr, int saddr, int maxlen, int *sattr) |
| 494 | 524 | { |
| 495 | 525 | if(hSession->ea_buf[saddr].fa) |
| ... | ... | @@ -528,10 +558,10 @@ char * cut_text(H3270 *hSession, char tok) |
| 528 | 558 | size_t szText; |
| 529 | 559 | size_t buflen; |
| 530 | 560 | size_t bufpos = 0; |
| 531 | - int daddr; /* Destination addr */ | |
| 532 | - int dattr; /* Destination addr attribute */ | |
| 533 | - int saddr; /* Source addr (First field after the selected area) */ | |
| 534 | - int sattr; /* Source addr attribute */ | |
| 561 | + int daddr; // Destination addr | |
| 562 | + int dattr; // Destination addr attribute | |
| 563 | + int saddr; // Source addr (First field after the selected area) | |
| 564 | + int sattr; // Source addr attribute | |
| 535 | 565 | char *text; |
| 536 | 566 | size_t maxlen = hSession->rows * hSession->cols; |
| 537 | 567 | size_t f; |
| ... | ... | @@ -543,7 +573,7 @@ char * cut_text(H3270 *hSession, char tok) |
| 543 | 573 | if(daddr >= end) |
| 544 | 574 | return NULL; |
| 545 | 575 | |
| 546 | - dattr = lib3270_field_attribute(hSession,daddr); /* Get first attribute */ | |
| 576 | + dattr = lib3270_field_attribute(hSession,daddr); // Get first attribute | |
| 547 | 577 | |
| 548 | 578 | szText = (end-daddr)+1; |
| 549 | 579 | buflen = szText; |
| ... | ... | @@ -603,8 +633,4 @@ char * cut_text(H3270 *hSession, char tok) |
| 603 | 633 | return NULL; |
| 604 | 634 | } |
| 605 | 635 | |
| 606 | -LIB3270_EXPORT char * lib3270_cut_selected(H3270 *hSession) | |
| 607 | -{ | |
| 608 | - return cut_text(hSession,0); | |
| 609 | -} | |
| 610 | - | |
| 636 | +*/ | ... | ... |