Commit 39ec5f7db10a26970ba79663575e0a159be95658

Authored by perry.werneck@gmail.com
1 parent 98c4d197

Padronizando action que move o cursor ao final do campo ativo, incluindo função …

…de biblioteca que obtem a posição do último caractere do campo
src/include/lib3270.h
@@ -125,7 +125,10 @@ @@ -125,7 +125,10 @@
125 LIB3270_DIR_UP, 125 LIB3270_DIR_UP,
126 LIB3270_DIR_DOWN, 126 LIB3270_DIR_DOWN,
127 LIB3270_DIR_LEFT, 127 LIB3270_DIR_LEFT,
128 - LIB3270_DIR_RIGHT 128 + LIB3270_DIR_RIGHT,
  129 +
  130 + LIB3270_DIR_END,
  131 +
129 } LIB3270_DIRECTION; 132 } LIB3270_DIRECTION;
130 133
131 /** 134 /**
@@ -782,6 +785,19 @@ @@ -782,6 +785,19 @@
782 LIB3270_EXPORT int lib3270_get_next_unprotected(H3270 *hSession, int baddr0); 785 LIB3270_EXPORT int lib3270_get_next_unprotected(H3270 *hSession, int baddr0);
783 786
784 /** 787 /**
  788 + * Get address of the first blank.
  789 + *
  790 + * Get address of the first blank after the last nonblank in the
  791 + * field, or if the field is full, to the last character in the field.
  792 + *
  793 + * @param hSession Session handle.
  794 + * @param baddr Field address.
  795 + *
  796 + * @return address of the first blank or -1 if invalid.
  797 + */
  798 + LIB3270_EXPORT int lib3270_get_field_end(H3270 *hSession, int baddr);
  799 +
  800 + /**
785 * Find the buffer address of the field attribute for a given buffer address. 801 * Find the buffer address of the field attribute for a given buffer address.
786 * 802 *
787 * @param h Session handle. 803 * @param h Session handle.
src/lib3270/kybd.c
@@ -2346,29 +2346,43 @@ ToggleReverse_action(Widget w unused, XEvent *event, String *params, Cardinal *n @@ -2346,29 +2346,43 @@ ToggleReverse_action(Widget w unused, XEvent *event, String *params, Cardinal *n
2346 */ 2346 */
2347 LIB3270_ACTION( fieldend ) 2347 LIB3270_ACTION( fieldend )
2348 { 2348 {
2349 - int baddr, faddr;  
2350 - unsigned char fa, c;  
2351 - int last_nonblank = -1; 2349 + int baddr;
2352 2350
2353 if (hSession->kybdlock) 2351 if (hSession->kybdlock)
2354 { 2352 {
2355 ENQUEUE_ACTION( lib3270_fieldend ); 2353 ENQUEUE_ACTION( lib3270_fieldend );
2356 return 0; 2354 return 0;
2357 } 2355 }
  2356 +
  2357 + baddr = lib3270_get_field_end(hSession,hSession->cursor_addr);
  2358 + if(baddr >= 0)
  2359 + cursor_move(hSession,baddr);
  2360 +
  2361 + return 0;
  2362 +}
  2363 +
  2364 +int lib3270_get_field_end(H3270 *hSession, int baddr)
  2365 +{
  2366 + int faddr;
  2367 + unsigned char fa, c;
  2368 + int last_nonblank = -1;
  2369 +
2358 #if defined(X3270_ANSI) /*[*/ 2370 #if defined(X3270_ANSI) /*[*/
2359 if (IN_ANSI) 2371 if (IN_ANSI)
2360 - return 0; 2372 + return -1;
2361 #endif /*]*/ 2373 #endif /*]*/
  2374 +
2362 if (!hSession->formatted) 2375 if (!hSession->formatted)
2363 - return 0;  
2364 - baddr = hSession->cursor_addr; 2376 + return -1;
  2377 +
2365 faddr = find_field_attribute(hSession,baddr); 2378 faddr = find_field_attribute(hSession,baddr);
2366 fa = hSession->ea_buf[faddr].fa; 2379 fa = hSession->ea_buf[faddr].fa;
2367 if (faddr == baddr || FA_IS_PROTECTED(fa)) 2380 if (faddr == baddr || FA_IS_PROTECTED(fa))
2368 - return 0; 2381 + return -1;
2369 2382
2370 baddr = faddr; 2383 baddr = faddr;
2371 - while (True) { 2384 + while (True)
  2385 + {
2372 INC_BA(baddr); 2386 INC_BA(baddr);
2373 c = hSession->ea_buf[baddr].cc; 2387 c = hSession->ea_buf[baddr].cc;
2374 if (hSession->ea_buf[baddr].fa) 2388 if (hSession->ea_buf[baddr].fa)
@@ -2377,17 +2391,19 @@ LIB3270_ACTION( fieldend ) @@ -2377,17 +2391,19 @@ LIB3270_ACTION( fieldend )
2377 last_nonblank = baddr; 2391 last_nonblank = baddr;
2378 } 2392 }
2379 2393
2380 - if (last_nonblank == -1) { 2394 + if (last_nonblank == -1)
  2395 + {
2381 baddr = faddr; 2396 baddr = faddr;
2382 INC_BA(baddr); 2397 INC_BA(baddr);
2383 - } else { 2398 + }
  2399 + else
  2400 + {
2384 baddr = last_nonblank; 2401 baddr = last_nonblank;
2385 INC_BA(baddr); 2402 INC_BA(baddr);
2386 if (hSession->ea_buf[baddr].fa) 2403 if (hSession->ea_buf[baddr].fa)
2387 baddr = last_nonblank; 2404 baddr = last_nonblank;
2388 } 2405 }
2389 - cursor_move(hSession,baddr);  
2390 - return 0; 2406 + return baddr;
2391 } 2407 }
2392 2408
2393 /** 2409 /**
src/lib3270/selection.c
@@ -862,6 +862,12 @@ LIB3270_EXPORT int lib3270_move_cursor(H3270 *hSession, LIB3270_DIRECTION dir, u @@ -862,6 +862,12 @@ LIB3270_EXPORT int lib3270_move_cursor(H3270 *hSession, LIB3270_DIRECTION dir, u
862 cursor_addr++; 862 cursor_addr++;
863 break; 863 break;
864 864
  865 + case LIB3270_DIR_END:
  866 + cursor_addr = lib3270_get_field_end(hSession,cursor_addr);
  867 + if(cursor_addr == -1)
  868 + return EINVAL;
  869 + break;
  870 +
865 default: 871 default:
866 return -1; 872 return -1;
867 } 873 }
src/pw3270/actions.c
@@ -320,7 +320,7 @@ static void cursor_move_action(GtkAction *action, GtkWidget *widget) @@ -320,7 +320,7 @@ static void cursor_move_action(GtkAction *action, GtkWidget *widget)
320 widget, 320 widget,
321 (unsigned int) flags); 321 (unsigned int) flags);
322 322
323 - lib3270_move_cursor(v3270_get_session(widget),(LIB3270_DIRECTION) (flags & 0x03), (flags & 0x80) ); 323 + lib3270_move_cursor(v3270_get_session(widget),(LIB3270_DIRECTION) (flags & 0x0F), (flags & 0x80) );
324 } 324 }
325 325
326 static void connect_move_action(GtkAction *action, GtkWidget *widget, const gchar *target, unsigned short flags, GError **error) 326 static void connect_move_action(GtkAction *action, GtkWidget *widget, const gchar *target, unsigned short flags, GError **error)
@@ -333,7 +333,7 @@ static void connect_move_action(GtkAction *action, GtkWidget *widget, const gcha @@ -333,7 +333,7 @@ static void connect_move_action(GtkAction *action, GtkWidget *widget, const gcha
333 333
334 if(!g_ascii_strcasecmp(target,"selection")) 334 if(!g_ascii_strcasecmp(target,"selection"))
335 { 335 {
336 - g_object_set_data(G_OBJECT(action),"direction",GINT_TO_POINTER((flags & 3))); 336 + g_object_set_data(G_OBJECT(action),"direction",GINT_TO_POINTER((flags & 0x0F)));
337 g_signal_connect(action,"activate",G_CALLBACK(selection_move_action),widget); 337 g_signal_connect(action,"activate",G_CALLBACK(selection_move_action),widget);
338 } 338 }
339 else if(!g_ascii_strcasecmp(target,"cursor")) 339 else if(!g_ascii_strcasecmp(target,"cursor"))
@@ -504,7 +504,7 @@ GtkAction * ui_get_action(GtkWidget *widget, const gchar *name, GHashTable *hash @@ -504,7 +504,7 @@ GtkAction * ui_get_action(GtkWidget *widget, const gchar *name, GHashTable *hash
504 } action_type = ACTION_TYPE_DEFAULT; 504 } action_type = ACTION_TYPE_DEFAULT;
505 505
506 if(dir != UI_ATTR_DIRECTION_NONE) 506 if(dir != UI_ATTR_DIRECTION_NONE)
507 - flags |= ((unsigned char) dir) & 0x03; 507 + flags |= ((unsigned char) dir) & 0x0F;
508 508
509 if(ui_get_bool_attribute("selecting",names,values,FALSE)) 509 if(ui_get_bool_attribute("selecting",names,values,FALSE))
510 flags |= 0x80; 510 flags |= 0x80;
src/pw3270/uiparser/parser.c
@@ -38,7 +38,7 @@ @@ -38,7 +38,7 @@
38 38
39 /*--[ Globals ]--------------------------------------------------------------------------------------*/ 39 /*--[ Globals ]--------------------------------------------------------------------------------------*/
40 40
41 -static const gchar * dirname[] = { "up", "down", "left", "right" }; 41 +static const gchar * dirname[] = { "up", "down", "left", "right", "end" };
42 42
43 /*--[ Implement ]------------------------------------------------------------------------------------*/ 43 /*--[ Implement ]------------------------------------------------------------------------------------*/
44 44
ui/00default.xml
@@ -214,7 +214,6 @@ @@ -214,7 +214,6 @@
214 <accelerator action='Delete' key='Delete' group='online' /> 214 <accelerator action='Delete' key='Delete' group='online' />
215 <accelerator action='erase' target='char' key='BackSpace' group='online' /> 215 <accelerator action='erase' target='char' key='BackSpace' group='online' />
216 <accelerator action='erase' target='eof' key='End' group='online' /> 216 <accelerator action='erase' target='eof' key='End' group='online' />
217 - <accelerator action='fieldend' key='<ctrl>End' group='online' />  
218 217
219 <accelerator action='SysREQ' key='Sys_Req' group='online' /> 218 <accelerator action='SysREQ' key='Sys_Req' group='online' />
220 <accelerator action='SysREQ' key='<shift>Print' group='online' /> 219 <accelerator action='SysREQ' key='<shift>Print' group='online' />
@@ -233,6 +232,7 @@ @@ -233,6 +232,7 @@
233 <accelerator action='move' target='cursor' direction='left' key='Left' group='online' /> 232 <accelerator action='move' target='cursor' direction='left' key='Left' group='online' />
234 <accelerator action='move' target='cursor' direction='up' key='Up' group='online' /> 233 <accelerator action='move' target='cursor' direction='up' key='Up' group='online' />
235 <accelerator action='move' target='cursor' direction='down' key='Down' group='online' /> 234 <accelerator action='move' target='cursor' direction='down' key='Down' group='online' />
  235 + <accelerator action='move' target='cursor' direction='end' key='<ctrl>End' group='online' />
236 236
237 <accelerator action='previousfield' key='ISO_Left_Tab' group='online' label='Previous field' /> 237 <accelerator action='previousfield' key='ISO_Left_Tab' group='online' label='Previous field' />
238 <accelerator action='nextfield' key='Tab' group='online' label='Next field'/> 238 <accelerator action='nextfield' key='Tab' group='online' label='Next field'/>