From ae2663cf907c2f6dad82b2d352cee914f1d5ff0d Mon Sep 17 00:00:00 2001 From: perry.werneck@gmail.com Date: Tue, 24 Jan 2012 13:56:20 +0000 Subject: [PATCH] Iniciando ajustes no processo de tela para que a biblioteca passe a enviar para o cliente apenas os campos que foram modificados --- latest/src/include/lib3270.h | 37 +++++++++++++++++++++++++++++++++++++ latest/src/include/lib3270/api.h | 13 ++++++------- latest/src/lib/screen.c | 58 ++++++++++++++++++++++++++-------------------------------- 3 files changed, 69 insertions(+), 39 deletions(-) diff --git a/latest/src/include/lib3270.h b/latest/src/include/lib3270.h index 0318b8a..1f3e4d9 100644 --- a/latest/src/include/lib3270.h +++ b/latest/src/include/lib3270.h @@ -32,6 +32,43 @@ #ifndef LIB3270_H_INCLUDED + /** + * Character attributes + */ + typedef enum _lib3270_attr + { + LIB3270_ATTR_COLOR_BACKGROUND = 0x0000, + + LIB3270_ATTR_COLOR_BLUE = 0x0001, + LIB3270_ATTR_COLOR_RED = 0x0002, + LIB3270_ATTR_COLOR_PINK = 0x0003, + LIB3270_ATTR_COLOR_GREEN = 0x0004, + LIB3270_ATTR_COLOR_TURQUOISE = 0x0005, + LIB3270_ATTR_COLOR_YELLOW = 0x0006, + LIB3270_ATTR_COLOR_WHITE = 0x0007, + LIB3270_ATTR_COLOR_BLACK = 0x0008, + LIB3270_ATTR_COLOR_DARK_BLUE = 0x0009, + LIB3270_ATTR_COLOR_ORANGE = 0x000A, + LIB3270_ATTR_COLOR_PURPLE = 0x000B, + LIB3270_ATTR_COLOR_DARK_GREEN = 0x000C, + LIB3270_ATTR_COLOR_DARK_TURQUOISE = 0x000D, + LIB3270_ATTR_COLOR_MUSTARD = 0x000E, + LIB3270_ATTR_COLOR_GRAY = 0x000F, + + LIB3270_ATTR_COLOR = 0x00FF, + + LIB3270_ATTR_FIELD = 0x0100, + LIB3270_ATTR_BLINK = 0x0200, + LIB3270_ATTR_UNDERLINE = 0x0400, + LIB3270_ATTR_INTENSIFY = 0x0800, + + LIB3270_ATTR_CG = 0x1000, + LIB3270_ATTR_MARKER = 0x2000, + LIB3270_ATTR_BACKGROUND_INTENSITY = 0x4000, + + } LIB3270_ATTR; + + #include /** diff --git a/latest/src/include/lib3270/api.h b/latest/src/include/lib3270/api.h index ef488dc..df6539a 100644 --- a/latest/src/include/lib3270/api.h +++ b/latest/src/include/lib3270/api.h @@ -441,15 +441,14 @@ #define query_screen_change_counter() query_counter(COUNTER_ID_CTLR_DONE) - #define COLOR_ATTR_NONE 0x0000 - #define COLOR_ATTR_FIELD 0x0100 - #define COLOR_ATTR_BLINK 0x0200 - #define COLOR_ATTR_UNDERLINE 0x0400 - #define COLOR_ATTR_INTENSIFY 0x0800 + #define COLOR_ATTR_FIELD LIB3270_ATTR_FIELD + #define COLOR_ATTR_BLINK LIB3270_ATTR_BLINK + #define COLOR_ATTR_UNDERLINE LIB3270_ATTR_UNDERLINE + #define COLOR_ATTR_INTENSIFY LIB3270_ATTR_INTENSIFY - #define CHAR_ATTR_CG 0x1000 - #define CHAR_ATTR_MARKER 0x2000 + #define CHAR_ATTR_CG LIB3270_ATTR_CG + #define CHAR_ATTR_MARKER LIB3270_ATTR_MARKER #define CHAR_ATTR_UNCONVERTED CHAR_ATTR_CG diff --git a/latest/src/lib/screen.c b/latest/src/lib/screen.c index c0a49ca..cf90f98 100644 --- a/latest/src/lib/screen.c +++ b/latest/src/lib/screen.c @@ -90,7 +90,7 @@ static void screen_update(H3270 *session, int bstart, int bend); static void status_connect(H3270 *session, int ignored, void *dunno); static void status_3270_mode(H3270 *session, int ignored, void *dunno); static void status_printer(H3270 *session, int on, void *dunno); -static int color_from_fa(unsigned char fa); +static unsigned short color_from_fa(unsigned char fa); static void relabel(H3270 *session, int ignored, void *dunno); void set_display_charset(char *dcs) @@ -165,8 +165,7 @@ int screen_init(H3270 *session) } /* Map a field attribute to its default colors. */ -static int -color_from_fa(unsigned char fa) +static unsigned short color_from_fa(unsigned char fa) { if (appres.m3279) return get_color_pair(DEFCOLOR_MAP(fa),0) | COLOR_ATTR_FIELD; @@ -175,20 +174,22 @@ color_from_fa(unsigned char fa) return get_color_pair(0,0) | COLOR_ATTR_FIELD | ((FA_IS_HIGH(fa)) ? COLOR_ATTR_INTENSIFY : 0); } +/* static int reverse_colors(int a) { int bg = (a & 0xF0) >> 4; int fg = (a & 0x0F); return get_color_pair(bg,fg) | (a&0xFF00); } +*/ /* * Find the display attributes for a baddr, fa_addr and fa. */ -static int -calc_attrs(int baddr, int fa_addr, int fa) +static unsigned short calc_attrs(int baddr, int fa_addr, int fa) { - int fg = 0, bg = 0, gr, a; + unsigned short fg=0, bg=0, a; + int gr; /* Compute the color. */ @@ -197,11 +198,12 @@ calc_attrs(int baddr, int fa_addr, int fa) (!ea_buf[baddr].fg && !ea_buf[fa_addr].fg && !ea_buf[baddr].bg && - !ea_buf[fa_addr].bg)) { - - a = color_from_fa(fa); - - } else { + !ea_buf[fa_addr].bg)) + { + a = color_from_fa(fa); + } + else + { /* The current location or the fa specifies the fg or bg. */ if (ea_buf[baddr].fg) @@ -239,29 +241,20 @@ calc_attrs(int baddr, int fa_addr, int fa) if(!(gr & GR_REVERSE) && !bg) { if(gr & GR_BLINK) - a |= COLOR_ATTR_BLINK; + a |= LIB3270_ATTR_BLINK; if(gr & GR_UNDERLINE) - a |= COLOR_ATTR_UNDERLINE; + a |= LIB3270_ATTR_UNDERLINE; } - -/* - if (appres.highlight_underline && - appres.m3279 && - (gr & (GR_BLINK | GR_UNDERLINE)) && - !(gr & GR_REVERSE) && - !bg) { - - a |= BACKGROUND_INTENSITY; - } -*/ + if(appres.m3279 && (gr & (GR_BLINK | GR_UNDERLINE)) && !(gr & GR_REVERSE) && !bg) + a |= LIB3270_ATTR_BACKGROUND_INTENSITY; if(!appres.m3279 && ((gr & GR_INTENSIFY) || FA_IS_HIGH(fa))) - a |= COLOR_ATTR_INTENSIFY; + a |= LIB3270_ATTR_INTENSIFY; if (gr & GR_REVERSE) - a = reverse_colors(a); + a = get_color_pair(((a & 0xF0) >> 4),(a & 0x0F)) | (a&0xFF00); // a = reverse_colors(a); return a; } @@ -341,13 +334,13 @@ static void screen_update(H3270 *session, int bstart, int bend) { int baddr, row, col; - int a; + unsigned short a; int attr = COLOR_GREEN; unsigned char fa; int fa_addr; - fa = get_field_attribute(bstart); - a = color_from_fa(fa); + fa = get_field_attribute(bstart); + a = color_from_fa(fa); fa_addr = find_field_attribute(bstart); // may be -1, that's okay row = bstart/session->cols; @@ -379,13 +372,14 @@ static void screen_update(H3270 *session, int bstart, int bend) } else { - int b; - +// unsigned short b; // // Override some of the field // attributes. // - attr = b = calc_attrs(baddr, fa_addr, fa); +// attr = b = calc_attrs(baddr, fa_addr, fa); + + attr = calc_attrs(baddr, fa_addr, fa); } if (ea_buf[baddr].cs == CS_LINEDRAW) -- libgit2 0.21.2