void drawinputdlg (char *title1, char *title2, char *msg1, int textwidth) { int left, top, width, height, tleft, ttop, twidth, theight; int shadowx = 2, shadowy = 1; int swidth = 80, sheight = 25; twidth = textwidth + 2; theight = 3; width = twidth + 4; height = theight + 7; left = (swidth - (width + shadowx) + 1) / 2; top = (sheight - 2 - (height + shadowy) + 1) / 2 + 2; tleft = left + 2; ttop = top + 2; call0x10 (3, 0, 0, 0); /* set mode */ fillchar (0x13, ' ', 0, 0, swidth, sheight); /* paint blue */ printstr (0x1B, title1, 1, 0); /* title */ fillchar (0x1B, 0xC4, 1, 1, swidth - 2, 1); /* line */ drawdlgframe (left, top, width, height); /* frame */ printstr (0x79, title2, left + (width - strlen (title2)) / 2, top); printstr (0x74, msg1, left + 2, top + 1); drawframe (0x70, 0x7F, tleft, ttop, twidth, theight); printstr (0x1F, "< >", left + (width - 8) / 2, top + height - 2); printstr (0x1F, "O", left + (width - 8) / 2 + 3, top + height - 2); printstr (0x1E, "K", left + (width - 8) / 2 + 4, top + height - 2); printstr (0x70, " ", tleft + 1, ttop + 1); }
void drawdlgframe (int left, int top, int width, int height) { int right = left + width - 1; int bottom = top + height - 1; fillchar (0x00, ' ', left + 2, top + 1, width, height); fillchar (0x70, ' ', left, top, width, height); drawframe (0x7F, 0x70, left, top, width, height); fillchar (0x7F, 0xC3, left, bottom - 2, 1, 1); fillchar (0x7F, 0xC4, left + 1, bottom - 2, width - 2, 1); fillchar (0x70, 0xB4, right, bottom - 2, 1, 1); }
char * PROC dodash(char *src) /* parse the innards of a [] */ { int k; register char *start = src; char cs[128]; fillchar(cs,sizeof(cs),FALSE); while (*src && *src != CCLEND) { if (*src == DASH && src>start && src[1] != CCLEND && src[-1]<src[1]) { for ( k = src[-1]; k <= src[1]; k++) cs[k] = TRUE; src++; } else cs[esc(&src)] = TRUE; src++; } for (k=0; k < sizeof(cs); k++) if (cs[k]) concatch((char)k); return src; }
PROC adjuster(bool sleft, int endd, int sw) { bool noerror; int np, ts, ip, ss, adjp, DLEnum; if (sw == -1) sw = shiftwidth; if (sleft) sw = -sw; curr = bseekeol(curr); ip = curr; noerror = TRUE; do { DLEnum = sw + findDLE(ip, &np, bufmax,0); if (DLEnum >= 0 && DLEnum <= COLS && core[np] != EOL && np < bufmax) { ts = DLEnum / tabsize; ss = DLEnum % tabsize; adjp = ts+ss+ip; if (np-adjp < 0) { /* expand the buf */ moveright(&core[np], &core[adjp], bufmax-np); insert_to_undo(&undo, adjp, adjp - np); } else delete_to_undo(&undo, adjp, np - adjp); endd += (adjp-np); noerror = move_to_undo(&undo, ip, ts+ss); fillchar(&core[ip], ts, TAB); fillchar(&core[ip+ts], ss, 32); } else if (np > ip) { /* remove the indent code */ noerror = delete_to_undo(&undo, ip, np-ip); endd += (ip - np); } ip = 1 + fseekeol(ip); } while (noerror && ip < endd); if (!noerror) error(); newc = skipws(curr); disp = curr; newend = endd; endY = setY(min(newend, pend)); }
void clearbytes (ptrvoid pclear, long ctclear) { /* fill memory with 0's. */ fillchar (pclear, ctclear, (char) 0); } /*clearbytes*/
void drawframe (int attr, int attrshadow, int left, int top, int width, int height) { int right = left + width - 1; int bottom = top + height - 1; fillchar (attr, 0xDA, left, top, 1, 1); fillchar (attr, 0xC4, left + 1, top, width - 2, 1); fillchar (attrshadow, 0xBF, right, top, 1, 1); fillchar (attr, 0xB3, left, top + 1, 1, height - 2); fillchar (attrshadow, 0xB3, right, top + 1, 1, height - 2); fillchar (attr, 0xC0, left, bottom, 1, 1); fillchar (attrshadow, 0xC4, left + 1, bottom, width - 2, 1); fillchar (attrshadow, 0xD9, right, bottom, 1, 1); }
void clearhandle (Handle hclear) { /* fill a handle's data with 0's. */ register Handle h = hclear; register long size; size = gethandlesize (h); /* lockhandle (h); */ fillchar (*h, size, (char) 0); /* unlockhandle (h); */ } /*clearhandle*/
void printf (const char *fmt, ...) { char c; int count = 0; va_list args; va_start(args, fmt); while ((c = *fmt++) != 0) { if (c != '%') { _putch(c); } else { char tmp[32]; char *p; unsigned int format1 = 0; unsigned int format2 = 3; char zerofill = ' '; int rightfill = 0; int n; int longfmt = 0; int longlongfmt = 0; if (*fmt && *fmt =='-') { rightfill = 1; fmt++; } p = (char *) fmt; /* Read formatting parameters. */ while (*p && isdigit(*p)) { p++; } if (p > fmt) { char s[100]; strncpy(s, fmt, p - fmt); s[p - fmt] = 0; if (s[0] == '0') { zerofill = '0'; } format1 = (u32)strtoull (s, 0, 10); fmt = p; if (*p && *p == '.') { p++; fmt++; while (*p && isdigit (*p)) { p++; } if (p > fmt) { char fstr[100]; strncpy (fstr, fmt, p - fmt); format2 = (u32)strtoull (fstr, 0, 10); fmt = p; } } } c = *fmt++; if (c == 'l') { longfmt = 1; c = *fmt++; } switch (c) { case 'p': puts("0x"); c = 'x'; /* fall through */ case 'x': case 'u': case 'd': if (longfmt) { n = va_arg (args, long); } else { n = va_arg (args, int); } itoa(tmp, c, n); if (! rightfill && strlen (tmp) < format1) { fillchar (zerofill, format1 - strlen (tmp)); } puts(tmp); if (rightfill && strlen (tmp) < format1) { fillchar (zerofill, format1 - strlen (tmp)); } break; case 'c': n = va_arg (args, int); _putch(n & 0xff); break; case 's': p = va_arg (args, char *); if (p) { if (!rightfill && strlen (p) < format1) { fillchar (zerofill, format1 - strlen (p)); } puts(p); if (rightfill && strlen (p) < format1) { fillchar (zerofill, format1 - strlen (p)); } } else { puts("(null)"); } break; default: _putch (c); break; } } }