Commit 44f280c7d6083e77a25b325fdcea572b911eeee2

Authored by perry.werneck@gmail.com
1 parent 51b3ec90

Implementando suporte atk

Showing 4 changed files with 70 additions and 56 deletions   Show diff stats
api.h
... ... @@ -303,10 +303,10 @@
303 303 #define COLOR_ATTR_UNDERLINE LIB3270_ATTR_UNDERLINE
304 304 #define COLOR_ATTR_INTENSIFY LIB3270_ATTR_INTENSIFY
305 305  
306   - #define CHAR_ATTR_CG LIB3270_ATTR_CG
  306 +// #define CHAR_ATTR_CG LIB3270_ATTR_CG
307 307 #define CHAR_ATTR_MARKER LIB3270_ATTR_MARKER
308 308  
309   - #define CHAR_ATTR_UNCONVERTED CHAR_ATTR_CG
  309 + #define CHAR_ATTR_UNCONVERTED LIB3270_ATTR_CG
310 310  
311 311 struct lib3270_option
312 312 {
... ...
host.c
... ... @@ -476,13 +476,11 @@ static int do_connect(H3270 *hSession, const char *n)
476 476 char nb[2048]; /* name buffer */
477 477 char *s; /* temporary */
478 478 const char *chost; /* to whom we will connect */
479   -// char *target_name;
480 479 char *ps = CN;
481 480 char *port = CN;
482 481 Boolean resolving;
483 482 Boolean pending;
484 483 static Boolean ansi_host;
485   -// const char *localprocess_cmd = NULL;
486 484 Boolean has_colons = False;
487 485  
488 486 if (lib3270_connected(hSession) || hSession->auto_reconnect_inprogress)
... ... @@ -499,7 +497,7 @@ static int do_connect(H3270 *hSession, const char *n)
499 497 }
500 498  
501 499 /* Save in a modifiable buffer. */
502   - (void) strcpy(nb, n);
  500 + (void) strncpy(nb, n, 2047);
503 501  
504 502 /* Strip trailing blanks. */
505 503 s = nb + strlen(nb) - 1;
... ... @@ -509,14 +507,6 @@ static int do_connect(H3270 *hSession, const char *n)
509 507 /* Remember this hostname, as the last hostname we connected to. */
510 508 lib3270_set_host(hSession,nb);
511 509  
512   -/*
513   -#if defined(LOCAL_PROCESS)
514   - if ((localprocess_cmd = parse_localprocess(nb)) != CN) {
515   - chost = localprocess_cmd;
516   - port = appres.port;
517   - } else
518   -#endif
519   -*/
520 510 {
521 511 Boolean needed;
522 512  
... ... @@ -541,23 +531,8 @@ static int do_connect(H3270 *hSession, const char *n)
541 531 * and port number
542 532 * full_current_host is the entire string, for use in reconnecting
543 533 */
544   - if (n != hSession->full_current_host)
545   - lib3270_set_host(hSession,n);
546   -
547 534 Replace(hSession->current_host, CN);
548 535  
549   -/*
550   -
551   - if (localprocess_cmd != CN) {
552   - if (hSession->full_current_host[strlen(OptLocalProcess)] != '\0')
553   - hSession->current_host = NewString(hSession->full_current_host + strlen(OptLocalProcess) + 1);
554   - else
555   - hSession->current_host = NewString("default shell");
556   - } else {
557   - hSession->current_host = s;
558   - }
559   -*/
560   -
561 536 has_colons = (strchr(chost, ':') != NULL);
562 537  
563 538 Replace(hSession->qualified_host,
... ... @@ -780,13 +755,18 @@ LIB3270_EXPORT const char * lib3270_set_host(H3270 *h, const char *n)
780 755  
781 756 Trace("%s: %p",__FUNCTION__,n);
782 757  
783   - if(!n)
784   - return NULL;
  758 + if(n && n != h->full_current_host)
  759 + {
  760 + char *new_hostname = strdup(n);
  761 +
  762 + trace("new hostname is \"%s\"",new_hostname);
785 763  
786   - if(h->full_current_host)
787   - free(h->full_current_host);
  764 + if(h->full_current_host)
  765 + free(h->full_current_host);
788 766  
789   - h->full_current_host = strdup(n);
  767 + h->full_current_host = new_hostname;
  768 +
  769 + }
790 770  
791 771 return h->full_current_host;
792 772 }
... ...
screen.c
... ... @@ -72,6 +72,8 @@
72 72 #define get_color_pair(fg,bg) (((bg&0x0F) << 4) | (fg&0x0F))
73 73 #define DEFCOLOR_MAP(f) ((((f) & FA_PROTECT) >> 4) | (((f) & FA_INT_HIGH_SEL) >> 3))
74 74  
  75 +/*--[ Implement ]------------------------------------------------------------------------------------*/
  76 +
75 77 static int logpopup(H3270 *session, LIB3270_NOTIFY type, const char *title, const char *msg, const char *fmt, va_list arg);
76 78  
77 79 static int (*popup_handler)(H3270 *, LIB3270_NOTIFY, const char *, const char *, const char *, va_list) = logpopup;
... ... @@ -84,14 +86,20 @@ static void status_3270_mode(H3270 *session, int ignored, void *dunno);
84 86 static void status_printer(H3270 *session, int on, void *dunno);
85 87 static unsigned short color_from_fa(unsigned char fa);
86 88  
87   -static void addch(H3270 *session, int baddr, unsigned char c, unsigned short attr)
  89 +/*--[ Implement ]------------------------------------------------------------------------------------*/
  90 +
  91 +static void addch(H3270 *session, int baddr, unsigned char c, unsigned short attr, int *first, int *last)
88 92 {
89 93 // If set to keep selection adjust corresponding flag based on the current state
90 94 if(lib3270_get_toggle(session,LIB3270_TOGGLE_KEEP_SELECTED))
91 95 attr |= (session->text[baddr].attr & LIB3270_ATTR_SELECTED);
92 96  
93 97 if(session->text[baddr].chr == c && session->text[baddr].attr == attr)
94   - return;
  98 + return;
  99 +
  100 + if(*first < 0)
  101 + *first = baddr;
  102 + *last = baddr;
95 103  
96 104 /* Converted char has changed, update it */
97 105 session->text[baddr].chr = c;
... ... @@ -275,11 +283,13 @@ LIB3270_EXPORT int lib3270_get_contents(H3270 *h, int first, int last, unsigned
275 283 /* Display what's in the buffer. */
276 284 static void screen_update(H3270 *session, int bstart, int bend)
277 285 {
278   - int baddr;
279   - unsigned short a;
280   - int attr = COLOR_GREEN;
281   - unsigned char fa;
282   - int fa_addr;
  286 + int baddr;
  287 + unsigned short a;
  288 + int attr = COLOR_GREEN;
  289 + unsigned char fa;
  290 + int fa_addr;
  291 + int first = -1;
  292 + int last = -1;
283 293  
284 294 fa = get_field_attribute(session,bstart);
285 295 a = color_from_fa(fa);
... ... @@ -293,12 +303,12 @@ static void screen_update(H3270 *session, int bstart, int bend)
293 303 fa_addr = baddr;
294 304 fa = session->ea_buf[baddr].fa;
295 305 a = calc_attrs(session, baddr, baddr, fa);
296   - addch(session,baddr,' ',(attr = COLOR_GREEN)|CHAR_ATTR_MARKER);
  306 + addch(session,baddr,' ',(attr = COLOR_GREEN)|CHAR_ATTR_MARKER,&first,&last);
297 307 }
298 308 else if (FA_IS_ZERO(fa))
299 309 {
300 310 // Blank.
301   - addch(session,baddr,' ',attr=a);
  311 + addch(session,baddr,' ',attr=a,&first,&last);
302 312 }
303 313 else
304 314 {
... ... @@ -314,23 +324,37 @@ static void screen_update(H3270 *session, int bstart, int bend)
314 324  
315 325 if (session->ea_buf[baddr].cs == CS_LINEDRAW)
316 326 {
317   - addch(session,baddr,session->ea_buf[baddr].cc,attr);
  327 + addch(session,baddr,session->ea_buf[baddr].cc,attr,&first,&last);
318 328 }
319 329 else if (session->ea_buf[baddr].cs == CS_APL || (session->ea_buf[baddr].cs & CS_GE))
320 330 {
321   - addch(session,baddr,session->ea_buf[baddr].cc,attr|CHAR_ATTR_CG);
  331 + addch(session,baddr,session->ea_buf[baddr].cc,attr|LIB3270_ATTR_CG,&first,&last);
322 332 }
323 333 else
324 334 {
325 335 if (toggled(MONOCASE))
326   - addch(session,baddr,asc2uc[ebc2asc[session->ea_buf[baddr].cc]],attr);
  336 + addch(session,baddr,asc2uc[ebc2asc[session->ea_buf[baddr].cc]],attr,&first,&last);
327 337 else
328   - addch(session,baddr,ebc2asc[session->ea_buf[baddr].cc],attr);
  338 + addch(session,baddr,ebc2asc[session->ea_buf[baddr].cc],attr,&first,&last);
329 339 }
330 340 }
331 341  
  342 +
  343 + }
  344 +
  345 + if(first >= 0)
  346 + {
  347 + int len = (last - first)+1;
  348 + int f;
  349 +
  350 + for(f=first;f<last;f++)
  351 + {
  352 + if(f%session->cols == 0)
  353 + len++;
  354 + }
  355 +
  356 + session->changed(session,first,len);
332 357 }
333   - session->changed(session,bstart,bend);
334 358 }
335 359  
336 360 void screen_disp(H3270 *session)
... ...
selection.c
... ... @@ -409,12 +409,15 @@ static char * get_text(H3270 *hSession,unsigned char all)
409 409  
410 410 LIB3270_EXPORT char * lib3270_get_text(H3270 *h, int offset, int len)
411 411 {
412   - char *buffer;
413   - int col, maxlen;
414   - char *ptr;
  412 + char * buffer;
  413 + int maxlen;
  414 + char * ptr;
415 415  
416 416 CHECK_SESSION_HANDLE(h);
417 417  
  418 + if(!lib3270_connected(h))
  419 + return NULL;
  420 +
418 421 maxlen = h->rows * (h->cols+1);
419 422  
420 423 if(len < 0)
... ... @@ -422,21 +425,28 @@ LIB3270_EXPORT char * lib3270_get_text(H3270 *h, int offset, int len)
422 425 else if(len > maxlen)
423 426 len = maxlen;
424 427  
425   - buffer = malloc(len+1);
426   - col = offset%h->cols;
  428 + buffer = malloc(len+2);
427 429 ptr = buffer;
428 430  
429 431 while(len-- > 0)
430 432 {
431   - *(ptr++) = h->text[offset++].chr;
432   - if(col++ >= h->cols && len > 0)
  433 + if(h->text[offset].attr & LIB3270_ATTR_CG)
  434 + *ptr = ' ';
  435 + else if(h->text[offset].chr)
  436 + *ptr = h->text[offset].chr;
  437 + else
  438 + *ptr = " ";
  439 +
  440 + ptr++;
  441 + offset++;
  442 +
  443 + if((offset%h->cols) == 0)
433 444 {
434   - col = 0;
435 445 *(ptr++) = '\n';
436 446 len--;
437 447 }
438 448 }
439   - *ptr = 0;
  449 + buffer[len] = 0;
440 450  
441 451 return buffer;
442 452 }
... ...