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 450 if(!widget)
451 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 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 459 {
460 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 463 if (widget == NULL ||selection_num != 0)
464 464 return NULL;
465 465  
466 466 if(v3270_get_selection_bounds(widget, start_pos, end_pos))
467 467 {
468   - trace("%s: TRUE",__FUNCTION__);
  468 +// trace("%s: TRUE",__FUNCTION__);
469 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 473 return NULL;
474 474 }
475 475  
... ... @@ -506,6 +506,28 @@ static gboolean v3270_accessible_set_selection(AtkText *text, gint selection_num
506 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 531 static void atk_text_interface_init(AtkTextIface *iface)
510 532 {
511 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 42 GdkPoint point;
43 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 56 return -1;
54 57 }
... ... @@ -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 85  
86 86 /*--[ Globals ]--------------------------------------------------------------------------------------*/
87 87  
88   - #define V3270_CURSOR_NORMAL LIB3270_CURSOR_NORMAL
  88 + #define V3270_CURSOR_UNPROTECTED LIB3270_CURSOR_EDITABLE
89 89 #define V3270_CURSOR_WAITING LIB3270_CURSOR_WAITING
90 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 106 struct v3270_metrics
... ... @@ -189,6 +190,7 @@ const GtkWidgetClass * v3270_get_parent_class(void);
189 190  
190 191 gboolean v3270_draw(GtkWidget * widget, cairo_t * cr);
191 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 195 #if ! GTK_CHECK_VERSION(3,0,0)
194 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 271 #ifdef WIN32
272 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 288 #else
288 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 305 #endif // WIN32
304 306  
... ... @@ -313,12 +315,6 @@ static void v3270_class_init(v3270Class *klass)
313 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 319 // Signals
324 320 widget_class->activate_signal =
... ... @@ -573,8 +569,19 @@ static void select_cursor(H3270 *session, LIB3270_CURSOR id)
573 569 if(gtk_widget_get_realized(widget) && gtk_widget_get_has_window(widget))
574 570 {
575 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 587 static void update_connect(H3270 *session, unsigned char connected)
... ... @@ -700,6 +707,8 @@ static void v3270_init(v3270 *widget)
700 707 widget->host->update_connect = update_connect;
701 708 widget->host->update_model = update_model;
702 709 widget->host->changed = changed;
  710 + widget->host->ctlr_done = ctlr_done;
  711 +
703 712  
704 713 // Setup input method
705 714 widget->input_method = gtk_im_multicontext_new();
... ...
src/include/lib3270.h
... ... @@ -186,7 +186,7 @@
186 186 */
187 187 typedef enum _LIB3270_CURSOR
188 188 {
189   - LIB3270_CURSOR_NORMAL, /**< Ready for user actions */
  189 + LIB3270_CURSOR_EDITABLE, /**< Ready for user actions */
190 190 LIB3270_CURSOR_WAITING, /**< Waiting for host */
191 191 LIB3270_CURSOR_LOCKED, /**< Locked, can't receive user actions */
192 192  
... ... @@ -698,6 +698,9 @@
698 698 LIB3270_EXPORT int lib3270_set_model(H3270 *session, int model);
699 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 704 #ifdef __cplusplus
702 705 }
703 706 #endif
... ...
src/lib3270/api.h
... ... @@ -271,7 +271,7 @@
271 271  
272 272 /* Screen processing */
273 273  
274   - #define CURSOR_MODE_NORMAL LIB3270_CURSOR_NORMAL
  274 + #define CURSOR_MODE_NORMAL LIB3270_CURSOR_EDITABLE
275 275 #define CURSOR_MODE_WAITING LIB3270_CURSOR_WAITING
276 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 380 */
381 381 unsigned char get_field_attribute(H3270 *h, int baddr)
382 382 {
383   - CHECK_SESSION_HANDLE(h);
384 383 return h->ea_buf[find_field_attribute(h,baddr)].fa;
385 384 }
386 385  
... ... @@ -435,20 +434,19 @@ fa2ea(int baddr)
435 434 * unprotected attribute byte, or 0 if no nonzero-width unprotected field
436 435 * can be found.
437 436 */
438   -int
439   -next_unprotected(int baddr0)
  437 +int next_unprotected(H3270 *session, int baddr0)
440 438 {
441 439 register int baddr, nbaddr;
442 440  
443 441 nbaddr = baddr0;
444   - do {
  442 + do
  443 + {
445 444 baddr = nbaddr;
446 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 447 return nbaddr;
451 448 } while (nbaddr != baddr0);
  449 +
452 450 return 0;
453 451 }
454 452  
... ... @@ -1287,7 +1285,7 @@ ctlr_write(unsigned char buf[], int buflen, Boolean erase)
1287 1285 * Otherwise, advance to the first position of the
1288 1286 * next unprotected field.
1289 1287 */
1290   - baddr = next_unprotected(h3270.buffer_addr);
  1288 + baddr = next_unprotected(&h3270,h3270.buffer_addr);
1291 1289 if (baddr < h3270.buffer_addr)
1292 1290 baddr = 0;
1293 1291 /*
... ...
src/lib3270/ctlrc.h
... ... @@ -53,7 +53,7 @@ LIB3270_INTERNAL struct ea *fa2ea(int baddr);
53 53 LIB3270_INTERNAL Boolean get_bounded_field_attribute(register int baddr, register int bound, unsigned char *fa_out);
54 54 LIB3270_INTERNAL void mdt_clear(int baddr);
55 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 57 LIB3270_INTERNAL enum pds process_ds(unsigned char *buf, int buflen);
58 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 962 if (skipped != NULL)
963 963 *skipped = True;
964 964 if (FA_IS_SKIP(h3270.ea_buf[baddr].fa))
965   - baddr = next_unprotected(baddr);
  965 + baddr = next_unprotected(&h3270,baddr);
966 966 else
967 967 INC_BA(baddr);
968 968 }
... ... @@ -1269,7 +1269,7 @@ retry:
1269 1269 if (skipped != NULL)
1270 1270 *skipped = True;
1271 1271 if (FA_IS_SKIP(ea_buf[baddr].fa))
1272   - baddr = next_unprotected(baddr);
  1272 + baddr = next_unprotected(&h3270,baddr);
1273 1273 else
1274 1274 INC_BA(baddr);
1275 1275 }
... ... @@ -1387,7 +1387,7 @@ LIB3270_KEY_ACTION( tab )
1387 1387 return 0;
1388 1388 }
1389 1389 #endif /*]*/
1390   - cursor_move(&h3270,next_unprotected(h3270.cursor_addr));
  1390 + cursor_move(hSession,next_unprotected(hSession,hSession->cursor_addr));
1391 1391 return 0;
1392 1392 }
1393 1393  
... ... @@ -1550,7 +1550,7 @@ LIB3270_ACTION( firstfield )
1550 1550 cursor_move(hSession,0);
1551 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 1555 return 0;
1556 1556 }
... ... @@ -2240,7 +2240,7 @@ LIB3270_CURSOR_ACTION( newline )
2240 2240 if (faddr != baddr && !FA_IS_PROTECTED(fa))
2241 2241 cursor_move(hSession,baddr);
2242 2242 else
2243   - cursor_move(hSession,next_unprotected(baddr));
  2243 + cursor_move(hSession,next_unprotected(hSession,baddr));
2244 2244  
2245 2245 return 0;
2246 2246 }
... ... @@ -2263,7 +2263,7 @@ LIB3270_ACTION( dup )
2263 2263 if (key_Character(EBC_dup, False, False, NULL))
2264 2264 {
2265 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 2931 faddr = find_field_attribute(&h3270,baddr);
2932 2932 fa = h3270.ea_buf[faddr].fa;
2933 2933 if (faddr == baddr || FA_IS_PROTECTED(fa)) {
2934   - baddr = next_unprotected(baddr);
  2934 + baddr = next_unprotected(&h3270,baddr);
2935 2935 if (baddr <= b0)
2936 2936 return False;
2937 2937 }
... ... @@ -3354,7 +3354,7 @@ kybd_prime(void)
3354 3354 * The cursor is not in an unprotected field. Find the
3355 3355 * next one.
3356 3356 */
3357   - baddr = next_unprotected(h3270.cursor_addr);
  3357 + baddr = next_unprotected(&h3270,h3270.cursor_addr);
3358 3358  
3359 3359 /* If there isn't any, give up. */
3360 3360 if (!baddr)
... ...
src/lib3270/paste.c
... ... @@ -122,7 +122,7 @@
122 122 fa = session->ea_buf[faddr].fa;
123 123 if (faddr == baddr || FA_IS_PROTECTED(fa))
124 124 {
125   - baddr = next_unprotected(baddr);
  125 + baddr = next_unprotected(session,baddr);
126 126 if (baddr <= b0)
127 127 return 0;
128 128 }
... ... @@ -212,7 +212,7 @@ LIB3270_EXPORT int lib3270_set_string(H3270 *h, const unsigned char *str)
212 212 if (faddr != baddr && !FA_IS_PROTECTED(fa))
213 213 cursor_move(h,baddr);
214 214 else
215   - cursor_move(h,next_unprotected(baddr));
  215 + cursor_move(h,next_unprotected(h,baddr));
216 216 data.row = BA_TO_ROW(h->cursor_addr);
217 217 }
218 218 last = ' ';
... ...
src/lib3270/screen.c
... ... @@ -768,3 +768,18 @@ LIB3270_EXPORT void lib3270_popup_dialog(H3270 *session, LIB3270_NOTIFY id , con
768 768 popup_handler(session,id,title ? title : _( "3270 Error" ), message,fmt,args);
769 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 606  
607 607 flag &= 0x1f;
608 608  
  609 + trace("%s: flag=%04x",__FUNCTION__,flag);
  610 +
609 611 if(!flag)
610 612 return origin;
611 613 else if(flag == SELECTION_ACTIVE)
... ...