|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T k
Length: 1923 (0x783) Types: TextFile Names: »key.c«
└─⟦b20c6495f⟧ Bits:30007238 EUUGD18: Wien-båndet, efterår 1987 └─⟦this⟧ »EUUGD18/General/Abermud/key.c«
/* Key drivers */ #include "kernel.h" #include <sgtty.h> #ifdef RCSID static char RCS[] = "$Header: key.c,v 1.1 89/03/13 09:36:33 rsalz Exp $"; #endif /* RCSID */ static char *pr_bf; long save_flag = -1; keysetup() { struct sgttyb x; gtty(fileno(stdin), &x); save_flag = x.sg_flags; x.sg_flags &= ~ECHO; x.sg_flags |= CBREAK; stty(fileno(stdin), &x); } keysetback() { struct sgttyb x; if(save_flag == -1) return; gtty(fileno(stdin), &x); x.sg_flags = save_flag; stty(fileno(stdin), &x); } key_input(ppt, len_max) char *ppt; int len_max; { int len_cur = 0, tmp; char x; key_mode = 1; pr_bf = ppt; bprintf("%s", ppt); pbfr(); pr_due = 0; *key_buff = '\0'; while(len_cur < len_max) { switch (x = getchar()) { case '\n': /* return */ putchar('\n'); key_mode = 0; return; case 18: /* ctrl-r */ for (tmp = len_cur; tmp; tmp--) { putchar(8); putchar(' '); putchar(8); } printf("%s", key_buff); continue; case 21: /* ctrl-u */ for (tmp = len_cur; tmp; tmp--) { putchar(8); putchar(' '); putchar(8); } key_buff[len_cur = 0] = '\0'; continue; case 8: /* backspace and del */ case 127: if(!len_cur) continue; putchar(8); putchar(' '); putchar(8); len_cur--; key_buff[len_cur] = '\0'; continue; default: /* insert to key_buff */ if (x < 32) continue; putchar(x); key_buff[len_cur++] = x; key_buff[len_cur] = '\0'; } } } key_reprint() { pr_qcr = 1; pbfr(); if (pr_due && key_mode) printf("\n%s%s", pr_bf, key_buff); fflush(stdout); pr_due = 0; }