From 88d395877e54b986ebc4dd96b2050af208429471 Mon Sep 17 00:00:00 2001 From: perry.werneck@gmail.com Date: Mon, 12 Mar 2012 13:36:03 +0000 Subject: [PATCH] Unificando controle de toggles --- XtGlue.c | 4 +++- ansi.c | 2 +- glue.c | 26 +------------------------- kybd.c | 3 ++- screen.c | 13 ------------- selection.c | 40 +++++++++++++++++++++++++++++++++++++++- toggles.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++++------------------- togglesc.h | 2 +- 8 files changed, 95 insertions(+), 62 deletions(-) diff --git a/XtGlue.c b/XtGlue.c index e6c1d6c..34a00dd 100644 --- a/XtGlue.c +++ b/XtGlue.c @@ -1002,7 +1002,9 @@ LIB3270_EXPORT int lib3270_wait(seconds) LIB3270_EXPORT void lib3270_ring_bell(H3270 *session) { CHECK_SESSION_HANDLE(session); - callbacks->ring_bell(session); + + if(lib3270_get_toggle(session,LIB3270_TOGGLE_BEEP)) + callbacks->ring_bell(session); } diff --git a/ansi.c b/ansi.c index afb7a5d..218ced9 100644 --- a/ansi.c +++ b/ansi.c @@ -1827,7 +1827,7 @@ ansi_send_pa(int nn) void toggle_lineWrap(H3270 *session, struct toggle *t unused, LIB3270_TOGGLE_TYPE type unused) { - if (toggled(LINE_WRAP)) + if (toggled(LIB3270_TOGGLE_LINE_WRAP)) wraparound_mode = 1; else wraparound_mode = 0; diff --git a/glue.c b/glue.c index fea472b..fd08dc8 100644 --- a/glue.c +++ b/glue.c @@ -117,31 +117,6 @@ char *profile_name = CN; #endif /*]*/ -const char *toggle_names[N_TOGGLES] = -{ - "Monocase", - "AltCursor", - "CursorBlink", - "ShowTiming", - "CursorPos", - "DSTrace", - "ScrollBar", - "LineWrap", - "BlankFill", - "ScreenTrace", - "EventTrace", - "MarginedPaste", - "RectSelect", - "CrossHair", - "VisibleControl", - "AidWait", - "FullScreen", - "Reconnect", - "Insert", - "Keypad", - "SmartPaste" -}; - void lib3270_session_free(H3270 *h) { int f; @@ -319,6 +294,7 @@ static void initialize(void) Trace("Initializing library (calls: %d)",init_calls); #endif + h3270.selected.begin = h3270.selected.end = -1; initialize_toggles(&h3270,appres.toggle); #if defined(_WIN32) diff --git a/kybd.c b/kybd.c index c26f1e8..7fbe2c9 100644 --- a/kybd.c +++ b/kybd.c @@ -651,7 +651,7 @@ static Boolean ins_prep(int faddr, int baddr, int count) while (need && (xaddr != next_faddr)) { if (ea_buf[xaddr].cc == EBC_null) need--; - else if (toggled(BLANK_FILL) && + else if (toggled(LIB3270_TOGGLE_BLANK_FILL) && ((ea_buf[xaddr].cc == EBC_space) || (ea_buf[xaddr].cc == EBC_underscore))) { if (tb_start == -1) @@ -3653,3 +3653,4 @@ clear_xks(void) } } + diff --git a/screen.c b/screen.c index b7a9196..f7c0532 100644 --- a/screen.c +++ b/screen.c @@ -735,19 +735,6 @@ void popup_system_error(H3270 *session, const char *title, const char *message, va_end(args); } -/* -LIB3270_EXPORT void update_toggle_actions(void) -{ - int f; - - if(callbacks && callbacks->toggle_changed) - { - for(f=0;f< N_TOGGLES;f++) - callbacks->toggle_changed(&h3270,f,appres.toggle[f].value,TT_UPDATE,toggle_names[f]); - } -} -*/ - void mcursor_set(H3270 *session,LIB3270_CURSOR m) { CHECK_SESSION_HANDLE(session); diff --git a/selection.c b/selection.c index abf30d0..6cfe59a 100644 --- a/selection.c +++ b/selection.c @@ -219,7 +219,7 @@ LIB3270_EXPORT void lib3270_select_word(H3270 *session, int baddr) update_selected_region(session); } -LIB3270_EXPORT int lib3270_select_field(H3270 *session, int baddr) +LIB3270_EXPORT int lib3270_select_field_at(H3270 *session, int baddr) { int start,len; @@ -251,3 +251,41 @@ LIB3270_EXPORT int lib3270_select_field(H3270 *session, int baddr) return 0; } + +LIB3270_ACTION( selectfield ) +{ + lib3270_select_field_at(hSession,hSession->cursor_addr); +} + +LIB3270_ACTION( selectall ) +{ + int len = hSession->rows*hSession->cols; + int baddr; + + // First remove unselected areas + for(baddr = 0; baddr < len; baddr++) + { + if(!(ea_buf[baddr].attr & LIB3270_ATTR_SELECTED)) + { + ea_buf[baddr].attr |= LIB3270_ATTR_SELECTED; + hSession->update(hSession,baddr,ea_buf[baddr].chr,ea_buf[baddr].attr,baddr == hSession->cursor_addr); + } + } +} + +LIB3270_ACTION( unselect ) +{ + int len = hSession->rows*hSession->cols; + int baddr; + + // First remove unselected areas + for(baddr = 0; baddr < len; baddr++) + { + if(ea_buf[baddr].attr & LIB3270_ATTR_SELECTED) + { + ea_buf[baddr].attr &= ~LIB3270_ATTR_SELECTED; + hSession->update(hSession,baddr,ea_buf[baddr].chr,ea_buf[baddr].attr,baddr == hSession->cursor_addr); + } + } +} + diff --git a/toggles.c b/toggles.c index 6c58e6d..0b6f959 100644 --- a/toggles.c +++ b/toggles.c @@ -52,6 +52,33 @@ +static const char *toggle_names[LIB3270_TOGGLE_COUNT] = +{ + "monocase", + "cursorblink", + "showtiming", + "cursorpos", + "dstrace", + "linewrap", + "blankfill", + "screentrace", + "eventtrace", + "marginedpaste", + "rectselect", + "crosshair", + "fullscreen", + "reconnect", + "insert", + "smartpaste", + "bold", + "keepselected", + "underline", + "autoconnect", + "kpalternative", /**< Keypad +/- move to next/previous field */ + "beep", /**< Beep on errors */ +}; + + static void no_callback(H3270 *h, int value, LIB3270_TOGGLE_TYPE reason) { } @@ -154,7 +181,7 @@ void initialize_toggles(H3270 *session, struct toggle *toggle) { int f; - for(f=0;f