Commit ef2d0b3fb770479a46255c341b5b0517e7687c66
1 parent
016a9ca1
Exists in
master
and in
3 other branches
Incluindo funcoes para obtenção das bordas de palavra e campo para uso no compon…
…ente de acessibilidade
Showing
3 changed files
with
137 additions
and
72 deletions
Show diff stats
Makefile.in
@@ -95,7 +95,7 @@ SOURCES = XtGlue.c init.c actions.c ansi.c charset.c ctlr.c \ | @@ -95,7 +95,7 @@ SOURCES = XtGlue.c init.c actions.c ansi.c charset.c ctlr.c \ | ||
95 | print.c printer.c proxy.c resources.c rpq.c screen.c see.c \ | 95 | print.c printer.c proxy.c resources.c rpq.c screen.c see.c \ |
96 | sf.c tables.c telnet.c toggles.c trace_ds.c utf8.c util.c \ | 96 | sf.c tables.c telnet.c toggles.c trace_ds.c utf8.c util.c \ |
97 | xio.c resolver.c log.c paste.c macros.c fallbacks.c version.c \ | 97 | xio.c resolver.c log.c paste.c macros.c fallbacks.c version.c \ |
98 | - selection.c | 98 | + selection.c bounds.c |
99 | 99 | ||
100 | #---[ Misc targets ]----------------------------------------------------------- | 100 | #---[ Misc targets ]----------------------------------------------------------- |
101 | 101 |
@@ -0,0 +1,94 @@ | @@ -0,0 +1,94 @@ | ||
1 | +/* | ||
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., 59 Temple | ||
19 | + * Place, Suite 330, Boston, MA, 02111-1307, USA | ||
20 | + * | ||
21 | + * Este programa está nomeado como bounds.c 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) | ||
27 | + * licinio@bb.com.br (Licínio Luis Branco) | ||
28 | + * kraucer@bb.com.br (Kraucer Fernandes Mazuco) | ||
29 | + * macmiranda@bb.com.br (Marco Aurélio Caldas Miranda) | ||
30 | + * | ||
31 | + */ | ||
32 | + | ||
33 | +#include "globals.h" | ||
34 | + | ||
35 | +/*--[ Implement ]------------------------------------------------------------------------------------*/ | ||
36 | + | ||
37 | +LIB3270_EXPORT int lib3270_get_field_bounds(H3270 *session, int baddr, int *start, int *end) | ||
38 | +{ | ||
39 | + int first; | ||
40 | + | ||
41 | + CHECK_SESSION_HANDLE(session); | ||
42 | + | ||
43 | + if(!lib3270_connected(session)) | ||
44 | + return -1; | ||
45 | + | ||
46 | + first = lib3270_field_addr(session,baddr); | ||
47 | + | ||
48 | + if(first < 0) | ||
49 | + return -1; | ||
50 | + | ||
51 | + first++; | ||
52 | + | ||
53 | + if(start) | ||
54 | + *start = first; | ||
55 | + | ||
56 | + if(end) | ||
57 | + { | ||
58 | + int maxlen = (session->rows * session->cols)-1; | ||
59 | + *end = first + lib3270_field_length(session,first); | ||
60 | + if(*end > maxlen) | ||
61 | + *end = maxlen; | ||
62 | + } | ||
63 | + | ||
64 | + return 0; | ||
65 | +} | ||
66 | + | ||
67 | +LIB3270_EXPORT int lib3270_get_word_bounds(H3270 *session, int baddr, int *start, int *end) | ||
68 | +{ | ||
69 | + int pos; | ||
70 | + | ||
71 | + CHECK_SESSION_HANDLE(session); | ||
72 | + | ||
73 | + if(!lib3270_connected(session) || isspace(session->text[baddr].chr)) | ||
74 | + return -1; | ||
75 | + | ||
76 | + if(start) | ||
77 | + { | ||
78 | + for(pos = baddr; pos > 0 && !isspace(session->text[pos].chr);pos--); | ||
79 | + | ||
80 | + *start = pos > 0 ? pos+1 : 0; | ||
81 | + } | ||
82 | + | ||
83 | + if(end) | ||
84 | + { | ||
85 | + int maxlen = session->rows * session->cols; | ||
86 | + for(pos = baddr; pos < maxlen && !isspace(session->text[pos].chr);pos++); | ||
87 | + | ||
88 | + *end = pos < maxlen ? pos-1 : maxlen; | ||
89 | + } | ||
90 | + | ||
91 | + return 0; | ||
92 | +} | ||
93 | + | ||
94 | + |
selection.c
@@ -34,13 +34,16 @@ | @@ -34,13 +34,16 @@ | ||
34 | #include <lib3270/session.h> | 34 | #include <lib3270/session.h> |
35 | #include <lib3270/selection.h> | 35 | #include <lib3270/selection.h> |
36 | 36 | ||
37 | - #define SELECTION_LEFT 0x01 | ||
38 | - #define SELECTION_TOP 0x02 | ||
39 | - #define SELECTION_RIGHT 0x04 | ||
40 | - #define SELECTION_BOTTOM 0x08 | ||
41 | - #define SELECTION_ACTIVE 0x10 | 37 | + #define SELECTION_LEFT 0x01 |
38 | + #define SELECTION_TOP 0x02 | ||
39 | + #define SELECTION_RIGHT 0x04 | ||
40 | + #define SELECTION_BOTTOM 0x08 | ||
41 | + #define SELECTION_SINGLE_ROW 0x10 | ||
42 | + #define SELECTION_SINGLE_COL 0x20 | ||
42 | 43 | ||
43 | - static void select_region(H3270 *h, int start, int end); | 44 | + #define SELECTION_ACTIVE 0x80 |
45 | + | ||
46 | + static void do_select(H3270 *h, int start, int end, int rect); | ||
44 | 47 | ||
45 | /*--[ Implement ]------------------------------------------------------------------------------------*/ | 48 | /*--[ Implement ]------------------------------------------------------------------------------------*/ |
46 | 49 | ||
@@ -212,7 +215,7 @@ LIB3270_EXPORT void lib3270_select_to(H3270 *session, int baddr) | @@ -212,7 +215,7 @@ LIB3270_EXPORT void lib3270_select_to(H3270 *session, int baddr) | ||
212 | 215 | ||
213 | cursor_move(session,end = baddr); | 216 | cursor_move(session,end = baddr); |
214 | 217 | ||
215 | - select_region(session,start,end); | 218 | + do_select(session,start,end,lib3270_get_toggle(session,LIB3270_TOGGLE_RECTANGLE_SELECT)); |
216 | 219 | ||
217 | } | 220 | } |
218 | 221 | ||
@@ -231,12 +234,12 @@ LIB3270_EXPORT void lib3270_select_region(H3270 *h, int start, int end) | @@ -231,12 +234,12 @@ LIB3270_EXPORT void lib3270_select_region(H3270 *h, int start, int end) | ||
231 | if(start < 0 || start > maxlen || end < 0 || end > maxlen || start > end) | 234 | if(start < 0 || start > maxlen || end < 0 || end > maxlen || start > end) |
232 | return; | 235 | return; |
233 | 236 | ||
234 | - select_region(h,start,end); | 237 | + do_select(h,start,end,lib3270_get_toggle(h,LIB3270_TOGGLE_RECTANGLE_SELECT)); |
235 | cursor_move(h,h->select.end); | 238 | cursor_move(h,h->select.end); |
236 | 239 | ||
237 | } | 240 | } |
238 | 241 | ||
239 | -static void select_region(H3270 *h, int start, int end) | 242 | +static void do_select(H3270 *h, int start, int end, int rect) |
240 | { | 243 | { |
241 | 244 | ||
242 | // Do we really need to change selection? | 245 | // Do we really need to change selection? |
@@ -246,10 +249,16 @@ static void select_region(H3270 *h, int start, int end) | @@ -246,10 +249,16 @@ static void select_region(H3270 *h, int start, int end) | ||
246 | h->select.start = start; | 249 | h->select.start = start; |
247 | h->select.end = end; | 250 | h->select.end = end; |
248 | 251 | ||
249 | - if(lib3270_get_toggle(h,LIB3270_TOGGLE_RECTANGLE_SELECT)) | 252 | + if(rect) |
253 | + { | ||
254 | + h->rectsel = 1; | ||
250 | update_selected_rectangle(h); | 255 | update_selected_rectangle(h); |
256 | + } | ||
251 | else | 257 | else |
258 | + { | ||
259 | + h->rectsel = 0; | ||
252 | update_selected_region(h); | 260 | update_selected_region(h); |
261 | + } | ||
253 | 262 | ||
254 | if(!h->selected) | 263 | if(!h->selected) |
255 | { | 264 | { |
@@ -275,6 +284,12 @@ LIB3270_EXPORT unsigned char lib3270_get_selection_flags(H3270 *hSession, int ba | @@ -275,6 +284,12 @@ LIB3270_EXPORT unsigned char lib3270_get_selection_flags(H3270 *hSession, int ba | ||
275 | col = baddr % hSession->cols; | 284 | col = baddr % hSession->cols; |
276 | rc |= SELECTION_ACTIVE; | 285 | rc |= SELECTION_ACTIVE; |
277 | 286 | ||
287 | + if( (hSession->select.start % hSession->cols) == (hSession->select.end % hSession->cols) ) | ||
288 | + rc |= SELECTION_SINGLE_COL; | ||
289 | + | ||
290 | + if( (hSession->select.start / hSession->cols) == (hSession->select.end / hSession->cols) ) | ||
291 | + rc |= SELECTION_SINGLE_ROW; | ||
292 | + | ||
278 | if( (col == 0) || !(hSession->text[baddr-1].attr & LIB3270_ATTR_SELECTED) ) | 293 | if( (col == 0) || !(hSession->text[baddr-1].attr & LIB3270_ATTR_SELECTED) ) |
279 | rc |= SELECTION_LEFT; | 294 | rc |= SELECTION_LEFT; |
280 | 295 | ||
@@ -290,57 +305,28 @@ LIB3270_EXPORT unsigned char lib3270_get_selection_flags(H3270 *hSession, int ba | @@ -290,57 +305,28 @@ LIB3270_EXPORT unsigned char lib3270_get_selection_flags(H3270 *hSession, int ba | ||
290 | return rc; | 305 | return rc; |
291 | } | 306 | } |
292 | 307 | ||
293 | -LIB3270_EXPORT void lib3270_select_word(H3270 *session, int baddr) | 308 | +LIB3270_EXPORT int lib3270_select_word_at(H3270 *session, int baddr) |
294 | { | 309 | { |
295 | - int pos, len, start, end; | ||
296 | - | ||
297 | - CHECK_SESSION_HANDLE(session); | 310 | + int start, end; |
298 | 311 | ||
299 | - if(!lib3270_connected(session) || isspace(session->text[baddr].chr)) | ||
300 | - { | ||
301 | - lib3270_ring_bell(session); | ||
302 | - return; | ||
303 | - } | 312 | + if(lib3270_get_word_bounds(session,baddr,&start,&end)) |
313 | + return -1; | ||
304 | 314 | ||
305 | - start = session->select.start; | ||
306 | - for(pos = baddr; pos > 0 && !isspace(session->text[pos].chr);pos--); | ||
307 | - start = pos > 0 ? pos+1 : 0; | 315 | + trace("%s: baddr=%d start=%d end=%d",__FUNCTION__,baddr,start,end); |
308 | 316 | ||
309 | - len = session->rows * session->cols; | ||
310 | - for(pos = baddr; pos < len && !isspace(session->text[pos].chr);pos++); | ||
311 | - end = pos < len ? pos-1 : len; | 317 | + do_select(session,start,end,0); |
312 | 318 | ||
313 | - select_region(session,start,end); | 319 | + return 0; |
314 | } | 320 | } |
315 | 321 | ||
316 | LIB3270_EXPORT int lib3270_select_field_at(H3270 *session, int baddr) | 322 | LIB3270_EXPORT int lib3270_select_field_at(H3270 *session, int baddr) |
317 | { | 323 | { |
318 | - int start, end,len; | ||
319 | - | ||
320 | - CHECK_SESSION_HANDLE(session); | ||
321 | - | ||
322 | - if(!lib3270_connected(session)) | ||
323 | - { | ||
324 | - lib3270_ring_bell(session); | ||
325 | - return -1; | ||
326 | - } | ||
327 | - | ||
328 | - start = lib3270_field_addr(session,baddr); | 324 | + int start, end; |
329 | 325 | ||
330 | - if(start < 0) | ||
331 | - { | ||
332 | - lib3270_ring_bell(session); | 326 | + if(lib3270_get_field_bounds(session,baddr,&start,&end)) |
333 | return -1; | 327 | return -1; |
334 | - } | ||
335 | - | ||
336 | - start++; | ||
337 | 328 | ||
338 | - len = (session->rows * session->cols)-1; | ||
339 | - end = start + lib3270_field_length(session,start); | ||
340 | - if(end > len) | ||
341 | - end = len; | ||
342 | - | ||
343 | - select_region(session,start,end); | 329 | + do_select(session,start,end,0); |
344 | 330 | ||
345 | return 0; | 331 | return 0; |
346 | } | 332 | } |
@@ -358,21 +344,8 @@ LIB3270_ACTION( selectall ) | @@ -358,21 +344,8 @@ LIB3270_ACTION( selectall ) | ||
358 | 344 | ||
359 | CHECK_SESSION_HANDLE(hSession); | 345 | CHECK_SESSION_HANDLE(hSession); |
360 | 346 | ||
361 | - select_region(hSession,0,hSession->rows*hSession->cols); | ||
362 | -/* | ||
363 | - len = hSession->rows*hSession->cols; | ||
364 | - | ||
365 | - for(baddr = 0; baddr < len; baddr++) | ||
366 | - { | ||
367 | - if(!(hSession->text[baddr].attr & LIB3270_ATTR_SELECTED)) | ||
368 | - { | ||
369 | - hSession->text[baddr].attr |= LIB3270_ATTR_SELECTED; | ||
370 | - hSession->update(hSession,baddr,hSession->text[baddr].chr,hSession->text[baddr].attr,baddr == hSession->cursor_addr); | ||
371 | - } | ||
372 | - } | 347 | + do_select(hSession,0,hSession->rows*hSession->cols,0); |
373 | 348 | ||
374 | - set_selected(hSession); | ||
375 | -*/ | ||
376 | return 0; | 349 | return 0; |
377 | } | 350 | } |
378 | 351 | ||
@@ -385,7 +358,7 @@ LIB3270_ACTION( reselect ) | @@ -385,7 +358,7 @@ LIB3270_ACTION( reselect ) | ||
385 | if(!lib3270_connected(hSession) || hSession->select.start == hSession->select.end || hSession->selected) | 358 | if(!lib3270_connected(hSession) || hSession->select.start == hSession->select.end || hSession->selected) |
386 | return 0; | 359 | return 0; |
387 | 360 | ||
388 | - select_region(hSession, hSession->select.start,hSession->select.end); | 361 | + do_select(hSession, hSession->select.start,hSession->select.end,lib3270_get_toggle(hSession,LIB3270_TOGGLE_RECTANGLE_SELECT)); |
389 | 362 | ||
390 | return 0; | 363 | return 0; |
391 | } | 364 | } |
@@ -589,9 +562,9 @@ LIB3270_EXPORT int lib3270_move_selected_area(H3270 *hSession, int from, int to) | @@ -589,9 +562,9 @@ LIB3270_EXPORT int lib3270_move_selected_area(H3270 *hSession, int from, int to) | ||
589 | cols = hSession->cols - ((pos[f] % hSession->cols)+1); | 562 | cols = hSession->cols - ((pos[f] % hSession->cols)+1); |
590 | } | 563 | } |
591 | 564 | ||
592 | - step = (rows * hSession->cols) + cols; | 565 | + step = (rows * hSession->cols) + cols; |
593 | 566 | ||
594 | - select_region(hSession,hSession->select.start + step,hSession->select.end + step); | 567 | + do_select(hSession,hSession->select.start + step,hSession->select.end + step,hSession->rectsel); |
595 | cursor_move(hSession,hSession->select.end); | 568 | cursor_move(hSession,hSession->select.end); |
596 | 569 | ||
597 | return from+step; | 570 | return from+step; |
@@ -604,8 +577,6 @@ LIB3270_EXPORT int lib3270_drag_selection(H3270 *h, unsigned char flag, int orig | @@ -604,8 +577,6 @@ LIB3270_EXPORT int lib3270_drag_selection(H3270 *h, unsigned char flag, int orig | ||
604 | if(!lib3270_get_selection_bounds(h,&first,&last)) | 577 | if(!lib3270_get_selection_bounds(h,&first,&last)) |
605 | return origin; | 578 | return origin; |
606 | 579 | ||
607 | - flag &= 0x1f; | ||
608 | - | ||
609 | trace("%s: flag=%04x",__FUNCTION__,flag); | 580 | trace("%s: flag=%04x",__FUNCTION__,flag); |
610 | 581 | ||
611 | if(!flag) | 582 | if(!flag) |
@@ -629,9 +600,9 @@ LIB3270_EXPORT int lib3270_drag_selection(H3270 *h, unsigned char flag, int orig | @@ -629,9 +600,9 @@ LIB3270_EXPORT int lib3270_drag_selection(H3270 *h, unsigned char flag, int orig | ||
629 | origin = last = (row*h->cols) + (last%h->cols); | 600 | origin = last = (row*h->cols) + (last%h->cols); |
630 | 601 | ||
631 | if(first < last) | 602 | if(first < last) |
632 | - select_region(h,first,last); | 603 | + do_select(h,first,last,h->rectsel); |
633 | else | 604 | else |
634 | - select_region(h,last,first); | 605 | + do_select(h,last,first,h->rectsel); |
635 | 606 | ||
636 | cursor_move(h,h->select.end); | 607 | cursor_move(h,h->select.end); |
637 | 608 | ||
@@ -683,7 +654,7 @@ LIB3270_EXPORT int lib3270_move_selection(H3270 *hSession, LIB3270_DIRECTION dir | @@ -683,7 +654,7 @@ LIB3270_EXPORT int lib3270_move_selection(H3270 *hSession, LIB3270_DIRECTION dir | ||
683 | return -1; | 654 | return -1; |
684 | } | 655 | } |
685 | 656 | ||
686 | - select_region(hSession,start,end); | 657 | + do_select(hSession,start,end,hSession->rectsel); |
687 | cursor_move(hSession,hSession->select.end); | 658 | cursor_move(hSession,hSession->select.end); |
688 | 659 | ||
689 | return 0; | 660 | return 0; |