mouse.c
19.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
/*
* Copyright 2008, Banco do Brasil S.A.
*
* This file is part of g3270
*
* This program file is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; version 3 of the License.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program in a file named COPYING; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*
* Authors:
*
* Perry Werneck<perry.werneck@gmail.com>
*
*/
#include "g3270.h"
#include "config.h"
#include "lib/kybdc.h"
#include "lib/actionsc.h"
#include "lib/tablesc.h"
#include "lib/utilc.h"
#include "lib/ctlrc.h"
#include "lib/3270ds.h"
/*---[ Defines ]--------------------------------------------------------------*/
typedef struct _position
{
unsigned char updated;
long x;
long y;
long row;
long col;
} POSITION;
enum _selection_positions
{
SELECTION_BEGIN,
SELECTION_END,
SELECTION_COUNT
};
typedef struct _cursor
{
GdkCursor *cursor;
GdkCursorType type;
} CURSOR;
#define SELECTING_NONE 0x00
#define SELECTING_LEFT 0x01
#define SELECTING_MOTION 0x02
#define SELECTING_DOUBLE_LEFT 0x03
#define SELECTING_RESTORED 0x0D
#define SELECTING_CLICK 0x0E
#define SELECTING_KEYBOARD 0x0F
#define SELECTING_ACTION SELECTING_KEYBOARD
#define SELECTING_SHOW SELECTING_RESTORED
/*---[ Prototipes ]-----------------------------------------------------------*/
/*---[ Constants ]------------------------------------------------------------*/
/*---[ Statics ]--------------------------------------------------------------*/
static POSITION pos[SELECTION_COUNT];
static GdkCursor *pointer = 0;
static int selected_cursor = -1;
static CURSOR cursor[] = { { 0, GDK_TOP_LEFT_CORNER },
{ 0, GDK_TOP_RIGHT_CORNER },
{ 0, GDK_BOTTOM_LEFT_CORNER },
{ 0, GDK_BOTTOM_RIGHT_CORNER },
};
/*---[ Globals ]--------------------------------------------------------------*/
unsigned short selecting = SELECTING_NONE;
unsigned short modifier = 0;
/*---[ Implement ]------------------------------------------------------------*/
/**
* Invalida uma caixa de selecao.
*
* Recalcula as coordenadas de terminal correspondentes as posicoes de mouse
* capturadas e redesenha toda a caixa de selecao.
*
*/
static void InvalidateSelectionBox(void)
{
int rows;
int cols;
int f;
if(!Get3270DeviceBuffer(&rows, &cols))
return;
for(f=0;f<SELECTION_COUNT;f++)
{
if(pos[f].updated)
{
pos[f].col = (pos[f].x - left_margin) / font->Width;
if(pos[f].col < 0)
pos[f].col = 0;
if(pos[f].col > cols)
pos[f].col = cols;
pos[f].row = (pos[f].y - top_margin) / (font->Height + line_spacing);
if(pos[f].row < 0)
pos[f].row = 0;
if(pos[f].row > rows)
pos[f].row = rows;
pos[f].x = (pos[f].col * font->Width) + left_margin;
pos[f].y = (pos[f].row * (font->Height+line_spacing))+top_margin;
pos[f].updated = 0;
}
}
RedrawTerminalContents();
}
/**
* Configura a caixa de selecao.
*
* Recalcula novas coordenadas de tela de acordo com as coordenadas de terminal.
* Chamada a cada "resize" da janela principal e no caso de acoes de teclado ou
* campo. Tambem forca o recalculo de todos os indicadores e redesenho da caixa
* de selecao.
*
*/
void ConfigureSelectionBox(void)
{
int f;
if(!selecting)
return;
DBGPrintf("Select from %ldx%ld to %ldx%ld",
pos[0].row,pos[0].col,
pos[1].row,pos[1].col);
for(f=0;f<SELECTION_COUNT;f++)
{
pos[f].updated = 1;
pos[f].x = (pos[f].col * font->Width) + left_margin;
pos[f].y = (pos[f].row * (font->Height+line_spacing))+top_margin;
}
InvalidateSelectionBox();
}
static void SelectCursor(int cr)
{
if(cr == selected_cursor)
return;
selected_cursor = cr;
DBGTrace(selected_cursor);
if(terminal && terminal->window)
{
if(cr < 0)
{
if(pointer)
gdk_window_set_cursor(terminal->window,pointer);
return;
}
gdk_window_set_cursor(terminal->window,cursor[cr].cursor);
}
}
void DrawSelectionBox(GdkDrawable *drawable, GdkGC *gc)
{
int x[2];
int y[2];
if(!selecting)
return;
x[0] = min(pos[SELECTION_BEGIN].x,pos[SELECTION_END].x);
x[1] = max(pos[SELECTION_BEGIN].x,pos[SELECTION_END].x);
y[0] = min(pos[SELECTION_BEGIN].y,pos[SELECTION_END].y);
y[1] = max(pos[SELECTION_BEGIN].y,pos[SELECTION_END].y);
if( (x[0] == x[1]) || (y[0] == y[1]) )
return;
gdk_gc_set_foreground(gc,selection_cmap);
gdk_draw_rectangle(drawable,gc,1,x[0],y[0],x[1]-x[0],y[1]-y[0]);
gdk_gc_set_foreground(gc,selection_cmap+1);
gdk_draw_rectangle(drawable,gc,0,x[0],y[0],x[1]-x[0],y[1]-y[0]);
}
gboolean mouse_button_press(GtkWidget *widget, GdkEventButton *event, gpointer user_data)
{
/*
DBGTracex(event->button);
DBGTracex(event->type);
DBGTracex(event->state);
DBGTrace(event->state & GDK_BUTTON1_MASK);
DBGTrace(event->state & GDK_BUTTON3_MASK);
*/
switch( ((event->type & 0x0F) << 4) | (event->button & 0x0F))
{
case ((GDK_BUTTON_PRESS & 0x0F) << 4) | 1:
DBGMessage("Button 1 Click");
pos[SELECTION_BEGIN].updated =
pos[SELECTION_END].updated = 1;
pos[SELECTION_BEGIN].x =
pos[SELECTION_END].x = (unsigned long) event->x;
pos[SELECTION_BEGIN].y =
pos[SELECTION_END].y = (unsigned long) event->y;
if(!(event->state & GDK_BUTTON3_MASK))
modifier = 0;
selecting = SELECTING_LEFT;
break;
case ((GDK_2BUTTON_PRESS & 0x0F) << 4) | 1:
DBGMessage("Button 1 Double-Click");
selecting = SELECTING_DOUBLE_LEFT;
break;
case ((GDK_BUTTON_PRESS & 0x0F) << 4) | 3:
DBGMessage("Button 2 Click");
modifier = 1;
break;
case ((GDK_2BUTTON_PRESS & 0x0F) << 4) | 3:
DBGMessage("Button 2 Double-Click");
modifier = 2;
break;
default:
DBGPrintf("Unknown mouse click %d with button %d",event->type, event->button);
return 0;
}
InvalidateSelectionBox();
return 0;
}
static int FieldAction(int button, int row, int col)
{
int rows;
int cols;
int baddr;
const struct ea *trm = Get3270DeviceBuffer(&rows, &cols);
int length;
int maxlength;
if(!trm)
return 0;
baddr = find_field_attribute((row * cols) + col);
maxlength = (rows * cols) - baddr;
DBGTrace(maxlength);
for(length=1; !trm[baddr+length].fa && length < maxlength;length++);
length--;
DBGTrace(length);
/*
* If the field begins with "F", is protected and folowed by numeric
* digits act as a clickable function key indicator.
*
*/
if(ebc2asc[trm[baddr+1].cc] == 'F' && length < 4 && FA_IS_PROTECTED(trm[baddr].fa))
{
int key = 0;
int f;
for(f=1; f<length;f++)
{
unsigned char chr = ebc2asc[trm[baddr+1+f].cc];
DBGPrintf("[%c]",chr);
if(key >= 0 && isdigit(chr))
{
key *= 10;
key += (chr - '0');
}
else
{
key = -1;
}
}
if(key > 0 && key < 12)
{
// It's a function key! Activate it!
char ks[6];
snprintf(ks,5,"%d",key);
DBGPrintf("Function: %s",ks);
action_internal(PF_action, IA_DEFAULT, ks, CN);
return 0;
}
}
DBGTrace(button);
if(button == 1)
{
// It's not protected, try to select a word.
int paddr = (row * cols) + col;
int c = col;
DBGPrintf("Double-click in a field at %dx%d",row,col);
while(c > 0 && paddr > baddr && !isspace(ebc2asc[trm[paddr].cc]))
{
DBGPrintf("%d [%c] %d",c,ebc2asc[trm[paddr].cc],FA_IS_ZERO(trm[paddr].fa));
paddr--;
c--;
}
c++;
paddr++;
selecting = SELECTING_CLICK;
pos[0].row = row;
pos[0].col = c;
while(c < cols && !isspace(ebc2asc[trm[paddr].cc]))
{
DBGPrintf("%d [%c] %d",c,ebc2asc[trm[paddr].cc],FA_IS_ZERO(trm[paddr].fa));
paddr++;
c++;
}
pos[1].row = row+1;
pos[1].col = c;
ConfigureSelectionBox();
return 1;
}
if(button == 2)
{
// Select the entire field
DBGTrace(baddr - (row * cols));
}
return 0;
}
static unsigned long QueuedCopy = 0;
static void RemoveQueuedCopy(void)
{
modifier = 0; // Disable right-button
if(QueuedCopy)
{
RemoveTimeOut(QueuedCopy);
QueuedCopy = 0;
}
}
static void DoQueuedCopy(void)
{
DBGMessage("**** TIMED COPY ****");
RemoveQueuedCopy();
action_copy(0,0);
}
#define MouseFlags(button) (((selecting & 0x0F) << 8) | ((modifier & 0x0F) << 4) | button)
gboolean mouse_button_release(GtkWidget *widget, GdkEventButton *event, gpointer user_data)
{
int rows, cols;
DBGPrintf("Mouse flags: 0x%04x",MouseFlags(event->button));
switch(MouseFlags(event->button))
{
case 0x101: // Single click!
DBGPrintf("Move cursor position to %ld,%ld",pos[0].row,pos[0].col);
selecting = SELECTING_NONE;
if(Get3270DeviceBuffer(&rows, &cols))
move3270Cursor((pos[0].row * cols) + pos[0].col);
InvalidateSelectionBox();
break;
case 0x201: // Selecting box
DBGMessage("Finish selection");
break;
case 0x211: // Direct Copy
if(QueuedCopy)
DoQueuedCopy();
break;
case 0x213: // Left-on, single-click on right (Queue copy)
QueuedCopy = AddTimeOut(500, DoQueuedCopy);
break;
case 0x223: // Left-on, double-click on Right (Append, remove queued copy)
DBGMessage("Append");
RemoveQueuedCopy();
action_append(0,0);
break;
case 0x301: // Double-click (left)
if(FieldAction(1,pos[0].row,pos[0].col))
return 0;
break;
case 0x113: // Single-click (right)
break;
/*
* Right button only
*/
case 0xd13: // Single-click with selection box visible
pos[1].updated = 1;
pos[1].x = (unsigned long) event->x;
pos[1].y = (unsigned long) event->y;
InvalidateSelectionBox();
break;
case 0xd23: // Double-click (right)
case 0xe23: // Double-click (right)
action_SelectField(0,0);
modifier = 0;
break;
case 0xe13: // Single-click (right) + SELECTING_CLICK
case 0x013: // Single-click (right)
if(selecting != SELECTING_CLICK)
{
selecting = SELECTING_CLICK;
pos[0].col = pos[1].col = cursor_col;
pos[0].row = pos[1].row = cursor_row;
ConfigureSelectionBox();
}
pos[1].updated = 1;
pos[1].x = (unsigned long) event->x;
pos[1].y = (unsigned long) event->y;
InvalidateSelectionBox();
break;
}
if(event->button == 1)
{
DBGTracex(selecting);
if(selecting == SELECTING_LEFT || selecting == SELECTING_MOTION)
selecting = SELECTING_SHOW;
modifier = 0;
SelectCursor(-1);
DBGPrintf("New mouse flags: 0x%04x",MouseFlags(event->button));
}
return 0;
}
gboolean mouse_motion(GtkWidget *widget, GdkEventMotion *event, gpointer user_data)
{
switch(selecting)
{
case SELECTING_LEFT: // Left button pressed
case SELECTING_MOTION: // Selecting by mouse-motion
pos[SELECTION_END].updated = 1;
pos[SELECTION_END].x = (unsigned long) event->x;
pos[SELECTION_END].y = (unsigned long) event->y;
selecting = SELECTING_MOTION;
SelectCursor( (pos[SELECTION_BEGIN].x > pos[SELECTION_END].x ? 0 : 1) | (pos[SELECTION_BEGIN].y > pos[SELECTION_END].y ? 0 : 2));
InvalidateSelectionBox();
break;
}
return 0;
}
gboolean mouse_scroll(GtkWidget *widget, GdkEventScroll *event, gpointer user_data)
{
// FIXME (perry#1#): Read associoation from scroll to function key from configuration file.
static const char *scroll[] = { "7", "8" };
if(event->direction < 2 && !WaitForScreen)
{
WaitForScreen = TRUE;
action_internal(PF_action, IA_DEFAULT, scroll[event->direction], CN);
}
return 0;
}
void LoadMousePointers(GdkDrawable *drawable, GdkGC *gc)
{
int f;
for(f = 0; f < (sizeof(cursor)/sizeof(CURSOR)); f++)
cursor[f].cursor = gdk_cursor_new(cursor[f].type);
}
void SetMousePointer(GdkCursor *cursor)
{
if(!cursor)
return;
pointer = cursor;
DBGTracex(pointer);
if(!selecting)
{
if(terminal && terminal->window && pointer)
gdk_window_set_cursor(terminal->window,pointer);
}
}
void action_remove_selection(GtkWidget *w, gpointer data)
{
selecting = 0;
InvalidateSelectionBox();
}
void action_select_all(GtkWidget *w, gpointer data)
{
int rows;
int cols;
if(!Get3270DeviceBuffer(&rows, &cols))
return;
pos[0].updated =
pos[1].updated = 1;
pos[0].x =
pos[0].y = 0;
pos[1].x = (cols * font->Width) + left_margin;
pos[1].y = (rows * (font->Height+line_spacing))+top_margin;
selecting = SELECTING_ACTION;
InvalidateSelectionBox();
}
#define GetTerminalSize() int rows, cols ; \
if(!Get3270DeviceBuffer(&rows, &cols)) return;
void action_SelectRight(GtkWidget *w, gpointer data)
{
GetTerminalSize();
if(!selecting)
{
selecting = SELECTING_KEYBOARD;
pos[0].col =
pos[1].col = cursor_col;
pos[0].row = cursor_row;
pos[1].row = cursor_row+1;
}
if(pos[1].col < cols)
pos[1].col++;
ConfigureSelectionBox();
}
void action_SelectDown(GtkWidget *w, gpointer data)
{
GetTerminalSize();
if(!selecting)
{
selecting = SELECTING_KEYBOARD;
pos[0].col = cursor_col;
pos[1].col = cursor_col+1;
pos[0].row =
pos[1].row = cursor_row;
}
if(pos[1].row < rows)
pos[1].row++;
ConfigureSelectionBox();
}
void action_SelectLeft(GtkWidget *w, gpointer data)
{
if(!selecting)
{
selecting = SELECTING_KEYBOARD;
pos[0].col =
pos[1].col = cursor_col;
pos[0].row = cursor_row;
pos[1].row = cursor_row+1;
}
if(pos[1].col > 0)
pos[1].col--;
ConfigureSelectionBox();
}
void action_SelectUp(GtkWidget *w, gpointer data)
{
GetTerminalSize();
if(!selecting)
{
selecting = SELECTING_KEYBOARD;
pos[0].col = cursor_col;
pos[1].col = cursor_col+1;
pos[0].row =
pos[1].row = cursor_row;
}
if(pos[1].row > 0)
pos[1].row--;
ConfigureSelectionBox();
}
void action_SelectionUp(GtkWidget *w, gpointer data)
{
GetTerminalSize();
if(!selecting)
return;
if(pos[0].row <= 1 || pos[1].row < 1)
return;
CHKPoint();
pos[0].row--;
pos[1].row--;
ConfigureSelectionBox();
}
void action_SelectionDown(GtkWidget *w, gpointer data)
{
GetTerminalSize();
if(!selecting)
return;
if(pos[0].row >= rows || pos[1].row >= rows)
return;
CHKPoint();
pos[0].row++;
pos[1].row++;
ConfigureSelectionBox();
}
void action_SelectionLeft(GtkWidget *w, gpointer data)
{
GetTerminalSize();
if(!selecting)
return;
if(pos[0].col < 1 || pos[1].col < 1)
return;
CHKPoint();
pos[0].col--;
pos[1].col--;
ConfigureSelectionBox();
}
void action_SelectionRight(GtkWidget *w, gpointer data)
{
GetTerminalSize();
if(!selecting)
return;
if(pos[0].col >= cols || pos[1].col >= cols)
return;
CHKPoint();
pos[0].col++;
pos[1].col++;
ConfigureSelectionBox();
}
void action_RestoreSelection(GtkWidget *w, gpointer data)
{
if(!selecting)
{
selecting = SELECTING_RESTORED;
ConfigureSelectionBox();
}
}
static void do_copy(int clear, int table)
{
int row[2];
int col[2];
if(!selecting)
return;
row[0] = min(pos[SELECTION_BEGIN].row,pos[SELECTION_END].row);
row[1] = max(pos[SELECTION_BEGIN].row,pos[SELECTION_END].row);
col[0] = min(pos[SELECTION_BEGIN].col,pos[SELECTION_END].col);
col[1] = max(pos[SELECTION_BEGIN].col,pos[SELECTION_END].col);
DBGPrintf("Copy %dx%d<->%dx%d to clipboard",row[0],col[0],row[1],col[1]);
if( (row[0] == row[1]) || (col[0] == col[1]) )
return;
AddToClipboard(row[0],col[0],row[1],col[1], clear, table);
}
void action_copy_as_table(GtkWidget *w, gpointer data)
{
CHKPoint();
do_copy(1,1);
}
void action_copy(GtkWidget *w, gpointer data)
{
CHKPoint();
do_copy(1,0);
}
void action_append(GtkWidget *w, gpointer data)
{
do_copy(0,0);
}
gchar * CopySelectedText(void)
{
if(!selecting)
return NULL;
return CopyTerminalContents( min(pos[SELECTION_BEGIN].row,pos[SELECTION_END].row),
min(pos[SELECTION_BEGIN].col,pos[SELECTION_END].col),
max(pos[SELECTION_BEGIN].row,pos[SELECTION_END].row),
max(pos[SELECTION_BEGIN].col,pos[SELECTION_END].col),
0
);
}
static gpointer exec_with_selection_thread(gpointer cmd)
{
gchar *screen;
int fd;
char filename[1024];
char buffer[1024];
FILE *arq;
int rc;
if(!cmd)
return 0;
DBGTrace(selecting);
screen = CopySelectedText();
if(!screen)
return 0;
snprintf(filename,1023,"%s/%s.XXXXXX",TMPPATH,PACKAGE_NAME);
fd = mkstemp(filename);
DBGMessage(filename);
arq = fdopen(fd,"w");
if(arq)
{
if(fwrite(screen,strlen(screen),1,arq) != 1)
{
Error("Error writing screen contents to %s",filename);
fclose(arq);
}
else
{
fclose(arq);
snprintf(buffer,1023,cmd,filename);
DBGMessage(buffer);
rc = system(buffer);
if(rc)
Log("System(\"%s\"): %d",buffer,rc);
remove(filename);
}
}
else
{
Error("Unable to open \"%s\" for writing",filename);
}
g_free(screen);
return 0;
}
void action_exec_with_selection(GtkWidget *w, gpointer data)
{
GThread *thd = 0;
if(!selecting)
{
GtkWidget *widget = gtk_message_dialog_new(
GTK_WINDOW(top_window),
GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_WARNING,
GTK_BUTTONS_OK,
_( "Selecione algum texto antes" ) );
gtk_dialog_run(GTK_DIALOG(widget));
gtk_widget_destroy (widget);
return;
}
thd = g_thread_create( exec_with_selection_thread, (gpointer) data, 0, NULL);
}
void action_SelectField(GtkWidget *w, gpointer data)
{
int rows;
int cols;
int baddr;
const struct ea *trm = Get3270DeviceBuffer(&rows, &cols);
int sz;
if(!trm)
return;
baddr = find_field_attribute((cursor_row * cols) + cursor_col);
selecting = SELECTING_ACTION;
pos[1].row = ( pos[0].row = (baddr/cols)) + 1;
pos[1].col = ( pos[0].col = (baddr - (pos[0].row * cols))+1) +1;
for(sz = 1; !trm[baddr+sz].fa && pos[1].col++ < cols; sz++);
pos[1].col--;
ConfigureSelectionBox();
}