diff --git a/latest/src/gtk2/screen.c b/latest/src/gtk2/screen.c index 57f9847..0ff653c 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, unsigned char on); + static void set_oia(H3270 *session, 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); @@ -121,9 +121,9 @@ erase, // void (*erase)(void); display, // void (*display)(H3270 *session); #ifdef HAVE_ALTSCREEN - view_changed, // void (*set_viewsize)(H3270 *session, int rows, int cols); + view_changed, // void (*set_viewsize)(H3270 *session, unsigned short rows, unsigned short cols); #else - NULL, // void (*set_viewsize)(int rows, int cols); + NULL, // void (*set_viewsize)(unsigned short rows, unsigned short cols); #endif update_toggle, // void (*toggle_changed)(int ix, int value, int reason, const char *name); @@ -454,7 +454,7 @@ g_free(luname); } - static void set_oia(OIA_FLAG id, unsigned char on) + static void set_oia(H3270 *session, OIA_FLAG id, unsigned char on) { if(id > OIA_FLAG_USER) return; diff --git a/latest/src/include/lib3270.h b/latest/src/include/lib3270.h index 785fc7e..8de4371 100644 --- a/latest/src/include/lib3270.h +++ b/latest/src/include/lib3270.h @@ -186,6 +186,17 @@ */ LIB3270_EXPORT int lib3270_get_cursor_address(H3270 *h); + /** + * Get buffer contents. + * + * @param h Session handle. + * @param first First element to get. + * @param last Last element to get. + * @param chr Pointer to buffer which will receive the read chars. + * @param attr Pointer to buffer which will receive the chars attributes. + * + */ + LIB3270_EXPORT int lib3270_get_contents(H3270 *h, int first, int last, unsigned char *chr, unsigned short *attr); LIB3270_EXPORT STATUS_CODE lib3270_get_oia_status(H3270 *h); LIB3270_EXPORT const char * lib3270_get_luname(H3270 *h); diff --git a/latest/src/include/lib3270/api.h b/latest/src/include/lib3270/api.h index cb4b411..8040e68 100644 --- a/latest/src/include/lib3270/api.h +++ b/latest/src/include/lib3270/api.h @@ -241,8 +241,8 @@ // int last_changed; int maxROWS; int maxCOLS; - int rows; - int cols; + unsigned short rows; + unsigned short cols; int cursor_addr; char flipped; int screen_alt; /**< alternate screen? */ @@ -502,7 +502,7 @@ void (*erase)(void); void (*display)(H3270 *session); - void (*set_viewsize)(H3270 *session, int rows, int cols); + void (*set_viewsize)(H3270 *session, unsigned short rows, unsigned short cols); void (*toggle_changed)(int ix, int value, int reason, const char *name); void (*show_timer)(long seconds); diff --git a/latest/src/lib/screen.c b/latest/src/lib/screen.c index 5c9e605..6d9db4b 100644 --- a/latest/src/lib/screen.c +++ b/latest/src/lib/screen.c @@ -140,6 +140,10 @@ int screen_init(H3270 *session) if(callbacks->set_oia) session->set_oia = callbacks->set_oia; + + if(callbacks->set_viewsize) + session->configure = callbacks->set_viewsize; + } /* Set up callbacks for state changes. */ @@ -302,6 +306,27 @@ void update_model_info(H3270 *session, int model, int cols, int rows) callbacks->model_changed(session, session->model_name,session->model_num,cols,rows); } +LIB3270_EXPORT int lib3270_get_contents(H3270 *h, int first, int last, unsigned char *chr, unsigned short *attr) +{ + int baddr; + int len; + + CHECK_SESSION_HANDLE(h); + + len = h->rows * h->cols; + + if(first > len || last > len || first < 0 || last < 0) + return EFAULT; + + for(baddr = first; baddr < last;baddr++) + { + *(chr++) = ea_buf[baddr].chr; + *(attr++) = ea_buf[baddr].attr; + } + + return 0; +} + /* Get screen contents */ int screen_read(char *dest, int baddr, int count) { @@ -451,11 +476,6 @@ LIB3270_EXPORT int lib3270_set_cursor_address(H3270 *h, int 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,row,col); -*/ - return ret; } @@ -584,11 +604,8 @@ void set_viewsize(H3270 *session, int rows, int cols) session->rows = rows; session->cols = cols; - if(callbacks && callbacks->set_viewsize) - callbacks->set_viewsize(session,rows,cols); - if(session->configure) - session->configure(session,rows,cols); + session->configure(session,session->rows,session->cols); } -- libgit2 0.21.2