|
|
1.1 ! root 1: #include <jerq.h> ! 2: #include <font.h> ! 3: ! 4: static void ! 5: getstr(s, p, start, bs, at) ! 6: char *s, *start; ! 7: Point p; ! 8: { ! 9: char c; ! 10: static char str[] = "x"; ! 11: ! 12: for(;;) ! 13: { ! 14: wait(KBD); ! 15: if(((c=kbdchar()) == '\r') || (c == '\n')) ! 16: { ! 17: *s = '\0'; ! 18: return; ! 19: } ! 20: if(c == bs) ! 21: { ! 22: if(s>start) ! 23: { ! 24: str[0] = *(--s); ! 25: p.x -= defont.info[*s].width; ! 26: *s = 0; ! 27: string(&defont, str, &display, p, F_XOR); ! 28: } ! 29: } ! 30: else if(c == at) ! 31: { ! 32: if(s>start) ! 33: { ! 34: p.x -= strwidth(&defont, start); ! 35: string(&defont, start, &display, p, F_XOR); ! 36: s = start; ! 37: *s = 0; ! 38: } ! 39: } ! 40: else if((c >= ' ') && (c <= '~')) ! 41: { ! 42: if(s-start<50) ! 43: { ! 44: *s++ = (str[0] = c); ! 45: *s = 0; ! 46: p = string(&defont, str, &display , p, F_XOR); ! 47: } ! 48: } ! 49: } ! 50: } ! 51: ! 52: kbdstr(s) ! 53: char *s; ! 54: { ! 55: kbordstr(s, s+strlen(s), '\b', '@'); ! 56: } ! 57: ! 58: kbordstr(str, start, bs, at) ! 59: char *str, *start; ! 60: { ! 61: Bitmap *b; ! 62: Point p; ! 63: Rectangle r; ! 64: ! 65: p = mouse.xy; ! 66: p.x = min(p.x, Drect.corner.x-300); ! 67: b = balloc(raddp(Rect(0, 0, 300, defont.height+4), p)); ! 68: bitblt(&display, b->rect, b, b->rect.origin, F_STORE); ! 69: rectf(&display, b->rect, F_STORE); ! 70: rectf(&display, r = inset(b->rect, 1), F_XOR); ! 71: p = add(r.origin, Pt(1,1)); ! 72: p = string(&defont, str, &display, p, F_XOR); ! 73: getstr(start+strlen(start), p, start, bs, at); ! 74: bitblt(b, b->rect, &display, b->rect.origin, F_STORE); ! 75: bfree(b); ! 76: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.