|
|
1.1 root 1: #include "mint.h"
2:
3: #include "fasttext.h"
4:
5:
6:
7: #ifdef FASTTEXT
8:
9:
10:
11: #ifdef __GNUC__
12:
13: #define INLINE inline
14:
15: #define ITYPE long /* gcc's optimizer likes 32 bit integers */
16:
17: #else
18:
19: #define INLINE
20:
21: #define ITYPE int
22:
23: #endif
24:
25:
26:
27: #define CONDEV (2)
28:
29:
30:
31: static SCREEN *current;
32:
33:
34:
35: static void paint P_((SCREEN *, int, char *)),
36:
37: paint8c P_((SCREEN *, int, char *)),
38:
39: paint16m P_((SCREEN *, int, char *));
40:
41:
42:
43: INLINE static void curs_off P_((SCREEN *)), curs_on P_((SCREEN *));
44:
45: INLINE static void flash P_((SCREEN *));
46:
47: static void normal_putch P_((SCREEN *, int));
48:
49: static void escy_putch P_((SCREEN *, int));
50:
1.1.1.2 ! root 51: static void quote_putch P_((SCREEN *, int));
! 52:
1.1 root 53:
54:
55: static char *chartab[256];
56:
57:
58:
1.1.1.2 ! root 59: #define MAX_PLANES 8
! 60:
! 61: static int fgmask[MAX_PLANES], bgmask[MAX_PLANES];
! 62:
! 63:
! 64:
1.1 root 65: static long scrnsize;
66:
67:
68:
69: short hardscroll;
70:
71: static char *hardbase, *oldbase;
72:
73:
74:
75: typedef void (*Vfunc) P_((SCREEN *, int));
76:
77:
78:
79: #define base *((char **)0x44eL)
80:
81: #define escy1 *((short *)0x4acL)
82:
83:
84:
85: static Vfunc state;
86:
87:
88:
89: static short hardline;
90:
91: static void (*vpaint) P_((SCREEN *, int, char *));
92:
93:
94:
95: void init P_((void));
96:
97: void hardware_scroll P_((SCREEN *));
98:
99: INLINE static char *PLACE P_((SCREEN *, int, int));
100:
101: INLINE static void gotoxy P_((SCREEN *, int, int));
102:
103: INLINE static void clrline P_((SCREEN *, int));
104:
105: INLINE static void clear P_((SCREEN *));
106:
107: INLINE static void clrchar P_((SCREEN *, int, int));
108:
109: INLINE static void clrfrom P_((SCREEN *, int, int, int, int));
110:
111: INLINE static void delete_line P_((SCREEN *, int));
112:
113: INLINE static void insert_line P_((SCREEN *, int));
114:
115: static void setbgcol P_((SCREEN *, int));
116:
117: static void setfgcol P_((SCREEN *, int));
118:
119: static void putesc P_((SCREEN *, int));
120:
121: static void escy1_putch P_((SCREEN *, int));
122:
123: INLINE static void put_ch P_((SCREEN *, int));
124:
125:
126:
127: /* routines for flashing the cursor for screen v */
128:
129: /* flash(v): invert the character currently under the cursor */
130:
131:
132:
133: INLINE static void
134:
135: flash(v)
136:
137: SCREEN *v;
138:
139: {
140:
1.1.1.2 ! root 141: char *place;
1.1 root 142:
143: ITYPE i, j, vplanes;
144:
145:
146:
147: vplanes = v->planes + v->planes;
148:
149: place = v->cursaddr;
150:
151:
152:
153: for (j = v->cheight; j > 0; --j) {
154:
155: for (i = 0; i < vplanes; i+=2)
156:
1.1.1.2 ! root 157: place[i] = ~place[i];
1.1 root 158:
159:
160:
161: place += v->planesiz;
162:
163: }
164:
1.1.1.2 ! root 165: v->curstimer = v->period;
! 166:
1.1 root 167: }
168:
169:
170:
171: /* make sure the cursor is off */
172:
173:
174:
175: INLINE
176:
177: static void
178:
179: curs_off(v)
180:
181: SCREEN *v;
182:
183: {
184:
185: if (v->flags & CURS_ON) {
186:
187: if (v->flags & CURS_FSTATE) {
188:
189: flash(v);
190:
191: v->flags &= ~CURS_FSTATE;
192:
193: }
194:
195: }
196:
197: }
198:
199:
200:
201: /* OK, show the cursor again (if appropriate) */
202:
203:
204:
205: INLINE static void
206:
207: curs_on(v)
208:
209: SCREEN *v;
210:
211: {
212:
213: if (v->hidecnt) return;
214:
215:
216:
217: if (v->flags & CURS_ON) {
218:
1.1.1.2 ! root 219: #if 0
! 220:
1.1 root 221: /* if the cursor is flashing, we cheat a little and leave it off
222:
223: * to be turned on again (if necessary) by the VBL routine
224:
225: */
226:
227: if (v->flags & CURS_FLASH) {
228:
229: v->curstimer = 2;
230:
231: return;
232:
233: }
234:
1.1.1.2 ! root 235: #endif
! 236:
1.1 root 237: if (!(v->flags & CURS_FSTATE)) {
238:
239: v->flags |= CURS_FSTATE;
240:
241: flash(v);
242:
243: }
244:
245: }
246:
247: }
248:
249:
250:
251: void
252:
253: init()
254:
255: {
256:
257: SCREEN *v;
258:
259: int i, j;
260:
261: char *data, *foo;
262:
263: static char chardata[256*16];
264:
265:
266:
267: foo = lineA0();
268:
269: v = (SCREEN *)(foo - 346);
270:
271:
272:
273: /* Ehem... The screen might be bigger than 32767 bytes.
274:
275: Let's do some casting...
276:
277: Erling
278:
279: */
280:
281: scrnsize = (v->maxy+1)*(long)v->linelen;
282:
1.1.1.2 ! root 283: if (hardscroll == -1) {
! 284:
! 285: /* request for auto-setting */
! 286:
! 287: hardscroll = v->maxy+1;
! 288:
! 289: }
! 290:
1.1 root 291: if (hardscroll > 0) {
292:
293: if (!hardbase)
294:
295: hardbase = (char *)(((long)kcore(SCNSIZE(v)+256L)+255L)
296:
297: & 0xffffff00L);
298:
299:
300:
301: if (hardbase == 0) {
302:
303: ALERT("Insufficient memory for hardware scrolling!");
304:
305: } else {
306:
307: quickmove(hardbase, base, scrnsize);
308:
309: v->cursaddr = v->cursaddr + (hardbase - base);
310:
311: oldbase = base;
312:
313: base = hardbase;
314:
315: Setscreen(hardbase, hardbase, -1);
316:
317: }
318:
319: }
320:
321: hardline = 0;
322:
323: if (v->cheight == 8 && v->planes == 2) {
324:
325: foo = &chardata[0];
326:
327: vpaint = paint8c;
328:
329: for (i = 0; i < 256; i++) {
330:
331: chartab[i] = foo;
332:
333: data = v->fontdata + i;
334:
335: for (j = 0; j < 8; j++) {
336:
337: *foo++ = *data;
338:
339: data += v->form_width;
340:
341: }
342:
343: }
344:
345: } else if (v->cheight == 16 && v->planes == 1) {
346:
347: foo = &chardata[0];
348:
349: vpaint = paint16m;
350:
351: for (i = 0; i < 256; i++) {
352:
353: chartab[i] = foo;
354:
355: data = v->fontdata + i;
356:
357: for (j = 0; j < 16; j++) {
358:
359: *foo++ = *data;
360:
361: data += v->form_width;
362:
363: }
364:
365: }
366:
367: }
368:
369: else
370:
371: vpaint = paint;
372:
373:
374:
375: if (v->hidecnt == 0) {
376:
377: /*
378:
379: * make sure the cursor is set up correctly and turned on
380:
381: */
382:
383: (void)Cursconf(0,0); /* turn cursor off */
384:
385:
386:
1.1.1.2 ! root 387: v->flags &= ~CURS_FSTATE;
1.1 root 388:
389:
390:
391: /* now turn the cursor on the way we like it */
392:
393: v->hidecnt = 0;
394:
395: curs_on(v);
396:
397: } else {
398:
399: (void)Cursconf(0,0);
400:
401: v->flags &= ~CURS_ON;
402:
403: v->hidecnt = 1;
404:
405: }
406:
407:
408:
409: current = v;
410:
1.1.1.2 ! root 411: /* setup bgmask and fgmask */
! 412:
! 413: setbgcol(v, v->bgcol);
! 414:
! 415: setfgcol(v, v->fgcol);
! 416:
1.1 root 417: state = normal_putch;
418:
419: }
420:
421:
422:
423: /*
424:
425: * PLACE(v, x, y): the address corresponding to the upper left hand corner of
426:
427: * the character at position (x,y) on screen v
428:
429: */
430:
431: INLINE static
432:
433: char *PLACE(v, x, y)
434:
435: SCREEN *v;
436:
437: int x, y;
438:
439: {
440:
441: char *place;
442:
443: int i, j;
444:
445:
446:
447: place = base + x;
448:
449: if (y == v->maxy)
450:
451: place += scrnsize - v->linelen;
452:
453: else if (y) /* Yo, the screen might be bigger than 32767 bytes...
454:
455: Do a cast to long. Erling. */
456:
457: place += (long)y * v->linelen;
458:
459:
460:
461: if ((j = v->planes) > 1) {
462:
463: i = (x & 0xfffe);
464:
465: while (--j > 0)
466:
467: place += i;
468:
469: }
470:
471: return place;
472:
473: }
474:
475:
476:
477: /*
478:
479: * paint(v, c, place): put character 'c' at position 'place' on screen
480:
481: * v. It is assumed that x, y are proper coordinates!
482:
483: * Specialized versions (paint8c and paint16m) of this routine follow;
484:
485: * they assume 8 line high characters, medium res. and 16 line/mono,
486:
487: * respectively.
488:
489: */
490:
491:
492:
493: static void
494:
495: paint(v, c, place)
496:
497: SCREEN *v;
498:
499: int c;
500:
501: char *place;
502:
503: {
504:
505: char *data, d, doinverse;
506:
507: ITYPE j, planecount;
508:
509: int vplanes;
510:
511: long vform_width, vplanesiz;
512:
513:
514:
515: vplanes = v->planes;
516:
517:
518:
519: data = v->fontdata + c;
520:
521: doinverse = (v->flags & FINVERSE) ? 0xff : 0;
522:
523: vform_width = v->form_width;
524:
525: vplanesiz = v->planesiz;
526:
527:
528:
529: for (j = v->cheight; j > 0; --j) {
530:
531: d = *data ^ doinverse;
532:
1.1.1.2 ! root 533: for (planecount = 0; planecount < vplanes; planecount++)
1.1 root 534:
1.1.1.2 ! root 535: place[planecount << 1]
1.1 root 536:
1.1.1.2 ! root 537: = ((d & (char) fgmask[planecount])
1.1 root 538:
1.1.1.2 ! root 539: | (~d & (char) bgmask[planecount]));
1.1 root 540:
541: place += vplanesiz;
542:
543: data += vform_width;
544:
545: }
546:
547: }
548:
549:
550:
551: static void
552:
553: paint8c(v, c, place)
554:
555: SCREEN *v;
556:
557: int c;
558:
559: char *place;
560:
561: {
562:
563: char *data;
564:
565: char d, doinverse;
566:
1.1.1.2 ! root 567: char bg0, bg1, fg0, fg1;
! 568:
1.1 root 569: long vplanesiz;
570:
571:
572:
573: data = chartab[c];
574:
575:
576:
577: doinverse = (v->flags & FINVERSE) ? 0xff : 0;
578:
579: vplanesiz = v->planesiz;
580:
1.1.1.2 ! root 581: bg0 = bgmask[0];
! 582:
! 583: bg1 = bgmask[1];
! 584:
! 585: fg0 = fgmask[0];
! 586:
! 587: fg1 = fgmask[1];
1.1 root 588:
589:
1.1.1.2 ! root 590:
! 591: if (!doinverse && !bg0 && !bg1 && fg0 && fg1) {
1.1 root 592:
593: /* line 1 */
594:
595: d = *data++;
596:
597: *place = d;
598:
599: place[2] = d;
600:
601: place += vplanesiz;
602:
603:
604:
605: /* line 2 */
606:
607: d = *data++;
608:
609: *place = d;
610:
611: place[2] = d;
612:
613: place += vplanesiz;
614:
615:
616:
617: /* line 3 */
618:
619: d = *data++;
620:
621: *place = d;
622:
623: place[2] = d;
624:
625: place += vplanesiz;
626:
627:
628:
629: /* line 4 */
630:
631: d = *data++;
632:
633: *place = d;
634:
635: place[2] = d;
636:
637: place += vplanesiz;
638:
639:
640:
641: /* line 5 */
642:
643: d = *data++;
644:
645: *place = d;
646:
647: place[2] = d;
648:
649: place += vplanesiz;
650:
651:
652:
653: /* line 6 */
654:
655: d = *data++;
656:
657: *place = d;
658:
659: place[2] = d;
660:
661: place += vplanesiz;
662:
663:
664:
665: /* line 7 */
666:
667: d = *data++;
668:
669: *place = d;
670:
671: place[2] = d;
672:
673: place += vplanesiz;
674:
675:
676:
677: /* line 8 */
678:
1.1.1.2 ! root 679: d = *data;
1.1 root 680:
681: *place = d;
682:
683: place[2] = d;
684:
685: } else {
686:
687: /* line 1 */
688:
689: d = *data++ ^ doinverse;
690:
1.1.1.2 ! root 691: *place = ((d & fg0) | (~d & bg0));
1.1 root 692:
1.1.1.2 ! root 693: place[2] = ((d & fg1) | (~d & bg1));
1.1 root 694:
695: place += vplanesiz;
696:
697:
698:
699: /* line 2 */
700:
701: d = *data++ ^ doinverse;
702:
1.1.1.2 ! root 703: *place = ((d & fg0) | (~d & bg0));
1.1 root 704:
1.1.1.2 ! root 705: place[2] = ((d & fg1) | (~d & bg1));
1.1 root 706:
707: place += vplanesiz;
708:
709:
710:
711: /* line 3 */
712:
713: d = *data++ ^ doinverse;
714:
1.1.1.2 ! root 715: *place = ((d & fg0) | (~d & bg0));
1.1 root 716:
1.1.1.2 ! root 717: place[2] = ((d & fg1) | (~d & bg1));
1.1 root 718:
719: place += vplanesiz;
720:
721:
722:
723: /* line 4 */
724:
725: d = *data++ ^ doinverse;
726:
1.1.1.2 ! root 727: *place = ((d & fg0) | (~d & bg0));
1.1 root 728:
1.1.1.2 ! root 729: place[2] = ((d & fg1) | (~d & bg1));
1.1 root 730:
731: place += vplanesiz;
732:
733:
734:
735: /* line 5 */
736:
737: d = *data++ ^ doinverse;
738:
1.1.1.2 ! root 739: *place = ((d & fg0) | (~d & bg0));
1.1 root 740:
1.1.1.2 ! root 741: place[2] = ((d & fg1) | (~d & bg1));
1.1 root 742:
743: place += vplanesiz;
744:
745:
746:
747: /* line 6 */
748:
749: d = *data++ ^ doinverse;
750:
1.1.1.2 ! root 751: *place = ((d & fg0) | (~d & bg0));
1.1 root 752:
1.1.1.2 ! root 753: place[2] = ((d & fg1) | (~d & bg1));
1.1 root 754:
755: place += vplanesiz;
756:
757:
758:
759: /* line 7 */
760:
761: d = *data++ ^ doinverse;
762:
1.1.1.2 ! root 763: *place = ((d & fg0) | (~d & bg0));
1.1 root 764:
1.1.1.2 ! root 765: place[2] = ((d & fg1) | (~d & bg1));
1.1 root 766:
767: place += vplanesiz;
768:
769:
770:
771: /* line 8 */
772:
1.1.1.2 ! root 773: d = *data ^ doinverse;
1.1 root 774:
1.1.1.2 ! root 775: *place = ((d & fg0) | (~d & bg0));
1.1 root 776:
1.1.1.2 ! root 777: place[2] = ((d & fg1) | (~d & bg1));
1.1 root 778:
779: }
780:
781: }
782:
783:
784:
785: static void
786:
787: paint16m(v, c, place)
788:
789: SCREEN *v;
790:
791: int c;
792:
793: char *place;
794:
795: {
796:
797: char *data;
798:
799: char d, doinverse;
800:
801: long vplanesiz;
802:
803:
804:
805: data = chartab[c];
806:
807: doinverse = (v->flags & FINVERSE) ? 0xff : 0;
808:
1.1.1.2 ! root 809: doinverse ^= bgmask[0];
! 810:
1.1 root 811: vplanesiz = v->planesiz;
812:
813:
814:
1.1.1.2 ! root 815: if (bgmask[0] == fgmask[0])
! 816:
! 817: {
! 818:
! 819: /* fgcol and bgcol are the same -- easy */
! 820:
! 821: d = (char) bgmask[0];
! 822:
! 823: *place = d;
! 824:
! 825: place += vplanesiz;
! 826:
! 827: *place = d;
! 828:
! 829: place += vplanesiz;
! 830:
! 831: *place = d;
! 832:
! 833: place += vplanesiz;
! 834:
! 835: *place = d;
! 836:
! 837: place += vplanesiz;
! 838:
! 839: *place = d;
! 840:
! 841: place += vplanesiz;
! 842:
! 843: *place = d;
! 844:
! 845: place += vplanesiz;
! 846:
! 847: *place = d;
! 848:
! 849: place += vplanesiz;
! 850:
! 851: *place = d;
! 852:
! 853: place += vplanesiz;
! 854:
! 855: *place = d;
! 856:
! 857: place += vplanesiz;
! 858:
! 859: *place = d;
! 860:
! 861: place += vplanesiz;
! 862:
! 863: *place = d;
! 864:
! 865: place += vplanesiz;
! 866:
! 867: *place = d;
! 868:
! 869: place += vplanesiz;
! 870:
! 871: *place = d;
! 872:
! 873: place += vplanesiz;
! 874:
! 875: *place = d;
! 876:
! 877: place += vplanesiz;
! 878:
! 879: *place = d;
! 880:
! 881: place += vplanesiz;
! 882:
! 883: *place = d;
! 884:
! 885: }
! 886:
! 887: else if (!doinverse) {
1.1 root 888:
889: /* line 1 */
890:
891: d = *data++;
892:
893: *place = d;
894:
895: place += vplanesiz;
896:
897:
898:
899: /* line 2 */
900:
901: d = *data++;
902:
903: *place = d;
904:
905: place += vplanesiz;
906:
907:
908:
909: /* line 3 */
910:
911: d = *data++;
912:
913: *place = d;
914:
915: place += vplanesiz;
916:
917:
918:
919: /* line 4 */
920:
921: d = *data++;
922:
923: *place = d;
924:
925: place += vplanesiz;
926:
927:
928:
929: /* line 5 */
930:
931: d = *data++;
932:
933: *place = d;
934:
935: place += vplanesiz;
936:
937:
938:
939: /* line 6 */
940:
941: d = *data++;
942:
943: *place = d;
944:
945: place += vplanesiz;
946:
947:
948:
949: /* line 7 */
950:
951: d = *data++;
952:
953: *place = d;
954:
955: place += vplanesiz;
956:
957:
958:
959: /* line 8 */
960:
961: d = *data++;
962:
963: *place = d;
964:
965: place += vplanesiz;
966:
967:
968:
969: /* line 9 */
970:
971: d = *data++;
972:
973: *place = d;
974:
975: place += vplanesiz;
976:
977:
978:
979: /* line 10 */
980:
981: d = *data++;
982:
983: *place = d;
984:
985: place += vplanesiz;
986:
987:
988:
989: /* line 11 */
990:
991: d = *data++;
992:
993: *place = d;
994:
995: place += vplanesiz;
996:
997:
998:
999: /* line 12 */
1000:
1001: d = *data++;
1002:
1003: *place = d;
1004:
1005: place += vplanesiz;
1006:
1007:
1008:
1009: /* line 13 */
1010:
1011: d = *data++;
1012:
1013: *place = d;
1014:
1015: place += vplanesiz;
1016:
1017:
1018:
1019: /* line 14 */
1020:
1021: d = *data++;
1022:
1023: *place = d;
1024:
1025: place += vplanesiz;
1026:
1027:
1028:
1029: /* line 15 */
1030:
1031: d = *data++;
1032:
1033: *place = d;
1034:
1035: place += vplanesiz;
1036:
1037:
1038:
1039: /* line 16 */
1040:
1.1.1.2 ! root 1041: d = *data;
1.1 root 1042:
1043: *place = d;
1044:
1045: } else {
1046:
1047: /* line 1 */
1048:
1.1.1.2 ! root 1049: d = ~*data++;
1.1 root 1050:
1051: *place = d;
1052:
1053: place += vplanesiz;
1054:
1055:
1056:
1057: /* line 2 */
1058:
1.1.1.2 ! root 1059: d = ~*data++;
1.1 root 1060:
1061: *place = d;
1062:
1063: place += vplanesiz;
1064:
1065:
1066:
1067: /* line 3 */
1068:
1.1.1.2 ! root 1069: d = ~*data++;
1.1 root 1070:
1071: *place = d;
1072:
1073: place += vplanesiz;
1074:
1075:
1076:
1077: /* line 4 */
1078:
1.1.1.2 ! root 1079: d = ~*data++;
1.1 root 1080:
1081: *place = d;
1082:
1083: place += vplanesiz;
1084:
1085:
1086:
1087: /* line 5 */
1088:
1.1.1.2 ! root 1089: d = ~*data++;
1.1 root 1090:
1091: *place = d;
1092:
1093: place += vplanesiz;
1094:
1095:
1096:
1097: /* line 6 */
1098:
1.1.1.2 ! root 1099: d = ~*data++;
1.1 root 1100:
1101: *place = d;
1102:
1103: place += vplanesiz;
1104:
1105:
1106:
1107: /* line 7 */
1108:
1.1.1.2 ! root 1109: d = ~*data++;
1.1 root 1110:
1111: *place = d;
1112:
1113: place += vplanesiz;
1114:
1115:
1116:
1117: /* line 8 */
1118:
1.1.1.2 ! root 1119: d = ~*data++;
1.1 root 1120:
1121: *place = d;
1122:
1123: place += vplanesiz;
1124:
1125:
1126:
1127: /* line 9 */
1128:
1.1.1.2 ! root 1129: d = ~*data++;
1.1 root 1130:
1131: *place = d;
1132:
1133: place += vplanesiz;
1134:
1135:
1136:
1137: /* line 10 */
1138:
1.1.1.2 ! root 1139: d = ~*data++;
1.1 root 1140:
1141: *place = d;
1142:
1143: place += vplanesiz;
1144:
1145:
1146:
1147: /* line 11 */
1148:
1.1.1.2 ! root 1149: d = ~*data++;
1.1 root 1150:
1151: *place = d;
1152:
1153: place += vplanesiz;
1154:
1155:
1156:
1157: /* line 12 */
1158:
1.1.1.2 ! root 1159: d = ~*data++;
1.1 root 1160:
1161: *place = d;
1162:
1163: place += vplanesiz;
1164:
1165:
1166:
1167: /* line 13 */
1168:
1.1.1.2 ! root 1169: d = ~*data++;
1.1 root 1170:
1171: *place = d;
1172:
1173: place += vplanesiz;
1174:
1175:
1176:
1177: /* line 14 */
1178:
1.1.1.2 ! root 1179: d = ~*data++;
1.1 root 1180:
1181: *place = d;
1182:
1183: place += vplanesiz;
1184:
1185:
1186:
1187: /* line 15 */
1188:
1.1.1.2 ! root 1189: d = ~*data++;
1.1 root 1190:
1191: *place = d;
1192:
1193: place += vplanesiz;
1194:
1195:
1196:
1197: /* line 16 */
1198:
1.1.1.2 ! root 1199: d = ~*data;
1.1 root 1200:
1201: *place = d;
1202:
1203: }
1204:
1205: }
1206:
1207:
1208:
1209: /*
1210:
1211: * gotoxy (v, x, y): move current cursor address of screen v to (x, y)
1212:
1213: * makes sure that (x, y) will be legal
1214:
1215: */
1216:
1217:
1218:
1219: INLINE static void
1220:
1221: gotoxy(v, x, y)
1222:
1223: SCREEN *v;
1224:
1225: int x, y;
1226:
1227: {
1228:
1229: if (x > v->maxx) x = v->maxx;
1230:
1231: else if (x < 0) x = 0;
1232:
1233: if (y > v->maxy) y = v->maxy;
1234:
1235: else if (y < 0) y = 0;
1236:
1237:
1238:
1239: v->cx = x;
1240:
1241: v->cy = y;
1242:
1243: v->cursaddr = PLACE(v, x, y);
1244:
1245: }
1246:
1247:
1248:
1249: /*
1250:
1251: * clrline(v, r): clear line r of screen v
1252:
1253: */
1254:
1255:
1256:
1257: INLINE static void
1258:
1259: clrline(v, r)
1260:
1261: SCREEN *v;
1262:
1263: int r;
1264:
1265: {
1266:
1.1.1.2 ! root 1267: int *dst, *m;
1.1 root 1268:
1.1.1.2 ! root 1269: long nwords;
1.1 root 1270:
1.1.1.2 ! root 1271: int i, vplanes;
1.1 root 1272:
1273:
1274:
1275: /* Hey, again the screen might be bigger than 32767 bytes.
1276:
1277: Do another cast... */
1278:
1.1.1.2 ! root 1279: dst = (int *)(base + ((long)r * v->linelen));
! 1280:
! 1281: if (v->bgcol == 0)
! 1282:
! 1283: zero((char *)dst, v->linelen);
! 1284:
! 1285: else
! 1286:
! 1287: {
! 1288:
! 1289: /* do it the hard way */
! 1290:
! 1291: vplanes = v->planes;
1.1 root 1292:
1.1.1.2 ! root 1293: for (nwords = v->linelen >> 1; nwords > 0; nwords -= vplanes)
! 1294:
! 1295: {
! 1296:
! 1297: m = bgmask;
! 1298:
! 1299: for (i = 0; i < vplanes; i++)
! 1300:
! 1301: *dst++ = *m++;
! 1302:
! 1303: }
! 1304:
! 1305: }
1.1 root 1306:
1307: }
1308:
1309:
1310:
1311: /*
1312:
1313: * clear(v): clear the whole screen v
1314:
1315: */
1316:
1317:
1318:
1319: INLINE static void
1320:
1321: clear(v)
1322:
1323: SCREEN *v;
1324:
1325: {
1326:
1.1.1.2 ! root 1327: int i, vplanes;
! 1328:
! 1329: int *dst, *m;
! 1330:
! 1331: long nwords;
! 1332:
! 1333:
! 1334:
! 1335: if (v->bgcol == 0)
! 1336:
! 1337: zero(base, scrnsize);
! 1338:
! 1339: else
! 1340:
! 1341: {
! 1342:
! 1343: /* do it the hard way */
! 1344:
! 1345: dst = (int *) base;
! 1346:
! 1347: vplanes = v->planes;
! 1348:
! 1349: for (nwords = scrnsize >> 1; nwords > 0; nwords -= vplanes)
! 1350:
! 1351: {
! 1352:
! 1353: m = bgmask;
! 1354:
! 1355: for (i = 0; i < vplanes; i++)
! 1356:
! 1357: *dst++ = *m++;
! 1358:
! 1359: }
! 1360:
! 1361: }
1.1 root 1362:
1363: }
1364:
1365:
1366:
1367: /*
1368:
1369: * clrchar(v, x, y): clear the (x,y) position on screen v
1370:
1371: */
1372:
1373:
1374:
1375: INLINE static void
1376:
1377: clrchar(v, x, y)
1378:
1379: SCREEN *v;
1380:
1381: int x, y;
1382:
1383: {
1384:
1385: int i, j, vplanes;
1386:
1387: char *place;
1388:
1.1.1.2 ! root 1389: int *m;
! 1390:
1.1 root 1391:
1392:
1393: vplanes = v->planes + v->planes;
1394:
1395:
1396:
1397: place = PLACE(v, x, y);
1398:
1399:
1400:
1401: for (j = v->cheight; j > 0; --j) {
1402:
1.1.1.2 ! root 1403: m = bgmask;
! 1404:
! 1405: for (i = 0; i < vplanes; i += 2)
1.1 root 1406:
1.1.1.2 ! root 1407: place[i] = (char) *m++;
1.1 root 1408:
1409: place += v->planesiz;
1410:
1411: }
1412:
1413: }
1414:
1415:
1416:
1417: /*
1418:
1419: * clrfrom(v, x1, y1, x2, y2): clear screen v from position (x1,y1) to
1420:
1421: * position (x2, y2) inclusive. It is assumed that y2 >= y1.
1422:
1423: */
1424:
1425:
1426:
1427: INLINE static void
1428:
1429: clrfrom(v, x1, y1, x2, y2)
1430:
1431: SCREEN *v;
1432:
1433: int x1,y1,x2,y2;
1434:
1435: {
1436:
1437: int i;
1438:
1439:
1440:
1441: for (i = x1; i <= v->maxx; i++)
1442:
1443: clrchar(v, i, y1);
1444:
1445: if (y2 > y1) {
1446:
1447: for (i = 0; i <= x2; i++)
1448:
1449: clrchar(v, i, y2);
1450:
1451: for (i = y1+1; i < y2; i++)
1452:
1453: clrline(v, i);
1454:
1455: }
1456:
1457: }
1458:
1459:
1460:
1461: /*
1462:
1463: * scroll a screen in hardware; if we still have hardware scrolling lines left,
1464:
1465: * just move the physical screen base, otherwise copy the screen back to the
1466:
1467: * hardware base and start over
1468:
1469: */
1470:
1471: void
1472:
1473: hardware_scroll(v)
1474:
1475: SCREEN *v;
1476:
1477: {
1478:
1479:
1480:
1481: ++hardline;
1482:
1483: if (hardline < hardscroll) { /* just move the screen */
1484:
1485: base += v->linelen;
1486:
1487: v->cursaddr = PLACE(v, v->cx, v->cy);
1488:
1489: Setscreen(base, base, -1);
1490:
1491: }
1492:
1493: else {
1494:
1495: hardline = 0;
1496:
1497: quickmove(hardbase, base + v->linelen, scrnsize - v->linelen);
1498:
1499: base = hardbase;
1500:
1501: v->cursaddr = PLACE(v, v->cx, v->cy);
1502:
1503: Setscreen(hardbase, hardbase, -1);
1504:
1505: }
1506:
1507: }
1508:
1509:
1510:
1511: /*
1512:
1513: * delete_line(v, r): delete line r of screen v. The screen below this
1514:
1515: * line is scrolled up, and the bottom line is cleared.
1516:
1517: */
1518:
1519:
1520:
1521: #define scroll(v) delete_line(v, 0)
1522:
1523:
1524:
1525: INLINE static void
1526:
1527: delete_line(v, r)
1528:
1529: SCREEN *v;
1530:
1531: int r;
1532:
1533: {
1534:
1535: long *src, *dst, nbytes;
1536:
1537:
1538:
1539: if (r == 0) {
1540:
1541: if (hardbase) {
1542:
1543: hardware_scroll(v);
1544:
1545: clrline(v, v->maxy);
1546:
1547: return;
1548:
1549: }
1550:
1551: nbytes = scrnsize - v->linelen;
1552:
1553: }
1554:
1555: else
1556:
1557: nbytes = (long)v->linelen * (v->maxy - r);
1558:
1559:
1560:
1561: /* Sheeze, how many times do we really have to cast...
1562:
1563: Erling.
1564:
1565: */
1566:
1567:
1568:
1569: dst = (long *)(base + ((long)r * v->linelen));
1570:
1571: src = (long *)( ((long)dst) + v->linelen);
1572:
1573:
1574:
1575: quickmove(dst, src, nbytes);
1576:
1577:
1578:
1579: /* clear the last line */
1580:
1581: clrline(v, v->maxy);
1582:
1583: }
1584:
1585:
1586:
1587: /*
1588:
1589: * insert_line(v, r): scroll all of the screen starting at line r down,
1590:
1591: * and then clear line r.
1592:
1593: */
1594:
1595:
1596:
1597: INLINE static void
1598:
1599: insert_line(v, r)
1600:
1601: SCREEN *v;
1602:
1603: int r;
1604:
1605: {
1606:
1607: long *src, *dst;
1608:
1609: int i, limit;
1610:
1611:
1612:
1613: limit = v->maxy;
1614:
1615: for (i = limit-1; i >= r ; --i) {
1616:
1617: /* move line i to line i+1 */
1618:
1619: /* AND do some casting to support big screens.
1620:
1621: Erling
1622:
1623: */
1624:
1625: src = (long *)(base + ((long)i * v->linelen));
1626:
1627: dst = (long *)(base + ((i+1)*(long)v->linelen));
1628:
1629: quickmove(dst, src, v->linelen);
1630:
1631: }
1632:
1633:
1634:
1635: /* clear line r */
1636:
1637: clrline(v, r);
1638:
1639: }
1640:
1641:
1642:
1643: /*
1644:
1645: * special states for handling ESC b x and ESC c x. Note that for now,
1646:
1647: * color is ignored.
1648:
1649: */
1650:
1651:
1652:
1653: static void
1654:
1655: setbgcol(v, c)
1656:
1657: SCREEN *v;
1658:
1659: int c;
1660:
1661: {
1662:
1.1.1.2 ! root 1663: int i;
! 1664:
! 1665:
! 1666:
1.1 root 1667: v->bgcol = c & ((1 << v->planes)-1);
1668:
1.1.1.2 ! root 1669: for (i = 0; i < v->planes; i++)
! 1670:
! 1671: bgmask[i] = (v->bgcol & (1 << i)) ? -1 : 0;
! 1672:
1.1 root 1673: state = normal_putch;
1674:
1675: }
1676:
1677:
1678:
1679: static void
1680:
1681: setfgcol(v, c)
1682:
1683: SCREEN *v;
1684:
1685: int c;
1686:
1687: {
1688:
1.1.1.2 ! root 1689: int i;
! 1690:
! 1691:
! 1692:
1.1 root 1693: v->fgcol = c & ((1 << v->planes)-1);
1694:
1.1.1.2 ! root 1695: for (i = 0; i < v->planes; i++)
! 1696:
! 1697: fgmask[i] = (v->fgcol & (1 << i)) ? -1 : 0;
! 1698:
! 1699: state = normal_putch;
! 1700:
! 1701: }
! 1702:
! 1703:
! 1704:
! 1705: static void
! 1706:
! 1707: quote_putch(v, c)
! 1708:
! 1709: SCREEN *v;
! 1710:
! 1711: int c;
! 1712:
! 1713: {
! 1714:
! 1715: (*vpaint)(v, c, v->cursaddr);
! 1716:
1.1 root 1717: state = normal_putch;
1718:
1719: }
1720:
1721:
1722:
1723: /*
1724:
1725: * putesc(v, c): handle the control sequence ESC c
1726:
1727: */
1728:
1729:
1730:
1731: static void
1732:
1733: putesc(v, c)
1734:
1735: SCREEN *v;
1736:
1737: int c;
1738:
1739: {
1740:
1741: int cx, cy;
1742:
1743:
1744:
1745: cx = v->cx; cy = v->cy;
1746:
1747:
1748:
1749: switch (c) {
1750:
1751: case 'A': /* cursor up */
1752:
1753: gotoxy(v, cx, cy-1);
1754:
1755: break;
1756:
1757: case 'B': /* cursor down */
1758:
1759: gotoxy(v, cx, cy+1);
1760:
1761: break;
1762:
1763: case 'C': /* cursor right */
1764:
1765: gotoxy(v, cx+1, cy);
1766:
1767: break;
1768:
1769: case 'D': /* cursor left */
1770:
1771: gotoxy(v, cx-1, cy);
1772:
1773: break;
1774:
1775: case 'E': /* clear home */
1776:
1777: clear(v);
1778:
1779: /* fall through... */
1780:
1781: case 'H': /* cursor home */
1782:
1783: gotoxy(v, 0, 0);
1784:
1785: break;
1786:
1787: case 'I': /* cursor up, insert line */
1788:
1789: if (cy == 0) {
1790:
1791: insert_line(v, 0);
1792:
1793: }
1794:
1795: else
1796:
1797: gotoxy(v, cx, cy-1);
1798:
1799: break;
1800:
1801: case 'J': /* clear below cursor */
1802:
1803: clrfrom(v, cx, cy, v->maxx, v->maxy);
1804:
1805: break;
1806:
1807: case 'K': /* clear remainder of line */
1808:
1809: clrfrom(v, cx, cy, v->maxx, cy);
1810:
1811: break;
1812:
1813: case 'L': /* insert a line */
1814:
1815: gotoxy(v, 0, cy);
1816:
1817: insert_line(v, cy);
1818:
1819: break;
1820:
1821: case 'M': /* delete line */
1822:
1823: gotoxy(v, 0, cy);
1824:
1825: delete_line(v, cy);
1826:
1827: break;
1828:
1.1.1.2 ! root 1829: case 'Q': /* quote-next-char */
! 1830:
! 1831: state = quote_putch;
! 1832:
! 1833: return;
! 1834:
1.1 root 1835: case 'Y':
1836:
1837: state = escy_putch;
1838:
1839: return; /* YES, this should be 'return' */
1840:
1841:
1842:
1843: case 'b':
1844:
1845: state = setfgcol;
1846:
1847: return;
1848:
1849: case 'c':
1850:
1851: state = setbgcol;
1852:
1853: return;
1854:
1855: case 'd': /* clear to cursor position */
1856:
1857: clrfrom(v, 0, 0, cx, cy);
1858:
1859: break;
1860:
1861: case 'e': /* enable cursor */
1862:
1863: v->flags |= CURS_ON;
1864:
1865: v->hidecnt = 1; /* so --v->hidecnt shows the cursor */
1866:
1867: break;
1868:
1869: case 'f': /* cursor off */
1870:
1871: v->hidecnt++;
1872:
1873: v->flags &= ~CURS_ON;
1874:
1875: break;
1876:
1877: case 'j': /* save cursor position */
1878:
1879: v->savex = v->cx;
1880:
1881: v->savey = v->cy;
1882:
1883: break;
1884:
1885: case 'k': /* restore saved position */
1886:
1887: gotoxy(v, v->savex, v->savey);
1888:
1889: break;
1890:
1891: case 'l': /* clear line */
1892:
1893: gotoxy(v, 0, cy);
1894:
1895: clrline(v, cy);
1896:
1897: break;
1898:
1899: case 'o': /* clear from start of line to cursor */
1900:
1901: clrfrom(v, 0, cy, cx, cy);
1902:
1903: break;
1904:
1905: case 'p': /* reverse video on */
1906:
1907: v->flags |= FINVERSE;
1908:
1909: break;
1910:
1911: case 'q': /* reverse video off */
1912:
1913: v->flags &= ~FINVERSE;
1914:
1915: break;
1916:
1917: case 'v': /* wrap on */
1918:
1919: v->flags |= FWRAP;
1920:
1921: break;
1922:
1923: case 'w':
1924:
1925: v->flags &= ~FWRAP;
1926:
1927: break;
1928:
1929: }
1930:
1931: state = normal_putch;
1932:
1933: }
1934:
1935:
1936:
1937: /*
1938:
1939: * escy1_putch(v, c): for when an ESC Y + char has been seen
1940:
1941: */
1942:
1943: static void
1944:
1945: escy1_putch(v, c)
1946:
1947: SCREEN *v;
1948:
1949: int c;
1950:
1951: {
1952:
1953: gotoxy(v, c - ' ', escy1 - ' ');
1954:
1955: state = normal_putch;
1956:
1957: }
1958:
1959:
1960:
1961: /*
1962:
1963: * escy_putch(v, c): for when an ESC Y has been seen
1964:
1965: */
1966:
1967: static void
1968:
1969: escy_putch(v, c)
1970:
1971: SCREEN *v;
1972:
1973: int c;
1974:
1975: {
1976:
1.1.1.2 ! root 1977: UNUSED(v);
! 1978:
1.1 root 1979: escy1 = c;
1980:
1981: state = escy1_putch;
1982:
1983: }
1984:
1985:
1986:
1987: /*
1988:
1989: * normal_putch(v, c): put character 'c' on screen 'v'. This is the default
1990:
1991: * for when no escape, etc. is active
1992:
1993: */
1994:
1995:
1996:
1997: static void
1998:
1999: normal_putch(v, c)
2000:
2001: SCREEN *v;
2002:
2003: int c;
2004:
2005: {
2006:
2007: /* control characters */
2008:
2009: if (c < ' ') {
2010:
2011: switch (c) {
2012:
2013: case '\r':
2014:
2015: gotoxy(v, 0, v->cy);
2016:
2017: return;
2018:
2019: case '\n':
2020:
2021: if (v->cy == v->maxy) {
2022:
2023: scroll(v);
2024:
2025: }
2026:
2027: else
2028:
2029: gotoxy(v, v->cx, v->cy+1);
2030:
2031: return;
2032:
2033: case '\b':
2034:
2035: gotoxy(v, v->cx-1, v->cy);
2036:
2037: return;
2038:
2039: case '\007': /* BELL */
2040:
2041: (void)bconout(CONDEV, 7);
2042:
2043: return;
2044:
2045: case '\033': /* ESC */
2046:
2047: state = putesc;
2048:
2049: return;
2050:
2051: case '\t':
2052:
2053: gotoxy(v, (v->cx + 8) & ~7, v->cy);
2054:
2055: return;
2056:
2057: default:
2058:
2059: return;
2060:
2061: }
2062:
2063: }
2064:
2065:
2066:
2067: (*vpaint)(v, c, v->cursaddr);
2068:
2069: v->cx++;
2070:
2071: if (v->cx > v->maxx) {
2072:
2073: if (v->flags & FWRAP) {
2074:
2075: v->cx = 0;
2076:
2077: normal_putch(v, '\n');
2078:
2079: v->cursaddr = PLACE(v, v->cx, v->cy);
2080:
2081: } else {
2082:
2083: v->cx = v->maxx;
2084:
2085: }
2086:
2087: } else {
2088:
2089: #if 0
2090:
2091: v->cursaddr = PLACE(v, v->cx, v->cy);
2092:
2093: #else
2094:
2095: v->cursaddr++;
2096:
2097: if ( (v->cx & 1) == 0 && v->planes > 1) { /* new word */
2098:
2099: short skipwords = v->planes - 1;
2100:
2101: v->cursaddr += skipwords+skipwords;
2102:
2103: }
2104:
2105: #endif
2106:
2107: }
2108:
2109: }
2110:
2111:
2112:
2113: INLINE static void
2114:
2115: put_ch(v, c)
2116:
2117: SCREEN *v;
2118:
2119: int c;
2120:
2121: {
2122:
2123: (*state)(v, c & 0x00ff);
2124:
2125: }
2126:
2127:
2128:
1.1.1.2 ! root 2129: static long ARGS_ON_STACK screen_open P_((FILEPTR *f));
1.1 root 2130:
1.1.1.2 ! root 2131: static long ARGS_ON_STACK screen_read P_((FILEPTR *f, char *buf, long nbytes));
1.1 root 2132:
1.1.1.2 ! root 2133: static long ARGS_ON_STACK screen_write P_((FILEPTR *f, const char *buf, long nbytes));
1.1 root 2134:
1.1.1.2 ! root 2135: static long ARGS_ON_STACK screen_lseek P_((FILEPTR *f, long where, int whence));
1.1 root 2136:
1.1.1.2 ! root 2137: static long ARGS_ON_STACK screen_ioctl P_((FILEPTR *f, int mode, void *buf));
1.1 root 2138:
1.1.1.2 ! root 2139: static long ARGS_ON_STACK screen_close P_((FILEPTR *f, int pid));
1.1 root 2140:
1.1.1.2 ! root 2141: static long ARGS_ON_STACK screen_select P_((FILEPTR *f, long p, int mode));
1.1 root 2142:
1.1.1.2 ! root 2143: static void ARGS_ON_STACK screen_unselect P_((FILEPTR *f, long p, int mode));
1.1 root 2144:
2145:
2146:
1.1.1.2 ! root 2147: extern long ARGS_ON_STACK null_datime P_((FILEPTR *f, short *time, int rwflag));
1.1 root 2148:
2149:
2150:
2151: DEVDRV screen_device = {
2152:
2153: screen_open, screen_write, screen_read, screen_lseek, screen_ioctl,
2154:
2155: null_datime, screen_close, screen_select, screen_unselect
2156:
2157: };
2158:
2159:
2160:
1.1.1.2 ! root 2161: static long ARGS_ON_STACK
1.1 root 2162:
2163: screen_open(f)
2164:
2165: FILEPTR *f;
2166:
2167: {
2168:
2169:
2170:
2171: if (!current) {
2172:
2173: init();
2174:
2175: } else
2176:
2177: return EACCDN; /* screen in use */
2178:
2179:
2180:
2181: f->flags |= O_TTY;
2182:
2183: return 0;
2184:
2185: }
2186:
2187:
2188:
1.1.1.2 ! root 2189: static long ARGS_ON_STACK
1.1 root 2190:
2191: screen_close(f, pid)
2192:
2193: FILEPTR *f;
2194:
2195: int pid;
2196:
2197: {
2198:
1.1.1.2 ! root 2199: UNUSED(pid);
! 2200:
! 2201:
! 2202:
1.1 root 2203: if (f->links <= 0) {
2204:
2205: if (hardbase) {
2206:
2207: quickmove(oldbase, base, scrnsize);
2208:
2209: base = oldbase;
2210:
2211: Setscreen(oldbase, oldbase, -1);
2212:
2213: }
2214:
2215: current = 0;
2216:
2217: }
2218:
2219: return 0;
2220:
2221: }
2222:
2223:
2224:
1.1.1.2 ! root 2225: static long ARGS_ON_STACK
1.1 root 2226:
2227: screen_write(f, buf, bytes)
2228:
2229: FILEPTR *f; const char *buf; long bytes;
2230:
2231: {
2232:
2233: SCREEN *v = current;
2234:
2235: long *r;
2236:
2237: long ret = 0;
2238:
2239: int c;
2240:
2241:
2242:
1.1.1.2 ! root 2243: UNUSED(f);
! 2244:
! 2245:
! 2246:
1.1 root 2247: (void)checkkeys();
2248:
2249: v->hidecnt++;
2250:
2251: v->flags |= CURS_UPD; /* for TOS 1.0 */
2252:
1.1.1.2 ! root 2253: curs_off(v);
! 2254:
1.1 root 2255: r = (long *)buf;
2256:
2257: while (bytes > 0) {
2258:
1.1.1.2 ! root 2259: c = (int) *r++;
1.1 root 2260:
2261: put_ch(v, c);
2262:
2263: bytes -= 4; ret+= 4;
2264:
2265: }
2266:
1.1.1.2 ! root 2267: if (v->hidecnt > 0)
1.1 root 2268:
1.1.1.2 ! root 2269: --v->hidecnt;
! 2270:
! 2271: else
! 2272:
! 2273: v->hidecnt = 0;
1.1 root 2274:
2275: curs_on(v);
2276:
1.1.1.2 ! root 2277: v->flags &= ~CURS_UPD;
! 2278:
1.1 root 2279: return ret;
2280:
2281: }
2282:
2283:
2284:
1.1.1.2 ! root 2285: static long ARGS_ON_STACK
1.1 root 2286:
2287: screen_read(f, buf, bytes)
2288:
2289: FILEPTR *f; char *buf; long bytes;
2290:
2291: {
2292:
2293: long *r, ret = 0;
2294:
2295:
2296:
2297: r = (long *)buf;
2298:
2299:
2300:
2301: while (bytes > 0) {
2302:
2303: if ( (f->flags & O_NDELAY) && !bconstat(CONDEV) )
2304:
2305: break;
2306:
1.1.1.2 ! root 2307: *r++ = bconin(CONDEV) & 0x7fffffffL;
1.1 root 2308:
2309: bytes -= 4; ret += 4;
2310:
2311: }
2312:
2313: return ret;
2314:
2315: }
2316:
2317:
2318:
1.1.1.2 ! root 2319: static long ARGS_ON_STACK
1.1 root 2320:
2321: screen_lseek(f, where, whence)
2322:
2323: FILEPTR *f;
2324:
2325: long where;
2326:
2327: int whence;
2328:
2329: {
2330:
2331: /* terminals always are at position 0 */
2332:
1.1.1.2 ! root 2333: UNUSED(f); UNUSED(where);
! 2334:
! 2335: UNUSED(whence);
! 2336:
1.1 root 2337: return 0;
2338:
2339: }
2340:
2341:
2342:
1.1.1.2 ! root 2343: static long ARGS_ON_STACK
1.1 root 2344:
2345: screen_ioctl(f, mode, buf)
2346:
2347: FILEPTR *f; int mode; void *buf;
2348:
2349: {
2350:
2351: long *r = (long *)buf;
2352:
2353: struct winsize *w;
2354:
2355:
2356:
1.1.1.2 ! root 2357: UNUSED(f);
! 2358:
! 2359:
! 2360:
1.1 root 2361: if (mode == FIONREAD) {
2362:
2363: if (bconstat(CONDEV))
2364:
2365: *r = 1;
2366:
2367: else
2368:
2369: *r = 0;
2370:
2371: }
2372:
2373: else if (mode == FIONWRITE) {
2374:
2375: *r = 1;
2376:
2377: }
2378:
2379: else if (mode == TIOCFLUSH) {
2380:
2381: /* BUG: this should flush the input/output buffers */
2382:
2383: return 0;
2384:
2385: }
2386:
2387: else if (mode == TIOCGWINSZ) {
2388:
2389: w = (struct winsize *)buf;
2390:
2391: w->ws_row = current->maxy+1;
2392:
2393: w->ws_col = current->maxx+1;
2394:
2395: }
2396:
1.1.1.2 ! root 2397: else if (mode >= TCURSOFF && mode <= TCURSGRATE) {
! 2398:
! 2399: SCREEN *v = current;
! 2400:
! 2401: switch(mode) {
! 2402:
! 2403: case TCURSOFF:
1.1 root 2404:
1.1.1.2 ! root 2405: curs_off(v);
! 2406:
! 2407: v->hidecnt++;
! 2408:
! 2409: v->flags &= ~CURS_ON;
! 2410:
! 2411: break;
! 2412:
! 2413: case TCURSON:
! 2414:
! 2415: v->flags |= CURS_ON;
! 2416:
! 2417: v->hidecnt = 0;
! 2418:
! 2419: curs_on(v);
! 2420:
! 2421: break;
! 2422:
! 2423: case TCURSBLINK:
! 2424:
! 2425: curs_off(v);
! 2426:
! 2427: v->flags |= CURS_FLASH;
! 2428:
! 2429: curs_on(v);
! 2430:
! 2431: break;
! 2432:
! 2433: case TCURSSTEADY:
! 2434:
! 2435: curs_off(v);
! 2436:
! 2437: v->flags &= ~CURS_FLASH;
! 2438:
! 2439: curs_on(v);
! 2440:
! 2441: break;
! 2442:
! 2443: case TCURSSRATE:
! 2444:
! 2445: v->period = *((short *)buf);
! 2446:
! 2447: break;
! 2448:
! 2449: case TCURSGRATE:
! 2450:
! 2451: return v->period;
! 2452:
! 2453: }
! 2454:
! 2455: } else
! 2456:
! 2457: return EINVFN;
1.1 root 2458:
2459:
2460:
2461: return 0;
2462:
2463: }
2464:
2465:
2466:
1.1.1.2 ! root 2467: static long ARGS_ON_STACK
1.1 root 2468:
2469: screen_select(f, p, mode)
2470:
2471: FILEPTR *f; long p; int mode;
2472:
2473: {
2474:
2475: struct tty *tty = (struct tty *)f->devinfo;
2476:
2477: int dev = CONDEV;
2478:
2479:
2480:
2481: if (mode == O_RDONLY) {
2482:
2483: if (bconstat(dev)) {
2484:
2485: return 1;
2486:
2487: }
2488:
2489: if (tty) {
2490:
2491: /* avoid collisions with other processes */
2492:
2493: if (!tty->rsel)
2494:
2495: tty->rsel = p;
2496:
2497: }
2498:
2499: return 0;
2500:
2501: } else if (mode == O_WRONLY) {
2502:
2503: return 1;
2504:
2505: }
2506:
2507: /* default -- we don't know this mode, return 0 */
2508:
2509: return 0;
2510:
2511: }
2512:
2513:
2514:
1.1.1.2 ! root 2515: static void ARGS_ON_STACK
1.1 root 2516:
2517: screen_unselect(f, p, mode)
2518:
2519: FILEPTR *f;
2520:
2521: long p;
2522:
2523: int mode;
2524:
2525: {
2526:
2527: struct tty *tty = (struct tty *)f->devinfo;
2528:
2529:
2530:
2531: if (tty) {
2532:
2533: if (mode == O_RDONLY && tty->rsel == p)
2534:
2535: tty->rsel = 0;
2536:
2537: else if (mode == O_WRONLY && tty->wsel == p)
2538:
2539: tty->wsel = 0;
2540:
2541: }
2542:
2543: }
2544:
2545:
2546:
2547: #endif /* FASTTEXT */
2548:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.