diff --git a/src/lib3270/selection.c b/src/lib3270/selection.c index 54db131..d45cd4a 100644 --- a/src/lib3270/selection.c +++ b/src/lib3270/selection.c @@ -372,12 +372,13 @@ LIB3270_ACTION( reselect ) return 0; } -static char * get_text(H3270 *hSession,unsigned char all) +static char * get_text(H3270 *hSession,unsigned char all, unsigned char tok) { - int row, col, baddr; - char *ret; - size_t buflen = (hSession->rows * (hSession->cols+1))+1; - size_t sz = 0; + int row, col, baddr; + char * ret; + size_t buflen = (hSession->rows * (hSession->cols+1))+1; + size_t sz = 0; + unsigned short attr = 0; if(!(lib3270_connected(hSession) && hSession->text)) { @@ -388,6 +389,15 @@ static char * get_text(H3270 *hSession,unsigned char all) ret = lib3270_malloc(buflen); baddr = 0; + + if(tok) + { + attr = hSession->text[baddr].attr; + ret[sz++] = tok; + ret[sz++] = (attr & 0x0F); + ret[sz++] = ((attr & 0xF0) >> 4); + } + for(row=0;row < hSession->rows;row++) { int cr = 0; @@ -396,6 +406,14 @@ static char * get_text(H3270 *hSession,unsigned char all) { if(all || hSession->text[baddr].attr & LIB3270_ATTR_SELECTED) { + if(tok && attr != hSession->text[baddr].attr) + { + attr = hSession->text[baddr].attr; + ret[sz++] = tok; + ret[sz++] = (attr & 0x0F); + ret[sz++] = ((attr & 0xF0) >> 4); + } + cr++; ret[sz++] = hSession->text[baddr].chr; } @@ -404,6 +422,12 @@ static char * get_text(H3270 *hSession,unsigned char all) if(cr) ret[sz++] = '\n'; + + if((sz+10) > buflen) + { + buflen += 100; + ret = lib3270_realloc(ret,buflen); + } } if(!sz) @@ -563,7 +587,7 @@ LIB3270_EXPORT char * lib3270_get_selected(H3270 *hSession) return NULL; - return get_text(hSession,0); + return get_text(hSession,0,0); } static void copy_chr(H3270 *hSession, int from, int to) @@ -602,14 +626,6 @@ int cut_addr(H3270 *hSession, int daddr, int saddr, int maxlen, int *sattr) if(hSession->ea_buf[saddr].fa) *sattr = hSession->ea_buf[saddr++].fa; -/* - if(FA_IS_PROTECTED(*sattr)) - { - saddr = lib3270_get_next_unprotected(hSession,saddr); - *sattr = lib3270_field_attribute(hSession,saddr); - } -*/ - if(FA_IS_PROTECTED(*sattr) || saddr >= maxlen) clear_chr(hSession,daddr); else diff --git a/src/pw3270/v3270/private.h b/src/pw3270/v3270/private.h index 0e54959..724d5bf 100644 --- a/src/pw3270/v3270/private.h +++ b/src/pw3270/v3270/private.h @@ -244,6 +244,8 @@ void v3270_draw_shift_status(v3270 *terminal); void v3270_draw_alt_status(v3270 *terminal); void v3270_draw_ins_status(v3270 *terminal); +void v3270_clear_clipboard(v3270 *terminal); + void v3270_update_cursor_surface(v3270 *widget,unsigned char chr,unsigned short attr); void v3270_register_io_handlers(v3270Class *cls); diff --git a/src/pw3270/v3270/selection.c b/src/pw3270/v3270/selection.c index 4213745..aace895 100644 --- a/src/pw3270/v3270/selection.c +++ b/src/pw3270/v3270/selection.c @@ -138,11 +138,7 @@ const gchar * v3270_get_selected_text(GtkWidget *widget, gboolean cut) terminal = GTK_V3270(widget); - if(terminal->clipboard) - { - g_free(terminal->clipboard); - terminal->clipboard = NULL; - } + v3270_clear_clipboard(terminal); if(cut) text = lib3270_cut_selected(terminal->host); @@ -276,7 +272,7 @@ const gchar * v3270_copy_append(GtkWidget *widget) clip = g_strconcat(terminal->clipboard,"\n",text,NULL); g_free(text); - g_free(terminal->clipboard); + v3270_clear_clipboard(terminal); terminal->clipboard = clip; diff --git a/src/pw3270/v3270/widget.c b/src/pw3270/v3270/widget.c index f256229..ed79e14 100644 --- a/src/pw3270/v3270/widget.c +++ b/src/pw3270/v3270/widget.c @@ -895,6 +895,15 @@ GtkWidget * v3270_new(void) return g_object_new(GTK_TYPE_V3270, NULL); } +void v3270_clear_clipboard(v3270 *terminal) +{ + if(terminal->clipboard) + { + g_free(terminal->clipboard); + terminal->clipboard = NULL; + } +} + #if GTK_CHECK_VERSION(3,0,0) static void v3270_destroy(GtkWidget *widget) #else @@ -969,11 +978,7 @@ static void v3270_destroy(GtkObject *widget) terminal->input_method = NULL; } - if(terminal->clipboard) - { - g_free(terminal->clipboard); - terminal->clipboard = NULL; - } + v3270_clear_clipboard(terminal); if(terminal->session_name) { -- libgit2 0.21.2