guido@cwi.nl (Guido van Rossum) (03/04/91)
Archive-name: stdwin/part14 #! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh <file", e.g.. If this archive is complete, you # will see the following message at the end: # "End of archive 14 (of 19)." # Contents: Appls/bed/Dada Appls/bed/Woman Appls/dpv/dpvfunny.c # Appls/dpv/dpvparse.c Appls/dpv/dpvrestart.c Appls/test/magic.c # Appls/test/sevenseg.h H/vt.h Packs/vt/vtfunc.c Ports/alfa/timer.c # Ports/vtrm/uxtty.c # Wrapped by guido@voorn.cwi.nl on Mon Mar 4 12:37:32 1991 PATH=/bin:/usr/bin:/usr/ucb ; export PATH if test -f 'Appls/bed/Dada' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'Appls/bed/Dada'\" else echo shar: Extracting \"'Appls/bed/Dada'\" \(4767 characters\) sed "s/^X//" >'Appls/bed/Dada' <<'END_OF_FILE' X#define dadada_width 75 X#define dadada_height 75 Xstatic char dadada_bits[] { X 0x20, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, X 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x04, 0x00, X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, X 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x1c, 0x00, 0xff, 0xff, 0x0f, 0x00, X 0x00, 0x00, 0x10, 0x00, 0x24, 0x00, 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00, X 0x10, 0x00, 0x44, 0x00, 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x10, 0x08, X 0x84, 0x01, 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x10, 0x30, 0x04, 0x02, X 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x10, 0x40, 0x04, 0x04, 0xff, 0xff, X 0x0f, 0x00, 0x00, 0x00, 0x20, 0x80, 0x02, 0x18, 0xff, 0xff, 0x0f, 0x00, X 0x00, 0x00, 0x20, 0xfe, 0xfc, 0xdf, 0x00, 0xfc, 0x0f, 0x00, 0x00, 0x00, X 0x20, 0xfe, 0xf9, 0xbf, 0x00, 0xfc, 0x0f, 0x00, 0x00, 0x00, 0x40, 0xfe, X 0xf6, 0x7f, 0xf1, 0xfb, 0x0f, 0x00, 0x00, 0x00, 0x40, 0xfe, 0xce, 0xff, X 0x0e, 0xe4, 0x0f, 0x00, 0x00, 0x00, 0x80, 0x7e, 0xbf, 0xff, 0x07, 0x9c, X 0x0f, 0x00, 0x00, 0x00, 0x80, 0x7e, 0x7f, 0x7f, 0x18, 0x7c, 0x0f, 0x00, X 0x00, 0x00, 0x00, 0x9d, 0xff, 0xbc, 0x20, 0xfc, 0x0e, 0x00, 0x00, 0x00, X 0x00, 0xe2, 0xff, 0xdb, 0x40, 0xfc, 0x0d, 0x00, 0x00, 0x00, 0x00, 0xfe, X 0xff, 0xe7, 0x80, 0xfd, 0x0b, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xcf, X 0x00, 0xfe, 0x0b, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xb7, 0xff, 0x03, X 0x08, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xff, 0x77, 0xfe, 0x03, 0x08, 0x00, X 0x00, 0x00, 0x00, 0xfe, 0xff, 0xf7, 0xfd, 0x03, 0x08, 0x00, 0x00, 0x00, X 0x00, 0xfe, 0xff, 0xfb, 0xfb, 0x03, 0x10, 0x00, 0x00, 0x00, 0x00, 0xfe, X 0xff, 0xfb, 0xe7, 0x03, 0x10, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xfb, X 0xdf, 0x03, 0x10, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xfb, 0xbf, 0x03, X 0x10, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xfb, 0x7f, 0x02, 0x10, 0x00, X 0x00, 0x00, 0x00, 0xfe, 0xff, 0xfb, 0xff, 0x01, 0x10, 0x00, 0x00, 0x00, X 0x00, 0xfe, 0xff, 0xfb, 0xff, 0x03, 0x10, 0x00, 0x00, 0x00, 0x00, 0xfe, X 0xff, 0xf7, 0xff, 0x03, 0x08, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xf7, X 0xff, 0x03, 0x08, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xf7, 0xff, 0x03, X 0x08, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xef, 0xff, 0x03, 0x04, 0x00, X 0x00, 0x00, 0x00, 0xfe, 0xff, 0xef, 0xff, 0x03, 0x04, 0x00, 0x00, 0x00, X 0x00, 0xfe, 0xff, 0xdf, 0xff, 0x03, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, X 0x00, 0x40, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, X 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x60, X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x18, 0x00, 0x00, X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x07, 0x00, 0x00, 0x00, 0x00, X 0x00, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x80, X 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x02, 0x00, X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, X 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, X 0x00, 0x00, 0x04, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, X 0x04, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, X 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x10, 0xff, X 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x10, 0xff, 0xff, 0xff, X 0x00, 0x38, 0x00, 0x00, 0x08, 0x00, 0x08, 0xff, 0xff, 0xff, 0xe0, 0x07, X 0x00, 0x00, 0x10, 0x00, 0x04, 0xff, 0xff, 0xff, 0x1f, 0x00, 0x00, 0x00, X 0x20, 0x00, 0x02, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x80, X 0x01, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x00, 0xff, X 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0xff, 0xff, 0xff, 0x00, 0x00, X 0x00, 0x00, 0x00, 0xf8, 0x01, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, X 0x00, 0x07, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, X 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, X 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, X 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, X 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, X 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, X 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, X 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, X 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, X 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; END_OF_FILE if test 4767 -ne `wc -c <'Appls/bed/Dada'`; then echo shar: \"'Appls/bed/Dada'\" unpacked with wrong size! fi # end of 'Appls/bed/Dada' fi if test -f 'Appls/bed/Woman' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'Appls/bed/Woman'\" else echo shar: Extracting \"'Appls/bed/Woman'\" \(4764 characters\) sed "s/^X//" >'Appls/bed/Woman' <<'END_OF_FILE' X#define woman_width 75 X#define woman_height 75 Xstatic char woman_bits[] { X 0xfc, 0x7e, 0x40, 0x20, 0x90, 0x00, 0x07, 0x80, 0x23, 0x00, 0x00, 0xc6, X 0xc1, 0x41, 0x98, 0xb8, 0x01, 0x07, 0x66, 0x00, 0x15, 0x9f, 0x03, 0x47, X 0x8c, 0xc6, 0xdc, 0x7b, 0xcc, 0x00, 0xb0, 0x71, 0x0e, 0x4d, 0x06, 0x66, X 0x73, 0x8e, 0x8f, 0x01, 0x18, 0xc4, 0x39, 0x4b, 0x02, 0x23, 0x0c, 0x04, X 0x1e, 0x03, 0x0c, 0x08, 0xc7, 0xef, 0x08, 0x30, 0x06, 0x07, 0x1c, 0x02, X 0x06, 0x30, 0x18, 0xae, 0xc8, 0x98, 0x3f, 0x78, 0x20, 0x06, 0x02, 0x20, X 0x60, 0xa0, 0xc4, 0x1d, 0xc0, 0xff, 0x41, 0x04, 0xfa, 0x63, 0x80, 0xa1, X 0xa4, 0xbd, 0x00, 0x84, 0xbf, 0x04, 0x0f, 0x06, 0xfc, 0xa1, 0x34, 0x6b, X 0x01, 0x1c, 0xc9, 0x05, 0x06, 0xc7, 0x06, 0xbe, 0x11, 0x1e, 0x43, 0x30, X 0x91, 0x07, 0xc3, 0x61, 0x02, 0x30, 0x1b, 0x30, 0xcc, 0x30, 0x11, 0x00, X 0xc1, 0x3c, 0x03, 0x20, 0x0a, 0x00, 0xe8, 0x60, 0x21, 0x00, 0x61, 0x1b, X 0xc1, 0x63, 0x08, 0xf0, 0xc6, 0xc7, 0x21, 0x03, 0xf8, 0x08, 0xe1, 0xcf, X 0x0a, 0xfc, 0x4d, 0x99, 0x43, 0x07, 0x3c, 0x0c, 0xf1, 0x9f, 0x0b, 0xfc, X 0x5b, 0x91, 0x47, 0x02, 0x16, 0x04, 0x31, 0x1c, 0x0b, 0x1f, 0x17, 0x89, X 0x4d, 0x06, 0x1a, 0x04, 0x31, 0x38, 0x02, 0x07, 0x56, 0x99, 0x4b, 0x04, X 0x0b, 0x04, 0xb1, 0x72, 0x82, 0xa1, 0x54, 0xba, 0x49, 0x04, 0x1d, 0x66, X 0x50, 0xe7, 0xc2, 0xf0, 0x54, 0x9a, 0x58, 0x04, 0x0d, 0x62, 0xc1, 0x1f, X 0x44, 0xfc, 0x51, 0x90, 0x90, 0x04, 0x86, 0x63, 0xe0, 0x74, 0x04, 0xef, X 0x31, 0x1a, 0x91, 0x00, 0x02, 0xe2, 0xc1, 0xfd, 0x84, 0xf9, 0x30, 0x0a, X 0x91, 0x00, 0x82, 0xa9, 0xc0, 0xb9, 0x84, 0xf9, 0x31, 0x16, 0x81, 0x00, X 0x42, 0xa9, 0xdb, 0x7f, 0x0c, 0xff, 0x1c, 0x16, 0x11, 0x00, 0x02, 0x28, X 0x0b, 0x07, 0x08, 0x60, 0x1c, 0x02, 0x91, 0x00, 0x46, 0x29, 0x0e, 0x00, X 0x00, 0x00, 0x10, 0x16, 0x11, 0x02, 0x06, 0x29, 0x04, 0x00, 0x00, 0x00, X 0x10, 0x16, 0x91, 0x06, 0xa6, 0x2a, 0x04, 0x00, 0x00, 0x00, 0x18, 0x24, X 0x91, 0x04, 0x86, 0x2a, 0x04, 0x00, 0x00, 0x00, 0x18, 0x27, 0x93, 0x04, X 0x96, 0x4a, 0x04, 0x00, 0x00, 0x20, 0x04, 0x02, 0x91, 0x04, 0x86, 0x4a, X 0x0c, 0x00, 0x00, 0x00, 0x1e, 0x23, 0x93, 0x04, 0x56, 0x88, 0x08, 0x00, X 0x00, 0x00, 0x90, 0x21, 0x93, 0x04, 0x52, 0x0a, 0x09, 0x80, 0x01, 0x00, X 0xd0, 0x21, 0x95, 0x04, 0x57, 0x0a, 0x0f, 0x80, 0x27, 0x00, 0xd8, 0x20, X 0x9d, 0x04, 0x5d, 0x08, 0x1c, 0x80, 0x67, 0x00, 0xe4, 0x01, 0x85, 0x04, X 0x79, 0x8a, 0x3f, 0x00, 0x00, 0x00, 0xf4, 0x11, 0x85, 0x06, 0x39, 0x08, X 0x7d, 0x00, 0x00, 0x18, 0xb7, 0x10, 0x81, 0x03, 0x29, 0x12, 0xcb, 0x00, X 0x7e, 0x30, 0x28, 0x00, 0x85, 0x03, 0x29, 0x10, 0xbe, 0x81, 0xff, 0x27, X 0x0c, 0x10, 0x85, 0x03, 0x29, 0x32, 0xfa, 0xc1, 0xff, 0x27, 0x94, 0x11, X 0x85, 0x03, 0x28, 0x20, 0x6c, 0xe1, 0xff, 0x07, 0x0c, 0x01, 0x85, 0x01, X 0x28, 0x62, 0x5c, 0xe3, 0x8f, 0x03, 0x4e, 0x91, 0x80, 0x05, 0x39, 0x40, X 0xf4, 0xc2, 0xff, 0x00, 0x9f, 0x91, 0x84, 0x05, 0x31, 0xc6, 0xe8, 0x07, X 0x7f, 0x80, 0xcd, 0x00, 0xc4, 0x04, 0x31, 0x06, 0xc9, 0x0e, 0x00, 0xc0, X 0x48, 0x88, 0xe0, 0x04, 0x79, 0x04, 0xdb, 0x12, 0x00, 0x30, 0x0c, 0xc8, X 0xe4, 0x04, 0x6d, 0x06, 0xb6, 0x23, 0x00, 0x18, 0x1c, 0xc0, 0x84, 0x06, X 0x25, 0x0c, 0xff, 0xc2, 0x00, 0x4e, 0x06, 0xb0, 0x80, 0x04, 0x3f, 0x8a, X 0xb3, 0x83, 0xff, 0xc3, 0x03, 0x91, 0x84, 0x04, 0x2e, 0xd8, 0x0f, 0x3f, X 0x00, 0x00, 0x5f, 0x83, 0x84, 0x04, 0x2a, 0x70, 0xfd, 0x7f, 0x00, 0x00, X 0xc8, 0xc0, 0x84, 0x04, 0x4b, 0xe2, 0x2f, 0x01, 0x00, 0x08, 0x58, 0x60, X 0x80, 0x05, 0x5b, 0x82, 0xff, 0x01, 0x00, 0x08, 0xd0, 0xa0, 0x84, 0x04, X 0x72, 0x80, 0xe5, 0x00, 0x00, 0x28, 0xd2, 0x20, 0x44, 0x04, 0xca, 0x02, X 0xff, 0x00, 0x00, 0x08, 0xde, 0xa0, 0x44, 0x04, 0x82, 0x02, 0x6d, 0x00, X 0x00, 0x08, 0xf6, 0xb0, 0x40, 0x02, 0x82, 0x07, 0x3f, 0x00, 0x00, 0x08, X 0x44, 0x58, 0xc4, 0x02, 0x93, 0x3f, 0x1f, 0x00, 0x00, 0x30, 0x88, 0x4f, X 0x44, 0x03, 0x83, 0x23, 0x3e, 0x00, 0x00, 0x00, 0x18, 0x60, 0xe0, 0x07, X 0xe3, 0x0f, 0xfe, 0x00, 0x00, 0x00, 0x70, 0x70, 0xe4, 0x07, 0xc7, 0x1b, X 0xfe, 0x01, 0x00, 0x40, 0xe0, 0x3c, 0xe4, 0x07, 0xc7, 0xe3, 0xfe, 0x1f, X 0x00, 0x00, 0xff, 0x1f, 0xfc, 0x07, 0xc7, 0x03, 0xf8, 0x33, 0x00, 0xc0, X 0xf0, 0x07, 0xff, 0x07, 0x87, 0x02, 0xfc, 0x43, 0x00, 0x60, 0xf0, 0xff, X 0xff, 0x07, 0x8f, 0x06, 0xbe, 0x87, 0x00, 0x30, 0xf8, 0xff, 0xff, 0x07, X 0x8f, 0x14, 0x9c, 0x8f, 0x00, 0x00, 0xfc, 0xff, 0xff, 0x07, 0x9f, 0x8d, X 0x8a, 0x0f, 0x00, 0x00, 0xfe, 0xff, 0xff, 0x07, 0xbf, 0x0b, 0x80, 0x1f, X 0x00, 0x40, 0xff, 0xff, 0xff, 0x07, 0x7f, 0x3a, 0x80, 0x3f, 0x00, 0x80, X 0xff, 0xff, 0xff, 0x07, 0xff, 0x20, 0xc0, 0x3f, 0x00, 0x80, 0xff, 0xff, X 0xff, 0x07, 0xff, 0x01, 0xe0, 0x7f, 0x00, 0xc0, 0xff, 0xff, 0xff, 0x07, X 0xff, 0x0f, 0xf8, 0xff, 0x40, 0xe0, 0xff, 0xff, 0xff, 0x07, 0xff, 0xff, X 0xff, 0xff, 0x40, 0xf0, 0xff, 0xff, 0xff, 0x07, 0xff, 0xff, 0xff, 0xff, X 0x41, 0xf0, 0xff, 0xff, 0xff, 0x07}; END_OF_FILE if test 4764 -ne `wc -c <'Appls/bed/Woman'`; then echo shar: \"'Appls/bed/Woman'\" unpacked with wrong size! fi # end of 'Appls/bed/Woman' fi if test -f 'Appls/dpv/dpvfunny.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'Appls/dpv/dpvfunny.c'\" else echo shar: Extracting \"'Appls/dpv/dpvfunny.c'\" \(4890 characters\) sed "s/^X//" >'Appls/dpv/dpvfunny.c' <<'END_OF_FILE' X/* dpv -- ditroff previewer. Funny character translation. */ X X#include "dpv.h" X#include "dpvmachine.h" X#include "dpvoutput.h" X Xchar *funnyfile; /* File to read table from */ X Xchar *funnytries[]= { /* Alternative files to try */ X "funnytab", X "/usr/local/lib/funnytab", X "/userfs3/amoeba/lib/funnytab", X "/ufs/guido/lib/funnytab", X NULL X }; X X/* Funny character translation table. X The table implies that character 'name' (the ditroff input name, X e.g. "bu" for bullet, which is input as "\(bu") must be translated X the string 'trans' drawn in font 'font', or in the current font X if 'font' is NULL. 'Trans' is a string because some characters X need several real characters to print them (e.g., ligatures). X For higher-quality output, the table should be extended to X include a point size increment/decrement and possibly a (dh, dv) X translation; but what the heck, this is only a previewer! */ X Xstatic struct _funny { X char name[4]; X char trans[4]; X char *fontname; X}; X X/* Read funny character translation table. X File format: X name fontname translation X where: X name is the ditroff character name, e.g., bs for \(bs X fontname is the font name, or - if the translation uses the current font X translation is one or more hexadecimal numbers, or a string X enclosed in double quotes X In any case the string may be no more than 3 characters long X*/ X Xreadfunnytab(filename) X char *filename; X{ X char buf[BUFSIZ]; X FILE *fp= fopen(filename, "r"); X if (fp == NULL) { X if (dbg > 0) X fprintf(stderr, "Can't open funnytab %s\n", filename); X return FALSE; X } X if (dbg > 0) X fprintf(stderr, "Reading funnytab from %s\n", filename); X while (fgets(buf, sizeof buf, fp) != NULL) { X char *name; X char *fontname; X char *trans; X char ctrans[4]; X char *p= buf; X while (*p != EOS && isspace(*p)) X ++p; X if (*p == EOS) X continue; X name= p; X while (*p != EOS && !isspace(*p)) X ++p; X if (*p == EOS) X continue; X *p++ = EOS; X while (*p != EOS && isspace(*p)) X ++p; X if (*p == EOS) X continue; X fontname= p; X while (*p != EOS && !isspace(*p)) X ++p; X if (*p == EOS) X continue; X *p++ = EOS; X while (*p != EOS && isspace(*p)) X ++p; X if (*p == EOS) X continue; X if (*p == '"') { X trans= ++p; X while (*p != EOS && *p != EOL && *p != '"') X ++p; X *p= EOS; X } X else if (*p == '0' && p[1] == 'x') { X int a= 0, b= 0, c= 0; X (void) sscanf(p, "0x%x 0x%x 0x%x", &a, &b, &c); X ctrans[0]= a; X ctrans[1]= b; X ctrans[2]= c; X ctrans[3]= EOS; X trans= ctrans; X } X else X error(WARNING, "almost-match in funnytab"); X addtranslation(name, fontname, trans); X } X fclose(fp); X sorttranslations(); X return TRUE; X} X Xint nfunny; Xstruct _funny *funnytab; X Xstatic Xaddtranslation(name, fontname, trans) X char *name, *fontname, *trans; X{ X struct _funny f; X strncpy(f.name, name, 4); X f.name[3]= EOS; X strncpy(f.trans, trans, 4); X f.trans[3]= EOS; X if (fontname == NULL || fontname[0] == EOS || X fontname[0] == '-' && fontname[1] == EOS) X f.fontname= NULL; X else { X static char *lastfontname; X if (lastfontname == NULL || X strcmp(fontname, lastfontname) != 0) X lastfontname= strdup(fontname); X f.fontname= lastfontname; X } X L_APPEND(nfunny, funnytab, struct _funny, f); X if (funnytab == NULL) X error(FATAL, "out of mem for funnytab"); X} X Xstatic Xfunnycmp(p, q) X struct _funny *p, *q; X{ X return strcmp(p->name, q->name); X} X Xstatic Xsorttranslations() X{ X /* Don't sort -- the lookup algorithm depends on the order */ X#if 0 X if (nfunny > 1) X qsort(funnytab, nfunny, sizeof(struct _funny), funnycmp); X#endif X} X X/* Draw a funny character. Called from put1s. */ X Xdrawfunny(name) X register char *name; X{ X register struct _funny *f; X TEXTATTR save; X static bool inited; X X if (!inited) { X if (funnyfile != NULL) { X /* Explicitly specified funnyfile -- must exist */ X if (!readfunnytab(funnyfile)) X error(FATAL, "can't find funnytab file %s", X funnyfile); X } X else { X /* Try to find default funnyfile */ X int i= 0; X while ((funnyfile= funnytries[i++]) != NULL) { X if (readfunnytab(funnyfile)) X break; X } X /* If not found, limp ahead... */ X if (funnyfile == NULL) X error(WARNING, X "can't find default funnytab"); X } X inited= TRUE; X } X X /* If this is too slow, could use binary search and/or X replace the strcmp by an explicit comparison of two X characters. But spend your time on the program's X main loop (especially, 'put1') first! */ X for (f= funnytab; f < &funnytab[nfunny]; ++f) { X /* Assume names are always 1 or 2 chars */ X if (f->name[0] == name[0] && f->name[1] == name[1]) X break; X } X if (f >= &funnytab[nfunny]) X return; /* Unknown character -- don't draw it */ X if (f->fontname != NULL) { X char buf[256]; X wgettextattr(&save); X fonthack(f->fontname); X } X wdrawtext(HWINDOW, VWINDOW - wbaseline(), f->trans, -1); X if (f->fontname != NULL) X wsettextattr(&save); X} END_OF_FILE if test 4890 -ne `wc -c <'Appls/dpv/dpvfunny.c'`; then echo shar: \"'Appls/dpv/dpvfunny.c'\" unpacked with wrong size! fi # end of 'Appls/dpv/dpvfunny.c' fi if test -f 'Appls/dpv/dpvparse.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'Appls/dpv/dpvparse.c'\" else echo shar: Extracting \"'Appls/dpv/dpvparse.c'\" \(4648 characters\) sed "s/^X//" >'Appls/dpv/dpvparse.c' <<'END_OF_FILE' X/* dpv -- ditroff previewer. Parser for ditroff output. */ X X#include "dpv.h" X#include "dpvmachine.h" X#include "dpvoutput.h" X#include "dpvdoc.h" /* Descripton of ditroff output format */ X X/* Parser main loop. Read input from fp. X Stop when EOF hit, 'x stop' found, or nextpage returns < 0. X This makes calls to the machine module to update the X virtual machine's state, and to the output module to perform X actual output. X Code derived from a (not very robust) ditroff filter by BWK. */ X Xparse(fp) X register FILE *fp; X{ X register int c, k; X int m, n, n1, m1; X char str[100], buf[300]; X X while ((c = getc(fp)) != EOF) { X switch (c) { X case '\n': /* when input is text */ X case '\0': /* occasional noise creeps in */ X case '\t': X case ' ': X break; X case '{': /* push down current environment */ X t_push(); X break; X case '}': X t_pop(); X break; X case '0': case '1': case '2': case '3': case '4': X case '5': case '6': case '7': case '8': case '9': X /* two motion digits plus a character */ X k= (c-'0')*10; X c= getc(fp); X k += c-'0'; X hmot(k); X c= getc(fp); X put1(c); X break; X case 'c': /* single ascii character */ X c= getc(fp); X put1(c); X break; X case 'C': X fscanf(fp, "%s", str); X put1s(str); X break; X case 't': /* straight text */ X if (fgets(buf, sizeof(buf), fp) == NULL) X error(FATAL, "unexpected end of input"); X t_text(buf); X break; X case 'D': /* draw function */ X if (fgets(buf, sizeof(buf), fp) == NULL) X error(FATAL, "unexpected end of input"); X switch (buf[0]) { X case 'l': /* draw a line */ X sscanf(buf+1, "%d %d", &n, &m); X drawline(n, m); X break; X case 'c': /* circle */ X sscanf(buf+1, "%d", &n); X drawcirc(n); X break; X case 'e': /* ellipse */ X sscanf(buf+1, "%d %d", &m, &n); X drawellip(m, n); X break; X case 'a': /* arc */ X sscanf(buf+1, "%d %d %d %d", &n, &m, &n1, &m1); X drawarc(n, m, n1, m1); X break; X case '~': /* wiggly line */ X /* HIRO: how to scan? */ X drawwig(buf+1, fp, 1); X break; X default: X error(FATAL, "unknown drawing function %s", buf); X break; X } X recheck(); X break; X case 's': X fscanf(fp, "%d", &n); X setsize(t_size(n)); X break; X case 'f': X fscanf(fp, "%s", str); X setfont(t_font(str)); X break; X case 'H': /* absolute horizontal motion */ X while ((c = getc(fp)) == ' ') X ; X k = 0; X do { X k = 10 * k + c - '0'; X } while (isdigit(c = getc(fp))); X ungetc(c, fp); X hgoto(k); X break; X case 'h': /* relative horizontal motion */ X while ((c = getc(fp)) == ' ') X ; X k = 0; X do { X k = 10 * k + c - '0'; X } while (isdigit(c = getc(fp))); X ungetc(c, fp); X hmot(k); X break; X case 'w': /* word space */ X break; X case 'V': X fscanf(fp, "%d", &n); X vgoto(n); X break; X case 'v': X fscanf(fp, "%d", &n); X vmot(n); X break; X case 'P': /* new spread (Versatec hack) */ X break; X case 'p': /* new page */ X fscanf(fp, "%d", &n); X if (t_page(n) < 0) X return; X break; X case 'n': /* end of line */ X t_newline(); X /* Fall through */ X case '#': /* comment */ X do { X c = getc(fp); X } while (c != EOL && c != EOF); X break; X case 'x': /* device control */ X if (devcntrl(fp) < 0) X return; X break; X default: X error(FATAL, "unknown input character %o %c", c, c); X } X } X error(WARNING, "read till EOF"); X} X X/* Parse rest of device control line. X Returns -1 upon receiving EOF or "stop" command. */ X Xstatic int Xdevcntrl(fp) X FILE *fp; X{ X char str[20], str1[50], buf[50]; X extern char *namemap(); /* ??? */ X int c, n; X X fscanf(fp, "%s", str); X switch (str[0]) { /* crude for now */ X case 'i': /* initialize */ X t_init(); X break; X case 't': /* trailer */ X break; X case 'p': /* pause -- can restart */ X t_reset('p'); X break; X case 's': /* stop */ X t_reset('s'); X return -1; X case 'r': /* resolution assumed when prepared */ X fscanf(fp, "%d", &res); X break; X case 'f': /* font used */ X fscanf(fp, "%d %s", &n, str); X (void) fgets(buf, sizeof buf, fp); /* in case of filename */ X ungetc(EOL, fp); /* fgets goes too far */ X str1[0] = 0; /* in case nothing comes in */ X (void) sscanf(buf, "%s", str1); X loadfont(n, str, str1); X break; X case 'H': /* char height */ X fscanf(fp, "%d", &n); X t_charht(n); X break; X case 'S': /* slant */ X fscanf(fp, "%d", &n); X t_slant(n); X break; X case 'T': /* device name */ X buf[0]= EOS; X fscanf(fp, "%s", buf); X if (buf[0] != EOS) X devname= strdup(buf); X break; X X } X while ((c = getc(fp)) != EOL) { /* skip rest of input line */ X if (c == EOF) X return -1; X } X return 0; X} END_OF_FILE if test 4648 -ne `wc -c <'Appls/dpv/dpvparse.c'`; then echo shar: \"'Appls/dpv/dpvparse.c'\" unpacked with wrong size! fi # end of 'Appls/dpv/dpvparse.c' fi if test -f 'Appls/dpv/dpvrestart.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'Appls/dpv/dpvrestart.c'\" else echo shar: Extracting \"'Appls/dpv/dpvrestart.c'\" \(4228 characters\) sed "s/^X//" >'Appls/dpv/dpvrestart.c' <<'END_OF_FILE' X/* dpv -- ditroff previewer. Functions to restart anywhere in the file. */ X X#include "dpv.h" X#include "dpvmachine.h" X#include "dpvoutput.h" X Xtypedef struct _restartinfo { X long filepos; /* File position for fseek */ X int pageno; /* External page number */ X fontinfo fonts; /* Mounted font table */ X int font, size; /* Current font and size */ X} restartinfo; X Xint npages; /* Number of pages so far */ Xbool nomore; /* Set when the last page has been seen */ Xrestartinfo *pagelist; /* State needed to start each page */ Xint ipage; /* Internal page in file */ Xint showpage; /* Internal page displayed in window */ Xint prevpage; /* Last page visited (for '-' command) */ Xint stoppage; /* Internal page where to stop */ XFILE *ifile; /* The input file */ X X /* In order to avoid passing the file pointer around from X parse() via t_page() to nextpage(), the input file is X made available as a global variable. */ X X/* Initialize everything in the right order. Tricky! */ X Xinitialize(filename, firstpage) X char *filename; X int firstpage; X{ X ifile= fopen(filename, "r"); X if (ifile == NULL) X error(ABORT, "%s: cannot open", filename); X setpageinfo(ftell(ifile), 0); /* Page 0 (== header) starts here */ X X showpage= -1; /* Show no pages */ X stoppage= 1; /* Stop at beginning of page 1 */ X parse(ifile); /* Read the header */ X X initoutput(filename); /* Create the window */ X X showpage= 1; X skiptopage(firstpage); X} X X/* Close the file */ X Xcleanup() X{ X fclose(ifile); X} X X/* Skip n pages forward, default 1 */ X Xforwpage(n) X int n; X{ X if (n <= 0) X n= 1; X gotopage(showpage+n); X} X X/* Skip n pages back, default 1 */ X Xbackpage(n) X int n; X{ X if (n <= 0) X n= 1; X gotopage(showpage-n); X} X X/* Go to internal page number n, and force a redraw */ X Xgotopage(n) X int n; X{ X int saveshowpage= showpage; X skiptopage(n); X if (showpage != saveshowpage) X prevpage= saveshowpage; X changeall(); X} X X/* Skip to internal page number n -- don't force a redraw */ X Xstatic Xskiptopage(n) X int n; X{ X int orign= n; X if (n <= 0) X n= 1; X if (n == showpage) { X if (orign < n) X wfleep(); X return; X } X if (n >= npages) { X if (nomore) { X n= npages-1; X if (n == showpage) { X wfleep(); X return; X } X showpage= n; X } X else { X backtopage(npages-1); X showpage= -1; X stoppage= n; X parse(ifile); X showpage= npages-1; X } X } X else X showpage= n; X} X X/* Draw procedure */ X Xvoid Xdrawproc(drawwin, left, top, right, bottom) X WINDOW *drawwin; X int left, top, right, bottom; X{ X topdraw= top; X botdraw= bottom; X backtopage(showpage); X stoppage= showpage+1; X parse(ifile); X} X X/* Record the current file position as the start of the page X with (external) page number 'pageno'. X Note that the 'p' command has already been consumed by the parser. X Return < 0 if the parser can stop parsing. */ X Xint Xnextpage(pageno) X int pageno; X{ X ++ipage; X setpageinfo(ftell(ifile), pageno); X if (ipage >= stoppage) X return -1; /* Stop parsing */ X else X return 0; X} X X/* Indicate that the end of the input has been reached. X No more new pages will be accepted. */ X Xlastpage() X{ X nomore= TRUE; X} X X/* Store info about coming page. X Called at start of file and after 'p' command processed */ X Xstatic Xsetpageinfo(filepos, pageno) X long filepos; X int pageno; X{ X if (statep != state) X error(FATAL, "setpageinfo: {} stack not empty"); X if (ipage < npages) { X /* We've been here already. X Might as well check consistency. */ X /* HIRO */ X } X else if (ipage > npages) X error(ABORT, "setpageinfo: ipage>npages (can't happen)"); X else { X restartinfo r; X r.filepos= filepos; X r.pageno= pageno; X r.fonts= fonts; X r.font= font; X r.size= size; X L_APPEND(npages, pagelist, restartinfo, r); X if (pagelist == NULL) X error(FATAL, "out of mem for pagelist"); X } X} X X/* Position the input stream at the start of internal page i X and restore the machine state to the state remembered for that page */ X Xstatic Xbacktopage(i) X int i; X{ X restartinfo *p; X X if (i < 0 || i >= npages) X error(ABORT, "backtopage: called with wrong arg"); X p= &pagelist[i]; X if (fseek(ifile, p->filepos, 0) < 0) X error(FATAL, "backtopage: can't fseek"); X ipage= i; X fonts= p->fonts; X font= p->font; X size= p->size; X hpos= 0; X vpos= 0; X statep= state; X usefont(); X} END_OF_FILE if test 4228 -ne `wc -c <'Appls/dpv/dpvrestart.c'`; then echo shar: \"'Appls/dpv/dpvrestart.c'\" unpacked with wrong size! fi # end of 'Appls/dpv/dpvrestart.c' fi if test -f 'Appls/test/magic.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'Appls/test/magic.c'\" else echo shar: Extracting \"'Appls/test/magic.c'\" \(4520 characters\) sed "s/^X//" >'Appls/test/magic.c' <<'END_OF_FILE' X/* Magic -- tool to help editing magic squares */ X X#include "stdwin.h" X X/* Arbitrary limitations */ X#define MAXSIZE 25 X#define DEFSIZE 5 X#define FARAWAY 10000 X X/* Defining data */ Xint size; Xchar sq[MAXSIZE][MAXSIZE]; X X/* Derived data */ Xint rowsum[MAXSIZE]; Xint colsum[MAXSIZE]; Xint diagsum, secdiagsum; Xint ok; X X/* Input parameters */ Xint last; X X/* Output parameters */ XWINDOW *win; Xint origleft, origtop; Xint rowheight, colwidth; X Xevaluate() X{ X int row, col; X int sum; X X diagsum = 0; X secdiagsum = 0; X for (row = 0; row < size; ++row) { X diagsum += sq[row][row]; X secdiagsum += sq[row][size-1-row]; X } X X ok = (diagsum == secdiagsum) && (diagsum > 0); X X for (row = 0; row < size; ++row) { X sum = 0; X for (col = 0; col < size; ++col) X sum += sq[row][col]; X rowsum[row] = sum; X if (ok) X ok = (sum == diagsum); X } X X for (col = 0; col < size; ++col) { X sum = 0; X for (row = 0; row < size; ++row) X sum += sq[row][col]; X colsum[col] = sum; X if (ok) X ok = (sum == diagsum); X } X} X Xcenter(h, v, n) X int h, v; X int n; X{ X char buf[25]; X int width; X X if (n == 0) X return; X sprintf(buf, "%d", n); X width = wtextwidth(buf, -1); X wdrawtext(h + (colwidth - width)/2, v + wlineheight()/2, buf, -1); X} X Xvoid Xdrawproc(win, left, top, right, bottom) X WINDOW *win; X{ X int h, v; X int row, col; X X v = origtop; X for (row = 0; row < size; ++row) { X h = origleft; X wdrawline(h, v, h+size*colwidth, v); X for (col = 0; col < size; ++col) { X center(h, v, sq[row][col]); X h += colwidth; X } X center(h+3, v, rowsum[row]); X v += rowheight; X } X wdrawline(origleft, v, origleft + size*colwidth, v); X X center(origleft - colwidth, v, secdiagsum); X X h = origleft; X for (col = 0; col < size; ++col) { X wdrawline(h, origtop, h, v); X center(h, v, colsum[col]); X h += colwidth; X } X wdrawline(h, origtop, h, v); X X center(h+3, v, diagsum); X X wdrawbox(origleft-1, origtop-1, h+2, v+2); X X if (last > 0 && ok) X wdrawbox(origleft-3, origtop-3, h+4, v+4); X} X Xreset(newsize) X int newsize; X{ X int row, col; X char buf[100]; X X size = newsize; X for (row = 0; row < size; ++row) X for (col = 0; col < size; ++col) X sq[row][col] = 0; X X evaluate(); X X last = 0; X X sprintf(buf, "%dx%d Magic Square", size, size); X wsettitle(win, buf); X X wsetdocsize(win, X origleft + (size+1)*colwidth + 3, X origtop + (size+1)*rowheight); X X wchange(win, 0, 0, FARAWAY, FARAWAY); X} X Xinit() X{ X colwidth = wtextwidth(" 000 ", -1); X rowheight = wlineheight() * 2; X origleft = colwidth; X origtop = rowheight; X} X Xclick(h, v) X int h, v; X{ X int row, col; X int oldok; X X if (last >= size*size) { X wfleep(); X return; X } X X if (h < origleft || v < origtop) X return; X X col = (h - origleft) / colwidth; X row = (v - origtop) / rowheight; X if (row >= size || col >= size) X return; X X if (sq[row][col] != 0) { X wfleep(); X return; X } X X sq[row][col] = ++last; X X oldok = ok; X evaluate(); X if (ok != oldok) X wchange(win, 0, 0, FARAWAY, FARAWAY); X else X change(row, col); X} X Xchange(row, col) X int row, col; X{ X wchange(win, X origleft + col*colwidth + 1, origtop + row*rowheight + 1, X origleft + (col+1)*colwidth, origtop + (row+1)*rowheight); X wchange(win, 0, origtop + size*rowheight + 2, FARAWAY, FARAWAY); X wchange(win, origleft + size*colwidth + 2, 0, FARAWAY, FARAWAY); X} X Xundo() X{ X int row, col; X int oldok; X X if (last == 0) { X wfleep(); X return; X } X X for (row = 0; row < size; ++row) { X for (col = 0; col < size; ++col) { X if (sq[row][col] == last) { X sq[row][col] = 0; X --last; X oldok = ok; X evaluate(); X if (ok != oldok) X wchange(win, 0, 0, FARAWAY, FARAWAY); X else X change(row, col); X return; X } X } X } X /* Shouldn't get here */ X wfleep(); wfleep(); X} X Xmain(argc, argv) X int argc; X char **argv; X{ X EVENT e; X X winitargs(&argc, &argv); X init(); X wsetdefwinsize(origleft + (DEFSIZE+2)*colwidth, X origtop + (DEFSIZE+2)*rowheight); X win = wopen("Magic Square", drawproc); X reset(DEFSIZE); X X for (;;) { X wgetevent(&e); X switch (e.type) { X case WE_MOUSE_UP: X click(e.u.where.h, e.u.where.v); X break; X case WE_COMMAND: X switch (e.u.command) { X case WC_CLOSE: X wdone(); X exit(0); X case WC_CANCEL: X reset(size); X break; X case WC_BACKSPACE: X undo(); X break; X } X break; X case WE_CLOSE: X wdone(); X exit(0); X case WE_CHAR: X if (e.u.character >= '1' && e.u.character <= '9') X reset(e.u.character - '0'); X else if (e.u.character == '0') X reset(size); X else if (e.u.character == 'q') { X wdone(); X exit(0); X } X else X wfleep(); X break; X } X } X} END_OF_FILE if test 4520 -ne `wc -c <'Appls/test/magic.c'`; then echo shar: \"'Appls/test/magic.c'\" unpacked with wrong size! fi # end of 'Appls/test/magic.c' fi if test -f 'Appls/test/sevenseg.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'Appls/test/sevenseg.h'\" else echo shar: Extracting \"'Appls/test/sevenseg.h'\" \(605 characters\) sed "s/^X//" >'Appls/test/sevenseg.h' <<'END_OF_FILE' X/* 7-segment digit definitions */ X X#define __ <<1) | 1) X#define _ <<1) | 0) X#define I __ X#define i _ X#define AA ((((((((((((((0 X Xshort sevenseg[10]= { X XAA __ X I I X _ X I I X __ , /* 0 */ X XAA _ X i I X _ X i I X _ , /* 1 */ X XAA __ X i I X __ X I i X __ , /* 2 */ X XAA __ X i I X __ X i I X __ , /* 3 */ X XAA _ X I I X __ X i I X _ , /* 4 */ X XAA __ X I i X __ X i I X __ , /* 5 */ X XAA __ X I i X __ X I I X __ , /* 6 */ X XAA __ X i I X _ X i I X _ , /* 7 */ X XAA __ X I I X __ X I I X __ , /* 8 */ X XAA __ X I I X __ X i I X __ /* 9 */ X X}; X X#undef __ X#undef _ X#undef I X#undef i X#undef AA END_OF_FILE if test 605 -ne `wc -c <'Appls/test/sevenseg.h'`; then echo shar: \"'Appls/test/sevenseg.h'\" unpacked with wrong size! fi # end of 'Appls/test/sevenseg.h' fi if test -f 'H/vt.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'H/vt.h'\" else echo shar: Extracting \"'H/vt.h'\" \(5019 characters\) sed "s/^X//" >'H/vt.h' <<'END_OF_FILE' X/* Interface for VT (Virtual Terminal windows) package */ X X/* WARNING: the cursor coordinate system is (row, col) here, X like in the ANSI escape sequences. X However, the origin is 0, and ranges are given in C style: X first, last+1. X ANSI escapes (which have origin 1) are translated as soon X as they are parsed. */ X X#define VTNARGS 10 /* Max # args in ansi escape sequence */ X X/* Structure describing a VT window */ X Xtypedef struct _vt { X WINDOW *win; /* Window used for display */ X char **data; /* Character data array [row][col] */ X unsigned char **flags; /* Corresponding flags per character */ X short *llen; /* Line length array */ X short rows, cols; /* Size of data matrix */ X short cwidth, cheight; /* Character cell size */ X short cur_row, cur_col; /* Cursor position */ X short save_row, save_col; /* Saved cursor position */ X short scr_top, scr_bot; /* Scrolling region */ X short topterm; /* Top line of emulated terminal */ X short toscroll; /* Delayed screen scrolling */ X unsigned char gflags; /* Global flags for inserted characters */ X X /* XXX The following Booleans are stored in characters. X This is probably the most efficient way to store them. X Since we normally have only one VT window per application, X space considerations are not important and we could even use X ints if they were faster. */ X X char insert; /* Insert mode */ X char keypadmode; /* Send ESC O A for arrows, not ESC [ A */ X char nlcr; /* \n implies \r */ X char lazy; /* Delay output operations */ X char mitmouse; /* Send ESC [ M <button;col;row> on clicks */ X char visualbell; /* Blink instead of beep (for ctrl-G) */ X char flagschanged; /* Set when certain state flags changed */ X char drawing; /* Used by VT{BEGIN,END}DRAWING() macros */ X X /* State for the ANSI escape sequence interpreter */ X X char modarg; /* \0: ansi vt100; '?': DEC private mode etc */ X char *(*action)(); /* Function to call for next input */ X short *nextarg; /* Points to current arg */ X short args[VTNARGS]; /* Argument list */ X X /* State for the selected region */ X X short sel_row1, sel_col1; /* Start of selected region, <0 if nothing */ X short sel_row2, sel_col2; /* End of selected region */ X X /* XXX There ought to be an array of tab stops somewhere... */ X} VT; X X/* Flags in gflags and flags array. X These correspond to the ANSI codes used in ESC [ ... m. X Not all are implemented! */ X X#define VT_BOLD (1 << 1) X#define VT_DIM (1 << 2) X#define VT_UNDERLINE (1 << 4) X#define VT_BLINK (1 << 5) X#define VT_INVERSE (1 << 7) X#define VT_SELECTED (1 << 3) /* <- This one does NOT correspond */ X X/* Access macros */ X X#define vtcheight(vt) ((vt)->cheight) X#define vtcwidth(vt) ((vt)->cwidth) X#define vtwindow(vt) ((vt)->win) X X#define vtsetnlcr(vt, new_nlcr) ((vt)->nlcr = (new_nlcr)) X#define vtsetlazy(vt, new_lazy) ((vt)->lazy= (new_lazy)) X#define vtsetflags(vt, new_flags) ((vt)->gflags= (new_flags)) X#define vtsetinsert(vt, new_insert) ((vt)->insert= (new_insert)) X X/* Basic functions (vt.c) */ X XVT *vtopen _ARGS((char *title, int rows, int cols, int save)); Xvoid vtclose _ARGS((VT *vt)); Xvoid vtputstring _ARGS((VT *vt, char *text, int len)); Xvoid vtsetcursor _ARGS((VT *vt, int row, int col)); Xvoid vtreset _ARGS((VT *vt)); XVT *vtfind _ARGS((WINDOW *win)); X X/* Optional functions (vtansi.c, vtputs.c, vtresize.c) */ X Xvoid vtansiputs _ARGS((VT *vt, char *text, int len)); Xvoid vtputs _ARGS((VT *vt, char *text)); X/*bool*/int vtresize _ARGS((VT *vt, int rows, int cols, int save)); X/*bool*/int vtautosize _ARGS((VT *vt)); X X/* Functions used by the ANSI interface (vtfunc.c) */ X Xvoid vtresetattr _ARGS((VT *vt)); Xvoid vtsetattr _ARGS((VT *vt, int bit)); Xvoid vtsavecursor _ARGS((VT *vt)); Xvoid vtrestorecursor _ARGS((VT *vt)); Xvoid vtarrow _ARGS((VT *vt, int code, int repeat)); Xvoid vteolclear _ARGS((VT *vt, int row, int col)); Xvoid vteosclear _ARGS((VT *vt, int row, int col)); Xvoid vtlinefeed _ARGS((VT *vt, int repeat)); Xvoid vtrevlinefeed _ARGS((VT *vt, int repeat)); Xvoid vtinslines _ARGS((VT *vt, int n)); Xvoid vtdellines _ARGS((VT *vt, int n)); Xvoid vtscrollup _ARGS((VT *vt, int r1, int r2, int n)); Xvoid vtscrolldown _ARGS((VT *vt, int r1, int r2, int n)); Xvoid vtinschars _ARGS((VT *vt, int n)); Xvoid vtdelchars _ARGS((VT *vt, int n)); Xvoid vtsetscroll _ARGS((VT *vt, int top, int bot)); Xvoid vtsendid _ARGS((VT *vt)); Xvoid vtsendpos _ARGS((VT *vt)); X X/* Selection interface (vtselect.c) */ X X/* XXX This will change */ Xint vtselect _ARGS((VT *vt, EVENT *ep)); Xint vtextendselection _ARGS((VT *vt, EVENT *ep)); X X/* Macros to avoid too many wbegindrawing calls */ X X#define VTBEGINDRAWING(vt) \ X if (!(vt)->drawing) { wbegindrawing((vt)->win); (vt)->drawing= 1; } X#define VTENDDRAWING(vt) \ X if ((vt)->drawing) { wenddrawing((vt)->win); (vt)->drawing = 0; } X X/* Note -- the main application *MUST* call VTENDDRAWING(vt) before X it calls wgetevent(). */ X X#ifndef NDEBUG X X/* Panic function. The caller may provide one. The library has a default. */ X Xvoid vtpanic _ARGS((char *)); X X#endif /* NDEBUG */ END_OF_FILE if test 5019 -ne `wc -c <'H/vt.h'`; then echo shar: \"'H/vt.h'\" unpacked with wrong size! fi # end of 'H/vt.h' fi if test -f 'Packs/vt/vtfunc.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'Packs/vt/vtfunc.c'\" else echo shar: Extracting \"'Packs/vt/vtfunc.c'\" \(4558 characters\) sed "s/^X//" >'Packs/vt/vtfunc.c' <<'END_OF_FILE' X/* Functions implementing ANSI operations */ X X#include "vtimpl.h" X X/* Linefeed */ X Xvoid Xvtlinefeed(vt, n) X VT *vt; X int n; X{ X while (--n >= 0) { X if (vt->cur_row == vt->scr_bot - 1) { X int scr_top = vt->scr_top; X if (scr_top == vt->topterm) X scr_top = 0; X vtscrollup(vt, scr_top, vt->scr_bot, 1); X } X else X vtsetcursor(vt, vt->cur_row + 1, vt->cur_col); X } X} X X/* Reverse linefeed */ X Xvoid Xvtrevlinefeed(vt, n) X VT *vt; X int n; X{ X while (--n >= 0) { X if (vt->cur_row == vt->scr_top) X vtscrolldown(vt, vt->scr_top, vt->scr_bot, 1); X else X vtsetcursor(vt, vt->cur_row - 1, vt->cur_col); X } X} X X/* Reset underline, inverse video attributes */ X Xvoid Xvtresetattr(vt) X VT *vt; X{ X vtsetflags(vt, 0); X} X X/* Set attribute flag (without clearing the others) */ X Xvoid Xvtsetattr(vt, bit) X VT *vt; X int bit; X{ X vtsetflags(vt, vt->gflags | (1 << bit)); X} X X/* Save cursor position */ X Xvoid Xvtsavecursor(vt) X VT *vt; X{ X vt->save_row = vt->cur_row; X vt->save_col = vt->cur_col; X} X X/* Restore cursor position */ X Xvoid Xvtrestorecursor(vt) X VT *vt; X{ X vtsetcursor(vt, vt->save_row, vt->save_col); X} X X/* Process an arrow key (possibly repeated) */ X Xvoid Xvtarrow(vt, code, repeat) X VT *vt; X int code; X int repeat; X{ X int row = vt->cur_row; X int col = vt->cur_col; X int minrow = 0, maxrow = vt->rows; X X CLIPMAX(col, vt->cols-1); X switch (code) { X case WC_LEFT: X col -= repeat; X break; X case WC_RIGHT: X col += repeat; X break; X case WC_UP: X row -= repeat; X break; X case WC_DOWN: X row += repeat; X break; X } X CLIPMAX(col, vt->cols-1); X CLIPMIN(col, 0); X if (vt->cur_row >= vt->scr_top) X minrow = vt->scr_top; X if (vt->cur_row < vt->scr_bot) X maxrow = vt->scr_bot; X CLIPMIN(row, minrow); X CLIPMAX(row, maxrow-1); X vtsetcursor(vt, row, col); X} X X/* Clear to end of line */ X Xvoid Xvteolclear(vt, row, col) X VT *vt; X int row, col; X{ X if (row < vt->rows) { X if (vt->llen[row] > col) { X if (vt->lazy) X vtchange(vt, row, col, row + 1, vt->llen[row]); X else { X VTBEGINDRAWING(vt); X werase(col*vt->cwidth, row*vt->cheight, X vt->llen[row]*vt->cwidth, X (row+1)*vt->cheight); X } X vt->llen[row] = col; X } X } X} X X/* Clear to end of screen */ X Xvoid Xvteosclear(vt, row, col) X VT *vt; X int row, col; X{ X vteolclear(vt, row, col); X if (vt->lazy) X vtchange(vt, row + 1, 0, vt->rows, vt->cols); X else { X VTBEGINDRAWING(vt); X werase(0, (row + 1) * vt->cheight, X vt->cols * vt->cwidth, vt->rows * vt->cheight); X } X for (row = row + 1; row < vt->rows; ++row) X vt->llen[row] = 0; X} X X/* Delete n lines */ X Xvoid Xvtdellines(vt, n) X VT *vt; X int n; X{ X vtscrollup(vt, vt->cur_row, vt->scr_bot, n); X} X X/* Insert n lines */ X Xvoid Xvtinslines(vt, n) X VT *vt; X int n; X{ X vtscrolldown(vt, vt->cur_row, vt->scr_bot, n); X} X X/* Scroll a range of lines n positions up */ X Xvoid Xvtscrollup(vt, r1, r2, n) X VT *vt; X int r1, r2; X int n; X{ X if (n > 0 && r1 < r2) { X int i; X vtcirculate(vt, r1, r2, -n); X /* Clear lines at bottom of scrolling screenpart */ X for (i = r2 - n; i < r2; ++i) X vt->llen[i] = 0; X vtscroll(vt, r1, 0, r2, vt->cols, -n, 0); X } X} X X X/* Scroll a range of lines n positions down */ X Xvoid Xvtscrolldown(vt, r1, r2, n) X VT *vt; X int r1, r2; X int n; X{ X if (n > 0 && r1 < r2) { X int i; X vtcirculate(vt, r1, r2, n); X for (i = r1 + n; --i >= r1; ) X vt->llen[i] = 0; X vtscroll(vt, r1, 0, r2, vt->cols, n, 0); X } X} X X/* Insert n characters */ X Xvoid Xvtinschars(vt, n) X VT *vt; X int n; X{ X int row; X X if (n > 0 && (row= vt->cur_row) < vt->rows) { X int col = vt->cur_col; X int len = vt->llen[row]; X if (len > col) { X if (col+n >= vt->cols) { X vtchange(vt, row, col, row+1, len); X vt->llen[row] = col; X } X else { X register int i; X char *data = vt->data[row]; X unsigned char *flags = vt->flags[row]; X len += n; X if (len > vt->cols) X len = vt->cols; X for (i = len-n; --i >= col; ) X data[i+n] = data[i]; X vtscroll(vt, row, col, row+1, len, 0, n); X vt->llen[row] = len; X /* Clear the inserted stretch */ X for (i = col+n; --i >= col; ) { X data[i] = ' '; X flags[i] = 0; X } X } X } X } X} X X/* Delete n characters */ X Xvoid Xvtdelchars(vt, n) X VT *vt; X int n; X{ X int row; X X if (n > 0 && (row = vt->cur_row) < vt->rows) { X int col = vt->cur_col; X int len = vt->llen[row]; X if (len > col) { X if (len <= col+n) { X vtchange(vt, row, col, row+1, len); X vt->llen[row] = col; X } X else { X register int i; X char *data = vt->data[row]; X for (i = col+n; i < len; ++i) X data[i-n] = data[i]; X vtscroll(vt, row, col, row+1, len, 0, -n); X vt->llen[row] -= n; X } X } X } X} END_OF_FILE if test 4558 -ne `wc -c <'Packs/vt/vtfunc.c'`; then echo shar: \"'Packs/vt/vtfunc.c'\" unpacked with wrong size! fi # end of 'Packs/vt/vtfunc.c' fi if test -f 'Ports/alfa/timer.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'Ports/alfa/timer.c'\" else echo shar: Extracting \"'Ports/alfa/timer.c'\" \(4449 characters\) sed "s/^X//" >'Ports/alfa/timer.c' <<'END_OF_FILE' X/* TERMCAP STDWIN -- Alarm timers (BSD-specific) */ X X#include "alfa.h" X X#include <errno.h> X#include <sys/time.h> X X#ifdef AMOEBA X#define select(a, b, c, d, e) (-1) /* XXX just to get it to link... */ X#endif X X/* Alarm timer values must be stored as absolute times, X but since they are in tenths of a second and stored in a long, X there isn't enough space to store the true absolute time. X Therefore, they are stored relative to the second when the X first call to wsettimer was made, which is saved in torigin */ X Xstatic long torigin; /* Seconds */ Xstatic long nexttimer; /* Deciseconds */ X X/* Return the window with the first timer to go off, if any, NULL otherwise */ X Xstatic WINDOW * Xgetnexttimer() X{ X WINDOW *win; X WINDOW *cand= NULL; X X for (win= &winlist[0]; win < &winlist[MAXWINDOWS]; ++win) { X if (win->open) { X long t= win->timer; X if (t != 0) { X if (cand == NULL || t < cand->timer) X cand= win; X } X } X } X return cand; X} X X/* Compute a new value for nexttimer. X Return the relevant window as a convenience. */ X Xstatic WINDOW * Xsetnexttimer() X{ X WINDOW *win= getnexttimer(); X X if (win == NULL) X nexttimer= 0; X else X nexttimer= win->timer; X return win; X} X X/* Set the alarm timer for a given window */ X Xvoid Xwsettimer(win, deciseconds) X WINDOW *win; X int deciseconds; X{ X win->timer= 0; X if (deciseconds > 0) { X struct timeval tv; X struct timezone tz; X X if (gettimeofday(&tv, &tz) >= 0) { X if (torigin == 0) { X torigin= tv.tv_sec; X } X win->timer= deciseconds + 10 * (tv.tv_sec - torigin) + X tv.tv_usec/100000; X } X } X (void) setnexttimer(); X} X X/* Return a pointer suitable as timeout parameter for BSD select(2). X If no alarms are currently set, return a NULL pointer. */ X Xstatic struct timeval * Xtimeout() X{ X if (nexttimer == 0) { X return NULL; X } X else { X static struct timeval tv; X struct timezone tz; X X if (gettimeofday(&tv, &tz) < 0) { X return NULL; X } X else { X long tout; X tout= nexttimer X - (tv.tv_sec - torigin) * 10 X - tv.tv_usec / 100000; X if (tout <= 0) X tv.tv_sec= tv.tv_usec= 0; X else { X tv.tv_sec= tout / 10; X tv.tv_usec= (tout % 10) * 100000; X } X return &tv; X } X } X} X X/* Check if an alarm has gone off, and if so, generate an appropriate event. X This can be called at any time, but for efficiency reasons it should X only be called when an alarm has actually gone of (i.e., select has X timed out). If an alarm has gone off, it will always be found by X this function. */ X Xstatic bool Xdotimer(ep) X EVENT *ep; X{ X WINDOW *win= setnexttimer(); X struct timeval *tp; X X if (win == NULL) { X /* no event found (spurious call) */ X return FALSE; X } X tp= timeout(); X if (tp == NULL) { X /* unexpected NULL timeout() */ X return FALSE; X } X if (tp->tv_sec == 0 && tp->tv_usec == 0) { X /* report timer event */ X ep->type= WE_TIMER; X ep->window= win; X win->timer= 0; X (void) setnexttimer(); X return TRUE; X } X else { X /* it is not yet time */ X return FALSE; X } X} X X/* Check for timer events. X Call this after trmavail() returns 0, just before calling trminput() */ X Xbool X_w_checktimer(ep, mayblock) X EVENT *ep; X bool mayblock; X{ X for (;;) { X struct timeval *tp= timeout(); X /* This is naive. BSD 4.3 really uses arrays of longs X as arguments to select. Fortunately, stdin is fd 0. */ X unsigned long rd, wd, xd; X int fd, nfd; X int nfound; X if (!mayblock) { X return tp != NULL && X tp->tv_sec == 0 && tp->tv_usec == 0 && X dotimer(ep); X } X fd= 0; /* stdin */ X rd= 1 << fd; X nfd= fd+1; X wd= xd= 0; X errno= 0; X nfound= select(nfd, &rd, &wd, &xd, tp); X /* Note: if select returns negative, we also break X out of the loop -- better drop a timer event than X loop forever on a select error. X The only exception is EINTR, which may have been caused X by an application's signal handler */ X if (nfound < 0) { X if (errno == EINTR) { X continue; X } X } X if (nfound != 0) X break; X if (dotimer(ep)) X return TRUE; X } X return FALSE; X} X X/* P.S.: It is not necessary to recompute nextalarm when windows are X deleted. This can at most cause a spurious time-out, after which X dotimeout() is called again which recomputes nextalarm as a side X effect (twice, even). Applications incur a slight overhead if they X delete a window with a timer set and no other windows have timers X set; in this case a larger part of the timeout code is called until X the alarm goes off (which is then ignored!). */ END_OF_FILE if test 4449 -ne `wc -c <'Ports/alfa/timer.c'`; then echo shar: \"'Ports/alfa/timer.c'\" unpacked with wrong size! fi # end of 'Ports/alfa/timer.c' fi if test -f 'Ports/vtrm/uxtty.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'Ports/vtrm/uxtty.c'\" else echo shar: Extracting \"'Ports/vtrm/uxtty.c'\" \(4997 characters\) sed "s/^X//" >'Ports/vtrm/uxtty.c' <<'END_OF_FILE' X/* VTRM -- unix-dependent tty twiddling. */ X X#ifdef SYSV X#define TERMIO X#endif X X#include <stdio.h> X#ifndef TERMIO X#include <sgtty.h> X#else X#include <termio.h> X#endif TERMIO X#include <sys/types.h> X#include <signal.h> X X#include "vtrm.h" X#include "sigtype.h" /* Defines SIGTYPE as int or void */ X Xtypedef char *string; Xtypedef int bool; X#define Yes 1 X#define No 0 X Xextern short ospeed; /* Defined in vtrm.c, used by termcap's tgoto/tputs. */ X X/* tty modes */ X#ifndef TERMIO X X/* v7/BSD tty control */ Xstatic struct sgttyb oldtty, newtty; X#ifdef TIOCSETN X/* Redefine stty to uses TIOCSETN, so type-ahead is not flushed */ X#define stty(fd, bp) ioctl(fd, TIOCSETN, (char *) bp) X#endif X X#ifdef TIOCSLTC /* BSD -- local special chars, must all be turned off */ Xstatic struct ltchars oldltchars; Xstatic struct ltchars newltchars= {-1, -1, -1, -1, -1, -1}; X#endif TIOCSLTC X X#ifdef TIOCSETC /* V7 -- standard special chars, some must be turned off too */ Xstatic struct tchars oldtchars; Xstatic struct tchars newtchars; X#endif TIOCSETC X X#else TERMIO X X/* AT&T tty control */ Xstatic struct termio oldtty, newtty; X#define gtty(fd,bp) ioctl(fd, TCGETA, (char *) bp) X#define stty(fd,bp) ioctl(fd, TCSETAW, (char *) bp) X X#endif TERMIO X Xstatic bool know_ttys = No; X Xint Xsetttymode() X{ X if (!know_ttys) { X if (gtty(0, &oldtty) != 0 || gtty(0, &newtty) != 0) X return TE_NOTTY; X#ifndef TERMIO X ospeed = oldtty.sg_ospeed; X#ifdef PWB X newtty.sg_flags = (newtty.sg_flags & ~ECHO & ~CRMOD & ~XTABS) X | RAW; X#else PWB X newtty.sg_flags = (newtty.sg_flags & ~ECHO & ~CRMOD & ~XTABS) X | CBREAK; X#endif PWB X#ifdef TIOCSLTC X ioctl(0, TIOCGLTC, (char *) &oldltchars); X#endif X#ifdef TIOCSETC X ioctl(0, TIOCGETC, (char *) &oldtchars); X#endif X X#else TERMIO X /* ospeed= oldtty.c_lflag & CBAUD; /* BOGUS */ X newtty.c_iflag &= ~ICRNL; /* No CR->NL mapping on input */ X newtty.c_oflag &= ~ONLCR; /* NL doesn't output CR */ X newtty.c_lflag &= ~(ICANON|ECHO|ISIG); X /* No line editing, no echo, no signals */ X newtty.c_cc[VMIN]= 3; /* wait for 3 characters */ X newtty.c_cc[VTIME]= 1; /* or 0.1 sec. */ X#endif TERMIO X know_ttys = Yes; X } X stty(0, &newtty); X#ifndef TERMIO X#ifdef TIOCSLTC X ioctl(0, TIOCSLTC, (char *) &newltchars); X#endif TIOCSLTC X#ifdef TIOCSETC X ioctl(0, TIOCGETC, (char *) &newtchars); X newtchars.t_intrc= -1; X#ifdef NDEBUG X newtchars.t_quitc= -1; X#endif X newtchars.t_eofc= -1; X newtchars.t_brkc= -1; X ioctl(0, TIOCSETC, (char *) &newtchars); X#endif TIOCSETC X#endif TERMIO X return TE_OK; X} X Xresetttymode() X{ X if (know_ttys) { X stty(0, &oldtty); X#ifndef TERMIO X#ifdef TIOCSLTC X ioctl(0, TIOCSLTC, (char *) &oldltchars); X#endif TIOCSLTC X#ifdef TIOCSETC X ioctl(0, TIOCSETC, (char *) &oldtchars); X#endif TIOCSETC X#endif TERMIO X know_ttys= No; X } X} X X X/* X * Return the next input character, or -1 if read fails. X * Only the low 7 bits are returned, so reading in RAW mode is permissible X * (although CBREAK is preferred if implemented). X * To avoid having to peek in the input buffer for trmavail, we use the X * 'read' system call rather than getchar(). X * (The interface allows 8-bit characters to be returned, to accomodate X * larger character sets!) X */ X Xstatic int pushback= -1; X Xint Xtrminput() X{ X char c; X X if (pushback >= 0) { X c= pushback; X pushback= -1; X return c; X } X if (read(0, &c, 1) <= 0) X return -1; X return c & 0177; X} X Xtrmpushback(c) X int c; X{ X pushback= c; X} X X X/* X * See if there's input available from the keyboard. X * The code to do this is dependent on the type of Unix you have X * (BSD, System V, ...). X * Return value: 0 -- no input; 1 -- input; -1 -- unimplementable. X * Note that each implementation form should first check pushback. X * X * TO DO: X * - Implement it for other than 4.x BSD! (notably System 5) X */ X X#ifdef SELECT X X#include <sys/time.h> X Xint Xtrmavail() X{ X int nfound, nfds, readfds; X static struct timeval timeout= {0, 0}; X X if (pushback >= 0) X return 1; X readfds= 1 << 0; X nfds= 0+1; X nfound= select(nfds, &readfds, (int*) NIL, (int*) NIL, &timeout); X return nfound > 0; X} X X#define TRMAVAIL_DEFINED X X#endif SELECT X X#if !defined(TRMAVAIL_DEFINED) && defined(FIONREAD) X Xint Xtrmavail() X{ X long n; X X if (pushback >= 0) X return 1; X if (ioctl(0, FIONREAD, (char *) &n) < 0) X return -1; X return n > 0; X} X X#define TRMAVAIL_DEFINED X X#endif FIONREAD X X#ifndef TRMAVAIL_DEFINED X Xint Xtrmavail() X{ X if (pushback >= 0) X return 1; X return -1; X} X X#endif X X X/* X * Suspend the editor. X * Should be called only after trmend and before trmstart! X */ X Xtrmsuspend() X{ X SIGTYPE (*oldsig)(); X X oldsig= signal(SIGTSTP, SIG_IGN); X if (oldsig == SIG_IGN) X return; /* Could spawn a subshell here... */ X trmend(); /* Safety net */ X (void) signal(SIGTSTP, oldsig); X kill(0, SIGSTOP); X} X X/* X * Get the true window size. X * May return 0 if unknown. X */ X Xgettruewinsize(plines, pcols) X int *plines, *pcols; X{ X#ifdef TIOCGWINSZ X struct winsize win; X X if (ioctl(0, TIOCGWINSZ, (char *) &win) == 0) { X *plines= win.ws_row; X *pcols= win.ws_col; X } X else X#endif X *plines= *pcols= 0; X} END_OF_FILE if test 4997 -ne `wc -c <'Ports/vtrm/uxtty.c'`; then echo shar: \"'Ports/vtrm/uxtty.c'\" unpacked with wrong size! fi # end of 'Ports/vtrm/uxtty.c' fi echo shar: End of archive 14 \(of 19\). cp /dev/null ark14isdone MISSING="" for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 ; do if test ! -f ark${I}isdone ; then MISSING="${MISSING} ${I}" fi done if test "${MISSING}" = "" ; then echo You have unpacked all 19 archives. rm -f ark[1-9]isdone ark[1-9][0-9]isdone else echo You still need to unpack the following archives: echo " " ${MISSING} fi ## End of shell archive. exit 0