diff --git a/src/core/actions/table.c b/src/core/actions/table.c index 653d1d4..e3b14bf 100644 --- a/src/core/actions/table.c +++ b/src/core/actions/table.c @@ -260,8 +260,8 @@ .summary = N_( "Paste file." ), .activate = paste_file, - .group = LIB3270_ACTION_GROUP_ONLINE, - .activatable = lib3270_is_connected + .group = LIB3270_ACTION_GROUP_LOCK_STATE, + .activatable = lib3270_is_unlocked }, // @@ -397,8 +397,8 @@ .summary = N_( "Backspaces the cursor until it hits the front of a word." ), .activate = lib3270_deleteword, - .group = LIB3270_ACTION_GROUP_ONLINE, - .activatable = lib3270_is_connected + .group = LIB3270_ACTION_GROUP_LOCK_STATE, + .activatable = lib3270_is_unlocked }, { @@ -411,8 +411,8 @@ .summary = N_( "Delete field" ), .activate = lib3270_deletefield, - .group = LIB3270_ACTION_GROUP_ONLINE, - .activatable = lib3270_is_formatted + .group = LIB3270_ACTION_GROUP_LOCK_STATE, + .activatable = lib3270_is_unlocked }, @@ -613,8 +613,8 @@ .summary = NULL, .activate = lib3270_paste_next, - .group = LIB3270_ACTION_GROUP_ONLINE, - .activatable = lib3270_is_connected + .group = LIB3270_ACTION_GROUP_LOCK_STATE, + .activatable = lib3270_is_unlocked }, { diff --git a/src/core/keyboard/kybd.c b/src/core/keyboard/kybd.c index f6f0a73..7603711 100644 --- a/src/core/keyboard/kybd.c +++ b/src/core/keyboard/kybd.c @@ -325,7 +325,7 @@ static void kybdlock_set(H3270 *hSession, unsigned int bits) #endif if ((hSession->kybdlock ^ bits) & KL_DEFERRED_UNLOCK) { - /* Turned on deferred unlock. */ + // Turned on deferred unlock. hSession->unlock_delay_time = time(NULL); } hSession->kybdlock = n; @@ -498,7 +498,7 @@ static void key_AID(H3270 *hSession, unsigned char aid_code) if (!IN_SSCP || aid_code != AID_CLEAR) { status_twait(hSession); - mcursor_waiting(hSession); + mcursor_set(hSession,LIB3270_POINTER_WAITING); lib3270_set_toggle(hSession,LIB3270_TOGGLE_INSERT,0); kybdlock_set(hSession,KL_OIA_TWAIT | KL_OIA_LOCKED); } @@ -1073,7 +1073,7 @@ void do_reset(H3270 *hSession, Boolean explicit) /* Clean up other modes. */ status_reset(hSession); - mcursor_normal(hSession); + mcursor_set(hSession,LIB3270_POINTER_UNLOCKED); } diff --git a/src/core/screen.c b/src/core/screen.c index 3b95c47..f311082 100644 --- a/src/core/screen.c +++ b/src/core/screen.c @@ -830,15 +830,16 @@ void popup_system_error(H3270 *session, const char *title, const char *message, va_end(args); } -void mcursor_set(H3270 *session,LIB3270_POINTER m) +void mcursor_set(H3270 *hSession,LIB3270_POINTER m) { - CHECK_SESSION_HANDLE(session); - - if(session->pointer != ((unsigned short) m)) { + if(hSession->pointer != ((unsigned short) m)) { // Pointer changed - session->pointer = (unsigned short) m; - session->cbk.cursor(session,m & 0x03); + hSession->pointer = (unsigned short) m; + hSession->cbk.cursor(hSession,m & 0x03); + + // Notify lock state change. + lib3270_notify_actions(hSession, LIB3270_ACTION_GROUP_LOCK_STATE); } } diff --git a/src/core/state.c b/src/core/state.c index ccd46d8..4f9f40f 100644 --- a/src/core/state.c +++ b/src/core/state.c @@ -86,4 +86,9 @@ LIB3270_EXPORT int lib3270_in_e(const H3270 *h) return (h->connection.state >= LIB3270_CONNECTED_INITIAL_E); } +LIB3270_EXPORT int lib3270_is_unlocked(const H3270 *h) +{ + return h->pointer == LIB3270_POINTER_UNLOCKED; +} + diff --git a/src/include/lib3270.h b/src/include/lib3270.h index 9c61ddb..292c946 100644 --- a/src/include/lib3270.h +++ b/src/include/lib3270.h @@ -51,7 +51,7 @@ #define LIB3270_AUTOPTR_FUNC_NAME(TypeName) lib3270_autoptr_cleanup_##TypeName #define lib3270_autoptr(TypeName) TypeName * __attribute__ ((__cleanup__(LIB3270_AUTOPTR_FUNC_NAME(TypeName)))) - + #endif // __GNUC__ #if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1) || defined (__clang__) @@ -218,9 +218,9 @@ */ typedef enum _LIB3270_POINTER { - LIB3270_POINTER_UNLOCKED, /**< @brief Ready for user actions */ - LIB3270_POINTER_WAITING, /**< @brief Waiting for host */ - LIB3270_POINTER_LOCKED, /**< @brief Locked, can't receive user actions */ + LIB3270_POINTER_UNLOCKED, ///< @brief Ready for user actions + LIB3270_POINTER_WAITING, ///< @brief Waiting for host + LIB3270_POINTER_LOCKED, ///< @brief Locked, can't receive user actions LIB3270_POINTER_PROTECTED, LIB3270_POINTER_MOVE_SELECTION, @@ -993,6 +993,8 @@ LIB3270_EXPORT int lib3270_is_connected(const H3270 *h); LIB3270_EXPORT int lib3270_is_disconnected(const H3270 *h); + LIB3270_EXPORT int lib3270_is_unlocked(const H3270 *h); + LIB3270_EXPORT int lib3270_has_active_script(const H3270 *h); LIB3270_EXPORT int lib3270_get_typeahead(const H3270 *h); LIB3270_EXPORT int lib3270_get_undera(const H3270 *h); diff --git a/src/include/lib3270/actions.h b/src/include/lib3270/actions.h index c2e11ee..ca63e7c 100644 --- a/src/include/lib3270/actions.h +++ b/src/include/lib3270/actions.h @@ -39,6 +39,7 @@ LIB3270_ACTION_GROUP_ONLINE, ///< @brief Action requires online state. LIB3270_ACTION_GROUP_OFFLINE, ///< @brief Action requires offline state. LIB3270_ACTION_GROUP_SELECTION, ///< @brief Action depends on selection. + LIB3270_ACTION_GROUP_LOCK_STATE, ///< @brief Action depends on keyboard lock state. LIB3270_ACTION_GROUP_CUSTOM ///< @brief Custom group/Number of groups. } LIB3270_ACTION_GROUP; diff --git a/src/include/screenc.h b/src/include/screenc.h index 30ed263..eaa55a8 100644 --- a/src/include/screenc.h +++ b/src/include/screenc.h @@ -43,10 +43,6 @@ LIB3270_INTERNAL int screen_init(H3270 *session); LIB3270_INTERNAL void mcursor_set(H3270 *session,LIB3270_POINTER m); -#define mcursor_locked(x) mcursor_set(x,LIB3270_POINTER_LOCKED) -#define mcursor_normal(x) mcursor_set(x,LIB3270_POINTER_UNLOCKED) -#define mcursor_waiting(x) mcursor_set(x,LIB3270_POINTER_WAITING) - LIB3270_INTERNAL void notify_toggle_changed(H3270 *session, LIB3270_TOGGLE_ID ix, unsigned char value, LIB3270_TOGGLE_TYPE reason); LIB3270_INTERNAL void set_viewsize(H3270 *session, unsigned int rows, unsigned int cols); -- libgit2 0.21.2