Commit b8d9f54c535115c82ba31a4b147bb3f2744f5174

Authored by perry.werneck@gmail.com
1 parent 5b3ad06f

Ativando opção para salvamento do buffer do terminal em um arquivo texto

Showing 1 changed file with 16 additions and 3 deletions   Show diff stats
@@ -313,13 +313,13 @@ LIB3270_ACTION( reselect ) @@ -313,13 +313,13 @@ LIB3270_ACTION( reselect )
313 return 0; 313 return 0;
314 } 314 }
315 315
316 -LIB3270_EXPORT char * lib3270_get_selected(H3270 *hSession) 316 +static char * get_text(H3270 *hSession,unsigned char all)
317 { 317 {
318 int row, col, baddr; 318 int row, col, baddr;
319 char *ret; 319 char *ret;
320 size_t sz = 0; 320 size_t sz = 0;
321 321
322 - if(!hSession->selected || hSession->select.begin == hSession->select.end) 322 + if(!lib3270_connected(hSession))
323 return NULL; 323 return NULL;
324 324
325 ret = malloc(hSession->rows * (hSession->cols+1)); 325 ret = malloc(hSession->rows * (hSession->cols+1));
@@ -331,7 +331,7 @@ LIB3270_EXPORT char * lib3270_get_selected(H3270 *hSession) @@ -331,7 +331,7 @@ LIB3270_EXPORT char * lib3270_get_selected(H3270 *hSession)
331 331
332 for(col = 0; col < hSession->cols;col++) 332 for(col = 0; col < hSession->cols;col++)
333 { 333 {
334 - if(hSession->text[baddr].attr & LIB3270_ATTR_SELECTED) 334 + if(all || hSession->text[baddr].attr & LIB3270_ATTR_SELECTED)
335 { 335 {
336 cr++; 336 cr++;
337 ret[sz++] = hSession->text[baddr].chr; 337 ret[sz++] = hSession->text[baddr].chr;
@@ -347,6 +347,19 @@ LIB3270_EXPORT char * lib3270_get_selected(H3270 *hSession) @@ -347,6 +347,19 @@ LIB3270_EXPORT char * lib3270_get_selected(H3270 *hSession)
347 return realloc(ret,sz+1); 347 return realloc(ret,sz+1);
348 } 348 }
349 349
  350 +LIB3270_EXPORT char * lib3270_get_text(H3270 *hSession)
  351 +{
  352 + return get_text(hSession,1);
  353 +}
  354 +
  355 +LIB3270_EXPORT char * lib3270_get_selected(H3270 *hSession)
  356 +{
  357 + if(!hSession->selected || hSession->select.begin == hSession->select.end)
  358 + return NULL;
  359 +
  360 + return get_text(hSession,0);
  361 +}
  362 +
350 LIB3270_EXPORT int lib3270_move_selection(H3270 *hSession, LIB3270_DIRECTION dir) 363 LIB3270_EXPORT int lib3270_move_selection(H3270 *hSession, LIB3270_DIRECTION dir)
351 { 364 {
352 if(!hSession->selected || hSession->select.begin == hSession->select.end) 365 if(!hSession->selected || hSession->select.begin == hSession->select.end)