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