From b48cbcf080279591000b7c0a864acb22c28127a7 Mon Sep 17 00:00:00 2001 From: perry.werneck@gmail.com Date: Tue, 24 Jan 2012 17:16:56 +0000 Subject: [PATCH] Implementação de multi-sessões: Movendo mais campos de controle do terminal para a estrutura de sessão --- latest/src/gtk2/main.c | 2 +- latest/src/include/lib3270/api.h | 15 +++++++++------ latest/src/lib/ansi.c | 20 ++++++++++---------- latest/src/lib/ctlr.c | 152 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------------------------------------------- latest/src/lib/ctlr.h | 4 ++-- latest/src/lib/ctlrc.h | 5 +++-- latest/src/lib/globals.h | 8 ++++---- latest/src/lib/kybd.c | 60 ++++++++++++++++++++++++++++++------------------------------ latest/src/lib/paste.c | 6 +++--- latest/src/lib/print.c | 2 +- latest/src/lib/screen.c | 49 ++++++++++++++++++++++++------------------------- latest/src/lib/sf.c | 18 +++++++++--------- latest/src/lib/trace_ds.c | 2 +- 13 files changed, 178 insertions(+), 165 deletions(-) diff --git a/latest/src/gtk2/main.c b/latest/src/gtk2/main.c index cb4bc63..e6daed9 100644 --- a/latest/src/gtk2/main.c +++ b/latest/src/gtk2/main.c @@ -90,7 +90,7 @@ static void connect_main(H3270 *session, int status, void *dunno) { SetStatusCode(STATUS_CODE_DISCONNECTED); cMode &= ~CURSOR_MODE_ENABLED; - ctlr_erase(1); +// ctlr_erase(1); online = FALSE; #ifdef X3270_FT action_group_set_sensitive(ACTION_GROUP_FT,status); diff --git a/latest/src/include/lib3270/api.h b/latest/src/include/lib3270/api.h index df6539a..c94b944 100644 --- a/latest/src/include/lib3270/api.h +++ b/latest/src/include/lib3270/api.h @@ -230,6 +230,10 @@ int cols; int cursor_addr; char flipped; + int screen_alt; /**< alternate screen? */ + int is_altbuffer; + + int formatted; /**< set in screen_disp */ // Widget info void * widget; @@ -522,9 +526,9 @@ LIB3270_EXPORT void show_3270_popup_dialog(H3270 *session, PW3270_DIALOG type, const char *title, const char *msg, const char *fmt, ...); /* Set/Get screen contents */ - LIB3270_EXPORT int find_field_attribute(int baddr); - LIB3270_EXPORT int find_field_length(int baddr); - LIB3270_EXPORT unsigned char get_field_attribute(int baddr); + LIB3270_EXPORT int find_field_attribute(H3270 *session, int baddr); + LIB3270_EXPORT int find_field_length(H3270 *session, int baddr); + LIB3270_EXPORT unsigned char get_field_attribute(H3270 *session, int baddr); LIB3270_EXPORT int screen_read(char *dest, int baddr, int count); LIB3270_EXPORT void Input_String(const unsigned char *str); LIB3270_EXPORT void screen_size(int *rows, int *cols); @@ -561,9 +565,8 @@ LIB3270_EXPORT void RunPendingEvents(int wait); LIB3270_EXPORT int Wait(int seconds); - LIB3270_EXPORT void ctlr_erase(int alt); - LIB3270_EXPORT int ctlr_get_cols(void); - LIB3270_EXPORT int ctlr_get_rows(void); + LIB3270_EXPORT int ctlr_get_cols(void) __attribute__ ((deprecated)); + LIB3270_EXPORT int ctlr_get_rows(void) __attribute__ ((deprecated)); /* Screen calls */ LIB3270_EXPORT void screen_resume(void); diff --git a/latest/src/lib/ansi.c b/latest/src/lib/ansi.c index e85e2f2..492a8bd 100644 --- a/latest/src/lib/ansi.c +++ b/latest/src/lib/ansi.c @@ -605,10 +605,10 @@ ansi_reset(int ig1 unused, int ig2 unused) tabs[i] = 0x01; held_wrap = False; if (!first) { - ctlr_altbuffer(True); + ctlr_altbuffer(&h3270,True); ctlr_aclear(0, h3270.rows * h3270.cols, 1); - ctlr_altbuffer(False); - ctlr_clear(False); + ctlr_altbuffer(&h3270,False); + ctlr_clear(&h3270,False); screen_80(); } first = False; @@ -714,7 +714,7 @@ ansi_erase_in_display(int nn, int ig2 unused) ctlr_aclear(0, h3270.cursor_addr + 1, 1); break; case 2: /* all (without moving cursor) */ - if (cursor_addr == 0 && !is_altbuffer) + if (cursor_addr == 0 && !h3270.is_altbuffer) scroll_save(h3270.rows, True); ctlr_aclear(0, h3270.rows * h3270.cols, 1); break; @@ -924,7 +924,7 @@ ansi_bell(int ig1 unused, int ig2 unused) static enum state ansi_newpage(int ig1 unused, int ig2 unused) { - ctlr_clear(False); + ctlr_clear(&h3270,False); return DATA; } @@ -1443,7 +1443,7 @@ dec_set(int ig1 unused, int ig2 unused) rev_wraparound_mode = 1; break; case 47: /* alt buffer */ - ctlr_altbuffer(True); + ctlr_altbuffer(&h3270,True); break; } return DATA; @@ -1475,7 +1475,7 @@ dec_reset(int ig1 unused, int ig2 unused) rev_wraparound_mode = 0; break; case 47: /* alt buffer */ - ctlr_altbuffer(False); + ctlr_altbuffer(&h3270,False); break; } return DATA; @@ -1504,7 +1504,7 @@ dec_save(int ig1 unused, int ig2 unused) saved_rev_wraparound_mode = rev_wraparound_mode; break; case 47: /* alt buffer */ - saved_altbuffer = is_altbuffer; + saved_altbuffer = h3270.is_altbuffer; break; } return DATA; @@ -1539,7 +1539,7 @@ dec_restore(int ig1 unused, int ig2 unused) rev_wraparound_mode = saved_rev_wraparound_mode; break; case 47: /* alt buffer */ - ctlr_altbuffer(saved_altbuffer); + ctlr_altbuffer(&h3270,saved_altbuffer); break; } return DATA; @@ -1664,7 +1664,7 @@ ansi_scroll(void) /* Save the top line */ if (scroll_top == 1 && scroll_bottom == h3270.rows) { - if (!is_altbuffer) + if (!h3270.is_altbuffer) scroll_save(1, False); ctlr_scroll(); return; diff --git a/latest/src/lib/ctlr.c b/latest/src/lib/ctlr.c index b3f89b4..54c5c5b 100644 --- a/latest/src/lib/ctlr.c +++ b/latest/src/lib/ctlr.c @@ -77,13 +77,13 @@ extern unsigned char aid; // int cursor_addr; int buffer_addr; -Boolean screen_alt = False; /* alternate screen? */ -Boolean is_altbuffer = False; +// Boolean screen_alt = False; /* alternate screen? */ +// Boolean is_altbuffer = False; struct ea *ea_buf = NULL; /* 3270 device buffer */ /* ea_buf[-1] is the dummy default field attribute */ -Boolean formatted = False; /* set in screen_disp */ +// Boolean formatted = False; /* set in screen_disp */ unsigned char reply_mode = SF_SRM_FIELD; int crm_nattr = 0; unsigned char crm_attr[16]; @@ -92,7 +92,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 void set_formatted(void); +static void set_formatted(H3270 *session); static void ctlr_blanks(void); static Boolean trace_primed = False; static unsigned char default_fg; @@ -251,7 +251,7 @@ void ctlr_set_rows_cols(H3270 *session, int mn, int ovc, int ovr) // Make sure that the current rows/cols are still 24x80. session->cols = 80; session->rows = 24; - screen_alt = False; + session->screen_alt = False; } @@ -260,16 +260,19 @@ void ctlr_set_rows_cols(H3270 *session, int mn, int ovc, int ovr) * Set the formatted screen flag. A formatted screen is a screen that * has at least one field somewhere on it. */ -static void -set_formatted(void) +static void set_formatted(H3270 *session) { - register int baddr; + register int baddr; - formatted = False; + CHECK_SESSION_HANDLE(session); + + session->formatted = False; baddr = 0; - do { - if (ea_buf[baddr].fa) { - formatted = True; + do + { + if (ea_buf[baddr].fa) + { + session->formatted = True; break; } INC_BA(baddr); @@ -288,8 +291,7 @@ static void ctlr_half_connect(H3270 *session, int ignored unused, void *dunno) /* * Called when a host connects, disconnects, or changes ANSI/3270 modes. */ -static void -ctlr_connect(H3270 *session, int ignored unused, void *dunno) +static void ctlr_connect(H3270 *session, int ignored unused, void *dunno) { ticking_stop(session); status_untiming(session); @@ -318,12 +320,13 @@ ctlr_connect(H3270 *session, int ignored unused, void *dunno) * Find the buffer address of the field attribute for a given buffer address. * Returns -1 if the screen isn't formatted. */ -int -find_field_attribute(int baddr) +int find_field_attribute(H3270 *h, int baddr) { int sbaddr; - if (!formatted) + CHECK_SESSION_HANDLE(h); + + if (!h->formatted) return -1; sbaddr = baddr; @@ -338,12 +341,16 @@ find_field_attribute(int baddr) /* * Get Field width */ -int find_field_length(int baddr) +int find_field_length(H3270 *h, int baddr) { int saddr; - int addr = find_field_attribute(baddr); + int addr; int width = 0; + CHECK_SESSION_HANDLE(h); + + addr = find_field_attribute(h,baddr); + if(addr < 0) return -1; @@ -364,10 +371,10 @@ int find_field_length(int baddr) * Find the field attribute for the given buffer address. Return its address * rather than its value. */ -unsigned char -get_field_attribute(int baddr) +unsigned char get_field_attribute(H3270 *h, int baddr) { - return ea_buf[find_field_attribute(baddr)].fa; + CHECK_SESSION_HANDLE(h); + return ea_buf[find_field_attribute(h,baddr)].fa; } /* @@ -382,7 +389,7 @@ get_bounded_field_attribute(register int baddr, register int bound, { int sbaddr; - if (!formatted) { + if (!h3270.formatted) { *fa_out = ea_buf[-1].fa; return True; } @@ -442,36 +449,39 @@ next_unprotected(int baddr0) * Perform an erase command, which may include changing the (virtual) screen * size. */ -void -ctlr_erase(int alt) +void ctlr_erase(H3270 *session, int alt) { - kybd_inhibit(False); + CHECK_SESSION_HANDLE(session); - ctlr_clear(True); - screen_erase(&h3270); + kybd_inhibit(False); - /* Let a script go. */ -// sms_host_output(); + ctlr_clear(session,True); + screen_erase(session); - if (alt == screen_alt) + if(alt == session->screen_alt) return; - if (alt) { + if (alt) + { /* Going from 24x80 to maximum. */ - screen_disp(&h3270); - set_viewsize(&h3270,h3270.maxROWS,h3270.maxCOLS); - } else { + screen_disp(session); + set_viewsize(session,session->maxROWS,session->maxCOLS); + } + else + { /* Going from maximum to 24x80. */ - if (h3270.maxROWS > 24 || h3270.maxCOLS > 80) { - if (visible_control) { + if (session->maxROWS > 24 || session->maxCOLS > 80) + { + if (visible_control) + { ctlr_blanks(); - screen_disp(&h3270); + screen_disp(session); } - set_viewsize(&h3270,24,80); + set_viewsize(session,24,80); } } - screen_alt = alt; + session->screen_alt = alt; } @@ -500,7 +510,7 @@ process_ds(unsigned char *buf, int buflen) case CMD_EWA: /* erase/write alternate */ case SNA_CMD_EWA: trace_ds("EraseWriteAlternate"); - ctlr_erase(True); + ctlr_erase(NULL,True); if ((rv = ctlr_write(buf, buflen, True)) < 0) return rv; return PDS_OKAY_NO_OUTPUT; @@ -508,7 +518,7 @@ process_ds(unsigned char *buf, int buflen) case CMD_EW: /* erase/write */ case SNA_CMD_EW: trace_ds("EraseWrite"); - ctlr_erase(False); + ctlr_erase(NULL,False); if ((rv = ctlr_write(buf, buflen, True)) < 0) return rv; return PDS_OKAY_NO_OUTPUT; @@ -685,7 +695,7 @@ ctlr_read_modified(unsigned char aid_byte, Boolean all) } baddr = 0; - if (formatted) { + if (h3270.formatted) { /* find first field attribute */ do { if (ea_buf[baddr].fa) @@ -934,7 +944,7 @@ ctlr_snap_buffer(void) unsigned char av; space3270out(2); - *obptr++ = screen_alt ? CMD_EWA : CMD_EW; + *obptr++ = h3270.screen_alt ? CMD_EWA : CMD_EW; *obptr++ = code_table[0]; do { @@ -1061,7 +1071,7 @@ ctlr_erase_all_unprotected(void) kybd_inhibit(False); - if (formatted) { + if (h3270.formatted) { /* find first field attribute */ baddr = 0; do { @@ -1095,7 +1105,7 @@ ctlr_erase_all_unprotected(void) if (!f) cursor_move(0); } else { - ctlr_clear(True); + ctlr_clear(&h3270,True); } aid = AID_NO; do_reset(False); @@ -1151,7 +1161,7 @@ ctlr_write(unsigned char buf[], int buflen, Boolean erase) ctlr_add_gr(buffer_addr, 0); \ ctlr_add_ic(buffer_addr, 0); \ trace_ds("%s",see_attr(fa)); \ - formatted = True; \ + h3270.formatted = True; \ } kybd_inhibit(False); @@ -1203,7 +1213,7 @@ ctlr_write(unsigned char buf[], int buflen, Boolean erase) last_cmd = True; last_zpt = False; - current_fa = get_field_attribute(buffer_addr); + current_fa = get_field_attribute(&h3270,buffer_addr); #define ABORT_WRITEx { \ rv = PDS_BAD_ADDR; \ @@ -1239,7 +1249,7 @@ ctlr_write(unsigned char buf[], int buflen, Boolean erase) if (buffer_addr >= h3270.cols * h3270.rows) { ABORT_WRITE("invalid SBA address"); } - current_fa = get_field_attribute(buffer_addr); + current_fa = get_field_attribute(&h3270,buffer_addr); last_cmd = True; last_zpt = False; break; @@ -1399,7 +1409,7 @@ ctlr_write(unsigned char buf[], int buflen, Boolean erase) INC_BA(buffer_addr); } } while (buffer_addr != baddr); - current_fa = get_field_attribute(buffer_addr); + current_fa = get_field_attribute(&h3270,buffer_addr); last_cmd = True; last_zpt = False; break; @@ -1430,7 +1440,7 @@ ctlr_write(unsigned char buf[], int buflen, Boolean erase) } INC_BA(buffer_addr); } while (buffer_addr != baddr); - current_fa = get_field_attribute(buffer_addr); + current_fa = get_field_attribute(&h3270,buffer_addr); last_cmd = True; last_zpt = False; break; @@ -1450,7 +1460,7 @@ ctlr_write(unsigned char buf[], int buflen, Boolean erase) ctlr_add_gr(buffer_addr, default_gr); ctlr_add_ic(buffer_addr, default_ic); INC_BA(buffer_addr); - current_fa = get_field_attribute(buffer_addr); + current_fa = get_field_attribute(&h3270,buffer_addr); last_cmd = False; last_zpt = False; break; @@ -1697,7 +1707,7 @@ ctlr_write(unsigned char buf[], int buflen, Boolean erase) if (d != DBCS_NONE && why == DBCS_FIELD) { ABORT_WRITE("SI in DBCS field"); } - fa_addr = find_field_attribute(buffer_addr); + fa_addr = find_field_attribute(&h3270,buffer_addr); baddr = buffer_addr; DEC_BA(baddr); while (!aborted && @@ -1849,7 +1859,7 @@ ctlr_write(unsigned char buf[], int buflen, Boolean erase) break; } } - set_formatted(); + set_formatted(&h3270); END_TEXT0; trace_ds("\n"); if (wcc_keyboard_restore) { @@ -2278,8 +2288,8 @@ ps_process(void) #if defined(X3270_FT) /*[*/ /* Process file transfers. */ if (ft_state != FT_NONE && /* transfer in progress */ - formatted && /* screen is formatted */ - !screen_alt && /* 24x80 screen */ + h3270.formatted && /* screen is formatted */ + !h3270.screen_alt && /* 24x80 screen */ !kybdlock && /* keyboard not locked */ /* magic field */ ea_buf[1919].fa && FA_IS_SKIP(ea_buf[1919].fa)) { @@ -2308,7 +2318,7 @@ ctlr_any_data(void) * and buffer addresses and extended attributes. */ void -ctlr_clear(Boolean can_snap) +ctlr_clear(H3270 *session, Boolean can_snap) { /* Snap any data that is about to be lost into the trace file. */ if (ctlr_any_data()) { @@ -2316,18 +2326,18 @@ ctlr_clear(Boolean can_snap) if (can_snap && !trace_skipping && toggled(SCREEN_TRACE)) trace_screen(); #endif /*]*/ - scroll_save(maxROWS, ever_3270 ? False : True); + scroll_save(session->maxROWS, ever_3270 ? False : True); } #if defined(X3270_TRACE) /*[*/ trace_skipping = False; #endif /*]*/ /* Clear the screen. */ - (void) memset((char *)ea_buf, 0, h3270.rows*h3270.cols*sizeof(struct ea)); + (void) memset((char *)ea_buf, 0, session->rows*session->cols*sizeof(struct ea)); cursor_move(0); buffer_addr = 0; // unselect(0, ROWS*COLS); - formatted = False; + session->formatted = False; default_fg = 0; default_bg = 0; default_gr = 0; @@ -2335,7 +2345,7 @@ ctlr_clear(Boolean can_snap) sscp_start = 0; // ALL_CHANGED; - screen_erase(&h3270); + screen_erase(session); } @@ -2354,7 +2364,7 @@ ctlr_blanks(void) cursor_move(0); buffer_addr = 0; // unselect(0, ROWS*COLS); - formatted = False; + h3270.formatted = False; ALL_CHANGED; } @@ -2376,7 +2386,7 @@ ctlr_add(int baddr, unsigned char c, unsigned char cs) if (toggled(SCREEN_TRACE)) trace_screen(); #endif /*]*/ - scroll_save(maxROWS, False); + scroll_save(session->maxROWS, False); trace_primed = False; } /* @@ -2622,22 +2632,23 @@ void changed(H3270 *session, int bstart, int bend) } -#if defined(X3270_ANSI) /*[*/ /* * Swap the regular and alternate screen buffers */ -void -ctlr_altbuffer(Boolean alt) +void ctlr_altbuffer(H3270 *session, int alt) { struct ea *etmp; - if (alt != is_altbuffer) { + CHECK_SESSION_HANDLE(session); + + if (alt != session->is_altbuffer) + { etmp = ea_buf; ea_buf = aea_buf; aea_buf = etmp; - is_altbuffer = alt; + session->is_altbuffer = alt; ALL_CHANGED; // unselect(0, ROWS*COLS); @@ -2648,7 +2659,6 @@ ctlr_altbuffer(Boolean alt) blink_start(); } } -#endif /*]*/ /* @@ -2659,7 +2669,7 @@ mdt_set(int baddr) { int faddr; - faddr = find_field_attribute(baddr); + faddr = find_field_attribute(&h3270,baddr); if (faddr >= 0 && !(ea_buf[faddr].fa & FA_MODIFY)) { ea_buf[faddr].fa |= FA_MODIFY; if (appres.modified_sel) @@ -2672,7 +2682,7 @@ mdt_clear(int baddr) { int faddr; - faddr = find_field_attribute(baddr); + faddr = find_field_attribute(&h3270,baddr); if (faddr >= 0 && (ea_buf[faddr].fa & FA_MODIFY)) { ea_buf[faddr].fa &= ~FA_MODIFY; if (appres.modified_sel) diff --git a/latest/src/lib/ctlr.h b/latest/src/lib/ctlr.h index 3010143..13808ab 100644 --- a/latest/src/lib/ctlr.h +++ b/latest/src/lib/ctlr.h @@ -20,5 +20,5 @@ LIB3270_INTERNAL int buffer_addr; /**< buffer address */ LIB3270_INTERNAL int cursor_addr; /**< cursor address */ LIB3270_INTERNAL struct ea *ea_buf; /**< 3270 device buffer */ -LIB3270_INTERNAL Boolean formatted; /**< contains at least one field? */ -LIB3270_INTERNAL Boolean is_altbuffer; /**< in alternate-buffer mode? */ +//LIB3270_INTERNAL Boolean formatted; /**< contains at least one field? */ +//LIB3270_INTERNAL Boolean is_altbuffer; /**< in alternate-buffer mode? */ diff --git a/latest/src/lib/ctlrc.h b/latest/src/lib/ctlrc.h index aefa93d..f8c6e0c 100644 --- a/latest/src/lib/ctlrc.h +++ b/latest/src/lib/ctlrc.h @@ -31,11 +31,11 @@ LIB3270_INTERNAL void ctlr_add_cs(int baddr, unsigned char cs); LIB3270_INTERNAL void ctlr_add_fa(int baddr, unsigned char fa, unsigned char cs); LIB3270_INTERNAL void ctlr_add_fg(int baddr, unsigned char color); LIB3270_INTERNAL void ctlr_add_gr(int baddr, unsigned char gr); -LIB3270_INTERNAL void ctlr_altbuffer(Boolean alt); +LIB3270_INTERNAL void ctlr_altbuffer(H3270 *session, int alt); LIB3270_INTERNAL Boolean ctlr_any_data(void); LIB3270_INTERNAL void ctlr_bcopy(int baddr_from, int baddr_to, int count, int move_ea); // LIB3270_INTERNAL void ctlr_changed(int bstart, int bend); -LIB3270_INTERNAL void ctlr_clear(Boolean can_snap); +LIB3270_INTERNAL void ctlr_clear(H3270 *session, Boolean can_snap); LIB3270_INTERNAL void ctlr_erase_all_unprotected(void); LIB3270_INTERNAL void ctlr_init(unsigned cmask); LIB3270_INTERNAL void ctlr_read_buffer(unsigned char aid_byte); @@ -59,6 +59,7 @@ LIB3270_INTERNAL void ps_process(void); LIB3270_INTERNAL void update_model_info(H3270 *session, int model, int cols, int rows); LIB3270_INTERNAL void ctlr_set_rows_cols(H3270 *session, int mn, int ovc, int ovr); +LIB3270_INTERNAL void ctlr_erase(H3270 *session, int alt); LIB3270_INTERNAL void ticking_start(H3270 *session, Boolean anyway); LIB3270_INTERNAL void toggle_nop(struct toggle *t, enum toggle_type tt); diff --git a/latest/src/lib/globals.h b/latest/src/lib/globals.h index 1124e18..64a5e34 100644 --- a/latest/src/lib/globals.h +++ b/latest/src/lib/globals.h @@ -203,10 +203,10 @@ LIB3270_INTERNAL char *hostname; LIB3270_INTERNAL Boolean local_process; #endif /*]*/ -LIB3270_INTERNAL int maxCOLS; -LIB3270_INTERNAL int maxROWS; -LIB3270_INTERNAL char *model_name; -LIB3270_INTERNAL int model_num; +// LIB3270_INTERNAL int maxCOLS; +// LIB3270_INTERNAL int maxROWS; +// LIB3270_INTERNAL char *model_name; +// LIB3270_INTERNAL int model_num; LIB3270_INTERNAL Boolean no_login_host; LIB3270_INTERNAL Boolean non_tn3270e_host; LIB3270_INTERNAL int ov_cols, ov_rows; diff --git a/latest/src/lib/kybd.c b/latest/src/lib/kybd.c index 3c149d9..d8f278a 100644 --- a/latest/src/lib/kybd.c +++ b/latest/src/lib/kybd.c @@ -766,8 +766,8 @@ key_Character(int code, Boolean with_ge, Boolean pasting, Boolean *skipped) return False; } baddr = h3270.cursor_addr; - faddr = find_field_attribute(baddr); - fa = get_field_attribute(baddr); + faddr = find_field_attribute(&h3270,baddr); + fa = get_field_attribute(&h3270,baddr); if (ea_buf[baddr].fa || FA_IS_PROTECTED(fa)) { operator_error(KL_OERR_PROTECTED); return False; @@ -919,7 +919,7 @@ key_Character(int code, Boolean with_ge, Boolean pasting, Boolean *skipped) INC_BA(baddr); /* Replace leading nulls with blanks, if desired. */ - if (formatted && toggled(BLANK_FILL)) { + if (h3270.formatted && toggled(BLANK_FILL)) { register int baddr_fill = baddr; DEC_BA(baddr_fill); @@ -1602,7 +1602,7 @@ LIB3270_ACTION( firstfield ) return 0; } #endif /*]*/ - if (!formatted) { + if (!h3270.formatted) { cursor_move(0); return 0; } @@ -1692,7 +1692,7 @@ do_delete(void) baddr = h3270.cursor_addr; /* Can't delete a field attribute. */ - fa = get_field_attribute(baddr); + fa = get_field_attribute(&h3270,baddr); if (FA_IS_PROTECTED(fa) || ea_buf[baddr].fa) { operator_error(KL_OERR_PROTECTED); return False; @@ -1718,7 +1718,7 @@ do_delete(void) ndel = 1; /* find next fa */ - if (formatted) { + if (h3270.formatted) { end_baddr = baddr; do { INC_BA(end_baddr); @@ -1826,7 +1826,7 @@ do_erase(void) enum dbcs_state d; baddr = h3270.cursor_addr; - faddr = find_field_attribute(baddr); + faddr = find_field_attribute(&h3270,baddr); if (faddr == baddr || FA_IS_PROTECTED(ea_buf[baddr].fa)) { operator_error(KL_OERR_PROTECTED); return; @@ -1994,11 +1994,11 @@ LIB3270_ACTION( previousword ) if (IN_ANSI) return 0; #endif /*]*/ - if (!formatted) + if (!h3270.formatted) return 0; baddr = h3270.cursor_addr; - prot = FA_IS_PROTECTED(get_field_attribute(baddr)); + prot = FA_IS_PROTECTED(get_field_attribute(&h3270,baddr)); /* Skip to before this word, if in one now. */ if (!prot) { @@ -2017,7 +2017,7 @@ LIB3270_ACTION( previousword ) c = ea_buf[baddr].cc; if (ea_buf[baddr].fa) { DEC_BA(baddr); - prot = FA_IS_PROTECTED(get_field_attribute(baddr)); + prot = FA_IS_PROTECTED(get_field_attribute(&h3270,baddr)); continue; } if (!prot && c != EBC_space && c != EBC_null) @@ -2087,7 +2087,7 @@ nu_word(int baddr) unsigned char c; Boolean prot; - prot = FA_IS_PROTECTED(get_field_attribute(baddr)); + prot = FA_IS_PROTECTED(get_field_attribute(&h3270,baddr)); do { c = ea_buf[baddr].cc; @@ -2145,12 +2145,12 @@ LIB3270_ACTION( nextword ) if (IN_ANSI) return 0; #endif /*]*/ - if (!formatted) + if (!h3270.formatted) return 0; /* If not in an unprotected field, go to the next unprotected word. */ if (ea_buf[h3270.cursor_addr].fa || - FA_IS_PROTECTED(get_field_attribute(h3270.cursor_addr))) { + FA_IS_PROTECTED(get_field_attribute(&h3270,h3270.cursor_addr))) { baddr = nu_word(h3270.cursor_addr); if (baddr != -1) cursor_move(baddr); @@ -2311,7 +2311,7 @@ LIB3270_CURSOR_ACTION( newline ) #endif /*]*/ baddr = (h3270.cursor_addr + h3270.cols) % (h3270.cols * h3270.rows); /* down */ baddr = (baddr / h3270.cols) * h3270.cols; /* 1st col */ - faddr = find_field_attribute(baddr); + faddr = find_field_attribute(&h3270,baddr); fa = ea_buf[faddr].fa; if (faddr != baddr && !FA_IS_PROTECTED(fa)) cursor_move(baddr); @@ -2426,7 +2426,7 @@ LIB3270_ACTION( clear ) } #endif /*]*/ buffer_addr = 0; - ctlr_clear(True); + ctlr_clear(&h3270,True); cursor_move(0); if (CONNECTED) key_AID(AID_CLEAR); @@ -2566,14 +2566,14 @@ LIB3270_ACTION( eraseeol ) #endif /*]*/ baddr = h3270.cursor_addr; - fa = get_field_attribute(baddr); + fa = get_field_attribute(&h3270,baddr); if (FA_IS_PROTECTED(fa) || ea_buf[baddr].fa) { operator_error(KL_OERR_PROTECTED); return -1; } - if (formatted) + if (h3270.formatted) { /* erase to next field attribute or current line */ do @@ -2631,12 +2631,12 @@ LIB3270_ACTION( eraseeof ) return 0; #endif /*]*/ baddr = h3270.cursor_addr; - fa = get_field_attribute(baddr); + fa = get_field_attribute(&h3270,baddr); if (FA_IS_PROTECTED(fa) || ea_buf[baddr].fa) { operator_error(KL_OERR_PROTECTED); return -1; } - if (formatted) { /* erase to next field attribute */ + if (h3270.formatted) { /* erase to next field attribute */ do { ctlr_add(baddr, EBC_null, 0); INC_BA(baddr); @@ -2679,7 +2679,7 @@ LIB3270_ACTION( eraseinput ) if (IN_ANSI) return 0; #endif /*]*/ - if (formatted) { + if (h3270.formatted) { /* find first field attribute */ baddr = 0; do { @@ -2712,7 +2712,7 @@ LIB3270_ACTION( eraseinput ) if (!f) cursor_move(0); } else { - ctlr_clear(True); + ctlr_clear(&h3270,True); cursor_move(0); } screen_disp(&h3270); @@ -2745,11 +2745,11 @@ LIB3270_ACTION( deleteword ) return 0; } #endif /*]*/ - if (!formatted) + if (!h3270.formatted) return 0; baddr = h3270.cursor_addr; - fa = get_field_attribute(baddr); + fa = get_field_attribute(&h3270,baddr); /* Make sure we're on a modifiable field. */ if (FA_IS_PROTECTED(fa) || ea_buf[baddr].fa) { @@ -2812,11 +2812,11 @@ LIB3270_ACTION( deletefield ) return 0; } #endif /*]*/ - if (!formatted) + if (!h3270.formatted) return 0; baddr = h3270.cursor_addr; - fa = get_field_attribute(baddr); + fa = get_field_attribute(&h3270,baddr); if (FA_IS_PROTECTED(fa) || ea_buf[baddr].fa) { operator_error(KL_OERR_PROTECTED); return -1; @@ -2916,10 +2916,10 @@ LIB3270_ACTION( fieldend ) if (IN_ANSI) return 0; #endif /*]*/ - if (!formatted) + if (!h3270.formatted) return 0; baddr = h3270.cursor_addr; - faddr = find_field_attribute(baddr); + faddr = find_field_attribute(&h3270,baddr); fa = ea_buf[faddr].fa; if (faddr == baddr || FA_IS_PROTECTED(fa)) return 0; @@ -3299,7 +3299,7 @@ remargin(int lmargin) b0 = baddr; ever = True; } - faddr = find_field_attribute(baddr); + faddr = find_field_attribute(&h3270,baddr); fa = ea_buf[faddr].fa; if (faddr == baddr || FA_IS_PROTECTED(fa)) { baddr = next_unprotected(baddr); @@ -3855,10 +3855,10 @@ kybd_prime(void) * No point in trying if the screen isn't formatted, the keyboard * is locked, or we aren't in 3270 mode. */ - if (!formatted || kybdlock || !IN_3270) + if (!h3270.formatted || kybdlock || !IN_3270) return 0; - fa = get_field_attribute(h3270.cursor_addr); + fa = get_field_attribute(&h3270,h3270.cursor_addr); if (ea_buf[h3270.cursor_addr].fa || FA_IS_PROTECTED(fa)) { /* * The cursor is not in an unprotected field. Find the diff --git a/latest/src/lib/paste.c b/latest/src/lib/paste.c index ea6e756..2433699 100644 --- a/latest/src/lib/paste.c +++ b/latest/src/lib/paste.c @@ -111,7 +111,7 @@ ever = True; } - faddr = find_field_attribute(baddr); + faddr = find_field_attribute(&h3270,baddr); fa = ea_buf[faddr].fa; if (faddr == baddr || FA_IS_PROTECTED(fa)) { @@ -132,7 +132,7 @@ if(toggled(SMART_PASTE)) { - int faddr = find_field_attribute(h3270.cursor_addr); + int faddr = find_field_attribute(&h3270,h3270.cursor_addr); if(FA_IS_PROTECTED(ea_buf[faddr].fa)) h3270.cursor_addr++; else @@ -190,7 +190,7 @@ LIB3270_EXPORT int lib3270_set_string(H3270 *h, const unsigned char *str) { baddr = (h->cursor_addr + h->cols) % (h->cols * h->rows); /* down */ baddr = (baddr / h->cols) * h->cols; /* 1st col */ - faddr = find_field_attribute(baddr); + faddr = find_field_attribute(h,baddr); fa = ea_buf[faddr].fa; if (faddr != baddr && !FA_IS_PROTECTED(fa)) cursor_move(baddr); diff --git a/latest/src/lib/print.c b/latest/src/lib/print.c index f0dd752..f7613a1 100644 --- a/latest/src/lib/print.c +++ b/latest/src/lib/print.c @@ -150,7 +150,7 @@ fprint_screen(FILE *f, Boolean even_if_empty, Boolean use_html) int ns = 0; int nr = 0; Boolean any = False; - int fa_addr = find_field_attribute(0); + int fa_addr = find_field_attribute(&h3270,0); unsigned char fa = ea_buf[fa_addr].fa; int fa_color, current_color; Bool fa_high, current_high; diff --git a/latest/src/lib/screen.c b/latest/src/lib/screen.c index cf90f98..ec1429c 100644 --- a/latest/src/lib/screen.c +++ b/latest/src/lib/screen.c @@ -99,11 +99,19 @@ void set_display_charset(char *dcs) callbacks->charset(dcs); } +/* static void addch(int row, int col, int c, int attr) { if(callbacks && callbacks->addch) callbacks->addch(row, col, c, attr); } +*/ + +static void addch(H3270 *session, int baddr, unsigned short c, int attr) +{ + if(callbacks && callbacks->addch) + callbacks->addch(baddr/session->cols, baddr%session->cols, c, attr); +} /** * Initialize the screen. @@ -141,8 +149,6 @@ int screen_init(H3270 *session) // if (ab_mode == TS_AUTO) // ab_mode = appres.m3279? TS_ON: TS_OFF; - /* Pull in the user's color mappings. */ - /* Set up the controller. */ ctlr_init(-1); ctlr_reinit(session,-1); @@ -298,7 +304,7 @@ void update_model_info(H3270 *session, int model, int cols, int rows) /* Get screen contents */ int screen_read(char *dest, int baddr, int count) { - unsigned char fa = get_field_attribute(baddr); + unsigned char fa = get_field_attribute(&h3270,baddr); int max = (h3270.maxROWS * h3270.maxCOLS); *dest = 0; @@ -333,20 +339,15 @@ int screen_read(char *dest, int baddr, int count) static void screen_update(H3270 *session, int bstart, int bend) { - int baddr, row, col; + int baddr; unsigned short a; int attr = COLOR_GREEN; unsigned char fa; int fa_addr; - fa = get_field_attribute(bstart); + fa = get_field_attribute(session,bstart); a = color_from_fa(fa); - fa_addr = find_field_attribute(bstart); // may be -1, that's okay - - row = bstart/session->cols; - col = bstart%session->cols; - - Trace("Update@%d-%d (%d,%d): [%c]",bstart,bend,row,col,ebc2asc[ea_buf[bstart].cc]); + fa_addr = find_field_attribute(session,bstart); // may be -1, that's okay for(baddr = bstart; baddr <= bend; baddr++) { @@ -356,12 +357,12 @@ static void screen_update(H3270 *session, int bstart, int bend) fa_addr = baddr; fa = ea_buf[baddr].fa; a = calc_attrs(baddr, baddr, fa); - addch(row,col,' ',(attr = COLOR_GREEN)|CHAR_ATTR_MARKER); + addch(session,baddr,' ',(attr = COLOR_GREEN)|CHAR_ATTR_MARKER); } else if (FA_IS_ZERO(fa)) { // Blank. - addch(row,col,' ',attr=a); + addch(session,baddr,' ',attr=a); } else { @@ -384,27 +385,21 @@ static void screen_update(H3270 *session, int bstart, int bend) if (ea_buf[baddr].cs == CS_LINEDRAW) { - addch(row,col,ea_buf[baddr].cc,attr); + addch(session,baddr,ea_buf[baddr].cc,attr); } else if (ea_buf[baddr].cs == CS_APL || (ea_buf[baddr].cs & CS_GE)) { - addch(row,col,ea_buf[baddr].cc,attr|CHAR_ATTR_CG); + addch(session,baddr,ea_buf[baddr].cc,attr|CHAR_ATTR_CG); } else { if (toggled(MONOCASE)) - addch(row,col,asc2uc[ebc2asc[ea_buf[baddr].cc]],attr); + addch(session,baddr,asc2uc[ebc2asc[ea_buf[baddr].cc]],attr); else - addch(row,col,ebc2asc[ea_buf[baddr].cc],attr); + addch(session,baddr,ebc2asc[ea_buf[baddr].cc],attr); } } - if(++col >= session->cols) - { - row++; - col=0; - } - } } @@ -598,8 +593,10 @@ static void status_connect(H3270 *session, int connected, void *dunno) { STATUS_CODE id = STATUS_CODE_USER; - if (connected) { + ctlr_erase(session,1); + if (connected) + { set_status(session,OIA_FLAG_BOXSOLID,IN_3270 && !IN_SSCP); if (kybdlock & KL_AWAITING_FIRST) @@ -611,7 +608,9 @@ static void status_connect(H3270 *session, int connected, void *dunno) set_status(session,OIA_FLAG_SECURE,session->secure_connection); #endif /*]*/ - } else { + } + else + { set_status(session,OIA_FLAG_BOXSOLID,False); set_status(session,OIA_FLAG_SECURE,False); diff --git a/latest/src/lib/sf.c b/latest/src/lib/sf.c index e5d4cf6..18c1386 100644 --- a/latest/src/lib/sf.c +++ b/latest/src/lib/sf.c @@ -65,7 +65,7 @@ #include /* Externals: ctlr.c */ -extern Boolean screen_alt; +// extern Boolean screen_alt; extern unsigned char reply_mode; extern int crm_nattr; extern unsigned char crm_attr[]; @@ -380,11 +380,11 @@ sf_erase_reset(unsigned char buf[], int buflen) switch (buf[3]) { case SF_ER_DEFAULT: trace_ds(" Default\n"); - ctlr_erase(False); + ctlr_erase(NULL,False); break; case SF_ER_ALT: trace_ds(" Alternate\n"); - ctlr_erase(True); + ctlr_erase(NULL,True); break; default: trace_ds(" unknown type 0x%02x\n", buf[3]); @@ -509,13 +509,13 @@ sf_create_partition(unsigned char buf[], int buflen) GET16(h, &buf[6]); trace_ds(",h=%d", h); } else - h = maxROWS; + h = h3270.maxROWS; if (buflen > 9) { GET16(w, &buf[8]); trace_ds(",w=%d", w); } else - w = maxCOLS; + w = h3270.maxCOLS; if (buflen > 11) { GET16(rv, &buf[10]); @@ -533,13 +533,13 @@ sf_create_partition(unsigned char buf[], int buflen) GET16(hv, &buf[14]); trace_ds(",hv=%d", hv); } else - hv = (h > maxROWS)? maxROWS: h; + hv = (h > h3270.maxROWS)? h3270.maxROWS: h; if (buflen > 17) { GET16(wv, &buf[16]); trace_ds(",wv=%d", wv); } else - wv = (w > maxCOLS)? maxCOLS: w; + wv = (w > h3270.maxCOLS)? h3270.maxCOLS: w; if (buflen > 19) { GET16(rw, &buf[18]); @@ -605,7 +605,7 @@ sf_outbound_ds(unsigned char buf[], int buflen) break; case SNA_CMD_EW: trace_ds(" EraseWrite"); - ctlr_erase(screen_alt); + ctlr_erase(&h3270,h3270.screen_alt); if (buflen > 5) { if ((rv = ctlr_write(&buf[4], buflen-4, True)) < 0) return rv; @@ -614,7 +614,7 @@ sf_outbound_ds(unsigned char buf[], int buflen) break; case SNA_CMD_EWA: trace_ds(" EraseWriteAlternate"); - ctlr_erase(screen_alt); + ctlr_erase(&h3270,h3270.screen_alt); if (buflen > 5) { if ((rv = ctlr_write(&buf[4], buflen-4, True)) < 0) return rv; diff --git a/latest/src/lib/trace_ds.c b/latest/src/lib/trace_ds.c index 4ccf06c..c89592e 100644 --- a/latest/src/lib/trace_ds.c +++ b/latest/src/lib/trace_ds.c @@ -447,7 +447,7 @@ create_tracefile_header(const char *mode) * write to ensure that the display is in the right * mode. */ - if (formatted) { + if (h3270.formatted) { wtrace(" Screen contents:\n"); obptr = obuf; #if defined(X3270_TN3270E) /*[*/ -- libgit2 0.21.2