From bfffb7e55768824f78e39b079cfb8c5b4a3c3e76 Mon Sep 17 00:00:00 2001 From: perry.werneck@gmail.com Date: Mon, 2 Apr 2012 20:48:17 +0000 Subject: [PATCH] Acertando ponteiro do mouse em windows, corrigindo "drag" da area selecionada --- selection.c | 41 ++++++++++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/selection.c b/selection.c index aee6baf..4d10daf 100644 --- a/selection.c +++ b/selection.c @@ -437,27 +437,42 @@ LIB3270_EXPORT int lib3270_get_selected_addr(H3270 *hSession, int *begin, int *e LIB3270_EXPORT int lib3270_move_selected_area(H3270 *hSession, int from, int to) { - int step = (to - from); - int first, last, pos, len; + int pos[2]; + int rows, cols, f, step; - if(lib3270_get_selected_addr(hSession,&first,&last)) + if(lib3270_get_selected_addr(hSession,&pos[0],&pos[1])) return from; - len = hSession->rows * hSession->cols; + rows = (to / hSession->cols) - (from / hSession->cols); + cols = (to % hSession->cols) - (from % hSession->cols); - pos = first+step; - trace("first=%d pos=%d step=%d",first,pos,step); - if(pos < 0) - step -= pos; + for(f=0;f<2;f++) + { + int row = (pos[f] / hSession->cols) + rows; + int col = (pos[f] % hSession->cols) + cols; + + if(row < 0) + rows = - (pos[f] / hSession->cols); + + if(col < 0) + cols = - (pos[f] % hSession->cols); + + if(row >= (hSession->rows)) + rows = hSession->rows - ((pos[f] / hSession->cols)+1); - pos = last+step; - if(pos > len) - step -= (pos - len); + if(col >= hSession->cols) + cols = hSession->cols - ((pos[f] % hSession->cols)+1); + } + + step = (rows * hSession->cols) + cols; + hSession->select.begin += step; + hSession->select.end += step; - trace("%s step=%d",__FUNCTION__,step); + update_selection(hSession); + lib3270_set_cursor_address(hSession,hSession->select.end); - return from; + return from+step; } LIB3270_EXPORT int lib3270_move_selection(H3270 *hSession, LIB3270_DIRECTION dir) -- libgit2 0.21.2