Commit 3cfc57fa111a84644deea68629e27d8af635c89e
1 parent
044b6e2b
Exists in
master
and in
5 other branches
Removendo campos sem uso, incluindo suporte a auto-reconnect, iniciando reinclus…
…ao de movimentação da seleção por mouse
Showing
16 changed files
with
385 additions
and
90 deletions
Show diff stats
src/gtk/dialog.c
@@ -364,11 +364,7 @@ | @@ -364,11 +364,7 @@ | ||
364 | ); | 364 | ); |
365 | 365 | ||
366 | if(!lib3270_connect(v3270_get_session(widget),hostname,1)) | 366 | if(!lib3270_connect(v3270_get_session(widget),hostname,1)) |
367 | - { | ||
368 | - // Connection OK | ||
369 | - set_string_to_config("host","uri","%s",hostname); | ||
370 | again = FALSE; | 367 | again = FALSE; |
371 | - } | ||
372 | 368 | ||
373 | g_free(hostname); | 369 | g_free(hostname); |
374 | break; | 370 | break; |
src/gtk/globals.h
@@ -58,7 +58,7 @@ | @@ -58,7 +58,7 @@ | ||
58 | 58 | ||
59 | #include "common/common.h" | 59 | #include "common/common.h" |
60 | 60 | ||
61 | - G_GNUC_INTERNAL GtkWidget * create_main_window(void); | 61 | + G_GNUC_INTERNAL GtkWidget * create_main_window(const gchar *uri); |
62 | G_GNUC_INTERNAL void setup_font_list(GtkWidget *widget, GtkWidget *obj); | 62 | G_GNUC_INTERNAL void setup_font_list(GtkWidget *widget, GtkWidget *obj); |
63 | G_GNUC_INTERNAL void load_color_schemes(GtkWidget *widget, gchar *active); | 63 | G_GNUC_INTERNAL void load_color_schemes(GtkWidget *widget, gchar *active); |
64 | G_GNUC_INTERNAL GtkWidget * color_scheme_new(const GdkColor *current); | 64 | G_GNUC_INTERNAL GtkWidget * color_scheme_new(const GdkColor *current); |
src/gtk/main.c
@@ -106,14 +106,15 @@ static int initialize(void) | @@ -106,14 +106,15 @@ static int initialize(void) | ||
106 | int main(int argc, char *argv[]) | 106 | int main(int argc, char *argv[]) |
107 | { | 107 | { |
108 | static const gchar * appname = PACKAGE_NAME; | 108 | static const gchar * appname = PACKAGE_NAME; |
109 | + static const gchar * host = NULL; | ||
109 | int rc = 0; | 110 | int rc = 0; |
110 | 111 | ||
111 | // Process command-line options | 112 | // Process command-line options |
112 | { | 113 | { |
113 | static const GOptionEntry app_options[] = | 114 | static const GOptionEntry app_options[] = |
114 | { | 115 | { |
115 | - { "appname", 'a', 0, G_OPTION_ARG_STRING, &appname, N_( "Application name" ), PACKAGE_NAME }, | ||
116 | - | 116 | + { "appname", 'a', 0, G_OPTION_ARG_STRING, &appname, N_( "Application name" ), PACKAGE_NAME }, |
117 | + { "host", 'h', 0, G_OPTION_ARG_STRING, &host, N_( "Host to connect"), NULL }, | ||
117 | { NULL } | 118 | { NULL } |
118 | }; | 119 | }; |
119 | 120 | ||
@@ -152,7 +153,7 @@ int main(int argc, char *argv[]) | @@ -152,7 +153,7 @@ int main(int argc, char *argv[]) | ||
152 | { | 153 | { |
153 | configuration_init(); | 154 | configuration_init(); |
154 | 155 | ||
155 | - toplevel = create_main_window(); | 156 | + toplevel = create_main_window(host); |
156 | 157 | ||
157 | if(toplevel) | 158 | if(toplevel) |
158 | { | 159 | { |
src/gtk/mainwindow.c
@@ -133,6 +133,7 @@ | @@ -133,6 +133,7 @@ | ||
133 | 133 | ||
134 | static void connected(GtkWidget *widget, const gchar *host, GtkActionGroup **group) | 134 | static void connected(GtkWidget *widget, const gchar *host, GtkActionGroup **group) |
135 | { | 135 | { |
136 | + set_string_to_config("host","uri","%s",host); | ||
136 | gtk_window_set_title(GTK_WINDOW(gtk_widget_get_toplevel(widget)),host); | 137 | gtk_window_set_title(GTK_WINDOW(gtk_widget_get_toplevel(widget)),host); |
137 | gtk_action_group_set_sensitive(group[ACTION_GROUP_ONLINE],TRUE); | 138 | gtk_action_group_set_sensitive(group[ACTION_GROUP_ONLINE],TRUE); |
138 | gtk_action_group_set_sensitive(group[ACTION_GROUP_OFFLINE],FALSE); | 139 | gtk_action_group_set_sensitive(group[ACTION_GROUP_OFFLINE],FALSE); |
@@ -251,7 +252,7 @@ | @@ -251,7 +252,7 @@ | ||
251 | } | 252 | } |
252 | 253 | ||
253 | 254 | ||
254 | - GtkWidget * create_main_window(void) | 255 | + GtkWidget * create_main_window(const gchar *uri) |
255 | { | 256 | { |
256 | static const UI_WIDGET_SETUP widget_setup[] = | 257 | static const UI_WIDGET_SETUP widget_setup[] = |
257 | { | 258 | { |
@@ -280,6 +281,18 @@ | @@ -280,6 +281,18 @@ | ||
280 | GtkWidget **popup; | 281 | GtkWidget **popup; |
281 | int f; | 282 | int f; |
282 | 283 | ||
284 | + if(uri) | ||
285 | + { | ||
286 | + lib3270_set_host(host,uri); | ||
287 | + } | ||
288 | + else | ||
289 | + { | ||
290 | + gchar *ptr = get_string_from_config("host","uri",""); | ||
291 | + if(*ptr) | ||
292 | + lib3270_set_host(host,ptr); | ||
293 | + g_free(ptr); | ||
294 | + } | ||
295 | + | ||
283 | g_object_set_data_full(G_OBJECT(terminal),"toggle_actions",g_new0(GtkAction *,LIB3270_TOGGLE_COUNT),g_free); | 296 | g_object_set_data_full(G_OBJECT(terminal),"toggle_actions",g_new0(GtkAction *,LIB3270_TOGGLE_COUNT),g_free); |
284 | g_object_set_data_full(G_OBJECT(terminal),"named_actions",(gpointer) action, (GDestroyNotify) g_free); | 297 | g_object_set_data_full(G_OBJECT(terminal),"named_actions",(gpointer) action, (GDestroyNotify) g_free); |
285 | 298 | ||
@@ -352,7 +365,6 @@ | @@ -352,7 +365,6 @@ | ||
352 | g_signal_connect(terminal,"has_text",G_CALLBACK(has_text),group); | 365 | g_signal_connect(terminal,"has_text",G_CALLBACK(has_text),group); |
353 | 366 | ||
354 | g_free(path); | 367 | g_free(path); |
355 | -// gtk_widget_grab_focus(terminal); | ||
356 | 368 | ||
357 | if(lib3270_get_toggle(host,LIB3270_TOGGLE_FULL_SCREEN)) | 369 | if(lib3270_get_toggle(host,LIB3270_TOGGLE_FULL_SCREEN)) |
358 | gtk_window_fullscreen(GTK_WINDOW(window)); | 370 | gtk_window_fullscreen(GTK_WINDOW(window)); |
@@ -363,6 +375,10 @@ | @@ -363,6 +375,10 @@ | ||
363 | 375 | ||
364 | trace("%s ends",__FUNCTION__); | 376 | trace("%s ends",__FUNCTION__); |
365 | gtk_window_set_focus(GTK_WINDOW(window),terminal); | 377 | gtk_window_set_focus(GTK_WINDOW(window),terminal); |
378 | + | ||
379 | + if(lib3270_get_toggle(host,LIB3270_TOGGLE_CONNECT_ON_STARTUP)) | ||
380 | + lib3270_connect(host,NULL,0); | ||
381 | + | ||
366 | return window; | 382 | return window; |
367 | } | 383 | } |
368 | 384 |
src/gtk/v3270/mouse.c
@@ -53,15 +53,34 @@ static int decode_position(v3270 *widget, gdouble x, gdouble y) | @@ -53,15 +53,34 @@ static int decode_position(v3270 *widget, gdouble x, gdouble y) | ||
53 | return -1; | 53 | return -1; |
54 | } | 54 | } |
55 | 55 | ||
56 | -static void button_1_press(GtkWidget *widget, GdkEventType type, int baddr) | 56 | +static void single_click(v3270 *widget, int baddr) |
57 | { | 57 | { |
58 | - GTK_V3270(widget)->selecting = 1; | 58 | + switch(lib3270_get_selection_flags(widget->host,baddr)) |
59 | + { | ||
60 | + case 0x00: | ||
61 | + // Unselected area, move cursor and remove selection | ||
62 | + lib3270_set_cursor_address(widget->host,baddr); | ||
63 | + lib3270_unselect(widget->host); | ||
64 | + widget->selecting = 1; | ||
65 | + break; | ||
66 | + | ||
67 | + | ||
68 | + default: | ||
69 | + // Move selected area | ||
70 | + trace("%s: default action",__FUNCTION__); | ||
71 | + widget->selection_addr = baddr; | ||
72 | + widget->moving = 1; | ||
73 | + } | ||
74 | + | ||
59 | 75 | ||
76 | +} | ||
77 | + | ||
78 | +static void button_1_press(GtkWidget *widget, GdkEventType type, int baddr) | ||
79 | +{ | ||
60 | switch(type) | 80 | switch(type) |
61 | { | 81 | { |
62 | - case GDK_BUTTON_PRESS: // Single click - Just move cursor | ||
63 | - lib3270_set_cursor_address(GTK_V3270(widget)->host,baddr); | ||
64 | - lib3270_unselect(GTK_V3270(widget)->host); | 82 | + case GDK_BUTTON_PRESS: // Single click - set mode |
83 | + single_click(GTK_V3270(widget),baddr); | ||
65 | break; | 84 | break; |
66 | 85 | ||
67 | case GDK_2BUTTON_PRESS: // Double click - Select word | 86 | case GDK_2BUTTON_PRESS: // Double click - Select word |
@@ -132,6 +151,8 @@ gboolean v3270_button_release_event(GtkWidget *widget, GdkEventButton*event) | @@ -132,6 +151,8 @@ gboolean v3270_button_release_event(GtkWidget *widget, GdkEventButton*event) | ||
132 | { | 151 | { |
133 | case 1: | 152 | case 1: |
134 | GTK_V3270(widget)->selecting = 0; | 153 | GTK_V3270(widget)->selecting = 0; |
154 | + GTK_V3270(widget)->moving = 0; | ||
155 | + GTK_V3270(widget)->resizing = 0; | ||
135 | break; | 156 | break; |
136 | 157 | ||
137 | default: | 158 | default: |
@@ -145,13 +166,76 @@ gboolean v3270_button_release_event(GtkWidget *widget, GdkEventButton*event) | @@ -145,13 +166,76 @@ gboolean v3270_button_release_event(GtkWidget *widget, GdkEventButton*event) | ||
145 | 166 | ||
146 | gboolean v3270_motion_notify_event(GtkWidget *widget, GdkEventMotion *event) | 167 | gboolean v3270_motion_notify_event(GtkWidget *widget, GdkEventMotion *event) |
147 | { | 168 | { |
148 | - int baddr = decode_position(GTK_V3270(widget),event->x,event->y); | 169 | + v3270 * terminal = GTK_V3270(widget); |
170 | + int baddr = decode_position(terminal,event->x,event->y); | ||
149 | 171 | ||
150 | if(baddr < 0) | 172 | if(baddr < 0) |
151 | return FALSE; | 173 | return FALSE; |
152 | 174 | ||
153 | - if(GTK_V3270(widget)->selecting) | ||
154 | - lib3270_select_to(GTK_V3270(widget)->host,baddr); | 175 | + if(terminal->selecting) |
176 | + { | ||
177 | + // Select area | ||
178 | + lib3270_select_to(terminal->host,baddr); | ||
179 | + } | ||
180 | + else if(terminal->moving) | ||
181 | + { | ||
182 | + // Move selected area | ||
183 | + terminal->selection_addr = lib3270_move_selected_area(terminal->host,terminal->selection_addr,baddr); | ||
184 | + } | ||
185 | + else if(terminal->pointer_id == LIB3270_CURSOR_NORMAL) | ||
186 | + { | ||
187 | + unsigned char new_pointer = lib3270_get_selection_flags(terminal->host,baddr); | ||
188 | + if(new_pointer != terminal->pointer) | ||
189 | + { | ||
190 | + GdkWindow *window = gtk_widget_get_window(widget); | ||
191 | + trace("Pointer changes to %04x",new_pointer); | ||
192 | + | ||
193 | + switch(new_pointer & 0x1F) | ||
194 | + { | ||
195 | + case 0x00: | ||
196 | + gdk_window_set_cursor(window,v3270_cursor[V3270_CURSOR_NORMAL]); | ||
197 | + break; | ||
198 | + | ||
199 | + case 0x05: | ||
200 | + gdk_window_set_cursor(window,v3270_cursor[V3270_CURSOR_SELECTION_TOP]); | ||
201 | + break; | ||
202 | + | ||
203 | + case 0x0d: | ||
204 | + gdk_window_set_cursor(window,v3270_cursor[V3270_CURSOR_SELECTION_TOP_RIGHT]); | ||
205 | + break; | ||
206 | + | ||
207 | + case 0x09: | ||
208 | + gdk_window_set_cursor(window,v3270_cursor[V3270_CURSOR_SELECTION_RIGHT]); | ||
209 | + break; | ||
210 | + | ||
211 | + case 0x03: | ||
212 | + gdk_window_set_cursor(window,v3270_cursor[V3270_CURSOR_SELECTION_LEFT]); | ||
213 | + break; | ||
214 | + | ||
215 | + case 0x13: | ||
216 | + gdk_window_set_cursor(window,v3270_cursor[V3270_CURSOR_SELECTION_BOTTOM_LEFT]); | ||
217 | + break; | ||
218 | + | ||
219 | + case 0x11: | ||
220 | + gdk_window_set_cursor(window,v3270_cursor[V3270_CURSOR_SELECTION_BOTTOM]); | ||
221 | + break; | ||
222 | + | ||
223 | + case 0x19: | ||
224 | + gdk_window_set_cursor(window,v3270_cursor[V3270_CURSOR_SELECTION_BOTTOM_RIGHT]); | ||
225 | + break; | ||
226 | + | ||
227 | + case 0x07: | ||
228 | + gdk_window_set_cursor(window,v3270_cursor[V3270_CURSOR_SELECTION_TOP_LEFT]); | ||
229 | + break; | ||
230 | + | ||
231 | + default: | ||
232 | + gdk_window_set_cursor(window,v3270_cursor[V3270_CURSOR_MOVE_SELECTION]); | ||
233 | + | ||
234 | + } | ||
235 | + | ||
236 | + terminal->pointer = new_pointer; | ||
237 | + } | ||
238 | + } | ||
155 | 239 | ||
156 | return FALSE; | 240 | return FALSE; |
157 | } | 241 | } |
src/gtk/v3270/private.h
@@ -82,7 +82,24 @@ G_BEGIN_DECLS | @@ -82,7 +82,24 @@ G_BEGIN_DECLS | ||
82 | 82 | ||
83 | /*--[ Globals ]--------------------------------------------------------------------------------------*/ | 83 | /*--[ Globals ]--------------------------------------------------------------------------------------*/ |
84 | 84 | ||
85 | - G_GNUC_INTERNAL guint v3270_widget_signal[LAST_SIGNAL]; | 85 | + #define V3270_CURSOR_NORMAL LIB3270_CURSOR_NORMAL |
86 | + #define V3270_CURSOR_WAITING LIB3270_CURSOR_WAITING | ||
87 | + #define V3270_CURSOR_LOCKED LIB3270_CURSOR_LOCKED | ||
88 | + | ||
89 | + #define V3270_CURSOR_MOVE_SELECTION LIB3270_CURSOR_USER | ||
90 | + #define V3270_CURSOR_SELECTION_TOP_LEFT LIB3270_CURSOR_USER+1 | ||
91 | + #define V3270_CURSOR_SELECTION_TOP_RIGHT LIB3270_CURSOR_USER+2 | ||
92 | + #define V3270_CURSOR_SELECTION_TOP LIB3270_CURSOR_USER+3 | ||
93 | + #define V3270_CURSOR_SELECTION_BOTTOM_LEFT LIB3270_CURSOR_USER+4 | ||
94 | + #define V3270_CURSOR_SELECTION_BOTTOM_RIGHT LIB3270_CURSOR_USER+5 | ||
95 | + #define V3270_CURSOR_SELECTION_BOTTOM LIB3270_CURSOR_USER+6 | ||
96 | + #define V3270_CURSOR_SELECTION_LEFT LIB3270_CURSOR_USER+7 | ||
97 | + #define V3270_CURSOR_SELECTION_RIGHT LIB3270_CURSOR_USER+8 | ||
98 | + | ||
99 | + #define V3270_CURSOR_COUNT LIB3270_CURSOR_USER+9 | ||
100 | + | ||
101 | + G_GNUC_INTERNAL guint v3270_widget_signal[LAST_SIGNAL]; | ||
102 | + G_GNUC_INTERNAL GdkCursor * v3270_cursor[V3270_CURSOR_COUNT]; | ||
86 | 103 | ||
87 | /*--[ Prototipes ]-----------------------------------------------------------------------------------*/ | 104 | /*--[ Prototipes ]-----------------------------------------------------------------------------------*/ |
88 | 105 |
src/gtk/v3270/v3270.h
@@ -146,7 +146,9 @@ | @@ -146,7 +146,9 @@ | ||
146 | GtkWidget parent; | 146 | GtkWidget parent; |
147 | 147 | ||
148 | /* private */ | 148 | /* private */ |
149 | - int selecting : 1; | 149 | + int selecting : 1; /**< Selecting region */ |
150 | + int moving : 1; /**< Moving selected region */ | ||
151 | + int resizing : 1; /**< Resizing selected region */ | ||
150 | 152 | ||
151 | #if GTK_CHECK_VERSION(3,0,0) | 153 | #if GTK_CHECK_VERSION(3,0,0) |
152 | 154 | ||
@@ -158,7 +160,11 @@ | @@ -158,7 +160,11 @@ | ||
158 | GSource * timer; | 160 | GSource * timer; |
159 | GtkIMContext * input_method; | 161 | GtkIMContext * input_method; |
160 | unsigned short keyflags; | 162 | unsigned short keyflags; |
161 | - gchar * clipboard; /**< Clipboard contents (text only) */ | 163 | + gchar * clipboard; /**< Clipboard contents (text only) */ |
164 | + | ||
165 | + LIB3270_CURSOR pointer_id; | ||
166 | + unsigned char pointer; /** Mouse pointer ID */ | ||
167 | + int selection_addr; /** Selection addr */ | ||
162 | 168 | ||
163 | /* Font info */ | 169 | /* Font info */ |
164 | gchar * font_family; | 170 | gchar * font_family; |
src/gtk/v3270/widget.c
@@ -50,8 +50,8 @@ | @@ -50,8 +50,8 @@ | ||
50 | 50 | ||
51 | /*--[ Globals ]--------------------------------------------------------------------------------------*/ | 51 | /*--[ Globals ]--------------------------------------------------------------------------------------*/ |
52 | 52 | ||
53 | - guint v3270_widget_signal[LAST_SIGNAL] = { 0 }; | ||
54 | - static GdkCursor * v3270_cursor[LIB3270_CURSOR_USER] = { 0 }; | 53 | + guint v3270_widget_signal[LAST_SIGNAL] = { 0 }; |
54 | + GdkCursor * v3270_cursor[V3270_CURSOR_COUNT] = { 0 }; | ||
55 | 55 | ||
56 | /*--[ Prototipes ]-----------------------------------------------------------------------------------*/ | 56 | /*--[ Prototipes ]-----------------------------------------------------------------------------------*/ |
57 | 57 | ||
@@ -262,9 +262,58 @@ static void v3270_class_init(v3270Class *klass) | @@ -262,9 +262,58 @@ static void v3270_class_init(v3270Class *klass) | ||
262 | v3270_register_io_handlers(klass); | 262 | v3270_register_io_handlers(klass); |
263 | 263 | ||
264 | // Cursors | 264 | // Cursors |
265 | - v3270_cursor[LIB3270_CURSOR_NORMAL] = gdk_cursor_new(GDK_XTERM); | ||
266 | - v3270_cursor[LIB3270_CURSOR_WAITING] = gdk_cursor_new(GDK_WATCH); | ||
267 | - v3270_cursor[LIB3270_CURSOR_LOCKED] = gdk_cursor_new(GDK_X_CURSOR); | 265 | + { |
266 | +#ifdef WIN32 | ||
267 | + static const gchar * cr[V3270_CURSOR_COUNT] = | ||
268 | + { | ||
269 | + "arrow", | ||
270 | + "wait", | ||
271 | + "arrow", | ||
272 | + "sizeall", | ||
273 | + "sizenwse", // Top-left | ||
274 | + "sizenesw", // Top-right | ||
275 | + "sizens", // Top | ||
276 | + "sizenesw", // Bottom-left | ||
277 | + "sizenwse", // Bottom-right | ||
278 | + "sizens", // Bottom | ||
279 | + "sizewe", // Left | ||
280 | + "sizewe", // Right | ||
281 | + } | ||
282 | +#else | ||
283 | + static const int cr[V3270_CURSOR_COUNT] = | ||
284 | + { | ||
285 | + GDK_XTERM, | ||
286 | + GDK_WATCH, | ||
287 | + GDK_X_CURSOR, | ||
288 | + GDK_FLEUR, | ||
289 | + GDK_TOP_LEFT_CORNER, // Top-left | ||
290 | + GDK_TOP_RIGHT_CORNER, // Top-right | ||
291 | + GDK_TOP_SIDE, // Top | ||
292 | + GDK_BOTTOM_LEFT_CORNER, // Bottom-left | ||
293 | + GDK_BOTTOM_RIGHT_CORNER, // Bottom-right | ||
294 | + GDK_BOTTOM_SIDE, // Bottom | ||
295 | + GDK_LEFT_SIDE, // Left | ||
296 | + GDK_RIGHT_SIDE, // Right | ||
297 | + }; | ||
298 | +#endif // WIN32 | ||
299 | + | ||
300 | + int f; | ||
301 | + | ||
302 | + for(f=0;f<V3270_CURSOR_COUNT;f++) | ||
303 | + { | ||
304 | + #ifdef WIN32 | ||
305 | + v3270_cursor[f] = gdk_cursor_new_from_name(gdk_display_get_default(),cr[f]); | ||
306 | + #else | ||
307 | + v3270_cursor[f] = gdk_cursor_new(cr[f]); | ||
308 | + #endif | ||
309 | + } | ||
310 | + } | ||
311 | +/* | ||
312 | + v3270_cursor[V3270_CURSOR_NORMAL] = gdk_cursor_new(GDK_XTERM); | ||
313 | + v3270_cursor[V3270_CURSOR_WAITING] = gdk_cursor_new(GDK_WATCH); | ||
314 | + v3270_cursor[V3270_CURSOR_LOCKED] = gdk_cursor_new(GDK_X_CURSOR); | ||
315 | + v3270_cursor[] | ||
316 | +*/ | ||
268 | 317 | ||
269 | // Signals | 318 | // Signals |
270 | widget_class->activate_signal = | 319 | widget_class->activate_signal = |
@@ -513,6 +562,7 @@ static void select_cursor(H3270 *session, LIB3270_CURSOR id) | @@ -513,6 +562,7 @@ static void select_cursor(H3270 *session, LIB3270_CURSOR id) | ||
513 | 562 | ||
514 | if(gtk_widget_get_realized(widget) && gtk_widget_get_has_window(widget)) | 563 | if(gtk_widget_get_realized(widget) && gtk_widget_get_has_window(widget)) |
515 | { | 564 | { |
565 | + GTK_V3270(widget)->pointer_id = id; | ||
516 | gdk_window_set_cursor(gtk_widget_get_window(widget),v3270_cursor[id]); | 566 | gdk_window_set_cursor(gtk_widget_get_window(widget),v3270_cursor[id]); |
517 | } | 567 | } |
518 | } | 568 | } |
@@ -989,25 +1039,9 @@ int v3270_connect(GtkWidget *widget, const gchar *host) | @@ -989,25 +1039,9 @@ int v3270_connect(GtkWidget *widget, const gchar *host) | ||
989 | 1039 | ||
990 | g_return_val_if_fail(GTK_IS_V3270(widget),EINVAL); | 1040 | g_return_val_if_fail(GTK_IS_V3270(widget),EINVAL); |
991 | 1041 | ||
992 | - | ||
993 | terminal = GTK_V3270(widget); | 1042 | terminal = GTK_V3270(widget); |
994 | 1043 | ||
995 | - if(host) | ||
996 | - { | ||
997 | - set_string_to_config("host","uri","%s",host); | ||
998 | - rc = lib3270_connect(terminal->host,host,0); | ||
999 | - } | ||
1000 | - else | ||
1001 | - { | ||
1002 | - gchar *hs = get_string_from_config("host","uri",""); | ||
1003 | - | ||
1004 | - trace("[%s]",hs); | ||
1005 | - | ||
1006 | - if(*hs) | ||
1007 | - rc = lib3270_connect(terminal->host,hs,0); | ||
1008 | - | ||
1009 | - g_free(hs); | ||
1010 | - } | 1044 | + rc = lib3270_connect(terminal->host,host,0); |
1011 | 1045 | ||
1012 | trace("%s exits with rc=%d (%s)",__FUNCTION__,rc,strerror(rc)); | 1046 | trace("%s exits with rc=%d (%s)",__FUNCTION__,rc,strerror(rc)); |
1013 | 1047 | ||
@@ -1040,8 +1074,10 @@ static void v3270_activate(GtkWidget *widget) | @@ -1040,8 +1074,10 @@ static void v3270_activate(GtkWidget *widget) | ||
1040 | 1074 | ||
1041 | if(lib3270_connected(terminal->host)) | 1075 | if(lib3270_connected(terminal->host)) |
1042 | lib3270_enter(terminal->host); | 1076 | lib3270_enter(terminal->host); |
1043 | - else | 1077 | + else if(lib3270_get_host(terminal->host)) |
1044 | v3270_connect(widget,NULL); | 1078 | v3270_connect(widget,NULL); |
1079 | + else | ||
1080 | + g_warning("Terminal widget %p activated without connection or valid hostname",terminal); | ||
1045 | } | 1081 | } |
1046 | 1082 | ||
1047 | const GtkWidgetClass * v3270_get_parent_class(void) | 1083 | const GtkWidgetClass * v3270_get_parent_class(void) |
src/include/lib3270.h
@@ -300,6 +300,28 @@ | @@ -300,6 +300,28 @@ | ||
300 | */ | 300 | */ |
301 | LIB3270_EXPORT void lib3270_register_schange(H3270 *h,LIB3270_STATE tx, void (*func)(H3270 *, int, void *),void *data); | 301 | LIB3270_EXPORT void lib3270_register_schange(H3270 *h,LIB3270_STATE tx, void (*func)(H3270 *, int, void *),void *data); |
302 | 302 | ||
303 | + | ||
304 | + /** | ||
305 | + * Set host id for the connect/reconnect operations. | ||
306 | + * | ||
307 | + * @param h Session handle. | ||
308 | + * @param n Host ID to set. | ||
309 | + * | ||
310 | + * @return Pointer to host id set (internal data, do not change it) | ||
311 | + * | ||
312 | + */ | ||
313 | + LIB3270_EXPORT const char * lib3270_set_host(H3270 *h, const char *n); | ||
314 | + | ||
315 | + /** | ||
316 | + * Get host id for the connect/reconnect operations. | ||
317 | + * | ||
318 | + * @param h Session handle. | ||
319 | + * | ||
320 | + * @return Pointer to host id set (internal data, do not change it) | ||
321 | + * | ||
322 | + */ | ||
323 | + LIB3270_EXPORT const char * lib3270_get_host(H3270 *h); | ||
324 | + | ||
303 | /** | 325 | /** |
304 | * Network connect operation, keep main loop running | 326 | * Network connect operation, keep main loop running |
305 | * | 327 | * |
@@ -307,7 +329,7 @@ | @@ -307,7 +329,7 @@ | ||
307 | * side-effects. | 329 | * side-effects. |
308 | * | 330 | * |
309 | * @param h Session handle. | 331 | * @param h Session handle. |
310 | - * @param n Host ID | 332 | + * @param n Host ID (NULL to use the last one) |
311 | * @param wait Non zero to wait for connection to be ok. | 333 | * @param wait Non zero to wait for connection to be ok. |
312 | * | 334 | * |
313 | * @return 0 for success, EAGAIN if auto-reconnect is in progress, EBUSY if connected, ENOTCONN if connection has failed, -1 on unexpected failure. | 335 | * @return 0 for success, EAGAIN if auto-reconnect is in progress, EBUSY if connected, ENOTCONN if connection has failed, -1 on unexpected failure. |
@@ -544,8 +566,6 @@ | @@ -544,8 +566,6 @@ | ||
544 | */ | 566 | */ |
545 | LIB3270_EXPORT const char * lib3270_get_luname(H3270 *h); | 567 | LIB3270_EXPORT const char * lib3270_get_luname(H3270 *h); |
546 | 568 | ||
547 | - LIB3270_EXPORT const char * lib3270_get_host(H3270 *h); | ||
548 | - | ||
549 | #define lib3270_has_printer_session(h) (h->oia_flag[LIB3270_FLAG_PRINTER] != 0) | 569 | #define lib3270_has_printer_session(h) (h->oia_flag[LIB3270_FLAG_PRINTER] != 0) |
550 | #define lib3270_has_active_script(h) (h->oia_flag[LIB3270_FLAG_SCRIPT] != 0) | 570 | #define lib3270_has_active_script(h) (h->oia_flag[LIB3270_FLAG_SCRIPT] != 0) |
551 | #define lib3270_get_typeahead(h) (h->oia_flag[LIB3270_FLAG_TYPEAHEAD] != 0) | 571 | #define lib3270_get_typeahead(h) (h->oia_flag[LIB3270_FLAG_TYPEAHEAD] != 0) |
src/include/lib3270/selection.h
@@ -74,6 +74,18 @@ | @@ -74,6 +74,18 @@ | ||
74 | LIB3270_EXPORT int lib3270_move_selection(H3270 *h, LIB3270_DIRECTION dir); | 74 | LIB3270_EXPORT int lib3270_move_selection(H3270 *h, LIB3270_DIRECTION dir); |
75 | 75 | ||
76 | /** | 76 | /** |
77 | + * Move selected box. | ||
78 | + * | ||
79 | + * @param h Session handle. | ||
80 | + * @param from Address of origin position inside the selected buffer. | ||
81 | + * @param to Address of the new origin position. | ||
82 | + * | ||
83 | + * @return The new origin position. | ||
84 | + * | ||
85 | + */ | ||
86 | + LIB3270_EXPORT int lib3270_move_selected_area(H3270 *h, int from, int to); | ||
87 | + | ||
88 | + /** | ||
77 | * Get addresses of selected area. | 89 | * Get addresses of selected area. |
78 | * | 90 | * |
79 | * @param h Session handle. | 91 | * @param h Session handle. |
@@ -85,5 +97,16 @@ | @@ -85,5 +97,16 @@ | ||
85 | */ | 97 | */ |
86 | LIB3270_EXPORT int lib3270_get_selected_addr(H3270 *hSession, int *begin, int *end); | 98 | LIB3270_EXPORT int lib3270_get_selected_addr(H3270 *hSession, int *begin, int *end); |
87 | 99 | ||
100 | + /** | ||
101 | + * Get bitmasked flag for the current selection. | ||
102 | + * | ||
103 | + * Calculate flags to help drawing of the correct mouse pointer over a selection. | ||
104 | + * | ||
105 | + * @param h Session handle. | ||
106 | + * @param baddr Position. | ||
107 | + * | ||
108 | + * @return bitmask for mouse pointer. | ||
109 | + */ | ||
110 | + LIB3270_EXPORT unsigned char lib3270_get_selection_flags(H3270 *h, int baddr); | ||
88 | 111 | ||
89 | #endif // LIB3270_SELECTION_H_INCLUDED | 112 | #endif // LIB3270_SELECTION_H_INCLUDED |
src/include/lib3270/session.h
@@ -93,7 +93,6 @@ | @@ -93,7 +93,6 @@ | ||
93 | 93 | ||
94 | char * current_host; /**< the hostname part, stripped of qualifiers, luname and port number */ | 94 | char * current_host; /**< the hostname part, stripped of qualifiers, luname and port number */ |
95 | char * full_current_host; /**< the entire string, for use in reconnecting */ | 95 | char * full_current_host; /**< the entire string, for use in reconnecting */ |
96 | - char * reconnect_host; | ||
97 | char * qualified_host; | 96 | char * qualified_host; |
98 | char auto_reconnect_inprogress; | 97 | char auto_reconnect_inprogress; |
99 | 98 |
src/lib3270/api.h
@@ -379,7 +379,7 @@ | @@ -379,7 +379,7 @@ | ||
379 | 379 | ||
380 | /* Get connection info */ | 380 | /* Get connection info */ |
381 | #define get_connected_lu(h) lib3270_get_luname(h) | 381 | #define get_connected_lu(h) lib3270_get_luname(h) |
382 | - #define get_current_host(h) lib3270_get_host(h) | 382 | +// #define get_current_host(h) lib3270_get_host(h) |
383 | 383 | ||
384 | LOCAL_EXTERN SCRIPT_STATE status_script(SCRIPT_STATE state); | 384 | LOCAL_EXTERN SCRIPT_STATE status_script(SCRIPT_STATE state); |
385 | 385 |
src/lib3270/globals.h
@@ -212,9 +212,11 @@ LIB3270_INTERNAL char *hostname; | @@ -212,9 +212,11 @@ LIB3270_INTERNAL char *hostname; | ||
212 | 212 | ||
213 | #endif /*]*/ | 213 | #endif /*]*/ |
214 | 214 | ||
215 | -#if defined(LOCAL_PROCESS) /*[*/ | 215 | +/* |
216 | +#if defined(LOCAL_PROCESS) | ||
216 | LIB3270_INTERNAL Boolean local_process; | 217 | LIB3270_INTERNAL Boolean local_process; |
217 | -#endif /*]*/ | 218 | +#endif |
219 | +*/ | ||
218 | 220 | ||
219 | // LIB3270_INTERNAL int maxCOLS; | 221 | // LIB3270_INTERNAL int maxCOLS; |
220 | // LIB3270_INTERNAL int maxROWS; | 222 | // LIB3270_INTERNAL int maxROWS; |
src/lib3270/host.c
@@ -194,8 +194,9 @@ hostfile_lookup(const char *name, char **hostname, char **loginstring) | @@ -194,8 +194,9 @@ hostfile_lookup(const char *name, char **hostname, char **loginstring) | ||
194 | } | 194 | } |
195 | */ | 195 | */ |
196 | 196 | ||
197 | -#if defined(LOCAL_PROCESS) /*[*/ | ||
198 | -/* Recognize and translate "-e" options. */ | 197 | +/* |
198 | +#if defined(LOCAL_PROCESS) | ||
199 | +// Recognize and translate "-e" options. | ||
199 | static const char * | 200 | static const char * |
200 | parse_localprocess(const char *s) | 201 | parse_localprocess(const char *s) |
201 | { | 202 | { |
@@ -216,7 +217,8 @@ parse_localprocess(const char *s) | @@ -216,7 +217,8 @@ parse_localprocess(const char *s) | ||
216 | } | 217 | } |
217 | return CN; | 218 | return CN; |
218 | } | 219 | } |
219 | -#endif /*]*/ | 220 | +#endif |
221 | +*/ | ||
220 | 222 | ||
221 | /* | 223 | /* |
222 | * Strip qualifiers from a hostname. | 224 | * Strip qualifiers from a hostname. |
@@ -480,16 +482,18 @@ static int do_connect(H3270 *hSession, const char *n) | @@ -480,16 +482,18 @@ static int do_connect(H3270 *hSession, const char *n) | ||
480 | Boolean resolving; | 482 | Boolean resolving; |
481 | Boolean pending; | 483 | Boolean pending; |
482 | static Boolean ansi_host; | 484 | static Boolean ansi_host; |
483 | - const char *localprocess_cmd = NULL; | 485 | +// const char *localprocess_cmd = NULL; |
484 | Boolean has_colons = False; | 486 | Boolean has_colons = False; |
485 | 487 | ||
486 | - if (CONNECTED || hSession->auto_reconnect_inprogress) | ||
487 | - return 0; | 488 | + if (lib3270_connected(hSession) || hSession->auto_reconnect_inprogress) |
489 | + return EBUSY; | ||
488 | 490 | ||
489 | /* Skip leading blanks. */ | 491 | /* Skip leading blanks. */ |
490 | while (*n == ' ') | 492 | while (*n == ' ') |
491 | n++; | 493 | n++; |
492 | - if (!*n) { | 494 | + |
495 | + if (!*n) | ||
496 | + { | ||
493 | popup_an_error(hSession,_( "Invalid (empty) hostname" )); | 497 | popup_an_error(hSession,_( "Invalid (empty) hostname" )); |
494 | return -1; | 498 | return -1; |
495 | } | 499 | } |
@@ -503,19 +507,16 @@ static int do_connect(H3270 *hSession, const char *n) | @@ -503,19 +507,16 @@ static int do_connect(H3270 *hSession, const char *n) | ||
503 | *s-- = '\0'; | 507 | *s-- = '\0'; |
504 | 508 | ||
505 | /* Remember this hostname, as the last hostname we connected to. */ | 509 | /* Remember this hostname, as the last hostname we connected to. */ |
506 | - Replace(hSession->reconnect_host, NewString(nb)); | 510 | + lib3270_set_host(hSession,nb); |
507 | 511 | ||
508 | -// #if defined(X3270_DISPLAY) | ||
509 | -// /* Remember this hostname in the recent connection list and file. */ | ||
510 | -// save_recent(nb); | ||
511 | -// #endif | ||
512 | - | ||
513 | -#if defined(LOCAL_PROCESS) /*[*/ | 512 | +/* |
513 | +#if defined(LOCAL_PROCESS) | ||
514 | if ((localprocess_cmd = parse_localprocess(nb)) != CN) { | 514 | if ((localprocess_cmd = parse_localprocess(nb)) != CN) { |
515 | chost = localprocess_cmd; | 515 | chost = localprocess_cmd; |
516 | port = appres.port; | 516 | port = appres.port; |
517 | } else | 517 | } else |
518 | -#endif /*]*/ | 518 | +#endif |
519 | +*/ | ||
519 | { | 520 | { |
520 | Boolean needed; | 521 | Boolean needed; |
521 | 522 | ||
@@ -541,12 +542,12 @@ static int do_connect(H3270 *hSession, const char *n) | @@ -541,12 +542,12 @@ static int do_connect(H3270 *hSession, const char *n) | ||
541 | * full_current_host is the entire string, for use in reconnecting | 542 | * full_current_host is the entire string, for use in reconnecting |
542 | */ | 543 | */ |
543 | if (n != hSession->full_current_host) | 544 | if (n != hSession->full_current_host) |
544 | - { | ||
545 | - Replace(hSession->full_current_host, NewString(n)); | ||
546 | - } | 545 | + lib3270_set_host(hSession,n); |
547 | 546 | ||
548 | Replace(hSession->current_host, CN); | 547 | Replace(hSession->current_host, CN); |
549 | 548 | ||
549 | +/* | ||
550 | + | ||
550 | if (localprocess_cmd != CN) { | 551 | if (localprocess_cmd != CN) { |
551 | if (hSession->full_current_host[strlen(OptLocalProcess)] != '\0') | 552 | if (hSession->full_current_host[strlen(OptLocalProcess)] != '\0') |
552 | hSession->current_host = NewString(hSession->full_current_host + strlen(OptLocalProcess) + 1); | 553 | hSession->current_host = NewString(hSession->full_current_host + strlen(OptLocalProcess) + 1); |
@@ -555,6 +556,7 @@ static int do_connect(H3270 *hSession, const char *n) | @@ -555,6 +556,7 @@ static int do_connect(H3270 *hSession, const char *n) | ||
555 | } else { | 556 | } else { |
556 | hSession->current_host = s; | 557 | hSession->current_host = s; |
557 | } | 558 | } |
559 | +*/ | ||
558 | 560 | ||
559 | has_colons = (strchr(chost, ':') != NULL); | 561 | has_colons = (strchr(chost, ':') != NULL); |
560 | 562 | ||
@@ -569,7 +571,7 @@ static int do_connect(H3270 *hSession, const char *n) | @@ -569,7 +571,7 @@ static int do_connect(H3270 *hSession, const char *n) | ||
569 | 571 | ||
570 | /* Attempt contact. */ | 572 | /* Attempt contact. */ |
571 | hSession->ever_3270 = False; | 573 | hSession->ever_3270 = False; |
572 | - hSession->net_sock = net_connect(hSession, chost, port, localprocess_cmd != CN, &resolving,&pending); | 574 | + hSession->net_sock = net_connect(hSession, chost, port, 0, &resolving,&pending); |
573 | 575 | ||
574 | if (hSession->net_sock < 0 && !resolving) | 576 | if (hSession->net_sock < 0 && !resolving) |
575 | { | 577 | { |
@@ -612,6 +614,16 @@ static int do_connect(H3270 *hSession, const char *n) | @@ -612,6 +614,16 @@ static int do_connect(H3270 *hSession, const char *n) | ||
612 | return 0; | 614 | return 0; |
613 | } | 615 | } |
614 | 616 | ||
617 | +/** | ||
618 | + * Connect to selected host. | ||
619 | + * | ||
620 | + * @param h Session handle. | ||
621 | + * @param n Hostname (null to reconnect to the last one; | ||
622 | + * @param wait Wait for connection ok before return. | ||
623 | + * | ||
624 | + * @return 0 if the connection was ok, non zero on error. | ||
625 | + * | ||
626 | + */ | ||
615 | int lib3270_connect(H3270 *h, const char *n, int wait) | 627 | int lib3270_connect(H3270 *h, const char *n, int wait) |
616 | { | 628 | { |
617 | int rc; | 629 | int rc; |
@@ -627,7 +639,11 @@ int lib3270_connect(H3270 *h, const char *n, int wait) | @@ -627,7 +639,11 @@ int lib3270_connect(H3270 *h, const char *n, int wait) | ||
627 | return EBUSY; | 639 | return EBUSY; |
628 | 640 | ||
629 | if(!n) | 641 | if(!n) |
630 | - return ENOENT; | 642 | + { |
643 | + n = h->full_current_host; | ||
644 | + if(!n) | ||
645 | + return EINVAL; | ||
646 | + } | ||
631 | 647 | ||
632 | rc = do_connect(h,n); | 648 | rc = do_connect(h,n); |
633 | if(rc) | 649 | if(rc) |
@@ -654,7 +670,7 @@ int lib3270_connect(H3270 *h, const char *n, int wait) | @@ -654,7 +670,7 @@ int lib3270_connect(H3270 *h, const char *n, int wait) | ||
654 | */ | 670 | */ |
655 | static void try_reconnect(H3270 *session) | 671 | static void try_reconnect(H3270 *session) |
656 | { | 672 | { |
657 | - WriteLog("3270","Starting auto-reconnect (Host: %s)",session->reconnect_host ? session->reconnect_host : "-"); | 673 | + WriteLog("3270","Starting auto-reconnect (Host: %s)",session->full_current_host ? session->full_current_host : "-"); |
658 | session->auto_reconnect_inprogress = False; | 674 | session->auto_reconnect_inprogress = False; |
659 | lib3270_reconnect(session,0); | 675 | lib3270_reconnect(session,0); |
660 | } | 676 | } |
@@ -758,6 +774,29 @@ void lib3270_st_changed(H3270 *h, int tx, int mode) | @@ -758,6 +774,29 @@ void lib3270_st_changed(H3270 *h, int tx, int mode) | ||
758 | } | 774 | } |
759 | } | 775 | } |
760 | 776 | ||
777 | +LIB3270_EXPORT const char * lib3270_set_host(H3270 *h, const char *n) | ||
778 | +{ | ||
779 | + CHECK_SESSION_HANDLE(h); | ||
780 | + | ||
781 | + Trace("%s: %p",__FUNCTION__,n); | ||
782 | + | ||
783 | + if(!n) | ||
784 | + return NULL; | ||
785 | + | ||
786 | + if(h->full_current_host) | ||
787 | + free(h->full_current_host); | ||
788 | + | ||
789 | + h->full_current_host = strdup(n); | ||
790 | + | ||
791 | + return h->full_current_host; | ||
792 | +} | ||
793 | + | ||
794 | +LIB3270_EXPORT const char * lib3270_get_host(H3270 *h) | ||
795 | +{ | ||
796 | + CHECK_SESSION_HANDLE(h); | ||
797 | + return h->full_current_host; | ||
798 | +} | ||
799 | + | ||
761 | LIB3270_EXPORT int lib3270_reconnect(H3270 *h,int wait) | 800 | LIB3270_EXPORT int lib3270_reconnect(H3270 *h,int wait) |
762 | { | 801 | { |
763 | int rc; | 802 | int rc; |
@@ -767,13 +806,13 @@ LIB3270_EXPORT int lib3270_reconnect(H3270 *h,int wait) | @@ -767,13 +806,13 @@ LIB3270_EXPORT int lib3270_reconnect(H3270 *h,int wait) | ||
767 | if (CONNECTED || HALF_CONNECTED) | 806 | if (CONNECTED || HALF_CONNECTED) |
768 | return EBUSY; | 807 | return EBUSY; |
769 | 808 | ||
770 | - if (h->current_host == CN) | ||
771 | - return ENOENT; | 809 | + if (h->full_current_host == CN) |
810 | + return EINVAL; | ||
772 | 811 | ||
773 | if (h->auto_reconnect_inprogress) | 812 | if (h->auto_reconnect_inprogress) |
774 | return EBUSY; | 813 | return EBUSY; |
775 | 814 | ||
776 | - rc = lib3270_connect(h,h->reconnect_host,wait); | 815 | + rc = lib3270_connect(h,h->full_current_host,wait); |
777 | 816 | ||
778 | if(rc) | 817 | if(rc) |
779 | { | 818 | { |
@@ -790,8 +829,3 @@ LIB3270_EXPORT const char * lib3270_get_luname(H3270 *h) | @@ -790,8 +829,3 @@ LIB3270_EXPORT const char * lib3270_get_luname(H3270 *h) | ||
790 | return h->connected_lu; | 829 | return h->connected_lu; |
791 | } | 830 | } |
792 | 831 | ||
793 | -LIB3270_EXPORT const char * lib3270_get_host(H3270 *h) | ||
794 | -{ | ||
795 | - CHECK_SESSION_HANDLE(h); | ||
796 | - return h->current_host; | ||
797 | -} |
src/lib3270/selection.c
@@ -71,6 +71,20 @@ static void update_selected_rectangle(H3270 *session) | @@ -71,6 +71,20 @@ static void update_selected_rectangle(H3270 *session) | ||
71 | p[1].row = (end/session->cols); | 71 | p[1].row = (end/session->cols); |
72 | p[1].col = (end%session->cols); | 72 | p[1].col = (end%session->cols); |
73 | 73 | ||
74 | + if(p[0].row > p[1].row) | ||
75 | + { | ||
76 | + int swp = p[0].row; | ||
77 | + p[0].row = p[1].row; | ||
78 | + p[1].row = swp; | ||
79 | + } | ||
80 | + | ||
81 | + if(p[0].col > p[1].col) | ||
82 | + { | ||
83 | + int swp = p[0].col; | ||
84 | + p[0].col = p[1].col; | ||
85 | + p[1].col = swp; | ||
86 | + } | ||
87 | + | ||
74 | // First remove unselected areas | 88 | // First remove unselected areas |
75 | baddr = 0; | 89 | baddr = 0; |
76 | for(row=0;row < session->rows;row++) | 90 | for(row=0;row < session->rows;row++) |
@@ -214,6 +228,35 @@ LIB3270_EXPORT void lib3270_select_to(H3270 *session, int baddr) | @@ -214,6 +228,35 @@ LIB3270_EXPORT void lib3270_select_to(H3270 *session, int baddr) | ||
214 | 228 | ||
215 | } | 229 | } |
216 | 230 | ||
231 | +LIB3270_EXPORT unsigned char lib3270_get_selection_flags(H3270 *hSession, int baddr) | ||
232 | +{ | ||
233 | + int row,col; | ||
234 | + unsigned char rc = 0; | ||
235 | + | ||
236 | + CHECK_SESSION_HANDLE(hSession); | ||
237 | + | ||
238 | + if(!(lib3270_connected(hSession) && (hSession->text[baddr].attr & LIB3270_ATTR_SELECTED))) | ||
239 | + return rc; | ||
240 | + | ||
241 | + row = baddr / hSession->cols; | ||
242 | + col = baddr % hSession->cols; | ||
243 | + rc |= 0x01; | ||
244 | + | ||
245 | + if( (col == 0) || !(hSession->text[baddr-1].attr & LIB3270_ATTR_SELECTED) ) | ||
246 | + rc |= 0x02; | ||
247 | + | ||
248 | + if( (row == 0) || !(hSession->text[baddr-hSession->cols].attr & LIB3270_ATTR_SELECTED) ) | ||
249 | + rc |= 0x04; | ||
250 | + | ||
251 | + if( (col == hSession->cols) || !(hSession->text[baddr+1].attr & LIB3270_ATTR_SELECTED) ) | ||
252 | + rc |= 0x08; | ||
253 | + | ||
254 | + if( (row == hSession->rows) || !(hSession->text[baddr+hSession->cols].attr & LIB3270_ATTR_SELECTED) ) | ||
255 | + rc |= 0x10; | ||
256 | + | ||
257 | + return rc; | ||
258 | +} | ||
259 | + | ||
217 | LIB3270_EXPORT void lib3270_select_word(H3270 *session, int baddr) | 260 | LIB3270_EXPORT void lib3270_select_word(H3270 *session, int baddr) |
218 | { | 261 | { |
219 | int pos, len; | 262 | int pos, len; |
@@ -373,6 +416,8 @@ LIB3270_EXPORT char * lib3270_get_selected(H3270 *hSession) | @@ -373,6 +416,8 @@ LIB3270_EXPORT char * lib3270_get_selected(H3270 *hSession) | ||
373 | 416 | ||
374 | LIB3270_EXPORT int lib3270_get_selected_addr(H3270 *hSession, int *begin, int *end) | 417 | LIB3270_EXPORT int lib3270_get_selected_addr(H3270 *hSession, int *begin, int *end) |
375 | { | 418 | { |
419 | + CHECK_SESSION_HANDLE(hSession); | ||
420 | + | ||
376 | if(!hSession->selected || hSession->select.begin == hSession->select.end) | 421 | if(!hSession->selected || hSession->select.begin == hSession->select.end) |
377 | return -1; | 422 | return -1; |
378 | 423 | ||
@@ -390,6 +435,12 @@ LIB3270_EXPORT int lib3270_get_selected_addr(H3270 *hSession, int *begin, int *e | @@ -390,6 +435,12 @@ LIB3270_EXPORT int lib3270_get_selected_addr(H3270 *hSession, int *begin, int *e | ||
390 | return 0; | 435 | return 0; |
391 | } | 436 | } |
392 | 437 | ||
438 | +LIB3270_EXPORT int lib3270_move_selected_area(H3270 *hSession, int from, int to) | ||
439 | +{ | ||
440 | + | ||
441 | + | ||
442 | + return from; | ||
443 | +} | ||
393 | 444 | ||
394 | LIB3270_EXPORT int lib3270_move_selection(H3270 *hSession, LIB3270_DIRECTION dir) | 445 | LIB3270_EXPORT int lib3270_move_selection(H3270 *hSession, LIB3270_DIRECTION dir) |
395 | { | 446 | { |
src/lib3270/telnet.c
@@ -111,6 +111,7 @@ int ns_rsent; | @@ -111,6 +111,7 @@ int ns_rsent; | ||
111 | unsigned char *obuf; /* 3270 output buffer */ | 111 | unsigned char *obuf; /* 3270 output buffer */ |
112 | unsigned char *obptr = (unsigned char *) NULL; | 112 | unsigned char *obptr = (unsigned char *) NULL; |
113 | int linemode = 1; | 113 | int linemode = 1; |
114 | + | ||
114 | /* | 115 | /* |
115 | #if defined(LOCAL_PROCESS) | 116 | #if defined(LOCAL_PROCESS) |
116 | Boolean local_process = False; | 117 | Boolean local_process = False; |
@@ -1010,10 +1011,11 @@ void net_input(H3270 *session) | @@ -1010,10 +1011,11 @@ void net_input(H3270 *session) | ||
1010 | 1011 | ||
1011 | ns_brcvd += nr; | 1012 | ns_brcvd += nr; |
1012 | for (cp = netrbuf; cp < (netrbuf + nr); cp++) { | 1013 | for (cp = netrbuf; cp < (netrbuf + nr); cp++) { |
1013 | -#if defined(LOCAL_PROCESS) /*[*/ | 1014 | +/* |
1015 | +#if defined(LOCAL_PROCESS) | ||
1014 | if (local_process) { | 1016 | if (local_process) { |
1015 | - /* More to do here, probably. */ | ||
1016 | - if (IN_NEITHER) { /* now can assume ANSI mode */ | 1017 | + // More to do here, probably. |
1018 | + if (IN_NEITHER) { // now can assume ANSI mode | ||
1017 | host_in3270(CONNECTED_ANSI); | 1019 | host_in3270(CONNECTED_ANSI); |
1018 | hisopts[TELOPT_ECHO] = 1; | 1020 | hisopts[TELOPT_ECHO] = 1; |
1019 | check_linemode(False); | 1021 | check_linemode(False); |
@@ -1023,7 +1025,8 @@ void net_input(H3270 *session) | @@ -1023,7 +1025,8 @@ void net_input(H3270 *session) | ||
1023 | } | 1025 | } |
1024 | ansi_process((unsigned int) *cp); | 1026 | ansi_process((unsigned int) *cp); |
1025 | } else { | 1027 | } else { |
1026 | -#endif /*]*/ | 1028 | +#endif |
1029 | +*/ | ||
1027 | if (telnet_fsm(*cp)) { | 1030 | if (telnet_fsm(*cp)) { |
1028 | (void) ctlr_dbcs_postprocess(); | 1031 | (void) ctlr_dbcs_postprocess(); |
1029 | host_disconnect(&h3270,True); | 1032 | host_disconnect(&h3270,True); |
@@ -1891,11 +1894,13 @@ process_eor(void) | @@ -1891,11 +1894,13 @@ process_eor(void) | ||
1891 | */ | 1894 | */ |
1892 | void net_exception(H3270 *session) | 1895 | void net_exception(H3270 *session) |
1893 | { | 1896 | { |
1894 | -#if defined(LOCAL_PROCESS) /*[*/ | 1897 | +/* |
1898 | +#if defined(LOCAL_PROCESS) | ||
1895 | if (local_process) { | 1899 | if (local_process) { |
1896 | trace_dsn("RCVD exception\n"); | 1900 | trace_dsn("RCVD exception\n"); |
1897 | } else | 1901 | } else |
1898 | -#endif /*[*/ | 1902 | +#endif |
1903 | +*/ | ||
1899 | { | 1904 | { |
1900 | trace_dsn("RCVD urgent data indication\n"); | 1905 | trace_dsn("RCVD urgent data indication\n"); |
1901 | if (!syncing) { | 1906 | if (!syncing) { |
@@ -1953,11 +1958,14 @@ net_rawout(unsigned const char *buf, int len) | @@ -1953,11 +1958,14 @@ net_rawout(unsigned const char *buf, int len) | ||
1953 | nw = SSL_write(ssl_con, (const char *) buf, n2w); | 1958 | nw = SSL_write(ssl_con, (const char *) buf, n2w); |
1954 | else | 1959 | else |
1955 | #endif /*]*/ | 1960 | #endif /*]*/ |
1956 | -#if defined(LOCAL_PROCESS) /*[*/ | 1961 | + |
1962 | +/* | ||
1963 | +#if defined(LOCAL_PROCESS) | ||
1957 | if (local_process) | 1964 | if (local_process) |
1958 | nw = write(sock, (const char *) buf, n2w); | 1965 | nw = write(sock, (const char *) buf, n2w); |
1959 | else | 1966 | else |
1960 | -#endif /*]*/ | 1967 | +#endif |
1968 | +*/ | ||
1961 | nw = send(h3270.sock, (const char *) buf, n2w, 0); | 1969 | nw = send(h3270.sock, (const char *) buf, n2w, 0); |
1962 | if (nw < 0) { | 1970 | if (nw < 0) { |
1963 | #if defined(HAVE_LIBSSL) /*[*/ | 1971 | #if defined(HAVE_LIBSSL) /*[*/ |
@@ -2791,9 +2799,11 @@ void | @@ -2791,9 +2799,11 @@ void | ||
2791 | net_sendc(char c) | 2799 | net_sendc(char c) |
2792 | { | 2800 | { |
2793 | if (c == '\r' && !linemode | 2801 | if (c == '\r' && !linemode |
2794 | -#if defined(LOCAL_PROCESS) /*[*/ | 2802 | +/* |
2803 | +#if defined(LOCAL_PROCESS) | ||
2795 | && !local_process | 2804 | && !local_process |
2796 | -#endif /*]*/ | 2805 | +#endif |
2806 | +*/ | ||
2797 | ) { | 2807 | ) { |
2798 | /* CR must be quoted */ | 2808 | /* CR must be quoted */ |
2799 | net_cookout("\r\0", 2); | 2809 | net_cookout("\r\0", 2); |