From 016a9ca1e1cafa6c01eed0b29eaab6cc541e1462 Mon Sep 17 00:00:00 2001 From: perry.werneck@gmail.com Date: Fri, 13 Apr 2012 14:10:49 +0000 Subject: [PATCH] Implementando mudança do ponteiro do mouse de acordo com o campo --- api.h | 2 +- ctlr.c | 14 ++++++-------- ctlrc.h | 2 +- kybd.c | 16 ++++++++-------- paste.c | 4 ++-- screen.c | 15 +++++++++++++++ selection.c | 2 ++ 7 files changed, 35 insertions(+), 20 deletions(-) diff --git a/api.h b/api.h index e03a15d..96b35a6 100644 --- a/api.h +++ b/api.h @@ -271,7 +271,7 @@ /* Screen processing */ - #define CURSOR_MODE_NORMAL LIB3270_CURSOR_NORMAL + #define CURSOR_MODE_NORMAL LIB3270_CURSOR_EDITABLE #define CURSOR_MODE_WAITING LIB3270_CURSOR_WAITING #define CURSOR_MODE_LOCKED LIB3270_CURSOR_LOCKED diff --git a/ctlr.c b/ctlr.c index 1e7a737..9fd2077 100644 --- a/ctlr.c +++ b/ctlr.c @@ -380,7 +380,6 @@ int lib3270_field_length(H3270 *h, int baddr) */ unsigned char get_field_attribute(H3270 *h, int baddr) { - CHECK_SESSION_HANDLE(h); return h->ea_buf[find_field_attribute(h,baddr)].fa; } @@ -435,20 +434,19 @@ fa2ea(int baddr) * unprotected attribute byte, or 0 if no nonzero-width unprotected field * can be found. */ -int -next_unprotected(int baddr0) +int next_unprotected(H3270 *session, int baddr0) { register int baddr, nbaddr; nbaddr = baddr0; - do { + do + { baddr = nbaddr; INC_BA(nbaddr); - if (h3270.ea_buf[baddr].fa && - !FA_IS_PROTECTED(h3270.ea_buf[baddr].fa) && - !h3270.ea_buf[nbaddr].fa) + if(session->ea_buf[baddr].fa &&!FA_IS_PROTECTED(session->ea_buf[baddr].fa) &&!session->ea_buf[nbaddr].fa) return nbaddr; } while (nbaddr != baddr0); + return 0; } @@ -1287,7 +1285,7 @@ ctlr_write(unsigned char buf[], int buflen, Boolean erase) * Otherwise, advance to the first position of the * next unprotected field. */ - baddr = next_unprotected(h3270.buffer_addr); + baddr = next_unprotected(&h3270,h3270.buffer_addr); if (baddr < h3270.buffer_addr) baddr = 0; /* diff --git a/ctlrc.h b/ctlrc.h index 2a5b71c..df8df2a 100644 --- a/ctlrc.h +++ b/ctlrc.h @@ -53,7 +53,7 @@ LIB3270_INTERNAL struct ea *fa2ea(int baddr); LIB3270_INTERNAL Boolean get_bounded_field_attribute(register int baddr, register int bound, unsigned char *fa_out); LIB3270_INTERNAL void mdt_clear(int baddr); LIB3270_INTERNAL void mdt_set(int baddr); -LIB3270_INTERNAL int next_unprotected(int baddr0); +LIB3270_INTERNAL int next_unprotected(H3270 *session, int baddr0); LIB3270_INTERNAL enum pds process_ds(unsigned char *buf, int buflen); LIB3270_INTERNAL void ps_process(void); diff --git a/kybd.c b/kybd.c index 35d7ae3..2ada857 100644 --- a/kybd.c +++ b/kybd.c @@ -962,7 +962,7 @@ static Boolean key_Character(int code, Boolean with_ge, Boolean pasting, Boolean if (skipped != NULL) *skipped = True; if (FA_IS_SKIP(h3270.ea_buf[baddr].fa)) - baddr = next_unprotected(baddr); + baddr = next_unprotected(&h3270,baddr); else INC_BA(baddr); } @@ -1269,7 +1269,7 @@ retry: if (skipped != NULL) *skipped = True; if (FA_IS_SKIP(ea_buf[baddr].fa)) - baddr = next_unprotected(baddr); + baddr = next_unprotected(&h3270,baddr); else INC_BA(baddr); } @@ -1387,7 +1387,7 @@ LIB3270_KEY_ACTION( tab ) return 0; } #endif /*]*/ - cursor_move(&h3270,next_unprotected(h3270.cursor_addr)); + cursor_move(hSession,next_unprotected(hSession,hSession->cursor_addr)); return 0; } @@ -1550,7 +1550,7 @@ LIB3270_ACTION( firstfield ) cursor_move(hSession,0); return 0; } - cursor_move(hSession,next_unprotected(hSession->rows*hSession->cols-1)); + cursor_move(hSession,next_unprotected(hSession,hSession->rows*hSession->cols-1)); return 0; } @@ -2240,7 +2240,7 @@ LIB3270_CURSOR_ACTION( newline ) if (faddr != baddr && !FA_IS_PROTECTED(fa)) cursor_move(hSession,baddr); else - cursor_move(hSession,next_unprotected(baddr)); + cursor_move(hSession,next_unprotected(hSession,baddr)); return 0; } @@ -2263,7 +2263,7 @@ LIB3270_ACTION( dup ) if (key_Character(EBC_dup, False, False, NULL)) { screen_disp(hSession); - cursor_move(hSession,next_unprotected(hSession->cursor_addr)); + cursor_move(hSession,next_unprotected(hSession,hSession->cursor_addr)); } } @@ -2931,7 +2931,7 @@ remargin(int lmargin) faddr = find_field_attribute(&h3270,baddr); fa = h3270.ea_buf[faddr].fa; if (faddr == baddr || FA_IS_PROTECTED(fa)) { - baddr = next_unprotected(baddr); + baddr = next_unprotected(&h3270,baddr); if (baddr <= b0) return False; } @@ -3354,7 +3354,7 @@ kybd_prime(void) * The cursor is not in an unprotected field. Find the * next one. */ - baddr = next_unprotected(h3270.cursor_addr); + baddr = next_unprotected(&h3270,h3270.cursor_addr); /* If there isn't any, give up. */ if (!baddr) diff --git a/paste.c b/paste.c index e7b99ec..8c831da 100644 --- a/paste.c +++ b/paste.c @@ -122,7 +122,7 @@ fa = session->ea_buf[faddr].fa; if (faddr == baddr || FA_IS_PROTECTED(fa)) { - baddr = next_unprotected(baddr); + baddr = next_unprotected(session,baddr); if (baddr <= b0) return 0; } @@ -212,7 +212,7 @@ LIB3270_EXPORT int lib3270_set_string(H3270 *h, const unsigned char *str) if (faddr != baddr && !FA_IS_PROTECTED(fa)) cursor_move(h,baddr); else - cursor_move(h,next_unprotected(baddr)); + cursor_move(h,next_unprotected(h,baddr)); data.row = BA_TO_ROW(h->cursor_addr); } last = ' '; diff --git a/screen.c b/screen.c index ba0991b..8fc4000 100644 --- a/screen.c +++ b/screen.c @@ -768,3 +768,18 @@ LIB3270_EXPORT void lib3270_popup_dialog(H3270 *session, LIB3270_NOTIFY id , con popup_handler(session,id,title ? title : _( "3270 Error" ), message,fmt,args); va_end(args); } + +LIB3270_EXPORT int lib3270_is_protected(H3270 *h, unsigned int baddr) +{ + unsigned char fa; + + CHECK_SESSION_HANDLE(h); + + if(baddr > (h->rows * h->cols)) + return -1; + + fa = get_field_attribute(h,baddr); + + return FA_IS_PROTECTED(fa); +} + diff --git a/selection.c b/selection.c index e167894..3f915d1 100644 --- a/selection.c +++ b/selection.c @@ -606,6 +606,8 @@ LIB3270_EXPORT int lib3270_drag_selection(H3270 *h, unsigned char flag, int orig flag &= 0x1f; + trace("%s: flag=%04x",__FUNCTION__,flag); + if(!flag) return origin; else if(flag == SELECTION_ACTIVE) -- libgit2 0.21.2