Commit a6fdb1f5b6a1f9335d21bf3a56d112e790c74b1c

Authored by perry.werneck@gmail.com
1 parent df9d674a

Corrigindo erro ao arrastar uma caixa de seleção que ocupe toda a tela do terminal

Showing 1 changed file with 12 additions and 7 deletions   Show diff stats
selection.c
... ... @@ -176,7 +176,7 @@ void toggle_rectselect(H3270 *session, struct lib3270_toggle *t, LIB3270_TOGGLE_
176 176 update_selected_region(session);
177 177 }
178 178  
179   -LIB3270_ACTION(unselect)
  179 +LIB3270_EXPORT int lib3270_unselect(H3270 *hSession)
180 180 {
181 181 int a;
182 182  
... ... @@ -242,11 +242,14 @@ LIB3270_EXPORT void lib3270_select_region(H3270 *h, int start, int end)
242 242  
243 243 static void do_select(H3270 *h, int start, int end, int rect)
244 244 {
  245 + if(start < 0 || end > (h->rows * h->cols))
  246 + return;
245 247  
246 248 // Do we really need to change selection?
247 249 if(start == h->select.start && end == h->select.end && h->selected)
248 250 return;
249 251  
  252 + // Start address is inside the screen?
250 253 h->select.start = start;
251 254 h->select.end = end;
252 255  
... ... @@ -340,20 +343,18 @@ LIB3270_EXPORT int lib3270_select_field_at(H3270 *session, int baddr)
340 343 return 0;
341 344 }
342 345  
343   -LIB3270_ACTION( selectfield )
  346 +LIB3270_EXPORT int lib3270_select_field(H3270 *hSession)
344 347 {
345 348 CHECK_SESSION_HANDLE(hSession);
346 349 lib3270_select_field_at(hSession,hSession->cursor_addr);
347 350 return 0;
348 351 }
349 352  
350   -LIB3270_ACTION( selectall )
  353 +LIB3270_EXPORT int lib3270_select_all(H3270 * hSession)
351 354 {
352   -// int len, baddr;
353   -
354 355 CHECK_SESSION_HANDLE(hSession);
355 356  
356   - do_select(hSession,0,hSession->rows*hSession->cols,0);
  357 + do_select(hSession,0,(hSession->rows*hSession->cols)-1,0);
357 358  
358 359 return 0;
359 360 }
... ... @@ -764,7 +765,9 @@ LIB3270_EXPORT int lib3270_move_selected_area(H3270 *hSession, int from, int to)
764 765 {
765 766 int pos[2];
766 767 int rows, cols, f, step;
767   - // , start, end;
  768 +
  769 + if(from == to)
  770 + return from;
768 771  
769 772 if(!lib3270_get_selection_bounds(hSession,&pos[0],&pos[1]))
770 773 return from;
... ... @@ -835,6 +838,8 @@ LIB3270_EXPORT int lib3270_drag_selection(H3270 *h, unsigned char flag, int orig
835 838 if(flag & SELECTION_BOTTOM) // Update bottom margin
836 839 origin = last = (row*h->cols) + (last%h->cols);
837 840  
  841 + trace("origin=%d first=%d last=%d",origin,first,last);
  842 +
838 843 if(first < last)
839 844 do_select(h,first,last,h->rectsel);
840 845 else
... ...