|
|
1.1 ! root 1: /* tinytcap.c */ ! 2: ! 3: /* This file contains functions which simulate the termcap functions, but which ! 4: * can only describe the capabilities of the ANSI.SYS and NANSI.SYS drivers on ! 5: * an MS-DOS system or the VT-52 emulator of an Atari-ST. These functions ! 6: * do *NOT* access a "termcap" database file. ! 7: */ ! 8: ! 9: #include "config.h" ! 10: #if MSDOS || TOS || MINIX || COHERENT ! 11: ! 12: #define CAP(str) CAP2((str)[0], (str)[1]) ! 13: #define CAP2(a,b) (((a) << 8) + ((b) & 0xff)) ! 14: ! 15: #if MSDOS ! 16: # define VAL2(v,a) (a) ! 17: # define VAL3(v,a,n) (nansi ? (n) : (a)) ! 18: static int nansi; ! 19: #endif ! 20: ! 21: #if TOS ! 22: # define VAL2(v,a) (v) ! 23: # define VAL3(v,a,n) (v) ! 24: #endif ! 25: ! 26: #if MINIX || COHERENT ! 27: # define VAL2(v,a) (a) ! 28: # define VAL3(v,a,n) (n) ! 29: #endif ! 30: ! 31: ! 32: /*ARGSUSED*/ ! 33: int tgetent(bp, name) ! 34: char *bp; /* buffer for storing the entry -- ignored */ ! 35: char *name; /* name of the entry */ ! 36: { ! 37: #if MSDOS ! 38: nansi = strcmp(name, "ansi"); ! 39: #endif ! 40: return 1; ! 41: } ! 42: ! 43: int tgetnum(id) ! 44: char *id; ! 45: { ! 46: switch (CAP(id)) ! 47: { ! 48: case CAP2('l','i'): return 25; ! 49: case CAP2('c','o'): return 80; ! 50: case CAP2('s','g'): return 0; ! 51: case CAP2('u','g'): return 0; ! 52: default: return -1; ! 53: } ! 54: } ! 55: ! 56: int tgetflag(id) ! 57: char *id; ! 58: { ! 59: switch (CAP(id)) ! 60: { ! 61: #if !MINIX || COHERENT ! 62: case CAP2('a','m'): return 1; ! 63: #endif ! 64: case CAP2('b','s'): return 1; ! 65: case CAP2('m','i'): return 1; ! 66: default: return 0; ! 67: } ! 68: } ! 69: ! 70: /*ARGSUSED*/ ! 71: char *tgetstr(id, bp) ! 72: char *id; ! 73: char **bp; /* pointer to pointer to buffer - ignored */ ! 74: { ! 75: switch (CAP(id)) ! 76: { ! 77: case CAP2('c','e'): return VAL2("\033K", "\033[K"); ! 78: case CAP2('c','l'): return VAL2("\033E", "\033[2J"); ! 79: ! 80: case CAP2('a','l'): return VAL3("\033L", (char *)0, "\033[L"); ! 81: case CAP2('d','l'): return VAL3("\033M", (char *)0, "\033[M"); ! 82: ! 83: case CAP2('c','m'): return VAL2("\033Y%i%+ %+ ", "\033[%i%d;%dH"); ! 84: case CAP2('d','o'): return VAL2("\033B", "\033[B"); ! 85: case CAP2('n','d'): return VAL2("\033C", "\033[C"); ! 86: case CAP2('u','p'): return VAL2("\033A", "\033[A"); ! 87: case CAP2('t','i'): return VAL2("\033e", ""); ! 88: case CAP2('t','e'): return VAL2("", ""); ! 89: ! 90: case CAP2('s','o'): return VAL2("\033p", "\033[7m"); ! 91: case CAP2('s','e'): return VAL2("\033q", "\033[m"); ! 92: case CAP2('u','s'): return VAL2((char *)0, "\033[4m"); ! 93: case CAP2('u','e'): return VAL2((char *)0, "\033[m"); ! 94: case CAP2('m','d'): return VAL2((char *)0, "\033[1m"); ! 95: case CAP2('m','e'): return VAL2((char *)0, "\033[m"); ! 96: ! 97: #if MINIX || COHERENT ! 98: case CAP2('k','u'): return "\033[A"; ! 99: case CAP2('k','d'): return "\033[B"; ! 100: case CAP2('k','l'): return "\033[D"; ! 101: case CAP2('k','r'): return "\033[C"; ! 102: case CAP2('P','U'): return "\033[V"; ! 103: case CAP2('P','D'): return "\033[U"; ! 104: case CAP2('H','M'): return "\033[H"; ! 105: # if MINIX ! 106: case CAP2('E','N'): return "\033[Y"; ! 107: # else /* COHERENT */ ! 108: case CAP2('E','N'): return "\033[24H"; ! 109: # endif ! 110: #else /* MS-DOS or TOS */ ! 111: case CAP2('k','u'): return "#H"; ! 112: case CAP2('k','d'): return "#P"; ! 113: case CAP2('k','l'): return "#K"; ! 114: case CAP2('k','r'): return "#M"; ! 115: case CAP2('H','M'): return "#G"; ! 116: case CAP2('E','N'): return "#O"; ! 117: case CAP2('P','U'): return "#I"; ! 118: case CAP2('P','D'): return "#Q"; ! 119: #endif ! 120: ! 121: default: return (char *)0; ! 122: } ! 123: } ! 124: ! 125: /*ARGSUSED*/ ! 126: char *tgoto(cm, destcol, destrow) ! 127: char *cm; /* cursor movement string -- ignored */ ! 128: int destcol;/* destination column, 0 - 79 */ ! 129: int destrow;/* destination row, 0 - 24 */ ! 130: { ! 131: static char buf[30]; ! 132: ! 133: #if MSDOS || MINIX || COHERENT ! 134: sprintf(buf, "\033[%d;%dH", destrow + 1, destcol + 1); ! 135: #endif ! 136: #if TOS ! 137: sprintf(buf, "\033Y%c%c", ' ' + destrow, ' ' + destcol); ! 138: #endif ! 139: return buf; ! 140: } ! 141: ! 142: /*ARGSUSED*/ ! 143: void tputs(cp, affcnt, outfn) ! 144: char *cp; /* the string to output */ ! 145: int affcnt; /* number of affected lines -- ignored */ ! 146: int (*outfn)(); /* the output function */ ! 147: { ! 148: while (*cp) ! 149: { ! 150: (*outfn)(*cp); ! 151: cp++; ! 152: } ! 153: } ! 154: #endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.