byte putampm(byte x,char *_hour) { static byte hour,pm; if(_24hr) return x; if(*_hour==' ') { if(propfont) PROPPUTCH0(' '); else ttyprint(' '); return x; } hour=gettwodigits(_hour); if(hour>=12) pm=1; else pm=0; if(propfont) { ozfont(FONT_OZ_NORMAL); PROPPUTCH(AM_CHAR+pm); ozfont(FONT_PC_NORMAL); return x; } else { ttyprint(pm?'p':'a'); return 0; } }
void print_error(char *pstr) { #ifdef SCRN_DEBUG ttyprint(0,0, padding); #endif /* SCRN_DEBUG */ ttyprint(0,35, pstr); while(1); }
void termputch(byte c) { switch(c) { case 7: beep(); return; case 8: xorcursor(); if(curcol>0) curcol--; else curcol=0; xorcursor(); return; case 11: case 12: case '\n': newline(); return; case '\r': if(LNM) crlf(); else { xorcursor(); curcol=0; xorcursor(); } return; default: ttyprint(c); return; } }
void tty_print_screen(void) { #ifdef SCRN_DEBUG int i; for (i=0; i < SCREEN_Y; ++i) ttyprint(i,0, padding); #endif /* SCRN_DEBUG */ tty_print_region(0, 0, SCREEN_Y, SCREEN_X); }
void asmlinkage printf(const char* fmt, ...) { va_list args; char str[256] = {0}; va_start(args,fmt); vsprintf(str,fmt,args); va_end(args); ttyprint(str); }
byte puthour(byte x,char *_hour) { static byte hour; static char hour1; if(*_hour==' ') { if(propfont) { PROPPUTCH0(' '); PROPPUTCH0(' '); } else { ttyprint(' '); ttyprint(' '); } return x; } hour=gettwodigits(_hour); if(!_24hr) { if(hour>12) hour-=12; else if(hour==0) hour=12; } hour1=hour/10+'0'; if(!_24hr && hour1=='0') hour1=' '; if(propfont) { PROPPUTCH0(hour1); PROPPUTCH(hour%10+'0'); return x; } else { ttyprint(hour1); ttyprint(hour%10+'0'); return 0; } }
int dumpdate(int x, int y, long startdate, int index, int longform) { if(!propfont) { termputs(longform?days[(startdate+index) % 7]: shortdays[(startdate+index) % 7]); termputs(", "); #ifdef ITALIAN termputs(itoa(theday[index])); ttyprint(' '); #endif /* ITALIAN */ termputs(months[themonth[index]-1]); ttyprint(' '); #ifndef ITALIAN termputs(itoa(theday[index])); termputs(", "); #endif /* not ITALIAN */ termputs(itoa(theyear[index])); return 0; } else { x=ozputs(x,y,longform?days[(startdate+index) % 7]: shortdays[(startdate+index) % 7]); x=ozputs(x,y,", "); #ifdef ITALIAN x=ozputs(x,y,itoa(theday[index])); x=ozputs(x,y," "); #endif /* ITALIAN */ x=ozputs(x,y,months[themonth[index]-1]); x=ozputch(x,y,' '); #ifndef ITALIAN x=ozputs(x,y,itoa(theday[index])); x=ozputs(x,y,", "); #endif /* not ITALIAN */ x=ozputs(x,y,itoa(theyear[index])); return x; } }
void tty_print_line( int y, int x, const char *text) { for(; *text && (x < SCREEN_X); x++, text++) { if (*text != screen_buf[y][x]) { break; } } /* If there is nothing to do return */ if (*text == '\0') { return; } ttyprint(y, x, text); for(; *text && (x < SCREEN_X); x++, text++) { screen_buf[y][x] = *text; } }
void tty_print_region(const int pi_top, const int pi_left, const int pi_bottom, const int pi_right) { int y; char tmp; for (y=pi_top; y < pi_bottom; ++y){ CHECK_BOUNDS(y, pi_right); tmp = screen_buf[y][pi_right]; screen_buf[y][pi_right] = '\0'; CHECK_BOUNDS(y, pi_left); ttyprint(y, pi_left, &(screen_buf[y][pi_left])); screen_buf[y][pi_right] = tmp; } }
command() { float tval; int i,echeck; int pmin,pmax,pstep; char tbuf[20]; while (echeck = getstring(": ")) { if (echeck == EOF) { fileinput(STD); } else if (startsame(in,"cycle")) { cycle(); } else if (startsame(in,"coarticulation")) { ttyprint("coarticulation %s: change? ",(coartflag ? "ON":"OFF")); fscanf(infp,"%s",in); if(in[0] == 'n') continue; coartflag = 1 - coartflag; } else if (startsame(in,"rc")) { printf("reset and cycle\n"); zarrays(); cycle(); } else if (startsame(in,"wordacts")) { printwords(printmin,printmax,3,stdout); if (outfile) printwords(printmin,printmax,3,outfile); } else if (startsame(in,"wtacts")) { printwt(printmin,printmax,3,stdout); if (outfile) printwt(printmin,printmax,3,outfile); } else if (startsame(in,"owtacts")) { getstring("word: "); strcpy(tbuf,in); printonewt(tbuf,printmin,printmax,3,stdout); if (outfile) printonewt(tbuf,printmin,printmax,3,outfile); } else if (startsame(in,"phonacts")) { printphonemes(printmin,printmax,3,stdout); if (outfile) printphonemes(printmin,printmax,3,outfile); } else if (startsame(in,"featacts")) { printf("feature activations - give min,max,step: "); scanf("%d %d %d",&pmin,&pmax,&pstep); printfeatures(pmin,pmax,pstep,stdout); if (outfile) printfeatures(pmin,pmax,pstep,outfile); } else if (startsame(in,"expression")) { setex(); } else if (startsame(in,"fileinput")) { fileinput(NONSTD); } else if (startsame(in,"inspecs")) { ttyprint("File name (- = stdin): "); fscanf(infp,"%s",in); inspecs(in); } else if (startsame(in,"infeatures")) { ttyprint("File name: "); fscanf(infp,"%s",in); infeats(in); } /* NOT PRESENTLY OPERATIVE -- JLM 10-5-82 else if (startsame(in,"wsubset")) { wordsubset(); } */ else if (startsame(in,"test")) { getstring("test string: "); test(in); } else if (startsame(in,"topdown")) { topdown(); } else if (startsame(in,"output")) { setout(); } else if (startsame(in,"ofile")) { getstring("give filename (or - for none): "); setoutfile(in); } else if (in[0] == '!') { system(&in[1]); } else if (in[0] == '?') { help(); } else if (startsame(in,"help")) { help(); } else if (startsame(in,"lexicon")) { getlex(); } else if (startsame(in,"parameters")) { getpars(); } else if (startsame(in,"quit")) { quit(); } else if (startsame(in,"decay")) { ttyprint ("decay values:\n"); getfloat(decay,NLEVS,"F","P","W"); } else if (startsame(in,"alpha")) { ttyprint ("alpha values:\n"); getfloat(alpha,NPARAMS, "IF","FF","FP","PP","PW","WW","WP","PF","PFC"); } else if (startsame(in,"gamma")) { ttyprint ("gamma values:\n"); getfloat(ga,NLEVS,"F","P","W"); } else if (startsame(in,"grace")) { ttyprint ("grace %s: change? ",(grace ? "ON" : "OFF")); fscanf(infp,"%s",in); if (in[0] == 'n') continue; grace = 1 - grace; } else if (startsame(in,"rest")) { tval = rest[W]; ttyprint ("rest values:\n"); getfloat(rest,NLEVS,"F","P","W"); if (tval != rest[W]) { initialize(); } } else if (startsame(in,"fweight")) { ttyprint ("fweight values:\n"); getfloat(fweight,NCONTINS, "POW","PIT","VOI","ABT","DIF","ACU","CON","LWS", "MDS", "HIS","FT1","FT2","FT3","FT4","FT5","FT6"); } else if (startsame(in,"pthresh")) { ttyprint ("pthresh values:\n"); getfloat(pthresh,NLEVS,"F","P","W"); } else if (startsame(in,"nreps")) { ttyprint ("%d nreps: change? ",nreps); fscanf(infp,"%s",in); if (in[0] == 'n') continue; sscanf(in,"%d",&nreps); } else if (startsame(in,"pfreq")) { ttyprint ("%d pfreq: change? ",printfreq); fscanf(infp,"%s",in); if (in[0] == 'n') continue; sscanf(in,"%d",&printfreq); } else if (startsame(in,"summarypr")) { ttyprint("give min, max, and step: "); fscanf(infp,"%d %d %d",&pmin,&pmax,&pstep); summarypr(pmin,pmax,pstep,stdout); if (outfile) summarypr(pmin,pmax,pstep,outfile); } else if (startsame(in,"spointers")) { qsort(wordptr,nwptrs,sizeof(struct word *),ecomp); } else if (startsame(in,"sinspec")) { sinspec(); } else if (startsame(in,"sfeatures")) { ttyprint("file name: "); fscanf(infp,"%s",in); sfeatures(in); } else if (startsame(in,"dinspec")) { dinspec(); } else if (startsame(in,"acoustinput")) { ttyprint("give min, max, and step: "); fscanf(infp,"%d %d %d",&pmin,&pmax,&pstep); acoustinput(pmin,pmax,pstep,stdout); if (outfile) acoustinput(pmin,pmax,pstep,outfile); } else if (startsame(in,"sumopt")) { ttyprint ("summaryprint %s: change? ",(sumflag ? "ON" : "OFF")); fscanf(infp,"%s",in); if (in[0] == 'n') continue; sumflag = 1 - sumflag; } else if (startsame(in,"echooutput")) { ttyprint ("echooutput %s: change? ",(echoflag ? "ON" : "OFF")); fscanf(infp,"%s",in); if (in[0] == 'n') continue; echoflag = 1 - echoflag; } else if (startsame(in,"min")) { ttyprint ("min = "); getval(&min); } else if (startsame(in,"max")) { ttyprint ("max = "); getval(&max); } else if (startsame(in,"windowcent")) { ttyprint ("windowcent = "); getval(&windowcent); } else if (startsame(in,"wbase")) { ttyprint ("wbase = "); getval(&wbase); } else if (startsame(in,"wchange")) { ttyprint ("wchange = "); getval(&wchange); } else if (startsame(in,"wgain")) { ttyprint ("wgain = "); getval(&wgain); } else if (startsame(in,"wramp")) { ttyprint ("wramp = "); getval(&wramp); } else if (startsame(in,"imax")) { ttyprint ("imax = "); getval(&imax); } else if (startsame(in,"freqscale")) { ttyprint ("freqscale = "); tval = fscale; getval(&fscale); if (tval != fscale) { initialize(); } } else if (startsame(in,"abort")) { abort(); /* to get a core dump for sdb */ } else { printf("Unrecognized request: For help type ?.\n"); if (infp != stdin) fileinput(STD); } wait(0); } }
void minihead(long start, int index, int i) { switch(i) { int d; case 0: d=(start+index)%7; if(propfont) { char day[4]; strncpy(day,days[d],3); day[3]=0; ozputs(0,y,day); reverse2bytes(y,PROP_FONT_HEIGHT); x=NOHEAD_INDENT; } else { reverse=1; ttyprint(days[d][0]); ttyprint(days[d][1]); ttyprint(days[d][2]); reverse=0; ttyprint(' '); } break; case 1: if(propfont) { ozputs(x,y,itoa(theday[index])); x=NOHEAD_INDENT; } else { termputs(itoa(theday[index])); while(curcol<3) ttyprint(' '); ttyprint(' '); } break; case 2: if(propfont) { char month[4]; strncpy(month,months[themonth[index]-1],3); month[3]=0; ozputs(0,y,month); x=NOHEAD_INDENT; } else { ttyprint(months[themonth[index]-1][0]); ttyprint(months[themonth[index]-1][1]); ttyprint(months[themonth[index]-1][2]); ttyprint(' '); } break; default: if(propfont) x=NOHEAD_INDENT; else termputs(" "); break; } }
int dumpday(int _y, long start, int index, int from, int maxn) { static int i; static char *b; static byte x0; register char *b2; if((!viewempty || !viewheaders || repeatchooser) && !num_appts[index]) return 0; if(index>=NUMDAYS || maxn==0) return 0; x=0; y=_y; if(from==-1) { reverse=1; #ifndef OLDSTYLE if(propfont) x=ozputch(x,y,' '); else termputch(' '); #endif x=dumpdate(x,y,start,index,1); if(propfont) { PROPPUTS(": "); #ifndef ITALIAN PROPPUTS(num_appts[index]?itoa(num_appts[index]):"no"); ozputs(x,y,num_appts[index]==1?" entry.":" entries."); #else /* ITALIAN */ PROPPUTS(num_appts[index]?itoa(num_appts[index]):"nessun"); ozputs(x,y,num_appts[index]==1?" campo.":" campi."); #endif /* ITALIAN */ reverselines(y,PROP_FONT_HEIGHT); x=0; y+=PROP_FONT_HEIGHT; } else { termputs(": "); termputs(num_appts[index]?itoa(num_appts[index]):"no"); #ifndef ITALIAN termputs(num_appts[index]==1?" entry.":" entries."); #else /* ITALIAN */ termputs(num_appts[index]==1?" campo.":" campi."); #endif /* ITALIAN */ while(curcol<WIDTH) ttyprint(' '); } reverse=0; } if(num_appts[index]-from>maxn) maxn=from+maxn; else maxn=num_appts[index]; for(i=from<0?0:from; i<maxn; i++) { if(repeatchooser) { dumpdate(x,y,start,index,1); if(propfont) { y+=PROP_FONT_HEIGHT; x=0; } else { currow++; curcol=0; } } else if(!viewheaders) minihead(start,index,i); b=ozloadcluster(appts[index][i].loc); switch(appts[index][i].type) { case TYPE_SCHEDULE: x0=x; x=puthour(x,b+24); if(propfont) { PROPPUTCH(':'); PROPPUTCH0(b[26]); PROPPUTCH0(b[27]); x=putampm(x,b+24); PROPPUTCH('-'); x=puthour(x,b+28); PROPPUTCH(':'); PROPPUTCH0(b[30]); PROPPUTCH0(b[31]); x=putampm(x,b+28); x=x0+time_indent; } else { ttyprint(':'); ttyprint(b[26]); ttyprint(b[27]); putampm(0,b+24); ttyprint('-'); puthour(0,b+28); ttyprint(':'); termputs(b+30); putampm(0,b+28); ttyprint(' '); } b2=b+38; break; case TYPE_ANNIVERSARY: if(propfont) { ozputs(x,y,"Anniv."); x+=time_indent; } else { underline=1; #ifndef ITALIAN termputs("Anniversary"); #else /* ITALIAN */ termputs("Anniversario"); #endif /* ITALIAN */ underline=0; if(!_24hr) termputs(" "); ttyprint(' '); } b2=b+2+13+5; break; case TYPE_TODO: if(propfont) { int x0=x; #ifndef ITALIAN PROPPUTS("TO DO ["); #else /* ITALIAN */ PROPPUTS("DAFARE["); #endif /* ITALIAN */ PROPPUTCH(b[2+13+2+9]); ozputch(x,y,']'); x=x0+time_indent; } else { underline=1; #ifndef ITALIAN termputs("TO DO ["); #else /* ITALIAN */ termputs("DAFARE["); #endif /* ITALIAN */ ttyprint(b[2+13+2+9]); termputs("]"); underline=0; termputs(" "); if(!_24hr) termputs(" "); } b2=b+2+13+2+9+4; break; } if(propfont) PROPPUTS(b2); else while(*b2 && b2<b+64 && curcol<WIDTH) ttyprint(*b2++); if(b[1]!='\xFF' || b[0]!='\xFF') { unsigned loc2; b2=2+ozloadcluster(loc2=ozinclocation(appts[index][i].loc)); if(propfont) { if(x<SCREEN_WIDTH && !*(ozputsgetend())) PROPPUTS(b2); if(x<SCREEN_WIDTH && (b2[-2]!='\xFF' || b2[-1]!='\xFF') && !*(ozputsgetend())) ozputs(x,y,2+ozloadcluster(ozinclocation(loc2))); } else while(*b2 && curcol<WIDTH) ttyprint(*b2++); } if(propfont) { x=0; y+=PROP_FONT_HEIGHT; } else curcol=WIDTH; } return i-from; }