Commit 3c3aa221325b21d083cc9908073dd2ad59cbf94a

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

Corrigindo "drag" da area selecionada

Showing 2 changed files with 33 additions and 16 deletions   Show diff stats
src/lib3270/selection.c
@@ -38,8 +38,9 @@ @@ -38,8 +38,9 @@
38 #define SELECTION_TOP 0x02 38 #define SELECTION_TOP 0x02
39 #define SELECTION_RIGHT 0x04 39 #define SELECTION_RIGHT 0x04
40 #define SELECTION_BOTTOM 0x08 40 #define SELECTION_BOTTOM 0x08
41 - #define SELECTION_SINGLE_ROW 0x10  
42 - #define SELECTION_SINGLE_COL 0x20 41 +
  42 + #define SELECTION_SINGLE_COL 0x10
  43 + #define SELECTION_SINGLE_ROW 0x20
43 44
44 #define SELECTION_ACTIVE 0x80 45 #define SELECTION_ACTIVE 0x80
45 46
@@ -285,22 +286,30 @@ LIB3270_EXPORT unsigned char lib3270_get_selection_flags(H3270 *hSession, int ba @@ -285,22 +286,30 @@ LIB3270_EXPORT unsigned char lib3270_get_selection_flags(H3270 *hSession, int ba
285 rc |= SELECTION_ACTIVE; 286 rc |= SELECTION_ACTIVE;
286 287
287 if( (hSession->select.start % hSession->cols) == (hSession->select.end % hSession->cols) ) 288 if( (hSession->select.start % hSession->cols) == (hSession->select.end % hSession->cols) )
  289 + {
288 rc |= SELECTION_SINGLE_COL; 290 rc |= SELECTION_SINGLE_COL;
  291 + }
  292 + else
  293 + {
  294 + if( (col == 0) || !(hSession->text[baddr-1].attr & LIB3270_ATTR_SELECTED) )
  295 + rc |= SELECTION_LEFT;
  296 +
  297 + if( (col == hSession->cols) || !(hSession->text[baddr+1].attr & LIB3270_ATTR_SELECTED) )
  298 + rc |= SELECTION_RIGHT;
  299 + }
289 300
290 if( (hSession->select.start / hSession->cols) == (hSession->select.end / hSession->cols) ) 301 if( (hSession->select.start / hSession->cols) == (hSession->select.end / hSession->cols) )
  302 + {
291 rc |= SELECTION_SINGLE_ROW; 303 rc |= SELECTION_SINGLE_ROW;
  304 + }
  305 + else
  306 + {
  307 + if( (row == 0) || !(hSession->text[baddr-hSession->cols].attr & LIB3270_ATTR_SELECTED) )
  308 + rc |= SELECTION_TOP;
292 309
293 - if( (col == 0) || !(hSession->text[baddr-1].attr & LIB3270_ATTR_SELECTED) )  
294 - rc |= SELECTION_LEFT;  
295 -  
296 - if( (row == 0) || !(hSession->text[baddr-hSession->cols].attr & LIB3270_ATTR_SELECTED) )  
297 - rc |= SELECTION_TOP;  
298 -  
299 - if( (col == hSession->cols) || !(hSession->text[baddr+1].attr & LIB3270_ATTR_SELECTED) )  
300 - rc |= SELECTION_RIGHT;  
301 -  
302 - if( (row == hSession->rows) || !(hSession->text[baddr+hSession->cols].attr & LIB3270_ATTR_SELECTED) )  
303 - rc |= SELECTION_BOTTOM; 310 + if( (row == hSession->rows) || !(hSession->text[baddr+hSession->cols].attr & LIB3270_ATTR_SELECTED) )
  311 + rc |= SELECTION_BOTTOM;
  312 + }
304 313
305 return rc; 314 return rc;
306 } 315 }
@@ -577,13 +586,21 @@ LIB3270_EXPORT int lib3270_drag_selection(H3270 *h, unsigned char flag, int orig @@ -577,13 +586,21 @@ LIB3270_EXPORT int lib3270_drag_selection(H3270 *h, unsigned char flag, int orig
577 if(!lib3270_get_selection_bounds(h,&first,&last)) 586 if(!lib3270_get_selection_bounds(h,&first,&last))
578 return origin; 587 return origin;
579 588
580 - trace("%s: flag=%04x",__FUNCTION__,flag); 589 + trace("%s: flag=%04x %s %s %s %s",__FUNCTION__,
  590 + flag,
  591 + flag & SELECTION_LEFT ? "Left" : "-",
  592 + flag & SELECTION_TOP ? "Top" : "-",
  593 + flag & SELECTION_RIGHT ? "Right" : "-",
  594 + flag & SELECTION_BOTTOM ? "Bottom" : "-"
  595 + );
581 596
582 if(!flag) 597 if(!flag)
583 return origin; 598 return origin;
584 - else if(flag == SELECTION_ACTIVE) 599 + else if((flag&0x8F) == SELECTION_ACTIVE)
585 return lib3270_move_selected_area(h,origin,baddr); 600 return lib3270_move_selected_area(h,origin,baddr);
586 601
  602 + trace("%s",__FUNCTION__);
  603 +
587 row = baddr/h->cols; 604 row = baddr/h->cols;
588 col = baddr%h->cols; 605 col = baddr%h->cols;
589 606
src/lib3270/telnet.c
@@ -880,7 +880,7 @@ connection_complete(void) @@ -880,7 +880,7 @@ connection_complete(void)
880 */ 880 */
881 static void output_possible(H3270 *session) 881 static void output_possible(H3270 *session)
882 { 882 {
883 - trace("%s: %s",HALF_CONNECTED ? "Half connected" : "Connected"); 883 + trace("%s: %s",__FUNCTION__,HALF_CONNECTED ? "Half connected" : "Connected");
884 if (HALF_CONNECTED) 884 if (HALF_CONNECTED)
885 { 885 {
886 connection_complete(); 886 connection_complete();