Commit 30b68cb166ceb88d602eb2f943f811da32cf825c
1 parent
4c176b46
Exists in
master
and in
5 other branches
Implementando indicador de insert, otimizando toggles
Showing
9 changed files
with
91 additions
and
125 deletions
Show diff stats
src/gtk/v3270/oia.c
| @@ -421,7 +421,22 @@ static void draw_status_message(cairo_t *cr, LIB3270_MESSAGE id, struct v3270_me | @@ -421,7 +421,22 @@ static void draw_status_message(cairo_t *cr, LIB3270_MESSAGE id, struct v3270_me | ||
| 421 | cairo_show_text(cr,gettext(msg)); | 421 | cairo_show_text(cr,gettext(msg)); |
| 422 | } | 422 | } |
| 423 | 423 | ||
| 424 | -// trace("%s ends",__FUNCTION__); | 424 | +} |
| 425 | + | ||
| 426 | +static void draw_insert(cairo_t *cr, H3270 *host, GdkColor *color, GdkRectangle *rect) | ||
| 427 | +{ | ||
| 428 | + if(lib3270_get_toggle(host,LIB3270_TOGGLE_INSERT)) | ||
| 429 | + { | ||
| 430 | + double y = rect->y+(rect->height-2); | ||
| 431 | + | ||
| 432 | + gdk_cairo_set_source_color(cr,color+V3270_COLOR_OIA_FOREGROUND); | ||
| 433 | + | ||
| 434 | + cairo_move_to(cr,rect->x,y); | ||
| 435 | + cairo_rel_line_to(cr,rect->width/2,-(rect->height/1.7)); | ||
| 436 | + cairo_line_to(cr,rect->x+rect->width,y); | ||
| 437 | + cairo_stroke(cr); | ||
| 438 | + } | ||
| 439 | + | ||
| 425 | } | 440 | } |
| 426 | 441 | ||
| 427 | void v3270_draw_oia(cairo_t *cr, H3270 *host, int row, int cols, struct v3270_metrics *metrics, GdkColor *color, GdkRectangle *rect) | 442 | void v3270_draw_oia(cairo_t *cr, H3270 *host, int row, int cols, struct v3270_metrics *metrics, GdkColor *color, GdkRectangle *rect) |
| @@ -446,8 +461,6 @@ void v3270_draw_oia(cairo_t *cr, H3270 *host, int row, int cols, struct v3270_me | @@ -446,8 +461,6 @@ void v3270_draw_oia(cairo_t *cr, H3270 *host, int row, int cols, struct v3270_me | ||
| 446 | { V3270_OIA_SSL, setup_double_char_position }, | 461 | { V3270_OIA_SSL, setup_double_char_position }, |
| 447 | }; | 462 | }; |
| 448 | 463 | ||
| 449 | -// static const V3270_OIA_FIELD left[] = { V3270_OIA_UNDERA, V3270_OIA_CONNECTION }; | ||
| 450 | - | ||
| 451 | int f; | 464 | int f; |
| 452 | int rCol = metrics->left+(cols*metrics->width); | 465 | int rCol = metrics->left+(cols*metrics->width); |
| 453 | int lCol = metrics->left+1; | 466 | int lCol = metrics->left+1; |
| @@ -514,8 +527,6 @@ void v3270_draw_oia(cairo_t *cr, H3270 *host, int row, int cols, struct v3270_me | @@ -514,8 +527,6 @@ void v3270_draw_oia(cairo_t *cr, H3270 *host, int row, int cols, struct v3270_me | ||
| 514 | 527 | ||
| 515 | memset(rect+V3270_OIA_MESSAGE,0,sizeof(GdkRectangle)); | 528 | memset(rect+V3270_OIA_MESSAGE,0,sizeof(GdkRectangle)); |
| 516 | 529 | ||
| 517 | -// trace("%s lcol=%d rcol=%d",__FUNCTION__,lCol,rCol); | ||
| 518 | - | ||
| 519 | if(lCol < rCol) | 530 | if(lCol < rCol) |
| 520 | { | 531 | { |
| 521 | GdkRectangle *r = rect+V3270_OIA_MESSAGE; | 532 | GdkRectangle *r = rect+V3270_OIA_MESSAGE; |
| @@ -529,6 +540,10 @@ void v3270_draw_oia(cairo_t *cr, H3270 *host, int row, int cols, struct v3270_me | @@ -529,6 +540,10 @@ void v3270_draw_oia(cairo_t *cr, H3270 *host, int row, int cols, struct v3270_me | ||
| 529 | cairo_save(cr); | 540 | cairo_save(cr); |
| 530 | v3270_draw_ssl_status(cr,host,metrics,color,rect+V3270_OIA_SSL); | 541 | v3270_draw_ssl_status(cr,host,metrics,color,rect+V3270_OIA_SSL); |
| 531 | cairo_restore(cr); | 542 | cairo_restore(cr); |
| 543 | + | ||
| 544 | + cairo_save(cr); | ||
| 545 | + draw_insert(cr,host,color,rect+V3270_OIA_INSERT); | ||
| 546 | + cairo_restore(cr); | ||
| 532 | } | 547 | } |
| 533 | 548 | ||
| 534 | /** | 549 | /** |
| @@ -810,6 +825,23 @@ void v3270_draw_alt_status(v3270 *terminal) | @@ -810,6 +825,23 @@ void v3270_draw_alt_status(v3270 *terminal) | ||
| 810 | update_text_field(terminal,terminal->keyflags & KEY_FLAG_ALT,V3270_OIA_ALT,"A"); | 825 | update_text_field(terminal,terminal->keyflags & KEY_FLAG_ALT,V3270_OIA_ALT,"A"); |
| 811 | } | 826 | } |
| 812 | 827 | ||
| 828 | +void v3270_draw_ins_status(v3270 *terminal) | ||
| 829 | +{ | ||
| 830 | + GdkRectangle *r; | ||
| 831 | + cairo_t *cr; | ||
| 832 | + | ||
| 833 | + if(!terminal->surface) | ||
| 834 | + return; | ||
| 835 | + | ||
| 836 | + cr = set_update_region(terminal,&r,V3270_OIA_INSERT); | ||
| 837 | + | ||
| 838 | + draw_insert(cr,terminal->host,terminal->color,r); | ||
| 839 | + | ||
| 840 | + cairo_destroy(cr); | ||
| 841 | + gtk_widget_queue_draw_area(GTK_WIDGET(terminal),r->x,r->y,r->width,r->height); | ||
| 842 | + | ||
| 843 | +} | ||
| 844 | + | ||
| 813 | static gboolean update_timer(struct timer_info *info) | 845 | static gboolean update_timer(struct timer_info *info) |
| 814 | { | 846 | { |
| 815 | cairo_t * cr; | 847 | cairo_t * cr; |
src/gtk/v3270/private.h
| @@ -96,6 +96,7 @@ void v3270_draw_oia(cairo_t *cr, H3270 *host, int row, int cols, struct v327 | @@ -96,6 +96,7 @@ void v3270_draw_oia(cairo_t *cr, H3270 *host, int row, int cols, struct v327 | ||
| 96 | 96 | ||
| 97 | void v3270_draw_shift_status(v3270 *terminal); | 97 | void v3270_draw_shift_status(v3270 *terminal); |
| 98 | void v3270_draw_alt_status(v3270 *terminal); | 98 | void v3270_draw_alt_status(v3270 *terminal); |
| 99 | +void v3270_draw_ins_status(v3270 *terminal); | ||
| 99 | 100 | ||
| 100 | void v3270_update_cursor_surface(v3270 *widget,unsigned char chr,unsigned short attr); | 101 | void v3270_update_cursor_surface(v3270 *widget,unsigned char chr,unsigned short attr); |
| 101 | 102 |
src/gtk/v3270/widget.c
| @@ -111,6 +111,7 @@ static void v3270_toggle_changed(v3270 *widget,LIB3270_TOGGLE toggle_id, gboolea | @@ -111,6 +111,7 @@ static void v3270_toggle_changed(v3270 *widget,LIB3270_TOGGLE toggle_id, gboolea | ||
| 111 | break; | 111 | break; |
| 112 | 112 | ||
| 113 | case LIB3270_TOGGLE_INSERT: | 113 | case LIB3270_TOGGLE_INSERT: |
| 114 | + v3270_draw_ins_status(widget); | ||
| 114 | v3270_cursor_draw(widget); | 115 | v3270_cursor_draw(widget); |
| 115 | break; | 116 | break; |
| 116 | 117 |
src/include/lib3270.h
| @@ -294,17 +294,6 @@ | @@ -294,17 +294,6 @@ | ||
| 294 | LIB3270_EXPORT void lib3270_register_schange(H3270 *h,LIB3270_STATE tx, void (*func)(H3270 *, int, void *),void *data); | 294 | LIB3270_EXPORT void lib3270_register_schange(H3270 *h,LIB3270_STATE tx, void (*func)(H3270 *, int, void *),void *data); |
| 295 | 295 | ||
| 296 | /** | 296 | /** |
| 297 | - * Register a toggle change callback. | ||
| 298 | - * | ||
| 299 | - * @param h Session handle. | ||
| 300 | - * @param ix Toggle id | ||
| 301 | - * @param func Function to call when toggle changes. | ||
| 302 | - * | ||
| 303 | - * @return 0 if ok, EINVAL if the toggle id is invalid. | ||
| 304 | - */ | ||
| 305 | - LIB3270_EXPORT int lib3270_register_tchange(H3270 *h, LIB3270_TOGGLE ix, void (*func)(H3270 *h, int, LIB3270_TOGGLE_TYPE reason)); | ||
| 306 | - | ||
| 307 | - /** | ||
| 308 | * Network connect operation, keep main loop running | 297 | * Network connect operation, keep main loop running |
| 309 | * | 298 | * |
| 310 | * Sets 'reconnect_host', 'current_host' and 'full_current_host' as | 299 | * Sets 'reconnect_host', 'current_host' and 'full_current_host' as |
| @@ -431,10 +420,8 @@ | @@ -431,10 +420,8 @@ | ||
| 431 | * @param ix Toggle id. | 420 | * @param ix Toggle id. |
| 432 | * @param value New toggle state (non zero for true). | 421 | * @param value New toggle state (non zero for true). |
| 433 | * | 422 | * |
| 434 | - * @return 0 if the toggle wasn't changed, non zero if it was changed. | ||
| 435 | - * | ||
| 436 | */ | 423 | */ |
| 437 | - LIB3270_EXPORT int lib3270_set_toggle(H3270 *h, LIB3270_TOGGLE ix, int value); | 424 | + LIB3270_EXPORT void lib3270_set_toggle(H3270 *h, LIB3270_TOGGLE ix, int value); |
| 438 | 425 | ||
| 439 | /** | 426 | /** |
| 440 | * Translate a string toggle name to the corresponding value. | 427 | * Translate a string toggle name to the corresponding value. |
src/lib3270/appres.h
| @@ -30,13 +30,12 @@ struct toggle { | @@ -30,13 +30,12 @@ struct toggle { | ||
| 30 | // Widget w[2]; /* the menu item widgets */ | 30 | // Widget w[2]; /* the menu item widgets */ |
| 31 | // const char *label[2]; /* labels */ | 31 | // const char *label[2]; /* labels */ |
| 32 | void (*upcall)(H3270 *, struct toggle *, LIB3270_TOGGLE_TYPE); /* change value */ | 32 | void (*upcall)(H3270 *, struct toggle *, LIB3270_TOGGLE_TYPE); /* change value */ |
| 33 | - void (*callback)(H3270 *, int, LIB3270_TOGGLE_TYPE); | 33 | +// void (*callback)(H3270 *, int, LIB3270_TOGGLE_TYPE); |
| 34 | 34 | ||
| 35 | }; | 35 | }; |
| 36 | 36 | ||
| 37 | #define toggled(ix) (appres.toggle[ix].value) | 37 | #define toggled(ix) (appres.toggle[ix].value) |
| 38 | -#define toggle_toggle(t) \ | ||
| 39 | - { (t)->value = !(t)->value; } | 38 | +// #define toggle_toggle(t) { (t)->value = !(t)->value; } |
| 40 | 39 | ||
| 41 | /* Application resources */ | 40 | /* Application resources */ |
| 42 | 41 |
src/lib3270/kybd.c
| @@ -18,7 +18,7 @@ | @@ -18,7 +18,7 @@ | ||
| 18 | * programa; se não, escreva para a Free Software Foundation, Inc., 59 Temple | 18 | * programa; se não, escreva para a Free Software Foundation, Inc., 59 Temple |
| 19 | * Place, Suite 330, Boston, MA, 02111-1307, USA | 19 | * Place, Suite 330, Boston, MA, 02111-1307, USA |
| 20 | * | 20 | * |
| 21 | - * Este programa está nomeado como kybd.c e possui 4414 linhas de código. | 21 | + * Este programa está nomeado como kybd.c e possui - linhas de código. |
| 22 | * | 22 | * |
| 23 | * Contatos: | 23 | * Contatos: |
| 24 | * | 24 | * |
| @@ -98,8 +98,7 @@ static unsigned char pa_xlate[] = { | @@ -98,8 +98,7 @@ static unsigned char pa_xlate[] = { | ||
| 98 | static unsigned long unlock_id; | 98 | static unsigned long unlock_id; |
| 99 | static time_t unlock_delay_time; | 99 | static time_t unlock_delay_time; |
| 100 | #define UNLOCK_MS 350 /* 0.35s after last unlock */ | 100 | #define UNLOCK_MS 350 /* 0.35s after last unlock */ |
| 101 | -static Boolean key_Character(int code, Boolean with_ge, Boolean pasting, | ||
| 102 | - Boolean *skipped); | 101 | +static Boolean key_Character(int code, Boolean with_ge, Boolean pasting,Boolean *skipped); |
| 103 | static Boolean flush_ta(void); | 102 | static Boolean flush_ta(void); |
| 104 | static void key_AID(unsigned char aid_code); | 103 | static void key_AID(unsigned char aid_code); |
| 105 | static void kybdlock_set(unsigned int bits, const char *cause); | 104 | static void kybdlock_set(unsigned int bits, const char *cause); |
| @@ -527,10 +526,11 @@ key_AID(unsigned char aid_code) | @@ -527,10 +526,11 @@ key_AID(unsigned char aid_code) | ||
| 527 | /* Act as if the host had written our input. */ | 526 | /* Act as if the host had written our input. */ |
| 528 | h3270.buffer_addr = h3270.cursor_addr; | 527 | h3270.buffer_addr = h3270.cursor_addr; |
| 529 | } | 528 | } |
| 530 | - if (!IN_SSCP || aid_code != AID_CLEAR) { | 529 | + if (!IN_SSCP || aid_code != AID_CLEAR) |
| 530 | + { | ||
| 531 | status_twait(&h3270); | 531 | status_twait(&h3270); |
| 532 | mcursor_waiting(&h3270); | 532 | mcursor_waiting(&h3270); |
| 533 | - set_toggle(INSERT,0); | 533 | + lib3270_set_toggle(&h3270,LIB3270_TOGGLE_INSERT,0); |
| 534 | kybdlock_set(KL_OIA_TWAIT | KL_OIA_LOCKED, "key_AID"); | 534 | kybdlock_set(KL_OIA_TWAIT | KL_OIA_LOCKED, "key_AID"); |
| 535 | } | 535 | } |
| 536 | aid = aid_code; | 536 | aid = aid_code; |
| @@ -745,15 +745,12 @@ key_Character_wrapper(Widget w unused, XEvent *event unused, String *params, | @@ -745,15 +745,12 @@ key_Character_wrapper(Widget w unused, XEvent *event unused, String *params, | ||
| 745 | * Handle an ordinary displayable character key. Lots of stuff to handle | 745 | * Handle an ordinary displayable character key. Lots of stuff to handle |
| 746 | * insert-mode, protected fields and etc. | 746 | * insert-mode, protected fields and etc. |
| 747 | */ | 747 | */ |
| 748 | -static Boolean | ||
| 749 | -key_Character(int code, Boolean with_ge, Boolean pasting, Boolean *skipped) | 748 | +static Boolean key_Character(int code, Boolean with_ge, Boolean pasting, Boolean *skipped) |
| 750 | { | 749 | { |
| 751 | register int baddr, faddr, xaddr; | 750 | register int baddr, faddr, xaddr; |
| 752 | register unsigned char fa; | 751 | register unsigned char fa; |
| 753 | enum dbcs_why why; | 752 | enum dbcs_why why; |
| 754 | 753 | ||
| 755 | -// reset_idle_timer(); | ||
| 756 | - | ||
| 757 | if (skipped != NULL) | 754 | if (skipped != NULL) |
| 758 | *skipped = False; | 755 | *skipped = False; |
| 759 | 756 | ||
| @@ -798,7 +795,7 @@ key_Character(int code, Boolean with_ge, Boolean pasting, Boolean *skipped) | @@ -798,7 +795,7 @@ key_Character(int code, Boolean with_ge, Boolean pasting, Boolean *skipped) | ||
| 798 | /* Add the character. */ | 795 | /* Add the character. */ |
| 799 | if (h3270.ea_buf[baddr].cc == EBC_so) { | 796 | if (h3270.ea_buf[baddr].cc == EBC_so) { |
| 800 | 797 | ||
| 801 | - if (toggled(INSERT)) { | 798 | + if (toggled(LIB3270_TOGGLE_INSERT)) { |
| 802 | if (!ins_prep(faddr, baddr, 1)) | 799 | if (!ins_prep(faddr, baddr, 1)) |
| 803 | return False; | 800 | return False; |
| 804 | } else { | 801 | } else { |
| @@ -835,7 +832,7 @@ key_Character(int code, Boolean with_ge, Boolean pasting, Boolean *skipped) | @@ -835,7 +832,7 @@ key_Character(int code, Boolean with_ge, Boolean pasting, Boolean *skipped) | ||
| 835 | /* fall through... */ | 832 | /* fall through... */ |
| 836 | case DBCS_LEFT: | 833 | case DBCS_LEFT: |
| 837 | if (why == DBCS_ATTRIBUTE) { | 834 | if (why == DBCS_ATTRIBUTE) { |
| 838 | - if (toggled(INSERT)) { | 835 | + if (toggled(LIB3270_TOGGLE_INSERT)) { |
| 839 | if (!ins_prep(faddr, baddr, 1)) | 836 | if (!ins_prep(faddr, baddr, 1)) |
| 840 | return False; | 837 | return False; |
| 841 | } else { | 838 | } else { |
| @@ -852,7 +849,7 @@ key_Character(int code, Boolean with_ge, Boolean pasting, Boolean *skipped) | @@ -852,7 +849,7 @@ key_Character(int code, Boolean with_ge, Boolean pasting, Boolean *skipped) | ||
| 852 | } else { | 849 | } else { |
| 853 | Boolean was_si; | 850 | Boolean was_si; |
| 854 | 851 | ||
| 855 | - if (toggled(INSERT)) { | 852 | + if (toggled(LIB3270_TOGGLE_INSERT)) { |
| 856 | /* | 853 | /* |
| 857 | * Inserting SBCS into a DBCS subfield. | 854 | * Inserting SBCS into a DBCS subfield. |
| 858 | * If this is the first position, we | 855 | * If this is the first position, we |
| @@ -909,7 +906,7 @@ key_Character(int code, Boolean with_ge, Boolean pasting, Boolean *skipped) | @@ -909,7 +906,7 @@ key_Character(int code, Boolean with_ge, Boolean pasting, Boolean *skipped) | ||
| 909 | break; | 906 | break; |
| 910 | default: | 907 | default: |
| 911 | case DBCS_NONE: | 908 | case DBCS_NONE: |
| 912 | - if (toggled(INSERT) && !ins_prep(faddr, baddr, 1)) | 909 | + if (toggled(LIB3270_TOGGLE_INSERT) && !ins_prep(faddr, baddr, 1)) |
| 913 | return False; | 910 | return False; |
| 914 | break; | 911 | break; |
| 915 | } | 912 | } |
| @@ -1292,73 +1289,28 @@ retry: | @@ -1292,73 +1289,28 @@ retry: | ||
| 1292 | */ | 1289 | */ |
| 1293 | void key_ACharacter(unsigned char c, enum keytype keytype, enum iaction cause,Boolean *skipped) | 1290 | void key_ACharacter(unsigned char c, enum keytype keytype, enum iaction cause,Boolean *skipped) |
| 1294 | { | 1291 | { |
| 1295 | -// register int i; | ||
| 1296 | -// struct akeysym ak; | ||
| 1297 | - | ||
| 1298 | -// reset_idle_timer(); | ||
| 1299 | - | ||
| 1300 | if (skipped != NULL) | 1292 | if (skipped != NULL) |
| 1301 | *skipped = False; | 1293 | *skipped = False; |
| 1302 | 1294 | ||
| 1303 | -// ak.keysym = c; | ||
| 1304 | -// ak.keytype = keytype; | 1295 | + trace_event(" %s -> Key(\"%s\")\n",ia_name[(int) cause], ctl_see((int) c)); |
| 1305 | 1296 | ||
| 1306 | -/* | ||
| 1307 | - switch (composing) { | ||
| 1308 | - case NONE: | ||
| 1309 | - break; | ||
| 1310 | - case COMPOSE: | ||
| 1311 | - for (i = 0; i < n_composites; i++) | ||
| 1312 | - if (ak_eq(composites[i].k1, ak) || | ||
| 1313 | - ak_eq(composites[i].k2, ak)) | ||
| 1314 | - break; | ||
| 1315 | - if (i < n_composites) { | ||
| 1316 | - cc_first.keysym = c; | ||
| 1317 | - cc_first.keytype = keytype; | ||
| 1318 | - composing = FIRST; | ||
| 1319 | - status_compose(True, c, keytype); | ||
| 1320 | - } else { | ||
| 1321 | - lib3270_ring_bell(); | ||
| 1322 | - composing = NONE; | ||
| 1323 | - status_compose(False, 0, KT_STD); | ||
| 1324 | - } | ||
| 1325 | - return; | ||
| 1326 | - case FIRST: | ||
| 1327 | - composing = NONE; | ||
| 1328 | - status_compose(False, 0, KT_STD); | ||
| 1329 | - for (i = 0; i < n_composites; i++) | ||
| 1330 | - if ((ak_eq(composites[i].k1, cc_first) && | ||
| 1331 | - ak_eq(composites[i].k2, ak)) || | ||
| 1332 | - (ak_eq(composites[i].k1, ak) && | ||
| 1333 | - ak_eq(composites[i].k2, cc_first))) | ||
| 1334 | - break; | ||
| 1335 | - if (i < n_composites) { | ||
| 1336 | - c = composites[i].translation.keysym; | ||
| 1337 | - keytype = composites[i].translation.keytype; | ||
| 1338 | - } else { | ||
| 1339 | - lib3270_ring_bell(); | ||
| 1340 | - return; | ||
| 1341 | - } | ||
| 1342 | - break; | ||
| 1343 | - } | ||
| 1344 | -*/ | ||
| 1345 | - | ||
| 1346 | - trace_event(" %s -> Key(\"%s\")\n", | ||
| 1347 | - ia_name[(int) cause], ctl_see((int) c)); | ||
| 1348 | - if (IN_3270) { | ||
| 1349 | - if (c < ' ') { | 1297 | + if (IN_3270) |
| 1298 | + { | ||
| 1299 | + if (c < ' ') | ||
| 1300 | + { | ||
| 1350 | trace_event(" dropped (control char)\n"); | 1301 | trace_event(" dropped (control char)\n"); |
| 1351 | return; | 1302 | return; |
| 1352 | } | 1303 | } |
| 1353 | - (void) key_Character((int) asc2ebc[c], keytype == KT_GE, False, | ||
| 1354 | - skipped); | 1304 | + (void) key_Character((int) asc2ebc[c], keytype == KT_GE, False, skipped); |
| 1355 | } | 1305 | } |
| 1356 | #if defined(X3270_ANSI) /*[*/ | 1306 | #if defined(X3270_ANSI) /*[*/ |
| 1357 | - else if (IN_ANSI) { | 1307 | + else if (IN_ANSI) |
| 1308 | + { | ||
| 1358 | net_sendc((char) c); | 1309 | net_sendc((char) c); |
| 1359 | } | 1310 | } |
| 1360 | #endif /*]*/ | 1311 | #endif /*]*/ |
| 1361 | - else { | 1312 | + else |
| 1313 | + { | ||
| 1362 | trace_event(" dropped (not connected)\n"); | 1314 | trace_event(" dropped (not connected)\n"); |
| 1363 | } | 1315 | } |
| 1364 | } | 1316 | } |
| @@ -1533,7 +1485,7 @@ do_reset(Boolean explicit) | @@ -1533,7 +1485,7 @@ do_reset(Boolean explicit) | ||
| 1533 | } | 1485 | } |
| 1534 | 1486 | ||
| 1535 | /* Always clear insert mode. */ | 1487 | /* Always clear insert mode. */ |
| 1536 | - set_toggle(INSERT,0); | 1488 | + lib3270_set_toggle(&h3270,LIB3270_TOGGLE_INSERT,0); |
| 1537 | 1489 | ||
| 1538 | /* Otherwise, if not connect, reset is a no-op. */ | 1490 | /* Otherwise, if not connect, reset is a no-op. */ |
| 1539 | if (!CONNECTED) | 1491 | if (!CONNECTED) |
src/lib3270/paste.c
| @@ -133,14 +133,14 @@ | @@ -133,14 +133,14 @@ | ||
| 133 | return -1; | 133 | return -1; |
| 134 | } | 134 | } |
| 135 | 135 | ||
| 136 | - static int paste_char(PASTE_DATA *data, unsigned char c) | 136 | + static int paste_char(H3270 *session, PASTE_DATA *data, unsigned char c) |
| 137 | { | 137 | { |
| 138 | 138 | ||
| 139 | if(toggled(SMART_PASTE)) | 139 | if(toggled(SMART_PASTE)) |
| 140 | { | 140 | { |
| 141 | - int faddr = find_field_attribute(&h3270,h3270.cursor_addr); | ||
| 142 | - if(FA_IS_PROTECTED(h3270.ea_buf[faddr].fa)) | ||
| 143 | - h3270.cursor_addr++; | 141 | + int faddr = find_field_attribute(session,session->cursor_addr); |
| 142 | + if(FA_IS_PROTECTED(session->ea_buf[faddr].fa)) | ||
| 143 | + session->cursor_addr++; | ||
| 144 | else | 144 | else |
| 145 | key_ACharacter(c, KT_STD, IA_PASTE, NULL); | 145 | key_ACharacter(c, KT_STD, IA_PASTE, NULL); |
| 146 | } | 146 | } |
| @@ -197,7 +197,7 @@ LIB3270_EXPORT int lib3270_set_string(H3270 *h, const unsigned char *str) | @@ -197,7 +197,7 @@ LIB3270_EXPORT int lib3270_set_string(H3270 *h, const unsigned char *str) | ||
| 197 | switch(*str) | 197 | switch(*str) |
| 198 | { | 198 | { |
| 199 | case '\t': | 199 | case '\t': |
| 200 | - last = paste_char(&data, ' '); | 200 | + last = paste_char(h,&data, ' '); |
| 201 | break; | 201 | break; |
| 202 | 202 | ||
| 203 | case '\n': | 203 | case '\n': |
| @@ -218,7 +218,7 @@ LIB3270_EXPORT int lib3270_set_string(H3270 *h, const unsigned char *str) | @@ -218,7 +218,7 @@ LIB3270_EXPORT int lib3270_set_string(H3270 *h, const unsigned char *str) | ||
| 218 | break; | 218 | break; |
| 219 | 219 | ||
| 220 | default: | 220 | default: |
| 221 | - last = paste_char(&data, *str); | 221 | + last = paste_char(h,&data, *str); |
| 222 | 222 | ||
| 223 | } | 223 | } |
| 224 | str++; | 224 | str++; |
src/lib3270/toggle.h
| @@ -59,14 +59,14 @@ | @@ -59,14 +59,14 @@ | ||
| 59 | #define AID_WAIT LIB3270_TOGGLE_AID_WAIT | 59 | #define AID_WAIT LIB3270_TOGGLE_AID_WAIT |
| 60 | #define FULL_SCREEN LIB3270_TOGGLE_FULL_SCREEN | 60 | #define FULL_SCREEN LIB3270_TOGGLE_FULL_SCREEN |
| 61 | #define RECONNECT LIB3270_TOGGLE_RECONNECT | 61 | #define RECONNECT LIB3270_TOGGLE_RECONNECT |
| 62 | - #define INSERT LIB3270_TOGGLE_INSERT | 62 | +// #define INSERT LIB3270_TOGGLE_INSERT |
| 63 | #define KEYPAD LIB3270_TOGGLE_KEYPAD | 63 | #define KEYPAD LIB3270_TOGGLE_KEYPAD |
| 64 | #define SMART_PASTE LIB3270_TOGGLE_SMART_PASTE | 64 | #define SMART_PASTE LIB3270_TOGGLE_SMART_PASTE |
| 65 | #define N_TOGGLES LIB3270_TOGGLE_COUNT | 65 | #define N_TOGGLES LIB3270_TOGGLE_COUNT |
| 66 | 66 | ||
| 67 | #define LIB3270_TOGGLE_ID LIB3270_TOGGLE | 67 | #define LIB3270_TOGGLE_ID LIB3270_TOGGLE |
| 68 | 68 | ||
| 69 | - #define register_3270_toggle_monitor(ix,callback) lib3270_register_tchange(NULL,ix,callback) | 69 | +// #define register_3270_toggle_monitor(ix,callback) lib3270_register_tchange(NULL,ix,callback) |
| 70 | #define get_3270_toggle_by_name(x) lib3270_get_toggle_id(x) | 70 | #define get_3270_toggle_by_name(x) lib3270_get_toggle_id(x) |
| 71 | 71 | ||
| 72 | // Compatibility macros | 72 | // Compatibility macros |
| @@ -75,7 +75,7 @@ | @@ -75,7 +75,7 @@ | ||
| 75 | 75 | ||
| 76 | #define get_3270_toggle_name(ix) lib3270_get_toggle_name(ix) | 76 | #define get_3270_toggle_name(ix) lib3270_get_toggle_name(ix) |
| 77 | #define get_toggle_name(ix) lib3270_get_toggle_name(ix) | 77 | #define get_toggle_name(ix) lib3270_get_toggle_name(ix) |
| 78 | - #define set_toggle(ix,value) lib3270_set_toggle(NULL,ix,value) | 78 | +// #define set_toggle(ix,value) lib3270_set_toggle(NULL,ix,value) |
| 79 | #define get_toggle_by_name(name) lib3270_get_toggle_id(name) | 79 | #define get_toggle_by_name(name) lib3270_get_toggle_id(name) |
| 80 | 80 | ||
| 81 | #endif /* TOGGLE3270_H_INCLUDED */ | 81 | #endif /* TOGGLE3270_H_INCLUDED */ |
src/lib3270/toggles.c
| @@ -79,6 +79,7 @@ static const char *toggle_names[LIB3270_TOGGLE_COUNT] = | @@ -79,6 +79,7 @@ static const char *toggle_names[LIB3270_TOGGLE_COUNT] = | ||
| 79 | }; | 79 | }; |
| 80 | 80 | ||
| 81 | 81 | ||
| 82 | +/* | ||
| 82 | static void no_callback(H3270 *h, int value, LIB3270_TOGGLE_TYPE reason) | 83 | static void no_callback(H3270 *h, int value, LIB3270_TOGGLE_TYPE reason) |
| 83 | { | 84 | { |
| 84 | } | 85 | } |
| @@ -106,6 +107,7 @@ LIB3270_EXPORT int lib3270_register_tchange(H3270 *h, LIB3270_TOGGLE_ID ix, void | @@ -106,6 +107,7 @@ LIB3270_EXPORT int lib3270_register_tchange(H3270 *h, LIB3270_TOGGLE_ID ix, void | ||
| 106 | 107 | ||
| 107 | return 0; | 108 | return 0; |
| 108 | } | 109 | } |
| 110 | +*/ | ||
| 109 | 111 | ||
| 110 | LIB3270_EXPORT unsigned char lib3270_get_toggle(H3270 *session, LIB3270_TOGGLE ix) | 112 | LIB3270_EXPORT unsigned char lib3270_get_toggle(H3270 *session, LIB3270_TOGGLE ix) |
| 111 | { | 113 | { |
| @@ -117,54 +119,46 @@ LIB3270_EXPORT unsigned char lib3270_get_toggle(H3270 *session, LIB3270_TOGGLE i | @@ -117,54 +119,46 @@ LIB3270_EXPORT unsigned char lib3270_get_toggle(H3270 *session, LIB3270_TOGGLE i | ||
| 117 | } | 119 | } |
| 118 | 120 | ||
| 119 | /* | 121 | /* |
| 120 | - * Generic toggle stuff | 122 | + * Call the internal update routine |
| 121 | */ | 123 | */ |
| 122 | -static void do_toggle_reason(H3270 *session, LIB3270_TOGGLE ix, LIB3270_TOGGLE_TYPE reason) | 124 | +static void toggle_notify(H3270 *session, struct toggle *t, LIB3270_TOGGLE ix) |
| 123 | { | 125 | { |
| 124 | - struct toggle *t = &appres.toggle[ix]; | ||
| 125 | - | ||
| 126 | - /* | ||
| 127 | - * Change the value, call the internal update routine, and reset the | ||
| 128 | - * menu label(s). | ||
| 129 | - */ | ||
| 130 | - toggle_toggle(t); | ||
| 131 | - t->upcall(session, t, reason); | ||
| 132 | - t->callback(session,t->value, (int) reason); | 126 | + t->upcall(session, t, TT_INTERACTIVE); |
| 127 | +// t->callback(session,t->value, (int) TT_INTERACTIVE); | ||
| 133 | 128 | ||
| 134 | if(session->update_toggle) | 129 | if(session->update_toggle) |
| 135 | - session->update_toggle(session,ix,t->value,reason,toggle_names[ix]); | 130 | + session->update_toggle(session,ix,t->value,TT_INTERACTIVE,toggle_names[ix]); |
| 136 | 131 | ||
| 137 | } | 132 | } |
| 138 | 133 | ||
| 139 | -LIB3270_EXPORT int lib3270_set_toggle(H3270 *session, LIB3270_TOGGLE ix, int value) | 134 | +LIB3270_EXPORT void lib3270_set_toggle(H3270 *session, LIB3270_TOGGLE ix, int value) |
| 140 | { | 135 | { |
| 141 | - Boolean v = ((Boolean) (value != 0)); // Convert int in Boolean | ||
| 142 | - | ||
| 143 | struct toggle *t; | 136 | struct toggle *t; |
| 144 | 137 | ||
| 145 | CHECK_SESSION_HANDLE(session); | 138 | CHECK_SESSION_HANDLE(session); |
| 146 | 139 | ||
| 147 | if(ix < 0 || ix >= LIB3270_TOGGLE_COUNT) | 140 | if(ix < 0 || ix >= LIB3270_TOGGLE_COUNT) |
| 148 | - return 0; | 141 | + return; |
| 149 | 142 | ||
| 150 | t = &appres.toggle[ix]; | 143 | t = &appres.toggle[ix]; |
| 144 | + t->value = (value != 0); | ||
| 151 | 145 | ||
| 152 | - if(t->value == v) | ||
| 153 | - return 0; | ||
| 154 | - | ||
| 155 | - do_toggle_reason(session, ix, TT_INTERACTIVE); | ||
| 156 | - | ||
| 157 | - return -1; | 146 | + toggle_notify(session,t,ix); |
| 158 | } | 147 | } |
| 159 | 148 | ||
| 160 | LIB3270_EXPORT int lib3270_toggle(H3270 *session, LIB3270_TOGGLE ix) | 149 | LIB3270_EXPORT int lib3270_toggle(H3270 *session, LIB3270_TOGGLE ix) |
| 161 | { | 150 | { |
| 151 | + struct toggle *t; | ||
| 152 | + | ||
| 162 | CHECK_SESSION_HANDLE(session); | 153 | CHECK_SESSION_HANDLE(session); |
| 163 | 154 | ||
| 164 | if(ix < 0 || ix >= LIB3270_TOGGLE_COUNT) | 155 | if(ix < 0 || ix >= LIB3270_TOGGLE_COUNT) |
| 165 | - return EINVAL; | 156 | + return; |
| 157 | + | ||
| 158 | + t = &appres.toggle[ix]; | ||
| 166 | 159 | ||
| 167 | - do_toggle_reason(session, ix, TT_INTERACTIVE); | 160 | + t->value = !t->value; |
| 161 | + toggle_notify(session,t,ix); | ||
| 168 | 162 | ||
| 169 | return 0; | 163 | return 0; |
| 170 | } | 164 | } |
| @@ -183,7 +177,7 @@ void initialize_toggles(H3270 *session, struct toggle *toggle) | @@ -183,7 +177,7 @@ void initialize_toggles(H3270 *session, struct toggle *toggle) | ||
| 183 | 177 | ||
| 184 | for(f=0;f<LIB3270_TOGGLE_COUNT;f++) | 178 | for(f=0;f<LIB3270_TOGGLE_COUNT;f++) |
| 185 | { | 179 | { |
| 186 | - toggle[f].callback = no_callback; | 180 | +// toggle[f].callback = no_callback; |
| 187 | toggle[f].upcall = toggle_nop; | 181 | toggle[f].upcall = toggle_nop; |
| 188 | } | 182 | } |
| 189 | 183 |