📄 windos2.c
字号:
wintext_textoff();
}
setclear()
{
extern int far wintext_buffer_init;
wintext_buffer_init = 0;
wintext_paintscreen(0,80,0,25);
}
int putstringcenter(int row, int col, int width, int attr, char far *msg)
{
char buf[81];
int i,j,k;
i = 0;
while (msg[i]) ++i; /* strlen for a far */
if (i == 0) return(-1);
j = (width - i) / 2;
j -= (width + 10 - i) / 20; /* when wide a bit left of center looks better */
memset(buf,' ',width);
buf[width] = 0;
i = 0;
k = j;
while (msg[i]) buf[k++] = msg[i++]; /* strcpy for a far */
putstring(row,col,attr,buf);
return j;
}
void putstring(int row, int col, int attr, unsigned char far *buf)
{
extern unsigned char far wintext_chars[25][80];
extern unsigned char far wintext_attrs[25][80];
int i, j, k, maxrow, maxcol;
char xc, xa;
if (row == -1) row = textrow;
if (col == -1) col = textcol;
j = maxrow = row;
k = maxcol = col-1;
for (i = 0; (xc = buf[i]) != 0; i++) {
if (xc == 13 || xc == 10) {
j++;
k = -1;
}
else {
if ((++k) + textcbase >= 80) {
j++;
k = 0;
}
if (j+textrbase >= 25) j = 24-textrbase;
if (k+textcbase >= 80) k = 79-textcbase;
if (maxrow < j) maxrow = j;
if (maxcol < k) maxcol = k;
xa = (attr & 0x0ff);
wintext_chars[j+textrbase][k+textcbase] = xc;
wintext_attrs[j+textrbase][k+textcbase] = xa;
}
}
if (i > 0) {
textrow = j;
textcol = k + 1;
wintext_paintscreen(
col+textcbase, maxcol+textcbase,
row+textrbase, maxrow+textrbase);
}
}
void setattr(int row, int col, int attr, int count)
{
extern unsigned char far wintext_attrs[25][80];
int i, j, k, maxrow, maxcol;
char xc, xa;
j = maxrow = row;
k = maxcol = col-1;
xa = (attr & 0x0ff);
for (i = 0; i < count; i++) {
if ((++k + textcbase) >= 80) {
j++;
k = 0;
}
if (j+textrbase >= 25) j = 24-textrbase;
if (k+textcbase >= 80) k = 79-textcbase;
if (maxrow < j) maxrow = j;
if (maxcol < k) maxcol = k;
wintext_attrs[j+textrbase][k+textcbase] = xa;
}
if (count > 0)
wintext_paintscreen(
col+textcbase, maxcol+textcbase,
row+textrbase, maxrow+textrbase);
}
void movecursor(int row, int col)
{
int cursor_type;
cursor_type = -1;
if (row >= 25 || col >= 80) {
row=1;
col=1;
cursor_type = 0;
}
if (row >= 0)
textrow = row;
if (col >= 0)
textcol = col;
wintext_cursor(col, row, -1);
}
int keycursor(int row, int col)
{
int i, cursor_style;
if (row == -2 && col == -2)
return(fractint_getkeypress(1));
if (row == -1)
row = textrow;
if (col == -1)
col = textcol;
cursor_style = 1;
if (row < 0) {
cursor_style = 2;
row = row & 0x7fff;
}
i = fractint_getkeypress(0);
if (i == 0)
wintext_cursor(col, row, cursor_style);
i = fractint_getkeypress(1);
wintext_cursor(col, row, 0);
return(i);
}
/* get a "fractint-style" keystroke, with "help" sensitivity */
int fractint_getkeypress(int option)
{
int i;
restart:
i = wintext_getkeypress(option);
if (i == 0)
return(i);
/* "fractint-i-size" the keystroke */
if (i != 0 && (i & 255) == 0) /* function key? */
i = (i >> 8) + 1000;
else
i = (i & 255);
if (i == F1) { /* F1 - bring up Windows-style help */
if (option == 0) wintext_getkeypress(1);
winfract_help();
goto restart;
}
if (i == (F1+35)) { /* Control-F1 - bring up Fractint-style help */
if (option == 0) wintext_getkeypress(1);
if (! in_fractint_help) {
fractint_help();
goto restart;
}
}
return(i);
}
int getakeynohelp() {
return(fractint_getkeypress(1));
}
int strncasecmp(char *s,char *t,int ct)
{
for(; (tolower(*s) == tolower(*t)) && --ct ; s++,t++)
if(*s == '\0')
return(0);
return(tolower(*s) - tolower(*t));
}
extern char temp1[];
extern int colors;
extern unsigned char dacbox[256][3];
extern unsigned char olddacbox[256][3];
extern int colorstate;
extern char colorfile[];
char mapmask[13] = {"*.map"};
void save_palette()
{
FILE *dacfile;
int i,oldhelpmode;
oldhelpmode = helpmode;
stackscreen();
temp1[0] = 0;
helpmode = HELPCOLORMAP;
i = field_prompt(0,"Name of map file to write",NULL,temp1,60,NULL);
unstackscreen();
if (i != -1 && temp1[0]) {
if (strchr(temp1,'.') == NULL)
strcat(temp1,".map");
dacfile = fopen(temp1,"w");
if (dacfile == NULL)
buzzer(2);
else {
for (i = 0; i < colors; i++)
fprintf(dacfile, "%3d %3d %3d\n",
dacbox[i][0] << 2,
dacbox[i][1] << 2,
dacbox[i][2] << 2);
memcpy(olddacbox,dacbox,256*3);
colorstate = 2;
strcpy(colorfile,temp1);
}
fclose(dacfile);
}
helpmode = oldhelpmode;
}
void load_palette(void)
{
int i,oldhelpmode;
char filename[80];
oldhelpmode = helpmode;
strcpy(filename,colorfile);
stackscreen();
helpmode = HELPCOLORMAP;
i = getafilename("Select a MAP File",mapmask,filename);
unstackscreen();
if (i >= 0)
if (ValidateLuts(filename) == 0) {
memcpy(olddacbox,dacbox,256*3);
colorstate = 2;
strcpy(colorfile,filename);
}
helpmode = oldhelpmode;
}
void fractint_help()
{
int i,oldhelpmode;
in_fractint_help = 1;
oldhelpmode = helpmode;
helpmode = HELP_INDEX;
help(0);
in_fractint_help = 0;
helpmode = oldhelpmode;
}
extern FILE *parmfile;
int win_make_batch_file()
{
int i,numparms;
int gotinfile;
char outname[81],buf[256],buf2[128];
FILE *infile;
char colorspec[14];
int maxcolor;
char *sptr,*sptr2;
extern char CommandFile[];
extern char CommandName[];
extern char far CommandComment1[];
extern char far CommandComment2[];
extern int colorstate;
extern int win_temp1, win_temp2;
extern char colorfile[];
extern int mapset;
extern char MAP_name[];
#ifdef WINFRACT
extern char suffix[4096];
#else
extern char dstack[4096];
#endif
extern char boxx[8192];
extern char s_cantopen[];
extern char s_cantwrite[];
extern char s_cantcreate[];
extern char s_cantunderstand[];
extern char s_cantfind[];
if (strchr(CommandFile,'.') == NULL)
strcat(CommandFile,".par"); /* default extension .par */
if (win_temp2 > 0 && win_temp2 <= 256)
maxcolor = win_temp2;
strcpy(colorspec,"n");
if (win_temp1 == 0) { /* default colors */
}
else if (win_temp1 == 2) { /* colors match colorfile */
colorspec[0] = '@';
sptr = colorfile;
}
else /* colors match no .map that we know of */
colorspec[0] = 'y';
if (colorspec[0] == '@') {
if ((sptr2 = strrchr(sptr,'\\'))) sptr = sptr2 + 1;
if ((sptr2 = strrchr(sptr,':'))) sptr = sptr2 + 1;
strncpy(&colorspec[1],sptr,12);
colorspec[13] = 0;
}
strcpy(outname,CommandFile);
gotinfile = 0;
if (access(CommandFile,0) == 0) { /* file exists */
gotinfile = 1;
if (access(CommandFile,6)) {
sprintf(buf,s_cantwrite,CommandFile);
stopmsg(0,buf);
return(0);
}
i = strlen(outname);
while (--i >= 0 && outname[i] != '\\')
outname[i] = 0;
strcat(outname,"fractint.tmp");
infile = fopen(CommandFile,"rt");
setvbuf(infile,suffix,_IOFBF,4096); /* improves speed */
}
if ((parmfile = fopen(outname,"wt")) == NULL) {
sprintf(buf,s_cantcreate,outname);
stopmsg(0,buf);
if (gotinfile) fclose(infile);
return(0);
}
if (gotinfile) {
while (file_gets(buf,255,infile) >= 0) {
if (strchr(buf,'{') /* entry heading? */
&& sscanf(buf," %40[^ \t({]",buf2)
&& stricmp(buf2,CommandName) == 0) { /* entry with same name */
sprintf(buf2,"File already has an entry named %s\n\
Continue to replace it, Cancel to back out",CommandName);
if (stopmsg(18,buf2) < 0) { /* cancel */
fclose(infile);
fclose(parmfile);
unlink(outname);
return(0);
}
while (strchr(buf,'}') == NULL
&& file_gets(buf,255,infile) > 0 ) { } /* skip to end of set */
break;
}
fputs(buf,parmfile);
fputc('\n',parmfile);
}
}
fprintf(parmfile,"%-19s{",CommandName);
if (CommandComment1[0]) fprintf(parmfile," ; %Fs",CommandComment1);
fputc('\n',parmfile);
if (CommandComment2[0])
fprintf(parmfile," ; %Fs\n",CommandComment2);
write_batch_parms(parmfile,colorspec,maxcolor); /* write the parameters */
fprintf(parmfile," }\n\n");
if (gotinfile) { /* copy the rest of the file */
while ((i = file_gets(buf,255,infile)) == 0) { } /* skip blanks */
while (i >= 0) {
fputs(buf,parmfile);
fputc('\n',parmfile);
i = file_gets(buf,255,infile);
}
fclose(infile);
}
fclose(parmfile);
if (gotinfile) { /* replace the original file with the new */
unlink(CommandFile); /* success assumed on these lines */
rename(outname,CommandFile); /* since we checked earlier with access */
}
return(1);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -