diff --git a/api.h b/api.h index 3c18cbe..f0a8497 100644 --- a/api.h +++ b/api.h @@ -303,10 +303,10 @@ #define COLOR_ATTR_UNDERLINE LIB3270_ATTR_UNDERLINE #define COLOR_ATTR_INTENSIFY LIB3270_ATTR_INTENSIFY - #define CHAR_ATTR_CG LIB3270_ATTR_CG +// #define CHAR_ATTR_CG LIB3270_ATTR_CG #define CHAR_ATTR_MARKER LIB3270_ATTR_MARKER - #define CHAR_ATTR_UNCONVERTED CHAR_ATTR_CG + #define CHAR_ATTR_UNCONVERTED LIB3270_ATTR_CG struct lib3270_option { diff --git a/host.c b/host.c index ebc9450..9c082ed 100644 --- a/host.c +++ b/host.c @@ -476,13 +476,11 @@ static int do_connect(H3270 *hSession, const char *n) char nb[2048]; /* name buffer */ char *s; /* temporary */ const char *chost; /* to whom we will connect */ -// char *target_name; char *ps = CN; char *port = CN; Boolean resolving; Boolean pending; static Boolean ansi_host; -// const char *localprocess_cmd = NULL; Boolean has_colons = False; if (lib3270_connected(hSession) || hSession->auto_reconnect_inprogress) @@ -499,7 +497,7 @@ static int do_connect(H3270 *hSession, const char *n) } /* Save in a modifiable buffer. */ - (void) strcpy(nb, n); + (void) strncpy(nb, n, 2047); /* Strip trailing blanks. */ s = nb + strlen(nb) - 1; @@ -509,14 +507,6 @@ static int do_connect(H3270 *hSession, const char *n) /* Remember this hostname, as the last hostname we connected to. */ lib3270_set_host(hSession,nb); -/* -#if defined(LOCAL_PROCESS) - if ((localprocess_cmd = parse_localprocess(nb)) != CN) { - chost = localprocess_cmd; - port = appres.port; - } else -#endif -*/ { Boolean needed; @@ -541,23 +531,8 @@ static int do_connect(H3270 *hSession, const char *n) * and port number * full_current_host is the entire string, for use in reconnecting */ - if (n != hSession->full_current_host) - lib3270_set_host(hSession,n); - Replace(hSession->current_host, CN); -/* - - if (localprocess_cmd != CN) { - if (hSession->full_current_host[strlen(OptLocalProcess)] != '\0') - hSession->current_host = NewString(hSession->full_current_host + strlen(OptLocalProcess) + 1); - else - hSession->current_host = NewString("default shell"); - } else { - hSession->current_host = s; - } -*/ - has_colons = (strchr(chost, ':') != NULL); Replace(hSession->qualified_host, @@ -780,13 +755,18 @@ LIB3270_EXPORT const char * lib3270_set_host(H3270 *h, const char *n) Trace("%s: %p",__FUNCTION__,n); - if(!n) - return NULL; + if(n && n != h->full_current_host) + { + char *new_hostname = strdup(n); + + trace("new hostname is \"%s\"",new_hostname); - if(h->full_current_host) - free(h->full_current_host); + if(h->full_current_host) + free(h->full_current_host); - h->full_current_host = strdup(n); + h->full_current_host = new_hostname; + + } return h->full_current_host; } diff --git a/screen.c b/screen.c index 2732bec..e300441 100644 --- a/screen.c +++ b/screen.c @@ -72,6 +72,8 @@ #define get_color_pair(fg,bg) (((bg&0x0F) << 4) | (fg&0x0F)) #define DEFCOLOR_MAP(f) ((((f) & FA_PROTECT) >> 4) | (((f) & FA_INT_HIGH_SEL) >> 3)) +/*--[ Implement ]------------------------------------------------------------------------------------*/ + static int logpopup(H3270 *session, LIB3270_NOTIFY type, const char *title, const char *msg, const char *fmt, va_list arg); 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); static void status_printer(H3270 *session, int on, void *dunno); static unsigned short color_from_fa(unsigned char fa); -static void addch(H3270 *session, int baddr, unsigned char c, unsigned short attr) +/*--[ Implement ]------------------------------------------------------------------------------------*/ + +static void addch(H3270 *session, int baddr, unsigned char c, unsigned short attr, int *first, int *last) { // If set to keep selection adjust corresponding flag based on the current state if(lib3270_get_toggle(session,LIB3270_TOGGLE_KEEP_SELECTED)) attr |= (session->text[baddr].attr & LIB3270_ATTR_SELECTED); if(session->text[baddr].chr == c && session->text[baddr].attr == attr) - return; + return; + + if(*first < 0) + *first = baddr; + *last = baddr; /* Converted char has changed, update it */ session->text[baddr].chr = c; @@ -275,11 +283,13 @@ LIB3270_EXPORT int lib3270_get_contents(H3270 *h, int first, int last, unsigned /* Display what's in the buffer. */ static void screen_update(H3270 *session, int bstart, int bend) { - int baddr; - unsigned short a; - int attr = COLOR_GREEN; - unsigned char fa; - int fa_addr; + int baddr; + unsigned short a; + int attr = COLOR_GREEN; + unsigned char fa; + int fa_addr; + int first = -1; + int last = -1; fa = get_field_attribute(session,bstart); a = color_from_fa(fa); @@ -293,12 +303,12 @@ static void screen_update(H3270 *session, int bstart, int bend) fa_addr = baddr; fa = session->ea_buf[baddr].fa; a = calc_attrs(session, baddr, baddr, fa); - addch(session,baddr,' ',(attr = COLOR_GREEN)|CHAR_ATTR_MARKER); + addch(session,baddr,' ',(attr = COLOR_GREEN)|CHAR_ATTR_MARKER,&first,&last); } else if (FA_IS_ZERO(fa)) { // Blank. - addch(session,baddr,' ',attr=a); + addch(session,baddr,' ',attr=a,&first,&last); } else { @@ -314,23 +324,37 @@ static void screen_update(H3270 *session, int bstart, int bend) if (session->ea_buf[baddr].cs == CS_LINEDRAW) { - addch(session,baddr,session->ea_buf[baddr].cc,attr); + addch(session,baddr,session->ea_buf[baddr].cc,attr,&first,&last); } else if (session->ea_buf[baddr].cs == CS_APL || (session->ea_buf[baddr].cs & CS_GE)) { - addch(session,baddr,session->ea_buf[baddr].cc,attr|CHAR_ATTR_CG); + addch(session,baddr,session->ea_buf[baddr].cc,attr|LIB3270_ATTR_CG,&first,&last); } else { if (toggled(MONOCASE)) - addch(session,baddr,asc2uc[ebc2asc[session->ea_buf[baddr].cc]],attr); + addch(session,baddr,asc2uc[ebc2asc[session->ea_buf[baddr].cc]],attr,&first,&last); else - addch(session,baddr,ebc2asc[session->ea_buf[baddr].cc],attr); + addch(session,baddr,ebc2asc[session->ea_buf[baddr].cc],attr,&first,&last); } } + + } + + if(first >= 0) + { + int len = (last - first)+1; + int f; + + for(f=first;fcols == 0) + len++; + } + + session->changed(session,first,len); } - session->changed(session,bstart,bend); } void screen_disp(H3270 *session) diff --git a/selection.c b/selection.c index 7ef4b61..f25678e 100644 --- a/selection.c +++ b/selection.c @@ -409,12 +409,15 @@ static char * get_text(H3270 *hSession,unsigned char all) LIB3270_EXPORT char * lib3270_get_text(H3270 *h, int offset, int len) { - char *buffer; - int col, maxlen; - char *ptr; + char * buffer; + int maxlen; + char * ptr; CHECK_SESSION_HANDLE(h); + if(!lib3270_connected(h)) + return NULL; + maxlen = h->rows * (h->cols+1); if(len < 0) @@ -422,21 +425,28 @@ LIB3270_EXPORT char * lib3270_get_text(H3270 *h, int offset, int len) else if(len > maxlen) len = maxlen; - buffer = malloc(len+1); - col = offset%h->cols; + buffer = malloc(len+2); ptr = buffer; while(len-- > 0) { - *(ptr++) = h->text[offset++].chr; - if(col++ >= h->cols && len > 0) + if(h->text[offset].attr & LIB3270_ATTR_CG) + *ptr = ' '; + else if(h->text[offset].chr) + *ptr = h->text[offset].chr; + else + *ptr = " "; + + ptr++; + offset++; + + if((offset%h->cols) == 0) { - col = 0; *(ptr++) = '\n'; len--; } } - *ptr = 0; + buffer[len] = 0; return buffer; } -- libgit2 0.21.2