📄 prompts1.c
字号:
case F10:
done = i;
break;
case PAGE_UP:
curchoice = -1;
case DOWN_ARROW:
case DOWN_ARROW_2:
do {
if (++curchoice >= numprompts) curchoice = 0;
} while (values[curchoice].type == '*');
break;
case PAGE_DOWN:
curchoice = numprompts;
case UP_ARROW:
case UP_ARROW_2:
do {
if (--curchoice < 0) curchoice = numprompts - 1;
} while (values[curchoice].type == '*');
break;
}
}
fullscreen_exit:
movecursor(25,80);
lookatmouse = savelookatmouse;
EXIT_OVLY;
return(done);
}
static int prompt_valuestring(char *buf,struct fullscreenvalues *val)
{ /* format value into buf, return field width */
int i,ret;
switch (val->type) {
case 'd':
ret = 20;
i = 16; /* cellular needs 16 (was 15)*/
while (1) {
sprintf(buf,"%.*g",i,val->uval.dval);
if (strlen(buf) <= ret) break;
--i;
}
break;
case 'D':
if (val->uval.dval<0) { /* We have to round the right way */
sprintf(buf,"%ld",(long)(val->uval.dval-.5));
}
else {
sprintf(buf,"%ld",(long)(val->uval.dval+.5));
}
ret = 20;
break;
case 'f':
sprintf(buf,"%.7g",val->uval.dval);
ret = 14;
break;
case 'i':
sprintf(buf,"%d",val->uval.ival);
ret = 6;
break;
case '*':
*buf = ret = 0;
break;
case 's':
strncpy(buf,val->uval.sval,16);
buf[15] = 0;
ret = 15;
break;
case 'l':
strcpy(buf,val->uval.ch.list[val->uval.ch.val]);
ret = val->uval.ch.vlen;
break;
default: /* assume 0x100+n */
strcpy(buf,val->uval.sbuf);
ret = val->type & 0xff;
}
return ret;
}
int prompt_checkkey(int curkey)
{
switch(curkey) {
case PAGE_UP:
case DOWN_ARROW:
case DOWN_ARROW_2:
case PAGE_DOWN:
case UP_ARROW:
case UP_ARROW_2:
return(curkey);
case F2:
case F3:
case F4:
case F5:
case F6:
case F7:
case F8:
case F9:
case F10:
if (promptfkeys & (1<<(curkey+1-F1)) )
return(curkey);
}
return(0);
}
static int input_field_list(
int attr, /* display attribute */
char *fld, /* display form field value */
int vlen, /* field length */
char **list, /* list of values */
int llen, /* number of entries in list */
int row, /* display row */
int col, /* display column */
int (*checkkey)(int) /* routine to check non data keys, or NULL */
)
{
int initval,curval;
char buf[81];
int curkey;
int i, j;
int ret,savelookatmouse;
savelookatmouse = lookatmouse;
lookatmouse = 0;
for (initval = 0; initval < llen; ++initval)
if (strcmp(fld,list[initval]) == 0) break;
if (initval >= llen) initval = 0;
curval = initval;
ret = -1;
while (1) {
strcpy(buf,list[curval]);
i = strlen(buf);
while (i < vlen)
buf[i++] = ' ';
buf[vlen] = 0;
putstring(row,col,attr,buf);
curkey = keycursor(row,col); /* get a keystroke */
switch (curkey) {
case ENTER:
case ENTER_2:
ret = 0;
goto inpfldl_end;
case ESC:
goto inpfldl_end;
case RIGHT_ARROW:
case RIGHT_ARROW_2:
if (++curval >= llen)
curval = 0;
break;
case LEFT_ARROW:
case LEFT_ARROW_2:
if (--curval < 0)
curval = llen - 1;
break;
case F5:
curval = initval;
break;
default:
if (nonalpha(curkey)) {
if (checkkey && (ret = (*checkkey)(curkey)))
goto inpfldl_end;
break; /* non alphanum char */
}
j = curval;
for (i = 0; i < llen; ++i) {
if (++j >= llen)
j = 0;
if ((*list[j] & 0xdf) == (curkey & 0xdf)) {
curval = j;
break;
}
}
}
}
inpfldl_end:
strcpy(fld,list[curval]);
lookatmouse = savelookatmouse;
return(ret);
}
/* --------------------------------------------------------------------- */
/* MCP 7-7-91, This is static code, but not called anywhere */
#ifdef DELETE_UNUSED_CODE
/* compare for sort of type table */
static int compare(const VOIDPTR i, const VOIDPTR j)
{
return(strcmp(fractalspecific[(int)*((BYTE*)i)].name,
fractalspecific[(int)*((BYTE*)j)].name));
}
/* --------------------------------------------------------------------- */
static void clear_line(int row, int start, int stop, int color) /* clear part of a line */
{
int col;
for(col=start;col<= stop;col++)
putstring(row,col,color," ");
}
#endif
/* --------------------------------------------------------------------- */
int get_fracttype() /* prompt for and select fractal type */
{
int done,i,oldfractype,t;
ENTER_OVLY(OVLY_PROMPTS1);
done = -1;
oldfractype = fractype;
while (1) {
if ((t = select_fracttype(fractype)) < 0)
break;
if ((i = select_type_params(t, fractype)) == 0) { /* ok, all done */
done = 0;
break;
}
if (i > 0) /* can't return to prior image anymore */
done = 1;
}
if (done < 0)
fractype = oldfractype;
curfractalspecific = &fractalspecific[fractype];
EXIT_OVLY;
return(done);
}
struct FT_CHOICE {
char name[15];
int num;
};
static struct FT_CHOICE **ft_choices; /* for sel_fractype_help subrtn */
static int select_fracttype(int t) /* subrtn of get_fracttype, separated */
/* so that storage gets freed up */
{
static char far head1[] = {"Select a Fractal Type"};
static char far head2[] = {"Select Orbit Algorithm for Julibrot"};
static char far instr[] = {"Press F2 for a description of the highlighted type"};
char head[40];
int oldhelpmode;
int numtypes, done;
int i, j;
#define MAXFTYPES 200
char tname[40];
struct FT_CHOICE *choices[MAXFTYPES];
int attributes[MAXFTYPES];
/* steal existing array for "choices" */
choices[0] = (struct FT_CHOICE *)boxy;
attributes[0] = 1;
for (i = 1; i < MAXFTYPES; ++i) {
choices[i] = choices[i-1] + 1;
attributes[i] = 1;
}
ft_choices = &choices[0];
/* setup context sensitive help */
oldhelpmode = helpmode;
helpmode = HELPFRACTALS;
if(julibrot)
far_strcpy(head,head2);
else
far_strcpy(head,head1);
if (t == IFS3D) t = IFS;
i = j = -1;
while(fractalspecific[++i].name) {
if(julibrot)
{
int isinteger;
isinteger = curfractalspecific->isinteger;
if (!((fractalspecific[i].flags & OKJB) && *fractalspecific[i].name != '*'))
continue;
}
if (fractalspecific[i].name[0] == '*')
continue;
strcpy(choices[++j]->name,fractalspecific[i].name);
choices[j]->name[14] = 0; /* safety */
choices[j]->num = i; /* remember where the real item is */
}
numtypes = j + 1;
qsort(choices,numtypes,sizeof(char *),lccompare); /* sort list */
j = 0;
for (i = 0; i < numtypes; ++i) /* find starting choice in sorted list */
if (choices[i]->num == t || choices[i]->num == fractalspecific[t].tofloat)
j = i;
tname[0] = 0;
done = fullscreen_choice(CHOICEHELP+8,head,NULL,instr,numtypes,
(char **)choices,attributes,0,0,0,j,NULL,tname,NULL,sel_fractype_help);
if (done >= 0)
done = choices[done]->num;
helpmode = oldhelpmode;
return(done);
}
static int sel_fractype_help(int curkey,int choice)
{
int oldhelpmode;
if (curkey == F2) {
oldhelpmode = helpmode;
helpmode = fractalspecific[(*(ft_choices+choice))->num].helptext;
help(0);
helpmode = oldhelpmode;
}
return(0);
}
int select_type_params( /* prompt for new fractal type parameters */
int newfractype, /* new fractal type */
int oldfractype /* previous fractal type */
)
{
int ret,oldhelpmode;
oldhelpmode = helpmode;
ret = 0;
fractype = newfractype;
curfractalspecific = &fractalspecific[fractype];
if (fractype == LSYSTEM) {
helpmode = HT_LSYS;
if (get_file_entry(GETLSYS,"L-System",lsysmask,LFileName,LName) < 0) {
ret = 1;
goto sel_type_exit;
}
}
if (fractype == FORMULA || fractype == FFORMULA) {
helpmode = HT_FORMULA;
if (get_file_entry(GETFORMULA,"Formula",formmask,FormFileName,FormName) < 0) {
ret = 1;
goto sel_type_exit;
}
}
if (fractype == IFS || fractype == IFS3D) {
static char far ifsmsg[] = {
#ifndef XFRACT
"Current IFS parameters have been edited but not saved.\n"
"Continue to replace them with new selection, cancel to keep them."};
#else
"Current IFS parameters have been edited but not saved.\n\
Continue to replace them with new selection, cancel to keep them."};
#endif
helpmode = HT_IFS;
if (!ifs_defn || !ifs_changed || !stopmsg(22,ifsmsg))
if (get_file_entry(GETIFS,"IFS",ifsmask,IFSFileName,IFSName) < 0) {
ret = 1;
goto sel_type_exit;
}
}
/* Added the following to accommodate fn bifurcations. JCO 7/2/92 */
if(((fractype == BIFURCATION) || (fractype == LBIFURCATION)) &&
!((oldfractype == BIFURCATION) || (oldfractype == LBIFURCATION)))
set_trig_array(0,"ident");
if(((fractype == BIFSTEWART) || (fractype == LBIFSTEWART)) &&
!((oldfractype == BIFSTEWART) || (oldfractype == LBIFSTEWART)))
set_trig_array(0,"ident");
if(((fractype == BIFLAMBDA) || (fractype == LBIFLAMBDA)) &&
!((oldfractype == BIFLAMBDA) || (oldfractype == LBIFLAMBDA)))
set_trig_array(0,"ident");
if(((fractype == BIFEQSINPI) || (fractype == LBIFEQSINPI)) &&
!((oldfractype == BIFEQSINPI) || (oldfractype == LBIFEQSINPI)))
set_trig_array(0,"sin");
if(((fractype == BIFADSINPI) || (fractype == LBIFADSINPI)) &&
!((oldfractype == BIFADSINPI) || (oldfractype == LBIFADSINPI)))
set_trig_array(0,"sin");
set_default_parms();
if (get_fract_params(0) < 0)
ret = 1;
else {
if (newfractype != oldfractype) {
invert = 0;
inversion[0] = inversion[1] = inversion[2] = 0;
}
}
sel_type_exit:
helpmode = oldhelpmode;
return(ret);
}
void set_default_parms()
{
int i;
xxmin = curfractalspecific->xmin;
xxmax = curfractalspecific->xmax;
yymin = curfractalspecific->ymin;
yymax = curfractalspecific->ymax;
xx3rd = xxmin;
yy3rd = yymin;
if (viewcrop && finalaspectratio != screenaspect)
aspectratio_crop(screenaspect,finalaspectratio);
for (i = 0; i < 4; i++) {
param[i] = curfractalspecific->paramvalue[i];
if (fractype != CELLULAR) /* don't round cellular */
roundfloatd(¶m[i]);
}
if(curfractalspecific->flags&MORE) {
int extra;
if((extra=find_extra_param(fractype)) > -1)
for(i=0;i<MAXPARAMS-4;i++) {
param[i+4] = moreparams[extra].paramvalue[i];
}
}
}
#define MAXFRACTALS 25
extern int neworbittype, num_fractal_types;
int build_fractal_list(int fractals[], int *last_val, char *nameptr[])
{
int numfractals,i;
numfractals = 0;
for (i = 0; i < num_fractal_types; i++)
{
int isinteger;
isinteger = curfractalspecific->isinteger;
if ((fractalspecific[i].flags & OKJB) && *fractalspecific[i].name != '*')
{
fractals[numfractals] = i;
if (i == neworbittype || i == fractalspecific[neworbittype].tofloat)
*last_val = numfractals;
nameptr[numfractals] = fractalspecific[i].name;
numfractals++;
if (numfractals >= MAXFRACTALS)
break;
}
}
return (numfractals);
}
char far v00[] = {"Orbit Algorithm"};
char far v0a[] = {"From cx (real part)"};
char far v1a[] = {"From cy (imaginary part)"};
char far v2a[] = {"To cx (real part)"};
char far v3a[] = {"To cy (imaginary part)"};
/* 4D Mandelbrot */
char far v0b[] = {"From cj (3rd dim)"};
char far v1b[] = {"From ck (4th dim)"};
char far v2b[] = {"To cj (3rd dim)"};
char far v3b[] = {"To ck (4th dim)"};
/* 4D Julia */
char far v0c[] = {"From zj (3rd dim)"};
char far v1c[] = {"From zk (4th dim)"};
char far v2c[] = {"To zj (3rd dim)"};
char far v3c[] = {"To zk (4th dim)"};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -