Commit aeb92025d39ef0c1c73ee8848490afbc4e037f5c
1 parent
546a3f95
Exists in
master
and in
3 other branches
Implementando seleção por campo/palavra direto na biblioteca.
Showing
5 changed files
with
72 additions
and
21 deletions
Show diff stats
@@ -383,7 +383,8 @@ | @@ -383,7 +383,8 @@ | ||
383 | const char *description; | 383 | const char *description; |
384 | }; | 384 | }; |
385 | 385 | ||
386 | - LOCAL_EXTERN int Register3270ScreenCallbacks(const struct lib3270_screen_callbacks *cbk); | 386 | + // LOCAL_EXTERN int Register3270ScreenCallbacks(const struct lib3270_screen_callbacks *cbk); |
387 | + LOCAL_EXTERN void ring_bell(void); | ||
387 | 388 | ||
388 | #define new_3270_session(m) lib3270_session_new(m) | 389 | #define new_3270_session(m) lib3270_session_new(m) |
389 | 390 | ||
@@ -395,8 +396,23 @@ | @@ -395,8 +396,23 @@ | ||
395 | LOCAL_EXTERN void show_3270_popup_dialog(H3270 *session, PW3270_DIALOG type, const char *title, const char *msg, const char *fmt, ...); | 396 | LOCAL_EXTERN void show_3270_popup_dialog(H3270 *session, PW3270_DIALOG type, const char *title, const char *msg, const char *fmt, ...); |
396 | 397 | ||
397 | /* Set/Get screen contents */ | 398 | /* Set/Get screen contents */ |
398 | - LOCAL_EXTERN int find_field_attribute(H3270 *session, int baddr); | ||
399 | - LOCAL_EXTERN int find_field_length(H3270 *session, int baddr); | 399 | + #define find_field_attribute(s,a) lib3270_field_addr(s,a) |
400 | + #define find_field_length(s,a) find_field_length(s,a) | ||
401 | + | ||
402 | + /** | ||
403 | + * Find the buffer address of the field attribute for a given buffer address. | ||
404 | + * | ||
405 | + * @param h Session handle. | ||
406 | + * @param addr Buffer address of the field. | ||
407 | + * | ||
408 | + * @return field address or -1 if the screen isn't formatted. | ||
409 | + * | ||
410 | + */ | ||
411 | + LIB3270_EXPORT int lib3270_field_addr(H3270 *h, int baddr); | ||
412 | + | ||
413 | + LIB3270_EXPORT int lib3270_field_length(H3270 *session, int baddr); | ||
414 | + | ||
415 | + | ||
400 | LOCAL_EXTERN unsigned char get_field_attribute(H3270 *session, int baddr); | 416 | LOCAL_EXTERN unsigned char get_field_attribute(H3270 *session, int baddr); |
401 | LOCAL_EXTERN int screen_read(char *dest, int baddr, int count); | 417 | LOCAL_EXTERN int screen_read(char *dest, int baddr, int count); |
402 | LOCAL_EXTERN void Input_String(const unsigned char *str); | 418 | LOCAL_EXTERN void Input_String(const unsigned char *str); |
ctlr.c
@@ -320,11 +320,7 @@ static void ctlr_connect(H3270 *session, int ignored unused, void *dunno) | @@ -320,11 +320,7 @@ static void ctlr_connect(H3270 *session, int ignored unused, void *dunno) | ||
320 | 320 | ||
321 | 321 | ||
322 | 322 | ||
323 | -/* | ||
324 | - * Find the buffer address of the field attribute for a given buffer address. | ||
325 | - * Returns -1 if the screen isn't formatted. | ||
326 | - */ | ||
327 | -int find_field_attribute(H3270 *h, int baddr) | 323 | +LIB3270_EXPORT int lib3270_field_addr(H3270 *h, int baddr) |
328 | { | 324 | { |
329 | int sbaddr; | 325 | int sbaddr; |
330 | 326 | ||
@@ -334,18 +330,20 @@ int find_field_attribute(H3270 *h, int baddr) | @@ -334,18 +330,20 @@ int find_field_attribute(H3270 *h, int baddr) | ||
334 | return -1; | 330 | return -1; |
335 | 331 | ||
336 | sbaddr = baddr; | 332 | sbaddr = baddr; |
337 | - do { | 333 | + do |
334 | + { | ||
338 | if (ea_buf[baddr].fa) | 335 | if (ea_buf[baddr].fa) |
339 | return baddr; | 336 | return baddr; |
340 | DEC_BA(baddr); | 337 | DEC_BA(baddr); |
341 | } while (baddr != sbaddr); | 338 | } while (baddr != sbaddr); |
339 | + | ||
342 | return -1; | 340 | return -1; |
343 | } | 341 | } |
344 | 342 | ||
345 | /* | 343 | /* |
346 | * Get Field width | 344 | * Get Field width |
347 | */ | 345 | */ |
348 | -int find_field_length(H3270 *h, int baddr) | 346 | +int lib3270_field_length(H3270 *h, int baddr) |
349 | { | 347 | { |
350 | int saddr; | 348 | int saddr; |
351 | int addr; | 349 | int addr; |
lib3270.cbp
@@ -7,8 +7,8 @@ | @@ -7,8 +7,8 @@ | ||
7 | <Option compiler="gcc" /> | 7 | <Option compiler="gcc" /> |
8 | <Build> | 8 | <Build> |
9 | <Target title="Debug"> | 9 | <Target title="Debug"> |
10 | - <Option output=".bin/Debug/lib3270" prefix_auto="1" extension_auto="1" /> | ||
11 | - <Option object_output=".obj/Debug/" /> | 10 | + <Option output=".bin\Debug\lib3270" prefix_auto="1" extension_auto="1" /> |
11 | + <Option object_output=".obj\Debug\" /> | ||
12 | <Option type="1" /> | 12 | <Option type="1" /> |
13 | <Option compiler="gcc" /> | 13 | <Option compiler="gcc" /> |
14 | <Option use_console_runner="0" /> | 14 | <Option use_console_runner="0" /> |
@@ -21,8 +21,8 @@ | @@ -21,8 +21,8 @@ | ||
21 | </Linker> | 21 | </Linker> |
22 | </Target> | 22 | </Target> |
23 | <Target title="Release"> | 23 | <Target title="Release"> |
24 | - <Option output=".bin/Release/lib3270" prefix_auto="1" extension_auto="1" /> | ||
25 | - <Option object_output=".obj/Release/" /> | 24 | + <Option output=".bin\Release\lib3270" prefix_auto="1" extension_auto="1" /> |
25 | + <Option object_output=".obj\Release\" /> | ||
26 | <Option type="3" /> | 26 | <Option type="3" /> |
27 | <Option compiler="gcc" /> | 27 | <Option compiler="gcc" /> |
28 | <Option createDefFile="1" /> | 28 | <Option createDefFile="1" /> |
@@ -35,8 +35,8 @@ | @@ -35,8 +35,8 @@ | ||
35 | </Linker> | 35 | </Linker> |
36 | </Target> | 36 | </Target> |
37 | <Target title="testprogram"> | 37 | <Target title="testprogram"> |
38 | - <Option output=".bin/Debug/lib3270" prefix_auto="1" extension_auto="1" /> | ||
39 | - <Option object_output=".obj/testprogram/" /> | 38 | + <Option output=".bin\Debug\lib3270" prefix_auto="1" extension_auto="1" /> |
39 | + <Option object_output=".obj\testprogram\" /> | ||
40 | <Option type="1" /> | 40 | <Option type="1" /> |
41 | <Option compiler="gcc" /> | 41 | <Option compiler="gcc" /> |
42 | <Option use_console_runner="0" /> | 42 | <Option use_console_runner="0" /> |
@@ -53,10 +53,12 @@ | @@ -53,10 +53,12 @@ | ||
53 | <Add option="-Wmissing-declarations" /> | 53 | <Add option="-Wmissing-declarations" /> |
54 | <Add option="-Wall" /> | 54 | <Add option="-Wall" /> |
55 | <Add option="-DLIB3270=1" /> | 55 | <Add option="-DLIB3270=1" /> |
56 | - <Add directory="../include" /> | ||
57 | - <Add directory="../include/lib3270" /> | 56 | + <Add directory="..\include" /> |
57 | + <Add directory="..\include\lib3270" /> | ||
58 | </Compiler> | 58 | </Compiler> |
59 | - <Unit filename="../include/lib3270/config.h.in" /> | 59 | + <Unit filename="..\include\lib3270.h" /> |
60 | + <Unit filename="..\include\lib3270\config.h.in" /> | ||
61 | + <Unit filename="..\include\lib3270\selection.h" /> | ||
60 | <Unit filename="3270ds.h" /> | 62 | <Unit filename="3270ds.h" /> |
61 | <Unit filename="Makefile.in" /> | 63 | <Unit filename="Makefile.in" /> |
62 | <Unit filename="X11keysym.h" /> | 64 | <Unit filename="X11keysym.h" /> |
screenc.h
@@ -27,7 +27,6 @@ | @@ -27,7 +27,6 @@ | ||
27 | #define screen_80() /* */ | 27 | #define screen_80() /* */ |
28 | 28 | ||
29 | 29 | ||
30 | -LIB3270_INTERNAL void ring_bell(void); | ||
31 | LIB3270_INTERNAL void screen_erase(H3270 *session); | 30 | LIB3270_INTERNAL void screen_erase(H3270 *session); |
32 | LIB3270_INTERNAL void screen_changed(H3270 *session, int bstart, int bend); | 31 | LIB3270_INTERNAL void screen_changed(H3270 *session, int bstart, int bend); |
33 | LIB3270_INTERNAL int screen_init(H3270 *session); | 32 | LIB3270_INTERNAL int screen_init(H3270 *session); |
selection.c
@@ -178,7 +178,6 @@ LIB3270_EXPORT void lib3270_clear_selection(H3270 *session) | @@ -178,7 +178,6 @@ LIB3270_EXPORT void lib3270_clear_selection(H3270 *session) | ||
178 | 178 | ||
179 | } | 179 | } |
180 | 180 | ||
181 | - | ||
182 | LIB3270_EXPORT void lib3270_select_to(H3270 *session, int baddr) | 181 | LIB3270_EXPORT void lib3270_select_to(H3270 *session, int baddr) |
183 | { | 182 | { |
184 | CHECK_SESSION_HANDLE(session); | 183 | CHECK_SESSION_HANDLE(session); |
@@ -195,3 +194,40 @@ LIB3270_EXPORT void lib3270_select_to(H3270 *session, int baddr) | @@ -195,3 +194,40 @@ LIB3270_EXPORT void lib3270_select_to(H3270 *session, int baddr) | ||
195 | 194 | ||
196 | } | 195 | } |
197 | 196 | ||
197 | +LIB3270_EXPORT void lib3270_select_word(H3270 *session, int baddr) | ||
198 | +{ | ||
199 | + int pos, len; | ||
200 | + | ||
201 | + CHECK_SESSION_HANDLE(session); | ||
202 | + | ||
203 | + for(pos = baddr; pos > 0 && !isspace(ea_buf[pos].chr);pos--); | ||
204 | + session->selected.begin = pos; | ||
205 | + | ||
206 | + len = session->rows * session->cols; | ||
207 | + for(pos = baddr; pos < len && !isspace(ea_buf[pos].chr);pos++); | ||
208 | + session->selected.end = pos; | ||
209 | + | ||
210 | + update_selected_region(session); | ||
211 | +} | ||
212 | + | ||
213 | +LIB3270_EXPORT int lib3270_select_field(H3270 *session, int baddr) | ||
214 | +{ | ||
215 | + int start; | ||
216 | + | ||
217 | + CHECK_SESSION_HANDLE(session); | ||
218 | + | ||
219 | + start = lib3270_field_addr(session,baddr); | ||
220 | + | ||
221 | + if(start < 0) | ||
222 | + { | ||
223 | + ring_bell(); | ||
224 | + return -1; | ||
225 | + } | ||
226 | + | ||
227 | + session->selected.begin = start; | ||
228 | + session->selected.end = start + lib3270_field_length(session,start); | ||
229 | + | ||
230 | + update_selected_region(session); | ||
231 | + | ||
232 | + return 0; | ||
233 | +} |