Commit 51b3ec906969eda9472870bf9aa3c1b770dba8f4
1 parent
8bee3b8b
Exists in
master
and in
3 other branches
Trabalhando no suporte atk
Showing
2 changed files
with
42 additions
and
2 deletions
Show diff stats
screen.c
@@ -223,8 +223,15 @@ static unsigned short calc_attrs(H3270 *session, int baddr, int fa_addr, int fa) | @@ -223,8 +223,15 @@ static unsigned short calc_attrs(H3270 *session, int baddr, int fa_addr, int fa) | ||
223 | return a; | 223 | return a; |
224 | } | 224 | } |
225 | 225 | ||
226 | +LIB3270_EXPORT unsigned int lib3270_get_length(H3270 *h) | ||
227 | +{ | ||
228 | + CHECK_SESSION_HANDLE(h); | ||
229 | + return h->rows * h->cols; | ||
230 | +} | ||
231 | + | ||
226 | LIB3270_EXPORT void lib3270_get_screen_size(H3270 *h, int *r, int *c) | 232 | LIB3270_EXPORT void lib3270_get_screen_size(H3270 *h, int *r, int *c) |
227 | { | 233 | { |
234 | + CHECK_SESSION_HANDLE(h); | ||
228 | *r = h->rows; | 235 | *r = h->rows; |
229 | *c = h->cols; | 236 | *c = h->cols; |
230 | } | 237 | } |
selection.c
@@ -407,9 +407,38 @@ static char * get_text(H3270 *hSession,unsigned char all) | @@ -407,9 +407,38 @@ static char * get_text(H3270 *hSession,unsigned char all) | ||
407 | return ret; | 407 | return ret; |
408 | } | 408 | } |
409 | 409 | ||
410 | -LIB3270_EXPORT char * lib3270_get_text(H3270 *hSession) | 410 | +LIB3270_EXPORT char * lib3270_get_text(H3270 *h, int offset, int len) |
411 | { | 411 | { |
412 | - return get_text(hSession,1); | 412 | + char *buffer; |
413 | + int col, maxlen; | ||
414 | + char *ptr; | ||
415 | + | ||
416 | + CHECK_SESSION_HANDLE(h); | ||
417 | + | ||
418 | + maxlen = h->rows * (h->cols+1); | ||
419 | + | ||
420 | + if(len < 0) | ||
421 | + len = (maxlen - offset); | ||
422 | + else if(len > maxlen) | ||
423 | + len = maxlen; | ||
424 | + | ||
425 | + buffer = malloc(len+1); | ||
426 | + col = offset%h->cols; | ||
427 | + ptr = buffer; | ||
428 | + | ||
429 | + while(len-- > 0) | ||
430 | + { | ||
431 | + *(ptr++) = h->text[offset++].chr; | ||
432 | + if(col++ >= h->cols && len > 0) | ||
433 | + { | ||
434 | + col = 0; | ||
435 | + *(ptr++) = '\n'; | ||
436 | + len--; | ||
437 | + } | ||
438 | + } | ||
439 | + *ptr = 0; | ||
440 | + | ||
441 | + return buffer; | ||
413 | } | 442 | } |
414 | 443 | ||
415 | LIB3270_EXPORT char * lib3270_get_selected(H3270 *hSession) | 444 | LIB3270_EXPORT char * lib3270_get_selected(H3270 *hSession) |
@@ -417,6 +446,10 @@ LIB3270_EXPORT char * lib3270_get_selected(H3270 *hSession) | @@ -417,6 +446,10 @@ LIB3270_EXPORT char * lib3270_get_selected(H3270 *hSession) | ||
417 | if(!hSession->selected || hSession->select.begin == hSession->select.end) | 446 | if(!hSession->selected || hSession->select.begin == hSession->select.end) |
418 | return NULL; | 447 | return NULL; |
419 | 448 | ||
449 | + if(!lib3270_connected(hSession)) | ||
450 | + return NULL; | ||
451 | + | ||
452 | + | ||
420 | return get_text(hSession,0); | 453 | return get_text(hSession,0); |
421 | } | 454 | } |
422 | 455 |