Commit 402173bcbeb93486cb004ffbfaeb26d118aca43f

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

Iniciando inclusão da ação "pastenext"

src/gtk/mainwindow.c
@@ -123,6 +123,7 @@ @@ -123,6 +123,7 @@
123 gtk_action_group_set_sensitive(group[ACTION_GROUP_OFFLINE],TRUE); 123 gtk_action_group_set_sensitive(group[ACTION_GROUP_OFFLINE],TRUE);
124 } 124 }
125 125
  126 +/*
126 #ifndef WIN32 127 #ifndef WIN32
127 static void clipboard_text_check(GtkClipboard *clipboard, const gchar *text, GtkActionGroup **group) 128 static void clipboard_text_check(GtkClipboard *clipboard, const gchar *text, GtkActionGroup **group)
128 { 129 {
@@ -130,18 +131,22 @@ @@ -130,18 +131,22 @@
130 gtk_action_group_set_sensitive(group[ACTION_GROUP_PASTE],text != NULL); 131 gtk_action_group_set_sensitive(group[ACTION_GROUP_PASTE],text != NULL);
131 } 132 }
132 #endif 133 #endif
  134 +*/
133 135
134 static void connected(GtkWidget *widget, GtkActionGroup **group) 136 static void connected(GtkWidget *widget, GtkActionGroup **group)
135 { 137 {
136 gtk_action_group_set_sensitive(group[ACTION_GROUP_ONLINE],TRUE); 138 gtk_action_group_set_sensitive(group[ACTION_GROUP_ONLINE],TRUE);
137 gtk_action_group_set_sensitive(group[ACTION_GROUP_OFFLINE],FALSE); 139 gtk_action_group_set_sensitive(group[ACTION_GROUP_OFFLINE],FALSE);
  140 + gtk_action_group_set_sensitive(group[ACTION_GROUP_PASTE],TRUE);
138 141
  142 +/*
139 #ifdef WIN32 143 #ifdef WIN32
140 gtk_action_group_set_sensitive(group[ACTION_GROUP_PASTE],TRUE); 144 gtk_action_group_set_sensitive(group[ACTION_GROUP_PASTE],TRUE);
141 #else 145 #else
142 gtk_action_group_set_sensitive(group[ACTION_GROUP_PASTE],FALSE); 146 gtk_action_group_set_sensitive(group[ACTION_GROUP_PASTE],FALSE);
143 gtk_clipboard_request_text(gtk_widget_get_clipboard(widget,GDK_SELECTION_CLIPBOARD),(GtkClipboardTextReceivedFunc) clipboard_text_check,(gpointer) group); 147 gtk_clipboard_request_text(gtk_widget_get_clipboard(widget,GDK_SELECTION_CLIPBOARD),(GtkClipboardTextReceivedFunc) clipboard_text_check,(gpointer) group);
144 #endif 148 #endif
  149 +*/
145 150
146 } 151 }
147 152
@@ -193,6 +198,11 @@ @@ -193,6 +198,11 @@
193 198
194 } 199 }
195 200
  201 + static void pastenext(GtkWidget *widget, gboolean on, GtkAction **action)
  202 + {
  203 + gtk_action_set_sensitive(action[ACTION_PASTENEXT],on);
  204 + }
  205 +
196 static void setup_input_method(GtkWidget *widget, GtkWidget *obj) 206 static void setup_input_method(GtkWidget *widget, GtkWidget *obj)
197 { 207 {
198 GtkWidget *menu = gtk_menu_new(); 208 GtkWidget *menu = gtk_menu_new();
@@ -316,7 +326,10 @@ @@ -316,7 +326,10 @@
316 gtk_action_set_visible(action[ACTION_UNFULLSCREEN],lib3270_get_toggle(host,LIB3270_TOGGLE_FULL_SCREEN)); 326 gtk_action_set_visible(action[ACTION_UNFULLSCREEN],lib3270_get_toggle(host,LIB3270_TOGGLE_FULL_SCREEN));
317 327
318 if(action[ACTION_PASTENEXT]) 328 if(action[ACTION_PASTENEXT])
  329 + {
319 gtk_action_set_sensitive(action[ACTION_PASTENEXT],FALSE); 330 gtk_action_set_sensitive(action[ACTION_PASTENEXT],FALSE);
  331 + g_signal_connect(terminal,"pastenext",G_CALLBACK(pastenext),action);
  332 + }
320 333
321 if(action[ACTION_RESELECT]) 334 if(action[ACTION_RESELECT])
322 gtk_action_set_sensitive(action[ACTION_RESELECT],FALSE); 335 gtk_action_set_sensitive(action[ACTION_RESELECT],FALSE);
src/gtk/v3270/clipboard.c
@@ -227,6 +227,8 @@ void v3270_paste_string(GtkWidget *widget, const gchar *text, const gchar *encod @@ -227,6 +227,8 @@ void v3270_paste_string(GtkWidget *widget, const gchar *text, const gchar *encod
227 227
228 next = lib3270_paste(session,buffer) ? TRUE : FALSE; 228 next = lib3270_paste(session,buffer) ? TRUE : FALSE;
229 229
  230 + trace("Pastenext is %s",next ? "On" : "Off");
  231 +
230 g_free(buffer); 232 g_free(buffer);
231 233
232 g_signal_emit(widget,v3270_widget_signal[SIGNAL_PASTENEXT], 0, next); 234 g_signal_emit(widget,v3270_widget_signal[SIGNAL_PASTENEXT], 0, next);
src/lib3270/paste.c
@@ -99,7 +99,7 @@ @@ -99,7 +99,7 @@
99 * Move the cursor back within the legal paste area. 99 * Move the cursor back within the legal paste area.
100 * Returns a Boolean indicating success. 100 * Returns a Boolean indicating success.
101 */ 101 */
102 - static int remargin(int lmargin) 102 + static int remargin(H3270 *session, int lmargin)
103 { 103 {
104 int ever = False; 104 int ever = False;
105 int baddr, b0 = 0; 105 int baddr, b0 = 0;
@@ -108,7 +108,7 @@ @@ -108,7 +108,7 @@
108 108
109 if(toggled(MARGINED_PASTE)) 109 if(toggled(MARGINED_PASTE))
110 { 110 {
111 - baddr = h3270.cursor_addr; 111 + baddr = session->cursor_addr;
112 while(BA_TO_COL(baddr) < lmargin) 112 while(BA_TO_COL(baddr) < lmargin)
113 { 113 {
114 baddr = ROWCOL_TO_BA(BA_TO_ROW(baddr), lmargin); 114 baddr = ROWCOL_TO_BA(BA_TO_ROW(baddr), lmargin);
@@ -118,8 +118,8 @@ @@ -118,8 +118,8 @@
118 ever = True; 118 ever = True;
119 } 119 }
120 120
121 - faddr = find_field_attribute(&h3270,baddr);  
122 - fa = h3270.ea_buf[faddr].fa; 121 + faddr = find_field_attribute(session,baddr);
  122 + fa = session->ea_buf[faddr].fa;
123 if (faddr == baddr || FA_IS_PROTECTED(fa)) 123 if (faddr == baddr || FA_IS_PROTECTED(fa))
124 { 124 {
125 baddr = next_unprotected(baddr); 125 baddr = next_unprotected(baddr);
@@ -152,12 +152,12 @@ @@ -152,12 +152,12 @@
152 152
153 data->qtd++; 153 data->qtd++;
154 154
155 - if(BA_TO_ROW(h3270.cursor_addr) != data->row) 155 + if(BA_TO_ROW(session->cursor_addr) != data->row)
156 { 156 {
157 - Trace("Row changed from %d to %d",data->row,BA_TO_ROW(h3270.cursor_addr));  
158 - if(!remargin(data->orig_col)) 157 + Trace("Row changed from %d to %d",data->row,BA_TO_ROW(session->cursor_addr));
  158 + if(!remargin(session,data->orig_col))
159 return 0; 159 return 0;
160 - data->row = BA_TO_ROW(h3270.cursor_addr); 160 + data->row = BA_TO_ROW(session->cursor_addr);
161 return '\n'; 161 return '\n';
162 } 162 }
163 163
@@ -177,9 +177,6 @@ LIB3270_EXPORT int lib3270_set_string(H3270 *h, const unsigned char *str) @@ -177,9 +177,6 @@ LIB3270_EXPORT int lib3270_set_string(H3270 *h, const unsigned char *str)
177 { 177 {
178 PASTE_DATA data; 178 PASTE_DATA data;
179 unsigned char last = 1; 179 unsigned char last = 1;
180 - int baddr;  
181 - int faddr;  
182 - unsigned char fa;  
183 180
184 CHECK_SESSION_HANDLE(h); 181 CHECK_SESSION_HANDLE(h);
185 182
@@ -204,10 +201,14 @@ LIB3270_EXPORT int lib3270_set_string(H3270 *h, const unsigned char *str) @@ -204,10 +201,14 @@ LIB3270_EXPORT int lib3270_set_string(H3270 *h, const unsigned char *str)
204 case '\n': 201 case '\n':
205 if(last != '\n') 202 if(last != '\n')
206 { 203 {
  204 + int baddr;
  205 + int faddr;
  206 + unsigned char fa;
  207 +
207 baddr = (h->cursor_addr + h->cols) % (h->cols * h->rows); /* down */ 208 baddr = (h->cursor_addr + h->cols) % (h->cols * h->rows); /* down */
208 baddr = (baddr / h->cols) * h->cols; /* 1st col */ 209 baddr = (baddr / h->cols) * h->cols; /* 1st col */
209 faddr = find_field_attribute(h,baddr); 210 faddr = find_field_attribute(h,baddr);
210 - fa = h3270.ea_buf[faddr].fa; 211 + fa = h->ea_buf[faddr].fa;
211 if (faddr != baddr && !FA_IS_PROTECTED(fa)) 212 if (faddr != baddr && !FA_IS_PROTECTED(fa))
212 cursor_move(baddr); 213 cursor_move(baddr);
213 else 214 else
@@ -226,12 +227,16 @@ LIB3270_EXPORT int lib3270_set_string(H3270 *h, const unsigned char *str) @@ -226,12 +227,16 @@ LIB3270_EXPORT int lib3270_set_string(H3270 *h, const unsigned char *str)
226 227
227 if(IN_3270 && toggled(MARGINED_PASTE) && BA_TO_COL(h->cursor_addr) < data.orig_col) 228 if(IN_3270 && toggled(MARGINED_PASTE) && BA_TO_COL(h->cursor_addr) < data.orig_col)
228 { 229 {
229 - if(!remargin(data.orig_col)) 230 + if(!remargin(h,data.orig_col))
230 last = 0; 231 last = 0;
231 } 232 }
  233 +
  234 + if(h->cursor_addr == data.orig_addr)
  235 + break;
232 } 236 }
233 237
234 h->resume(h); 238 h->resume(h);
  239 +
235 return data.qtd; 240 return data.qtd;
236 } 241 }
237 242