|
|
1.1 root 1: /* option.c - Display option screen */
2:
3: #include "ds.h"
4: #include "vars.h"
5:
6: extern decorateTree (Directory *);
7:
8:
9: char optScreen[][63] = {
10: /* 123456789 123456789 123456789 123456789 123456789 123456789 1 */
11: "������������������������[ Set Colors ]����������������������ͻ", /* 0 */
12: "� �", /* 1 */
13: "� Fore- Back- �", /* 2 */
14: "� ground ground Bright? Blink? Sample �", /* 3 */
15: "� ����������������������������������������������� �", /* 4 */
16: "� title � xxxxxxx xxxxxxx yes yes DosShell �", /* 5 */
17: "� name � filename �", /* 6 */
18: "� cursor � filename �", /* 7 */
19: "� bar � �������� �", /* 8 */
20: "� status � Info �", /* 9 */
21: "� popup � screens �", /* 10 */
22: "� error � Danger �", /* 11 */
23: "� blank � < > �", /* 12 */
24: "� �", /* 13 */
25: "� Use cursor keys to move between fields. �", /* 14 */
26: "� Use PgUp and PgDn to change a field. �", /* 15 */
27: "� �", /* 16 */
28: "�������������������[ Press Enter to return ]����������������ͼ" /* 17 */
29: };
30:
31: #define O_WIDTH 62
32: #define O_HEIGHT 18
33:
34: int O_ROW; /* ((N_of_Rows - O_HEIGHT)/2) */
35: int O_COL; /* ((N_of_Cols - O_WIDTH)/2) */
36:
37: int O_Start_Row; /* (O_ROW + 5) */
38: int O_FORE_COL; /* (O_COL + 13) */
39: int O_BACK_COL; /* (O_COL + 23) */
40: int O_BRIGHT_COL; /* (O_COL + 34) */
41: int O_BLINK_COL; /* (O_COL + 42) */
42: int O_SAMPLE_COL; /* (O_COL + 49) */
43:
44: #define SAMPLE_LEN 8
45:
46: #define CUR_COLS 4
47: int curCol[CUR_COLS]; /* Cursor columns for color screen */
48:
49: #define C_NAME_LEN 7
50: #define C_NAMES 8
51: char cName[C_NAMES][C_NAME_LEN+1] = {
52: "black ", /* 0 000 */
53: "blue ", /* 1 001 */
54: "green ", /* 2 010 */
55: "cyan ", /* 3 011 */
56: "red ", /* 4 100 */
57: "purple", /* 5 101 */
58: "yellow", /* 6 110 */
59: "white " /* 7 111 */
60: };
61:
62: #define TOGGLE_LEN 3
63: #define T_NAMES 8
64: char tName[T_NAMES][TOGGLE_LEN+1] = {
65: " no", /* 0 */
66: "yes" /* 1 */
67: };
68:
69:
70: int color[N_COLORS] = {
71: attr(green,black), /* titleC */
72: attr(cyan,black), /* nameC */
73: attr(bright+yellow,black), /* cursorC */
74: attr(red,black), /* barC */
75: attr(green,black), /* statusC */
76: attr(blue,white), /* popupC */
77: attr(red,black+blinking), /* errorC */
78: attr(white,black) /* blankC */
79: };
80:
81:
82: /*** optionInit - Initialize option screen stuff
83: *
84: *
85: */
86: optionInit ()
87: {
88: O_ROW = (N_of_Rows - O_HEIGHT)/2;
89: O_COL = (N_of_Cols - O_WIDTH)/2;
90: O_Start_Row = (O_ROW + 5);
91: O_FORE_COL = (O_COL + 13);
92: O_BACK_COL = (O_COL + 23);
93: O_BRIGHT_COL = (O_COL + 34);
94: O_BLINK_COL = (O_COL + 42);
95: O_SAMPLE_COL = (O_COL + 49);
96:
97: curCol[0] = O_FORE_COL;
98: curCol[1] = O_BACK_COL;
99: curCol[2] = O_BRIGHT_COL;
100: curCol[3] = O_BLINK_COL;
101:
102: } /* optionInit */
103:
104:
105: /*** showOption - display option screen and record user modifications
106: *
107: *
108: */
109: showOption ()
110: {
111: int row,col,key;
112: Attr attrib, fore, back, brite, blink;
113: int cRow,cCol;
114: Attr oldColor[N_COLORS];
115: int i;
116: Attr oldPopupC;
117: Attr a;
118: unsigned colorChanged;
119:
120: oldPopupC = color[popupC]; /* Use old blank color */
121: for (i=0; i<N_COLORS; i++) /* Remember old colors */
122: oldColor[i] = color[i];
123:
124: a = oldPopupC;
125: for (row=0; row<O_HEIGHT; row++)
126: VIOWRTCHARSTRATT (chfs(optScreen[row]), O_WIDTH, row+O_ROW,O_COL,
127: afs(&a), VioHandle);
128:
129: for (row=0; row<N_COLORS; row++)
130: showRow (row, oldPopupC);
131:
132: key = 0;
133: cRow = 0;
134: cCol = 0;
135: while (key != enterKey) {
136: VIOSETCURPOS (O_Start_Row+cRow,curCol[cCol]-1, VioHandle);
137: key = getKey();
138: switch (key) {
139: case upKey:
140: if (!cRow--)
141: cRow = N_COLORS - 1;
142: break;
143: case downKey:
144: if (cRow++ >= (N_COLORS-1))
145: cRow = 0;
146: break;
147: case leftKey:
148: if (!cCol--)
149: cCol = CUR_COLS - 1;
150: break;
151: case rightKey:
152: if (cCol++ >= (CUR_COLS-1))
153: cCol = 0;
154: break;
155: case pgUpKey:
156: modColor (cRow,cCol, 1, oldPopupC);
157: break;
158: case pgDownKey:
159: modColor (cRow,cCol,-1, oldPopupC);
160: break;
161: default:
162: break;
163: } /* switch */
164: } /* while */
165:
166: /* See if colors changed in the tree */
167:
168: colorChanged = FALSE; /* No color change (yet) */
169: if (color[nameC] != oldColor[nameC])
170: colorChanged = TRUE;
171: if (color[barC] != oldColor[barC])
172: colorChanged = TRUE;
173: if (color[blankC] != oldColor[blankC])
174: colorChanged = TRUE;
175:
176: if (colorChanged) /* Tree color changed, must re-image */
177: decorateTree (root);
178:
179: /* See if any colors changed */
180:
181: colorChanged = 0; /* No color change (yet) */
182: for (i=0; i<N_COLORS; i++) /* See if ANY colors changed */
183: colorChanged += ((oldColor[i] == color[i]) ? 0 : 1);
184:
185: if (colorChanged) /* At least one color changed */
186: stateModified = TRUE;
187:
188: } /* showOption */
189:
190:
191: /*** modColor - Modify color on option screen
192: *
193: *
194: */
195: modColor (row,col,inc,oldPopupC)
196: int row,col,inc,oldPopupC;
197: {
198: int attrib, fore, back, brite, blink;
199:
200: attrToParts (color[row], &fore, &back, &brite, &blink);
201: if (inc > 0) /* Increment value */
202: switch (col) {
203: case 0:
204: if (fore++ > (C_NAMES-1))
205: fore = 0;
206: break;
207: case 1:
208: if (back++ > (C_NAMES-1))
209: back = 0;
210: break;
211: case 2:
212: if (brite++ > (T_NAMES-1))
213: brite = 0;
214: break;
215: case 3:
216: if (blink++ > (T_NAMES-1))
217: blink = 0;
218: break;
219: } /* case */
220: else
221: switch (col) {
222: case 0:
223: if (!fore--)
224: fore = C_NAMES-1;
225: break;
226: case 1:
227: if (!back--)
228: back = C_NAMES-1;
229: break;
230: case 2:
231: if (!brite--)
232: brite = T_NAMES-1;
233: break;
234: case 3:
235: if (!blink--)
236: blink = T_NAMES-1;
237: break;
238: }; /* case */
239: partsToAttr (&color[row], fore, back, brite, blink);
240: showRow (row, oldPopupC);
241: } /* modColor */
242:
243:
244: /*** showRow - display a row of the option screen
245: *
246: *
247: */
248: showRow (row,oldPopupC)
249: int row;
250: int oldPopupC;
251: {
252: Attr attrib, fore, back, brite, blink;
253: Attr a;
254:
255: a = oldPopupC;
256:
257: attrToParts (color[row], &fore, &back, &brite, &blink);
258:
259: VIOWRTCHARSTRATT (chfs(cName[fore]), C_NAME_LEN,
260: row+O_Start_Row,O_FORE_COL, afs(&a), VioHandle);
261:
262: VIOWRTCHARSTRATT (chfs(cName[back]), C_NAME_LEN,
263: row+O_Start_Row,O_BACK_COL, afs(&a), VioHandle);
264:
265: VIOWRTCHARSTRATT (chfs(tName[brite]), TOGGLE_LEN,
266: row+O_Start_Row,O_BRIGHT_COL, afs(&a), VioHandle);
267:
268: VIOWRTCHARSTRATT (chfs(tName[blink]), TOGGLE_LEN,
269: row+O_Start_Row,O_BLINK_COL, afs(&a), VioHandle);
270:
271: a = color[row];
272: VIOWRTNATTR (afs(&a), SAMPLE_LEN, row+O_Start_Row,O_SAMPLE_COL, VioHandle);
273:
274: } /* showRow */
275:
276:
277: /*** attrToParts - Break cell attribute into component parts
278: *
279: *
280: */
281: attrToParts (attrib, fore, back, brite, blink)
282: AttrStruct attrib;
283: int *fore, *back, *brite, *blink;
284: {
285: *fore = attrib.a_fore;
286: *brite = attrib.a_bright;
287: *back = attrib.a_back;
288: *blink = attrib.a_blink;
289: } /* attrToParts */
290:
291:
292: /*** partsToAttr - Build cell attribute from component parts
293: *
294: *
295: */
296: partsToAttr (attrib, fore, back, brite, blink)
297: AttrStruct *attrib;
298: int fore, back, brite, blink;
299: {
300: attrib->a_fore = fore;
301: attrib->a_bright = brite;
302: attrib->a_back = back;
303: attrib->a_blink = blink;
304: } /* partsToAttr */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.