forked from bakagirl/Arachne-WWW-browser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ATOMS.C
1150 lines (1019 loc) · 28.5 KB
/
ATOMS.C
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
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// ========================================================================
// Arachne "activeatom" and mouse interface
// (c)1997-2000 Michael Polak, Arachne Labs
// ========================================================================
#include "arachne.h"
#include "html.h"
#include "gui.h"
//Goto next/previous atom when Tab/Shift+tab is pressend
char gotonextlink( int *x, int *y , char back, char asc)
{
int fx=0;
long fy=-1;
char frameID;
char lastlink=0;
char rv;
unsigned currentHTMLatom,nextHTMLatom;
struct HTMLrecord *atomptr;
struct HTMLframe *frame;
if(back)
currentHTMLatom=p->lastonscr;
else
currentHTMLatom=p->firstonscr;
while(currentHTMLatom!=IE_NULL)
{
atomptr=(struct HTMLrecord *)ie_getswap(currentHTMLatom);
if(!atomptr)
MALLOCERR();
if(back) //Shift+Tab
{
if(currentHTMLatom==p->firstonscr)
nextHTMLatom=IE_NULL;
else
nextHTMLatom=atomptr->prev;
}
else //Tab
{
if(currentHTMLatom==p->lastonscr)
nextHTMLatom=IE_NULL;
else
nextHTMLatom=atomptr->next;
}//endif
frame=&(p->htmlframe[atomptr->frameID]);
if(atomptr->linkptr!=IE_NULL &&
atomptr->x>frame->posX &&
atomptr->y>frame->posY &&
atomptr->xx<frame->posX+frame->scroll.xsize &&
atomptr->yy<frame->posY+frame->scroll.ysize &&
!(atomptr->type==TABLE || atomptr->type==TD || atomptr->type==TD_BACKGROUND ||
atomptr->type==INPUT && atomptr->data1==HIDDEN))
{
if(fy<0 ||
(lastlink &&
(atomptr->linkptr!=lastonmouse || atomptr->type==INPUT) &&
(asc!=13 || atomptr->type==INPUT &&
(atomptr->data1==TEXT || atomptr->data1==PASSWORD || atomptr->data1==TEXTAREA)
)))
{
char flag=0;
if(fy>=0)flag=1;
fx=atomptr->xx;
fy=atomptr->yy;
frameID=atomptr->frameID;
if(atomptr->type==INPUT && (atomptr->data1==TEXT ||
atomptr->data1==PASSWORD || atomptr->data1==TEXTAREA))
rv=1;
else
rv=0;
if(flag)
goto ret;
}
if(currentHTMLatom==activeadr)
lastlink=1;
}//endif it is link
currentHTMLatom=nextHTMLatom;
}//loop
ret:
if(fy>=0)
{
*x=(int)(fx-2-p->htmlframe[frameID].posX+p->htmlframe[frameID].scroll.xtop);
*y=(int)(fy-2-p->htmlframe[frameID].posY+p->htmlframe[frameID].scroll.ytop);
}
return rv;
}
// HTML code search for that last input inside <FORM> tag
char *activeislastinput(void)
{
struct HTMLrecord *atomptr=(struct HTMLrecord*)ie_getswap(activeadr); // active atom
if(atomptr && atomptr->type==INPUT && (atomptr->data1==TEXT || atomptr->data1==PASSWORD))
{
unsigned submitlink=atomptr->linkptr;
char found=0;
unsigned currentHTMLatom=p->firstonscr;
while(currentHTMLatom!=IE_NULL)
{
// kbhit();
atomptr=(struct HTMLrecord *)ie_getswap(currentHTMLatom);
if(!atomptr)
MALLOCERR();
if(found)
{
if(atomptr->linkptr==submitlink && atomptr->type==INPUT &&
atomptr->data1!=SUBMIT && atomptr->data1!=HIDDEN &&
atomptr->data1!=RADIO && atomptr->data1!=CHECKBOX)
return NULL;
}
else if(currentHTMLatom==activeadr)
found=1;
currentHTMLatom=atomptr->next;
}//loop
atomptr=(struct HTMLrecord *)ie_getswap(submitlink);
if(atomptr && atomptr->type==FORM)
{
GLOBAL.postdata=atomptr->data2+1; //GET==1, POST==2
arachne.target=atomptr->data1;
return(char *)ie_getswap(atomptr->ptr);
}//endif
}//endif
return NULL;
}
void ReadFileBox(void)
{
//!!glennmcc: May 08, 2002 (changed default read filename to QUICKPAD.TXT)
setTXTprompt("QUICKPAD.TXT");
// setTXTprompt("TEXTAREA.TXT");
inputatom(MSG_READF,MSG_EFNAME);
activeistextwindow=INPUT_READFILE;
}
void WriteFileBox(void)
{
//!!glennmcc: May 08, 2002 (changed default write filename to QUICKPAD.TXT)
setTXTprompt("QUICKPAD.TXT");
// setTXTprompt("TEXTAREA.TXT");
inputatom(MSG_WRITEF,MSG_EFNAME);
activeistextwindow=INPUT_WRITEFILE;
}
void SearchInTextBox(void)
{
// setTXTprompt("TEXTAREA.TXT");
inputatom(MSG_SRCHTX,MSG_ENTER);
activeistextwindow=INPUT_SEARCHINTEXT;
}
#define BOXTEXT 3,BOLD
#define BOXBORDER 5
void inputatom(char *msg1,char *msg2)
{
activeatomcursor(0);
activeatomptr=&TXTprompt;
mouseoff();
Box3D(TXTprompt.x-BOXBORDER,p->htscrn_ytop+(int)(TXTprompt.y-fonty(BOXTEXT)-BOXBORDER),
TXTprompt.xx+BOXBORDER,p->htscrn_ytop+(int)(TXTprompt.yy+BOXBORDER-2));
x_setcolor(0);
htmlfont(BOXTEXT);
{
int colormap[5]={15,-1,-1,8,7};
decorated_text(TXTprompt.x,p->htscrn_ytop+(int)(TXTprompt.y-fonty(BOXTEXT)-2),msg1,colormap);
}
activeatomredraw();
activeatomcursor(1);
outs(msg2);
mouseon();
}
// Coorperative multitaskng. If an atom is active, GUI event should also check this atom
int activeatomtick(int key,char textareacmd)
{
int redraw;
if(activeatomptr && activeatomptr->type==INPUT)
{
int x1,x2,xs,ys,asc,oldline;
long y1,y2;
struct HTMLframe *frame=&(p->htmlframe[activeatomptr->frameID]);
x2=activeatomptr->xx;
x1=activeatomptr->x;
y2=activeatomptr->yy;
y1=activeatomptr->y;
if(activeatomptr!=&URLprompt && activeatomptr!=&TXTprompt)
{
x1-=frame->posX;
y1-=frame->posY;
x2-=frame->posX;
y2-=frame->posY;
if(x2>frame->scroll.xsize && activeatomptr!=&URLprompt)
x2=frame->scroll.xsize;
if(y2>frame->scroll.ysize)
y2=frame->scroll.ysize;
if(x1<0)x1=0;
if(y1<0 && activeatomptr!=&URLprompt)y1=0;
if(activeatomptr->data1==TEXTAREA)
{
x2-=user_interface.scrollbarsize;
y2-=user_interface.scrollbarsize;
}
}//endif "not URL/textinput" special case
x2+=frame->scroll.xtop;
x1+=frame->scroll.xtop;
y2+=frame->scroll.ytop;
y1+=frame->scroll.ytop;
xs=(x2-x1-5)/fontx(SYSFONT,0,' ')-1;
if(xs<1)xs=1;
ys=(int)(y2-y1-4)/fonty(SYSFONT,0)-1;
if(ys<1)ys=1;
asc=key & 0xFF;
if(asc>127 && user_interface.keymap)
{
int i=0;
while (i<96)
{
if(user_interface.keymap[i]==asc)
{
asc=key=161+i;
break;
}
i++;
}
}
editorptr=(struct ib_editor *)ie_getswap(activeatomptr->ptr);
if(editorptr)
{
memcpy(&tmpeditor,editorptr,sizeof(struct ib_editor));
oldline=tmpeditor.y;
redraw=ie_key(&tmpeditor,key,bioskey(2),xs,ys);
//vraci 0:nic se nedeje, (tr.: nothing happens)
// 1:nastav kurzor (tr.: adjust cursor)
// 2:prekresli radku (tr.: overwrite row)
// 3:prekresli vsechno (tr.: overwrite everything)
editorptr=(struct ib_editor *)ie_getswap(activeatomptr->ptr);
if(editorptr)
{
memcpy(editorptr,&tmpeditor,sizeof(struct ib_editor));
swapmod=1;
}
else
MALLOCERR();
}
else
MALLOCERR();
if(tmpeditor.maxlines>1) //multiline textarea... -> handle special events
{
switch(redraw)
{
case 103:ReadFileBox();return 0;
case 123:WriteFileBox();return 0;
case 107:SearchInTextBox();return 0;
case 127:SearchInTextarea(1);return 0;
case 301:outs(MSG_BLCKWR);return 0;
}
}//end if special event ocured (Arachne GUI bindings...)
if(asc==27) //esc - leave current atom
{
activeatomcursor(0);
activeatomptr=NULL;
defaultmsg();
if(activeistextwindow) //!! hrruuuza :-( (tr.: horror)
return key;
}
else
if(asc==13 && activeatomptr->type==INPUT && activeatomptr->data1!=TEXTAREA ||
asc==9 || key==0xf00 || key==0x3c00 ||
(activeatomptr->type==INPUT && tmpeditor.maxlines==1 &&
(key==0x4800 || key==0x5000) && scrolllock()) )
//enter,tab,shit+tab,F2, lynx mode
{
activeatomcursor(0);
if(activeatomptr!=&URLprompt && activeatomptr!=&TXTprompt)
activeatomptr=NULL;
return key;
}
else if(redraw || textareacmd)
{
if(activeatomptr->data1!=TEXTAREA)
{
/* enable blocks ?
if(activeatomptr->data1==TEXT)
ie_redrawline(&tmpeditor,
x1+2,(int)y1+2,tmpeditor.zoomx, xs,tmpeditor.y);
else
*/
activeatomredraw();
}
else
{
if(textareacmd==TEXTAREA_NOREFRESH) //hack for smooth screen refreshing..
{
return 0;
}
else
if(redraw==3 || textareacmd) //redraw ALL atom and/or init scrollbar
{
mouseoff();
if(textareacmd!=TEXTAREA_INIT)
{
if(ie_redrawwin(&tmpeditor,(int)(x1+2),(int)(y1+2),
(int)(x2-2),(int)(y2-2),1))
{
mouseon();
return 0; //(key was pressed and put into bios buffer)
}
atomneedredraw=0;
}
if(textareacmd!=TEXTAREA_SCROLL)
{
char oldonx=activescroll.onscrollx;
char oldony=activescroll.onscrolly;
activescroll.xvisible=1;
activescroll.yvisible=1;
ScrollInit(&activescroll,(int)(x2-x1-5),(int)(y2-y1-5),
(int)(y2-y1-5+user_interface.scrollbarsize),
(int)(x1+2),(int)(y1+2),
tmpeditor.cols*fontx(SYSFONT,0,' '),(long)tmpeditor.lines*fonty(SYSFONT,0));
activescroll.onscrollx=oldonx;
activescroll.onscrolly=oldony;
ScrollDraw(&activescroll,tmpeditor.zoomx*fontx(SYSFONT,0,' '),(long)tmpeditor.zoomy*fonty(SYSFONT,0));
}
}//end forced redraw (level 3)
else //only last and current line redraw...
{
mouseoff();
if(oldline!=tmpeditor.y)
ie_redrawline(&tmpeditor,
x1+2,(int)y1+2+(oldline-tmpeditor.zoomy)*fonty(SYSFONT,0),
tmpeditor.zoomx, xs+1,oldline);
if(bioskey(1))
{
atomneedredraw=1;
return 0;
}
//redraw line where cursor IS
ie_redrawline(&tmpeditor,
x1+2,(int)y1+2+(tmpeditor.y-tmpeditor.zoomy)*fonty(SYSFONT,0),
tmpeditor.zoomx, xs+1,tmpeditor.y);
}//end if forced redraw (level 1)
if(bioskey(1))
{
atomneedredraw=1;
return 0;
}
if(tmpeditor.blockflag & 1)
outs(MSG_BLOCK);
else
{
char str[80];
// sprintf(str,MSG_LINECOL,tmpeditor.y+1,tmpeditor.lines,tmpeditor.x+1);
sprintf(str,"%04d/%04d:%03d",tmpeditor.y+1,tmpeditor.lines,tmpeditor.x+1);
if(tmpeditor.modified)
strcat(str," <mod>");
if(tmpeditor.wordwrap)
strcat(str," <wrap>");
if(tmpeditor.insert)
strcat(str," <ins>");
if(tmpeditor.blockflag & 2)
strcat(str," <block>");
outs(str);
}
}//endif handle textarea
activeatomcursor(1); //draw cursor
}//end if redraw
key=0;
}//endif tick
return key;
}
char *try2getURL(void)
{
if(activeatomptr && activeatomptr==&URLprompt && activeatomptr->type==INPUT)
{
editorptr=(struct ib_editor *)ie_getswap(activeatomptr->ptr);
if(editorptr)
{
memcpy(&tmpeditor,editorptr,sizeof(struct ib_editor));
return ie_getline(&tmpeditor,0);
}
else
MALLOCERR();
}
return NULL;
}
void activeurl(char *url)
{
activeatomcursor(0);
if(fullscreen || customerscreen)
{
setTXTprompt(url);
inputatom("URL","");
activeistextwindow=INPUT_URL;
}
else
{
toolbar(0,1);
activeatomptr=&URLprompt;
if(url[0])
SetInputAtom(&URLprompt,url);
activeatomredraw();
activeatomcursor(1);
outs(MSG_URL);
}
}
int activeismap(int *dx, int *dy) //je aktivnim obrazkem klikatelna mapa ?
// tr.: is the active picture a clickable image map?
{
//data1 | 1=ISMAP,2=USEMAP,4=INPUT TYPE=...
if(activeatomptr && activeatomptr->type==IMG &&
activeatomptr->data1 && activeatomptr->data1!=2)
{
*dx=(int)(activeatomptr->x+activeatomptr->data2+
p->htmlframe[activeatomptr->frameID].scroll.xtop-p->htmlframe[activeatomptr->frameID].posX);
*dy=(int)(activeatomptr->y+activeatomptr->data2+
p->htmlframe[activeatomptr->frameID].scroll.ytop-p->htmlframe[activeatomptr->frameID].posY);
return activeatomptr->data1;
}
else
return 0;
}
//. Radio is like check box. Only one of radios is checked at any moment
void RadioSwitch(int fromx, long fromy,XSWAP current,XSWAP formptr)
{
char name[80];
XSWAP currentHTMLatom=p->firstHTMLatom,nextHTMLatom;
struct ScrollBar *scroll;
struct HTMLrecord *atomptr;
//vyresetovat rediobuttons a vykreslit ty, co jsou na obrazovce
// tr.: reset radio buttons and draw those, that are on the screen
editorptr=(struct ib_editor *)ie_getswap(current);
if(!editorptr)
return;
else
strcpy(name,editorptr->filename);
mouseoff();
while(currentHTMLatom!=IE_NULL)
{
// kbhit();
atomptr=(struct HTMLrecord *)ie_getswap(currentHTMLatom);
if(!atomptr)
MALLOCERR();
nextHTMLatom=atomptr->next;
if(atomptr->type==INPUT && atomptr->data1==RADIO && atomptr->linkptr==formptr)
{
editorptr=(struct ib_editor *)ie_getswap(atomptr->ptr);
if(editorptr && !strcmpi(editorptr->filename,name))
{
atomptr=(struct HTMLrecord *)ie_getswap(currentHTMLatom);
if(!atomptr)
MALLOCERR();
if(atomptr->ptr==current)
atomptr->data2=1; //!is checked!
else
atomptr->data2=0; //!is not checked!
swapmod=1; //!save!
scroll=&(p->htmlframe[atomptr->frameID].scroll);
if(atomptr->y>=fromy && atomptr->y<fromy+scroll->ysize &&
atomptr->x>=fromx && atomptr->x<fromy+scroll->xsize)
{
drawatom(atomptr,fromx,fromy,
scroll->xsize,scroll->ysize,scroll->xtop,scroll->ytop);
}
}//endif is it editor
}//endif is it radio
currentHTMLatom=nextHTMLatom;
}//loop
mouseon();
}
void HideLink(char *hideURL)
{
XSWAP currentHTMLatom=p->firstHTMLatom,nextHTMLatom;
XSWAP hidethis=IE_NULL;
struct HTMLrecord *atomptr;
mouseoff();
while(currentHTMLatom!=IE_NULL)
{
// kbhit();
atomptr=(struct HTMLrecord *)ie_getswap(currentHTMLatom);
if(!atomptr)
MALLOCERR();
nextHTMLatom=atomptr->next;
if(atomptr->type==HREF)
{
char *href=ie_getswap(atomptr->ptr);
if(href && !strcmpi(href,hideURL))
hidethis=currentHTMLatom;
}
else
if(hidethis!=IE_NULL && atomptr->linkptr==hidethis)
{
atomptr->type=EMPTY;
swapmod=1;
}
currentHTMLatom=nextHTMLatom;
}//loop
}
int ProcessLinks(char generateASF)
{
struct Url url;
char frameID;
XSWAP currentHTMLatom=p->firstHTMLatom,nextHTMLatom;
XSWAP hidethis=IE_NULL;
unsigned dummy;
int count=0,asf;
struct HTMLrecord *atomptr;
struct HTTPrecord HTTPdoc;
char oldhref[URLSIZE] = "\0";
mouseoff();
if(generateASF)
{
char fname[80];
tempinit(fname);
strcat(fname,"$tmp$.asf");
asf=a_open(fname,O_BINARY|O_WRONLY|O_CREAT|O_TRUNC,S_IREAD|S_IWRITE);
if(asf>=0)
sprintf(GLOBAL.location,"file:%s",fname);
else
return 0;
}
while(currentHTMLatom!=IE_NULL)
{
// kbhit();
atomptr=(struct HTMLrecord *)ie_getswap(currentHTMLatom);
if(!atomptr)
MALLOCERR();
nextHTMLatom=atomptr->next;
frameID=atomptr->frameID;
if(atomptr->type==HREF)
{
char *href=ie_getswap(atomptr->ptr);
if(generateASF)
{
char *str;
str = strrchr(href, '#');
if(str)
href[(int)(str - href)] = '\0';
strcat(href, "\n");
if(!strncmpi(href, "mailto:", 6))
continue;
if(strcmp(oldhref, href) != 0)
write(asf,href,strlen(href));
strcpy(oldhref, href);
}
else
{
AnalyseURL(href,&url,frameID);
if(SearchInCache(&url,&HTTPdoc,&dummy,&dummy) && file_exists(HTTPdoc.locname))
hidethis=currentHTMLatom;
else
{
count++;
hidethis=IE_NULL;
}
}
}
else
if(hidethis!=IE_NULL && atomptr->linkptr==hidethis)
{
atomptr->R=p->tmpframedata[frameID].textR;
atomptr->G=p->tmpframedata[frameID].textG;
atomptr->B=p->tmpframedata[frameID].textB;
swapmod=1;
}
currentHTMLatom=nextHTMLatom;
}//loop
if(generateASF)
{
write(asf,p->htmlframe[0].cacheitem.URL,strlen(p->htmlframe[0].cacheitem.URL));
write(asf,"\n",1);
a_close(asf);
return 1;
}
redrawHTML(REDRAW_WITH_MESSAGE,REDRAW_CREATE_VIRTUAL);
return count;
}
void activeatomredraw(void)
{
if(activeatomptr)
{
struct HTMLframe *frame=&(p->htmlframe[activeatomptr->frameID]);
mouseoff();
if(activeatomptr==&URLprompt || activeatomptr==&TXTprompt)
drawatom(activeatomptr,0u,0,
frame->scroll.xsize,
frame->scroll.ysize,
frame->scroll.xtop,
frame->scroll.ytop);
else
drawatom(activeatomptr,
frame->posX,
frame->posY,
frame->scroll.xsize,
frame->scroll.ysize,
frame->scroll.xtop,
frame->scroll.ytop);
mouseon();
}
}
void activeatomcursor(char cursor)
{
//have to be optimized!!!
if(htmlpulldown || (activeistextwindow && activeatomptr!=&TXTprompt))
{
if(htmlpulldown && htmlsavex!=-1)
{
ImouseSet(htmlsavex,htmlsavey);
hidehighlight();
}
if(arachne.framescount)
{
p->activeframe=0;
redrawHTML(REDRAW_NO_MESSAGE,REDRAW_CREATE_VIRTUAL);
}
else
redrawHTML(REDRAW_WITH_MESSAGE,REDRAW_VIRTUAL);
}
if(activeatomptr && activeatomptr->type==INPUT)
{
char subtype=activeatomptr->data1;
long xc,yc;
char zn[2]=" "; //was " \0" [JdS 2004/3/6]
char *ptr;
int ink,paper;
struct HTMLframe *frame=&(p->htmlframe[activeatomptr->frameID]);
if(subtype==SELECT)
{
activeatomredraw();
return;
}
editorptr=(struct ib_editor *)ie_getswap(activeatomptr->ptr);
if(editorptr)
{
memcpy(&tmpeditor,editorptr,sizeof(struct ib_editor));
ptr=ie_getline(&tmpeditor,tmpeditor.y);
if(ptr && strlen(ptr)>tmpeditor.x)
{
if(subtype==PASSWORD)
zn[0]='*';
else
zn[0]=ptr[tmpeditor.x];
}
xc=frame->scroll.xtop+activeatomptr->x+2;
yc=frame->scroll.ytop+activeatomptr->y+2;
if(activeatomptr!=&URLprompt && activeatomptr!=&TXTprompt)
{
xc-=frame->posX;
yc-=frame->posY;
if(xc<frame->scroll.xtop+2)
xc=frame->scroll.xtop+2;
if(yc<frame->scroll.ytop+2)
yc=frame->scroll.ytop+2;
}
xc+=fontx(SYSFONT,0,zn[0])*(tmpeditor.x-tmpeditor.zoomx);
yc+=fonty(SYSFONT,0)*(tmpeditor.y-tmpeditor.zoomy);
if(xc>=frame->scroll.xtop &&
xc<frame->scroll.xtop+frame->scroll.xsize &&
yc>=frame->scroll.ytop && yc<frame->scroll.ytop+frame->scroll.ysize ||
activeatomptr==&URLprompt || activeatomptr==&TXTprompt)
{
mouseoff();
if(tmpeditor.y<tmpeditor.bby || tmpeditor.y>tmpeditor.bey ||
tmpeditor.y==tmpeditor.bby && tmpeditor.x<tmpeditor.bbx ||
tmpeditor.y==tmpeditor.bey && tmpeditor.x>=tmpeditor.bex ||
tmpeditor.blockflag!=2)
{
ink=user_interface.ink;
paper=user_interface.paper;
}
else
{
ink=BLOCK_INK;
paper=BLOCK_PAPER;
}
if(cursor)
x_setfill(0,ink); //green
else
x_setfill(0,paper); //black
x_bar((int)xc,(int)yc,(int)xc+fontx(SYSFONT,0,zn[0])-1,(int)yc+fonty(SYSFONT,0)-2);
if(cursor)
x_setcolor(paper);
else
x_setcolor(ink);
htmlfont(SYSFONT,0);
if(fonty(SYSFONT,0)!=14)
yc-=1;
x_text_ib((int)xc,(int)yc,(unsigned char *)zn);
}
mouseon();
#ifdef GGI
Smart_ggiFlush();
#endif
}
else
MALLOCERR();
}
}
void MakeInputAtom(struct HTMLrecord *atom,struct ib_editor *tmpeditor,int x,long y,int xx,long yy)
{
atom->x=x;
atom->y=y;
atom->xx=xx;
atom->yy=yy;
atom->type=INPUT;
atom->data1=TEXT;
atom->data2=0;
atom->ptr=ie_putswap((char *)tmpeditor,sizeof(struct ib_editor),CONTEXT_SYSTEM);
atom->datalen=sizeof(struct ib_editor);
atom->linkptr=IE_NULL;
}
void SetInputAtom(struct HTMLrecord *atom,char *str)
{
if(atom->type!=INPUT)
return;
editorptr=(struct ib_editor *)ie_getswap(atom->ptr);
if(editorptr)
{
editorptr->aktrad=0;
strcpy(editorptr->rad,str);
editorptr->x=strlen(str);
if((editorptr->x+1)*fontx(SYSFONT,0,' ')>atom->xx-atom->x-4)
editorptr->x=0;
editorptr->zoomx=0;
swapmod=1;
/*
nonsense ?!
memcpy(&tmpeditor,editorptr,sizeof(struct ib_editor));
ie_putline(&tmpeditor,0,str);
swapmod=1;
*/
}
else
MALLOCERR();
}
char *gotoactiveatom(char asc, XSWAP *formID)
{
struct HTMLrecord *atomptr=(struct HTMLrecord*)ie_getswap(activeadr);
if(atomptr && atomptr->type==INPUT &&
(atomptr->data1==TEXT || atomptr->data1==PASSWORD ||
atomptr->data1==TEXTAREA && asc!=13))
{
*formID=atomptr->linkptr;
atomptr=(struct HTMLrecord *)ie_getswap(*formID);
if(atomptr && atomptr->type==FORM)
{
GLOBAL.postdata=atomptr->data2+1;
arachne.target=atomptr->data1;
return(char *)ie_getswap(atomptr->ptr);
}//endif
}
*formID=IE_NULL;
return NULL;
}
//---------------------------- <SELECT> ---------------------------- begin
// Pull down select
void SelectSwitch(int x,long y,int key) //x coord will be maybe used in future
{
int selected;
long selecty=activeatom.y;
int fromx=p->htmlframe[activeatom.frameID].posX;
long fromy=p->htmlframe[activeatom.frameID].posY;
x++; // dummy, just supress warning
if(selecty<fromy)
selecty=fromy;
selected=(int)(y-selecty-1)/fonty(OPTIONFONT,0)*2;
editorptr=(struct ib_editor *)ie_getswap(activeatom.ptr);
if(editorptr)
{
char *ptr;
char singleline=0;
int rows;
long realy=activeatom.y;
long realyy=activeatom.yy;
struct ScrollBar *scroll=&(p->htmlframe[activeatom.frameID].scroll);
int onscreen_x=(int)(activeatom.x-fromx+scroll->xtop);
int onscreen_xx=(int)(activeatom.xx-fromx+scroll->xtop);
if(realy-fromy+scroll->ytop<p->htscrn_ytop)
realy=scroll->ytop-p->htscrn_ytop+fromy;
if(realyy-fromy+scroll->ytop>p->htscrn_ytop+p->htscrn_ysize)
realyy=p->htscrn_ytop+p->htscrn_ysize-scroll->ytop+fromy;
rows=2*(int)((realyy-realy-4)/fonty(OPTIONFONT,0));
if(selected>rows)
selected=rows;
selected+=editorptr->zoomy;
if(activeatom.yy-activeatom.y<2*fonty(OPTIONFONT,0))
{
singleline=1;
if(key)
return;
}
if((editorptr->lines>=rows) && !singleline || key)
{
int sw=0;
if(key==0 && user_interface.scrollbarsize>3)
{
struct ScrollBar tmpscroll;
char resetstyle=0;
if(!user_interface.scrollbarstyle)
{
user_interface.scrollbarstyle='N';
resetstyle=1;
}
tmpscroll.xvisible=0;
tmpscroll.yvisible=1;
ScrollInit(&tmpscroll,
(int)(activeatom.xx-activeatom.x-user_interface.scrollbarsize-6),
(int)(realyy-realy-8),
(int)(realyy-realy-8),
onscreen_x+3,
(int)(realy+3-fromy+scroll->ytop),1,1);
sw=OnScrollButtons(&tmpscroll);
if(resetstyle)
user_interface.scrollbarstyle=0;
}
if(sw || key)
{
if(sw==2 || key==PAGEDOWN || (key==DOWNARROW && editorptr->x==editorptr->zoomy+rows-2))
{
if(rows+editorptr->zoomy<editorptr->lines)
editorptr->zoomy+=rows; //down
else
editorptr->x=editorptr->zoomy+rows-2;
if(key==DOWNARROW)
key=PAGEDOWN; //not UPARROW || DOWNARROW
}
else
if(sw==1 || key==PAGEUP || (key==UPARROW && editorptr->x==editorptr->zoomy))
{
editorptr->zoomy-=rows; //up
if(key==UPARROW)
key=PAGEUP; //not UPARROW || DOWNARROW
}
else
if(key==ENDKEY)
{
editorptr->x=editorptr->zoomy+rows-2;
}
else
if(key==HOMEKEY)
{
editorptr->x=editorptr->zoomy;
}
if(editorptr->zoomy<0)
{
editorptr->zoomy=0;
editorptr->x=0;
}
swapmod=1; //editorptr was updated.
if(key)
{
if(key==CURSOR_SYNCHRO)
{
if(editorptr->x==selected)
return;
//!!Ray: Jan 27, 2007
// NO, DON'T RETURN! JUST BECAUSE YOU DOWN THE LAST UP BUTTON DOESN'T
// MEAN YOU ARE NOT STILL ON ANOTHER BUTTON. COMMENTING 'return' IS
// SUFFICIENT TO KILL THE BUG, BUT THE WHOLE BLOCK IS SUSPECT, IT ONLY
// DOWNS THE BUTTON IN ONE OF FOUR POSSIBLE SITUATIONS, AND IT DOES THAT
// IMPERFECTLY, BEST TO JUST KILL THE WHOLE THING, THE BUTTON WILL DROP
// JUST FINE WITHOUT ANY OF THIS.
/*
else if(x>onscreen_xx-user_interface.scrollbarsize-4)
{
hidehighlight();
return;
}
*/
//!!Ray: end
else
editorptr->x=selected;
}
if(key==DOWNARROW && htmlsavex!=-1)
editorptr->x+=2;
else
if(key==UPARROW)
editorptr->x-=2;
if(editorptr->x<editorptr->zoomy)
editorptr->x=editorptr->zoomy;
if(editorptr->x>editorptr->zoomy+rows-2)
editorptr->x=editorptr->zoomy+rows-2;
if(editorptr->x>editorptr->lines-2)
editorptr->x=editorptr->lines-2;
if(key!=CURSOR_SYNCHRO) // mouse event, not key event...
{
if(htmlsavex==-1)
{
htmlsavex=mousex;
htmlsavey=mousey;
}
mousey=(int)(realy-fromy+scroll->ytop)+
fonty(OPTIONFONT,0)*(editorptr->x-editorptr->zoomy+2)/2;
mousex=onscreen_xx-user_interface.scrollbarsize-4;
ImouseSet( mousex, mousey);
}
//nice highlight...
hidehighlight();
thisx=onscreen_x+3;