Commit 714aa8af40346706e1815a4a58101757f4c3faa2
1 parent
8c98b4ca
Exists in
master
and in
3 other branches
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
Showing
2 changed files
with
34 additions
and
12 deletions
Show diff stats
kybd.c
| ... | ... | @@ -2346,29 +2346,43 @@ ToggleReverse_action(Widget w unused, XEvent *event, String *params, Cardinal *n |
| 2346 | 2346 | */ |
| 2347 | 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 | 2351 | if (hSession->kybdlock) |
| 2354 | 2352 | { |
| 2355 | 2353 | ENQUEUE_ACTION( lib3270_fieldend ); |
| 2356 | 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 | 2370 | #if defined(X3270_ANSI) /*[*/ |
| 2359 | 2371 | if (IN_ANSI) |
| 2360 | - return 0; | |
| 2372 | + return -1; | |
| 2361 | 2373 | #endif /*]*/ |
| 2374 | + | |
| 2362 | 2375 | if (!hSession->formatted) |
| 2363 | - return 0; | |
| 2364 | - baddr = hSession->cursor_addr; | |
| 2376 | + return -1; | |
| 2377 | + | |
| 2365 | 2378 | faddr = find_field_attribute(hSession,baddr); |
| 2366 | 2379 | fa = hSession->ea_buf[faddr].fa; |
| 2367 | 2380 | if (faddr == baddr || FA_IS_PROTECTED(fa)) |
| 2368 | - return 0; | |
| 2381 | + return -1; | |
| 2369 | 2382 | |
| 2370 | 2383 | baddr = faddr; |
| 2371 | - while (True) { | |
| 2384 | + while (True) | |
| 2385 | + { | |
| 2372 | 2386 | INC_BA(baddr); |
| 2373 | 2387 | c = hSession->ea_buf[baddr].cc; |
| 2374 | 2388 | if (hSession->ea_buf[baddr].fa) |
| ... | ... | @@ -2377,17 +2391,19 @@ LIB3270_ACTION( fieldend ) |
| 2377 | 2391 | last_nonblank = baddr; |
| 2378 | 2392 | } |
| 2379 | 2393 | |
| 2380 | - if (last_nonblank == -1) { | |
| 2394 | + if (last_nonblank == -1) | |
| 2395 | + { | |
| 2381 | 2396 | baddr = faddr; |
| 2382 | 2397 | INC_BA(baddr); |
| 2383 | - } else { | |
| 2398 | + } | |
| 2399 | + else | |
| 2400 | + { | |
| 2384 | 2401 | baddr = last_nonblank; |
| 2385 | 2402 | INC_BA(baddr); |
| 2386 | 2403 | if (hSession->ea_buf[baddr].fa) |
| 2387 | 2404 | baddr = last_nonblank; |
| 2388 | 2405 | } |
| 2389 | - cursor_move(hSession,baddr); | |
| 2390 | - return 0; | |
| 2406 | + return baddr; | |
| 2391 | 2407 | } |
| 2392 | 2408 | |
| 2393 | 2409 | /** | ... | ... |
selection.c
| ... | ... | @@ -862,6 +862,12 @@ LIB3270_EXPORT int lib3270_move_cursor(H3270 *hSession, LIB3270_DIRECTION dir, u |
| 862 | 862 | cursor_addr++; |
| 863 | 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 | 871 | default: |
| 866 | 872 | return -1; |
| 867 | 873 | } | ... | ... |