From 28296b0c6073e25f400d0ad0531c9bf436dcbe70 Mon Sep 17 00:00:00 2001 From: perry.werneck@gmail.com Date: Mon, 2 Apr 2012 19:58:14 +0000 Subject: [PATCH] wip --- src/lib3270/api.h | 2 ++ src/lib3270/selection.c | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 0 deletions(-) diff --git a/src/lib3270/api.h b/src/lib3270/api.h index e026cc5..3c18cbe 100644 --- a/src/lib3270/api.h +++ b/src/lib3270/api.h @@ -91,8 +91,10 @@ /* Debug & log */ #if defined( DEBUG ) #define Trace( fmt, ... ) fprintf(stderr, "%s(%d) " fmt "\n", __FILE__, __LINE__, __VA_ARGS__ ); fflush(stderr); + #define trace( fmt, ... ) fprintf(stderr, "%s(%d) " fmt "\n", __FILE__, __LINE__, __VA_ARGS__ ); fflush(stderr); #else #define Trace( fmt, ... ) /* __VA_ARGS__ */ + #define trace( fmt, ... ) /* __VA_ARGS__ */ #endif diff --git a/src/lib3270/selection.c b/src/lib3270/selection.c index 434ef69..aee6baf 100644 --- a/src/lib3270/selection.c +++ b/src/lib3270/selection.c @@ -437,7 +437,25 @@ LIB3270_EXPORT int lib3270_get_selected_addr(H3270 *hSession, int *begin, int *e LIB3270_EXPORT int lib3270_move_selected_area(H3270 *hSession, int from, int to) { + int step = (to - from); + int first, last, pos, len; + if(lib3270_get_selected_addr(hSession,&first,&last)) + return from; + + len = hSession->rows * hSession->cols; + + pos = first+step; + trace("first=%d pos=%d step=%d",first,pos,step); + if(pos < 0) + step -= pos; + + pos = last+step; + if(pos > len) + step -= (pos - len); + + + trace("%s step=%d",__FUNCTION__,step); return from; } -- libgit2 0.21.2