|
|
1.1 root 1: /*** SSE - Simple Screen Editor
2: *
1.1.1.2 ! root 3: * Created by Microsoft Corp. 1987
1.1 root 4: */
5:
1.1.1.2 ! root 6: #define INCL_SUB
! 7: #define INCL_DOSFILEMGR
! 8: #define INCL_DOSSIGNALS
1.1 root 9:
1.1.1.2 ! root 10: #include <os2def.h>
! 11: #include <bse.h>
1.1 root 12: #include <ctype.h>
13: #include <stdlib.h>
14: #include <stdio.h>
15: #include "ssedefs.h"
16:
17:
1.1.1.2 ! root 18: USHORT TotalLines; /* num of entries in line table */
1.1 root 19: struct Line far *LineTable[MAXLINES]; /* the line table */
20:
1.1.1.2 ! root 21: USHORT TotalSegs; /* num of entries in seg table */
1.1 root 22: struct SegEntry SegTable[MAXSEGS];
23:
24: char fbuffer[FBUFFSIZE];
1.1.1.2 ! root 25: USHORT bytesread;
1.1 root 26:
1.1.1.2 ! root 27: UCHAR ScrBuff[LONGPAGE][LINESIZE];
! 28: UCHAR EditBuff[LINESIZE];
! 29: USHORT EditBuffDirty;
! 30:
! 31: USHORT PageSize;
! 32: USHORT Mode43Set = 0;
! 33:
! 34: USHORT ForeNorm = 0x07;
! 35: USHORT BackNorm = 0x10;
! 36: USHORT ForeHilite = 0x01;
! 37: USHORT BackHilite = 0x70;
! 38: USHORT Fore25 = 0x07;
! 39: USHORT Back25 = 0x40;
1.1 root 40:
1.1.1.2 ! root 41: USHORT CurRow, CurCol;
! 42: USHORT TopRow;
1.1 root 43:
1.1.1.2 ! root 44: USHORT LinesMarked, CharsMarked;
! 45: USHORT MarkedLine[MAXLINES], MarkedChar[LINESIZE];
1.1 root 46:
47: char *fname;
1.1.1.2 ! root 48: USHORT fhandle;
1.1 root 49:
50: /*** main
51: *
52: *
53: *
54: */
55:
56: main(argc, argv)
57: int argc;
58: char *argv[];
59: {
1.1.1.2 ! root 60: USHORT i;
1.1 root 61:
1.1.1.2 ! root 62: USHORT handtype, flagword;
1.1 root 63:
1.1.1.2 ! root 64: VIOMODEINFO modedata; /* from bsesub.h */
! 65: VIOCURSORINFO cursordata;
1.1 root 66:
67:
68: /* check if we're in foreground */
69:
1.1.1.2 ! root 70: DosQHandType( 0, &handtype, &flagword );
1.1 root 71: if( (handtype == 0) || ( !( flagword & 1 )) || ( !( flagword & 2 )) )
72: quit(1);
73:
74:
75: /* disable signals so user can't exit with Ctrl-C or Ctrl-Break */
76:
1.1.1.2 ! root 77: DosHoldSignal( TRUE );
1.1 root 78:
79:
80: /* initialize variables */
81:
82: EditBuffDirty = 0;
83: LinesMarked = 0;
84: CharsMarked = 0;
85: for (i = 0; i < MAXLINES; i++)
86: MarkedLine[i] = 0;
87: for (i = 0; i < LINESIZE; i++)
88: MarkedChar[i] = 0;
89:
90: /* Set PageSize to match the mode we're in, 25 or 43.
91: This may be changed later by a switch from the command line. */
92:
1.1.1.2 ! root 93: modedata.cb = sizeof( modedata );
! 94: VioGetMode( &modedata, 0 );
1.1 root 95: if( modedata.row == 25 )
96: PageSize = SHORTPAGE;
97: else PageSize = LONGPAGE;
98:
99: /* Parse file name */
100: if (argc < 2) {
101: error25(8);
102: quit(1);
103: }
104: else if (argc < 4) {
105: for( i = 1; i < (argc-1); i++ ) {
106: if( (argv[i][0] == '/') &&
107: ( argv[i][1] == '4' ) &&
108: ( argv[i][2] == '3' ) ) {
109: PageSize = LONGPAGE;
110: modedata.row = ( LONGPAGE + 1 );
1.1.1.2 ! root 111: VioSetMode( &modedata, 0 );
! 112: cursordata.yStart = 6;
! 113: cursordata.cEnd = 7;
! 114: cursordata.cx = 1;
! 115: cursordata.attr = 0;
! 116: VioSetCurType( &cursordata, 0 );
1.1 root 117: Mode43Set = 1;
118: }
119: else if( (argv[i][0] == '/') &&
120: ( (argv[i][1] == 'B') || (argv[i][1] == 'b') ) &&
121: ( (argv[i][2] == 'W') || (argv[i][2] == 'w') ) ) {
122: ForeNorm = 0x07;
123: BackNorm = 0;
124: ForeHilite = 0;
125: BackHilite = 0x70;
126: Fore25 = 0;
127: Back25 = 0x70;
128: }
129: else {
130: error25(9);
131: quit(1);
132: }
133:
134: }
135: fname = argv[i];
136: }
137: else {
138: error25(10);
139: quit(1);
140: }
141:
142: /* paint the screen */
143: clearscr();
144: drawscr(0);
145:
146: /* read file */
147: switch (openfile(fname, &fhandle, FOFLAG)) {
148: case 0:
149: if (readfile(fhandle))
150: error25(1);
151: if (backupfile(fname, fhandle))
152: error25(2);
153: break;
154:
155: case 110:
156: /* create the file */
157: error25(3);
158: if (openfile(fname, &fhandle, CFFLAG))
159: error25(4); /* error creating file */
160: break;
161:
162: case 32:
163: /* denied write access */
164: error25(5);
165: break;
166:
167: default :
168: /* error on opening file */
169: error25(6);
170: break;
171: }
172:
173:
174: /* if open worked, continue */
175:
176: drawscr(0);
177: name25();
1.1.1.2 ! root 178: VioSetCurPos(0,0,0);
1.1 root 179: getline( 0, &EditBuff[0] ); /* initialize */
180: dispatch();
181: freesegs();
182: }
183:
184:
185:
186:
187: quit(n) /* if we set 43 line mode from command line, */
1.1.1.2 ! root 188: USHORT n; /* set it back to 25 line mode before exiting */
1.1 root 189: {
1.1.1.2 ! root 190: VIOMODEINFO modedata;
! 191: VIOCURSORINFO cursordata;
1.1 root 192:
193: if( Mode43Set ) {
1.1.1.2 ! root 194: modedata.cb = sizeof( modedata );
! 195: VioGetMode( &modedata, 0 );
1.1 root 196: modedata.row = 25;
1.1.1.2 ! root 197: VioSetMode( &modedata, 0 );
! 198: cursordata.yStart = 12;
! 199: cursordata.cEnd = 13;
! 200: cursordata.cx = 1;
! 201: cursordata.attr = 0;
! 202: VioSetCurType( &cursordata, 0 );
1.1 root 203: BackNorm = 0;
204: ForeNorm = 0;
205: clearscr();
206: }
1.1.1.2 ! root 207: DosExit(EXIT_PROCESS,n); /* exit with specified completion code */
1.1 root 208: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.