diff --git a/android/jni/main.cpp b/android/jni/main.cpp index e657c3a..bfe9ae7 100644 --- a/android/jni/main.cpp +++ b/android/jni/main.cpp @@ -78,7 +78,7 @@ static void changed(H3270 *session, int offset, int len) trace("%s: offset=%d len=%d",__FUNCTION__,offset,len); { - char *text = lib3270_get_text(PW3270_SESSION,0,-1); + char *text = lib3270_get_text(PW3270_SESSION,0,-1,'\n'); if(text) { char *strtok_r(char *str, const char *delim, char **saveptr); diff --git a/android/jni/text.cpp b/android/jni/text.cpp index 82cc2c2..44fb1e8 100644 --- a/android/jni/text.cpp +++ b/android/jni/text.cpp @@ -76,7 +76,7 @@ JNIEXPORT jbyteArray JNICALL Java_br_com_bb_pw3270_lib3270_getText(JNIEnv *env, // trace("%s starts",__FUNCTION__); - char *text = lib3270_get_text(PW3270_SESSION,0,-1); + char *text = lib3270_get_text(PW3270_SESSION,0,-1,'\n'); if(text) { diff --git a/src/include/lib3270.h b/src/include/lib3270.h index 02b1097..26c84d8 100644 --- a/src/include/lib3270.h +++ b/src/include/lib3270.h @@ -907,11 +907,12 @@ * @param h Session Handle. * @param offset Start position. * @param len Text length or -1 to all text. + * @param lf Line break char (0 to disable line breaks). * * @return Contents at position if available, or NULL. Release it with lib3270_free() * */ - LIB3270_EXPORT char * lib3270_get_text(H3270 *h, int offset, int len); + LIB3270_EXPORT char * lib3270_get_text(H3270 *h, int offset, int len, char lf); /** * Get text at requested position diff --git a/src/lib3270/macros.c b/src/lib3270/macros.c index e459704..41ea30d 100644 --- a/src/lib3270/macros.c +++ b/src/lib3270/macros.c @@ -103,7 +103,7 @@ switch(argc) { case 1: // Get entire screen - buffer = lib3270_get_text(hSession,0,-1); + buffer = lib3270_get_text(hSession,0,-1,'\n'); break; /* diff --git a/src/lib3270/screen.c b/src/lib3270/screen.c index 3538d25..80489e3 100644 --- a/src/lib3270/screen.c +++ b/src/lib3270/screen.c @@ -374,7 +374,7 @@ void screen_update(H3270 *session, int bstart, int bend) #ifdef DEBUG { - char *text = lib3270_get_text(session,0,-1); + char *text = lib3270_get_text(session,0,-1,'\n'); trace("First screen:\n%s\n",text); lib3270_free(text); } diff --git a/src/lib3270/selection.c b/src/lib3270/selection.c index ac3f99a..4425a2c 100644 --- a/src/lib3270/selection.c +++ b/src/lib3270/selection.c @@ -475,7 +475,7 @@ LIB3270_EXPORT char * lib3270_get_region(H3270 *h, int start_pos, int end_pos, u return lib3270_realloc(text,sz); } -LIB3270_EXPORT char * lib3270_get_text(H3270 *h, int offset, int len) +LIB3270_EXPORT char * lib3270_get_text(H3270 *h, int offset, int len, char lf) { char * buffer; int maxlen; @@ -517,9 +517,9 @@ LIB3270_EXPORT char * lib3270_get_text(H3270 *h, int offset, int len) offset++; len--; - if((offset%h->cols) == 0 && len > 0) + if(lf && (offset%h->cols) == 0 && len > 0) { - *(ptr++) = '\n'; + *(ptr++) = lf; len--; } } @@ -533,7 +533,7 @@ LIB3270_EXPORT char * lib3270_get_text(H3270 *h, int offset, int len) LIB3270_EXPORT char * lib3270_get_text_at(H3270 *h, int row, int col, int len) { CHECK_SESSION_HANDLE(h); - return lib3270_get_text(h, ((row-1) * h->cols) + (col-1), len); + return lib3270_get_text(h, ((row-1) * h->cols) + (col-1), len, '\n'); } LIB3270_EXPORT int lib3270_cmp_text_at(H3270 *h, int row, int col, const char *text) @@ -569,7 +569,7 @@ LIB3270_EXPORT char * lib3270_get_field_at(H3270 *session, int baddr) if(first < 0) return NULL; - return lib3270_get_text(session,first,lib3270_field_length(session,first)+1); + return lib3270_get_text(session,first,lib3270_field_length(session,first)+1,0); } LIB3270_EXPORT int lib3270_has_selection(H3270 *hSession) diff --git a/src/libpw3270cpp/local.cc b/src/libpw3270cpp/local.cc index 242068f..648d124 100644 --- a/src/libpw3270cpp/local.cc +++ b/src/libpw3270cpp/local.cc @@ -137,7 +137,7 @@ int (*_pfkey)(H3270 *hSession, int key); int (*_pakey)(H3270 *hSession, int key); int (*_wait_for_ready)(H3270 *hSession, int seconds); - char * (*_get_text)(H3270 *h, int offset, int len); + char * (*_get_text)(H3270 *h, int offset, int len, char lf); char * (*_get_text_at)(H3270 *h, int row, int col, int len); int (*_cmp_text_at)(H3270 *h, int row, int col, const char *text); int (*_set_text_at)(H3270 *h, int row, int col, const unsigned char *str); @@ -380,7 +380,7 @@ string get_text(int offset, size_t len) { string rc; - char * ptr = _get_text(hSession,offset,len); + char * ptr = _get_text(hSession,offset,len,'\n'); if(ptr) { diff --git a/src/plugins/dbus3270/gobject.c b/src/plugins/dbus3270/gobject.c index a557a67..22c5a71 100644 --- a/src/plugins/dbus3270/gobject.c +++ b/src/plugins/dbus3270/gobject.c @@ -230,7 +230,7 @@ void pw3270_dbus_get_screen_contents(PW3270Dbus *object, DBusGMethodInvocation * if(pw3270_dbus_check_valid_state(object,context)) return; - text = lib3270_get_text(hSession,0,-1); + text = lib3270_get_text(hSession,0,-1,'\n'); utftext = g_convert_with_fallback(text,-1,"UTF-8",lib3270_get_display_charset(hSession),"?",NULL,NULL,NULL); @@ -323,7 +323,7 @@ void pw3270_dbus_get_text_at(PW3270Dbus *object, int row, int col, int len, DBus if(pw3270_dbus_check_valid_state(object,context)) return; - text = lib3270_get_text(hSession,offset,len); + text = lib3270_get_text(hSession,offset,len,'\n'); if(!text) { GError *error = pw3270_dbus_get_error_from_errno(errno); diff --git a/src/pw3270/v3270/accessible.c b/src/pw3270/v3270/accessible.c index e52efb7..1da7ad0 100644 --- a/src/pw3270/v3270/accessible.c +++ b/src/pw3270/v3270/accessible.c @@ -185,7 +185,7 @@ static gunichar v3270_accessible_get_character_at_offset(AtkText *atk_text, gint if(widget == NULL) { H3270 * host = v3270_get_session(widget); - gchar * text = lib3270_get_text(host,offset,1); + gchar * text = lib3270_get_text(host,offset,1,'\n'); if(text) { @@ -346,7 +346,7 @@ static gchar * v3270_accessible_get_text_at_offset(AtkText *atk_text, gint offse case ATK_TEXT_BOUNDARY_CHAR: // Boundary is the boundary between characters // (including non-printing characters) - text = lib3270_get_text(host,offset,1); + text = lib3270_get_text(host,offset,1,'\n'); break; case ATK_TEXT_BOUNDARY_WORD_START: // Boundary is the start (i.e. first character) of a word. @@ -373,7 +373,7 @@ static gchar * v3270_accessible_get_text_at_offset(AtkText *atk_text, gint offse pos = (offset/cols)*cols; if(pos == offset) offset++; - text = lib3270_get_text(host,pos,(offset-pos)); + text = lib3270_get_text(host,pos,(offset-pos),'\n'); break; @@ -426,7 +426,7 @@ static gchar * v3270_accessible_get_text(AtkText *atk_text, gint start_pos, gint if(!lib3270_connected(host)) return g_strdup( "" ); - text = lib3270_get_text(host,start_pos,end_pos < start_pos ? -1 : (end_pos - start_pos)); + text = lib3270_get_text(host,start_pos,end_pos < start_pos ? -1 : (end_pos - start_pos),'\n'); if(text) { diff --git a/src/pw3270/v3270/selection.c b/src/pw3270/v3270/selection.c index 6595ba8..d2d836e 100644 --- a/src/pw3270/v3270/selection.c +++ b/src/pw3270/v3270/selection.c @@ -99,7 +99,7 @@ gchar * v3270_get_text(GtkWidget *widget, int offset, int len) terminal = GTK_V3270(widget); - str = lib3270_get_text(terminal->host, offset, len); + str = lib3270_get_text(terminal->host, offset, len, '\n'); if(!str) return NULL; diff --git a/src/pw3270/v3270/widget.c b/src/pw3270/v3270/widget.c index eb1c36f..52bb291 100644 --- a/src/pw3270/v3270/widget.c +++ b/src/pw3270/v3270/widget.c @@ -826,7 +826,7 @@ static void changed(H3270 *session, int offset, int len) { // Get new text, notify atk gsize bytes_written = 0; - char * text = lib3270_get_text(session,offset,len); + char * text = lib3270_get_text(session,offset,len,'\n'); if(text) { -- libgit2 0.21.2