Commit ce603b9a7ea8ec5efeec015bea3a42e7956ca7d1

Authored by perry.werneck@gmail.com
1 parent fbcc0787

Iniciando inclusao das funções para paste direto pela biblioteca

src/gtk/actions.c
@@ -210,7 +210,7 @@ void ui_connect_pakey(GtkAction *action, GtkWidget *widget, const gchar *name, c @@ -210,7 +210,7 @@ void ui_connect_pakey(GtkAction *action, GtkWidget *widget, const gchar *name, c
210 210
211 void ui_connect_index_action(GtkAction *action, GtkWidget *widget, int ix, GtkAction **lst) 211 void ui_connect_index_action(GtkAction *action, GtkWidget *widget, int ix, GtkAction **lst)
212 { 212 {
213 - trace("action(%d): %p",ix,action); 213 +// trace("action(%d): %p",ix,action);
214 214
215 switch(ix) 215 switch(ix)
216 { 216 {
src/include/lib3270/selection.h
@@ -38,4 +38,30 @@ @@ -38,4 +38,30 @@
38 LIB3270_EXPORT void lib3270_select_word(H3270 *session, int baddr); 38 LIB3270_EXPORT void lib3270_select_word(H3270 *session, int baddr);
39 LIB3270_EXPORT int lib3270_select_field_at(H3270 *session, int baddr); 39 LIB3270_EXPORT int lib3270_select_field_at(H3270 *session, int baddr);
40 40
  41 + /**
  42 + * "Paste" supplied string.
  43 + *
  44 + * @param h Session handle.
  45 + * @param str String to paste.
  46 + *
  47 + * @see lib3270_pastenext.
  48 + *
  49 + * @return Non 0 if there's more to paste with lib3270_pastenext
  50 + *
  51 + */
  52 + LIB3270_EXPORT int lib3270_paste(H3270 *h, const char *str);
  53 +
  54 + /**
  55 + * Paste remaining string.
  56 + *
  57 + * @param h Session handle.
  58 + *
  59 + * @see lib3270_paste.
  60 + *
  61 + * @return Non 0 if there's more to paste.
  62 + *
  63 + */
  64 + LIB3270_EXPORT int lib3270_pastenext(H3270 *h);
  65 +
  66 +
41 #endif // LIB3270_SELECTION_H_INCLUDED 67 #endif // LIB3270_SELECTION_H_INCLUDED
src/include/lib3270/session.h
@@ -123,6 +123,7 @@ @@ -123,6 +123,7 @@
123 void * widget; 123 void * widget;
124 124
125 // selection 125 // selection
  126 + char * paste_buffer;
126 struct 127 struct
127 { 128 {
128 int begin; 129 int begin;
src/lib3270/glue.c
@@ -139,11 +139,10 @@ void lib3270_session_free(H3270 *h) @@ -139,11 +139,10 @@ void lib3270_session_free(H3270 *h)
139 } 139 }
140 140
141 // Release memory 141 // Release memory
142 - if(h->charset)  
143 - {  
144 - free(h->charset);  
145 - h->charset = NULL;  
146 - } 142 + #define RELEASE_BUFFER(x) if(x) { free(x); x = NULL; }
  143 +
  144 + RELEASE_BUFFER(h->charset);
  145 + RELEASE_BUFFER(h->paste_buffer);
147 146
148 } 147 }
149 148
src/lib3270/selection.c
@@ -344,3 +344,30 @@ LIB3270_EXPORT char * lib3270_get_selected(H3270 *hSession) @@ -344,3 +344,30 @@ LIB3270_EXPORT char * lib3270_get_selected(H3270 *hSession)
344 344
345 return realloc(ret,sz+1); 345 return realloc(ret,sz+1);
346 } 346 }
  347 +
  348 +LIB3270_EXPORT int lib3270_paste(H3270 *h, const char *str)
  349 +{
  350 + CHECK_SESSION_HANDLE(h);
  351 +
  352 + if(!lib3270_connected(h))
  353 + {
  354 + lib3270_ring_bell(h);
  355 + return 0;
  356 + }
  357 +
  358 + return 0;
  359 +}
  360 +
  361 +LIB3270_EXPORT int lib3270_pastenext(H3270 *h)
  362 +{
  363 + CHECK_SESSION_HANDLE(h);
  364 +
  365 + if(!(lib3270_connected(h) && h->paste_buffer))
  366 + {
  367 + lib3270_ring_bell(h);
  368 + return 0;
  369 + }
  370 +
  371 +
  372 + return 0;
  373 +}