Commit 4e287678326bc8c79f6445ebcf8dfa01bed50907
1 parent
7443b5e6
Exists in
master
and in
5 other branches
Corrigindo erro ao arrastar uma caixa de seleção que ocupe toda a tela do terminal
Showing
4 changed files
with
20 additions
and
12 deletions
Show diff stats
src/include/lib3270/action_table.h
| ... | ... | @@ -56,8 +56,8 @@ |
| 56 | 56 | DECLARE_LIB3270_ACTION( clear ) |
| 57 | 57 | DECLARE_LIB3270_ACTION( eraseinput ) |
| 58 | 58 | |
| 59 | - DECLARE_LIB3270_ACTION( selectfield ) | |
| 60 | - DECLARE_LIB3270_ACTION( selectall ) | |
| 59 | + DECLARE_LIB3270_ACTION( select_field ) | |
| 60 | + DECLARE_LIB3270_ACTION( select_all ) | |
| 61 | 61 | DECLARE_LIB3270_ACTION( unselect ) |
| 62 | 62 | DECLARE_LIB3270_ACTION( reselect ) |
| 63 | 63 | ... | ... |
src/include/lib3270/selection.h
| ... | ... | @@ -33,10 +33,12 @@ |
| 33 | 33 | |
| 34 | 34 | #define LIB3270_SELECTION_H_INCLUDED 1 |
| 35 | 35 | |
| 36 | - LIB3270_EXPORT void lib3270_clear_selection(H3270 *session); | |
| 36 | + LIB3270_EXPORT int lib3270_unselect(H3270 *session); | |
| 37 | 37 | LIB3270_EXPORT void lib3270_select_to(H3270 *session, int baddr); |
| 38 | 38 | LIB3270_EXPORT int lib3270_select_word_at(H3270 *session, int baddr); |
| 39 | 39 | LIB3270_EXPORT int lib3270_select_field_at(H3270 *session, int baddr); |
| 40 | + LIB3270_EXPORT int lib3270_select_field(H3270 *session); | |
| 41 | + LIB3270_EXPORT int lib3270_select_all(H3270 *session); | |
| 40 | 42 | |
| 41 | 43 | /** |
| 42 | 44 | * "Paste" supplied string. | ... | ... |
src/lib3270/selection.c
| ... | ... | @@ -176,7 +176,7 @@ void toggle_rectselect(H3270 *session, struct lib3270_toggle *t, LIB3270_TOGGLE_ |
| 176 | 176 | update_selected_region(session); |
| 177 | 177 | } |
| 178 | 178 | |
| 179 | -LIB3270_ACTION(unselect) | |
| 179 | +LIB3270_EXPORT int lib3270_unselect(H3270 *hSession) | |
| 180 | 180 | { |
| 181 | 181 | int a; |
| 182 | 182 | |
| ... | ... | @@ -242,11 +242,14 @@ LIB3270_EXPORT void lib3270_select_region(H3270 *h, int start, int end) |
| 242 | 242 | |
| 243 | 243 | static void do_select(H3270 *h, int start, int end, int rect) |
| 244 | 244 | { |
| 245 | + if(start < 0 || end > (h->rows * h->cols)) | |
| 246 | + return; | |
| 245 | 247 | |
| 246 | 248 | // Do we really need to change selection? |
| 247 | 249 | if(start == h->select.start && end == h->select.end && h->selected) |
| 248 | 250 | return; |
| 249 | 251 | |
| 252 | + // Start address is inside the screen? | |
| 250 | 253 | h->select.start = start; |
| 251 | 254 | h->select.end = end; |
| 252 | 255 | |
| ... | ... | @@ -340,20 +343,18 @@ LIB3270_EXPORT int lib3270_select_field_at(H3270 *session, int baddr) |
| 340 | 343 | return 0; |
| 341 | 344 | } |
| 342 | 345 | |
| 343 | -LIB3270_ACTION( selectfield ) | |
| 346 | +LIB3270_EXPORT int lib3270_select_field(H3270 *hSession) | |
| 344 | 347 | { |
| 345 | 348 | CHECK_SESSION_HANDLE(hSession); |
| 346 | 349 | lib3270_select_field_at(hSession,hSession->cursor_addr); |
| 347 | 350 | return 0; |
| 348 | 351 | } |
| 349 | 352 | |
| 350 | -LIB3270_ACTION( selectall ) | |
| 353 | +LIB3270_EXPORT int lib3270_select_all(H3270 * hSession) | |
| 351 | 354 | { |
| 352 | -// int len, baddr; | |
| 353 | - | |
| 354 | 355 | CHECK_SESSION_HANDLE(hSession); |
| 355 | 356 | |
| 356 | - do_select(hSession,0,hSession->rows*hSession->cols,0); | |
| 357 | + do_select(hSession,0,(hSession->rows*hSession->cols)-1,0); | |
| 357 | 358 | |
| 358 | 359 | return 0; |
| 359 | 360 | } |
| ... | ... | @@ -764,7 +765,9 @@ LIB3270_EXPORT int lib3270_move_selected_area(H3270 *hSession, int from, int to) |
| 764 | 765 | { |
| 765 | 766 | int pos[2]; |
| 766 | 767 | int rows, cols, f, step; |
| 767 | - // , start, end; | |
| 768 | + | |
| 769 | + if(from == to) | |
| 770 | + return from; | |
| 768 | 771 | |
| 769 | 772 | if(!lib3270_get_selection_bounds(hSession,&pos[0],&pos[1])) |
| 770 | 773 | return from; |
| ... | ... | @@ -835,6 +838,8 @@ LIB3270_EXPORT int lib3270_drag_selection(H3270 *h, unsigned char flag, int orig |
| 835 | 838 | if(flag & SELECTION_BOTTOM) // Update bottom margin |
| 836 | 839 | origin = last = (row*h->cols) + (last%h->cols); |
| 837 | 840 | |
| 841 | + trace("origin=%d first=%d last=%d",origin,first,last); | |
| 842 | + | |
| 838 | 843 | if(first < last) |
| 839 | 844 | do_select(h,first,last,h->rectsel); |
| 840 | 845 | else | ... | ... |
src/pw3270/actions.c
| ... | ... | @@ -398,12 +398,13 @@ static void action_reset_toggle(GtkAction *action, GtkWidget *widget) |
| 398 | 398 | |
| 399 | 399 | static void action_select_all(GtkAction *action, GtkWidget *widget) |
| 400 | 400 | { |
| 401 | - lib3270_selectall(v3270_get_session(widget)); | |
| 401 | + lib3270_trace_event(v3270_get_session(widget),"Action %s activated on widget %p\n",gtk_action_get_name(action),widget); | |
| 402 | + lib3270_select_all(v3270_get_session(widget)); | |
| 402 | 403 | } |
| 403 | 404 | |
| 404 | 405 | static void action_select_field(GtkAction *action, GtkWidget *widget) |
| 405 | 406 | { |
| 406 | - lib3270_selectfield(v3270_get_session(widget)); | |
| 407 | + lib3270_select_field(v3270_get_session(widget)); | |
| 407 | 408 | } |
| 408 | 409 | |
| 409 | 410 | static void action_select_none(GtkAction *action, GtkWidget *widget) | ... | ... |