Commit 1d59066407c26b6f5034800afb08cef0e21dad83

Authored by perry.werneck@gmail.com
1 parent c0840359
Exists in master

Função para emulação de entradas de teclado passa a receber uma estrutura de sessão como argumento

latest/src/gtk2/screen.c
... ... @@ -207,7 +207,8 @@
207 207 }
208 208  
209 209 // NOTE (perry#1#): Is it the best way?
210   - Input_String((const unsigned char *) input);
  210 +// Input_String((const unsigned char *) input);
  211 + lib3270_set_string(hSession, (const unsigned char *) input);
211 212  
212 213 g_free(input);
213 214 }
... ...
latest/src/include/lib3270.h
... ... @@ -242,6 +242,27 @@
242 242 LIB3270_EXPORT LIB3270_CSTATE lib3270_get_connection_state(H3270 *h);
243 243  
244 244 /**
  245 + * Pretend that a sequence of keys was entered at the keyboard.
  246 + *
  247 + * "Pasting" means that the sequence came from the clipboard. Returns are
  248 + * ignored; newlines mean "move to beginning of next line"; tabs and formfeeds
  249 + * become spaces. Backslashes are not special, but ASCII ESC characters are
  250 + * used to signify 3270 Graphic Escapes.
  251 + *
  252 + * "Not pasting" means that the sequence is a login string specified in the
  253 + * hosts file, or a parameter to the String action. Returns are "move to
  254 + * beginning of next line"; newlines mean "Enter AID" and the termination of
  255 + * processing the string. Backslashes are processed as in C.
  256 + *
  257 + * @param s String to input.
  258 + * @param len Size of the string (or -1 to null terminated strings)
  259 + * @param pasting pasting flag (See comments).
  260 + *
  261 + * @return The number of unprocessed characters.
  262 + */
  263 + LIB3270_EXPORT int lib3270_emulate_input(H3270 *session, char *s, int len, int pasting);
  264 +
  265 + /**
245 266 * Set string at current cursor position.
246 267 *
247 268 * Returns are ignored; newlines mean "move to beginning of next line";
... ...
latest/src/lib/ft.c
... ... @@ -262,7 +262,7 @@ static const struct filetransfer_callbacks *callbacks = NULL; // Callbacks to m
262 262  
263 263 Trace("Command: \"%s\"",buffer);
264 264  
265   - (void) emulate_input(buffer, strlen(buffer), False);
  265 + (void) lib3270_emulate_input(NULL, buffer, strlen(buffer), False);
266 266  
267 267 // Get this thing started.
268 268 set_ft_state(FT_AWAIT_ACK);
... ...
latest/src/lib/kybd.c
... ... @@ -3081,7 +3081,7 @@ xim_lookup(XKeyEvent *event)
3081 3081  
3082 3082 /*
3083 3083 * Key action by string
3084   - */
  3084 + */ /*
3085 3085 void Input_String(const unsigned char *str)
3086 3086 {
3087 3087 // reset_idle_timer();
... ... @@ -3093,7 +3093,7 @@ void Input_String(const unsigned char *str)
3093 3093 str++;
3094 3094 }
3095 3095 screen_disp(&h3270);
3096   -}
  3096 +} */
3097 3097  
3098 3098 /*
3099 3099 * Key action.
... ... @@ -3312,36 +3312,16 @@ remargin(int lmargin)
3312 3312 return True;
3313 3313 }
3314 3314  
3315   -/**
3316   - * Pretend that a sequence of keys was entered at the keyboard.
3317   - *
3318   - * "Pasting" means that the sequence came from the X clipboard. Returns are
3319   - * ignored; newlines mean "move to beginning of next line"; tabs and formfeeds
3320   - * become spaces. Backslashes are not special, but ASCII ESC characters are
3321   - * used to signify 3270 Graphic Escapes.
3322   - *
3323   - * "Not pasting" means that the sequence is a login string specified in the
3324   - * hosts file, or a parameter to the String action. Returns are "move to
3325   - * beginning of next line"; newlines mean "Enter AID" and the termination of
3326   - * processing the string. Backslashes are processed as in C.
3327   - *
3328   - * @param s String to input.
3329   - * @param len Size of the string (or -1 to null terminated strings)
3330   - * @param pasting pasting flag (See comments).
3331   - *
3332   - * @Returns the number of unprocessed characters.
3333   - */
3334   -LIB3270_EXPORT int emulate_input(char *s, int len, int pasting)
  3315 +LIB3270_EXPORT int lib3270_emulate_input(H3270 *session, char *s, int len, int pasting)
3335 3316 {
3336   - enum {
3337   - BASE, BACKSLASH, BACKX, BACKP, BACKPA, BACKPF, OCTAL, HEX, XGE
3338   - } state = BASE;
  3317 + enum { BASE, BACKSLASH, BACKX, BACKP, BACKPA, BACKPF, OCTAL, HEX, XGE } state = BASE;
3339 3318 int literal = 0;
3340 3319 int nc = 0;
3341 3320 enum iaction ia = pasting ? IA_PASTE : IA_STRING;
3342   - int orig_addr = h3270.cursor_addr;
3343   - int orig_col = BA_TO_COL(h3270.cursor_addr);
  3321 + int orig_addr;
  3322 + int orig_col;
3344 3323 Boolean skipped = False;
  3324 +
3345 3325 #if defined(X3270_DBCS) /*[*/
3346 3326 unsigned char ebc[2];
3347 3327 unsigned char cx;
... ... @@ -3354,6 +3334,11 @@ LIB3270_EXPORT int emulate_input(char *s, int len, int pasting)
3354 3334 char *ws;
3355 3335 #endif /*]*/
3356 3336  
  3337 + CHECK_SESSION_HANDLE(session);
  3338 +
  3339 + orig_addr = session->cursor_addr;
  3340 + orig_col = BA_TO_COL(session->cursor_addr);
  3341 +
3357 3342 if(len < 0)
3358 3343 len = strlen(s);
3359 3344  
... ...
latest/src/lib/macros.c
... ... @@ -212,7 +212,7 @@
212 212 }
213 213  
214 214 if(str)
215   - Input_String((unsigned char *) str);
  215 + lib3270_set_string(NULL, (const unsigned char *) str);
216 216  
217 217 return strdup(get_state(hSession));
218 218 }
... ...