Commit 44f280c7d6083e77a25b325fdcea572b911eeee2
1 parent
51b3ec90
Exists in
master
and in
3 other branches
Implementando suporte atk
Showing
4 changed files
with
70 additions
and
56 deletions
Show diff stats
@@ -303,10 +303,10 @@ | @@ -303,10 +303,10 @@ | ||
303 | #define COLOR_ATTR_UNDERLINE LIB3270_ATTR_UNDERLINE | 303 | #define COLOR_ATTR_UNDERLINE LIB3270_ATTR_UNDERLINE |
304 | #define COLOR_ATTR_INTENSIFY LIB3270_ATTR_INTENSIFY | 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 | #define CHAR_ATTR_MARKER LIB3270_ATTR_MARKER | 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 | struct lib3270_option | 311 | struct lib3270_option |
312 | { | 312 | { |
host.c
@@ -476,13 +476,11 @@ static int do_connect(H3270 *hSession, const char *n) | @@ -476,13 +476,11 @@ static int do_connect(H3270 *hSession, const char *n) | ||
476 | char nb[2048]; /* name buffer */ | 476 | char nb[2048]; /* name buffer */ |
477 | char *s; /* temporary */ | 477 | char *s; /* temporary */ |
478 | const char *chost; /* to whom we will connect */ | 478 | const char *chost; /* to whom we will connect */ |
479 | -// char *target_name; | ||
480 | char *ps = CN; | 479 | char *ps = CN; |
481 | char *port = CN; | 480 | char *port = CN; |
482 | Boolean resolving; | 481 | Boolean resolving; |
483 | Boolean pending; | 482 | Boolean pending; |
484 | static Boolean ansi_host; | 483 | static Boolean ansi_host; |
485 | -// const char *localprocess_cmd = NULL; | ||
486 | Boolean has_colons = False; | 484 | Boolean has_colons = False; |
487 | 485 | ||
488 | if (lib3270_connected(hSession) || hSession->auto_reconnect_inprogress) | 486 | if (lib3270_connected(hSession) || hSession->auto_reconnect_inprogress) |
@@ -499,7 +497,7 @@ static int do_connect(H3270 *hSession, const char *n) | @@ -499,7 +497,7 @@ static int do_connect(H3270 *hSession, const char *n) | ||
499 | } | 497 | } |
500 | 498 | ||
501 | /* Save in a modifiable buffer. */ | 499 | /* Save in a modifiable buffer. */ |
502 | - (void) strcpy(nb, n); | 500 | + (void) strncpy(nb, n, 2047); |
503 | 501 | ||
504 | /* Strip trailing blanks. */ | 502 | /* Strip trailing blanks. */ |
505 | s = nb + strlen(nb) - 1; | 503 | s = nb + strlen(nb) - 1; |
@@ -509,14 +507,6 @@ static int do_connect(H3270 *hSession, const char *n) | @@ -509,14 +507,6 @@ static int do_connect(H3270 *hSession, const char *n) | ||
509 | /* Remember this hostname, as the last hostname we connected to. */ | 507 | /* Remember this hostname, as the last hostname we connected to. */ |
510 | lib3270_set_host(hSession,nb); | 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 | Boolean needed; | 511 | Boolean needed; |
522 | 512 | ||
@@ -541,23 +531,8 @@ static int do_connect(H3270 *hSession, const char *n) | @@ -541,23 +531,8 @@ static int do_connect(H3270 *hSession, const char *n) | ||
541 | * and port number | 531 | * and port number |
542 | * full_current_host is the entire string, for use in reconnecting | 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 | Replace(hSession->current_host, CN); | 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 | has_colons = (strchr(chost, ':') != NULL); | 536 | has_colons = (strchr(chost, ':') != NULL); |
562 | 537 | ||
563 | Replace(hSession->qualified_host, | 538 | Replace(hSession->qualified_host, |
@@ -780,13 +755,18 @@ LIB3270_EXPORT const char * lib3270_set_host(H3270 *h, const char *n) | @@ -780,13 +755,18 @@ LIB3270_EXPORT const char * lib3270_set_host(H3270 *h, const char *n) | ||
780 | 755 | ||
781 | Trace("%s: %p",__FUNCTION__,n); | 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 | return h->full_current_host; | 771 | return h->full_current_host; |
792 | } | 772 | } |
screen.c
@@ -72,6 +72,8 @@ | @@ -72,6 +72,8 @@ | ||
72 | #define get_color_pair(fg,bg) (((bg&0x0F) << 4) | (fg&0x0F)) | 72 | #define get_color_pair(fg,bg) (((bg&0x0F) << 4) | (fg&0x0F)) |
73 | #define DEFCOLOR_MAP(f) ((((f) & FA_PROTECT) >> 4) | (((f) & FA_INT_HIGH_SEL) >> 3)) | 73 | #define DEFCOLOR_MAP(f) ((((f) & FA_PROTECT) >> 4) | (((f) & FA_INT_HIGH_SEL) >> 3)) |
74 | 74 | ||
75 | +/*--[ Implement ]------------------------------------------------------------------------------------*/ | ||
76 | + | ||
75 | static int logpopup(H3270 *session, LIB3270_NOTIFY type, const char *title, const char *msg, const char *fmt, va_list arg); | 77 | static int logpopup(H3270 *session, LIB3270_NOTIFY type, const char *title, const char *msg, const char *fmt, va_list arg); |
76 | 78 | ||
77 | static int (*popup_handler)(H3270 *, LIB3270_NOTIFY, const char *, const char *, const char *, va_list) = logpopup; | 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,14 +86,20 @@ static void status_3270_mode(H3270 *session, int ignored, void *dunno); | ||
84 | static void status_printer(H3270 *session, int on, void *dunno); | 86 | static void status_printer(H3270 *session, int on, void *dunno); |
85 | static unsigned short color_from_fa(unsigned char fa); | 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 | // If set to keep selection adjust corresponding flag based on the current state | 93 | // If set to keep selection adjust corresponding flag based on the current state |
90 | if(lib3270_get_toggle(session,LIB3270_TOGGLE_KEEP_SELECTED)) | 94 | if(lib3270_get_toggle(session,LIB3270_TOGGLE_KEEP_SELECTED)) |
91 | attr |= (session->text[baddr].attr & LIB3270_ATTR_SELECTED); | 95 | attr |= (session->text[baddr].attr & LIB3270_ATTR_SELECTED); |
92 | 96 | ||
93 | if(session->text[baddr].chr == c && session->text[baddr].attr == attr) | 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 | /* Converted char has changed, update it */ | 104 | /* Converted char has changed, update it */ |
97 | session->text[baddr].chr = c; | 105 | session->text[baddr].chr = c; |
@@ -275,11 +283,13 @@ LIB3270_EXPORT int lib3270_get_contents(H3270 *h, int first, int last, unsigned | @@ -275,11 +283,13 @@ LIB3270_EXPORT int lib3270_get_contents(H3270 *h, int first, int last, unsigned | ||
275 | /* Display what's in the buffer. */ | 283 | /* Display what's in the buffer. */ |
276 | static void screen_update(H3270 *session, int bstart, int bend) | 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 | fa = get_field_attribute(session,bstart); | 294 | fa = get_field_attribute(session,bstart); |
285 | a = color_from_fa(fa); | 295 | a = color_from_fa(fa); |
@@ -293,12 +303,12 @@ static void screen_update(H3270 *session, int bstart, int bend) | @@ -293,12 +303,12 @@ static void screen_update(H3270 *session, int bstart, int bend) | ||
293 | fa_addr = baddr; | 303 | fa_addr = baddr; |
294 | fa = session->ea_buf[baddr].fa; | 304 | fa = session->ea_buf[baddr].fa; |
295 | a = calc_attrs(session, baddr, baddr, fa); | 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 | else if (FA_IS_ZERO(fa)) | 308 | else if (FA_IS_ZERO(fa)) |
299 | { | 309 | { |
300 | // Blank. | 310 | // Blank. |
301 | - addch(session,baddr,' ',attr=a); | 311 | + addch(session,baddr,' ',attr=a,&first,&last); |
302 | } | 312 | } |
303 | else | 313 | else |
304 | { | 314 | { |
@@ -314,23 +324,37 @@ static void screen_update(H3270 *session, int bstart, int bend) | @@ -314,23 +324,37 @@ static void screen_update(H3270 *session, int bstart, int bend) | ||
314 | 324 | ||
315 | if (session->ea_buf[baddr].cs == CS_LINEDRAW) | 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 | else if (session->ea_buf[baddr].cs == CS_APL || (session->ea_buf[baddr].cs & CS_GE)) | 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 | else | 333 | else |
324 | { | 334 | { |
325 | if (toggled(MONOCASE)) | 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 | else | 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 | void screen_disp(H3270 *session) | 360 | void screen_disp(H3270 *session) |
selection.c
@@ -409,12 +409,15 @@ static char * get_text(H3270 *hSession,unsigned char all) | @@ -409,12 +409,15 @@ static char * get_text(H3270 *hSession,unsigned char all) | ||
409 | 409 | ||
410 | LIB3270_EXPORT char * lib3270_get_text(H3270 *h, int offset, int len) | 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 | CHECK_SESSION_HANDLE(h); | 416 | CHECK_SESSION_HANDLE(h); |
417 | 417 | ||
418 | + if(!lib3270_connected(h)) | ||
419 | + return NULL; | ||
420 | + | ||
418 | maxlen = h->rows * (h->cols+1); | 421 | maxlen = h->rows * (h->cols+1); |
419 | 422 | ||
420 | if(len < 0) | 423 | if(len < 0) |
@@ -422,21 +425,28 @@ LIB3270_EXPORT char * lib3270_get_text(H3270 *h, int offset, int len) | @@ -422,21 +425,28 @@ LIB3270_EXPORT char * lib3270_get_text(H3270 *h, int offset, int len) | ||
422 | else if(len > maxlen) | 425 | else if(len > maxlen) |
423 | len = maxlen; | 426 | len = maxlen; |
424 | 427 | ||
425 | - buffer = malloc(len+1); | ||
426 | - col = offset%h->cols; | 428 | + buffer = malloc(len+2); |
427 | ptr = buffer; | 429 | ptr = buffer; |
428 | 430 | ||
429 | while(len-- > 0) | 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 | *(ptr++) = '\n'; | 445 | *(ptr++) = '\n'; |
436 | len--; | 446 | len--; |
437 | } | 447 | } |
438 | } | 448 | } |
439 | - *ptr = 0; | 449 | + buffer[len] = 0; |
440 | 450 | ||
441 | return buffer; | 451 | return buffer; |
442 | } | 452 | } |