From e5e488231d26a1d85c4eefd133ad6ad377fdbef8 Mon Sep 17 00:00:00 2001 From: perry.werneck@gmail.com Date: Thu, 26 Jan 2012 11:54:40 +0000 Subject: [PATCH] Pequenos ajustes para multi-sessão --- latest/src/gtk2/cursor.c | 2 +- latest/src/gtk2/gui.h | 2 +- latest/src/gtk2/screen.c | 8 ++++---- latest/src/include/lib3270/api.h | 31 +++++++++++++++++-------------- latest/src/lib/screen.c | 21 +++++++++++++++++---- 5 files changed, 40 insertions(+), 24 deletions(-) diff --git a/latest/src/gtk2/cursor.c b/latest/src/gtk2/cursor.c index 5ed10cb..dd8500d 100755 --- a/latest/src/gtk2/cursor.c +++ b/latest/src/gtk2/cursor.c @@ -100,7 +100,7 @@ rCursor.height = terminal_font_info.height; } - void update_cursor_position(H3270 *session, int row, int col) + void update_cursor_position(H3270 *session, unsigned short row, unsigned short col) { int addr = (row * screen->cols) + col; diff --git a/latest/src/gtk2/gui.h b/latest/src/gtk2/gui.h index df30a4e..7b42aee 100644 --- a/latest/src/gtk2/gui.h +++ b/latest/src/gtk2/gui.h @@ -344,7 +344,7 @@ LOCAL_EXTERN void unselect(void); LOCAL_EXTERN void reselect(void); - LOCAL_EXTERN void update_cursor_position(H3270 *session, int row, int col); + LOCAL_EXTERN void update_cursor_position(H3270 *session, unsigned short row, unsigned short col); LOCAL_EXTERN void update_cursor_info(void); LOCAL_EXTERN void queue_draw_cursor(void); LOCAL_EXTERN void update_cursor_pixmap(void); diff --git a/latest/src/gtk2/screen.c b/latest/src/gtk2/screen.c index fe7f458..57f9847 100644 --- a/latest/src/gtk2/screen.c +++ b/latest/src/gtk2/screen.c @@ -71,7 +71,7 @@ static int SetSuspended(int state); static void SetScript(SCRIPT_STATE state); static void set_cursor(CURSOR_MODE mode); - static void set_oia(OIA_FLAG id, int on); + static void set_oia(OIA_FLAG id, unsigned char on); static void set_lu(const char *lu); // static void changed(int bstart, int bend); static void error(const char *fmt, va_list arg); @@ -109,14 +109,14 @@ settitle, // void (*title)(char *text); gdk_beep, // void (*ring_bell)(void); redraw, // void (*redraw)(void); - update_cursor_position, // void (*move_cursor)(H3270 *session, int row, int col); + update_cursor_position, // void (*move_cursor)(H3270 *session, unsigned short row, unsigned short col); SetSuspended, // int (*set_suspended)(int state); SetScript, // void (*set_script)(SCRIPT_STATE state); NULL, // void (*reset)(int lock); SetStatusCode, // void (*status)(STATUS_CODE id); set_cursor, // void (*cursor)(CURSOR_MODE mode); set_lu, // void (*lu)(const char *lu); - set_oia, // void (*set)(OIA_FLAG id, int on); + set_oia, // void (*set)(OIA_FLAG id, unsigned char on); erase, // void (*erase)(void); display, // void (*display)(H3270 *session); @@ -454,7 +454,7 @@ g_free(luname); } - static void set_oia(OIA_FLAG id, int on) + static void set_oia(OIA_FLAG id, unsigned char on) { if(id > OIA_FLAG_USER) return; diff --git a/latest/src/include/lib3270/api.h b/latest/src/include/lib3270/api.h index 46a5f14..cb4b411 100644 --- a/latest/src/include/lib3270/api.h +++ b/latest/src/include/lib3270/api.h @@ -183,6 +183,19 @@ } STATUS_CODE; + typedef enum _OIA_FLAG + { + OIA_FLAG_BOXSOLID, + OIA_FLAG_UNDERA, + OIA_FLAG_SECURE, + OIA_FLAG_TYPEAHEAD, + OIA_FLAG_PRINTER, + OIA_FLAG_REVERSE, + + OIA_FLAG_USER + } OIA_FLAG; + + struct lib3270_state_callback; typedef struct _h3270 H3270; @@ -261,6 +274,8 @@ /* Session based callbacks */ void (*configure)(H3270 *session, int rows, int cols); void (*update)(H3270 *session, int baddr, unsigned char c, unsigned short attr); + void (*update_cursor)(H3270 *session, unsigned short row, unsigned short col); + void (*set_oia)(H3270 *session, OIA_FLAG id, unsigned char on); }; @@ -438,18 +453,6 @@ } SCRIPT_STATE; - typedef enum _OIA_FLAG - { - OIA_FLAG_BOXSOLID, - OIA_FLAG_UNDERA, - OIA_FLAG_SECURE, - OIA_FLAG_TYPEAHEAD, - OIA_FLAG_PRINTER, - OIA_FLAG_REVERSE, - - OIA_FLAG_USER - } OIA_FLAG; - typedef enum _COUNTER_ID { COUNTER_ID_CTLR_DONE, @@ -488,14 +491,14 @@ void (*title)(char *text); void (*ring_bell)(void); void (*redraw)(void); - void (*move_cursor)(H3270 *session, int row, int col); + void (*move_cursor)(H3270 *session, unsigned short row, unsigned short col); int (*set_suspended)(int state); void (*set_script)(SCRIPT_STATE state); void (*reset)(int lock); void (*status)(STATUS_CODE id); void (*cursor)(CURSOR_MODE mode); void (*lu)(const char *lu); - void (*set)(OIA_FLAG id, int on); + void (*set_oia)(H3270 *session, OIA_FLAG id, unsigned char on); void (*erase)(void); void (*display)(H3270 *session); diff --git a/latest/src/lib/screen.c b/latest/src/lib/screen.c index 536bf42..5c9e605 100644 --- a/latest/src/lib/screen.c +++ b/latest/src/lib/screen.c @@ -123,15 +123,23 @@ static void addch(H3270 *session, int baddr, unsigned char c, unsigned short att */ int screen_init(H3270 *session) { + CHECK_SESSION_HANDLE(session); /* Initialize the console. */ - if(callbacks && callbacks->init) + if(callbacks) { if(callbacks->init()) { popup_an_error("Can't initialize terminal."); return -1; } + + /* Init default callbacks */ + if(callbacks->move_cursor) + session->update_cursor = callbacks->move_cursor; + + if(callbacks->set_oia) + session->set_oia = callbacks->set_oia; } /* Set up callbacks for state changes. */ @@ -440,8 +448,13 @@ 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)); + +/* if(callbacks && callbacks->move_cursor) - callbacks->move_cursor(h,baddr/h->cols, baddr%h->cols); + callbacks->move_cursor(h,row,col); +*/ return ret; } @@ -452,8 +465,8 @@ void set_status(H3270 *session, OIA_FLAG id, Boolean on) { CHECK_SESSION_HANDLE(session); - if(callbacks && callbacks->set) - callbacks->set(id,on); + if(session->set_oia) + session->set_oia(session,id,on); } void status_ctlr_done(H3270 *session) -- libgit2 0.21.2