diff --git a/src/core/actions/table.c b/src/core/actions/table.c index cb41153..e6bf007 100644 --- a/src/core/actions/table.c +++ b/src/core/actions/table.c @@ -39,27 +39,6 @@ /*---[ Implement ]------------------------------------------------------------------------------------------------------------*/ - /* - static int save_all(H3270 *hSession) - { - return lib3270_save_all(hSession,NULL); - } - */ - - /* - static int save_selected(H3270 *hSession) - { - return lib3270_save_selected(hSession,NULL); - } - */ - - /* - static int save_copy(H3270 *hSession) - { - return lib3270_save_copy(hSession,NULL); - } - */ - static int paste_file(H3270 *hSession) { return lib3270_load(hSession,NULL); @@ -211,55 +190,6 @@ .activatable = lib3270_is_connected }, - /* - - No need here; this actions are better when implemented on the widget or main application. - // - // Save/load actions - // - { - .name = "save-all", - .type = LIB3270_ACTION_TYPE_FILE, - - .keys = NULL, - .icon = "document-save", - .label = NULL, - .summary = N_( "Save screen to file" ), - .activate = save_all, - - .group = LIB3270_ACTION_GROUP_ONLINE, - .activatable = lib3270_is_connected - }, - - { - .name = "save-selected", - .type = LIB3270_ACTION_TYPE_FILE, - - .keys = NULL, - .icon = "document-save", - .label = NULL, - .summary = N_( "Save selected area to file" ), - .activate = save_selected, - - .group = LIB3270_ACTION_GROUP_SELECTION, - .activatable = lib3270_has_selection - }, - - { - .name = "save-copy", - .type = LIB3270_ACTION_TYPE_FILE, - - .keys = NULL, - .icon = "document-save", - .label = NULL, - .summary = NULL, - .activate = save_copy, - - .group = LIB3270_ACTION_GROUP_ONLINE, - .activatable = lib3270_is_connected - }, - */ - { .name = "paste-from-file", .type = LIB3270_ACTION_TYPE_FILE, @@ -642,71 +572,6 @@ }, // - // Misc actions - // - /* - - No need here; this actions are better when implemented on the widget or main application. - - { - .name = "print", - .type = LIB3270_ACTION_TYPE_PRINTER, - - .keys = "Print", - .icon = "document-print", - .label = N_("Print"), - .summary = N_("Send to printer"), - .description = N_("If the terminal has selected area print it, if not, print all contents"), - .activate = lib3270_print, - - .group = LIB3270_ACTION_GROUP_ONLINE, - .activatable = lib3270_is_connected - }, - - { - .name = "print-all", - .type = LIB3270_ACTION_TYPE_PRINTER, - - .keys = NULL, - .icon = "document-print", - .label = N_("Print screen"), - .summary = N_("Print screen contents"), - .activate = lib3270_print_all, - - .group = LIB3270_ACTION_GROUP_ONLINE, - .activatable = lib3270_is_connected - }, - - { - .name = "print-selected", - .type = LIB3270_ACTION_TYPE_PRINTER, - - .keys = NULL, - .icon = "document-print", - .label = N_("Print selection"), - .summary = N_( "Print selected area" ), - .activate = lib3270_print_selected, - - .group = LIB3270_ACTION_GROUP_SELECTION, - .activatable = lib3270_has_selection - }, - - { - .name = "print-copy", - .type = LIB3270_ACTION_TYPE_PRINTER, - - .keys = NULL, - .icon = "document-print", - .label = N_("Print copy"), - .summary = N_("Print copy (if available)"), - .activate = lib3270_print_copy, - - .group = LIB3270_ACTION_GROUP_COPY, - .activatable = lib3270_is_connected - }, - */ - - // // Test actions // @@ -751,19 +616,18 @@ return hSession == NULL ? 0 : 1; } - LIB3270_EXPORT int lib3270_action_group_get_activatable(const H3270 *hSession, const LIB3270_ACTION_GROUP group) - { - static const struct - { + LIB3270_EXPORT int lib3270_action_group_get_activatable(const H3270 *hSession, const LIB3270_ACTION_GROUP group) { + + static const struct { int (*get)(const H3270 *); - } activatable[LIB3270_ACTION_CUSTOM] = - { - { default_activatable_state }, // LIB3270_ACTION_GROUP_NONE - { lib3270_is_connected }, // LIB3270_ACTION_GROUP_ONLINE - { lib3270_is_disconnected }, // LIB3270_ACTION_GROUP_OFFLINE - { lib3270_has_selection }, // LIB3270_ACTION_GROUP_SELECTION - { lib3270_is_unlocked }, // LIB3270_ACTION_GROUP_LOCK_STATE - { lib3270_is_formatted }, // LIB3270_ACTION_GROUP_FORMATTED + } activatable[LIB3270_ACTION_CUSTOM] = { + { default_activatable_state }, // LIB3270_ACTION_GROUP_NONE + { lib3270_is_connected }, // LIB3270_ACTION_GROUP_ONLINE + { lib3270_is_disconnected }, // LIB3270_ACTION_GROUP_OFFLINE + { lib3270_get_has_selection }, // LIB3270_ACTION_GROUP_SELECTION + { lib3270_is_unlocked }, // LIB3270_ACTION_GROUP_LOCK_STATE + { lib3270_is_formatted }, // LIB3270_ACTION_GROUP_FORMATTED + { lib3270_get_has_copy }, // LIB3270_ACTION_GROUP_COPY }; if(group < (sizeof(activatable)/sizeof(activatable[0]))) { diff --git a/src/include/internals.h b/src/include/internals.h index 2fc20fd..11a6af6 100644 --- a/src/include/internals.h +++ b/src/include/internals.h @@ -353,6 +353,7 @@ struct _h3270 LIB3270_HOST_TYPE host_type; ///< @brief Host type. int selected : 1; ///< @brief Has selected region? + int has_copy : 1; ///< @brief Has copy? int rectsel : 1; ///< @brief Selected region is a rectangle ? int vcontrol : 1; ///< @brief Visible control ? int modified_sel : 1; diff --git a/src/include/lib3270.h b/src/include/lib3270.h index 8ca5728..bdafa49 100644 --- a/src/include/lib3270.h +++ b/src/include/lib3270.h @@ -1162,7 +1162,22 @@ * @return Greater than zero if the terminal has selected area, 0 if not. * */ - LIB3270_EXPORT int lib3270_has_selection(const H3270 *hSession); + LIB3270_EXPORT int lib3270_get_has_selection(const H3270 *hSession); + + LIB3270_EXPORT int LIB3270_DEPRECATED(lib3270_has_selection(const H3270 *hSession)); + + /** + * @brief Check if the terminal has stored clipboard contents. + * + * @param hSession Session handle. + * + * @return Greater than zero if the terminal has copy, 0 if not. + * + */ + LIB3270_EXPORT int lib3270_get_has_copy(const H3270 *hSession); + + LIB3270_EXPORT void lib3270_set_has_copy(H3270 *hSession, int has_copy); + /** * @brief Get all text inside the terminal. diff --git a/src/selection/selection.c b/src/selection/selection.c index ad3ef87..de8ec73 100644 --- a/src/selection/selection.c +++ b/src/selection/selection.c @@ -393,7 +393,7 @@ LIB3270_EXPORT char * lib3270_get_field_string_at(H3270 *session, int baddr) return lib3270_get_string_at_address(session,first,lib3270_field_length(session,first)+1,0); } -LIB3270_EXPORT int lib3270_has_selection(const H3270 *hSession) +LIB3270_EXPORT int lib3270_get_has_selection(const H3270 *hSession) { errno = 0; if(check_online_session(hSession)) @@ -402,6 +402,26 @@ LIB3270_EXPORT int lib3270_has_selection(const H3270 *hSession) return hSession->selected ? 1 : 0; } +LIB3270_EXPORT int lib3270_has_selection(const H3270 *hSession) { + return lib3270_get_has_selection(hSession); +} + +LIB3270_EXPORT int lib3270_get_has_copy(const H3270 *hSession) +{ + errno = 0; + if(check_online_session(hSession)) + return 0; + + return hSession->has_copy ? 1 : 0; +} + +LIB3270_EXPORT void lib3270_set_has_copy(H3270 *hSession, int has_copy) { + hSession->has_copy = has_copy ? 1 : 0; + lib3270_action_group_notify(hSession,LIB3270_ACTION_GROUP_COPY); +} + + + LIB3270_EXPORT int lib3270_get_selection_rectangle(H3270 *hSession, unsigned int *row, unsigned int *col, unsigned int *width, unsigned int *height) { unsigned int r, c, minRow, minCol, maxRow, maxCol, baddr, count; -- libgit2 0.21.2