Commit e5e488231d26a1d85c4eefd133ad6ad377fdbef8

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

Pequenos ajustes para multi-sessão

latest/src/gtk2/cursor.c
... ... @@ -100,7 +100,7 @@
100 100 rCursor.height = terminal_font_info.height;
101 101 }
102 102  
103   - void update_cursor_position(H3270 *session, int row, int col)
  103 + void update_cursor_position(H3270 *session, unsigned short row, unsigned short col)
104 104 {
105 105 int addr = (row * screen->cols) + col;
106 106  
... ...
latest/src/gtk2/gui.h
... ... @@ -344,7 +344,7 @@
344 344 LOCAL_EXTERN void unselect(void);
345 345 LOCAL_EXTERN void reselect(void);
346 346  
347   - LOCAL_EXTERN void update_cursor_position(H3270 *session, int row, int col);
  347 + LOCAL_EXTERN void update_cursor_position(H3270 *session, unsigned short row, unsigned short col);
348 348 LOCAL_EXTERN void update_cursor_info(void);
349 349 LOCAL_EXTERN void queue_draw_cursor(void);
350 350 LOCAL_EXTERN void update_cursor_pixmap(void);
... ...
latest/src/gtk2/screen.c
... ... @@ -71,7 +71,7 @@
71 71 static int SetSuspended(int state);
72 72 static void SetScript(SCRIPT_STATE state);
73 73 static void set_cursor(CURSOR_MODE mode);
74   - static void set_oia(OIA_FLAG id, int on);
  74 + static void set_oia(OIA_FLAG id, unsigned char on);
75 75 static void set_lu(const char *lu);
76 76 // static void changed(int bstart, int bend);
77 77 static void error(const char *fmt, va_list arg);
... ... @@ -109,14 +109,14 @@
109 109 settitle, // void (*title)(char *text);
110 110 gdk_beep, // void (*ring_bell)(void);
111 111 redraw, // void (*redraw)(void);
112   - update_cursor_position, // void (*move_cursor)(H3270 *session, int row, int col);
  112 + update_cursor_position, // void (*move_cursor)(H3270 *session, unsigned short row, unsigned short col);
113 113 SetSuspended, // int (*set_suspended)(int state);
114 114 SetScript, // void (*set_script)(SCRIPT_STATE state);
115 115 NULL, // void (*reset)(int lock);
116 116 SetStatusCode, // void (*status)(STATUS_CODE id);
117 117 set_cursor, // void (*cursor)(CURSOR_MODE mode);
118 118 set_lu, // void (*lu)(const char *lu);
119   - set_oia, // void (*set)(OIA_FLAG id, int on);
  119 + set_oia, // void (*set)(OIA_FLAG id, unsigned char on);
120 120  
121 121 erase, // void (*erase)(void);
122 122 display, // void (*display)(H3270 *session);
... ... @@ -454,7 +454,7 @@
454 454 g_free(luname);
455 455 }
456 456  
457   - static void set_oia(OIA_FLAG id, int on)
  457 + static void set_oia(OIA_FLAG id, unsigned char on)
458 458 {
459 459 if(id > OIA_FLAG_USER)
460 460 return;
... ...
latest/src/include/lib3270/api.h
... ... @@ -183,6 +183,19 @@
183 183  
184 184 } STATUS_CODE;
185 185  
  186 + typedef enum _OIA_FLAG
  187 + {
  188 + OIA_FLAG_BOXSOLID,
  189 + OIA_FLAG_UNDERA,
  190 + OIA_FLAG_SECURE,
  191 + OIA_FLAG_TYPEAHEAD,
  192 + OIA_FLAG_PRINTER,
  193 + OIA_FLAG_REVERSE,
  194 +
  195 + OIA_FLAG_USER
  196 + } OIA_FLAG;
  197 +
  198 +
186 199 struct lib3270_state_callback;
187 200  
188 201 typedef struct _h3270 H3270;
... ... @@ -261,6 +274,8 @@
261 274 /* Session based callbacks */
262 275 void (*configure)(H3270 *session, int rows, int cols);
263 276 void (*update)(H3270 *session, int baddr, unsigned char c, unsigned short attr);
  277 + void (*update_cursor)(H3270 *session, unsigned short row, unsigned short col);
  278 + void (*set_oia)(H3270 *session, OIA_FLAG id, unsigned char on);
264 279  
265 280 };
266 281  
... ... @@ -438,18 +453,6 @@
438 453  
439 454 } SCRIPT_STATE;
440 455  
441   - typedef enum _OIA_FLAG
442   - {
443   - OIA_FLAG_BOXSOLID,
444   - OIA_FLAG_UNDERA,
445   - OIA_FLAG_SECURE,
446   - OIA_FLAG_TYPEAHEAD,
447   - OIA_FLAG_PRINTER,
448   - OIA_FLAG_REVERSE,
449   -
450   - OIA_FLAG_USER
451   - } OIA_FLAG;
452   -
453 456 typedef enum _COUNTER_ID
454 457 {
455 458 COUNTER_ID_CTLR_DONE,
... ... @@ -488,14 +491,14 @@
488 491 void (*title)(char *text);
489 492 void (*ring_bell)(void);
490 493 void (*redraw)(void);
491   - void (*move_cursor)(H3270 *session, int row, int col);
  494 + void (*move_cursor)(H3270 *session, unsigned short row, unsigned short col);
492 495 int (*set_suspended)(int state);
493 496 void (*set_script)(SCRIPT_STATE state);
494 497 void (*reset)(int lock);
495 498 void (*status)(STATUS_CODE id);
496 499 void (*cursor)(CURSOR_MODE mode);
497 500 void (*lu)(const char *lu);
498   - void (*set)(OIA_FLAG id, int on);
  501 + void (*set_oia)(H3270 *session, OIA_FLAG id, unsigned char on);
499 502  
500 503 void (*erase)(void);
501 504 void (*display)(H3270 *session);
... ...
latest/src/lib/screen.c
... ... @@ -123,15 +123,23 @@ static void addch(H3270 *session, int baddr, unsigned char c, unsigned short att
123 123 */
124 124 int screen_init(H3270 *session)
125 125 {
  126 + CHECK_SESSION_HANDLE(session);
126 127  
127 128 /* Initialize the console. */
128   - if(callbacks && callbacks->init)
  129 + if(callbacks)
129 130 {
130 131 if(callbacks->init())
131 132 {
132 133 popup_an_error("Can't initialize terminal.");
133 134 return -1;
134 135 }
  136 +
  137 + /* Init default callbacks */
  138 + if(callbacks->move_cursor)
  139 + session->update_cursor = callbacks->move_cursor;
  140 +
  141 + if(callbacks->set_oia)
  142 + session->set_oia = callbacks->set_oia;
135 143 }
136 144  
137 145 /* Set up callbacks for state changes. */
... ... @@ -440,8 +448,13 @@ LIB3270_EXPORT int lib3270_set_cursor_address(H3270 *h, int baddr)
440 448  
441 449 h->cursor_addr = baddr;
442 450  
  451 + if(h->update_cursor)
  452 + h->update_cursor(h,(unsigned short) (baddr/h->cols),(unsigned short) (baddr%h->cols));
  453 +
  454 +/*
443 455 if(callbacks && callbacks->move_cursor)
444   - callbacks->move_cursor(h,baddr/h->cols, baddr%h->cols);
  456 + callbacks->move_cursor(h,row,col);
  457 +*/
445 458  
446 459 return ret;
447 460 }
... ... @@ -452,8 +465,8 @@ void set_status(H3270 *session, OIA_FLAG id, Boolean on)
452 465 {
453 466 CHECK_SESSION_HANDLE(session);
454 467  
455   - if(callbacks && callbacks->set)
456   - callbacks->set(id,on);
  468 + if(session->set_oia)
  469 + session->set_oia(session,id,on);
457 470 }
458 471  
459 472 void status_ctlr_done(H3270 *session)
... ...