Commit 4ffa4f375f4eb93fb78de7c4b22f0b5f1af2294c

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

Implementando mudança do ponteiro do mouse de acordo com o campo

src/gtk/v3270/accessible.c
@@ -450,7 +450,7 @@ static gint v3270_accessible_get_n_selections (AtkText *text) @@ -450,7 +450,7 @@ static gint v3270_accessible_get_n_selections (AtkText *text)
450 if(!widget) 450 if(!widget)
451 return 0; 451 return 0;
452 452
453 - trace("%s: n_selections=%d",__FUNCTION__,v3270_get_selection_bounds(widget, NULL, NULL) ? 1 : 0); 453 +// trace("%s: n_selections=%d",__FUNCTION__,v3270_get_selection_bounds(widget, NULL, NULL) ? 1 : 0);
454 454
455 return v3270_get_selection_bounds(widget, NULL, NULL) ? 1 : 0; 455 return v3270_get_selection_bounds(widget, NULL, NULL) ? 1 : 0;
456 } 456 }
@@ -459,17 +459,17 @@ static gchar * v3270_accessible_get_selection(AtkText *atk_text, gint selection_ @@ -459,17 +459,17 @@ static gchar * v3270_accessible_get_selection(AtkText *atk_text, gint selection_
459 { 459 {
460 GtkWidget *widget = gtk_accessible_get_widget(GTK_ACCESSIBLE (atk_text)); 460 GtkWidget *widget = gtk_accessible_get_widget(GTK_ACCESSIBLE (atk_text));
461 461
462 - trace("%s: selection_num=%d",__FUNCTION__,selection_num); 462 +// trace("%s: selection_num=%d",__FUNCTION__,selection_num);
463 if (widget == NULL ||selection_num != 0) 463 if (widget == NULL ||selection_num != 0)
464 return NULL; 464 return NULL;
465 465
466 if(v3270_get_selection_bounds(widget, start_pos, end_pos)) 466 if(v3270_get_selection_bounds(widget, start_pos, end_pos))
467 { 467 {
468 - trace("%s: TRUE",__FUNCTION__); 468 +// trace("%s: TRUE",__FUNCTION__);
469 return v3270_get_region(widget, *start_pos, *end_pos, FALSE); 469 return v3270_get_region(widget, *start_pos, *end_pos, FALSE);
470 } 470 }
471 471
472 - trace("%s: FALSE",__FUNCTION__); 472 +// trace("%s: FALSE",__FUNCTION__);
473 return NULL; 473 return NULL;
474 } 474 }
475 475
@@ -506,6 +506,28 @@ static gboolean v3270_accessible_set_selection(AtkText *text, gint selection_num @@ -506,6 +506,28 @@ static gboolean v3270_accessible_set_selection(AtkText *text, gint selection_num
506 return FALSE; 506 return FALSE;
507 } 507 }
508 508
  509 +/*
  510 +static AtkAttributeSet * v3270_accessible_get_run_attributes(AtkText *text, gint offset, gint * start_offset, gint * end_offset)
  511 +{
  512 + GtkWidget * widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (text));
  513 + AtkAttributeSet * attributes = NULL;
  514 +
  515 + if(!widget)
  516 + return NULL;
  517 +
  518 + trace("%s is incomplete ***********************",__FUNCTION__);
  519 +
  520 + // http://developer.gnome.org/atk/stable/AtkText.html#AtkTextAttribute
  521 +
  522 + attributes = add_attribute (attributes, ATK_TEXT_ATTR_DIRECTION,
  523 + atk_text_attribute_get_value (ATK_TEXT_ATTR_DIRECTION,
  524 + gtk_widget_get_direction(widget)));
  525 +
  526 +
  527 + return attributes;
  528 +}
  529 +*/
  530 +
509 static void atk_text_interface_init(AtkTextIface *iface) 531 static void atk_text_interface_init(AtkTextIface *iface)
510 { 532 {
511 iface->get_text = v3270_accessible_get_text; 533 iface->get_text = v3270_accessible_get_text;
src/gtk/v3270/mouse.c
@@ -42,13 +42,16 @@ gint v3270_get_offset_at_point(v3270 *widget, gint x, gint y) @@ -42,13 +42,16 @@ gint v3270_get_offset_at_point(v3270 *widget, gint x, gint y)
42 GdkPoint point; 42 GdkPoint point;
43 int r,c; 43 int r,c;
44 44
45 - point.x = ((x-widget->metrics.left)/widget->metrics.width);  
46 - point.y = ((y-widget->metrics.top)/widget->metrics.spacing); 45 + if(x > 0 && y > 0)
  46 + {
  47 + point.x = ((x-widget->metrics.left)/widget->metrics.width);
  48 + point.y = ((y-widget->metrics.top)/widget->metrics.spacing);
47 49
48 - lib3270_get_screen_size(widget->host,&r,&c); 50 + lib3270_get_screen_size(widget->host,&r,&c);
49 51
50 - if(point.x >= 0 && point.y >= 0 && point.x < c && point.y < r)  
51 - return (point.y * c) + point.x; 52 + if(point.x >= 0 && point.y >= 0 && point.x < c && point.y < r)
  53 + return (point.y * c) + point.x;
  54 + }
52 55
53 return -1; 56 return -1;
54 } 57 }
@@ -164,76 +167,93 @@ gboolean v3270_button_release_event(GtkWidget *widget, GdkEventButton*event) @@ -164,76 +167,93 @@ gboolean v3270_button_release_event(GtkWidget *widget, GdkEventButton*event)
164 } 167 }
165 168
166 169
167 -gboolean v3270_motion_notify_event(GtkWidget *widget, GdkEventMotion *event) 170 +static void update_mouse_pointer(GtkWidget *widget, int baddr)
168 { 171 {
169 - v3270 * terminal = GTK_V3270(widget);  
170 - int baddr = v3270_get_offset_at_point(terminal,event->x,event->y);  
171 -  
172 - if(baddr < 0)  
173 - return FALSE; 172 + v3270 *terminal = GTK_V3270(widget);
174 173
175 - if(terminal->selecting)  
176 - {  
177 - // Select area  
178 - lib3270_select_to(terminal->host,baddr);  
179 - }  
180 - else if(terminal->moving) 174 + if(baddr >= 0 && terminal->pointer_id == LIB3270_CURSOR_EDITABLE)
181 { 175 {
182 - // Move selected area  
183 - terminal->selection_addr = lib3270_drag_selection(terminal->host,terminal->pointer,terminal->selection_addr,baddr);  
184 - }  
185 - else if(terminal->pointer_id == LIB3270_CURSOR_NORMAL)  
186 - {  
187 - unsigned char new_pointer = lib3270_get_selection_flags(terminal->host,baddr);  
188 - if(new_pointer != terminal->pointer) 176 + int id = terminal->pointer;
  177 +
  178 + switch(lib3270_get_selection_flags(terminal->host,baddr) & 0x1f)
189 { 179 {
190 - GdkWindow *window = gtk_widget_get_window(widget);  
191 - trace("Pointer changes to %04x",new_pointer); 180 + case 0x10:
  181 + id = V3270_CURSOR_MOVE_SELECTION;
  182 + break;
  183 +
  184 + case 0x12:
  185 + id = V3270_CURSOR_SELECTION_TOP;
  186 + break;
  187 +
  188 + case 0x16:
  189 + id = V3270_CURSOR_SELECTION_TOP_RIGHT;
  190 + break;
  191 +
  192 + case 0x14:
  193 + id = V3270_CURSOR_SELECTION_RIGHT;
  194 + break;
192 195
193 - switch(new_pointer & 0x1F)  
194 - {  
195 - case 0x10:  
196 - gdk_window_set_cursor(window,v3270_cursor[V3270_CURSOR_MOVE_SELECTION]);  
197 - break; 196 + case 0x11:
  197 + id = V3270_CURSOR_SELECTION_LEFT;
  198 + break;
198 199
199 - case 0x12:  
200 - gdk_window_set_cursor(window,v3270_cursor[V3270_CURSOR_SELECTION_TOP]);  
201 - break; 200 + case 0x19:
  201 + id = V3270_CURSOR_SELECTION_BOTTOM_LEFT;
  202 + break;
202 203
203 - case 0x16:  
204 - gdk_window_set_cursor(window,v3270_cursor[V3270_CURSOR_SELECTION_TOP_RIGHT]);  
205 - break; 204 + case 0x18:
  205 + id = V3270_CURSOR_SELECTION_BOTTOM;
  206 + break;
206 207
207 - case 0x14:  
208 - gdk_window_set_cursor(window,v3270_cursor[V3270_CURSOR_SELECTION_RIGHT]);  
209 - break; 208 + case 0x1c:
  209 + id = V3270_CURSOR_SELECTION_BOTTOM_RIGHT;
  210 + break;
210 211
211 - case 0x11:  
212 - gdk_window_set_cursor(window,v3270_cursor[V3270_CURSOR_SELECTION_LEFT]);  
213 - break; 212 + case 0x13:
  213 + id = V3270_CURSOR_SELECTION_TOP_LEFT;
  214 + break;
214 215
215 - case 0x19:  
216 - gdk_window_set_cursor(window,v3270_cursor[V3270_CURSOR_SELECTION_BOTTOM_LEFT]);  
217 - break; 216 + default:
  217 + id = lib3270_is_protected(terminal->host,baddr) ? V3270_CURSOR_PROTECTED : V3270_CURSOR_UNPROTECTED;
218 218
219 - case 0x18:  
220 - gdk_window_set_cursor(window,v3270_cursor[V3270_CURSOR_SELECTION_BOTTOM]);  
221 - break; 219 + }
  220 +
  221 + gdk_window_set_cursor(gtk_widget_get_window(widget),v3270_cursor[id]);
  222 + }
222 223
223 - case 0x1c:  
224 - gdk_window_set_cursor(window,v3270_cursor[V3270_CURSOR_SELECTION_BOTTOM_RIGHT]);  
225 - break; 224 +}
226 225
227 - case 0x13:  
228 - gdk_window_set_cursor(window,v3270_cursor[V3270_CURSOR_SELECTION_TOP_LEFT]);  
229 - break; 226 +void v3270_update_mouse_pointer(GtkWidget *widget)
  227 +{
  228 + gint x, y;
230 229
231 - default:  
232 - gdk_window_set_cursor(window,v3270_cursor[V3270_CURSOR_NORMAL]); 230 +#if GTK_CHECK_VERSION(3,4,0)
  231 + #warning Implement gdk_window_get_device_position
  232 +#endif // GTK(3,4,0)
233 233
234 - } 234 + gtk_widget_get_pointer(widget,&x,&y);
  235 + update_mouse_pointer(widget,v3270_get_offset_at_point(GTK_V3270(widget),x,y));
  236 +}
235 237
236 - terminal->pointer = new_pointer; 238 +gboolean v3270_motion_notify_event(GtkWidget *widget, GdkEventMotion *event)
  239 +{
  240 + v3270 * terminal = GTK_V3270(widget);
  241 + int baddr = v3270_get_offset_at_point(terminal,event->x,event->y);
  242 +
  243 + if(baddr >= 0)
  244 + {
  245 + if(terminal->selecting) // Select region
  246 + {
  247 + lib3270_select_to(terminal->host,baddr);
  248 + }
  249 + if(terminal->moving) // Move selected area
  250 + {
  251 + terminal->selection_addr = lib3270_drag_selection(terminal->host,terminal->pointer,terminal->selection_addr,baddr);
  252 + }
  253 + else
  254 + {
  255 + terminal->pointer = lib3270_get_selection_flags(terminal->host,baddr);
  256 + update_mouse_pointer(widget,baddr);
237 } 257 }
238 } 258 }
239 259
src/gtk/v3270/private.h
@@ -85,21 +85,22 @@ G_BEGIN_DECLS @@ -85,21 +85,22 @@ G_BEGIN_DECLS
85 85
86 /*--[ Globals ]--------------------------------------------------------------------------------------*/ 86 /*--[ Globals ]--------------------------------------------------------------------------------------*/
87 87
88 - #define V3270_CURSOR_NORMAL LIB3270_CURSOR_NORMAL 88 + #define V3270_CURSOR_UNPROTECTED LIB3270_CURSOR_EDITABLE
89 #define V3270_CURSOR_WAITING LIB3270_CURSOR_WAITING 89 #define V3270_CURSOR_WAITING LIB3270_CURSOR_WAITING
90 #define V3270_CURSOR_LOCKED LIB3270_CURSOR_LOCKED 90 #define V3270_CURSOR_LOCKED LIB3270_CURSOR_LOCKED
91 91
92 - #define V3270_CURSOR_MOVE_SELECTION LIB3270_CURSOR_USER  
93 - #define V3270_CURSOR_SELECTION_TOP_LEFT LIB3270_CURSOR_USER+1  
94 - #define V3270_CURSOR_SELECTION_TOP_RIGHT LIB3270_CURSOR_USER+2  
95 - #define V3270_CURSOR_SELECTION_TOP LIB3270_CURSOR_USER+3  
96 - #define V3270_CURSOR_SELECTION_BOTTOM_LEFT LIB3270_CURSOR_USER+4  
97 - #define V3270_CURSOR_SELECTION_BOTTOM_RIGHT LIB3270_CURSOR_USER+5  
98 - #define V3270_CURSOR_SELECTION_BOTTOM LIB3270_CURSOR_USER+6  
99 - #define V3270_CURSOR_SELECTION_LEFT LIB3270_CURSOR_USER+7  
100 - #define V3270_CURSOR_SELECTION_RIGHT LIB3270_CURSOR_USER+8 92 + #define V3270_CURSOR_PROTECTED LIB3270_CURSOR_USER
  93 + #define V3270_CURSOR_MOVE_SELECTION LIB3270_CURSOR_USER+1
  94 + #define V3270_CURSOR_SELECTION_TOP_LEFT LIB3270_CURSOR_USER+2
  95 + #define V3270_CURSOR_SELECTION_TOP_RIGHT LIB3270_CURSOR_USER+3
  96 + #define V3270_CURSOR_SELECTION_TOP LIB3270_CURSOR_USER+4
  97 + #define V3270_CURSOR_SELECTION_BOTTOM_LEFT LIB3270_CURSOR_USER+5
  98 + #define V3270_CURSOR_SELECTION_BOTTOM_RIGHT LIB3270_CURSOR_USER+6
  99 + #define V3270_CURSOR_SELECTION_BOTTOM LIB3270_CURSOR_USER+7
  100 + #define V3270_CURSOR_SELECTION_LEFT LIB3270_CURSOR_USER+8
  101 + #define V3270_CURSOR_SELECTION_RIGHT LIB3270_CURSOR_USER+9
101 102
102 - #define V3270_CURSOR_COUNT LIB3270_CURSOR_USER+9 103 + #define V3270_CURSOR_COUNT LIB3270_CURSOR_USER+10
103 104
104 105
105 struct v3270_metrics 106 struct v3270_metrics
@@ -189,6 +190,7 @@ const GtkWidgetClass * v3270_get_parent_class(void); @@ -189,6 +190,7 @@ const GtkWidgetClass * v3270_get_parent_class(void);
189 190
190 gboolean v3270_draw(GtkWidget * widget, cairo_t * cr); 191 gboolean v3270_draw(GtkWidget * widget, cairo_t * cr);
191 void v3270_draw_oia(cairo_t *cr, H3270 *host, int row, int cols, struct v3270_metrics *metrics, GdkColor *color, GdkRectangle *rect); 192 void v3270_draw_oia(cairo_t *cr, H3270 *host, int row, int cols, struct v3270_metrics *metrics, GdkColor *color, GdkRectangle *rect);
  193 +void v3270_update_mouse_pointer(GtkWidget *widget);
192 194
193 #if ! GTK_CHECK_VERSION(3,0,0) 195 #if ! GTK_CHECK_VERSION(3,0,0)
194 gboolean v3270_expose(GtkWidget * widget, GdkEventExpose *event); 196 gboolean v3270_expose(GtkWidget * widget, GdkEventExpose *event);
src/gtk/v3270/widget.c
@@ -271,34 +271,36 @@ static void v3270_class_init(v3270Class *klass) @@ -271,34 +271,36 @@ static void v3270_class_init(v3270Class *klass)
271 #ifdef WIN32 271 #ifdef WIN32
272 static const gchar * cr[V3270_CURSOR_COUNT] = 272 static const gchar * cr[V3270_CURSOR_COUNT] =
273 { 273 {
274 - "ibeam",  
275 - "wait",  
276 - "arrow",  
277 - "hand",  
278 - "sizenwse", // Top-left  
279 - "sizenesw", // Top-right  
280 - "sizens", // Top  
281 - "sizenesw", // Bottom-left  
282 - "sizenwse", // Bottom-right  
283 - "sizens", // Bottom  
284 - "sizewe", // Left  
285 - "sizewe", // Right 274 + "ibeam", // V3270_CURSOR_UNPROTECTED
  275 + "wait", // V3270_CURSOR_WAITING
  276 + "arrow", // V3270_CURSOR_LOCKED
  277 + "arrow", // V3270_CURSOR_PROTECTED
  278 + "hand", // V3270_CURSOR_MOVE_SELECTION
  279 + "sizenwse", // V3270_CURSOR_SELECTION_TOP_LEFT
  280 + "sizenesw", // V3270_CURSOR_SELECTION_TOP_RIGHT
  281 + "sizens", // V3270_CURSOR_SELECTION_TOP
  282 + "sizenesw", // V3270_CURSOR_SELECTION_BOTTOM_LEFT
  283 + "sizenwse", // V3270_CURSOR_SELECTION_BOTTOM_RIGHT
  284 + "sizens", // V3270_CURSOR_SELECTION_BOTTOM
  285 + "sizewe", // V3270_CURSOR_SELECTION_LEFT
  286 + "sizewe", // V3270_CURSOR_SELECTION_RIGHT
286 }; 287 };
287 #else 288 #else
288 static const int cr[V3270_CURSOR_COUNT] = 289 static const int cr[V3270_CURSOR_COUNT] =
289 { 290 {
290 - GDK_XTERM,  
291 - GDK_WATCH,  
292 - GDK_X_CURSOR,  
293 - GDK_HAND1,  
294 - GDK_TOP_LEFT_CORNER, // Top-left  
295 - GDK_TOP_RIGHT_CORNER, // Top-right  
296 - GDK_TOP_SIDE, // Top  
297 - GDK_BOTTOM_LEFT_CORNER, // Bottom-left  
298 - GDK_BOTTOM_RIGHT_CORNER, // Bottom-right  
299 - GDK_BOTTOM_SIDE, // Bottom  
300 - GDK_LEFT_SIDE, // Left  
301 - GDK_RIGHT_SIDE, // Right 291 + GDK_XTERM, // V3270_CURSOR_UNPROTECTED
  292 + GDK_WATCH, // V3270_CURSOR_WAITING
  293 + GDK_X_CURSOR, // V3270_CURSOR_LOCKED
  294 + GDK_ARROW, // V3270_CURSOR_PROTECTED
  295 + GDK_HAND1, // V3270_CURSOR_MOVE_SELECTION
  296 + GDK_TOP_LEFT_CORNER, // V3270_CURSOR_SELECTION_TOP_LEFT
  297 + GDK_TOP_RIGHT_CORNER, // V3270_CURSOR_SELECTION_TOP_RIGHT
  298 + GDK_TOP_SIDE, // V3270_CURSOR_SELECTION_TOP
  299 + GDK_BOTTOM_LEFT_CORNER, // V3270_CURSOR_SELECTION_BOTTOM_LEFT
  300 + GDK_BOTTOM_RIGHT_CORNER, // V3270_CURSOR_SELECTION_BOTTOM_RIGHT
  301 + GDK_BOTTOM_SIDE, // V3270_CURSOR_SELECTION_BOTTOM
  302 + GDK_LEFT_SIDE, // V3270_CURSOR_SELECTION_LEFT
  303 + GDK_RIGHT_SIDE, // V3270_CURSOR_SELECTION_RIGHT
302 }; 304 };
303 #endif // WIN32 305 #endif // WIN32
304 306
@@ -313,12 +315,6 @@ static void v3270_class_init(v3270Class *klass) @@ -313,12 +315,6 @@ static void v3270_class_init(v3270Class *klass)
313 #endif 315 #endif
314 } 316 }
315 } 317 }
316 -/*  
317 - v3270_cursor[V3270_CURSOR_NORMAL] = gdk_cursor_new(GDK_XTERM);  
318 - v3270_cursor[V3270_CURSOR_WAITING] = gdk_cursor_new(GDK_WATCH);  
319 - v3270_cursor[V3270_CURSOR_LOCKED] = gdk_cursor_new(GDK_X_CURSOR);  
320 - v3270_cursor[]  
321 -*/  
322 318
323 // Signals 319 // Signals
324 widget_class->activate_signal = 320 widget_class->activate_signal =
@@ -573,8 +569,19 @@ static void select_cursor(H3270 *session, LIB3270_CURSOR id) @@ -573,8 +569,19 @@ static void select_cursor(H3270 *session, LIB3270_CURSOR id)
573 if(gtk_widget_get_realized(widget) && gtk_widget_get_has_window(widget)) 569 if(gtk_widget_get_realized(widget) && gtk_widget_get_has_window(widget))
574 { 570 {
575 GTK_V3270(widget)->pointer_id = id; 571 GTK_V3270(widget)->pointer_id = id;
576 - gdk_window_set_cursor(gtk_widget_get_window(widget),v3270_cursor[id]); 572 + v3270_update_mouse_pointer(widget);
  573 + }
  574 +}
  575 +
  576 +static void ctlr_done(H3270 *session)
  577 +{
  578 + GtkWidget *widget = GTK_WIDGET(session->widget);
  579 +
  580 + if(gtk_widget_get_realized(widget) && gtk_widget_get_has_window(widget))
  581 + {
  582 + v3270_update_mouse_pointer(widget);
577 } 583 }
  584 +
578 } 585 }
579 586
580 static void update_connect(H3270 *session, unsigned char connected) 587 static void update_connect(H3270 *session, unsigned char connected)
@@ -700,6 +707,8 @@ static void v3270_init(v3270 *widget) @@ -700,6 +707,8 @@ static void v3270_init(v3270 *widget)
700 widget->host->update_connect = update_connect; 707 widget->host->update_connect = update_connect;
701 widget->host->update_model = update_model; 708 widget->host->update_model = update_model;
702 widget->host->changed = changed; 709 widget->host->changed = changed;
  710 + widget->host->ctlr_done = ctlr_done;
  711 +
703 712
704 // Setup input method 713 // Setup input method
705 widget->input_method = gtk_im_multicontext_new(); 714 widget->input_method = gtk_im_multicontext_new();
src/include/lib3270.h
@@ -186,7 +186,7 @@ @@ -186,7 +186,7 @@
186 */ 186 */
187 typedef enum _LIB3270_CURSOR 187 typedef enum _LIB3270_CURSOR
188 { 188 {
189 - LIB3270_CURSOR_NORMAL, /**< Ready for user actions */ 189 + LIB3270_CURSOR_EDITABLE, /**< Ready for user actions */
190 LIB3270_CURSOR_WAITING, /**< Waiting for host */ 190 LIB3270_CURSOR_WAITING, /**< Waiting for host */
191 LIB3270_CURSOR_LOCKED, /**< Locked, can't receive user actions */ 191 LIB3270_CURSOR_LOCKED, /**< Locked, can't receive user actions */
192 192
@@ -698,6 +698,9 @@ @@ -698,6 +698,9 @@
698 LIB3270_EXPORT int lib3270_set_model(H3270 *session, int model); 698 LIB3270_EXPORT int lib3270_set_model(H3270 *session, int model);
699 LIB3270_EXPORT int lib3270_get_model(H3270 *session); 699 LIB3270_EXPORT int lib3270_get_model(H3270 *session);
700 700
  701 + LIB3270_EXPORT int lib3270_is_protected(H3270 *h, unsigned int baddr);
  702 +
  703 +
701 #ifdef __cplusplus 704 #ifdef __cplusplus
702 } 705 }
703 #endif 706 #endif
src/lib3270/api.h
@@ -271,7 +271,7 @@ @@ -271,7 +271,7 @@
271 271
272 /* Screen processing */ 272 /* Screen processing */
273 273
274 - #define CURSOR_MODE_NORMAL LIB3270_CURSOR_NORMAL 274 + #define CURSOR_MODE_NORMAL LIB3270_CURSOR_EDITABLE
275 #define CURSOR_MODE_WAITING LIB3270_CURSOR_WAITING 275 #define CURSOR_MODE_WAITING LIB3270_CURSOR_WAITING
276 #define CURSOR_MODE_LOCKED LIB3270_CURSOR_LOCKED 276 #define CURSOR_MODE_LOCKED LIB3270_CURSOR_LOCKED
277 277
src/lib3270/ctlr.c
@@ -380,7 +380,6 @@ int lib3270_field_length(H3270 *h, int baddr) @@ -380,7 +380,6 @@ int lib3270_field_length(H3270 *h, int baddr)
380 */ 380 */
381 unsigned char get_field_attribute(H3270 *h, int baddr) 381 unsigned char get_field_attribute(H3270 *h, int baddr)
382 { 382 {
383 - CHECK_SESSION_HANDLE(h);  
384 return h->ea_buf[find_field_attribute(h,baddr)].fa; 383 return h->ea_buf[find_field_attribute(h,baddr)].fa;
385 } 384 }
386 385
@@ -435,20 +434,19 @@ fa2ea(int baddr) @@ -435,20 +434,19 @@ fa2ea(int baddr)
435 * unprotected attribute byte, or 0 if no nonzero-width unprotected field 434 * unprotected attribute byte, or 0 if no nonzero-width unprotected field
436 * can be found. 435 * can be found.
437 */ 436 */
438 -int  
439 -next_unprotected(int baddr0) 437 +int next_unprotected(H3270 *session, int baddr0)
440 { 438 {
441 register int baddr, nbaddr; 439 register int baddr, nbaddr;
442 440
443 nbaddr = baddr0; 441 nbaddr = baddr0;
444 - do { 442 + do
  443 + {
445 baddr = nbaddr; 444 baddr = nbaddr;
446 INC_BA(nbaddr); 445 INC_BA(nbaddr);
447 - if (h3270.ea_buf[baddr].fa &&  
448 - !FA_IS_PROTECTED(h3270.ea_buf[baddr].fa) &&  
449 - !h3270.ea_buf[nbaddr].fa) 446 + if(session->ea_buf[baddr].fa &&!FA_IS_PROTECTED(session->ea_buf[baddr].fa) &&!session->ea_buf[nbaddr].fa)
450 return nbaddr; 447 return nbaddr;
451 } while (nbaddr != baddr0); 448 } while (nbaddr != baddr0);
  449 +
452 return 0; 450 return 0;
453 } 451 }
454 452
@@ -1287,7 +1285,7 @@ ctlr_write(unsigned char buf[], int buflen, Boolean erase) @@ -1287,7 +1285,7 @@ ctlr_write(unsigned char buf[], int buflen, Boolean erase)
1287 * Otherwise, advance to the first position of the 1285 * Otherwise, advance to the first position of the
1288 * next unprotected field. 1286 * next unprotected field.
1289 */ 1287 */
1290 - baddr = next_unprotected(h3270.buffer_addr); 1288 + baddr = next_unprotected(&h3270,h3270.buffer_addr);
1291 if (baddr < h3270.buffer_addr) 1289 if (baddr < h3270.buffer_addr)
1292 baddr = 0; 1290 baddr = 0;
1293 /* 1291 /*
src/lib3270/ctlrc.h
@@ -53,7 +53,7 @@ LIB3270_INTERNAL struct ea *fa2ea(int baddr); @@ -53,7 +53,7 @@ LIB3270_INTERNAL struct ea *fa2ea(int baddr);
53 LIB3270_INTERNAL Boolean get_bounded_field_attribute(register int baddr, register int bound, unsigned char *fa_out); 53 LIB3270_INTERNAL Boolean get_bounded_field_attribute(register int baddr, register int bound, unsigned char *fa_out);
54 LIB3270_INTERNAL void mdt_clear(int baddr); 54 LIB3270_INTERNAL void mdt_clear(int baddr);
55 LIB3270_INTERNAL void mdt_set(int baddr); 55 LIB3270_INTERNAL void mdt_set(int baddr);
56 -LIB3270_INTERNAL int next_unprotected(int baddr0); 56 +LIB3270_INTERNAL int next_unprotected(H3270 *session, int baddr0);
57 LIB3270_INTERNAL enum pds process_ds(unsigned char *buf, int buflen); 57 LIB3270_INTERNAL enum pds process_ds(unsigned char *buf, int buflen);
58 LIB3270_INTERNAL void ps_process(void); 58 LIB3270_INTERNAL void ps_process(void);
59 59
src/lib3270/kybd.c
@@ -962,7 +962,7 @@ static Boolean key_Character(int code, Boolean with_ge, Boolean pasting, Boolean @@ -962,7 +962,7 @@ static Boolean key_Character(int code, Boolean with_ge, Boolean pasting, Boolean
962 if (skipped != NULL) 962 if (skipped != NULL)
963 *skipped = True; 963 *skipped = True;
964 if (FA_IS_SKIP(h3270.ea_buf[baddr].fa)) 964 if (FA_IS_SKIP(h3270.ea_buf[baddr].fa))
965 - baddr = next_unprotected(baddr); 965 + baddr = next_unprotected(&h3270,baddr);
966 else 966 else
967 INC_BA(baddr); 967 INC_BA(baddr);
968 } 968 }
@@ -1269,7 +1269,7 @@ retry: @@ -1269,7 +1269,7 @@ retry:
1269 if (skipped != NULL) 1269 if (skipped != NULL)
1270 *skipped = True; 1270 *skipped = True;
1271 if (FA_IS_SKIP(ea_buf[baddr].fa)) 1271 if (FA_IS_SKIP(ea_buf[baddr].fa))
1272 - baddr = next_unprotected(baddr); 1272 + baddr = next_unprotected(&h3270,baddr);
1273 else 1273 else
1274 INC_BA(baddr); 1274 INC_BA(baddr);
1275 } 1275 }
@@ -1387,7 +1387,7 @@ LIB3270_KEY_ACTION( tab ) @@ -1387,7 +1387,7 @@ LIB3270_KEY_ACTION( tab )
1387 return 0; 1387 return 0;
1388 } 1388 }
1389 #endif /*]*/ 1389 #endif /*]*/
1390 - cursor_move(&h3270,next_unprotected(h3270.cursor_addr)); 1390 + cursor_move(hSession,next_unprotected(hSession,hSession->cursor_addr));
1391 return 0; 1391 return 0;
1392 } 1392 }
1393 1393
@@ -1550,7 +1550,7 @@ LIB3270_ACTION( firstfield ) @@ -1550,7 +1550,7 @@ LIB3270_ACTION( firstfield )
1550 cursor_move(hSession,0); 1550 cursor_move(hSession,0);
1551 return 0; 1551 return 0;
1552 } 1552 }
1553 - cursor_move(hSession,next_unprotected(hSession->rows*hSession->cols-1)); 1553 + cursor_move(hSession,next_unprotected(hSession,hSession->rows*hSession->cols-1));
1554 1554
1555 return 0; 1555 return 0;
1556 } 1556 }
@@ -2240,7 +2240,7 @@ LIB3270_CURSOR_ACTION( newline ) @@ -2240,7 +2240,7 @@ LIB3270_CURSOR_ACTION( newline )
2240 if (faddr != baddr && !FA_IS_PROTECTED(fa)) 2240 if (faddr != baddr && !FA_IS_PROTECTED(fa))
2241 cursor_move(hSession,baddr); 2241 cursor_move(hSession,baddr);
2242 else 2242 else
2243 - cursor_move(hSession,next_unprotected(baddr)); 2243 + cursor_move(hSession,next_unprotected(hSession,baddr));
2244 2244
2245 return 0; 2245 return 0;
2246 } 2246 }
@@ -2263,7 +2263,7 @@ LIB3270_ACTION( dup ) @@ -2263,7 +2263,7 @@ LIB3270_ACTION( dup )
2263 if (key_Character(EBC_dup, False, False, NULL)) 2263 if (key_Character(EBC_dup, False, False, NULL))
2264 { 2264 {
2265 screen_disp(hSession); 2265 screen_disp(hSession);
2266 - cursor_move(hSession,next_unprotected(hSession->cursor_addr)); 2266 + cursor_move(hSession,next_unprotected(hSession,hSession->cursor_addr));
2267 } 2267 }
2268 } 2268 }
2269 2269
@@ -2931,7 +2931,7 @@ remargin(int lmargin) @@ -2931,7 +2931,7 @@ remargin(int lmargin)
2931 faddr = find_field_attribute(&h3270,baddr); 2931 faddr = find_field_attribute(&h3270,baddr);
2932 fa = h3270.ea_buf[faddr].fa; 2932 fa = h3270.ea_buf[faddr].fa;
2933 if (faddr == baddr || FA_IS_PROTECTED(fa)) { 2933 if (faddr == baddr || FA_IS_PROTECTED(fa)) {
2934 - baddr = next_unprotected(baddr); 2934 + baddr = next_unprotected(&h3270,baddr);
2935 if (baddr <= b0) 2935 if (baddr <= b0)
2936 return False; 2936 return False;
2937 } 2937 }
@@ -3354,7 +3354,7 @@ kybd_prime(void) @@ -3354,7 +3354,7 @@ kybd_prime(void)
3354 * The cursor is not in an unprotected field. Find the 3354 * The cursor is not in an unprotected field. Find the
3355 * next one. 3355 * next one.
3356 */ 3356 */
3357 - baddr = next_unprotected(h3270.cursor_addr); 3357 + baddr = next_unprotected(&h3270,h3270.cursor_addr);
3358 3358
3359 /* If there isn't any, give up. */ 3359 /* If there isn't any, give up. */
3360 if (!baddr) 3360 if (!baddr)
src/lib3270/paste.c
@@ -122,7 +122,7 @@ @@ -122,7 +122,7 @@
122 fa = session->ea_buf[faddr].fa; 122 fa = session->ea_buf[faddr].fa;
123 if (faddr == baddr || FA_IS_PROTECTED(fa)) 123 if (faddr == baddr || FA_IS_PROTECTED(fa))
124 { 124 {
125 - baddr = next_unprotected(baddr); 125 + baddr = next_unprotected(session,baddr);
126 if (baddr <= b0) 126 if (baddr <= b0)
127 return 0; 127 return 0;
128 } 128 }
@@ -212,7 +212,7 @@ LIB3270_EXPORT int lib3270_set_string(H3270 *h, const unsigned char *str) @@ -212,7 +212,7 @@ LIB3270_EXPORT int lib3270_set_string(H3270 *h, const unsigned char *str)
212 if (faddr != baddr && !FA_IS_PROTECTED(fa)) 212 if (faddr != baddr && !FA_IS_PROTECTED(fa))
213 cursor_move(h,baddr); 213 cursor_move(h,baddr);
214 else 214 else
215 - cursor_move(h,next_unprotected(baddr)); 215 + cursor_move(h,next_unprotected(h,baddr));
216 data.row = BA_TO_ROW(h->cursor_addr); 216 data.row = BA_TO_ROW(h->cursor_addr);
217 } 217 }
218 last = ' '; 218 last = ' ';
src/lib3270/screen.c
@@ -768,3 +768,18 @@ LIB3270_EXPORT void lib3270_popup_dialog(H3270 *session, LIB3270_NOTIFY id , con @@ -768,3 +768,18 @@ LIB3270_EXPORT void lib3270_popup_dialog(H3270 *session, LIB3270_NOTIFY id , con
768 popup_handler(session,id,title ? title : _( "3270 Error" ), message,fmt,args); 768 popup_handler(session,id,title ? title : _( "3270 Error" ), message,fmt,args);
769 va_end(args); 769 va_end(args);
770 } 770 }
  771 +
  772 +LIB3270_EXPORT int lib3270_is_protected(H3270 *h, unsigned int baddr)
  773 +{
  774 + unsigned char fa;
  775 +
  776 + CHECK_SESSION_HANDLE(h);
  777 +
  778 + if(baddr > (h->rows * h->cols))
  779 + return -1;
  780 +
  781 + fa = get_field_attribute(h,baddr);
  782 +
  783 + return FA_IS_PROTECTED(fa);
  784 +}
  785 +
src/lib3270/selection.c
@@ -606,6 +606,8 @@ LIB3270_EXPORT int lib3270_drag_selection(H3270 *h, unsigned char flag, int orig @@ -606,6 +606,8 @@ LIB3270_EXPORT int lib3270_drag_selection(H3270 *h, unsigned char flag, int orig
606 606
607 flag &= 0x1f; 607 flag &= 0x1f;
608 608
  609 + trace("%s: flag=%04x",__FUNCTION__,flag);
  610 +
609 if(!flag) 611 if(!flag)
610 return origin; 612 return origin;
611 else if(flag == SELECTION_ACTIVE) 613 else if(flag == SELECTION_ACTIVE)