#include "defs.h" /* * Return one character of input and echo it. * CR, # and @ are not echoed. * control characters are ignored. * * return = input character * An error is generated if a DEL is input. */ key() { REG CHAR c; switch(c = anykey()) { case CR: case ' ': return(c); case DEL: longjmp(onerror,3); default: if(c==e_stty || c==k_stty) return(c); if (c > ' ') echo(c); return(c); } } /* * Read cursor position. * * returns character typed * character is saved */ cursor(p) DL p; { REG CHAR k; switch(k=kur(p)){ case SP: case CR: savech=0; break; default: savexh++; } return(k); } kur(p) DL p; { REG CHAR c; DL q; /* * read cursor position scaled to virtual screen */ if(savexh) { savexh=0; copypt(xhairs,p); return(SP); } c = cursin(p); wtod(q=p); chkcur(q); copypt(q, xhairs); switch(savech=c){ case CR: mode(CMD); return(c); case DEL: longjmp(onerror,2); default: case SP: return(c); } } /* * check bounds of point p1 */ chkcur(p1) REG DL p1; { REG INT x1, y1; x1 = p1->x; y1 = p1->y; if (x1 < 0 || x1 >= maxx || y1 < 0 || y1 >= maxy){ error("cursor out of bounds"); } }