diff --git a/src/core/properties/signed.c b/src/core/properties/signed.c index aa658c7..166895e 100644 --- a/src/core/properties/signed.c +++ b/src/core/properties/signed.c @@ -62,6 +62,14 @@ }, { + .name = "cursor_address", // Property name. + .group = LIB3270_ACTION_GROUP_ONLINE, // Property group. + .description = N_( "Cursor address" ), // Property description. + .get = lib3270_get_cursor_address, // Get value. + .set = lib3270_set_cursor_address // Set value. + }, + + { .name = "program_message", // Property name. .description = N_( "Latest program message" ), // Property description. .get = lib3270_get_program_message_as_int, // Get value. diff --git a/src/core/properties/unsigned.c b/src/core/properties/unsigned.c index 4a8264e..4d690ce 100644 --- a/src/core/properties/unsigned.c +++ b/src/core/properties/unsigned.c @@ -103,14 +103,6 @@ static unsigned int lib3270_get_host_type_number(const H3270 *hSession) }, { - .name = "cursor_address", // Property name. - .group = LIB3270_ACTION_GROUP_ONLINE, // Property group. - .description = N_( "Cursor address" ), // Property description. - .get = lib3270_get_cursor_address, // Get value. - .set = lib3270_set_cursor_address // Set value. - }, - - { .name = "width", // Property name. .description = N_( "Current screen width in columns" ), // Property description. .get = lib3270_get_width, // Get value. diff --git a/src/core/screen.c b/src/core/screen.c index c791a53..3faf38c 100644 --- a/src/core/screen.c +++ b/src/core/screen.c @@ -416,12 +416,10 @@ void screen_update(H3270 *session, int bstart, int bend) } -LIB3270_EXPORT unsigned int lib3270_get_cursor_address(const H3270 *hSession) +LIB3270_EXPORT int lib3270_get_cursor_address(const H3270 *hSession) { - if(check_online_session(hSession)) - return 0; - - return hSession->cursor_addr; + int state = check_online_session(hSession); + return state ? -state : hSession->cursor_addr; } /** @@ -448,13 +446,13 @@ LIB3270_EXPORT int lib3270_translate_to_address(const H3270 *hSession, unsigned } -LIB3270_EXPORT int lib3270_set_cursor_address(H3270 *hSession, unsigned int baddr) +LIB3270_EXPORT int lib3270_set_cursor_address(H3270 *hSession, int baddr) { FAIL_IF_NOT_ONLINE(hSession); trace("%s(%d)",__FUNCTION__,baddr); - if(baddr > (hSession->view.rows * hSession->view.cols)) + if( ((unsigned int) baddr) > (hSession->view.rows * hSession->view.cols)) return - (errno = EOVERFLOW); if(hSession->selected && !lib3270_get_toggle(hSession,LIB3270_TOGGLE_KEEP_SELECTED)) diff --git a/src/include/lib3270.h b/src/include/lib3270.h index 46fea59..b71c119 100644 --- a/src/include/lib3270.h +++ b/src/include/lib3270.h @@ -736,7 +736,7 @@ * @retval -ENOTCONN Disconnected from host. * */ - LIB3270_EXPORT int lib3270_set_cursor_address(H3270 *hSession, unsigned int baddr); + LIB3270_EXPORT int lib3270_set_cursor_address(H3270 *hSession, int baddr); /** * @brief Set cursor position. @@ -757,10 +757,14 @@ * * @param hSession Session handle. * - * @return Cursor address or 0 if invalid (sets errno). + * @return Cursor address or negative if invalid (sets errno). + * + * @retval -ENOTCONN Disconnected from host. + * @retval -EINVAL Invalid session handle. + * @retval -1 Unexpected error. * */ - LIB3270_EXPORT unsigned int lib3270_get_cursor_address(const H3270 *hSession); + LIB3270_EXPORT int lib3270_get_cursor_address(const H3270 *hSession); /** * @brief Move cursor -- libgit2 0.21.2