Commit ab2a33030f44fa48799708d8c1a861376a86b07b

Authored by perry.werneck@gmail.com
1 parent e5e48823
Exists in master

Incluindo função para obter o buffer de sessão

latest/src/gtk2/screen.c
@@ -71,7 +71,7 @@ @@ -71,7 +71,7 @@
71 static int SetSuspended(int state); 71 static int SetSuspended(int state);
72 static void SetScript(SCRIPT_STATE state); 72 static void SetScript(SCRIPT_STATE state);
73 static void set_cursor(CURSOR_MODE mode); 73 static void set_cursor(CURSOR_MODE mode);
74 - static void set_oia(OIA_FLAG id, unsigned char on); 74 + static void set_oia(H3270 *session, OIA_FLAG id, unsigned char on);
75 static void set_lu(const char *lu); 75 static void set_lu(const char *lu);
76 // static void changed(int bstart, int bend); 76 // static void changed(int bstart, int bend);
77 static void error(const char *fmt, va_list arg); 77 static void error(const char *fmt, va_list arg);
@@ -121,9 +121,9 @@ @@ -121,9 +121,9 @@
121 erase, // void (*erase)(void); 121 erase, // void (*erase)(void);
122 display, // void (*display)(H3270 *session); 122 display, // void (*display)(H3270 *session);
123 #ifdef HAVE_ALTSCREEN 123 #ifdef HAVE_ALTSCREEN
124 - view_changed, // void (*set_viewsize)(H3270 *session, int rows, int cols); 124 + view_changed, // void (*set_viewsize)(H3270 *session, unsigned short rows, unsigned short cols);
125 #else 125 #else
126 - NULL, // void (*set_viewsize)(int rows, int cols); 126 + NULL, // void (*set_viewsize)(unsigned short rows, unsigned short cols);
127 #endif 127 #endif
128 128
129 update_toggle, // void (*toggle_changed)(int ix, int value, int reason, const char *name); 129 update_toggle, // void (*toggle_changed)(int ix, int value, int reason, const char *name);
@@ -454,7 +454,7 @@ @@ -454,7 +454,7 @@
454 g_free(luname); 454 g_free(luname);
455 } 455 }
456 456
457 - static void set_oia(OIA_FLAG id, unsigned char on) 457 + static void set_oia(H3270 *session, OIA_FLAG id, unsigned char on)
458 { 458 {
459 if(id > OIA_FLAG_USER) 459 if(id > OIA_FLAG_USER)
460 return; 460 return;
latest/src/include/lib3270.h
@@ -186,6 +186,17 @@ @@ -186,6 +186,17 @@
186 */ 186 */
187 LIB3270_EXPORT int lib3270_get_cursor_address(H3270 *h); 187 LIB3270_EXPORT int lib3270_get_cursor_address(H3270 *h);
188 188
  189 + /**
  190 + * Get buffer contents.
  191 + *
  192 + * @param h Session handle.
  193 + * @param first First element to get.
  194 + * @param last Last element to get.
  195 + * @param chr Pointer to buffer which will receive the read chars.
  196 + * @param attr Pointer to buffer which will receive the chars attributes.
  197 + *
  198 + */
  199 + LIB3270_EXPORT int lib3270_get_contents(H3270 *h, int first, int last, unsigned char *chr, unsigned short *attr);
189 200
190 LIB3270_EXPORT STATUS_CODE lib3270_get_oia_status(H3270 *h); 201 LIB3270_EXPORT STATUS_CODE lib3270_get_oia_status(H3270 *h);
191 LIB3270_EXPORT const char * lib3270_get_luname(H3270 *h); 202 LIB3270_EXPORT const char * lib3270_get_luname(H3270 *h);
latest/src/include/lib3270/api.h
@@ -241,8 +241,8 @@ @@ -241,8 +241,8 @@
241 // int last_changed; 241 // int last_changed;
242 int maxROWS; 242 int maxROWS;
243 int maxCOLS; 243 int maxCOLS;
244 - int rows;  
245 - int cols; 244 + unsigned short rows;
  245 + unsigned short cols;
246 int cursor_addr; 246 int cursor_addr;
247 char flipped; 247 char flipped;
248 int screen_alt; /**< alternate screen? */ 248 int screen_alt; /**< alternate screen? */
@@ -502,7 +502,7 @@ @@ -502,7 +502,7 @@
502 502
503 void (*erase)(void); 503 void (*erase)(void);
504 void (*display)(H3270 *session); 504 void (*display)(H3270 *session);
505 - void (*set_viewsize)(H3270 *session, int rows, int cols); 505 + void (*set_viewsize)(H3270 *session, unsigned short rows, unsigned short cols);
506 506
507 void (*toggle_changed)(int ix, int value, int reason, const char *name); 507 void (*toggle_changed)(int ix, int value, int reason, const char *name);
508 void (*show_timer)(long seconds); 508 void (*show_timer)(long seconds);
latest/src/lib/screen.c
@@ -140,6 +140,10 @@ int screen_init(H3270 *session) @@ -140,6 +140,10 @@ int screen_init(H3270 *session)
140 140
141 if(callbacks->set_oia) 141 if(callbacks->set_oia)
142 session->set_oia = callbacks->set_oia; 142 session->set_oia = callbacks->set_oia;
  143 +
  144 + if(callbacks->set_viewsize)
  145 + session->configure = callbacks->set_viewsize;
  146 +
143 } 147 }
144 148
145 /* Set up callbacks for state changes. */ 149 /* Set up callbacks for state changes. */
@@ -302,6 +306,27 @@ void update_model_info(H3270 *session, int model, int cols, int rows) @@ -302,6 +306,27 @@ void update_model_info(H3270 *session, int model, int cols, int rows)
302 callbacks->model_changed(session, session->model_name,session->model_num,cols,rows); 306 callbacks->model_changed(session, session->model_name,session->model_num,cols,rows);
303 } 307 }
304 308
  309 +LIB3270_EXPORT int lib3270_get_contents(H3270 *h, int first, int last, unsigned char *chr, unsigned short *attr)
  310 +{
  311 + int baddr;
  312 + int len;
  313 +
  314 + CHECK_SESSION_HANDLE(h);
  315 +
  316 + len = h->rows * h->cols;
  317 +
  318 + if(first > len || last > len || first < 0 || last < 0)
  319 + return EFAULT;
  320 +
  321 + for(baddr = first; baddr < last;baddr++)
  322 + {
  323 + *(chr++) = ea_buf[baddr].chr;
  324 + *(attr++) = ea_buf[baddr].attr;
  325 + }
  326 +
  327 + return 0;
  328 +}
  329 +
305 /* Get screen contents */ 330 /* Get screen contents */
306 int screen_read(char *dest, int baddr, int count) 331 int screen_read(char *dest, int baddr, int count)
307 { 332 {
@@ -451,11 +476,6 @@ LIB3270_EXPORT int lib3270_set_cursor_address(H3270 *h, int baddr) @@ -451,11 +476,6 @@ LIB3270_EXPORT int lib3270_set_cursor_address(H3270 *h, int baddr)
451 if(h->update_cursor) 476 if(h->update_cursor)
452 h->update_cursor(h,(unsigned short) (baddr/h->cols),(unsigned short) (baddr%h->cols)); 477 h->update_cursor(h,(unsigned short) (baddr/h->cols),(unsigned short) (baddr%h->cols));
453 478
454 -/*  
455 - if(callbacks && callbacks->move_cursor)  
456 - callbacks->move_cursor(h,row,col);  
457 -*/  
458 -  
459 return ret; 479 return ret;
460 } 480 }
461 481
@@ -584,11 +604,8 @@ void set_viewsize(H3270 *session, int rows, int cols) @@ -584,11 +604,8 @@ void set_viewsize(H3270 *session, int rows, int cols)
584 session->rows = rows; 604 session->rows = rows;
585 session->cols = cols; 605 session->cols = cols;
586 606
587 - if(callbacks && callbacks->set_viewsize)  
588 - callbacks->set_viewsize(session,rows,cols);  
589 -  
590 if(session->configure) 607 if(session->configure)
591 - session->configure(session,rows,cols); 608 + session->configure(session,session->rows,session->cols);
592 609
593 } 610 }
594 611