Commit bfffb7e55768824f78e39b079cfb8c5b4a3c3e76
1 parent
fedf0724
Exists in
master
and in
3 other branches
Acertando ponteiro do mouse em windows, corrigindo "drag" da area selecionada
Showing
1 changed file
with
28 additions
and
13 deletions
Show diff stats
selection.c
| ... | ... | @@ -437,27 +437,42 @@ LIB3270_EXPORT int lib3270_get_selected_addr(H3270 *hSession, int *begin, int *e |
| 437 | 437 | |
| 438 | 438 | LIB3270_EXPORT int lib3270_move_selected_area(H3270 *hSession, int from, int to) |
| 439 | 439 | { |
| 440 | - int step = (to - from); | |
| 441 | - int first, last, pos, len; | |
| 440 | + int pos[2]; | |
| 441 | + int rows, cols, f, step; | |
| 442 | 442 | |
| 443 | - if(lib3270_get_selected_addr(hSession,&first,&last)) | |
| 443 | + if(lib3270_get_selected_addr(hSession,&pos[0],&pos[1])) | |
| 444 | 444 | return from; |
| 445 | 445 | |
| 446 | - len = hSession->rows * hSession->cols; | |
| 446 | + rows = (to / hSession->cols) - (from / hSession->cols); | |
| 447 | + cols = (to % hSession->cols) - (from % hSession->cols); | |
| 447 | 448 | |
| 448 | - pos = first+step; | |
| 449 | - trace("first=%d pos=%d step=%d",first,pos,step); | |
| 450 | - if(pos < 0) | |
| 451 | - step -= pos; | |
| 449 | + for(f=0;f<2;f++) | |
| 450 | + { | |
| 451 | + int row = (pos[f] / hSession->cols) + rows; | |
| 452 | + int col = (pos[f] % hSession->cols) + cols; | |
| 453 | + | |
| 454 | + if(row < 0) | |
| 455 | + rows = - (pos[f] / hSession->cols); | |
| 456 | + | |
| 457 | + if(col < 0) | |
| 458 | + cols = - (pos[f] % hSession->cols); | |
| 459 | + | |
| 460 | + if(row >= (hSession->rows)) | |
| 461 | + rows = hSession->rows - ((pos[f] / hSession->cols)+1); | |
| 452 | 462 | |
| 453 | - pos = last+step; | |
| 454 | - if(pos > len) | |
| 455 | - step -= (pos - len); | |
| 463 | + if(col >= hSession->cols) | |
| 464 | + cols = hSession->cols - ((pos[f] % hSession->cols)+1); | |
| 465 | + } | |
| 466 | + | |
| 467 | + step = (rows * hSession->cols) + cols; | |
| 456 | 468 | |
| 469 | + hSession->select.begin += step; | |
| 470 | + hSession->select.end += step; | |
| 457 | 471 | |
| 458 | - trace("%s step=%d",__FUNCTION__,step); | |
| 472 | + update_selection(hSession); | |
| 473 | + lib3270_set_cursor_address(hSession,hSession->select.end); | |
| 459 | 474 | |
| 460 | - return from; | |
| 475 | + return from+step; | |
| 461 | 476 | } |
| 462 | 477 | |
| 463 | 478 | LIB3270_EXPORT int lib3270_move_selection(H3270 *hSession, LIB3270_DIRECTION dir) | ... | ... |