File: dv_crt.c

package info (click to toggle)
boxshade 3.3.1-3
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 360 kB
  • ctags: 519
  • sloc: ansic: 4,923; xml: 410; makefile: 51; sh: 22
file content (171 lines) | stat: -rw-r--r-- 4,268 bytes parent folder | download | duplicates (8)
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
#include "dv_all.h"

#ifdef oCRT

typedef struct crtrecord {
  byte bgnd, fgnd;
} crtrecord;
static crtrecord crtrec[5];   /* CRT-specifics*/
static struct text_info ti;

#include <conio.h>

/*----------------------------------------*/
/*      CRT  specific section             */
/*----------------------------------------*/

static void menu_crt(crtrecord *crtrec, BOOL *lc, char *txt, char *parstring)
{
  char code;
  char instring[41];

  if (interactflag) {
    printf("\n-------------------------------------------------------------\n"
	   "Enter the text attributes for printing of ***>%s<*** residues:\n",
	   txt);
    printf("First choose the color/gray-value of the letter ***>background<***\n"
	   "Different letters specify different colors,\n"
	   "(R) red     (G) green         (U) blue \n"
	   "(B) black   (L) light gray\n\n"
	   "choose from  RGUYDL ( * %c * ) : ", parstring[0]);
    Fgets(instring, 41, stdin);
  } else
    *instring = '\0';
  if (*instring == '\0')
    code = parstring[0];
  else
    code = instring[0];
  code = toupper(code);
  if (strchr("RGUYDL", code) == NULL)
    code = 'R';
  switch (code) {
    case 'B': crtrec->bgnd = BLACK;      break;
    case 'R': crtrec->bgnd = RED;        break;
    case 'G': crtrec->bgnd = GREEN;      break;
    case 'U': crtrec->bgnd = BLUE;       break;
    case 'L': crtrec->bgnd = LIGHTGRAY;  break;
  }
  if (interactflag) {
    printf("\n\nNow choose the color/gray-value of the letter **>foreground<**\n"
	   "lowercase choices mean lowercase letters in the sequence:\n"
	   "(R,r) red    (G,g) green  (U,u) blue        (Y,y) yellow\n"
	   "(B,b) black  (W,w) white  (D,d) dark gray   (L,l) light gray\n\n"
	   "choose from  RrGgUuYyBbWwDdLl ( * %c * ) : ", parstring[1]);
    Fgets(instring, 41, stdin);
  } else
    *instring = '\0';
  if (*instring == '\0')
    code = parstring[1];
  else
    code = instring[0];
  if (strchr("BWRGUYDL", toupper(code)) == NULL)
    code = 'B';

  *lc = islower(code);

  code = toupper(code);
  switch (code) {
    case 'B': crtrec->fgnd = BLACK;     break;
    case 'W': crtrec->fgnd = WHITE;     break;
    case 'R': crtrec->fgnd = RED;       break;
    case 'G': crtrec->fgnd = GREEN;     break;
    case 'U': crtrec->fgnd = BLUE;      break;
    case 'Y': crtrec->fgnd = YELLOW;    break;
    case 'D': crtrec->fgnd = DARKGRAY;  break;
    case 'L': crtrec->fgnd = LIGHTGRAY; break;
  }
}


static void ask_crt(void)
{
  char parstring[6];

  term_par("CRT");
  if (interactflag)
    printf("-------------------------------------------------------------\n");
  Fgets(parstring, 6, parfile);
  parstring[2] = '\0';
  menu_crt(crtrec, lc, "different", parstring);
  Fgets(parstring, 6, parfile);
  parstring[2] = '\0';
  menu_crt(&crtrec[1], &lc[1], "identical", parstring);
  Fgets(parstring, 6, parfile);
  parstring[2] = '\0';
  if (simflag)
    menu_crt(&crtrec[2], &lc[2], "similar", parstring);
  else {
    crtrec[2] = crtrec[0];
    lc[2] = lc[0];
  }
  Fgets(parstring, 6, parfile);
  parstring[2] = '\0';
  if (globalflag)
    menu_crt(&crtrec[3], &lc[3], "conserved", parstring);
  else {
    crtrec[3] = crtrec[1];
    lc[3] = lc[1];
  }
  crtrec[4] = crtrec[0];
  lc[4] = lc[0];
}


static void CRTinit(double *xpos, double *ypos) {
  gettextinfo(&ti);
  dev_minx = 0.0;
  dev_miny = 1.0;
  dev_maxx = ti.screenwidth;
  dev_maxy = ti.screenheight;
  dev_xsize = 1.0;
  dev_ysize = 1.0;
  *xpos = dev_minx;
  *ypos = dev_maxy;
  textbackground(crtrec[0].bgnd);
  textcolor(crtrec[0].fgnd);
  clrscr();
}

static void CRTsetcolor(int colno) {
  textbackground(crtrec[colno].bgnd);
  textcolor(crtrec[colno].fgnd);
}

static void CRTcharout(char c, double *xpos, double *ypos) {
  putch(c);
  *xpos += dev_xsize;
}

static void CRTnewline(double *xpos, double *ypos) {
  textbackground(crtrec[0].bgnd);
  textcolor(crtrec[0].fgnd);
  cprintf("\r\n");
  *xpos = dev_minx;
  *ypos -= dev_ysize;
}

static void CRTnewpage(double *xpos, double *ypos) {
  scanf("%*[^\n]");
  getchar();
  *xpos = dev_minx;
  *ypos = dev_miny;
}

static void CRTexit(void) {
  normvideo();
  clreol();
}

GraphicsDevice Crt = {
  "CRT",
  ask_crt,
  CRTinit,
  CRTsetcolor,
  CRTcharout,
  GenericStringOut,
  CRTnewline,
  CRTnewpage,
  CRTexit
};

#endif