Commit e244e0adf0cd443fd3f789b003aa53ec9b3baa7a

Authored by Perry Werneck
1 parent a07c8642
Exists in master and in 2 other branches develop, macos

Adding callback for 'select-word' action.

configure.ac
... ... @@ -44,7 +44,6 @@ AC_CONFIG_MACRO_DIRS([m4])
44 44 dnl Initialize libtool.
45 45 LT_INIT
46 46  
47   -
48 47 dnl Put macro definitions here (though they aren't used).
49 48 AC_CONFIG_HEADERS([src/include/config.h])
50 49  
... ...
src/core/session.c
  1 +/* SPDX-License-Identifier: LGPL-3.0-or-later */
  2 +
1 3 /*
2   - * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
3   - * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
4   - * aplicativos mainframe. Registro no INPI sob o nome G3270. Registro no INPI sob o nome G3270.
5   - *
6   - * Copyright (C) <2008> <Banco do Brasil S.A.>
7   - *
8   - * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
9   - * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
10   - * Free Software Foundation.
11   - *
12   - * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
13   - * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
14   - * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
15   - * obter mais detalhes.
16   - *
17   - * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
18   - * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin
19   - * St, Fifth Floor, Boston, MA 02110-1301 USA
20   - *
21   - * Este programa está nomeado como session.c e possui - linhas de código.
  4 + * Copyright (C) 2008 Banco do Brasil S.A.
22 5 *
23   - * Contatos:
  6 + * This program is free software: you can redistribute it and/or modify
  7 + * it under the terms of the GNU Lesser General Public License as published
  8 + * by the Free Software Foundation, either version 3 of the License, or
  9 + * (at your option) any later version.
24 10 *
25   - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
26   - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
  11 + * This program is distributed in the hope that it will be useful,
  12 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14 + * GNU General Public License for more details.
27 15 *
  16 + * You should have received a copy of the GNU Lesser General Public License
  17 + * along with this program. If not, see <https://www.gnu.org/licenses/>.
28 18 */
29 19  
30 20 #ifndef ANDROID
... ... @@ -154,13 +144,16 @@ void lib3270_session_free(H3270 *h) {
154 144  
155 145 }
156 146  
157   -static void update_char(H3270 GNUC_UNUSED(*session), int GNUC_UNUSED(addr), unsigned char GNUC_UNUSED(chr), unsigned short GNUC_UNUSED(attr), unsigned char GNUC_UNUSED(cursor)) {
  147 +static void nop_void() {
158 148 }
159 149  
160   -static void nop_char(H3270 GNUC_UNUSED(*session), unsigned char GNUC_UNUSED(chr)) {
  150 +static int default_action(H3270 GNUC_UNUSED(*hSession), const char GNUC_UNUSED(*name)) {
  151 + return errno = ENOENT;
161 152 }
162 153  
163   -static void nop(H3270 GNUC_UNUSED(*session)) {
  154 +
  155 +/*
  156 +static void update_char(H3270 GNUC_UNUSED(*session), int GNUC_UNUSED(addr), unsigned char GNUC_UNUSED(chr), unsigned short GNUC_UNUSED(attr), unsigned char GNUC_UNUSED(cursor)) {
164 157 }
165 158  
166 159 static void update_model(H3270 GNUC_UNUSED(*session), const char GNUC_UNUSED(*name), int GNUC_UNUSED(model), int GNUC_UNUSED(rows), int GNUC_UNUSED(cols)) {
... ... @@ -181,6 +174,20 @@ static void update_selection(H3270 GNUC_UNUSED(*session), int GNUC_UNUSED(start)
181 174 static void set_cursor(H3270 GNUC_UNUSED(*session), LIB3270_POINTER GNUC_UNUSED(id)) {
182 175 }
183 176  
  177 +static void update_ssl(H3270 GNUC_UNUSED(*session), LIB3270_SSL_STATE GNUC_UNUSED(state)) {
  178 +}
  179 +
  180 +static void set_timer(H3270 GNUC_UNUSED(*session), unsigned char GNUC_UNUSED(on)) {
  181 +}
  182 +
  183 +static void default_update_luname(H3270 GNUC_UNUSED(*session), const char GNUC_UNUSED(*name)) {
  184 +}
  185 +
  186 +static void default_update_url(H3270 GNUC_UNUSED(*session), const char GNUC_UNUSED(*url)) {
  187 +}
  188 +
  189 +*/
  190 +
184 191 static int print(H3270 *session, LIB3270_CONTENT_OPTION GNUC_UNUSED(mode)) {
185 192 lib3270_write_log(session, "print", "%s", "Printing is unavailable");
186 193 lib3270_popup_dialog(session, LIB3270_NOTIFY_WARNING, _( "Can't print" ), _( "Unable to print" ), "%s", strerror(ENOTSUP));
... ... @@ -199,60 +206,46 @@ static int load(H3270 *session, const char GNUC_UNUSED(*filename)) {
199 206 return errno = ENOTSUP;
200 207 }
201 208  
202   -static void update_ssl(H3270 GNUC_UNUSED(*session), LIB3270_SSL_STATE GNUC_UNUSED(state)) {
203   -}
204   -
205   -static void set_timer(H3270 GNUC_UNUSED(*session), unsigned char GNUC_UNUSED(on)) {
206   -}
207   -
208 209 static void screen_disp(H3270 *session) {
209 210 CHECK_SESSION_HANDLE(session);
210 211 screen_update(session,0,session->view.rows*session->view.cols);
211 212 }
212 213  
213   -static void nop_int(H3270 GNUC_UNUSED(*session), int GNUC_UNUSED(width)) {
214   - return;
215   -}
216   -
217   -static void default_update_luname(H3270 GNUC_UNUSED(*session), const char GNUC_UNUSED(*name)) {
218   -}
219   -
220   -static void default_update_url(H3270 GNUC_UNUSED(*session), const char GNUC_UNUSED(*url)) {
221   -}
222   -
223   -static int default_action(H3270 GNUC_UNUSED(*hSession), const char GNUC_UNUSED(*name)) {
224   - return ENOENT;
225   -}
226   -
227 214 void lib3270_reset_callbacks(H3270 *hSession) {
228 215 // Default calls
229 216 memset(&hSession->cbk,0,sizeof(hSession->cbk));
230 217  
231   - hSession->cbk.update = update_char;
232   - hSession->cbk.update_model = update_model;
233   - hSession->cbk.update_cursor = update_cursor;
234   - hSession->cbk.set_selection = nop_char;
235   - hSession->cbk.ctlr_done = nop;
236   - hSession->cbk.changed = changed;
  218 + #pragma GCC diagnostic push
  219 + #pragma GCC diagnostic ignored "-Wincompatible-pointer-types"
  220 +
  221 + hSession->cbk.update = nop_void;
  222 + hSession->cbk.update_model = nop_void;
  223 + hSession->cbk.update_cursor = nop_void;
  224 + hSession->cbk.set_selection = nop_void;
  225 + hSession->cbk.ctlr_done = nop_void;
  226 + hSession->cbk.changed = nop_void;
237 227 hSession->cbk.erase = screen_disp;
238   - hSession->cbk.suspend = nop;
  228 + hSession->cbk.suspend = nop_void;
239 229 hSession->cbk.resume = screen_disp;
240   - hSession->cbk.update_oia = update_oia;
241   - hSession->cbk.update_selection = update_selection;
242   - hSession->cbk.cursor = set_cursor;
243   - hSession->cbk.update_ssl = update_ssl;
  230 + hSession->cbk.update_oia = nop_void;
  231 + hSession->cbk.update_selection = nop_void;
  232 + hSession->cbk.cursor = nop_void;
  233 + hSession->cbk.update_ssl = nop_void;
244 234 hSession->cbk.display = screen_disp;
245   - hSession->cbk.set_width = nop_int;
246   - hSession->cbk.update_status = (void (*)(H3270 *, LIB3270_MESSAGE)) nop_int;
247   - hSession->cbk.autostart = nop;
248   - hSession->cbk.set_timer = set_timer;
  235 + hSession->cbk.set_width = nop_void;
  236 + hSession->cbk.update_status = nop_void;
  237 + hSession->cbk.autostart = nop_void;
  238 + hSession->cbk.set_timer = nop_void;
249 239 hSession->cbk.print = print;
250 240 hSession->cbk.save = save;
251 241 hSession->cbk.load = load;
252   - hSession->cbk.update_luname = default_update_luname;
253   - hSession->cbk.update_url = default_update_url;
  242 + hSession->cbk.update_luname = nop_void;
  243 + hSession->cbk.update_url = nop_void;
254 244 hSession->cbk.action = default_action;
255 245 hSession->cbk.reconnect = lib3270_reconnect;
  246 + hSession->cbk.word_selected = nop_void;
  247 +
  248 + #pragma GCC diagnostic pop
256 249  
257 250 lib3270_set_popup_handler(hSession, NULL);
258 251 lib3270_set_log_handler(hSession,NULL,NULL);
... ... @@ -468,7 +461,7 @@ LIB3270_EXPORT char lib3270_get_session_id(H3270 *hSession) {
468 461  
469 462 struct lib3270_session_callbacks * lib3270_get_session_callbacks(H3270 *hSession, const char *revision, unsigned short sz) {
470 463  
471   - #define REQUIRED_REVISION "20210801"
  464 + #define REQUIRED_REVISION "20211118"
472 465  
473 466 if(revision && strcasecmp(revision,REQUIRED_REVISION) < 0) {
474 467 errno = EINVAL;
... ...
src/include/lib3270/selection.h
  1 +/* SPDX-License-Identifier: LGPL-3.0-or-later */
  2 +
1 3 /*
2   - * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
3   - * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
4   - * aplicativos mainframe. Registro no INPI sob o nome G3270.
5   - *
6   - * Copyright (C) <2008> <Banco do Brasil S.A.>
7   - *
8   - * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
9   - * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
10   - * Free Software Foundation.
11   - *
12   - * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
13   - * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
14   - * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
15   - * obter mais detalhes.
  4 + * Copyright (C) 2008 Banco do Brasil S.A.
16 5 *
17   - * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
18   - * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin
19   - * St, Fifth Floor, Boston, MA 02110-1301 USA
  6 + * This program is free software: you can redistribute it and/or modify
  7 + * it under the terms of the GNU Lesser General Public License as published
  8 + * by the Free Software Foundation, either version 3 of the License, or
  9 + * (at your option) any later version.
20 10 *
21   - * Este programa está nomeado como selection.h e possui - linhas de código.
22   - *
23   - * Contatos:
24   - *
25   - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
26   - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
  11 + * This program is distributed in the hope that it will be useful,
  12 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14 + * GNU General Public License for more details.
27 15 *
  16 + * You should have received a copy of the GNU Lesser General Public License
  17 + * along with this program. If not, see <https://www.gnu.org/licenses/>.
28 18 */
29 19  
30 20 /**
... ... @@ -75,11 +65,26 @@ typedef struct _lib3270_selection {
75 65  
76 66 LIB3270_EXPORT int lib3270_unselect(H3270 *session);
77 67 LIB3270_EXPORT void lib3270_select_to(H3270 *session, int baddr);
78   -LIB3270_EXPORT int lib3270_select_word_at(H3270 *session, int baddr);
79   -LIB3270_EXPORT int lib3270_select_word(H3270 *session);
80   -LIB3270_EXPORT int lib3270_select_field_at(H3270 *session, int baddr);
81   -LIB3270_EXPORT int lib3270_select_field(H3270 *session);
82   -LIB3270_EXPORT int lib3270_select_all(H3270 *session);
  68 +
  69 +/**
  70 + * @brief Select word at position.
  71 + *
  72 + * @param hSession Session handle.
  73 + * @param baddr position.
  74 + *
  75 + * @return 0 if ok, non zero if failed
  76 + *
  77 + * @retval 0 The word was selected.
  78 + * @retval EINVAL baddr is out of the screen.
  79 + * @retval ENOTCONN The terminal is offline.
  80 + *
  81 + */
  82 + LIB3270_EXPORT int lib3270_select_word_at(H3270 *session, int baddr);
  83 +
  84 + LIB3270_EXPORT int lib3270_select_word(H3270 *session);
  85 + LIB3270_EXPORT int lib3270_select_field_at(H3270 *session, int baddr);
  86 + LIB3270_EXPORT int lib3270_select_field(H3270 *session);
  87 + LIB3270_EXPORT int lib3270_select_all(H3270 *session);
83 88  
84 89 /**
85 90 * @brief Get selection options.
... ... @@ -103,7 +108,7 @@ typedef enum _LIB3270_SELECTION_OPTIONS {
103 108 *
104 109 * @see lib3270_paste_next.
105 110 *
106   - * @return 0 if suceeded, negative if faile, > 0 if there's more data.
  111 + * @return 0 if suceeded, negative if fails, > 0 if there's more data.
107 112 *
108 113 * @retval 0 The entire string was pasted.
109 114 * @retval -EINVAL Invalid argument.
... ...
src/include/lib3270/session.h
... ... @@ -80,6 +80,8 @@ struct lib3270_session_callbacks {
80 80  
81 81 int (*reconnect)(H3270 *hSession,int seconds);
82 82  
  83 + void (*word_selected)(H3270 *hSession, int start, int end);
  84 +
83 85 };
84 86  
85 87 /**
... ...
src/selection/actions.c
  1 +/* SPDX-License-Identifier: LGPL-3.0-or-later */
  2 +
1 3 /*
2   - * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
3   - * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
4   - * aplicativos mainframe. Registro no INPI sob o nome G3270.
5   - *
6   - * Copyright (C) <2008> <Banco do Brasil S.A.>
7   - *
8   - * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
9   - * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
10   - * Free Software Foundation.
11   - *
12   - * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
13   - * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
14   - * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
15   - * obter mais detalhes.
16   - *
17   - * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
18   - * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin
19   - * St, Fifth Floor, Boston, MA 02110-1301 USA
  4 + * Copyright (C) 2008 Banco do Brasil S.A.
20 5 *
21   - * Este programa está nomeado como - e possui - linhas de código.
  6 + * This program is free software: you can redistribute it and/or modify
  7 + * it under the terms of the GNU Lesser General Public License as published
  8 + * by the Free Software Foundation, either version 3 of the License, or
  9 + * (at your option) any later version.
22 10 *
23   - * Contatos:
24   - *
25   - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
26   - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
  11 + * This program is distributed in the hope that it will be useful,
  12 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14 + * GNU General Public License for more details.
27 15 *
  16 + * You should have received a copy of the GNU Lesser General Public License
  17 + * along with this program. If not, see <https://www.gnu.org/licenses/>.
28 18 */
29 19  
30 20 #include <internals.h>
... ... @@ -107,14 +97,20 @@ LIB3270_EXPORT int lib3270_select_word(H3270 *session) {
107 97 }
108 98  
109 99 LIB3270_EXPORT int lib3270_select_word_at(H3270 *session, int baddr) {
110   - int start, end;
  100 + int start, end, rc;
111 101  
112   - if(lib3270_get_word_bounds(session,baddr,&start,&end))
113   - return -1;
  102 + rc = lib3270_get_word_bounds(session,baddr,&start,&end);
  103 + if(rc)
  104 + return rc;
114 105  
115 106 trace("%s: baddr=%d start=%d end=%d",__FUNCTION__,baddr,start,end);
116 107  
117   - do_select(session,start,end,0);
  108 + rc = do_select(session,start,end,0);
  109 + if(rc)
  110 + return rc;
  111 +
  112 + // Notify word selected to allow testing for URL selection.
  113 + session->cbk.word_selected(session,start,end);
118 114  
119 115 return 0;
120 116 }
... ...
win/install-cross.sh
... ... @@ -19,22 +19,20 @@ install_packages() {
19 19 | xargs sudo zypper --non-interactive --verbose in
20 20  
21 21  
  22 + ## Instala apicativos e temas necessários
  23 + sudo zypper --non-interactive in \
  24 + gettext-tools \
  25 + automake
  26 +
  27 + while read FILE
  28 + do
  29 + sudo zypper --non-interactive in ${1}-${FILE}
  30 + done < ${TEMPFILE}
  31 +
  32 + rm -f ${TEMPFILE}
  33 +
22 34 }
23 35  
24   -## Instala apicativos e temas necessários
25   -#sudo zypper --non-interactive in \
26   -# gettext-tools \
27   -# automake
28   -#
29   -#while read FILE
30   -#do
31   -# sudo zypper --non-interactive in ${1}-${FILE}
32   -#done < ${TEMPFILE}
33   -#
34   -#rm -f ${TEMPFILE}
35   -#
36   -#}
37   -#
38 36  
39 37 if [ -z ${1} ]; then
40 38 echo "Use ${0} --32 for 32 bits cross-compiler"
... ...