From 1d59066407c26b6f5034800afb08cef0e21dad83 Mon Sep 17 00:00:00 2001 From: perry.werneck@gmail.com Date: Mon, 13 Feb 2012 13:02:10 +0000 Subject: [PATCH] Função para emulação de entradas de teclado passa a receber uma estrutura de sessão como argumento --- latest/src/gtk2/screen.c | 3 ++- latest/src/include/lib3270.h | 21 +++++++++++++++++++++ latest/src/lib/ft.c | 2 +- latest/src/lib/kybd.c | 39 ++++++++++++--------------------------- latest/src/lib/macros.c | 2 +- 5 files changed, 37 insertions(+), 30 deletions(-) diff --git a/latest/src/gtk2/screen.c b/latest/src/gtk2/screen.c index 98c2b6f..877defb 100644 --- a/latest/src/gtk2/screen.c +++ b/latest/src/gtk2/screen.c @@ -207,7 +207,8 @@ } // NOTE (perry#1#): Is it the best way? - Input_String((const unsigned char *) input); +// Input_String((const unsigned char *) input); + lib3270_set_string(hSession, (const unsigned char *) input); g_free(input); } diff --git a/latest/src/include/lib3270.h b/latest/src/include/lib3270.h index 55c43e6..e6aaa2f 100644 --- a/latest/src/include/lib3270.h +++ b/latest/src/include/lib3270.h @@ -242,6 +242,27 @@ LIB3270_EXPORT LIB3270_CSTATE lib3270_get_connection_state(H3270 *h); /** + * Pretend that a sequence of keys was entered at the keyboard. + * + * "Pasting" means that the sequence came from the clipboard. Returns are + * ignored; newlines mean "move to beginning of next line"; tabs and formfeeds + * become spaces. Backslashes are not special, but ASCII ESC characters are + * used to signify 3270 Graphic Escapes. + * + * "Not pasting" means that the sequence is a login string specified in the + * hosts file, or a parameter to the String action. Returns are "move to + * beginning of next line"; newlines mean "Enter AID" and the termination of + * processing the string. Backslashes are processed as in C. + * + * @param s String to input. + * @param len Size of the string (or -1 to null terminated strings) + * @param pasting pasting flag (See comments). + * + * @return The number of unprocessed characters. + */ + LIB3270_EXPORT int lib3270_emulate_input(H3270 *session, char *s, int len, int pasting); + + /** * Set string at current cursor position. * * Returns are ignored; newlines mean "move to beginning of next line"; diff --git a/latest/src/lib/ft.c b/latest/src/lib/ft.c index 9ef4171..75c79b6 100644 --- a/latest/src/lib/ft.c +++ b/latest/src/lib/ft.c @@ -262,7 +262,7 @@ static const struct filetransfer_callbacks *callbacks = NULL; // Callbacks to m Trace("Command: \"%s\"",buffer); - (void) emulate_input(buffer, strlen(buffer), False); + (void) lib3270_emulate_input(NULL, buffer, strlen(buffer), False); // Get this thing started. set_ft_state(FT_AWAIT_ACK); diff --git a/latest/src/lib/kybd.c b/latest/src/lib/kybd.c index 8bab3e5..c643dab 100644 --- a/latest/src/lib/kybd.c +++ b/latest/src/lib/kybd.c @@ -3081,7 +3081,7 @@ xim_lookup(XKeyEvent *event) /* * Key action by string - */ + */ /* void Input_String(const unsigned char *str) { // reset_idle_timer(); @@ -3093,7 +3093,7 @@ void Input_String(const unsigned char *str) str++; } screen_disp(&h3270); -} +} */ /* * Key action. @@ -3312,36 +3312,16 @@ remargin(int lmargin) return True; } -/** - * Pretend that a sequence of keys was entered at the keyboard. - * - * "Pasting" means that the sequence came from the X clipboard. Returns are - * ignored; newlines mean "move to beginning of next line"; tabs and formfeeds - * become spaces. Backslashes are not special, but ASCII ESC characters are - * used to signify 3270 Graphic Escapes. - * - * "Not pasting" means that the sequence is a login string specified in the - * hosts file, or a parameter to the String action. Returns are "move to - * beginning of next line"; newlines mean "Enter AID" and the termination of - * processing the string. Backslashes are processed as in C. - * - * @param s String to input. - * @param len Size of the string (or -1 to null terminated strings) - * @param pasting pasting flag (See comments). - * - * @Returns the number of unprocessed characters. - */ -LIB3270_EXPORT int emulate_input(char *s, int len, int pasting) +LIB3270_EXPORT int lib3270_emulate_input(H3270 *session, char *s, int len, int pasting) { - enum { - BASE, BACKSLASH, BACKX, BACKP, BACKPA, BACKPF, OCTAL, HEX, XGE - } state = BASE; + enum { BASE, BACKSLASH, BACKX, BACKP, BACKPA, BACKPF, OCTAL, HEX, XGE } state = BASE; int literal = 0; int nc = 0; enum iaction ia = pasting ? IA_PASTE : IA_STRING; - int orig_addr = h3270.cursor_addr; - int orig_col = BA_TO_COL(h3270.cursor_addr); + int orig_addr; + int orig_col; Boolean skipped = False; + #if defined(X3270_DBCS) /*[*/ unsigned char ebc[2]; unsigned char cx; @@ -3354,6 +3334,11 @@ LIB3270_EXPORT int emulate_input(char *s, int len, int pasting) char *ws; #endif /*]*/ + CHECK_SESSION_HANDLE(session); + + orig_addr = session->cursor_addr; + orig_col = BA_TO_COL(session->cursor_addr); + if(len < 0) len = strlen(s); diff --git a/latest/src/lib/macros.c b/latest/src/lib/macros.c index bce68fa..d25d725 100644 --- a/latest/src/lib/macros.c +++ b/latest/src/lib/macros.c @@ -212,7 +212,7 @@ } if(str) - Input_String((unsigned char *) str); + lib3270_set_string(NULL, (const unsigned char *) str); return strdup(get_state(hSession)); } -- libgit2 0.21.2