From fae7d9d28a7f4e490bc82f31fd4b2ff282326eec Mon Sep 17 00:00:00 2001 From: perry.werneck@gmail.com Date: Fri, 16 Mar 2012 18:36:19 +0000 Subject: [PATCH] Separando alocação/liberação da estrutura de sessão num bloco separado, reorganizando gerenciamento de buffers, melhorando apresentação da posição do cursor que as vezes, ficava cortada --- Makefile.in | 2 +- XtGlue.c | 33 ++++++++++++++++++++++++--------- ctlr.c | 39 ++++++++++++++++++++++----------------- glue.c | 246 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ init.c | 279 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ localdefs.h | 23 +++++++++++++++++++---- screen.c | 14 +++++++------- selection.c | 52 ++++++++++++++++++++++++++-------------------------- 8 files changed, 378 insertions(+), 310 deletions(-) create mode 100644 init.c diff --git a/Makefile.in b/Makefile.in index 7b255ea..8e9ba59 100644 --- a/Makefile.in +++ b/Makefile.in @@ -89,7 +89,7 @@ $(OBJRLS)/%.o: %.c $(DEPENDS) #---[ Sources ]---------------------------------------------------------------- -SOURCES = XtGlue.c actions.c ansi.c charset.c ctlr.c \ +SOURCES = XtGlue.c init.c actions.c ansi.c charset.c ctlr.c \ ft.c ft_cut.c ft_dft.c glue.c host.c kybd.c \ print.c printer.c proxy.c resources.c rpq.c screen.c see.c \ sf.c tables.c telnet.c toggles.c trace_ds.c utf8.c util.c \ diff --git a/XtGlue.c b/XtGlue.c index 34a00dd..04b37a9 100644 --- a/XtGlue.c +++ b/XtGlue.c @@ -555,8 +555,7 @@ static int DefaultProcessEvents(int block) /*---[ Implement external calls ]---------------------------------------------------------------------------*/ -void * -Malloc(size_t len) +void * Malloc(size_t len) { char *r; @@ -566,11 +565,10 @@ Malloc(size_t len) return r; } -void * -Calloc(size_t nelem, size_t elsize) +void * Calloc(size_t nelem, size_t elsize) { - int sz = nelem * elsize; - char *r = malloc(sz); + int sz = nelem * elsize; + char * r = malloc(sz); if(!r) Error(NULL,"Out of memory"); @@ -579,8 +577,7 @@ Calloc(size_t nelem, size_t elsize) return r; } -void * -Realloc(void *p, size_t len) +void * Realloc(void *p, size_t len) { p = realloc(p, len); if (p == NULL) @@ -590,10 +587,28 @@ Realloc(void *p, size_t len) void Free(void *p) { - if (p != NULL) + if(p) free(p); } +void * lib3270_calloc(size_t elsize, size_t nelem, void *ptr) +{ + size_t sz = nelem * elsize; + + if(ptr) + ptr = realloc(ptr,sz); + else + ptr = malloc(sz); + + if(ptr) + memset(ptr,0,sz); + else + Error(NULL,"Out of memory"); + + return ptr; +} + + static struct { const char *name; KeySym keysym; diff --git a/ctlr.c b/ctlr.c index 434c68b..e13bb5b 100644 --- a/ctlr.c +++ b/ctlr.c @@ -91,7 +91,7 @@ Boolean dbcs = False; /* Statics */ static struct ea *aea_buf; /* alternate 3270 extended attribute buffer */ -static unsigned char *zero_buf; /* empty buffer, for area clears */ +static unsigned char *zero_buf; // empty buffer, for area clears static void set_formatted(H3270 *session); static void ctlr_blanks(void); static Boolean trace_primed = False; @@ -160,22 +160,28 @@ void ctlr_init(H3270 *session, unsigned cmask unused) */ void ctlr_reinit(H3270 *session, unsigned cmask) { - static struct ea *real_ea_buf = NULL; - static struct ea *real_aea_buf = NULL; +// static struct ea *real_ea_buf = NULL; +// static struct ea *real_aea_buf = NULL; - if (cmask & MODEL_CHANGE) { + if (cmask & MODEL_CHANGE) + { /* Allocate buffers */ - if (real_ea_buf) - Free((char *)real_ea_buf); - real_ea_buf = (struct ea *)Calloc(sizeof(struct ea),(session->maxROWS * session->maxCOLS) + 1); - session->ea_buf = real_ea_buf + 1; - if (real_aea_buf) - Free((char *)real_aea_buf); - real_aea_buf = (struct ea *)Calloc(sizeof(struct ea),(session->maxROWS * session->maxCOLS) + 1); - aea_buf = real_aea_buf + 1; - Replace(zero_buf, (unsigned char *)Calloc(sizeof(struct ea),session->maxROWS * session->maxCOLS)); - session->cursor_addr = 0; - buffer_addr = 0; + struct ea *tmp; + size_t sz = (session->maxROWS * session->maxCOLS); + + + session->buffer[0] = tmp = lib3270_calloc(sizeof(struct ea),sz+1, session->buffer[0]); + session->ea_buf = tmp + 1; + + session->buffer[1] = tmp = lib3270_calloc(sizeof(struct ea),sz+1,session->buffer[1]); + aea_buf = tmp + 1; + + session->text = lib3270_calloc(sizeof(struct lib3270_text),sz,session->text); + + Replace(zero_buf, (unsigned char *)Calloc(sizeof(struct ea),sz)); + + session->cursor_addr = 0; + buffer_addr = 0; } } @@ -2551,8 +2557,7 @@ ctlr_bcopy(int baddr_from, int baddr_to, int count, int move_ea) * Erase a region of the 3270 buffer, optionally clearing extended attributes * as well. */ -void -ctlr_aclear(int baddr, int count, int clear_ea) +void ctlr_aclear(int baddr, int count, int clear_ea) { if (memcmp((char *) &h3270.ea_buf[baddr], (char *) zero_buf, count * sizeof(struct ea))) { diff --git a/glue.c b/glue.c index 37e3804..fddd25c 100644 --- a/glue.c +++ b/glue.c @@ -99,10 +99,6 @@ #define LAST_ARG "--" -/*---[ Statics ]--------------------------------------------------------------------------------------------------------------*/ - - static int parse_model_number(const char *m); - /*---[ Globals ]--------------------------------------------------------------------------------------------------------------*/ H3270 h3270; const char * programname; @@ -117,179 +113,6 @@ char *profile_name = CN; #endif /*]*/ -void lib3270_session_free(H3270 *h) -{ - int f; - - // Terminate session - if(lib3270_connected(h)) - lib3270_disconnect(h); - - shutdown_toggles(h,appres.toggle); - - // Release state change callbacks - for(f=0;fst_callbacks[f]) - { - struct lib3270_state_callback *next = h->st_callbacks[f]->next; - Free(h->st_callbacks[f]); - h->st_callbacks[f] = next; - } - } - - // Release memory - #define RELEASE_BUFFER(x) if(x) { free(x); x = NULL; } - - RELEASE_BUFFER(h->charset); - RELEASE_BUFFER(h->paste_buffer); - -} - -static void update_char(H3270 *session, int addr, unsigned char chr, unsigned short attr, unsigned char cursor) -{ - -} - -static void nop_char(H3270 *session, unsigned char chr) -{ - -} - -static void nop(H3270 *session) -{ - -} - -static void lib3270_session_init(H3270 *hSession, const char *model) -{ - int ovc, ovr; - char junk; - int model_number; - - memset(hSession,0,sizeof(H3270)); - hSession->sz = sizeof(H3270); - - // A few dummy calls to avoid "ifs" - hSession->update = update_char; - hSession->set_selection = nop_char; - hSession->ctlr_done = nop; - - hSession->sock = -1; - hSession->model_num = -1; - hSession->cstate = NOT_CONNECTED; - hSession->oia_status = -1; - - strncpy(hSession->full_model_name,"IBM-",LIB3270_FULL_MODEL_NAME_LENGTH); - hSession->model_name = &hSession->full_model_name[4]; - - /* - * Sort out model and color modes, based on the model number resource. - */ /* - if(appres.model && *appres.model) - model = appres.model; - */ - - if(!*model) - model = "2"; // No model, use the default one - -// Trace("Parsing model: %s",appres.model); - model_number = parse_model_number(model); - if (model_number < 0) - { - popup_an_error(NULL,"Invalid model number: %s", model); - model_number = 0; - } - - if (!model_number) - { -#if defined(RESTRICT_3279) - model_number = 3; -#else - model_number = 4; -#endif - } - - if(appres.mono) - appres.m3279 = False; - - if(!appres.extended) - appres.oversize = CN; - -#if defined(RESTRICT_3279) - if (appres.m3279 && model_number == 4) - model_number = 3; -#endif - - Trace("Model_number: %d",model_number); - - if (!appres.extended || appres.oversize == CN || sscanf(appres.oversize, "%dx%d%c", &ovc, &ovr, &junk) != 2) - { - ovc = 0; - ovr = 0; - } - ctlr_set_rows_cols(hSession, model_number, ovc, ovr); - - if (appres.termname != CN) - hSession->termtype = appres.termname; - else - hSession->termtype = hSession->full_model_name; - - Trace("Termtype: %s",hSession->termtype); - - if (appres.apl_mode) - appres.charset = Apl; - -} - -H3270 * lib3270_session_new(const char *model) -{ - static int configured = 0; - - H3270 *hSession = &h3270; - - Trace("%s - configured=%d",__FUNCTION__,configured); - - if(configured) - { - // TODO (perry#5#): Allocate a new structure. - errno = EBUSY; - return hSession; - } - - configured = 1; - - lib3270_session_init(hSession, model); - - if(screen_init(hSession)) - return NULL; - - Trace("Charset: %s",appres.charset); - if (charset_init(hSession,appres.charset) != CS_OKAY) - { - Warning(hSession, _( "Cannot find charset \"%s\", using defaults" ), appres.charset); - (void) charset_init(hSession,CN); - } - - kybd_init(); -// hostfile_init(); -// hostfile_init(); - ansi_init(); - -#if defined(X3270_FT) - ft_init(); -#endif - -#if defined(X3270_PRINTER) - printer_init(); -#endif - - Trace("%s finished",__FUNCTION__); - - errno = 0; - return hSession; -} - /* * Set default options */ @@ -536,75 +359,6 @@ const struct lib3270_option * get_3270_option_table(int sz) } /* - * Parse the model number. - * Returns -1 (error), 0 (default), or the specified number. - */ -static int parse_model_number(const char *m) -{ - int sl; - int n; - - if(!m) - return 0; - - sl = strlen(m); - - /* An empty model number is no good. */ - if (!sl) - return 0; - - if (sl > 1) { - /* - * If it's longer than one character, it needs to start with - * '327[89]', and it sets the m3279 resource. - */ - if (!strncmp(m, "3278", 4)) { - appres.m3279 = False; - } else if (!strncmp(m, "3279", 4)) { - appres.m3279 = True; - } else { - return -1; - } - m += 4; - sl -= 4; - - /* Check more syntax. -E is allowed, but ignored. */ - switch (m[0]) { - case '\0': - /* Use default model number. */ - return 0; - case '-': - /* Model number specified. */ - m++; - sl--; - break; - default: - return -1; - } - switch (sl) { - case 1: /* n */ - break; - case 3: /* n-E */ - if (strcasecmp(m + 1, "-E")) { - return -1; - } - break; - default: - return -1; - } - } - - /* Check the numeric model number. */ - n = atoi(m); - if (n >= 2 && n <= 5) { - return n; - } else { - return -1; - } - -} - -/* * Parse '-xrm' options. * Understands only: * {c,s,tcl}3270.: value diff --git a/init.c b/init.c new file mode 100644 index 0000000..676c39c --- /dev/null +++ b/init.c @@ -0,0 +1,279 @@ +/* + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a + * aplicativos mainframe. Registro no INPI sob o nome G3270. Registro no INPI sob o nome G3270. + * + * Copyright (C) <2008> + * + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela + * Free Software Foundation. + * + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para + * obter mais detalhes. + * + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este + * programa; se não, escreva para a Free Software Foundation, Inc., 59 Temple + * Place, Suite 330, Boston, MA, 02111-1307, USA + * + * Este programa está nomeado como init.c e possui - linhas de código. + * + * Contatos: + * + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) + * licinio@bb.com.br (Licínio Luis Branco) + * kraucer@bb.com.br (Kraucer Fernandes Mazuco) + * macmiranda@bb.com.br (Marco Aurélio Caldas Miranda) + * + */ + + +#include "globals.h" +#include "appres.h" +#include "charsetc.h" + +/*---[ Statics ]--------------------------------------------------------------------------------------------------------------*/ + + static int parse_model_number(H3270 *session, const char *m); + +/*---[ Implement ]------------------------------------------------------------------------------------------------------------*/ + +void lib3270_session_free(H3270 *h) +{ + int f; + + // Terminate session + if(lib3270_connected(h)) + lib3270_disconnect(h); + + shutdown_toggles(h,appres.toggle); + + // Release state change callbacks + for(f=0;fst_callbacks[f]) + { + struct lib3270_state_callback *next = h->st_callbacks[f]->next; + Free(h->st_callbacks[f]); + h->st_callbacks[f] = next; + } + } + + // Release memory + #define RELEASE_BUFFER(x) if(x) { free(x); x = NULL; } + + RELEASE_BUFFER(h->charset); + RELEASE_BUFFER(h->paste_buffer); + + for(f=0;f<(sizeof(h->buffer)/sizeof(h->buffer[0]));f++) + { + RELEASE_BUFFER(h->buffer[f]); + } + +} + +static void update_char(H3270 *session, int addr, unsigned char chr, unsigned short attr, unsigned char cursor) +{ + +} + +static void nop_char(H3270 *session, unsigned char chr) +{ + +} + +static void nop(H3270 *session) +{ + +} + +static void lib3270_session_init(H3270 *hSession, const char *model) +{ + int ovc, ovr; + char junk; + int model_number; + + memset(hSession,0,sizeof(H3270)); + hSession->sz = sizeof(H3270); + + // A few dummy calls to avoid "ifs" + hSession->update = update_char; + hSession->set_selection = nop_char; + hSession->ctlr_done = nop; + + hSession->sock = -1; + hSession->model_num = -1; + hSession->cstate = NOT_CONNECTED; + hSession->oia_status = -1; + + strncpy(hSession->full_model_name,"IBM-",LIB3270_FULL_MODEL_NAME_LENGTH); + hSession->model_name = &hSession->full_model_name[4]; + + if(!*model) + model = "2"; // No model, use the default one + + model_number = parse_model_number(hSession,model); + if (model_number < 0) + { + popup_an_error(NULL,"Invalid model number: %s", model); + model_number = 0; + } + + if (!model_number) + { +#if defined(RESTRICT_3279) + model_number = 3; +#else + model_number = 4; +#endif + } + + if(appres.mono) + appres.m3279 = False; + + if(!appres.extended) + appres.oversize = CN; + +#if defined(RESTRICT_3279) + if (appres.m3279 && model_number == 4) + model_number = 3; +#endif + + Trace("Model_number: %d",model_number); + + if (!appres.extended || appres.oversize == CN || sscanf(appres.oversize, "%dx%d%c", &ovc, &ovr, &junk) != 2) + { + ovc = 0; + ovr = 0; + } + ctlr_set_rows_cols(hSession, model_number, ovc, ovr); + + if (appres.termname != CN) + hSession->termtype = appres.termname; + else + hSession->termtype = hSession->full_model_name; + + Trace("Termtype: %s",hSession->termtype); + + if (appres.apl_mode) + appres.charset = "apl"; + +} + +H3270 * lib3270_session_new(const char *model) +{ + static int configured = 0; + + H3270 *hSession = &h3270; + + Trace("%s - configured=%d",__FUNCTION__,configured); + + if(configured) + { + // TODO (perry#5#): Allocate a new structure. + errno = EBUSY; + return hSession; + } + + configured = 1; + + lib3270_session_init(hSession, model); + + if(screen_init(hSession)) + return NULL; + + Trace("Charset: %s",appres.charset); + if (charset_init(hSession,appres.charset) != CS_OKAY) + { + Warning(hSession, _( "Cannot find charset \"%s\", using defaults" ), appres.charset); + (void) charset_init(hSession,CN); + } + + kybd_init(); + ansi_init(); + +#if defined(X3270_FT) + ft_init(); +#endif + +#if defined(X3270_PRINTER) + printer_init(); +#endif + + Trace("%s finished",__FUNCTION__); + + errno = 0; + return hSession; +} + + /* +- * Parse the model number. +- * Returns -1 (error), 0 (default), or the specified number. +- */ +static int parse_model_number(H3270 *session, const char *m) +{ + int sl; + int n; + + if(!m) + return 0; + + sl = strlen(m); + + /* An empty model number is no good. */ + if (!sl) + return 0; + + if (sl > 1) { + /* + * If it's longer than one character, it needs to start with + * '327[89]', and it sets the m3279 resource. + */ + if (!strncmp(m, "3278", 4)) { + appres.m3279 = False; + } else if (!strncmp(m, "3279", 4)) { + appres.m3279 = True; + } else { + return -1; + } + m += 4; + sl -= 4; + + /* Check more syntax. -E is allowed, but ignored. */ + switch (m[0]) { + case '\0': + /* Use default model number. */ + return 0; + case '-': + /* Model number specified. */ + m++; + sl--; + break; + default: + return -1; + } + switch (sl) { + case 1: /* n */ + break; + case 3: /* n-E */ + if (strcasecmp(m + 1, "-E")) { + return -1; + } + break; + default: + return -1; + } + } + + /* Check the numeric model number. */ + n = atoi(m); + if (n >= 2 && n <= 5) { + return n; + } else { + return -1; + } + +} diff --git a/localdefs.h b/localdefs.h index 381cec6..dc7a237 100644 --- a/localdefs.h +++ b/localdefs.h @@ -55,10 +55,25 @@ typedef struct _XtActionsRec{ #define NoSymbol 0L /* These are local functions with similar semantics to X functions. */ -void *Malloc(size_t); -void Free(void *); -void *Calloc(size_t, size_t); -void *Realloc(void *, size_t); + +void * Malloc(size_t); +void Free(void *); +void * Calloc(size_t, size_t); +void * Realloc(void *, size_t); + +/** + * Alloc/Realloc memory buffer. + * + * Allocate/reallocate an array. + * + * @param elsize Element size. + * @param nelem Number of elements in the array. + * @param ptr Pointer to the actual array. + * + * @return ptr allocated with the new array size. + * + */ +void * lib3270_calloc(size_t elsize, size_t nelem, void *ptr); #define NewString(x) strdup(x) //extern char *NewString(const char *); diff --git a/screen.c b/screen.c index 02e7793..511d766 100644 --- a/screen.c +++ b/screen.c @@ -88,14 +88,14 @@ static void addch(H3270 *session, int baddr, unsigned char c, unsigned short att { // If set to keep selection adjust corresponding flag based on the current state if(lib3270_get_toggle(session,LIB3270_TOGGLE_KEEP_SELECTED)) - attr |= (session->ea_buf[baddr].attr & LIB3270_ATTR_SELECTED); + attr |= (session->text[baddr].attr & LIB3270_ATTR_SELECTED); - if(session->ea_buf[baddr].chr == c && session->ea_buf[baddr].attr == attr) + if(session->text[baddr].chr == c && session->text[baddr].attr == attr) return; /* Converted char has changed, update it */ - session->ea_buf[baddr].chr = c; - session->ea_buf[baddr].attr = attr; + session->text[baddr].chr = c; + session->text[baddr].attr = attr; if(session->update) session->update(session,baddr,c,attr,baddr == session->cursor_addr); @@ -262,8 +262,8 @@ LIB3270_EXPORT int lib3270_get_contents(H3270 *h, int first, int last, unsigned for(baddr = first; baddr <= last;baddr++) { - *(chr++) = h3270.ea_buf[baddr].chr ? h3270.ea_buf[baddr].chr : ' '; - *(attr++) = h3270.ea_buf[baddr].attr; + *(chr++) = h->text[baddr].chr ? h->text[baddr].chr : ' '; + *(attr++) = h->text[baddr].attr; } return 0; @@ -410,7 +410,7 @@ LIB3270_EXPORT int lib3270_set_cursor_address(H3270 *h, int baddr) h->cursor_addr = baddr; if(h->update_cursor) - h->update_cursor(h,(unsigned short) (baddr/h->cols),(unsigned short) (baddr%h->cols),h->ea_buf[baddr].chr,h->ea_buf[baddr].attr); + h->update_cursor(h,(unsigned short) (baddr/h->cols),(unsigned short) (baddr%h->cols),h->text[baddr].chr,h->text[baddr].attr); return ret; } diff --git a/selection.c b/selection.c index 27c4ae1..4a3f98f 100644 --- a/selection.c +++ b/selection.c @@ -75,10 +75,10 @@ static void update_selected_rectangle(H3270 *session) { for(col = 0; col < session->cols;col++) { - if(!(row >= p[0].row && row <= p[1].row && col >= p[0].col && col <= p[1].col) && (session->ea_buf[baddr].attr & LIB3270_ATTR_SELECTED)) + if(!(row >= p[0].row && row <= p[1].row && col >= p[0].col && col <= p[1].col) && (session->text[baddr].attr & LIB3270_ATTR_SELECTED)) { - session->ea_buf[baddr].attr &= ~LIB3270_ATTR_SELECTED; - session->update(session,baddr,session->ea_buf[baddr].chr,session->ea_buf[baddr].attr,baddr == session->cursor_addr); + session->text[baddr].attr &= ~LIB3270_ATTR_SELECTED; + session->update(session,baddr,session->text[baddr].chr,session->text[baddr].attr,baddr == session->cursor_addr); } baddr++; } @@ -90,10 +90,10 @@ static void update_selected_rectangle(H3270 *session) { for(col = 0; col < session->cols;col++) { - if((row >= p[0].row && row <= p[1].row && col >= p[0].col && col <= p[1].col) && !(session->ea_buf[baddr].attr & LIB3270_ATTR_SELECTED)) + if((row >= p[0].row && row <= p[1].row && col >= p[0].col && col <= p[1].col) && !(session->text[baddr].attr & LIB3270_ATTR_SELECTED)) { - session->ea_buf[baddr].attr |= LIB3270_ATTR_SELECTED; - session->update(session,baddr,session->ea_buf[baddr].chr,session->ea_buf[baddr].attr,baddr == session->cursor_addr); + session->text[baddr].attr |= LIB3270_ATTR_SELECTED; + session->update(session,baddr,session->text[baddr].chr,session->text[baddr].attr,baddr == session->cursor_addr); } baddr++; } @@ -111,29 +111,29 @@ static void update_selected_region(H3270 *session) // First remove unselected areas for(baddr = 0; baddr < begin; baddr++) { - if(session->ea_buf[baddr].attr & LIB3270_ATTR_SELECTED) + if(session->text[baddr].attr & LIB3270_ATTR_SELECTED) { - session->ea_buf[baddr].attr &= ~LIB3270_ATTR_SELECTED; - session->update(session,baddr,session->ea_buf[baddr].chr,session->ea_buf[baddr].attr,baddr == session->cursor_addr); + session->text[baddr].attr &= ~LIB3270_ATTR_SELECTED; + session->update(session,baddr,session->text[baddr].chr,session->text[baddr].attr,baddr == session->cursor_addr); } } for(baddr = end+1; baddr < len; baddr++) { - if(session->ea_buf[baddr].attr & LIB3270_ATTR_SELECTED) + if(session->text[baddr].attr & LIB3270_ATTR_SELECTED) { - session->ea_buf[baddr].attr &= ~LIB3270_ATTR_SELECTED; - session->update(session,baddr,session->ea_buf[baddr].chr,session->ea_buf[baddr].attr,baddr == session->cursor_addr); + session->text[baddr].attr &= ~LIB3270_ATTR_SELECTED; + session->update(session,baddr,session->text[baddr].chr,session->text[baddr].attr,baddr == session->cursor_addr); } } // Then draw the selected ones for(baddr = begin; baddr <= end; baddr++) { - if(!(session->ea_buf[baddr].attr & LIB3270_ATTR_SELECTED)) + if(!(session->text[baddr].attr & LIB3270_ATTR_SELECTED)) { - session->ea_buf[baddr].attr |= LIB3270_ATTR_SELECTED; - session->update(session,baddr,session->ea_buf[baddr].chr,session->ea_buf[baddr].attr,baddr == session->cursor_addr); + session->text[baddr].attr |= LIB3270_ATTR_SELECTED; + session->update(session,baddr,session->text[baddr].chr,session->text[baddr].attr,baddr == session->cursor_addr); } } @@ -180,11 +180,11 @@ LIB3270_ACTION(unselect) for(a = 0; a < hSession->rows*hSession->cols; a++) { - if(hSession->ea_buf[a].attr & LIB3270_ATTR_SELECTED) + if(hSession->text[a].attr & LIB3270_ATTR_SELECTED) { - hSession->ea_buf[a].attr &= ~LIB3270_ATTR_SELECTED; + hSession->text[a].attr &= ~LIB3270_ATTR_SELECTED; if(hSession->update) - hSession->update(hSession,a,hSession->ea_buf[a].chr,hSession->ea_buf[a].attr,a == hSession->cursor_addr); + hSession->update(hSession,a,hSession->text[a].chr,hSession->text[a].attr,a == hSession->cursor_addr); } } @@ -218,17 +218,17 @@ LIB3270_EXPORT void lib3270_select_word(H3270 *session, int baddr) CHECK_SESSION_HANDLE(session); - if(!lib3270_connected(session) || isspace(session->ea_buf[baddr].chr)) + if(!lib3270_connected(session) || isspace(session->text[baddr].chr)) { lib3270_ring_bell(session); return; } - for(pos = baddr; pos > 0 && !isspace(session->ea_buf[pos].chr);pos--); + for(pos = baddr; pos > 0 && !isspace(session->text[pos].chr);pos--); session->select.begin = pos > 0 ? pos+1 : 0; len = session->rows * session->cols; - for(pos = baddr; pos < len && !isspace(session->ea_buf[pos].chr);pos++); + for(pos = baddr; pos < len && !isspace(session->text[pos].chr);pos++); session->select.end = pos < len ? pos-1 : len; set_selected(session); @@ -286,10 +286,10 @@ LIB3270_ACTION( selectall ) // First remove unselected areas for(baddr = 0; baddr < len; baddr++) { - if(!(hSession->ea_buf[baddr].attr & LIB3270_ATTR_SELECTED)) + if(!(hSession->text[baddr].attr & LIB3270_ATTR_SELECTED)) { - hSession->ea_buf[baddr].attr |= LIB3270_ATTR_SELECTED; - hSession->update(hSession,baddr,hSession->ea_buf[baddr].chr,hSession->ea_buf[baddr].attr,baddr == hSession->cursor_addr); + hSession->text[baddr].attr |= LIB3270_ATTR_SELECTED; + hSession->update(hSession,baddr,hSession->text[baddr].chr,hSession->text[baddr].attr,baddr == hSession->cursor_addr); } } @@ -329,10 +329,10 @@ LIB3270_EXPORT char * lib3270_get_selected(H3270 *hSession) for(col = 0; col < hSession->cols;col++) { - if(hSession->ea_buf[baddr].attr & LIB3270_ATTR_SELECTED) + if(hSession->text[baddr].attr & LIB3270_ATTR_SELECTED) { cr++; - ret[sz++] = hSession->ea_buf[baddr].chr; + ret[sz++] = hSession->text[baddr].chr; } baddr++; } -- libgit2 0.21.2