From 714aa8af40346706e1815a4a58101757f4c3faa2 Mon Sep 17 00:00:00 2001 From: perry.werneck@gmail.com Date: Thu, 6 Sep 2012 19:21:00 +0000 Subject: [PATCH] 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 --- kybd.c | 40 ++++++++++++++++++++++++++++------------ selection.c | 6 ++++++ 2 files changed, 34 insertions(+), 12 deletions(-) diff --git a/kybd.c b/kybd.c index 83af1ec..c2a57af 100644 --- a/kybd.c +++ b/kybd.c @@ -2346,29 +2346,43 @@ ToggleReverse_action(Widget w unused, XEvent *event, String *params, Cardinal *n */ LIB3270_ACTION( fieldend ) { - int baddr, faddr; - unsigned char fa, c; - int last_nonblank = -1; + int baddr; if (hSession->kybdlock) { ENQUEUE_ACTION( lib3270_fieldend ); return 0; } + + baddr = lib3270_get_field_end(hSession,hSession->cursor_addr); + if(baddr >= 0) + cursor_move(hSession,baddr); + + return 0; +} + +int lib3270_get_field_end(H3270 *hSession, int baddr) +{ + int faddr; + unsigned char fa, c; + int last_nonblank = -1; + #if defined(X3270_ANSI) /*[*/ if (IN_ANSI) - return 0; + return -1; #endif /*]*/ + if (!hSession->formatted) - return 0; - baddr = hSession->cursor_addr; + return -1; + faddr = find_field_attribute(hSession,baddr); fa = hSession->ea_buf[faddr].fa; if (faddr == baddr || FA_IS_PROTECTED(fa)) - return 0; + return -1; baddr = faddr; - while (True) { + while (True) + { INC_BA(baddr); c = hSession->ea_buf[baddr].cc; if (hSession->ea_buf[baddr].fa) @@ -2377,17 +2391,19 @@ LIB3270_ACTION( fieldend ) last_nonblank = baddr; } - if (last_nonblank == -1) { + if (last_nonblank == -1) + { baddr = faddr; INC_BA(baddr); - } else { + } + else + { baddr = last_nonblank; INC_BA(baddr); if (hSession->ea_buf[baddr].fa) baddr = last_nonblank; } - cursor_move(hSession,baddr); - return 0; + return baddr; } /** diff --git a/selection.c b/selection.c index c8a4aea..0bd46d2 100644 --- a/selection.c +++ b/selection.c @@ -862,6 +862,12 @@ LIB3270_EXPORT int lib3270_move_cursor(H3270 *hSession, LIB3270_DIRECTION dir, u cursor_addr++; break; + case LIB3270_DIR_END: + cursor_addr = lib3270_get_field_end(hSession,cursor_addr); + if(cursor_addr == -1) + return EINVAL; + break; + default: return -1; } -- libgit2 0.21.2