*** atk/console/stats/rt_aos4/Imakefile Sat Jun 1 13:56:11 1991 --- atk/console/stats/rt_aos4.NEW/Imakefile Sat Jun 1 13:54:19 1991 *************** *** 0 **** --- 1,11 ---- + /* ********************************************************************** *\ + * Copyright IBM Corporation 1988,1989 - All Rights Reserved * + * For full copyright information see:'andrew/config/COPYRITE' * + \* ********************************************************************** */ + LOCALINCLUDES = -I../../lib + + DependTarget() + NormalObjectRule() + + LibraryTarget(libgs.a, getstats.o) + *** atk/console/stats/rt_aos4/getstats.c Sat Jun 1 13:56:13 1991 --- atk/console/stats/rt_aos4.NEW/getstats.c Sat Jun 1 13:54:17 1991 *************** *** 0 **** --- 1,447 ---- + /* ********************************************************************** *\ + * Copyright IBM Corporation 1988,1989 - All Rights Reserved * + * For full copyright information see:'andrew/config/COPYRITE' * + \* ********************************************************************** */ + /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/console/stats/rt_aos4/RCS/getstats.c,v 1.1 1991/05/16 17:50:33 susan Exp $ */ + /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/console/stats/rt_aos4/RCS/getstats.c,v $ */ + + #ifndef lint + static char *getstats_c_id = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/console/stats/rt_aos4/RCS/getstats.c,v 1.1 1991/05/16 17:50:33 susan Exp $"; + #endif /* lint */ + + /* ********************************************************************** + * This code is designed to read what might be priveledged (setuid) + * information regarding both Disk Statistics (% full) and a host of + * stats from /dev/kmem (including but not limited to, CPU, I/O, and VM) + * + * When retriving the data - this program will print out to stdout + * a string in the form of either "%d:%d\n" or "%d:%d:%s\n" + * The latter case is for passing the name of where a disk is mounted + * back to the parent program. + * + * The parent program (Console, or any other program which wishes to get + * at this information) is responsible for setting up a pipe, binding the + * child's (this program) stdout to one end of a pipe, and parsing the + * strings which are passed back. + * + * The basic string format is an ID (int), a colon, a value (int), and + * optionally another colon followed by a string. The ID is coded from + * the included file "getstats.h" - ID values 50 and over represent + * ERRORS as documented in the above mentioned inclued file. When an + * ERROR or the optional string is passed, the value (second parameter) + * can be safely ignored, and is usually set to 0. + * + * The arguments to be passed to this program are the effective UID from + * the parent program, a polling frequency (# of seconds) for checking + * /dev/kmem (usually between 1 and 5, must be > 0), and a polling + * frequency for checking how full the local disks are (generally higher + * than the value for /dev/kmem, but could vary greatly). Thus the call + * is: + * + * execvp("getstats", argv) + * + * with argv as: + * + * argv[0]="getstats"; + * argv[1]=~ ("%d", UID); + * argv[2]=~ ("%d", kmempollfrequency); + * argv[3]=~ ("%d", diskpollfrequency); + * argv[4]=NULL; + * + ********************************************************************** */ + #include + + #include + #include + #include + #include + #include + #include + #include + #include + #include /* search namelist in vmunix */ + #include + #include + #include + #include + #include + #include + #include + #include + + #ifndef MAXUPRC /* This is a constant in BSD, but */ + long maxuprc = 0; /* we have to nlist in Ultrix */ + #else /* MAXUPRC */ + long maxuprc = MAXUPRC; + #endif /* MAXUPRC */ + + #define VMMON_DODECL + #include + extern struct nlist RawStatistics[]; + + + struct mtab mtab[NMOUNT]; + int fi; + daddr_t alloc(); + char *strcpy(); + + char root[32]; + + int TotalTime; + int deficit; + int MemoryFile /* file descriptor for unix memory */ ; + int nproc; + int SwapMapAddress; + int nSwapMapEntries; + int SwapMapSize; + int nSwapBlks; + int CurrentSwapUsed; + int dmmax; + off_t procp; + struct mapent *SwapMap; + struct proc proc[8];/* 8 = a few, for fewer syscalls */ + struct proc *mproc; + extern char *malloc(); + + + struct{ + long time[CPUSTATES]; + long xfer[DK_NDRIVE]; + struct vmmeter Rate; + struct vmtotal Total; + long dk_xfer[DK_NDRIVE]; + }s, s1; + + union { + struct fs iu_fs; + char dummy[SBSIZE]; + } sb; + + #define rate s.Rate + #define total s.Total + #define sblock sb.iu_fs + #define sendval(text) {printf text ;fflush(stdout);} + + + + + GetGVMStats(UsersID) + int UsersID; + { + register int i; + long t; + struct mapent *sp; + lseek(MemoryFile,(long) RawStatistics[X_CPTIME].n_value, 0); + read(MemoryFile, s.time, sizeof(s.time)); + + if (RawStatistics[X_NDSTAT].n_value == 0){ + lseek(MemoryFile,(long) RawStatistics[X_DKXFER].n_value, 0); + read(MemoryFile, s.dk_xfer, sizeof(s.dk_xfer)); + } + lseek(MemoryFile,(long) RawStatistics[X_RATE].n_value, 0); + read(MemoryFile, &rate, sizeof(rate)); + sp = SwapMap; + lseek(MemoryFile, SwapMapAddress, 0); + read(MemoryFile, sp, SwapMapSize); + for (CurrentSwapUsed = nSwapBlks;sp->m_size;sp++){ + CurrentSwapUsed -= sp->m_size; + } + lseek(MemoryFile,(long) RawStatistics[X_TOTAL].n_value, 0); + read(MemoryFile, &total, sizeof(total)); + lseek(MemoryFile,(long) RawStatistics[X_DEFICIT].n_value, 0); + read(MemoryFile, &deficit, sizeof(deficit)); + for (i = 0; i < CPUSTATES; i++) { + t = s.time[i]; + s.time[i] -= s1.time[i]; + s1.time[i] = t; + } + s.time[1] += s.time[0]; + TotalTime = 0; + for (i = 1; i < CPUSTATES; i++) + TotalTime += s.time[i]; + if (TotalTime == 0) + TotalTime = 1; + sendval(("%d:%d\n", LOADCPU, (s.time[1] + s.time[2]) * 100 / TotalTime)); + { + int myval = 0; + { + register int i; + for (i = 1; i < DK_NDRIVE - 1; i++) + s.dk_xfer[0] += s.dk_xfer[i]; + } + if (s1.dk_xfer[0] == 0){ + s1.dk_xfer[0] = s.dk_xfer[0]; + } + myval = s.dk_xfer[0] - s1.dk_xfer[0]; + if (myval > 100) myval = 100; + sendval(("%d:%d\n", LOADIO, myval)); + s1.dk_xfer[0] = s.dk_xfer[0]; + } + sendval(("%d:%d\n", LOADUSER, s.time[1] * 100 / TotalTime)); + sendval(("%d:%d\n", LOADSYS, s.time[2] * 100 / TotalTime)); + sendval(("%d:%d\n", LOADIDLE, s.time[3] * 100 / TotalTime)); + sendval(("%d:%d\n", VM, nSwapBlks ? CurrentSwapUsed * 100 / nSwapBlks : -1)); + sendval(("%d:%d\n", PAGEIN, rate.v_pgpgin / 2)); + sendval(("%d:%d\n", PAGEOUT, rate.v_pgpgout / 2)); + sendval(("%d:%d\n", PAGEREPLACABLE, rate.v_scan)); + sendval(("%d:%d\n", PAGEDEFICIT, deficit)); + sendval(("%d:%d\n", MEMACTIVE, total.t_avm / 2)); + sendval(("%d:%d\n", MEMFREE, total.t_free / 2)); + sendval(("%d:%d\n", QUEUERUN, total.t_rq)); + sendval(("%d:%d\n", QUEUEBLOCK, total.t_dw + total.t_pw)); + sendval(("%d:%d\n", QUEUEMEM, total.t_sw)); + sendval(("%d:%d\n", INTSIO, rate.v_intr)); + sendval(("%d:%d\n", INTSSYS, rate.v_syscall)); + sendval(("%d:%d\n", INTSSWAP, rate.v_swtch)); + if (1) {/* DoPROCESSES */ + int i, j, userprocesses, totalprocesses, otherprocs; + off_t tmpprocp; + + userprocesses = 0; + totalprocesses = 1; + otherprocs = 0; + tmpprocp = procp; + + for (i = 0; i < nproc; i += 8) { + lseek(MemoryFile, (long) tmpprocp, 0); + j = nproc - i; + if (j > 8) + j = 8; + j *= sizeof(struct proc); + if (read(MemoryFile, (char *) proc, j) != j) { + sendval(("%d:%d\n", GVM_ERR_1, 0)); + exit(-1); + } + tmpprocp += j; + for (j = j / sizeof(struct proc) - 1; j >= 0; j--) { + mproc = &proc[j]; + if (mproc->p_pid != 0) { + totalprocesses++; + if (UsersID == mproc->p_uid) { + userprocesses ++; + } else if (mproc->p_uid) { + otherprocs++; + } + } + } + } + sendval(("%d:%d\n", PROCSUSER, maxuprc ? (userprocesses * 100) / maxuprc : -1)); + sendval(("%d:%d\n", PROCSTOTAL, nproc ? totalprocesses * 100 / nproc : -1)); + sendval(("%d:%d\n", PROCSOTHER, otherprocs)); + } + } + + + + + + InitGVMStats() + { + time_t bootime; + int code = 0; + + /* + set up Unix interface: scan name list for current system + addresses and then open a file which is the memory image + of the system. + */ + code = nlist(_SITE_VMUNIX, RawStatistics); + if (code == -1){ + sendval(("%d:%d\n", GVM_ERR_2, 0)); + exit(-1); + } + else{ + if (RawStatistics[0].n_type == 0){ + sendval(("%d:%d\n", GVM_ERR_3, 0)); + exit(-1); + } + } + MemoryFile = open(_SITE_DEV_KMEM, 0); + if (MemoryFile < 0){ + sendval(("%d:%d\n", GVM_ERR_4, 0)); + exit(-1); + } + lseek(MemoryFile,(long) RawStatistics[X_BOOTIME].n_value, 0); + read(MemoryFile, &bootime, sizeof(bootime)); + lseek(MemoryFile, (long) RawStatistics[X_PROC].n_value, 0); + read(MemoryFile,(char *) &procp, sizeof(procp)); + lseek(MemoryFile, (long) RawStatistics[X_NPROC].n_value, 0); + read(MemoryFile,(char *) &nproc, sizeof(nproc)); + #ifndef MAXUPRC + lseek(MemoryFile, (long) RawStatistics[X_MAXUPRC].n_value, 0); + read(MemoryFile,(char *) &maxuprc, sizeof(maxuprc)); + #endif /* MAXUPRC */ + lseek(MemoryFile,(long) RawStatistics[X_SWAPMAP].n_value, 0); + read(MemoryFile, &SwapMapAddress, sizeof(SwapMapAddress)); + SwapMapAddress += sizeof(struct map); + lseek(MemoryFile,(long) RawStatistics[X_NSWAPMAP].n_value, 0); + read(MemoryFile, &nSwapMapEntries, sizeof(nSwapMapEntries)); + SwapMapSize = (--nSwapMapEntries)*sizeof(struct mapent); + lseek(MemoryFile,(long) RawStatistics[X_NSWAPBLKS].n_value, 0); + read(MemoryFile, &nSwapBlks, sizeof(nSwapBlks)); + lseek(MemoryFile,(long) RawStatistics[X_DMMAX].n_value, 0); + read(MemoryFile, &dmmax, sizeof(dmmax)); + nSwapBlks -= dmmax/2; /* See vm_sw.c--initialization of swap space */ + SwapMap = (struct mapent *) malloc(SwapMapSize); + } + + + /* the DeviceTable keeps a list of all the devices (and their mounted directory file name) that we should watch */ + + extern int getmnt(); + extern struct fstab *getfsent(); + GetDiskStats(Init) + int Init; + { + int i = 0; + struct fstab *fsp; + + + i = open(_SITE_MTAB, 0); + if (i >= 0) { + (void) read(i, (char *)mtab, sizeof (mtab)); + (void) close(i); + } + sync(); + if (setfsent() == 0){ + sendval(("%d:%d\n", DISK_ERR_5, 0)); + exit(1); + } + i = DISK1 - 1; /* figuratively 0 */ + while ((fsp = getfsent()) && i < MAXGETSTATSCOUNTERS) { + i++; + if (strcmp(fsp->fs_type, FSTAB_RW) && + strcmp(fsp->fs_type, FSTAB_RO) && + strcmp(fsp->fs_type, FSTAB_RQ)) + continue; + if (root[0] == 0){ + (void) strcpy(root, fsp->fs_spec); + } + dfree1(i, fsp->fs_spec, 1, Init); + } + endfsent(); + } + + int bread(fi, bno, buf, cnt) + int fi; + daddr_t bno; + char *buf; + int cnt; + { + extern int errno; + + (void) lseek(fi, (long)(bno * DEV_BSIZE), 0); + if (read(fi, buf, cnt) != cnt) + { + /* probably a dismounted disk if errno == EIO */ + if (errno != EIO) { + sendval(("%d:%d\n", DISK_ERR_5, 0)); + } + return (0); + } + return (1); + } + + /* + * Given a name like /dev/rrp0h, returns the mounted path, like /usr. + */ + char *mpath(file) + char *file; + { + register struct mtab *mp; + + + if (eq(file, root)){ + return ("/"); + } + for (mp = mtab; mp < mtab + NMOUNT; mp++){ + if (eq(file, mp->m_dname)){ + return (mp->m_path); + } + } + return ""; + } + + eq(f1, f2) + char *f1, *f2; + { + if (strncmp(f1, "/dev/", 5) == 0) + f1 += 5; + if (strncmp(f2, "/dev/", 5) == 0) + f2 += 5; + if (!strcmp(f1, f2)) + return (1); + if (*f1 == 'r' && !strcmp(f1+1, f2)) + return (1); + if (*f2 == 'r' && !strcmp(f1, f2+1)) + return (1); + if (*f1 == 'r' && *f2 == 'r' && strcmp(f1+1, f2+1) == 0) + return (1); + return (0); + } + + int round(num) + double num; + { + int inum = (int) num; + return(((num - inum) >= 0.5) ? (inum + 1) : inum); + } + + + dfree1(id, file, infsent, Init) + int id; + char *file; + int infsent; + int Init; + { + long totalblks, availblks, free, used; + int fi; + struct stat stbuf; + struct fstab *fsp; + + if (stat(file, &stbuf) == 0 && + (stbuf.st_mode&S_IFMT) != S_IFCHR && + (stbuf.st_mode&S_IFMT) != S_IFBLK) { + if (infsent) { + sendval(("%d:%d\n", DISK_ERR_3, 0)); + return; + } + setfsent(); + while (fsp = getfsent()) { + struct stat stb; + + if (stat(fsp->fs_spec, &stb) == 0 && + stb.st_rdev == stbuf.st_dev) { + file = fsp->fs_spec; + endfsent(); + goto found; + } + } + endfsent(); + sendval(("%d:%d\n", DISK_ERR_4, 0)); + return; + } + found: + fi = open(file, 0); + if (fi < 0){ + return; + } + if (bread(fi, SBLOCK, (char *)&sblock, SBSIZE) == 0) { + (void) close(fi); + return; + } + totalblks = sblock.fs_dsize; + free = sblock.fs_cstotal.cs_nbfree * sblock.fs_frag + + sblock.fs_cstotal.cs_nffree; + used = totalblks - free; + availblks = totalblks * (100 - sblock.fs_minfree) / 100; + if(Init){ + sendval(("%d:%d:%s\n", id, 0, mpath(file))); + } + else{ + sendval(("%d:%d\n", id, availblks == 0 ? 0 : round((double) used / (double) availblks * 100.0))); + } + (void) close(fi); + } + + *** atk/console/stats/hp800/getstats.c Thu May 30 19:43:25 1991 --- atk/console/stats/hp800/getstats.c.NEW Tue Apr 23 15:53:13 1991 *************** *** 0 **** --- 1,441 ---- + /* ********************************************************************** *\ + * Copyright IBM Corporation 1988,1989 - All Rights Reserved * + * For full copyright information see:'andrew/config/COPYRITE' * + \* ********************************************************************** */ + /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/console/stats/hp800/RCS/getstats.c,v 1.1 1991/03/29 11:19:39 dba Exp $ */ + /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/console/stats/hp800/RCS/getstats.c,v $ */ + + #ifndef lint + static char *getstats_c_id = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/console/stats/hp800/RCS/getstats.c,v 1.1 1991/03/29 11:19:39 dba Exp $"; + #endif /* lint */ + + /* ********************************************************************** + * This code is designed to read what might be priveledged (setuid) + * information regarding both Disk Statistics (% full) and a host of + * stats from /dev/kmem (including but not limited to, CPU, I/O, and VM) + * + * When retriving the data - this program will print out to stdout + * a string in the form of either "%d:%d\n" or "%d:%d:%s\n" + * The latter case is for passing the name of where a disk is mounted + * back to the parent program. + * + * The parent program (Console, or any other program which wishes to get + * at this information) is responsible for setting up a pipe, binding the + * child's (this program) stdout to one end of a pipe, and parsing the + * strings which are passed back. + * + * The basic string format is an ID (int), a colon, a value (int), and + * optionally another colon followed by a string. The ID is coded from + * the included file "getstats.h" - ID values 50 and over represent + * ERRORS as documented in the above mentioned inclued file. When an + * ERROR or the optional string is passed, the value (second parameter) + * can be safely ignored, and is usually set to 0. + * + * The arguments to be passed to this program are the effective UID from + * the parent program, a polling frequency (# of seconds) for checking + * /dev/kmem (usually between 1 and 5, must be > 0), and a polling + * frequency for checking how full the local disks are (generally higher + * than the value for /dev/kmem, but could vary greatly). Thus the call + * is: + * + * execvp("getstats", argv) + * + * with argv as: + * + * argv[0]="getstats"; + * argv[1]=~ ("%d", UID); + * argv[2]=~ ("%d", kmempollfrequency); + * argv[3]=~ ("%d", diskpollfrequency); + * argv[4]=NULL; + * + ********************************************************************** */ + #include + + #include + + #include + #include + #include + #include + #include + /* Because otherwise proc.h will try to include fss.h, + * which isn't there. + */ + #undef __hp9000s800 + #include + #define __hp9000s800 + #include + #include + #include + + #include + + #include + #include + #include + + #include + #include + #include + #include + #include + #include + #include + #include + + #define DK_NDRIVE 8 + + #undef MAXUPRC + + long maxuprc = 0; /* we have to nlist in HP-UX */ + + #define VMMON_DODECL + #include + #include + extern struct nlist RawStatistics[]; + + char root[32]; + + int TotalTime; + int deficit; + int MemoryFile /* file descriptor for unix memory */ ; + int nproc; + off_t procp; + struct proc proc[8];/* 8 = a few, for fewer syscalls */ + struct proc *mproc; + extern char *malloc(); + + + struct{ + long time[CPUSTATES]; + long xfer[DK_NDRIVE]; + struct vmmeter Rate; + struct vmtotal Total; + long dk_xfer[DK_NDRIVE]; + }s, s1; + + union { + struct fs iu_fs; + char dummy[SBSIZE]; + } sb; + + #define sendval(text) {printf text ;fflush(stdout);} + + + + + GetGVMStats(UsersID) + int UsersID; + { + register int i; + long t; + struct mapent *sp; + int myval = 0; + + lseek(MemoryFile,(long) RawStatistics[X_CPTIME].n_value, 0); + read(MemoryFile, s.time, sizeof(s.time)); + + lseek(MemoryFile,(long) RawStatistics[X_DKXFER].n_value, 0); + read(MemoryFile, s.dk_xfer, sizeof(s.dk_xfer)); + + lseek(MemoryFile,(long) RawStatistics[X_RATE].n_value, 0); + read(MemoryFile, &s.Rate, sizeof(s.Rate)); + + lseek(MemoryFile,(long) RawStatistics[X_TOTAL].n_value, 0); + read(MemoryFile, &s.Total, sizeof(s.Total)); + + lseek(MemoryFile,(long) RawStatistics[X_DEFICIT].n_value, 0); + read(MemoryFile, &deficit, sizeof(deficit)); + for (i = 0; i < CPUSTATES; i++) { + t = s.time[i]; + s.time[i] -= s1.time[i]; + s1.time[i] = t; + } + s.time[1] += s.time[0]; + TotalTime = 0; + for (i = 1; i < CPUSTATES; i++) + TotalTime += s.time[i]; + if (TotalTime == 0) + TotalTime = 1; + sendval(("%d:%d\n", LOADCPU, (s.time[1] + s.time[2]) * 100 / TotalTime)); + for (i = 1; i < DK_NDRIVE - 1; i++) + s.dk_xfer[0] += s.dk_xfer[i]; + if (s1.dk_xfer[0] == 0){ + s1.dk_xfer[0] = s.dk_xfer[0]; + } + myval = s.dk_xfer[0] - s1.dk_xfer[0]; + if (myval > 100) myval = 100; + sendval(("%d:%d\n", LOADIO, myval)); + s1.dk_xfer[0] = s.dk_xfer[0]; + sendval(("%d:%d\n", LOADUSER, s.time[1] * 100 / TotalTime)); + sendval(("%d:%d\n", LOADSYS, s.time[2] * 100 / TotalTime)); + sendval(("%d:%d\n", LOADIDLE, s.time[3] * 100 / TotalTime)); + sendval(("%d:%d\n", VM, (int)((double)s.Total.t_avm/(double)s.Total.t_vm * 100))); + sendval(("%d:%d\n", PAGEIN, s.Rate.v_pgpgin / 2)); + sendval(("%d:%d\n", PAGEOUT, s.Rate.v_pgpgout / 2)); + sendval(("%d:%d\n", PAGEREPLACABLE, s.Rate.v_scan)); + sendval(("%d:%d\n", PAGEDEFICIT, deficit)); + sendval(("%d:%d\n", MEMACTIVE, s.Total.t_avm / 2)); + sendval(("%d:%d\n", MEMFREE, s.Total.t_free / 2)); + sendval(("%d:%d\n", QUEUERUN, s.Total.t_rq)); + sendval(("%d:%d\n", QUEUEBLOCK, s.Total.t_dw + s.Total.t_pw)); + sendval(("%d:%d\n", QUEUEMEM, s.Total.t_sw)); + sendval(("%d:%d\n", INTSIO, s.Rate.v_intr)); + sendval(("%d:%d\n", INTSSYS, s.Rate.v_syscall)); + sendval(("%d:%d\n", INTSSWAP, s.Rate.v_swtch)); + if (1) {/* DoPROCESSES */ + int i, j, userprocesses, totalprocesses, otherprocs; + off_t tmpprocp; + + userprocesses = 0; + totalprocesses = 1; + otherprocs = 0; + tmpprocp = procp; + + for (i = 0; i < nproc; i += 8) { + lseek(MemoryFile, (long) tmpprocp, 0); + j = nproc - i; + if (j > 8) + j = 8; + j *= sizeof(struct proc); + if (read(MemoryFile, (char *) proc, j) != j) { + sendval(("%d:%d\n", GVM_ERR_1, 0)); + exit(-1); + } + tmpprocp += j; + for (j = j / sizeof(struct proc) - 1; j >= 0; j--) { + mproc = &proc[j]; + if (mproc->p_pid != 0) { + totalprocesses++; + if (UsersID == mproc->p_uid) { + userprocesses ++; + } else if (mproc->p_uid) { + otherprocs++; + } + } + } + } + sendval(("%d:%d\n", PROCSUSER, maxuprc ? (userprocesses * 100) / maxuprc : -1)); + sendval(("%d:%d\n", PROCSTOTAL, nproc ? totalprocesses * 100 / nproc : -1)); + sendval(("%d:%d\n", PROCSOTHER, otherprocs)); + } + } + + + + + + InitGVMStats() + { + time_t bootime; + int code = 0; + + /* + set up Unix interface: scan name list for current system + addresses and then open a file which is the memory image + of the system. + */ + code = nlist(_SITE_VMUNIX, RawStatistics); + if (code == -1){ + sendval(("%d:%d\n", GVM_ERR_2, 0)); + exit(-1); + } + else{ + if (RawStatistics[0].n_type == 0){ + sendval(("%d:%d\n", GVM_ERR_3, 0)); + exit(-1); + } + } + MemoryFile = open(_SITE_DEV_KMEM, 0); + if (MemoryFile < 0){ + sendval(("%d:%d\n", GVM_ERR_4, 0)); + exit(-1); + } + lseek(MemoryFile,(long) RawStatistics[X_BOOTIME].n_value, 0); + read(MemoryFile, &bootime, sizeof(bootime)); + + lseek(MemoryFile, (long) RawStatistics[X_PROC].n_value, 0); + read(MemoryFile,(char *) &procp, sizeof(procp)); + + lseek(MemoryFile, (long) RawStatistics[X_NPROC].n_value, 0); + read(MemoryFile,(char *) &nproc, sizeof(nproc)); + + #ifndef MAXUPRC + lseek(MemoryFile, (long) RawStatistics[X_MAXUPRC].n_value, 0); + read(MemoryFile,(char *) &maxuprc, sizeof(maxuprc)); + #endif /* MAXUPRC */ + } + + + /* the DeviceTable keeps a list of all the devices (and their mounted directory file name) that we should watch */ + + extern int getmnt(); + + GetDiskStats(Init) + int Init; + { + int i = 0; + struct stat statb; + char tmpname[1024]; + register FILE *mtabp; + register struct mntent *mnt; + + sync(); + if ((mtabp = setmntent(MNT_MNTTAB, "r")) == NULL) { + sendval(("%d:%d\n", DISK_ERR_1, 0)); + exit(1); + } + i = DISK1 - 1; /* figuratively 0 */ + while ((mnt = getmntent(mtabp)) != NULL) { + i++; + if (strcmp(mnt->mnt_type, MNTTYPE_IGNORE) == 0 || + strcmp(mnt->mnt_type, MNTTYPE_SWAP) == 0) + continue; + if (strcmp(mnt->mnt_type, MNTTYPE_HFS) == 0 && + (stat(mnt->mnt_fsname, &statb) >= 0) && + (((statb.st_mode & S_IFMT) == S_IFBLK) || + ((statb.st_mode & S_IFMT) == S_IFCHR))) { + (void) strcpy(tmpname, mnt->mnt_fsname); + dfree1(i, tmpname, 0, Init); + } else { + dfree2(i, mnt->mnt_dir, mnt, Init); + } + } + (void) endmntent(mtabp); + } + + int bread(fi, bno, buf, cnt) + int fi; + daddr_t bno; + char *buf; + int cnt; + { + extern int errno; + + (void) lseek(fi, (long)(bno * DEV_BSIZE), 0); + if (read(fi, buf, (unsigned) cnt) < 0) + { + /* probably a dismounted disk if errno == EIO */ + if (errno != EIO) { + sendval(("%d:%d\n", DISK_ERR_5, 0)); + } + return (0); + } + return (1); + } + + /* + * Given a name like /dev/rrp0h, returns the mounted path, like /usr. + */ + char *mpath(file) + char *file; + { + FILE *mntp; + register struct mntent *mnt; + + + if ((mntp = setmntent(MNT_MNTTAB, "r")) == 0) { + sendval(("%d:%d\n", DISK_ERR_1, 0)); + exit(1); + } + while ((mnt = getmntent(mntp)) != 0) { + if (strcmp(file, mnt->mnt_fsname) == 0) { + (void) endmntent(mntp); + return (mnt->mnt_dir); + } + } + (void) endmntent(mntp); + return ""; + } + + int round(num) + double num; + { + int inum = (int) num; + return(((num - inum) >= 0.5) ? (inum + 1) : inum); + } + + dfree1(id, file, infsent, Init) + int id; + char *file; + int infsent; + int Init; + { + long totalblks, availblks, free, used; + int fi; + struct stat stbuf; + struct checklist *fsp; + + if (stat(file, &stbuf) == 0 && + (stbuf.st_mode&S_IFMT) != S_IFCHR && + (stbuf.st_mode&S_IFMT) != S_IFBLK) { + if (infsent) { + sendval(("%d:%d\n", DISK_ERR_3, 0)); + return; + } + setfsent(); + while (fsp = getfsent()) { + struct stat stb; + + if (stat(fsp->fs_spec, &stb) == 0 && + stb.st_rdev == stbuf.st_dev) { + file = fsp->fs_spec; + endfsent(); + goto found; + } + } + endfsent(); + sendval(("%d:%d\n", DISK_ERR_4, 0)); + return; + } + found: + fi = open(file, 0); + if (fi < 0){ + return; + } + if (bread(fi, SBLOCK, (char *)&sb.iu_fs, SBSIZE) == 0) { + (void) close(fi); + return; + } + totalblks = sb.iu_fs.fs_dsize; + free = sb.iu_fs.fs_cstotal.cs_nbfree * sb.iu_fs.fs_frag + + sb.iu_fs.fs_cstotal.cs_nffree; + used = totalblks - free; + availblks = totalblks * (100 - sb.iu_fs.fs_minfree) / 100; + if(Init){ + sendval(("%d:%d:%s\n", id, 0, mpath(file))); + } + else{ + sendval(("%d:%d\n", id, availblks == 0 ? 0 : round((double) used / (double) availblks * 100.0))); + } + (void) close(fi); + } + + + dfree2(id, file, mnt, Init) + int id; + char *file; + struct mntent *mnt; + int Init; + { + struct statfs fs; + long totalblks, avail, free, used, reserved; + + if (statfs(file, &fs) < 0) { + return; + } + totalblks = fs.f_blocks; + free = fs.f_bfree; + used = totalblks - free; + avail = fs.f_bavail; + reserved = free - avail; + if (avail < 0) + avail = 0; + totalblks -= reserved; + if(Init){ + sendval(("%d:%d:%s\n",id, 0, mnt->mnt_dir)); + } + else{ + sendval(("%d:%d\n", id, round((double) used / (double) totalblks * 100.0))); + } + } *** atk/console/stats/sun3_41/Imakefile Thu May 30 19:43:42 1991 --- atk/console/stats/sun3_41/Imakefile.NEW Thu Mar 21 14:36:49 1991 *************** *** 0 **** --- 1,11 ---- + /* ********************************************************************** *\ + * Copyright IBM Corporation 1988,1989 - All Rights Reserved * + * For full copyright information see:'andrew/config/COPYRITE' * + \* ********************************************************************** */ + LOCALINCLUDES = -I../../lib + + DependTarget() + NormalObjectRule() + + LibraryTarget(libgs.a, getstats.o) + *** atk/console/stats/sun3_41/getstats.c Thu May 30 19:43:53 1991 --- atk/console/stats/sun3_41/getstats.c.NEW Thu Mar 21 14:36:51 1991 *************** *** 0 **** --- 1,473 ---- + /* ********************************************************************** *\ + * Copyright IBM Corporation 1988,1989 - All Rights Reserved * + * For full copyright information see:'andrew/config/COPYRITE' * + \* ********************************************************************** */ + /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/console/stats/sun3_41/RCS/getstats.c,v 1.1 91/02/15 17:12:39 gk5g Exp $ */ + /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/console/stats/sun3_41/RCS/getstats.c,v $ */ + + #ifndef lint + static char *getstats_c_id = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/console/stats/sun3_41/RCS/getstats.c,v 1.1 91/02/15 17:12:39 gk5g Exp $"; + #endif /* lint */ + + /* ********************************************************************** + * This code is designed to read what might be priveledged (setuid) + * information regarding both Disk Statistics (% full) and a host of + * stats from /dev/kmem (including but not limited to, CPU, I/O, and VM) + * + * When retriving the data - this program will print out to stdout + * a string in the form of either "%d:%d\n" or "%d:%d:%s\n" + * The latter case is for passing the name of where a disk is mounted + * back to the parent program. + * + * The parent program (Console, or any other program which wishes to get + * at this information) is responsible for setting up a pipe, binding the + * child's (this program) stdout to one end of a pipe, and parsing the + * strings which are passed back. + * + * The basic string format is an ID (int), a colon, a value (int), and + * optionally another colon followed by a string. The ID is coded from + * the included file "getstats.h" - ID values 50 and over represent + * ERRORS as documented in the above mentioned inclued file. When an + * ERROR or the optional string is passed, the value (second parameter) + * can be safely ignored, and is usually set to 0. + * + * The arguments to be passed to this program are the effective UID from + * the parent program, a polling frequency (# of seconds) for checking + * /dev/kmem (usually between 1 and 5, must be > 0), and a polling + * frequency for checking how full the local disks are (generally higher + * than the value for /dev/kmem, but could vary greatly). Thus the call + * is: + * + * execvp("getstats", argv) + * + * with argv as: + * + * argv[0]="getstats"; + * argv[1]=~ ("%d", UID); + * argv[2]=~ ("%d", kmempollfrequency); + * argv[3]=~ ("%d", diskpollfrequency); + * argv[4]=NULL; + * + ********************************************************************** */ + #include + + #include + + #include + #include + #include + #include + #include + #include + #include + #include + #include /* search namelist in vmunix */ + + #include + + #include + #include + #include + + #include + #include + #include + #include + #include + #include + #include + + #undef MAXUPRC + + long maxuprc = 0; + + #define VMMON_DODECL + #include + extern struct nlist RawStatistics[]; + + + char root[32]; + + int TotalTime; + int deficit; + int MemoryFile /* file descriptor for unix memory */ ; + int nproc; + int SwapMapAddress; + int nSwapMapEntries; + int SwapMapSize; + int nSwapBlks; + int CurrentSwapUsed; + int dmmax; + off_t procp; + struct mapent *SwapMap; + struct proc proc[8];/* 8 = a few, for fewer syscalls */ + struct proc *mproc; + extern char *malloc(); + + + struct{ + long time[CPUSTATES]; + long xfer[DK_NDRIVE]; + struct vmmeter Rate; + struct vmtotal Total; + struct ndstat ndstat; + long dk_xfer[DK_NDRIVE]; + }s, s1; + + union { + struct fs iu_fs; + char dummy[SBSIZE]; + } sb; + + #define rate s.Rate + #define total s.Total + #define sblock sb.iu_fs + #define sendval(text) {printf text ;fflush(stdout);} + + + + + GetGVMStats(UsersID) + int UsersID; + { + register int i; + long t; + struct mapent *sp; + lseek(MemoryFile,(long) RawStatistics[X_CPTIME].n_value, 0); + read(MemoryFile, s.time, sizeof(s.time)); + + if (RawStatistics[X_NDSTAT].n_value != 0){ + lseek(MemoryFile,(long) RawStatistics[X_NDSTAT].n_value, 0); + read(MemoryFile, &s.ndstat, sizeof(s.ndstat)); + } + if (RawStatistics[X_NDSTAT].n_value == 0){ + lseek(MemoryFile,(long) RawStatistics[X_DKXFER].n_value, 0); + read(MemoryFile, s.dk_xfer, sizeof(s.dk_xfer)); + } + lseek(MemoryFile,(long) RawStatistics[X_RATE].n_value, 0); + read(MemoryFile, &rate, sizeof(rate)); + sp = SwapMap; + if (sp != NULL) { + lseek(MemoryFile, SwapMapAddress, 0); + read(MemoryFile, sp, SwapMapSize); + for (CurrentSwapUsed = nSwapBlks;sp->m_size;sp++){ + CurrentSwapUsed -= sp->m_size; + } + } + lseek(MemoryFile,(long) RawStatistics[X_TOTAL].n_value, 0); + read(MemoryFile, &total, sizeof(total)); + lseek(MemoryFile,(long) RawStatistics[X_DEFICIT].n_value, 0); + read(MemoryFile, &deficit, sizeof(deficit)); + for (i = 0; i < CPUSTATES; i++) { + t = s.time[i]; + s.time[i] -= s1.time[i]; + s1.time[i] = t; + } + s.time[1] += s.time[0]; + TotalTime = 0; + for (i = 1; i < CPUSTATES; i++) + TotalTime += s.time[i]; + if (TotalTime == 0) + TotalTime = 1; + sendval(("%d:%d\n", LOADCPU, (s.time[1] + s.time[2]) * 100 / TotalTime)); + if (RawStatistics[X_NDSTAT].n_value != 0){ + int myval = 0; + if (s1.ndstat.ns_rpacks == 0){ + s1.ndstat = s.ndstat; + } + myval = s.ndstat.ns_rpacks - s1.ndstat.ns_rpacks + s.ndstat.ns_xpacks - s1.ndstat.ns_xpacks; + if (myval > 100) myval = 100; + sendval(("%d:%d\n", LOADIO, myval)); + s1.ndstat = s.ndstat; + } + else + { + int myval = 0; + { + register int i; + for (i = 1; i < DK_NDRIVE - 1; i++) + s.dk_xfer[0] += s.dk_xfer[i]; + } + if (s1.dk_xfer[0] == 0){ + s1.dk_xfer[0] = s.dk_xfer[0]; + } + myval = s.dk_xfer[0] - s1.dk_xfer[0]; + if (myval > 100) myval = 100; + sendval(("%d:%d\n", LOADIO, myval)); + s1.dk_xfer[0] = s.dk_xfer[0]; + } + sendval(("%d:%d\n", LOADUSER, s.time[1] * 100 / TotalTime)); + sendval(("%d:%d\n", LOADSYS, s.time[2] * 100 / TotalTime)); + sendval(("%d:%d\n", LOADIDLE, s.time[3] * 100 / TotalTime)); + sendval(("%d:%d\n", VM, nSwapBlks ? CurrentSwapUsed * 100 / nSwapBlks : -1)); + sendval(("%d:%d\n", PAGEIN, rate.v_pgpgin / 2)); + sendval(("%d:%d\n", PAGEOUT, rate.v_pgpgout / 2)); + sendval(("%d:%d\n", PAGEREPLACABLE, rate.v_scan)); + sendval(("%d:%d\n", PAGEDEFICIT, deficit)); + sendval(("%d:%d\n", MEMACTIVE, total.t_avm / 2)); + sendval(("%d:%d\n", MEMFREE, total.t_free / 2)); + sendval(("%d:%d\n", QUEUERUN, total.t_rq)); + sendval(("%d:%d\n", QUEUEBLOCK, total.t_dw + total.t_pw)); + sendval(("%d:%d\n", QUEUEMEM, total.t_sw)); + sendval(("%d:%d\n", INTSIO, rate.v_intr)); + sendval(("%d:%d\n", INTSSYS, rate.v_syscall)); + sendval(("%d:%d\n", INTSSWAP, rate.v_swtch)); + if (1) {/* DoPROCESSES */ + int i, j, userprocesses, totalprocesses, otherprocs; + off_t tmpprocp; + + userprocesses = 0; + totalprocesses = 1; + otherprocs = 0; + tmpprocp = procp; + + for (i = 0; i < nproc; i += 8) { + lseek(MemoryFile, (long) tmpprocp, 0); + j = nproc - i; + if (j > 8) + j = 8; + j *= sizeof(struct proc); + if (read(MemoryFile, (char *) proc, j) != j) { + sendval(("%d:%d\n", GVM_ERR_1, 0)); + exit(-1); + } + tmpprocp += j; + for (j = j / sizeof(struct proc) - 1; j >= 0; j--) { + mproc = &proc[j]; + if (mproc->p_pid != 0) { + totalprocesses++; + if (UsersID == mproc->p_uid) { + userprocesses ++; + } else if (mproc->p_uid) { + otherprocs++; + } + } + } + } + sendval(("%d:%d\n", PROCSUSER, maxuprc ? (userprocesses * 100) / maxuprc : -1)); + sendval(("%d:%d\n", PROCSTOTAL, nproc ? totalprocesses * 100 / nproc : -1)); + sendval(("%d:%d\n", PROCSOTHER, otherprocs)); + } + if (s1.ndstat.ns_rpacks == 0) s1.ndstat = s.ndstat; + sendval(("%d:%d\n", NDSTATIN, s.ndstat.ns_rpacks - s1.ndstat.ns_rpacks)); + sendval(("%d:%d\n", NDSTATOUT, s.ndstat.ns_xpacks - s1.ndstat.ns_xpacks)); + sendval(("%d:%d\n", NDSTATERR, s.ndstat.ns_utimo - s1.ndstat.ns_utimo + + s.ndstat.ns_stimo - s1.ndstat.ns_stimo)); + s1.ndstat = s.ndstat; + } + + + + + + InitGVMStats() + { + time_t bootime; + int code = 0; + + /* + set up Unix interface: scan name list for current system + addresses and then open a file which is the memory image + of the system. + */ + code = nlist(_SITE_VMUNIX, RawStatistics); + if (code == -1){ + sendval(("%d:%d\n", GVM_ERR_2, 0)); + exit(-1); + } + else{ + if (RawStatistics[0].n_type == 0){ + sendval(("%d:%d\n", GVM_ERR_3, 0)); + exit(-1); + } + } + MemoryFile = open(_SITE_DEV_KMEM, 0); + if (MemoryFile < 0){ + sendval(("%d:%d\n", GVM_ERR_4, 0)); + exit(-1); + } + lseek(MemoryFile,(long) RawStatistics[X_BOOTIME].n_value, 0); + read(MemoryFile, &bootime, sizeof(bootime)); + lseek(MemoryFile, (long) RawStatistics[X_PROC].n_value, 0); + read(MemoryFile,(char *) &procp, sizeof(procp)); + lseek(MemoryFile, (long) RawStatistics[X_NPROC].n_value, 0); + read(MemoryFile,(char *) &nproc, sizeof(nproc)); + /* + * Even if there is an nd driver in the system, we may not actually be + * a client. If the nd driver has never been used, ignore it. + */ + if (RawStatistics[X_NDSTAT].n_value){ + lseek(MemoryFile,(long) RawStatistics[X_NDSTAT].n_value, 0); + read(MemoryFile, &s.ndstat, sizeof(s.ndstat)); + if (s.ndstat.ns_xpacks == 0 || s.ndstat.ns_rpacks == 0) + RawStatistics[X_NDSTAT].n_value = 0; + } + #ifndef MAXUPRC + lseek(MemoryFile, (long) RawStatistics[X_MAXUPRC].n_value, 0); + read(MemoryFile,(char *) &maxuprc, sizeof(maxuprc)); + #endif /* MAXUPRC */ + lseek(MemoryFile,(long) RawStatistics[X_SWAPMAP].n_value, 0); + read(MemoryFile, &SwapMapAddress, sizeof(SwapMapAddress)); + SwapMapAddress += sizeof(struct map); + lseek(MemoryFile,(long) RawStatistics[X_NSWAPMAP].n_value, 0); + read(MemoryFile, &nSwapMapEntries, sizeof(nSwapMapEntries)); + SwapMapSize = (--nSwapMapEntries)*sizeof(struct mapent); + lseek(MemoryFile,(long) RawStatistics[X_NSWAPBLKS].n_value, 0); + read(MemoryFile, &nSwapBlks, sizeof(nSwapBlks)); + lseek(MemoryFile,(long) RawStatistics[X_DMMAX].n_value, 0); + read(MemoryFile, &dmmax, sizeof(dmmax)); + nSwapBlks -= dmmax/2; /* See vm_sw.c--initialization of swap space */ + if (SwapMapSize > 0) { + SwapMap = (struct mapent *) malloc(SwapMapSize); + } else { + SwapMap = NULL; + } + } + + + /* the DeviceTable keeps a list of all the devices (and their mounted directory file name) that we should watch */ + + extern int getmnt(); + + GetDiskStats(Init) + int Init; + { + int i = 0; + struct stat statb; + char tmpname[1024]; + register FILE *mtabp; + register struct mntent *mnt; + + sync(); + if ((mtabp = setmntent(MNTTAB, "r")) == NULL) { + sendval(("%d:%d\n", DISK_ERR_1, 0)); + exit(1); + } + i = DISK1 - 1; /* figuratively 0 */ + while ((mnt = getmntent(mtabp)) != NULL && i < MAXGETSTATSCOUNTERS) { + i++; + if (strcmp(mnt->mnt_type, MNTTYPE_IGNORE) == 0 || + strcmp(mnt->mnt_type, MNTTYPE_SWAP) == 0) + continue; + if (strcmp(mnt->mnt_type, MNTTYPE_42) == 0 && + (stat(mnt->mnt_fsname, &statb) >= 0) && + (((statb.st_mode & S_IFMT) == S_IFBLK) || + ((statb.st_mode & S_IFMT) == S_IFCHR))) { + (void) strcpy(tmpname, mnt->mnt_fsname); + dfree1(i, tmpname, 0, Init); + } else { + dfree2(i, mnt->mnt_dir, mnt, Init); + } + } + (void) endmntent(mtabp); + } + + int bread(fi, bno, buf, cnt) + int fi; + daddr_t bno; + char *buf; + int cnt; + { + extern int errno; + + (void) lseek(fi, (long)(bno * DEV_BSIZE), 0); + if (read(fi, buf, (unsigned) cnt) < 0) + { + /* probably a dismounted disk if errno == EIO */ + if (errno != EIO) { + sendval(("%d:%d\n", DISK_ERR_5, 0)); + } + return (0); + } + return (1); + } + + /* + * Given a name like /dev/rrp0h, returns the mounted path, like /usr. + */ + char *mpath(file) + char *file; + { + FILE *mntp; + register struct mntent *mnt; + + + if ((mntp = setmntent(MOUNTED, "r")) == 0) { + sendval(("%d:%d\n", DISK_ERR_1, 0)); + exit(1); + } + while ((mnt = getmntent(mntp)) != 0) { + if (strcmp(file, mnt->mnt_fsname) == 0) { + (void) endmntent(mntp); + return (mnt->mnt_dir); + } + } + (void) endmntent(mntp); + return ""; + } + + int round(num) + double num; + { + int inum = (int) num; + return(((num - inum) >= 0.5) ? (inum + 1) : inum); + } + + dfree1(id, file, infsent, Init) + int id; + char *file; + int infsent; + int Init; + { + long totalblks, availblks, free, used; + int fi; + fi = open(file, 0); + if (fi < 0){ + return; + } + if (bread(fi, SBLOCK, (char *)&sblock, SBSIZE) == 0) { + (void) close(fi); + return; + } + totalblks = sblock.fs_dsize; + free = sblock.fs_cstotal.cs_nbfree * sblock.fs_frag + + sblock.fs_cstotal.cs_nffree; + used = totalblks - free; + availblks = totalblks * (100 - sblock.fs_minfree) / 100; + if(Init){ + sendval(("%d:%d:%s\n", id, 0, mpath(file))); + } + else{ + sendval(("%d:%d\n", id, availblks == 0 ? 0 : round((double) used / (double) availblks * 100.0))); + } + (void) close(fi); + } + + + dfree2(id, file, mnt, Init) + int id; + char *file; + struct mntent *mnt; + int Init; + { + struct statfs fs; + long totalblks, avail, free, used, reserved; + + if (statfs(file, &fs) < 0) { + return; + } + totalblks = fs.f_blocks; + free = fs.f_bfree; + used = totalblks - free; + avail = fs.f_bavail; + reserved = free - avail; + if (avail < 0) + avail = 0; + totalblks -= reserved; + if(Init){ + sendval(("%d:%d:%s\n",id, 0, mnt->mnt_dir)); + } + else{ + sendval(("%d:%d\n", id, round((double) used / (double) totalblks * 100.0))); + } + } *** atk/console/stats/sun4_41/Imakefile Thu May 30 19:44:05 1991 --- atk/console/stats/sun4_41/Imakefile.NEW Thu Mar 21 14:36:54 1991 *************** *** 0 **** --- 1,11 ---- + /* ********************************************************************** *\ + * Copyright IBM Corporation 1988,1989 - All Rights Reserved * + * For full copyright information see:'andrew/config/COPYRITE' * + \* ********************************************************************** */ + LOCALINCLUDES = -I../../lib + + DependTarget() + NormalObjectRule() + + LibraryTarget(libgs.a, getstats.o) + *** atk/console/stats/sun4_41/getstats.c Thu May 30 19:44:16 1991 --- atk/console/stats/sun4_41/getstats.c.NEW Thu Mar 21 14:36:56 1991 *************** *** 0 **** --- 1,468 ---- + /* ********************************************************************** *\ + * Copyright IBM Corporation 1988,1989 - All Rights Reserved * + * For full copyright information see:'andrew/config/COPYRITE' * + \* ********************************************************************** */ + /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/console/stats/sun4_41/RCS/getstats.c,v 1.1 91/02/15 17:13:10 gk5g Exp $ */ + /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/console/stats/sun4_41/RCS/getstats.c,v $ */ + + #ifndef lint + static char *getstats_c_id = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/console/stats/sun4_41/RCS/getstats.c,v 1.1 91/02/15 17:13:10 gk5g Exp $"; + #endif /* lint */ + + /* ********************************************************************** + * This code is designed to read what might be priveledged (setuid) + * information regarding both Disk Statistics (% full) and a host of + * stats from /dev/kmem (including but not limited to, CPU, I/O, and VM) + * + * When retriving the data - this program will print out to stdout + * a string in the form of either "%d:%d\n" or "%d:%d:%s\n" + * The latter case is for passing the name of where a disk is mounted + * back to the parent program. + * + * The parent program (Console, or any other program which wishes to get + * at this information) is responsible for setting up a pipe, binding the + * child's (this program) stdout to one end of a pipe, and parsing the + * strings which are passed back. + * + * The basic string format is an ID (int), a colon, a value (int), and + * optionally another colon followed by a string. The ID is coded from + * the included file "getstats.h" - ID values 50 and over represent + * ERRORS as documented in the above mentioned inclued file. When an + * ERROR or the optional string is passed, the value (second parameter) + * can be safely ignored, and is usually set to 0. + * + * The arguments to be passed to this program are the effective UID from + * the parent program, a polling frequency (# of seconds) for checking + * /dev/kmem (usually between 1 and 5, must be > 0), and a polling + * frequency for checking how full the local disks are (generally higher + * than the value for /dev/kmem, but could vary greatly). Thus the call + * is: + * + * execvp("getstats", argv) + * + * with argv as: + * + * argv[0]="getstats"; + * argv[1]=~ ("%d", UID); + * argv[2]=~ ("%d", kmempollfrequency); + * argv[3]=~ ("%d", diskpollfrequency); + * argv[4]=NULL; + * + ********************************************************************** */ + #include + + #include + + #include + #include + #include + #include + #include + #include + #include + #include + #include /* search namelist in vmunix */ + + #include + + #include + #include + #include + + #include + #include + #include + #include + #include + #include + #include + + + #undef MAXUPRC + + long maxuprc = 0; + + #define VMMON_DODECL + #include + extern struct nlist RawStatistics[]; + + + char root[32]; + + int TotalTime; + int deficit; + int MemoryFile /* file descriptor for unix memory */ ; + int nproc; + int SwapMapAddress; + int nSwapMapEntries; + int SwapMapSize; + int nSwapBlks; + int CurrentSwapUsed; + int dmmax; + off_t procp; + struct mapent *SwapMap; + struct proc proc[8];/* 8 = a few, for fewer syscalls */ + struct proc *mproc; + extern char *malloc(); + + + struct{ + long time[CPUSTATES]; + long xfer[DK_NDRIVE]; + struct vmmeter Rate; + struct vmtotal Total; + struct ndstat ndstat; + long dk_xfer[DK_NDRIVE]; + }s, s1; + + union { + struct fs iu_fs; + char dummy[SBSIZE]; + } sb; + + #define rate s.Rate + #define total s.Total + #define sblock sb.iu_fs + #define sendval(text) {printf text ;fflush(stdout);} + + + + + GetGVMStats(UsersID) + int UsersID; + { + register int i; + long t; + struct mapent *sp; + lseek(MemoryFile,(long) RawStatistics[X_CPTIME].n_value, 0); + read(MemoryFile, s.time, sizeof(s.time)); + + if (RawStatistics[X_NDSTAT].n_value != 0){ + lseek(MemoryFile,(long) RawStatistics[X_NDSTAT].n_value, 0); + read(MemoryFile, &s.ndstat, sizeof(s.ndstat)); + } + if (RawStatistics[X_NDSTAT].n_value == 0){ + lseek(MemoryFile,(long) RawStatistics[X_DKXFER].n_value, 0); + read(MemoryFile, s.dk_xfer, sizeof(s.dk_xfer)); + } + lseek(MemoryFile,(long) RawStatistics[X_RATE].n_value, 0); + read(MemoryFile, &rate, sizeof(rate)); + sp = SwapMap; + lseek(MemoryFile, SwapMapAddress, 0); + read(MemoryFile, sp, SwapMapSize); + for (CurrentSwapUsed = nSwapBlks;sp->m_size;sp++){ + CurrentSwapUsed -= sp->m_size; + } + lseek(MemoryFile,(long) RawStatistics[X_TOTAL].n_value, 0); + read(MemoryFile, &total, sizeof(total)); + lseek(MemoryFile,(long) RawStatistics[X_DEFICIT].n_value, 0); + read(MemoryFile, &deficit, sizeof(deficit)); + for (i = 0; i < CPUSTATES; i++) { + t = s.time[i]; + s.time[i] -= s1.time[i]; + s1.time[i] = t; + } + s.time[1] += s.time[0]; + TotalTime = 0; + for (i = 1; i < CPUSTATES; i++) + TotalTime += s.time[i]; + if (TotalTime == 0) + TotalTime = 1; + sendval(("%d:%d\n", LOADCPU, (s.time[1] + s.time[2]) * 100 / TotalTime)); + if (RawStatistics[X_NDSTAT].n_value != 0){ + int myval = 0; + if (s1.ndstat.ns_rpacks == 0){ + s1.ndstat = s.ndstat; + } + myval = s.ndstat.ns_rpacks - s1.ndstat.ns_rpacks + s.ndstat.ns_xpacks - s1.ndstat.ns_xpacks; + if (myval > 100) myval = 100; + sendval(("%d:%d\n", LOADIO, myval)); + s1.ndstat = s.ndstat; + } + else + { + int myval = 0; + { + register int i; + for (i = 1; i < DK_NDRIVE - 1; i++) + s.dk_xfer[0] += s.dk_xfer[i]; + } + if (s1.dk_xfer[0] == 0){ + s1.dk_xfer[0] = s.dk_xfer[0]; + } + myval = s.dk_xfer[0] - s1.dk_xfer[0]; + if (myval > 100) myval = 100; + sendval(("%d:%d\n", LOADIO, myval)); + s1.dk_xfer[0] = s.dk_xfer[0]; + } + sendval(("%d:%d\n", LOADUSER, s.time[1] * 100 / TotalTime)); + sendval(("%d:%d\n", LOADSYS, s.time[2] * 100 / TotalTime)); + sendval(("%d:%d\n", LOADIDLE, s.time[3] * 100 / TotalTime)); + sendval(("%d:%d\n", VM, nSwapBlks ? CurrentSwapUsed * 100 / nSwapBlks : -1)); + sendval(("%d:%d\n", PAGEIN, rate.v_pgpgin / 2)); + sendval(("%d:%d\n", PAGEOUT, rate.v_pgpgout / 2)); + sendval(("%d:%d\n", PAGEREPLACABLE, rate.v_scan)); + sendval(("%d:%d\n", PAGEDEFICIT, deficit)); + sendval(("%d:%d\n", MEMACTIVE, total.t_avm / 2)); + sendval(("%d:%d\n", MEMFREE, total.t_free / 2)); + sendval(("%d:%d\n", QUEUERUN, total.t_rq)); + sendval(("%d:%d\n", QUEUEBLOCK, total.t_dw + total.t_pw)); + sendval(("%d:%d\n", QUEUEMEM, total.t_sw)); + sendval(("%d:%d\n", INTSIO, rate.v_intr)); + sendval(("%d:%d\n", INTSSYS, rate.v_syscall)); + sendval(("%d:%d\n", INTSSWAP, rate.v_swtch)); + if (1) {/* DoPROCESSES */ + int i, j, userprocesses, totalprocesses, otherprocs; + off_t tmpprocp; + + userprocesses = 0; + totalprocesses = 1; + otherprocs = 0; + tmpprocp = procp; + + for (i = 0; i < nproc; i += 8) { + lseek(MemoryFile, (long) tmpprocp, 0); + j = nproc - i; + if (j > 8) + j = 8; + j *= sizeof(struct proc); + if (read(MemoryFile, (char *) proc, j) != j) { + sendval(("%d:%d\n", GVM_ERR_1, 0)); + exit(-1); + } + tmpprocp += j; + for (j = j / sizeof(struct proc) - 1; j >= 0; j--) { + mproc = &proc[j]; + if (mproc->p_pid != 0) { + totalprocesses++; + if (UsersID == mproc->p_uid) { + userprocesses ++; + } else if (mproc->p_uid) { + otherprocs++; + } + } + } + } + sendval(("%d:%d\n", PROCSUSER, maxuprc ? (userprocesses * 100) / maxuprc : -1)); + sendval(("%d:%d\n", PROCSTOTAL, nproc ? totalprocesses * 100 / nproc : -1)); + sendval(("%d:%d\n", PROCSOTHER, otherprocs)); + } + if (s1.ndstat.ns_rpacks == 0) s1.ndstat = s.ndstat; + sendval(("%d:%d\n", NDSTATIN, s.ndstat.ns_rpacks - s1.ndstat.ns_rpacks)); + sendval(("%d:%d\n", NDSTATOUT, s.ndstat.ns_xpacks - s1.ndstat.ns_xpacks)); + sendval(("%d:%d\n", NDSTATERR, s.ndstat.ns_utimo - s1.ndstat.ns_utimo + + s.ndstat.ns_stimo - s1.ndstat.ns_stimo)); + s1.ndstat = s.ndstat; + } + + + + + + InitGVMStats() + { + time_t bootime; + int code = 0; + + /* + set up Unix interface: scan name list for current system + addresses and then open a file which is the memory image + of the system. + */ + code = nlist(_SITE_VMUNIX, RawStatistics); + if (code == -1){ + sendval(("%d:%d\n", GVM_ERR_2, 0)); + exit(-1); + } + else{ + if (RawStatistics[0].n_type == 0){ + sendval(("%d:%d\n", GVM_ERR_3, 0)); + exit(-1); + } + } + MemoryFile = open(_SITE_DEV_KMEM, 0); + if (MemoryFile < 0){ + sendval(("%d:%d\n", GVM_ERR_4, 0)); + exit(-1); + } + lseek(MemoryFile,(long) RawStatistics[X_BOOTIME].n_value, 0); + read(MemoryFile, &bootime, sizeof(bootime)); + lseek(MemoryFile, (long) RawStatistics[X_PROC].n_value, 0); + read(MemoryFile,(char *) &procp, sizeof(procp)); + lseek(MemoryFile, (long) RawStatistics[X_NPROC].n_value, 0); + read(MemoryFile,(char *) &nproc, sizeof(nproc)); + /* + * Even if there is an nd driver in the system, we may not actually be + * a client. If the nd driver has never been used, ignore it. + */ + if (RawStatistics[X_NDSTAT].n_value){ + lseek(MemoryFile,(long) RawStatistics[X_NDSTAT].n_value, 0); + read(MemoryFile, &s.ndstat, sizeof(s.ndstat)); + if (s.ndstat.ns_xpacks == 0 || s.ndstat.ns_rpacks == 0) + RawStatistics[X_NDSTAT].n_value = 0; + } + #ifndef MAXUPRC + lseek(MemoryFile, (long) RawStatistics[X_MAXUPRC].n_value, 0); + read(MemoryFile,(char *) &maxuprc, sizeof(maxuprc)); + #endif /* MAXUPRC */ + lseek(MemoryFile,(long) RawStatistics[X_SWAPMAP].n_value, 0); + read(MemoryFile, &SwapMapAddress, sizeof(SwapMapAddress)); + SwapMapAddress += sizeof(struct map); + lseek(MemoryFile,(long) RawStatistics[X_NSWAPMAP].n_value, 0); + read(MemoryFile, &nSwapMapEntries, sizeof(nSwapMapEntries)); + SwapMapSize = (--nSwapMapEntries)*sizeof(struct mapent); + lseek(MemoryFile,(long) RawStatistics[X_NSWAPBLKS].n_value, 0); + read(MemoryFile, &nSwapBlks, sizeof(nSwapBlks)); + lseek(MemoryFile,(long) RawStatistics[X_DMMAX].n_value, 0); + read(MemoryFile, &dmmax, sizeof(dmmax)); + nSwapBlks -= dmmax/2; /* See vm_sw.c--initialization of swap space */ + SwapMap = (struct mapent *) malloc(SwapMapSize); + } + + + /* the DeviceTable keeps a list of all the devices (and their mounted directory file name) that we should watch */ + + extern int getmnt(); + + GetDiskStats(Init) + int Init; + { + int i = 0; + struct stat statb; + char tmpname[1024]; + register FILE *mtabp; + register struct mntent *mnt; + + sync(); + if ((mtabp = setmntent(MNTTAB, "r")) == NULL) { + sendval(("%d:%d\n", DISK_ERR_1, 0)); + exit(1); + } + i = DISK1 - 1; /* figuratively 0 */ + while ((mnt = getmntent(mtabp)) != NULL && i < MAXGETSTATSCOUNTERS) { + i++; + if (strcmp(mnt->mnt_type, MNTTYPE_IGNORE) == 0 || + strcmp(mnt->mnt_type, MNTTYPE_SWAP) == 0) + continue; + if (strcmp(mnt->mnt_type, MNTTYPE_42) == 0 && + (stat(mnt->mnt_fsname, &statb) >= 0) && + (((statb.st_mode & S_IFMT) == S_IFBLK) || + ((statb.st_mode & S_IFMT) == S_IFCHR))) { + (void) strcpy(tmpname, mnt->mnt_fsname); + dfree1(i, tmpname, 0, Init); + } else { + dfree2(i, mnt->mnt_dir, mnt, Init); + } + } + (void) endmntent(mtabp); + } + + int bread(fi, bno, buf, cnt) + int fi; + daddr_t bno; + char *buf; + int cnt; + { + extern int errno; + + (void) lseek(fi, (long)(bno * DEV_BSIZE), 0); + if (read(fi, buf, (unsigned) cnt) < 0) + { + /* probably a dismounted disk if errno == EIO */ + if (errno != EIO) { + sendval(("%d:%d\n", DISK_ERR_5, 0)); + } + return (0); + } + return (1); + } + + /* + * Given a name like /dev/rrp0h, returns the mounted path, like /usr. + */ + char *mpath(file) + char *file; + { + FILE *mntp; + register struct mntent *mnt; + + + if ((mntp = setmntent(MOUNTED, "r")) == 0) { + sendval(("%d:%d\n", DISK_ERR_1, 0)); + exit(1); + } + while ((mnt = getmntent(mntp)) != 0) { + if (strcmp(file, mnt->mnt_fsname) == 0) { + (void) endmntent(mntp); + return (mnt->mnt_dir); + } + } + (void) endmntent(mntp); + return ""; + } + + int round(num) + double num; + { + int inum = (int) num; + return(((num - inum) >= 0.5) ? (inum + 1) : inum); + } + + dfree1(id, file, infsent, Init) + int id; + char *file; + int infsent; + int Init; + { + long totalblks, availblks, free, used; + int fi; + fi = open(file, 0); + if (fi < 0){ + return; + } + if (bread(fi, SBLOCK, (char *)&sblock, SBSIZE) == 0) { + (void) close(fi); + return; + } + totalblks = sblock.fs_dsize; + free = sblock.fs_cstotal.cs_nbfree * sblock.fs_frag + + sblock.fs_cstotal.cs_nffree; + used = totalblks - free; + availblks = totalblks * (100 - sblock.fs_minfree) / 100; + if(Init){ + sendval(("%d:%d:%s\n", id, 0, mpath(file))); + } + else{ + sendval(("%d:%d\n", id, availblks == 0 ? 0 : round((double) used / (double) availblks * 100.0))); + } + (void) close(fi); + } + + + dfree2(id, file, mnt, Init) + int id; + char *file; + struct mntent *mnt; + int Init; + { + struct statfs fs; + long totalblks, avail, free, used, reserved; + + if (statfs(file, &fs) < 0) { + return; + } + totalblks = fs.f_blocks; + free = fs.f_bfree; + used = totalblks - free; + avail = fs.f_bavail; + reserved = free - avail; + if (avail < 0) + avail = 0; + totalblks -= reserved; + if(Init){ + sendval(("%d:%d:%s\n",id, 0, mnt->mnt_dir)); + } + else{ + sendval(("%d:%d\n", id, round((double) used / (double) totalblks * 100.0))); + } + } *** atk/console/stats/vax_3/getstats.c Wed Nov 22 11:59:51 1989 --- atk/console/stats/vax_3/getstats.c.NEW Thu May 23 12:16:46 1991 *************** *** 2,12 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/console/stats/vax_3/RCS/getstats.c,v 1.3 89/11/14 11:54:15 ghoti Exp $ */ ! /* $Source: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/console/stats/vax_3/RCS/getstats.c,v $ */ #ifndef lint ! static char *getstats_c_id = "$Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/console/stats/vax_3/RCS/getstats.c,v 1.3 89/11/14 11:54:15 ghoti Exp $"; #endif /* lint */ /* ********************************************************************** --- 2,12 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/console/stats/vax_3/RCS/getstats.c,v 1.5 91/05/22 17:23:32 gk5g Exp $ */ ! /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/console/stats/vax_3/RCS/getstats.c,v $ */ #ifndef lint ! static char *getstats_c_id = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/console/stats/vax_3/RCS/getstats.c,v 1.5 91/05/22 17:23:32 gk5g Exp $"; #endif /* lint */ /* ********************************************************************** *** atk/ctext/ctext.c Wed Nov 22 12:01:04 1989 --- atk/ctext/ctext.c.NEW Fri Jan 4 17:00:42 1991 *************** *** 2,13 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/ctext/RCS/ctext.c,v 2.10 89/10/16 11:45:42 cfe Exp $ */ /* $ACIS:ctext.c 1.2$ */ ! /* $Source: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/ctext/RCS/ctext.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/ctext/RCS/ctext.c,v 2.10 89/10/16 11:45:42 cfe Exp $"; #endif /* lint */ --- 2,13 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/ctext/RCS/ctext.c,v 2.12 91/01/02 15:38:41 gk5g Exp $ */ /* $ACIS:ctext.c 1.2$ */ ! /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/ctext/RCS/ctext.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/ctext/RCS/ctext.c,v 2.12 91/01/02 15:38:41 gk5g Exp $"; #endif /* lint */ *************** *** 623,629 **** #define backwardMatch(self,pos,strConst) \ (pos>=cstrlen(strConst)-1 && match(self,pos-(cstrlen(strConst)-1)+1,strConst)) ! #define match(self,pos,str) ((pos==0 || !isalnum(ctext_GetChar(self,pos-1))) && !isalnum(ctext_GetChar(self,pos+cstrlen(str))) && domatch(self,pos,str,cstrlen(str))) domatch(self,pos,str,len) struct ctext *self; --- 623,629 ---- #define backwardMatch(self,pos,strConst) \ (pos>=cstrlen(strConst)-1 && match(self,pos-(cstrlen(strConst)-1)+1,strConst)) ! #define match(self,pos,str) ((pos==0 || !isalnum(ctext_GetChar(self,pos-1))) && !isident(ctext_GetChar(self,pos+cstrlen(str))) && domatch(self,pos,str,cstrlen(str))) domatch(self,pos,str,len) struct ctext *self; *** atk/ctext/ctext.tpl Fri Dec 21 14:23:13 1990 --- atk/ctext/ctext.tpl.NEW Tue Dec 18 16:33:38 1990 *************** *** 1,18 **** ! \begindata{text, 1} \textdsversion{12} \define{comment ! attr:[FontFace Italic Int Set] ! attr:[FontFace FixedFace Int Set] ! attr:[FontSize PreviousFontSize Point 2] ! attr:[FontFamily AndyType Int 0]} \define{function attr:[FontFace Bold Int Set]} \define{global ! attr:[FontFace FixedFace Int Set] ! attr:[Justification LeftJustified Point 0] attr:[LeftMargin LeftEdge Int 16] attr:[Indent LeftMargin Int -16] attr:[Flags ContinueIndent Int Set] ! attr:[FontSize ConstantFontSize Point 10] ! attr:[FontFamily AndyType Int 0]} ! \enddata{text,1} --- 1,19 ---- ! \begindata{text,268742804} \textdsversion{12} \define{comment ! ! attr:[FontFace Italic Int Set]} \define{function + attr:[FontFace Bold Int Set]} \define{global ! attr:[LeftMargin LeftEdge Int 16] attr:[Indent LeftMargin Int -16] + attr:[Justification LeftJustified Point 0] attr:[Flags ContinueIndent Int Set] ! attr:[Flags TabsCharacters Int Set] ! attr:[FontFace FixedFace Int Set] ! attr:[FontFamily AndyType Int 0] ! attr:[FontSize ConstantFontSize Point 10]} ! \enddata{text,268742804} *** atk/ctext/ctextv.c Fri Dec 21 14:54:23 1990 --- atk/ctext/ctextv.c.NEW Fri Dec 14 16:47:31 1990 *************** *** 2,13 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/ctext/RCS/ctextv.c,v 2.14 90/10/11 12:11:24 gk5g Exp $ */ /* $ACIS:ctextv.c 1.2$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/ctext/RCS/ctextv.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/ctext/RCS/ctextv.c,v 2.14 90/10/11 12:11:24 gk5g Exp $"; #endif /* lint */ /* CTextView, a ``c'' mode for BE2. */ --- 2,13 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/ctext/RCS/ctextv.c,v 2.15 90/12/14 15:07:16 ajp Exp $ */ /* $ACIS:ctextv.c 1.2$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/ctext/RCS/ctextv.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/ctext/RCS/ctextv.c,v 2.15 90/12/14 15:07:16 ajp Exp $"; #endif /* lint */ /* CTextView, a ``c'' mode for BE2. */ *************** *** 24,29 **** --- 24,31 ---- #include #include + #include + #include static long BounceTime = 0; *************** *** 170,175 **** --- 172,182 ---- struct ctext *ct = (struct ctext *)self->header.view.dataobject; int count = im_Argument(ctextview_GetIM(self)), i, pos; + /* Ctext needs to know about vi command mode (ecch!) */ + if (ctextview_GetEditor(self) == VI && + ctextview_GetVIMode(self) == COMMAND ) + return; + ctextview_CollapseDot(self); pos = ctextview_GetDotPosition(self); *************** *** 190,195 **** --- 197,215 ---- { struct ctext *ct = (struct ctext *)self->header.view.dataobject; int count = im_Argument(ctextview_GetIM(self)), i, pos = ctextview_GetDotPosition(self); + struct proctable_Entry *textviewEntry; + + /* Ctext needs to know about vi command mode (ecch!) */ + if (ctextview_GetEditor(self) == VI && + ctextview_GetVIMode(self) == COMMAND ) + { + if ( (textviewEntry = proctable_Lookup("textview-forward-para")) != NULL ) + (*textviewEntry->proc) ((struct textview *) self, key); + else + message_DisplayString(self, 0, + "Can`t find textview-forward-para in proctable"); + return; + } ctextview_CollapseDot(self); pos = ctextview_GetDotPosition(self); *************** *** 213,218 **** --- 233,251 ---- { struct ctext *ct = (struct ctext *)self->header.view.dataobject; int count = im_Argument(ctextview_GetIM(self)), i, pos = ctextview_GetDotPosition(self); + struct proctable_Entry *textviewEntry; + + /* Ctext needs to know about vi command mode (ecch!) */ + if ( ctextview_GetEditor(self) == VI && + ctextview_GetVIMode(self) == COMMAND ) + { + if ( (textviewEntry = proctable_Lookup("textview-search")) != NULL ) + (*textviewEntry->proc) ((struct textview *) self, key); + else + message_DisplayString(self, 0, + "Can`t find textview-search in proctable"); + return; + } ctextview_CollapseDot(self); pos = ctextview_GetDotPosition(self); *************** *** 266,271 **** --- 299,317 ---- int c; long pos,end; struct mark *mark; + struct proctable_Entry *textviewEntry; + + /* Ctext needs to know about vi command mode (ecch!) */ + if (ctextview_GetEditor(self) == VI && + ctextview_GetVIMode(self) == COMMAND ) + { + if ( (textviewEntry = proctable_Lookup("textview-next-line")) != NULL ) + (*textviewEntry->proc) ((struct textview *) self, key); + else + message_DisplayString(self, 0, + "Can`t find textview-next-line in proctable"); + return; + } ctextview_CollapseDot(self); ctext_ReindentLine(ct,ctextview_GetDotPosition(self)); *************** *** 295,300 **** --- 341,359 ---- { struct ctext *ct = (struct ctext *)self->header.view.dataobject; int count = im_Argument(ctextview_GetIM(self)), i, pos; + struct proctable_Entry *textviewEntry; + + /* Ctext needs to know about vi command mode (ecch!) */ + if (ctextview_GetEditor(self) == VI && + ctextview_GetVIMode(self) == COMMAND ) + { + if ( (textviewEntry = proctable_Lookup("textview-vi-command")) != NULL ) + (*textviewEntry->proc) ((struct textview *) self, key); + else + message_DisplayString(self, 0, + "Can`t find textview-next-line in proctable"); + return; + } ctextview_CollapseDot(self); pos = ctextview_GetDotPosition(self); *** atk/eq/Imakefile Wed Nov 22 12:02:28 1989 --- atk/eq/Imakefile.NEW Thu Jun 13 16:20:50 1991 *************** *** 2,7 **** --- 2,11 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ + #if defined(sys_ps_aix12) || defined(sys_ps_aix11) + CDEBUGFLAGS = + #endif + DOBJS = eq.do eqv.do IHFILES = eq.ih eqv.ih *** atk/eq/eq.c Wed Nov 22 12:02:15 1989 --- atk/eq/eq.c.NEW Tue Dec 4 08:55:14 1990 *************** *** 2,13 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/eq/RCS/eq.c,v 2.6 89/04/10 02:01:59 maria Exp $ */ /* $ACIS:eq.c 1.5$ */ ! /* $Source: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/eq/RCS/eq.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/eq/RCS/eq.c,v 2.6 89/04/10 02:01:59 maria Exp $"; #endif /* lint */ /* --- 2,13 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/eq/RCS/eq.c,v 2.7 90/11/20 14:03:47 gk5g Exp $ */ /* $ACIS:eq.c 1.5$ */ ! /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/eq/RCS/eq.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/eq/RCS/eq.c,v 2.7 90/11/20 14:03:47 gk5g Exp $"; #endif /* lint */ /* *************** *** 382,387 **** --- 382,388 ---- struct eq *self; long n; { + if (n < 0) return 0; if (n < self->p1) return &(self->f[n]); else if (n < self->p1+self->p2) *** atk/eq/eqvcmds.c Wed Nov 22 12:02:26 1989 --- atk/eq/eqvcmds.c.NEW Wed Apr 3 21:18:05 1991 *************** *** 2,13 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/eq/RCS/eqvcmds.c,v 2.9 89/10/31 10:53:56 maria Exp $ */ /* $ACIS:eqvcmds.c 1.5$ */ ! /* $Source: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/eq/RCS/eqvcmds.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/eq/RCS/eqvcmds.c,v 2.9 89/10/31 10:53:56 maria Exp $"; #endif /* lint */ /* --- 2,13 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/eq/RCS/eqvcmds.c,v 2.10 91/03/27 14:38:38 gk5g Exp $ */ /* $ACIS:eqvcmds.c 1.5$ */ ! /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/eq/RCS/eqvcmds.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/eq/RCS/eqvcmds.c,v 2.10 91/03/27 14:38:38 gk5g Exp $"; #endif /* lint */ /* *************** *** 37,42 **** --- 37,45 ---- char *line = "{ zilch ^}"; + char* eqview_cut_prefix = "{ lpile d_eqstyle { "; + char* eqview_cut_suffix = "} } "; + /* * Call this routine when you have changed something in * the data structure and you want it to get updated on *************** *** 797,802 **** --- 800,811 ---- /* * Cut, copy, paste. + * + * The cut buffer is set up to contain an autonomous equation + * in case we are pasting into something other than an eq + * object. For this we use eqview_cut_prefix before and + * eqview_cut_suffix after the sub-equation we put into + * the cut buffer. */ void eqview_Cut(self) *************** *** 811,818 **** --- 820,829 ---- cutFile = im_ToCutBuffer(view_GetIM((struct view *) self)); fprintf(cutFile, "\\begindata{%s,%d}\n", class_GetTypeName(eqptr), dataobject_UniqueID(self)); + fprintf(cutFile, "%s", eqview_cut_prefix); eqptr->header.dataobject.writeID = im_GetWriteID(); eq_WriteFILE(eqptr, cutFile, pos, pos+len, ' '); + fprintf(cutFile, "%s", eqview_cut_suffix); fprintf(cutFile, "\\enddata{%s,%d}\n", class_GetTypeName(eqptr), dataobject_UniqueID(self)); im_CloseToCutBuffer(view_GetIM((struct view *) self), cutFile); eq_DeleteCarefully(eqptr, pos, pos+len); *************** *** 833,840 **** --- 844,853 ---- cutFile = im_ToCutBuffer(view_GetIM((struct view *) self)); fprintf(cutFile, "\\begindata{%s,%d}\n", class_GetTypeName(eqptr), dataobject_UniqueID(self)); + fprintf(cutFile, "%s", eqview_cut_prefix); eqptr->header.dataobject.writeID = im_GetWriteID(); eq_WriteFILE(eqptr, cutFile, pos, pos+len, ' '); + fprintf(cutFile, "%s", eqview_cut_suffix); fprintf(cutFile, "\\enddata{%s,%d}\n", class_GetTypeName(eqptr), dataobject_UniqueID(self)); im_CloseToCutBuffer(view_GetIM((struct view *) self), cutFile); } *************** *** 887,892 **** --- 900,925 ---- } i++; im_CloseFromCutBuffer(view_GetIM((struct view *) self), pasteFile); + } + + + /* The cut buffer is set up to contain an autonomous equation + in case we are pasting into something other than an eq + object. + + When we paste into eq, we remove the additional crud: + "{ lpile d_eqstyle { " before and "} } " after. */ + + /* first confirm the crud is there */ + if ((len >= 5) && + (eq_Access(eqptr, pos)->symbol->type == BEGIN) && + (eq_Access(eqptr, pos + 1)->symbol->type == ALIGN) && + (eq_Access(eqptr, pos + 2)->symbol->type == EQSTYLE) && + (eq_Access(eqptr, pos + 3)->symbol->type == BEGIN)) { + for (i = 3; i >= 0; i --) { + eq_Delete(eqptr, pos + i); + len -= 1; + } } /* eliminate unmatched groups */ *** atk/eq/symbols.c Wed Nov 22 12:02:39 1989 --- atk/eq/symbols.c.NEW Tue May 21 15:20:46 1991 *************** *** 2,13 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/eq/RCS/symbols.c,v 2.3 89/02/17 15:38:39 ghoti Exp $ */ /* $ACIS:symbols.c 1.2$ */ ! /* $Source: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/eq/RCS/symbols.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/eq/RCS/symbols.c,v 2.3 89/02/17 15:38:39 ghoti Exp $"; #endif /* lint */ /* --- 2,13 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/eq/RCS/symbols.c,v 2.3 1989/02/17 15:38:39 ghoti Exp $ */ /* $ACIS:symbols.c 1.2$ */ ! /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/eq/RCS/symbols.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/eq/RCS/symbols.c,v 2.3 1989/02/17 15:38:39 ghoti Exp $"; #endif /* lint */ /* *** atk/examples/ex1/helloa.c Wed Nov 22 12:06:23 1989 --- atk/examples/ex1/helloa.c.NEW Thu Apr 25 16:15:09 1991 *************** *** 2,8 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/examples/ex1/RCS/helloa.c,v 2.5 89/09/13 11:40:39 tpn Exp $ */ #include --- 2,8 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/examples/ex1/RCS/helloa.c,v 2.5 1989/09/13 11:40:39 tpn Exp $ */ #include *** atk/ez/eza.c Fri Dec 21 14:54:26 1990 --- atk/ez/eza.c.NEW Thu May 23 12:21:00 1991 *************** *** 1,20 **** - /*LIBS: -lframe -lbasics - */ /* ********************************************************************** *\ * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/ez/RCS/eza.c,v 2.13 90/09/11 15:31:18 gk5g Exp $ */ /* $ACIS:eza.c 1.5$ */ ! /* $Source: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/ez/RCS/eza.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/ez/RCS/eza.c,v 2.13 90/09/11 15:31:18 gk5g Exp $"; #endif /* lint */ #include #include /* For MAXPATHLEN. */ - #include /* sys/types.h sys/file.h */ #include #include --- 1,19 ---- /* ********************************************************************** *\ * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/ez/RCS/eza.c,v 2.14 90/12/14 15:05:57 ajp Exp $ */ /* $ACIS:eza.c 1.5$ */ ! /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/ez/RCS/eza.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/ez/RCS/eza.c,v 2.14 90/12/14 15:05:57 ajp Exp $"; #endif /* lint */ + #include /* sys/types.h sys/file.h */ + #include #include /* For MAXPATHLEN. */ #include #include *************** *** 26,31 **** --- 25,32 ---- #include #include #include + #include + #include #include #include *************** *** 205,211 **** long count = 0; int cc; /* Loop until we have a file in a buffer. */ ! while (frame_VisitFilePrompting(frame, "Please enter the name of an initial file: ", FALSE) < 0) { boolean first = TRUE; --- 206,212 ---- long count = 0; int cc; /* Loop until we have a file in a buffer. */ ! while (frame_VisitFilePrompting(frame, "Please enter the name of an initial file: ", FALSE, FALSE) < 0) { boolean first = TRUE; *************** *** 252,261 **** message_DisplayString(frame, 0, "New file."); } ! static void addFile(self,name,newWin,ro) struct ezapp *self; char *name; boolean newWin,ro; { /* Its a file right? */ struct ezapp_fileList *fileEntry= --- 253,263 ---- message_DisplayString(frame, 0, "New file."); } ! static void addFile(self,name,newWin,ro,initline) struct ezapp *self; char *name; boolean newWin,ro; + int initline; { /* Its a file right? */ struct ezapp_fileList *fileEntry= *************** *** 265,270 **** --- 267,273 ---- fileEntry->ObjectName=self->defaultObject; fileEntry->newWindow=newWin; fileEntry->readOnly=ro; + fileEntry->initLine=initline; fileEntry->next=NULL; *self->fileLink=fileEntry; self->fileLink=(&(fileEntry->next)); *************** *** 279,284 **** --- 282,289 ---- boolean useNewWindow = FALSE; boolean pendingReadOnly = FALSE; boolean pendingObject=FALSE; + int pendingInitLine=0; + char *name=ezapp_GetName(self); if(!super_ParseArgs(self,argc,argv)) *************** *** 306,311 **** --- 311,319 ---- fprintf(stderr,"%s: unrecognized switch: %s\n", ezapp_GetName(self), *argv); return FALSE; } + else if (**argv=='+') { + pendingInitLine=atoi((*argv+1)); + } else{ if(pendingObject){ self->defaultObject= *argv; *************** *** 314,322 **** addFile(self, *argv, (useNewWindow || maxInitWindows-->0), ! pendingReadOnly); useNewWindow=FALSE; pendingReadOnly=FALSE; } } } --- 322,331 ---- addFile(self, *argv, (useNewWindow || maxInitWindows-->0), ! pendingReadOnly, pendingInitLine); useNewWindow=FALSE; pendingReadOnly=FALSE; + pendingInitLine=0; } } } *************** *** 342,347 **** --- 351,377 ---- super_ReadInitFile(self); } + static void GotoLine(text, view, line) + struct text *text; + struct textview *view; + int line; + { + + int argument, pos, endpos; + register int count; + + pos = text_GetPosForLine(text, line); + textview_SetDotPosition(view, pos); + endpos = text_GetEndOfLine(text, pos); + if (line > 0) textview_SetDotLength(view, endpos - pos); + else textview_SetDotLength(view, 0); + + textview_FrameDot(view, pos); + textview_WantUpdate(view, view); + + return; + } + boolean ezapp__Start(self) struct ezapp *self; { *************** *** 362,368 **** char *defFile; if ((defFile = environ_GetProfile("DefaultStartUpFile")) != NULL && *defFile != '\0') { ! addFile(self, defFile, TRUE, FALSE); } } --- 392,398 ---- char *defFile; if ((defFile = environ_GetProfile("DefaultStartUpFile")) != NULL && *defFile != '\0') { ! addFile(self, defFile, TRUE, FALSE, 0); } } *************** *** 405,411 **** frame_PostDefaultHandler(self->frame, "message", frame_WantHandler(self->frame, "message")); frame_SetBuffer(self->frame, self->buffer, TRUE); self->haveBufferInWindow = TRUE; ! } } else { char errorMessage[200]; --- 435,454 ---- frame_PostDefaultHandler(self->frame, "message", frame_WantHandler(self->frame, "message")); frame_SetBuffer(self->frame, self->buffer, TRUE); self->haveBufferInWindow = TRUE; ! ! /* go to line */ ! { ! struct dataobject *d = buffer_GetData(self->buffer); ! struct frame *f = frame_GetFrameInWindowForBuffer(self->buffer); ! struct view *v = frame_GetView(f); ! ! if (v != NULL && class_IsTypeByName(class_GetTypeName(v), "textview")) { ! if (class_IsTypeByName(class_GetTypeName(d), "text")) { ! GotoLine(d, v, fileEntry->initLine); ! } ! } ! } ! } } else { char errorMessage[200]; *************** *** 461,466 **** --- 504,513 ---- else frame_SetTitle(self->frame, "No files specified."); /* This will get reset below. */ self->im = im_Create(NULL); + if(self->im == NULL) { + /* Cannot run any further anyway, so just exit instead of dumping core! j_mukerji@att.com*/ + exit(1); + } im_SetView(self->im, self->frame); frame_PostDefaultHandler(self->frame, "message", frame_WantHandler(self->frame, "message")); } *** atk/ez/eza.ch Wed Nov 22 12:11:21 1989 --- atk/ez/eza.ch.NEW Thu May 23 12:21:02 1991 *************** *** 2,13 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/ez/RCS/eza.ch,v 2.6 89/02/20 12:48:18 ghoti Exp $ */ /* $ACIS:eza.ch 1.4$ */ ! /* $Source: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/ez/RCS/eza.ch,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsidezapp_H = "$Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/ez/RCS/eza.ch,v 2.6 89/02/20 12:48:18 ghoti Exp $"; #endif /* !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) */ --- 2,13 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/ez/RCS/eza.ch,v 2.7 90/12/14 15:05:44 ajp Exp $ */ /* $ACIS:eza.ch 1.4$ */ ! /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/ez/RCS/eza.ch,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsidezapp_H = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/ez/RCS/eza.ch,v 2.7 90/12/14 15:05:44 ajp Exp $"; #endif /* !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) */ *************** *** 17,22 **** --- 17,23 ---- char *ObjectName; boolean newWindow; boolean readOnly; + int initLine; /* new */ }; class ezapp[eza]: application[app] { *** atk/ez/eztroff.help Wed Nov 22 12:11:31 1989 --- atk/ez/eztroff.help.NEW Fri Jun 14 12:12:27 1991 *************** *** 1,4 **** ! \begindata{text,269034604} \textdsversion{12} \template{help} \chapter{Advanced Formatting in EZ --- 1,4 ---- ! \begindata{text,269694168} \textdsversion{12} \template{help} \chapter{Advanced Formatting in EZ *************** *** 6,16 **** using\italic{ troff} Commands} If the styles available on menu cards in EZ do not meet your formatting needs, ! you can use commands from \italic{troff }, the UNIX "typeset runoff" ! formatting package. This help document is not intended to explain all of ! troff, but it does introduce you to some of the troff commands that produce ! frequently requested formatting effects. It includes sections on: \leftindent{General instructions --- 6,37 ---- using\italic{ troff} Commands} + \section{Avoiding troff} + + If the styles available on menu cards in EZ do not meet your formatting needs, ! you can probably obtain the effect you want through a combination of the ! \italic{lookz} style editor, the \italic{header}/footer object, and ! \italic{compchar}, a facility for composing international characters. See ! these help documents for more information: ! ! ! \leftindent{\italic{lookz} (line and paragraph spacing, margins) ! ! \italic{header }(headers and footers, page numbering) ! ! \italic{compchar} (international characters) ! ! } ! \section{Using troff} ! ! ! If you've read the section on "Avoiding troff" and have determined that those ! capabilities don't meet your needs, then you may want to use commands from ! \italic{troff }, the UNIX "typeset runoff" formatting package. This help ! document is not intended to explain all of troff, but it does introduce you to ! some of the troff commands that produce frequently requested formatting ! effects. It includes sections on: \leftindent{General instructions *************** *** 455,458 **** preview } (on-screen document viewer)\italic{ ! }}\enddata{text,269034604} --- 476,479 ---- preview } (on-screen document viewer)\italic{ ! }}\enddata{text,269694168} *** atk/ez/ezkeys.help Fri Dec 21 14:23:44 1990 --- atk/ez/ezkeys.help.NEW Tue May 21 18:15:10 1991 *************** *** 1,4 **** ! \begindata{text,268942132} \textdsversion{12} \template{help} \chapter{Keybindings in EZ} --- 1,4 ---- ! \begindata{text,269302716} \textdsversion{12} \template{help} \chapter{Keybindings in EZ} *************** *** 325,333 **** \leftindent{\bold{^X2 } Opens new window that displays same buffer as current window. ! \bold{^X^D} Deletes current window. (Buffer remains active in process.)} \section{Manipulating spacing, lines, and paragraphs } --- 325,336 ---- \leftindent{\bold{^X2 } Opens new window that displays same buffer as current window. ! \bold{^U^X2} Prompts for a hostname and then opens a new window that displays ! same buffer as current window on the specified host.\bold{ + ^X^D} Deletes current window. (Buffer remains active in process.) + } \section{Manipulating spacing, lines, and paragraphs } *************** *** 445,448 **** \italic{ez-styles } (Applying and deleting styles) ! }\enddata{text,268942132} --- 448,451 ---- \italic{ez-styles } (Applying and deleting styles) ! }\enddata{text,269302716} *** atk/extensions/Imakefile Wed Sep 26 16:04:21 1990 --- atk/extensions/Imakefile.NEW Fri Apr 26 16:28:27 1991 *************** *** 41,47 **** DependTarget() NormalHelpRule() ! InstallDocs(tags.help ezdiff.help compile.help search.help ezdproc.help comproc.help metax.help desproc.help dsrproc.help gsrproc.help isrproc.help ftrproc.help splproc.help tgsproc.help, ${DESTDIR}/help) InstallHelpAlias(ftrproc, filterproc filterprocs) InstallHelpAlias(splproc, spellproc spellprocs) InstallHelpAlias(tgsproc, tagsproc tagsprocs) --- 41,48 ---- DependTarget() NormalHelpRule() ! InstallDocs(tags.help ezdiff.help compile.help search.help ezdproc.help comproc.help metax.help desproc.help dsrproc.help gsrproc.help gsearch.help isrproc.help ftrproc.help splproc.help tgsproc.help, ${DESTDIR}/help) ! InstallHelpAlias(gsearch, search searches searching) InstallHelpAlias(ftrproc, filterproc filterprocs) InstallHelpAlias(splproc, spellproc spellprocs) InstallHelpAlias(tgsproc, tagsproc tagsprocs) *** atk/extensions/compile.c Fri Dec 21 14:54:29 1990 --- atk/extensions/compile.c.NEW Mon Dec 17 12:02:23 1990 *************** *** 4,15 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/extensions/RCS/compile.c,v 2.8 90/09/11 16:39:40 gk5g Exp $ */ /* $ACIS:compile.c 1.2$ */ ! /* $Source: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/extensions/RCS/compile.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/extensions/RCS/compile.c,v 2.8 90/09/11 16:39:40 gk5g Exp $"; #endif /* lint */ /* compile.c --- 4,15 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/extensions/RCS/compile.c,v 2.10 90/12/16 22:47:10 ajp Exp $ */ /* $ACIS:compile.c 1.2$ */ ! /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/extensions/RCS/compile.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/extensions/RCS/compile.c,v 2.10 90/12/16 22:47:10 ajp Exp $"; #endif /* lint */ /* compile.c *************** *** 16,23 **** * compilation package for be2 based editor. */ - #include #include #include #include #include --- 16,23 ---- * compilation package for be2 based editor. */ #include + #include #include #include #include *************** *** 90,96 **** } lengths.first = pos; lengths.second = pos + len + 1; ! buffer_EnumerateViews(buffer, SetDotToEnd, &lengths); text_NotifyObservers(doc, 0); } --- 90,96 ---- } lengths.first = pos; lengths.second = pos + len + 1; ! buffer_EnumerateViews(buffer, SetDotToEnd, (long) &lengths); text_NotifyObservers(doc, 0); } *************** *** 235,241 **** processBuffer->buffer = commandLog; processBuffer->process = currentProcess; ! im_AddFileHandler(inputFile, handler, processBuffer, 3); /* Priority chosen at random! Should be checked and replaced. */ return commandLog; } else --- 235,241 ---- processBuffer->buffer = commandLog; processBuffer->process = currentProcess; ! im_AddFileHandler(inputFile, handler, (char *) processBuffer, 3); /* Priority chosen at random! Should be checked and replaced. */ return commandLog; } else *************** *** 258,264 **** text_InsertCharacters(logDoc, length, buffer, len = strlen(buffer)); lengths.first = length; lengths.second = length + len; ! buffer_EnumerateViews(processBuffer->buffer, SetDotToEnd, &lengths); text_NotifyObservers(logDoc, 0); } else { --- 258,264 ---- text_InsertCharacters(logDoc, length, buffer, len = strlen(buffer)); lengths.first = length; lengths.second = length + len; ! buffer_EnumerateViews(processBuffer->buffer, SetDotToEnd, (long) &lengths); text_NotifyObservers(logDoc, 0); } else { *************** *** 356,362 **** struct view *view; { ! return (buffer_Enumerate(SaveModifiedBuffer, view) == NULL); } static void compile_Build(view, key) --- 356,362 ---- struct view *view; { ! return (buffer_Enumerate(SaveModifiedBuffer, (long) view) == NULL); } static void compile_Build(view, key) *************** *** 838,844 **** struct view *view; { ! return frame_Enumerate(ViewEqual, view); } /* Find a window other that the one that contains this inset. Create one if we have to. */ --- 838,844 ---- struct view *view; { ! return frame_Enumerate(ViewEqual, (long) view); } /* Find a window other that the one that contains this inset. Create one if we have to. */ *************** *** 856,862 **** myInfo.otherFrame = NULL; myInfo.bestFrame = NULL; myInfo.myBuffer = buffer; ! frame_Enumerate(FrameFinder, &myInfo); frame = (myInfo.bestFrame != NULL) ? myInfo.bestFrame : ((myInfo.otherFrame != NULL) ? myInfo.otherFrame : NULL); if (frame == NULL) { --- 856,862 ---- myInfo.otherFrame = NULL; myInfo.bestFrame = NULL; myInfo.myBuffer = buffer; ! frame_Enumerate(FrameFinder, (long) &myInfo); frame = (myInfo.bestFrame != NULL) ? myInfo.bestFrame : ((myInfo.otherFrame != NULL) ? myInfo.otherFrame : NULL); if (frame == NULL) { *************** *** 927,934 **** struct classinfo *textviewType = class_Load("textview"); char *command; ! proctable_DefineProc("compile-build", compile_Build, textviewType, NULL, "Start a compilation."); ! proctable_DefineProc("compile-kill-build", compile_KillBuild, textviewType, NULL, "Terminate a compilation."); proctable_DefineProc("compile-next-error", compile_NextError, textviewType, NULL, "Step forward through compilation errors."); proctable_DefineProc("compile-previous-error", compile_PreviousError, textviewType, NULL, "Step backward through compilation errors."); --- 927,934 ---- struct classinfo *textviewType = class_Load("textview"); char *command; ! proctable_DefineProc("compile-build", (procedure) compile_Build, textviewType, NULL, "Start a compilation."); ! proctable_DefineProc("compile-kill-build", (procedure) compile_KillBuild, textviewType, NULL, "Terminate a compilation."); proctable_DefineProc("compile-next-error", compile_NextError, textviewType, NULL, "Step forward through compilation errors."); proctable_DefineProc("compile-previous-error", compile_PreviousError, textviewType, NULL, "Step backward through compilation errors."); *** atk/extensions/deskey.c Fri Dec 21 14:54:31 1990 --- atk/extensions/deskey.c.NEW Mon Dec 17 12:02:25 1990 *************** *** 58,68 **** struct classinfo *imc; imc = class_Load("im"); ! proctable_DefineProc("deskey-describe-key", describeAKey, imc, NULL, "Show binding of a typed in key sequence."); ! proctable_DefineProc("deskey-describe-bound-procs", sortByProc, imc, NULL, "Show bindings for all keys."); ! proctable_DefineProc("deskey-describe-bound-keys", sortByKey, imc, NULL, "Show bindings for all keys."); ! proctable_DefineTypedProc("deskey-describe-proctable", describeAllProcEntries, imc, NULL, "List all proctable entries.; Return count.", proctable_Long); ! proctable_DefineTypedProc("deskey-list-proctable", ListProctable, imc, NULL, "List the entries in the proctable to /tmp/ProcList; Return count.", proctable_Long); return TRUE; } --- 58,68 ---- struct classinfo *imc; imc = class_Load("im"); ! proctable_DefineProc("deskey-describe-key", (procedure) describeAKey, imc, NULL, "Show binding of a typed in key sequence."); ! proctable_DefineProc("deskey-describe-bound-procs", (procedure) sortByProc, imc, NULL, "Show bindings for all keys."); ! proctable_DefineProc("deskey-describe-bound-keys", (procedure) sortByKey, imc, NULL, "Show bindings for all keys."); ! proctable_DefineTypedProc("deskey-describe-proctable", (procedure) describeAllProcEntries, imc, NULL, "List all proctable entries.; Return count.", proctable_Long); ! proctable_DefineTypedProc("deskey-list-proctable", (procedure) ListProctable, imc, NULL, "List the entries in the proctable to /tmp/ProcList; Return count.", proctable_Long); return TRUE; } *************** *** 141,147 **** struct frame *f; struct im *im; ! if ((f = frame_Enumerate(bufferFind, b))==NULL) { /* No frame--need to map buffer to new window */ if((f = frame_New()) == NULL) { --- 141,147 ---- struct frame *f; struct im *im; ! if ((f = frame_Enumerate(bufferFind, (long) b))==NULL) { /* No frame--need to map buffer to new window */ if((f = frame_New()) == NULL) { *************** *** 387,393 **** message_DisplayString(im, 0, "Parsing Proc List......"); im_ForceUpdate(); ! proctable_Enumerate(describeProcEntry, tmpf); pclose(tmpf); if (!bufferSetup(&f, im, &text)) return(NProcs); --- 387,393 ---- message_DisplayString(im, 0, "Parsing Proc List......"); im_ForceUpdate(); ! proctable_Enumerate((procedure) describeProcEntry, (char *) tmpf); pclose(tmpf); if (!bufferSetup(&f, im, &text)) return(NProcs); *************** *** 769,775 **** } message_DisplayString(im, 0, "Writing /tmp/ProcList"); im_ForceUpdate(); /* cause the message to appear */ ! proctable_Enumerate(ListAProc, f); pclose(f); message_DisplayString(im, 0, "Wrote /tmp/ProcList"); return NProcs; --- 769,775 ---- } message_DisplayString(im, 0, "Writing /tmp/ProcList"); im_ForceUpdate(); /* cause the message to appear */ ! proctable_Enumerate((procedure) ListAProc, (char *) f); pclose(f); message_DisplayString(im, 0, "Wrote /tmp/ProcList"); return NProcs; *** atk/extensions/dsearch.c Wed Nov 22 12:11:52 1989 --- atk/extensions/dsearch.c.NEW Mon Dec 17 12:02:27 1990 *************** *** 2,13 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/extensions/RCS/dsearch.c,v 2.6 89/02/24 09:02:07 ghoti Exp $ */ /* $ACIS:dsearch.c 1.2$ */ ! /* $Source: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/extensions/RCS/dsearch.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/extensions/RCS/dsearch.c,v 2.6 89/02/24 09:02:07 ghoti Exp $"; #endif /* lint */ #include --- 2,13 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/extensions/RCS/dsearch.c,v 2.8 90/12/16 22:46:30 ajp Exp $ */ /* $ACIS:dsearch.c 1.2$ */ ! /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/extensions/RCS/dsearch.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/extensions/RCS/dsearch.c,v 2.8 90/12/16 22:46:30 ajp Exp $"; #endif /* lint */ #include *************** *** 21,36 **** #include #define MAXSTRING 256 - static char lastString[MAXSTRING] = ""; - static char *LastPattern; - static int lcSearch = 0; - static int failures = 0; - /* Describe how the current seach string has failed. */ #define FORWARD 1 #define REVERSE 2 ! static void SearchForward(view) register struct textview *view; { --- 21,37 ---- #include #define MAXSTRING 256 /* Describe how the current seach string has failed. */ #define FORWARD 1 #define REVERSE 2 ! static char lastString[MAXSTRING] = ""; ! static char *lastPattern; ! static int lcSearch = 0; ! static int failures = 0; ! static int lastDirection = FORWARD; ! ! static void dynsearch_SearchForward(view) register struct textview *view; { *************** *** 38,43 **** --- 39,45 ---- register int count; register struct text *text; + lastDirection = FORWARD; text = (struct text *) view->header.view.dataobject; argument = im_Argument(textview_GetIM(view)); if (GetPattern(view, text, FORWARD) < 0) *************** *** 44,50 **** return; textview_SetDotPosition(view, textview_GetDotPosition(view) + textview_GetDotLength(view)); for (count = 0; count < argument; count++) { ! pos = search_MatchPattern (text, textview_GetDotPosition(view), LastPattern); if (pos < 0) { textview_SetDotLength(view,0); message_DisplayString(view, 0, "Search failed."); --- 46,52 ---- return; textview_SetDotPosition(view, textview_GetDotPosition(view) + textview_GetDotLength(view)); for (count = 0; count < argument; count++) { ! pos = search_MatchPattern (text, textview_GetDotPosition(view), lastPattern); if (pos < 0) { textview_SetDotLength(view,0); message_DisplayString(view, 0, "Search failed."); *************** *** 62,68 **** return; } ! static void SearchReverse(view) register struct textview *view; { --- 64,70 ---- return; } ! static void dynsearch_SearchReverse(view) register struct textview *view; { *************** *** 70,75 **** --- 72,78 ---- register int count; register struct text *text; + lastDirection = REVERSE; text = (struct text *) view->header.view.dataobject; originalPos = textview_GetDotPosition(view); argument = im_Argument(textview_GetIM(view)); *************** *** 79,85 **** if (originalPos > 0) textview_SetDotPosition(view, originalPos - 1); for (count = 0; count < argument; count++) { ! pos = search_MatchPatternReverse(text, textview_GetDotPosition(view), LastPattern); if (pos < 0) { textview_SetDotPosition(view, originalPos); message_DisplayString(view, 0, "Reverse search failed."); --- 82,88 ---- if (originalPos > 0) textview_SetDotPosition(view, originalPos - 1); for (count = 0; count < argument; count++) { ! pos = search_MatchPatternReverse(text, textview_GetDotPosition(view), lastPattern); if (pos < 0) { textview_SetDotPosition(view, originalPos); message_DisplayString(view, 0, "Reverse search failed."); *************** *** 132,152 **** useLast = TRUE; } else { ! int c, to, from; ! /* Use the current selection. */ ! for (to = 0, from = 0; from < len && to+2 < MAXSTRING; ++from) { ! c = text_GetChar(text, pos + from); ! if (c == '\\' || c == '[' || c == ']' || c == '*') ! string[to++] = '\\'; ! string[to++] = c; ! } ! string[to++] = 0; ! if (from < len) { ! message_DisplayString(view, 0, "Search string too long."); ! return -1; } if (strcmp(string, lastString) == 0) useLast = TRUE; } --- 135,154 ---- useLast = TRUE; } else { + /* Use the current selection. */ ! char unquotedString[MAXSTRING]; ! if (len >= sizeof(unquotedString) - 1) { ! message_DisplayString(view, 0, "Search string too long - continuing with truncating string."); ! len = sizeof(unquotedString) -1; ! } ! ! text_CopySubString(text, pos, len, unquotedString, FALSE); ! if (search_GetQuotedSearchString(unquotedString, string, sizeof(string)) == NULL) { ! message_DisplayString(view, 0, "Search string too long - continuing with truncating string."); } + if (strcmp(string, lastString) == 0) useLast = TRUE; } *************** *** 155,161 **** char *errorMessage; failures = 0; ! errorMessage = search_CompilePattern(string, &LastPattern); if (errorMessage != NULL) { message_DisplayString(view, 0, errorMessage); return -1; --- 157,163 ---- char *errorMessage; failures = 0; ! errorMessage = search_CompilePattern(string, &lastPattern); if (errorMessage != NULL) { message_DisplayString(view, 0, errorMessage); return -1; *************** *** 166,171 **** --- 168,221 ---- return 0; } + void dynsearch_SearchAgain(self) + struct textview *self; + { + struct text *d = (struct text *)textview_GetDataObject(self); + long savePos, pos; + + if (lastPattern != NULL) { + savePos = pos = textview_GetDotPosition(self); + + if (lastDirection == FORWARD) { + pos = textview_CollapseDot(self); + pos = search_MatchPattern(d, pos, lastPattern); + } + else { + textview_SetDotLength(self, 0); + if (pos > 0) + textview_SetDotPosition(self, --pos); + pos = search_MatchPatternReverse(d, pos, lastPattern); + } + if (pos < 0) + { + message_DisplayString(self, 0, "Search failed."); + if ( !lastDirection ) + textview_SetDotPosition(self, savePos); + } + else { + textview_SetDotPosition(self,pos); + textview_SetDotLength(self, search_GetMatchLength()); + textview_FrameDot(self,pos); + textview_WantUpdate(self, self); + } + } + else + message_DisplayString(self, 0, "Must have searched at least once to search again."); + } + + void dynsearch_SearchAgainOpposite(self) + struct textview *self; + { + if (lastDirection == FORWARD) { + lastDirection = REVERSE; + } + else { + lastDirection = FORWARD; + } + dynsearch_SearchAgain(self); + } + boolean dynsearch__InitializeClass(classID) struct classheader *classID; { *************** *** 172,184 **** struct classinfo *textviewClassinfo; lcSearch = im_AllocLastCmd(); ! LastPattern = NULL; lastString[0] = 0; textviewClassinfo = class_Load("textview"); ! proctable_DefineProc("dynsearch-search-forward", SearchForward, textviewClassinfo, NULL, "Search forward for a pattern; uses selection."); ! proctable_DefineProc("dynsearch-search-reverse", SearchReverse, textviewClassinfo, NULL, "Search backwards for a pattern; uses selection."); return TRUE; } --- 222,238 ---- struct classinfo *textviewClassinfo; lcSearch = im_AllocLastCmd(); ! lastPattern = NULL; lastString[0] = 0; textviewClassinfo = class_Load("textview"); ! proctable_DefineProc("dynsearch-search-forward", (procedure) dynsearch_SearchForward, textviewClassinfo, NULL, "Search forward for a pattern; uses selection."); ! proctable_DefineProc("dynsearch-search-reverse", (procedure) dynsearch_SearchReverse, textviewClassinfo, NULL, "Search backwards for a pattern; uses selection."); + proctable_DefineProc("dynsearch-search-again", (procedure) dynsearch_SearchAgain, textviewClassinfo, NULL, + "Search again in the same direction, using the last search pattern."); + proctable_DefineProc("dynsearch-search-again-opposite", (procedure) dynsearch_SearchAgainOpposite, textviewClassinfo, NULL, + "Search again in the opposite direction, using the last search pattern."); return TRUE; } *** atk/extensions/ezdiff.c Wed Sep 26 16:04:22 1990 --- atk/extensions/ezdiff.c.NEW Fri Apr 26 09:16:51 1991 *************** *** 2,13 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/extensions/RCS/ezdiff.c,v 2.12 90/08/13 10:49:03 ajp Exp $ */ /* $ACIS:ezdiff.c 1.4$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/extensions/RCS/ezdiff.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/extensions/RCS/ezdiff.c,v 2.12 90/08/13 10:49:03 ajp Exp $"; #endif /* lint */ #include --- 2,13 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/extensions/RCS/ezdiff.c,v 2.13 1990/12/16 22:47:44 ajp Exp $ */ /* $ACIS:ezdiff.c 1.4$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/extensions/RCS/ezdiff.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/extensions/RCS/ezdiff.c,v 2.13 1990/12/16 22:47:44 ajp Exp $"; #endif /* lint */ #include *************** *** 351,359 **** if(delta != USECURRENTMARK) self->cmark = delta; d1.m = self->m1[self->cmark]; sprintf(d1.buf,"diff %d of %d",self->cmark + 1,self->nummarks); ! buffer_EnumerateViews(self->buf[0],LocateInView,&d1); d1.m = self->m2[self->cmark]; ! buffer_EnumerateViews(self->buf[1],LocateInView,&d1); } static ezdiff_Current(v,delta) struct textview *v; --- 351,359 ---- if(delta != USECURRENTMARK) self->cmark = delta; d1.m = self->m1[self->cmark]; sprintf(d1.buf,"diff %d of %d",self->cmark + 1,self->nummarks); ! buffer_EnumerateViews(self->buf[0], LocateInView, (long) &d1); d1.m = self->m2[self->cmark]; ! buffer_EnumerateViews(self->buf[1], LocateInView, (long) &d1); } static ezdiff_Current(v,delta) struct textview *v; *** atk/extensions/ezdiff.ch Wed Nov 22 12:11:53 1989 --- atk/extensions/ezdiff.ch.NEW Fri Apr 26 09:16:58 1991 *************** *** 2,13 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/extensions/RCS/ezdiff.ch,v 2.7 89/10/09 14:46:27 tpn Exp $ */ /* $ACIS:ezdiff.ch 1.4$ */ ! /* $Source: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/extensions/RCS/ezdiff.ch,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsidezdiff_H = "$Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/extensions/RCS/ezdiff.ch,v 2.7 89/10/09 14:46:27 tpn Exp $"; #endif /* !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) */ class ezdiff : observable[observe] { --- 2,13 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/extensions/RCS/ezdiff.ch,v 2.7 1989/10/09 14:46:27 tpn Exp $ */ /* $ACIS:ezdiff.ch 1.4$ */ ! /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/extensions/RCS/ezdiff.ch,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsidezdiff_H = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/extensions/RCS/ezdiff.ch,v 2.7 1989/10/09 14:46:27 tpn Exp $"; #endif /* !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) */ class ezdiff : observable[observe] { *** atk/extensions/filter.c Wed Nov 22 12:11:58 1989 --- atk/extensions/filter.c.NEW Mon Dec 17 12:02:30 1990 *************** *** 4,15 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/extensions/RCS/filter.c,v 2.6 89/02/17 16:07:39 ghoti Exp $ */ /* $ACIS:filter.c 1.2$ */ ! /* $Source: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/extensions/RCS/filter.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/extensions/RCS/filter.c,v 2.6 89/02/17 16:07:39 ghoti Exp $"; #endif /* lint */ /* filter the textview selection region through a command --- 4,15 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/extensions/RCS/filter.c,v 2.7 90/12/16 22:47:50 ajp Exp $ */ /* $ACIS:filter.c 1.2$ */ ! /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/extensions/RCS/filter.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/extensions/RCS/filter.c,v 2.7 90/12/16 22:47:50 ajp Exp $"; #endif /* lint */ /* filter the textview selection region through a command *************** *** 163,169 **** message_DisplayString(tv,1,"Fork failed."); return; default: ! im_AddZombieHandler(pid,commandFinished,(long)fd); message_DisplayString(tv,0,"Filtering..."); } } --- 163,169 ---- message_DisplayString(tv,1,"Fork failed."); return; default: ! im_AddZombieHandler(pid, (procedure) commandFinished,(long)fd); message_DisplayString(tv,0,"Filtering..."); } } *************** *** 249,269 **** return FALSE; proctable_DefineProc("filter-filter-region", ! filterRegion,tvi,NULL,"Prompts for a command and executes it with the selection region as standard input, replacing the region with the output of the command."); proctable_DefineProc("filter-sink-region", ! sinkRegion,tvi,NULL,"Prompts for a command and provides the selected region as standard input to it; the command's output is discarded."); proctable_DefineProc("filter-filter-region-thru-command", ! filterRegionThruCommand,tvi,NULL,"Executes a command with the selection region as standard input, replacing it with the output of the command."); proctable_DefineProc("filter-sink-region-thru-command", ! sinkRegionThruCommand,tvi,NULL,"Provides the selected region as standard input to the specified command; the command's output is discarded."); proctable_DefineProc("filter-filter-region-formatted", ! filterRegionFmt,tvi,NULL,"Prompts for a command and executes it with the selection region as standard input, replacing the region with the output of the command. ATK datastream is read and written."); proctable_DefineProc("filter-sink-region-formatted", ! sinkRegionFmt,tvi,NULL,"Prompts for a command and provides the selected region as standard input to it; the command's output is discarded. ATK datastream is written."); proctable_DefineProc("filter-filter-region-thru-command-formatted", ! filterRegionThruCmdFmt,tvi,NULL,"Executes a command with the selection region as standard input, replacing it with the output of the command. ATK datastream is read and written."); proctable_DefineProc("filter-sink-region-thru-command-formatted", ! sinkRegionThruCmdFmt,tvi,NULL,"Provides the selected region as standard input to the specified command; the command's output is discarded. ATK datastream is written."); return TRUE; } --- 249,269 ---- return FALSE; proctable_DefineProc("filter-filter-region", ! (procedure) filterRegion,tvi,NULL,"Prompts for a command and executes it with the selection region as standard input, replacing the region with the output of the command."); proctable_DefineProc("filter-sink-region", ! (procedure) sinkRegion,tvi,NULL,"Prompts for a command and provides the selected region as standard input to it; the command's output is discarded."); proctable_DefineProc("filter-filter-region-thru-command", ! (procedure) filterRegionThruCommand,tvi,NULL,"Executes a command with the selection region as standard input, replacing it with the output of the command."); proctable_DefineProc("filter-sink-region-thru-command", ! (procedure) sinkRegionThruCommand,tvi,NULL,"Provides the selected region as standard input to the specified command; the command's output is discarded."); proctable_DefineProc("filter-filter-region-formatted", ! (procedure) filterRegionFmt,tvi,NULL,"Prompts for a command and executes it with the selection region as standard input, replacing the region with the output of the command. ATK datastream is read and written."); proctable_DefineProc("filter-sink-region-formatted", ! (procedure) sinkRegionFmt,tvi,NULL,"Prompts for a command and provides the selected region as standard input to it; the command's output is discarded. ATK datastream is written."); proctable_DefineProc("filter-filter-region-thru-command-formatted", ! (procedure) filterRegionThruCmdFmt,tvi,NULL,"Executes a command with the selection region as standard input, replacing it with the output of the command. ATK datastream is read and written."); proctable_DefineProc("filter-sink-region-thru-command-formatted", ! (procedure) sinkRegionThruCmdFmt,tvi,NULL,"Provides the selected region as standard input to the specified command; the command's output is discarded. ATK datastream is written."); return TRUE; } *** atk/extensions/isearch.c Wed Nov 22 12:11:59 1989 --- atk/extensions/isearch.c.NEW Tue Dec 18 14:14:50 1990 *************** *** 2,13 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/extensions/RCS/isearch.c,v 2.6 89/08/27 20:41:45 zs01 Exp $ */ /* $ACIS:isearch.c 1.2$ */ ! /* $Source: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/extensions/RCS/isearch.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/extensions/RCS/isearch.c,v 2.6 89/08/27 20:41:45 zs01 Exp $"; #endif /* lint */ #include --- 2,13 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/extensions/RCS/isearch.c,v 2.9 90/12/18 13:46:51 ajp Exp $ */ /* $ACIS:isearch.c 1.2$ */ ! /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/extensions/RCS/isearch.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/extensions/RCS/isearch.c,v 2.9 90/12/18 13:46:51 ajp Exp $"; #endif /* lint */ #include *************** *** 19,27 **** --- 19,30 ---- #include #include #include + #include #include + static boolean useSelectionRegion; + #define MAXSTRING 256 static char LastString[MAXSTRING] = {0}; *************** *** 42,53 **** *dst = '\0'; } ! static boolean dosearch(tv, txt, pos, string, forwardp, errmsg) struct textview *tv; struct text *txt; struct mark *pos; char *string, *errmsg; boolean forwardp; { int c, fudge; boolean results; --- 45,58 ---- *dst = '\0'; } ! static boolean dosearch(tv, txt, pos, string, forwardp, contForward, contBackward, errmsg) struct textview *tv; struct text *txt; struct mark *pos; char *string, *errmsg; boolean forwardp; + boolean contForward; + boolean contBackward; { int c, fudge; boolean results; *************** *** 56,61 **** --- 61,68 ---- static char prompt[MAXSTRING+256]; long loc; struct SearchPattern *pattern; + boolean newContForward = contForward; + boolean newContBackward = contBackward; do { if (strlen (string) > 0) strcpy(LastString, string); *************** *** 90,96 **** case 'S'-64: case 'R'-64: forwardp = (c == 'S'-64); ! strcpy(newstring, LastString); break; case 'H'-64: case '\177': --- 97,105 ---- case 'S'-64: case 'R'-64: forwardp = (c == 'S'-64); ! strcpy(newstring, LastString); ! newContForward = TRUE; ! newContBackward = TRUE; break; case 'H'-64: case '\177': *************** *** 105,111 **** else strappend(newstring, string, c, sizeof(newstring)); ! if (newstring[0] != '\0') { newpos = NULL; pattern = NULL; newerr = search_CompilePattern(newstring, &pattern); --- 114,121 ---- else strappend(newstring, string, c, sizeof(newstring)); ! if (newstring[0] != '\0') { ! loc = -1; newpos = NULL; pattern = NULL; newerr = search_CompilePattern(newstring, &pattern); *************** *** 115,130 **** else fudge = 0; ! if (forwardp) ! loc = search_MatchPattern(txt, textview_GetDotPosition(tv) + fudge, pattern); ! else ! loc = search_MatchPatternReverse(txt, textview_GetDotPosition(tv) - fudge, pattern); ! ! if (loc >= 0) ! newpos = text_CreateMark(txt, loc, search_GetMatchLength()); } ! results = dosearch(tv, txt, newpos, newstring, forwardp, newerr); if (newpos != NULL) { text_RemoveMark(txt, newpos); mark_Destroy(newpos); --- 125,157 ---- else fudge = 0; ! if (forwardp) { ! if (contForward) { ! loc = search_MatchPattern(txt, textview_GetDotPosition(tv) + fudge, pattern); ! } ! } ! else { ! if (contBackward) { ! loc = search_MatchPatternReverse(txt, textview_GetDotPosition(tv) - fudge, pattern); ! } ! } ! ! if (loc >= 0) { ! newpos = text_CreateMark(txt, loc, search_GetMatchLength()); ! newContForward = TRUE; ! newContBackward = TRUE; ! } ! else { ! if (forwardp) { ! newContForward = FALSE; ! } ! else { ! newContBackward = FALSE; ! } ! } } ! results = dosearch(tv, txt, newpos, newstring, forwardp, newContForward, newContBackward, newerr); if (newpos != NULL) { text_RemoveMark(txt, newpos); mark_Destroy(newpos); *************** *** 131,137 **** } } else ! results = dosearch(tv, txt, pos, newstring, forwardp, NULL); } while (results); return FALSE; } --- 158,164 ---- } } else ! results = dosearch(tv, txt, pos, newstring, forwardp, TRUE, TRUE, NULL); } while (results); return FALSE; } *************** *** 141,151 **** long key; { struct text *txt = (struct text *)(tv->header.view.dataobject); ! struct mark *mark = text_CreateMark(txt, textview_GetDotPosition(tv), textview_GetDotLength(tv)); ! ! while (dosearch(tv, txt, mark, "", key == 'S'-64, NULL)) ; text_RemoveMark(txt, mark); mark_Destroy(mark); } --- 168,196 ---- long key; { struct text *txt = (struct text *)(tv->header.view.dataobject); ! long pos = textview_GetDotPosition(tv); ! long len = textview_GetDotLength(tv); ! struct mark *mark = text_CreateMark(txt, pos, len); ! char *searchString = NULL; ! ! if (useSelectionRegion && len != 0) { ! char unquotedString[1000]; ! ! if (len >= sizeof(unquotedString) - 1) { ! message_DisplayString(tv, 0, "Search string too long - continuing with truncating string."); ! len = sizeof(unquotedString) -1; ! } ! ! text_CopySubString(txt, pos, len, unquotedString, FALSE); ! searchString = search_GetQuotedSearchString(unquotedString, NULL, 0); ! } ! ! while (dosearch(tv, txt, mark, (searchString != NULL) ? searchString : "", key == 'S'-64, TRUE, TRUE, NULL)) ; + if (searchString != NULL) { + free(searchString); + } text_RemoveMark(txt, mark); mark_Destroy(mark); } *************** *** 159,164 **** --- 204,211 ---- {NULL}, }; struct classinfo *textviewClassinfo; + + useSelectionRegion = environ_GetProfileSwitch("incsearchUseSelectionRegion", TRUE); textviewClassinfo = class_Load("textview"); if (textviewClassinfo != NULL) { *** atk/extensions/spell.c Mon Aug 6 11:06:08 1990 --- atk/extensions/spell.c.NEW Mon Dec 17 12:02:34 1990 *************** *** 2,13 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/extensions/RCS/spell.c,v 2.10 90/07/11 12:35:27 rr2b Exp $ */ /* $ACIS:spell.c 1.2$ */ ! /* $Source: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/extensions/RCS/spell.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/extensions/RCS/spell.c,v 2.10 90/07/11 12:35:27 rr2b Exp $"; #endif /* lint */ /* xspell.c --- 2,13 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/extensions/RCS/spell.c,v 2.11 90/12/16 22:47:55 ajp Exp $ */ /* $ACIS:spell.c 1.2$ */ ! /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/extensions/RCS/spell.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/extensions/RCS/spell.c,v 2.11 90/12/16 22:47:55 ajp Exp $"; #endif /* lint */ /* xspell.c *************** *** 368,374 **** boolean spell__InitializeClass(classID) struct classheader *classID; { ! proctable_DefineProc("spell-check-document", spell_CheckSpellingCmd, class_Load("textview"), NULL, "Checks spelling from the caret on."); expertMode = environ_GetProfileSwitch("expertmode", FALSE); return TRUE; --- 368,374 ---- boolean spell__InitializeClass(classID) struct classheader *classID; { ! proctable_DefineProc("spell-check-document", (procedure) spell_CheckSpellingCmd, class_Load("textview"), NULL, "Checks spelling from the caret on."); expertMode = environ_GetProfileSwitch("expertmode", FALSE); return TRUE; *** atk/extensions/tags.c Fri Dec 21 14:54:33 1990 --- atk/extensions/tags.c.NEW Wed Apr 3 21:19:09 1991 *************** *** 2,13 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/extensions/RCS/tags.c,v 2.9 90/09/11 16:40:41 gk5g Exp $ */ /* $ACIS:tags.c 1.2$ */ ! /* $Source: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/extensions/RCS/tags.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/extensions/RCS/tags.c,v 2.9 90/09/11 16:40:41 gk5g Exp $"; #endif /* lint */ /* * tags.c -- A tags package for the ATK editor --- 2,13 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/extensions/RCS/tags.c,v 2.12 91/04/03 16:23:48 susan Exp $ */ /* $ACIS:tags.c 1.2$ */ ! /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/extensions/RCS/tags.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/extensions/RCS/tags.c,v 2.12 91/04/03 16:23:48 susan Exp $"; #endif /* lint */ /* * tags.c -- A tags package for the ATK editor *************** *** 19,26 **** * Now does recursive edit -- give it an argument (^U) to AVOID recursive edit */ - #include #include #ifndef hp9000s300 #include #endif /* hp9000s300 */ --- 19,26 ---- * Now does recursive edit -- give it an argument (^U) to AVOID recursive edit */ #include + #include #ifndef hp9000s300 #include #endif /* hp9000s300 */ *************** *** 73,79 **** struct view *view; { ! return frame_Enumerate(ViewEqual, view); } --- 73,79 ---- struct view *view; { ! return frame_Enumerate(ViewEqual, (long) view); } *************** *** 238,244 **** char find[255]; struct text *doc; /* = (struct text *) view->dataobject;*/ ! long position, curpos; int same; static struct SearchPattern *result = NULL; --- 238,244 ---- char find[255]; struct text *doc; /* = (struct text *) view->dataobject;*/ ! long position, curpos, length; int same; static struct SearchPattern *result = NULL; *************** *** 247,252 **** --- 247,253 ---- struct buffer *filebuffer, *curbuf, *TagsBuffer; static char c, filename[256], searchstring[256]; char *fname=filename, *sstring=searchstring; + int match_bol = 0, match_eol = 0; /* open or create tags buffer */ *************** *** 278,291 **** /* skip over '/^' */ position = nextField(doc, position); ! c = text_GetChar(doc,position); ! while ((c=='/') || (c=='^')) c = text_GetChar(doc,++position); ! while ((c!='$') && (c!='/')) { ! if (c=='*') ! *sstring++ = '\\'; ! *sstring++ = c; c = text_GetChar(doc,++position); } *sstring = '\0'; --- 279,304 ---- /* skip over '/^' */ position = nextField(doc, position); ! do { c = text_GetChar(doc,++position); + } while ((c=='/') || (c=='?')); ! while ((c!='/') && (c!='?')) { ! switch(c) { ! case '^': ! *sstring++ = '\n'; ! match_bol = 1; ! break; ! case '$': ! *sstring++ = '\n'; ! match_eol = 1; ! break; ! case '*': ! *sstring++ = '\\'; ! /* fall through */ ! default: ! *sstring++ = c; ! } c = text_GetChar(doc,++position); } *sstring = '\0'; *************** *** 308,313 **** --- 321,334 ---- return; } + length = search_GetMatchLength(); + if (match_bol) { + position++; + length--; + } + if (match_eol) + length--; + /* set the filebuffer to be current buffer */ ourFrame=FindByView(view); *************** *** 322,328 **** ourView = frame_GetView(ourFrame); textview_SetDotPosition((struct textview *) ourView, position); ! textview_SetDotLength((struct textview *) ourView, search_GetMatchLength()); textview_FrameDot((struct textview *) ourView, position); --- 343,349 ---- ourView = frame_GetView(ourFrame); textview_SetDotPosition((struct textview *) ourView, position); ! textview_SetDotLength((struct textview *) ourView, length); textview_FrameDot((struct textview *) ourView, position); *************** *** 421,429 **** { struct classinfo *textviewType = class_Load("textview"); ! proctable_DefineProc("tags-goto-tag", tags_GotoTagCmd, textviewType, NULL, "Goto a given tag."); ! proctable_DefineProc("tags-find-tag", tags_FindTagCmd, textviewType, NULL, "Goto the tag whose name is at the dot."); ! proctable_DefineProc("tags-rebuild-tags", tags_RebuildTagsFile, textviewType, NULL, "Regenerate the tag file with ctags"); ! proctable_DefineProc("tags-load-tag-file", tags_LoadTagFileCmd, textviewType, NULL, "Load a tag file from the current directory"); return TRUE; } --- 442,450 ---- { struct classinfo *textviewType = class_Load("textview"); ! proctable_DefineProc("tags-goto-tag", (procedure) tags_GotoTagCmd, textviewType, NULL, "Goto a given tag."); ! proctable_DefineProc("tags-find-tag", (procedure) tags_FindTagCmd, textviewType, NULL, "Goto the tag whose name is at the dot."); ! proctable_DefineProc("tags-rebuild-tags", (procedure) tags_RebuildTagsFile, textviewType, NULL, "Regenerate the tag file with ctags"); ! proctable_DefineProc("tags-load-tag-file", (procedure) tags_LoadTagFileCmd, textviewType, NULL, "Load a tag file from the current directory"); return TRUE; } *** atk/extensions/metax.c Fri Dec 21 14:54:38 1990 --- atk/extensions/metax.c.NEW Mon Apr 22 13:43:50 1991 *************** *** 2,17 **** * Copyright IBM Corporation 1990 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/extensions/RCS/metax.c,v 1.2 90/09/06 22:35:42 ajp Exp $ */ /* $ACIS:$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/extensions/RCS/metax.c,v $ */ #include #include #include - #include #include #include #include --- 2,17 ---- * Copyright IBM Corporation 1990 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/extensions/RCS/metax.c,v 1.4 1991/04/18 22:18:41 rr2b Exp $ */ /* $ACIS:$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/extensions/RCS/metax.c,v $ */ + #include #include #include #include #include #include #include *************** *** 163,169 **** { struct helpRock myrock; struct framemessage *fmsg=(struct framemessage *)view_WantHandler(v,"message"); ! if(!class_IsTypeByName(class_GetTypeName(fmsg),"framemessage")) return; if(fmsg) { struct buffer *b=frame_GetHelpBuffer(fmsg->frame); --- 163,169 ---- { struct helpRock myrock; struct framemessage *fmsg=(struct framemessage *)view_WantHandler(v,"message"); ! if(!fmsg || !class_IsTypeByName(class_GetTypeName(fmsg),"framemessage")) return; if(fmsg) { struct buffer *b=frame_GetHelpBuffer(fmsg->frame); *** atk/extensions/gsearch.c Fri Dec 21 14:54:36 1990 --- atk/extensions/gsearch.c.NEW Thu May 30 18:34:18 1991 *************** *** 1,9 **** /* ********************************************************************** *\ * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * ! \* ********************************************************************** */ #include #include --- 1,11 ---- /* ********************************************************************** *\ * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * ! \* ********************************************************************** */ + #include #include + #include #include *************** *** 17,302 **** #include ! enum gsearchdir { ! gsdir_forward, ! gsdir_backward ! }; ! #define MAXPATLEN (512) #define CTRL_G (7) #define CTRL_H (8) #define CTRL_R (18) #define CTRL_S (19) #define ESC (27) #define DEL (127) ! static char rcsid[] = "$Revision: 1.3 $"; ! static char LastPattern[MAXPATLEN]; ! static void dosearch(tv, txt, startpos, dir) struct textview *tv; ! struct text *txt; ! struct mark *startpos; ! enum gsearchdir dir; ! { ! int patternlen = 0, success = 1, c, lastsuccesslen = 0; ! int okpattern, juststarted = 1; ! char pattern[MAXPATLEN], *compiled = NULL; ! char prompt[100 + MAXPATLEN], *compileerr = NULL; ! char defaultpattern[5 + MAXPATLEN]; ! struct mark *lastmatch = startpos; ! long loc; ! ! *pattern = '\0'; ! if (*LastPattern) ! sprintf(defaultpattern, " [%s]", LastPattern); while (1) { ! sprintf(prompt, "%sI-Search %s%s: %s", ! success ? "" : "Failing ", ! (dir == gsdir_forward) ? "forward" : "backward", ! ((juststarted && (*LastPattern)) ! ? defaultpattern ! : ""), ! pattern); ! if (compileerr) { ! strcat(prompt, " {"); ! strcat(prompt, compileerr); ! strcat(prompt, "}"); ! } ! message_DisplayString(tv, 0, prompt); ! im_ForceUpdate(); ! c = im_GetCharacter(textview_GetIM(tv)); ! switch (c) { ! case CTRL_G: ! if (success) { ! textview_SetDotPosition(tv, mark_GetPos(startpos)); ! textview_SetDotLength(tv, mark_GetLength(startpos)); ! textview_FrameDot(tv, mark_GetPos(startpos)); ! text_RemoveMark(txt, startpos); ! mark_Destroy(startpos); ! if (lastmatch != startpos) { ! text_RemoveMark(txt, lastmatch); ! mark_Destroy(lastmatch); ! } ! message_DisplayString(tv, 0, "Aborted."); ! im_ForceUpdate(); ! return; ! } ! /* We're currently in a failing search. */ ! juststarted = 0; ! success = 1; ! mark_SetPos(tv->atMarker, mark_GetPos(lastmatch)); ! mark_SetLength(tv->atMarker, ! mark_GetLength(lastmatch)); ! textview_FrameDot(tv, mark_GetPos(lastmatch)); ! pattern[patternlen = lastsuccesslen] = '\0'; ! compiled = NULL; ! if (patternlen > 0) { ! okpattern = ((compileerr = search_CompilePattern(pattern, &compiled)) == NULL); ! } ! break; ! case EOF: ! case ESC: ! mark_SetPos(tv->atMarker, mark_GetPos(startpos)); ! mark_SetLength(tv->atMarker, ! mark_GetLength(startpos)); ! text_RemoveMark(txt, startpos); ! mark_Destroy(startpos); ! if (lastmatch != startpos) { ! text_RemoveMark(txt, lastmatch); ! mark_Destroy(lastmatch); ! } ! message_DisplayString(tv, 0, "Mark set."); ! strcpy(LastPattern, pattern); ! im_ForceUpdate(); ! return; ! case CTRL_S: ! if (juststarted) { ! juststarted = 0; ! strcpy(pattern, LastPattern); ! patternlen = strlen(LastPattern); ! compiled = NULL; ! if (okpattern = ((compileerr = search_CompilePattern(pattern, &compiled)) == NULL)) { ! dir = gsdir_backward; /* To fool the following ! * code into thinking it's ! * reversing directions; ! * that way, the search ! * will start from the ! * current position ! * instead of pos + 1 */ ! } ! } ! if ((compiled != NULL) ! && okpattern) { ! if ((loc = search_MatchPattern(txt, textview_GetDotPosition(tv) + ((dir == gsdir_backward) ? 0 : 1), compiled)) ! >= 0) { ! /* Found it (again) */ ! if (lastmatch != startpos) { ! text_RemoveMark(txt, lastmatch); ! mark_Destroy(lastmatch); ! } ! lastmatch = text_CreateMark(txt, loc, search_GetMatchLength()); ! textview_SetDotPosition(tv, loc); ! textview_SetDotLength(tv, search_GetMatchLength()); ! textview_FrameDot(tv, loc); ! lastsuccesslen = patternlen; ! success = 1; ! } ! else { ! success = 0; ! } ! } ! dir = gsdir_forward; ! break; ! case CTRL_R: ! if (juststarted) { ! juststarted = 0; ! strcpy(pattern, LastPattern); ! patternlen = strlen(LastPattern); ! compiled = NULL; ! if (okpattern = ((compileerr = search_CompilePattern(pattern, &compiled)) == NULL)) { ! dir = gsdir_forward; /* To fool the following ! * code into thinking it's ! * reversing directions; ! * that way, the search ! * will start from the ! * current position ! * instead of pos - 1 */ ! } ! } ! if ((compiled != NULL) ! && okpattern) { ! if ((loc = search_MatchPatternReverse(txt, textview_GetDotPosition(tv) - ((dir == gsdir_forward) ? 0 : 1), compiled)) ! >= 0) { ! /* Found it (again) */ ! if (lastmatch != startpos) { ! text_RemoveMark(txt, lastmatch); ! mark_Destroy(lastmatch); ! } ! lastmatch = text_CreateMark(txt, loc, search_GetMatchLength()); ! textview_SetDotPosition(tv, loc); ! textview_SetDotLength(tv, search_GetMatchLength()); ! textview_FrameDot(tv, loc); ! lastsuccesslen = patternlen; ! success = 1; ! } ! else { ! success = 0; ! } ! } ! dir = gsdir_backward; ! break; ! case CTRL_H: ! case DEL: ! if (patternlen > 0) { ! if (okpattern) { ! if (dir == gsdir_forward) ! loc = search_MatchPatternReverse(txt, textview_GetDotPosition(tv) - 1, compiled); ! else ! loc = search_MatchPattern(txt, textview_GetDotPosition(tv) + 1, compiled); ! if (loc >= 0) { ! if (lastmatch != startpos) { ! text_RemoveMark(txt, lastmatch); ! mark_Destroy(lastmatch); ! } ! lastmatch = text_CreateMark(txt, loc, search_GetMatchLength()); ! textview_SetDotPosition(tv, loc); ! textview_SetDotLength(tv, search_GetMatchLength()); ! textview_FrameDot(tv, loc); ! lastsuccesslen = patternlen; ! success = 1; ! break; ! } ! } ! pattern[--patternlen] = '\0'; ! compiled = NULL; ! if (patternlen > 0) { ! if (okpattern = ((compileerr = search_CompilePattern(pattern, &compiled)) == NULL)) { ! if (dir == gsdir_forward) ! loc = search_MatchPatternReverse(txt, textview_GetDotPosition(tv), compiled); ! else ! loc = search_MatchPattern(txt, textview_GetDotPosition(tv), compiled); ! if (loc >= 0) { ! if (lastmatch != startpos) { ! text_RemoveMark(txt, lastmatch); ! mark_Destroy(lastmatch); ! } ! lastmatch = text_CreateMark(txt, loc, search_GetMatchLength()); ! textview_SetDotPosition(tv, loc); ! textview_SetDotLength(tv, search_GetMatchLength()); ! textview_FrameDot(tv, loc); ! lastsuccesslen = patternlen; ! success = 1; ! } ! else { /* OK pattern, but not found */ ! success = 0; ! } ! } ! } ! else { /* empty pattern, go back to square ! * 1 */ ! if (lastmatch != startpos) { ! text_RemoveMark(txt, lastmatch); ! mark_Destroy(lastmatch); ! } ! lastmatch = text_CreateMark(txt, textview_GetDotPosition(tv), 0); ! textview_SetDotLength(tv, 0); ! textview_FrameDot(tv, mark_GetPos(lastmatch)); ! lastsuccesslen = patternlen; /* i.e., 0 */ ! success = 1; ! } ! } ! break; ! default: ! if (isascii(c) && (isprint(c) || isspace(c))) { /* Extend the search ! * pattern */ ! juststarted = 0; ! pattern[patternlen++] = c; ! pattern[patternlen] = '\0'; ! compiled = NULL; ! if (okpattern = ((compileerr = search_CompilePattern(pattern, &compiled)) == NULL)) { ! if (dir == gsdir_forward) ! loc = search_MatchPattern(txt, textview_GetDotPosition(tv), compiled); ! else ! loc = search_MatchPatternReverse(txt, textview_GetDotPosition(tv), compiled); ! if (loc >= 0) { ! if (lastmatch != startpos) { ! text_RemoveMark(txt, lastmatch); ! mark_Destroy(lastmatch); ! } ! lastmatch = text_CreateMark(txt, loc, search_GetMatchLength()); ! textview_SetDotPosition(tv, loc); ! textview_SetDotLength(tv, search_GetMatchLength()); ! textview_FrameDot(tv, loc); ! lastsuccesslen = patternlen; ! success = 1; ! } ! else { ! success = 0; ! } ! } ! } ! else { /* Search is over */ ! mark_SetPos(tv->atMarker, mark_GetPos(startpos)); ! mark_SetLength(tv->atMarker, ! mark_GetLength(startpos)); ! text_RemoveMark(txt, startpos); ! mark_Destroy(startpos); ! if (lastmatch != startpos) { ! text_RemoveMark(txt, lastmatch); ! mark_Destroy(lastmatch); ! } ! message_DisplayString(tv, 0, "Mark set."); ! strcpy(LastPattern, pattern); ! im_ForceUpdate(); ! im_DoKey(textview_GetIM(tv), c); ! return; ! } ! break; ! } } } static void fsearch(tv, key) --- 19,741 ---- #include ! #define MAX(a,b) (((a)>(b))?(a):(b)) ! #define DYNSTR_GROWSIZE (64) ! #define STATESTACK_GROWSIZE (32) #define CTRL_G (7) #define CTRL_H (8) + #define CTRL_L (12) + #define CTRL_Q (17) #define CTRL_R (18) #define CTRL_S (19) + #define CTRL_W (23) + #define CTRL_Y (25) #define ESC (27) #define DEL (127) ! struct dynstr { ! int used, allocated; ! char *text; ! }; ! ! struct statestacknode { ! int patternlen, wrappedp, failurep; ! long position, length, searchfrom; ! int forwardp; ! }; ! ! struct statestack { ! int used, allocated; ! struct statestacknode *nodes; ! }; ! ! static char rcsid[] = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/extensions/RCS/gsearch.c,v 1.5 91/05/25 22:15:46 bobg Exp $"; ! ! extern char *malloc(), *realloc(); ! ! static jmp_buf jmpenv; ! static struct dynstr LastPattern; ! static struct statestacknode *StackTop; ! ! static int statestack_init(s) ! struct statestack *s; ! { ! s->used = 0; ! s->allocated = STATESTACK_GROWSIZE; ! if (!(s->nodes = ! (struct statestacknode *) malloc(STATESTACK_GROWSIZE * ! (sizeof (struct statestacknode))))) ! return (1); ! return (0); ! } ! ! static void statestack_destroy(s) ! struct statestack *s; ! { ! free(s->nodes); ! } ! ! static void statestack_pop(s) ! struct statestack *s; ! { ! --(s->used); ! StackTop = s->nodes + s->used - 1; ! } ! ! static void statestack_push(s, pl, wp, fp, pos, len, sf, fwdp) ! struct statestack *s; ! int pl, wp, fp; ! long pos, len, sf; ! int fwdp; ! { ! if (s->used == s->allocated) { ! int newsize = s->allocated + STATESTACK_GROWSIZE; ! ! if (!(s->nodes = ! (struct statestacknode *) ! realloc(s->nodes, ! newsize * (sizeof (struct statestacknode))))) ! longjmp(jmpenv, 1); ! s->allocated = newsize; ! } ! s->nodes[s->used].patternlen = pl; ! s->nodes[s->used].wrappedp = wp; ! s->nodes[s->used].failurep = fp; ! s->nodes[s->used].position = pos; ! s->nodes[s->used].length = len; ! s->nodes[s->used].searchfrom = sf; ! s->nodes[(s->used)++].forwardp = fwdp; ! StackTop = s->nodes + s->used - 1; ! } ! ! static int dynstr_init(d) ! struct dynstr *d; ! { ! d->used = 1; ! d->allocated = DYNSTR_GROWSIZE; ! if (!(d->text = malloc(DYNSTR_GROWSIZE))) ! return (1); ! d->text[0] = '\0'; ! return (0); ! } ! ! static void dynstr_shortento(d, size) ! struct dynstr *d; ! int size; ! { ! d->used = size; ! d->text[d->used - 1] = '\0'; ! } ! ! static void dynstr_ensuresize(d, size) ! struct dynstr *d; ! int size; ! { ! int newsize; ! ! if (d->allocated >= size) ! return; ! if (!(d->text = realloc(d->text, ! newsize = MAX(DYNSTR_GROWSIZE, ! size + (DYNSTR_GROWSIZE >> 1))))) ! longjmp(jmpenv, 1); ! d->allocated = newsize; ! } ! ! static void dynstr_put(d, str) ! struct dynstr *d; ! char *str; ! { ! int need = 1 + strlen(str); ! ! dynstr_ensuresize(d, need); ! strcpy(d->text, str); ! d->used = need; ! } ! ! static void dynstr_append(d, str) ! struct dynstr *d; ! char *str; ! { ! int need = d->used + strlen(str); ! ! dynstr_ensuresize(d, need); ! strcat(d->text, str); ! d->used = need; ! } ! ! static void dynstr_destroy(d) ! struct dynstr *d; ! { ! free(d->text); ! } ! ! static int dynstr_empty(d) ! struct dynstr *d; ! { ! return ((d->used == 0) || (d->text[0] == '\0')); ! } ! ! static void dynstr_addchar(d, c) ! struct dynstr *d; ! int c; ! { ! int need = d->used + 1; ! ! dynstr_ensuresize(d, need); ! d->text[d->used - 1] = c; ! d->text[(d->used)++] = '\0'; ! } ! static void dynstr_copy(dest, src) ! struct dynstr *dest, *src; ! { ! dynstr_ensuresize(dest, src->used); ! strcpy(dest->text, src->text); ! dest->used = src->used; ! } ! static void dosearch(tv, forwardp) struct textview *tv; ! int forwardp; ! { ! FILE *tmpfile; ! struct text *txt = (struct text *) textview_GetDataObject(tv); ! long origpos = textview_GetDotPosition(tv); ! long origlen = textview_GetDotLength(tv); ! long foundloc, newsearchfrom; ! struct dynstr pattern, prompt; ! int c, dodokey = 0, oldforwardp; ! char *compiled, *compileerr, *tmpbuf; ! struct statestack stack; ! ! if (dynstr_init(&pattern)) { ! message_DisplayString(tv, 0, "I-Search is out of memory; aborted."); ! im_ForceUpdate(); ! return; ! } ! if (dynstr_init(&prompt)) { ! dynstr_destroy(&pattern); ! message_DisplayString(tv, 0, "I-Search is out of memory; aborted."); ! im_ForceUpdate(); ! return; ! } ! if (statestack_init(&stack)) { ! dynstr_destroy(&pattern); ! dynstr_destroy(&prompt); ! message_DisplayString(tv, 0, "I-Search is out of memory; aborted."); ! im_ForceUpdate(); ! return; ! } ! ! if (setjmp(jmpenv)) { ! dynstr_destroy(&pattern); ! dynstr_destroy(&prompt); ! statestack_destroy(&stack); ! textview_SetDotPosition(tv, origpos); ! textview_SetDotLength(tv, origlen); ! textview_FrameDot(tv, origpos); ! message_DisplayString(tv, 0, "I-Search is out of memory; aborted."); ! im_ForceUpdate(); ! return; ! } ! ! statestack_push(&stack, 1, 0, 0, origpos, origlen, ! textview_GetDotPosition(tv), forwardp); ! ! initialstate: ! ! dynstr_put(&prompt, "I-Search"); ! if (!forwardp) ! dynstr_append(&prompt, " backward"); ! if (!dynstr_empty(&LastPattern)) { ! dynstr_append(&prompt, " ["); ! dynstr_append(&prompt, LastPattern.text); ! dynstr_append(&prompt, "]"); ! } ! dynstr_append(&prompt, ": "); ! message_DisplayString(tv, 0, prompt.text); ! im_ForceUpdate(); ! while (1) { ! c = im_GetCharacter(textview_GetIM(tv)); ! switch (c) { ! case CTRL_L: ! im_RedrawWindow(textview_GetIM(tv)); ! break; ! case CTRL_G: ! dynstr_destroy(&prompt); ! dynstr_destroy(&pattern); ! statestack_destroy(&stack); ! message_DisplayString(tv, 0, "Cancelled."); ! im_ForceUpdate(); ! return; ! case CTRL_H: ! case DEL: ! break; ! case CTRL_Q: ! while ((c = im_GetCharacter(textview_GetIM(tv))) == EOF) ! ; ! dynstr_addchar(&pattern, c); ! goto compilestate; ! case CTRL_R: ! case CTRL_S: ! forwardp = (c == CTRL_S); ! if (!dynstr_empty(&LastPattern)) { ! dynstr_copy(&pattern, &LastPattern); ! goto compilestate; ! } ! goto initialstate; ! case CTRL_W: ! if (textview_GetDotLength(tv) > 0) ! goto appendselectionstate; ! break; ! case CTRL_Y: ! goto appendkillheadstate; ! case ESC: ! case EOF: ! goto exitstate; ! default: ! if (isascii(c) && (isprint(c) || isspace(c))) { ! dynstr_addchar(&pattern, c); ! goto compilestate; ! } ! else { ! dodokey = 1; ! goto exitstate; ! } ! } ! } ! ! emptypatternstate: ! ! dynstr_put(&prompt, "I-Search"); ! if (!forwardp) ! dynstr_append(&prompt, " backward"); ! dynstr_append(&prompt, ": "); ! message_DisplayString(tv, 0, prompt.text); ! im_ForceUpdate(); ! while (1) { ! c = im_GetCharacter(textview_GetIM(tv)); ! switch (c) { ! case CTRL_L: ! im_RedrawWindow(textview_GetIM(tv)); ! break; ! case CTRL_G: ! dynstr_destroy(&prompt); ! dynstr_destroy(&pattern); ! statestack_destroy(&stack); ! message_DisplayString(tv, 0, "Cancelled."); ! im_ForceUpdate(); ! return; ! case CTRL_H: ! case DEL: ! break; ! case CTRL_Q: ! while ((c = im_GetCharacter(textview_GetIM(tv))) == EOF) ! ; ! dynstr_addchar(&pattern, c); ! goto compilestate; ! case CTRL_R: ! case CTRL_S: ! forwardp = (c == CTRL_S); ! goto initialstate; ! case CTRL_W: ! if (textview_GetDotLength(tv) > 0) ! goto appendselectionstate; ! break; ! case CTRL_Y: ! goto appendkillheadstate; ! case ESC: ! case EOF: ! goto exitstate; ! default: ! if (isascii(c) && (isprint(c) || isspace(c))) { ! dynstr_addchar(&pattern, c); ! goto compilestate; ! } ! else { ! dodokey = 1; ! goto exitstate; ! } ! } ! } ! ! compilestate: ! ! compiled = NULL; ! if ((compileerr = search_CompilePattern(pattern.text, ! &compiled)) == NULL) ! goto searchstate; ! statestack_push(&stack, pattern.used, StackTop->wrappedp, ! StackTop->failurep, StackTop->position, StackTop->length, ! StackTop->searchfrom, forwardp); ! goto partialstate; ! ! searchstate: ! ! if (forwardp) ! foundloc = search_MatchPattern(txt, StackTop->searchfrom, compiled); ! else ! foundloc = search_MatchPatternReverse(txt, StackTop->searchfrom, ! compiled); ! if (foundloc >= 0) { ! statestack_push(&stack, pattern.used, StackTop->wrappedp, ! 0, foundloc, search_GetMatchLength(), ! StackTop->searchfrom, forwardp); ! textview_SetDotPosition(tv, foundloc); ! textview_SetDotLength(tv, search_GetMatchLength()); ! textview_FrameDot(tv, foundloc); ! goto successstate; ! } ! statestack_push(&stack, pattern.used, StackTop->wrappedp, ! 1, StackTop->position, StackTop->length, ! StackTop->searchfrom, forwardp); ! if (im_IsPlaying()) { ! im_CancelMacro(); /* This section should emulate exitstate */ ! ! if (!dynstr_empty(&pattern)) ! dynstr_copy(&LastPattern, &pattern); ! dynstr_destroy(&prompt); ! dynstr_destroy(&pattern); ! statestack_destroy(&stack); ! mark_SetPos(tv->atMarker, origpos); ! mark_SetLength(tv->atMarker, origlen); ! message_DisplayString(tv, 0, ! "Search failed, macro aborted, mark set."); ! im_ForceUpdate(); ! return; ! } ! goto failurestate; ! ! newsearchstate: ! ! if (forwardp) ! foundloc = search_MatchPattern(txt, newsearchfrom, compiled); ! else ! foundloc = search_MatchPatternReverse(txt, newsearchfrom, ! compiled); ! if (foundloc >= 0) { ! statestack_push(&stack, pattern.used, StackTop->wrappedp, ! 0, foundloc, search_GetMatchLength(), ! newsearchfrom, forwardp); ! textview_SetDotPosition(tv, foundloc); ! textview_SetDotLength(tv, search_GetMatchLength()); ! textview_FrameDot(tv, foundloc); ! goto successstate; ! } ! statestack_push(&stack, pattern.used, StackTop->wrappedp, ! 1, StackTop->position, StackTop->length, ! StackTop->searchfrom, forwardp); ! if (im_IsPlaying()) { ! im_CancelMacro(); /* This section should emulate exitstate */ ! ! if (!dynstr_empty(&pattern)) ! dynstr_copy(&LastPattern, &pattern); ! dynstr_destroy(&prompt); ! dynstr_destroy(&pattern); ! statestack_destroy(&stack); ! mark_SetPos(tv->atMarker, origpos); ! mark_SetLength(tv->atMarker, origlen); ! message_DisplayString(tv, 0, ! "Search failed, macro aborted, mark set."); ! im_ForceUpdate(); ! return; ! } ! goto failurestate; ! ! wrapsearchstate: ! ! if (forwardp) ! foundloc = search_MatchPattern(txt, (long) 0, compiled); ! else ! foundloc = search_MatchPatternReverse(txt, text_GetLength(txt), ! compiled); ! if (foundloc >= 0) { ! statestack_push(&stack, pattern.used, 1, ! 0, foundloc, search_GetMatchLength(), ! (long) 0, forwardp); ! textview_SetDotPosition(tv, foundloc); ! textview_SetDotLength(tv, search_GetMatchLength()); ! textview_FrameDot(tv, foundloc); ! goto successstate; ! } ! statestack_push(&stack, pattern.used, 1, ! 1, StackTop->position, StackTop->length, ! StackTop->searchfrom, forwardp); ! if (im_IsPlaying()) { ! im_CancelMacro(); /* This section should emulate exitstate */ ! ! if (!dynstr_empty(&pattern)) ! dynstr_copy(&LastPattern, &pattern); ! dynstr_destroy(&prompt); ! dynstr_destroy(&pattern); ! statestack_destroy(&stack); ! mark_SetPos(tv->atMarker, origpos); ! mark_SetLength(tv->atMarker, origlen); ! message_DisplayString(tv, 0, ! "Search failed, macro aborted, mark set."); ! im_ForceUpdate(); ! return; ! } ! goto failurestate; ! ! partialstate: ! ! dynstr_put(&prompt, ""); ! if (StackTop->failurep) ! dynstr_append(&prompt, "Failing "); ! if (StackTop->wrappedp) { ! if (StackTop->failurep) ! dynstr_addchar(&prompt, 'w'); ! else ! dynstr_addchar(&prompt, 'W'); ! dynstr_append(&prompt, "rapped "); ! } ! dynstr_append(&prompt, "I-Search"); ! if (!forwardp) ! dynstr_append(&prompt, " backward"); ! dynstr_append(&prompt, ": "); ! dynstr_append(&prompt, pattern.text); ! dynstr_append(&prompt, " [incomplete input"); ! if (compileerr) { ! dynstr_append(&prompt, " - "); ! dynstr_append(&prompt, compileerr); ! } ! dynstr_append(&prompt, "]"); ! message_DisplayString(tv, 0, prompt.text); ! im_ForceUpdate(); ! while (1) { ! c = im_GetCharacter(textview_GetIM(tv)); ! switch (c) { ! case CTRL_L: ! im_RedrawWindow(textview_GetIM(tv)); ! break; ! case CTRL_G: ! dynstr_destroy(&prompt); ! dynstr_destroy(&pattern); ! statestack_destroy(&stack); ! message_DisplayString(tv, 0, "Cancelled."); ! im_ForceUpdate(); ! return; ! case CTRL_H: ! case DEL: ! goto popstate; ! case CTRL_Q: ! while ((c = im_GetCharacter(textview_GetIM(tv))) == EOF) ! ; ! dynstr_addchar(&pattern, c); ! goto compilestate; ! case CTRL_R: ! case CTRL_S: ! forwardp = (c == CTRL_S); ! break; ! case CTRL_W: ! goto appendselectionstate; ! case CTRL_Y: ! goto appendkillheadstate; ! case ESC: ! case EOF: ! goto exitstate; ! default: ! if (isascii(c) && (isprint(c) || isspace(c))) { ! dynstr_addchar(&pattern, c); ! goto compilestate; ! } ! else { ! dodokey = 1; ! goto exitstate; ! } ! } ! } ! ! exitstate: ! ! if (!dynstr_empty(&pattern)) ! dynstr_copy(&LastPattern, &pattern); ! dynstr_destroy(&prompt); ! dynstr_destroy(&pattern); ! statestack_destroy(&stack); ! mark_SetPos(tv->atMarker, origpos); ! mark_SetLength(tv->atMarker, origlen); ! message_DisplayString(tv, 0, "Mark set."); ! im_ForceUpdate(); ! if (dodokey) ! im_DoKey(textview_GetIM(tv), c); ! return; ! ! popstate: ! ! statestack_pop(&stack); ! goto poppedstate; ! ! popbeforeerrorstate: ! ! while (StackTop->failurep) { ! statestack_pop(&stack); ! } ! goto poppedstate; ! ! poppedstate: ! ! textview_SetDotPosition(tv, StackTop->position); ! textview_SetDotLength(tv, StackTop->length); ! textview_FrameDot(tv, StackTop->position); ! dynstr_shortento(&pattern, StackTop->patternlen); ! forwardp = StackTop->forwardp; ! if (dynstr_empty(&pattern)) ! goto emptypatternstate; ! compiled = NULL; ! if (compileerr = search_CompilePattern(pattern.text, &compiled)) ! goto partialstate; ! if (StackTop->failurep) ! goto failurestate; ! goto successstate; ! ! appendselectionstate: ! ! if (!(tmpbuf = malloc(1 + textview_GetDotLength(tv)))) { ! longjmp(jmpenv, 1); ! } ! text_CopySubString(txt, textview_GetDotPosition(tv), ! textview_GetDotLength(tv), tmpbuf, FALSE); ! dynstr_append(&pattern, tmpbuf); ! free(tmpbuf); ! goto compilestate; ! ! appendkillheadstate: ! ! tmpfile = im_FromCutBuffer(textview_GetIM(tv)); ! while ((c = fgetc(tmpfile)) != EOF) ! dynstr_addchar(&pattern, c); ! im_CloseFromCutBuffer(textview_GetIM(tv), tmpfile); ! goto compilestate; ! ! successstate: ! ! dynstr_put(&prompt, ""); ! if (StackTop->wrappedp) ! dynstr_append(&prompt, "Wrapped "); ! dynstr_append(&prompt, "I-Search"); ! if (!forwardp) ! dynstr_append(&prompt, " backward"); ! dynstr_append(&prompt, ": "); ! dynstr_append(&prompt, pattern.text); ! message_DisplayString(tv, 0, prompt.text); ! im_ForceUpdate(); while (1) { ! c = im_GetCharacter(textview_GetIM(tv)); ! switch (c) { ! case CTRL_L: ! im_RedrawWindow(textview_GetIM(tv)); ! break; ! case CTRL_G: ! dynstr_destroy(&prompt); ! dynstr_destroy(&pattern); ! statestack_destroy(&stack); ! textview_SetDotPosition(tv, origpos); ! textview_SetDotLength(tv, origlen); ! textview_FrameDot(tv, origpos); ! message_DisplayString(tv, 0, "Cancelled."); ! im_ForceUpdate(); ! return; ! case CTRL_H: ! case DEL: ! goto popstate; ! case CTRL_Q: ! while ((c = im_GetCharacter(textview_GetIM(tv))) == EOF) ! ; ! dynstr_addchar(&pattern, c); ! goto compilestate; ! case CTRL_R: ! case CTRL_S: ! oldforwardp = forwardp; ! forwardp = (c == CTRL_S); ! if (oldforwardp == forwardp) { ! if (forwardp) ! newsearchfrom = StackTop->position + 1; ! else ! newsearchfrom = StackTop->position - 1; ! goto newsearchstate; ! } ! goto successstate; ! case CTRL_W: ! if (textview_GetDotLength(tv) > 0) ! goto appendselectionstate; ! break; ! case CTRL_Y: ! goto appendkillheadstate; ! case ESC: ! case EOF: ! goto exitstate; ! default: ! if (isascii(c) && (isprint(c) || isspace(c))) { ! dynstr_addchar(&pattern, c); ! goto compilestate; ! } ! else { ! dodokey = 1; ! goto exitstate; ! } ! } } + + failurestate: + + dynstr_put(&prompt, "Failing "); + if (StackTop->wrappedp) + dynstr_append(&prompt, "wrapped "); + dynstr_append(&prompt, "I-search"); + if (!forwardp) + dynstr_append(&prompt, " backward"); + dynstr_append(&prompt, ": "); + dynstr_append(&prompt, pattern.text); + message_DisplayString(tv, 0, prompt.text); + im_ForceUpdate(); + while (1) { + c = im_GetCharacter(textview_GetIM(tv)); + switch (c) { + case CTRL_L: + im_RedrawWindow(textview_GetIM(tv)); + break; + case CTRL_G: + goto popbeforeerrorstate; + case CTRL_H: + case DEL: + goto popstate; + case CTRL_Q: + while ((c = im_GetCharacter(textview_GetIM(tv))) == EOF) + ; + dynstr_addchar(&pattern, c); + goto compilestate; + case CTRL_R: + case CTRL_S: + oldforwardp = forwardp; + forwardp = (c == CTRL_S); + if (oldforwardp == forwardp) + goto wrapsearchstate; + goto searchstate; + case CTRL_W: + if (textview_GetDotLength(tv) > 0) + goto appendselectionstate; + break; + case CTRL_Y: + goto appendkillheadstate; + case ESC: + case EOF: + goto exitstate; + default: + if (isascii(c) && (isprint(c) || isspace(c))) { + dynstr_addchar(&pattern, c); + goto compilestate; + } + else { + dodokey = 1; + goto exitstate; + } + } + } } static void fsearch(tv, key) *************** *** 303,312 **** struct textview *tv; long key; { ! struct text *txt = (struct text *) (tv->header.view.dataobject); ! struct mark *mark = text_CreateMark(txt, textview_GetDotPosition(tv), textview_GetDotLength(tv)); ! ! dosearch(tv, txt, mark, gsdir_forward); } static void rsearch(tv, key) --- 742,748 ---- struct textview *tv; long key; { ! dosearch(tv, 1); } static void rsearch(tv, key) *************** *** 313,322 **** struct textview *tv; long key; { ! struct text *txt = (struct text *) (tv->header.view.dataobject); ! struct mark *mark = text_CreateMark(txt, textview_GetDotPosition(tv), textview_GetDotLength(tv)); ! ! dosearch(tv, txt, mark, gsdir_backward); } boolean gsearch__InitializeClass() --- 749,755 ---- struct textview *tv; long key; { ! dosearch(tv, 0); } boolean gsearch__InitializeClass() *************** *** 324,335 **** static struct bind_Description fns[] = { {"gsearch-forward", NULL, 0, NULL, 0, 0, fsearch, "Search forward incrementally.", "gsearch"}, ! {"gsearch-backward", NULL, 0, NULL, 0, 0, rsearch, "Search backward incrementally.", "gsearch"}, {NULL}, }; struct classinfo *textviewClassinfo; ! *LastPattern = '\0'; textviewClassinfo = class_Load("textview"); if (textviewClassinfo != NULL) { bind_BindList(fns, NULL, NULL, textviewClassinfo); --- 757,770 ---- static struct bind_Description fns[] = { {"gsearch-forward", NULL, 0, NULL, 0, 0, fsearch, "Search forward incrementally.", "gsearch"}, ! {"gsearch-backward", NULL, 0, NULL, 0, 0, rsearch, ! "Search backward incrementally.", "gsearch"}, {NULL}, }; struct classinfo *textviewClassinfo; ! if (dynstr_init(&LastPattern)) ! return FALSE; textviewClassinfo = class_Load("textview"); if (textviewClassinfo != NULL) { bind_BindList(fns, NULL, NULL, textviewClassinfo); *** atk/extensions/gsearch.help Thu May 30 19:48:53 1991 --- atk/extensions/gsearch.help.NEW Mon Apr 29 15:40:36 1991 *************** *** 0 **** --- 1,274 ---- + \begindata{text,269676824} + \textdsversion{12} + \template{help} + \chapter{Gsearch: An Alternative Search Package for EZ that Works Like + GNU-Emacs Search + + } + \section{What gsearch is + + }\leftindent{ + Gsearch is an alternative to the standard search facility in EZ and other + Andrew applications. It allows you to search the text of a document for a + specified pattern, and operates almost identically to the search function in + the popular text-editor GNU-Emacs. The primary features of gsearch are: + + + \leftindent{\description{1. It's incremental. This means that, as you type in + the search pattern, you can see the match taking place in the text. (The + standard search package requires you to enter an entire search pattern, then + press \typewriter{ENTER}, before a search begins.) + + + 2. At the end of a successful search, gsearch will place a ``mark'' at the + starting location of the search. This way, you can easily jump back and forth + between where you came from and where the search put you, using + \typewriter{^X^X}, the swap-point-and-mark command. + + + 3. At the end of a failing search (signified by your aborting the operation + with \typewriter{^G}), gsearch returns you to the starting location of the + search. + + }}} + \section{Enabling gsearch + + }\leftindent{ + To be able to use gsearch, you need to specify a \italic{keybinding} for the + two gsearch commands, ``gsearch-forward'' and ``gsearch-backward.'' + Keybindings are specified in \italic{initfiles}. Each Andrew application, + such as EZ, uses a different initfile in your home directory. To enable + gsearch in, say, EZ, you would put the following two lines in your + \bold{~/.ezinit} file: + + + \example{addkey gsearch-forward ^S textview + + addkey gsearch-backward ^R textview + + } + This would cause the two functions to be bound to the keys \typewriter{^S} and + \typewriter{^R}, which are the bindings that most people use. You may choose + whatever bindings you like. + + + Some people have a file called \bold{~/.atkinit} which is \italic{included} by + all their other initfiles. If you put the above \typewriter{addkey} commands + in \bold{~/.atkinit}, then gsearch will be enabled in all Andrew applications. + + } + \section{Using gsearch + + }\leftindent{ + You begin a search by invoking either gsearch-forward or gsearch-backward, + usually by pressing \typewriter{^S} or \typewriter{^R}. You are then prompted + with an empty \italic{search pattern}. + + + Typing ordinary characters will place them in the search pattern. Any time + the search pattern changes, the best match for the current pattern is found + and displayed in the text by highlighting it. If no appropriate match is + found, you are placed in a \italic{failing} search (note that you're still in + a search even if it is, at the moment, failing). + + + If the search is presently failing, pressing \typewriter{^G} will restore you + to the last state in which the search was \italic{succeeding}. If the search + is presently succeeding, then pressing \typewriter{^G} will abort the + operation altogether and return you to where you were before you started the + search. + + + \typewriter{^S} and \typewriter{^R} are the ``search-again'' keys. If the + search is presently succeeding, then search-again will look for the next + occurrence of the current pattern. If the search is presently failing, + search-again will \italic{wrap around} the end of the document and look for + another occurrence starting at the other end. \typewriter{^S}, which is + ``search-again-forward,'' will cause the search to wrap around the bottom of + the document and search forward from the top; \typewriter{^R}, which is + ``search-again-backward,'' will cause the search to wrap around the top of the + document and search backward from the bottom. If you use search-again in the + opposite direction of the current search, then the search direction will be + reversed. + + + \typewriter{^S} and \typewriter{^R} can also be used at the beginning of a + search to choose the default pattern, if one is offered. The default pattern + is the most recent succeeding pattern from a previous search. If a default is + available, it will be shown in square brackets when the search begins. Use + \typewriter{^S} or \typewriter{^R} to indicate that you want to use the + default. + + + The \typewriter{ESC} key is used to indicate successful termination of a + search. When \typewriter{ESC} is pressed, the search terminates in the + current location, and the current pattern is stored to be used again later as + a default pattern. Also, a \italic{mark} is placed in the location where you + were before the search began. This allows you to use \typewriter{^X^X}, the + swap-point-and-mark command, to jump back and forth between where you were and + where the search put you. + + + \typewriter{^Q} is used to ``quote'' a character. Use it when you need to + place a character in the search pattern which would normally be interpreted as + a gsearch command. For instance, typing \typewriter{^Q^S} would place a + ``^S'' in the search pattern without invoking ``search-again.'' + + + \typewriter{^W} is used to place the currently-selected text in the document + onto the end of the search pattern. \typewriter{^Y} will yank the contents of + the cut buffer onto the end of the search pattern. + + + The \typewriter{BACKSPACE} or \typewriter{DELETE} key can be used to erase + characters from the end of the search pattern, but this isn't precisely how it + works. What actually happens is that, with each press of + \typewriter{BACKSPACE} or \typewriter{DELETE}, you are taken one step + backwards through the history of the search. Thus, it's possible to press + \typewriter{BACKSPACE} or \typewriter{DELETE} and not have any characters + erased from the search pattern. Here's an example (\underline{underlining} is + used to indicate text that is selected): + + + \leftindent{Your document consists of the text + + + \leftindent{\typewriter{xyz xyz}} + + + }\leftindent{The text caret is at the beginning of the document, before the + first \typewriter{x}. You invoke a forward search and type \typewriter{x} at + the prompt. The search pattern is now the string ``x,'' and this is what it + matches: + + + }\leftindent{\typewriter{\leftindent{\underline{x}yz xyz}} + + + }\leftindent{Next you type a \typewriter{y}, making the pattern ``xy.'' + + } + \leftindent{\typewriter{\leftindent{\underline{xy}z xyz + + + }}Next you type a z:\typewriter{\leftindent{ + + + \underline{xyz} xyz + + + }}Now you hit \typewriter{^S} to ``search-again-forward,'' and you + match\typewriter{\leftindent{ + + + xyz \underline{xyz + + + }}}Now suppose you use \typewriter{BACKSPACE} or \typewriter{DELETE}. You + will back up to the previous state you were in, which in this case does not + include erasing any characters. After pressing \typewriter{BACKSPACE} or + \typewriter{DELETE}, you will see + + + \leftindent{\typewriter{\underline{xyz} xyz}} + + + since this was your previous state. If you press \typewriter{BACKSPACE} or + \typewriter{DELETE} a second time, you will be returned to the state before + this one, in which the pattern was ``xy'' (\italic{now} you've managed to + erase that ``z'') and the match was + + + \leftindent{\typewriter{\underline{xy}z xyz}} + + + So, \typewriter{BACKSPACE} or \typewriter{DELETE} works by backing up over + previous states, not necessarily by backing up over previous characters.} + + + \typewriter{^L} can be used at any time to redraw the window. + + + If a character not recognized by gsearch is typed in, then that character is + assumed to be some other command. Gsearch will exit as if \typewriter{ESC} + had been pressed (i.e., it will leave you where you are, and will place a mark + where you came from) and will execute the new keystroke. For instance, if + \typewriter{^F} is typed during a search, then the search will terminate + successfully in the current location, and then \typewriter{^F}, the + move-forward-by-one-character command, will be executed. + + + At all times, the message line at the bottom of the window indicates the + current state of gsearch (backward or forward, failing or succeeding, wrapped + or not) and what the current pattern looks like. + + + }\section{Quick reference + + }\leftindent{ + \description{\typewriter{^S} Search-again-forward. Also used to select the + default pattern, if one is provided. Will reverse the direction of a backward + search. In a failing forward search, will wrap around the end of the + document. + + \typewriter{^R} Search-again-backward. Also used to select the default + pattern, if one is provided. Will reverse the direction of a forward search. + In a failing reverse search, will wrap around the beginning of the document. + + \typewriter{^Q} Quote the next character. Used to add unusual characters to + the search pattern. + + \typewriter{BACKSPACE} or \typewriter{DELETE} + + Back up through previous states of the search. Can loosely be thought of as + erasing the end of the search pattern. + + \typewriter{^G} Abort. In a failing search, returns to the most recent + succeeding state. Otherwise, aborts the search altogether and returns to the + pre-search location. + + \typewriter{ESC} Exit. Terminates the search in the current location, places + a mark in the pre-search location, and saves the succeeding pattern to be + offered as a default in the next search. + + \typewriter{^W} Add selection to pattern. Used to take the + currently-displayed selection and place it on the end of the search pattern. + + \typewriter{^Y} Yank. Used to place the contents of the cut buffer on the end + of the search pattern. + + \typewriter{^L} Redraw. Redraws the window at any time. + + \italic{printing characters} + + Printing characters add themselves to the end of the search pattern. This + includes whitespace characters, which also include things like newline and + tab. + + \italic{anything else} + + Any other characters typed in are taken to be a new editing command. The + search is exited as if \typewriter{ESC} had been pressed, and then the new + keystroke is executed. + + }} + \section{Program Author} + + \leftindent{ + Bob Glickstein, Information Technology Center} + + + \section{Related tools} + + + Select (highlight) one of the italicized names and choose "Show Help on + Selected Word" from the pop-up menu to see the help file for: + + + \leftindent{\italic{search + + initfiles + + ez-keys} + + }\enddata{text,269676824} *** atk/ezprint/Imakefile Wed Nov 22 12:12:47 1989 --- atk/ezprint/Imakefile.NEW Thu Apr 4 17:42:11 1991 *************** *** 10,15 **** --- 10,16 ---- InstallClassFiles($(DOBJS),$(IHFILES)) + DynamicObject(ezprinta,,${SUPLIBS}) InstallLink(runapp, ${DESTDIR}/bin/ezprint) InstallFileToFile(prscribe.csh,${INSTPROGFLAGS},${DESTDIR}/bin/printscribe) *** atk/ezprint/ezprinta.c Fri Dec 21 14:54:40 1990 --- atk/ezprint/ezprinta.c.NEW Tue May 7 14:16:43 1991 *************** *** 2,13 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/ezprint/RCS/ezprinta.c,v 2.17 89/10/20 14:42:52 tpn Exp Locker: ajp $ */ /* $ACIS:ezprinta.c 1.2$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/ezprint/RCS/ezprinta.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/ezprint/RCS/ezprinta.c,v 2.17 89/10/20 14:42:52 tpn Exp Locker: ajp $"; #endif /* lint */ #include /* For MAXPATHLEN. */ --- 2,13 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/ezprint/RCS/ezprinta.c,v 2.18 1990/12/14 15:07:32 ajp Exp $ */ /* $ACIS:ezprinta.c 1.2$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/ezprint/RCS/ezprinta.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/ezprint/RCS/ezprinta.c,v 2.18 1990/12/14 15:07:32 ajp Exp $"; #endif /* lint */ #include /* For MAXPATHLEN. */ *************** *** 20,25 **** --- 20,26 ---- * * */ + #include /* sys/file.h */ #include #include #include *************** *** 35,41 **** /* doc_Read(dd,file) */ #include #include - #include /* sys/file.h */ #include #define print_INDEXTROFF 42424 #include --- 36,41 ---- *************** *** 78,84 **** struct dataobject *d; struct view *v; char *objectName,*viewName; ! int objectID; int ffl = 0; int popt = PRINT; int status; --- 78,84 ---- struct dataobject *d; struct view *v; char *objectName,*viewName; ! long objectID; int ffl = 0; int popt = PRINT; int status; *** atk/fad/Imakefile Wed Nov 22 12:13:11 1989 --- atk/fad/Imakefile.NEW Thu Apr 4 17:42:13 1991 *************** *** 8,13 **** --- 8,19 ---- NormalObjectRule() NormalATKRule() + #ifdef SCOunix + DynamicObject(fadv,,${SUPLIBS} -lX11) + #else + DynamicObject(fadv,,${SUPLIBS}) + #endif + InstallClassFiles($(DOBJS),$(IHFILES)) InstallLink(runapp, ${DESTDIR}/bin/fad) *** atk/fad/fadv.c Fri Dec 21 14:54:42 1990 --- atk/fad/fadv.c.NEW Tue Apr 9 13:23:42 1991 *************** *** 2,13 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/fad/RCS/fadv.c,v 2.10 90/05/08 16:12:43 gk5g Exp Locker: tpn $ */ /* $ACIS:fadv.c 1.6$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/fad/RCS/fadv.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/fad/RCS/fadv.c,v 2.10 90/05/08 16:12:43 gk5g Exp Locker: tpn $"; #endif /* lint */ #include /* sys/time.h sys/types.h */ --- 2,13 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/fad/RCS/fadv.c,v 2.13 91/04/09 13:22:41 gk5g Exp $ */ /* $ACIS:fadv.c 1.6$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/fad/RCS/fadv.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/fad/RCS/fadv.c,v 2.13 91/04/09 13:22:41 gk5g Exp $"; #endif /* lint */ #include /* sys/time.h sys/types.h */ *************** *** 28,34 **** --- 28,36 ---- #include #include #include + #include + #define GetDelay(A) (event_MSECtoTU(20)) #define SetMode(A,B) (A->mode = (B)) #define GetMode(A) (A->mode) #define IsMode(A,B) (A->mode & B) *************** *** 65,70 **** --- 67,78 ---- fadview_DrawLineTo(P,(long)A->x2,(long)A->y2);} static void idraw(); + struct aniinfo { + struct fadview *self; + struct anivect *anbuf,*eap; + struct fad_frame *lf,*sf; + int i; + }; #define fdraw(A) if (ISICONORLABEL(A->x2)) idraw(self,A); else ldraw(self,A) #define ObjectOf(ll) ll->header.view.dataobject *************** *** 178,183 **** --- 186,214 ---- } if(cp->currentfont == NULL && cp->initializedfonts > 1) cp->currentfont = cp->fontpt[cp->initializedfonts - 1] ; } + HaltAnimation(self) + struct fadview *self; + { + if(self->nextevent){ + event_Cancel(self->nextevent); + self->nextevent = NULL; + } + if(self->anobj){ + self->f = self->anobj->sf ; + if(self->anobj->i != 0){ + /* redraw the last frame */ + self->Redraw = TRUE; + /* fadview_WantUpdate(self,self); */ + } + else self->Redraw = FALSE; + fadview_FlushGraphics(self); + free(self->anobj->anbuf); + free(self->anobj); + self->FrameChanged = TRUE; + self->anobj = NULL; + fadview_WantUpdate(self,self); + } + } void fadview__Update(self) struct fadview *self; *************** *** 187,192 **** --- 218,224 ---- if(self->removed) return; fadview_SetTransferMode(self,graphic_INVERT); self->needUpdate = FALSE; + if(self->anobj) { doan(self->anobj); return ;} if(self->DoAnimation){ if(!DoAnimation(self)) return; } cp = findpic(self); if(cp->labelfont == NULL) cp->labelfont = my_DefineFont(cp->labelfontname); *************** *** 229,234 **** --- 261,271 ---- self->Redraw = TRUE; self->FrameChanged = TRUE; recalc(self); + if(self->anobj) { + /* reset the ongoing animation */ + HaltAnimation(self); + self->DoAnimation = TRUE; + } fadview_Update(self); } void fadview__aniframe(self,framecount,startat,gofor,mtm) *************** *** 242,247 **** --- 279,306 ---- self->DoAnimation = TRUE; fadview_WantUpdate(self,self); } + static int dodoan(); + queup(self) + struct fadview *self; + { + struct fad *cp = findpic(self); + self->nextevent = im_EnqueueEvent(dodoan,self,event_MSECtoTU(cp->frtime)); + } + + static int + dodoan(self) + struct fadview *self; + { + self->nextevent = NULL; + if(self->anobj){ + if(! self->updatedue){ + queup(self); + fadview_WantUpdate(self,self); + } + self->updatedue = TRUE; + } + } + static DoAnimation(self) struct fadview *self; { *************** *** 248,260 **** struct fad *cp; struct fad_frame *lf,*sf; ! struct vector *vc,*vc1,*ov; ! struct timeval now,then; int i; float fc; ! register struct anivect *ap,*eap; register struct vector *vp,*nvp; struct anivect *anbuf,*endanbuf; self->DoAnimation = FALSE; cp = findpic(self); lf = cp->bf; --- 307,321 ---- struct fad *cp; struct fad_frame *lf,*sf; ! struct vector *vc; int i; float fc; ! struct aniinfo *anobj; ! register struct anivect *ap; register struct vector *vp,*nvp; struct anivect *anbuf,*endanbuf; + + anobj = (struct aniinfo *) malloc(sizeof(struct aniinfo)); self->DoAnimation = FALSE; cp = findpic(self); lf = cp->bf; *************** *** 322,372 **** vecdraw(self,vc); } lf = lf->f; ! for(eap = anbuf;sf != lf;){ ! #ifdef DEBUG ! fprintf(stderr,"%d %d\n",self->framecount,sf->av - eap); ! #endif /* DEBUG */ ! fadview_FlushGraphics(self); ! gettimeofday(&then,NULL); ! for(i = 0; i < self->framecount; i++){ ! for( ap = eap ;ap != sf->av; ap++){ ! fdraw(ap); ! ap->x1 += ap->dx1; ! ap->y1 += ap->dy1; ! if(ISICONORLABEL(ap->x2)) { ! idraw(self,ap); ! } ! else { ! ap->x2 += ap->dx2; ! ap->y2 += ap->dy2; ! ldraw(self,ap); ! } ! } ! fadview_FlushGraphics(self); ! if(self->mtm != 0){ ! gettimeofday(&now,NULL); ! /* first test if more than a second has already past, ! if not, then the loop can work without testing tv_sec ! if so, then we don't have to loop, since mtm can't be more ! then a second ! */ ! if(!(now.tv_sec > then.tv_sec && now.tv_usec >= then.tv_usec)){ ! do{ ! if(now.tv_usec < then.tv_usec) { ! then.tv_usec += -1000000; ! } ! if(now.tv_usec - then.tv_usec >= self->mtm) break; ! gettimeofday(&now,NULL); ! }while (1) ; ! gettimeofday(&then,NULL); ! } ! } ! } for( ap = eap ;ap != sf->av; ap++) fdraw(ap); ov = sf->v; eap = sf->av; ! sf= sf->f; /* draw any new vectors for next frame */ for(vc = sf->v,vc1 = ov; vc != NULL && vc1 != NULL; vc = vc->v,vc1 = vc1->v) { if(vc1->stat != 'C') vecdraw(self,vc); --- 383,427 ---- vecdraw(self,vc); } lf = lf->f; ! anobj->self= self; ! anobj->anbuf = anbuf; ! anobj->eap = anbuf; ! anobj->i = 0; ! anobj->sf = sf; ! anobj->lf = lf; ! self->anobj = anobj; ! doan(anobj); ! queup(self); ! return FALSE; ! /* */ ! } ! doan(anobj) ! struct aniinfo *anobj; ! { ! struct fadview *self; ! struct fad_frame *lf,*sf; ! struct vector *vc,*vc1,*ov; ! int i; ! register struct anivect *ap,*eap; ! ! ! self= anobj->self; ! eap = anobj->eap; ! lf = anobj->lf; ! sf = anobj->sf; ! i = anobj->i; ! if(i == self->framecount){ ! /* advance to next frame */ ! i = 0; ! anobj->i = i; ! (self->startat)++; for( ap = eap ;ap != sf->av; ap++) fdraw(ap); ov = sf->v; eap = sf->av; ! anobj->eap = eap; ! sf= sf->f; ! anobj->sf = sf; /* draw any new vectors for next frame */ for(vc = sf->v,vc1 = ov; vc != NULL && vc1 != NULL; vc = vc->v,vc1 = vc1->v) { if(vc1->stat != 'C') vecdraw(self,vc); *************** *** 378,391 **** for(;vc!= NULL;vc = vc->v) vecdraw(self,vc); } ! self->f = sf ; fadview_FlushGraphics(self); ! free(anbuf); ! self->Redraw = FALSE; ! self->FrameChanged = TRUE; ! return TRUE; ! } void fadview__nextframe(self,cp) struct fadview *self; struct fad *cp; --- 433,470 ---- for(;vc!= NULL;vc = vc->v) vecdraw(self,vc); } ! else i++; ! if(sf == lf){ ! /* done */ ! HaltAnimation(self); ! return TRUE; ! } ! for( ap = eap ;ap != sf->av; ap++){ ! fdraw(ap); ! ap->x1 += ap->dx1; ! ap->y1 += ap->dy1; ! if(ISICONORLABEL(ap->x2)) { ! idraw(self,ap); ! } ! else { ! ap->x2 += ap->dx2; ! ap->y2 += ap->dy2; ! ldraw(self,ap); ! } ! } ! /* fprintf(stdout,"drawing %d - %d\n",lf,i); fflush(stdout); */ ! if(self->FocusChanged){ ! fadview_DrawRectSize(self,0,0, fadview_GetLogicalWidth(self) -1, fadview_GetLogicalHeight(self)-1); ! self->FocusChanged = FALSE; ! } fadview_FlushGraphics(self); ! anobj->lf = lf; ! anobj->i = i; ! self->updatedue = FALSE; ! if (self->nextevent == NULL) ! queup(self); + } void fadview__nextframe(self,cp) struct fadview *self; struct fad *cp; *************** *** 503,509 **** --- 582,590 ---- struct classheader *classID; struct fadview *self; { + HaltAnimation(self); if(self->menulist) menulist_Destroy(self->menulist); + } boolean fadview__InitializeObject(classID, self) *************** *** 524,529 **** --- 605,612 ---- self->needUpdate = FALSE; self->FocusChanged = FALSE; self->mode = LINEMODE; + self->anobj = NULL; + self->nextevent = NULL; return TRUE; } *************** *** 590,595 **** --- 673,685 ---- struct vector *vec,*nv; struct fadpoint *fp,*lp; struct fad *cp = findpic(self); + if(self->anobj) { + if(cr == 'a' || cr == 'p' || cr == 'P'){ + HaltAnimation(self); + fadview_WantUpdate(self,self); + } + return; + } if(self->mode == WAITMODE) return; switch(cr){ case 'L': *************** *** 782,787 **** --- 872,882 ---- } UpdateCursor(self); break; + case 'P': + self->DoAnimation = TRUE; + (self->startat)++; + fadview_WantUpdate(self,self); + break; case 'N': self->mode = LINEMODE; UpdateCursor(self); *************** *** 840,845 **** --- 935,941 ---- struct fadpoint *pt; struct vector *vc; struct fad *cp = findpic(self); + if(self->anobj) return(FALSE); if(action == view_LeftDown){ if((pt = fad_setpoint(cp,mousex,mousey,OLD,self->f)) != NULL){ for(vc = self->f->v; vc != NULL ; vc = vc->v){ *************** *** 878,883 **** --- 974,980 ---- cpic->fp = NULL; return( self); } + if(self->anobj) return(self); if(cpic->readonly) { if(action == view_LeftUp || action == view_RightUp) fadview_aniframe(self,cpic->Frames,0,0,cpic->frtime); *************** *** 1371,1377 **** fadviewKeymap = keymap_New(); FadProc = proctable_DefineProc("fadview-keys", KeyIn,&fadview_classinfo,NULL,"get keyed commands"); ! for(c = "cnlramIfuEdDsRbBN",buf[1] = '\0'; *c; c++){ *buf = *c; keymap_BindToKey(fadviewKeymap, buf, FadProc, *c); } --- 1468,1474 ---- fadviewKeymap = keymap_New(); FadProc = proctable_DefineProc("fadview-keys", KeyIn,&fadview_classinfo,NULL,"get keyed commands"); ! for(c = "cnlramIfuEdDsRbBNqP",buf[1] = '\0'; *c; c++){ *buf = *c; keymap_BindToKey(fadviewKeymap, buf, FadProc, *c); } *** atk/fad/fadv.ch Fri Dec 21 14:54:44 1990 --- atk/fad/fadv.ch.NEW Thu Apr 4 17:42:15 1991 *************** *** 2,13 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/fad/RCS/fadv.ch,v 2.6 90/05/08 16:13:20 gk5g Exp Locker: tpn $ */ /* $ACIS:fadv.ch 1.5$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/fad/RCS/fadv.ch,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsidfadview_H = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/fad/RCS/fadv.ch,v 2.6 90/05/08 16:13:20 gk5g Exp Locker: tpn $"; #endif /* !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) */ #include --- 2,13 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/fad/RCS/fadv.ch,v 2.7 91/04/04 17:16:08 tpn Exp $ */ /* $ACIS:fadv.ch 1.5$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/fad/RCS/fadv.ch,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsidfadview_H = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/fad/RCS/fadv.ch,v 2.7 91/04/04 17:16:08 tpn Exp $"; #endif /* !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) */ #include *************** *** 50,53 **** --- 50,56 ---- boolean Redraw,FrameChanged,animationPending,needUpdate,FocusChanged; struct fad_frame *f; int mode; + struct aniinfo *anobj; + struct event *nextevent; + boolean updatedue; }; *** atk/frame/frame.c Fri Dec 21 14:24:46 1990 --- atk/frame/frame.c.NEW Mon May 13 14:21:18 1991 *************** *** 2,13 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/frame/RCS/frame.c,v 2.17 90/08/23 14:48:08 ajp Exp $ */ /* $ACIS:frame.c 1.6$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/frame/RCS/frame.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/frame/RCS/frame.c,v 2.17 90/08/23 14:48:08 ajp Exp $"; #endif /* lint */ /* frame.c --- 2,13 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/frame/RCS/frame.c,v 2.24 1991/05/07 15:29:27 tpn Exp $ */ /* $ACIS:frame.c 1.6$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/frame/RCS/frame.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/frame/RCS/frame.c,v 2.24 1991/05/07 15:29:27 tpn Exp $"; #endif /* lint */ /* frame.c *************** *** 37,42 **** --- 37,44 ---- #include #include #include + #include + #include extern char *index(); *************** *** 50,56 **** #define CANCEL 2 #define COMPLETE 3 #define HELP 4 ! struct pendingupdates { struct view *v; struct pendingupdates *next; --- 52,60 ---- #define CANCEL 2 #define COMPLETE 3 #define HELP 4 ! #define frame_SetUpperShade(SELF,P) frame_setShade(SELF,((P)?200:(self->mono ?25:45))) ! #define frame_SetLowerShade(SELF,P) frame_setShade(SELF,((P)?(self->mono ?25:45):200)) ! #define FORESHADE 30 struct pendingupdates { struct view *v; struct pendingupdates *next; *************** *** 73,79 **** --- 77,237 ---- static struct proctable_Entry *returnconsidered, *cancel, *confirmAnswer, *gotkey; static boolean QuitWindowOnlyDefault ; + static double foreground_color[3],background_color[3]; + #define BUTTONDEPTH 3 + #define BUTTONPRESSDEPTH 2 + #define TEXTPAD 2 + + static void frame_setShade(self, val) + struct frame *self; + int val; /* 0 - 200*/ + { + double pct; + if(val > 100){ + /* frame_SetFGColor(self,.95,.95,.95); */ + if (self->mono) pct = .75; + else { + /* frame_SetFGColor(self,.95,.95,.95); */ + frame_SetForegroundColor(self,"Dark Gray",0,0,0); + return; + } + } + else if(val == 100){ + frame_SetFGColor(self, + foreground_color[0], + foreground_color[1], + foreground_color[2]); + return ; + } + else if(val == 0){ + frame_SetFGColor(self, + background_color[0], + background_color[1], + background_color[2]); + return; + } + + else pct = (double)val/ 100.; + frame_SetFGColor(self, + foreground_color[0]* pct + + background_color[0]*(1.0-pct), + foreground_color[1]*pct + + background_color[1]*(1.0-pct), + foreground_color[2]*pct + + background_color[2]*(1.0-pct)); + + } /* frame_setShade */ + + + #define CFGCOLOR "white" + #define CBGCOLOR "blue" + + #define BWFGCOLOR "black" + #define BWBGCOLOR "white" + + frame_CacheSettings(self) + struct frame *self; + { + char *fgcolor, *bgcolor; + unsigned char fg_rgb[3], bg_rgb[3]; + self->mono = (frame_DisplayClass(self ) & graphic_Monochrome); + if ( self->mono ){ + fgcolor = BWFGCOLOR; + bgcolor = BWBGCOLOR; + } + else { + fgcolor = CFGCOLOR; + bgcolor = CBGCOLOR; + } + + if (frame_GetIM(self) != NULL) { + /* these calls don't make sense if there is no IM, + (in fact they seg fault!) */ + + frame_SetForegroundColor(self, fgcolor, fg_rgb[0]*256L, fg_rgb[1]*256L, fg_rgb[2]*256L); + frame_SetBackgroundColor(self, bgcolor, bg_rgb[0]*256L, bg_rgb[1]*256L, bg_rgb[2]*256L); + frame_GetFGColor(self, + &(foreground_color[0]), + &(foreground_color[1]), + &(foreground_color[2])); + frame_GetBGColor(self, + &(background_color[0]), + &(background_color[1]), + &(background_color[2])); + } + } + static void drawButton(self,rect,text,pushed,borderonly,blit) + struct frame * self; + struct rectangle *rect; + char *text; + boolean pushed,borderonly,blit; + { + + struct rectangle Rect2; + int r2_bot, r_bot; + int tx = 0, ty = 0; + short t_op; + long offset; + struct rectangle r; + r = *rect; + r.left +=frame_SEPARATION; r.top +=frame_SEPARATION; + r.width = self->buttonmaxwid + frame_TOTALPADDING - frame_TWOSEPARATIONS; + r.height -= frame_TWOSEPARATIONS; + rect = &r; /* BOGUS FIX THIS */ + offset = 0; + /* frame_SetFont(self, self->activefont); */ + + frame_SetTransferMode(self, graphic_SOURCE); + t_op = graphic_BETWEENLEFTANDRIGHT | graphic_BETWEENTOPANDBOTTOM; + Rect2.top = rect->top + BUTTONDEPTH + offset; + Rect2.left = rect->left + BUTTONDEPTH + offset; + Rect2.width = rect->width - 2*BUTTONDEPTH ; + Rect2.height = rect->height - 2*BUTTONDEPTH ; + r2_bot = (Rect2.top)+(Rect2.height); + r_bot = (rect->top)+(rect->height); + tx = Rect2.left + (Rect2.width/ 2); + + ty = Rect2.top + ( Rect2.height/ 2); + + frame_SetTransferMode(self, graphic_COPY); + if(!borderonly && (!self->mono || !blit)){ + frame_setShade(self, ((self->mono) ? 0:((pushed)? 0: FORESHADE))); + frame_FillRect(self, &Rect2, NULL); /* the middle box */ + if(text && *text){ + long len = strlen(text); + frame_setShade(self, 100); + frame_SetTransferMode(self, graphic_BLACK); + frame_MoveTo(self, tx, ty); + frame_DrawText(self, text, len,t_op); + frame_SetTransferMode(self, graphic_COPY); + } + } + if(self->mono && (blit || ((!blit) && pushed))){ + frame_SetTransferMode(self, graphic_INVERT); + frame_FillRect(self, rect, NULL); + frame_SetTransferMode(self, graphic_COPY); + } + if(self->mono){ + frame_setShade(self, 100); + frame_DrawRect(self,rect); + /* frame_DrawRect(self,&Rect2); */ + } + else { + /* Drawing the button is too slow on mono displays */ + frame_SetUpperShade(self,pushed) ; + frame_FillRectSize(self, rect->left, rect->top, BUTTONDEPTH + offset, rect->height, NULL); /* left bar */ + + frame_SetLowerShade(self,pushed) ; + frame_FillRectSize(self, rect->left + rect->width - BUTTONDEPTH + offset, rect->top, BUTTONDEPTH - offset, rect->height, NULL); /* right bar */ + frame_FillTrapezoid(self, Rect2.left, r2_bot, Rect2.width, rect->left, r_bot, rect->width, NULL); /* lower trapz */ + + frame_SetUpperShade(self,pushed) ; + frame_FillTrapezoid(self, rect->left, rect->top, rect->width, Rect2.left, Rect2.top, Rect2.width, NULL); /* upper trapz */ + frame_SetTransferMode(self, graphic_COPY); + } + } + static int CalculateLineHeight(self) struct frame *self; { *************** *** 188,194 **** enum view_UpdateType type; long left, top, width, height; { - if (self->lineHeight == 0) { self->lineHeight = CalculateLineHeight(self); frame_VFixed(self, self->childView, self->messageView, self->lineHeight, TRUE); --- 346,351 ---- *************** *** 195,203 **** } SetTitle(self); ! super_FullUpdate(self, type, left, top, width, height); ! if (self->IsAsking) { ComputeSize(self); DoUpdate(self); } --- 352,360 ---- } SetTitle(self); ! self->drawn = FALSE; super_FullUpdate(self, type, left, top, width, height); ! if (self->IsAsking) { ComputeSize(self); DoUpdate(self); } *************** *** 492,498 **** return LastBuffer; } /* Put the buffer in the dialog box */ ! if(self->DialogBuffer == NULL) NeedUpdate++; if (buf != self->DialogBuffer) { if (self->DialogBuffer != NULL) { if (self->DialogBufferView != NULL) --- 649,658 ---- return LastBuffer; } /* Put the buffer in the dialog box */ ! if(self->DialogBuffer == NULL){ ! self->drawn = FALSE; ! NeedUpdate++; ! } if (buf != self->DialogBuffer) { if (self->DialogBuffer != NULL) { if (self->DialogBufferView != NULL) *************** *** 545,551 **** else { char titleBuffer[WMTITLELEN], *titleLine; ! int len, maxLen = sizeof(titleBuffer) - 1; *titleBuffer = '\0'; --- 705,711 ---- else { char titleBuffer[WMTITLELEN], *titleLine; ! int maxLen = sizeof(titleBuffer) - 2; *titleBuffer = '\0'; *************** *** 552,595 **** if (self->buffer != NULL){ if(buffer_GetScratch(self->buffer)) self->dataModified = FALSE; ! else if (self->dataModified = (buffer_GetWriteVersion(self->buffer) < dataobject_GetModified(buffer_GetData(self->buffer)))) --maxLen; /* Make room for '*' */ } titleLine=buffer_GetFilename(frame_GetBuffer(self)); ! if (titleLine!= NULL){ ! char *home=environ_Get("HOME"); ! ! if(home!=NULL){ ! int hlen=strlen(home); ! if(strncmp(titleLine,home,hlen)==0){ ! strcpy(titleBuffer,"~"); ! --maxLen; ! titleLine+=hlen; ! } ! } ! ! len = strlen(titleLine); ! ! if (len > maxLen) { ! char *partialName; ! ! maxLen -= sizeof("---") - 1; ! partialName = index(titleLine + (len - maxLen), '/'); ! if (partialName == NULL) ! partialName = titleLine + (len - maxLen); ! else ! ++partialName; /* Skip slash... */ ! strcpy(titleBuffer, "---"); ! strcat(titleBuffer, partialName); ! } ! else ! strcat(titleBuffer, titleLine); ! }else{ titleLine=buffer_GetName(frame_GetBuffer(self)); if (titleLine==NULL) { im_SetTitle(frame_GetIM(self), ""); return; ! }else{ strcpy(titleBuffer, "Buffer: "); maxLen-=sizeof("Buffer: ")-1; strncat(titleBuffer,titleLine,maxLen); --- 712,732 ---- if (self->buffer != NULL){ if(buffer_GetScratch(self->buffer)) self->dataModified = FALSE; ! else if (self->dataModified = (buffer_GetWriteVersion(self->buffer) < dataobject_GetModified(buffer_GetData(self->buffer)))) { --maxLen; /* Make room for '*' */ + } } titleLine=buffer_GetFilename(frame_GetBuffer(self)); ! if (titleLine!= NULL && *titleLine != '\0'){ ! path_TruncatePath(titleLine, titleBuffer, maxLen, TRUE); ! } ! else { titleLine=buffer_GetName(frame_GetBuffer(self)); if (titleLine==NULL) { im_SetTitle(frame_GetIM(self), ""); return; ! } ! else{ strcpy(titleBuffer, "Buffer: "); maxLen-=sizeof("Buffer: ")-1; strncat(titleBuffer,titleLine,maxLen); *************** *** 630,638 **** --- 767,779 ---- break; case COMPLETE: frameview_Complete(self->dialogView,(long)' '); + drawButton(self,&self->HeightsOfAnswer[self->DefaultWildestAnswer], self->MultipleAnswers[self->DefaultWildestAnswer],FALSE,FALSE,self->drawn); + self->DefaultWildestAnswer = 0; return; case HELP: frameview_Help(self->dialogView,(long)'?'); + drawButton(self,&self->HeightsOfAnswer[self->DefaultWildestAnswer], self->MultipleAnswers[self->DefaultWildestAnswer],FALSE,FALSE,self->drawn); + self->DefaultWildestAnswer = 0; return; } } *************** *** 658,669 **** || (!self->IsBlocking && !InRectangle(&self->AnswerBox, x, y))) { return super_Hit(self, action, x, y, nclicks); } - if (action != view_LeftUp && action != view_RightUp) { return((struct view *) self); } /* Choose the answer here */ ! for (i=1; i<=self->NumAnswerChoices; ++i) { r = self->HeightsOfAnswer[i]; r.width = self->buttonmaxwid + frame_TOTALPADDING - frame_TWOSEPARATIONS; if (InRectangle(&r, x, y)) { --- 799,846 ---- || (!self->IsBlocking && !InRectangle(&self->AnswerBox, x, y))) { return super_Hit(self, action, x, y, nclicks); } + if (action == view_LeftDown || action == view_RightDown) { + r = self->HeightsOfAnswer[self->DefaultWildestAnswer]; + r.width = self->buttonmaxwid + frame_TOTALPADDING - frame_TWOSEPARATIONS; + if(!(InRectangle(&r, x, y))){ + for (i=1; i<=self->NumAnswerChoices; ++i) { + r = self->HeightsOfAnswer[i]; + r.width = self->buttonmaxwid + frame_TOTALPADDING - frame_TWOSEPARATIONS; + if (InRectangle(&r, x, y)) { + if(self->DefaultWildestAnswer != 0) + drawButton(self,&self->HeightsOfAnswer[self->DefaultWildestAnswer], self->MultipleAnswers[self->DefaultWildestAnswer],FALSE,FALSE,self->drawn); + self->DefaultWildestAnswer = i; + drawButton(self,&self->HeightsOfAnswer[self->DefaultWildestAnswer], self->MultipleAnswers[self->DefaultWildestAnswer],TRUE,FALSE,self->drawn); + } + } + } + return((struct view *) self); + } + else if (action == view_LeftMovement || action == view_RightMovement) { + if(self->DefaultWildestAnswer != 0){ + r = self->HeightsOfAnswer[self->DefaultWildestAnswer]; + r.width = self->buttonmaxwid + frame_TOTALPADDING - frame_TWOSEPARATIONS; + if(!(InRectangle(&r, x, y))){ + drawButton(self,&self->HeightsOfAnswer[self->DefaultWildestAnswer], self->MultipleAnswers[self->DefaultWildestAnswer],FALSE,FALSE,self->drawn); + self->PotentialChoice = self->DefaultWildestAnswer; + self->DefaultWildestAnswer = 0; + } + } + else if(self->PotentialChoice != 0){ + r = self->HeightsOfAnswer[self->PotentialChoice]; + r.width = self->buttonmaxwid + frame_TOTALPADDING - frame_TWOSEPARATIONS; + if((InRectangle(&r, x, y))){ + drawButton(self,&self->HeightsOfAnswer[self->PotentialChoice], self->MultipleAnswers[self->PotentialChoice],TRUE,FALSE,self->drawn); + self->DefaultWildestAnswer = self->PotentialChoice ; + self->PotentialChoice = 0; + } + } return((struct view *) self); } /* Choose the answer here */ ! i = self->DefaultWildestAnswer ; ! if(i > 0){ r = self->HeightsOfAnswer[i]; r.width = self->buttonmaxwid + frame_TOTALPADDING - frame_TWOSEPARATIONS; if (InRectangle(&r, x, y)) { *************** *** 693,747 **** frame_FillRectSize(self,r->left + OFFSET,r->top + r->height,r->width,OFFSET,frame_GrayPattern(self,8,16)); frame_FillRectSize(self,r->left + r->width,r->top + OFFSET,OFFSET,r->height - OFFSET,frame_GrayPattern(self,8,16)); } - static drawButton(self,rr,str,pushed) - struct frame *self; - struct rectangle *rr; - char *str; - boolean pushed; - { - - struct rectangle r; - r = *rr; - r.left +=frame_SEPARATION; r.top +=frame_SEPARATION; - r.width = self->buttonmaxwid + frame_TOTALPADDING - frame_TWOSEPARATIONS; - r.height -= frame_TWOSEPARATIONS; - frame_FillRectSize(self,r.left,r.top,r.width + BUTTONOFF,r.height + BUTTONOFF,frame_WhitePattern(self)); - #ifdef RAISEDBUTTONS - offset = (pushed) ? BUTTONON: BUTTONOFF; - if(pushed) { - r.left += BUTTONOFF - BUTTONON; r.top += BUTTONOFF - BUTTONON; - } - frame_FillTrapezoid(self,r.left,r.top + r.height, r.width, - r.left + offset, r.top + r.height + offset, r.width, - frame_GrayPattern(self,8,16)); - frame_FillTrapezoid(self,r.left + r.width ,r.top , 0, - r.left + r.width, r.top + offset,offset, - frame_GrayPattern(self,12,16)); - frame_FillTrapezoid(self,r.left + r.width ,r.top + r.height , offset, - r.left + r.width +offset , r.top + r.height + offset,0, - frame_GrayPattern(self,12,16)); - frame_FillRectSize(self,r.left + r.width ,r.top + offset, - offset,r.height - offset,frame_GrayPattern(self,12,16)); - frame_MoveTo(self,r.left + r.width,r.top ); - frame_DrawLine(self,offset,offset);frame_DrawLine(self,0,r.height); - frame_DrawLine(self,-r.width,0);frame_DrawLine(self,-offset,-offset); - frame_MoveTo(self,r.left + r.width,r.top + r.height); - frame_DrawLine(self,offset,offset); - #endif /* RAISEDBUTTONS */ - frame_DrawRect(self, &r); - if(str){ - frame_MoveTo(self, r.left + ((r.width - rr->width) / 2), r.top + frame_SEPARATION + 1); - frame_DrawString(self, str, graphic_ATLEFT | graphic_ATTOP); - } - if(pushed){ - r.top++; r.left++;r.width--;r.height--;r.width--;r.height--; - r.top++; r.left++;r.width--;r.height--; - frame_SetTransferMode(self, graphic_INVERT); - frame_FillRect(self, &r,frame_BlackPattern(self)); - frame_SetTransferMode(self, graphic_COPY); - } - } - static DoUpdate(self) struct frame *self; --- 870,875 ---- *************** *** 748,797 **** { struct rectangle *r; int i; ! ! SaveBits(self); ! frame_SetFont(self, self->myfontdesc); ! frame_SetTransferMode(self, graphic_COPY); ! if(self->DialogBuffer){ ! frame_FillRect(self, &self->bufferrec, frame_WhitePattern(self)); ! frame_FillRect(self, &self->AnswerBox, frame_WhitePattern(self)); /* Also clear area between boxes */ ! if(self->AnswerBox.top == self->bufferrec.top) ! frame_FillRectSize(self,self->AnswerBox.left + self->AnswerBox.width , self->AnswerBox.top,10, self->AnswerBox.height + OFFSET , frame_WhitePattern(self)); ! else { ! frame_FillRectSize(self,self->AnswerBox.left, self->AnswerBox.height +self->AnswerBox.top, self->AnswerBox.width + OFFSET ,10, frame_WhitePattern(self)); ! } ! } ! else ! frame_FillRect(self,&self->AnswerBox, frame_WhitePattern(self)); ! if(self->DialogBuffer) { ! drawshadow(self,&self->bufferrec); ! frame_DrawRect(self,&self->bufferrec); ! } ! drawshadow(self,&self->AnswerBox); ! frame_DrawRect(self,&self->AnswerBox); ! for (i=1; i<= self->NumAnswerChoices; ++i) { ! drawButton(self,&self->HeightsOfAnswer[i],self->MultipleAnswers[i],(i == self->DefaultWildestAnswer)); ! } ! if(self->hasDialogMessage){ ! r = &self->mesrec; ! frame_DrawRectSize(self, r->left - 1, r->top -1, r->width + 2, r->height + 2); ! } ! r = &self->HeightsOfAnswer[0]; ! frame_MoveTo(self, r->left + frame_SEPARATION + 3, r->top + frame_SEPARATION + 3); ! frame_DrawString(self, self->MultipleAnswers[0], graphic_ATLEFT | graphic_ATTOP); ! frame_PostCursor(self, &self->AnswerBox, self->octcursor); ! if(self->hasDialogMessage){ ! frameview_InsertView(self->dialogView, self, &self->mesrec); ! frameview_FullUpdate(self->dialogView, view_FullRedraw , 0, 0, 0, 0); ! frame_PostCursor(self, &self->mesrec, self->arrowcursor); ! if(self->DialogBuffer){ ! struct rectangle nr; ! nr = self->bufferrec; ! nr.top++;nr.left++; nr.width += -2; nr.height += -2; ! view_InsertView(self->DialogBufferView, self, &nr); ! view_FullUpdate(self->DialogBufferView, view_FullRedraw , 0, 0, 0, 0); } } } --- 876,939 ---- { struct rectangle *r; int i; ! if(!self->drawn){ ! struct graphic *pattern; ! frame_CacheSettings(self); ! pattern = ((self->mono) ? frame_WhitePattern(self):frame_BlackPattern(self)); ! self->drawn = TRUE; ! SaveBits(self); ! if(!self->mono)frame_setShade(self,FORESHADE); ! frame_SetFont(self, self->myfontdesc); ! frame_SetTransferMode(self, graphic_COPY); ! if(self->DialogBuffer){ ! frame_FillRect(self, &self->bufferrec, pattern); ! frame_FillRect(self, &self->AnswerBox, pattern); /* Also clear area between boxes */ ! if(!self->mono)frame_SetFGColor(self, 1.,1.,1.); ! if(self->AnswerBox.top == self->bufferrec.top) ! frame_FillRectSize(self,self->AnswerBox.left + self->AnswerBox.width , self->AnswerBox.top,10, self->AnswerBox.height + OFFSET , pattern ); ! else { ! frame_FillRectSize(self,self->AnswerBox.left, self->AnswerBox.height +self->AnswerBox.top, self->AnswerBox.width + OFFSET ,10, pattern); ! } ! } ! else ! frame_FillRect(self,&self->AnswerBox, pattern); ! frame_setShade(self,100); ! if(self->DialogBuffer) { ! drawshadow(self,&self->bufferrec); ! frame_DrawRect(self,&self->bufferrec); ! } ! drawshadow(self,&self->AnswerBox); ! frame_DrawRect(self,&self->AnswerBox); ! for (i=1; i<= self->NumAnswerChoices; ++i) { ! drawButton(self,&self->HeightsOfAnswer[i],self->MultipleAnswers[i],(i == self->DefaultWildestAnswer),FALSE,FALSE); ! } ! frame_setShade(self,100); ! if(self->hasDialogMessage){ ! r = &self->mesrec; ! frame_DrawRectSize(self, r->left - 1, r->top -1, r->width + 2, r->height + 2); ! } ! r = &self->HeightsOfAnswer[0]; ! frame_MoveTo(self, r->left + frame_SEPARATION + 3, r->top + frame_SEPARATION + 3); ! frame_DrawString(self, self->MultipleAnswers[0], graphic_ATLEFT | graphic_ATTOP); ! frame_PostCursor(self, &self->AnswerBox, self->octcursor); ! if(self->hasDialogMessage){ ! frameview_InsertView(self->dialogView, self, &self->mesrec); ! frameview_FullUpdate(self->dialogView, view_FullRedraw , 0, 0, 0, 0); ! frame_PostCursor(self, &self->mesrec, self->arrowcursor); ! if(self->DialogBuffer){ ! struct rectangle nr; ! nr = self->bufferrec; ! nr.top++;nr.left++; nr.width += -2; nr.height += -2; ! view_InsertView(self->DialogBufferView, self, &nr); ! view_FullUpdate(self->DialogBufferView, view_FullRedraw , 0, 0, 0, 0); ! } ! } ! if (frame_GetIM(self) != NULL) { ! frame_SetBGColor(self, 1.,1.,1.); ! frame_SetFGColor(self,0.,0.,0.); ! frame_SetTransferMode(self, graphic_INVERT); } } } *************** *** 1080,1088 **** if (++curpt > self->NumAnswerChoices) curpt = 1; if ((*self->MultipleAnswers[curpt] == c) || (*self->MultipleAnswers[curpt] == c1)) { ! drawButton(self,&self->HeightsOfAnswer[self->DefaultWildestAnswer], self->MultipleAnswers[self->DefaultWildestAnswer],FALSE); self->DefaultWildestAnswer = curpt; ! drawButton(self,&self->HeightsOfAnswer[self->DefaultWildestAnswer], self->MultipleAnswers[self->DefaultWildestAnswer],TRUE); return; } if (curpt == startpt) { --- 1222,1230 ---- if (++curpt > self->NumAnswerChoices) curpt = 1; if ((*self->MultipleAnswers[curpt] == c) || (*self->MultipleAnswers[curpt] == c1)) { ! if(self->DefaultWildestAnswer != 0) drawButton(self,&self->HeightsOfAnswer[self->DefaultWildestAnswer], self->MultipleAnswers[self->DefaultWildestAnswer],FALSE,FALSE,self->drawn); self->DefaultWildestAnswer = curpt; ! drawButton(self,&self->HeightsOfAnswer[self->DefaultWildestAnswer], self->MultipleAnswers[self->DefaultWildestAnswer],TRUE,FALSE,self->drawn); return; } if (curpt == startpt) { *************** *** 1141,1146 **** --- 1283,1289 ---- self->IsAsking = self->NumAnswerChoices = 0; self->IsBlocking = TRUE; + self->drawn = FALSE; self->DefaultWildestAnswer = self->StackPos = -1; self->PositionalPreference = message_Center; self->MultipleAnswers = NULL; *************** *** 1164,1169 **** --- 1307,1313 ---- self->DialogBufferView = NULL; self->DialogTargetView = NULL; self->hasDialogMessage = 0; + self->PotentialChoice = 0; } static isDialogChild(self, v) struct frame *self; *************** *** 1189,1195 **** pu->v = v; self->uplist = pu; } ! super_WantUpdate(self, self); self->UpdateRequested = TRUE; } else { super_WantUpdate(self, v); --- 1333,1339 ---- pu->v = v; self->uplist = pu; } ! super_WantUpdate(self, self); self->UpdateRequested = TRUE; } else { super_WantUpdate(self, v); *************** *** 1218,1224 **** int bufferSize; /* Is actual sizeof buffer including NUL. */ boolean CompButtons; { ! static char *ans[4]; struct view *focus; self->AwaitingFocus = 1; focus = im_GetInputFocus(frame_GetIM(self)); --- 1362,1368 ---- int bufferSize; /* Is actual sizeof buffer including NUL. */ boolean CompButtons; { ! static char *ans[6]; struct view *focus; self->AwaitingFocus = 1; focus = im_GetInputFocus(frame_GetIM(self)); *************** *** 1271,1276 **** --- 1415,1440 ---- if (focus) view_WantInputFocus(focus,focus); return i; } + int frame__AskForPasswd(self, priority, prompt, defaultString, buffer, bufferSize) + struct frame *self; + int priority; + char *prompt, *defaultString, *buffer; + int bufferSize; /* Is actual sizeof buffer including NUL. */ + { + int i; + struct view *focus; + if (self->IsAsking || self->AwaitingFocus) return(-1); + focus = PrepareForStringInput(self,prompt,bufferSize,FALSE); + i = framemessage_AskForPasswd(self->dialogLine, 0 ,"", defaultString, buffer, bufferSize); + while(im_Interact(0)); + --frame_GlobalStackCount; + retractCursors(self); + if(!RestoreBits(self)) + CannotRestoreBits(self); + TidyUp(self); + if (focus) view_WantInputFocus(focus,focus); + return i; + } int frame__AskForStringCompleted(self, priority, prompt, defaultString, buffer, bufferSize, keystate, completionProc, helpProc, completionData, flags) struct frame *self; int priority; *************** *** 1345,1348 **** --- 1509,1573 ---- keymap_BindToKey(mykm, "\015", confirmAnswer, 0); QuitWindowOnlyDefault = environ_GetProfileSwitch("QuitWindowOnly", FALSE); return TRUE; + } + + static boolean + FindBuffer(f,b) + struct frame *f; + struct buffer *b; + { + /* + Little, dippy routine passed to frame_Enumerate to find the + frame which contains the buffer we want. + */ + + return(frame_GetBuffer(f)==b); + } + + struct frame *frame__FindFrameForBuffer(classhdr, b) + struct classheader *classhdr; + struct buffer *b; + { + /* + This tries to find the frame of our buffer. If there is no + such frame, make one + */ + + struct frame *f; + + if ((f = frame_Enumerate(FindBuffer, (long) b)) == NULL) { + /* No frame--need to map buffer to new window */ + + if((f = frame_New()) == NULL) { + fprintf(stderr,"frame: Could not allocate enough memory.\n"); + return NULL; + } + + frame_SetCommandEnable(f, TRUE); + frame_SetBuffer(f, b, TRUE); + } + return f; + } + + struct frame *frame__GetFrameInWindowForBuffer(classhdr, b) + struct classheader *classhdr; + struct buffer *b; + { + struct frame *f; + struct im *im; + + f = frame_FindFrameForBuffer(b); + + if (f != NULL) { + if (frame_GetIM(f) == NULL) { + if((im = im_Create(NULL)) == NULL) { + fprintf(stderr,"frame: Could not create new window.\n"); + return NULL; + } + im_SetView(im, f); + frame_PostDefaultHandler(f, "message", frame_WantHandler(f, "message")); + } + } + + return f; } *** atk/frame/frame.ch Wed Sep 26 16:04:51 1990 --- atk/frame/frame.ch.NEW Mon Apr 29 17:22:36 1991 *************** *** 2,19 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/frame/RCS/frame.ch,v 2.10 90/08/23 16:32:00 ajp Exp $ */ /* $ACIS:frame.ch 1.5$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/frame/RCS/frame.ch,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsidframe_H = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/frame/RCS/frame.ch,v 2.10 90/08/23 16:32:00 ajp Exp $"; #endif /* !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) */ /* frame.H * Class definition for frame module. * ! * $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/frame/RCS/frame.ch,v 2.10 90/08/23 16:32:00 ajp Exp $ * $ACIS:frame.ch 1.5$ * */ --- 2,19 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/frame/RCS/frame.ch,v 2.14 1991/04/29 21:06:30 tpn Exp $ */ /* $ACIS:frame.ch 1.5$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/frame/RCS/frame.ch,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsidframe_H = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/frame/RCS/frame.ch,v 2.14 1991/04/29 21:06:30 tpn Exp $"; #endif /* !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) */ /* frame.H * Class definition for frame module. * ! * $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/frame/RCS/frame.ch,v 2.14 1991/04/29 21:06:30 tpn Exp $ * $ACIS:frame.ch 1.5$ * */ *************** *** 41,46 **** --- 41,47 ---- Advice(enum message_Preference pp); DisplayString(int priority, char *string) returns int; AskForString(int priority, char *prompt, char *defaultString, char *buffer, int bufferSize) returns int; + AskForPasswd(int priority, char *prompt, char *defaultString, char *buffer, int bufferSize) returns int; AskForStringCompleted(int priority, char *prompt, char *defaultString, char *buffer, int bufferSize, struct keystate *keystate, procedure completionProc, procedure helpProc, long functionData, int flags) returns int; MultipleChoiceQuestion(int priority, char *prompt, long defaultChoice, long *result, char **choices, char *abbrevKeys) returns int; *************** *** 56,62 **** classprocedures: InitializeObject(struct frame *self) returns boolean; FinalizeObject(struct frame *self); ! Enumerate(procedure function, long functionData) returns struct frame *; Create(struct buffer *buffer) returns struct frame *; InitializeClass()returns boolean; overrides: /* Make it hard for people to access our lpair functions. */ --- 57,65 ---- classprocedures: InitializeObject(struct frame *self) returns boolean; FinalizeObject(struct frame *self); ! Enumerate(procedure function, long functionData) returns struct frame *; ! FindFrameForBuffer(struct buffer *b) returns struct frame *; ! GetFrameInWindowForBuffer(struct buffer *b) returns struct frame *; Create(struct buffer *buffer) returns struct frame *; InitializeClass()returns boolean; overrides: /* Make it hard for people to access our lpair functions. */ *************** *** 112,115 **** --- 115,121 ---- struct dataobject *object; boolean dataModified; boolean QuitWindowOnly; + boolean drawn; + boolean mono; + int PotentialChoice; }; *** atk/frame/framecmd.c Fri Dec 21 14:54:47 1990 --- atk/frame/framecmd.c.NEW Thu May 30 18:34:45 1991 *************** *** 2,13 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/frame/RCS/framecmd.c,v 2.44 90/11/01 15:00:58 gk5g Exp $ */ /* $ACIS:framecmd.c 1.3$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/frame/RCS/framecmd.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/frame/RCS/framecmd.c,v 2.44 90/11/01 15:00:58 gk5g Exp $"; #endif /* lint */ /* framecmd.c --- 2,13 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/frame/RCS/framecmd.c,v 2.53 91/05/30 19:00:02 gk5g Exp $ */ /* $ACIS:framecmd.c 1.3$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/frame/RCS/framecmd.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/frame/RCS/framecmd.c,v 2.53 91/05/30 19:00:02 gk5g Exp $"; #endif /* lint */ /* framecmd.c *************** *** 29,36 **** * */ ! ! #include #include #include #include --- 29,35 ---- * */ ! #include /* sys/types.h sys/file.h */ #include #include #include *************** *** 50,70 **** #include #include #include #include - #include /* sys/types.h sys/file.h */ #include #include /* needed for hp - sometimes included in sys/param.h */ #include #include - extern int errno; - extern char *rindex(); static struct keymap *framecmdsKeymap; static struct menulist *framecmdsMenus; static struct cursor *waitCursor; /* isString(arg) tests arg to see if it is a string --- 49,70 ---- #include #include #include + #include #include #include #include /* needed for hp - sometimes included in sys/param.h */ #include #include extern int errno; static struct keymap *framecmdsKeymap; static struct menulist *framecmdsMenus; static struct cursor *waitCursor; + #ifdef CONTRIB_ENV + #define PRINTER_SETUP_DIALOG_ENV 1 + #endif /* isString(arg) tests arg to see if it is a string *************** *** 72,78 **** */ static jmp_buf trap; static SigHandler() {longjmp(trap, 1);} ! static boolean isString(arg) char *arg; { --- 72,79 ---- */ static jmp_buf trap; static SigHandler() {longjmp(trap, 1);} ! ! static boolean isString(arg) char *arg; { *************** *** 533,542 **** struct buffer *buffer; char *dir; /* Output: At least MAXPATHLEN, please. */ { ! char *slash; ! if ((buffer_GetFilename(buffer)) != NULL) { ! strcpy(dir, buffer_GetFilename(buffer)); slash = rindex(dir, '/'); if (slash != NULL) slash[1] = '\0'; --- 534,543 ---- struct buffer *buffer; char *dir; /* Output: At least MAXPATHLEN, please. */ { ! char *slash, *fname = buffer_GetFilename(buffer); ! if ((fname != NULL) && (*fname != '\0')) { ! strcpy(dir, fname); slash = rindex(dir, '/'); if (slash != NULL) slash[1] = '\0'; *************** *** 576,582 **** { long code; ! code = frame_VisitFilePrompting(self, "Recursive visit file: ", FALSE); if (code >= 0) im_KeyboardProcessor(); } --- 577,583 ---- { long code; ! code = frame_VisitFilePrompting(self, "Recursive visit file: ", FALSE, FALSE); if (code >= 0) im_KeyboardProcessor(); } *************** *** 793,808 **** fileName = buffer_GetFilename(buffer); shortFileName[0] = '\0'; ! if (fileName != NULL) { ! char *home = environ_Get("HOME"); ! if (home != NULL) { ! int hlen = strlen(home); ! if (strncmp(fileName, home, hlen) == 0) { ! strcpy(shortFileName, "~"); ! fileName += hlen; ! } ! } ! strcat(shortFileName, fileName); } sprintf(infoBuffer, "%-16s%7s %-3s %-8s %s", --- 794,801 ---- fileName = buffer_GetFilename(buffer); shortFileName[0] = '\0'; ! if (fileName != NULL) { ! path_TruncatePath(fileName, shortFileName, sizeof(shortFileName) - 1, TRUE); } sprintf(infoBuffer, "%-16s%7s %-3s %-8s %s", *************** *** 1204,1210 **** else message_DisplayString(self, 0, "New file."); ! if((buffer = buffer_FindBufferByName(lastBuffer)) == NULL) strcpy(lastBuffer,""); return 0; --- 1197,1203 ---- else message_DisplayString(self, 0, "New file."); ! if(buffer_FindBufferByName(lastBuffer) == NULL) strcpy(lastBuffer,""); return 0; *************** *** 1213,1222 **** /* Not static so it can be used from eza.c */ ! int frame_VisitFilePrompting(self, prompt, newWindow) struct frame *self; char *prompt; boolean newWindow; { char filename[MAXPATHLEN]; struct buffer *buffer; --- 1206,1216 ---- /* Not static so it can be used from eza.c */ ! int frame_VisitFilePrompting(self, prompt, newWindow, rawMode) struct frame *self; char *prompt; boolean newWindow; + boolean rawMode; { char filename[MAXPATHLEN]; struct buffer *buffer; *************** *** 1227,1247 **** bufferDirectory(buffer, filename); if (completion_GetFilename(self, prompt, filename, filename, ! sizeof(filename), FALSE, FALSE) == -1) { errno = 0; return -1; } ! return VisitNamedFile(self, filename, newWindow); } ! int VisitNamedFile(self, filename, newWindow) struct frame *self; char *filename; boolean newWindow; { struct buffer *buffer; ! if ((buffer = LocalGetBufferOnFile(self, filename, 0)) == NULL) return -1; if (frame_GetBuffer(self) != buffer) --- 1221,1248 ---- bufferDirectory(buffer, filename); if (completion_GetFilename(self, prompt, filename, filename, ! sizeof(filename), FALSE, rawMode) == -1) { errno = 0; return -1; } ! return VisitNamedFile(self, filename, newWindow, rawMode); } ! int VisitNamedFile(self, filename, newWindow, rawMode) struct frame *self; char *filename; boolean newWindow; + boolean rawMode; { struct buffer *buffer; ! long flags = 0; ! ! if (rawMode) { ! flags = buffer_RawMode; ! } ! ! if ((buffer = LocalGetBufferOnFile(self, filename, flags)) == NULL) return -1; if (frame_GetBuffer(self) != buffer) *************** *** 1278,1286 **** boolean newWindow; { if (isString(arg)) ! return VisitNamedFile(self, arg, newWindow); else ! return frame_VisitFilePrompting(self, prompt, newWindow); } int frame_VisitFile(self, arg) --- 1279,1287 ---- boolean newWindow; { if (isString(arg)) ! return VisitNamedFile(self, arg, newWindow, FALSE); else ! return frame_VisitFilePrompting(self, prompt, newWindow, FALSE); } int frame_VisitFile(self, arg) *************** *** 1291,1296 **** --- 1292,1305 ---- im_ArgProvided(frame_GetIM(self))); } + int frame_VisitRawFile(self, arg) + struct frame *self; + char *arg; + { + return frame_VisitFilePrompting(self, "Visit file (raw mode): ", + im_ArgProvided(frame_GetIM(self)), TRUE); + } + int frame_VisitFileNewWindow(self, arg) struct frame *self; char *arg; *************** *** 1760,1765 **** --- 1769,1776 ---- (void (*)())frame_cd, "Change current working directory."}, {"frame-visit-file", "\030\026",0, NULL,0,frame_BufferMenus, (void (*)())frame_VisitFile, "Prompts for a file to visit."}, + {"frame-visit-file-uninterpreted", "\030\033v",0, NULL,0,frame_BufferMenus, + (void (*)())frame_VisitRawFile, "Prompts for a file to visit uninterpreted."}, {"frame-visit-file-new-window", NULL,0, NULL,0,frame_BufferMenus, (void (*)())frame_VisitFileNewWindow, "Prompts for a file to visit. Creates a new window for it."}, *************** *** 1805,1813 **** --- 1816,1836 ---- "Prompts for a file to save the current buffer in."}, {"frame-save-all-files", "\030\015",0, "File~10,Save All~2",0, frame_BufferMenus, frame_SaveAll, "Saves all files."}, + #ifdef SET_PRINTER_COMMAND_ENV {"frame-set-printer", NULL,0, "File~10,Set Printer~20",0, frame_BufferMenus, frame_SetPrinter, "Set the printer for the print command to spool to."}, + #else /* SET_PRINTER_COMMAND_ENV */ + /* Define the proctable entry but don't bind it to a menu.*/ + {"frame-set-printer", NULL,0, NULL,0, + frame_BufferMenus, frame_SetPrinter, + "Set the printer for the print command to spool to."}, + #endif /* SET_PRINTER_COMMAND_ENV */ + #ifdef PRINTER_SETUP_DIALOG_ENV + {"printopts-post-window", NULL,0, "File~10,Printer Setup~20",0, + frame_BufferMenus, NULL, + "Pop up dialogue box to set printer name and other parameters.", "printopts"}, + #endif /* PRINTER_SETUP_DIALOG_ENV */ {"frame-preview", NULL,0, "File~10,Preview~21",0, frame_BufferMenus, frame_PreviewCmd, "Previews document."}, {"frame-print", NULL,0, "File~10,Print~22",0, *** atk/frame/framemsg.c Wed Sep 26 16:05:00 1990 --- atk/frame/framemsg.c.NEW Tue Apr 2 20:44:23 1991 *************** *** 2,13 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/frame/RCS/framemsg.c,v 1.10 90/08/23 16:32:47 ajp Exp $ */ /* $ACIS:framemsg.c 1.4$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/frame/RCS/framemsg.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/frame/RCS/framemsg.c,v 1.10 90/08/23 16:32:47 ajp Exp $"; #endif /* lint */ /* framemsg.c --- 2,13 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/frame/RCS/framemsg.c,v 1.12 91/04/02 16:56:34 susan Exp $ */ /* $ACIS:framemsg.c 1.4$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/frame/RCS/framemsg.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/frame/RCS/framemsg.c,v 1.12 91/04/02 16:56:34 susan Exp $"; #endif /* lint */ /* framemsg.c *************** *** 23,29 **** --- 23,31 ---- #include #include #include + #include #include + #include #include #define DEFAULTMESSAGETIMEOUT 15 /* Default timeout in seconds. */ *************** *** 183,188 **** --- 185,194 ---- if (framemessage_Asking(self)) return ERROR; + if ( ((struct textview *) self->messageView)->editor == VI && + ((struct textview *) self->messageView)->viMode == COMMAND ) + frameview_ToggleVIMode(self->messageView); + if (USEDIALOG(priority) ) { return frame_AskForString(self->frame, priority, prompt, defaultString, buffer, bufferSize); } *************** *** 214,219 **** --- 220,277 ---- return 0; } + int framemessage__AskForPasswd(self, priority, prompt, defaultString, buffer, bufferSize) + struct framemessage *self; + int priority; + char *prompt, *defaultString, *buffer; + int bufferSize; /* Is actual sizeof buffer including NUL. */ + { + static struct style *passwdStyle = NULL; + + if (passwdStyle == NULL) { + passwdStyle = style_New(); + style_AddHidden(passwdStyle); + } + self->flags = 0; + self->hasDefault = (defaultString != NULL); + + if (framemessage_Asking(self)) + return ERROR; + + if (USEDIALOG(priority) ) { + return frame_AskForPasswd(self->frame, priority, prompt, defaultString, buffer, bufferSize); + } + BuildPrompt(self, prompt, defaultString); + + self->oldInputFocus = im_GetInputFocus(frameview_GetIM(self->messageView)); + + self->asking = TRUE; + + text_AlwaysAddStyle(self->messageText, + text_GetLength(self->messageText)-1, 1, passwdStyle); + + frameview_WantInputFocus(self->messageView, self->messageView); + + im_KeyboardProcessor(); + + if (!self->punt) + framemessage_GetCurrentString(self, buffer, bufferSize); + + self->asking = FALSE; + + if (self->oldInputFocus != NULL) + view_WantInputFocus(self->oldInputFocus, self->oldInputFocus); + + if (self->punt) { + self->punt = FALSE; + return ERROR; + } + + QueueErasure(self, text_GetLength(self->messageText)); + + return 0; + } + /* Hairy function... */ int framemessage__AskForStringCompleted(self, priority, prompt, defaultString, buffer, bufferSize, keystate, completionProc, helpProc, completionData, flags) struct framemessage *self; *************** *** 237,242 **** --- 295,304 ---- self->flags = flags; self->hasDefault = (defaultString != NULL); + if ( ((struct textview *) self->messageView)->editor == VI && + ((struct textview *) self->messageView)->viMode == COMMAND ) + frameview_ToggleVIMode(self->messageView); + BuildPrompt(self, prompt, defaultString); self->textBuffer = buffer; *************** *** 388,393 **** --- 450,459 ---- if ((tempPrompt = KludgePrompt(prompt, defaultChoice, choices, abbrevKeys)) == NULL) return ERROR; + + /* if VI user, put them in input mode if necessary */ + if ( (self->messageView)->editor == VI && (self->messageView)->viMode == COMMAND ) + frameview_ToggleVIMode(self->messageView); BuildPrompt(self, tempPrompt, ""); *** atk/frame/framemsg.ch Wed Sep 26 16:05:02 1990 --- atk/frame/framemsg.ch.NEW Tue Apr 2 20:44:24 1991 *************** *** 2,13 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/frame/RCS/framemsg.ch,v 1.8 90/08/23 16:32:55 ajp Exp $ */ /* $ACIS:framemsg.ch 1.2$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/frame/RCS/framemsg.ch,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsidframemessage_H = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/frame/RCS/framemsg.ch,v 1.8 90/08/23 16:32:55 ajp Exp $"; #endif /* !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) */ /* framemsg.H --- 2,13 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/frame/RCS/framemsg.ch,v 1.9 91/04/02 16:56:26 susan Exp $ */ /* $ACIS:framemsg.ch 1.2$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/frame/RCS/framemsg.ch,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsidframemessage_H = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/frame/RCS/framemsg.ch,v 1.9 91/04/02 16:56:26 susan Exp $"; #endif /* !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) */ /* framemsg.H *************** *** 22,27 **** --- 22,28 ---- overrides: DisplayString(int priority, char *string) returns int; AskForString(int priority, char *prompt, char *defaultString, char *buffer, int bufferSize) returns int; + AskForPasswd(int priority, char *prompt, char *defaultString, char *buffer, int bufferSize) returns int; AskForStringCompleted(int priority, char *prompt, char *defaultString, char *buffer, int bufferSize, struct keystate *keystate, procedure completionProc, procedure helpProc, long functionData, int flags) returns int; MultipleChoiceQuestion(int priority, char *prompt, long defaultChoice, long *result, char **choices, char *abbrevKeys) returns int; *** atk/frame/helptxtv.c Wed Nov 22 12:13:45 1989 --- atk/frame/helptxtv.c.NEW Wed Apr 24 16:20:08 1991 *************** *** 2,13 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/frame/RCS/helptxtv.c,v 2.4 89/02/17 16:14:11 ghoti Exp $ */ /* $ACIS:helptxtv.c 1.3$ */ ! /* $Source: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/frame/RCS/helptxtv.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/frame/RCS/helptxtv.c,v 2.4 89/02/17 16:14:11 ghoti Exp $"; #endif /* lint */ #define Text(self) ((struct text *) ((self)->header.view.dataobject)) --- 2,13 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/frame/RCS/helptxtv.c,v 2.5 91/04/24 16:18:00 gk5g Exp $ */ /* $ACIS:helptxtv.c 1.3$ */ ! /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/frame/RCS/helptxtv.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/frame/RCS/helptxtv.c,v 2.5 91/04/24 16:18:00 gk5g Exp $"; #endif /* lint */ #define Text(self) ((struct text *) ((self)->header.view.dataobject)) *************** *** 49,59 **** register int i,len; struct text *doc = Text(self); len = text_GetLength(doc); ! for(i = 0;i < len; i++) if(text_GetChar(doc,i) == '"') break; ! for(i++, bp = buf;i < len && (*bp = text_GetChar(doc,i)) != '"'; i++) bp++; ! if(i >= len) { *buf = '\0'; return buf; } while (*bp != '/' && bp != buf) bp--; ! if(*bp == '/') bp++; *bp = '\0'; return bp; } --- 49,60 ---- register int i,len; struct text *doc = Text(self); len = text_GetLength(doc); ! for(i = 0;i < len; i++) if(text_GetChar(doc,i) == '`') break; ! if(i < len) i++; ! for(i++, bp = buf;i < len && ((*bp = text_GetChar(doc,i)) != '\''); i++) bp++; ! if(i >= len) { *buf = '\0'; return buf; } while (*bp != '/' && bp != buf) bp--; ! if(*bp == '/') bp++; *bp = '\0'; return bp; } *** atk/help/src/Imakefile Thu Jan 10 14:57:41 1991 --- atk/help/src/Imakefile.NEW Thu Apr 4 17:42:23 1991 *************** *** 13,23 **** InstallFile(helpmac.an, $(INSTINCFLAGS), $(DESTDIR)/lib/tmac) InstallFile(config.h, $(INSTINCFLAGS), $(DESTDIR)/include/atk) ! DynamicMultiObject(helpa.do, helpa.o, ,) ! DynamicMultiObject(helpdb.do, helpdb.o, ${BASEDIR}/lib/libindex.a,) - - DynamicMultiObject(help.do, help.o, ${BASEDIR}/lib/librxp.a,) InstallClassFiles($(DOBJS),$(IHFILES)) --- 13,21 ---- InstallFile(helpmac.an, $(INSTINCFLAGS), $(DESTDIR)/lib/tmac) InstallFile(config.h, $(INSTINCFLAGS), $(DESTDIR)/include/atk) ! DynamicMultiObject(help.do, help.o helpaux.o, ${BASEDIR}/lib/librxp.a,) ! DynamicMultiObject(helpa.do, helpa.o, ,${NETLIBS}) DynamicMultiObject(helpdb.do, helpdb.o, ${BASEDIR}/lib/libindex.a,) InstallClassFiles($(DOBJS),$(IHFILES)) *** atk/help/src/config.h Fri Dec 21 14:54:52 1990 --- atk/help/src/config.h.NEW Tue May 28 17:39:24 1991 *************** *** 2,13 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/help/src/RCS/config.h,v 1.9 90/07/19 13:40:43 gk5g Exp Locker: gk5g $ */ /* $ACIS$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/help/src/RCS/config.h,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/help/src/RCS/config.h,v 1.9 90/07/19 13:40:43 gk5g Exp Locker: gk5g $"; #endif /* !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) */ --- 2,13 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/help/src/RCS/config.h,v 1.10 1991/02/06 17:05:37 gk5g Exp $ */ /* $ACIS$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/help/src/RCS/config.h,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/help/src/RCS/config.h,v 1.10 1991/02/06 17:05:37 gk5g Exp $"; #endif /* !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) */ *************** *** 276,278 **** --- 276,279 ---- #define HELP_KEY_DELETE_WINDOW "\030\004" /* ^X-^D */ #define HELP_KEY_WINDOW_SPLIT "\0302" /* ^X-2 */ #define HELP_KEY_ADD_BOOKMARK "\030\002" /* ^X^B */ + #define HELP_KEY_QUIT "\030\003" /* ^X^C */ *** atk/help/src/help.c Fri Dec 21 14:55:02 1990 --- atk/help/src/help.c.NEW Tue May 28 17:39:27 1991 *************** *** 2,13 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/help/src/RCS/help.c,v 2.74 90/11/06 14:13:33 gk5g Exp Locker: gk5g $ */ /* $ACIS$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/help/src/RCS/help.c,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/help/src/RCS/help.c,v 2.74 90/11/06 14:13:33 gk5g Exp Locker: gk5g $"; #endif /* !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) */ --- 2,13 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/help/src/RCS/help.c,v 2.85 1991/05/28 21:29:49 gk5g Exp $ */ /* $ACIS$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/help/src/RCS/help.c,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/help/src/RCS/help.c,v 2.85 1991/05/28 21:29:49 gk5g Exp $"; #endif /* !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) */ *************** *** 33,64 **** #include #define label gezornenplatz - #include /* sys/types.h in AIX PS2 defines "struct label", causing a type name clash. Avoid this by temporarily redefining "label" to be something else in the preprocessor. */ #include /* sys/types.h sys/file.h */ #undef label #include ! #include ! #include #include #include #include - #include - #include #include - #include - #include #include #include #include #include #include #include - #include - #include - #include #include #include #include --- 33,57 ---- #include #define label gezornenplatz /* sys/types.h in AIX PS2 defines "struct label", causing a type name clash. Avoid this by temporarily redefining "label" to be something else in the preprocessor. */ #include /* sys/types.h sys/file.h */ #undef label + #include #include ! #include #include #include #include #include #include #include #include #include + #include #include #include #include #include #include *************** *** 68,86 **** #include #include #include #include #include - #include #include #include /* use the reg expression routines in overhead */ ! #include "config.h" ! #include "helpsys.h" ! #include "help.h" #include - #include /*---------------------------------------------------------------------------*/ /* GLOBALS */ --- 61,82 ---- #include #include + #ifdef M_UNIX + #include + #define direct dirent + #else #include + #endif #include #include #include #include /* use the reg expression routines in overhead */ ! #include ! #include ! #include #include /*---------------------------------------------------------------------------*/ /* GLOBALS */ *************** *** 87,115 **** /*---------------------------------------------------------------------------*/ /* the new menu and key states */ ! static struct keymap *Help_Map; ! static struct menulist *Help_Menus; ! /* statics representing information cache */ ! static char *tutorialDirs[MAX_TUTORIAL_DIRS]; ! static char changesDir[MAXPATHLEN]; /* a list of instances of help */ ! static struct self_help *ego = (struct self_help *)NULL; ! static struct cursor *waitCursor; /* the watch cursor */ ! static char **panelList = NULL; /* used for enumerating across the help index */ ! static int panelIndex = 0, panelListSize = help_MAXPANEL; /* hooks to textview and frame procs */ ! static void (*textSearch)() = (void (*)())NULL; ! static void (*textRevSearch)() = (void (*)())NULL; ! static void (*textSearchAgain)() = (void (*)())NULL; ! static void (*textCopyRegion)() = (void (*)())NULL; ! static void (*textPageDown)() = (void (*)())NULL; ! static void (*textPageUp)() = (void (*)())NULL; ! static void (*frameSetPrinter)() = (void (*)())NULL; /*---------------------------------------------------------------------------*/ /* CONDITIONAL DEBUGGING */ --- 83,125 ---- /*---------------------------------------------------------------------------*/ /* the new menu and key states */ ! struct keymap *Help_Map; ! struct menulist *Help_Menus; ! char *tutorialDirs[MAX_TUTORIAL_DIRS]; ! char changesDir[MAXPATHLEN]; /* a list of instances of help */ ! struct self_help *ego = (struct self_help *)NULL; ! struct cursor *waitCursor; /* the watch cursor */ ! char **panelList = NULL; /* used for enumerating across the help index */ ! int panelIndex = 0, panelListSize = help_MAXPANEL; /* hooks to textview and frame procs */ ! void (*textSearch)() = (void (*)())NULL; ! void (*textRevSearch)() = (void (*)())NULL; ! void (*textSearchAgain)() = (void (*)())NULL; ! void (*textCopyRegion)() = (void (*)())NULL; ! void (*textPageDown)() = (void (*)())NULL; ! void (*textPageUp)() = (void (*)())NULL; ! void (*frameSetPrinter)() = (void (*)())NULL; ! ! extern void AddSearchDir(); ! extern void AddBookmark(); ! extern void ExitProc(); ! extern void Print(); ! extern void NewHelp(); ! ! void SetupMenus(); ! static void TogglePanels(); ! static void ToggleOverviews(); ! static void TogglePrograms(); ! static void ToggleHistory(); ! static void SortAndMakePanel(); ! static char *AddToPanelList(); ! static void RestorePanel(); /*---------------------------------------------------------------------------*/ /* CONDITIONAL DEBUGGING */ *************** *** 125,130 **** --- 135,141 ---- #undef DEBUG #define DEBUG(arg) if (HELPDEBUG != 0) { printf arg; fflush(stdout); } #else + #undef DEBUG #define DEBUG(arg) #endif /* DEBUGGING */ *************** *** 137,143 **** * copy protoname into aresult, prepending /usr/andy or whatever, * as appropriate */ ! static char *AndyCopy(aproto, aresult) register char *aproto, *aresult; { register char *tp; --- 148,155 ---- * copy protoname into aresult, prepending /usr/andy or whatever, * as appropriate */ ! static char * ! AndyCopy(aproto, aresult) register char *aproto, *aresult; { register char *tp; *************** *** 150,160 **** /* * allocate new string */ ! static char *CopyString(as) register char *as; { register char *tp; ! tp = (char *) malloc(strlen(as)+1); if (!tp) return NULL; strcpy(tp, as); --- 162,173 ---- /* * allocate new string */ ! static char * ! CopyString(as) register char *as; { register char *tp; ! tp = (char*) malloc(strlen(as)+1); if (!tp) return NULL; strcpy(tp, as); *************** *** 164,170 **** /* * parse comma terminated field followed by new-line terminated field */ ! static int ScanLine(afile, ae1, ae2) register FILE *afile; char *ae1, *ae2; { --- 177,184 ---- /* * parse comma terminated field followed by new-line terminated field */ ! static int ! ScanLine(afile, ae1, ae2) register FILE *afile; char *ae1, *ae2; { *************** *** 196,202 **** /* * just like system(3) only closes fds 3..., and doesn't wait */ ! static int mysystem (acmd) register char *acmd; { register long pid; --- 210,217 ---- /* * just like system(3) only closes fds 3..., and doesn't wait */ ! static int ! mysystem(acmd) register char *acmd; { register long pid; *************** *** 216,222 **** /* * lowercases's a string. */ ! static char *LowerCase(astring) register char *astring; { register char *tp = astring; --- 231,238 ---- /* * lowercases's a string. */ ! char * ! LowerCase(astring) register char *astring; { register char *tp = astring; *************** *** 234,240 **** /* * maps string(n) to string.n in place */ ! static char *MapParens(s) char *s; { char *lpp, *rpp; --- 250,257 ---- /* * maps string(n) to string.n in place */ ! static char * ! MapParens(s) char *s; { char *lpp, *rpp; *************** *** 252,258 **** /* * stolen from libcs. Returns the index of string small in big, 0 otherwise */ ! char *sindex (big,small) char *big,*small; { register char *bp, *bp1, *sp; register char c = *small++; --- 269,277 ---- /* * stolen from libcs. Returns the index of string small in big, 0 otherwise */ ! static char * ! sindex(big, small) ! char *big, *small; { register char *bp, *bp1, *sp; register char c = *small++; *************** *** 267,272 **** --- 286,335 ---- return 0; } + /* + * add an item to the history buffer + */ + void + AddHistoryItem (self, marcp, flash) + register struct help *self; + int marcp; /* is this a bookmark? */ + int flash; /* should we expose the history panel? */ + { + struct history_entry *ent; + register struct cache *c = self->info; + + DEBUG(("addhist\n")); + if (c->histent == NULL || c->histent[0] == '\0') + return; + + ent = (struct history_entry *) malloc (sizeof(struct history_entry)); + if (ent == NULL) + return; + + ent->pos = textview_GetDotPosition((struct textview *)c->view), + ent->top = textview_GetTopPosition((struct textview *)c->view), + ent->sellen = textview_GetDotLength((struct textview *)c->view), + ent->fname = (char *) malloc (strlen(c->histent) + 1); + strcpy(ent->fname, c->histent); + + if (marcp == help_HE_HISTORY) { /* normal history add */ + + /* now add the item */ + c->lastHist = panel_Add(c->hist, c->histent, ent, TRUE); + } else { /* a bookmark */ + char tfname[HNSIZE + 11]; + + sprintf(tfname, "%s @ %d", c->histent, ent->top); + /* now add the item */ + c->lastHist = panel_Add(c->hist, tfname, ent, TRUE); + } + + if (flash == help_SHOW_HIST) + ToggleHistory(self, help_SHOW_HIST); + + DEBUG(("OUT addhist\n")); + } + /*---------------------------------------------------------------------------*/ /* MAIN FUNCTIONS */ *************** *** 274,280 **** /* * Help's file displayer - given a filename, attempts to find out if ! * it's a roff file (1st char '.' or '#') and read it in using rofftext. * Otherwise, assumes it's text or ATK format and lets text_read take care * of the dirty work of dealing with that. * --- 337,343 ---- /* * Help's file displayer - given a filename, attempts to find out if ! * it's a roff file (1st char '.' or '#' or '\'') and read it in using rofftext. * Otherwise, assumes it's text or ATK format and lets text_read take care * of the dirty work of dealing with that. * *************** *** 285,291 **** * Also takes care of adding elements to the history panel for the last-shown * help file. */ ! static int ShowFile(self, afilename, amoreFlag, hist) register struct help *self; register char *afilename; /* the file */ int amoreFlag; /* put "(more)" in the titlebar? --- 348,355 ---- * Also takes care of adding elements to the history panel for the last-shown * help file. */ ! static int ! ShowFile(self, afilename, amoreFlag, hist) register struct help *self; register char *afilename; /* the file */ int amoreFlag; /* put "(more)" in the titlebar? *************** *** 338,344 **** /* is it troff ? */ tc = getc(fd); ungetc(tc, fd); ! isTroffFormat = (tc == '.' || tc == '#'); /* what kind of object does this file want ? (don't touch attributes) */ objName = filetype_Lookup(NULL, afilename, NULL, NULL); --- 402,408 ---- /* is it troff ? */ tc = getc(fd); ungetc(tc, fd); ! isTroffFormat = (tc == '.' || tc == '#' || tc == '\''); /* what kind of object does this file want ? (don't touch attributes) */ objName = filetype_Lookup(NULL, afilename, NULL, NULL); *************** *** 404,415 **** return 0; } } else { /* it's troff */ /* check if the manfiles are absolute or relative paths. If 1st char is '/', path is absolute, OW, we andycopy it into a temp buffer, since it will be relative to ANDREWDIR */ while (*manptr) { if (**manptr != '/') { ! tmp = (char *)malloc(strlen(*manptr)+1); tmp[0] = '/'; strcat(tmp, *manptr); *manptr = AndyCopy(tmp, (char *)malloc(MAXPATHLEN)); --- 468,482 ---- return 0; } } else { /* it's troff */ + char *manroot = "/usr/man", *slash = NULL; + /* check if the manfiles are absolute or relative paths. If 1st char is '/', path is absolute, OW, we andycopy it into a temp buffer, since it will be relative to ANDREWDIR */ + while (*manptr) { if (**manptr != '/') { ! tmp = (char *)malloc(strlen(*manptr)+2); tmp[0] = '/'; strcat(tmp, *manptr); *manptr = AndyCopy(tmp, (char *)malloc(MAXPATHLEN)); *************** *** 419,424 **** --- 486,515 ---- } message_DisplayString(c->view, 0, msg_converting); im_ForceUpdate(); + + /* ======== START of change to root of man pages ========== */ + slash = (char*)strchr(afilename, '/'); + while(slash && (slash+1)) { + if(!strncmp(slash+1,"man",3) && *(slash+4) == '/') { + /* found substring "man" somewhere in afilename; chdir there */ + slash += 4; + *slash = '\0'; + manroot = afilename; + break; + } + else + slash = (char*)strchr(slash + 1, '/'); + } + if(!slash) { /* troff file not located in standard man path */ + /* Chdir to directory containing afilename */ + manroot = afilename; + slash = rindex(afilename,'/'); + *slash = '\0'; + } + *slash = '/'; + chdir(manroot); + /* ======== END of change to root of man pages ========== */ + if (rofftext_ReadRoffIntoText((struct text *)newdata, fd, 0, manfiles) != dataobject_NOREADERROR) { ERRORBOX(c->view, err_read); view_Destroy(newview); *************** *** 495,503 **** */ static char * ! FindEntryInDirs( dirs, entry , extension ) ! char *dirs[]; ! char *entry, *extension; { static char fullPath[MAXPATHLEN]; char *returnPath = NULL; --- 586,594 ---- */ static char * ! FindEntryInDirs(dirs, entry , extension) ! char *dirs[]; ! char *entry, *extension; { static char fullPath[MAXPATHLEN]; char *returnPath = NULL; *************** *** 547,553 **** return code; } */ ! static int GetHelpOn(self, aname, isnew, ahistory, errmsg) register struct help *self; char *aname; /* what topic */ long isnew; /* is this a new topic? */ --- 638,645 ---- return code; } */ ! int ! GetHelpOn(self, aname, isnew, ahistory, errmsg) register struct help *self; char *aname; /* what topic */ long isnew; /* is this a new topic? */ *************** *** 572,578 **** MapParens(aname); if (isnew) { /* if the first time through, setup c->all */ ! code = helpdb_SetupHelp(c, aname, TRUE); #ifdef DEBUGGING if (code != 0) { --- 664,670 ---- MapParens(aname); if (isnew) { /* if the first time through, setup c->all */ ! code = helpdb_SetupHelp(c, aname, TRUE); #ifdef DEBUGGING if (code != 0) { *************** *** 639,714 **** /*---------------------------------------------------------------------------*/ /* - * Allows help to just delete one window - */ - static void ExitProc(self) - register struct help *self; - { - struct self_help *t, *p; - - DEBUG(("IN exit\n")); - - DEBUG(("ego: %d self: %d\n",(int)ego, (int)self)); - for (t=ego;t;t=t->next) { - DEBUG(("t: %d this: %d next: %d\n", (int)t, (int)t->this, (int)t->next)); - } - - /* delete self from the instance list */ - p = NULL; - t = ego; - while (t) { - if (t->this == self) { - if (p == NULL) { /* deleting head */ - ego = t->next; - free(t); - t = ego; - } else { - p->next = t->next; - free(t); - t = p->next; - } - } else { - p = t; - t = t->next; - } - } - DEBUG(("ego: %d self: %d\n",(int)ego, (int)self)); - for (t=ego;t;t=t->next) { - DEBUG(("t: %d this: %d next: %d\n", (int)t, (int)t->this, (int)t->next)); - } - - /* take care of the cases with 0 and 1 instances left in the list */ - if (ego) { /* something in the list */ - if (ego->next == (struct self_help *)NULL) { /* only one left */ - /* remove "Delete this window" menu item */ - DEBUG(("one left, Delete delete\n")); - ego->this->info->flags &= ~MENU_SwitchDeleteMenu; - SetupMenus(ego->this->info); - } - } else { /* nobody left, all gone, we be outta here */ - im_KeyboardExit(); - } - - help_FinalizeObject(self); - - DEBUG(("OUT exit\n")); - } - - - /* - * random key hit proc to chastise the user - */ - static void nono(self) - register struct help *self; - { - message_DisplayString(self, 0, err_readonly); - } - - - /* * setup the menumask based on internal flags */ ! static void SetupMenus(c) register struct cache *c; { DEBUG(("IN setupmenus..")); --- 731,740 ---- /*---------------------------------------------------------------------------*/ /* * setup the menumask based on internal flags */ ! void ! SetupMenus(c) register struct cache *c; { DEBUG(("IN setupmenus..")); *************** *** 721,727 **** /* * Do a search in the overview panel */ ! static void SearchOverviews(self) register struct help* self; { if (!self->showPanels) --- 747,754 ---- /* * Do a search in the overview panel */ ! static void ! SearchOverviews(self) register struct help* self; { if (!self->showPanels) *************** *** 735,741 **** /* * Do a search in the programs panel */ ! static void SearchPrograms(self) register struct help* self; { if (!self->showPanels) --- 762,769 ---- /* * Do a search in the programs panel */ ! static void ! SearchPrograms(self) register struct help* self; { if (!self->showPanels) *************** *** 753,763 **** * like this, rather than just binding in a call to proctable_GetProc(...) */ ! static void TextviewProc(self, rock) register struct help* self; long rock; { ! switch (rock) { case help_SEARCH: (*textSearch) ((struct textview *)self->info->view); break; --- 781,792 ---- * like this, rather than just binding in a call to proctable_GetProc(...) */ ! static void ! TextviewProc(self, rock) register struct help* self; long rock; { ! switch(rock) { case help_SEARCH: (*textSearch) ((struct textview *)self->info->view); break; *************** *** 785,807 **** } /* ! * print a help file */ ! static void Print(self) register struct help *self; { - message_DisplayString(self, 0, msg_print_queue); - im_ForceUpdate(); im_SetProcessCursor(waitCursor); ! print_ProcessView((struct textview *)self->info->view, 1, 0, "", ""); ! message_DisplayString(self, 0, msg_queue_done); ! im_SetProcessCursor((struct cursor *) NULL); } /* * send gripes/kudos to the help maintainers */ ! static void SendComments(self) register struct help *self; { char cmd[MAXPATHLEN], *prof; --- 814,834 ---- } /* ! * quit help */ ! static void ! Quit(self) register struct help *self; { im_SetProcessCursor(waitCursor); ! im_KeyboardExit(); } /* * send gripes/kudos to the help maintainers */ ! static void ! SendComments(self) register struct help *self; { char cmd[MAXPATHLEN], *prof; *************** *** 820,826 **** /* * show a tutorial, if it exists */ ! static void ShowTutorial(self) register struct help *self; { static char tbuffer[MAXPATHLEN]; --- 847,854 ---- /* * show a tutorial, if it exists */ ! static void ! ShowTutorial(self) register struct help *self; { static char tbuffer[MAXPATHLEN]; *************** *** 837,843 **** /* * show changes doc */ ! static void ShowChanges(self) register struct help *self; { static char tbuffer[MAXPATHLEN]; --- 865,872 ---- /* * show changes doc */ ! static void ! ShowChanges(self) register struct help *self; { static char tbuffer[MAXPATHLEN]; *************** *** 851,921 **** /* * show next file in list */ ! static void NextHelp (self) register struct help *self; { ! if (GetHelpOn(self, self->info->name, help_OLD, help_HIST_TAIL, err_no_more) != 0) panel_ClearSelection(self->historyPanel); } - - /* - * Add a history item for a given file with given dot, dotlen and top - */ - static void AddBookmark(self) - register struct help *self; - { - AddHistoryItem(self, help_HE_BOOKMARK, help_SHOW_HIST); - } - - - /* - * add an item to the history buffer - */ - static void AddHistoryItem (self, marcp, flash) - register struct help *self; - int marcp; /* is this a bookmark? */ - int flash; /* should we expose the history panel? */ - { - struct history_entry *ent; - register struct cache *c = self->info; - - DEBUG(("addhist\n")); - if (c->histent == NULL || c->histent[0] == '\0') - return; - - ent = (struct history_entry *) malloc (sizeof(struct history_entry)); - if (ent == NULL) - return; - - ent->pos = textview_GetDotPosition((struct textview *)c->view), - ent->top = textview_GetTopPosition((struct textview *)c->view), - ent->sellen = textview_GetDotLength((struct textview *)c->view), - ent->fname = (char *) malloc (strlen(c->histent) + 1); - strcpy(ent->fname, c->histent); - - if (marcp == help_HE_HISTORY) { /* normal history add */ - - /* now add the item */ - c->lastHist = panel_Add(c->hist, c->histent, ent, TRUE); - } else { /* a bookmark */ - char tfname[HNSIZE + 11]; - - sprintf(tfname, "%s @ %d", c->histent, ent->top); - /* now add the item */ - c->lastHist = panel_Add(c->hist, tfname, ent, TRUE); - } - - if (flash == help_SHOW_HIST) - ToggleHistory(self, help_SHOW_HIST); - - DEBUG(("OUT addhist\n")); - } - /* * get help on a clicked-on history item */ ! static void HistoryHelp (self, ent, apanel) struct help *self; /* callback rock */ struct history_entry *ent; /* panelEntry rock */ struct panel *apanel; /* appropriate panel */ --- 880,897 ---- /* * show next file in list */ ! void NextHelp(self) register struct help *self; { ! if(GetHelpOn(self, self->info->name, help_OLD, help_HIST_TAIL, err_no_more)) panel_ClearSelection(self->historyPanel); } /* * get help on a clicked-on history item */ ! void ! HistoryHelp(self, ent, apanel) struct help *self; /* callback rock */ struct history_entry *ent; /* panelEntry rock */ struct panel *apanel; /* appropriate panel */ *************** *** 974,980 **** /* * show overview or a help file from the program list panel */ ! static void OverviewHelp (self, name, apanel) struct panel *apanel; register char *name; /* which topic to request - panelEntry rock */ register struct help *self; --- 950,957 ---- /* * show overview or a help file from the program list panel */ ! void ! OverviewHelp(self, name, apanel) struct panel *apanel; register char *name; /* which topic to request - panelEntry rock */ register struct help *self; *************** *** 994,1112 **** } - /* - * get help on a prompted-for topic or a selected word, bringing up a - * new window if necessary - */ - static void NewHelp(self, type) - register struct help *self; - long type; /* help_ON if Help On... */ - /* help_ON & help_NEW_WIN if New Help On... */ - /* help_SEL if Help On Selected */ - /* help_SEL & help_NEW_WIN if New Help On Selected */ - { - register int i, pos, len, code; - char tc; - char helpName[HNSIZE]; - char buf[HNSIZE + HELP_MAX_ERR_LENGTH]; - struct help *hv; - - if (type & help_SEL) { - pos = textview_GetDotPosition((struct textview *)self->info->view); - len = textview_GetDotLength((struct textview *)self->info->view); - - /* only shows menu item if a selection has been made */ - /* but, since can bind the procedure, must handle this */ - /* case anyway. */ - if (len == 0) { - ERRORBOX(self->info->view, err_no_sel); - return; - } else { - if (len >= HNSIZE) { - ERRORBOX(self->info->view, err_sel_too_long); - return; - } - } - i = 0; /* position in text object */ - code = 0; /* position in helpName */ - while(iinfo->data, i+pos); - i++; - if (tc == ' ' || tc == '\t' || tc == '\n') continue; - helpName[code++] = tc; - } - helpName[code++] = '\0'; - } else { /* prompt for topic */ - code = message_AskForString(self, 0, msg_ask_prompt, - 0, helpName, HNSIZE); - if ((code < 0) || (helpName[0] == '\0')) return; - } - - if (type & help_NEW_WIN) { - struct im *im; - struct frame *frame; - - im = im_Create(NULL); - frame = frame_New(); - hv = help_New(); - if (!hv || !im || !frame) { - ERRORBOX(self->info->view, err_no_new_view); - return; - } - - /* since we exits, ego must exist now, too */ - if (ego->next != (struct self_help *)NULL) { /* > 1 instances */ - struct self_help *tmp; - - for (tmp = ego; tmp; tmp = tmp->next) { - /* add "delete this window" menu item" */ - DEBUG(("Add delete\n")); - tmp->this->info->flags |= MENU_SwitchDeleteMenu; - SetupMenus(tmp->this->info); - } - } - - /* frame for frame_SetView must have associated im */ - frame_SetView(frame, help_GetApplicationLayer(hv)); - im_SetView(im, frame); - - /* add in a message handler */ - frame_PostDefaultHandler(frame, "message", - frame_WantHandler(frame, "message")); - - } - - sprintf(buf, err_sorry, helpName); - if (GetHelpOn((!(type & help_NEW_WIN)) ? self : hv - , helpName, help_NEW, help_HIST_NAME, buf) != 0) { - panel_ClearSelection(self->overviewPanel); - panel_ClearSelection(self->listPanel); - panel_ClearSelection(self->historyPanel); - } - } - - - /* - * Adds a search directory to the searchpath - */ - static void AddSearchDir(self) - struct help *self; - { - char buf[MAXPATHLEN]; - char buf2[MAXPATHLEN+100]; - int code; - - sprintf(buf2, "%s", "Added directory: "); - code = completion_GetFilename((struct view *)self, msg_dir_prompt, NULL, - buf, sizeof(buf), TRUE, TRUE); - if (code != -1) { - buf[strlen(buf)-1] = '\0'; /* remove trailing '/' */ - helpdb_AddSearchDir(buf); - strcat(buf2, buf); - message_DisplayString(self, 0, buf2); - } - } - /*---------------------------------------------------------------------------*/ /* PANEL FUNCTIONS */ /*---------------------------------------------------------------------------*/ --- 971,976 ---- *************** *** 1127,1133 **** return(panelList ? TRUE : FALSE); } ! static void FreePanelListData() { if(panelList && (panelIndex > 0)) { --- 991,997 ---- return(panelList ? TRUE : FALSE); } ! void FreePanelListData() { if(panelList && (panelIndex > 0)) { *************** *** 1159,1165 **** returns the number of entries added to the panel */ ! static long SetupPanel(readpairs, fname, panel, def) boolean readpairs; char *fname; --- 1023,1029 ---- returns the number of entries added to the panel */ ! long SetupPanel(readpairs, fname, panel, def) boolean readpairs; char *fname; *************** *** 1239,1245 **** /* * Setup the lpairs for the side panel(s) */ ! static struct view *SetupLpairs(self) register struct help *self; { long which = 0; --- 1103,1109 ---- /* * Setup the lpairs for the side panel(s) */ ! struct view *SetupLpairs(self) register struct help *self; { long which = 0; *************** *** 1300,1306 **** /* * turn side panels on and off */ ! static void TogglePanels(self, rock) register struct help *self; long rock; { --- 1164,1171 ---- /* * turn side panels on and off */ ! static void ! TogglePanels(self, rock) register struct help *self; long rock; { *************** *** 1346,1352 **** /* * toggle overview panel on and off */ ! static void ToggleOverviews(self, rock) register struct help *self; long rock; { --- 1211,1218 ---- /* * toggle overview panel on and off */ ! static void ! ToggleOverviews(self, rock) register struct help *self; long rock; { *************** *** 1383,1389 **** /* * toggle program list panel on and off */ ! static void TogglePrograms(self, rock) register struct help *self; long rock; { --- 1249,1256 ---- /* * toggle program list panel on and off */ ! static void ! TogglePrograms(self, rock) register struct help *self; long rock; { *************** *** 1421,1427 **** /* * toggle history panel on and off */ ! static void ToggleHistory(self, rock) register struct help *self; long rock; { --- 1288,1295 ---- /* * toggle history panel on and off */ ! static void ! ToggleHistory(self, rock) register struct help *self; long rock; { *************** *** 1459,1470 **** /* * Used to add all files in a directory to the expanded program list */ ! static void ExpanderAux(dname) char *dname; { DIR *tmpdir; struct direct *tde; ! char tf[MAXPATHLEN], *tfp, *tfp2; tmpdir = opendir(dname); --- 1327,1339 ---- /* * Used to add all files in a directory to the expanded program list */ ! static void ! ExpanderAux(dname) char *dname; { DIR *tmpdir; struct direct *tde; ! char tf[MAXPATHLEN], *tfp; tmpdir = opendir(dname); *************** *** 1477,1485 **** while((tde=readdir(tmpdir)) != NULL) { if (*tde->d_name != '.') { /* no dot files */ strcpy(tfp, tde->d_name); /* finish the filename */ - tfp2 = rindex(tde->d_name, '.'); - if (tfp2 && !isdigit(*(tfp2+1))) - *tfp2 = '\0'; /* chop off non-numeric extension */ AddToPanelList(tde->d_name); } } --- 1346,1351 ---- *************** *** 1490,1496 **** /* * comparison function for qsort */ ! static int panelCompare(s1, s2) char **s1, **s2; { return (strcmp(*s1, *s2)); --- 1356,1363 ---- /* * comparison function for qsort */ ! static int ! panelCompare(s1, s2) char **s1, **s2; { return (strcmp(*s1, *s2)); *************** *** 1500,1509 **** /* * terminates and then sorts the panelList */ ! static void SortAndMakePanel(p) struct panel *p; { ! int i; DEBUG(("sort and make...")); DEBUG(("sort...")); --- 1367,1377 ---- /* * terminates and then sorts the panelList */ ! static void ! SortAndMakePanel(p) struct panel *p; { ! register int i; DEBUG(("sort and make...")); DEBUG(("sort...")); *************** *** 1511,1522 **** qsort(panelList, panelIndex, sizeof(char *), panelCompare); DEBUG(("removing...")); if(panelIndex > 0){ panel_FreeAllTags(p); panel_RemoveAll(p); DEBUG(("adding...")); for (i = 0; i < panelIndex; i++) { ! panel_Add(p, panelList[i], panelList[i], FALSE); } } DEBUG(("done\n")); } --- 1379,1396 ---- qsort(panelList, panelIndex, sizeof(char *), panelCompare); DEBUG(("removing...")); if(panelIndex > 0){ + static char lastItem[100] = ""; + panel_FreeAllTags(p); panel_RemoveAll(p); DEBUG(("adding...")); for (i = 0; i < panelIndex; i++) { ! if(panelList[i] && strcmp(lastItem,panelList[i])) { ! panel_Add(p, panelList[i], panelList[i], FALSE); ! strcpy(lastItem, panelList[i]); ! } } + *lastItem = '\0'; } DEBUG(("done\n")); } *************** *** 1525,1531 **** /* * just adds a string to the global panelList */ ! static char *AddToPanelList(s) char *s; { if(EnsurePanelListSize()) { --- 1399,1406 ---- /* * just adds a string to the global panelList */ ! static char * ! AddToPanelList(s) char *s; { if(EnsurePanelListSize()) { *************** *** 1547,1558 **** /* * Index library callback helper for 'expand the program list' */ ! static void Expander(aindex, ac, self) struct Index *aindex; struct indexComponent *ac; struct help *self; { ! AddToPanelList(ac->name); } --- 1422,1436 ---- /* * Index library callback helper for 'expand the program list' */ ! static void ! Expander(aindex, ac, self) struct Index *aindex; struct indexComponent *ac; struct help *self; { ! if(ac && ac->name && (*(ac->name) != '\0')) { ! AddToPanelList(ac->name); ! } } *************** *** 1559,1565 **** /* * toggle programs list size. Like da name dun say. */ ! static void ToggleProgramListSize(self, rock) register struct help* self; long rock; { --- 1437,1444 ---- /* * toggle programs list size. Like da name dun say. */ ! void ! ToggleProgramListSize(self, rock) register struct help* self; long rock; { *************** *** 1662,1668 **** /* * restores the original program panel (unfiltered) */ ! static void RestorePanel(self) register struct help *self; { if (!self->oldpanel) { --- 1541,1548 ---- /* * restores the original program panel (unfiltered) */ ! static void ! RestorePanel(self) register struct help *self; { if (!self->oldpanel) { *************** *** 1690,1696 **** * replaces the program panel with a new panel that contains only those * entries from the old panel specified by the user */ ! static void FilterPanel(self, rock) register struct help *self; long rock; { --- 1570,1577 ---- * replaces the program panel with a new panel that contains only those * entries from the old panel specified by the user */ ! static void ! FilterPanel(self, rock) register struct help *self; long rock; { *************** *** 1763,2465 **** im_SetProcessCursor((struct cursor *)NULL); } - - - /*---------------------------------------------------------------------------*/ - /* HELP CLASSPROCEDURES */ - /*---------------------------------------------------------------------------*/ - /* ! * makes new instance of a help object. Creates keylist and menus, binds procedures ! * to menus and keys, and adds a default filetype so that all files will have ! * at least the default template when they are displayed. */ ! boolean help__InitializeClass(classID) ! struct classheader *classID; { ! unsigned char c[2]; ! struct proctable_Entry *pe; - #ifdef DEBUGGING - if ((char *)getenv("HELPDEBUG") != (char *) NULL) - HELPDEBUG = 1; - #endif /* DEBUGGING */ - - DEBUG(("IN init class\n")); - Help_Menus = menulist_New(); - Help_Map = keymap_New(); - if (!Help_Menus || !Help_Map) - return FALSE; ! /* make all printing keys put a readonly message in the message line */ ! c[1] = '\0'; ! pe = proctable_DefineProc("help-readonly-key", nono, &help_classinfo, 0, "fake readonliness"); ! for (c[0] = (unsigned char)0; c[0] <= (unsigned char)127; c[0]++) ! if (isprint(c[0]) || c[0] == '\n' || c[0] == ' ') ! keymap_BindToKey(Help_Map, c, pe, NULL); ! bind_BindList(helpBindings, Help_Map, Help_Menus, &help_classinfo); ! /* what this is really doing is adding a catchall filetype and template */ ! filetype_AddEntry("*", "text", "template=default"); ! class_Load("helpdb"); ! class_Load("framcmds"); ! ! DEBUG(("OUT init class\n")); ! return TRUE; ! } ! /* ! * initializes a new help object. Sets up the view hiearchy, sets up panels, etc ! */ ! boolean help__InitializeObject(classID,self) ! struct classheader *classID; ! register struct help *self; ! { ! char pathName[MAXPATHLEN], *tmp = NULL, *colon = NULL; ! struct proctable_Entry *pe; ! struct self_help *id; ! struct view *v; ! int i = 0; - DEBUG(("IN init obj\n")); - waitCursor = cursor_Create(0); - cursor_SetStandard(waitCursor, Cursor_Wait); - im_SetProcessCursor(waitCursor); ! tmp = environ_GetConfiguration(SETUP_CHANGEDIR); ! if (tmp == NULL) { ! tmp = environ_LocalDir(DEFAULT_CHANGEDIR); ! } ! strcpy(changesDir, tmp); ! ! for(i = 0; i < MAX_TUTORIAL_DIRS; i++) ! tutorialDirs[i] = NULL; ! i = 0; ! if(tmp = environ_GetConfiguration(SETUP_TUTORIALDIR)) { ! if((colon = rindex(tmp,':')) == NULL) { ! tutorialDirs[i] = (char*) malloc(strlen(tmp) + 1); ! strcpy(tutorialDirs[i],tmp); ! } ! else { ! while(colon && (colon != '\0')) { ! *colon = '\0'; ! tutorialDirs[i] = (char*) malloc(strlen(tmp) + 1); ! strcpy(tutorialDirs[i],tmp); ! *colon = ':'; ! tmp = colon + 1; ! colon = rindex(tmp,':'); ! i++; ! } ! tutorialDirs[i] = (char*) malloc(strlen(tmp) + 1); ! strcpy(tutorialDirs[i],tmp); ! } ! } ! else { ! tmp = environ_AndrewDir(DEFAULT_TUTORIALDIR); ! tutorialDirs[i] = (char*) malloc(strlen(tmp) + 1); ! strcpy(tutorialDirs[i],tmp); ! } ! im_SetProcessCursor((struct cursor *) NULL); ! /* general variables */ ! self->expandedList = 0; ! self->showPanels = environ_GetProfileSwitch("ShowPanels", TRUE); ! self->showOverview = environ_GetProfileSwitch("ShowOverviews", TRUE); ! self->showList = environ_GetProfileSwitch("ShowPrograms", TRUE); ! self->showHistory = environ_GetProfileSwitch("ShowHistory", FALSE); ! ! self->state = keystate_Create(self, Help_Map); ! self->info = (struct cache *)malloc(sizeof(struct cache)); ! if (!self->info || !self->state) ! return FALSE; ! DEBUG(("info state ")); ! self->info->scroll = NULL; ! self->info->menus = menulist_DuplicateML(Help_Menus, self); ! if (!self->info->menus) ! return FALSE; ! DEBUG(("menus ")); ! self->info->flags = 0; ! self->info->flags = MENU_ToggleSizeExpand; /* start out shrunk initially */ ! self->info->flags |= (self->showPanels) ? MENU_TogglePanelHide : MENU_TogglePanelShow; ! self->info->flags |= (self->showOverview) ? MENU_ToggleOverHide : MENU_ToggleOverShow; ! self->info->flags |= (self->showList) ? MENU_ToggleListHide : MENU_ToggleListShow; ! self->info->flags |= (self->showHistory) ? MENU_ToggleHistHide : MENU_ToggleHistShow; ! self->info->flags |= MENU_ToggleFilterShow; ! self->info->all = self->info->cur = (struct helpFile *)NULL; ! self->info->histat = help_HIST_NOADD; ! self->info->histent[0] = '\0'; ! self->info->lastHist = NULL; ! ! self->mainLpair = NULL; ! ! /* the help text object */ ! self->info->data = (struct dataobject *)text_New(); ! self->info->view = (struct view *)textview_New(); ! if (!self->info->data || !self->info->view) ! return FALSE; ! DEBUG(("data view ")); - view_SetDataObject(self->info->view, self->info->data); - - self->info->scroll = scroll_Create(self->info->view, scroll_LEFT); - textview_SetEmbeddedBorder((struct textview *) self->info->view, 20, 5); - if (!self->info->scroll) - return FALSE; - DEBUG(("scroll ")); - - /* panels and their scrollbars */ - self->oldpanel = (struct panel *)NULL; - self->tmpanel = panel_New(); - self->overviewPanel = panel_New(); - self->listPanel = panel_New(); - self->historyPanel = panel_New(); - if (!self->tmpanel || !self->overviewPanel || !self->listPanel || !self->historyPanel) - return FALSE; - DEBUG(("panels ")); - self->info->hist = self->historyPanel; ! self->overviewScroll = (struct scroll *) panel_GetApplicationLayer(self->overviewPanel); ! self->listScroll = (struct scroll *) panel_GetApplicationLayer(self->listPanel); ! self->historyScroll = (struct scroll *) panel_GetApplicationLayer(self->historyPanel); ! if (!self->overviewScroll || !self->listScroll) ! return FALSE; ! /* labels */ ! self->overviewLab = label_New(); ! self->overviewLabV = labelview_New(); ! self->listLab = label_New(); ! self->listLabV = labelview_New(); ! self->historyLab = label_New(); ! self->historyLabV = labelview_New(); ! if (!self->overviewLab || !self->overviewLabV || !self->historyLab || !self->historyLabV ! || !self->listLab || !self->listLabV) ! return FALSE; - labelview_SetDataObject(self->overviewLabV, self->overviewLab); - label_SetFlags(self->overviewLab, label_CENTERED | label_BOXED); - label_SetText(self->overviewLab, "Overviews"); - - labelview_SetDataObject(self->listLabV, self->listLab); - label_SetFlags(self->listLab, label_CENTERED | label_BOXED); - label_SetText(self->listLab, "Programs"); - - labelview_SetDataObject(self->historyLabV, self->historyLab); - label_SetFlags(self->historyLab, label_CENTERED | label_BOXED); - label_SetText(self->historyLab, "Help History"); ! /* lpairs */ ! self->overviewLpair = lpair_Create(self->overviewLabV, self->overviewScroll, LABPCT); ! self->listLpair = lpair_Create(self->listLabV, self->listScroll, LABPCT); ! self->historyLpair = lpair_Create(self->historyLabV, self->historyScroll, LABPCT); ! self->panelLpair1 = lpair_Create(NULL, NULL, -PANELPCT); ! self->panelLpair2 = lpair_Create(NULL, NULL, -33); ! if (!self->overviewLpair || !self->listLpair || !self->historyLpair ! || !self->panelLpair1 || !self->panelLpair2) ! return FALSE; ! ! lpair_VTFixed(self->overviewLpair, self->overviewLabV, self->overviewScroll, LABPCT, 0); ! lpair_VTFixed(self->listLpair, self->listLabV, self->listScroll, LABPCT, 0); ! lpair_VTFixed(self->historyLpair, self->historyLabV, self->historyScroll, LABPCT, 0); ! /* if the user has all panels off, use the overview panel by default */ ! v = SetupLpairs(self); ! self->mainLpair = lpair_Create(self->info->scroll, ! v ? v : (struct view *)self->overviewScroll, -MAINPCT); ! if (!self->mainLpair) ! return FALSE; ! DEBUG(("main lpair ")); ! ! lpair_SetLPState(self->mainLpair, lpair_NOCHANGE, lpair_VERTICAL, 1); - DEBUG(("handlers ")); ! /* default panel handlers */ ! panel_SetHandler(self->overviewPanel, OverviewHelp, (char *) self); ! panel_SetHandler(self->listPanel, OverviewHelp, (char *) self); ! panel_SetHandler(self->tmpanel, OverviewHelp, (char *) self); ! panel_SetHandler(self->historyPanel, HistoryHelp, (char *) self); ! if (self->showPanels) ! lpair_LinkTree(self->mainLpair, self); ! else ! scroll_LinkTree(self->info->scroll, self); ! /* add minimum set of entries to listPanel */ ! if((tmp = environ_GetConfiguration(SETUP_PANELSDIR)) == NULL) { ! tmp = environ_GetConfiguration(SETUP_LIBDIR); ! if (tmp == NULL) ! tmp = environ_AndrewDir(DEFAULT_LIBDIR); ! } ! sprintf(pathName, "%s%s", tmp, PROGRAMFILE); ! ! if (0 == SetupPanel(TRUE, pathName, self->listPanel, NULL)) { ! /* got nothing from lib/help.programs; use extensions */ ! tmp = environ_GetConfiguration(SETUP_HELPDIR); ! if (tmp == NULL) ! tmp = environ_AndrewDir(DEFAULT_HELPDIR); ! strcpy(pathName, tmp); ! help_AddSearchDir(pathName); /* ??? XXX */ ! ! SetupPanel(FALSE, pathName, self->listPanel, program_ext_array); ! } - DEBUG(("expanding ")); - if (environ_GetProfileSwitch("ExpandedList", FALSE)) - ToggleProgramListSize(self, help_EXPAND); - - /* get overviews entries */ - if((tmp = environ_GetConfiguration(SETUP_PANELSDIR)) == NULL) { - tmp = environ_GetConfiguration(SETUP_LIBDIR); - if (tmp == NULL) - tmp = environ_AndrewDir(DEFAULT_LIBDIR); - } - sprintf(pathName, "%s%s", tmp, OVERVIEWFILE); - if (0 == SetupPanel(TRUE, pathName, self->overviewPanel, NULL)) { - tmp = environ_GetConfiguration(SETUP_HELPDIR); - if (tmp == NULL) - tmp = environ_AndrewDir(DEFAULT_HELPDIR); - strcpy(pathName, tmp); - help_AddSearchDir(pathName); /* ??? XXX */ ! SetupPanel(FALSE, pathName, self->overviewPanel, overview_ext_array); ! } ! /* post our menus */ ! SetupMenus(self->info); ! /* runtime-bound procedures */ ! pe = proctable_Lookup("textview-search"); ! if (pe) textSearch = (void (*)()) proctable_GetFunction(pe); ! else return FALSE; ! pe = proctable_Lookup("textview-reverse-search"); ! if (pe) textRevSearch = (void (*)()) proctable_GetFunction(pe); ! else return FALSE; ! pe = proctable_Lookup("textview-search-again"); ! if (pe) textSearchAgain = (void (*)()) proctable_GetFunction(pe); ! else return FALSE; ! pe = proctable_Lookup("textview-copy-region"); ! if (pe) textCopyRegion = (void (*)()) proctable_GetFunction(pe); ! else return FALSE; ! pe = proctable_Lookup("textview-next-screen"); ! if (pe) textPageDown = (void (*)()) proctable_GetFunction(pe); ! else return FALSE; ! pe = proctable_Lookup("textview-prev-screen"); ! if (pe) textPageUp = (void (*)()) proctable_GetFunction(pe); ! else return FALSE; ! pe = proctable_Lookup("frame-set-printer"); ! if (pe) frameSetPrinter = (void (*)()) proctable_GetFunction(pe); ! else return FALSE; ! ! /* now add ourself to the head of the instance list */ ! DEBUG(("ego: %d\n",(int)ego)); ! id = (struct self_help *)malloc(sizeof(struct self_help)); ! if (!id) ! return FALSE; ! id->this = self; ! id->next = ego; ! ego = id; ! DEBUG(("ego: %d\n",(int)ego)); - DEBUG(("OUT init obj\n")); - return TRUE; - } ! /* ! * destroys the resources of the help object ! */ ! void help__FinalizeObject(classID, self) ! struct classhead *classID; ! register struct help *self; ! { ! DEBUG(("IN finalize\n")); ! /* the presence/absence of self->info indicates whether we are ! in the process of finalizing, so that in update we know we ! can't post menus */ ! free(self->info); ! self->info = NULL; ! if(panelList) FreePanelListData(); ! im_Destroy(view_GetIM((struct view *)self)); ! DEBUG(("info\n")); ! DEBUG(("OUT finalize\n")); ! } ! ! /* ! * help__ method interface for using an alias file ! */ ! void help__SetAliasesFile(classID,alias) ! struct classheader *classID; ! register char *alias; ! { ! helpdb_ReadAliasesFile(alias); ! } ! /* ! * help__ method for adding a help index directory ! */ ! void help__SetIndex(classID,aindex) ! struct classheader *classID; ! register char *aindex; ! { ! DEBUG(("IN SetIndex: %s\n",aindex)); ! helpdb_SetIndex(aindex); ! } - /* - * help__ method for adding a directory to the searchpath - */ - void help__AddSearchDir(classID,dirName) - struct classheader *classID; - char *dirName; - { - if (access(dirName, 4) < 0) { - fprintf(stderr, "help: cannot open search directory '%s'\n", dirName); - return; - } - DEBUG(("adding dir: '%s'\n",dirName)); - helpdb_AddSearchDir(dirName); - } ! /* ! * outside interface help__ method for GetHelpOn. Used by helpapp ! * ! * Returns: ! * -1: if a server was down while trying to get help on this topic ! * 0: if no help found for this topic ! * 1: if successful ! */ ! static int help__HelpappGetHelpOn(classID, aname, isnew, ahistory, errmsg) ! struct classheader *classID; ! char *aname; /* what topic */ ! long isnew; /* is this a new topic? */ ! int ahistory; /* show in history log? 1-show aname 2-show tail of filename */ ! char *errmsg; /* error to print if failure. "Error" if this is NULL */ ! { ! if (aname[0] == '\0') { ! /* so -e flag with no file shown works */ ! return 1; ! } ! /* use the last instance added to the list */ ! DEBUG(("using %d view %d asking %d\n", (int)ego->this,(int)ego->this->info->view, ! message_Asking(ego->this->info->view))); ! if (message_Asking(ego->this->info->view)) { ! DEBUG(("retracting\n")); ! message_CancelQuestion(ego->this->info->view); ! } ! return GetHelpOn(ego->this, aname, isnew, ahistory, errmsg); ! } ! /* ! * return the first view in the list of instances, so helpapp can expose ! * a hidden window. ! */ ! struct view *help__GetInstance(classID) ! struct classheader *classID; ! { ! return (struct view *)(ego->this); ! } ! /*---------------------------------------------------------------------------*/ ! /* HELP METHODS */ ! /*---------------------------------------------------------------------------*/ ! /* ! * self explanatory ! */ ! void help__PostMenus(self, menuList) ! register struct help *self; ! struct menulist *menuList; ! { ! DEBUG(("post menus\n")); ! if (self->info != NULL) ! super_PostMenus(self, self->info->menus); ! } ! /* ! * override parents' keybindings ! */ ! void help__PostKeyState(self, keyState) ! register struct help *self; ! struct keystate *keyState; ! { ! DEBUG(("post keys\n")); ! keystate_AddBefore(self->state, keyState); ! super_PostKeyState(self, self->state); ! } ! /* ! * mouse action handler ! */ ! struct view *help__Hit(self, action, x, y, numberOfClicks) ! struct help *self; ! enum view_MouseAction action; ! long x, y; ! long numberOfClicks; ! { ! if (self->showPanels) ! return lpair_Hit(self->mainLpair, action, x, y, numberOfClicks); ! else ! return scroll_Hit(self->info->scroll, action, x, y, numberOfClicks); ! } ! /* ! * set up the view tree based on whether panels or scrollbar is the top level view ! */ ! void help__LinkTree(self, parent) ! struct help *self; ! struct view *parent; ! { ! DEBUG(("IN link tree\n")); ! DEBUG(("\tsuper...")); ! super_LinkTree(self, parent); ! if (self->showPanels) { ! if (self->mainLpair) ! lpair_LinkTree(self->mainLpair, self); ! } else { ! if (self->info!=NULL && self->info->scroll) ! scroll_LinkTree(self->info->scroll, self); ! } ! DEBUG(("OUT link tree\n")); ! } ! /* ! * refreshing! ! */ ! void help__FullUpdate(self, type, left, top, width, right) ! register struct help *self; ! enum view_UpdateType type; ! long left, top, width, right; ! { ! struct rectangle childRect; ! DEBUG(("IN fullupdate\n")); ! help_GetLogicalBounds(self, &childRect); ! if (self->showPanels) { /* need the main lpair as the root */ ! lpair_InsertView(self->mainLpair, self, &childRect); ! lpair_FullUpdate(self->mainLpair, type, left, top, width, right); ! } else { /* we just have the textview to show */ ! scroll_InsertView(self->info->scroll, self, &childRect); ! scroll_FullUpdate(self->info->scroll, type, left, top, width, right); ! } ! super_WantInputFocus(self, self->info->view); ! DEBUG(("OUT fullupdate\n")); ! } ! /* ! * erase and refresh the screen ! */ ! void help__Update(self) ! register struct help *self; ! { ! DEBUG(("IN update\n")); ! /* clear out the region, then do a full redraw */ ! help_EraseVisualRect(self); ! help_FullUpdate(self, view_FullRedraw, help_GetLogicalTop(self), help_GetLogicalLeft(self), ! help_GetLogicalWidth(self), help_GetLogicalHeight(self)); ! DEBUG(("OUT update\n")); ! } ! /* ! * update event handler ! */ ! void help__WantUpdate(self, requestor) ! register struct help *self; ! register struct view *requestor; ! { ! /* if the scrollbar took the hit, check if the user has selected something, ! and turn on some menus items if so */ ! if (self->info && (requestor == (struct view *)self->info->scroll)) { ! /* if the menumask changes, post menus */ ! if (menulist_SetMask(self->info->menus, ! (textview_GetDotLength((struct textview *)self->info->view) != 0) ? ! menulist_GetMask(self->info->menus) | MENU_SwitchCopy : ! menulist_GetMask(self->info->menus) & ~MENU_SwitchCopy)) ! help_PostMenus(self, self->info->menus); ! } ! super_WantUpdate(self, requestor); ! } /* ! * classproc to handle getting help using a terminal-based interface */ ! void help__GetHelpOnTerminal(classID,akey,list,print) struct classheader *classID; ! register char *akey; /* topic string */ ! register int list; /* do help on topic, or just list files? */ ! register int print; /* prompt for printing each helpfile? */ ! { ! FILE *tfile; ! char *alias, *pager, *index, *tmp; ! char pathName[MAXPATHLEN], cmdLine[MAXPATHLEN]; ! char hbuffer[HNSIZE], tbuffer[HNSIZE]; ! long digitMode, digitValue, firstChar; ! struct helpFile *tmpf; ! struct cache c; ! int tc; ! int first = 0; ! ! DEBUG(("key: %s\n",akey)); ! if (!helpdb_CheckIndex(NULL)) { /* if we haven't SetIndex */ ! index = environ_GetConfiguration(SETUP_INDEXDIR); ! if (index == NULL) ! index = environ_AndrewDir(DEFAULT_INDEXDIR); ! help_SetIndex(index); ! } ! ! if ((pager = environ_Get(PAGERVAR)) == (char *) NULL) ! pager = DEFAULTPAGER; ! ! if (!helpdb_CheckIndex(NULL)) { ! fprintf(stderr, err_index, pathName); ! return; ! } ! ! /* map helpKey */ ! strncpy(tbuffer, LowerCase(akey), HNSIZE); ! tbuffer[HNSIZE-1] = 0; ! ! /* now see if it has an illegal, command running, alias */ ! alias = (char *)helpdb_MapAlias(tbuffer); ! DEBUG(("map alias on: %s\n",tbuffer)); ! if (alias) { ! DEBUG(("alias: %s\n", alias)); ! if (alias[0] == '#') { ! fprintf(stderr,err_terminal); ! putchar('\n'); ! exit(1); ! /*NOTREACHED*/ ! } ! } ! ! alias = tbuffer; /* src */ ! tmp = hbuffer; /* dst */ ! digitMode = 0; ! digitValue = 0; ! firstChar = 1; ! /* copy alias (points to tbuffer) to hbuffer, suppressing spaces and ! computing digitValue */ ! while((tc = *alias++) != NULL) { ! if (tc == ' ' || tc == '\n' || tc == '\t') ! continue; ! if (tc == '(' || (!firstChar && tc == '.')) ! digitMode = 1; ! else if (digitMode) { ! if (tc >= '0' && tc <= '9') { ! digitValue *= 10; ! digitValue += tc - '0'; ! } ! } else { ! *tmp++ = tc; ! } ! firstChar = 1; ! } ! *tmp++ = 0; ! ! DEBUG(("tbuf: %s hbuf: %s\n",tbuffer,hbuffer)); ! ! c.all = (struct helpFile *)NULL; ! ! if (helpdb_SetupHelp(&c, hbuffer, FALSE) == 0) { ! fprintf(stderr, err_sorry, akey); ! putchar('\n'); ! exit(1); ! /*NOTREACHED*/ ! } ! ! /* if non-0 return, c->all was set up for us */ ! DEBUG(("setup done\n")); ! if (list) { ! printf("Using search directories: "); ! helpdb_PrintSearchDirs(); ! printf("\n"); ! printf("For topic %s the files are:\n",akey); ! for (tmpf = c.all; tmpf; tmpf = tmpf->next) { ! printf("\t%s\n",tmpf->fileName); ! } ! exit(0); ! /*NOTREACHED*/ ! } ! /* o.w. do real help on the topic */ ! first = TRUE; ! for(tmpf = c.all; tmpf; tmpf = tmpf->next) { ! int in = 0; ! char *fn; ! int skipFlag = FALSE; ! ! tfile = fopen(tmpf->fileName, "r"); ! if (!tfile) { ! fprintf(stderr, err_file, tmpf->fileName); ! continue; ! } ! ! if (!first) { ! skipFlag = FALSE; ! fn = rindex(tmpf->fileName, '/'); ! printf(msg_term_prompt, fn ? fn+1 : tmpf->fileName); ! in = getchar(); ! DEBUG(("'%c'\n", in)); ! if (in < 0) exit(1); ! else if (in == 'q' || in == 'Q') exit(0); ! else if (in == 'n' || in == 'N') skipFlag = TRUE; ! if (in != '\n') ! while ((in = getchar()) > 0 && in != '\n') ! ; ! } ! first = FALSE; ! ! if (!skipFlag) { ! /* show the file */ ! tc = fgetc(tfile); ! ungetc(tc,tfile); ! fclose(tfile); ! if ((tc == '.') || (tc == '#')) { /* troff file */ ! sprintf(cmdLine, ROFFCMD, tmpf->fileName, pager); ! } else { ! sprintf(cmdLine, ATKROFFCMD, tmpf->fileName, pager); ! } ! DEBUG(("cmd: %s\n",cmdLine)); ! system(cmdLine); ! } ! if (print) { ! /* see if they want to print it */ ! if (in < 0) exit(1); ! fn = rindex(tmpf->fileName, '/'); ! printf(msg_print_prompt, fn ? fn+1 : tmpf->fileName); ! in = getchar(); ! DEBUG(("'%c'\n", in)); ! if (in < 0) exit(1); ! else if (in != 'n' && in != 'N') { /* print it */ ! if ((tc == '.') || (tc == '#')) { /* troff file */ ! sprintf(cmdLine, ROFFPRINTCMD, tmpf->fileName); ! } else { ! sprintf(cmdLine, ATKPRINTCMD, tmpf->fileName); ! } ! DEBUG(("cmd: %s\n",cmdLine)); ! system(cmdLine); ! } ! if (in != '\n') ! while ((in = getchar()) > 0 && in != '\n') ! ; ! } ! } } --- 1644,1901 ---- im_SetProcessCursor((struct cursor *)NULL); } /* ! * random key hit proc to chastise the user */ ! static void ! nono(self) ! register struct help *self; { ! message_DisplayString(self, 0, err_readonly); ! } ! static struct bind_Description helpBindings[] = { ! /* ! {"proc-name", keybinding, keyrock, ! "menu string", menurock, menuflag, function-to-call, ! "documentation string", module-name} ! */ ! /* Toggling menu items */ ! /* if self->showPanels */ ! {"help-toggle-panels", NULL, help_HIDE_PANEL, ! "Panels~10,Hide Panels~2", help_HIDE_PANEL, MENU_TogglePanelHide, TogglePanels, ! NULL, NULL}, ! {"help-toggle-panels", NULL, help_SHOW_PANEL, ! "Panels~10,Show Panels~2", help_SHOW_PANEL, MENU_TogglePanelShow, TogglePanels, ! NULL, NULL}, + {"help-toggle-panels", HELP_KEY_TOGGLE_PANELS, help_ALWAYS_TOGGLE, + NULL, help_ALWAYS_TOGGLE, MENU_Never, TogglePanels, + "toggle help panels", NULL}, ! /* if self->showOverview */ ! {"help-toggle-overviews", NULL, help_HIDE_OVER, ! "Panels~10,Hide Overviews~20", help_HIDE_OVER, MENU_ToggleOverHide, ToggleOverviews, ! NULL, NULL}, ! {"help-toggle-overviews", NULL, help_SHOW_OVER, ! "Panels~10,Show Overviews~20", help_SHOW_OVER, MENU_ToggleOverShow, ToggleOverviews, ! NULL, NULL}, ! {"help-toggle-overviews", HELP_KEY_TOGGLE_OVER, help_ALWAYS_TOGGLE, ! NULL, help_ALWAYS_TOGGLE, MENU_Never, ToggleOverviews, ! "toggle overviews panel", NULL}, ! /* if self->showList */ ! {"help-toggle-programs", NULL, help_HIDE_LIST, ! "Panels~10,Hide Programs~22", help_HIDE_LIST, MENU_ToggleListHide, TogglePrograms, ! NULL, NULL}, + {"help-toggle-programs", NULL, help_SHOW_LIST, + "Panels~10,Show Programs~22", help_SHOW_LIST, MENU_ToggleListShow, TogglePrograms, + NULL, NULL}, ! {"help-toggle-programs", HELP_KEY_TOGGLE_PROGRAMS, help_ALWAYS_TOGGLE, ! NULL, help_ALWAYS_TOGGLE, MENU_Never, TogglePrograms, ! "toggle programs panel", NULL}, + /* if self->showHistory */ + {"help-toggle-history", NULL, help_HIDE_HIST, + "Panels~10,Hide History~24", help_HIDE_HIST, MENU_ToggleHistHide, ToggleHistory, + NULL, NULL}, ! {"help-toggle-history", NULL, help_SHOW_HIST, ! "Panels~10,Show History~24", help_SHOW_HIST, MENU_ToggleHistShow, ToggleHistory, ! NULL, NULL}, ! {"help-toggle-history", HELP_KEY_TOGGLE_HIST, help_ALWAYS_TOGGLE, ! NULL, help_ALWAYS_TOGGLE, MENU_Never, ToggleHistory, ! "toggle history panel", NULL}, ! /* if self->expandedList */ ! {"help-toggle-size", NULL, help_SHRINK, ! "Panels~10,Shrink Programs List~10", help_SHRINK, MENU_ToggleSizeShrink, ! ToggleProgramListSize, NULL, NULL}, ! {"help-toggle-size", NULL, help_EXPAND, ! "Panels~10,Expand Programs List~10", help_EXPAND, MENU_ToggleSizeExpand, ! ToggleProgramListSize, NULL, NULL}, ! {"help-toggle-size", HELP_KEY_TOGGLE_PROGRAMS, help_ALWAYS_TOGGLE, ! NULL, help_ALWAYS_TOGGLE, MENU_Never, ToggleProgramListSize, ! "toggle program list size", NULL}, ! {"help-filter-programs", NULL, help_FILTER_FILTER, ! "Other~10,Filter Programs Panel~10", help_FILTER_FILTER, MENU_ToggleFilterShow, FilterPanel, ! "filter-programs", NULL}, ! {"help-refilter-programs", NULL, help_FILTER_REFILTER, ! "Other~10,ReFilter Programs Panel~12", help_FILTER_REFILTER, MENU_ToggleReFilterShow, FilterPanel, ! "filter-programs", NULL}, ! {"help-restore-programs", NULL, help_FILTER_RESTORE, ! "Other~10,Restore Programs Panel~10", help_FILTER_RESTORE, MENU_ToggleRestoreShow, RestorePanel, ! "restore programs panel", NULL}, + {"help-show-more", HELP_KEY_SHOW_MORE, 0, + "Show More Documentation~30", 0, MENU_SwitchMoreMenu, NextHelp, + "show more documentation", NULL}, ! {"help-show-tutorial", HELP_KEY_SHOW_TUTORIAL, 0, ! "Show Tutorial~32", 0, MENU_SwitchTutorialMenu, ShowTutorial, ! "show tutorial", NULL}, ! {"help-changes", HELP_KEY_SHOW_CHANGES, 0, ! "Show Changes~34", 0, MENU_SwitchChangesMenu, ShowChanges, ! "show changes on topic", NULL}, ! ! {"help-copy-region", HELP_KEY_COPY_REGION, help_COPY_REGION, ! "Copy~2", help_COPY_REGION, MENU_SwitchCopy, TextviewProc, ! "Copy region to kill-buffer", NULL}, ! ! /* non-toggling menu items */ + {"help-delete-window", HELP_KEY_DELETE_WINDOW, 0, + "Window~12,Delete This Window~90",0 ,MENU_SwitchDeleteMenu, ExitProc, + "delete this window", NULL}, ! {"help-add-search-dir", HELP_KEY_ADD_SEARCH_DIR, 0, ! "Other~10,Add Search Directory~20", 0, MENU_Always, AddSearchDir, ! "add a directory to the search path", NULL}, + {"help-add-bookmark", HELP_KEY_ADD_BOOKMARK, 0, + "Other~10,Make Bookmark~30", 0, MENU_Always, AddBookmark, + "add a history entry for this file", NULL}, ! {"help-show-help-on", HELP_KEY_HELP_ON, help_ON, ! "Show Help on ...~14", help_ON, MENU_Always, NewHelp, ! "show help on a prompted keyword", NULL}, + {"help-show-help-on", HELP_KEY_HELP_ON_2, help_ON, + NULL, help_ON, MENU_Always, NewHelp, + NULL, NULL}, ! {"help-new-show-help-on", HELP_KEY_WINDOW_SPLIT, help_ON | help_NEW_WIN, ! "Window~12,Show Help on...~14", help_ON | help_NEW_WIN, MENU_Always, NewHelp, ! "show help on a prompted keyword in a new window", NULL}, ! {"help-show-help-on-selected", HELP_KEY_HELP_ON_SELECTED, help_SEL, ! "Show Help on Selected Word~16", help_SEL, MENU_Always, NewHelp, ! "show help on selected region", NULL}, ! {"help-new-show-help-on-selected", NULL, help_SEL | help_NEW_WIN, ! "Window~12,Show Help on Selected Word~26", help_SEL | help_NEW_WIN, MENU_Always, NewHelp, ! "show help on selected region in a new window", NULL}, ! {"help-comments", HELP_KEY_SEND_COMMENT, 0, ! "Send Comment On Help~31", 0, MENU_Always, SendComments, ! "send comments on help", NULL}, ! {"help-set-printer", HELP_KEY_SET_PRINTER, help_SET_PRINTER, ! "Print~6,Set Printer~12", help_SET_PRINTER, MENU_Always, TextviewProc, ! "set the printer", NULL}, ! {"help-print", HELP_KEY_PRINT, 0, ! "Print~6,Print This File~22", 0, MENU_Always, Print, ! "print current help file", NULL}, ! {"help-quit", HELP_KEY_QUIT, 0, ! "Quit~99", 0, MENU_Always, Quit, ! "quit help", NULL}, ! /* imported from textview... */ ! {"help-search", HELP_KEY_SEARCH, help_SEARCH, ! "Search~4,Forward~12", help_SEARCH, MENU_Always, TextviewProc, ! "forward search", NULL}, ! {"help-reverse-search", HELP_KEY_RSEARCH, help_RSEARCH, ! "Search~4,Backward~14", help_RSEARCH, MENU_Always, TextviewProc, ! "reverse search", NULL}, ! ! {"help-search-again", HELP_KEY_SEARCH_AGAIN, help_SEARCH_AGAIN, ! "Search~4,Search Again~16", help_SEARCH_AGAIN, MENU_Always, TextviewProc, ! "search again", NULL}, ! {"help-search-overviews", HELP_KEY_SEARCH_OVERVIEWS, 0, ! "Search~4,Search Overviews~20", 0, MENU_Always, SearchOverviews, ! "search overviews", NULL}, ! {"help-search-programs", HELP_KEY_SEARCH_PROGRAMS, 0, ! "Search~4,Search Programs~22", 0, MENU_Always, SearchPrograms, ! "search programs", NULL}, ! ! {"help-next-screen", HELP_KEY_NEXT_SCREEN, help_PAGE_DOWN, ! NULL, help_PAGE_DOWN, 0, TextviewProc, ! "advance to next screen", NULL}, ! ! {"help-next-screen", HELP_KEY_NEXT_SCREEN2, help_PAGE_DOWN, ! NULL, help_PAGE_DOWN, 0, TextviewProc, ! "advance to next screen", NULL}, + {"help-prev-screen", HELP_KEY_PREV_SCREEN, help_PAGE_UP, + NULL, help_PAGE_UP, 0, TextviewProc, + "go back to previous screen", NULL}, + NULL}; + /* ! * makes new instance of a help object. Creates keylist and menus, binds procedures ! * to menus and keys, and adds a default filetype so that all files will have ! * at least the default template when they are displayed. */ ! boolean ! help__InitializeClass(classID) struct classheader *classID; ! { ! unsigned char c[2]; ! struct proctable_Entry *pe; ! #ifdef DEBUGGING ! if ((char *)getenv("HELPDEBUG") != (char *) NULL) ! HELPDEBUG = 1; ! #endif /* DEBUGGING */ ! DEBUG(("IN init class\n")); ! Help_Menus = menulist_New(); ! Help_Map = keymap_New(); ! DEBUG(("created Help_Menus, Help_Map\n")); ! if (!Help_Menus || !Help_Map) ! return FALSE; ! /* make all printing keys put a readonly message in the message line */ ! c[1] = '\0'; ! pe = proctable_DefineProc("help-readonly-key", nono, &help_classinfo, 0, "fake readonliness"); ! for (c[0] = (unsigned char)0; c[0] <= (unsigned char)127; c[0]++) ! if (isprint(c[0]) || c[0] == '\n' || c[0] == ' ') ! keymap_BindToKey(Help_Map, c, pe, NULL); ! DEBUG(("about to bind helpBindings\n")); ! bind_BindList(helpBindings, Help_Map, Help_Menus, &help_classinfo); ! DEBUG(("about to create catchall filetype\n")); ! /* what this is really doing is adding a catchall filetype and template */ ! filetype_AddEntry("*", "text", "template=default"); ! ! DEBUG(("about to load helpdb\n")); ! class_Load("helpdb"); ! DEBUG(("about to load framecmds\n")); ! class_Load("framecmds"); ! ! DEBUG(("OUT init class\n")); ! return TRUE; } *** atk/help/src/help.ch Mon Aug 6 11:06:53 1990 --- atk/help/src/help.ch.NEW Fri May 24 17:27:37 1991 *************** *** 2,13 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/help/src/RCS/help.ch,v 2.18 89/05/02 13:36:47 mp1w Exp $ */ /* $ACIS$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/help/src/RCS/help.ch,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/help/src/RCS/help.ch,v 2.18 89/05/02 13:36:47 mp1w Exp $"; #endif /* !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) */ --- 2,13 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/help/src/RCS/help.ch,v 2.19 1991/04/18 20:59:23 gk5g Exp $ */ /* $ACIS$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/help/src/RCS/help.ch,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/help/src/RCS/help.ch,v 2.19 1991/04/18 20:59:23 gk5g Exp $"; #endif /* !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) */ *************** *** 86,89 **** --- 86,90 ---- struct panel *tmpanel; /* for filtered programList */ struct panel *oldpanel; /* to placehold original programPanel */ + struct scroll *app; /* This view's application layer */ }; *** atk/help/src/help.h Fri Dec 21 14:55:05 1990 --- atk/help/src/help.h.NEW Tue May 28 17:39:30 1991 *************** *** 2,13 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/help/src/RCS/help.h,v 1.36 90/11/06 14:11:46 gk5g Exp Locker: gk5g $ */ /* $ACIS$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/help/src/RCS/help.h,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/help/src/RCS/help.h,v 1.36 90/11/06 14:11:46 gk5g Exp Locker: gk5g $"; #endif /* !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) */ --- 2,13 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/help/src/RCS/help.h,v 1.40 1991/02/13 15:28:11 gk5g Exp $ */ /* $ACIS$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/help/src/RCS/help.h,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/help/src/RCS/help.h,v 1.40 1991/02/13 15:28:11 gk5g Exp $"; #endif /* !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) */ *************** *** 18,283 **** /*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/ - /* PROTOTYPES */ - /*---------------------------------------------------------------------------*/ - - boolean help__InitializeClass(); - boolean help__InitializeObject(); - extern char *index(), *rindex(); - extern int errno; - static char *AddToPanelList(); - static char *AndyCopy(); - static char *CopyString(); - static int ScanLine(); - static char *LowerCase(); - static char *MapParens(); - static int GetHelpOn(); - static int ShowFile(); - static int help__HelpappGetHelpOn(); - static int mysystem (); - static int panelCompare(); - static struct view *SetupLpairs(); - static void AddBookmark(); - static void AddHistoryItem (); - static void AddSearchDir(); - static void ExitProc(); - static void Expander (); - static void ExpanderAux(); - static void FilterPanel(); - static void HistoryHelp (); - static void NewHelp(); - static void NextHelp (); - static void OverviewHelp (); - static void Print(); - static void RestorePanel(); - static void SearchOverviews(); - static void SearchPrograms(); - static void SendComments(); - static void SetupMenus(); - static long SetupPanel(); - static void ShowChanges(); - static void ShowTutorial(); - static void SortAndMakePanel(); - static void TextviewProc(); - static void ToggleHistory(); - static void ToggleOverviews(); - static void TogglePanels(); - static void ToggleProgramListSize(); - static void TogglePrograms(); - static void nono(); - struct view *help__GetInstance(); - struct view *help__Hit(); - void help__AddSearchDir(); - void help__FinalizeObject(); - void help__FullUpdate(); - void help__LinkTree(); - void help__MoreMode(); - void help__PostKeyState(); - void help__PostMenus(); - void help__SetAliasesFile(); - void help__SetIndex(); - void help__Update(); - void help__WantUpdate(); - - /*---------------------------------------------------------------------------*/ /* INTERNAL CONSTANTS */ /*---------------------------------------------------------------------------*/ - - /* - * globals bindings for menus and keys - */ - static struct bind_Description helpBindings[]={ - - /* - {"proc-name", keybinding, keyrock, - "menu string", menurock, menuflag, function-to-call, - "documentation string", module-name} - */ - - /* Toggling menu items */ - - /* if self->showPanels */ - {"help-toggle-panels", NULL, help_HIDE_PANEL, - "Panels~10,Hide Panels~2", help_HIDE_PANEL, MENU_TogglePanelHide, TogglePanels, - NULL, NULL}, - - {"help-toggle-panels", NULL, help_SHOW_PANEL, - "Panels~10,Show Panels~2", help_SHOW_PANEL, MENU_TogglePanelShow, TogglePanels, - NULL, NULL}, - - {"help-toggle-panels", HELP_KEY_TOGGLE_PANELS, help_ALWAYS_TOGGLE, - NULL, help_ALWAYS_TOGGLE, MENU_Never, TogglePanels, - "toggle help panels", NULL}, - - - /* if self->showOverview */ - {"help-toggle-overviews", NULL, help_HIDE_OVER, - "Panels~10,Hide Overviews~20", help_HIDE_OVER, MENU_ToggleOverHide, ToggleOverviews, - NULL, NULL}, - - {"help-toggle-overviews", NULL, help_SHOW_OVER, - "Panels~10,Show Overviews~20", help_SHOW_OVER, MENU_ToggleOverShow, ToggleOverviews, - NULL, NULL}, - - {"help-toggle-overviews", HELP_KEY_TOGGLE_OVER, help_ALWAYS_TOGGLE, - NULL, help_ALWAYS_TOGGLE, MENU_Never, ToggleOverviews, - "toggle overviews panel", NULL}, - - - /* if self->showList */ - {"help-toggle-programs", NULL, help_HIDE_LIST, - "Panels~10,Hide Programs~22", help_HIDE_LIST, MENU_ToggleListHide, TogglePrograms, - NULL, NULL}, - - {"help-toggle-programs", NULL, help_SHOW_LIST, - "Panels~10,Show Programs~22", help_SHOW_LIST, MENU_ToggleListShow, TogglePrograms, - NULL, NULL}, - - {"help-toggle-programs", HELP_KEY_TOGGLE_PROGRAMS, help_ALWAYS_TOGGLE, - NULL, help_ALWAYS_TOGGLE, MENU_Never, TogglePrograms, - "toggle programs panel", NULL}, - - - /* if self->showHistory */ - {"help-toggle-history", NULL, help_HIDE_HIST, - "Panels~10,Hide History~24", help_HIDE_HIST, MENU_ToggleHistHide, ToggleHistory, - NULL, NULL}, - - {"help-toggle-history", NULL, help_SHOW_HIST, - "Panels~10,Show History~24", help_SHOW_HIST, MENU_ToggleHistShow, ToggleHistory, - NULL, NULL}, - - {"help-toggle-history", HELP_KEY_TOGGLE_HIST, help_ALWAYS_TOGGLE, - NULL, help_ALWAYS_TOGGLE, MENU_Never, ToggleHistory, - "toggle history panel", NULL}, - - - /* if self->expandedList */ - {"help-toggle-size", NULL, help_SHRINK, - "Panels~10,Shrink Programs List~10", help_SHRINK, MENU_ToggleSizeShrink, - ToggleProgramListSize, NULL, NULL}, - - {"help-toggle-size", NULL, help_EXPAND, - "Panels~10,Expand Programs List~10", help_EXPAND, MENU_ToggleSizeExpand, - ToggleProgramListSize, NULL, NULL}, - - {"help-toggle-size", HELP_KEY_TOGGLE_PROGRAMS, help_ALWAYS_TOGGLE, - NULL, help_ALWAYS_TOGGLE, MENU_Never, ToggleProgramListSize, - "toggle program list size", NULL}, - - - {"help-filter-programs", NULL, help_FILTER_FILTER, - "Other~10,Filter Programs Panel~10", help_FILTER_FILTER, MENU_ToggleFilterShow, FilterPanel, - "filter-programs", NULL}, - - {"help-refilter-programs", NULL, help_FILTER_REFILTER, - "Other~10,ReFilter Programs Panel~12", help_FILTER_REFILTER, MENU_ToggleReFilterShow, FilterPanel, - "filter-programs", NULL}, - - {"help-restore-programs", NULL, help_FILTER_RESTORE, - "Other~10,Restore Programs Panel~10", help_FILTER_RESTORE, MENU_ToggleRestoreShow, RestorePanel, - "restore programs panel", NULL}, - - - {"help-show-more", HELP_KEY_SHOW_MORE, 0, - "Show More Documentation~30", 0, MENU_SwitchMoreMenu, NextHelp, - "show more documentation", NULL}, - - {"help-show-tutorial", HELP_KEY_SHOW_TUTORIAL, 0, - "Show Tutorial~32", 0, MENU_SwitchTutorialMenu, ShowTutorial, - "show tutorial", NULL}, - - {"help-changes", HELP_KEY_SHOW_CHANGES, 0, - "Show Changes~34", 0, MENU_SwitchChangesMenu, ShowChanges, - "show changes on topic", NULL}, - - {"help-copy-region", HELP_KEY_COPY_REGION, help_COPY_REGION, - "Copy~2", help_COPY_REGION, MENU_SwitchCopy, TextviewProc, - "Copy region to kill-buffer", NULL}, - - - /* non-toggling menu items */ - - - {"help-delete-window", HELP_KEY_DELETE_WINDOW, 0, - "Window~12,Delete This Window~90",0 ,MENU_SwitchDeleteMenu, ExitProc, - "delete this window", NULL}, - - {"help-add-search-dir", HELP_KEY_ADD_SEARCH_DIR, 0, - "Other~10,Add Search Directory~20", 0, MENU_Always, AddSearchDir, - "add a directory to the search path", NULL}, - - {"help-add-bookmark", HELP_KEY_ADD_BOOKMARK, 0, - "Other~10,Make Bookmark~30", 0, MENU_Always, AddBookmark, - "add a history entry for this file", NULL}, - - {"help-show-help-on", HELP_KEY_HELP_ON, help_ON, - "Show Help on ...~14", help_ON, MENU_Always, NewHelp, - "show help on a prompted keyword", NULL}, - - {"help-show-help-on", HELP_KEY_HELP_ON_2, help_ON, - NULL, help_ON, MENU_Always, NewHelp, - NULL, NULL}, - - {"help-new-show-help-on", HELP_KEY_WINDOW_SPLIT, help_ON | help_NEW_WIN, - "Window~12,Show Help on...~14", help_ON | help_NEW_WIN, MENU_Always, NewHelp, - "show help on a prompted keyword in a new window", NULL}, - - {"help-show-help-on-selected", HELP_KEY_HELP_ON_SELECTED, help_SEL, - "Show Help on Selected Word~16", help_SEL, MENU_Always, NewHelp, - "show help on selected region", NULL}, - - {"help-new-show-help-on-selected", NULL, help_SEL | help_NEW_WIN, - "Window~12,Show Help on Selected Word~26", help_SEL | help_NEW_WIN, MENU_Always, NewHelp, - "show help on selected region in a new window", NULL}, - - {"help-comments", HELP_KEY_SEND_COMMENT, 0, - "Send Comment On Help~31", 0, MENU_Always, SendComments, - "send comments on help", NULL}, - - {"help-set-printer", HELP_KEY_SET_PRINTER, help_SET_PRINTER, - "Print~6,Set Printer~12", help_SET_PRINTER, MENU_Always, TextviewProc, - "set the printer", NULL}, - - {"help-print", HELP_KEY_PRINT, 0, - "Print~6,Print This File~22", 0, MENU_Always, Print, - "print current help file", NULL}, - - /* imported from textview... */ - - {"help-search", HELP_KEY_SEARCH, help_SEARCH, - "Search~4,Forward~12", help_SEARCH, MENU_Always, TextviewProc, - "forward search", NULL}, - - {"help-reverse-search", HELP_KEY_RSEARCH, help_RSEARCH, - "Search~4,Backward~14", help_RSEARCH, MENU_Always, TextviewProc, - "reverse search", NULL}, - - {"help-search-again", HELP_KEY_SEARCH_AGAIN, help_SEARCH_AGAIN, - "Search~4,Search Again~16", help_SEARCH_AGAIN, MENU_Always, TextviewProc, - "search again", NULL}, - - {"help-search-overviews", HELP_KEY_SEARCH_OVERVIEWS, 0, - "Search~4,Search Overviews~20", 0, MENU_Always, SearchOverviews, - "search overviews", NULL}, - - {"help-search-programs", HELP_KEY_SEARCH_PROGRAMS, 0, - "Search~4,Search Programs~22", 0, MENU_Always, SearchPrograms, - "search programs", NULL}, - - {"help-next-screen", HELP_KEY_NEXT_SCREEN, help_PAGE_DOWN, - NULL, help_PAGE_DOWN, 0, TextviewProc, - "advance to next screen", NULL}, - - {"help-next-screen", HELP_KEY_NEXT_SCREEN2, help_PAGE_DOWN, - NULL, help_PAGE_DOWN, 0, TextviewProc, - "advance to next screen", NULL}, - - {"help-prev-screen", HELP_KEY_PREV_SCREEN, help_PAGE_UP, - NULL, help_PAGE_UP, 0, TextviewProc, - "go back to previous screen", NULL}, - - NULL}; static char *overview_ext_array[] = OVERVIEW_EXTS; static char *program_ext_array[] = PROGRAM_EXTS; --- 18,25 ---- *** atk/help/src/helpa.c Fri Dec 21 14:55:07 1990 --- atk/help/src/helpa.c.NEW Tue May 28 17:39:33 1991 *************** *** 2,13 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/help/src/RCS/helpa.c,v 2.32 90/10/26 15:57:03 gk5g Exp $ */ /* $ACIS$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/help/src/RCS/helpa.c,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/help/src/RCS/helpa.c,v 2.32 90/10/26 15:57:03 gk5g Exp $"; #endif /* !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) */ /*---------------------------------------------------------------------------*/ --- 2,13 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/help/src/RCS/helpa.c,v 2.43 1991/05/28 21:33:25 gk5g Exp $ */ /* $ACIS$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/help/src/RCS/helpa.c,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/help/src/RCS/helpa.c,v 2.43 1991/05/28 21:33:25 gk5g Exp $"; #endif /* !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) */ /*---------------------------------------------------------------------------*/ *************** *** 30,41 **** /* on a socket to listen for new help connections. */ /*---------------------------------------------------------------------------*/ - #include - #define label gezornenplatz - #include #include /* sys/types.h sys/time.h strings.h */ #undef label #include #include --- 30,39 ---- /* on a socket to listen for new help connections. */ /*---------------------------------------------------------------------------*/ #define label gezornenplatz #include /* sys/types.h sys/time.h strings.h */ #undef label + #include #include #include *************** *** 50,61 **** #include #include #include #include #include ! #include "config.h" ! #include "helpsys.h" #include #define IPPORT_HELPNAME "andrewhelp" --- 48,67 ---- #include #include + #ifdef M_UNIX + #include + #define direct dirent + #else #include + #endif #include #include + #include + #include + #include ! #include ! #include #include #define IPPORT_HELPNAME "andrewhelp" *************** *** 83,89 **** /* for setting up the help service */ static struct servent *ts; static struct hostent *th; - static short helpPort; static struct sockaddr_in myaddr; static int helpSocket = -1; --- 89,94 ---- *************** *** 104,110 **** /* * usage statement */ ! static void show_usage(self) struct helpapp *self; { #ifdef DEBUGGING --- 109,116 ---- /* * usage statement */ ! static void ! show_usage(self) struct helpapp *self; { #ifdef DEBUGGING *************** *** 134,140 **** /* * start up and start accepting connections and commands from other helps */ ! static void ncproc () { register int ns; struct sockaddr_in helpaddr; --- 140,147 ---- /* * start up and start accepting connections and commands from other helps */ ! static void ! ncproc () { register int ns; struct sockaddr_in helpaddr; *************** *** 179,185 **** /* * add a path to those to be searched */ ! static AddPath(astr) register char *astr; { char tname[MAXPATHLEN]; --- 186,193 ---- /* * add a path to those to be searched */ ! static ! AddPath(astr) register char *astr; { char tname[MAXPATHLEN]; *************** *** 208,227 **** /* * send_pack: send a command packet to an existing help instance */ ! static int send_pack(c, s, sock) char c; /* the command char */ char *s; /* the string to send */ int sock; /* the socket to send to */ { long len; ! char buf[MAXPATHLEN + 1 + sizeof(long)]; /* length = string + NULL + sizeof(length) + command char */ len = strlen(s) + sizeof(long) + 2; ! *(long *)buf = htonl(len); ! sprintf(buf+sizeof(long), "%c%s", c, s); ! DEBUG(("ha: sent: %s\n", buf+sizeof(long))); ! return write(sock, buf, len); } --- 216,240 ---- /* * send_pack: send a command packet to an existing help instance */ ! static int ! send_pack(c, s, sock) char c; /* the command char */ char *s; /* the string to send */ int sock; /* the socket to send to */ { long len; ! /* buf needs to be an array of longs so that it will be ! * properly aligned for architectures like the HP-PA ! * that insist that longs be 4-byte aligned ! */ ! long buf[(MAXPATHLEN + 1 + 2*sizeof(long))/sizeof(long)]; /* length = string + NULL + sizeof(length) + command char */ len = strlen(s) + sizeof(long) + 2; ! buf[0] = htonl(len); ! sprintf(((char *)buf)+sizeof(long), "%c%s", c, s); ! DEBUG(("ha: sent: %s\n", ((char *)buf)+sizeof(long))); ! return write(sock, ((char *)buf), len); } *************** *** 239,245 **** #endif /* MAXHOSTNAMELEN */ #define MAXHOSTNAMELEN 64 /* some people just don't */ ! static void unique_help() { register int i; char *wmHost; --- 252,260 ---- #endif /* MAXHOSTNAMELEN */ #define MAXHOSTNAMELEN 64 /* some people just don't */ ! static void ! unique_help(self) ! struct helpapp *self; { register int i; char *wmHost; *************** *** 249,257 **** /* lookup the help port, default to the 'right' thing */ if ((ts = getservbyname(IPPORT_HELPNAME, 0)) != (struct servent *)NULL) ! helpPort = ts->s_port; else ! helpPort = htons(HELPSOCK); #ifdef WM_ENV wmHost = (char *) environ_Get("WMHOST"); if (wmHost == NULL) { --- 264,272 ---- /* lookup the help port, default to the 'right' thing */ if ((ts = getservbyname(IPPORT_HELPNAME, 0)) != (struct servent *)NULL) ! self->helpPort = ts->s_port; else ! self->helpPort = htons(HELPSOCK); #ifdef WM_ENV wmHost = (char *) environ_Get("WMHOST"); if (wmHost == NULL) { *************** *** 277,283 **** if (th != NULL) { bcopy(th->h_addr, &myaddr.sin_addr.s_addr, sizeof(long)); myaddr.sin_family = AF_INET; ! myaddr.sin_port = helpPort; helpSocket = socket(AF_INET, SOCK_STREAM, 0); i = connect(helpSocket, &myaddr, sizeof(myaddr)); if (i >= 0) { --- 292,298 ---- if (th != NULL) { bcopy(th->h_addr, &myaddr.sin_addr.s_addr, sizeof(long)); myaddr.sin_family = AF_INET; ! myaddr.sin_port = self->helpPort; helpSocket = socket(AF_INET, SOCK_STREAM, 0); i = connect(helpSocket, &myaddr, sizeof(myaddr)); if (i >= 0) { *************** *** 313,319 **** on = 1; setsockopt(helpSocket, SOL_SOCKET, SO_REUSEADDR, on, sizeof(on) ); myaddr.sin_family = AF_INET; ! myaddr.sin_port = helpPort; myaddr.sin_addr.s_addr = 0; /* me, me! */ i = bind(helpSocket, &myaddr, sizeof(myaddr)); if (i >= 0) { --- 328,334 ---- on = 1; setsockopt(helpSocket, SOL_SOCKET, SO_REUSEADDR, on, sizeof(on) ); myaddr.sin_family = AF_INET; ! myaddr.sin_port = self->helpPort; myaddr.sin_addr.s_addr = 0; /* me, me! */ i = bind(helpSocket, &myaddr, sizeof(myaddr)); if (i >= 0) { *************** *** 332,347 **** } } - /* * parse command line arguments */ ! boolean helpapp__ParseArgs(self,argc,argv) struct helpapp *self; int argc; char **argv; { ! struct helpDir *thd=(struct helpDir *)NULL; DEBUG(("ha: IN parse args\n")); --- 347,362 ---- } } /* * parse command line arguments */ ! boolean ! helpapp__ParseArgs(self, argc, argv) struct helpapp *self; int argc; char **argv; { ! char *helpPath; DEBUG(("ha: IN parse args\n")); *************** *** 360,369 **** var= *++argv;\ } while(*++argv!=NULL) if(**argv=='-') switch((*argv)[1]){ - char *temp; case 'i': if (indexName != NULL) { fprintf(stderr,"%s: only one index allowed\n", --- 375,387 ---- var= *++argv;\ } + if((helpPath = environ_Get("HELPPATH")) != NULL) { + AddPath(helpPath); + } + while(*++argv!=NULL) if(**argv=='-') switch((*argv)[1]){ case 'i': if (indexName != NULL) { fprintf(stderr,"%s: only one index allowed\n", *************** *** 384,397 **** moreMode=TRUE; break; case 's': ! GETARGSTR(temp); ! thd = (struct helpDir *)malloc(sizeof(struct helpDir)); ! thd->next = searchDirs; ! searchDirs = thd; ! thd->dirName = malloc(strlen(temp) + 1); ! strcpy(thd->dirName, temp); ! if(thd->dirName[strlen(thd->dirName) - 1] == '/') ! thd->dirName[strlen(thd->dirName) - 1] = '\0'; break; case 'n': newWindow=TRUE; --- 402,410 ---- moreMode=TRUE; break; case 's': ! GETARGSTR(helpPath); ! if(helpPath && *helpPath != '\0') ! AddPath(helpPath); break; case 'n': newWindow=TRUE; *************** *** 418,430 **** return TRUE; } ! boolean helpapp__Start(self) struct helpapp *self; { char *tp; struct helpDir *thd, *nhd; - static struct im *im; - static struct frame *frame; DEBUG(("ha: IN start\n")); if(!super_Start(self)) --- 431,442 ---- return TRUE; } ! boolean ! helpapp__Start(self) struct helpapp *self; { char *tp; struct helpDir *thd, *nhd; DEBUG(("ha: IN start\n")); if(!super_Start(self)) *************** *** 435,445 **** ((tp = environ_Get("DISPLAY")) == NULL || *tp == '\0') && ((tp = environ_Get("TERM")) == NULL || strcmp(tp, "wm") != 0)) { moreMode = TRUE; ! helpobj = help_New(); } if (!moreMode) { ! unique_help(); } /* allow us to 'see' the frame proctable, so we can use bind frame procs */ --- 447,457 ---- ((tp = environ_Get("DISPLAY")) == NULL || *tp == '\0') && ((tp = environ_Get("TERM")) == NULL || strcmp(tp, "wm") != 0)) { moreMode = TRUE; ! self->helpobj = help_New(); } if (!moreMode) { ! unique_help(self); } /* allow us to 'see' the frame proctable, so we can use bind frame procs */ *************** *** 447,475 **** if (!moreMode) { ! im = im_Create(NULL); /* default window */ ! if (!im) { fprintf(stderr,"%s: failed to create new window; exiting.\n", helpapp_GetName(self)); exit(1); } ! helpobj = help_New(); ! frame = frame_New(); ! if (!helpobj || !frame) { fprintf(stderr,"%s: Could not initialize help properly; exiting.\n", helpapp_GetName(self)); exit(1); } /* frame for frame_SetView must have associated im */ ! frame_SetView(frame, help_GetApplicationLayer(helpobj)); ! im_SetView(im, frame); /* add in a message handler */ ! frame_PostDefaultHandler(frame, "message", ! frame_WantHandler(frame, "message")); } for (thd = searchDirs; thd; thd = nhd) { --- 459,488 ---- if (!moreMode) { ! self->im = im_Create(NULL); /* default window */ ! if (!self->im) { fprintf(stderr,"%s: failed to create new window; exiting.\n", helpapp_GetName(self)); exit(1); } ! self->helpobj = help_New(); ! self->frame = frame_New(); ! if (!self->helpobj || !self->frame) { fprintf(stderr,"%s: Could not initialize help properly; exiting.\n", helpapp_GetName(self)); exit(1); } /* frame for frame_SetView must have associated im */ ! self->helpobj->app = (struct scroll*) help_GetApplicationLayer(self->helpobj); ! frame_SetView(self->frame, self->helpobj->app); ! im_SetView(self->im, self->frame); /* add in a message handler */ ! frame_PostDefaultHandler(self->frame, "message", ! frame_WantHandler(self->frame, "message")); } for (thd = searchDirs; thd; thd = nhd) { *************** *** 508,514 **** return TRUE; } ! int helpapp__Run(self) struct helpapp *self; { char tbuffer[200]; --- 521,528 ---- return TRUE; } ! int ! helpapp__Run(self) struct helpapp *self; { char tbuffer[200]; *************** *** 527,537 **** help_HelpappGetHelpOn(WMDEFAULTFILE, help_NEW, help_HIST_NOADD, tbuffer); } super_Run(self); DEBUG(("ha: OUT run\n")); return(0); } ! boolean helpapp__InitializeObject(classID,self) struct classheader *classID; struct helpapp *self; { --- 541,554 ---- help_HelpappGetHelpOn(WMDEFAULTFILE, help_NEW, help_HIST_NOADD, tbuffer); } super_Run(self); + frame_SetView(self->frame,NULL); + helpapp_Destroy(self); DEBUG(("ha: OUT run\n")); return(0); } ! boolean ! helpapp__InitializeObject(classID, self) struct classheader *classID; struct helpapp *self; { *************** *** 538,545 **** helpapp_SetMajorVersion(self, MAJOR_VERSION); helpapp_SetMinorVersion(self, MINOR_VERSION); #ifdef DEBUGGING ! if ((char *)getenv("HELPAPPDEBUG") != (char *) NULL) HELPAPPDEBUG = 1; #endif /* DEBUGGING */ return TRUE; } --- 555,575 ---- helpapp_SetMajorVersion(self, MAJOR_VERSION); helpapp_SetMinorVersion(self, MINOR_VERSION); #ifdef DEBUGGING ! if ((char *)environ_Get("HELPAPPDEBUG") != (char *) NULL) HELPAPPDEBUG = 1; #endif /* DEBUGGING */ + self->helpPort = 0; return TRUE; + } + + void + helpapp__FinalizeObject(classID, self) + struct classheader *classID; + struct helpapp *self; + { + frame_SetView(self->frame,NULL); + help_Destroy(self->helpobj); + im_SetView(self->im,NULL); + frame_Destroy(self->frame); + im_Destroy(self->im); } *** atk/help/src/helpa.ch Fri Dec 21 14:55:08 1990 --- atk/help/src/helpa.ch.NEW Mon Feb 11 16:10:12 1991 *************** *** 2,13 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/help/src/RCS/helpa.ch,v 2.8 89/03/30 19:10:58 mp1w Exp $ */ /* $ACIS$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/help/src/RCS/helpa.ch,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/help/src/RCS/helpa.ch,v 2.8 89/03/30 19:10:58 mp1w Exp $"; #endif /* !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) */ --- 2,13 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/help/src/RCS/helpa.ch,v 2.9 91/02/06 17:08:01 gk5g Exp $ */ /* $ACIS$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/help/src/RCS/helpa.ch,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/help/src/RCS/helpa.ch,v 2.9 91/02/06 17:08:01 gk5g Exp $"; #endif /* !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) */ *************** *** 25,29 **** --- 25,35 ---- Run() returns int; classprocedures: InitializeObject(struct helpapp *self) returns boolean; + FinalizeObject(struct helpapp *self); + data: + short helpPort; + struct im *im; + struct frame *frame; + struct help *helpobj; }; *** atk/help/src/helpdb.c Wed Sep 26 16:05:11 1990 --- atk/help/src/helpdb.c.NEW Tue May 28 17:39:35 1991 *************** *** 2,13 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/help/src/RCS/helpdb.c,v 1.13 90/07/31 12:20:55 gk5g Exp $ */ /* $ACIS$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/help/src/RCS/helpdb.c,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/help/src/RCS/helpdb.c,v 1.13 90/07/31 12:20:55 gk5g Exp $"; #endif /* !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) */ #ifdef CCH --- 2,13 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/help/src/RCS/helpdb.c,v 1.17 1991/05/28 21:34:38 gk5g Exp $ */ /* $ACIS$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/help/src/RCS/helpdb.c,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/help/src/RCS/helpdb.c,v 1.17 1991/05/28 21:34:38 gk5g Exp $"; #endif /* !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) */ #ifdef CCH *************** *** 24,34 **** /* matching algorithms. */ /*---------------------------------------------------------------------------*/ ! #include #include - #include /* sys/types.h sys/file.h */ #include #include --- 24,33 ---- /* matching algorithms. */ /*---------------------------------------------------------------------------*/ ! #include /* sys/types.h sys/file.h */ #include #include #include #include *************** *** 38,44 **** --- 37,50 ---- #include #include #include + #ifdef M_UNIX + #include + #define direct dirent + #define namlen(d) (strlen((d)->d_name)) + #else #include + #define namlen(d) ((d)->d_namlen) + #endif #include #include #include *************** *** 265,278 **** char *dirName; { struct helpDir *thd; ! for(thd = firstHelpDirs; thd; thd = thd->next) ! if(!strcmp(dirName,thd->dirName)) return; ! thd = (struct helpDir *) malloc(sizeof(struct helpDir)); ! thd->next = firstHelpDirs; ! firstHelpDirs = thd; ! thd->dirName = malloc(1 + strlen(dirName)); ! strcpy(thd->dirName, dirName); } --- 271,297 ---- char *dirName; { struct helpDir *thd; + char *lastchar, *firstchar; ! if(dirName && (*dirName != (char)0)) { ! lastchar = dirName + strlen(dirName) - 1; ! firstchar = dirName; ! ! if(*lastchar == '/') /* remove trailing '/' */ ! *lastchar = '\0'; ! while(firstchar && (*firstchar != (char)0) && isspace(*firstchar)) /* skip whitespace */ ! firstchar++; ! dirName = firstchar; ! ! for(thd = firstHelpDirs; thd; thd = thd->next) ! if(!strcmp(dirName, thd->dirName)) return; ! ! thd = (struct helpDir*) malloc(sizeof(struct helpDir)); ! thd->next = firstHelpDirs; ! firstHelpDirs = thd; ! thd->dirName = malloc(1 + strlen(dirName)); ! strcpy(thd->dirName, dirName); ! } } *************** *** 654,662 **** close(fd); } - - #define CCH - #ifdef CCH static char *LowerCase(astring) register char *astring; { --- 673,678 ---- *************** *** 670,676 **** tp++; return astring; } - #endif /* * Given a directory path "dname", adds all files in that directory --- 686,691 ---- *************** *** 698,711 **** while((tde=readdir(tempdir)) != NULL) { struct stat buf; - #ifdef CCH char lfname[MAXPATHLEN]; strcpy(lfname, tde->d_name); LowerCase(lfname); if (!Match(aname, lfname, 1)) continue; - #else - if (!Match(aname, tde->d_name, 1)) continue; - #endif /* don't add directories */ strcpy(tfp, tde->d_name); /* finish the filename */ if ((stat(tfn, &buf) != 0) || (buf.st_mode & S_IFDIR)) { --- 713,722 ---- *************** *** 717,723 **** /* allocate enough room for dir, file, slash between them and a null at the end */ tf->fileName = ! (char *) malloc(strlen(dname) + 1 + tde->d_namlen + 1); strcpy(tf->fileName, dname); strcat(tf->fileName, "/"); strcat(tf->fileName, tde->d_name); --- 728,734 ---- /* allocate enough room for dir, file, slash between them and a null at the end */ tf->fileName = ! (char *) malloc(strlen(dname) + 1 + namlen(tde) + 1); strcpy(tf->fileName, dname); strcat(tf->fileName, "/"); strcat(tf->fileName, tde->d_name); *** atk/help/src/helpdb.ch Wed Nov 22 12:14:58 1989 --- atk/help/src/helpdb.ch.NEW Mon Feb 11 16:10:15 1991 *************** *** 2,13 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/help/src/RCS/helpdb.ch,v 1.2 89/05/03 17:28:40 mp1w Exp $ */ /* $ACIS$ */ ! /* $Source: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/help/src/RCS/helpdb.ch,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/help/src/RCS/helpdb.ch,v 1.2 89/05/03 17:28:40 mp1w Exp $"; #endif /* !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) */ /*---------------------------------------------------------------------------*/ --- 2,13 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/help/src/RCS/helpdb.ch,v 1.2 89/05/03 17:28:40 mp1w Exp $ */ /* $ACIS$ */ ! /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/help/src/RCS/helpdb.ch,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/help/src/RCS/helpdb.ch,v 1.2 89/05/03 17:28:40 mp1w Exp $"; #endif /* !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) */ /*---------------------------------------------------------------------------*/ *** atk/help/src/helpaux.c Thu May 30 19:52:22 1991 --- atk/help/src/helpaux.c.NEW Tue May 28 17:39:37 1991 *************** *** 0 **** --- 1,1029 ---- + /* ********************************************************************** *\ + * Copyright IBM Corporation 1988,1989 - All Rights Reserved * + * For full copyright information see:'andrew/config/COPYRITE' * + \* ********************************************************************** */ + /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/help/src/RCS/helpaux.c,v 1.7 1991/05/28 21:37:31 gk5g Exp $ */ + /* $ACIS$ */ + /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/help/src/RCS/helpaux.c,v $ */ + + #include + + #define label gezornenplatz + /* sys/types.h in AIX PS2 defines "struct label", causing a type name clash. + Avoid this by temporarily redefining "label" to be something else in the preprocessor. */ + #include /* sys/types.h sys/file.h */ + #undef label + + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + + #include + #include + #include + #include + #include + + #include + #include + #include + #include + #define AUXMODULE 1 + #include + + /* statics representing information cache */ + extern char *tutorialDirs[MAX_TUTORIAL_DIRS]; + extern char changesDir[MAXPATHLEN]; + + /* a list of instances of help */ + extern struct self_help *ego; + + extern struct keymap *Help_Map; + extern struct menulist *Help_Menus; + + extern struct cursor *waitCursor; /* the watch cursor */ + + extern char **panelList; /* used for enumerating across the help index */ + + /* hooks to textview and frame procs */ + extern void (*textSearch)(); + extern void (*textRevSearch)(); + extern void (*textSearchAgain)(); + extern void (*textCopyRegion)(); + extern void (*textPageDown)(); + extern void (*textPageUp)(); + extern void (*frameSetPrinter)(); + + extern void ToggleProgramListSize(); + extern void HistoryHelp(); + extern void OverviewHelp(); + extern struct view *SetupLpairs(); + extern void SetupMenus(); + extern void FreePanelListData(); + extern int GetHelpOn(); + extern char *LowerCase(); + extern long SetupPanel(); + extern void NewHelp(); + extern void AddHistoryItem(); + + #ifdef DEBUGGING + /* + * debugging statements can be included by compiling add modules with + * -DDEBUGGING. Debugging output is toggled by existance/nonexistance + * of the environment variable HELPDEBUG. + */ + extern int HELPDEBUG; + #undef DEBUG + #define DEBUG(arg) if (HELPDEBUG != 0) { printf arg; fflush(stdout); } + #else + #undef DEBUG + #define DEBUG(arg) + #endif /* DEBUGGING */ + + /*---------------------------------------------------------------------------*/ + /* HELP CLASSPROCEDURES */ + /*---------------------------------------------------------------------------*/ + + /* + * help__ method for adding a directory to the searchpath + */ + void help__AddSearchDir(classID, dirName) + struct classheader *classID; + char *dirName; + { + if (access(dirName, 4) < 0) { + fprintf(stderr, "help: cannot open search directory '%s'\n", dirName); + return; + } + DEBUG(("adding dir: '%s'\n",dirName)); + helpdb_AddSearchDir(dirName); + } + + + /* + * initializes a new help object. Sets up the view hiearchy, sets up panels, etc + */ + boolean help__InitializeObject(classID,self) + struct classheader *classID; + register struct help *self; + { + char pathName[MAXPATHLEN], *tmp = NULL, *colon = NULL; + struct proctable_Entry *pe; + struct self_help *id; + struct view *v; + int i = 0; + + + DEBUG(("IN init obj\n")); + waitCursor = cursor_Create(0); + cursor_SetStandard(waitCursor, Cursor_Wait); + im_SetProcessCursor(waitCursor); + + tmp = environ_GetConfiguration(SETUP_CHANGEDIR); + if (tmp == NULL) { + tmp = environ_LocalDir(DEFAULT_CHANGEDIR); + } + strcpy(changesDir, tmp); + + for(i = 0; i < MAX_TUTORIAL_DIRS; i++) + tutorialDirs[i] = NULL; + i = 0; + if(tmp = environ_GetConfiguration(SETUP_TUTORIALDIR)) { + if((colon = rindex(tmp,':')) == NULL) { + tutorialDirs[i] = (char*) malloc(strlen(tmp) + 1); + strcpy(tutorialDirs[i],tmp); + } + else { + while(colon && (colon != '\0')) { + *colon = '\0'; + tutorialDirs[i] = (char*) malloc(strlen(tmp) + 1); + strcpy(tutorialDirs[i],tmp); + *colon = ':'; + tmp = colon + 1; + colon = rindex(tmp,':'); + i++; + } + tutorialDirs[i] = (char*) malloc(strlen(tmp) + 1); + strcpy(tutorialDirs[i],tmp); + } + } + else { + tmp = environ_AndrewDir(DEFAULT_TUTORIALDIR); + tutorialDirs[i] = (char*) malloc(strlen(tmp) + 1); + strcpy(tutorialDirs[i],tmp); + } + + im_SetProcessCursor((struct cursor *) NULL); + + /* general variables */ + self->expandedList = 0; + self->showPanels = environ_GetProfileSwitch("ShowPanels", TRUE); + self->showOverview = environ_GetProfileSwitch("ShowOverviews", TRUE); + self->showList = environ_GetProfileSwitch("ShowPrograms", TRUE); + self->showHistory = environ_GetProfileSwitch("ShowHistory", FALSE); + + self->state = keystate_Create(self, Help_Map); + self->info = (struct cache *)malloc(sizeof(struct cache)); + if (!self->info || !self->state) + return FALSE; + DEBUG(("info state ")); + self->info->scroll = NULL; + self->info->menus = menulist_DuplicateML(Help_Menus, self); + if (!self->info->menus) + return FALSE; + DEBUG(("menus ")); + self->info->flags = 0; + self->info->flags = MENU_ToggleSizeExpand; /* start out shrunk initially */ + self->info->flags |= (self->showPanels) ? MENU_TogglePanelHide : MENU_TogglePanelShow; + self->info->flags |= (self->showOverview) ? MENU_ToggleOverHide : MENU_ToggleOverShow; + self->info->flags |= (self->showList) ? MENU_ToggleListHide : MENU_ToggleListShow; + self->info->flags |= (self->showHistory) ? MENU_ToggleHistHide : MENU_ToggleHistShow; + self->info->flags |= MENU_ToggleFilterShow; + self->info->all = self->info->cur = (struct helpFile *)NULL; + self->info->histat = help_HIST_NOADD; + self->info->histent[0] = '\0'; + self->info->lastHist = NULL; + + self->mainLpair = NULL; + + /* the help text object */ + self->info->data = (struct dataobject *)text_New(); + self->info->view = (struct view *)textview_New(); + if (!self->info->data || !self->info->view) + return FALSE; + DEBUG(("data view ")); + + view_SetDataObject(self->info->view, self->info->data); + + self->info->scroll = scroll_Create(self->info->view, scroll_LEFT); + textview_SetEmbeddedBorder((struct textview *) self->info->view, 20, 5); + if (!self->info->scroll) + return FALSE; + DEBUG(("scroll ")); + + /* panels and their scrollbars */ + self->oldpanel = (struct panel *)NULL; + self->tmpanel = panel_New(); + self->overviewPanel = panel_New(); + self->listPanel = panel_New(); + self->historyPanel = panel_New(); + if (!self->tmpanel || !self->overviewPanel || !self->listPanel || !self->historyPanel) + return FALSE; + DEBUG(("panels ")); + self->info->hist = self->historyPanel; + + self->overviewScroll = (struct scroll *) panel_GetApplicationLayer(self->overviewPanel); + self->listScroll = (struct scroll *) panel_GetApplicationLayer(self->listPanel); + self->historyScroll = (struct scroll *) panel_GetApplicationLayer(self->historyPanel); + if (!self->overviewScroll || !self->listScroll) + return FALSE; + + + /* labels */ + self->overviewLab = label_New(); + self->overviewLabV = labelview_New(); + self->listLab = label_New(); + self->listLabV = labelview_New(); + self->historyLab = label_New(); + self->historyLabV = labelview_New(); + if (!self->overviewLab || !self->overviewLabV || !self->historyLab || !self->historyLabV + || !self->listLab || !self->listLabV) + return FALSE; + + labelview_SetDataObject(self->overviewLabV, self->overviewLab); + label_SetFlags(self->overviewLab, label_CENTERED | label_BOXED); + label_SetText(self->overviewLab, "Overviews"); + + labelview_SetDataObject(self->listLabV, self->listLab); + label_SetFlags(self->listLab, label_CENTERED | label_BOXED); + label_SetText(self->listLab, "Programs"); + + labelview_SetDataObject(self->historyLabV, self->historyLab); + label_SetFlags(self->historyLab, label_CENTERED | label_BOXED); + label_SetText(self->historyLab, "Help History"); + + + /* lpairs */ + self->overviewLpair = lpair_Create(self->overviewLabV, self->overviewScroll, LABPCT); + self->listLpair = lpair_Create(self->listLabV, self->listScroll, LABPCT); + self->historyLpair = lpair_Create(self->historyLabV, self->historyScroll, LABPCT); + self->panelLpair1 = lpair_Create(NULL, NULL, -PANELPCT); + self->panelLpair2 = lpair_Create(NULL, NULL, -33); + if (!self->overviewLpair || !self->listLpair || !self->historyLpair + || !self->panelLpair1 || !self->panelLpair2) + return FALSE; + + lpair_VTFixed(self->overviewLpair, self->overviewLabV, self->overviewScroll, LABPCT, 0); + lpair_VTFixed(self->listLpair, self->listLabV, self->listScroll, LABPCT, 0); + lpair_VTFixed(self->historyLpair, self->historyLabV, self->historyScroll, LABPCT, 0); + + /* if the user has all panels off, use the overview panel by default */ + v = SetupLpairs(self); + self->mainLpair = lpair_Create(self->info->scroll, + v ? v : (struct view *)self->overviewScroll, -MAINPCT); + if (!self->mainLpair) + return FALSE; + DEBUG(("main lpair ")); + + lpair_SetLPState(self->mainLpair, lpair_NOCHANGE, lpair_VERTICAL, 1); + + DEBUG(("handlers ")); + + /* default panel handlers */ + panel_SetHandler(self->overviewPanel, OverviewHelp, (char *) self); + panel_SetHandler(self->listPanel, OverviewHelp, (char *) self); + panel_SetHandler(self->tmpanel, OverviewHelp, (char *) self); + panel_SetHandler(self->historyPanel, HistoryHelp, (char *) self); + + if (self->showPanels) + lpair_LinkTree(self->mainLpair, self); + else + scroll_LinkTree(self->info->scroll, self); + + /* add minimum set of entries to listPanel */ + if((tmp = environ_GetConfiguration(SETUP_PANELSDIR)) == NULL) { + tmp = environ_GetConfiguration(SETUP_LIBDIR); + if (tmp == NULL) + tmp = environ_AndrewDir(DEFAULT_LIBDIR); + } + sprintf(pathName, "%s%s", tmp, PROGRAMFILE); + + if (0 == SetupPanel(TRUE, pathName, self->listPanel, NULL)) { + /* got nothing from lib/help.programs; use extensions */ + tmp = environ_GetConfiguration(SETUP_HELPDIR); + if (tmp == NULL) + tmp = environ_AndrewDir(DEFAULT_HELPDIR); + strcpy(pathName, tmp); + help_AddSearchDir(pathName); /* ??? XXX */ + + SetupPanel(FALSE, pathName, self->listPanel, program_ext_array); + } + + DEBUG(("expanding ")); + if (environ_GetProfileSwitch("ExpandedList", FALSE)) + ToggleProgramListSize(self, help_EXPAND); + + /* get overviews entries */ + if((tmp = environ_GetConfiguration(SETUP_PANELSDIR)) == NULL) { + tmp = environ_GetConfiguration(SETUP_LIBDIR); + if (tmp == NULL) + tmp = environ_AndrewDir(DEFAULT_LIBDIR); + } + sprintf(pathName, "%s%s", tmp, OVERVIEWFILE); + if (0 == SetupPanel(TRUE, pathName, self->overviewPanel, NULL)) { + tmp = environ_GetConfiguration(SETUP_HELPDIR); + if (tmp == NULL) + tmp = environ_AndrewDir(DEFAULT_HELPDIR); + strcpy(pathName, tmp); + help_AddSearchDir(pathName); /* ??? XXX */ + + SetupPanel(FALSE, pathName, self->overviewPanel, overview_ext_array); + } + + /* post our menus */ + SetupMenus(self->info); + + /* runtime-bound procedures */ + pe = proctable_Lookup("textview-search"); + if (pe) textSearch = (void (*)()) proctable_GetFunction(pe); + else return FALSE; + pe = proctable_Lookup("textview-reverse-search"); + if (pe) textRevSearch = (void (*)()) proctable_GetFunction(pe); + else return FALSE; + pe = proctable_Lookup("textview-search-again"); + if (pe) textSearchAgain = (void (*)()) proctable_GetFunction(pe); + else return FALSE; + pe = proctable_Lookup("textview-copy-region"); + if (pe) textCopyRegion = (void (*)()) proctable_GetFunction(pe); + else return FALSE; + pe = proctable_Lookup("textview-next-screen"); + if (pe) textPageDown = (void (*)()) proctable_GetFunction(pe); + else return FALSE; + pe = proctable_Lookup("textview-prev-screen"); + if (pe) textPageUp = (void (*)()) proctable_GetFunction(pe); + else return FALSE; + pe = proctable_Lookup("frame-set-printer"); + if (pe) frameSetPrinter = (void (*)()) proctable_GetFunction(pe); + else return FALSE; + + /* now add ourself to the head of the instance list */ + DEBUG(("ego: %d\n",(int)ego)); + id = (struct self_help *)malloc(sizeof(struct self_help)); + if (!id) + return FALSE; + id->this = self; + id->next = ego; + ego = id; + DEBUG(("ego: %d\n",(int)ego)); + + self->app = NULL; + + DEBUG(("OUT init obj\n")); + return TRUE; + } + + + /* + * destroys the resources of the help object + */ + void help__FinalizeObject(classID, self) + struct classhead *classID; + register struct help *self; + { + DEBUG(("IN finalize\n")); + self->mainLpair->obj[0] = NULL; + self->mainLpair->obj[1] = NULL; + lpair_Destroy(self->mainLpair); + + view_Destroy(self->info->view); + dataobject_Destroy(self->info->data); + + self->panelLpair1->obj[0] = NULL; + self->panelLpair1->obj[1] = NULL; + lpair_Destroy(self->panelLpair1); + + if(self->panelLpair2) { + self->panelLpair2->obj[0] = NULL; + self->panelLpair2->obj[1] = NULL; + lpair_Destroy(self->panelLpair2); + } + + if(self->overviewLpair) { + self->overviewLpair->obj[0] = NULL; + self->overviewLpair->obj[1] = NULL; + lpair_Destroy(self->overviewLpair); + scroll_Destroy(self->overviewScroll); + panel_Destroy(self->overviewPanel); + labelview_Destroy(self->overviewLabV); + label_Destroy(self->overviewLab); + } + + if(self->listLpair) { + self->listLpair->obj[0] = NULL; + self->listLpair->obj[1] = NULL; + lpair_Destroy(self->listLpair); + scroll_Destroy(self->listScroll); + panel_Destroy(self->listPanel); + labelview_Destroy(self->listLabV); + label_Destroy(self->listLab); + } + + if(self->historyLpair) { + self->historyLpair->obj[0] = NULL; + self->historyLpair->obj[1] = NULL; + lpair_Destroy(self->historyLpair); + scroll_Destroy(self->historyScroll); + panel_Destroy(self->historyPanel); + labelview_Destroy(self->historyLabV); + label_Destroy(self->historyLab); + } + + /* the presence/absence of self->info indicates whether we are + in the process of finalizing, so that in update we know we + can't post menus */ + free(self->info); + self->info = NULL; + if(panelList) FreePanelListData(); + DEBUG(("info\n")); + DEBUG(("OUT finalize\n")); + } + + + /* + * help__ method interface for using an alias file + */ + void help__SetAliasesFile(classID,alias) + struct classheader *classID; + register char *alias; + { + helpdb_ReadAliasesFile(alias); + } + + /* + * help__ method for adding a help index directory + */ + void help__SetIndex(classID,aindex) + struct classheader *classID; + register char *aindex; + { + DEBUG(("IN SetIndex: %s\n",aindex)); + helpdb_SetIndex(aindex); + } + + /* + * outside interface help__ method for GetHelpOn. Used by helpapp + * + * Returns: + * -1: if a server was down while trying to get help on this topic + * 0: if no help found for this topic + * 1: if successful + */ + int help__HelpappGetHelpOn(classID, aname, isnew, ahistory, errmsg) + struct classheader *classID; + char *aname; /* what topic */ + long isnew; /* is this a new topic? */ + int ahistory; /* show in history log? 1-show aname 2-show tail of filename */ + char *errmsg; /* error to print if failure. "Error" if this is NULL */ + { + if (aname[0] == '\0') { + /* so -e flag with no file shown works */ + return 1; + } + /* use the last instance added to the list */ + DEBUG(("using %d view %d asking %d\n", (int)ego->this,(int)ego->this->info->view, + message_Asking(ego->this->info->view))); + if (message_Asking(ego->this->info->view)) { + DEBUG(("retracting\n")); + message_CancelQuestion(ego->this->info->view); + } + return GetHelpOn(ego->this, aname, isnew, ahistory, errmsg); + } + + + /* + * return the first view in the list of instances, so helpapp can expose + * a hidden window. + */ + struct view *help__GetInstance(classID) + struct classheader *classID; + { + return (struct view *)(ego->this); + } + + + /*---------------------------------------------------------------------------*/ + /* HELP METHODS */ + /*---------------------------------------------------------------------------*/ + + /* + * self explanatory + */ + void help__PostMenus(self, menuList) + register struct help *self; + struct menulist *menuList; + { + DEBUG(("post menus\n")); + if (self->info != NULL) + super_PostMenus(self, self->info->menus); + } + + /* + * override parents' keybindings + */ + void help__PostKeyState(self, keyState) + register struct help *self; + struct keystate *keyState; + { + DEBUG(("post keys\n")); + keystate_AddBefore(self->state, keyState); + super_PostKeyState(self, self->state); + } + + /* + * mouse action handler + */ + struct view *help__Hit(self, action, x, y, numberOfClicks) + struct help *self; + enum view_MouseAction action; + long x, y; + long numberOfClicks; + { + if (self->showPanels) + return lpair_Hit(self->mainLpair, action, x, y, numberOfClicks); + else + return scroll_Hit(self->info->scroll, action, x, y, numberOfClicks); + } + + /* + * set up the view tree based on whether panels or scrollbar is the top level view + */ + void help__LinkTree(self, parent) + struct help *self; + struct view *parent; + { + DEBUG(("IN link tree\n")); + DEBUG(("\tsuper...")); + super_LinkTree(self, parent); + + if (self->showPanels) { + if (self->mainLpair) + lpair_LinkTree(self->mainLpair, self); + } else { + if (self->info!=NULL && self->info->scroll) + scroll_LinkTree(self->info->scroll, self); + } + DEBUG(("OUT link tree\n")); + } + + /* + * refreshing! + */ + void help__FullUpdate(self, type, left, top, width, right) + register struct help *self; + enum view_UpdateType type; + long left, top, width, right; + { + struct rectangle childRect; + + DEBUG(("IN fullupdate\n")); + + help_GetLogicalBounds(self, &childRect); + + if (self->showPanels) { /* need the main lpair as the root */ + lpair_InsertView(self->mainLpair, self, &childRect); + lpair_FullUpdate(self->mainLpair, type, left, top, width, right); + } else { /* we just have the textview to show */ + scroll_InsertView(self->info->scroll, self, &childRect); + scroll_FullUpdate(self->info->scroll, type, left, top, width, right); + } + super_WantInputFocus(self, self->info->view); + DEBUG(("OUT fullupdate\n")); + } + + /* + * erase and refresh the screen + */ + void help__Update(self) + register struct help *self; + { + DEBUG(("IN update\n")); + /* clear out the region, then do a full redraw */ + help_EraseVisualRect(self); + help_FullUpdate(self, view_FullRedraw, help_GetLogicalTop(self), help_GetLogicalLeft(self), + help_GetLogicalWidth(self), help_GetLogicalHeight(self)); + DEBUG(("OUT update\n")); + } + + /* + * update event handler + */ + void help__WantUpdate(self, requestor) + register struct help *self; + register struct view *requestor; + { + /* if the scrollbar took the hit, check if the user has selected something, + and turn on some menus items if so */ + if (self->info && (requestor == (struct view *)self->info->scroll)) { + /* if the menumask changes, post menus */ + if (menulist_SetMask(self->info->menus, + (textview_GetDotLength((struct textview *)self->info->view) != 0) ? + menulist_GetMask(self->info->menus) | MENU_SwitchCopy : + menulist_GetMask(self->info->menus) & ~MENU_SwitchCopy)) + help_PostMenus(self, self->info->menus); + } + super_WantUpdate(self, requestor); + } + + + /* + * classproc to handle getting help using a terminal-based interface + */ + void help__GetHelpOnTerminal(classID,akey,list,print) + struct classheader *classID; + register char *akey; /* topic string */ + register int list; /* do help on topic, or just list files? */ + register int print; /* prompt for printing each helpfile? */ + { + FILE *tfile; + char *alias, *pager, *index, *tmp; + char pathName[MAXPATHLEN], cmdLine[MAXPATHLEN]; + char hbuffer[HNSIZE], tbuffer[HNSIZE]; + long digitMode, digitValue, firstChar; + struct helpFile *tmpf; + struct cache c; + int tc; + int first = 0; + + DEBUG(("key: %s\n",akey)); + if (!helpdb_CheckIndex(NULL)) { /* if we haven't SetIndex */ + index = environ_GetConfiguration(SETUP_INDEXDIR); + if (index == NULL) + index = environ_AndrewDir(DEFAULT_INDEXDIR); + help_SetIndex(index); + } + + if ((pager = environ_Get(PAGERVAR)) == (char *) NULL) + pager = DEFAULTPAGER; + + if (!helpdb_CheckIndex(NULL)) { + fprintf(stderr, err_index, pathName); + return; + } + + /* map helpKey */ + strncpy(tbuffer, LowerCase(akey), HNSIZE); + tbuffer[HNSIZE-1] = 0; + + /* now see if it has an illegal, command running, alias */ + alias = (char *)helpdb_MapAlias(tbuffer); + DEBUG(("map alias on: %s\n",tbuffer)); + if (alias) { + DEBUG(("alias: %s\n", alias)); + if (alias[0] == '#') { + fprintf(stderr,err_terminal); + putchar('\n'); + exit(1); + /*NOTREACHED*/ + } + } + + alias = tbuffer; /* src */ + tmp = hbuffer; /* dst */ + digitMode = 0; + digitValue = 0; + firstChar = 1; + /* copy alias (points to tbuffer) to hbuffer, suppressing spaces and + computing digitValue */ + while((tc = *alias++) != NULL) { + if (tc == ' ' || tc == '\n' || tc == '\t') + continue; + if (tc == '(' || (!firstChar && tc == '.')) + digitMode = 1; + else if (digitMode) { + if (tc >= '0' && tc <= '9') { + digitValue *= 10; + digitValue += tc - '0'; + } + } else { + *tmp++ = tc; + } + firstChar = 1; + } + *tmp++ = 0; + + DEBUG(("tbuf: %s hbuf: %s\n",tbuffer,hbuffer)); + + c.all = (struct helpFile *)NULL; + + if (helpdb_SetupHelp(&c, hbuffer, FALSE) == 0) { + fprintf(stderr, err_sorry, akey); + putchar('\n'); + exit(1); + /*NOTREACHED*/ + } + + /* if non-0 return, c->all was set up for us */ + + DEBUG(("setup done\n")); + + if (list) { + printf("Using search directories: "); + helpdb_PrintSearchDirs(); + printf("\n"); + printf("For topic %s the files are:\n",akey); + for (tmpf = c.all; tmpf; tmpf = tmpf->next) { + printf("\t%s\n",tmpf->fileName); + } + exit(0); + /*NOTREACHED*/ + } + + /* o.w. do real help on the topic */ + first = TRUE; + for(tmpf = c.all; tmpf; tmpf = tmpf->next) { + int in = 0; + char *fn; + int skipFlag = FALSE; + + tfile = fopen(tmpf->fileName, "r"); + if (!tfile) { + fprintf(stderr, err_file, tmpf->fileName); + continue; + } + + if (!first) { + skipFlag = FALSE; + fn = rindex(tmpf->fileName, '/'); + printf(msg_term_prompt, fn ? fn+1 : tmpf->fileName); + in = getchar(); + DEBUG(("'%c'\n", in)); + if (in < 0) exit(1); + else if (in == 'q' || in == 'Q') exit(0); + else if (in == 'n' || in == 'N') skipFlag = TRUE; + if (in != '\n') + while ((in = getchar()) > 0 && in != '\n') + ; + } + + first = FALSE; + + if (!skipFlag) { + /* show the file */ + tc = fgetc(tfile); + ungetc(tc,tfile); + fclose(tfile); + if ((tc == '.') || (tc == '#')) { /* troff file */ + sprintf(cmdLine, ROFFCMD, tmpf->fileName, pager); + } else { + sprintf(cmdLine, ATKROFFCMD, tmpf->fileName, pager); + } + DEBUG(("cmd: %s\n",cmdLine)); + system(cmdLine); + } + + if (print) { + /* see if they want to print it */ + if (in < 0) exit(1); + fn = rindex(tmpf->fileName, '/'); + printf(msg_print_prompt, fn ? fn+1 : tmpf->fileName); + in = getchar(); + DEBUG(("'%c'\n", in)); + if (in < 0) exit(1); + else if (in != 'n' && in != 'N') { /* print it */ + if ((tc == '.') || (tc == '#')) { /* troff file */ + sprintf(cmdLine, ROFFPRINTCMD, tmpf->fileName); + } else { + sprintf(cmdLine, ATKPRINTCMD, tmpf->fileName); + } + DEBUG(("cmd: %s\n",cmdLine)); + system(cmdLine); + } + if (in != '\n') + while ((in = getchar()) > 0 && in != '\n') + ; + } + } + } + + struct frame * + getframe(vw) + struct view *vw; + { + while(vw->parent) { + vw = vw->parent; + if(class_IsTypeByName(class_GetTypeName(vw),"frame")) + return((struct frame*) vw); + } + return(NULL); + } + + void + destroyWindow(self) + struct help *self; + { + struct frame *fr; + struct proctable_Entry *pr; + int (*proc)(); + + if((pr = proctable_Lookup("frame-delete-window")) != NULL && + proctable_Defined(pr) && + (fr = getframe((struct view*)self)) != NULL) { + proc = proctable_GetFunction(pr) ; + help_UnlinkTree(self); + help_DeleteApplicationLayer(self,self->app); + (*proc)(fr,0); + } + } + + /* + * Allows help to just delete one window + */ + void ExitProc(self) + register struct help *self; + { + struct self_help *t, *p; + + DEBUG(("IN exit\n")); + + DEBUG(("ego: %d self: %d\n",(int)ego, (int)self)); + for (t=ego;t;t=t->next) { + DEBUG(("t: %d this: %d next: %d\n", (int)t, (int)t->this, (int)t->next)); + } + + /* delete self from the instance list */ + p = NULL; + t = ego; + while (t) { + if (t->this == self) { + if (p == NULL) { /* deleting head */ + ego = t->next; + free(t); + t = ego; + } else { + p->next = t->next; + free(t); + t = p->next; + } + } else { + p = t; + t = t->next; + } + } + DEBUG(("ego: %d self: %d\n",(int)ego, (int)self)); + for (t=ego;t;t=t->next) { + DEBUG(("t: %d this: %d next: %d\n", (int)t, (int)t->this, (int)t->next)); + } + + /* take care of the cases with 0 and 1 instances left in the list */ + if (ego) { /* something in the list */ + if (ego->next == (struct self_help *)NULL) { /* only one left */ + /* remove "Delete this window" menu item */ + DEBUG(("one left, Delete delete\n")); + ego->this->info->flags &= ~MENU_SwitchDeleteMenu; + SetupMenus(ego->this->info); + } + } else { /* nobody left, all gone, we be outta here */ + im_KeyboardExit(); + } + + destroyWindow(self); + + DEBUG(("OUT exit\n")); + } + + /* + * print a help file + */ + void Print(self) + register struct help *self; + { + message_DisplayString(self, 0, msg_print_queue); + im_ForceUpdate(); + im_SetProcessCursor(waitCursor); + print_ProcessView((struct textview *)self->info->view, 1, 0, "", ""); + message_DisplayString(self, 0, msg_queue_done); + im_SetProcessCursor((struct cursor *) NULL); + } + + /* + * get help on a prompted-for topic or a selected word, bringing up a + * new window if necessary + */ + void NewHelp(self, type) + register struct help *self; + long type; /* help_ON if Help On... */ + /* help_ON & help_NEW_WIN if New Help On... */ + /* help_SEL if Help On Selected */ + /* help_SEL & help_NEW_WIN if New Help On Selected */ + { + register int i, pos, len, code; + char tc; + char helpName[HNSIZE]; + char buf[HNSIZE + HELP_MAX_ERR_LENGTH]; + struct help *hv; + + if (type & help_SEL) { + pos = textview_GetDotPosition((struct textview *)self->info->view); + len = textview_GetDotLength((struct textview *)self->info->view); + + /* only shows menu item if a selection has been made */ + /* but, since can bind the procedure, must handle this */ + /* case anyway. */ + if (len == 0) { + ERRORBOX(self->info->view, err_no_sel); + return; + } else { + if (len >= HNSIZE) { + ERRORBOX(self->info->view, err_sel_too_long); + return; + } + } + i = 0; /* position in text object */ + code = 0; /* position in helpName */ + while(iinfo->data, i+pos); + i++; + if (tc == ' ' || tc == '\t' || tc == '\n') continue; + helpName[code++] = tc; + } + helpName[code++] = '\0'; + } else { /* prompt for topic */ + code = message_AskForString(self, 0, msg_ask_prompt, + 0, helpName, HNSIZE); + if ((code < 0) || (helpName[0] == '\0')) return; + } + + if (type & help_NEW_WIN) { + struct im *im; + struct frame *frame; + + im = im_Create(NULL); + frame = frame_New(); + hv = (struct help*) class_NewObject("help"); + if (!hv || !im || !frame) { + ERRORBOX(self->info->view, err_no_new_view); + return; + } + + /* since we exits, ego must exist now, too */ + if (ego->next != (struct self_help *)NULL) { /* > 1 instances */ + struct self_help *tmp; + + for (tmp = ego; tmp; tmp = tmp->next) { + /* add "delete this window" menu item" */ + DEBUG(("Add delete\n")); + tmp->this->info->flags |= MENU_SwitchDeleteMenu; + SetupMenus(tmp->this->info); + } + } + + /* frame for frame_SetView must have associated im */ + hv->app = (struct scroll*) help_GetApplicationLayer(hv); + frame_SetView(frame, hv->app); + im_SetView(im, frame); + + /* add in a message handler */ + frame_PostDefaultHandler(frame, "message", + frame_WantHandler(frame, "message")); + + } + + sprintf(buf, err_sorry, helpName); + if (GetHelpOn((!(type & help_NEW_WIN)) ? self : hv + , helpName, help_NEW, help_HIST_NAME, buf) != 0) { + panel_ClearSelection(self->overviewPanel); + panel_ClearSelection(self->listPanel); + panel_ClearSelection(self->historyPanel); + } + } + + + /* + * Add a history item for a given file with given dot, dotlen and top + */ + void AddBookmark(self) + register struct help *self; + { + AddHistoryItem(self, help_HE_BOOKMARK, help_SHOW_HIST); + } + + + /* + * Adds a search directory to the searchpath + */ + void AddSearchDir(self) + struct help *self; + { + char buf[MAXPATHLEN]; + char buf2[MAXPATHLEN+100]; + int code; + + sprintf(buf2, "%s", "Added directory: "); + code = completion_GetFilename((struct view *)self, msg_dir_prompt, NULL, + buf, sizeof(buf), TRUE, TRUE); + if(code != -1) { + help_AddSearchDir(buf); + strcat(buf2, buf); + message_DisplayString(self, 0, buf2); + } + } + *** atk/help/maint/mkindex.c Fri Dec 21 14:55:11 1990 --- atk/help/maint/mkindex.c.NEW Wed Apr 3 21:19:38 1991 *************** *** 2,13 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/help/maint/RCS/mkindex.c,v 2.21 90/10/23 17:44:05 gk5g Exp $ */ /* $ACIS:mkindex.c 1.3$ */ ! /* $Source: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/help/maint/RCS/mkindex.c,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsid = "$Header: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/help/maint/RCS/mkindex.c,v 2.21 90/10/23 17:44:05 gk5g Exp $"; #endif /* !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) */ #define FSSIZE 32 /* max number of files */ --- 2,13 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/help/maint/RCS/mkindex.c,v 2.28 91/04/02 16:58:00 susan Exp $ */ /* $ACIS:mkindex.c 1.3$ */ ! /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/help/maint/RCS/mkindex.c,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/help/maint/RCS/mkindex.c,v 2.28 91/04/02 16:58:00 susan Exp $"; #endif /* !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) */ #define FSSIZE 32 /* max number of files */ *************** *** 14,32 **** #define BUCKETS 11 /* number of hash buckets */ #define MANSUBS "12345678nolp" /* array of possible subdirectories of MANDIR, ie man1, mann */ ! #include #include #include #include #include - - #include /* sys/types.h sys/file.h */ #include - extern char *index(); static char *prog; /* our name */ - static int verbose = 0; /* --- 14,33 ---- #define BUCKETS 11 /* number of hash buckets */ #define MANSUBS "12345678nolp" /* array of possible subdirectories of MANDIR, ie man1, mann */ ! #include /* sys/types.h sys/file.h */ #include #include #include + #ifdef M_UNIX + #include + #define direct dirent + #else #include + #endif #include #include static char *prog; /* our name */ static int verbose = 0; /* *************** *** 37,43 **** { register char *tp = astring; ! while (tp && *tp != NULL) if (isupper(*tp)) { *tp = tolower(*tp); tp++; --- 38,44 ---- { register char *tp = astring; ! while (tp && *tp != (char)0) if (isupper(*tp)) { *tp = tolower(*tp); tp++; *************** *** 92,98 **** strcpy(keyBuffer, sde->d_name); tp = index(keyBuffer, '.'); if (tp) *tp = '\0'; /* remove extension */ - /* check for "man" subdir */ code = stat(srcPath, &tstat); if ((code == 0 && (tstat.st_mode & S_IFMT) == S_IFDIR) && (mandir != 0) && strncmp(sde->d_name, ManName, sizeof(ManName)-1) == 0) { --- 93,98 ---- *************** *** 100,110 **** } else { if (tp && index(MANSUBS, *(tp+1))) { /* it's a man page */ - /* add w/o extension */ index_AddPrimary(aindex, LowerCase(keyBuffer), targetPath); *tp = '.'; /* put back extension */ - /* add with extension */ index_AddPrimary(aindex, LowerCase(keyBuffer), targetPath); } else { --- 100,108 ---- *** atk/hyplink/link.intro Sun May 12 21:12:24 1991 --- atk/hyplink/link.intro.NEW Wed Feb 13 16:51:57 1991 *************** *** 0 **** --- 1,20 ---- + \begindata{text,268708704} + \textdsversion{12} + \template{help} + \chapter{links: several different documents + + } + If you are interested in seeing \italic{link(2) }or \italic{ link(3) }, use + \bold{Show Help on Selected Word} with one of the italicized words to see + those documents explicitly. + + + If you are interested in seeing a help file about the ATK inset called "link," + and are running Help from a workstation, select (highlight) + + + \leftindent{\italic{linkinset} } + + + and choose \bold{Show Help On Selected Word} from the Help menus.\ + \enddata{text,268708704} *** atk/hyplink/Developr.pro Sun May 12 21:11:52 1991 --- atk/hyplink/Developr.pro.NEW Wed Feb 13 16:51:49 1991 *************** *** 0 **** --- 1,134 ---- + \begindata{text,268720648} + \textdsversion{12} + \template{default} + \majorheading{Link Developer Documentation} + + \center{How to Make Linked Documents} + + + \quotation{\center{Abstract} + + The Link inset provides a simple, fast way of building a set of + cross-referenced hypermedia documents. Using a Link inset requires no + programming and can be done by anyone. + + } + \heading{Why do I want to use Links?} + + By using Linked documents, you, the document developer, can tie together large + amounts of information which can be conveniently navigated by users of your + document (for a description of the user interface, see + \begindata{link,268747656} + Datastream version: 1 + Link Help + $DESTDIR/Help.d + andysans8b + \enddata{link,268747656} + \view{linkv,268747656,0,0,0}). Links also give you new freedom in structuring + your documents, because with links, you can break large pieces of information + into smaller, more manageable chunks which cross-reference each other. + + + Links are a file-reference tool. They do not support offsets into documents, + and so it is recommended that links be used to help users find whole + documents, rather than pieces of it. (For instance, Links wouldn't be useful + for producing a table of contents warp for a large document. However, if that + document is broken up into chapters and sections, then a table of contents + link document could be used to reference each of the pieces of the document.) + + + \heading{How do I insert a Link?} + + \quotation{Note: The following procedure assumes that you have customized + your ".ezinit" file to allow for Autolinking. If you haven't, please see + \begindata{link,268740664} + Datastream version: 1 + Link Procs + $DESTDIR/Procs.d + andysans8b + \enddata{link,268740664} + \view{linkv,268740664,1,0,0} before continuing.} + + Links are inserted just like any other inset. For instance, most ATK objects + capable of holding insets (like text) use "Esc-Tab" to specify the inset. The + name of the Link dataobject is "link", so, to insert a link in a text + document, you would: + + \indent{\description{- select an insertion point (where you want the Link + inset to appear) + + - press the "Esc" key and then the "Tab" key + + - type "link" and press the "Enter" key}} + + At this point, you should see an empty Link inset (which has no target, and no + label, displaying itself as + "\ + \begindata{link,268768672} + Datastream version: 1 + Link (v30) + + andy12b + \enddata{link,268768672} + \view{linkview,268768672,2,0,0}"). The easiest way to specify the target (and + a label for the link) is to use the "Autolink" procedure. To do this, with + the Link inset selected: + + \indent{\description{- press the menu button on your mouse (the middle button + on a three-button mouse or the left and right buttons together on a two button + mouse) and choose "Autolink" from the menu. + + - move the mouse to the window of the file you want to link to, and bring up + the menus again. Choose "Autolink target here".}} + + At this point, the Link inset will change its name to the filename of the + target document, and it will be ready for use as a Link. To test it, just + click your left mouse button over the link inset, and you should be warped to + the target document. You can insert as many links as you want into a + document, and you can link to any other document (even system files)--you can + even link to the same document the link is in (although it's of dubious worth, + since there are no offests). + + + \heading{How do I change a Link?} + + You can autolink again, but it won't change the label. The reason for this is + that you may want to set your label manually before autolinking, and the + autolink procedure won't change an already defined label. You can change the + label manually using the Set Label menu item (on the Pushbutton card), which + will prompt you for a new text string. You can also change the font, using + the Set Font menu item. Finally, you can set the link manually, using the Set + Link menu item, which uses the "completion" package to help you specify a + filename. The Set Link procedure will also set the label of the link if there + isn't already one defined (like autolink). + + + \heading{How do I remove a Link?} + + You can remove a Link inset like any other inset: just select it and choose + the cut option from the menu, or backspace over it (and confirm the dialog + prompt). + + + \heading{Caveats} + + \description{You shouldn't put Links (or any other inset or style) into system + documents (like programs and init files). This will cause the document to + become unreadable by the system. + + Don't change the name of a link to the empty string. It will become invisible + and very hard to select again. You will probably need to backspace over it.} + + + \heading{How can I find out more?} + + You can use the overview document + \begindata{link,268768468} + Datastream version: 1 + Link + $DESTDIR/Link.d + andy12b + \enddata{link,268768468} + \view{linkv,268768468,3,0,0} to find out more about Links. + + \enddata{text,268720648} *** atk/hyplink/Help.pro Sun May 12 21:11:59 1991 --- atk/hyplink/Help.pro.NEW Wed Feb 13 16:51:50 1991 *************** *** 0 **** --- 1,83 ---- + \begindata{text,268687040} + \textdsversion{12} + \template{default} + \majorheading{Link User Documentation + + }\center{How to use Linked Documents} + + + \quotation{\center{Abstract} + + As a link user, you can easily navigate a set of Linked documents by using + your left mouse button. + + } + \heading{What is a Link?} + + A link is an ATK Inset. Hypermedia Developers place Links in documents to + help you locate additional information (if you'd like information on making + your own Linked documents, see + \begindata{link,268829692} + Datastream version: 1 + Link Developer + $DESTDIR/Developr.d + andysans8b + \enddata{link,268829692} + \view{linkv,268829692,10,0,0}). By default, a link looks like a pushbutton. + However, you may set your "\typewriter{linkstyle}" preference to "0", which + makes a link look like regular text, typically in \bold{Boldface} (although it + may not be), (see + \begindata{link,268707156} + Datastream version: 1 + Link Preferences + $DESTDIR/Prefs.d + andysans8b + \enddata{link,268707156} + \view{linkview,268707156,11,0,0}). The Hypermedia Developer will usually give + some kind of contextual indication that there is a link here, like "see + such-and-such". Also, the mouse cursor will change from a North-West arrow to + a crosshairs sight cursor. + + + \heading{How do I use a Link?} + + If you would like to follow the Link, just press your left mouse button over + the link inset (i.e., anywhere in the region where the target cursor is + visible). The Link inset will then bring up a window with the referenced + document in it, and your mouse pointer will be warped to that window. The + original source document will remain in its window. + + + \heading{What else should I know?} + + \description{To remove a window brought up by a link, remember to use "^X^D" + (delete window), and not "^X^C" (quit application). + + + When a Link has the input focus, typing to it will cause the "Unkown command" + message to appear. If you want to type in your document, simply use the mouse + to select a new insertion point. + + + Sometimes a Link inset won't have a target document. In this case, pressing + on the link will cause the message "No link." to be displayed. It will also + give the input focus to the link (see previous note). + + + There is a Link menu, which is meant for Hypermedia Developers. You should + ignore it. If you accidentally select one of these menu items, "^G" should + get you out of it. + + } + \heading{Where can I find out more?} + + The overview document for Link is + \begindata{link,268977524} + Datastream version: 1 + Link + $DESTDIR/Link.d + andy12b + \enddata{link,268977524} + \view{linkv,268977524,12,0,0}. + + \enddata{text,268687040} *** atk/hyplink/Link.pro Sun May 12 21:12:11 1991 --- atk/hyplink/Link.pro.NEW Wed Feb 13 16:51:52 1991 *************** *** 0 **** --- 1,87 ---- + \begindata{text,268687040} + \textdsversion{12} + \template{default} + \majorheading{Link} + + \center{A File Reference Inset} + + + \quotation{\center{Abstract} + + Link is an ATK inset that implments a file referencing tool. When a user + presses the left button on a link, the referenced file will be brought up in a + window and the focus and mouse pointer will be set to that window. + + } + \heading{User Documentation} + + For end user documentation see + \begindata{link,268944596} + Datastream version: 1 + LinkHelp + $DESTDIR/Help.d + andy12b + \enddata{link,268944596} + \view{linkv,268944596,0,0,0}. + + + \heading{Hypermedia Developer Documentation} + + For developer documentation see + \begindata{link,268921236} + Datastream version: 1 + Link Developer + $DESTDIR/Developr.d + andy12b + \enddata{link,268921236} + \view{linkv,268921236,1,0,0}. + + + \heading{Link Proctable Entries} + + To know what Procedure Table entries Link defines for use in menus and + keybinding, see + \begindata{link,268768824} + Datastream version: 1 + LinkProcs + $DESTDIR/Procs.d + andy12b + \enddata{link,268768824} + \view{linkv,268768824,2,0,0}. + + + \heading{Link Preferences} + + If you would like to modify the way Link looks, see + \begindata{link,268817176} + Datastream version: 1 + LinkPreferences + $DESTDIR/Prefs.d + andy12b + \enddata{link,268817176} + \view{linkview,268817176,3,0,0}. + + + \heading{Link Class Header} + + To see the link header file see + \begindata{link,268686572} + Datastream version: 1 + link.ch + $SRCDIR/link.ch + andy12b + \enddata{link,268686572} + \view{linkv,268686572,4,0,0}. + + To see the linkview header file see + \begindata{link,268899052} + Datastream version: 1 + linkv.ch + $SRCDIR/linkv.ch + andy12b + \enddata{link,268899052} + \view{linkv,268899052,5,0,0}. + + + + \enddata{text,268687040} *** atk/hyplink/Prefs.pro Sun May 12 21:12:05 1991 --- atk/hyplink/Prefs.pro.NEW Wed Feb 13 16:51:53 1991 *************** *** 0 **** --- 1,54 ---- + \begindata{text,268687040} + \textdsversion{12} + \template{default} + \majorheading{Link Preferences + + }\center{Changing the Link Appearance + + } + \quotation{\center{Abstract} + + You can select one of two "look-and-feels" for a Link inset. + + } + \heading{The Link Style Preference + + }Link currently only supports one preference, \typewriter{linkstyle}, which + should be an integer, either 0 or 2. Set \typewriter{linkstyle} to 0 if you + want links to look like regular, in-line text. A \typewriter{linkstyle} of 2 + is the default, and causes Links to look like three-dimensional buttons. + + + You can change link styles on a global or per-application basis only. You + cannot, for instance, change the way links appear on a document or per-link + basis. + + + To make a global change, put the following line in your preferences file: + + \example{*.linkstyle: \italic{desired-style} + + }where \italic{desired-style} is either 0 or 2. + + + To make a per-application change, put a line of the form: + + \example{\italic{application}.linkstyle: \italic{desired-style} + + }where \italic{application} is the name of the application (ez, table, + \italic{etc}.) and \italic{desired-style} is again either 0 or 2. + + + + \heading{Where can I find out more?} + + The overview document for Link is + \begindata{link,268988628} + Datastream version: 1 + Link + $DESTDIR/Link.d + andy12b + \enddata{link,268988628} + \view{linkv,268988628,13,0,0}. + + \enddata{text,268687040} *** atk/hyplink/Imakefile Thu May 30 19:53:01 1991 --- atk/hyplink/Imakefile.NEW Wed Feb 13 16:51:51 1991 *************** *** 0 **** --- 1,63 ---- + /* ********************************************************************** *\ + * Copyright IBM Corporation 1988,1989 - All Rights Reserved * + * For full copyright information see:'andrew/config/COPYRITE' * + \* ********************************************************************** */ + DOBJS = pshbttn.do \ + pshbttnv.do \ + link.do \ + linkv.do + + IHFILES = pshbttn.ih \ + pshbttnv.ih \ + link.ih \ + linkv.ih + + LINKHELP = linkins + + LINKHELPALIASES = linkinset linkinsets \ + hyplink hyplinks + + PBHELP = pshbttn + PBHELPALIASES = pushbutton trigger + + LINKFILES = Link.d Developr.d \ + Help.d Prefs.d \ + Procs.d + LIBS = ${UTILLIB} + + LINKDIR = $(DESTDIR)/doc/atk/linkinset + + INCDIR = $(DESTDIR)/include/atk + + NormalObjectRule() + NormalATKRule() + NormalHelpRule() + DependTarget() + + DynamicMultiObject(pshbttn.do, pshbttn.o, ${LIBS},) /* all because of NewString */ + InstallClassFiles($(DOBJS), $(IHFILES)) + + + /* Beware: there is a build dependancy here. We are assuming that $DESTDIR/doc/atk already exists. If it doesn't, the build will fail. This directory should be made by the top-level doc imkfile. */ + + MkdirTarget($(DESTDIR)/doc $(DESTDIR)/doc/atk $(DESTDIR)/doc/atk/linkinset) + + CleanTarget($(LINKFILES) $(LINKHELP).help) + + .SUFFIXES: .pro .d .help + .pro.d: + $(SED) -e s:\$$DESTDIR:$(LINKDIR):g \ + -e s:\$$SRCDIR:$(INCDIR):g \ + $*.pro > $*.d + .pro.help: + $(SED) -e s:\$$DESTDIR:$(LINKDIR):g \ + -e s:\$$SRCDIR:$(INCDIR):g \ + $*.pro > $*.help + + InstallDocs($(LINKHELP).help, $(DESTDIR)/help) + InstallHelpAlias($(LINKHELP), $(LINKHELPALIASES)) + InstallDocs($(LINKFILES), $(LINKDIR)) + InstallDocs(link.intro, ${DESTDIR}/help) + InstallDocs($(PBHELP).help, $(DESTDIR)/help) + InstallHelpAlias($(PBHELP), $(PBHELPALIASES)) + *** atk/hyplink/Procs.pro Sun May 12 21:12:07 1991 --- atk/hyplink/Procs.pro.NEW Wed Feb 13 16:51:54 1991 *************** *** 0 **** --- 1,90 ---- + \begindata{text,268720652} + \textdsversion{12} + \template{default} + \majorheading{Link Procedure Table Entries} + + \center{Link and your .ezinit file} + + + \quotation{\center{Abstract} + + Link defines several proctable entries. Only one, linkview-set-target, is + intended for use in your .ezinit file. The rest are used by Link itself (and + posted on its own menu), but you could bind keys to them, or use them in + compound procedures. + + } + \heading{Modifying your .ezinit file} + + You will probably want to modify your .ezinit file if you want to develop + Linked documents, so that autolinking will work. You don't need to do this, + as you can make links without autolink, but this will make development easier. + + + Basically, in order for Autolinking to work properly, you will need a way of + executing the "linkview-set-target" procedure in the target frame (window). + One way to do this, is to add the following line to your ~/.ezinit file + (please read the help document on Init files before attempting this + operation): + + \example{addmenu linkview-set-target "Link,Autolink target here" frame + + } + \heading{Proctable Entries} + + These are the five proctable entries defined by the Link inset. + + + \bold{Name:} \typewriter{\smaller{ linkview-set-target}} + + \bold{Type of object}:\typewriter{\smaller{ frame}} + + \bold{Documentation string}: \typewriter{\smaller{Execute this proc from the + frame of the the buffer for the target file of a link. To be called after + linkview-autolink.}} + + \bold{Comments:} Usually bound to a menu item reading something like + "Autolink target here". Execution of this procedure after starting an + Autolink with "linkview-autolink" (see next proc) completes the autolink + procedure by indicating to the source link that this frame contains a buffer + on a file which is to be the target. + + + \bold{Name}: \typewriter{\smaller{linkview-autolink}} + + \bold{Type of object}: \typewriter{\smaller{linkview}} + + \bold{Documentation string}: \typewriter{\smaller{Starts the autolink process. + Waits for linkview-set-target to be invoked, which tells this link what file + to link to.}} + + \bold{Comments}: This item will be bound to the Link card's "Autolink" item. + Selecting this item will start the autolinking procedure. You will need to + invoke \typewriter{\smaller{linkview-set-target}} in order to complete the + autolink procedure, which is preferably bound to "Autolink target here" on the + Link menu card. + + + \bold{Name}: \typewriter{\smaller{linkview-set-link}} + + \bold{Type of object}:\typewriter{\smaller{ linkview}} + + \bold{Documentation string}: \typewriter{\smaller{Prompts for user to set + target filename of the link button.}} + + \bold{Comments}: The Link inset binds this proc entry to the Link card's "Set + Link" entry. + + + \heading{Where can I find out more?} + + The overview document for Link is + \begindata{link,268748956} + Datastream version: 1 + Link + $DESTDIR/Link.d + andy12b + \enddata{link,268748956} + \view{linkv,268748956,0,0,0}. + + \enddata{text,268720652} *** atk/hyplink/link.c Thu May 30 19:53:17 1991 --- atk/hyplink/link.c.NEW Wed Apr 3 21:19:46 1991 *************** *** 0 **** --- 1,468 ---- + /* ********************************************************************** *\ + * Copyright IBM Corporation 1988,1989 - All Rights Reserved * + * For full copyright information see:'andrew/config/COPYRITE' * + \* ********************************************************************** */ + + #include + + #include + #include + + #include + #include + #include + + /* Defined constants and macros */ + #define MAX_LINE_LENGTH 70 /* can't be less than 6 */ + #define DS_VERSION 2 /* datastream version */ + + /* External declarations */ + + #ifndef _IBMR2 + extern char *malloc(); + #endif /* _IBMR2 */ + + /* Forward Declarations */ + static void WriteLine(); + static char *GlomStrings(), *ReadLine(); + #ifdef PL8 + static char *EncodeFont(); + #endif + + /* Global variables */ + + + boolean + link__InitializeClass(c) + struct classheader *c; + { + /* + Initialize all the class data. + */ + return(TRUE); + } + + + boolean + link__InitializeObject(c, self) + struct classheader *c; + struct link *self; + { + /* + Inititialize the object instance data. + */ + + self->link = NULL; + #ifdef PL8 + self->new_ds = 0; + #endif + + link_SetStyle(self,environ_GetProfileInt("linkstyle", 2)); + return(TRUE); + } + + + void + link__FinalizeObject(c, self) + struct classheader *c; + struct link *self; + { + /* + Finalize the object instance data. + */ + if (self->link) free(link_GetLink(self)); + self->link = NULL; + return; + } + + + long + link__Write(self, fp, id, level) + struct link *self; + FILE *fp; + long id; + int level; + { + /* + Write the object data out onto the datastream. + + Sample output from datastream version 1: + \begindata{link, 1234567} + Datastream version: 1 + This is my button label + /afs/andrew.cmu.edu/usr5/mcinerny/target_file + + \enddata{link, 1234567} + + Sample output from datastream version 2: + \begindata{link, 1234567} + Datastream version: 2 + /afs/andrew.cmu.edu/usr5/mcinerny/target_file -- the target of the link + \begindata{link, 1234567} -- really pushbutton (superclass) + Datastream version: 2 + This is my button label -- label + 2 -- style + andy12b -- font + black -- foreground color + 0xFFFFFF -- background color, RGB representation + \enddata{link, 1234567} -- again, really for the pushbutton part + \enddata{link, 1234567} + + */ + + long uniqueid = link_UniqueID(self); + + if (id != link_GetWriteID(self)) { + /* New Write Operation */ + #ifdef PL8 + if (self->new_ds == 0) { + fprintf(fp, "\\begindata{%s,%d}\nDatastream version: %d\n", + class_GetTypeName(self), uniqueid, 1); /* lie! */ + WriteLine(fp, link_GetText(self) ? link_GetText(self) : ""); + WriteLine(fp, link_GetLink(self) ? link_GetLink(self) : ""); + WriteLine(fp, link_GetButtonFont(self) ? EncodeFont(self) : ""); + } else { + #endif /* PL8 */ + fprintf(fp, "\\begindata{%s,%d}\nDatastream version: %d\n", + class_GetTypeName(self), uniqueid, DS_VERSION); + WriteLine(fp, link_GetLink(self) ? link_GetLink(self) : ""); + super_Write(self, fp, id, level); + #ifdef PL8 + } /* if (self->new_ds == 0) */ + #endif /* PL8 */ + + fprintf(fp, "\\enddata{%s,%d}\n", + class_GetTypeName(self), uniqueid); + link_SetWriteID(self, id); + } + return(uniqueid); + } + + + + static long + link_SanelyReturnReadError(self, fp, id, code) + struct link *self; + FILE *fp; + long id; + long code; + { + /* + Suck up the file until our enddata, then return the error code. + */ + char *buf, buf2[255]; + + buf = NULL; + sprintf(buf2, "\\enddata{%s,%ld}", class_GetTypeName(self), id); + do { + if (buf != NULL) free(buf); + if ((buf = ReadLine(fp)) == NULL) + return(dataobject_PREMATUREEOF); + } while (strncmp(buf, "\\enddata{", 9) != 0); /* find an enddata */ + + if (strcmp(buf, buf2) != 0) { + free(buf); + return(dataobject_MISSINGENDDATAMARKER); /* not ours! */ + } + free(buf); + + return(code); + } + + + static long + ReadOldFormat(self, fp, id) + struct link *self; + FILE *fp; + long id; + { + char *buf; + + if ((buf = ReadLine(fp)) == NULL) { + return(link_SanelyReturnReadError(self, fp, id, dataobject_PREMATUREEOF)); + } + if (strcmp(buf,"")!= 0 ) { + link_SetText(self, buf); + } + free(buf); + + if ((buf = ReadLine(fp)) == NULL) { + return(link_SanelyReturnReadError(self, fp, id, dataobject_PREMATUREEOF)); + } + if (strcmp(buf,"")!= 0 ) { + link_SetLink(self, buf); + } + free(buf); + + if ((buf = ReadLine(fp)) == NULL) { + return(link_SanelyReturnReadError(self, fp, id, dataobject_PREMATUREEOF)); + } + if (strcmp(buf,"")!= 0) { + char name[255]; + long style, size; + + if (!fontdesc_ExplodeFontName(buf,name,sizeof(name), + &style, &size)) { + strcpy(name,"andy"); + style = fontdesc_Bold; + size = 12; + } + link_SetButtonFont(self,fontdesc_Create(name,style,size)); + } + free(buf); + return(dataobject_NOREADERROR); + } + + + long + link__Read(self, fp, id) + struct link *self; + FILE *fp; + long id; + { + /* + Read in the object from the file. + */ + + char *buf; + int ds_version; + long error; + + link_SetID(self, link_UniqueID(self)); + + + if ((buf = ReadLine(fp)) == NULL) { + return(link_SanelyReturnReadError(self, fp, id, dataobject_PREMATUREEOF)); + } + if (strncmp(buf,"Datastream version:",19)) { + return(link_SanelyReturnReadError(self, fp, id, dataobject_BADFORMAT)); + } + ds_version = atoi(buf+19); + if ((ds_version < 1) || (ds_version > DS_VERSION)) { + return(link_SanelyReturnReadError(self, fp, id, dataobject_BADFORMAT)); + } + free(buf); + + switch (ds_version) { + case 1: + if ((error = ReadOldFormat(self, fp, id)) != dataobject_NOREADERROR) { + return(error); /* already read past \enddata */ + } + break; + case 2: + #ifdef PL8 + self->new_ds = 1; /* preserve new data on write */ + #endif /* PL8 */ + if ((buf = ReadLine(fp)) == NULL) { + return(link_SanelyReturnReadError(self, fp, id, dataobject_PREMATUREEOF)); + } + if (strcmp(buf,"")!= 0 ) { + link_SetLink(self, buf); + } + free(buf); + + if ((buf = ReadLine(fp)) == NULL) { + return(link_SanelyReturnReadError(self, fp, id, dataobject_PREMATUREEOF)); + } + if (strncmp(buf,"\\begindata{", 11)!= 0 ) { + return(link_SanelyReturnReadError(self, fp, id, dataobject_BADFORMAT)); + } + free(buf); + super_Read(self, fp, id); + + break; + + default: + fprintf(stderr, "ERROR: Link asked to read a format it doesn't know (ver. %d). Shouldn't happen.\n", ds_version); + return(link_SanelyReturnReadError(self, fp, id, dataobject_BADFORMAT)); + } + + return(link_SanelyReturnReadError(self, fp, id, dataobject_NOREADERROR)); + } + + + + void + link__SetLink(self, link) + struct link *self; + char *link; + { + /* + Set the link target (a filename) for this object. + */ + + if (link_GetLink(self)) free(link_GetLink(self)); + if (link) { + self->link = (char *)malloc(1+strlen(link)); + strcpy(link_GetLink(self), link); + } else { + self->link = NULL; + } + link_SetModified(self); + link_NotifyObservers(self, 0); + } + + + static void + WriteLine(f, l) + FILE *f; + char *l; + { + /* + Output a single line onto the data stream, quoting + back slashes and staying within line length limits. + Warning: this routine wasn't meant to handle embedded + newlines. + */ + + char buf[MAX_LINE_LENGTH]; + int i = 0; + + for (;*l != '\0'; ++l) { + if (i > (MAX_LINE_LENGTH - 5)) { + buf[i++] = '\\'; /* signal for line continuation */ + buf[i++] = '\n'; + buf[i++] = '\0'; + fputs(buf,f); + i = 0; + } /* if (i > ...) */ + switch (*l) { + case '\\': + /* if a backslash, quote it. */ + buf[i++] = '\\'; + buf[i++] = *l; + break; + default: + buf[i++] = *l; + } /* switch (*l) */ + } /* for (; *l != ... ) */ + + /* Need to empty buffer */ + if ((i > 0) && (buf[i-1]==' ')) { + /* don't allow trailing whitespace */ + buf[i++] = '\\'; + buf[i++] = '\n'; + buf[i++] = '\0'; + fputs(buf,f); + fputs("\n",f); + } else { + buf[i++] = '\n'; + buf[i++] = '\0'; + fputs(buf,f); + } + } + + + static char * + GlomStrings(s, t) + char *s, *t; + { + /* + Safely (allocs more memory) concatenates the two strings, + freeing the first. Meant to build a new string of unknown length. + */ + + char *r; + + r = (char *)malloc(strlen(s)+strlen(t)+1); + *r = '\0'; + strcpy(r,s); + free(s); + strcat(r,t); + return r; + } + + + static char * + ReadLine(f) + FILE *f; + { + /* + Reads from the datastream, attempting to return a single string. + Undoes quoting and broken lines. + Warning: this routine wasn't meant to handle embedded + newlines. + Warning: possible source of memory leaks; remember to + free the returned string when finished with it! + */ + + char buf[MAX_LINE_LENGTH], /* (BUG) What if the datastream is broken? */ + buf2[MAX_LINE_LENGTH], + *result; + int i,j; + + + result = (char *)malloc(1); + *result = '\0'; + + while (fgets(buf,sizeof(buf),f)) { + for (i = 0, j = 0; buf[i] != '\0'; ++i) { + switch (buf[i]) { + case '\\': + /* Unquote backslash or splice line */ + switch (buf[++i]) { + case '\\': + /* Unquote the backslash */ + buf2[j++] = buf[i]; + break; + case '\n': + /* broke long line */ + break; + default: + /* things like \enddata come through here */ + buf2[j++] = '\\'; + buf2[j++] = buf[i]; + break; + } /* switch (buf[++i]) */ + break; + case '\n': + /* An unquoted newline means end of string */ + buf2[j++] = '\0'; + result = GlomStrings(result, buf2); + return(result); + default: + buf2[j++] = buf[i]; + break; + } /* switch (buf[i]) */ + } /* for (i = 0, ...) */ + buf2[j++] = '\0'; + result = GlomStrings(result, buf2); + } /* while (fgets...) */ + /* Should not get here... it means we went off the end + of the data stream. Ooops. */ + return(NULL); + } + + #ifdef PL8 + + static char * + EncodeFont(self) + struct link *self; + { + /* + Returns a string representing the name of the font for this object. + (BUG) I shouldn't have to do this function, it should be a method + of the fontdesc object. In any case, I handle only Bold, Italic, + and fixed styles. + */ + + char *buf, type[15]; + long myfonttype, myfontsize; + char *myfontname; + + *type = '\0'; + myfontname = fontdesc_GetFontFamily(link_GetButtonFont(self)); + myfontsize = fontdesc_GetFontSize(link_GetButtonFont(self)); + myfonttype = fontdesc_GetFontStyle(link_GetButtonFont(self)); + if (myfonttype & fontdesc_Bold) strcpy(type,"b"); + if (myfonttype & fontdesc_Italic) strcpy(type,"i"); + if (myfonttype & fontdesc_Fixed) strcpy(type,"f"); + if (buf = (char *)malloc(strlen(myfontname)+25)) { + sprintf(buf,"%s%d%s", myfontname, myfontsize, type); + return (buf); + } else { + return(NULL); + } + } + + #endif /* PL8 */ *** atk/hyplink/link.ch Sun May 12 21:12:21 1991 --- atk/hyplink/link.ch.NEW Wed Feb 13 16:51:56 1991 *************** *** 0 **** --- 1,23 ---- + /* ********************************************************************** *\ + * Copyright IBM Corporation 1988,1989 - All Rights Reserved * + * For full copyright information see:'andrew/config/COPYRITE' * + \* ********************************************************************** */ + class link: pushbutton[pshbttn] { + classprocedures: + InitializeClass() returns boolean; + InitializeObject(struct link *self) returns boolean; + FinalizeObject(struct link *self); + overrides: + Read (FILE *file, long id) returns long; + Write (FILE *file, long writeid, int level) returns long; + methods: + SetLink(char *link); + macromethods: + GetLink() (self->link) + data: + char *link; + #ifdef PL8 + int new_ds; + #endif + }; + *** atk/hyplink/pshbttn.ch Thu May 30 19:53:33 1991 --- atk/hyplink/pshbttn.ch.NEW Mon Apr 29 15:42:33 1991 *************** *** 0 **** --- 1,84 ---- + /* ********************************************************************** *\ + * Copyright IBM Corporation 1989 - All Rights Reserved * + * For full copyright information see:'andrew/config/COPYRITE' * + \* ********************************************************************** */ + + /* + Ooops. I screwed up. + + It is the insets responsibility to read through their \enddata's. + The old version of this code didn't. This one does. + Problem is, I changed the datastream representation that tickles this + bug in the old version of this code. + + This means that if I were to release this code, with the new + datastream, now, I will cause old code to break (badly) when reading + documents created with the new code. + + So, for patch level 8, which the world will get (particularly CMU + campus), the nifty color stuff has no UI, and the old datastream is + written. (But both the old and the new datastreams will be supported.) + + For patch level 9, undefine "PL8", and the UI to the new features will + be available, and the new datastream will be written. This means that + people running PL8 will be able to read documents created using PL9 + features. + + NOTE: users who save PL9-created documents under PL8-code will + keep information, since the PL8 code will write the new datastream, + if it reads an inset with the new datastream! + + So, remember inset designers, slurp up those \enddata's! + */ + /* #define PL8 */ /* enable color */ + + /* + Appearances for pushbutton: + + Style Look + 0 plain, in line text + 1 a boxed rectangle + 2 a motif-ish 3-Dish button + 3 A mac-ish rounded rectangle box + 4 a single rectangle + */ + #define pushbutton_PLAIN 0 + #define pushbutton_BOXEDRECT 1 + #define pushbutton_THREEDEE 2 + #define pushbutton_ROUNDRECT 3 + #define pushbutton_PLAINBOX 4 + #define pushbutton_MOTIF 5 + + class pushbutton[pshbttn]: dataobject[dataobj] { + classprocedures: + InitializeClass() returns boolean; + InitializeObject(struct pushbutton *self) returns boolean; + FinalizeObject(struct pushbutton *self); + overrides: + Read (FILE *fp, long id) returns long; + Write (FILE *fp, long id, int level) returns long; + methods: + SetText(char *txt); + SetStyle(int stylecode); + SetButtonFont(struct fontdesc *f); + SetFGColor(char *name, int red, int green, int blue); /* if name is NULL, use RGB */ + SetBGColor(char *name, int red, int green, int blue); + GetFGColor(unsigned char *rgb_vect) returns char *; + GetBGColor(unsigned char *rgb_vect) returns char *; + ParseRGB(char *rgb_string, unsigned char rgb_vect); + macromethods: + GetText() (self->text) + GetStyle() (self->style) + GetButtonFont() (self->myfontdesc) + data: + char *text; + int style; + struct fontdesc *myfontdesc; + char *foreground_name, *background_name; + unsigned char foreground_color[3], background_color[3]; + #ifdef PL8 + int new_DS; + #endif /* PL8 */ + + }; + *** atk/hyplink/linkv.c Thu May 30 19:53:42 1991 --- atk/hyplink/linkv.c.NEW Thu Mar 28 09:36:30 1991 *************** *** 0 **** --- 1,363 ---- + /* ********************************************************************** *\ + * Copyright IBM Corporation 1988,1989 - All Rights Reserved * + * For full copyright information see:'andrew/config/COPYRITE' * + \* ********************************************************************** */ + #include + #include /* for MAXPATHLEN */ + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + + /* Defined constants and macros */ + #define DBG(x) fprintf(stderr, "\nDebug: %s.", x);fflush(stderr); + + #define PROMPTFONT "andy12b" + #define FONT "andy" + #define FONTSIZE 12 + #define BUTTONDEPTH 4 + #define BUTTONPRESSDEPTH 2 + #define TEXTPAD 2 + + /* External Declarations */ + + /* Forward Declarations */ + static void LinkProc(), WarpLink(), TargetProc(), AutolinkProc(); + static boolean FindBuffer(); + static char *FileName(); + static struct view *FindViewofBuffer(); + + /* Global Variables */ + static struct menulist *linkview_menulist = NULL; + static struct linkview *autolink_source = NULL; + static struct classinfo *proctype = NULL; + + + boolean + linkview__InitializeClass(c) + struct classheader *c; + { + /* + Initialize all the class data, particularly, set up the proc table entries + and the menu list (which is cloned for each instance of this class). + */ + + struct proctable_Entry *proc = NULL; + + proctype = class_Load("frame"); + linkview_menulist = menulist_New(); + + proc = proctable_DefineProc("linkview-set-target", TargetProc, proctype, NULL, "Execute this proc from the frame of the the buffer for the target file of a link. To be called after linkview-autolink."); + + proc = proctable_DefineProc("linkview-autolink", AutolinkProc, &linkview_classinfo, NULL, "Starts the autolink process. Waits for linkview-set-target to be invoked, which tells this link what file to link to."); + menulist_AddToML(linkview_menulist, "Link~1,Autolink~1", proc, NULL, 0); + + proc = proctable_DefineProc("linkview-set-link", LinkProc, &linkview_classinfo, NULL, "Prompts for user to set target filename of the link button."); + menulist_AddToML(linkview_menulist, "Link~1,Set Link~11", proc, NULL, 0); + + + return(TRUE); + } + + + boolean + linkview__InitializeObject(c, self) + struct classheader *c; + struct linkview *self; + { + /* + Set up the data for each instance of the object (i.e.: clone the menu + list, add the trigger recipient). + */ + + self->ml = menulist_DuplicateML(linkview_menulist, self); + return(linkview_AddRecipient(self, atom_Intern("buttonpushed"), self, WarpLink, 0L)); + } + + + void + linkview__FinalizeObject(c, self) + struct classheader *c; + struct linkview *self; + { + return; + } + + + + void + linkview__PostMenus(self, ml) + struct linkview *self; + struct menulist *ml; + { + /* + Enable the menus for this object. + */ + + menulist_ClearChain(self->ml); + if (ml) menulist_ChainAfterML(self->ml, ml, ml); + super_PostMenus(self, self->ml); + } + + + static void + LinkProc(self, param) + struct linkview *self; + char *param; + { + /* + This is the routine which asks the user for the target of the link. + Uses the (amazingly quick) completion package. + */ + + char buf[MAXPATHLEN]; + struct link *l = (struct link *)linkview_GetDataObject(self); + + if (param != NULL) + strcpy(buf, param); + else if (completion_GetFilename(self, "New target file for link: ", + link_GetLink(l) ? link_GetLink(l) : NULL, + buf, sizeof(buf), 0, 0) < 0) + return; + + link_SetLink(l, buf); + if (link_GetText(l) == NULL) { + link_SetText(l, FileName(buf)); + message_DisplayString(self, 10, "Changed link target (and label)."); + } else { + message_DisplayString(self, 10, "Changed link target."); + } + } + + + + static boolean + FindBuffer(f,b) + struct frame *f; + struct buffer *b; + { + /* + Little, dippy routine passed to frame_Enumerate to find the + frame which contains the buffer we want. + */ + + return(frame_GetBuffer(f)==b); + } + + + static struct view * + FindViewofBuffer(b) + struct buffer *b; + { + /* + I don't know why *I* have to do this, it should be a buffer method. + Anyways, this tries to find the frame of our buffer. If there is no + such frame, make one, make a new IM for it (new window), and put the + buffer in the frame in the IM. *phew* + */ + + struct frame *f; + struct im *im; + + if ((f = frame_Enumerate(FindBuffer, b))==NULL) { + /* No frame--need to map buffer to new window */ + + if((f = frame_New()) == NULL) { + fprintf(stderr,"hyplink: Could not allocate enough memory.\n"); + return((struct view*) NULL); + } + if((im = im_Create(NULL)) == NULL) { + fprintf(stderr,"hyplink: Could not create new window.\n"); + if(f) frame_Destroy(f); + return((struct view*) NULL); + } + im_SetView(im, f); + + frame_SetCommandEnable(f, TRUE); + frame_PostDefaultHandler(f, "message", frame_WantHandler(f, "message")); + frame_SetBuffer(f, b, TRUE); + } + return(frame_GetView(f)); + } + + + static void + WarpLink(self, triggerer, rock) + struct linkview *self; + struct observable *triggerer; + long rock; + { + /* + Do the actual "warp". The semantics I want are: + If the file isn't in a buffer, put it in one. + If the buffer isn't in a window, put it in one. + Warp the cursor & set the input focus to the target window (file). + */ + + char temp[MAXPATHLEN]; + struct buffer *buffer; + struct view *view; + struct im *im; + char *filename; + struct link *b = (struct link *)linkview_GetDataObject(self); + + if (!(filename=link_GetLink(b))) { + message_DisplayString(self, 10, "No link"); + return; + } + + if ((buffer = buffer_FindBufferByFile(filename)) == NULL) { + /* don't have the file in memory, get it */ + if ((buffer = buffer_GetBufferOnFile(filename, 0)) == NULL) { + sprintf(temp, "Couldn't get file %s.", filename); + message_DisplayString(self, 50, temp); + return; + } + } + /* have the file in buffer buffer */ + + /* get a view on the buffer */ + view = FindViewofBuffer(buffer); + + if ((view == NULL) || ((im = view_GetIM(view)) == NULL)) { + message_DisplayString(self, 50, "Couldn't find window."); + return; + } + + view_WantInputFocus(view,view); + /* pop to top window */ + im_ExposeWindow(im); + /* warp cursor there */ + im_SetWMFocus(im); + } + + + static char * + FileName(path) + char *path; + { + /* + Returns the filename portion of path (i.e.: strips leading + directories and any extensions--unless the filename begins + with a '.', in which case it strips the extensions after the + first '.' [so: ".cshrc" and ".cshrc.BAK" maps to ".cshrc"]); + Warning: destructively modifies the string path! + */ + char *r, *s; + + if ((s = rindex(path, '/'))==NULL) { + s = path; + } else { + ++s; + } + if ((r = index(s+1, '.'))!=NULL) *r = '\0'; + + return(s); + } + + + static void + TargetProc(v, param) + struct view *v; + long param; + { + /* + First, checks to see if there is a link object waiting for an + autolink. Then, if checks to make sure this frame has a buffer, + and that the buffer has a filename. + */ + struct buffer *fb; + char *fn, name[255]; + struct link *l; + + if (!autolink_source) { + message_DisplayString(v, 50, "Please set autolink source first."); + return; + } + + if (!class_IsTypeByName(class_GetTypeName(v),"frame")) { + message_DisplayString(v, 10, "Autolink works on frames only"); + return; + } + if ((fb = (struct buffer *)frame_GetBuffer(((struct frame *)v)))==NULL) { + message_DisplayString(v, 10, "Autolink works with buffers only"); + return; + } + + if ((fn = buffer_GetFilename((struct buffer *)fb))==NULL) { + message_DisplayString(v, 50, "Can only autolink to buffers on files."); + } else { + strcpy(name, fn); + l = (struct link *)linkview_GetDataObject(autolink_source); + link_SetLink(l, name); + if (link_GetText(l) == NULL) { + link_SetText(l,FileName(name)); + message_DisplayString(autolink_source, 10, "Changed link target (and label)."); + } else { + message_DisplayString(autolink_source, 10, "Changed link target."); + } /* if (!link_LabelSetP(...)) */ + } /* if (!(fn = ...)) */ + autolink_source = NULL; + + return; + } + + + static void + AutolinkProc(self, param) + struct linkview *self; + long param; + { + /* + Start the autolink process. Check to make sure we're not trouncing + on another autolink first though.... + */ + static char *conflict[] = { + "Use new autolink source", + "Use old autolink source", + "Cancel autolink", + NULL + }; + int answer; + + if (autolink_source) { + if (message_MultipleChoiceQuestion(self,99,"Already autolinking!", 2, &answer, conflict, NULL)>= 0) { + switch(answer) { + case 0: + message_DisplayString(self, 10, "Please indicate autolink target buffer."); + message_DisplayString(autolink_source, 10, "Cancelled. Using new source."); + autolink_source = self; + return; + case 1: + message_DisplayString(self, 10, "Cancelled. Using old source"); + message_DisplayString(autolink_source, 10, "Please indicate autolink target buffer with the linkview-set-target proc."); + return; + case 2: + message_DisplayString(self, 10, "Autolink cancelled."); + message_DisplayString(autolink_source, 10, "Autolink cancelled."); + autolink_source = NULL; + return; + } + } else { + message_DisplayString(self, 10, "Autolink cancelled."); + message_DisplayString(autolink_source, 10, "Autolink cancelled."); + autolink_source = NULL; + return; + } + } + message_DisplayString(self, 10, "Please indicate autolink target buffer."); + autolink_source = self; + + return; + } + *** atk/hyplink/linkv.ch Sun May 12 21:12:36 1991 --- atk/hyplink/linkv.ch.NEW Wed Feb 13 16:52:01 1991 *************** *** 0 **** --- 1,15 ---- + /* ********************************************************************** *\ + * Copyright IBM Corporation 1988,1989 - All Rights Reserved * + * For full copyright information see:'andrew/config/COPYRITE' * + \* ********************************************************************** */ + class linkview[linkv]: pushbuttonview[pshbttnv] { + classprocedures: + InitializeClass() returns boolean; + InitializeObject(struct linkview *self) returns boolean; + FinalizeObject(struct linkview *self); + overrides: + PostMenus(struct menulist *ml); + data: + struct menulist *ml; + }; + *** atk/hyplink/linkins.pro Sun May 12 21:12:16 1991 --- atk/hyplink/linkins.pro.NEW Wed Feb 13 16:51:58 1991 *************** *** 0 **** --- 1,112 ---- + \begindata{text,268720652} + \textdsversion{12} + \template{help} + \chapter{Link Inset: A Static Hyperlink + + } + \section{What Link is + + }\leftindent{ + The \bold{link} inset is a button that resides in the text of a document. It + ``links'' one document to another: a new window containing a target document + is created when the link inset is clicked on with the left mouse button. Link + is a basic hypermedia building block. + + + Use Delete Window (\bold{Ctrl-X Ctrl-D}) to remove the new window. See also + \bold{Warnings}. + + } + \section{Starting Link + + }\leftindent{ + You can ``follow'' a link by left-clicking on the link inset. By default, a + link inset looks like a shaded button, but its appearance may be changed with + the linkstyle preference. See the \italic{preferences} help document for + more information on setting preferences. + + + You insert a link in a document in the same manner as any other inset. Type + ESC-Tab, and answer ``link'' to the prompt ``Data object to insert here''. + See the \italic{inset } help document for more information on inserting + insets into documents. + + } + \section{Warnings + + }\leftindent{ + Following a link results in the creation of a new window, with the target of + the link in that new window. Note that with some window managers (e.g.: twm + on X-Windows), the new window may appear directly on top of the window in + which you invoked the link--just move the new window to see the old one. + + + Also, note that \bold{\italic{to remove a window}} created by following a + link, \bold{\italic{do \underline{not}}} use Quit (either from the menu or a + keystroke sequence, most likely bound to Ctrl-X Ctrl-C), or ``Zap'' the + window, as this will quit the application (EZ, Help, Messages, etc.) from + which you invoked the link. You want to use \bold{Delete Window} (usually + bound to the keystroke sequence \bold{Ctrl-X Ctrl-D}). + + } + \section{Pop-up menu meanings + + } + \leftindent{Link provides only one menu card, entitled Link, for configuring + links. The menu card becomes visible when the link is selected. You can + select a link without bringing up the target by right-mouse-clicking on the + link inset. These are the options: + + + \bold{Autolink Target Here}: Select this menu option from the target window, + after selecting ``\bold{Autolink''} on the source link. + + + \bold{Autolink}: Select this menu option on the source link, and then specify + the target window with the ``\bold{Autolink Target Here''} menu option. If + you can't find ``\bold{Autolink Target Here''}, you need to modify your + .ezinit file. + + + \bold{Set Link}: Specify the name of the target file for this link manually + (assisted by the completion package). + + + Because link is a subclass of the pushbutton inset, you may use the Pushbutton + menu to program link as well. + + } + \section{How Link works, Using Link, Link Concepts, The default Link, + Preferences, Programming Link + + }\leftindent{ + For more information on these topics, + \begindata{link,268728840} + Datastream version: 1 + Press Me + $DESTDIR/Link.d + andysans8b + \enddata{link,268728840} + \view{linkview,268728840,0,0,0}. + + } + \section{Program Author} + + \leftindent{ + Michael McInerny, ITC (address mail to mcinerny+@andrew.cmu.edu).} + + + \section{Related tools} + + + Select (highlight) one of the italicized names and choose "Show Help on + Selected Word" from the pop-up menu to see the help file for: + + + \leftindent{\italic{pushbutton + + insets + + ez} + + }\enddata{text,268720652} *** atk/hyplink/pshbttn.c Thu May 30 19:53:59 1991 --- atk/hyplink/pshbttn.c.NEW Thu May 2 13:30:48 1991 *************** *** 0 **** --- 1,706 ---- + /* ********************************************************************** *\ + * Copyright IBM Corporation 1989 - All Rights Reserved * + * For full copyright information see:'andrew/config/COPYRITE' * + \* ********************************************************************** */ + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + + /* Defined constants and macros */ + #define DS_VERSION 2 /* datastream version */ + + #define MAX_LINE_LENGTH 70 /* can't be less than 6 */ + + + /* External declarations */ + + /* Forward Declarations */ + static void WriteLine(); + static char *GlomStrings(), *ReadLine(), *EncodeFont(); + + /* Global variables */ + static struct atom *pushbutton_trigger; + + + boolean + pushbutton__InitializeClass(c) + struct classheader *c; + { + /* + Initialize all the class data. + */ + if ((pushbutton_trigger = atom_Intern("buttonpushed")) == NULL) return(FALSE); + return(TRUE); + } + + + boolean + pushbutton__InitializeObject(c, self) + struct classheader *c; + struct pushbutton *self; + { + /* + Inititialize the object instance data. + */ + + self->text = NULL; + observable_DefineTrigger(self, pushbutton_trigger); + + self->style = environ_GetProfileInt("pushbuttonstyle", 2); + + self->foreground_name = environ_GetProfile("foreground"); + if(self->foreground_name) self->foreground_name=NewString(self->foreground_name); + if ((self->foreground_name == NULL) || (strcmp(self->foreground_name, "") == 0)) { + if (self->foreground_name != NULL) free(self->foreground_name); + self->foreground_name = NewString("black"); + } else { + self->foreground_name = NewString(self->foreground_name); + } + self->foreground_color[0] = 0; + self->foreground_color[1] = 0; + self->foreground_color[2] = 0; + + self->background_name = environ_GetProfile("background"); + if(self->background_name) self->background_name=NewString(self->background_name); + if ((self->background_name == NULL) || (strcmp(self->background_name, "") == 0)) { + if (self->background_name != NULL) free(self->background_name); + self->background_name = NewString("white"); + } else { + self->background_name = NewString(self->background_name); + } + self->background_color[0] = 0; + self->background_color[1] = 0; + self->background_color[2] = 0; + + self->myfontdesc = NULL; + return(TRUE); + } + + + void + pushbutton__FinalizeObject(c, self) + struct classheader *c; + struct pushbutton *self; + { + /* + Finalize the object instance data. + */ + if (self->text != NULL) { + free(self->text); + self->text = NULL; + } + if (self->foreground_name != NULL) { + free(self->foreground_name); + self->foreground_name = NULL; + } + if (self->background_name != NULL) { + free(self->background_name); + self->background_name = NULL; + } + return; + } + + + static void + pushbutton__WriteDataPart(self, fp) + struct pushbutton *self; + FILE *fp; + { + /* + Write the object data out onto the datastream. + */ + char buf[100], *encfont; + + WriteLine(fp, self->text ? self->text : ""); + sprintf(buf,"%d", self->style); /* *BUG* how do we tell a defaulted + style from a set style? */ + WriteLine(fp, buf); + + encfont = self->myfontdesc ? EncodeFont(self) : NULL; + WriteLine(fp, encfont ? encfont : ""); + if (encfont) { + free(encfont); + encfont = NULL; + } + + #ifdef PL8 + if (!(self->new_DS)) return; + #endif /* PL8 */ + + if (self->foreground_name != NULL) { + sprintf(buf, "%s", self->foreground_name); + } else { + sprintf(buf, "0x%02x%02x%02x", + self->foreground_color[0], + self->foreground_color[1], + self->foreground_color[2]); + } + WriteLine(fp, buf); + + if (self->background_name != NULL) { + sprintf(buf, "%s", self->background_name); + } else { + sprintf(buf, "0x%02x%02x%02x", + self->background_color[0], + self->background_color[1], + self->background_color[2]); + } + WriteLine(fp, buf); + + } + + + + long + pushbutton__Write(self, fp, id, level) + struct pushbutton *self; + FILE *fp; + long id; + int level; + { + /* + Write the object data out onto the datastream. + + Sample output from datastream version 1: + \begindata{pushbutton, 1234567} + Datastream version: 1 + This is my button label -- label + 2 -- style + andy12b -- font + \enddata{pushbutton, 1234567} + + Sample output from datastream version 2: + \begindata{pushbutton, 1234567} + Datastream version: 2 + This is my button label -- label + 2 -- style + andy12b -- font + black -- foreground color + 0xFFFFFF -- background color, RGB representation + \enddata{pushbutton, 1234567} + + */ + + long uniqueid = pushbutton_UniqueID(self); + + if (id != pushbutton_GetWriteID(self)) { + /* New Write Operation */ + pushbutton_SetWriteID(self, id); + fprintf(fp, "\\begindata{%s,%d}\nDatastream version: %d\n", + class_GetTypeName(self), + uniqueid, + #ifndef PL8 + DS_VERSION); + #else /* PL8 */ + self->new_DS?DS_VERSION:1); /* lie, if we must*/ + #endif /* PL8 */ + + pushbutton__WriteDataPart(self, fp); + + fprintf(fp, "\\enddata{%s,%d}\n", class_GetTypeName(self), uniqueid); + } + return(uniqueid); + } + + + static long + pushbutton__ReadDataPart(self, fp, dsversion) + struct pushbutton *self; + FILE *fp; + { + /* + Read in the object from the file. + */ + char *buf; + unsigned char rgb[3]; + + if ((buf = ReadLine(fp)) == NULL) + return(dataobject_PREMATUREEOF); + if (strcmp(buf,"")!= 0 ) + pushbutton_SetText(self, buf); + free(buf); + + if ((buf = ReadLine(fp)) == NULL) + return(dataobject_PREMATUREEOF); + if (strcmp(buf,"")!= 0 ) + pushbutton_SetStyle(self, atoi(buf)); + free(buf); + + if ((buf = ReadLine(fp)) == NULL) + return(dataobject_PREMATUREEOF); + if (strcmp(buf,"")!= 0) { + char name[MAXPATHLEN]; + long style, size; + if (fontdesc_ExplodeFontName(buf,name,sizeof(name), &style, &size)) { + pushbutton_SetButtonFont(self,fontdesc_Create(name,style,size)); + } + } + free(buf); + + if (dsversion >= 2) { + if ((buf = ReadLine(fp)) == NULL) + return(dataobject_PREMATUREEOF); + if (strcmp(buf,"")!= 0 ) { + if ((strncmp(buf, "0x", 2) != 0) + &&(strncmp(buf, "0X", 2) != 0)) { + pushbutton_SetFGColor(self, buf, 0, 0, 0); + } else { + pushbutton_ParseRGB(self, buf, rgb); + pushbutton_SetFGColor(self, NULL, rgb[0], rgb[1], rgb[2]); + } + } + free(buf); + + if ((buf = ReadLine(fp)) == NULL) + return(dataobject_PREMATUREEOF); + if (strcmp(buf,"")!= 0 ) { + if (strncmp(buf, "0x", 2) != 0) { + pushbutton_SetBGColor(self, buf, 0, 0, 0); + } else { + pushbutton_ParseRGB(self, buf, rgb); + pushbutton_SetBGColor(self, NULL, rgb[0], rgb[1], rgb[2]); + } + } + free(buf); + } + + return(dataobject_NOREADERROR); + } + + + + static long + pushbutton_SanelyReturnReadError(self, fp, id, code) + struct pushbutton *self; + FILE *fp; + long id; + long code; + { + /* + Suck up the file until our enddata, then return the error code. + */ + char *buf, buf2[255]; + + buf = NULL; + sprintf(buf2, "\\enddata{%s,%ld}", class_GetTypeName(self), id); + do { + if (buf != NULL) free(buf); + if ((buf = ReadLine(fp)) == NULL) + return(dataobject_PREMATUREEOF); + } while (strncmp(buf, "\\enddata{", 9) != 0); /* find an enddata */ + + if (strcmp(buf, buf2) != 0) { + free(buf); + return(dataobject_MISSINGENDDATAMARKER); /* not ours! */ + } + free(buf); + + return(code); + } + + + + long + pushbutton__Read(self, fp, id) + struct pushbutton *self; + FILE *fp; + long id; + { + /* + Read in the object from the file. + (BUG) Doesn't set the font. + */ + char *buf; + long result; + int dsversion; + + pushbutton_SetID(self, pushbutton_UniqueID(self)); + + if ((buf = ReadLine(fp)) == NULL) + return(pushbutton_SanelyReturnReadError(self, fp, id, dataobject_PREMATUREEOF)); + if (strncmp(buf,"Datastream version:",19)) + return(pushbutton_SanelyReturnReadError(self, fp, id, dataobject_BADFORMAT)); + if ((dsversion = atoi(buf+19)) > DS_VERSION) /* datastream version */ + return(pushbutton_SanelyReturnReadError(self, fp, id, dataobject_BADFORMAT)); + if (dsversion < 1) + return(pushbutton_SanelyReturnReadError(self, fp, id, dataobject_BADFORMAT)); + free(buf); + #ifdef PL8 + if (dsversion > 1) self->new_DS = TRUE; /* preserve information */ + #endif /* PL8 */ + + if ((result = pushbutton__ReadDataPart(self, fp, dsversion)) != dataobject_NOREADERROR) + return(pushbutton_SanelyReturnReadError(self, fp, id, result)); + + return(pushbutton_SanelyReturnReadError(self, fp, id, dataobject_NOREADERROR)); + } + + + void + pushbutton__SetText(self, txt) + struct pushbutton *self; + char *txt; + { + /* + Set the text label for this object. + */ + + if (self->text) { + free(self->text); + self->text = NULL; + } + if (txt) + if (self->text = (char *)malloc(1+strlen(txt))) + strcpy(self->text, txt); + pushbutton_SetModified(self); + pushbutton_NotifyObservers(self, observable_OBJECTCHANGED); + } + + + void + pushbutton__SetStyle(self, stylecode) + struct pushbutton *self; + int stylecode; + { + /* + Set the style code for this object. + */ + + self->style = stylecode; + pushbutton_SetModified(self); + pushbutton_NotifyObservers(self,observable_OBJECTCHANGED); + } + + + void + pushbutton__SetButtonFont(self, f) + struct pushbutton *self; + struct fontdesc *f; + { + /* + Set the font descriptor for this object. + */ + + /* DON'T EVER FREE FONTS! */ + /* if (self->myfontdesc) free(self->myfontdesc); */ + + self->myfontdesc = f; + pushbutton_SetModified(self); + pushbutton_NotifyObservers(self,observable_OBJECTCHANGED); + } + + + + void + pushbutton__SetFGColor(self, name, red, green, blue) + struct pushbutton *self; + char *name; + int red, green, blue; + { + /* + Set the foreground color for this object. + */ + + if (self->foreground_name != NULL) free(self->foreground_name); + self->foreground_name = NULL; + + if (name != NULL) { + self->foreground_name = NewString(name); + self->foreground_color[0] = 0; + self->foreground_color[1] = 0; + self->foreground_color[2] = 0; + } else { + self->foreground_color[0] = red; + self->foreground_color[1] = green; + self->foreground_color[2] = blue; + } + + pushbutton_SetModified(self); + pushbutton_NotifyObservers(self,observable_OBJECTCHANGED); + #ifdef PL8 + self->new_DS = TRUE; /* preserve information */ + #endif /* PL8 */ + } + + + void + pushbutton__SetBGColor(self, name, red, green, blue) + struct pushbutton *self; + char *name; + int red, green, blue; + { + /* + Set the background color for this object. + */ + + if (self->background_name != NULL) free(self->background_name); + self->background_name = NULL; + + if (name != NULL) { + self->background_name = NewString(name); + self->background_color[0] = 0; + self->background_color[1] = 0; + self->background_color[2] = 0; + } else { + self->background_color[0] = red; + self->background_color[1] = green; + self->background_color[2] = blue; + } + + pushbutton_SetModified(self); + pushbutton_NotifyObservers(self,observable_OBJECTCHANGED); + #ifdef PL8 + self->new_DS = TRUE; /* preserve information */ + #endif /* PL8 */ + } + + + char * + pushbutton__GetFGColor(self, rgb_vect) + struct pushbutton *self; + unsigned char rgb_vect[]; + { + /* + Return the foreground color for this object. + */ + + rgb_vect[0] = self->foreground_color[0]; + rgb_vect[1] = self->foreground_color[1]; + rgb_vect[2] = self->foreground_color[2]; + + return(self->foreground_name); + } + + + char * + pushbutton__GetBGColor(self, rgb_vect) + struct pushbutton *self; + unsigned char rgb_vect[]; + { + /* + Return the background color for this object. + */ + + rgb_vect[0] = self->background_color[0]; + rgb_vect[1] = self->background_color[1]; + rgb_vect[2] = self->background_color[2]; + + return(self->background_name); + } + + + int + htoin(s, n) + char *s; + int n; + { + int i, t; + + for(i = 0, t = 0; i < n; ++i) { + t *= 16; + t += ((s[i]>='a') + ?(s[i]-'a'+10) + :((s[i]>='A') + ?(s[i]-'A'+10) + :(s[i]-'0'))); + } + + return(t); + } + + + void + pushbutton__ParseRGB(self, rgb_string, rgb_vect) + struct pushbutton *self; + char *rgb_string; + unsigned char rgb_vect[]; + { + /* + Return the background color for this object. + */ + + if ((rgb_string != NULL) + && ((strncmp(rgb_string, "0x", 2) == 0) + || (strncmp(rgb_string, "0X", 2) == 0)) + && (strlen(rgb_string) == 8)) { + rgb_vect[0] = htoin(rgb_string+2,2); + rgb_vect[1] = htoin(rgb_string+4,2); + rgb_vect[2] = htoin(rgb_string+6,2); + } + } + + + static void + WriteLine(f, l) + FILE *f; + char *l; + { + /* + Output a single line onto the data stream, quoting + back slashes and staying within line length limits. + Warning: this routine wasn't meant to handle embedded + newlines. + */ + + char buf[MAX_LINE_LENGTH]; + int i = 0; + + for (;*l != '\0'; ++l) { + if (i > (MAX_LINE_LENGTH - 5)) { + buf[i++] = '\\'; /* signal for line continuation */ + buf[i++] = '\n'; + buf[i++] = '\0'; + fputs(buf,f); + i = 0; + } /* if (i > ...) */ + switch (*l) { + case '\\': + /* if a backslash, quote it. */ + buf[i++] = '\\'; + buf[i++] = *l; + break; + default: + buf[i++] = *l; + } /* switch (*l) */ + } /* for (; *l != ... ) */ + + /* Need to empty buffer */ + if ((i > 0) && (buf[i-1]==' ')) { + /* don't allow trailing whitespace */ + buf[i++] = '\\'; + buf[i++] = '\n'; + buf[i++] = '\0'; + fputs(buf,f); + fputs("\n",f); + } else { + buf[i++] = '\n'; + buf[i++] = '\0'; + fputs(buf,f); + } + } + + + static char * + GlomStrings(s, t) + char *s, *t; + { + /* + Safely (allocs more memory) concatenates the two strings, + freeing the first. Meant to build a new string of unknown length. + */ + + char *r; + + if (r = (char *)malloc(strlen(s)+strlen(t)+1)) { + *r = '\0'; + strcpy(r,s); + free(s); + strcat(r,t); + return(r); + } else { + free(s); + return(NULL); + } + } + + + static char * + ReadLine(f) + FILE *f; + { + /* + Reads from the datastream, attempting to return a single string. + Undoes quoting and broken lines. + Warning: this routine wasn't meant to handle embedded + newlines. + Warning: possible source of memory leaks; remember to + free the returned string when finished with it! + */ + + char buf[MAX_LINE_LENGTH], /* (BUG) What if the datastream is broken? */ + buf2[MAX_LINE_LENGTH], + *result; + int i,j; + + + if (result = (char *)malloc(1)) { + *result = '\0'; + + while (fgets(buf,sizeof(buf),f)) { + for (i = 0, j = 0; buf[i] != '\0'; ++i) { + switch (buf[i]) { + case '\\': + /* Unquote backslash or splice line */ + switch (buf[++i]) { + case '\\': + /* Unquote the backslash */ + buf2[j++] = buf[i]; + break; + case '\n': + /* broke long line */ + break; + default: + /* things like \enddata come through here */ + buf2[j++] = '\\'; + buf2[j++] = buf[i]; + break; + } /* switch (buf[++i]) */ + break; + case '\n': + /* An unquoted newline means end of string */ + buf2[j++] = '\0'; + result = GlomStrings(result, buf2); + return(result); + default: + buf2[j++] = buf[i]; + break; + } /* switch (buf[i]) */ + } /* for (i = 0, ...) */ + buf2[j++] = '\0'; + result = GlomStrings(result, buf2); + } /* while (fgets...) */ + /* Should not get here... it means we went off the end + of the data stream. Ooops. */ + } /* if (result = ... ) */ + return(NULL); + } + + + static char * + EncodeFont(self) + struct pushbutton *self; + { + /* + Returns a string representing the name of the font for this object. + (BUG) I shouldn't have to do this function, it should be a method + of the fontdesc object. In any case, I handle only Bold, Italic, + and fixed styles. + */ + + char *buf, type[15]; + long myfonttype, myfontsize; + char *myfontname; + + *type = '\0'; + myfontname = fontdesc_GetFontFamily(self->myfontdesc); + myfontsize = fontdesc_GetFontSize(self->myfontdesc); + myfonttype = fontdesc_GetFontStyle(self->myfontdesc); + if (myfonttype & fontdesc_Bold) strcpy(type,"b"); + if (myfonttype & fontdesc_Italic) strcpy(type,"i"); + if (myfonttype & fontdesc_Fixed) strcpy(type,"f"); + if (buf = (char *)malloc(strlen(myfontname)+25)) { + sprintf(buf,"%s%d%s", myfontname, myfontsize, type); + return (buf); + } else { + return(NULL); + } + } + *** atk/hyplink/pshbttnv.c Thu May 30 19:54:08 1991 --- atk/hyplink/pshbttnv.c.NEW Thu May 2 13:30:54 1991 *************** *** 0 **** --- 1,1089 ---- + /* ********************************************************************** *\ + * Copyright IBM Corporation 1989 - All Rights Reserved * + * For full copyright information see:'andrew/config/COPYRITE' * + \* ********************************************************************** */ + + #include /* for MAXPATHLEN */ + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + + /* Defined constants and macros */ + #define CURSORON 1 /* yes, use crosshairs cursor over button */ + #define NOROUNDRECT 1 /* round rect is broken */ + #if 0 + #define DEBUG 1 /* turn on debugging */ + #endif + #ifdef DEBUG + #define DBG(x) fprintf(stderr, "\nDebug: %s.", x);fflush(stderr); + #else + #define DBG(x) ; + #endif + + #define NO_MSG "Push Me" + + #define PROMPTFONT "andysans12b" + #define FONT "andysans" + #define FONTTYPE fontdesc_Bold + #define FONTSIZE 12 + #define BUTTONDEPTH 4 + #define ULSHADE 0.25 /* upper & left sides */ + #define LRSHADE 0.75 /* lower & right sides */ + #define TOPSHADE 0.50 /* face of button */ + #define MOTIFBUTTONDEPTH 2 + #define MOTIFULSHADE 0.10 + #define MOTIFLRSHADE 0.50 + #define MOTIFTOPSHADE 0.25 + #define BUTTONPRESSDEPTH 2 + #define TEXTPAD 2 + + /* External Declarations */ + + /* Forward Declarations */ + static void LabelProc(), FontProc(), StyleProc(), ColorProc(); + + /* Global Variables */ + static struct atom *pushedtrigger; + static struct menulist *menulist = NULL; + + + static void + pushbuttonview_setShade(self, pct) + struct pushbuttonview *self; + double pct; /* 0.0 -> 1.0 */ + { + pushbuttonview_SetFGColor(self, + self->foreground_color[0]*pct + + self->background_color[0]*(1.0-pct), + self->foreground_color[1]*pct + + self->background_color[1]*(1.0-pct), + self->foreground_color[2]*pct + + self->background_color[2]*(1.0-pct)); + + } /* pushbuttonview_setShade */ + + + boolean + pushbuttonview__InitializeClass(c) + struct classheader *c; + { + /* + Initialize all the class data. + Set up the proc table entries and the menu list + (which is cloned for each instance of this class). + */ + struct proctable_Entry *proc = NULL; + + if ((pushedtrigger = atom_Intern("buttonpushed")) == NULL) return(FALSE); + + if ((menulist = menulist_New()) == NULL) return(FALSE); + + if ((proc = proctable_DefineProc("pushbuttonview-set-label-text", LabelProc, &pushbuttonview_classinfo, NULL, "Prompts for user to set the text string of the pushbutton.")) == NULL) return(FALSE); + menulist_AddToML(menulist, "Pushbutton~1,Set Label~11", proc, NULL, 0); + + if ((proc = proctable_DefineProc("pushbuttonview-set-font", FontProc, &pushbuttonview_classinfo, NULL, "Prompts for user to set the font of the pushbutton.")) == NULL) return(FALSE); + menulist_AddToML(menulist, "Pushbutton~1,Set Font~12", proc, NULL, 0); + + if ((proc = proctable_DefineProc("pushbuttonview-set-style", StyleProc, &pushbuttonview_classinfo, NULL, "Prompts for user to set the appearance of the pushbutton.")) == NULL) return(FALSE); + menulist_AddToML(menulist, "Pushbutton~1,Set Style~13", proc, NULL, 0); + + if ((proc = proctable_DefineProc("pushbuttonview-set-color", ColorProc, &pushbuttonview_classinfo, NULL, "Prompts for user to set the foreground and background color of the pushbutton.")) == NULL) return(FALSE); + #ifndef PL8 /* users of PL8 can't set color */ + menulist_AddToML(menulist, "Pushbutton~1,Set Color~14", proc, NULL, 0); + #endif /* PL8 */ + + return(TRUE); + } + + + boolean + pushbuttonview__InitializeObject(c, self) + struct classheader *c; + struct pushbuttonview *self; + { + /* + Set up the data for each instance of the object. + */ + int i; + + self->lit = 0; + self->awaitingUpdate = 0; + self->ml = menulist_DuplicateML(menulist, self); + self->cached_label = "NOT YET CACHED"; + self->cached_style = -1; + self->cached_fontdesc = NULL; + for (i = 0 ; i < 3; i++) { + self->foreground_color[i] = 0.0; + self->background_color[i] = 0.0; + } + + #if CURSORON + if (!(self->cursor = cursor_Create(self))) return(FALSE); + cursor_SetStandard(self->cursor, Cursor_Gunsight); + #endif /* CURSORON */ + observable_DefineTrigger(self, pushedtrigger); + return(TRUE); + } + + + void + pushbuttonview__PostMenus(self, ml) + struct pushbuttonview *self; + struct menulist *ml; + { + /* + Enable the menus for this object. + */ + + menulist_ClearChain(self->ml); + if (ml) menulist_ChainAfterML(self->ml, ml, ml); + super_PostMenus(self, self->ml); + } + + + static void + pushbuttonview_CacheSettings(self, b, updateflag) + struct pushbuttonview *self; + struct pushbutton *b; + int updateflag; /* call WantUpdate if necessary */ + { + char *fgcolor, *bgcolor; + unsigned char fg_rgb[3], bg_rgb[3]; + double get_rgb[3]; + int i; + char *pb_label; + int pb_style; + struct fontdesc *pb_font; + int UpdateNeeded, NewSize; + + if (b && pushbuttonview_GetIM(self)) { + /* these calls don't make sense if there is no IM or button, + (in fact they seg fault!) */ + + UpdateNeeded = 0; + NewSize = 0; /* A new size requires an update */ + + pb_label = pushbutton_GetText(b); + if (pb_label != self->cached_label) { + self->cached_label = pb_label; + NewSize = 1; + } + + pb_style = pushbutton_GetStyle(b); + if (pb_style != self->cached_style) { + self->cached_style = pb_style; + NewSize = 1; + } + + pb_font = pushbutton_GetButtonFont(b); + if (pb_font != self->cached_fontdesc) { + self->cached_fontdesc = pb_font; + NewSize = 1; + } + + fgcolor = pushbutton_GetFGColor(b, fg_rgb); + bgcolor = pushbutton_GetBGColor(b, bg_rgb); + + /* We need to set the colors to find out their interpretation + on the window server. */ + pushbuttonview_SetForegroundColor(self, + fgcolor, + fg_rgb[0]*256L, + fg_rgb[1]*256L, + fg_rgb[2]*256L); + pushbuttonview_SetBackgroundColor(self, + bgcolor, + bg_rgb[0]*256L, + bg_rgb[1]*256L, + bg_rgb[2]*256L); + + pushbuttonview_GetFGColor(self, + &(get_rgb[0]), + &(get_rgb[1]), + &(get_rgb[2])); + for(i = 0; i < 3; i++) { + if (get_rgb[i] != self->foreground_color[i]) { + self->foreground_color[i] = get_rgb[i]; + UpdateNeeded = 1; /* color changed, not size */ + } + } + + pushbuttonview_GetBGColor(self, + &(get_rgb[0]), + &(get_rgb[1]), + &(get_rgb[2])); + for(i = 0; i < 3; i++) { + if (get_rgb[i] != self->background_color[i]) { + self->background_color[i] = get_rgb[i]; + UpdateNeeded = 1; /* color changed, not size */ + } + } + + if (NewSize) { + pushbuttonview_WantNewSize(self,self); + } + if (updateflag && (NewSize || UpdateNeeded)) { + pushbuttonview_WantUpdate(self, self); + } + } /* if (b && im) */ + + } + + + void + pushbuttonview__LinkTree(self, parent) + struct pushbuttonview *self; + struct view *parent; + { + super_LinkTree(self, parent); + + pushbuttonview_CacheSettings(self, (struct pushbutton *) pushbuttonview_GetDataObject(self), 0); + + } /* pushbuttonview__LinkTree */ + + + void + pushbuttonview__FinalizeObject(c, self) + struct classheader *c; + struct pushbuttonview *self; + { + #if CURSORON + if (self->cursor) cursor_Destroy(self->cursor); + self->cursor = NULL; + #endif /* CURSORON */ + return; + } + + + void + pushbuttonview__FullUpdate(self, type, left, top, width, height) + struct pushbuttonview *self; + enum view_UpdateType type; + long left, top, width, height; + { + /* + Redisplay this object. Specifically, set my font, and put my text label + in the center of my display box. + */ + + struct rectangle Rect, Rect2; + struct pushbutton *b = (struct pushbutton *) pushbuttonview_GetDataObject(self); + int bdepth, r2_bot, r_bot; + double ulshade, lrshade, topshade; + int tx = 0, ty = 0; + short t_op; + char *text; + int style; + struct fontdesc *my_fontdesc; + struct graphic *my_graphic; + struct FontSummary *my_FontSummary; + int redraw; + + self->awaitingUpdate = 0; + + pushbuttonview_GetLogicalBounds(self, &Rect); + + switch (type) { + case view_FullRedraw: + case view_LastPartialRedraw: + redraw = 1; + break; + case view_MoveNoRedraw: + #if CURSORON + pushbuttonview_PostCursor(self, &Rect, self->cursor); + #endif /* CURSORON */ + redraw = 0; + break; + case view_PartialRedraw: + redraw = 0; + break; + case view_Remove: + #if CURSORON + pushbuttonview_RetractCursor(self, self->cursor); + #endif /* CURSORON */ + redraw = 0; + break; + default: + redraw = 1; + } + + + if (b && redraw) { + style = pushbutton_GetStyle(b); + my_graphic = (struct graphic *)pushbuttonview_GetDrawable(self); + if (!(my_fontdesc = pushbutton_GetButtonFont(b))) { + my_fontdesc= fontdesc_Create(FONT, FONTTYPE, FONTSIZE); + } + if (my_fontdesc) { + pushbuttonview_SetFont(self, my_fontdesc); + my_FontSummary = fontdesc_FontSummary(my_fontdesc, my_graphic); + } + + pushbuttonview_SetTransferMode(self, graphic_SOURCE); + if ((style != pushbutton_THREEDEE) && (style != pushbutton_MOTIF)) { + /* Erase with BG color, only if style is not 3-D (3-D draws all bits) */ + pushbuttonview_setShade(self, 0.0); + pushbuttonview_FillRect(self, &Rect, NULL); + } + pushbuttonview_setShade(self, 1.0); + + t_op = graphic_BETWEENLEFTANDRIGHT | graphic_ATBASELINE; + text = pushbutton_GetText(b) ? pushbutton_GetText(b) : NO_MSG; + ty = 0; /* default, in case my_FontSummary is NULL */ + + switch (style) { + case pushbutton_BOXEDRECT: + Rect.width--; + Rect.height--; + /* Rect2 is the inner rect */ + Rect2.top = Rect.top + BUTTONDEPTH; + Rect2.left = Rect.left + BUTTONDEPTH; + Rect2.width = Rect.width - 2*BUTTONDEPTH; + Rect2.height = Rect.height - 2*BUTTONDEPTH; + tx = TEXTPAD + (Rect2.left + Rect2.width) / 2; + if (my_FontSummary) + ty = TEXTPAD + (Rect2.top + my_FontSummary->maxHeight - my_FontSummary->maxBelow); + + pushbuttonview_SetTransferMode(self, graphic_COPY); + pushbuttonview_DrawRect(self, &Rect); + pushbuttonview_DrawRect(self, &Rect2); + pushbuttonview_MoveTo(self, tx, ty); + pushbuttonview_DrawString(self, text, t_op); + break; + + case pushbutton_ROUNDRECT: + /* THIS CODE IS STILL BROKEN, DUE TO A LACK OF DOCUMENTATION ON RRect! */ + /* Rect2 is the inner rect for DrawRRect */ + Rect2.top = Rect.top; + Rect2.left = Rect.left; + Rect2.height = BUTTONDEPTH; + Rect2.width = BUTTONDEPTH; + Rect.width -= 1; + Rect.height -= BUTTONDEPTH; + + tx = TEXTPAD + (Rect.left + Rect.width) / 2; + if (my_FontSummary) + ty = TEXTPAD + (Rect.top + my_FontSummary->maxHeight - my_FontSummary->maxBelow); + + pushbuttonview_SetTransferMode(self, graphic_COPY); + pushbuttonview_DrawRRect(self, &Rect, &Rect2); + pushbuttonview_MoveTo(self, tx, ty); + pushbuttonview_DrawString(self, text, t_op); + break; + + case pushbutton_MOTIF: + case pushbutton_THREEDEE: + if (style == pushbutton_MOTIF) { + bdepth = MOTIFBUTTONDEPTH; + ulshade = MOTIFULSHADE; + lrshade = MOTIFLRSHADE; + topshade = MOTIFTOPSHADE; + } else { + bdepth = BUTTONDEPTH; + ulshade = ULSHADE; + lrshade = LRSHADE; + topshade = TOPSHADE; + } + + + /* Rect2 is the inner (Text) region */ + Rect2.top = Rect.top + bdepth; + Rect2.left = Rect.left + bdepth; + Rect2.width = Rect.width - 2*bdepth; + Rect2.height = Rect.height - 2*bdepth; + r2_bot = (Rect2.top)+(Rect2.height); + r_bot = (Rect.top)+(Rect.height); + + tx = TEXTPAD + (Rect2.left + Rect2.width) / 2; + if (my_FontSummary) { + ty = TEXTPAD + (Rect2.top + my_FontSummary->maxHeight - my_FontSummary->maxBelow); + } + + #ifdef WM_ENV + if (im_WhichWS(pushbuttonview_GetIM(self))[0] == 'w') { + pushbuttonview_FillRectSize(self, Rect.left, Rect.top, bdepth, Rect.height, pushbuttonview_GrayPattern(self, 1, 4)); /* left bar */ + + pushbuttonview_FillRectSize(self, Rect.left + Rect.width - bdepth, Rect.top, bdepth, Rect.height, pushbuttonview_GrayPattern(self, 3, 4)); /* right bar */ + + pushbuttonview_FillTrapezoid(self, Rect2.left, r2_bot, Rect2.width, Rect.left, r_bot, Rect.width, pushbuttonview_GrayPattern(self, 3, 4)); /* lower trapz */ + + pushbuttonview_FillTrapezoid(self, Rect.left, Rect.top, Rect.width, Rect2.left, Rect2.top, Rect2.width, pushbuttonview_GrayPattern(self, 1, 4)); /* upper trapz */ + + pushbuttonview_FillRect(self, &Rect2, pushbuttonview_GrayPattern(self,1,2)); /* the middle box */ + } + else + #endif /* WM_ENV */ + { + pushbuttonview_SetTransferMode(self, graphic_COPY); + pushbuttonview_setShade(self, ulshade); + pushbuttonview_FillRectSize(self, Rect.left, Rect.top, bdepth, Rect.height, NULL); /* left bar */ + + pushbuttonview_setShade(self, lrshade); + pushbuttonview_FillRectSize(self, Rect.left + Rect.width - bdepth, Rect.top, bdepth, Rect.height, NULL); /* right bar */ + pushbuttonview_FillTrapezoid(self, Rect2.left, r2_bot, Rect2.width, Rect.left, r_bot, Rect.width, NULL); /* lower trapz */ + + pushbuttonview_setShade(self, ulshade); + pushbuttonview_FillTrapezoid(self, Rect.left, Rect.top, Rect.width, Rect2.left, Rect2.top, Rect2.width, NULL); /* upper trapz */ + + pushbuttonview_setShade(self, topshade); + pushbuttonview_FillRect(self, &Rect2, NULL); /* the middle box */ + + pushbuttonview_setShade(self, 1.0); + } + + if (style != pushbutton_MOTIF) { + pushbuttonview_SetTransferMode(self, graphic_WHITE); + pushbuttonview_MoveTo(self, tx+1, ty); + pushbuttonview_DrawString(self, text, t_op); + pushbuttonview_MoveTo(self, tx, ty+1); + pushbuttonview_DrawString(self, text, t_op); + pushbuttonview_MoveTo(self, tx+1, ty+1); + pushbuttonview_DrawString(self, text, t_op); + } + pushbuttonview_SetTransferMode(self, graphic_BLACK); + pushbuttonview_MoveTo(self, tx, ty); + pushbuttonview_DrawString(self, text, t_op); + break; + + case pushbutton_PLAINBOX: + Rect.width--; + Rect.height--; + pushbuttonview_DrawRect(self, &Rect); + + tx = Rect.left + (Rect.width / 2); + ty = Rect.top + (Rect.height / 2); + + pushbuttonview_MoveTo(self, tx, ty); + t_op = graphic_BETWEENLEFTANDRIGHT | graphic_BETWEENTOPANDBOTTOM; + pushbuttonview_DrawString(self, text, t_op); + + break; + + default: /* PLAIN */ + tx = (Rect.left + Rect.width) / 2; + if (my_FontSummary) + ty = (Rect.top + my_FontSummary->maxHeight - my_FontSummary->maxBelow); + + pushbuttonview_SetTransferMode(self, graphic_COPY); + pushbuttonview_MoveTo(self, tx, ty); + pushbuttonview_DrawString(self, text, t_op); + break; + } /* switch (style) */ + + } /* if (b && redraw) */ + self->lit = 0; + } + + + void + pushbuttonview__Update(self) + struct pushbuttonview *self; + { + /* + Do an update. Just set up the call to FullUpdate method. + */ + struct rectangle r; + + #if 0 + /* Shouldn't need this 'cuz full update fills the BG already */ + pushbuttonview_EraseVisualRect(self); + #endif /* 0 */ + pushbuttonview_GetLogicalBounds(self, &r); + pushbuttonview_FullUpdate(self, view_FullRedraw, r.left, r.top, r.width, r.height); + } + + + static int + RectEnclosesXY(r, x, y) + struct rectangle *r; + long x, y; + { + return( ( ((r->top) <= y) && ((r->top + r->height) >= y) ) + && ( ((r->left) <= x) && ((r->left + r->width) >= x) ) + ); + } + + + static void + HighlightButton(self) + struct pushbuttonview *self; + { + struct pushbutton *b = (struct pushbutton *) pushbuttonview_GetDataObject(self); + struct rectangle Rect, Rect2; + int style; + struct fontdesc *my_fontdesc; + struct graphic *my_graphic; + struct FontSummary *my_FontSummary; + int tx, ty; + short t_op; + char *text; + int bdepth, r2_bot, r_bot; + double ulshade, lrshade; + + if (!(self->lit)) { + style = pushbutton_GetStyle(b); + pushbuttonview_GetLogicalBounds(self, &Rect); + + switch (style) { + case pushbutton_PLAIN: + case pushbutton_PLAINBOX: + pushbuttonview_SetTransferMode(self, graphic_INVERT); + pushbuttonview_FillRect(self,&Rect,pushbuttonview_BlackPattern(self)); + break; + + case pushbutton_BOXEDRECT: + /* Rect2 is the inner rect */ + Rect2.top = Rect.top + BUTTONDEPTH; + Rect2.left = Rect.left + BUTTONDEPTH; + Rect2.width = Rect.width - 2*BUTTONDEPTH; + Rect2.height = Rect.height - 2*BUTTONDEPTH; + + pushbuttonview_SetTransferMode(self, graphic_INVERT); + pushbuttonview_FillRect(self, &Rect,pushbuttonview_BlackPattern(self)); + pushbuttonview_FillRect(self, &Rect2,pushbuttonview_BlackPattern(self)); + + break; + case pushbutton_ROUNDRECT: + /* Rect2 is the inner rect for DrawRRect */ + Rect2.top = Rect.top; + Rect2.left = Rect.left; + Rect2.height = BUTTONDEPTH; + Rect2.width = BUTTONDEPTH; + Rect.width -= 1; + Rect.height -= BUTTONDEPTH; + + pushbuttonview_SetTransferMode(self, graphic_INVERT); + pushbuttonview_FillRRect(self, &Rect, &Rect2, pushbuttonview_BlackPattern(self)); + + break; + + case pushbutton_MOTIF: + case pushbutton_THREEDEE: + if (style == pushbutton_MOTIF) { + bdepth = MOTIFBUTTONDEPTH; + ulshade = MOTIFLRSHADE; + lrshade = MOTIFULSHADE; + } else { + bdepth = BUTTONDEPTH; + ulshade = ULSHADE; + lrshade = LRSHADE; + } + + /* Rect2 is the inner (Text) region */ + Rect2.top = Rect.top + bdepth; + Rect2.left = Rect.left + bdepth; + Rect2.width = Rect.width - 2*bdepth; + Rect2.height = Rect.height - 2*bdepth; + r2_bot = (Rect2.top)+(Rect2.height); + r_bot = (Rect.top)+(Rect.height); + + if (style == pushbutton_MOTIF) { + pushbuttonview_SetTransferMode(self, graphic_COPY); + pushbuttonview_setShade(self, ulshade); + pushbuttonview_FillRectSize(self, Rect.left, Rect.top, bdepth, Rect.height, NULL); /* left bar */ + + pushbuttonview_setShade(self, lrshade); + pushbuttonview_FillRectSize(self, Rect.left + Rect.width - bdepth, Rect.top, bdepth, Rect.height, NULL); /* right bar */ + pushbuttonview_FillTrapezoid(self, Rect2.left, r2_bot, Rect2.width, Rect.left, r_bot, Rect.width, NULL); /* lower trapz */ + + pushbuttonview_setShade(self, ulshade); + pushbuttonview_FillTrapezoid(self, Rect.left, Rect.top, Rect.width, Rect2.left, Rect2.top, Rect2.width, NULL); /* upper trapz */ + + pushbuttonview_setShade(self, 1.0); + + } else { + my_graphic = (struct graphic *)pushbuttonview_GetDrawable(self); + if (!(my_fontdesc = pushbutton_GetButtonFont(b))) { + my_fontdesc= fontdesc_Create(FONT, FONTTYPE, FONTSIZE); + } + if (my_fontdesc) { + pushbuttonview_SetFont(self, my_fontdesc); + my_FontSummary = fontdesc_FontSummary(my_fontdesc, my_graphic); + } + t_op = graphic_BETWEENLEFTANDRIGHT | graphic_ATBASELINE; + text = pushbutton_GetText(b) ? pushbutton_GetText(b) : NO_MSG; + tx = TEXTPAD + (Rect2.left + Rect2.width) / 2; + if (my_FontSummary) + ty = TEXTPAD + (Rect2.top + my_FontSummary->maxHeight - my_FontSummary->maxBelow); + + pushbuttonview_SetTransferMode(self, graphic_WHITE); + pushbuttonview_MoveTo(self, tx, ty); + pushbuttonview_DrawString(self, text, t_op); + } /* MOTIF? */ + + break; + } + } + self->lit = 1; + } + + + static void + UnhighlightButton(self) + struct pushbuttonview *self; + { + struct pushbutton *b = (struct pushbutton *) pushbuttonview_GetDataObject(self); + struct rectangle Rect, Rect2; + int style; + struct fontdesc *my_fontdesc; + struct graphic *my_graphic; + struct FontSummary *my_FontSummary; + int tx, ty; + short t_op; + char *text; + int bdepth, r2_bot, r_bot; + double ulshade, lrshade; + + if (self->lit) { + style = pushbutton_GetStyle(b); + pushbuttonview_GetLogicalBounds(self, &Rect); + + switch (style) { + case pushbutton_PLAIN: + case pushbutton_PLAINBOX: + pushbuttonview_SetTransferMode(self, graphic_INVERT); + pushbuttonview_FillRect(self,&Rect,pushbuttonview_BlackPattern(self)); + break; + + case pushbutton_BOXEDRECT: + /* Rect2 is the inner rect */ + Rect2.top = Rect.top + BUTTONDEPTH; + Rect2.left = Rect.left + BUTTONDEPTH; + Rect2.width = Rect.width - 2*BUTTONDEPTH; + Rect2.height = Rect.height - 2*BUTTONDEPTH; + + pushbuttonview_SetTransferMode(self, graphic_INVERT); + pushbuttonview_FillRect(self, &Rect,pushbuttonview_BlackPattern(self)); + pushbuttonview_FillRect(self, &Rect2,pushbuttonview_BlackPattern(self)); + + break; + case pushbutton_ROUNDRECT: + /* Rect2 is the inner rect for DrawRRect */ + Rect2.top = Rect.top; + Rect2.left = Rect.left; + Rect2.height = BUTTONDEPTH; + Rect2.width = BUTTONDEPTH; + Rect.width -= 1; + Rect.height -= BUTTONDEPTH; + + pushbuttonview_SetTransferMode(self, graphic_INVERT); + pushbuttonview_FillRRect(self, &Rect, &Rect2, pushbuttonview_BlackPattern(self)); + + break; + + case pushbutton_MOTIF: + case pushbutton_THREEDEE: + if (style == pushbutton_MOTIF) { + bdepth = MOTIFBUTTONDEPTH; + ulshade = MOTIFULSHADE; + lrshade = MOTIFLRSHADE; + } else { + bdepth = BUTTONDEPTH; + ulshade = ULSHADE; + lrshade = LRSHADE; + } + + + /* Rect2 is the inner (Text) region */ + Rect2.top = Rect.top + bdepth; + Rect2.left = Rect.left + bdepth; + Rect2.width = Rect.width - 2*bdepth; + Rect2.height = Rect.height - 2*bdepth; + r2_bot = (Rect2.top)+(Rect2.height); + r_bot = (Rect.top)+(Rect.height); + + if (style == pushbutton_MOTIF) { + pushbuttonview_SetTransferMode(self, graphic_COPY); + pushbuttonview_setShade(self, ulshade); + pushbuttonview_FillRectSize(self, Rect.left, Rect.top, bdepth, Rect.height, NULL); /* left bar */ + + pushbuttonview_setShade(self, lrshade); + pushbuttonview_FillRectSize(self, Rect.left + Rect.width - bdepth, Rect.top, bdepth, Rect.height, NULL); /* right bar */ + pushbuttonview_FillTrapezoid(self, Rect2.left, r2_bot, Rect2.width, Rect.left, r_bot, Rect.width, NULL); /* lower trapz */ + + pushbuttonview_setShade(self, ulshade); + pushbuttonview_FillTrapezoid(self, Rect.left, Rect.top, Rect.width, Rect2.left, Rect2.top, Rect2.width, NULL); /* upper trapz */ + + pushbuttonview_setShade(self, 1.0); + + } else { + my_graphic = (struct graphic *)pushbuttonview_GetDrawable(self); + if (!(my_fontdesc = pushbutton_GetButtonFont(b))) { + my_fontdesc= fontdesc_Create(FONT, FONTTYPE, FONTSIZE); + } + if (my_fontdesc) { + pushbuttonview_SetFont(self, my_fontdesc); + my_FontSummary = fontdesc_FontSummary(my_fontdesc, my_graphic); + } + t_op = graphic_BETWEENLEFTANDRIGHT | graphic_ATBASELINE; + text = pushbutton_GetText(b) ? pushbutton_GetText(b) : NO_MSG; + tx = TEXTPAD + (Rect2.left + Rect2.width) / 2; + if (my_FontSummary) + ty = TEXTPAD + (Rect2.top + my_FontSummary->maxHeight - my_FontSummary->maxBelow); + + pushbuttonview_SetTransferMode(self, graphic_BLACK); + pushbuttonview_MoveTo(self, tx, ty); + pushbuttonview_DrawString(self, text, t_op); + } /* MOTIF? */ + + break; + } + } + self->lit = 0; + } + + + struct view * + pushbuttonview__Hit(self, action, x, y, numclicks) + struct pushbuttonview *self; + long x, y; + enum view_MouseAction action; + long numclicks; + { + /* + Handle the button event. Currently, semantics are: + + Left Down -- Draw button pressed + Right Down -- select button (Receive input focus, for menuing without activating) + Left Up -- draw button at rest, pull trigger + Right Up -- No Op + Left Movement -- unhighlight if moved off, highlight if moved on + Right Movement -- No Op + */ + struct cursor *wait_cursor; + + switch (action) { + case view_LeftDown: + HighlightButton(self); + pushbuttonview_WantInputFocus(self,self); + break; + case view_LeftMovement: + { + struct rectangle r; + + pushbuttonview_GetVisualBounds(self, &r); + if (RectEnclosesXY(&r, x, y)) + HighlightButton(self); + else + UnhighlightButton(self); + } + break; + case view_LeftUp: + { + short litp = self->lit; + + UnhighlightButton(self); + if (litp) { + if (wait_cursor = cursor_Create(self)) { + cursor_SetStandard(wait_cursor, Cursor_Wait); + im_SetProcessCursor(wait_cursor); + pushbutton_PullTrigger((struct pushbutton *) pushbuttonview_GetDataObject(self), pushedtrigger); + pushbuttonview_PullTrigger(self, pushedtrigger); + im_SetProcessCursor(NULL); + cursor_Destroy(wait_cursor); + } + } + } + break; + case view_RightDown: + pushbuttonview_WantInputFocus(self, self); + break; + } + + return((struct view *)self); + } + + + void + pushbuttonview__ObservedChanged(self, b, v) + struct pushbuttonview *self; + struct pushbutton *b; + long v; + { + super_ObservedChanged(self, b, v); + pushbuttonview_CacheSettings(self, b, 1); + } + + + enum view_DSattributes + pushbuttonview__DesiredSize(self, width, height, pass, desired_width, desired_height) + struct pushbuttonview *self; + long width; + long height; + enum view_DSpass pass; + long *desired_width; + long *desired_height; + { + /* + Tell parent that this object wants to be as big as the box around its + text string. For some reason IM allows resizing of this object. (BUG) + */ + + struct fontdesc *my_fontdesc; + struct FontSummary *my_FontSummary; + struct graphic *my_graphic; + struct pushbutton *b = (struct pushbutton *) pushbuttonview_GetDataObject(self); + int style; + + style = pushbutton_GetStyle(b); + + my_graphic = (struct graphic *)pushbuttonview_GetDrawable(self); + if (!(my_fontdesc = pushbutton_GetButtonFont(b))) { + my_fontdesc= fontdesc_Create(FONT, FONTTYPE, FONTSIZE); + } + if (my_fontdesc) { + fontdesc_StringSize(my_fontdesc, my_graphic, pushbutton_GetText(b) ? pushbutton_GetText(b) : NO_MSG, desired_width, desired_height); + my_FontSummary = fontdesc_FontSummary(my_fontdesc, my_graphic); + } + + switch (style) { + case pushbutton_PLAIN: + case pushbutton_PLAINBOX: + if (my_FontSummary) + *desired_height = my_FontSummary->maxHeight; + break; + case pushbutton_MOTIF: + *desired_width = *desired_width + 2*TEXTPAD + 2*MOTIFBUTTONDEPTH; + if (my_FontSummary) + *desired_height = my_FontSummary->maxHeight + 2*TEXTPAD + 2*MOTIFBUTTONDEPTH; + break; + case pushbutton_BOXEDRECT: + case pushbutton_ROUNDRECT: + case pushbutton_THREEDEE: + *desired_width = *desired_width + 2*TEXTPAD + 2*BUTTONDEPTH; + if (my_FontSummary) + *desired_height = my_FontSummary->maxHeight + 2*TEXTPAD + 2*BUTTONDEPTH; + break; + } + + /* + (BUG) I don't check to see if I can specify a size, I just do it. + Will this break things? What if I can't change my size? Will I be + Ugly? What to do, what to do.... + */ + + return(view_Fixed); /* (BUG) should disable user sizing, but this doesn't */ + } + + + void + pushbuttonview__GetOrigin(self, width, height, originX, originY) + struct pushbuttonview *self; + long width, height; + long *originX, *originY; + { + /* + We want this object to sit in-line with text, not below the baseline. + Simply, we could negate the height as the originX, but then our + text would be too high. So, instead, we use the height of + our font above the baseline + */ + + struct FontSummary *my_FontSummary; + struct fontdesc *my_fontdesc; + struct graphic *my_graphic; + struct pushbutton *b = (struct pushbutton *) pushbuttonview_GetDataObject(self); + int style; + + style = pushbutton_GetStyle(b); + + my_graphic = (struct graphic *)pushbuttonview_GetDrawable(self); + if (!(my_fontdesc = pushbutton_GetButtonFont(b))) { + my_fontdesc= fontdesc_Create(FONT, FONTTYPE, FONTSIZE); + } + if (my_fontdesc) { + my_FontSummary = fontdesc_FontSummary(my_fontdesc, my_graphic); + } + + *originX = 0; + switch (style) { + case pushbutton_PLAIN: + case pushbutton_PLAINBOX: + if (my_FontSummary) + *originY = (my_FontSummary->maxHeight) - (my_FontSummary->maxBelow) + 1; + break; + case pushbutton_MOTIF: + if (my_FontSummary) + *originY = (my_FontSummary->maxHeight) - (my_FontSummary->maxBelow) + 1 + TEXTPAD + MOTIFBUTTONDEPTH; + break; + case pushbutton_BOXEDRECT: + case pushbutton_ROUNDRECT: + case pushbutton_THREEDEE: + if (my_FontSummary) + *originY = (my_FontSummary->maxHeight) - (my_FontSummary->maxBelow) + 1 + TEXTPAD + BUTTONDEPTH; + break; + } + return; + } + + + static void + LabelProc(self, param) + struct pushbuttonview *self; + long param; + { + /* + This is the routine which asks the user for a new text label. + (BUG) Should not allow newlines (or should it?) + */ + + char buf[MAXPATHLEN]; + struct pushbutton *b = (struct pushbutton *)pushbuttonview_GetDataObject(self); + char *oldtext; + + oldtext = pushbutton_GetText(b); + if (message_AskForString(self,50,"Enter new text for button: ", + oldtext, buf, sizeof(buf)) >= 0) { + pushbutton_SetText(b, buf); + message_DisplayString(self, 10, "Changed button text."); + } + } + + + static void + FontProc(self, param) + struct pushbuttonview *self; + long param; + { + /* + This is the routine which asks the user for a new font. + It sucks, but I don't know how to smoothly integrate this button + with a textview-like font change. Oh well. + */ + + char buf[MAXPATHLEN], name[MAXPATHLEN]; + long style, size; + struct pushbutton *b = (struct pushbutton *)pushbuttonview_GetDataObject(self); + struct fontdesc *fd; + + if (message_AskForString(self,50,"Enter new fontname for pushbutton: ", PROMPTFONT, buf, sizeof(buf)) >= 0) { + if (!fontdesc_ExplodeFontName(buf, name, sizeof(name), &style, &size)) { + message_DisplayString(self, 50, "Couldn't parse fontname."); + return; + } + if ((fd = fontdesc_Create(name,style,size))!=NULL) { + pushbutton_SetButtonFont(b, fd); + message_DisplayString(self, 10, "Changed font."); + } else { + message_DisplayString(self, 50, "Font change failed. Using old font."); + } + } + } + + + static void + StyleProc(self, param) + struct pushbuttonview *self; + long param; + { + /* + This is the routine which asks the user for a new pushbutton appearance. + */ + + struct pushbutton *b = (struct pushbutton *)pushbuttonview_GetDataObject(self); + static char *style_menu[] = { + "Plain Text", + "Boxed Text", + "Three Dimensional", + #ifndef NOROUNDRECT + "Rounded Rect", + #endif + "Simple Boxed Text", + "OSF/Motif", + NULL + }; + int choice; + + if (message_MultipleChoiceQuestion(self,99,"Pick a new style:", pushbutton_GetStyle(b), &choice, style_menu, NULL)>= 0) { + #ifdef NOROUNDRECT + if (choice >= pushbutton_ROUNDRECT) { + choice++; + } + #endif + pushbutton_SetStyle(b, choice); + message_DisplayString(self, 10, "Changed button style."); + } else { + message_DisplayString(self, 10, "Choice cancelled."); + } + } + + + static void + ColorProc(self, param) + struct pushbuttonview *self; + long param; + { + /* + This is the routine which asks the user for a new pushbutton colors. + */ + + char buf[MAXPATHLEN], rgb_buf[10]; + struct pushbutton *b = (struct pushbutton *)pushbuttonview_GetDataObject(self); + char *oldcolor; + unsigned char rgb[3]; + + oldcolor = pushbutton_GetFGColor(b, rgb); + if (oldcolor == NULL) { + sprintf(rgb_buf, "0x%02x%02x%02x", rgb[0], rgb[1], rgb[2]); + oldcolor = rgb_buf; + } + if (message_AskForString(self,50,"Enter new foreground color for button: ", oldcolor, buf, sizeof(buf)) >= 0) { + if ((strncmp(buf,"0x",2) != 0) + && (strncmp(buf,"0X",2) != 0)) { + pushbutton_SetFGColor(b, buf, 0, 0, 0); + message_DisplayString(self, 10, "Changed foreground color."); + } else { + pushbutton_ParseRGB(b, buf, rgb); + pushbutton_SetFGColor(b, NULL, rgb[0], rgb[1], rgb[2]); + sprintf(buf, "Changed button foreground color to 0x%x%x%x.", rgb[0], rgb[1], rgb[2]); + message_DisplayString(self, 10, buf); + } + } + + oldcolor = pushbutton_GetBGColor(b, rgb); + if (oldcolor == NULL) { + sprintf(rgb_buf, "0x%02x%02x%02x", rgb[0], rgb[1], rgb[2]); + oldcolor = rgb_buf; + } + if (message_AskForString(self,50,"Enter new background color for button: ", oldcolor, buf, sizeof(buf)) >= 0) { + if ((strncmp(buf,"0x",2) != 0) + && (strncmp(buf,"0X",2) != 0)) { + pushbutton_SetBGColor(b, buf, 0, 0, 0); + message_DisplayString(self, 10, "Changed background color."); + } else { + pushbutton_ParseRGB(b, buf, rgb); + pushbutton_SetBGColor(b, NULL, rgb[0], rgb[1], rgb[2]); + sprintf(buf, "Changed button background color to 0x%x%x%x.", rgb[0], rgb[1], rgb[2]); + message_DisplayString(self, 10, buf); + } + } + } + + + void pushbuttonview__WantUpdate(self, requestor) + struct pushbuttonview *self; + struct view *requestor; + { + if ((struct view *) self == requestor) { + if (self->awaitingUpdate) { + return; + } + self->awaitingUpdate = TRUE; + } + super_WantUpdate(self, requestor); + } /* pushbuttonview__WantUpdate */ *** atk/hyplink/pshbttn.help Sun May 12 21:12:32 1991 --- atk/hyplink/pshbttn.help.NEW Wed Feb 13 16:52:05 1991 *************** *** 0 **** --- 1,89 ---- + \begindata{text,268704672} + \textdsversion{12} + \template{help} + \chapter{Pushbutton Inset: A Triggering Mechanism + + } + \section{What Pushbutton is + + }\leftindent{ + The \bold{Pushbutton} inset is a button that resides in the text of a + document. It can be used by Ness or Class applications, since it defines a + trigger, or subclassed, to produce button-like insets that perform various + actions. + + } + \section{Using Pushbutton + + }\leftindent{ + The best way to insert a Pushbutton is with the \italic{Arbcon} object. Add + the pushbutton object to the list of known Arbcon objects, create one, give it + a name, then paste it into your document. Using Ness, you can then extend the + pushbutton like this: + + + \leftindent{extend "\italic{yourbuttonname}" + + on event "buttonpushed" + + -- your Ness code here + + end event + + end extend + + } + Where "yourbuttonname" is the name you gave the button in the Arbcon. + + } + \section{Can I change the way it looks? + + } + \leftindent{There is a preference option, the \typewriter{pushbuttonstyle}, + which you can adjust so that your pushbuttons will look different. Please see + the help document on preferences for more information. You can also change + the style, label and colors by calling the \typewriter{pushbutton_SetStyle}, + \typewriter{pushbutton_SetText, pushbutton_SetFGColor }or\typewriter{ + pushbuttonSetBGColor } methods from Ness or Class. + + + Furthermore, there is a user interface to these features, on the "Pushbutton" + menu card. The menus are bound as: + + \begindata{table,268946644} + \cols 121 247 + - - + | ^Menu Name | ^Proctable Entry | + - - + | "Set Label | 'pushbuttonview-set-label-text | + | "Set Font | 'pushbuttonview-set-font | + | "Set Style | 'pushbuttonview-set-style | + | "Set Color | 'pushbuttonview-set-color | + - - + \enddata{table,268946644} + \view{spread,268946644,0,0,0} + + } + \section{Program Author} + + \leftindent{ + Michael McInerny, ITC (address mail to mcinerny+@andrew.cmu.edu).} + + + \section{Related tools} + + + Select (highlight) one of the italicized names and choose "Show Help on + Selected Word" from the pop-up menu to see the help file for: + + + \leftindent{\italic{insets + + ez + + arbcon + + ness + + } + }\enddata{text,268704672} *** atk/hyplink/pshbttnv.ch Thu May 30 19:54:26 1991 --- atk/hyplink/pshbttnv.ch.NEW Thu Mar 28 09:36:35 1991 *************** *** 0 **** --- 1,37 ---- + /* ********************************************************************** *\ + * Copyright IBM Corporation 1989 - All Rights Reserved * + * For full copyright information see:'andrew/config/COPYRITE' * + \* ********************************************************************** */ + + /* + Trigger: "buttonpushed" + called when the user lets up on the pushbutton over the pushbutton. + + */ + + class pushbuttonview[pshbttnv]: view { + classprocedures: + InitializeClass() returns boolean; + InitializeObject(struct pushbuttonview *self) returns boolean; + FinalizeObject(struct pushbuttonview *self); + overrides: + ObservedChanged (struct observable *changed, long value); + DesiredSize(long width, long height, enum view_DSpass pass, long * desired_width, long * desired_height) returns enum view_DSattributes; + GetOrigin(long width, long height, long * originX, long * originY); + FullUpdate(enum view_UpdateType type, long left, long top, long width, long height); + Update(); + Hit (enum view_MouseAction action, long x, long y, long numberOfClicks) returns struct view *; + LinkTree(struct view *parent); + PostMenus(struct menulist *ml); + WantUpdate(struct view *requestor); + data: + short lit; + struct cursor *cursor; + double foreground_color[3], background_color[3]; + char *cached_label; + int cached_style; + struct fontdesc *cached_fontdesc; + struct menulist *ml; + int awaitingUpdate; + }; + *** atk/layout/box.c Thu Jan 10 14:57:53 1991 --- atk/layout/box.c.NEW Thu Jan 10 13:26:44 1991 *************** *** 2,13 **** * Copyright IBM Corporation 1988,1990 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/layout/RCS/box.c,v 1.2 90/12/13 11:07:18 jhh Exp $ */ /* $ACIS$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/layout/RCS/box.c,v $ */ #ifndef lint ! char *box_rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/layout/RCS/box.c,v 1.2 90/12/13 11:07:18 jhh Exp $"; #endif /* lint */ #include --- 2,13 ---- * Copyright IBM Corporation 1988,1990 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/layout/RCS/box.c,v 1.3 91/01/10 13:09:56 gk5g Exp $ */ /* $ACIS$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/layout/RCS/box.c,v $ */ #ifndef lint ! char *box_rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/layout/RCS/box.c,v 1.3 91/01/10 13:09:56 gk5g Exp $"; #endif /* lint */ #include *************** *** 23,29 **** --- 23,31 ---- #include + #ifndef _IBMR2 extern char * malloc (); + #endif /* _IBMR2 */ #define classname(do) ((do) == NULL ? "" : class_GetTypeName(do)) #define safename(c) ((c) == NULL ? "" : classname(c->data)) *** atk/layout/boxview.c Thu Jan 10 14:57:56 1991 --- atk/layout/boxview.c.NEW Thu Jan 10 13:26:46 1991 *************** *** 2,19 **** * Copyright IBM Corporation 1988,1990 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/layout/RCS/boxview.c,v 1.1 90/08/02 14:55:30 jhh Exp $ */ /* $ACIS$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/layout/RCS/boxview.c,v $ */ #ifndef lint ! char *boxv_rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/layout/RCS/boxview.c,v 1.1 90/08/02 14:55:30 jhh Exp $"; #endif /* lint */ #define viewname(v) ((v) == NULL ? "" : atom_Name(atomlist_First(view_GetName(v)))) #define classname(do) ((do) == NULL ? "" : class_GetTypeName(do)) extern char *malloc(); #include #include --- 2,21 ---- * Copyright IBM Corporation 1988,1990 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/layout/RCS/boxview.c,v 1.2 91/01/10 13:10:01 gk5g Exp $ */ /* $ACIS$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/layout/RCS/boxview.c,v $ */ #ifndef lint ! char *boxv_rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/layout/RCS/boxview.c,v 1.2 91/01/10 13:10:01 gk5g Exp $"; #endif /* lint */ #define viewname(v) ((v) == NULL ? "" : atom_Name(atomlist_First(view_GetName(v)))) #define classname(do) ((do) == NULL ? "" : class_GetTypeName(do)) + #ifndef _IBMR2 extern char *malloc(); + #endif /* _IBMR2 */ #include #include *** atk/layout/fillerv.c Fri Dec 21 14:55:23 1990 --- atk/layout/fillerv.c.NEW Thu Jan 10 13:26:47 1991 *************** *** 2,13 **** * Copyright IBM Corporation 1988,1990 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/layout/RCS/fillerv.c,v 1.2 90/10/03 15:02:15 jhh Exp $ */ /* $ACIS$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/layout/RCS/fillerv.c,v $ */ #ifndef lint ! char *fillerv_rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/layout/RCS/fillerv.c,v 1.2 90/10/03 15:02:15 jhh Exp $"; #endif /* lint */ #define fillerview_MINIMUMSIZE 100 --- 2,13 ---- * Copyright IBM Corporation 1988,1990 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/layout/RCS/fillerv.c,v 1.3 91/01/10 13:10:09 gk5g Exp $ */ /* $ACIS$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/layout/RCS/fillerv.c,v $ */ #ifndef lint ! char *fillerv_rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/layout/RCS/fillerv.c,v 1.3 91/01/10 13:10:09 gk5g Exp $"; #endif /* lint */ #define fillerview_MINIMUMSIZE 100 *************** *** 16,23 **** --- 16,25 ---- #define viewnamestring(v) ((v) == NULL ? "" : atom_Name(atomlist_First(view_GetName(v)))) + #ifndef _IBMR2 extern char *malloc(); extern char *realloc(); + #endif /* _IBMR2 */ #include #include *** atk/layout/layout.c Fri Dec 21 14:55:25 1990 --- atk/layout/layout.c.NEW Thu Jan 10 13:26:43 1991 *************** *** 2,20 **** * Copyright IBM Corporation 1988,1990 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/layout/RCS/layout.c,v 1.2 90/10/10 17:05:32 jhh Exp $ */ /* $ACIS$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/layout/RCS/layout.c,v $ */ #ifndef lint ! char *layout_rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/layout/RCS/layout.c,v 1.2 90/10/10 17:05:32 jhh Exp $"; #endif /* lint */ #include #include #include - #include #include #include #include --- 2,20 ---- * Copyright IBM Corporation 1988,1990 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/layout/RCS/layout.c,v 1.5 91/01/10 13:09:17 gk5g Exp $ */ /* $ACIS$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/layout/RCS/layout.c,v $ */ #ifndef lint ! char *layout_rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/layout/RCS/layout.c,v 1.5 91/01/10 13:09:17 gk5g Exp $"; #endif /* lint */ + #include #include #include #include #include #include #include *************** *** 22,28 **** --- 22,30 ---- #include + #ifndef _IBMR2 extern char * malloc (); + #endif /* _IBMR2 */ #define classname(do) ((do) == NULL ? "" : class_GetTypeName(do)) #define safename(c) ((c) == NULL ? "" : classname(cData(c))) *************** *** 192,200 **** static long /* returns read error status */ ! readASCII(self, f) struct layout *self; FILE *f; /* input file */ { int ch; struct component *c; --- 194,203 ---- static long /* returns read error status */ ! readASCII(self, f, id) struct layout *self; FILE *f; /* input file */ + long id; /* unique identifier in data stream */ { int ch; struct component *c; *************** *** 286,295 **** break; case '\\': /* enddata coming */ ! if (fscanf(f, "enddata{layout,%ld}\n", &uniqueID) != 1) { objectto(f, "layout: expected enddata or another component"); return dataobject_BADFORMAT; } return dataobject_NOREADERROR; default: --- 289,306 ---- break; case '\\': /* enddata coming */ ! if (fscanf(f, "enddata{%255[^,}\n],%ld}\n", dataname, &uniqueID) != 2) { objectto(f, "layout: expected enddata or another component"); return dataobject_BADFORMAT; } + else if (strncmp(dataname, class_GetTypeName(self)) != 0) { + objectto(f, "layout: wrong data name in enddata"); + return dataobject_BADFORMAT; + } + else if (uniqueID != id) { + objectto(f, "layout: wrong unique ID in enddata"); + return dataobject_BADFORMAT; + } return dataobject_NOREADERROR; default: *************** *** 319,325 **** layout_SetID(self, layout_UniqueID(self)); layout_SetModified(self); ! rc = readASCII(self, f); layout_NotifyObservers(self, observable_OBJECTCHANGED); if (debug) printf("layout_Read rc = %d\n", rc); --- 330,336 ---- layout_SetID(self, layout_UniqueID(self)); layout_SetModified(self); ! rc = readASCII(self, f, id); layout_NotifyObservers(self, observable_OBJECTCHANGED); if (debug) printf("layout_Read rc = %d\n", rc); *** atk/layout/layoutv.c Fri Dec 21 14:55:28 1990 --- atk/layout/layoutv.c.NEW Thu Jan 10 13:26:49 1991 *************** *** 2,13 **** * Copyright IBM Corporation 1988,1990 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/layout/RCS/layoutv.c,v 1.4 90/10/10 17:06:10 jhh Exp $ */ /* $ACIS$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/layout/RCS/layoutv.c,v $ */ #ifndef lint ! char *layoutv_rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/layout/RCS/layoutv.c,v 1.4 90/10/10 17:06:10 jhh Exp $"; #endif /* lint */ #define layoutview_MINIMUMSIZE 100 --- 2,13 ---- * Copyright IBM Corporation 1988,1990 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/layout/RCS/layoutv.c,v 1.5 91/01/10 13:10:13 gk5g Exp $ */ /* $ACIS$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/layout/RCS/layoutv.c,v $ */ #ifndef lint ! char *layoutv_rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/layout/RCS/layoutv.c,v 1.5 91/01/10 13:10:13 gk5g Exp $"; #endif /* lint */ #define layoutview_MINIMUMSIZE 100 *************** *** 15,21 **** --- 15,23 ---- #define viewname(v) ((v) == NULL ? "" : atom_Name(atomlist_First(view_GetName(v)))) + #ifndef _IBMR2 extern char *malloc(); + #endif /* _IBMR2 */ #include #include *** atk/lookz/Imakefile Fri Dec 21 14:26:17 1990 --- atk/lookz/Imakefile.NEW Fri Dec 14 16:51:35 1990 *************** *** 2,9 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! DOBJS = lookz.do lookzv.do ! IHFILES = lookz.ih lookzv.ih NormalObjectRule() NormalATKRule() --- 2,9 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! DOBJS = tabrulv.do lookz.do lookzv.do ! IHFILES = tabrulv.ih lookz.ih lookzv.ih NormalObjectRule() NormalATKRule() *** atk/lookz/lookz.help Fri Dec 21 14:26:24 1990 --- atk/lookz/lookz.help.NEW Fri Jun 14 12:13:09 1991 *************** *** 1,4 **** ! \begindata{text,268624292} \textdsversion{12} \template{help} --- 1,4 ---- ! \begindata{text,269831612} \textdsversion{12} \template{help} *************** *** 25,30 **** --- 25,35 ---- styles for each document that you write. + It is also possible to use LookZ to create and edit templates, which can be + used to establish styles and style changes for a whole series of documents. + See the \italic{templates} help document for more information. + + \flushleft{\bold{Note: }}You cannot use LookZ to add styles to selected pieces of text. To do that, you must use EZ. For details about using styles to format text, see the \italic{ez} or \italic{styles} help documents. *************** *** 33,39 **** This help document is composed of the following sections: }\leftindent{\leftindent{ ! Enabling and Starting LookZ Changing style attributes --- 38,44 ---- This help document is composed of the following sections: }\leftindent{\leftindent{ ! Starting LookZ Changing style attributes *************** *** 50,93 **** Related Tools } ! }\section{Enabling LookZ} ! ! \leftindent{ ! Before you start Lookz for the first time, you must add a new menu option to ! your EZ menus. You can do this by editing a file called .ezinit in your home ! directory and copying the following lines into it: ! ! ! #Add a "Customizing Styles" menu option to the File Menu ! ! addmenu textview-edit-styles "File,Customize Styles~30" ! ! ! The first line, starting with a #, is a comment. The second line is a command ! for the EZ text view that tells it to add a menu option called "Customize ! Styles" on the File menu card. This new menu option will appear the next time ! you start EZ. ! ! ! \bold{Note:} Read the \italic{ initfiles }help document if you have never ! used an .ezinit file before. ! ! } ! \section{Starting Lookz} \leftindent{ To start Lookz, place the text caret in the text of your EZ document. Then, ! choose the \bold{Customize Styles} menu option from the \italic{File} menu ! card in EZ. \bold{Parts of LookZ. } LookZ appears as a rectangle that contains a series of boxes. There are three boxes in the top row. The small box on the left ! contains the shrink-icon. To shrink LookZ, click on the shrink icon with the ! left mouse button; to reexpose it, click again. If you click outside the ! shrink icon to continue working in your text, the shrink-icon changes to a ! Kilroy (a face peering over the a wall). The Kilroy indicates that a LookZ ! has been opened, but is not currently being used. --- 55,71 ---- Related Tools } ! }\section{Starting Lookz} \leftindent{ To start Lookz, place the text caret in the text of your EZ document. Then, ! choose the \bold{Edit Styles} menu option from the \italic{File} menu card in ! EZ. \bold{Parts of LookZ. } LookZ appears as a rectangle that contains a series of boxes. There are three boxes in the top row. The small box on the left ! contains the icon. *************** *** 96,102 **** a menu card, the name is darkened and the styles contained on that menu card are displayed in the right box. For example, you can click on "Title" to see the styles listed in the Title menu card. These include Chapter, Section, ! Paragraph, and other styles. The right box, \bold{name on menu card}, lets you choose a particular style --- 74,81 ---- a menu card, the name is darkened and the styles contained on that menu card are displayed in the right box. For example, you can click on "Title" to see the styles listed in the Title menu card. These include Chapter, Section, ! Paragraph, and other styles. Use the option to edit the default ! styles in your document. The right box, \bold{name on menu card}, lets you choose a particular style *************** *** 104,110 **** the styles displayed here, its attributes are displayed in the bottom three rows of boxes. The attributes that apply to the style are darkened. For example, you can click on "Section" to display the attributes for the Section ! style, which include Bold, Left flush, and +2. } \section{Changing style attributes} --- 83,94 ---- the styles displayed here, its attributes are displayed in the bottom three rows of boxes. The attributes that apply to the style are darkened. For example, you can click on "Section" to display the attributes for the Section ! style, which include Bold, Left flush, and +2. ! ! ! The "global" style under the menu card controls the overall style of ! a document. By changing it, you can readily change your entire document to use ! a different font, be double-spaced, or to have different margins.} \section{Changing style attributes} *************** *** 176,181 **** --- 160,171 ---- EZ to other formatting systems, such as troff.} + \leftindent{TabsCharacters specifies that tabs should be represented by the + ``character'' model. This means that tab stops will be found every 8 space + characters, instead of found by moving a particular distance. This is useful + to be enabled when using Fixed Width. + + } \bold{justify} contains attributes for justification of a style. The following options are available: *************** *** 202,207 **** --- 192,204 ---- right. } + \bold{line (and paragraph) spacing} are the number of extra points to be left + between lines (and paragraphs). + + + \bold{color} is the color in which the text should be displayed. + + \bold{baseline} contains attributes for raising and lowering scripted text from the normal baseline of the document. Use these attributes to make superscripts and subscripts. *************** *** 226,231 **** --- 223,263 ---- to use a paragraph indent and a left margin at the same time. Note that when you move the left margin, the paragraph indent moves too. + + \bold{tab stops} contains a ruler for the width of the page, showing where all + the tab stops are for the selected style. Tab stops are represented by a + small downward-pointing arrow. To change the tab stops for a style, simply + drag the arrows around with the left mouse button. Upon releasing the button, + the tab stop will be set at that location. By default, the tab stops are every + \^{=}" across the page. + + + To add a new tab stop, click with the left mouse button on the arrow which is + inside the shaded area. The arrow will move up to the top left of the ruler + and you can then drag it to the location you desire. To remove a tab stop, + click with the right mouse button on the stop you wish to remove. + + + There are three ``whirlwind'' icons at the bottom of the ruler: the leftmost + icon allows you to change the current units of measurement, in the same + fashion as used for the indentation ruler. + + + The middle icon, labelled ``AllClear'', will mark this style as clearing all + tabs. Note: Any tab changes you perform are recorded \italic{in the order} in + which you do them. So making a lot of tab changes and then recording an + ``AllClear'' would be pretty pointless - all the changes before the AllClear + would be cancelled. + + + The rightmost icon, labelled ``Cancel'' will cancel all the changes which you + have done to the tabs. + + + When the character-model of tabs is enabled from the attributes section, then + although the tab stops will still be shown and can be edited, they will not be + used to find tab positions when drawing text in that style. + } \section{Adding styles to your menus} *************** *** 300,308 **** Because some of the screen display fonts differ in size by four points instead of two, something made bigger or smaller by only 2 points may not necessarily appear that way on the screen. Previewing or printing the document should ! achieve the desired result, though.}\bold{ ! } \section{Pop-Up Menu Meanings} --- 332,348 ---- Because some of the screen display fonts differ in size by four points instead of two, something made bigger or smaller by only 2 points may not necessarily appear that way on the screen. Previewing or printing the document should ! achieve the desired result, though.} ! ! \leftindent{Because of the differences between the fonts displayed on the ! screen, and those printed out on paper, you may find that a table created ! using tab stops does not come out correctly when printed. As far as possible, ! we have tried to maintain the correct proportions when printing tabs, but be ! aware that it is not always correct (especially when using larger fonts). If ! you really want to create a table, you should use a table inset.\bold{ ! ! }} \section{Pop-Up Menu Meanings} *************** *** 327,333 **** \leftindent{Fred Hansen}\leftindent{ ! } \section{Related tools} --- 367,375 ---- \leftindent{Fred Hansen}\leftindent{ ! }\leftindent{Tabs by Nick Williams} (njw@athena.mit.edu) ! ! \section{Related tools} *************** *** 337,346 **** \leftindent{\italic{ez ! styles} ! } ! \leftindent{ ! } ! \enddata{text,268624292} --- 379,391 ---- \leftindent{\italic{ez ! \italic{compchar }}(for international characters)\italic{\italic{ ! header }}(for page headers, footers, and numbering)\italic{\italic{ ! }styles} ! ! }\italic{\leftindent{table}} ! ! ! \enddata{text,269831612} *** atk/lookz/lookz.c Wed Nov 22 12:15:42 1989 --- atk/lookz/lookz.c.NEW Mon Mar 4 13:35:43 1991 *************** *** 2,13 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/lookz/RCS/lookz.c,v 2.6 89/04/04 19:52:53 wjh Exp $ */ /* $ACIS:lookz.c 1.2$ */ ! /* $Source: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/lookz/RCS/lookz.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/lookz/RCS/lookz.c,v 2.6 89/04/04 19:52:53 wjh Exp $"; #endif /* lint */ --- 2,13 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/lookz/RCS/lookz.c,v 2.9 91/02/25 18:27:29 gk5g Exp $ */ /* $ACIS:lookz.c 1.2$ */ ! /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/lookz/RCS/lookz.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/lookz/RCS/lookz.c,v 2.9 91/02/25 18:27:29 gk5g Exp $"; #endif /* lint */ *************** *** 18,23 **** --- 18,24 ---- #include #include /* for dataobject_NOREADERROR */ + #include #include #define MAXFILELINE 255 *************** *** 24,41 **** boolean lookz__InitializeObject(ClassID, self) ! struct classhdr *ClassID; register struct lookz *self; { self->visible = TRUE; return TRUE; } void lookz__FinalizeObject(ClassID, self) ! struct classhdr *ClassID; register struct lookz *self; { } long --- 25,48 ---- boolean lookz__InitializeObject(ClassID, self) ! struct classheader *ClassID; register struct lookz *self; { self->visible = TRUE; + self->canClose = TRUE; + self->text = NULL; return TRUE; } void lookz__FinalizeObject(ClassID, self) ! struct classheader *ClassID; register struct lookz *self; { + if(self->text != NULL) { + text_RemoveObserver(self->text, self); + self->text = NULL; + } } long *************** *** 97,105 **** { /* this routine ensures that self->visible will be either TRUE or FALSE */ if (self->visible != (visibility ? TRUE : FALSE)) { - lookz_NotifyObservers(self, lookz_VISIBILITYCHANGED); self->visible = (visibility ? TRUE : FALSE); } } --- 104,152 ---- { /* this routine ensures that self->visible will be either TRUE or FALSE */ if (self->visible != (visibility ? TRUE : FALSE)) { self->visible = (visibility ? TRUE : FALSE); + lookz_NotifyObservers(self, lookz_VISIBILITYCHANGED); + } + } + + void lookz__SetCanClose(self, canClose) + struct lookz *self; + boolean canClose; + { + if (self->canClose != canClose) { + self->canClose = canClose; + lookz_SetVisibility(self, TRUE); + lookz_NotifyObservers(self, lookz_CANCLOSECHANGED); + } + } + + void lookz__SetTextObject(self, text) + struct lookz *self; + struct text *text; + { + if (self->text != text) { + if (self->text != NULL) { + text_RemoveObserver(self->text, self); } + self->text = text; + if (text != NULL) { + text_AddObserver(text, self); + } + lookz_NotifyObservers(self, lookz_TEXTOBJECTCHANGED); + } } + void lookz__ObservedChanged(self, dobj, value) + struct lookz *self; + struct dataobject *dobj; + long value; + { + if (value == observable_OBJECTDESTROYED && + (struct dataobject *) self->text == dobj) { + text_RemoveObserver(self->text, self); + self->text = NULL; + lookz_NotifyObservers(self, lookz_TEXTOBJECTCHANGED); + } + } + *** atk/lookz/lookz.ch Wed Nov 22 12:15:36 1989 --- atk/lookz/lookz.ch.NEW Fri Dec 14 16:51:37 1990 *************** *** 2,13 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/lookz/RCS/lookz.ch,v 2.6 89/04/04 19:53:03 wjh Exp $ */ /* $ACIS:lookz.ch 1.2$ */ ! /* $Source: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/lookz/RCS/lookz.ch,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsidlookz_H = "$Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/lookz/RCS/lookz.ch,v 2.6 89/04/04 19:53:03 wjh Exp $"; #endif /* !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) */ /* --- 2,13 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/lookz/RCS/lookz.ch,v 2.7 90/12/14 15:08:04 ajp Exp $ */ /* $ACIS:lookz.ch 1.2$ */ ! /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/lookz/RCS/lookz.ch,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsidlookz_H = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/lookz/RCS/lookz.ch,v 2.7 90/12/14 15:08:04 ajp Exp $"; #endif /* !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) */ /* *************** *** 28,33 **** --- 28,35 ---- /* status values for NotifyObservers */ #define lookz_VISIBILITYCHANGED 1 + #define lookz_CANCLOSECHANGED 2 + #define lookz_TEXTOBJECTCHANGED 4 class lookz : dataobject[dataobj] { *************** *** 36,49 **** Read( /* struct lookz *self, */ FILE *file, long id ) returns long; Write( /* struct lookz *self, */ FILE *file, long id, long level ) returns long; methods: ! SetVisibility( /* struct lookz *self, */ boolean visible ); macromethods: GetVisibility( /* struct lookz *self */ ) (((struct lookz *)self)->visible + 0) classprocedures: InitializeObject(/* struct classhdr *ClassID;*/ struct lookz *self) returns boolean; --- 38,56 ---- Read( /* struct lookz *self, */ FILE *file, long id ) returns long; Write( /* struct lookz *self, */ FILE *file, long id, long level ) returns long; + ObservedChanged(/* struct lookzview *self, */ struct dataobject *dobj, long status); methods: ! SetVisibility( /* struct lookz *self, */ boolean visible ); ! SetTextObject(struct text *text); ! SetCanClose(boolean canClose); macromethods: GetVisibility( /* struct lookz *self */ ) (((struct lookz *)self)->visible + 0) + GetCanClose() (self->canClose) + GetTextObject() (self->text) classprocedures: InitializeObject(/* struct classhdr *ClassID;*/ struct lookz *self) returns boolean; *************** *** 56,60 **** --- 63,69 ---- this field is constrained to be TRUE or FALSE */ + boolean canClose; + struct text *text; }; *** atk/lookz/tabrulv.ch Sun May 12 21:20:41 1991 --- atk/lookz/tabrulv.ch.NEW Fri Dec 14 16:51:55 1990 *************** *** 0 **** --- 1,57 ---- + + #define tabrulerview_PROGRAMMERVERSION 1 + + #define tabrulerview_NoValue (-999<<16) + + class tabrulerview[tabrulv] : view { + overrides: + FullUpdate( enum view_UpdateType type, + long left, long top, long width, long height ); + Update(); + Hit( enum view_MouseAction action, long x, long y, long n) + returns struct view *; + DesiredSize( long width, long height, enum view_DSpass pass, + long *desiredWidth, long *desiredHeight ) + returns enum view_DSattributes; + + methods: + SetValues(/* struct tabrulerview *self, */ struct tabs *tabs); + GetValues(/* struct tabrulerview *self, */ struct tabs **tabs); + macromethods: + SetValueChangeProc(proc, rock) /* store a proc to call when a value changes */ \ + (self->ValueChangeRock = (long)rock, \ + self->ValueChangeProc = (void (*)())proc) + classprocedures: + InitializeClass(/* struct classhdr *ClassID*/) returns boolean; + InitializeObject(/* struct classhdr *ClassID;*/ struct tabrulerview *self) returns boolean; + FinalizeObject(/* struct classhdr *ClassID;*/ struct tabrulerview *self); + data: + boolean OnScreen; /* if not view_Removed */ + boolean tabrulerchanged; + boolean iconschanged; + boolean textchanged; /* indicate redraw requirements */ + + /* Image patterns might differ between instances on different displays: */ + struct graphic *Grey25Pattern, *WhitePattern; + + long leftline, rightline, bottomline, topline, textloc; + long cleartxt, canceltxt; /* Where to place the text */ + long clearpos, cancelpos; /* Where to place the button */ + long leftzero; + struct TickTbl *TickTbl; + + void (*ValueChangeProc)(); /* called when a value changes */ + /* ValueChangeProc(tabrulerview, ValueChangeRock, iconcode, newvalue) */ + long ValueChangeRock; /* passed as second arg to ValueChangeProc */ + + enum style_Unit unit; + struct tabs *tabs; + short icony; /* baseline for icons */ + + boolean Moving; + long Movex; + int oldtab; + + int mul; /* Used to scale the ruler to pretend it's real... */ + int div; + }; *** atk/lookz/lookzv.c Fri Dec 21 14:55:40 1990 --- atk/lookz/lookzv.c.NEW Mon Mar 4 13:35:50 1991 *************** *** 2,13 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/lookz/RCS/lookzv.c,v 2.16 90/03/05 16:54:33 gk5g Exp Locker: ajp $ */ /* $ACIS:lookzv.c 1.4$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/lookz/RCS/lookzv.c,v $ */ #ifndef lint ! char *lookzv_rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/lookz/RCS/lookzv.c,v 2.16 90/03/05 16:54:33 gk5g Exp Locker: ajp $"; #endif /* lint */ /* lookzv.c --- 2,13 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/lookz/RCS/lookzv.c,v 2.20 91/02/25 18:15:28 gk5g Exp $ */ /* $ACIS:lookzv.c 1.4$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/lookz/RCS/lookzv.c,v $ */ #ifndef lint ! char *lookzv_rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/lookz/RCS/lookzv.c,v 2.20 91/02/25 18:15:28 gk5g Exp $"; #endif /* lint */ /* lookzv.c *************** *** 39,44 **** --- 39,45 ---- #include #include #include + #include #include #include #include *************** *** 46,51 **** --- 47,53 ---- #include #include #include + #include #include #include *************** *** 52,63 **** #include #include #include #include #include ! #define class_StaticEntriesOnly ! #include /* for face codes */ ! #undef class_StaticEntriesOnly #include #include --- 54,64 ---- #include #include #include + #include #include #include ! #include #include #include *************** *** 65,77 **** --- 66,84 ---- #include #include #include + #include #include + #include + #include + #include + static boolean debug = FALSE; #define DEBUG(s) {if (debug) {printf s ; fflush(stdout);}} #define ENTER(r) DEBUG(("Enter %s(0x%lx)\n", "r", self)) #define LEAVE(r) DEBUG(("Leave %s(0x%lx)\n", "r", self)) + #define NOMENUSTRING "" static void UpdateDocument(), AddStyle(); *************** *** 87,98 **** static struct menulist *MenuList; static struct keymap *Keymap; /* indices into arrays st[] and stv[] */ enum TableNum { TNmenucard, TNstylename, TNfont, TNsize, ! TNmode, TNsubscr, TNenable, TNdisable }; /* set up initial strings for stringtbls. --- 94,114 ---- static struct menulist *MenuList; static struct keymap *Keymap; + static struct fontdesc *StrtblFont; + + struct styleeditorlist { + struct text *text; + struct lookz *lookz; + }; + static struct styleeditorlist *styleEditors = NULL; + static long numStyleEditors = 0; + static long maxStyleEditors = 0; /* indices into arrays st[] and stv[] */ enum TableNum { TNmenucard, TNstylename, TNfont, TNsize, ! TNmode, TNsubscr, TNenable, TNdisable, TNspacing, TNspread, TNcolor }; /* set up initial strings for stringtbls. *************** *** 101,120 **** both must be spelled identically */ static char *Imenucard[] = {"", NULL,}; static char *Istylename[] = {"", NULL,}; ! static char *Ifont[] = {"Andy", "AndySans", "AndyType", NULL,}; ! static char *Isize[] = { ! "-8", "-6", "-4", "-3", "-2", "+2", "+3", "+4", "+6", "+8", ! "7", "8", "9", "10", "11", "12", "14", "16", "18", ! "20", "24", "30", "36", NULL,}; static char *Imode[] = {"Center", "Left flush", "Right flush", "Justified", "Left-right", NULL,}; ! static char *Isubscr[] = {"up 15", "up 6", "up 4", "super (up 2)", ! "sub (down 2)", "down 4", "down 6", NULL,}; ! static char *Ienable[] = {"Bold", "Italic", "Fixed width", "Pass thru", NULL,}; ! static char *Idisable[] = {"Bold", "Italic", "Fixed width", "Pass thru", NULL,}; static char **InitialStrings[]= ! {Imenucard, Istylename, Ifont, Isize, Imode, Isubscr, Ienable, Idisable, NULL,}; struct strTbl {char *str; long val;}; --- 117,136 ---- both must be spelled identically */ static char *Imenucard[] = {"", NULL,}; static char *Istylename[] = {"", NULL,}; ! static char *Ifont[] = {"Andy", "AndySans", "AndyType", "", NULL,}; ! static char *Isize[] = {"-2", "+2", "7", "8", "9", "10", "12", "14", "16", "18", "24", "30", "36", "", NULL,}; static char *Imode[] = {"Center", "Left flush", "Right flush", "Justified", "Left-right", NULL,}; ! static char *Isubscr[] = {"super (up 6)", ! "sub (down 2)", "", NULL,}; ! static char *Ienable[] = {"Bold", "Italic", "Fixed width", "Underline", "Pass thru", "TabsCharacters", NULL,}; ! static char *Idisable[] = {"Bold", "Italic", "Fixed width", "Underline", "Pass thru", "TabsCharacters", NULL,}; ! static char *Ispacing[] = {"0", "2", "4", "6", "8", "10", "12", "", NULL,}; ! static char *Ispread[] = {"0", "2", "4", "6", "8", "10", "12", "14", "16", "18", "20", "", NULL,}; ! static char *Icolor[] = {"Black", "Red", "Green", "Blue", "Magenta", "Cyan", "Yellow", "", NULL,}; static char **InitialStrings[]= ! {Imenucard, Istylename, Ifont, Isize, Imode, Isubscr, Ienable, Idisable, Ispacing, Ispread, Icolor, NULL,}; struct strTbl {char *str; long val;}; *************** *** 146,151 **** --- 162,168 ---- {"NoFill", style_NoFill}, {"KeepPriorNL", style_KeepPriorNL}, {"KeepNextNL", style_KeepNextNL}, + {"TabsCharacters", style_TabsCharacters}, {NULL, 0L}, }; /* map face names to and from face codes*/ *************** *** 292,298 **** register struct lookzview *self; { self->curstyle->template = 0; ! stylesheet_NotifyObservers(self->curss, self); /*BOGUS XXX The protocol for stylesheet observed_changed status is to send the address of the view that caused the change; Thus its own ObservedChanged routine can reject it. */ --- 309,315 ---- register struct lookzview *self; { self->curstyle->template = 0; ! stylesheet_NotifyObservers(self->curss, (long) self); /*BOGUS XXX The protocol for stylesheet observed_changed status is to send the address of the view that caused the change; Thus its own ObservedChanged routine can reject it. */ *************** *** 332,337 **** --- 349,370 ---- ChangeStyle(self); } + static void + TabsValueChanged(rv, self, pos, op, unit) + struct lprrulerview *rv; + register struct lookzview *self; + long pos; + enum style_TabAlignment op; + enum style_Unit unit; + { + if (self->curstyle == NULL) return; + + if (pos == -1) /* Cannot have negative tabstops - this is cancel code */ + style_ClearTabChanges(self->curstyle); + else + style_AddTabChange(self->curstyle, op, pos, unit); + ChangeStyle(self); + } /* SetBitsForCode(code, names, tbl, parity) *************** *** 360,365 **** --- 393,403 ---- { register struct style *style = self->curstyle; register struct stringtbl **st = self->st; + + if (style == NULL) { + return; + } + { /* justification mode */ stringtbl_ClearBits(st[(long)TNmode]); stringtbl_SetBit(st[(long)TNmode], *************** *** 432,437 **** --- 470,521 ---- paraindent = CVFractionalPoints(Operand, Unit); lprrulerview_SetValues(self->rulerview, leftmargin, rightmargin, paraindent); } + { /* Interline/Interparagraph Spacing */ + enum style_SpacingValue Basis; + long Operand; + enum style_Unit Unit; + unsigned char value[100]; + + stringtbl_ClearBits(st[(long)TNspacing]); + style_GetNewInterlineSpacing(style, &Basis, &Operand, &Unit); + if (Basis == style_ConstantSpacing && Unit == style_Points) { + sprintf(value, "%d", Operand); + stringtbl_SetBitOfEntry(st[(long)TNspacing], + stringtbl_AddString(st[(long)TNspacing], + value), 1); + } + stringtbl_ClearBits(st[(long)TNspread]); + style_GetNewInterparagraphSpacing(style, &Basis, &Operand, &Unit); + if (Basis == style_ConstantSpacing && Unit == style_Points) { + sprintf(value, "%d", Operand); + stringtbl_SetBitOfEntry(st[(long)TNspread], + stringtbl_AddString(st[(long)TNspread], + value), 1); + } + } + { /* Color */ + char *color; + + stringtbl_ClearBits(st[(long) TNcolor]); + if( ( color = style_GetAttribute(self->curstyle,"color")) != NULL) { + stringtbl_SetBitOfEntry(st[(long)TNcolor], stringtbl_AddString(st[(long)TNcolor], color), 1); + } + } + { /* Tabs */ + long numTabChanges; + struct tabentry **TabChangeArray; + long i; + struct tabs *tabs; + + tabs = tabs_Create(); + + style_GetTabChangeList(style, &numTabChanges, &TabChangeArray); + for (i = 0; i < numTabChanges; i++) + tabs = tabs_ApplyChange(tabs, TabChangeArray[i]); + if (TabChangeArray) + free(TabChangeArray); + tabrulerview_SetValues(self->tabrulerv, tabs); + } self->NeedsUnpack = FALSE; } *************** *** 494,504 **** register struct lookzview *self; { long i; ! for (i=(long)TNfont; i<=(long)TNdisable; i++) stringtbl_ClearBits(self->st[i]); lprrulerview_SetValues(self->rulerview, lprrulerview_NoValue, lprrulerview_NoValue, lprrulerview_NoValue); } /* CloseStyleSheet(self) --- 578,589 ---- register struct lookzview *self; { long i; ! for (i=(long)TNfont; i<=(long)TNcolor; i++) stringtbl_ClearBits(self->st[i]); lprrulerview_SetValues(self->rulerview, lprrulerview_NoValue, lprrulerview_NoValue, lprrulerview_NoValue); + tabrulerview_SetValues(self->tabrulerv, NULL); } /* CloseStyleSheet(self) *************** *** 515,521 **** --- 600,609 ---- ClearStyleDisplay(self); stringtbl_Clear(self->st[(long)TNmenucard]); stringtbl_Clear(self->st[(long)TNstylename]); + self->foundstylesheet = FALSE; stylesheet_RemoveObserver(self->curss, self); + self->curss = NULL; + self->curstyle = NULL; } /* called by EnumerateStyles in OpenStyleSheet */ *************** *** 535,579 **** register struct stylesheet *ss; { self->curss = ss; ! stylesheet_AddObserver(ss, self); ! /* set up the cardmenu and stylename data objects */ ! stylesheet_EnumerateStyles(self->curss, AddCardName, ! self->st[(long)TNmenucard]); ! self->foundstylesheet = TRUE; ! } ! ! ! /* called by EnumerateStyles in HitMenuCard */ ! static boolean ! AddStyleName(s, lv) ! register struct style *s; ! register struct lookzview *lv; ! { ! register char *mnnm = style_GetMenuName(s), *ThisStylename; ! if (mnnm != NULL && strcmp(lv->curcard, InitialWord(mnnm)) == 0) { ! ThisStylename = index(mnnm, ','); ! if (ThisStylename) ! stringtbl_AddString(lv->st[(long)TNstylename], ! (unsigned char *)InitialWord(ThisStylename+1)); } ! return FALSE; } - /* called as an ItemHitProc for stringtbl[TNmenucard] - set up the stylename stringtbl */ - static - HitMenuCard(st0, lv, accnum) - struct stringtbl *st0; - register struct lookzview *lv; - long accnum; - { - strtblview_OneOnly(st0, lv, accnum); - stringtbl_Clear(lv->st[(long)TNstylename]); - ClearStyleDisplay(lv); - lv->curstyle = NULL; - lv->curcard = (char *)stringtbl_GetStringOfEntry(st0, accnum); - stylesheet_EnumerateStyles(lv->curss, AddStyleName, lv); - } static char *TempStyleName; /* holds the stylename during --- 623,638 ---- register struct stylesheet *ss; { self->curss = ss; ! if (ss != NULL) { ! stylesheet_AddObserver(ss, self); ! /* set up the cardmenu and stylename data objects */ ! stylesheet_EnumerateStyles(self->curss, AddCardName, ! (long) self->st[(long)TNmenucard]); ! stringtbl_AddString(self->st[(long)TNmenucard], NOMENUSTRING); } ! self->foundstylesheet = TRUE; } static char *TempStyleName; /* holds the stylename during *************** *** 599,604 **** --- 658,681 ---- return FALSE; } + static boolean + FindAndUnpackNoMenus(s, lv) + register struct style *s; + register struct lookzview *lv; + { + register char *mnnm = style_GetMenuName(s); + if (mnnm == NULL) { + register char *ThisStylename = style_GetName(s); + if (ThisStylename + && strcmp(InitialWord(ThisStylename), + TempStyleName) == 0) { + SetStyleDisplay(lv, s); + return TRUE; /* finished */ + } + } + return FALSE; + } + /* HitStyleName is called as an ItemHitProc for the stylename stringtbl */ static HitStyleName(st1, lv, accnum) *************** *** 610,618 **** ClearStyleDisplay(lv); TempStyleName = (char *) stringtbl_GetStringOfEntry(lv->st[(long)TNstylename], accnum); /* side arg to FindAndUnpack KLUDGE */ ! stylesheet_EnumerateStyles(lv->curss, FindAndUnpack, lv); } /* called as an ItemHitProc for stringtbl[TNfont] modify font in the stylesheet */ --- 687,794 ---- ClearStyleDisplay(lv); TempStyleName = (char *) stringtbl_GetStringOfEntry(lv->st[(long)TNstylename], accnum); /* side arg to FindAndUnpack KLUDGE */ ! stylesheet_EnumerateStyles(lv->curss, FindAndUnpack, (long) lv); ! } ! ! ! static ! HitStyleNameNoMenus(st1, lv, accnum) ! register struct stringtbl *st1; ! register struct lookzview *lv; ! long accnum; ! { ! strtblview_OneOnly(st1, lv, accnum); ! ClearStyleDisplay(lv); ! TempStyleName = (char *) stringtbl_GetStringOfEntry(lv->st[(long)TNstylename], ! accnum); /* side arg to FindAndUnpack KLUDGE */ ! stylesheet_EnumerateStyles(lv->curss, FindAndUnpackNoMenus, (long) lv); ! } ! ! /* called by EnumerateStyles in HitMenuCard */ ! static boolean ! AddStyleName(s, lv) ! register struct style *s; ! register struct lookzview *lv; ! { ! register char *mnnm = style_GetMenuName(s), *ThisStylename; ! if (mnnm != NULL && strcmp(lv->curcard, InitialWord(mnnm)) == 0) { ! ThisStylename = index(mnnm, ','); ! if (ThisStylename) ! stringtbl_AddString(lv->st[(long)TNstylename], ! (unsigned char *)InitialWord(ThisStylename+1)); ! } ! return FALSE; ! } ! ! static boolean ! AddStyleNameNoMenus(s, lv) ! register struct style *s; ! register struct lookzview *lv; ! { ! register char *mnnm = style_GetMenuName(s), *ThisStylename; ! if (mnnm == NULL) { ! ThisStylename = style_GetName(s); ! if (ThisStylename) { ! stringtbl_AddString(lv->st[(long)TNstylename], ! (unsigned char *)InitialWord(ThisStylename)); ! } ! } ! return FALSE; ! } ! ! /* called as an ItemHitProc for stringtbl[TNmenucard] ! set up the stylename stringtbl */ ! static ! HitMenuCard(st0, lv, accnum) ! struct stringtbl *st0; ! register struct lookzview *lv; ! long accnum; ! { ! strtblview_OneOnly(st0, lv, accnum); ! stringtbl_Clear(lv->st[(long)TNstylename]); ! ClearStyleDisplay(lv); ! lv->curcard = (char *)stringtbl_GetStringOfEntry(st0, accnum); ! lv->curstyle = NULL; ! if (strcmp(lv->curcard, NOMENUSTRING) != 0) { ! stylesheet_EnumerateStyles(lv->curss, AddStyleName, (long) lv); ! strtblview_SetItemHitProc(lv->stv[(long)TNstylename], HitStyleName, lv); ! } ! else { ! stylesheet_EnumerateStyles(lv->curss, AddStyleNameNoMenus, (long) lv); ! strtblview_SetItemHitProc(lv->stv[(long)TNstylename], HitStyleNameNoMenus, lv); ! } } + static char newString[300]; + + static char *GetStringValue(st, self, str, prompt) + struct stringtbl *st; + struct lookzview *self; + char *str; + char *prompt; + { + if (strcmp(str, "") == 0) { + long ans = message_AskForString(self, 0, prompt, NULL, newString, sizeof(newString)); + stringtbl_ClearBits(st); + + if (ans == -1) { + UnpackStyle(self); + return NULL; + } + else { + long id; + + str = newString; + if ((id = stringtbl_GetEntryOfString(st, str, 0)) < 0) { + stringtbl_RemoveString(st, ""); + id = stringtbl_AddString(st, str); + stringtbl_AddString(st, ""); + } + stringtbl_SetBitOfEntry(st, id, 1); + } + } + return str; + } /* called as an ItemHitProc for stringtbl[TNfont] modify font in the stylesheet */ *************** *** 624,631 **** { if (self->curstyle == NULL) return; strtblview_ZeroOrOne(st, self, accnum); ! if (stringtbl_GetBitOfEntry(st, accnum)) ! style_SetFontFamily(self->curstyle, (char *)stringtbl_GetStringOfEntry(st, accnum)); else { /* delete font reference from style. KLUDGE KLUDGE: style_SetFontFamily --- 800,812 ---- { if (self->curstyle == NULL) return; strtblview_ZeroOrOne(st, self, accnum); ! if (stringtbl_GetBitOfEntry(st, accnum)) { ! char *str = GetStringValue(st, self, (char *) stringtbl_GetStringOfEntry(st, accnum), "New font: "); ! ! if (str != NULL) { ! style_SetFontFamily(self->curstyle, str); ! } ! } else { /* delete font reference from style. KLUDGE KLUDGE: style_SetFontFamily *************** *** 658,668 **** long points; if (self->curstyle == NULL) return; strtblview_ZeroOrOne(st, self, accnum); ! if (stringtbl_GetBitOfEntry(st, accnum)) ! MapStringToDelta(((char *)stringtbl_GetStringOfEntry(st, accnum)), &points, &basis); ! else points = 0, basis = style_PreviousFontSize; ! style_SetFontSize(self->curstyle, basis, points); ChangeStyle(self); } --- 839,856 ---- long points; if (self->curstyle == NULL) return; strtblview_ZeroOrOne(st, self, accnum); ! if (stringtbl_GetBitOfEntry(st, accnum)) { ! char *str = GetStringValue(st, self, (char *) stringtbl_GetStringOfEntry(st, accnum), "New font size: "); ! ! if (str != NULL) { ! MapStringToDelta(str, &points, &basis); ! style_SetFontSize(self->curstyle, basis, points); ! } ! } ! else { points = 0, basis = style_PreviousFontSize; ! style_SetFontSize(self->curstyle, basis, points); ! } ChangeStyle(self); } *************** *** 702,714 **** if (self->curstyle == NULL) return; strtblview_ZeroOrOne(st, self, accnum); if (stringtbl_GetBitOfEntry(st, accnum)) { ! register char *str = (char *)stringtbl_GetStringOfEntry(st, accnum); points = MapStringToVal(SubScrNames, str); ! if (points == -999L) MapStringToDelta(str, &points, (enum style_FontSize *)&basis); } ! /* else points=0 and basis=style_PreviousScriptMovement */ ! style_SetFontScript(self->curstyle, basis, points, style_Points); ChangeStyle(self); } --- 890,908 ---- if (self->curstyle == NULL) return; strtblview_ZeroOrOne(st, self, accnum); if (stringtbl_GetBitOfEntry(st, accnum)) { ! char *str = GetStringValue(st, self, (char *) stringtbl_GetStringOfEntry(st, accnum), "New script position: "); ! ! if (str != NULL) { points = MapStringToVal(SubScrNames, str); ! if (points == -999L) { MapStringToDelta(str, &points, (enum style_FontSize *)&basis); + } + style_SetFontScript(self->curstyle, basis, points, style_Points); + } } ! else { ! style_SetFontScript(self->curstyle, basis, points, style_Points); ! } ChangeStyle(self); } *************** *** 773,788 **** } static HitShrink(shrink, action, self) struct labelview *shrink; register enum view_MouseAction action; register struct lookzview *self; ! { if (action != view_LeftDown && action != view_RightDown) return; ! lookzview_SetVisibility(self, ! lookzview_GetVisibility(self)); ! lookzview_WantNewSize(self, self); ! lookzview_WantInputFocus(self, self); } --- 967,1068 ---- } static + HitSpacing(st, self, accnum) + struct stringtbl *st; + register struct lookzview *self; + long accnum; + { + enum style_SpacingValue basis; + long points; + if (self->curstyle == NULL) return; + strtblview_ZeroOrOne(st, self, accnum); + if (stringtbl_GetBitOfEntry(st, accnum)) { + char *str = GetStringValue(st, self, (char *) stringtbl_GetStringOfEntry(st, accnum), "New interline spacing: "); + + if (str != NULL) { + if (*str == '+' || *str == '-') { + basis = style_InterlineSpacing; + } + else { + basis = style_ConstantSpacing; + } + points = atoi(str); + style_SetNewInterlineSpacing(self->curstyle, basis, points, style_Points); + } + } + else { + points = 0; + basis = style_PreviousFontSize; + style_SetNewInterlineSpacing(self->curstyle, basis, points, style_Points); + } + ChangeStyle(self); + } + + static + HitSpread(st, self, accnum) + struct stringtbl *st; + register struct lookzview *self; + long accnum; + { + enum style_SpacingValue basis; + long points; + if (self->curstyle == NULL) return; + strtblview_ZeroOrOne(st, self, accnum); + if (stringtbl_GetBitOfEntry(st, accnum)) { + char *str = GetStringValue(st, self, (char *) stringtbl_GetStringOfEntry(st, accnum), "New interparagraph spacing: "); + + if (str != NULL) { + if (*str == '+' || *str == '-') { + basis = style_InterparagraphSpacing; + } + else { + basis = style_ConstantSpacing; + } + points = atoi(str); + style_SetNewInterparagraphSpacing(self->curstyle, basis, points, style_Points); + } + } + else { + points = 0; + basis = style_PreviousFontSize; + style_SetNewInterparagraphSpacing(self->curstyle, basis, points, style_Points); + } + ChangeStyle(self); + } + + static void HitColor(st, self, accnum) + struct stringtbl *st; + register struct lookzview *self; + long accnum; + { + if (self->curstyle == NULL) return; + strtblview_ZeroOrOne(st, self, accnum); + if (stringtbl_GetBitOfEntry(st, accnum)) { + char *str = GetStringValue(st, self, (char *) stringtbl_GetStringOfEntry(st, accnum), "New color: "); + style_AddAttribute(self->curstyle, "color", str); + } + else { + style_RemoveAttribute(self->curstyle,"color"); + } + ChangeStyle(self); + } + + static HitShrink(shrink, action, self) struct labelview *shrink; register enum view_MouseAction action; register struct lookzview *self; ! { ! struct lookz *lookz; ! if (action != view_LeftDown && action != view_RightDown) return; ! lookz = (struct lookz *) lookzview_GetDataObject(self); ! if (! lookzview_GetVisibility(self) || lookz_GetCanClose(lookz)) { ! lookzview_SetVisibility(self, ! lookzview_GetVisibility(self)); ! lookzview_WantNewSize(self, self); ! lookzview_WantInputFocus(self, self); ! } } *************** *** 836,854 **** label_SetFont(l, "andysans", fontdesc_Bold, 8); label_SetText(l, label); labelview_SetDataObject(lv, l); ! return (struct lpair *)(bpair_VTFixed(bpair_New(), lv, view, 12, FALSE)); } boolean lookzview__InitializeClass(ClassID) struct classhdr *ClassID; { ! MenuList = menulist_New(); ! Keymap = keymap_New(); ! bind_BindList(MenuOptions, Keymap, MenuList, ! &lookzview_classinfo); ! return TRUE; } boolean --- 1116,1225 ---- label_SetFont(l, "andysans", fontdesc_Bold, 8); label_SetText(l, label); labelview_SetDataObject(lv, l); ! return (struct lpair *)(bpair_VTFixed(bpair_New(), lv, view, 14, FALSE)); ! } ! ! #define Text(v) (struct text *) ((v)->header.view.dataobject) ! ! static EditStylesInWindow(textv) ! struct view *textv; ! { ! register struct text *d; ! struct lookz *newobject; ! int i; ! int openSlot = -1; ! struct buffer *buffer = NULL; ! ! d = (struct text *) view_GetDataObject(textv); ! ! for (i = 0; i < numStyleEditors; i++) { ! if (styleEditors[i].text == d) { ! buffer = buffer_FindBufferByData(styleEditors[i].lookz); ! break; ! } ! else if (styleEditors[i].text == NULL) { ! openSlot = i; ! } ! } ! ! if (buffer == NULL) { ! if ((newobject = (struct lookz *) class_NewObject("lookz"))) { ! char bufferName[50]; ! ! lookz_SetID(newobject, lookz_UniqueID(newobject)); ! lookz_SetTextObject(newobject, d); ! lookz_SetCanClose(newobject, FALSE); ! buffer_GetUniqueBufferName("Style-Editor", bufferName, sizeof(bufferName)); ! buffer = buffer_Create(bufferName, NULL, "lookzview", newobject); ! buffer_SetDestroyData(buffer, TRUE); ! ! if (openSlot == -1) { ! if (numStyleEditors == maxStyleEditors) { ! if (maxStyleEditors == 0) { ! maxStyleEditors = 4; ! styleEditors = (struct styleeditorlist *) malloc(sizeof(struct styleeditorlist) * maxStyleEditors); ! } ! else { ! maxStyleEditors += 4; ! styleEditors = (struct styleeditorlist *) realloc(styleEditors, sizeof(struct styleeditorlist) * maxStyleEditors); ! } ! } ! openSlot = numStyleEditors++; ! } ! styleEditors[openSlot].text = d; ! styleEditors[openSlot].lookz = newobject; ! } ! } ! ! if (buffer != NULL) { ! /* get a view on the buffer */ ! struct frame *frame = frame_GetFrameInWindowForBuffer(buffer); ! struct view *view; ! struct im *im; ! ! if (frame == NULL || (im = frame_GetIM(frame)) == NULL) { ! message_DisplayString(textv, 50, "Couldn't find window."); ! return; ! } ! ! view = frame_GetView(frame); ! view_WantInputFocus(view,view); ! /* pop to top window */ ! im_ExposeWindow(im); ! } } + static NewTextObject(self, text) + struct lookzview *self; + struct text *text; + { + CloseStyleSheet(self); + if (text != NULL) { + lookzview_SetStyleSheet(self, text_GetStyleSheet(text)); + } + lookzview_WantUpdate(self, self); + } + boolean lookzview__InitializeClass(ClassID) struct classhdr *ClassID; { ! struct classinfo *textviewClassinfo; ! ! textviewClassinfo = class_Load("textview"); ! proctable_DefineProc("lookzview-edit-styles", EditStylesInWindow, textviewClassinfo, NULL, ! "Bring up style editor in a seprate window"); ! ! MenuList = menulist_New(); ! Keymap = keymap_New(); ! bind_BindList(MenuOptions, Keymap, MenuList, ! &lookzview_classinfo); ! /* We *really* want the default font to be smaller - it just looks ! Sooo gross if you have the default 12pt thing... ! so while we're at it, let the user have a choice */ ! StrtblFont = fontdesc_Create("andysans", fontdesc_Plain, environ_GetProfileInt("lookzfontsize", 10)); ! return TRUE; } boolean *************** *** 857,863 **** register struct lookzview *self; { long i, j; ! struct lpair *R[5]; struct label *shrinklabel, *emptylabel; struct labelview *emptylabelview; --- 1228,1234 ---- register struct lookzview *self; { long i, j; ! struct lpair *R[7]; struct label *shrinklabel, *emptylabel; struct labelview *emptylabelview; *************** *** 878,888 **** self->NeedsUnpack = FALSE; self->OnScreen = FALSE; self->Linked = FALSE; shrinklabel = label_New(); label_SetFont(shrinklabel, "icon", fontdesc_Plain, 12); self->shrinkicon = labelview_New(); ! labelview_SetHitProc(self->shrinkicon, HitShrink, self); labelview_SetDataObject(self->shrinkicon, shrinklabel); /* defer initial ChooseShrinkIcon because it will call SetText, which calls NotifyObservers, --- 1249,1260 ---- self->NeedsUnpack = FALSE; self->OnScreen = FALSE; self->Linked = FALSE; + self->OnceOnlyInUpdate = FALSE; /* We haven't been thru yet */ shrinklabel = label_New(); label_SetFont(shrinklabel, "icon", fontdesc_Plain, 12); self->shrinkicon = labelview_New(); ! labelview_SetHitProc(self->shrinkicon, (void (*)()) HitShrink, (char *) self); labelview_SetDataObject(self->shrinkicon, shrinklabel); /* defer initial ChooseShrinkIcon because it will call SetText, which calls NotifyObservers, *************** *** 916,928 **** --- 1288,1308 ---- strtblview_SetItemHitProc(self->stv[(long)TNsubscr], HitSubscr, self); strtblview_SetItemHitProc(self->stv[(long)TNenable], HitEnable, self); strtblview_SetItemHitProc(self->stv[(long)TNdisable], HitDisable, self); + strtblview_SetItemHitProc(self->stv[(long)TNspacing], HitSpacing, self); + strtblview_SetItemHitProc(self->stv[(long)TNspread], HitSpread, self); + strtblview_SetItemHitProc(self->stv[(long)TNcolor], HitColor, self); self->ruler = lprruler_New(); + self->tabruler = lprruler_New(); + self->tabrulerv = tabrulerview_New(); self->rulerview = lprrulerview_New(); + tabrulerview_SetDataObject(self->tabrulerv, self->tabruler); lprrulerview_SetDataObject(self->rulerview, self->ruler); lprrulerview_SetValues(self->rulerview, lprrulerview_NoValue, lprrulerview_NoValue, lprrulerview_NoValue); lprrulerview_SetValueChangeProc(self->rulerview, RulerValueChanged, self); + tabrulerview_SetValues(self->tabrulerv, NULL); + tabrulerview_SetValueChangeProc(self->tabrulerv, TabsValueChanged, self); /* build image *************** *** 942,951 **** R[0] (icon, MENUCARD, MENUNAME) R[1] (FONT, ENABLE, DISABLE) R[2] (JUSTIFICATION, BASELINE) ! R[3] (FONTSIZE) R[4] (RULER) We first create each group and then arrange them as a whole. */ R[0] = LL(V, 4, self->shrinkparent = LL(H, 94, (struct lpair *)self->shrinkicon, --- 1322,1334 ---- R[0] (icon, MENUCARD, MENUNAME) R[1] (FONT, ENABLE, DISABLE) R[2] (JUSTIFICATION, BASELINE) ! R[3] (FONTSIZE, COLOR) R[4] (RULER) We first create each group and then arrange them as a whole. */ + + /* njw, August 1990: R[5] for tabruler */ + R[0] = LL(V, 4, self->shrinkparent = LL(H, 94, (struct lpair *)self->shrinkicon, *************** *** 969,991 **** LBL("justify", (struct view *)self->stv[(long)TNmode]), LBL("baseline", (struct view *)self->stv[(long)TNsubscr]) ); ! R[3] = LBL("font size", (struct view *)self->stv[(long)TNsize]); R[4] = LBL("relative margins and paragraph indent", (struct view *)self->rulerview); /* put it all together */ ! self->image = LL(V, 74, ! R[0], /* menucard and menuname */ ! LL(V, 32, ! LL(H, 35, ! LL(V, 37, ! R[1], /* font, enable, disable */ ! R[3] /* fontsize */ ! ), ! R[2] /* justification and baseline */ ! ), ! R[4] /* ruler */ ! ) ! ); ChooseShrinkIcon(self); --- 1352,1385 ---- LBL("justify", (struct view *)self->stv[(long)TNmode]), LBL("baseline", (struct view *)self->stv[(long)TNsubscr]) ); ! R[3] = LL(H, 50, ! LBL("font size", (struct view *)self->stv[(long)TNsize]), ! LBL("color", (struct view *) self->stv[(long)TNcolor])); R[4] = LBL("relative margins and paragraph indent", (struct view *)self->rulerview); + R[5] = LL(H, 50, + LBL("line spacing", (struct view *) self->stv[(long) TNspacing]), + LBL("paragraph spacing", (struct view *) self->stv[(long) TNspread])); + R[6] = LBL("tab stops - relative to left margin", (struct view *)self->tabrulerv); /* put it all together */ ! self->image = LL(V, 85, ! R[0], /* menucard and menuname */ ! LL(V, 64, ! LL(V, 37, ! LL(H, 35, ! R[1], /* font, enable, disable */ ! R[2] /* justification and baseline */ ! ), ! R[3] /* fontsize */ ! ), ! LL(V, 40, ! LL(V, 67, ! R[5], /* spacing */ ! R[4]), /* ruler */ ! R[6] /* tabs */ ! ) ! ) ! ); ChooseShrinkIcon(self); *************** *** 1123,1128 **** --- 1517,1524 ---- register long left, top, width, height; { struct rectangle r; + int i; + self->OnScreen = (type != view_Remove); lookzview_GetLogicalBounds(self, &r); DEBUG(("FullUpdate type %d redraw (%d,%d,%d,%d) within (%d,%d,%d,%d)\n", *************** *** 1160,1168 **** && type != view_LastPartialRedraw) { lpair_InsertView(self->image, self, &r); } ! lpair_FullUpdate(self->image, type, left, top, width, height); } ! else { if (type != view_PartialRedraw && type != view_LastPartialRedraw) labelview_InsertView(self->shrinkicon, self, &r); --- 1556,1572 ---- && type != view_LastPartialRedraw) { lpair_InsertView(self->image, self, &r); } ! /* Now that we are here, the strtbl's have been instantiated, ! so we can set their font's to something reasonable! */ ! /* This should only be done once... */ ! if (!self->OnceOnlyInUpdate) { ! for (i = 0; InitialStrings[i]; i++) ! strtblview_SetFont(self->stv[i], StrtblFont); ! self->OnceOnlyInUpdate = TRUE; } ! ! lpair_FullUpdate(self->image, type, left, top, width, height); ! } else { if (type != view_PartialRedraw && type != view_LastPartialRedraw) labelview_InsertView(self->shrinkicon, self, &r); *************** *** 1226,1232 **** long *desiredHeight; { if (lookzview_GetVisibility(self)) ! *desiredWidth = 550, *desiredHeight = 260; else *desiredWidth = 26, *desiredHeight = 20; DEBUG(("Desired Size %d x %d\n", *desiredWidth, *desiredHeight)); --- 1630,1636 ---- long *desiredHeight; { if (lookzview_GetVisibility(self)) ! *desiredWidth = 550, *desiredHeight = 400; else *desiredWidth = 26, *desiredHeight = 20; DEBUG(("Desired Size %d x %d\n", *desiredWidth, *desiredHeight)); *************** *** 1247,1260 **** void lookzview__ObservedChanged(self, dobj, status) register struct lookzview *self; ! struct stylesheet *dobj; long status; { ! if (status == (long)self || self->curstyle == NULL ! || status == observable_OBJECTDESTROYED) ! return; /* changed by self or deleting it */ - self->NeedsUnpack = TRUE; lookzview_WantUpdate(self, self); } --- 1651,1693 ---- void lookzview__ObservedChanged(self, dobj, status) register struct lookzview *self; ! struct dataobject *dobj; long status; { ! if (dobj == lookzview_GetDataObject(self)) { ! struct lookz *lookz; ! struct text *text; ! ! lookz = (struct lookz *) lookzview_GetDataObject(self); ! text = lookz_GetTextObject(lookz); ! ! if (status == lookz_TEXTOBJECTCHANGED) { ! NewTextObject(self, text); ! } ! if (status == observable_OBJECTDESTROYED) { ! long i; ! ! for (i = 0; i < numStyleEditors; i++) { ! if (((struct dataobject *) (styleEditors[i].lookz)) == dobj) { ! styleEditors[i].text = NULL; ! styleEditors[i].lookz = NULL; ! break; ! } ! } ! } ! } ! else if (dobj == (struct dataobject *) self->curss) { ! if (status == observable_OBJECTDESTROYED) { ! CloseStyleSheet(self); ! } ! else if (status == (long)self || self->curstyle == NULL) { ! return; /* changed by self */ ! } ! else { ! self->NeedsUnpack = TRUE; ! } ! } lookzview_WantUpdate(self, self); } *************** *** 1295,1315 **** return self->curss; } static void UpdateDocument(self) register struct lookzview *self; { ! if (self->embedded) { ! /* BOGOSITY ALERT: we call Full_Update of parent */ ! register struct view *v; ! for (v = (struct view *)self; v != NULL; v = v->parent) ! if (strcmp("textview", class_GetTypeName(v)) == 0) { ! /* this is exceedingly dangerous XXX XXX ! We call a FullUpdate ! without establishing any environment */ ! view_FullUpdate(v, view_FullRedraw, 0, 0, 0, 0); ! break; ! } ! } } --- 1728,1765 ---- return self->curss; } + void lookzview__SetEmbedded(self, isEmbedded) + struct lookzview *self; + boolean isEmbedded; + { + self->embedded = isEmbedded; + } + static void UpdateDocument(self) register struct lookzview *self; { ! struct lookz *lookz; ! struct text *text; ! ! lookz = (struct lookz *) lookzview_GetDataObject(self); ! text = lookz_GetTextObject(lookz); ! ! if (text != NULL) { ! text_RegionModified(text, 0, text_GetLength(text)); ! text_NotifyObservers(text, observable_OBJECTCHANGED); ! } ! if (self->embedded) { ! /* BOGOSITY ALERT: we call Full_Update of parent */ ! register struct view *v; ! for (v = (struct view *)self; v != NULL; v = v->parent) ! if (strcmp("textview", class_GetTypeName(v)) == 0) { ! /* this is exceedingly dangerous XXX XXX ! We call a FullUpdate ! without establishing any environment */ ! view_FullUpdate(v, view_FullRedraw, 0, 0, 0, 0); ! break; ! } ! } } *************** *** 1369,1375 **** /* There is no tilde for the card name, see if there is an existing menu card */ *comma = '\0'; ! stylesheet_EnumerateStyles(lv->curss, FindCardName, name); *comma = ','; } if (*CardFound != '\0') { --- 1819,1825 ---- /* There is no tilde for the card name, see if there is an existing menu card */ *comma = '\0'; ! stylesheet_EnumerateStyles(lv->curss, FindCardName, (long) name); *comma = ','; } if (*CardFound != '\0') { *************** *** 1437,1450 **** /* create the style */ newsty = style_New(); style_SetName(newsty, stylename); ! stylesheet_Add(self->curss, newsty); ! style_SetMenuName(newsty, NewMenuName(self, name)); } else if (index(name, '~') != NULL) { /* existing style and the input contains a ~, change the menu name */ ! style_SetMenuName(newsty, name); } SetStyleDisplay(self, newsty); } --- 1887,1917 ---- /* create the style */ newsty = style_New(); style_SetName(newsty, stylename); ! stylesheet_Add(self->curss, newsty); ! if (strncmp(name, NOMENUSTRING, strlen(NOMENUSTRING)) != 0) { ! style_SetMenuName(newsty, NewMenuName(self, name)); ! } } else if (index(name, '~') != NULL) { /* existing style and the input contains a ~, change the menu name */ ! if (strncmp(name, NOMENUSTRING, strlen(NOMENUSTRING)) != 0) { ! style_SetMenuName(newsty, name); ! } } SetStyleDisplay(self, newsty); } + + void lookzview__SetDataObject(self, dobj) + struct lookzview *self; + struct dataobject *dobj; + { + super_SetDataObject(self, dobj); + if (class_IsTypeByName(class_GetTypeName(dobj), "lookz")) { + struct lookz *lookz = (struct lookz *) dobj; + + NewTextObject(self, lookz_GetTextObject(lookz)); + } + } + *** atk/lookz/lookzv.ch Fri Dec 21 14:55:42 1990 --- atk/lookz/lookzv.ch.NEW Thu Dec 20 09:55:42 1990 *************** *** 2,13 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/lookz/RCS/lookzv.ch,v 2.5 89/02/23 09:58:07 ghoti Exp Locker: ajp $ */ /* $ACIS:lookzv.ch 1.3$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/lookz/RCS/lookzv.ch,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsidlookzview_H = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/lookz/RCS/lookzv.ch,v 2.5 89/02/23 09:58:07 ghoti Exp Locker: ajp $"; #endif /* !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) */ /* --- 2,13 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/lookz/RCS/lookzv.ch,v 2.7 90/12/19 16:24:01 ajp Exp $ */ /* $ACIS:lookzv.ch 1.3$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/lookz/RCS/lookzv.ch,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsidlookzview_H = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/lookz/RCS/lookzv.ch,v 2.7 90/12/19 16:24:01 ajp Exp $"; #endif /* !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) */ /* *************** *** 37,42 **** --- 37,43 ---- ObservedChanged(/* struct lookzview *self, */ struct stylesheet *dobj, long status); GetApplicationLayer(/* struct lookzview *self */) returns struct lookzview *; LinkTree(/* struct lookzview *self, */ struct view *parent); + SetDataObject(struct dataobject *dobj); methods: *************** *** 45,50 **** --- 46,56 ---- SetStyleSheet( /* struct lookzview *self, */ struct stylesheet *ss ); GetStyleSheet( /* struct lookzview *self */ ) returns struct stylesheet *; + SetEmbedded(boolean isEmbedded); + + macromethods: + GetEmbedded() self->embedded; + classprocedures: InitializeClass(/* struct classhdr *ClassID*/) returns boolean; *************** *** 55,68 **** data: boolean embedded; ! struct stringtbl *(st[8]); ! struct strtblview *(stv[8]); struct lprruler *ruler; struct lprrulerview *rulerview; struct lpair *image; struct labelview *shrinkicon; struct lpair *shrinkparent; boolean Linked; boolean foundstylesheet; struct stylesheet *curss; /* the stylesheet being edited */ --- 61,77 ---- data: boolean embedded; ! struct stringtbl *(st[11]); ! struct strtblview *(stv[11]); struct lprruler *ruler; struct lprrulerview *rulerview; + struct lprruler *tabruler; + struct tabrulerview *tabrulerv; struct lpair *image; struct labelview *shrinkicon; struct lpair *shrinkparent; boolean Linked; + boolean OnceOnlyInUpdate; boolean foundstylesheet; struct stylesheet *curss; /* the stylesheet being edited */ *** atk/lookz/tabrulv.c Sun May 12 21:20:42 1991 --- atk/lookz/tabrulv.c.NEW Fri Dec 14 16:51:56 1990 *************** *** 0 **** --- 1,652 ---- + + #include + #include + #include + #include + #include + #include + #define class_StaticEntriesOnly + #include + #undef class_StaticEntriesOnly + #include + #include + + #include + + #include + + #define IconString "/" + #define ClearString "AllClear" + #define CancelString "Cancel" + + static void RemoveIcon(), RepaintIcon(), RedrawPark(), RedrawIcons(), RedrawCommands(), RedrawText(), RedrawRuler(); + + #define ICONHEIGHT 14 /*C*//* height of area where icons move */ + #define PARKWIDTH 19 /*C*//* width of icon parking area */ + #define tabrulerHEIGHT 22 /*C*//* bottom line = topline + tabrulerHEIGHT */ + + static struct fontdesc *TextFont, *IconFont; + + + struct TickTbl { + short major, minor; /* number of pixels for major and minor cycles */ + short one; /* increment for -zero- value */ + short ht[10]; /* height of each tick + cyclecnt==0 is the first tick + and is where numeric value is displayed */ + char fmt[10]; /* format for text area */ + char unitstring[10]; /* units name to be displayed */ + }; + + static struct TickTbl InchTbl = {72, 9, 1, {6, 3, 5, 3, 7, 3, 5, 3}, "%+5.2f i", "In."}; + static struct TickTbl PointTbl = {36, 6, 36, {6, 3, 3, 5, 3, 3}, "%+3.0f p", "Pts."}; + static struct TickTbl CMTbl = {30, 6, 1, {6, 3, 3, 3, 3}, "%+5.2f c", "Cm."}; + + + static boolean + BogusCallFromParent(self, where, msg) + register struct tabrulerview *self; + char *where, *msg; + { + fprintf(stderr, "Bogus call to %s, %s\n", where, msg); + return FALSE; + } + + static boolean + CheckWindow(self, where) + register struct tabrulerview *self; + char *where; + { + register struct graphic *g + = (struct graphic *)tabrulerview_GetDrawable(self); + if ( ! g) return BogusCallFromParent(self, where, "No Graphic"); + return TRUE; + } + + + + boolean + tabrulerview__InitializeClass(ClassID) + struct classhdr *ClassID; + { + TextFont = fontdesc_Create("andysans", fontdesc_Bold, 12); + IconFont = fontdesc_Create("icon", fontdesc_Plain, 12); + return TRUE; + } + + boolean + tabrulerview__InitializeObject(ClassID, self) + struct classhdr *ClassID; + register struct tabrulerview *self; + { + self->OnScreen = FALSE; + self->tabrulerchanged = self->iconschanged = self->textchanged = TRUE; + self->unit = style_Inches; + self->TickTbl = &InchTbl; + self->ValueChangeProc = NULL; + self->tabs = NULL; + self->Moving = FALSE; + self->mul = environ_GetProfileInt("TabScalingMultiplier", 14); + self->div = environ_GetProfileInt("TabScalingDivisor", 12); + return TRUE; + } + + void + tabrulerview__FinalizeObject(ClassID, self) + struct classhdr *ClassID; + register struct tabrulerview *self; + { + } + + void + tabrulerview__ObservedChanged(self, dobj, status) + register struct tabrulerview *self; + struct tabruler *dobj; + long status; + { + if (status == lprruler_DATACHANGED) + self->iconschanged = self->textchanged = TRUE; + else if (status == observable_OBJECTDESTROYED) + return; + + tabrulerview_WantUpdate(self, self); + } + + static void + MoveIcon(self, newx) + struct tabrulerview *self; + register long newx; + { + RemoveIcon(self, self->Movex); + self->Movex = newx; + RepaintIcon(self, newx, graphic_COPY); + } + + + static void + RepaintIcon(self, position, color) + register struct tabrulerview *self; + register long position; + short color; + { + tabrulerview_SetTransferMode(self, color); + tabrulerview_MoveTo(self, position*self->mul/self->div, self->icony); + tabrulerview_DrawText(self, IconString, 1, graphic_NOMOVEMENT); + } + + static void + RemoveIcon(self, pos) + register struct tabrulerview *self; + register long pos; + { + register long dx; + register int i; + + RepaintIcon(self, pos, graphic_WHITE); + for (i = 0; i < self->tabs->number; i++) { + dx = self->tabs->Positions[i] - pos; + if (dx < 10 && dx > -10) /*C*/ + RepaintIcon(self, self->tabs->Positions[i], graphic_COPY); + } + } + + + /* Draw tick marks in a tabruler for -self- on the topline, from -left- to -right- + the value zero would be plotted at location zeroloc, which may be off + the tabruler to either end + the length of tick marks is given by -tbl-, with one entry for + each minor cycle within a major cycle. + The lengths of the cycles are given by -major- and -minor- + assume major % minor == 0 */ + static void + DoTicks(self, zeroloc, left, right, tbl) + register struct tabrulerview *self; + short zeroloc, right; + register short left; + register struct TickTbl *tbl; + { + short cycmax = tbl->major / tbl->minor; /* number of minor cycles in a major */ + register short tickloc; /* where to place next tick */ + register short cyclecnt; /* count minor ticks within major cycle */ + short ordloc; /* where to first plot an ordinate value */ + short ordval; /* next ordinate value to plot */ + register short x; + + /* since division and remainder are ill-defined for negative operands: + the "<<12" items arrange that the %'s are done on positive operands + the divisions always come out to exact values + */ + tickloc = left + (zeroloc + (tbl->minor << 12) - left) % tbl->minor; + ordloc = left + (zeroloc + (tbl->major << 12) - left) % tbl->major; + ordval = (ordloc - zeroloc) / tbl->major * tbl->one; + cyclecnt = cycmax - (ordloc-tickloc)/tbl->minor; + if (cyclecnt == cycmax) cyclecnt = 0; + + tabrulerview_SetFont(self, TextFont); + for ( ; tickloc < right; tickloc += tbl->minor) { + x = tickloc * self->mul / self->div; + tabrulerview_MoveTo(self, x, self->topline); + tabrulerview_DrawLineTo(self, x, self->topline + tbl->ht[cyclecnt]); + if (cyclecnt == 0) { + /* draw digit */ + char buf[10]; + if (ordval > 0) + sprintf(buf, "%+d", ordval); + else sprintf(buf, "%d", ordval); /* no sign if ordval==0 */ + tabrulerview_MoveTo(self, x-1, self->topline + 7); /*C*/ + tabrulerview_DrawString(self, buf, + graphic_BETWEENLEFTANDRIGHT | graphic_ATTOP); + ordval += tbl->one; + } + if (++cyclecnt >= cycmax) cyclecnt = 0; + } + } + + static void + RecomputeAndRedraw(self) + register struct tabrulerview *self; + { + struct rectangle r; + + tabrulerview_GetLogicalBounds(self, &r); + + self->leftline = 0; + self->rightline = r.width; + /* Assuming icons are square... */ + self->textloc = self->leftline + ICONHEIGHT*4 + 4; /* with icon for unit change to its left */ + self->cleartxt = (self->rightline - self->leftline) / 2 + self->leftline; + self->canceltxt = self->rightline - 4; + + self->topline = 4 + ICONHEIGHT; + self->bottomline = self->topline + tabrulerHEIGHT; + self->icony = self->topline - 2; + self->leftzero = self->leftline; + + tabrulerview_SetTransferMode(self, graphic_COPY); + tabrulerview_FillRect(self, &r, self->WhitePattern); + + RedrawRuler(self); + RedrawPark(self); + RedrawIcons(self); + RedrawText(self, 0.0, FALSE); + RedrawCommands(self); + + self->tabrulerchanged = FALSE; + } + + static void + RedrawRuler(self) + struct tabrulerview *self; + { + struct rectangle r; + r.left = self->leftline; + r.top = self->topline; + r.width = self->rightline - self->leftline; + r.height = self->bottomline - self->topline; + + /* Clean the area */ + tabrulerview_SetTransferMode(self, graphic_COPY); + tabrulerview_FillRect(self, &r, self->WhitePattern); + + /* draw outline */ + tabrulerview_MoveTo(self, self->leftline, self->topline); + tabrulerview_DrawLineTo(self, self->rightline, self->topline); + tabrulerview_DrawLineTo(self, self->rightline, self->bottomline); + tabrulerview_DrawLineTo(self, self->leftline, self->bottomline); + tabrulerview_DrawLineTo(self, self->leftline, self->topline); + + DoTicks(self, self->leftline, self->leftline, + self->rightline, self->TickTbl); + + } + + static void + RedrawText(self, number, flag) + register struct tabrulerview *self; + float number; + boolean flag; + { + struct rectangle r; + char buf[10]; + long buttony; + + r.top = self->bottomline + 2, r.left = self->textloc; + r.height = ICONHEIGHT + 4/*C*/; + r.width = self->clearpos - self->textloc - ICONHEIGHT; + buttony = self->bottomline + (ICONHEIGHT>>1) + 4; + tabrulerview_SetTransferMode(self, graphic_COPY); + tabrulerview_FillRect(self, &r, self->WhitePattern); + tabrulerview_SetFont(self, TextFont); + tabrulerview_MoveTo(self, self->textloc, self->bottomline + 2); + if (flag) + /* We want to display a number here */ + sprintf(buf, self->TickTbl->fmt, number); + else + strcpy(buf, self->TickTbl->unitstring); + + tabrulerview_DrawString(self, buf, graphic_ATLEFT | graphic_ATTOP); + + /* display button icons */ + tabrulerview_SetFont(self, IconFont); + tabrulerview_MoveTo(self, self->textloc-ICONHEIGHT, buttony); + tabrulerview_DrawText(self, "\'", 1, graphic_NOMOVEMENT); + + self->textchanged = FALSE; + } + + static void + RedrawCommands(self) + register struct tabrulerview *self; + { + long x, y, buttony; + struct rectangle r; + + /* + fontdesc_StringSize(TextFont, (struct graphic *) self, ClearString, &x,&y); + */ + x = 60; /* x = Width of ClearString */ + self->clearpos = self->cleartxt - (x>>1) - ICONHEIGHT; + /* + fontdesc_StringSize(TextFont, (struct graphic *) self, CancelString, &x,&y); + */ + x = 50; /* x = Width of CancelString */ + self->cancelpos = self->canceltxt - x - ICONHEIGHT; + + r.top = self->bottomline + 2; + r.left = self->clearpos - ICONHEIGHT; + r.height = ICONHEIGHT + 4/*C*/; + r.width = self->rightline - r.left; + buttony = self->bottomline + (ICONHEIGHT>>1) + 4; + + tabrulerview_SetTransferMode(self, graphic_COPY); + tabrulerview_FillRect(self, &r, self->WhitePattern); + tabrulerview_SetFont(self, TextFont); + + /* The text for AllClear and Cancel */ + tabrulerview_MoveTo(self, self->cleartxt, self->bottomline + 2); + tabrulerview_DrawString(self, ClearString, graphic_BETWEENLEFTANDRIGHT | graphic_ATTOP); + + tabrulerview_MoveTo(self, self->canceltxt, self->bottomline + 2); + tabrulerview_DrawString(self, CancelString, graphic_ATRIGHT | graphic_ATTOP); + + /* display button icons */ + tabrulerview_SetFont(self, IconFont); + tabrulerview_MoveTo(self, self->cancelpos, buttony); + tabrulerview_DrawText(self, "\'", 1, graphic_NOMOVEMENT); + tabrulerview_MoveTo(self, self->clearpos, buttony); + tabrulerview_DrawText(self, "\'", 1, graphic_NOMOVEMENT); + } + + static void + RedrawPark(self) + register struct tabrulerview *self; + { + struct rectangle r; + + /* Redraw the parking lot... */ + r. height = ICONHEIGHT+4, r.width = PARKWIDTH; /*C*/ + r.top = self->bottomline + 2; /*C*/ + r.left = self->leftline + 2; + tabrulerview_SetTransferMode(self, graphic_COPY); + tabrulerview_FillRect(self, &r, self->Grey25Pattern); + + /* If we are moving the icon, then we leave the park empty */ + if (!self->Moving) { + tabrulerview_MoveTo(self, self->leftline+PARKWIDTH/2 + 2, + self->bottomline+ICONHEIGHT + 4); /*C*/ + tabrulerview_DrawText(self, IconString, 1, graphic_NOMOVEMENT); + } + } + + static void + RedrawIcons(self) + register struct tabrulerview *self; + { + register int i; + struct rectangle r; + + /* Clear the tabstops */ + r.top = self->topline - ICONHEIGHT - 4/*C*/, r.left = 0; + r.height = ICONHEIGHT + 3/*C*/, r.width = self->rightline; + tabrulerview_SetTransferMode(self, graphic_COPY); + tabrulerview_FillRect(self, &r, self->WhitePattern); + tabrulerview_SetFont(self, IconFont); + + if (self->tabs) + for (i = 0; i < self->tabs->number; i++) + RepaintIcon(self, self->tabs->Positions[i] + + self->leftline, graphic_COPY); + + /* The moving icon... */ + if (self->Moving) + RepaintIcon(self, self->Movex, graphic_COPY); + + RedrawPark(self); + + self->iconschanged = FALSE; + } + + void + tabrulerview__FullUpdate( self, type, left, top, width, height ) + register struct tabrulerview *self; + register enum view_UpdateType type; + register long left, top, width, height; + { + if (type == view_Remove) { + self->OnScreen = FALSE; + return; + } + if ( ! CheckWindow(self, "FullUpdate")) return; + if ((type != view_FullRedraw + && type != view_LastPartialRedraw) + || tabrulerview_GetLogicalWidth(self) == 0 + || tabrulerview_GetLogicalHeight(self) == 0) + return; + self->OnScreen = TRUE; + if (type == view_FullRedraw) { + /* must recompute graphics info because image + may be on different display hardware */ + self->Grey25Pattern = tabrulerview_GrayPattern(self, 4, 16); + self->WhitePattern = tabrulerview_WhitePattern(self); + } + self->tabrulerchanged = self->textchanged = self->iconschanged = TRUE; + RecomputeAndRedraw(self); + } + + + void + tabrulerview__Update( self ) + register struct tabrulerview *self; + { + if (! self->OnScreen || ! CheckWindow(self, "Update")) return; + if (self->tabrulerchanged) RedrawRuler(self); + if (self->textchanged) RedrawText(self, 0.0, FALSE); + if (self->iconschanged) RedrawIcons(self); + } + + struct view * + tabrulerview__Hit(self, action, x, y, num_clicks) + register struct tabrulerview *self; + register enum view_MouseAction action; + register long x, y, num_clicks; + { + if (action == view_NoMouseEvent) + return (struct view *) self; + if (!self->OnScreen || !CheckWindow(self, "Hit")) + return NULL; + + if (action == view_LeftDown || action == view_RightDown) { + if (self->Moving) { + /* Cancel */ + RemoveIcon(self, self->Movex); + self->Moving = FALSE; + RedrawPark(self); + } else { + short dx, dy; + dx = x - (self->textloc - ICONHEIGHT); + dy = y - (self->bottomline + ICONHEIGHT/2 + 4); + if (dy < 10 && dy > -10) { + /* Vertically, we're in the right place */ + if (dx < 10 && dx > -10) { + /* change units button */ + switch(self->unit) { + case style_CM: + self->TickTbl = &PointTbl; + self->unit = style_Points; + break; + case style_Points: + self->TickTbl = &InchTbl; + self->unit = style_Inches; + break; + default: + self->TickTbl = &CMTbl; + self->unit = style_CM; + break; + } + RedrawRuler(self); + RedrawText(self, 0.0, FALSE); + } else if (self->tabs) { + if ((dx = x - self->cancelpos) < 10 && dx >-10) { + /* The cancel button */ + self->tabs = tabs_Create(); + RedrawIcons(self); + RedrawText(self, 0.0, FALSE); + if (self->ValueChangeProc) + /* notify client of new value */ + /* cannot have -ve tabstops, so we use it + * to indicate cancel code + */ + (self->ValueChangeProc)(self, + self->ValueChangeRock, + -1L, style_AllClear, + style_Points); + } else if ((dx = x - self->clearpos) < 10 && dx > -10) { + /* The AllClear button */ + self->tabs = tabs_Clear(self->tabs); + RedrawIcons(self); + RedrawText(self, 0.0, FALSE); + if (self->ValueChangeProc) + /* notify client of new value */ + (self->ValueChangeProc)(self, + self->ValueChangeRock, + 0L, style_AllClear, + style_Points); + } else if (x < PARKWIDTH) { + /* We are in the park! - create a new tab in process */ + self->Moving = TRUE; + self->Movex = x; + self->oldtab = -1; /* Cannot have -ve tabs */ + RepaintIcon(self, x, graphic_COPY); + RedrawPark(self); + } + } + } else if (y < self->topline) { + /* Playing with existing tabstops */ + int i = FindClosestTab(self, (x - self->leftzero)*self->div / self->mul); + if (i >= 0) { + /* Only do something if we are close enough to a tab */ + float f = ((float) self->tabs->Positions[i]) / + self->TickTbl->major * + self->TickTbl->one; + if (action == view_LeftDown) { + /* Hit on a tab - let's move it... */ + self->Moving = TRUE; + self->Movex = self->tabs->Positions[i]; + /* remove it from its old position */ + self->tabs = tabs_Delete(self->tabs, i); + self->oldtab = self->Movex; + RedrawText(self, f, TRUE); + } else if (action == view_RightDown) { + /* we want to remove a tab */ + long x = self->tabs->Positions[i]; + self->tabs = tabs_Delete(self->tabs, i); + RemoveIcon(self, x); + RedrawText(self, 0.0, FALSE); + if (self->ValueChangeProc) + /* notify client of new value */ + (self->ValueChangeProc)(self, + self->ValueChangeRock, + x, style_TabClear, + style_Points); + } + } + } + } + } else { + /* Either move or up event */ + if (action == view_LeftUp && self->Moving) { + float f; + /* Plant a tab here */ + int i; + x = (x - self->leftline) * self->div / self->mul; + i = FindClosestTab(self, x); + self->Moving = FALSE; + if (i == -1) { + f = ((float) (x - self->leftline)) / + self->TickTbl->major * + self->TickTbl->one; + if (self->oldtab == x) { + /* Seems user has moved an old tab nowhere */ + MoveIcon(self, x); + self->tabs=tabs_Add(self->tabs, x, style_LeftAligned /*C*/); + } else { + /* We have just created a new tab */ + /* ONLY LEFTALIGNED TABS ALLOWED!!! XXX */ + MoveIcon(self, x); + if (self->ValueChangeProc) { + /* notify client of new value */ + (self->ValueChangeProc)(self, self->ValueChangeRock, x, + style_LeftAligned, /*C*/ + style_Points); + if (self->oldtab >= 0) + (self->ValueChangeProc)(self, self->ValueChangeRock, + self->oldtab, style_TabClear, + style_Points); + } + self->tabs = tabs_Add(self->tabs, x, style_LeftAligned /*C*/); + } + } else { + f = ((float) (self->tabs->Positions[i] - self->leftline)) / + self->TickTbl->major * + self->TickTbl->one; + RemoveIcon(self, x); + /* If we were moving a tab around, then there's more work */ + if (self->oldtab >= 0) + if (self->ValueChangeProc) + (self->ValueChangeProc)(self, self->ValueChangeRock, + self->oldtab,style_TabClear, + style_Points); + } + RedrawPark(self); + RedrawText(self, f, TRUE); + } else if (self->Moving && + (action == view_LeftMovement || + action == view_RightMovement)) { + /* We are still moving the new tab to its position */ + float f; + if (x - self->leftline >= 0) { + x = (x - self->leftline) *self->div / self->mul; + f = ((float) (x - self->leftline)) / + self->TickTbl->major * + self->TickTbl->one; + MoveIcon(self, x); + RedrawText(self, f, TRUE); + } + } + } + if (action == view_LeftDown || action == view_RightDown) + tabrulerview_WantInputFocus(self, self); + return (struct view *) self; + } + + enum view_DSattributes + tabrulerview__DesiredSize( self, width, height, pass, + desiredWidth, desiredHeight ) + register struct tabrulerview *self; + long width; + long height; + enum view_DSpass pass; + long *desiredWidth; + long *desiredHeight; + { + *desiredHeight = 80; + *desiredWidth = 700; + return view_Fixed; + } + + void + tabrulerview__SetValues(self, tabs) + register struct tabrulerview *self; + struct tabs *tabs; + { + self->tabs = tabs; + self->iconschanged = self->textchanged = TRUE; + tabrulerview_WantUpdate(self, self); + } + + void + tabrulerview__GetValues(self, tabs) + register struct tabrulerview *self; + struct tabs **tabs; + { + *tabs = self->tabs; + } + + int + FindClosestTab(self, pos) + register struct tabrulerview *self; + register long pos; + { + int i; + long dx; + + if (self->tabs) + for (i = 0; i < self->tabs->number; i++) { + dx = pos - self->tabs->Positions[i]; + if (dx < 0) + dx = -dx; + if (dx < 6) /* Cannot have tabs closer than 6 pts apart */ + return i; + } + return -1; + } *** atk/lset/cel.c Mon Aug 6 11:06:59 1990 --- atk/lset/cel.c.NEW Wed Apr 10 19:00:24 1991 *************** *** 2,27 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/lset/RCS/cel.c,v 2.13 90/06/06 14:23:11 rr2b Exp $ */ /* $ACIS: $ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/lset/RCS/cel.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/lset/RCS/cel.c,v 2.13 90/06/06 14:23:11 rr2b Exp $ "; #endif /* lint */ #include #include ! #include #include #include #include #include #include ! #include ! ! #include #define VALUE 10 static long viewID = 0; --- 2,28 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/lset/RCS/cel.c,v 2.15 91/04/10 18:15:39 gk5g Exp $ */ /* $ACIS: $ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/lset/RCS/cel.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/lset/RCS/cel.c,v 2.15 91/04/10 18:15:39 gk5g Exp $ "; #endif /* lint */ #include #include ! #include ! #include #include #include #include #include ! #include #include + #include + #include #define VALUE 10 static long viewID = 0; *************** *** 55,60 **** --- 56,75 ---- { if(self->dataObject) dataobject_RemoveObserver(self->dataObject,self); cel_NotifyObservers(self,observable_OBJECTDESTROYED); + if(self->chain != self){ + struct cel *nlink; + if(self->ab == NULL || self->ab->first == (struct cel *) self->ab) return; + nlink = self->ab->first; + if(nlink == self){ + self->ab->first = self->chain; + } + else for(; nlink != NULL && nlink != nlink->chain ; nlink = nlink->chain){ + if(nlink->chain == self){ + nlink->chain = self->chain; + break; + } + } + } } static SetVisible(self) *************** *** 88,93 **** --- 103,114 ---- self->readfromfile = 0; self->usedefaultview = 0; self->mode = cel_VISIBLE; + cel_SetDefaultStream(self,NULL); + cel_SetInitFile(self,NULL); + cel_SetWriteChild(self,TRUE); + self->count = 0; + self->chain = self; + self->ab = NULL; return TRUE; } *************** *** 323,328 **** --- 344,393 ---- *place = buf; return atom_Intern(tmpbuf); } + long cel__ReadSup(self, file, id) + struct cel *self; + FILE *file; + long id; + { + return dataobject_NOREADERROR; + } + long cel__ReadFile(self,thisFile) + struct cel *self; + FILE *thisFile; + { + int objectID; + long result; + char *objectName; + objectName = filetype_Lookup(thisFile, NULL, &objectID, NULL); /* For now, ignore attributes. */ + if(objectName == NULL) objectName = "text"; + if(class_IsTypeByName("cel",objectName) || class_IsTypeByName(objectName,"cel")){ + result = cel_Read(self,thisFile,objectID); + /* if(self->arb) arbiterview_InitCell(self->arb,self); */ + } + else{ + + if(/* objecttest(self,objectName,"dataobject") && */ cel_SetObjectByName(self,objectName) && cel_GetObject(self) != NULL){ + char *nm = NULL; + struct cel *arb = NULL; + cel_SetViewName(self,NULL,TRUE); + cel_SetRefName(self,""); + result = dataobject_Read(cel_GetObject(self),thisFile,objectID); + if(strcmp(objectName,"arbiter") == 0){ + arb = (struct cel *) cel_GetObject(self); + if((nm = cel_GetRefName(arb)) == NULL || *nm == '\0'){ + cel_SetRefName(arb,objectName); + } + cel_SetRefName(self,"arbcel"); + } + else{ + cel_SetRefName(self,objectName); + } + } + } + cel_NotifyObservers(self,0); + return result; + } + long cel__Read(self, file, id) struct cel *self; FILE *file; *************** *** 332,337 **** --- 397,403 ---- boolean begindata; char *s; long c; + struct arbiter *master; long status; char objectname[200],*cp; long objectid; *************** *** 344,349 **** --- 410,416 ---- textpending = 0; buf = cbuf; /* printf("In Cel Read\n"); */ + self->count++; cel_SetID(self,cel_UniqueID(self));/* change id to unique number */ while (endcount != 0) { while ((c = getc(file)) != EOF && c != '\\') { *************** *** 371,376 **** --- 438,446 ---- while ((c = getc(file)) != EOF && c != '\n') if(isdigit(c)) version = (version * 10) + (c - '0'); if (c == EOF) return dataobject_NOREADERROR; + if((status = cel_ReadSup(self, file, id)) != dataobject_NOREADERROR){ + return status; + } } } continue; *************** *** 393,399 **** (strcmp(objectname,class_GetTypeName(self)) == 0) ){ /* reading the begindata for this object */ id = 1; - printf("Skipping Self\n"); continue; } if ((newobject = (struct dataobject *) class_NewObject(objectname))) { --- 463,468 ---- *************** *** 474,479 **** --- 543,551 ---- #ifdef DEBUG printf("dobj = %d\n",self->dataObject); #endif /* DEBUG */ + if(self->dataObject == NULL) self->count = 0; + if((self->ab = arbiter_GetMaster()) != NULL) + arbiter_DeclareRead(self->ab,self); return dataobject_NOREADERROR; } *************** *** 491,496 **** --- 563,576 ---- self->dataObject = dob; return val; } + long cel__WriteSup(self,file ,writeid,level) + struct cel *self; + FILE *file; + long writeid; + int level; + { + return TRUE; + } long cel__Write(self,file ,writeid,level) struct cel *self; FILE *file; *************** *** 506,512 **** strcmp(class_GetTypeName(self),"arbiter") == 0 && class_IsTypeByName(class_GetTypeName(self->dataObject),"text") && ( text_GetExportEnvironments((struct text *) self->dataObject) == FALSE || ! environment_NumberOfChildren(((struct text *) self->dataObject)->rootEnvironment) <= 0)) /* don't write out self over plain text */ level--; if(level != -1){ --- 586,592 ---- strcmp(class_GetTypeName(self),"arbiter") == 0 && class_IsTypeByName(class_GetTypeName(self->dataObject),"text") && ( text_GetExportEnvironments((struct text *) self->dataObject) == FALSE || ! environment_NumberOfChildren(((struct text *) self->dataObject)->rootEnvironment) <= 0)) /* don't write out self over plain text */ level--; if(level != -1){ *************** *** 513,518 **** --- 593,603 ---- self->header.dataobject.writeID = writeid; fprintf(file,"\\begindata{%s,%ld}\n",class_GetTypeName(self),cel_GetID(self)); fprintf(file,"\\V 2\n"); /* Version Number */ + cel_WriteSup(self,file ,writeid,level); + if(self->WriteChild == FALSE){ + fprintf(file,"1 0 0 0 0 0 \n>OBJ< \n>VIEW< \n>REF< \n"); fprintf(file,"\\enddata{%s,%ld}\n",class_GetTypeName(self),cel_GetID(self)); + return cel_GetID(self); + } } #ifdef WOULDWORKBUT if(self->dataObject) did = dataobject_Write(self->dataObject,file,writeid,level+1); *************** *** 646,649 **** --- 731,784 ---- struct classheader *classID; struct cel *self; { + + } + long cel__InitDefault(self) + struct cel *self; + { + + FILE *f; + long ret; + char fnm[20]; + self->count++; + if(self->initfile && *self->initfile && + (f = fopen(self->initfile,"r")) != NULL){ + ret = cel_ReadFile(self,f); + fclose(f); + return ret; + } + if(self->defaultStream){ + strcpy(fnm, "/tmp/celXXXXXX"); + mktemp(fnm); + /* need to generate tmpfile name */ + if((f = fopen(fnm,"w")) == NULL){ + fputs("Can't write init file for cel in /tmp\n",stderr); + fflush(stderr); + self->count--; + return dataobject_OBJECTCREATIONFAILED; + } + fwrite(self->defaultStream,strlen(self->defaultStream),1,f); + fclose(f); + f = fopen(fnm,"r"); + ret = cel_ReadFile(self,f); + fclose(f); + unlink(fnm); + return ret; + } + return dataobject_OBJECTCREATIONFAILED; + + } + #if 0 + void cel__ClearChain(self) + struct cel *self; + { + struct cel *nlink; + + nlink = self->chain; + while(self != nlink){ + self->chain = self; + self = nlink; + nlink = self->chain; + } } + #endif *** atk/lset/Imakefile Thu Jan 10 14:57:51 1991 --- atk/lset/Imakefile.NEW Thu Apr 25 16:16:12 1991 *************** *** 14,19 **** --- 14,30 ---- pagev.do \ runadewa.do + OBJS = arbcon.o \ + arbiter.o \ + arbiterv.o \ + cel.o \ + celv.o \ + lset.o \ + lsetv.o \ + wincelv.o \ + page.o \ + pagev.o + IHFILES = arbcon.ih \ arbiter.ih \ arbiterv.ih \ *************** *** 31,40 **** --- 42,59 ---- RefMan.doc \ Title.doc + #ifdef RESOLVER_ENV + #ifdef LIBDL_ENV + SYS_LIBS = -lresolv + RESOLVER_LIB = + #else RESOLVER_LIB = $(RESOLVLIB) + SYS_LIBS = + #endif /* LIBDL_ENV */ #else RESOLVER_LIB = + SYS_LIBS = #endif NormalObjectRule() *************** *** 46,52 **** --- 65,73 ---- InstallMultiple(makefile.arb Arb vallist, $(INSTINCFLAGS), $(DESTDIR)/lib/arbiters) InstallProgram(conpros.awk, $(DESTDIR)/lib/arbiters) + InstallProgram(instpros.awk, $(DESTDIR)/lib/arbiters) InstallProgram(arb, $(DESTDIR)/bin) + InstallFile(adew.h, ${INSTINCFLAGS}, ${DESTDIR}/include/atk) InstallLink(runapp, ${DESTDIR}/bin/runadew) *************** *** 63,69 **** $(LN) ../../adew/$$i $$i ) \ done) ! ProgramTarget(createcon, mkcon.o, ${UTILLIB} ${BASEDIR}/lib/libclass.a $(RESOLVLIB),) InstallProgram(createcon, $(DESTDIR)/bin) DependTarget() --- 84,93 ---- $(LN) ../../adew/$$i $$i ) \ done) ! ProgramTarget(createcon, mkcon.o, ${UTILLIB} ${BASEDIR}/lib/libclass.a $(RESOLVER_LIB),$(SYS_LIBS)) InstallProgram(createcon, $(DESTDIR)/bin) + + LibraryTarget(libadew.a, $(OBJS)) + InstallLibrary(libadew.a, ${DESTDIR}/lib/atk) DependTarget() *** atk/lset/arb Wed Nov 22 12:16:45 1989 --- atk/lset/arb.NEW Wed Apr 3 21:20:02 1991 *************** *** 1,4 **** ! #! /bin/csh if ($?ANDREWDIR) then exec ez $1 $ANDREWDIR/lib/arbiters/Arb else --- 1,4 ---- ! #! /bin/csh -f if ($?ANDREWDIR) then exec ez $1 $ANDREWDIR/lib/arbiters/Arb else *** atk/lset/arbcon.c Fri Dec 21 14:55:46 1990 --- atk/lset/arbcon.c.NEW Thu Apr 25 16:16:20 1991 *************** *** 3,11 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/lset/RCS/arbcon.c,v 2.35 90/09/11 18:33:59 gk5g Exp $ */ /* $ACIS: $ */ ! /* $Source: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/lset/RCS/arbcon.c,v $ */ /* user code ends here for HeaderInfo */ #include #include --- 3,11 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/lset/RCS/arbcon.c,v 2.37 1991/04/25 19:42:03 tpn Exp $ */ /* $ACIS: $ */ ! /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/lset/RCS/arbcon.c,v $ */ /* user code ends here for HeaderInfo */ #include #include *************** *** 63,69 **** static char defaultvwlist[] = "text,fad,table,eq,raster,lookz,lset,page,ness,zip,link,chomp,calc,bush,chart,value bargraphV,value fourwayV,value sliderV,value thumbV,value buttonV,value \ onoffV,value sliderstrV,value thumbstrV,value controlV,value pianoV,value stringV,value enterstrV,value menterstrV,value clicklistV,arbiter" ; struct menulist *arbconMenus; ! static void DoCopy(self,clear) struct arbcon *self; boolean clear; --- 63,69 ---- static char defaultvwlist[] = "text,fad,table,eq,raster,lookz,lset,page,ness,zip,link,chomp,calc,bush,chart,value bargraphV,value fourwayV,value sliderV,value thumbV,value buttonV,value \ onoffV,value sliderstrV,value thumbstrV,value controlV,value pianoV,value stringV,value enterstrV,value menterstrV,value clicklistV,arbiter" ; struct menulist *arbconMenus; ! static struct atom *atta[7]; static void DoCopy(self,clear) struct arbcon *self; boolean clear; *************** *** 74,80 **** if (Gself->currentcelview && (value_GetValue(Gself->ArbLinkCel) == 0)){ celview_Copy(Gself->currentcelview); sprintf(buf,"Copying %s",cel_GetRefName(Cel(Gself->currentcelview))); ! message_DisplayString(Gself->arbv,0,buf); clear = FALSE; } else { --- 74,80 ---- if (Gself->currentcelview && (value_GetValue(Gself->ArbLinkCel) == 0)){ celview_Copy(Gself->currentcelview); sprintf(buf,"Copying %s",cel_GetRefName(Cel(Gself->currentcelview))); ! message_DisplayString(NULL,0,buf); clear = FALSE; } else { *************** *** 82,88 **** struct cel *cl; cl = cel_New(); if(setupcel(cl)){ ! cutFile = im_ToCutBuffer(view_GetIM(Gself->v)); if (Gself->currentcelview){ oldref = cel_GetRefName(Cel(Gself->currentcelview)); if(oldref == NULL) oldref = ""; --- 82,89 ---- struct cel *cl; cl = cel_New(); if(setupcel(cl)){ ! struct im *mim = im_GetLastUsed(); ! cutFile = im_ToCutBuffer(mim); if (Gself->currentcelview){ oldref = cel_GetRefName(Cel(Gself->currentcelview)); if(oldref == NULL) oldref = ""; *************** *** 92,98 **** else sprintf(buf,"Copying New link to %s",oldref); clear = FALSE; ! message_DisplayString(Gself->arbv,0,buf); } else { cel_Write(cl,cutFile,im_GetWriteID(),0); --- 93,99 ---- else sprintf(buf,"Copying New link to %s",oldref); clear = FALSE; ! message_DisplayString(NULL,0,buf); } else { cel_Write(cl,cutFile,im_GetWriteID(),0); *************** *** 103,109 **** if(value_GetValue(Gself->ArbApplicationChoice)) strcat(buf," w/ application layer"); } ! im_CloseToCutBuffer(view_GetIM(Gself->v), cutFile); } cel_Destroy(cl); } --- 104,110 ---- if(value_GetValue(Gself->ArbApplicationChoice)) strcat(buf," w/ application layer"); } ! im_CloseToCutBuffer(mim, cutFile); } cel_Destroy(cl); } *************** *** 120,126 **** if(s1 == NULL || s2 == NULL) return 1; return strcmp(s1,s2); } ! findinlist(lst,cnt,str) char **lst; int cnt; char *str; --- 121,127 ---- if(s1 == NULL || s2 == NULL) return 1; return strcmp(s1,s2); } ! static findinlist(lst,cnt,str) char **lst; int cnt; char *str; *************** *** 181,187 **** value_SetArraySize(Gself->ArbTextEdit,0); value_SetString(Gself->ArbTextEdit,""); value_SetString(Gself->ArbTextEdit,Gself->arr); ! message_DisplayString(Gself->arbv,0,""); } static appendlist(lst,cnt,str,TEST) char **lst; --- 182,188 ---- value_SetArraySize(Gself->ArbTextEdit,0); value_SetString(Gself->ArbTextEdit,""); value_SetString(Gself->ArbTextEdit,Gself->arr); ! message_DisplayString(NULL,0,""); } static appendlist(lst,cnt,str,TEST) char **lst; *************** *** 258,264 **** } return -1; } ! void handleclicks(self,ct,position, numberOfClicks, action, startLeft, startRight, leftPos, rightPos,which,type) struct arbcon *self; struct cltextview *ct; long *position; --- 259,265 ---- } return -1; } ! static void handleclicks(self,ct,position, numberOfClicks, action, startLeft, startRight, leftPos, rightPos,which,type) struct arbcon *self; struct cltextview *ct; long *position; *************** *** 644,650 **** value_SetString(Gself->ArbTextEdit,Gself->arr); menterstrV_WantInputFocus(Gself->ArbTextEditView,Gself->ArbTextEditView); } ! struct celview *currentcelview(ClassID) struct classheader *ClassID; { if(Gself == NULL) return NULL; --- 645,651 ---- value_SetString(Gself->ArbTextEdit,Gself->arr); menterstrV_WantInputFocus(Gself->ArbTextEditView,Gself->ArbTextEditView); } ! static struct celview *currentcelview(ClassID) struct classheader *ClassID; { if(Gself == NULL) return NULL; *************** *** 747,753 **** if(++arr == NULL || --size == 0) break; len = text_GetLength(src); } ! celview_PostParameters(Gself->currentcelview); } oldstr = cel_GetRefName(Cel(Gself->currentcelview)); --- 748,755 ---- if(++arr == NULL || --size == 0) break; len = text_GetLength(src); } ! /* celview_PostParameters(Gself->currentcelview); */ ! cel_NotifyObservers(Cel(Gself->currentcelview),cel_NeedsRepost); } oldstr = cel_GetRefName(Cel(Gself->currentcelview)); *************** *** 754,769 **** if(str && *str && oldstr && *oldstr && strcmp(str,oldstr) != 0){ sprintf(buf,"saving attributes and renaming %s to %s",oldstr,str); ! message_DisplayString(Gself->arbv,0,buf); SetName(Gself->currentcelview,Gself->CurrentArbiterview,str); } else { sprintf(buf,"saving attributes for %s",oldstr); ! message_DisplayString(Gself->arbv,0,buf); } #endif /* 0 */ } void arbcon__SetCurrentCelview(ClassID,cv) struct classheader *ClassID; struct celview *cv; --- 756,785 ---- if(str && *str && oldstr && *oldstr && strcmp(str,oldstr) != 0){ sprintf(buf,"saving attributes and renaming %s to %s",oldstr,str); ! message_DisplayString(NULL,0,buf); SetName(Gself->currentcelview,Gself->CurrentArbiterview,str); } else { sprintf(buf,"saving attributes for %s",oldstr); ! message_DisplayString(NULL,0,buf); } #endif /* 0 */ } + + static boolean isarbcon(cv) + struct celview *cv; + { + struct atom *att,**atp; + att = cel_GetRefAtom(Cel(cv)); + for(atp = atta; *atp != NULL; atp++) + if(*atp == att){ + return TRUE; + } + return FALSE; + + } + void arbcon__SetCurrentCelview(ClassID,cv) struct classheader *ClassID; struct celview *cv; *************** *** 771,776 **** --- 787,795 ---- char *srs; char buf[256]; /* printf("In SetCurrentCelview cv = %d\n",(long)cv); */ + /* fprintf(stderr,"In scc\n"); + fflush(stderr); + */ if(Gself == NULL || Gself->currentcelview == cv ) return; if(cv == NULL || Cel(cv) == NULL || cel_GetRefName(Cel(cv)) == NULL){ Gself->currentcelview = NULL; *************** *** 780,785 **** --- 799,805 ---- } else { if(cv->arb == OwnArb) return; + if(isarbcon(cv)) return; Gself->currentcelview = NULL; if(value_GetValue(Gself->ArbLinkCel)) value_SetValue(Gself->ArbLinkCel,FALSE); *************** *** 802,808 **** value_SetValue(Gself->ArbSetVisible,cel_Visible(Cel(cv)) ? VISIBLEPOS: INVISPOS); */ sprintf(buf,"Setting current celview to %s",cel_GetRefName(Cel(cv))); ! message_DisplayString(Gself->arbv,0,buf); } if(cv) arbcon_EditCurrentCelview(); } --- 822,828 ---- value_SetValue(Gself->ArbSetVisible,cel_Visible(Cel(cv)) ? VISIBLEPOS: INVISPOS); */ sprintf(buf,"Setting current celview to %s",cel_GetRefName(Cel(cv))); ! message_DisplayString(NULL,0,buf); } if(cv) arbcon_EditCurrentCelview(); } *************** *** 812,819 **** --- 832,842 ---- if(Gself != NULL && Gself->currentcelview!= NULL) { struct celview *cv; cv = Gself->currentcelview; + cel_Destroy(Cel(cv)); + /* celview_UnlinkTree(cv); celview_Destroy(cv); + */ } } static setobview(self,str,docopy) *************** *** 862,873 **** vw = parseobv(buf,objbuf); if(!class_IsTypeByName(objbuf,"dataobject")){ sprintf(buf,"No known dataobject named %s",objbuf); ! message_DisplayString(Gself->arbv,0,buf); return; } if(vw && *vw && !class_IsTypeByName(vw,"view")){ sprintf(buf,"No known view named %s",vw); ! message_DisplayString(Gself->arbv,0,buf); return; } m = malloc(strlen(buf) + 1); --- 885,896 ---- vw = parseobv(buf,objbuf); if(!class_IsTypeByName(objbuf,"dataobject")){ sprintf(buf,"No known dataobject named %s",objbuf); ! message_DisplayString(NULL,0,buf); return; } if(vw && *vw && !class_IsTypeByName(vw,"view")){ sprintf(buf,"No known view named %s",vw); ! message_DisplayString(NULL,0,buf); return; } m = malloc(strlen(buf) + 1); *************** *** 894,900 **** { if(Gself == NULL) return; if(Gself->currentcelview == NULL) { ! message_DisplayString(Gself->arbv,0,"No current cel to link to"); return; } if(value_GetValue(Gself->ArbLinkCel) == 0) --- 917,923 ---- { if(Gself == NULL) return; if(Gself->currentcelview == NULL) { ! message_DisplayString(NULL,0,"No current cel to link to"); return; } if(value_GetValue(Gself->ArbLinkCel) == 0) *************** *** 1068,1074 **** value_SetArraySize(self->Arbobviewlist,self->vwcount); value_SetNotify(self->Arbobviewlist,TRUE); value_SetStringArray(self->Arbobviewlist,self->vwlist); ! self->ArbCelListView = NULL; self->ArbCelList = text_New(); self->ArbArbList = text_New(); --- 1091,1104 ---- value_SetArraySize(self->Arbobviewlist,self->vwcount); value_SetNotify(self->Arbobviewlist,TRUE); value_SetStringArray(self->Arbobviewlist,self->vwlist); ! ! atta[0] = atom_Intern("ArbLinkCel"); ! atta[1] = atom_Intern("ArbCutCel"); ! atta[2] = atom_Intern("ArbApplicationChoice"); ! atta[3] = atom_Intern("Arbobviewlist"); ! atta[4] = atom_Intern("ArbTextEdit"); ! atta[5] = atom_Intern("copycon"); ! atta[6] = NULL; self->ArbCelListView = NULL; self->ArbCelList = text_New(); self->ArbArbList = text_New(); *************** *** 1128,1134 **** if(self->arbv == arbv) return self; last = self; } ! if(Gself != NULL) return NULL; self = arbcon_New(); self->arbv = arbv; initself(self,v); --- 1158,1166 ---- if(self->arbv == arbv) return self; last = self; } ! if(Gself != NULL){ ! return Gself; ! } self = arbcon_New(); self->arbv = arbv; initself(self,v); *************** *** 1151,1157 **** if(value_GetValue(val) == 1){ if(self->currentcelview == NULL){ value_SetValue(val,0); ! message_DisplayString(Gself->arbv,0,"No current cel to link to"); } else { DoCopy(self,TRUE); --- 1183,1189 ---- if(value_GetValue(val) == 1){ if(self->currentcelview == NULL){ value_SetValue(val,0); ! message_DisplayString(NULL,0,"No current cel to link to"); } else { DoCopy(self,TRUE); *************** *** 1162,1168 **** if(value_GetValue(val) == 1){ value_SetValue(val,0); if(Gself) ! message_DisplayString(Gself->arbv,0,"No current cel to link to"); } } else { --- 1194,1200 ---- if(value_GetValue(val) == 1){ value_SetValue(val,0); if(Gself) ! message_DisplayString(NULL,0,"No current cel to link to !"); } } else { *************** *** 1187,1193 **** char buf[256]; if(Gself != NULL && Gself->currentcelview){ sprintf(buf,"Cutting %s",cel_GetRefName(Cel(Gself->currentcelview))); ! message_DisplayString(Gself->arbv,0,buf); celview_Copy(Gself->currentcelview); arbcon_DestroyCurrentCelview(); SetNotice(buf); --- 1219,1225 ---- char buf[256]; if(Gself != NULL && Gself->currentcelview){ sprintf(buf,"Cutting %s",cel_GetRefName(Cel(Gself->currentcelview))); ! message_DisplayString(NULL,0,buf); celview_Copy(Gself->currentcelview); arbcon_DestroyCurrentCelview(); SetNotice(buf); *************** *** 1215,1221 **** curval = (cel_GetApplication(cl) == cel_APPLICATION); if((setto == 0) != (curval == 0)){ value_SetValue(val,(setto == 0) ? 1:0); ! message_DisplayString(Gself->arbv,0,"Can't change application status of existing cel"); } } else DoCopy(self,TRUE); --- 1247,1253 ---- curval = (cel_GetApplication(cl) == cel_APPLICATION); if((setto == 0) != (curval == 0)){ value_SetValue(val,(setto == 0) ? 1:0); ! message_DisplayString(NULL,0,"Can't change application status of existing cel"); } } else DoCopy(self,TRUE); *************** *** 1286,1292 **** if(createGself(self) == FALSE) Gself = NULL; } else{ ! DoCopy(Gself,TRUE); } /* user code ends here for arbcon_copycon */ } --- 1318,1335 ---- if(createGself(self) == FALSE) Gself = NULL; } else{ ! struct arbiterview *arbv =arbiterview_FindArb(v); ! if(((struct celview *)arbv)->menulist == NULL){ ! struct classinfo *viewtype = class_Load("view"); ! arbconMenus = menulist_New(); ! bind_BindList(arbconBindings, NULL , arbconMenus, viewtype); ! arbiterview_SetMenulist(arbv,arbconMenus); ! } ! /* ! fprintf(stderr,"In CopyCon\n"); ! fflush(stderr); ! */ ! DoCopy(Gself,TRUE); } /* user code ends here for arbcon_copycon */ } *************** *** 1391,1588 **** return TRUE;} /* user code begins here for Other Functions */ /* user code ends here for Other Functions */ - - #ifdef UNUSED_USER_CODE - /* user code begins here for mystuff */ - if(Gself != NULL) return NULL; - /* user code ends here for mystuff */ - /* user code begins here for ArbNewWindowCallBack */ - newwin(NULL); - /* user code ends here for ArbNewWindowCallBack */ - /* user code begins here for ArbCopyCelCallBack */ - /* user code ends here for ArbCopyCelCallBack */ - /* user code begins here for ArbEnterObjectCallBack */ - char *ss; - if((ss = value_GetString(self->ArbEnterView)) != NULL && *ss){ - value_SetString(self->ArbEnterView,""); - } - if(Gself->currentcelview != NULL) - arbcon_SetCurrentCelview(NULL); - /* user code ends here for ArbEnterObjectCallBack */ - /* user code begins here for ArbEnterViewCallBack */ - /*Unimportant */ - if(Gself->currentcelview != NULL && value_GetValue(self->ArbLinkCel) == 0) - arbcon_SetCurrentCelview(NULL); - /* user code ends here for ArbEnterViewCallBack */ - /* user code begins here for ArbNameChoiceCallBack */ - - char buf[256],*str,*oldstr,res[256]; - str = value_GetString(Gself->ArbNameChoice); - if(str && *str){ - if(self->currentcelview && self->CurrentArbiterview){ - /* automatic renaming code */ - oldstr = cel_GetRefName(Cel(Gself->currentcelview)); - if(str != oldstr && str && *str && oldstr && *oldstr && strcmp(str,oldstr) != 0){ - if(value_GetValue(self->ArbLinkCel) == 1){ - ArbCopyCelCallBack(self,self->ArbCopyCel,0,0); - value_SetString(Gself->ArbNameChoice,oldstr); - } - else { - sprintf(buf,"rename %s to %s? (y) ",oldstr,str); - if(message_AskForString(NULL,0,buf,NULL,res,256) == -1 ) return; - if(*res == '\0' || *res == 'Y' || *res == 'y'){ - sprintf(buf,"renaming %s to %s",oldstr,str); - message_DisplayString(Gself->arbv,0,buf); - SetName(self->currentcelview,self->CurrentArbiterview,NULL); - } - else { - sprintf(buf,"copy new %s (%s)? (y) ", value_GetString(Gself->ArbEnterObject),str); - if(message_AskForString(NULL,0,buf,NULL,res,256) == -1 ) return; - if(*res == '\0' || *res == 'Y' || *res == 'y'){ - Gself->currentcelview = NULL; - ArbCopyCelCallBack(self,self->ArbCopyCel,0,0); - arbcon_EditCurrentCelview(); - } - else { - message_DisplayString(Gself->arbv,0,"Canceling Change"); - value_SetString(Gself->ArbNameChoice,oldstr); - } - } - } - } - } - else { - ArbCopyCelCallBack(self,self->ArbCopyCel,0,0); - } - } - /* user code ends here for ArbNameChoiceCallBack */ - /* user code begins here for arbcon_start */ - - /* - Style = style_New(); - style_SetName(Style, "center"); - stylesheet_Add(tst->styleSheet, Style); - style_AddNewFontFace(self->Style, fontdesc_Center); - */ - - /* user code ends here for arbcon_start */ - /* user code begins here for ArbSetCelCallBack */ - char buf[256]; - if(self->currentcelview && self->CurrentArbiterview && value_GetString(Gself->ArbNameChoice)){ - /* arbcon_InitCel(self->currentcelview,self->currentcelview->arb);*/ - sprintf(buf,"renaming %s to %s",cel_GetRefName(Cel(Gself->currentcelview)), - value_GetString(Gself->ArbNameChoice)); - message_DisplayString(Gself->arbv,0,buf); - SetName(self->currentcelview,self->CurrentArbiterview,NULL); - } - #ifdef AUTOCOPY - else { - ArbCopyCelCallBack(self,self->ArbCopyCel,0,0); - } - #endif /* AUTOCOPY */ - /* user code ends here for ArbSetCelCallBack */ - /* user code begins here for ArbEditResourceCallBack */ - arbcon_EditCurrentCelview(); - /* user code ends here for ArbEditResourceCallBack */ - /* user code begins here for ArbSaveResourceCallBack */ - arbcon_SaveCurrentCelview(); - /* user code ends here for ArbSaveResourceCallBack */ - /* user code begins here for ArbSetVisibleCallBack */ - struct cel *cl; - if(Gself != NULL && Gself->currentcelview != NULL && (cl = Cel(Gself->currentcelview)) != NULL){ - if(value_GetValue(self->ArbSetVisible) == INVISPOS){ - if(cel_Visible(cl)) cel_SetInvisible(cl); - } - else if(!cel_Visible(cl)) cel_SetVisible(cl); - } - /* user code ends here for ArbSetVisibleCallBack */ - /* user code begins here for ArbObjectWheelCallBack */ - struct celview *cv; - struct cel *cl; - char *srs; - int i; - int obptr = value_GetValue(Gself->ArbObjectWheel); - - cv = self->currentcelview; - if(cv != NULL) cl = Cel(cv); - else cl = NULL; - if(obptr == EXISTINGOBJECT ) { - if(cl && cel_GetObjectName(cl)) - value_SetString(self->ArbEnterObject, cel_GetObjectName(cl)); - else value_SetString(self->ArbEnterObject,NULL); - } - else if(obptr == 0) value_SetString(self->ArbEnterObject,NULL); - else value_SetString(self->ArbEnterObject,Gself->obnamelist[obptr]); - if(cl && obptr == EXISTINGOBJECT){ - if((srs = cel_GetViewName(cl)) != NULL && - (i = findinlist(Gself->vwlist,Gself->vwcount,srs)) != -1) - value_SetValue(Gself->ArbViewWheel,i); - else value_SetValue(Gself->ArbViewWheel,1); - if((srs = cel_GetRefName(cl)) != NULL) - value_SetString(Gself->ArbNameChoice,srs); - } - else value_SetValue(Gself->ArbViewWheel,1); - /* user code ends here for ArbObjectWheelCallBack */ - /* user code begins here for ArbViewWheelCallBack */ - int vwptr = value_GetValue(Gself->ArbViewWheel); - int obptr = value_GetValue(Gself->ArbObjectWheel); - if(vwptr == DEFAULTVIEW){ - if( obptr == EXISTINGOBJECT - && self->currentcelview && Cel(self->currentcelview) && cel_GetViewName(Cel(self->currentcelview))) - value_SetString(self->ArbEnterView, cel_GetViewName(Cel(self->currentcelview))); - else value_SetString(self->ArbEnterView,NULL); - } - else if (vwptr == WRITEINVIEW) - value_SetString(self->ArbEnterView,NULL); - else value_SetString(self->ArbEnterView,Gself->vwlist[vwptr]); - value_SetString(Gself->ArbNameChoice,""); - - /* user code ends here for ArbViewWheelCallBack */ - /* user code begins here for ArbCreateConCallBack */ - if(Gself->CurrentArbiterview) - arbiterview_CreateCon(Gself->CurrentArbiterview,Gself->ArbText); - /* user code ends here for ArbCreateConCallBack */ - /* user code begins here for ArbCopyModeCallBack */ - if(Gself && Gself->CurrentArbiterview) - arbiterview_SetCopyMode(Gself->CurrentArbiterview,value_GetValue(Gself->ArbCopyMode)); - /* user code ends here for ArbCopyModeCallBack */ - /* user code begins here for ArbWriteButtonCallBack */ - - char frs[512]; - FILE *f; - if(message_AskForString(NULL,0,"File to save",self->filename,frs,256) == -1 || - *frs == '\0') return; - filetype_CanonicalizeFilename(self->filename, frs, sizeof(self->filename) - 1); - if(*(self->filename) == '\0' || (f = fopen(self->filename,"w")) == NULL) { - sprintf(frs,"ERROR:Can't Write %s",self->filename); - message_DisplayString(NULL,0,frs); - return; - } - /* printf("Writeing %s \n",class_GetTypeName(Arbiter(self))); */ - arbiter_Write(Arbiter(Gself->CurrentArbiterview),f,im_GetWriteID(),0); - fclose(f); - strcpy(self->filename,frs); - /* user code ends here for ArbWriteButtonCallBack */ - /* user code begins here for ArbReadButtonCallBack */ - char frs[1024]; - if(self->CurrentArbiterview && completion_GetFilename(Gself->v,"File to read: ",NULL,frs,256,FALSE,TRUE) == -1) - return; - arbiterview_ArbRead(self->CurrentArbiterview,frs); - /* user code ends here for ArbReadButtonCallBack */ - /* user code begins here for ArbDestroyCelCallBack */ - arbcon_DestroyCurrentCelview(); - /* user code ends here for ArbDestroyCelCallBack */ - /* user code begins here for ArbViewChoiceCallBack */ - #if 0 - if(value_GetValue(self->ArbViewChoice) == NamedView){ - value_SetArraySize(self->ArbViewWheel,self->vwcount); - value_SetStringArray(self->ArbViewWheel,self->vwlist); - } - else { - value_SetArraySize(self->ArbViewWheel,0); - value_SetStringArray(self->ArbViewWheel,NULL); - } - #endif /* 0 */ - /* user code ends here for ArbViewChoiceCallBack */ - - #endif /* UNUSED_USER_CODE */ --- 1434,1436 ---- *** atk/lset/arbiter.c Wed Nov 22 12:16:17 1989 --- atk/lset/arbiter.c.NEW Wed Apr 3 21:20:03 1991 *************** *** 2,14 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/lset/RCS/arbiter.c,v 2.3 89/02/17 16:32:21 ghoti Exp $ */ /* $ACIS: $ */ ! /* $Source: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/lset/RCS/arbiter.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/lset/RCS/arbiter.c,v 2.3 89/02/17 16:32:21 ghoti Exp $ "; #endif /* lint */ #include #include --- 2,127 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/lset/RCS/arbiter.c,v 2.4 91/04/03 11:19:42 tpn Exp $ */ /* $ACIS: $ */ ! /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/lset/RCS/arbiter.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/lset/RCS/arbiter.c,v 2.4 91/04/03 11:19:42 tpn Exp $ "; #endif /* lint */ #include + #include #include + struct arbiter *master; + + struct arbiter *arbiter__GetMaster(classID) + struct classheader *classID; + { + return master; + } + struct arbiter *arbiter__SetMaster(classID,newmaster) + struct classheader *classID; + struct arbiter *newmaster; + { + struct arbiter *oldmaster; + oldmaster = master; + master = newmaster; + return oldmaster; + } + boolean arbiter__InitializeClass(classID) + struct classheader *classID; + { + master = NULL; + return TRUE; + } + + long arbiter__Read(self, file, id) + struct arbiter *self; + FILE *file; + long id; + { + long result; /* set self as master so that as child cells are read, they will + call declare read on self, thus the arbiter will find all + of it's children */ + struct arbiter *lastmaster; + lastmaster = arbiter_SetMaster(self); + arbiter_SetArbiter(self,lastmaster); + self->first = (struct cel *)self; + result = super_Read(self, file, id); + arbiter_SetMaster(lastmaster); + arbiter_SetArbiter(self,lastmaster); + arbiter_ReadObjects(self); + return result; + } + long arbiter__ReadFile(self,thisFile) + struct arbiter *self; + FILE *thisFile; + { + long result; /* set self as master so that as child cells are read, they will + call declare read on self, thus the arbiter will find all + of it's children */ + struct arbiter *lastmaster; + lastmaster = arbiter_SetMaster(self); + arbiter_SetArbiter(self,lastmaster); + self->first = (struct cel *)self; + result = super_ReadFile(self, thisFile); + arbiter_SetMaster(lastmaster); + arbiter_SetArbiter(self,lastmaster); + arbiter_ReadObjects(self); + return result; + } + FILE *arbiter__DeclareRead(self,cel) + struct arbiter *self; + struct cel *cel; + { + #ifdef DEBUG + fprintf(stdout,"declaring %d(%s) to %d(%s)\n",cel,cel_GetRefName(cel),self,arbiter_GetRefName(self));fflush(stdout); + #endif /* DEBUG */ + if(cel != (struct cel *) self){ + cel->chain = self->first; + self->first = cel; + } + else if(arbiter_GetArbiter(self) && arbiter_GetArbiter(self) != self) + arbiter_DeclareRead(arbiter_GetArbiter(self),(struct cel *)self); + + return NULL; + } + struct cel *arbiter__FindChildCelByName(self,name) + struct arbiter *self; + char *name; + { + struct cel *cel,*ncel; + char *tname; + cel = arbiter_GetFirst(self); + while(cel != (struct cel *) self){ + if((tname = cel_GetRefName(cel)) != NULL && + strcmp(tname,name) == 0) + return cel; + ncel = cel_GetNextChain(cel); + if(ncel == cel) return NULL; /* shouldn't happen */ + cel = ncel; + } + return NULL; + } + struct dataobject *arbiter__FindChildObjectByName(self,name) + struct arbiter *self; + char *name; + { + struct cel *cel; + cel = arbiter_FindChildCelByName(self,name); + if(cel != NULL) return cel_GetObject(cel); + return NULL; + } + void arbiter__ReadObjects(self) + struct arbiter *self; + { + /* for subclass to use */ + } + boolean arbiter__InitializeObject(classID, self) + struct classheader *classID; + struct arbiter *self; + { + self->first = (struct cel *)self; + return TRUE; + } *** atk/lset/arbiter.ch Wed Nov 22 12:16:05 1989 --- atk/lset/arbiter.ch.NEW Wed Apr 3 21:20:04 1991 *************** *** 2,14 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/lset/RCS/arbiter.ch,v 2.4 89/02/17 16:32:25 ghoti Exp $ */ /* $ACIS: $ */ ! /* $Source: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/lset/RCS/arbiter.ch,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsid_arbiter_H = "$Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/lset/RCS/arbiter.ch,v 2.4 89/02/17 16:32:25 ghoti Exp $ "; #endif /* !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) */ class arbiter : cel { }; --- 2,31 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/lset/RCS/arbiter.ch,v 2.5 91/04/03 11:19:46 tpn Exp $ */ /* $ACIS: $ */ ! /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/lset/RCS/arbiter.ch,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsid_arbiter_H = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/lset/RCS/arbiter.ch,v 2.5 91/04/03 11:19:46 tpn Exp $ "; #endif /* !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) */ class arbiter : cel { + macromethods: + GetFirst() ((self)->first) + overrides: + Read (FILE *file, long id) returns long; + ReadFile(FILE *file) returns long; + methods: + DeclareRead(struct cel *cel) returns FILE *; + FindChildCelByName(char *name) returns struct cel *; + FindChildObjectByName(char *name) returns struct dataobject *; + ReadObjects(); + classprocedures: + GetMaster() returns struct arbiter *; + SetMaster(struct thisobject *newmaster) returns struct arbiter *; + InitializeClass() returns boolean; + InitializeObject(struct thisobject *self) returns boolean; + data: + struct cel *first; }; *** atk/lset/arbiterv.c Mon Aug 6 11:07:06 1990 --- atk/lset/arbiterv.c.NEW Thu Apr 25 16:16:27 1991 *************** *** 2,13 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/lset/RCS/arbiterv.c,v 2.17 90/06/06 14:44:05 gk5g Exp $ */ /* $ACIS: $ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/lset/RCS/arbiterv.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/lset/RCS/arbiterv.c,v 2.17 90/06/06 14:44:05 gk5g Exp $ "; #endif /* lint */ #include --- 2,13 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/lset/RCS/arbiterv.c,v 2.19 1991/04/25 19:42:03 tpn Exp $ */ /* $ACIS: $ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/lset/RCS/arbiterv.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/lset/RCS/arbiterv.c,v 2.19 1991/04/25 19:42:03 tpn Exp $ "; #endif /* lint */ #include *************** *** 200,206 **** mktemp(fnm); im_SetProcessCursor(WaitCursor); ! if(strcmp(class_GetTypeName(truechild),"frame") == 0 && (buff= frame_GetBuffer(((struct frame *) truechild)))!= NULL && (dat = buffer_GetData(buff)) != NULL){ int ver; --- 200,206 ---- mktemp(fnm); im_SetProcessCursor(WaitCursor); ! if(class_IsTypeByName(class_GetTypeName(truechild),"frame") && (buff= frame_GetBuffer(((struct frame *) truechild)))!= NULL && (dat = buffer_GetData(buff)) != NULL){ int ver; *************** *** 366,372 **** arbcon_DeleteArbiter(self); } ! addlist(self,cv) struct arbiterview *self; struct celview *cv; { --- 366,372 ---- arbcon_DeleteArbiter(self); } ! static addlist(self,cv) struct arbiterview *self; struct celview *cv; { *************** *** 384,390 **** arbiterview_NotifyObservers(self,0); return self->celcount - 1; } ! deletelist(self,cv) struct arbiterview *self; struct celview *cv; { --- 384,390 ---- arbiterview_NotifyObservers(self,0); return self->celcount - 1; } ! static deletelist(self,cv) struct arbiterview *self; struct celview *cv; { *************** *** 457,462 **** --- 457,463 ---- struct atomlist *al; struct celview **v; register int i ; + struct atom *at; char *ObjectName,buf[1024]; strcpy(buf,name); ObjectName = buf; *************** *** 476,486 **** #ifdef DEBUG printf("Self = %ld\n",self); #endif /* DEBUG */ if(self){ for(v = (self->celviewlist), i = 0; i < self->celcount; v++,i++){ cl = Cel((*v)); ! st = cel_GetRefName(cl); ! if(*st == *ObjectName && (strcmp(st,ObjectName) == 0)){ #ifdef DEBUG printf("Found via arbiter %s = %s (%s)- Returning %d\n",cel_GetRefName(cl),ObjectName,class_GetTypeName(cel_GetObject(cl)),cel_GetObject(cl)); #endif /* DEBUG */ --- 477,487 ---- #ifdef DEBUG printf("Self = %ld\n",self); #endif /* DEBUG */ + at = atom_Intern(name); if(self){ for(v = (self->celviewlist), i = 0; i < self->celcount; v++,i++){ cl = Cel((*v)); ! if(at == cel_GetRefAtom(cl)){ #ifdef DEBUG printf("Found via arbiter %s = %s (%s)- Returning %d\n",cel_GetRefName(cl),ObjectName,class_GetTypeName(cel_GetObject(cl)),cel_GetObject(cl)); #endif /* DEBUG */ *************** *** 488,493 **** --- 489,506 ---- } } } + { /* support the new child finding stuff in arbiter */ + struct cel *cel; + struct arbiter *fcel; + if((fcel = (struct arbiter *) self->header.view.dataobject) != NULL){ + + for(cel = arbiter_GetFirst(fcel); cel != (struct cel *)fcel; cel = cel_GetNextChain(cel)){ + if(at == cel_GetRefAtom(cel)){ + return cel_GetObject(cel); + } + } + } + } sprintf(ss,"DOBJ-%s",ObjectName); al = atomlist_StringToAtomlist(ss); if(rm_GetResource(al,al,a_vp,&val)) { *************** *** 664,670 **** */ if(((struct view *)self)->parent == NULL){ if((arbiterview_GetTrueChild(self) != NULL) && ! (strcmp(class_GetTypeName(arbiterview_GetTrueChild(self)),"frame") == 0) && arbiterview_GetTrueChild(self)->parent != NULL && (arbiterview_GetApplication(self) != NULL) && ((arbiterview_GetApplication(self))->parent != NULL)){ --- 677,684 ---- */ if(((struct view *)self)->parent == NULL){ if((arbiterview_GetTrueChild(self) != NULL) && ! class_IsTypeByName(class_GetTypeName(arbiterview_GetTrueChild(self)),"frame") && ! /* (strcmp(class_GetTypeName(arbiterview_GetTrueChild(self)),"frame") == 0) && */ arbiterview_GetTrueChild(self)->parent != NULL && (arbiterview_GetApplication(self) != NULL) && ((arbiterview_GetApplication(self))->parent != NULL)){ *************** *** 712,719 **** self = (struct arbiterview *) view_WantHandler(vw,"arbiterview"); if(self == NULL && (im = view_GetIM(vw)) != NULL && (frame = (struct frame *)(im->topLevel)) != NULL && ! strcmp(class_GetTypeName(frame),"frame") == 0 && ! (frame_GetChildView(frame)) != NULL){ for(self = firstlink; self != NULL ; self = self->next){ if(frame == (struct frame *) arbiterview_GetTrueChild(self)){ return(self); --- 726,734 ---- self = (struct arbiterview *) view_WantHandler(vw,"arbiterview"); if(self == NULL && (im = view_GetIM(vw)) != NULL && (frame = (struct frame *)(im->topLevel)) != NULL && ! class_IsTypeByName(class_GetTypeName(frame),"frame") && ! /* strcmp(class_GetTypeName(frame),"frame") == 0 && */ ! frame_GetChildView(frame) != NULL){ for(self = firstlink; self != NULL ; self = self->next){ if(frame == (struct frame *) arbiterview_GetTrueChild(self)){ return(self); *** atk/lset/arbiterv.ch Wed Nov 22 12:16:02 1989 --- atk/lset/arbiterv.ch.NEW Thu Apr 25 16:16:31 1991 *************** *** 2,13 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/lset/RCS/arbiterv.ch,v 2.8 89/05/05 13:12:04 tpn Exp $ */ /* $ACIS: $ */ ! /* $Source: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/lset/RCS/arbiterv.ch,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsid_arbiterview_H = "$Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/lset/RCS/arbiterv.ch,v 2.8 89/05/05 13:12:04 tpn Exp $ "; #endif /* !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) */ #define arbiterview_SEPCHAR ':' --- 2,13 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/lset/RCS/arbiterv.ch,v 2.8 1989/05/05 13:12:04 tpn Exp $ */ /* $ACIS: $ */ ! /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/lset/RCS/arbiterv.ch,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsid_arbiterview_H = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/lset/RCS/arbiterv.ch,v 2.8 1989/05/05 13:12:04 tpn Exp $ "; #endif /* !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) */ #define arbiterview_SEPCHAR ':' *** atk/lset/cel.ch Mon Aug 6 11:07:07 1990 --- atk/lset/cel.ch.NEW Wed Apr 3 21:20:07 1991 *************** *** 2,13 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/lset/RCS/cel.ch,v 2.10 90/06/06 14:24:08 rr2b Exp $ */ /* $ACIS: $ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/lset/RCS/cel.ch,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsid_cel_H = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/lset/RCS/cel.ch,v 2.10 90/06/06 14:24:08 rr2b Exp $ "; #endif /* !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) */ #include --- 2,13 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/lset/RCS/cel.ch,v 2.11 91/04/03 11:19:16 tpn Exp $ */ /* $ACIS: $ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/lset/RCS/cel.ch,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsid_cel_H = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/lset/RCS/cel.ch,v 2.11 91/04/03 11:19:16 tpn Exp $ "; #endif /* !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) */ #include *************** *** 55,60 **** --- 55,64 ---- GetLongAtt(char *attname) returns long; SetLongAtt(char *attname,long val); SetStringAtt(char *attname,char *attval); + ReadSup (FILE *file, long id) returns long; + WriteSup (FILE *file, long writeid, int level) returns long; + ReadFile(FILE *file) returns long; + InitDefault() returns long; macromethods: GetRefName() (self->refname) GetViewName() (self->viewType) *************** *** 70,75 **** --- 74,89 ---- SetInvisible() cel_SetVisibilityBit(self,cel_INVISIBLE) Visible() (self->mode == cel_VISIBLE) SetNoSave(val) (self->NoSave = val) + SetDefaultStream(S) (self->defaultStream = S) + SetInitFile(S) (self->initfile = S) + SetWriteChild(TF) (self->WriteChild = TF) + GetDefaultStream() (self->defaultStream) + GetInitFile() (self->initfile) + GetWriteChild() (self->WriteChild ) + GetReadCount() (self->count) + GetNextChain() ((self)->chain) + GetArbiter() ((self)->ab) + SetArbiter(AA) ((self)->ab = (AA)) data: struct atom *viewatm,*dataatm,*refatm,*linkatm; char *viewType, *dataType, *refname, *linkname; *************** *** 80,83 **** --- 94,102 ---- boolean readfromfile,usedefaultview,NoSave; struct text *script; int mode; + char *defaultStream,*initfile; + long count; + boolean WriteChild; + struct cel *chain; + struct arbiter *ab; }; *** atk/lset/celv.c Fri Dec 21 14:55:49 1990 --- atk/lset/celv.c.NEW Thu Apr 25 16:16:33 1991 *************** *** 2,13 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/lset/RCS/celv.c,v 2.24 90/05/08 15:59:14 gk5g Exp Locker: tpn $ */ /* $ACIS: $ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/lset/RCS/celv.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/lset/RCS/celv.c,v 2.24 90/05/08 15:59:14 gk5g Exp Locker: tpn $ "; #endif /* lint */ #define UNSET 0 --- 2,13 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/lset/RCS/celv.c,v 2.26 1991/04/25 19:42:03 tpn Exp $ */ /* $ACIS: $ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/lset/RCS/celv.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/lset/RCS/celv.c,v 2.26 1991/04/25 19:42:03 tpn Exp $ "; #endif /* lint */ #define UNSET 0 *************** *** 45,51 **** #include #include #include ! #include "celv.eh" #include /* #define DEBUG */ #define DataObject(A) (A->header.view.dataobject) --- 45,51 ---- #include #include #include ! #include #include /* #define DEBUG */ #define DataObject(A) (A->header.view.dataobject) *************** *** 70,76 **** #define SCALEWID #define DOINDENT(SELF) (SELF->drawing || SELF->resizing) #define celview_COVERCHILD 1 ! scaleoverlay(self,ov,or) struct celview *self; struct overlay *ov; struct rectangle *or; --- 70,76 ---- #define SCALEWID #define DOINDENT(SELF) (SELF->drawing || SELF->resizing) #define celview_COVERCHILD 1 ! static scaleoverlay(self,ov,or) struct celview *self; struct overlay *ov; struct rectangle *or; *************** *** 186,191 **** --- 186,197 ---- *dHeight = 0; return(view_Fixed); } + if(cel_GetReadCount(Cel(self)) == 0 && + (cel_GetDefaultStream(Cel(self)) != NULL || + cel_GetInitFile(Cel(self)) != NULL)){ + cel_InitDefault(Cel(self)); + celview_makeview(self,Cel(self)); + } /* if(self->child && self->mode == celview_FirstUpdate){ view_LinkTree(self->child,self); *************** *** 229,234 **** --- 235,246 ---- else if(self->desw != UNSET) pass = view_WidthSet; } if(self->child )val = view_DesiredSize(self->child, pwidth , pheight , pass, dWidth, dHeight); + else if( cel_GetDefaultStream(Data(self)) || cel_GetInitFile(Data(self)) ){ + val = view_HeightFlexible | view_WidthFlexible; + *dWidth = width; + *dHeight = height; + return val; + } else{ val = view_HeightFlexible | view_WidthFlexible; /* *************** *** 266,272 **** } ! UpdateDrawing(self) struct celview *self; { if(self->OldMode != self->drawing || self->child == NULL){ --- 278,284 ---- } ! static UpdateDrawing(self) struct celview *self; { if(self->OldMode != self->drawing || self->child == NULL){ *************** *** 352,358 **** if(self->application != ls->application ){ self->application = ls->application; if(self->truechild){ ! if(ls->application == cel_APPLICATION || ls->application == cel_VALUE){ if((self->child = view_GetApplicationLayer(self->truechild)) == NULL) self->child = self->truechild; else view_LinkTree(self->child,self); --- 364,370 ---- if(self->application != ls->application ){ self->application = ls->application; if(self->truechild){ ! if(ls->application == cel_APPLICATION || ls->application == cel_VALUE || self->AddAppLayer){ if((self->child = view_GetApplicationLayer(self->truechild)) == NULL) self->child = self->truechild; else view_LinkTree(self->child,self); *************** *** 565,570 **** --- 577,587 ---- struct overlay *ov,*lastov; currec = self->enclosingRect; if(self->mode == celview_NoUpdate) return; + if(cel_GetReadCount(Cel(self)) == 0 && + (cel_GetDefaultStream(Cel(self)) != NULL || + cel_GetInitFile(Cel(self)) != NULL)){ + cel_InitDefault(Cel(self)); + } if(self->arb == NULL && !self->TopLevel && (self->arb = arbiterview_FindArb(self->header.view.parent)) != NULL){ arbiterview_InitCell(self->arb,self); *************** *** 581,603 **** self->enclosingRect.top = 0; self->enclosingRect.left = 0; self->enclosingRect.width = celview_GetLogicalWidth(self) ; self->enclosingRect.height = celview_GetLogicalHeight(self) ; ! /* if(DOINDENT(self)){ */ ! (self->enclosingRect.width)--; ! (self->enclosingRect.height)--; ! /* } */ ! if(type != view_Remove) { ! UpdateCursors(self); ! if(type != view_MoveNoRedraw ){ ! celview_SetTransferMode(self,graphic_WHITE); ! celview_EraseRect(self,&(self->enclosingRect)); ! celview_SetTransferMode(self,graphic_INVERT); ! if(self->drawing){ ! celview_DrawRect(self,&(self->enclosingRect)); ! } } ! } ! /* UpdateDrawing(self); */ self->OldMode = self->drawing; /* self->childRect = self->enclosingRect; */ celview_GetLogicalBounds(self,&(self->childRect)); --- 598,620 ---- self->enclosingRect.top = 0; self->enclosingRect.left = 0; self->enclosingRect.width = celview_GetLogicalWidth(self) ; self->enclosingRect.height = celview_GetLogicalHeight(self) ; ! /* if(DOINDENT(self)){ */ ! (self->enclosingRect.width)--; ! (self->enclosingRect.height)--; ! /* } */ ! if(type != view_Remove) { ! UpdateCursors(self); ! if(type != view_MoveNoRedraw){ ! celview_SetTransferMode(self,graphic_WHITE); ! celview_EraseRect(self,&(self->enclosingRect)); ! celview_SetTransferMode(self,graphic_INVERT); ! if(self->drawing){ ! celview_DrawRect(self,&(self->enclosingRect)); ! } ! } } ! /* UpdateDrawing(self); */ self->OldMode = self->drawing; /* self->childRect = self->enclosingRect; */ celview_GetLogicalBounds(self,&(self->childRect)); *************** *** 691,696 **** --- 708,714 ---- self->TopLevel = FALSE; self->olist = NULL; self->rarb = NULL; + self->AddAppLayer = FALSE; menulist_SetMask(self->menus,1); return TRUE; } *************** *** 825,831 **** {"",0} }; ! lookuptype(ty) char *ty; { struct types *tp; --- 843,849 ---- {"",0} }; ! static lookuptype(ty) char *ty; { struct types *tp; *************** *** 835,841 **** return 0; } ! char * atomlisttostring(al) struct atomlist *al; /* should be an atomlist call */ { --- 853,859 ---- return 0; } ! static char * atomlisttostring(al) struct atomlist *al; /* should be an atomlist call */ { *************** *** 913,919 **** resources[x].found = FALSE; } } ! editresourceList( self, resources,askres ) struct celview * self; struct resourceList * resources; int askres; --- 931,937 ---- resources[x].found = FALSE; } } ! static editresourceList( self, resources,askres ) struct celview * self; struct resourceList * resources; int askres; *************** *** 955,961 **** SKIPTOSET(S1,C2,S2,tmp);\ *S2++ ; *tmp = '\0' ! boolean StringToResourceList(rl,str) struct resourceList *rl; char *str; { --- 973,979 ---- SKIPTOSET(S1,C2,S2,tmp);\ *S2++ ; *tmp = '\0' ! static boolean StringToResourceList(rl,str) struct resourceList *rl; char *str; { *************** *** 1053,1059 **** celview_WantUpdate(self,self); } /* #define DEBUG */ ! PostParameters(self) struct celview *self; { int len; --- 1071,1077 ---- celview_WantUpdate(self,self); } /* #define DEBUG */ ! static PostParameters(self) struct celview *self; { int len; *************** *** 1399,1404 **** --- 1417,1424 ---- /* NO LONGER assumes the parent is also observing the cel and will destroy the celview */ if(parent == NULL) self->truechild = NULL; else celview_UnlinkTree(self); + super_ObservedChanged(self,changed,value); /* sets dataobject to NULL, so remove observer + won't be called when the view is destroyed */ celview_Destroy(self); } else if(parent == NULL) *** atk/lset/celv.ch Fri Dec 21 14:55:51 1990 --- atk/lset/celv.ch.NEW Wed Apr 3 21:20:14 1991 *************** *** 2,13 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/lset/RCS/celv.ch,v 2.10 90/10/25 14:02:32 wjh Exp $ */ /* $ACIS: $ */ ! /* $Source: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/lset/RCS/celv.ch,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsid_celview_H = "$Header: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/lset/RCS/celv.ch,v 2.10 90/10/25 14:02:32 wjh Exp $ "; #endif /* !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) */ #define celview_UnInitialized 0 --- 2,13 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/lset/RCS/celv.ch,v 2.11 91/04/03 11:19:32 tpn Exp $ */ /* $ACIS: $ */ ! /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/lset/RCS/celv.ch,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsid_celview_H = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/lset/RCS/celv.ch,v 2.11 91/04/03 11:19:32 tpn Exp $ "; #endif /* !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) */ #define celview_UnInitialized 0 *************** *** 65,70 **** --- 65,72 ---- GetRemoteArb() ((self)->rarb) SetRemoteArb(Arb) ((self)->rarb = (Arb)) GetCel() (struct cel *) celview_GetDataObject(self) + GetAppFlag ((self)->AddAppLayer) + SetAppFlag(VAL) ((self)->AddAppLayer = (VAL)) classprocedures: InitializeClass()returns boolean; FinalizeObject(struct cel *self); *************** *** 96,100 **** --- 98,103 ---- struct rectangle enclosingRect,childRect; struct overlay *olist; boolean TopLevel; + boolean AddAppLayer; /* Add an application layer, regardless of flag in cel */ }; *** atk/lset/lsetv.c Mon Aug 6 11:07:15 1990 --- atk/lset/lsetv.c.NEW Thu Apr 25 16:16:35 1991 *************** *** 2,13 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/lset/RCS/lsetv.c,v 2.10 90/06/29 09:59:38 rr2b Exp $ */ /* $ACIS: $ */ ! /* $Source: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/lset/RCS/lsetv.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/lset/RCS/lsetv.c,v 2.10 90/06/29 09:59:38 rr2b Exp $ "; #endif /* lint */ --- 2,13 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/lset/RCS/lsetv.c,v 2.11 1991/04/25 19:42:03 tpn Exp $ */ /* $ACIS: $ */ ! /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/lset/RCS/lsetv.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/lset/RCS/lsetv.c,v 2.11 1991/04/25 19:42:03 tpn Exp $ "; #endif /* lint */ *************** *** 55,61 **** {"",0} }; ! lookuptype(ty) char *ty; { struct types *tp; --- 55,61 ---- {"",0} }; ! static lookuptype(ty) char *ty; { struct types *tp; *************** *** 124,130 **** self->mode = lsetview_IsSplit; lsetview_WantUpdate(self,self); } ! dolink(self) struct lsetview *self; { struct lset *ls; --- 124,130 ---- self->mode = lsetview_IsSplit; lsetview_WantUpdate(self,self); } ! static dolink(self) struct lsetview *self; { struct lset *ls; *** atk/lset/mkcon.c Fri Dec 21 14:55:54 1990 --- atk/lset/mkcon.c.NEW Wed Apr 3 21:20:16 1991 *************** *** 4,25 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/lset/RCS/mkcon.c,v 2.16 90/09/21 11:47:54 tpn Exp $ */ /* $ACIS: $ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/lset/RCS/mkcon.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/lset/RCS/mkcon.c,v 2.16 90/09/21 11:47:54 tpn Exp $ "; #endif /* lint */ #include #include #include - #include /* sys/file.h */ #include extern char *AndrewDir(); ! #define AWKPROG AndrewDir("/lib/arbiters/conpros.awk") #define MAKEFILE AndrewDir("/lib/arbiters/makefile.arb") #define START "* user code begins here for " #define END "* user code ends here for " --- 4,64 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/lset/RCS/mkcon.c,v 2.19 91/04/03 11:19:59 tpn Exp $ */ /* $ACIS: $ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/lset/RCS/mkcon.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/lset/RCS/mkcon.c,v 2.19 91/04/03 11:19:59 tpn Exp $ "; #endif /* lint */ + #include /* sys/file.h */ #include #include #include #include + #include extern char *AndrewDir(); ! char *cls,*viewname,*oldcls,*oldvw; ! static char defstring[] = {"\ ! usage: createcon <-C ClassName(:oldclassname)> <-F FunctionName> <-T Title> <-O ShellScriptName> <-M> <-I> <-V Viewname(:oldviewname)> <-W> <-Help> \n\ ! Explanation of Arguments\n\ ! -C ClassName(:oldclassname) \n\ ! Sets the name of the class for createcon to create\n\ ! If the source file contains a control button view,\n\ ! it will default to the class given there.\n\ ! If an old classname is given, it will merge in the information from that file\n\ ! -F FunctionName\n\ ! Sets the name of the initialzation function \n\ ! If the source file contains a control button view,\n\ ! it will default to the function given there.\n\ ! If used w/ -I, classname_FunctionName will be used as the initialization method,\n\ ! which will default to classname_InitApp.\n\ ! -O ShellScriptName \n\ ! Tells createcon to create a shell script that will use runadew\n\ ! to run the application in stand-alone mode.\n\ ! -T Title \n\ ! Sets the title to use when the application is run stand alone with\n\ ! the shell script created with -O.\n\ ! -M \n\ ! Forces the creation of a new Imakefile, even if one already exists.\n\ ! The old Makefile is moved to Makefile.old\n\ ! -I \n\ ! Creates an inset rather than a controller. The callbacks and pointers\n\ ! will be placed in the view. The -C argument will specify the name of\n\ ! the dataobject to create. Control buttons are supported but unnecessary.\n\ ! -V Viewname(:oldviewname) \n\ ! If -I is specified, -V can be used to specify the name of the view to create.\n\ ! By default, a 'v' will be appended to the dataobject name.\n\ ! If an old viewname is given, it will merge in the information from that file\n\ ! -W\n\ ! If -I is specified, -W will indicate that the datastream describing the object\n\ ! will be written when the file containing the object is saved. \n\ ! -Help\n\ ! Display this help message.\n\ ! "}; #define AWKPROG AndrewDir("/lib/arbiters/conpros.awk") + #define INSETAWKPROG AndrewDir("/lib/arbiters/instpros.awk") #define MAKEFILE AndrewDir("/lib/arbiters/makefile.arb") #define START "* user code begins here for " #define END "* user code ends here for " *************** *** 32,39 **** struct stf *next,*bro; }; static char Imakebase[] = "\ - DOBJS = %s.do\n\ - IHFILES = %s.ih\n\ NormalObjectRule()\n\ NormalATKRule()\n\ InstallClassFiles($(DOBJS),$(IHFILES))\n\ --- 71,76 ---- *************** *** 51,57 **** fi\n\ make\n\ "; ! void ws(s,f) struct stf *s; FILE *f; --- 88,101 ---- fi\n\ make\n\ "; ! static char Insetbase[] = "\ ! DOBJS = %s.do %s.do \n\ ! IHFILES = %s.ih %s.ih\n\ ! "; ! static char Controlbase[] = "\ ! DOBJS = %s.do\n\ ! IHFILES = %s.ih\n\ ! "; void ws(s,f) struct stf *s; FILE *f; *************** *** 108,113 **** --- 152,189 ---- new->bro = new->next = NULL; return new; } + writestr(fi,fo,name) + FILE *fi,*fo; + char *name; + { + int c; + fprintf(fo,"static char %s[] = {\"\\\n",name); + while((c = getc(fi))!= EOF){ + if(c == '\\' || c == '"' )putc('\\',fo); + if(c == '\n') fprintf(fo,"\\n\\"); + putc(c,fo); + } + fprintf(fo,"\"};\n"); + } + long createchfile(src,classn,name) + char *src,*classn,*name; + { + FILE *oldf,*newf; + sprintf(name,"%s.fh",classn); + printf("creating %s\n",name); + if((oldf =fopen(src,"r")) == NULL){ + fprintf(stderr,"Can't Read %s\n",name); + return -1; + } + if((newf = fopen(name,"w")) == NULL){ + fprintf(stderr,"Can't Write %s\n",name); + return -1; + } + writestr(oldf,newf,"defaultstr"); + close(oldf); + close(newf); + return 0; + } struct stf *makestf(buf) char *buf; { *************** *** 138,153 **** new->end = c; return start; } ! char *getf(f,s,buf) FILE *f; ! char *s,*buf; { static char ending[1024]; register char *c,*cp; extern char *index(); struct MapEntryStruct *mp; for(c = buf;fgets(c,2048,f) != NULL; ){ ! if(*c == *s && strncmp(c,s,strlen(s)) == 0){ *c = '\0'; return buf; } --- 214,231 ---- new->end = c; return start; } ! char *getf(f,s,buf,s1,s2) FILE *f; ! char *s,*buf,*s1,*s2; { static char ending[1024]; register char *c,*cp; extern char *index(); struct MapEntryStruct *mp; + int s2len = 0; + if(s2 != NULL) s2len = strlen(s2); for(c = buf;fgets(c,2048,f) != NULL; ){ ! if(*c && *c == *s && strncmp(c,s,strlen(s)) == 0){ *c = '\0'; return buf; } *************** *** 164,171 **** sprintf(c,"%s.%s",mp->Key,ending); } } ! } ! while(*c != '\0') c++; } } keycmp(s1,s2) --- 242,265 ---- sprintf(c,"%s.%s",mp->Key,ending); } } ! } ! if(s2len == 0){ ! while(*c != '\0') c++; ! } ! else{ ! while(*c != '\0'){ ! if(*c == *s2 && ! (!isalnum((*(c + s2len)))) && ! (c == buf || !isalnum((*(c - 1)))) && ! strncmp(c,s2,s2len) == 0){ ! /* substitute the new name for the old */ ! strcpy(ending,c + s2len); ! sprintf(c,"%s%s",s1,c+s2len); ! c += s2len; ! } ! c++; ! } ! } } } keycmp(s1,s2) *************** *** 192,204 **** } } ! static FILE *tryopen(name,renamed) char *name; boolean *renamed; { char buf[1024],*p; FILE *f; *renamed = FALSE; if((f =fopen(name,"r")) != NULL) return f; strcpy(buf,name); p = rindex(buf,'.'); --- 286,324 ---- } } ! static FILE *tryopen(name,renamed,s1,s2) char *name; boolean *renamed; + char **s1,**s2; { char buf[1024],*p; FILE *f; + int len; *renamed = FALSE; + p = rindex(name,'.'); + *s1 = *s2 = NULL; + if(p != NULL){ + len = p - name; + *buf = '\0'; + if(oldcls != NULL && strlen(cls) == len && strncmp(name,cls,len) == 0){ + sprintf(buf,"%s%s",oldcls,p); + *s1= cls;*s2 = oldcls; + } + else if(oldvw != NULL && strlen(viewname) == len && strncmp(name,viewname,len) == 0){ + sprintf(buf,"%s%s",oldvw,p); + *s1 = viewname; *s2 = oldvw; + } + if(*buf != '\0'){ + if((f = fopen(buf,"r")) == NULL){ + printf("Warning, can't open %s\n",buf); + *s1 = *s2 = NULL; + return NULL; + } + printf("Merging data from %s into %s\n",buf,name); + *renamed = TRUE; + return f; + } + } if((f =fopen(name,"r")) != NULL) return f; strcpy(buf,name); p = rindex(buf,'.'); *************** *** 206,211 **** --- 326,332 ---- strcpy(p,".H"); if((f =fopen(buf,"r")) != NULL){ *renamed = TRUE; + printf("Merging old .H file and new info to create %s\n",name); return f; } } *************** *** 220,227 **** FILE *newf; boolean renamed; struct stf *olds,*news; ! getf(oldf,"! THIS IS THE END OF THIS FILE !!!\n",oldb); ! if((newf = tryopen(name,&renamed)) == NULL ){ if((newf = fopen(name,"w")) != NULL){ printf("Creating %s\n",name); fwrite(oldb,strlen(oldb),1,newf); --- 341,350 ---- FILE *newf; boolean renamed; struct stf *olds,*news; ! char *sub1,*sub2; ! sub1 = sub2 = NULL; ! getf(oldf,"! THIS IS THE END OF THIS FILE !!!\n",oldb,NULL,NULL); ! if((newf = tryopen(name,&renamed,&sub1,&sub2)) == NULL ){ if((newf = fopen(name,"w")) != NULL){ printf("Creating %s\n",name); fwrite(oldb,strlen(oldb),1,newf); *************** *** 231,245 **** fprintf(stderr,"Can't Write %s\n",name); return FALSE; } ! if(renamed){ ! printf("Merging old .H file and new info to create %s\n",name); ! } ! else { sprintf(newb,"%s.old",name); rename(name,newb); printf("Moving %s to %s.old\n",name,name); } ! getf(newf,"",newb); fclose(newf); if((newf = fopen(name,"w")) == NULL){ fprintf(stderr,"Can't Write %s\n",name); --- 354,365 ---- fprintf(stderr,"Can't Write %s\n",name); return FALSE; } ! if(access(name,R_OK) != -1){ sprintf(newb,"%s.old",name); rename(name,newb); printf("Moving %s to %s.old\n",name,name); } ! getf(newf,"",newb,sub1,sub2); fclose(newf); if((newf = fopen(name,"w")) == NULL){ fprintf(stderr,"Can't Write %s\n",name); *************** *** 258,284 **** usage(s) char *s; { ! fprintf(stderr,"usage: %s <-C ClassName> <-F FunctionName> <-T Title> <-S ShellScriptName> \n",s); exit(1); } ! static char makefile[MAXPATHLEN]; ! main(argc,argv) char *argv[]; { register char *c; register int cc; ! char bb[256],cmd[5200],tmpfile[256]; ! char *awkprog,*src,*program,defaultawk[256]; ! char *cls,*func,*title,*sname; int success = TRUE; FILE *f; strcpy(makefile,MAKEFILE); class_Init(AndrewDir("/dlib/atk")); sprintf(defaultawk,"awk -f %s",AWKPROG); awkprog = defaultawk; ! src = cls = title = sname = NULL; func = "go"; *tmpfile = '\0'; program = *argv; --- 378,419 ---- usage(s) char *s; { ! fprintf(stderr,"usage: %s <-C ClassName(:oldclassname)> <-F FunctionName> <-T Title> <-O ShellScriptName> <-M> <-I> <-V Viewname(:oldviewname)> <-W> <-Help> \n",s); exit(1); } ! writeinset(iname,src,cls,func) ! char *iname,*src,*cls,*func; ! { ! ! } static char makefile[MAXPATHLEN]; ! char *ps(s) ! char *s; ! { ! char *c; ! extern char *index(); ! if((c = index(s,':')) != NULL) ! *c++ = '\0'; ! return c; ! } main(argc,argv) char *argv[]; { register char *c; register int cc; ! char bb[256],cmd[5200],tmpfile[256],bv[256]; ! char *awkprog,*src,*program,defaultawk[256],parentname[1024]; ! boolean iname = FALSE; ! boolean writechild = FALSE; int success = TRUE; + int domake = FALSE; + char *func,*title,*sname; FILE *f; strcpy(makefile,MAKEFILE); class_Init(AndrewDir("/dlib/atk")); sprintf(defaultawk,"awk -f %s",AWKPROG); awkprog = defaultawk; ! src = cls = viewname = title = sname = NULL; func = "go"; *tmpfile = '\0'; program = *argv; *************** *** 286,293 **** if(**argv=='-'){ switch((*argv)[1]){ case 'c': /* Classname for controller class */ ! case 'C': cls = (argv[0][2] == '\0')? *++argv : (*argv) + 2; break; case 'f': /* function in controllers class to call */ case 'F': /* (default is 'go' ) */ --- 421,429 ---- if(**argv=='-'){ switch((*argv)[1]){ case 'c': /* Classname for controller class */ ! case 'C': /* dataobject name when used w/ -i */ cls = (argv[0][2] == '\0')? *++argv : (*argv) + 2; + oldcls = ps(cls); break; case 'f': /* function in controllers class to call */ case 'F': /* (default is 'go' ) */ *************** *** 294,305 **** func =(argv[0][2] == '\0')? *++argv : (*argv) + 2; break; case 't': /* Title for top of screen */ ! case 'T': title =(argv[0][2] == '\0')? *++argv : (*argv) + 2; break; case 'a': /* Name of alternate Awk program to run */ case 'A': /* (debugging purposes only) */ - awkprog =(argv[0][2] == '\0')? *++argv : (*argv) + 2; break; case 'o': /* name of shellscript to create for running application */ --- 430,440 ---- func =(argv[0][2] == '\0')? *++argv : (*argv) + 2; break; case 't': /* Title for top of screen */ ! case 'T': /* requires -o */ title =(argv[0][2] == '\0')? *++argv : (*argv) + 2; break; case 'a': /* Name of alternate Awk program to run */ case 'A': /* (debugging purposes only) */ awkprog =(argv[0][2] == '\0')? *++argv : (*argv) + 2; break; case 'o': /* name of shellscript to create for running application */ *************** *** 306,311 **** --- 441,477 ---- case 'O': sname = (argv[0][2] == '\0')? *++argv : (*argv) + 2; break; + case 'm': /* force creation of new Imakefile */ + case 'M': + domake = TRUE; + printf("Renaming Imakefile to Imakefile.old\n"); + rename("Imakefile","Imakefile.old"); + printf("Renaming Makefile to Makefile.old\n"); + rename("Makefile","Makefile.old"); + break; + case 'i': /* tells createcon to make an inset rather than a controller */ + case 'I': + iname = TRUE; + break; + case 'v': /* next arg indicates viewname */ + case 'V': /* requires -i */ + viewname = (argv[0][2] == '\0')? *++argv : (*argv) + 2; + oldvw = ps(viewname); + break; + case 'w': /* force inset to write childrens data-stream when finished */ + case 'W': /* requires -i */ + #ifdef WRITECHILDWORKS + writechild = TRUE; + #else + fprintf(stderr,"Warning, writechild option not currently supported \n"); + fflush(stderr); + #endif /* WRITECHILDWORKS */ + break; + case 'h': + case 'H': + fputs(defstring,stdout); + fflush(stdout); + exit(0); default: break; } *************** *** 313,319 **** } else src = *argv; } ! if(src){ if(access(src,R_OK) == -1){ fprintf(stderr,"ERROR: Can't Open %s\n",src); --- 479,495 ---- } else src = *argv; } ! if(iname){ ! if( cls == NULL){ ! fprintf(stderr,"Need classname for inset, use -c flag\n"); ! exit(2); ! } ! if( src == NULL){ ! fprintf(stderr,"Need source file for inset, can't read stdin\n"); ! exit(3); ! } ! sprintf(defaultawk,"awk -f %s",INSETAWKPROG); ! } if(src){ if(access(src,R_OK) == -1){ fprintf(stderr,"ERROR: Can't Open %s\n",src); *************** *** 320,329 **** --- 496,510 ---- exit(1); } printf("Creating a controller for %s. Please wait...\n",src); + if(iname){ + if(createchfile(src,cls,parentname) == -1) exit(4); + } + } else { printf("Attempting to read file from standard input\n"); } + if(cls == NULL){ if (src) sprintf(cmd,"%s %s",awkprog,src); *************** *** 331,337 **** sprintf(cmd,"%s",awkprog); } else { ! FILE *ff; int i; for(i = 0; i < 100; i++){ sprintf(tmpfile,"/tmp/adew%d.tmp",i); --- 512,518 ---- sprintf(cmd,"%s",awkprog); } else { ! FILE *ff,*fin; int i; for(i = 0; i < 100; i++){ sprintf(tmpfile,"/tmp/adew%d.tmp",i); *************** *** 342,347 **** --- 523,551 ---- fprintf(stderr,"ERROR: Can't open file in /tmp"); exit(1); } + if(iname){ + /* look for and append .dcl file */ + char fnm[128]; + sprintf(fnm,"%s.dcl",cls); + if(viewname != NULL && *viewname != '\0'){ + fprintf(ff,"DECLARE %s viewname\n",viewname); + } + if(cls && *cls){ + fprintf(ff,"DECLARE %s classname\n",cls); + } + if(func && *func){ + fprintf(ff,"DECLARE %s funcname\n",func); + } + if(writechild == TRUE) + fprintf(ff,"DECLARE TRUE writechild\n"); + if((fin = fopen(fnm,"r")) != NULL){ + int cc; + while((cc = getc(fin)) != EOF) + putc(cc,ff); + fclose(fin); + putc('\n',ff); + } + } fprintf(ff,"CLASSNAME= %s FUNCTIONAME= %s\n",cls,func); if(src == NULL) { while((cc = getc(stdin)) != EOF){ *************** *** 388,397 **** break; } } sprintf(cmd,"make%s",bb); ! if(access("Imakefile",R_OK) == -1 && ((f = fopen("Imakefile","w")) != NULL)){ printf("Creating Imakefile\n"); fprintf(f,Imakebase,bb,bb); fclose(f); } --- 592,613 ---- break; } } + if(cls)strcpy(bb,cls); sprintf(cmd,"make%s",bb); ! if((domake || access("Imakefile",R_OK) == -1) && ((f = fopen("Imakefile","w")) != NULL)){ printf("Creating Imakefile\n"); + if(iname){ + if(viewname){ + strcpy(bv,viewname); + } + else { + sprintf(bv,"%sv",bb); + } + fprintf(f,Insetbase,bb,bv,bb,bv); + } + else + fprintf(f,Controlbase,bb,bb); fprintf(f,Imakebase,bb,bb); fclose(f); } *************** *** 408,420 **** ((f = fopen(sname,"w")) != NULL)){ printf("Creating %s shellscript\n",sname); fprintf(f,"runadew"); - if(cls){ - fprintf(f," -C\"%s\" -F\"%s\"",cls,func); - } if(title){ fprintf(f," -T\"%s\"",title); } ! fprintf(f," -S\"%s\" $*\n",src); fclose(f); chmod(sname,0755); } --- 624,641 ---- ((f = fopen(sname,"w")) != NULL)){ printf("Creating %s shellscript\n",sname); fprintf(f,"runadew"); if(title){ fprintf(f," -T\"%s\"",title); } ! if(iname){ ! fprintf(f," -I\"%s\" $*\n",cls); ! } ! else { ! if(cls){ ! fprintf(f," -C\"%s\" -F\"%s\"",cls,func); ! } ! fprintf(f," -S\"%s\" $*\n",src); ! } fclose(f); chmod(sname,0755); } *** atk/lset/runadewa.c Fri Dec 21 14:55:58 1990 --- atk/lset/runadewa.c.NEW Wed Apr 3 21:20:17 1991 *************** *** 2,13 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/lset/RCS/runadewa.c,v 1.3 90/09/21 12:13:25 tpn Exp $ */ /* $ACIS:$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/lset/RCS/runadewa.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/lset/RCS/runadewa.c,v 1.3 90/09/21 12:13:25 tpn Exp $"; #endif /* lint */ #include /* sys/types.h sys/file.h */ --- 2,13 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/lset/RCS/runadewa.c,v 1.4 91/04/03 11:19:35 tpn Exp $ */ /* $ACIS:$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/lset/RCS/runadewa.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/lset/RCS/runadewa.c,v 1.4 91/04/03 11:19:35 tpn Exp $"; #endif /* lint */ #include /* sys/types.h sys/file.h */ *************** *** 47,52 **** --- 47,53 ---- self->cls = NULL; self->func = "go"; self->title = NULL; + self->objectname = NULL; return TRUE; } *************** *** 127,133 **** getarg(argv,&Gargc), (useNewWindow || maxInitWindows-->0), pendingReadOnly); ! break; default: argv++; } --- 128,137 ---- getarg(argv,&Gargc), (useNewWindow || maxInitWindows-->0), pendingReadOnly); ! break; ! case 'I': ! self->objectname = getarg(argv,&Gargc); ! break; default: argv++; } *************** *** 149,155 **** int (*proc)(); if(!super_Start(self)) return FALSE; ! for (fileEntry = self->files; fileEntry != NULL; fileEntry = next) { self->buffer = buffer_GetBufferOnFile(fileEntry->filename, fileEntry->readOnly ? buffer_ReadOnly : 0); if (self->buffer != NULL && fileEntry->newWindow) { --- 153,182 ---- int (*proc)(); if(!super_Start(self)) return FALSE; ! if(self->objectname){ ! if((self->buffer = buffer_Create("", NULL, self->objectname, NULL)) == NULL){ ! fprintf(stderr,"adew: Could not create a buffer with %s; exiting.\n",self->objectname); ! exit(-1); ! } ! ! if((self->frame = frame_New()) == NULL) { ! fprintf(stderr,"adew: Could not allocate enough memory; exiting.\n"); ! exit(-1); ! } ! if((self->im = im_Create(NULL)) == NULL) { ! fprintf(stderr,"adew: Could not create new window; exiting.\n"); ! exit(-1); ! } ! im_SetView(self->im, self->frame); ! frame_PostDefaultHandler(self->frame, "message", frame_WantHandler(self->frame, "message")); ! frame_SetBuffer(self->frame, self->buffer, TRUE); ! buffer_SetScratch(self->buffer,TRUE); ! frame_SetCommandEnable(self->frame, FALSE); ! if(self->title) ! frame_SetTitle(self->frame,self->title); ! self->haveBufferInWindow = TRUE; ! } ! else for (fileEntry = self->files; fileEntry != NULL; fileEntry = next) { self->buffer = buffer_GetBufferOnFile(fileEntry->filename, fileEntry->readOnly ? buffer_ReadOnly : 0); if (self->buffer != NULL && fileEntry->newWindow) { *** atk/lset/runadewa.ch Wed Nov 22 12:17:43 1989 --- atk/lset/runadewa.ch.NEW Wed Apr 3 21:20:18 1991 *************** *** 2,13 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/lset/RCS/runadewa.ch,v 1.1 89/10/03 14:10:46 tpn Exp $ */ /* $ACIS:eza.ch 1.4$ */ ! /* $Source: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/lset/RCS/runadewa.ch,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsidrunadewa_H = "$Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/lset/RCS/runadewa.ch,v 1.1 89/10/03 14:10:46 tpn Exp $"; #endif /* !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) */ --- 2,13 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/lset/RCS/runadewa.ch,v 1.2 91/04/03 11:19:40 tpn Exp $ */ /* $ACIS:eza.ch 1.4$ */ ! /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/lset/RCS/runadewa.ch,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsidrunadewa_H = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/lset/RCS/runadewa.ch,v 1.2 91/04/03 11:19:40 tpn Exp $"; #endif /* !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) */ *************** *** 33,36 **** --- 33,37 ---- struct frame *frame; struct buffer *buffer; char *title, *cls,*func; + char *objectname; }; *** atk/lset/instpros.awk Thu May 30 19:58:39 1991 --- atk/lset/instpros.awk.NEW Wed Apr 3 21:20:19 1991 *************** *** 0 **** --- 1,405 ---- + #/* ********************************************************************** *\ + # * Copyright IBM Corporation 1989 - All Rights Reserved * + # * For full copyright information see:'andrew/config/COPYRITE' * + #\* ********************************************************************** */ + # + # $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/lset/RCS/instpros.awk,v 1.2 91/04/03 11:19:53 tpn Exp $ + # $ACIS: $ + # $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/lset/RCS/instpros.awk,v $ + BEGIN{ + vcount = 0 + class= "! No Control Button Defined" + classoverride = 0 + lastfunc = "" + initing = 1 + acount = 0; # number of objects + bcount = 0; + dclview = ""; + dclclass = ""; + funcdefined = 0; + obcount = 0; + childflag = "FALSE"; + ist = "nada"; + dclfunc = "InitApp"; + } + { + if(initing == 1){ + if($1 == "DECLARE"){ + if($3 == "long"){ + declarenm[acount] = "long " $2 ";" + readnm[acount] = "adew_ReadLong(" "self->" $2 ",file,count);" + writenm[acount] = "adew_WriteLong(" "self->" $2 ",file);" + initnm[acount] = "adew_InitLong(" "self->" $2 ");" + bcount++ + acount++ + } + if($3 == "string"){ + declarenm[acount] = "char " $2 "[" $4 "];" + readnm[acount] = "adew_ReadString(" "self->" $2 ",file,count);" + writenm[acount] = "adew_WriteString(" "self->" $2 ",file);" + initnm[acount] = "adew_InitString(" "self->" $2 ");" + bcount++ + acount++ + } + if($3 == "float"){ + declarenm[acount] = "float " $2 ";" + readnm[acount] = "adew_ReadFloat(" "self->" $2 ",file,count);" + writenm[acount] = "adew_WriteFloat(" "self->" $2 ",file);" + initnm[acount] = "adew_InitFloat(" "self->" $2 ");" + bcount++ + acount++ + } + if($3 == "longarray"){ + declarenm[acount] = "long " $2 "[" $4 "];" + readnm[acount] = "adew_ReadLongArray(" "self->" $2 ",file,count," $4 ");" + writenm[acount] = "adew_WriteLongArray(" "self->" $2 ",file," $4 ");" + initnm[acount] = "adew_InitLongArray(" "self->" $2 "," $4 ");" + bcount += $4 + acount++ + } + if($3 == "stringarray"){ + declarenm[acount] = "char " $2 "[" $4 "][" $5 "];" + readnm[acount] = "adew_ReadStringArray(" "self->" $2 ",file,count," $4 ");" + writenm[acount] = "adew_WriteStringArray(" "self->" $2 ",file," $4 ");" + initnm[acount] = "adew_InitStringArray(" "self->" $2 "," $4 ");" + bcount += $4 + acount++ + } + if($3 == "viewname") + dclview = $2; + if($3 == "funcname") + dclfunc = $2; + if($3 == "classname"){ + dclclass = $2 ; + class = $2; + classoverride = 1; + } + if($3 == "writechild") + childflag = $2 + continue; + } + else { + initing = 2 + } + } + if ($1 == ">OBJ<" && NF ==2){ + typelist[$2] = $2 + type=$2 + } + if ($1 == ">VIEW<" && NF ==2){ + typelist[$2] = $2 + view = $2 + } + if ($1 == ">REF<" ) { + if(NF == 2) rname = $2 + else rname = substr($0,7,length - 6); + if(rname != "" && rname != " "){ + if(view == "controlV"){ + cvlist[rname] = rname + } + else { + oblist[rname] = rname + str = "" + slen = 0 + for(i = 1; i <= length(rname); i++){ + cc = substr(rname,i,1) + if(cc < "0" || (cc > "9" && cc < "A") || (cc > "Z" && cc < "a") || cc > "z") { + str = str "_" + if(slen == 0) slen = i + } + else { + if(slen > 0 && (cc < "0" || cc > "9")) slen = 0 + str = str cc + } + } + obfunc[rname] = str + if(type == "value") { + num = 0 + if(slen > 0){ + num = substr(str,slen + 1 ,10) + str = substr(str,1,slen - 1) + } + valuelist[rname] = str + uval[str] = str + numlist[rname] = num + vcount++ + } + obtype[rname] = type + obview[rname]=view + obcount++ + } + } + } + if($2 == "" && $1=="[string]" && NF==3 && view == "controlV"){ + newclass = substr($3,2,(length($3) - 2)) + if(class == "! No Control Button Defined") + class = newclass + if(newclass == dclview){ + if(lastfunc != ""){ + funcs[lastfunc] = lastfunc + funcdefined = 1 + lastfunc = "" + } + } + else if(classoverride == 0){ + class = "! More Than one controller classes defined" + classoverride = 2 + } + } + if($2 == "" && $1=="[string]" && NF==3 && view == "controlV"){ + lastfunc = substr($3,2,(length($3) - 2)) + } + } + END { + if(substr(class,1,1) == "!" ) { + print class + } + else { + dclass = class + if(dclview == "") + class = class "v" + else class = dclview; + #write dataobj .ch file + printf "%s.ch\n",dclass + printf "/* user code begins here for HeaderInfo */\n" + printf "/* user code ends here for HeaderInfo */\n" + printf "class %s : arbiter{ \n",dclass + printf "methods:\n" + printf "/* user code begins here for methods*/\n" + printf "/* user code ends here for methods */\n" + printf "overrides:\n" + printf " ViewName() returns char *;\n" + printf " ReadSup (FILE *file, long id) returns long;\n" + printf " WriteSup (FILE *file, long writeid, int level) returns long;\n" + printf " ReadObjects() ;\n" + printf "/* user code begins here for overrides */\n" + printf "/* user code ends here for overrides */\n" + printf "classprocedures:\n" + printf " InitializeObject(struct lset *self) returns boolean;\n" + printf "/* user code begins here for classprocedures */\n" + printf "/* user code ends here for classprocedures */\n" + printf "macromethods:\n" + printf "/* user code begins here for macromethods */\n" + printf "/* user code ends here for macromethods */\n" + printf "data:\n" + for(i = 0; i < acount; i++) print " " declarenm[i]; + printf "/* user code begins here for classdata */\n" + printf "/* user code ends here for classdata */\n" + printf "};\n" + printf "! THIS IS THE END OF THIS FILE !!!\n%s.c\n",dclass + #write dataobj .c file + printf "/* user code begins here for HeaderInfo */\n" + printf "/* user code ends here for HeaderInfo */\n" + printf "#include \n" + printf "#include <%s.eh>\n",dclass + printf "#include <%s.fh>\n",dclass + printf "#include \n" + printf "#include \n" + printf "/* user code begins here for includes */\n" + printf "/* user code ends here for includes */\n" + printf "char *%s__ViewName(self)\n",dclass + printf "struct %s *self;\n",dclass + printf "{\n" + printf " return \"%s\";\n",class + printf "}\n" + printf "void %s__ReadObjects(self)\n",dclass + printf "struct %s *self;\n",dclass + printf "{\n" + printf "/* user code begins here for ReadObjects */\n" + printf "/* user code ends here for ReadObjects */\n" + printf "}\n" + printf "boolean %s__InitializeObject(classID, self)\n",dclass + printf "struct classheader *classID;\n" + printf "struct %s *self;\n",dclass + printf "{\n" + printf "%s_SetDefaultStream(self,defaultstr);\n",dclass + printf "%s_SetWriteChild(self,%s);\n",dclass,childflag + # series of generated init calls are here + for(i = 0; i < acount; i++) print " " initnm[i]; + printf "/* user code begins here for InitializeObject */\n" + printf "/* user code ends here for InitializeObject */\n" + printf "return TRUE;\n" + printf "}\n" + printf "long %s__ReadSup(self, file, id)\n",dclass + printf "struct %s *self;\n",dclass + printf "FILE *file;\n" + printf "long id;\n" + printf "{\n" + printf " long c,count,extradata;\n" + printf " if((c = getc(file)) != '@'){\n" + printf " ungetc(c,file);\n" + printf " return dataobject_NOREADERROR;\n" + printf " }\n" + # read the number of data elements to be read + print " fscanf(file,\"%ld\\n\",&count);" + # read known data elements + for(i = 0; i < acount; i++) print " " readnm[i]; + # read data saved by newer versions that this version doesn't know about + print " if((extradata = count) > 0)" # may cause compiler warning + print " adew_ReadExtraData(file,count);" + printf "/* user code begins here for ReadSup */\n" + printf "/* user code ends here for ReadSup */\n" + printf " return dataobject_NOREADERROR;\n" + printf "}\n" + printf "long %s__WriteSup(self,file ,writeid,level)\n",dclass + printf "struct %s *self;\n",dclass + printf "FILE *file;\n" + printf "long writeid;\n" + printf "int level;\n" + printf "{\n" + printf "/* user code begins here for Preparing_To_Write */\n" + printf "/* user code ends here for Preparing_To_Write */\n" + printf " fprintf(file,\"@%d\\n\");/* the number of data elements */\n",bcount + for(i = 0; i < acount; i++) print " " writenm[i]; + printf "/* user code begins here for WriteSup */\n" + printf "/* user code ends here for WriteSup */\n" + printf " return(TRUE);\n" + printf "}\n" + printf "! THIS IS THE END OF THIS FILE !!!\n" + # write view ch file + printf "%s.ch\n",class + printf "/* user code begins here for %s */\n","HeaderInfo" + printf "/* user code ends here for %s */\n","HeaderInfo" + printf "#include \n" + printf "#define ADEWARRAYSIZE %d\n",obcount + 1; + printf "class %s : arbiterview[arbiterv] { \nclassprocedures :\n",class + printf " FinalizeObject(struct %s *self);\n",class + printf " InitializeObject(struct %s *self) returns boolean;\n",class + printf " InitializeClass() returns boolean;\n" + printf "/* user code begins here for %s */\n","classprocedures" + printf "/* user code ends here for %s */\n","classprocedures" + printf "overrides:\n\tObservedChanged( struct observable * observed, long status );\n" + printf "\tInitCell(struct celview *cv);\n" + printf "\tGetApplicationLayer() returns struct view *;\n" + printf "/* user code begins here for %s */\n","overrides" + printf "/* user code ends here for %s */\n","overrides" + printf "methods:\n\t%s();\n",dclfunc + printf "/* user code begins here for %s */\n","methods" + printf "/* user code ends here for %s */\n","methods" + printf "data:\n" + printf "long InitCount;\n" + for(i in oblist){ + printf " struct %s *%s;\n",obtype[i],obfunc[i] + printf " struct %s *%sView;\n",obview[i],obfunc[i] + } + printf " struct adew_array AdewArray[ADEWARRAYSIZE];\n" + printf "/* user code begins here for %s */\n","classdata" + printf "/* user code ends here for %s */\n","classdata" + printf " struct view *v;\n\tstruct arbiterview *arbv;\n\tstruct %s *next;\n};\n\n",class + printf "! THIS IS THE END OF THIS FILE !!!\n%s.c\n",class + #write view .c file + printf "/* user code begins here for %s */\n","HeaderInfo" + printf "/* user code ends here for %s */\n","HeaderInfo" + printf "#include \n#include \n#include \n#include \n#include \n" + printf "#include \n#include \n#include \n#include <%s.ih>\n#include <%s.eh>\n",dclass,class + for(i in typelist){ + printf "#include <%s.ih>\n",typelist[i] + } + printf "#define DataObject(A) (A->header.view.dataobject)\n" + printf "#define Parent(A) (A->header.view.parent)\n" + printf "#define Data(A) ((struct %s *)DataObject(A) )\n",dclass + printf "#define CEL(A) ((struct cel *)DataObject(A) )\n" + printf "/* user code begins here for %s */\n","includes" + printf "/* user code ends here for %s */\n","includes" + printf "static struct %s *FindSelf(v)\n",class + printf "struct view *v;\n{\n" + printf " if(class_IsTypeByName(v,\"%s\")) return (struct %s *) v;\n",class,class + printf "else return (struct %s *)arbiterview_FindArb(v);\n}\n",class + # Should probably make sure it is a 'class' type + printf "struct view *%s__GetApplicationLayer(self)\n",class + printf " struct %s *self;\n",class + printf "{\n" + printf " %s_SetAppFlag(self,TRUE);\n",class + printf " return super_GetApplicationLayer(self);\n" + printf "}\n" + if(vcount){ + for(i in uval){ + printf "static void %sCallBack(self,val,r1,r2)\nstruct %s *self;\nstruct value *val;\nlong r1,r2;\n{\n", uval[i],class + printf "if(r2 == value_OBJECTDESTROYED) {\n" + for(j in valuelist){ + if(valuelist[j] == uval[i]){ + printf "\tif(self->%s == val) ",obfunc[j] + printf "self->%s = NULL;\n",obfunc[j] + } + } + printf "}\n",uval[i] + printf "{\n/* user code begins here for %sCallBack */\n",uval[i] + printf "/* user code ends here for %sCallBack */\n}\n}\n",uval[i] + } + } + #code for initapp + printf "void %s__%s(self)\nstruct %s *self;",class,dclfunc,class + printf "{\n/* user code begins here for %s_%s */\n",class,dclfunc + printf "/* user code ends here for %s_%s */\n}\n",class,dclfunc + #code for initcell + printf "void %s__InitCell(self,cv)\nstruct %s *self;\nstruct celview *cv;\n{\n",class,class + printf "\tif(*(self->AdewArray[0].object) == NULL) adew_InitDataObjects(self,self->AdewArray);\n" + printf "\tadew_InitApplicationCel(self,NULL,cv,self->AdewArray,&(self->InitCount));\n" + printf "\tif(self->InitCount == 0){\n\t\tself->InitCount--;\n" + printf "\t\t%s_%s(self);\n\t}\n",class,dclfunc + printf "/* code begins here for InitCell */\n" + printf "/* code ends here for InitCell */\n" + printf "}\n" + # add function definitions + if(funcdefined == 1){ + for(i in funcs){ + printf "%s_%s(v,dat)\nstruct view *v;\n long dat;\n{\n",class,funcs[i] + printf "struct %s *self;\nif((self = FindSelf(v)) == NULL) return;\n",class + printf "/* user code begins here for %s_%s */\n",class,funcs[i] + printf "/* user code ends here for %s_%s */\n}\n",class,funcs[i] + } + } + printf "void %s__ObservedChanged(self,observed,status)\n",class + printf "struct %s *self;\nstruct observable * observed;\nlong status;\n{\n",class + printf "/* user code begins here for %s */\n","ObservedChanged" + printf "/* user code ends here for %s */\n","ObservedChanged" + printf "if (status == observable_OBJECTDESTROYED) {\n" + printf "adew_NoteDestroyed(self,observed,self->AdewArray);\n"; + printf "}\n" + printf "}\n" + printf "boolean %s__InitializeClass(ClassID)\nstruct classheader *ClassID;\n{\n",class + if(funcdefined == 1){ + printf "struct classinfo *viewtype = class_Load(\"view\");\n" + for(i in funcs){ + printf "proctable_DefineProc(\"%s-%s\",%s_%s, viewtype,NULL,\"%s %s\");\n", class,funcs[i],class,funcs[i],class,funcs[i] + } + } + printf "/* user code begins here for %s */\n","InitializeClass" + printf "/* user code ends here for %s */\n","InitializeClass" + print "return TRUE;\n}" + printf "void %s__FinalizeObject(ClassID,self)\nstruct classheader *ClassID;\n",class + printf "struct %s *self;\n{\n",class + printf "adew_FinalizeApplication(self,self->AdewArray);\n"; + printf "/* user code begins here for %s */\n","FinalizeObject" + printf "/* user code ends here for %s */\n","FinalizeObject" + print "}" + printf "boolean %s__InitializeObject(ClassID,self)\nstruct classheader *ClassID;\nstruct %s *self;\n{\n",class,class + j = 0 + printf "struct adew_array *aa = self->AdewArray;\n" + for(i in oblist){ + printf "aa->object = (struct dataobject **) &(self->%s);\n",obfunc[i]; + printf "aa->view = (struct view **) &(self->%sView);\n",obfunc[i]; + printf "aa->name = atom_Intern(\"%s\");\n",oblist[i]; + if(obtype[i] == "value"){ + printf "aa->callback = %sCallBack;\n",valuelist[i] + printf "aa->rock = %d;\n",numlist[i] + } + else { + printf "aa->callback = NULL;\n" + printf "aa->rock = -1;\n" + } + printf "aa++;\n" + } + printf "aa->object = NULL;",j + printf "adew_InitializeApplication(self,self->AdewArray);\n"; + printf "self->v = NULL;\nself->next = NULL;\n" + printf "self->InitCount = %d;\n",obcount + printf "/* user code begins here for %s */\n","InitializeObject" + printf "/* user code ends here for %s */\n","InitializeObject" + printf "return TRUE;}\n" + printf "/* user code begins here for %s */\n","Other Functions" + printf "/* user code ends here for %s */\n","Other Functions" + printf "! THIS IS THE END OF THIS FILE !!!\n" + } + } + *** atk/lset/adew.h Thu May 30 19:58:48 1991 --- atk/lset/adew.h.NEW Wed Apr 3 21:20:20 1991 *************** *** 0 **** --- 1,96 ---- + /* ********************************************************************** *\ + * Copyright IBM Corporation 1989 - All Rights Reserved * + * For full copyright information see:'andrew/config/COPYRITE' * + \* ********************************************************************** */ + /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/lset/RCS/adew.h,v 1.2 91/04/03 11:19:49 tpn Exp $ */ + /* $ACIS: $ */ + /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/lset/RCS/adew.h,v $ */ + #ifndef adew_ReadShort + struct adew_array { + struct dataobject **object; + struct view **view; + struct cel *cel; + struct atom *name; + void (*callback)(); + long rock; + }; + #define adew_InitializeApplication(SELF,ARRAY) { struct adew_array *aa ;\ + for(aa = ARRAY; aa->object != NULL;aa++){\ + *(aa->object) = NULL;\ + *(aa->view) = NULL;\ + aa->cel = NULL;\ + }\ + }; + #define adew_FinalizeApplication(SELF,ARRAY) { struct adew_array *aa ;\ + for(aa = ARRAY; aa->object != NULL;aa++){\ + if(aa->callback) value_RemoveCallBackObserver((struct value *)*(aa->object),SELF);\ + }\ + }; + #define adew_NoteDestroyed(SELF,OB,ARRAY){ struct adew_array *aa ;\ + for(aa = ARRAY; aa->object != NULL;aa++){\ + if((struct observable *)(*(aa->object)) == OB){\ + *(aa->object) = NULL; aa->cel = NULL;}\ + else if((struct observable *)(*(aa->view)) == OB) *(aa->view) = NULL;\ + }\ + }; + #define adew_InitApplicationCel(SELF,CL,CLV,ARRAY,ICNT){ struct cel *cel = NULL;\ + struct adew_array *aa ;struct atom *nm;\ + if(CL) cel = CL;\ + else if(CLV) cel = (struct cel *) celview_GetDataObject(cv);\ + if(cel != NULL) { \ + nm = cel_GetRefAtom(cel);\ + for(aa = ARRAY; aa->object != NULL;aa++){\ + if(aa->name == nm){\ + if(CLV){ *(aa->view) = celview_GetTrueChild((struct celview *)CLV);\ + (*(ICNT))--;}\ + if(*(aa->object) != cel_GetObject(cel)){\ + *(aa->object) = cel_GetObject(cel);\ + aa->cel = cel;\ + if(aa->callback)value_AddCallBackObserver((struct value *) *(aa->object), SELF,aa->callback,aa->rock);\ + }\ + break;\ + }\ + }\ + }\ + }; + #define adew_InitDataObjects(SELF,ARRAY){ struct cel *ccl; struct arbiter *aab;int dummy;\ + aab = (struct arbiter *) (SELF)->header.view.dataobject;\ + for(ccl = arbiter_GetFirst(aab); ccl != (struct cel *)aab; ccl = cel_GetNextChain(ccl)){\ + adew_InitApplicationCel(SELF,ccl,NULL,ARRAY,&dummy);}} + + + #define adew_ReadShort(A,F,CNT) if(CNT-- > 0) fscanf(F,"%d\n",&(A)) + #define adew_ReadLong(A,F,CNT) if(CNT-- > 0) fscanf(F,"%ld\n",&(A)) + #define adew_ReadString(A,F,CNT) if(CNT-- > 0){int ii; char *c;\ + fscanf(F,"#%d\n",&ii);c = (A);\ + while(ii-- > 0) {*c++ = getc(F);}\ + if((*c = getc(F))!= '\n') ungetc(*c,F); \ + *c = '\0';\ + } + #define adew_ReadFloat(A,F,CNT) if(CNT-- > 0) fscanf(F,"%f\n",&(A)) + #define adew_ReadStringArray(A,F,CNT,SIZE) {int inc; for(inc = 0; inc < SIZE; inc++) adew_ReadString((A)[inc],F,CNT);} + #define adew_ReadLongArray(A,F,CNT,SIZE) {int inc; for(inc = 0; inc < SIZE; inc++) adew_ReadLong((A)[inc],F,CNT);} + + #define adew_DiscardString(F) {int ii; \ + fscanf(F,"%d ",&ii);\ + while(ii-- > 0) getc(F);\ + getc(F);\ + } + #define adew_ReadJunk(F) {char c; c = getc(F); if(c != '#'){ while(c != '\n') c = getc(F); }\ + else adew_DiscardString(F) } + #define adew_ReadExtraData(F,CNT) { while (CNT-- > 0) adew_ReadJunk(F) } + + #define adew_WriteShort(A,F) fprintf(F,"%d\n",(A)) + #define adew_WriteLong(A,F) fprintf(F,"%ld\n",(A)) + #define adew_WriteString(A,F) fprintf(F,"#%d\n%s\n",strlen(A),(A)) + #define adew_WriteFloat(A,F) fprintf(F,"%f\n",(A)) + #define adew_WriteStringArray(A,F,SIZE) {int inc; for(inc = 0; inc < SIZE; inc++) adew_WriteString((A)[inc],F);} + #define adew_WriteLongArray(A,F,SIZE) {int inc; for(inc = 0; inc < SIZE; inc++) adew_WriteLong((A)[inc],F);} + + #define adew_InitShort(A) (A) = 0 + #define adew_InitLong(A) (A) = 0L + #define adew_InitString(A) (*(A)) = '\0' + #define adew_InitFloat(A) (A) = 0.0 + #define adew_InitStringArray(A,SIZE) {int inc; for(inc = 0; inc < SIZE; inc++) adew_InitString((A)[inc]);} + #define adew_InitLongArray(A,SIZE) {int inc; for(inc = 0; inc < SIZE; inc++) adew_InitLong((A)[inc]);} + #endif *** atk/music/play.c Wed Nov 22 12:17:59 1989 --- atk/music/play.c.NEW Tue May 21 12:16:04 1991 *************** *** 2,12 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/music/RCS/play.c,v 1.7 89/04/27 21:11:23 wjh Exp $ */ /* $ACIS: $ */ ! /* $Source: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/music/RCS/play.c,v $ */ #ifndef lint ! char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/music/RCS/play.c,v 1.7 89/04/27 21:11:23 wjh Exp $ "; #endif /* lint */ --- 2,12 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/music/RCS/play.c,v 1.8 1991/05/21 14:06:42 wjh Exp $ */ /* $ACIS: $ */ ! /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/music/RCS/play.c,v $ */ #ifndef lint ! char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/music/RCS/play.c,v 1.8 1991/05/21 14:06:42 wjh Exp $ "; #endif /* lint */ *************** *** 30,38 **** #include #include ! #ifdef sys_rt_r3 #include ! #endif /* sys_rt_r3 */ #include #include --- 30,38 ---- #include #include ! #ifdef IBM032_ENV #include ! #endif /* IBM032_ENV */ #include #include *************** *** 50,56 **** static long Volume; /* global volume */ ! #ifdef sys_rt_r3 /* setbl(b, freq) sets the speaker control block bl for frequency freq */ --- 50,56 ---- static long Volume; /* global volume */ ! #ifdef IBM032_ENV /* setbl(b, freq) sets the speaker control block bl for frequency freq */ *************** *** 88,94 **** b->freqlow=SPKOLOMIN; } } ! #endif /* sys_rt_r3 */ /* table mapping vol x Volume into an output volume value. */ static long volTable[] = { --- 88,94 ---- b->freqlow=SPKOLOMIN; } } ! #endif /* IBM032_ENV */ /* table mapping vol x Volume into an output volume value. */ static long volTable[] = { *************** *** 109,115 **** double freq; long length, tempo, vol; { ! #ifdef sys_rt_r3 struct spk_blk b; vol = (vol+2)/3; /* 0->0; 1,2,3->1; 4,5,6->2; 7,8,9->3 */ --- 109,115 ---- double freq; long length, tempo, vol; { ! #ifdef IBM032_ENV struct spk_blk b; vol = (vol+2)/3; /* 0->0; 1,2,3->1; 4,5,6->2; 7,8,9->3 */ *************** *** 136,142 **** b.duration = 1; write(Speaker, &b, sizeof(b)); #endif /* 0 */ ! #endif /* sys_rt_r3 */ } --- 136,142 ---- b.duration = 1; write(Speaker, &b, sizeof(b)); #endif /* 0 */ ! #endif /* IBM032_ENV */ } *************** *** 279,290 **** { if (duration < 0) return; if (duration > 10000) duration = 5000; /* if more than 10 seconds, give 5 seconds */ ! #ifdef sys_rt_r3 if ((Speaker=open("/dev/speaker",1)) <= 0) return; playonenote(freq, duration, 120, 3); close(Speaker); ! #endif /* sys_rt_r3 */ } void --- 279,290 ---- { if (duration < 0) return; if (duration > 10000) duration = 5000; /* if more than 10 seconds, give 5 seconds */ ! #ifdef IBM032_ENV if ((Speaker=open("/dev/speaker",1)) <= 0) return; playonenote(freq, duration, 120, 3); close(Speaker); ! #endif /* IBM032_ENV */ } void *************** *** 297,308 **** else if (volume > 9) volume = 9; if (duration < 0) return; if (duration > 10000) duration = 5000; /* if more than 10 seconds, give 5 seconds */ ! #ifdef sys_rt_r3 if ((Speaker=open("/dev/speaker",1)) <= 0) return; playonenote(freq, duration, 120, volume); close(Speaker); ! #endif /* sys_rt_r3 */ } --- 297,308 ---- else if (volume > 9) volume = 9; if (duration < 0) return; if (duration > 10000) duration = 5000; /* if more than 10 seconds, give 5 seconds */ ! #ifdef IBM032_ENV if ((Speaker=open("/dev/speaker",1)) <= 0) return; playonenote(freq, duration, 120, volume); close(Speaker); ! #endif /* IBM032_ENV */ } *************** *** 457,466 **** length = WHOLENOTE / 4; /* at tempo 120, a quarter note is 500 milliseconds */ octave = 4; vol = 3; ! #ifdef sys_rt_r3 if ((Speaker=open("/dev/speaker",1)) <= 0) return; ! #endif /* sys_rt_r3 */ for (codep = s; *codep != '\0'; codep ++) { switch (*codep) { --- 457,466 ---- length = WHOLENOTE / 4; /* at tempo 120, a quarter note is 500 milliseconds */ octave = 4; vol = 3; ! #ifdef IBM032_ENV if ((Speaker=open("/dev/speaker",1)) <= 0) return; ! #endif /* IBM032_ENV */ for (codep = s; *codep != '\0'; codep ++) { switch (*codep) { *************** *** 495,503 **** codep++; break; } } ! #ifdef sys_rt_r3 close(Speaker); ! #endif /* sys_rt_r3 */ } void --- 495,503 ---- codep++; break; } } ! #ifdef IBM032_ENV close(Speaker); ! #endif /* IBM032_ENV */ } void *************** *** 527,535 **** Volume = 3; InitFreq(EqualTemper); ! #ifdef sys_rt_r3 return TRUE; ! #else /* sys_rt_r3 */ return FALSE; ! #endif /* sys_rt_r3 */ } --- 527,535 ---- Volume = 3; InitFreq(EqualTemper); ! #ifdef IBM032_ENV return TRUE; ! #else /* IBM032_ENV */ return FALSE; ! #endif /* IBM032_ENV */ } *** atk/ness/tokens/Imakefile Thu Jan 10 14:57:45 1991 --- atk/ness/tokens/Imakefile.NEW Wed Apr 3 21:20:28 1991 *************** *** 9,17 **** DOCS = lex.doc sym.doc #ifdef RESOLVER_ENV ! RESOLVER_LIB = ${RESOLVLIB} #else RESOLVER_LIB = #endif NormalObjectRule() --- 9,24 ---- DOCS = lex.doc sym.doc #ifdef RESOLVER_ENV ! #ifdef LIBDL_ENV ! SYS_LIBS = -lresolv -lm ! RESOLVER_LIB = #else + RESOLVER_LIB = $(RESOLVLIB) + SYS_LIBS = -lm + #endif /* LIBDL_ENV */ + #else RESOLVER_LIB = + SYS_LIBS = -lm #endif NormalObjectRule() *************** *** 31,37 **** ProgramTarget(buildy, buildy.o, ${MALLOCLIB}, -lm) ProgramTarget(reyacc, reyacc.o qsearch.o, ${MALLOCLIB}, -lm) ! ProgramTarget(lextest, lextest.o, ${LIBS}, -lm) test:: lextest lextest test.in | diff - test.owt --- 38,44 ---- ProgramTarget(buildy, buildy.o, ${MALLOCLIB}, -lm) ProgramTarget(reyacc, reyacc.o qsearch.o, ${MALLOCLIB}, -lm) ! ProgramTarget(lextest, lextest.o, ${LIBS}, $(SYS_LIBS)) test:: lextest lextest test.in | diff - test.owt *** atk/ness/tokens/toksym.c Wed Nov 22 12:18:59 1989 --- atk/ness/tokens/toksym.c.NEW Mon May 13 14:24:07 1991 *************** *** 2,13 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/ness/tokens/RCS/toksym.c,v 1.4 89/06/01 10:09:24 wjh Exp $ */ /* $ACIS:$ */ ! /* $Source: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/ness/tokens/RCS/toksym.c,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/ness/tokens/RCS/toksym.c,v 1.4 89/06/01 10:09:24 wjh Exp $"; #endif /* toksym.c --- 2,13 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/ness/tokens/RCS/toksym.c,v 1.6 1991/05/13 18:17:04 susan Exp $ */ /* $ACIS:$ */ ! /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/ness/tokens/RCS/toksym.c,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/ness/tokens/RCS/toksym.c,v 1.6 1991/05/13 18:17:04 susan Exp $"; #endif /* toksym.c *************** *** 15,21 **** Code for the toksym object */ /* ! * $Log: toksym.c,v $ * Revision 1.4 89/06/01 10:09:24 wjh * revision for new securtiy system * --- 15,28 ---- Code for the toksym object */ /* ! * $Log: toksym.c,v $ ! * Revision 1.6 1991/05/13 18:17:04 susan ! * added end of line ! * . ! * ! * Revision 1.5 1991/01/14 17:23:03 wjh ! * added a routine to extract the symbol value from the original text ! * * Revision 1.4 89/06/01 10:09:24 wjh * revision for new securtiy system * *************** *** 29,34 **** --- 36,43 ---- #include #include + #include + #include boolean *************** *** 48,51 **** --- 57,84 ---- struct classhdr *ClassID; struct toksym *self; { + } + + /* toksym__ToC(t, buf, maxlen) + copies the token from the text t to the buffer buf, up to maxlen bytes + returns buf + */ + char * + toksym__ToC(self, t, buf, maxlen) + struct toksym *self; + register struct text *t; + register char *buf; + long maxlen; + { + register char *cx; + register long loc, len; + cx = buf; + loc = self->loc; + len = self->len; + if (len > maxlen-1) + len = maxlen - 1; + for ( ; len > 0; len--, loc++) + *cx++ = simpletext_CorrectGetChar(&t->header.simpletext, loc); + *cx = '\0'; + return buf; } *** atk/ness/tokens/toksym.ch Wed Nov 22 12:19:05 1989 --- atk/ness/tokens/toksym.ch.NEW Mon Jan 21 12:39:36 1991 *************** *** 2,13 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/ness/tokens/RCS/toksym.ch,v 1.6 89/08/23 16:11:49 wjh Exp $ */ /* $ACIS:$ */ ! /* $Source: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/ness/tokens/RCS/toksym.ch,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *toksym_H_rcsid = "$Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/ness/tokens/RCS/toksym.ch,v 1.6 89/08/23 16:11:49 wjh Exp $"; #endif /* toksym.H --- 2,13 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/ness/tokens/RCS/toksym.ch,v 1.7 91/01/14 17:23:26 wjh Exp $ */ /* $ACIS:$ */ ! /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/ness/tokens/RCS/toksym.ch,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *toksym_H_rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/ness/tokens/RCS/toksym.ch,v 1.7 91/01/14 17:23:26 wjh Exp $"; #endif /* toksym.H *************** *** 21,26 **** --- 21,29 ---- /* * $Log: toksym.ch,v $ + Revision 1.7 91/01/14 17:23:26 wjh + added a routine to extract the symbol value from the original text + Revision 1.6 89/08/23 16:11:49 wjh andrewos *************** *** 61,66 **** --- 64,74 ---- class toksym : sym { + methods: + + ToC(/*struct toksym *self, */ struct text *t, char *buf, long maxlen) returns char *; + /* copies the token from the text to the buffer, up to maxlen bytes + returns buf */ macros: *** atk/ness/tokens/qsearch.c Fri Dec 21 14:56:22 1990 --- atk/ness/tokens/qsearch.c.NEW Tue Dec 4 08:59:03 1990 *************** *** 1,12 **** /* ********************************************************************** *\ * Copyright IBM Corporation 1988,1989 - All Rights Reserved * \* ********************************************************************** */ ! /* $Header: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/ness/tokens/RCS/qsearch.c,v 1.1 90/10/12 20:54:33 wjh Exp $ */ /* $ACIS:$ */ ! /* $Source: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/ness/tokens/RCS/qsearch.c,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsid = "$Header: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/ness/tokens/RCS/qsearch.c,v 1.1 90/10/12 20:54:33 wjh Exp $"; #endif /* --- 1,12 ---- /* ********************************************************************** *\ * Copyright IBM Corporation 1988,1989 - All Rights Reserved * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/ness/tokens/RCS/qsearch.c,v 1.2 90/11/28 14:39:46 susan Exp $ */ /* $ACIS:$ */ ! /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/ness/tokens/RCS/qsearch.c,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/ness/tokens/RCS/qsearch.c,v 1.2 90/11/28 14:39:46 susan Exp $"; #endif /* *************** *** 30,35 **** --- 30,38 ---- */ /* * $Log: qsearch.c,v $ + * Revision 1.2 90/11/28 14:39:46 susan + * moved andrewos.h to be first include file + * * Revision 1.1 90/10/12 20:54:33 wjh * Initial revision * *************** *** 38,46 **** * */ #include /* for NULL */ #include /* isspace() */ - #include /* bcmp() */ /* qsearch(srcloc, srclen, patloc, patlen) returns char *; returns the location of the found string --- 41,49 ---- * */ + #include /* bcmp() */ #include /* for NULL */ #include /* isspace() */ /* qsearch(srcloc, srclen, patloc, patlen) returns char *; returns the location of the found string *** atk/ness/type/Imakefile Thu Jan 10 14:57:44 1991 --- atk/ness/type/Imakefile.NEW Wed Apr 3 21:20:31 1991 *************** *** 13,21 **** DOCFILES = type.doc #ifdef RESOLVER_ENV ! RESOLVER_LIB = ${RESOLVLIB} #else RESOLVER_LIB = #endif ATKLIBS= ${BASEDIR}/lib/atk/libframe.a \ --- 13,28 ---- DOCFILES = type.doc #ifdef RESOLVER_ENV ! #ifdef LIBDL_ENV ! SYS_LIBS = -lresolv -lm ! RESOLVER_LIB = #else + RESOLVER_LIB = $(RESOLVLIB) + SYS_LIBS = -lm + #endif /* LIBDL_ENV */ + #else RESOLVER_LIB = + SYS_LIBS = -lm #endif ATKLIBS= ${BASEDIR}/lib/atk/libframe.a \ *************** *** 36,44 **** InstallClassFiles($(DOBJS), $(IHFILES)) DynamicMultiObject(type.do, type.o parse.o err.o, ${BASEDIR}/lib/atk/libbasics.a, -lm) ! ProgramTarget(chtest, chtest.o, ${LIBS}, ) InstallProgram(chtest, $(DESTDIR)/bin) ! TestProgramTarget(typetest, typetest.o, ${LIBS},) parse.y: ../tokens/buildy parse.gra ../tokens/buildy parse.gra parse.y --- 43,51 ---- InstallClassFiles($(DOBJS), $(IHFILES)) DynamicMultiObject(type.do, type.o parse.o err.o, ${BASEDIR}/lib/atk/libbasics.a, -lm) ! ProgramTarget(chtest, chtest.o, ${LIBS}, $(SYS_LIBS)) InstallProgram(chtest, $(DESTDIR)/bin) ! TestProgramTarget(typetest, typetest.o, ${LIBS}, $(SYS_LIBS)) parse.y: ../tokens/buildy parse.gra ../tokens/buildy parse.gra parse.y *** atk/ness/objects/Imakefile Fri Dec 21 14:56:25 1990 --- atk/ness/objects/Imakefile.NEW Mon Feb 18 18:01:36 1991 *************** *** 33,38 **** --- 33,50 ---- ${UTILLIB} \ ${WMLIB} + #ifdef LIBDL_ENV + /* + * We have to make sure the "shared" directory is made when we do "depend", + * because to do a "depend" we need the ".h" files, to get the ".h" files + * we need to have "nodeclass" built", to get "nodeclass" built we need + * to have "nodeclss.o" built, and with the generic ".c.o" rule, in order + * to have "nodeclss.o" built we need the "shared" subdirectory. + */ + depend:: + @if [ ! -d shared ]; then mkdir shared; else exit 0; fi + #endif + all:: init NormalObjectRule() *************** *** 65,71 **** nesscomp.c:: nesscomp.gra ${TOKENS}/yaccpar ${TOKENS}/buildy ${TOKENS}/reyacc echo "nesscomp.c NOT REBUILT FROM nesscomp.gra" # nesscomp.c:: nesscomp.gra ${TOKENS}/yaccpar ${TOKENS}/buildy ${TOKENS}/reyacc ! #nesscomp.c:: # ${TOKENS}/buildy nesscomp.gra nesscomp.z # $(YACC) ${YFLAGS} $*.z # -$(RM) $*.c --- 77,83 ---- nesscomp.c:: nesscomp.gra ${TOKENS}/yaccpar ${TOKENS}/buildy ${TOKENS}/reyacc echo "nesscomp.c NOT REBUILT FROM nesscomp.gra" # nesscomp.c:: nesscomp.gra ${TOKENS}/yaccpar ${TOKENS}/buildy ${TOKENS}/reyacc ! # # ${TOKENS}/buildy nesscomp.gra nesscomp.z # $(YACC) ${YFLAGS} $*.z # -$(RM) $*.c *** atk/ness/objects/call.c Fri Dec 21 14:56:27 1990 --- atk/ness/objects/call.c.NEW Wed Apr 3 21:20:41 1991 *************** *** 1,12 **** /* ********************************************************************** *\ * Copyright IBM Corporation 1988,1989 - All Rights Reserved * \* ********************************************************************** */ ! /* $Header: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/ness/objects/RCS/call.c,v 1.38 90/10/12 21:07:59 wjh Exp $ */ /* $ACIS:$ */ ! /* $Source: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/ness/objects/RCS/call.c,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsid = "$Header: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/ness/objects/RCS/call.c,v 1.38 90/10/12 21:07:59 wjh Exp $"; #endif /* --- 1,12 ---- /* ********************************************************************** *\ * Copyright IBM Corporation 1988,1989 - All Rights Reserved * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/ness/objects/RCS/call.c,v 1.41 91/04/01 11:36:17 wjh Exp $ */ /* $ACIS:$ */ ! /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/ness/objects/RCS/call.c,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/ness/objects/RCS/call.c,v 1.41 91/04/01 11:36:17 wjh Exp $"; #endif /* *************** *** 13,20 **** call.c - call a function from Ness */ - #include #include #include #include #include --- 13,20 ---- call.c - call a function from Ness */ #include + #include #include #include #include *************** *** 999,1006 **** RunError(argcounterror(toomanyargs, call->nargs - n), iar); else if (call->nargs < n) RunError(argcounterror(toofewargs, n - call->nargs), iar); ! else for (n=0, formals = fnode->parmlist; formals != NULL; ! formals = formals->next, n++) if (formals->type != call->argtype[n]) RunError(argtypeerror(call->nargs - n, formals->type, call->argtype[n]), iar); --- 999,1006 ---- RunError(argcounterror(toomanyargs, call->nargs - n), iar); else if (call->nargs < n) RunError(argcounterror(toofewargs, n - call->nargs), iar); ! else for (formals = fnode->parmlist; --n, formals != NULL; ! formals = formals->next) if (formals->type != call->argtype[n]) RunError(argtypeerror(call->nargs - n, formals->type, call->argtype[n]), iar); *************** *** 1804,1809 **** } if (attributes != NULL) text_SetAttributes(text, attributes); ! val = text_Read(text, f, objectID); } --- 1804,1809 ---- } if (attributes != NULL) text_SetAttributes(text, attributes); ! return text_Read(text, f, objectID); } *** atk/ness/objects/dump.c Fri Dec 21 14:56:29 1990 --- atk/ness/objects/dump.c.NEW Mon Jan 21 12:40:39 1991 *************** *** 1,12 **** /* ********************************************************************** *\ * Copyright IBM Corporation 1988,1989 - All Rights Reserved * \* ********************************************************************** */ ! /* $Header: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/ness/objects/RCS/dump.c,v 1.12 90/10/12 21:08:21 wjh Exp $ */ /* $ACIS:$ */ ! /* $Source: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/ness/objects/RCS/dump.c,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsid = "$Header: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/ness/objects/RCS/dump.c,v 1.12 90/10/12 21:08:21 wjh Exp $"; #endif /* dump.c --- 1,12 ---- /* ********************************************************************** *\ * Copyright IBM Corporation 1988,1989 - All Rights Reserved * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/ness/objects/RCS/dump.c,v 1.13 91/01/14 17:22:13 wjh Exp $ */ /* $ACIS:$ */ ! /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/ness/objects/RCS/dump.c,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/ness/objects/RCS/dump.c,v 1.13 91/01/14 17:22:13 wjh Exp $"; #endif /* dump.c *************** *** 24,29 **** --- 24,37 ---- /* * $Log: dump.c,v $ + * Revision 1.13 91/01/14 17:22:13 wjh + * updated for changes to styles + * This fixes the problem that 'extend' did not work. + * The problem was that short strings were treated as having styles. + * Also added line spacing, tabs, and color to MergeStyles + * and fixed AddStyles to not put on styles that are already shared + * (by pointer) between target and source. + * * Revision 1.12 90/10/12 21:08:21 wjh * revised yaccpar to eliminate saving parser state. * moved yycompile to gen.c *************** *** 662,667 **** --- 670,676 ---- FILE *file; struct nesssym *symlist; { + char buf[256]; for ( ; symlist; symlist = symlist->next) switch (symlist->flags) { case flag_function | flag_ness: *************** *** 675,684 **** break; case flag_xobj: fprintf(file, "\nEXTENDED OBJECT %s\n", ! nesssym_NGetName(symlist) + 1); dumpAttrList(file, (nesssym_NGetINode(symlist,objnode)->attrs)); ! fprintf(file, "END OBJECT %s\n\n", ! nesssym_NGetName(symlist) + 1); break; case flag_event: dumpEventDef(file, symlist); --- 684,693 ---- break; case flag_xobj: fprintf(file, "\nEXTENDED OBJECT %s\n", ! nesssym_ToC(symlist, &curNess->header.text, ! buf, sizeof(buf))); dumpAttrList(file, (nesssym_NGetINode(symlist,objnode)->attrs)); ! fprintf(file, "END OBJECT %s\n\n", buf); break; case flag_event: dumpEventDef(file, symlist); *** atk/ness/objects/envt.h Fri Dec 21 14:28:31 1990 --- atk/ness/objects/envt.h.NEW Tue May 21 15:23:54 1991 *************** *** 2,8 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/ness/objects/RCS/envt.h,v 1.7 90/09/16 20:14:20 wjh Exp $ */ /* $ACIS:$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/ness/objects/RCS/envt.h,v $ */ --- 2,8 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/ness/objects/RCS/envt.h,v 1.9 1991/05/21 17:47:25 gk5g Exp $ */ /* $ACIS:$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/ness/objects/RCS/envt.h,v $ */ *************** *** 20,26 **** */ /* ! * $Log: envt.h,v $ * Revision 1.7 90/09/16 20:14:20 wjh * see ness/objects/changes.sept.90 * --- 20,34 ---- */ /* ! * $Log: envt.h,v $ ! * Revision 1.9 1991/05/21 17:47:25 gk5g ! * Removed reference to hpux in cpp declarations surrounding CLASS macro. ! * HPUX isn't completely ANSI yet. ! * . ! * ! * Revision 1.8 1991/02/21 10:19:16 wjh ! * adapted for ANSI-C. Thanks to Bill Cattey. ! * * Revision 1.7 90/09/16 20:14:20 wjh * see ness/objects/changes.sept.90 * *************** *** 67,74 **** extern struct classinfo *valueviewClass; extern struct classinfo *imClass; #define CLASS(d) ((d/**/Class == NULL) ? (d/**/Class = class_Load("d")) : d/**/Class) ! extern struct simpletext *ObjectCode; /* the compiled bytecode for the functions */ --- 75,85 ---- extern struct classinfo *valueviewClass; extern struct classinfo *imClass; + #if defined(__STDC__) && !defined(__HIGHC__) || defined(_IBMR2) + #define CLASS(d) ((d##Class == NULL) ? (d##Class = class_Load(#d)) : d##Class) + #else /* defined(__STDC__) && !defined(__HIGHC__) */ #define CLASS(d) ((d/**/Class == NULL) ? (d/**/Class = class_Load("d")) : d/**/Class) ! #endif /* defined(__STDC__) && !defined(__HIGHC__) */ extern struct simpletext *ObjectCode; /* the compiled bytecode for the functions */ *** atk/ness/objects/gen.c Fri Dec 21 14:56:37 1990 --- atk/ness/objects/gen.c.NEW Wed Feb 13 16:52:41 1991 *************** *** 1,12 **** /* ********************************************************************** *\ * Copyright IBM Corporation 1988,1989 - All Rights Reserved * \* ********************************************************************** */ ! /* $Header: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/ness/objects/RCS/gen.c,v 1.20 90/10/12 21:08:28 wjh Exp $ */ /* $ACIS:$ */ ! /* $Source: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/ness/objects/RCS/gen.c,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsid = "$Header: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/ness/objects/RCS/gen.c,v 1.20 90/10/12 21:08:28 wjh Exp $"; #endif /* --- 1,12 ---- /* ********************************************************************** *\ * Copyright IBM Corporation 1988,1989 - All Rights Reserved * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/ness/objects/RCS/gen.c,v 1.21 90/11/28 14:38:29 susan Exp $ */ /* $ACIS:$ */ ! /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/ness/objects/RCS/gen.c,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/ness/objects/RCS/gen.c,v 1.21 90/11/28 14:38:29 susan Exp $"; #endif /* *************** *** 15,20 **** --- 15,23 ---- */ /* * $Log: gen.c,v $ + * Revision 1.21 90/11/28 14:38:29 susan + * moved andrewos.h to be first include file + * * Revision 1.20 90/10/12 21:08:28 wjh * revised yaccpar to eliminate saving parser state. * moved yycompile to gen.c *************** *** 162,169 **** * Initial creation by WJHansen * */ - #include #include /* for bzero() */ #include #include --- 165,172 ---- * Initial creation by WJHansen * */ #include /* for bzero() */ + #include #include #include *** atk/ness/objects/interp.c Fri Dec 21 14:56:42 1990 --- atk/ness/objects/interp.c.NEW Thu Feb 21 15:37:33 1991 *************** *** 1,12 **** /* ********************************************************************** *\ * Copyright IBM Corporation 1988,1989 - All Rights Reserved * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/ness/objects/RCS/interp.c,v 1.32 90/09/30 09:48:00 wjh Exp $ */ /* $ACIS:$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/ness/objects/RCS/interp.c,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/ness/objects/RCS/interp.c,v 1.32 90/09/30 09:48:00 wjh Exp $"; #endif /* interp.c --- 1,12 ---- /* ********************************************************************** *\ * Copyright IBM Corporation 1988,1989 - All Rights Reserved * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/ness/objects/RCS/interp.c,v 1.35 91/02/21 10:47:02 wjh Exp $ */ /* $ACIS:$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/ness/objects/RCS/interp.c,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/ness/objects/RCS/interp.c,v 1.35 91/02/21 10:47:02 wjh Exp $"; #endif /* interp.c *************** *** 21,26 **** --- 21,38 ---- /* * $Log: interp.c,v $ + * Revision 1.35 91/02/21 10:47:02 wjh + * extend error check in readfile so it does not try to read file if the name is an empty string + * + * Revision 1.34 91/02/08 14:34:57 wjh + * readfile and writefile will no longer signal a runtime error if they cannot access the given file. + * Instead they send a message to stderr which shows up in the console. + * For an errroneous file, readfile and writefile return an empty strings. + * The control-G will no longer be treated as a runtime error. Instead it will calmly terminate Ness execution and display the message "Interrupted !" + * + * Revision 1.33 90/12/11 17:05:23 wjh + * fix so stack pointer is correctly set after calling a C function + * * Revision 1.32 90/09/30 09:48:00 wjh * improved compilability of the bcopys. compliments of Guy Harris * *************** *** 462,467 **** --- 474,489 ---- #endif static void + InterruptNess(ness) + struct ness *ness; + { + message_DisplayString(im_GetLastUsed(), 0, "Interrupted !"); + im_ForceUpdate(); + ness->ToldUser = TRUE; + longjmp(ExecutionExit, 1); /* normal exit */ + } + + static void QueryReadOnly(ness, s, msg, iar) struct ness *ness; struct simpletext *s; *************** *** 699,707 **** brancher: { long offset; unsigned char chi, clo; ! if (gocount++ >1000) { if (im_CheckForInterrupt()) ! RunError(":Interrupted !", iar - 3); if (! Gmessaged) { struct osi_Times now; osi_GetTimes(&now); --- 721,729 ---- brancher: { long offset; unsigned char chi, clo; ! if (gocount++ > 600) { if (im_CheckForInterrupt()) ! InterruptNess(ness); if (! Gmessaged) { struct osi_Times now; osi_GetTimes(&now); *************** *** 733,762 **** PTSTOMARK(NSP, iar-1); /* file name */ /* open the file */ s = nessmark_ToC(&NSP->m); ! f = fopen(s, "r"); ! if (f == NULL) { ! char *msg = malloc(strlen(s)+40); ! sprintf(msg, "*readfile is unable to open file \"%s\"", s); ! free(s); ! RunError(msg, iar-1); ! } NSP = popValue(NSP); /* discard filename */ - t = text_New(); /* create a new mark for the file to read into */ NSPushSpace(nessmark); nessmark_Initialize(&NSP->m); nessmark_Set(&NSP->m, t, 0, 0); ! /* now read the file into mark on top of stack */ ! val = ReadTextFileStream(t, s, f); ! if (val != dataobject_NOREADERROR) { ! char *msg = malloc(strlen(s)+70); ! sprintf(msg, "*readfile format failure %d for file \"%s\"", val, s); ! free(s); ! RunError(msg, iar-1); } - fclose(f); free(s); nessmark_SetLength(&NSP->m, text_GetLength(t)); } break; --- 755,778 ---- PTSTOMARK(NSP, iar-1); /* file name */ /* open the file */ s = nessmark_ToC(&NSP->m); ! f = (*s == '\0') ? NULL : fopen(s, "r"); NSP = popValue(NSP); /* discard filename */ /* create a new mark for the file to read into */ + t = text_New(); NSPushSpace(nessmark); nessmark_Initialize(&NSP->m); nessmark_Set(&NSP->m, t, 0, 0); ! if (f == NULL) ! fprintf(stderr, "Ness: cannot read file \"%s\"\n", s); ! else { ! /* read the file into mark on top of stack */ ! val = ReadTextFileStream(t, s, f); ! if (val != dataobject_NOREADERROR) ! fprintf(stderr, "Ness: file not in ATK format \"%s\"", s); ! fclose(f); } free(s); nessmark_SetLength(&NSP->m, text_GetLength(t)); } break; *************** *** 1102,1107 **** --- 1118,1124 ---- /* callC, callPE, callGet, callSet, callMethod, callClProc */ callCfunc(pcall.call, iar-5, ness); + NSP= NSPstore; } } break; case 'E': /* load to stack top a pointer to the current textview object */ *************** *** 1284,1292 **** /* operand is two bytes giving index into SysMark */ register unsigned long funcloc; long lengthgotten; ! if (gocount++ >1000) { if (im_CheckForInterrupt()) ! RunError(":Interrupted !", iar - 3); else gocount = 0; } funcloc = (unsigned long)*iar++ << 8; --- 1301,1309 ---- /* operand is two bytes giving index into SysMark */ register unsigned long funcloc; long lengthgotten; ! if (gocount++ >600) { if (im_CheckForInterrupt()) ! InterruptNess(ness); else gocount = 0; } funcloc = (unsigned long)*iar++ << 8; *************** *** 1546,1553 **** /* open the file */ f = fopen(s=nessmark_ToC(filename), "w"); free(s); ! if (f == NULL) ! RunError(":Could not open file for writing", iar-1); /* write contents to file */ pos = nessmark_GetPos(contents); --- 1563,1574 ---- /* open the file */ f = fopen(s=nessmark_ToC(filename), "w"); free(s); ! if (f == NULL) { ! /* return start(arg) */ ! NSP = popValue(NSP); /* discard filename */ ! nessmark_SetLength(&NSP->m, 0); /* nessmark_Start */ ! break; ! } /* write contents to file */ pos = nessmark_GetPos(contents); *** atk/ness/objects/ness.c Fri Dec 21 14:56:45 1990 --- atk/ness/objects/ness.c.NEW Wed Nov 28 15:53:03 1990 *************** *** 2,13 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/ness/objects/RCS/ness.c,v 1.30 90/10/12 21:11:20 wjh Exp $ */ /* $ACIS:$ */ ! /* $Source: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/ness/objects/RCS/ness.c,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsid = "$Header: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/ness/objects/RCS/ness.c,v 1.30 90/10/12 21:11:20 wjh Exp $"; #endif /* ness.c --- 2,13 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/ness/objects/RCS/ness.c,v 1.31 90/11/28 14:38:48 susan Exp $ */ /* $ACIS:$ */ ! /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/ness/objects/RCS/ness.c,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/ness/objects/RCS/ness.c,v 1.31 90/11/28 14:38:48 susan Exp $"; #endif /* ness.c *************** *** 16,21 **** --- 16,24 ---- */ /* * $Log: ness.c,v $ + * Revision 1.31 90/11/28 14:38:48 susan + * moved andrewos.h to be first include file + * * Revision 1.30 90/10/12 21:11:20 wjh * Revised the getc/ungetc code in ness__ReadNamedFile to try to make it work on PMAX and Sun4 * revised yaccpar to eliminate saving parser state. *************** *** 197,204 **** * Copied from /usr/andrew/lib/dummy */ - #include #include /* for strings.h */ #include #include #include --- 200,207 ---- * Copied from /usr/andrew/lib/dummy */ #include /* for strings.h */ + #include #include #include #include *** atk/ness/objects/nesscomp.gra Fri Dec 21 14:56:49 1990 --- atk/ness/objects/nesscomp.gra.NEW Wed Feb 13 16:52:49 1991 *************** *** 1,12 **** %{/* ********************************************************************** *\ * Copyright IBM Corporation 1988,1989 - All Rights Reserved * \* ********************************************************************** */ ! /* $Header: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/ness/objects/RCS/nesscomp.gra,v 1.13 90/10/12 21:05:57 wjh Exp $ */ /* $ACIS:$ */ ! /* $Source: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/ness/objects/RCS/nesscomp.gra,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! char *ness_gra_rcsid = "$Header: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/ness/objects/RCS/nesscomp.gra,v 1.13 90/10/12 21:05:57 wjh Exp $"; #endif /* !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) */ --- 1,12 ---- %{/* ********************************************************************** *\ * Copyright IBM Corporation 1988,1989 - All Rights Reserved * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/ness/objects/RCS/nesscomp.gra,v 1.14 91/02/08 14:31:50 wjh Exp $ */ /* $ACIS:$ */ ! /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/ness/objects/RCS/nesscomp.gra,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! char *ness_gra_rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/ness/objects/RCS/nesscomp.gra,v 1.14 91/02/08 14:31:50 wjh Exp $"; #endif /* !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) */ *************** *** 283,291 **** genSaveStmtStart(-1); predpush(predcond, lex_RecentPosition(-1, &len), 'E'); $$ = neventStartExtend(curNess->CurrentObject, $2); - /* link this extend so codeloc entries from ON xxx - are attached to the Ness */ - genLinkGlobal($$); curNess->saveAttrDest = curNess->AttrDest; curNess->AttrDest = &(nesssym_NGetINode($$, objnode)->attrs); curNess->CurrentObject = $$; --- 283,288 ---- *** atk/ness/objects/nevent.c Fri Dec 21 14:57:02 1990 --- atk/ness/objects/nevent.c.NEW Wed Feb 13 16:52:51 1991 *************** *** 1,12 **** /* ********************************************************************** *\ * Copyright IBM Corporation 1988,1989 - All Rights Reserved * \* ********************************************************************** */ ! /* $Header: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/ness/objects/RCS/nevent.c,v 1.24 90/10/12 21:17:15 wjh Exp $ */ /* $ACIS:$ */ ! /* $Source: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/ness/objects/RCS/nevent.c,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsid = "$Header: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/ness/objects/RCS/nevent.c,v 1.24 90/10/12 21:17:15 wjh Exp $"; #endif /* nevent.c - object extension and event handling for Ness --- 1,12 ---- /* ********************************************************************** *\ * Copyright IBM Corporation 1988,1989 - All Rights Reserved * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/ness/objects/RCS/nevent.c,v 1.26 91/02/08 14:33:29 wjh Exp $ */ /* $ACIS:$ */ ! /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/ness/objects/RCS/nevent.c,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/ness/objects/RCS/nevent.c,v 1.26 91/02/08 14:33:29 wjh Exp $"; #endif /* nevent.c - object extension and event handling for Ness *************** *** 81,99 **** { } static unsigned char * CelSymName(name) unsigned char *name; { - #define MAXNAME 100 static unsigned char buf[MAXNAME+1]; strncpy(buf+1, name, MAXNAME-1); buf[MAXNAME] = '\0'; /* truncate if too long */ buf[0] = '&'; return buf; - #undef MAXNAME } /* neventStartExtend(currobj, name) start compilation of an object extension --- 81,100 ---- { } + #define MAXNAME 100 + static unsigned char * CelSymName(name) unsigned char *name; { static unsigned char buf[MAXNAME+1]; strncpy(buf+1, name, MAXNAME-1); buf[MAXNAME] = '\0'; /* truncate if too long */ buf[0] = '&'; return buf; } + #undef MAXNAME /* neventStartExtend(currobj, name) start compilation of an object extension *************** *** 110,124 **** struct nesssym *newobj; boolean new; struct classinfo *viewClass = NULL; boolean isView = FALSE; ! unsigned char *cname = CelSymName(nesssym_NGetName(name)+1); ! if (currobj != NULL) ReportError(":'Extend' is not allowed inside an 'extend' block", -1); newobj = nesssym_NLocate(cname, name, nesssym_NGetScope(name), &new); newobj->flags = flag_xobj; newobj->type = Tptr; - if (strncmp(cname, "&view:", 6) == 0) { /* set viewClass from the rest of the name */ isView = TRUE; --- 111,131 ---- struct nesssym *newobj; boolean new; struct classinfo *viewClass = NULL; + char buf[100]; boolean isView = FALSE; ! unsigned char *cname = CelSymName(nesssym_ToC(name, ! &curNess->header.text, buf, sizeof(buf))); if (currobj != NULL) ReportError(":'Extend' is not allowed inside an 'extend' block", -1); + newobj = nesssym_NLocate(cname, name, nesssym_NGetScope(name), &new); + if ( ! new) { + genPushScope(nesssym_NGetINode(newobj, objnode)->scope); + return newobj; + } + newobj->flags = flag_xobj; newobj->type = Tptr; if (strncmp(cname, "&view:", 6) == 0) { /* set viewClass from the rest of the name */ isView = TRUE; *************** *** 132,137 **** --- 139,147 ---- (struct celview *) viewClass, NULL, NULL, /* pe's */ NULL, NULL, FALSE, isView)); /* data */ + + /* link this extend so codeloc entries from ON xxx are attached to the Ness */ + genLinkGlobal(newobj); return newobj; } *************** *** 170,183 **** struct nesssym *newevent; boolean new; unsigned char buf[400]; ! nesssym_scopeType oldscope = lex_GetScope(lex_GetCurrent()); /* save before changed ! by genNewScope() */ static long nextevent = 0; ! if (strlen(nesssym_NGetName(spec)) > 300) { ! ReportError(":specification truncated to 300 characters", 0); ! spec->header.sym.name[300] = '\0'; /* UGH */ ! } ! sprintf(buf, "\\ Event %d (%s)", nextevent++, nesssym_NGetName(spec)); if (currobj == NULL) ReportError(":'on' is not allowed outside an 'extend' block", -2); --- 180,195 ---- struct nesssym *newevent; boolean new; unsigned char buf[400]; ! nesssym_scopeType oldscope = lex_GetScope(lex_GetCurrent()); /* save ! before changed by genNewScope() */ static long nextevent = 0; ! char cname[256]; ! ! if (spec->header.toksym.len > sizeof(cname)) ! ReportError(":specification exceeds 256 characters", 0); ! ! sprintf(buf, "\\ Event %d (%s)", nextevent++, ! nesssym_ToC(spec, &curNess->header.text, cname, sizeof(cname))); if (currobj == NULL) ReportError(":'on' is not allowed outside an 'extend' block", -2); *************** *** 189,197 **** oldscope, genNewScope(), lex_RecentPosition(-2, 0), 999, NULL, e, ! (unsigned char *)freeze(nesssym_NGetName(spec) + 1), ! /* XXX when setSTRINGCON hasn't info, ! the above must change */ curNess, NULL, /* no TriggerHolder */ FALSE /* not enabled yet */ --- 201,207 ---- oldscope, genNewScope(), lex_RecentPosition(-2, 0), 999, NULL, e, ! (unsigned char *)freeze(cname), curNess, NULL, /* no TriggerHolder */ FALSE /* not enabled yet */ *************** *** 1035,1045 **** boolean repost; struct nesssym *xattr; struct objnode *onode; repost = FALSE; if (PostDebug) ! printf("Posting events for %s\n", nesssym_GetName(attr)+1); /* traverse xattr's, posting each event */ onode = nesssym_NGetINode(attr, objnode); --- 1045,1057 ---- boolean repost; struct nesssym *xattr; struct objnode *onode; + char buf[100]; repost = FALSE; if (PostDebug) ! printf("Posting events for %s\n", ! nesssym_ToC(attr, &curNess->header.text, buf, sizeof(buf))); /* traverse xattr's, posting each event */ onode = nesssym_NGetINode(attr, objnode); *************** *** 1086,1091 **** --- 1098,1104 ---- register struct objnode *onode = nesssym_NGetINode(attr, objnode); struct nesssym *xattr; boolean repost; + char buf[100]; if (onode->ExtendAView) { if (onode->menulist != NULL && globalInit != NULL) *************** *** 1103,1113 **** if (ness_GetArbiter(ness) == NULL || (onode->obj=arbiterview_GetNamedCelview( ness_GetArbiter(ness), ! nesssym_NGetName(attr)+1)) == NULL) { if (debug) { printf("unpostevents could not find \"%s\" in arb at 0x%lx\n", ! nesssym_NGetName(attr)+1, ness_GetArbiter(ness)); } return; --- 1116,1128 ---- if (ness_GetArbiter(ness) == NULL || (onode->obj=arbiterview_GetNamedCelview( ness_GetArbiter(ness), ! nesssym_ToC(attr, &curNess->header.text, ! buf, sizeof(buf)))) == NULL) { if (debug) { printf("unpostevents could not find \"%s\" in arb at 0x%lx\n", ! nesssym_ToC(attr, &curNess->header.text, ! buf, sizeof(buf)), ness_GetArbiter(ness)); } return; *************** *** 1256,1261 **** --- 1271,1277 ---- boolean debug; { struct nesssym *attr; + char buf[100]; globalInit = im_GetGlobalInit(); *************** *** 1265,1271 **** if (attr->flags == flag_xobj) { if (debug) printf("Unposting events for %s\n", ! nesssym_GetName(attr)+1); attr->parent.ness = ness; /* set parent */ unpostevents(ness, attr, debug); } --- 1281,1288 ---- if (attr->flags == flag_xobj) { if (debug) printf("Unposting events for %s\n", ! nesssym_ToC(attr, &curNess->header.text, ! buf, sizeof(buf))); attr->parent.ness = ness; /* set parent */ unpostevents(ness, attr, debug); } *** atk/ness/objects/search.c Fri Dec 21 14:57:06 1990 --- atk/ness/objects/search.c.NEW Wed Feb 13 16:52:54 1991 *************** *** 1,12 **** /* ********************************************************************** *\ * Copyright IBM Corporation 1988,1989 - All Rights Reserved * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/ness/objects/RCS/search.c,v 1.23 90/12/04 14:58:37 wjh Exp $ */ /* $ACIS:$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/ness/objects/RCS/search.c,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/ness/objects/RCS/search.c,v 1.23 90/12/04 14:58:37 wjh Exp $"; #endif /* --- 1,12 ---- /* ********************************************************************** *\ * Copyright IBM Corporation 1988,1989 - All Rights Reserved * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/ness/objects/RCS/search.c,v 1.26 91/02/08 14:37:53 wjh Exp $ */ /* $ACIS:$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/ness/objects/RCS/search.c,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/ness/objects/RCS/search.c,v 1.26 91/02/08 14:37:53 wjh Exp $"; #endif /* *************** *** 18,23 **** --- 18,38 ---- */ /* * $Log: search.c,v $ + * Revision 1.26 91/02/08 14:37:53 wjh + * clearstyles now does an additional step when clearing the styles from an entire text: it deletes all style definitions which have been added and are not part of a template. + * The effect is that writefile of text that has been processed with clearstyles will not have ATK formatting. + * + * Revision 1.25 91/01/31 22:22:25 wjh + * fixed a bug in addstyles wherein if the pattern had multiple styles the innermost was applied as many times as the depth and others were not applied at all + * + * Revision 1.24 91/01/14 17:19:18 wjh + * updated for changes to styles + * This fixes the problem that 'extend' did not work. + * The problem was that short strings were treated as having styles. + * Also added line spacing, tabs, and color to MergeStyles + * and fixed AddStyles to not put on styles that are already shared + * (by pointer) between target and source. + * * Revision 1.23 90/12/04 14:58:37 wjh * corrected search() to check for empty pattern argument * *************** *** 688,693 **** --- 703,711 ---- ((struct environment *)(env)->header.nestedmark.parent) + /* AddOneStyle(text, pos, len, style) + Adds to text at pos for length len teh given style. + */ static void AddOneStyle(text, pos, len, style) struct text *text; *************** *** 708,713 **** --- 726,735 ---- text_AddStyle(text, pos, len, newstyle); } + /* AddStyles(text, pos, len, env) + Adds to text at pos for length len all the styles had by env, + except not those from environments that are already shared by both. + */ static void AddStyles(text, pos, len, env) struct text *text; *************** *** 714,725 **** long pos, len; struct environment *env; { ! struct environment *dad = environment_GetParent(env); ! if (dad != NULL) ! AddStyles(text, pos, len, dad); ! if (env->type == environment_Style) ! AddOneStyle(text, pos, len, env->data.style); ! text_NotifyObservers(text, 0); } --- 736,756 ---- long pos, len; struct environment *env; { ! struct environment *subjenv, *tenv; ! boolean notify = FALSE; ! ! subjenv = environment_GetEnclosing(text->rootEnvironment, pos); ! if (len > 0) ! subjenv = environment_GetCommonParent(subjenv, ! environment_GetEnclosing(text->rootEnvironment, pos+len-1)); ! for (tenv = env; tenv != NULL; tenv = environment_GetParent(tenv)) { ! if (tenv->type != environment_Style) continue; ! /* if tenv is (identically) subjenv or an ancestor, break */ ! if (environment_Distance(subjenv, tenv) >= 0) break; ! AddOneStyle(text, pos, len, tenv->data.style); ! notify = TRUE; ! } ! if (notify) text_NotifyObservers(text, 0); } *************** *** 813,821 **** one style to another. As it is, we process only some of the attributes. The style attributes ! LeftMargin, RightMargin, Indent, Script, andFontSize are treated incrementally. The attributes ! Justification, Flags, FontFamily, FontFace are treated as new values. */ static struct style * --- 844,853 ---- one style to another. As it is, we process only some of the attributes. The style attributes ! LeftMargin, RightMargin, Indent, Script, and FontSize are treated incrementally. The attributes ! Justification, Flags, FontFamily, FontFace, ! Line Spacing, Paragraph Spacing, tabs, and color are treated as new values. */ static struct style * *************** *** 831,836 **** --- 863,874 ---- enum style_Justification Justification; long mask; + enum style_Unit Unit; + enum style_SpacingValue Basis; + char *color; + struct tabentry **tabchanges; + long n; + penv = environment_GetParent(env); if (penv != NULL) /* recur to do parent styles */ *************** *** 892,900 **** --- 930,972 ---- style->OutFontFaces = (mask & patstyle->OutFontFaces) | ((~mask) & style->OutFontFaces); + /* Spacing (of lines) */ + style_GetNewInterlineSpacing(style, &Basis, &Operand, &Unit); + if (Basis == style_ConstantSpacing && Unit == style_Points) + style_SetNewInterlineSpacing(style, Basis, Operand, Unit); + /* Spread (between paragraphs) */ + style_GetNewInterparagraphSpacing(style, &Basis, &Operand, &Unit); + if (Basis == style_ConstantSpacing && Unit == style_Points) + style_SetNewInterparagraphSpacing(style, Basis, Operand, Unit); + /* Tabs */ + style_GetTabChangeList(patstyle, &n, &tabchanges); + if (n != 0) { + style_ClearTabChanges(style); + while (n-- > 0) + style_AddTabChange(style, + tabchanges[n]->TabOpcode, + tabchanges[n]->Location, + tabchanges[n]->LocationUnit); + } + if (tabchanges) + free(tabchanges); + /* Color */ + color = style_GetAttribute(patstyle, "color"); + if (color != NULL) + style_AddAttribute(style, "color", color); return style; } + static boolean + DeleteNonTemplateStyles(style, ss) + struct style *style; + struct stylesheet *ss; + { + if ( ! style->template) + /* not in template, delete it */ + stylesheet_Delete(ss, style); + return FALSE; + } /* SearchOp(op, NSP, opiar) First five ops perform searches, depending on op. *************** *** 1479,1491 **** else /* no enclosing style */ nessmark_Start(subject); break; /* {"clearstyles", "Fu", {Tstr, Tstr, Tvoid}, ness_codeOrange} */ case 'u': - /* remove all styles that include exactly the subject */ text = (struct text *)nessmark_GetText(subject); ! if (class_IsType(text, textClass)) { ! #if 0 /* debugging code */ for (pos = 0; pos <= text_GetLength(text); pos ++) { --- 1551,1562 ---- else /* no enclosing style */ nessmark_Start(subject); break; + /* {"clearstyles", "Fu", {Tstr, Tstr, Tvoid}, ness_codeOrange} */ case 'u': /* remove all styles that include exactly the subject */ text = (struct text *)nessmark_GetText(subject); ! if ( ! class_IsType(text, textClass)) break; #if 0 /* debugging code */ for (pos = 0; pos <= text_GetLength(text); pos ++) { *************** *** 1504,1519 **** printf("\n"); } #else ! pos = nessmark_GetPos(subject); ! len = nessmark_GetLength(subject); ! if (len == 0) break; ! if (environment_Remove(text->rootEnvironment, ! pos, len, environment_Style, TRUE)) ! text_SetModified(text); ! text_RegionModified(text, pos, len); ! text_NotifyObservers(text, 0); #endif - } break; /* {"nextstylesegment", "Fv", {Tstr, Tstr, Tvoid}, ness_codeOrange} */ --- 1575,1595 ---- printf("\n"); } #else ! pos = nessmark_GetPos(subject); ! len = nessmark_GetLength(subject); ! if (len == 0) break; ! if (environment_Remove(text->rootEnvironment, ! pos, len, environment_Style, TRUE)) ! text_SetModified(text); ! text_RegionModified(text, pos, len); ! text_NotifyObservers(text, 0); ! ! if (pos == 0 && len >= text_GetLength(text)) ! /* We have removed all style invocations from entire document. ! Remove also all non-template style definitions. */ ! stylesheet_EnumerateStyles(text->styleSheet, ! (procedure) DeleteNonTemplateStyles, text->styleSheet); #endif break; /* {"nextstylesegment", "Fv", {Tstr, Tstr, Tvoid}, ness_codeOrange} */ *** atk/ness/objects/nesscomp.c Fri Dec 21 14:57:11 1990 --- atk/ness/objects/nesscomp.c.NEW Wed Feb 13 16:52:58 1991 *************** *** 3,14 **** /* ********************************************************************** *\ * Copyright IBM Corporation 1988,1989 - All Rights Reserved * \* ********************************************************************** */ ! /* $Header: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/ness/objects/RCS/nesscomp.c,v 1.1 90/10/12 21:06:32 wjh Exp $ */ /* $ACIS:$ */ ! /* $Source: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/ness/objects/RCS/nesscomp.c,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! char *ness_gra_rcsid = "$Header: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/ness/objects/RCS/nesscomp.c,v 1.1 90/10/12 21:06:32 wjh Exp $"; #endif /* !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) */ --- 3,14 ---- /* ********************************************************************** *\ * Copyright IBM Corporation 1988,1989 - All Rights Reserved * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/ness/objects/RCS/nesscomp.c,v 1.2 91/02/08 14:33:17 wjh Exp $ */ /* $ACIS:$ */ ! /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/ness/objects/RCS/nesscomp.c,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! char *ness_gra_rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/ness/objects/RCS/nesscomp.c,v 1.2 91/02/08 14:33:17 wjh Exp $"; #endif /* !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) */ *************** *** 341,352 **** * Copyright IBM Corporation 1990 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/ness/objects/RCS/nesscomp.c,v 1.1 90/10/12 21:06:32 wjh Exp $ */ /* $ACIS:$ */ ! /* $Source: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/ness/objects/RCS/nesscomp.c,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! char *yaccpar_rcsid = "$Header: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/ness/objects/RCS/nesscomp.c,v 1.1 90/10/12 21:06:32 wjh Exp $"; #endif /* --- 341,352 ---- * Copyright IBM Corporation 1990 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/ness/objects/RCS/nesscomp.c,v 1.2 91/02/08 14:33:17 wjh Exp $ */ /* $ACIS:$ */ ! /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/ness/objects/RCS/nesscomp.c,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! char *yaccpar_rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/ness/objects/RCS/nesscomp.c,v 1.2 91/02/08 14:33:17 wjh Exp $"; #endif /* *************** *** 721,790 **** genSaveStmtStart(-1); predpush(predcond, lex_RecentPosition(-1, &len), 'E'); yyval.s = neventStartExtend(curNess->CurrentObject, yypvt[-0].s); - /* link this extend so codeloc entries from ON xxx - are attached to the Ness */ - genLinkGlobal(yyval.s); curNess->saveAttrDest = curNess->AttrDest; curNess->AttrDest = &(nesssym_NGetINode(yyval.s, objnode)->attrs); curNess->CurrentObject = yyval.s; curNess->CurrentObject->parent.ness = curNess; } break; case 37: ! # line 298 "nesscomp.z" { genCheckEndtag(yypvt[-0].s, EXTEND); neventFinishExtend(yypvt[-3].s); predpop(); curNess->AttrDest = curNess->saveAttrDest; curNess->CurrentObject = NULL; } break; case 38: ! # line 306 "nesscomp.z" { long len; genSaveStmtStart(-2); predpush(predcond, lex_RecentPosition(-1, &len), 'V'); yyval.s = neventStartEvent(curNess->CurrentObject, yypvt[-1].s, yypvt[-0].s); } break; case 39: ! # line 313 "nesscomp.z" { genCheckEndtag(yypvt[-0].s, ON); yypvt[-3].s = neventFinishEvent(yypvt[-3].s, yypvt[-2].s, yypvt[-0].s); predpop(); yypvt[-3].s->parent.nesssym = curNess->CurrentObject; } break; case 40: ! # line 321 "nesscomp.z" { yyval.s = NULL; } break; case 42: ! # line 330 "nesscomp.z" { yyval.s = uniqueinscope(yypvt[-0].s, flag_var | flag_parmvar, 0); yyval.s->type = yypvt[-1].i; } break; case 43: ! # line 337 "nesscomp.z" { yyval.s = uniqueinscope(yypvt[-0].s, flag_var | flag_parmvar, 0); yyval.s->type = yypvt[-1].i; yyval.s->next = yypvt[-3].s; } break; case 44: ! # line 346 "nesscomp.z" { genCheckEndtag(yypvt[-0].s, FUNCTION); yyval.s = yypvt[-2].s; } break; case 45: ! # line 356 "nesscomp.z" { yyval.s = NULL; } break; case 46: ! # line 359 "nesscomp.z" { genSaveStmtStart(0); yyval.s = yypvt[-0].s; } break; case 47: ! # line 362 "nesscomp.z" { yyval.s = appendlists(yypvt[-1].s, yypvt[-0].s); } break; case 48: ! # line 368 "nesscomp.z" { yyval.s = NULL; } break; case 49: ! # line 372 "nesscomp.z" { yyval.varnode = varIsStorable(yypvt[-1].varnode); predpush(FALSE, yyval.varnode->loc+yyval.varnode->len, 'X'); } break; case 50: ! # line 375 "nesscomp.z" { predvalue(&yypvt[-0].exprnode->type); predpop(); demandnodetype(yypvt[-0].exprnode, yypvt[-1].varnode->sym->type); exprnode_Destroy(yypvt[-0].exprnode); genvarstore(yypvt[-1].varnode); yyval.s = NULL; } break; case 51: ! # line 382 "nesscomp.z" { yyval.varnode = varIsStorable(yypvt[-1].varnode); demandsymboltype(yypvt[-1].varnode->sym, Tstr); predpush(predcond, yypvt[-1].varnode->loc, 'X'); /* save loc for runtime error */ --- 721,787 ---- genSaveStmtStart(-1); predpush(predcond, lex_RecentPosition(-1, &len), 'E'); yyval.s = neventStartExtend(curNess->CurrentObject, yypvt[-0].s); curNess->saveAttrDest = curNess->AttrDest; curNess->AttrDest = &(nesssym_NGetINode(yyval.s, objnode)->attrs); curNess->CurrentObject = yyval.s; curNess->CurrentObject->parent.ness = curNess; } break; case 37: ! # line 295 "nesscomp.z" { genCheckEndtag(yypvt[-0].s, EXTEND); neventFinishExtend(yypvt[-3].s); predpop(); curNess->AttrDest = curNess->saveAttrDest; curNess->CurrentObject = NULL; } break; case 38: ! # line 303 "nesscomp.z" { long len; genSaveStmtStart(-2); predpush(predcond, lex_RecentPosition(-1, &len), 'V'); yyval.s = neventStartEvent(curNess->CurrentObject, yypvt[-1].s, yypvt[-0].s); } break; case 39: ! # line 310 "nesscomp.z" { genCheckEndtag(yypvt[-0].s, ON); yypvt[-3].s = neventFinishEvent(yypvt[-3].s, yypvt[-2].s, yypvt[-0].s); predpop(); yypvt[-3].s->parent.nesssym = curNess->CurrentObject; } break; case 40: ! # line 318 "nesscomp.z" { yyval.s = NULL; } break; case 42: ! # line 327 "nesscomp.z" { yyval.s = uniqueinscope(yypvt[-0].s, flag_var | flag_parmvar, 0); yyval.s->type = yypvt[-1].i; } break; case 43: ! # line 334 "nesscomp.z" { yyval.s = uniqueinscope(yypvt[-0].s, flag_var | flag_parmvar, 0); yyval.s->type = yypvt[-1].i; yyval.s->next = yypvt[-3].s; } break; case 44: ! # line 343 "nesscomp.z" { genCheckEndtag(yypvt[-0].s, FUNCTION); yyval.s = yypvt[-2].s; } break; case 45: ! # line 353 "nesscomp.z" { yyval.s = NULL; } break; case 46: ! # line 356 "nesscomp.z" { genSaveStmtStart(0); yyval.s = yypvt[-0].s; } break; case 47: ! # line 359 "nesscomp.z" { yyval.s = appendlists(yypvt[-1].s, yypvt[-0].s); } break; case 48: ! # line 365 "nesscomp.z" { yyval.s = NULL; } break; case 49: ! # line 369 "nesscomp.z" { yyval.varnode = varIsStorable(yypvt[-1].varnode); predpush(FALSE, yyval.varnode->loc+yyval.varnode->len, 'X'); } break; case 50: ! # line 372 "nesscomp.z" { predvalue(&yypvt[-0].exprnode->type); predpop(); demandnodetype(yypvt[-0].exprnode, yypvt[-1].varnode->sym->type); exprnode_Destroy(yypvt[-0].exprnode); genvarstore(yypvt[-1].varnode); yyval.s = NULL; } break; case 51: ! # line 379 "nesscomp.z" { yyval.varnode = varIsStorable(yypvt[-1].varnode); demandsymboltype(yypvt[-1].varnode->sym, Tstr); predpush(predcond, yypvt[-1].varnode->loc, 'X'); /* save loc for runtime error */ *************** *** 791,797 **** genvarref(yypvt[-1].varnode->sym); predpop(); } break; case 52: ! # line 388 "nesscomp.z" { demandnodetype(yypvt[-0].exprnode, Tstr); if (curNess->accesslevel >= ness_codeYellow) genop('A'); /* APPEND */ --- 788,794 ---- genvarref(yypvt[-1].varnode->sym); predpop(); } break; case 52: ! # line 385 "nesscomp.z" { demandnodetype(yypvt[-0].exprnode, Tstr); if (curNess->accesslevel >= ness_codeYellow) genop('A'); /* APPEND */ *************** *** 806,816 **** genvarstore(yypvt[-1].varnode); yyval.s = NULL; } break; case 53: ! # line 404 "nesscomp.z" { yyval.s = yypvt[-1].s; yyval.s->next = yypvt[-0].s; ProcessIdList(yyval.s->type, yyval.s, flag_var | flag_localvar); } break; case 54: ! # line 409 "nesscomp.z" { yyval.varnode = genvarnode(yypvt[-1].s); ProcessIdList(yypvt[-1].s->type, yyval.varnode->sym, flag_var | flag_localvar); --- 803,813 ---- genvarstore(yypvt[-1].varnode); yyval.s = NULL; } break; case 53: ! # line 401 "nesscomp.z" { yyval.s = yypvt[-1].s; yyval.s->next = yypvt[-0].s; ProcessIdList(yyval.s->type, yyval.s, flag_var | flag_localvar); } break; case 54: ! # line 406 "nesscomp.z" { yyval.varnode = genvarnode(yypvt[-1].s); ProcessIdList(yypvt[-1].s->type, yyval.varnode->sym, flag_var | flag_localvar); *************** *** 817,823 **** varIsStorable(yyval.varnode); predpush(FALSE, yyval.varnode->loc+yyval.varnode->len, 'X'); } break; case 55: ! # line 415 "nesscomp.z" { predvalue(&yypvt[-0].exprnode->type); predpop(); demandnodetype(yypvt[-0].exprnode, yypvt[-1].varnode->sym->type); exprnode_Destroy(yypvt[-0].exprnode); --- 814,820 ---- varIsStorable(yyval.varnode); predpush(FALSE, yyval.varnode->loc+yyval.varnode->len, 'X'); } break; case 55: ! # line 412 "nesscomp.z" { predvalue(&yypvt[-0].exprnode->type); predpop(); demandnodetype(yypvt[-0].exprnode, yypvt[-1].varnode->sym->type); exprnode_Destroy(yypvt[-0].exprnode); *************** *** 824,904 **** yyval.s = yypvt[-1].varnode->sym; /* access before destroy varnode */ genvarstore(yypvt[-1].varnode); } break; case 56: ! # line 422 "nesscomp.z" { if (yypvt[-0].exprnode->type != Tvoid) genop('y'); /* POP - discardvalue */ exprnode_Destroy(yypvt[-0].exprnode); yyval.s = NULL; } break; case 57: ! # line 428 "nesscomp.z" { long loc, len; loc = lex_RecentPosition(0, &len); predpush(FALSE, loc + len, 'X'); } break; case 58: ! # line 431 "nesscomp.z" { predvalue(&(yypvt[-0].exprnode->type)); predpop(); genreturn(TRUE); exprnode_Destroy(yypvt[-0].exprnode); yyval.s = NULL; } break; case 59: ! # line 438 "nesscomp.z" { genreturn(FALSE); yyval.s = NULL; } break; case 60: ! # line 442 "nesscomp.z" { genreturn(FALSE); yyval.s = NULL; } break; case 61: ! # line 447 "nesscomp.z" { genreturn(FALSE); yyval.s = NULL; } break; case 62: ! # line 450 "nesscomp.z" { long loc, len; loc = lex_RecentPosition(0, &len); yyval.predstatenode = predpush(FALSE, loc + len, 'W'); } break; case 63: ! # line 453 "nesscomp.z" { predbranch(yypvt[-0].exprnode); predfixdropthru(); exprnode_Destroy(yypvt[-0].exprnode); yyval.predstatenode = yypvt[-1].predstatenode; } break; case 64: ! # line 460 "nesscomp.z" { genCheckEndtag(yypvt[-0].s, WHILE); genbranch('g', yypvt[-4].predstatenode->objloc); predfixtarget(); predpop(); yyval.s = yypvt[-2].s; } break; case 65: ! # line 467 "nesscomp.z" { predexit('W'); yyval.s = NULL; } break; case 66: ! # line 470 "nesscomp.z" { long loc, len; loc = lex_RecentPosition(0, &len); predpush(FALSE, loc + len, 'I'); } break; case 67: ! # line 474 "nesscomp.z" { predbranch(yypvt[-1].exprnode); predfixdropthru(); exprnode_Destroy(yypvt[-1].exprnode); } break; case 68: ! # line 480 "nesscomp.z" { genCheckEndtag(yypvt[-0].s, IF); predpop(); yyval.s = appendlists(yypvt[-3].s, yypvt[-2].s); } break; case 69: ! # line 488 "nesscomp.z" { yyval.s = uniqueinscope(yypvt[-0].s, flag_var, 0); yyval.s->type = yypvt[-1].i; } break; case 70: ! # line 495 "nesscomp.z" { yyval.s =NULL; } break; case 71: ! # line 499 "nesscomp.z" { yyval.s = appendlists(yypvt[-2].s, uniqueinscope(yypvt[-0].s, flag_var, 0)); } break; case 72: ! # line 506 "nesscomp.z" { predfixtarget(); yyval.s = NULL; } break; case 73: ! # line 509 "nesscomp.z" { yyval.i = genbranch('g', 0); predfixtarget(); } break; case 74: ! # line 511 "nesscomp.z" { fixbranch(yypvt[-1].i); yyval.s = yypvt[-0].s; } break; case 75: ! # line 514 "nesscomp.z" { long loc, len; int fixloc = genbranch('g', 0); predfixtarget(); loc = lex_RecentPosition(0, &len); --- 821,901 ---- yyval.s = yypvt[-1].varnode->sym; /* access before destroy varnode */ genvarstore(yypvt[-1].varnode); } break; case 56: ! # line 419 "nesscomp.z" { if (yypvt[-0].exprnode->type != Tvoid) genop('y'); /* POP - discardvalue */ exprnode_Destroy(yypvt[-0].exprnode); yyval.s = NULL; } break; case 57: ! # line 425 "nesscomp.z" { long loc, len; loc = lex_RecentPosition(0, &len); predpush(FALSE, loc + len, 'X'); } break; case 58: ! # line 428 "nesscomp.z" { predvalue(&(yypvt[-0].exprnode->type)); predpop(); genreturn(TRUE); exprnode_Destroy(yypvt[-0].exprnode); yyval.s = NULL; } break; case 59: ! # line 435 "nesscomp.z" { genreturn(FALSE); yyval.s = NULL; } break; case 60: ! # line 439 "nesscomp.z" { genreturn(FALSE); yyval.s = NULL; } break; case 61: ! # line 444 "nesscomp.z" { genreturn(FALSE); yyval.s = NULL; } break; case 62: ! # line 447 "nesscomp.z" { long loc, len; loc = lex_RecentPosition(0, &len); yyval.predstatenode = predpush(FALSE, loc + len, 'W'); } break; case 63: ! # line 450 "nesscomp.z" { predbranch(yypvt[-0].exprnode); predfixdropthru(); exprnode_Destroy(yypvt[-0].exprnode); yyval.predstatenode = yypvt[-1].predstatenode; } break; case 64: ! # line 457 "nesscomp.z" { genCheckEndtag(yypvt[-0].s, WHILE); genbranch('g', yypvt[-4].predstatenode->objloc); predfixtarget(); predpop(); yyval.s = yypvt[-2].s; } break; case 65: ! # line 464 "nesscomp.z" { predexit('W'); yyval.s = NULL; } break; case 66: ! # line 467 "nesscomp.z" { long loc, len; loc = lex_RecentPosition(0, &len); predpush(FALSE, loc + len, 'I'); } break; case 67: ! # line 471 "nesscomp.z" { predbranch(yypvt[-1].exprnode); predfixdropthru(); exprnode_Destroy(yypvt[-1].exprnode); } break; case 68: ! # line 477 "nesscomp.z" { genCheckEndtag(yypvt[-0].s, IF); predpop(); yyval.s = appendlists(yypvt[-3].s, yypvt[-2].s); } break; case 69: ! # line 485 "nesscomp.z" { yyval.s = uniqueinscope(yypvt[-0].s, flag_var, 0); yyval.s->type = yypvt[-1].i; } break; case 70: ! # line 492 "nesscomp.z" { yyval.s =NULL; } break; case 71: ! # line 496 "nesscomp.z" { yyval.s = appendlists(yypvt[-2].s, uniqueinscope(yypvt[-0].s, flag_var, 0)); } break; case 72: ! # line 503 "nesscomp.z" { predfixtarget(); yyval.s = NULL; } break; case 73: ! # line 506 "nesscomp.z" { yyval.i = genbranch('g', 0); predfixtarget(); } break; case 74: ! # line 508 "nesscomp.z" { fixbranch(yypvt[-1].i); yyval.s = yypvt[-0].s; } break; case 75: ! # line 511 "nesscomp.z" { long loc, len; int fixloc = genbranch('g', 0); predfixtarget(); loc = lex_RecentPosition(0, &len); *************** *** 905,947 **** yyval.predstatenode = predpush(FALSE, loc + len, 'I'); yyval.predstatenode->fixuploc = fixloc; } break; case 76: ! # line 521 "nesscomp.z" { predbranch(yypvt[-1].exprnode); predfixdropthru(); exprnode_Destroy(yypvt[-1].exprnode); } break; case 77: ! # line 525 "nesscomp.z" { fixbranch(yypvt[-5].predstatenode->fixuploc); predpop(); yyval.s = appendlists(yypvt[-1].s, yypvt[-0].s); } break; case 78: ! # line 533 "nesscomp.z" { yyval.i = predEQ; } break; case 79: ! # line 535 "nesscomp.z" { yyval.i = predLT; } break; case 80: ! # line 537 "nesscomp.z" { yyval.i = predGT; } break; case 81: ! # line 539 "nesscomp.z" { yyval.i = predNE; } break; case 82: ! # line 541 "nesscomp.z" { yyval.i = predLE; } break; case 83: ! # line 543 "nesscomp.z" { yyval.i = predGE; } break; case 85: ! # line 559 "nesscomp.z" { yyval.i = lex_RecentPosition(0, 0); predcond = ! predcond; } break; case 86: ! # line 562 "nesscomp.z" { predbranch(yypvt[-0].exprnode); predcond = ! predcond; yyval.exprnode = yypvt[-0].exprnode; yyval.exprnode->type = Tbra; yyval.exprnode->len += yyval.exprnode->loc - yypvt[-1].i; yyval.exprnode->loc = yypvt[-1].i; } break; case 87: ! # line 569 "nesscomp.z" { long loc, len; predbranch(yypvt[-1].exprnode); preddropthru(predOR); if (predcond == FALSE) predfixtarget(); --- 902,944 ---- yyval.predstatenode = predpush(FALSE, loc + len, 'I'); yyval.predstatenode->fixuploc = fixloc; } break; case 76: ! # line 518 "nesscomp.z" { predbranch(yypvt[-1].exprnode); predfixdropthru(); exprnode_Destroy(yypvt[-1].exprnode); } break; case 77: ! # line 522 "nesscomp.z" { fixbranch(yypvt[-5].predstatenode->fixuploc); predpop(); yyval.s = appendlists(yypvt[-1].s, yypvt[-0].s); } break; case 78: ! # line 530 "nesscomp.z" { yyval.i = predEQ; } break; case 79: ! # line 532 "nesscomp.z" { yyval.i = predLT; } break; case 80: ! # line 534 "nesscomp.z" { yyval.i = predGT; } break; case 81: ! # line 536 "nesscomp.z" { yyval.i = predNE; } break; case 82: ! # line 538 "nesscomp.z" { yyval.i = predLE; } break; case 83: ! # line 540 "nesscomp.z" { yyval.i = predGE; } break; case 85: ! # line 556 "nesscomp.z" { yyval.i = lex_RecentPosition(0, 0); predcond = ! predcond; } break; case 86: ! # line 559 "nesscomp.z" { predbranch(yypvt[-0].exprnode); predcond = ! predcond; yyval.exprnode = yypvt[-0].exprnode; yyval.exprnode->type = Tbra; yyval.exprnode->len += yyval.exprnode->loc - yypvt[-1].i; yyval.exprnode->loc = yypvt[-1].i; } break; case 87: ! # line 566 "nesscomp.z" { long loc, len; predbranch(yypvt[-1].exprnode); preddropthru(predOR); if (predcond == FALSE) predfixtarget(); *************** *** 950,990 **** loc = lex_RecentPosition (0, &len); predpush(predcond, loc + len, 'X'); } break; case 88: ! # line 577 "nesscomp.z" { predbranch(yypvt[-0].exprnode); predfixdropthru(); predpop(); yyval.exprnode = exprnode_Combine(yypvt[-1].exprnode, yypvt[-0].exprnode, Tbra); } break; case 89: ! # line 583 "nesscomp.z" { predbranch(yypvt[-1].exprnode); preddropthru(predAND); if (predcond == TRUE) predfixtarget(); yyval.exprnode = yypvt[-1].exprnode; } break; case 90: ! # line 587 "nesscomp.z" { predbranch(yypvt[-0].exprnode); yyval.exprnode = exprnode_Combine(yypvt[-1].exprnode, yypvt[-0].exprnode, Tbra); } break; case 92: ! # line 599 "nesscomp.z" { gencomp(yypvt[-2].exprnode, yypvt[-0].exprnode); predtarget (yypvt[-1].i); yyval.exprnode = exprnode_Combine(yypvt[-2].exprnode, yypvt[-0].exprnode, Tbra); } break; case 94: ! # line 609 "nesscomp.z" { yyval.exprnode = genarith('+', yypvt[-2].exprnode, yypvt[-0].exprnode); } break; case 95: ! # line 612 "nesscomp.z" { yyval.exprnode = genarith('-', yypvt[-2].exprnode, yypvt[-0].exprnode); } break; case 97: ! # line 620 "nesscomp.z" { yyval.exprnode = genarith('*', yypvt[-2].exprnode, yypvt[-0].exprnode); } break; case 98: ! # line 623 "nesscomp.z" { yyval.exprnode = genarith('/', yypvt[-2].exprnode, yypvt[-0].exprnode); } break; case 99: ! # line 626 "nesscomp.z" { yyval.exprnode = genarith('%', yypvt[-2].exprnode, yypvt[-0].exprnode); } break; case 100: ! # line 632 "nesscomp.z" { yyval.exprnode = exprnode_Create(yypvt[-0].varnode->sym->type, NULL, FALSE, yypvt[-0].varnode->loc, yypvt[-0].varnode->len); predpush(predcond, yypvt[-0].varnode->loc, 'X'); /* save loc for runtime error */ --- 947,987 ---- loc = lex_RecentPosition (0, &len); predpush(predcond, loc + len, 'X'); } break; case 88: ! # line 574 "nesscomp.z" { predbranch(yypvt[-0].exprnode); predfixdropthru(); predpop(); yyval.exprnode = exprnode_Combine(yypvt[-1].exprnode, yypvt[-0].exprnode, Tbra); } break; case 89: ! # line 580 "nesscomp.z" { predbranch(yypvt[-1].exprnode); preddropthru(predAND); if (predcond == TRUE) predfixtarget(); yyval.exprnode = yypvt[-1].exprnode; } break; case 90: ! # line 584 "nesscomp.z" { predbranch(yypvt[-0].exprnode); yyval.exprnode = exprnode_Combine(yypvt[-1].exprnode, yypvt[-0].exprnode, Tbra); } break; case 92: ! # line 596 "nesscomp.z" { gencomp(yypvt[-2].exprnode, yypvt[-0].exprnode); predtarget (yypvt[-1].i); yyval.exprnode = exprnode_Combine(yypvt[-2].exprnode, yypvt[-0].exprnode, Tbra); } break; case 94: ! # line 606 "nesscomp.z" { yyval.exprnode = genarith('+', yypvt[-2].exprnode, yypvt[-0].exprnode); } break; case 95: ! # line 609 "nesscomp.z" { yyval.exprnode = genarith('-', yypvt[-2].exprnode, yypvt[-0].exprnode); } break; case 97: ! # line 617 "nesscomp.z" { yyval.exprnode = genarith('*', yypvt[-2].exprnode, yypvt[-0].exprnode); } break; case 98: ! # line 620 "nesscomp.z" { yyval.exprnode = genarith('/', yypvt[-2].exprnode, yypvt[-0].exprnode); } break; case 99: ! # line 623 "nesscomp.z" { yyval.exprnode = genarith('%', yypvt[-2].exprnode, yypvt[-0].exprnode); } break; case 100: ! # line 629 "nesscomp.z" { yyval.exprnode = exprnode_Create(yypvt[-0].varnode->sym->type, NULL, FALSE, yypvt[-0].varnode->loc, yypvt[-0].varnode->len); predpush(predcond, yypvt[-0].varnode->loc, 'X'); /* save loc for runtime error */ *************** *** 995,1017 **** predpop(); varnode_Destroy(yypvt[-0].varnode); } break; case 101: ! # line 643 "nesscomp.z" { yyval.i = lex_RecentPosition(0, 0); } break; case 102: ! # line 645 "nesscomp.z" { if (yypvt[-0].exprnode->type == Tdbl) {genop('H'); genop('_');} else {demandnodetype(yypvt[-0].exprnode, Tlong); genop('_');} yyval.exprnode = yypvt[-0].exprnode; yyval.exprnode->len += yyval.exprnode->loc - yypvt[-1].i; yyval.exprnode->loc = yypvt[-1].i; } break; case 103: ! # line 651 "nesscomp.z" { yyval.i = lex_RecentPosition(0, 0); } break; case 104: ! # line 653 "nesscomp.z" { yyval.exprnode = yypvt[-0].exprnode; yyval.exprnode->len += yyval.exprnode->loc - yypvt[-1].i; yyval.exprnode->loc = yypvt[-1].i; } break; case 105: ! # line 657 "nesscomp.z" { if (yypvt[-0].exprnode->type == Tvoid) { genop('0'); yypvt[-0].exprnode->type = Tlong; --- 992,1014 ---- predpop(); varnode_Destroy(yypvt[-0].varnode); } break; case 101: ! # line 640 "nesscomp.z" { yyval.i = lex_RecentPosition(0, 0); } break; case 102: ! # line 642 "nesscomp.z" { if (yypvt[-0].exprnode->type == Tdbl) {genop('H'); genop('_');} else {demandnodetype(yypvt[-0].exprnode, Tlong); genop('_');} yyval.exprnode = yypvt[-0].exprnode; yyval.exprnode->len += yyval.exprnode->loc - yypvt[-1].i; yyval.exprnode->loc = yypvt[-1].i; } break; case 103: ! # line 648 "nesscomp.z" { yyval.i = lex_RecentPosition(0, 0); } break; case 104: ! # line 650 "nesscomp.z" { yyval.exprnode = yypvt[-0].exprnode; yyval.exprnode->len += yyval.exprnode->loc - yypvt[-1].i; yyval.exprnode->loc = yypvt[-1].i; } break; case 105: ! # line 654 "nesscomp.z" { if (yypvt[-0].exprnode->type == Tvoid) { genop('0'); yypvt[-0].exprnode->type = Tlong; *************** *** 1018,1042 **** } yyval.exprnode = yypvt[-0].exprnode; } break; case 106: ! # line 664 "nesscomp.z" { long loc, len; loc = lex_RecentPosition(0, &len); yyval.exprnode = exprnode_Create(Tbool, NULL, FALSE, loc, len); genop('1'); } break; case 107: ! # line 670 "nesscomp.z" { long loc, len; loc = lex_RecentPosition(0, &len); yyval.exprnode = exprnode_Create(Tbool, NULL, FALSE, loc, len); genop('9'); } break; case 108: ! # line 676 "nesscomp.z" { long loc, len; loc = lex_RecentPosition(0, &len); yyval.exprnode = exprnode_Create(Tptr, NULL, FALSE, loc, len); genop('^'); } break; case 109: ! # line 683 "nesscomp.z" { demandnodetype(yypvt[-1].exprnode, Tstr); if ( ! yypvt[-1].exprnode->IsCat) { genop('q'); /* NEWBASE */ --- 1015,1039 ---- } yyval.exprnode = yypvt[-0].exprnode; } break; case 106: ! # line 661 "nesscomp.z" { long loc, len; loc = lex_RecentPosition(0, &len); yyval.exprnode = exprnode_Create(Tbool, NULL, FALSE, loc, len); genop('1'); } break; case 107: ! # line 667 "nesscomp.z" { long loc, len; loc = lex_RecentPosition(0, &len); yyval.exprnode = exprnode_Create(Tbool, NULL, FALSE, loc, len); genop('9'); } break; case 108: ! # line 673 "nesscomp.z" { long loc, len; loc = lex_RecentPosition(0, &len); yyval.exprnode = exprnode_Create(Tptr, NULL, FALSE, loc, len); genop('^'); } break; case 109: ! # line 680 "nesscomp.z" { demandnodetype(yypvt[-1].exprnode, Tstr); if ( ! yypvt[-1].exprnode->IsCat) { genop('q'); /* NEWBASE */ *************** *** 1045,1063 **** } yyval.exprnode = yypvt[-1].exprnode; } break; case 110: ! # line 691 "nesscomp.z" { demandnodetype(yypvt[-0].exprnode, Tstr); genop('A'); /* append */ yyval.exprnode = exprnode_Combine(yypvt[-1].exprnode, yypvt[-0].exprnode, Tstr); yyval.exprnode->IsCat = TRUE; } break; case 111: ! # line 697 "nesscomp.z" { long loc, len; loc = lex_RecentPosition(0, &len); yyval.varnode = varnode_Create(loc, 0, NULL, (struct toksym *)yypvt[-0].s); predpush(predcond, loc + len, 'X'); } break; case 112: ! # line 703 "nesscomp.z" { long loc, len; parencheck(yypvt[-2].varnode, yypvt[-0].s); loc = lex_RecentPosition(0, &len); --- 1042,1060 ---- } yyval.exprnode = yypvt[-1].exprnode; } break; case 110: ! # line 688 "nesscomp.z" { demandnodetype(yypvt[-0].exprnode, Tstr); genop('A'); /* append */ yyval.exprnode = exprnode_Combine(yypvt[-1].exprnode, yypvt[-0].exprnode, Tstr); yyval.exprnode->IsCat = TRUE; } break; case 111: ! # line 694 "nesscomp.z" { long loc, len; loc = lex_RecentPosition(0, &len); yyval.varnode = varnode_Create(loc, 0, NULL, (struct toksym *)yypvt[-0].s); predpush(predcond, loc + len, 'X'); } break; case 112: ! # line 700 "nesscomp.z" { long loc, len; parencheck(yypvt[-2].varnode, yypvt[-0].s); loc = lex_RecentPosition(0, &len); *************** *** 1066,1113 **** yypvt[-1].exprnode->loc = yypvt[-2].varnode->loc; yyval.exprnode = yypvt[-1].exprnode; varnode_Destroy(yypvt[-2].varnode); } break; case 113: ! # line 716 "nesscomp.z" { yyval.varnode = yypvt[-0].varnode; } break; case 114: ! # line 719 "nesscomp.z" { yyval.varnode = yypvt[-0].varnode; } break; case 115: ! # line 726 "nesscomp.z" { yyval.varnode = varIsFunction(yypvt[-1].varnode); yyval.varnode->paren = (struct toksym *)yypvt[-0].s; predpush(predcond, yyval.varnode->loc, 'A'); } break; case 116: ! # line 731 "nesscomp.z" { parencheck(yypvt[-2].varnode , yypvt[-0].s); yyval.exprnode = callFunc(yypvt[-2].varnode, yypvt[-1].exprnode); predpop(); } break; case 117: ! # line 739 "nesscomp.z" { yyval.exprnode = yypvt[-0].exprnode; } break; case 118: ! # line 742 "nesscomp.z" { yyval.exprnode = NULL; } break; case 119: ! # line 749 "nesscomp.z" { long loc, len; loc = lex_RecentPosition(0, &len); predpush(FALSE, loc + len, 'A'); } break; case 120: ! # line 752 "nesscomp.z" { predvalue(&yypvt[-0].exprnode->type); predpop(); yyval.exprnode = yypvt[-0].exprnode; } break; case 121: ! # line 757 "nesscomp.z" { long loc, len; loc = lex_RecentPosition(0, &len); predpush(FALSE, loc + len, 'A'); } break; case 122: ! # line 760 "nesscomp.z" { predvalue(&yypvt[-0].exprnode->type); predpop(); yyval.exprnode = yypvt[-0].exprnode; yypvt[-0].exprnode->next = yypvt[-3].exprnode; } break; case 123: ! # line 769 "nesscomp.z" { yyval.varnode = genvarnode(yypvt[-0].s); } break; case 124: ! # line 775 "nesscomp.z" { /* there are 4 cases: EmptyStringToken, short string, styled short string, and long string. The EmptyStringToken has name '"'. --- 1063,1110 ---- yypvt[-1].exprnode->loc = yypvt[-2].varnode->loc; yyval.exprnode = yypvt[-1].exprnode; varnode_Destroy(yypvt[-2].varnode); } break; case 113: ! # line 713 "nesscomp.z" { yyval.varnode = yypvt[-0].varnode; } break; case 114: ! # line 716 "nesscomp.z" { yyval.varnode = yypvt[-0].varnode; } break; case 115: ! # line 723 "nesscomp.z" { yyval.varnode = varIsFunction(yypvt[-1].varnode); yyval.varnode->paren = (struct toksym *)yypvt[-0].s; predpush(predcond, yyval.varnode->loc, 'A'); } break; case 116: ! # line 728 "nesscomp.z" { parencheck(yypvt[-2].varnode , yypvt[-0].s); yyval.exprnode = callFunc(yypvt[-2].varnode, yypvt[-1].exprnode); predpop(); } break; case 117: ! # line 736 "nesscomp.z" { yyval.exprnode = yypvt[-0].exprnode; } break; case 118: ! # line 739 "nesscomp.z" { yyval.exprnode = NULL; } break; case 119: ! # line 746 "nesscomp.z" { long loc, len; loc = lex_RecentPosition(0, &len); predpush(FALSE, loc + len, 'A'); } break; case 120: ! # line 749 "nesscomp.z" { predvalue(&yypvt[-0].exprnode->type); predpop(); yyval.exprnode = yypvt[-0].exprnode; } break; case 121: ! # line 754 "nesscomp.z" { long loc, len; loc = lex_RecentPosition(0, &len); predpush(FALSE, loc + len, 'A'); } break; case 122: ! # line 757 "nesscomp.z" { predvalue(&yypvt[-0].exprnode->type); predpop(); yyval.exprnode = yypvt[-0].exprnode; yypvt[-0].exprnode->next = yypvt[-3].exprnode; } break; case 123: ! # line 766 "nesscomp.z" { yyval.varnode = genvarnode(yypvt[-0].s); } break; case 124: ! # line 772 "nesscomp.z" { /* there are 4 cases: EmptyStringToken, short string, styled short string, and long string. The EmptyStringToken has name '"'. *************** *** 1130,1136 **** yypvt[-0].s->type = Tstr; yypvt[-0].s->flags = flag_const; yyval.varnode = varnode_Create(loc, len, yypvt[-0].s, NULL); } break; case 125: ! # line 798 "nesscomp.z" { long loc, len; if ( ! (yypvt[-0].s->flags & flag_const)) { /* need to allocate new const */ --- 1127,1133 ---- yypvt[-0].s->type = Tstr; yypvt[-0].s->flags = flag_const; yyval.varnode = varnode_Create(loc, len, yypvt[-0].s, NULL); } break; case 125: ! # line 795 "nesscomp.z" { long loc, len; if ( ! (yypvt[-0].s->flags & flag_const)) { /* need to allocate new const */ *************** *** 1145,1151 **** loc = lex_RecentPosition(0, &len); yyval.varnode = varnode_Create(loc, len, yypvt[-0].s, NULL); } break; case 126: ! # line 812 "nesscomp.z" { long loc, len; if ( ! (yypvt[-0].s->flags & flag_const)) { /* need to allocate new const */ --- 1142,1148 ---- loc = lex_RecentPosition(0, &len); yyval.varnode = varnode_Create(loc, len, yypvt[-0].s, NULL); } break; case 126: ! # line 809 "nesscomp.z" { long loc, len; if ( ! (yypvt[-0].s->flags & flag_const)) { /* need to allocate new const */ *** atk/ness/nesslib/Imakefile Mon Aug 6 11:07:49 1990 --- atk/ness/nesslib/Imakefile.NEW Mon Mar 4 13:38:17 1991 *************** *** 3,9 **** * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! NFILES = ctype.n enum.n format.n funchdr.n sort.n swap.n tokens.n unscribe.n vp2scribe.n wc.n xwipe.n date.n MkdirTarget($(DESTDIR)/lib/ness) --- 3,9 ---- * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! NFILES = ctype.n date.n enum.n fileconvert.n format.n fromrtf.n funchdr.n gnutranspose.n octalimage.n sort.n swap.n tokens.n unscribe.n vp2scribe.n wc.n xwipe.n MkdirTarget($(DESTDIR)/lib/ness) *** atk/ness/nesslib/format.n Wed Nov 22 12:22:35 1989 --- atk/ness/nesslib/format.n.NEW Wed Dec 19 11:40:11 1990 *************** *** 27,33 **** triple := start(m) newline := search(m, "\n") ! while newline /= "" do if extent(newline, tab) = "" then tab := search(extent(newline, m), "\t") end if --- 27,33 ---- triple := start(m) newline := search(m, "\n") ! while extent(newline, m) /= "" do if extent(newline, tab) = "" then tab := search(extent(newline, m), "\t") end if *************** *** 35,41 **** triple := search(extent(newline, m), " ") -- three spaces end if nextnewline := search(extent(next(newline), m), "\n") - -- at this point, newline refers to a \n within m -- nextnewline, tab, and triple refer to the earlier of finish(m) -- or the next, respectively, \n, \t, or three spaces. --- 35,40 ---- *************** *** 44,50 **** replace(extent(previous(newline), newline), " ") elif previous(newline) = "\n" ! or search(" \t\n", next(newline)) /= "" or extent(tab, nextnewline) /= "" or extent(triple, nextnewline) /= "" then --- 43,51 ---- replace(extent(previous(newline), newline), " ") elif previous(newline) = "\n" ! or next(newline) = " " ! or next(newline) = "\t" ! or next(newline) = "\n" or extent(tab, nextnewline) /= "" or extent(triple, nextnewline) /= "" then *************** *** 52,58 **** else p := previous(newline) while p = " " and extent(m, p) /= "" do ! -- replace preceding space replace (p, "") p := previous(newline) end while --- 53,59 ---- else p := previous(newline) while p = " " and extent(m, p) /= "" do ! -- delete preceding spaces replace (p, "") p := previous(newline) end while *** atk/ness/nesslib/tokens.n Wed Nov 22 12:22:33 1989 --- atk/ness/nesslib/tokens.n.NEW Fri Dec 14 16:53:07 1990 *************** *** 62,68 **** text := next(span(finish(text), whitespace)) preSpace := extent(finish(orig), start(text)) ! if extent(text, next(text)) = comstart then -- skip comment text := search(start(text), comend) if text = "" then --- 62,70 ---- text := next(span(finish(text), whitespace)) preSpace := extent(finish(orig), start(text)) ! if text = "" then ! return text ! elif extent(text, next(text)) = comstart then -- skip comment text := search(start(text), comend) if text = "" then *** atk/ness/nesslib/unscribe.n Wed Nov 22 12:22:39 1989 --- atk/ness/nesslib/unscribe.n.NEW Wed Dec 19 11:40:13 1990 *************** *** 1,4 **** ! \begindata{text, 268818976} \textdsversion{12} \template{default} \define{deleteme --- 1,4 ---- ! \begindata{text,269807156} \textdsversion{12} \template{default} \define{deleteme *************** *** 12,18 **** -- ! -- uasge: nessrun -blue thisfile filetoconvert -- --- 12,18 ---- -- ! -- uasge: nessrun unscribe.n filetoconvert -- *************** *** 48,67 **** -- a longer word of which it is a prefix ! marker StyleTable; - - marker LeftBrackets; -- the list of characters to terminate the string - after @ - - marker RightBrackets; -- table associating right brackets with left brackets - - - function init() - - StyleTable := - // \bold{b} \italic{i} \leftindent{LeftIndent} \leftindent{leftindent} --- 48,57 ---- -- a longer word of which it is a prefix + ! marker StyleTable := // \bold{b} \italic{i} \leftindent{LeftIndent} \leftindent{leftindent} *************** *** 72,83 **** \example{programexample} \example{ProgramExample} \example{Programexample} IndexX IndexEntryX IndexSecondaryX ! \smaller{Smaller} \subscript{-} blankspaceX commentX newpageX 30longdescriptionX \description{description} includeX partX \chapter{\bigger{Unnumbered}} \section{\bigger{Section}} \section{\bigger{section}} \subsection{\bigger{Subsection}} \subsection{\bigger{subsection}} --- 62,75 ---- \example{programexample} \example{ProgramExample} \example{Programexample} IndexX IndexEntryX IndexSecondaryX ! \smaller{smaller} \subscript{-} blankspaceX commentX newpageX 30longdescriptionX \description{description} includeX partX \chapter{\bigger{Unnumbered}} + \chapter{Chapter chapter} + \section{\bigger{Section}} \section{\bigger{section}} \subsection{\bigger{Subsection}} \subsection{\bigger{subsection}} *************** *** 84,99 **** \bold{Paragraph} \bold{paragraph} ! \\\\; - LeftBrackets := "[(\{\\"`<@"; ! RightBrackets := "() \{\} [] <> \\"\\" `' "; ! end function; -- matchingBracket(m, brackets) -- searches for second(brackets). Ignores nested left-right pairs. --- 76,97 ---- \bold{Paragraph} \bold{paragraph} ! \flushright{Rightflush rightflush } ! ! \flushright{Flushright flushright} ! ! \\\\ ! marker LeftBrackets := "[(\{\\"`<@" -- the list of characters to terminate ! the string after @ ! marker RightBrackets := "() \{\} [] <> \\"\\" `' " -- table associating right ! brackets with left brackets + -- matchingBracket(m, brackets) -- searches for second(brackets). Ignores nested left-right pairs. *************** *** 102,164 **** function matchingBracket(m, brackets) ! marker q; ! ! marker right; ! -- printline(brackets ~ " " ~ extent(m, nextn(m,5))); ! right := second(brackets); ! q := m; while True do ! q := anyof(q, brackets); ! if q = "" or q = right then return q; end if; -- q must be left bracket: recur and repeat ! q := matchingBracket(next(q), brackets); ! if q = "" then return start(m); end if; ! q := next(q); -- skip the nested right bracket ! end while; ! end function; -- ConvertRegion(m, left, right, s) ! -- Converts the region from next(left) to start(right) ! -- to have style given by name s function ConvertRegion(m, left, right, s) ! if right = "" then return next(left); end if; ! s := search(StyleTable, s); ! if s = "" then return next(left); end if; if next(s) = "X" then ! return replace(extent(m, right), ""); else ! AddStyles(extent(next(left), start(right)), s); ! return extent(replace(extent(m, left), ""), replace(right, "")); ! end if; ! end function; --- 100,164 ---- function matchingBracket(m, brackets) ! marker q, right ! -- printline(brackets ~ " " ~ extent(m, nextn(m,5))) ! right := second(brackets) ! q := start(m) while True do ! q := anyof(start(q), brackets) ! if q = "" or q = right then return q end if -- q must be left bracket: recur and repeat ! q := matchingBracket(finish(q), brackets) ! if q = "" then return start(m) end if ! q := next(q) -- skip the nested right bracket ! end while ! end function -- ConvertRegion(m, left, right, s) ! -- Converts the region whose style delimiters are ! ! -- extent(m, left) and right ! ! -- to have style whose name is s ! -- returns the converted region function ConvertRegion(m, left, right, s) ! if right = "" then return next(left) end if ! s := search(StyleTable, s) ! if s = "" then return next(left) end if if next(s) = "X" then ! return replace(extent(m, right), "") else ! AddStyles(extent(next(left), start(right)), s) ! return extent(replace(extent(m, left), ""), replace(right, "")) ! end if ! end function *************** *** 176,203 **** function ConvertBeginEnd(m) ! marker m1; ! ! marker s; ! ! marker mend; ! m := extent (m, nextn(m, 6)); ! m1 := anyof(next(m), ",)@"); ! if m1 = "@" then return m1; end if; ! s := extent(next(m), start(m1)); -- the style name ! mend := search(m1, "@end(" ~ s ~ ")"); -- found it: do the replace ! return ConvertRegion(m, m1, mend, s); ! end function; --- 176,199 ---- function ConvertBeginEnd(m) ! marker m1, s, mend ! m := extent (m, nextn(m, 6)) ! m1 := anyof(finish(m), ",)@") ! if m1 = "@" then return m1 end if ! s := extent(next(m), start(m1)) -- the style name ! mend := search(finish(m1), "@end(" ~ s ~ ")") -- found it: do the replace ! return ConvertRegion(m, m1, mend, s) ! end function *************** *** 220,280 **** function ConvertStyles(m) ! marker m1; -- another pointer into m ! ! marker s; -- the style ! marker b; ! marker right; while True do ! m := search(m, "@"); ! if m = "" then return; end if; ! --printline(extent(m, nextn(m,5))); ! if next(m) = "@" then m := next(next(replace(m, ""))); ! elif match(next(m), "begin(") /= "" then ! m := ConvertBeginEnd(m); ! elif match(next(m), "newpage") /= "" then ! m := replace(extent(m, nextn(m,7)), ""); else ! m1 := anyof (next(m), LeftBrackets); ! if m1 = "" then return; end if; if m1 = "@" then -- the @ at m is not followed by bracket: ignore it ! m := m1; else ! s := extent(next(m), start(m1)); ! b := search(RightBrackets, m1); ! right := matchingBracket(next(m1), ! extent(b, next(b))); ! m := ConvertRegion(m, m1, right, s); ! end if; ! end if; ! end while; end function --- 216,274 ---- function ConvertStyles(m) ! marker m1 -- another pointer into m ! marker s -- the style ! marker b, right while True do ! m := search(start(m), "@") ! if m = "" then exit function end if ! --printline(extent(m, nextn(m,5))) ! if next(m) = "@" then m := next(next(replace(m, ""))) ! elif match(finish(m), "begin(") /= "" then ! m := ConvertBeginEnd(m) ! elif match(finish(m), "newpage") /= "" then ! m := replace(extent(m, nextn(m,7)), "") else ! m1 := anyof (finish(m), LeftBrackets) ! if m1 = "" then exit function end if if m1 = "@" then -- the @ at m is not followed by bracket: ignore it ! m := m1 else ! s := extent(next(m), start(m1)) ! b := search(RightBrackets, m1) ! right := matchingBracket(finish(m1), ! extent(b, next(b))) ! m := ConvertRegion(m, m1, right, s) ! end if ! end if ! end while end function *************** *** 282,339 **** function main(args) ! marker filename; ! ! marker outname; - marker text; - filename := token(args, "qwertyuiopasdfghjklzxcvbnm" ~ "QWERTYUIOPASDFGHJKLZXCVBNM" ! ~ "./0123456789"); ! outname := search(filename, "."); ! text := search(next(outname), "."); while text /= "" do ! outname := text; ! text := search(next(outname), "."); ! end while; if outname = "" or search(outname, "/") /= "" or extent(next(outname), filename) = "d" then ! outname := filename ~ ".d"; else ! outname := extent(filename, outname) ~ "d"; ! ! end if; - printline("deScribe: " ~ filename ~ " -> " ~ outname); ! text := readfile(filename) ~ ""; -- XXX remove ~"" after readfile() is fixed ! system("mv " ~ outname ~ " " ~ outname ~ ".BAK"); - ConvertStyles(text); ! addStyles(text, "\sans{sans}"); ! writefile(outname, text); end function ! \enddata{text,268818976} --- 276,327 ---- function main(args) ! marker filename, outname, text filename := token(args, "qwertyuiopasdfghjklzxcvbnm" ~ "QWERTYUIOPASDFGHJKLZXCVBNM" ! ~ "./0123456789") ! outname := search(filename, ".") ! text := search(finish(outname), ".") while text /= "" do ! outname := text ! text := search(finish(outname), ".") ! end while if outname = "" or search(outname, "/") /= "" or extent(next(outname), filename) = "d" then ! outname := filename ~ ".d" else ! outname := extent(filename, outname) ~ "d" + end if ! printline("unscribe: " ~ filename ~ " -> " ~ outname) ! text := copy(readfile(filename)) + system("mv " ~ outname ~ " " ~ outname ~ ".BAK") ! ConvertStyles(text) ! writefile(outname, text) end function ! \enddata{text,269807156} *** atk/ness/nesslib/fromrtf.n Thu May 30 20:02:17 1991 --- atk/ness/nesslib/fromrtf.n.NEW Thu May 2 13:32:47 1991 *************** *** 0 **** --- 1,2593 ---- + \begindata{text,269274372} + \textdsversion{12} + \template{default} + \define{footnote + + attr:[Flags OverBar Int Set] + attr:[FontSize PreviousFontSize Point -2]} + \define{hidden + menu:[Region~4,Hidden] + attr:[FontFamily AndySans Int 0] + attr:[FontSize PreviousFontSize Point -4]} + \define{reallyhidden + menu:[Region~4,ReallyHidden] + attr:[Flags Hidden Int Set]} + \define{min1 + menu:[Font~1,Min1] + attr:[FontSize PreviousFontSize Point -1]} + \define{plus6 + menu:[Font~1,Plus6] + attr:[FontSize PreviousFontSize Point 6]} + \define{plus18 + menu:[Font~1,Plus18] + attr:[FontSize PreviousFontSize Point 18]} + \define{sans + menu:[Font~1,Sans] + attr:[FontFamily AndySans Int 0]} + \define{symbol + menu:[Font~1,Symbol] + attr:[FontFamily Symbol Int 0]} + \define{symbola + menu:[Font~1,SymbolA] + attr:[FontFamily SymbolA Int 0]} + \define{andy + menu:[Font~1,Andy] + attr:[FontFamily Andy Int 0]} + \define{up2 + menu:[Justify~2,Up2] + attr:[Script PreviousScriptMovement Point -2]} + \define{down2 + menu:[Justify~2,Down2] + attr:[Script PreviousScriptMovement Point 2]} + \define{para6 + menu:[Justify~2,Para6] + attr:[Spacing ConstantSpacing Point 0] + attr:[Spread ConstantSpacing Point 6]} + \define{para12 + menu:[Justify~2,Para12] + attr:[Spread ConstantSpacing Point 14]} + \define{para24 + menu:[Justify~2,Para24] + attr:[Spread ConstantSpacing Point 24]} + \define{line6 + menu:[Justify~2,Line6] + attr:[Spacing ConstantSpacing Point 6]} + \define{line12 + menu:[Justify~2,Line12] + attr:[Spacing ConstantSpacing Point 12]} + \define{line24 + menu:[Justify~2,Line24] + attr:[Spacing ConstantSpacing Point 24]} + \define{leftinmin36 + menu:[Indent~5,LeftInMin36] + attr:[LeftMargin LeftMargin Cm -83231]} + \define{leftinmin12 + menu:[Indent~5,LeftInMin12] + attr:[LeftMargin LeftMargin Cm -27744]} + \define{leftindent12 + menu:[Indent~5,LeftIndent12] + attr:[LeftMargin LeftMargin Cm 27744]} + \define{leftindent36 + menu:[Indent~5,LeftIndent36] + attr:[LeftMargin LeftMargin Cm 83231]} + \define{leftindent72 + menu:[Indent~5,LeftIndent72] + attr:[LeftMargin LeftMargin Cm 166461]} + \define{rightinmin36 + menu:[Indent~5,RightInMin36] + attr:[RightMargin RightMargin Cm -83231]} + \define{rightinmin12 + menu:[Indent~5,RightInMin12] + attr:[RightMargin RightMargin Cm -27744]} + \define{rightindent12 + menu:[Indent~5,RightIndent12] + attr:[RightMargin RightMargin Cm 27744]} + \define{rightindent36 + menu:[Indent~5,RightIndent36] + attr:[RightMargin RightMargin Cm 83231]} + \define{rightindent72 + menu:[Indent~5,RightIndent72] + attr:[RightMargin RightMargin Cm 166461]} + \define{firstinmin72 + menu:[Indent~5,FirstInMin72] + attr:[Indent PreviousIndentation Cm -166461]} + \define{firstinmin36 + menu:[Indent~5,FirstInMin36] + attr:[Indent PreviousIndentation Cm -83231]} + \define{firstinmin12 + menu:[Indent~5,FirstInMin12] + attr:[Indent PreviousIndentation Cm -27744]} + \define{firstindent12 + menu:[Indent~5,FirstIndent12] + attr:[Indent PreviousIndentation Cm 27744]} + \define{firstindent36 + menu:[Indent~5,FirstIndent36] + attr:[Indent PreviousIndentation Cm 83231]} + -- fromrtf.n + + -- Convert a file (or selected section) from RTF format to ATK format. + + -- + + -- Author: WJHansen + + + marker Version := "1.3" + + + -- Version 1.3 - 19 February 1991 + + -- bug fixes, especially to indentation and \\* + + -- now deals with an old fonttbl format + + + -- Version 1.2 - 13 Feb 1991 + + -- Added features: + + -- annotations, fields, index entries, table of contents (partial) + + -- all page numbering options + + -- paragraph indentation has been corrected + + + -------------------------------------------- + + -- HERE'S HOW + + + -- To convert an entire file give the command + + -- nessrun /usr/andrew/lib/ness/fromrtf.n + + -- The output will be in a file having the same prefix and the extension '.d' + + -- An existing file with the name generated for the output will be moved to + + -- the same name with the extension '.old' + + + -- To convert a piece of a document: + + -- Select the piece, type ESC-ESC, and at the 'Ness:' prompt type + + -- fileconvert_convert() + + + -- To have the conversion as a menu option, add to your ~/.atkinit (or other + .XYZinit): + + -- call ness-load FILENAME + + -- where FILENAME is the full pathname of this file + + + -- To invoke conversion from another Ness program, call the function + + -- fromrtf_to_atk(text) + + -- The return value will be the converted text. + + + -- For the second, third, and fourth options your ~/.atkinit (or other + .XYZinit file) + + -- should contain the lines + + -- load ness + + -- addkey ness-dostmt \\e\\e view + + + ----------------------------------------- + + -- Known Problems + + + -- Styles are fragmented, a long indented section will have separate pieces + + -- at each place where the style of an internal piece changes. + + -- + + -- Table of contents entries in ATK are generated based on styles. These + + -- styles are not currently generated by this program; instead the individual + + -- components of the styles are generated. + + + -- Hidden text in ATK cannot be viewed readily. Users can get around this + + -- by using lookz to give some other attributes to the style "Hidden". + + + ----------------------------------------- + + -- Algorithm + + + -- The main loop searches for the next \\ \{ \} or newline, + + -- processing each appropriately. + + -- CurrText is the unprocessed tail of the original input. + + -- The accumulated output is in OutText. + + -- Newlines and carriage returns are ignored, everywhere. + + + -- The format of a control is + + -- backslash, letters, optional-number-optionally-signed, optional-space + + -- or + + -- backslash, non-letter + + -- PeelControl() knows this syntax and strips one control off the input. + + + -- Our strategy for dealing with styles is to accumulate a style + + -- string from style information. When the style changes or a group + + -- ends, the current style string is applied to the text that has just + + -- been finished. + + + -- The style string to be applied to any given piece of text may have a + sequence + + -- of styles, each of which is represented as a byte with that style. + + -- The entire sequence is stored as a sequence of such bytes, each followed + + -- by a single unstyled blank. A style defined in the rtf \\stylesheet is + stored + + -- in variable StyleSheet as the sequence: + + -- \\sdd (where dd is an integer), followed by a dash, + + -- the style sequence, and finally a comma. + + + -- On encountering a style, the plain text collected since the last style + + -- is marked with the former style. Then the new style is applied + + -- (added or deleted) to the style string. + + -- At the end of a group, the outer style string is reinstated, popping + + -- its string off StyleStack in ParseGroup. + + + -- The following rtf controls are processed by this program. + + -- A # means the style has a numeric operand + + -- A * means the control may have the operand 0 to turn off the style. + + + -- Major groups that are specially processed + + -- \\rtf# \\fonttbl \\stylesheet \\footnote + + -- \\footer \\footerl \\footerr \\header \\headerl \\headerr + + -- \\*\\annotation \\*\\atnid stored as hidden text + + -- \\field - minimal processing. + + -- convert page to \\chpgn or use \\fldrslt (if not \\fldpriv) + + -- ignore \\flddirty \\fldedit \\fldlock \\*\\fldinst + + -- \\xe text goes into document (possibly hidden ala \\v) \\: -> : + + -- ignore \\bxe \\ixe \\rxe \\txe + + -- \\tc ignore \\tcf# and \\tcl# + + -- \\info saved in document with "Hidden" style + + -- \\info includes the following: + + -- \\title \\subject \\author \\keywords \\comment \\version + + -- \\doccomm \\vern# \\creatim \\yr# \\mo# \\dy# \\hr# \\min# \\id# + + -- \\revtim \\printim \\buptim \\edmins# \\nopages# \\nofwords# \\nofchars# + + -- Character set is assumed to be ASCII, so the mappings + + -- \\ansi \\mac \\pc \\pca \\nextcset + + -- are minimal and utilized only for \\' + + -- These maps can be extended by adding appropriate entries. + + + -- Page numbering and section controls + + -- \\page \\pgnstart# \\pgnstarts# \\pgnrestart \\pgncont + + -- \\pgndec \\pgnucrm \\pgnlcrm \\pgnucltr \\pgnlcltr + + -- \\sect \\sectd \\sbknone \\sbkcol \\sbkpage \\sbkeven \\sbkodd + + + -- Controls that result in modifications to the style string + + -- \\pard \\s# + + -- \\v uses "Hidden" style + + -- \\ql \\qr \\qj \\qc + + -- \\plain \\b* \\i* \\f \\fs \\ulnone + + -- \\ul* \\ulw* \\uld* \\uldb* all treated as \\ul + + -- \\fi# \\li# \\ri# rounded to nearest 12 points + + -- \\up# \\dn# \\sb# \\sa# \\sl# rounded to nearest 2 points + + -- as installed, the Region,Hidden style is sanserif and four points smaller. + + -- To make this text invisible, edit the style to have the Hidden + + -- attribute in the "enable" section. This attribute can be made visible + + -- by clicking the Region,ReallyHidden style name in lookz. + + -- Unfortunately, ReallyHidden text still prints as of February, 1991 + + + -- Controls that are replaced with text + + -- \\par newline + + -- backslash-newline newline + + -- backslash-return newline + + -- \\row newline + + -- \\cell tab + + -- \\line carriage return ("soft" newline) + + -- \\tab + + -- \\~ unpaddable space + + -- \\'n uses the n'th ASCII character (may be mapped) + + -- \\- soft hyphen + + -- \\_ non-breaking hyphen + + -- \\\\ \\ + + -- \\\{ \{ + + -- \\\} \} + + -- \\: : + + -- \\chpgn page number + + -- \\chdate mo/day/yr, as 1/30/91 + + -- \\bullet \\emdash \\endash \\lquote \\rquote \\ldblquote \\rdblquote + + + + ---------------------------------------- + + -- Ignored controls + + -- + + -- Groups beginning with these words + + -- \\headerf \\footerf \\pict \\colortbl + + -- \\*\\bkmkstart \\*\\bkmkend + + -- Associated with the ignored groups are these controls + + -- which appear only in these groups and are thus never encountered + + -- \\red# \\green# \\blue# \\ftnsep \\ftnspec \\ftncn + + -- \\pich# \\picw# \\picscaled \\wmetafile# \\macpict \\bin# + + -- \\wbitmap# \\picwGoal# \\pichGoal# \\picscalex# \\picscaley# + + -- \\piccropt# \\piccropb# \\piccropl# \\piccropr# + + -- \\wbmbitspixel# \\wbmplanes# \\wbmwidthbytes# + + -- Document formatting controls + + -- \\paperw# \\paperh# \\margl# \\margr# \\margt# \\margb# \\facingp + + -- \\gutter# \\ogutter# \\deftab# \\widowctrl \\deff# \\revbar# + + -- \\hyphotz# \\ftncn \\enddoc \\defformat \\revisions \\revprop# + + -- \\ftnbj \\ftnsep \\ftnsepc \\endnotes \\ftntj \\ftnstart# + + -- \\ftnrestart \\linestart# \\landscape \\margmirror + + -- \\fracwidth \\*\\nextfile \\*\\template \\makeback + + -- Section properties: + + -- \\pgnx# \\pgny# \\headery# \\footery# + + -- \\linemod# \\linex# \\linestarts# \\linerestart \\lineppage + + -- \\linecont \\vertalt \\vertalc \\vertalj \\vertal + + -- \\cols# \\colsx# \\linebetcol \\endnhere \\titlepg + + -- Paragraph styles + + -- \\keep \\keepn \\sbys \\noline \\tx# \\tqr \\tb \\tqc \\tqdec + + -- \\brdrt \\brdrb \\brdrl \\brdrr \\box \\brdrs + + -- \\brdrth \\brdrsh \\brdrdb \\brdrdot \\brdrhair \\brsp# + + -- \\tldot \\tlhyph \\tlul \\tlth \\pagebb + + -- Absolute positioned objects + + -- \\posx# \\posxc \\posxi \\posxl \\posxo \\posxr + + -- \\posy# \\posyil \\posyt \\posyc \\posyb + + -- \\absw# \\dxfrtext# \\pvmrg \\pvpg \\phmrg \\phpg \\phcol + + -- Tables + + -- \\intbl \\clbrdrb \\clbrdrt \\clbrdrr \\clbrdrl + + -- \\trowd \\trql \\trqc \\trqr \\trgaph# \\trrh# \\trleft# + + -- \\cellx# \\clmgf \\clmgr + + -- Character styles + + -- \\strike \\outl \\shad \\scaps \\caps \\expnd# \\cb# \\cf# \\revised + + -- Special characters + + -- \\chftn \\chftnsep \\chftnsepc \\chtime \\| \\chatn \\column + + + ------- Lookz to edit the special styles used in this program + + -- Do not use lookz to edit styles FirstIndent\italic{xx} and + FirstInMin\italic{xx}. + + -- + \begindata{lookz, 269273264} + hidden + \enddata{lookz, 269273264} + \view{lookzview,269273264,0,0,0} + + + + --------------------------------------------- + + -- constants + + + integer DEFAULTFONTSIZE := 12 -- whatever size is usual + + + marker Letters := "qwertyuiopasdfghjklzxcvbnm" + + ~ "QWERTYUIOPASDFGHJKLZXCVBNM" + + + marker Hidden := "\hidden{h}idden" -- first letter has "hidden" style + + -- (this value is temporarily replaced in processing \\xe) + + + marker PageBreak := + + // + + + \begindata{bp,269350112} + \enddata{bp,269350112} + \view{bpv,269350112,1,0,0} + + \\\\ + + + --------------------------------------------- + + -- global state + + + marker CurrText -- what remains to be parsed + + + -- results of parseControl() + + marker CurrCtl -- the result of parsing the latest control + + marker CurrRand -- the operand string + + integer CurrRandValue -- the numeric operand + + + marker StyleSheet -- constructed from \\stylesheet + + marker FontTbl -- constructed from \\fonttbl group + + marker CurrMap -- set from macmap, ansimap, pcmap, or pcamap + + + boolean DefinedHeader -- have we seen \\header... + + boolean sectBreakPage := True -- set False by \\sbknone + + boolean restartpgnumpersect := False -- set true by \\pgnrestart + + integer sectFirstPageNum := 1 -- set by \\pgnstarts + + boolean pageNumberSupplied := False -- kludge + + marker currPageNFmt := "1" -- set by \\pgnxcxx + + + --------------------------------------------- + + -- Control Interpretation Table + + + -- The ControlInterpretationTable gives a translation for every control + + -- interpreted by this program. + + -- The proper entry for "control" is found by searching for "\\control-" + + -- and utilizing subsequent characters up to the comma. + + -- The first character after the dash is the major function indicator + + -- and determines, for example, whether preceding text should have the + + -- current style applied. + + + marker ControlInterpretationTable := + + + -- these entries all introduce new styles. The major function code is "s". + + -- the action for those without $ is to append the style to the current + style + + -- for those with subcode $, individual actions are taken + + -- The style code letters are not duplicated so when a style is to be deleted + + -- from the current style, its code letter is deleted from the style string. + + "\\\\ql-s\flushleft{A},\\\\qr-s\flushright{B},\\\\qj-sC,\\\\qc-s\center{D},\ + \\\\b-s\bold{E},\\\\i-s\italic{F}," + + ~ "\\\\v-s\hidden{G}," -- between the s and comma is a "G" in style Hidden + + ~ + "\\\\ul-s\underline{I},\\\\ulw-s\underline{J},\\\\uld-s\underline{K},\\\\uldb-s\ + \underline{L},\\\\up-s$R\up2{M}\down2{M},\\\\dn-s$R\down2{N}\up2{N}," + + ~ + "\\\\li-s$P\leftinmin36{h}\leftindent72{h}\leftinmin12{h}\leftindent36{h}\leftindent12{h\ + },\\\\ri-s$P\rightinmin36{i}\rightindent72{i}\rightinmin12{i}\rightindent36{i}\ + \rightindent12{i},\\\\fi-s$Q\firstinmin72{j}\firstindent36{j}\firstinmin36{j}\ + \firstindent12{j}\firstinmin12{j},\\\\sb-s$U\para6{k}\para12{k}\para24{k},\\\\s\ + a-s$U\para6{k}\para12{k}\para24{k},\\\\sl-s$U\line6{l}\line12{l}\line24{l}," + + ~ "\\\\s-s$S,\\\\fs-s$T,\\\\f-s$f,\\\\ulnone-s$V," + + ~ "\\\\plain-s$W,\\\\pard-s$X,\\\\snext-s$n,\\\\sbasedon-s$b," + + + -- the following are simply replaced with the text following the + + -- major function code, which is "r" + + ~ "\\\\par-r\\n,\\\\tab-r\\t,\\\\~-r\formatnote{\\\\ + },\\\\_-r\formatnote{\\\\-},\\\\--r\formatnote{\\\\%},\\\\:-r:," + + ~ + "\\\\\\r-r\\n,\\\\line-r\\r,\\\\\{-r\{,\\\\\}-r\},\\\\\\\\-r\\\\,\\\\\\n-r\\n,"\ + + ~ + "\\\\chpgn-r\formatnote{\\\\\\\\n(PN},\\\\chdate-r\formatnote{\\\\\\\\n(mo/\\\\\ + \\\\n(dy/\\\\\\\\n(yr}," + + ~ + "\\\\cell-r\\t,\\\\row-r\\n,\\\\bullet-r\symbola{7},\\\\emdash-r\symbola{>},\\\\\ + endash-r-," + + ~ + "\\\\lquote-r`,\\\\rquote-r',\\\\ldblquote-r\\",\\\\rdblquote-r\symbola{2}," + + + -- footnotes (code "p") return text to be inserted unstyled + + -- picts are ignored. annotations are stored as hidden text + + ~ "\\\\footnote-pA,\\\\pict-pB," + + ~ "\\\\annotation-pC,\\\\atnid-pD,\\\\annotation-pC,\\\\atnid-pD," + + ~ "\\\\field-pE,\\\\xe-pF,\\\\tc-pG," + + + -- hex chars are mapped. major function code "m" + + ~ "\\\\'-m," + + + -- map font codes to ATK fonts. major function code "f" + + -- (These should only be seen by parseFonttbl) + + ~ + "\\\\fnil-f,\\\\froman-\andy{f},\\\\fswiss-\sans{f},\\\\fmodern-\typewriter{f},\ + " + + ~ + "\\\\fscript-\italic{\underline{f}},\\\\fdecor-\bold{\underline{f}},\\\\ftech-\ + \symbol{f}," + + + -- page numbering and section controls, func code "qP" + + ~ "\\\\pgnstart-qPa,\\\\pgnstarts-qPb,\\\\pgnrestart-qPc,\\\\pgncont-qPd," + + ~ + "\\\\pgnucrm-qPe,\\\\pgnlcrm-qPf,\\\\pgnucltr-qPg,\\\\pgnlcltr-qPh,\\\\pgndec-q\ + Pi," + + ~ "\\\\sect-qPj,\\\\sectd-qPk,\\\\sbknone-qPl,\\\\sbkcol-qPm," + + ~ "\\\\sbkpage-qPm,\\\\sbkeven-qPm,\\\\sbkodd-qPm,\\\\page-qPp," + + + -- these introduce major blocks. Function code "q" + + ~ "\\\\footer-qEfs,\\\\footerl-qEfd,\\\\footerr-qEfd," + + ~ "\\\\header-qEhs,\\\\headerl-qEhd,\\\\headerr-qEhd," + + ~ "\\\\mac-qCA,\\\\pc-qCB,\\\\ansi-qCC,\\\\nextcset-qCC,\\\\pca-qCD," + + ~ "\\\\rtf-qR,\\\\fonttbl-qF,\\\\stylesheet-qS,\\\\info-qI," + + ~ "\\\\*-q*," -- unknown destinations are ignored + + ~ "\\\\colortbl-q#,\\\\bkmkstart-q#,\\\\bkmkend-q#," -- ignored + + ~ "\\\\txe-q#,\\\\rxe-q#," + + + --------------------------------------------- + + -- font controls + + \symbola{ + }-- Font choices: + + -- \\fnil -> default font + + -- \\roman -> andy + + -- \\fswiss -> andysans + + -- \\fmodern-> andytype + + -- \\fscript -> default-italic-underline + + -- \\fdecor -> default-bold-underline + + -- \\ftech -> symbol (could be symbola, XXX need mapping) + + + -- The fonts Symbol and SymbolA under ATK are in the PostScript ordering. + + + -- font Symbol: (PostScript symbol codes 0x20 ... 0x7F) + + --\symbol{ !"#$%&'()*+,-./} 2x punctuation + + -- \symbol{0123456789:;<=>?} 3x digits + + -- \symbol{@ABCDEFGHIJKLMNO} 4x upper case + + -- \symbol{PQRSTUVWXYZ[\\]^_} 5x upper case\symbol{ + + }-- \symbol{`abcdefghijklmno} 6x lower case\symbol{ + + }-- \symbol{pqrstuvwxyz\{|\}~?} 7x lower case + + + -- font SymbolA: (PostScript symbol codes 0xA0 ... 0xFF, mapped to 0x20 ... + 0x7F) + + -- \symbola{ !"#$%&'()*+,-./} 2x\symbola{ + + }--\symbola{ 0123456789:;<=>?} 3x + + --\symbola{ @ABCDEFGHIJKLMNO} 4x + + --\symbola{ PQRSTUVWXYZ[\\]^_} 5x + + --\symbola{ `abcdefghijklmno} 6x + + --\symbola{ pqrstuvwxyz\{|\}~?} 7x + + + marker macmap := + "a1-\symbola{0}a5-\symbola{7}a8-\symbola{b}a9-\symbola{c}aa-\symbola{T}ad-\ + \symbola{9}c9-\symbola{<}d" + + ~ "1-\symbola{m}d2-\\"d3-\symbola{2}d4-`d5-'" + + marker ansimap := "aa-\\"ba-\symbola{2}b7-\symbola{7}e3-\symbola{c}" + + marker pcmap := "" + + marker pcamap := "" + + + --------------------------------------------- + + -- table for \\'#, the hexadecimal character convention (we just use ASCII) + + + marker hextran := + + "\\000\\001\\002\\003\\004\\005\\006\\007\\010\\011\\012\\013\\014\\015\\0\ + 16\\017" + + ~ + "\\020\\021\\022\\023\\024\\025\\026\\027\\030\\031\\032\\033\\034\\035\\036\\0\ + 37" + + ~ + "\\040\\041\\042\\043\\044\\045\\046\\047\\050\\051\\052\\053\\054\\055\\056\\0\ + 57" + + ~ + "\\060\\061\\062\\063\\064\\065\\066\\067\\070\\071\\072\\073\\074\\075\\076\\0\ + 77" + + ~ + "\\100\\101\\102\\103\\104\\105\\106\\107\\110\\111\\112\\113\\114\\115\\116\\1\ + 17" + + ~ + "\\120\\121\\122\\123\\124\\125\\126\\127\\130\\131\\132\\133\\134\\135\\136\\1\ + 37" + + ~ + "\\140\\141\\142\\143\\144\\145\\146\\147\\150\\151\\152\\153\\154\\155\\156\\1\ + 57" + + ~ + "\\160\\161\\162\\163\\164\\165\\166\\167\\170\\171\\172\\173\\174\\175\\176\\1\ + 77" + + ~ + "\\200\\201\\202\\203\\204\\205\\206\\207\\210\\211\\212\\213\\214\\215\\216\\2\ + 17" + + ~ + "\\220\\221\\222\\223\\224\\225\\226\\227\\230\\231\\232\\233\\234\\235\\236\\2\ + 37" + + ~ + "\\240\\241\\242\\243\\244\\245\\246\\247\\250\\251\\252\\253\\254\\255\\256\\2\ + 57" + + ~ + "\\260\\261\\262\\263\\264\\265\\266\\267\\270\\271\\272\\273\\274\\275\\276\\2\ + 77" + + ~ + "\\300\\301\\302\\303\\304\\305\\306\\307\\310\\311\\312\\313\\314\\315\\316\\3\ + 17" + + ~ + "\\320\\321\\322\\323\\324\\325\\326\\327\\330\\331\\332\\333\\334\\335\\336\\3\ + 37" + + ~ + "\\340\\341\\342\\343\\344\\345\\346\\347\\350\\351\\352\\353\\354\\355\\356\\3\ + 57" + + ~ + "\\360\\361\\362\\363\\364\\365\\366\\367\\370\\371\\372\\373\\374\\375\\376\\3\ + 77" + + + + function printdump(msg, text) + + writefile ("/tmp/a", text) + + printline(msg) + + printline(system("cat /tmp/a")) + + end function + + + + --------------------------------------------- + + -- text manipulation + + + -- SkipNewlines() + + -- advance CurrText beyond any initial newline or carriage return + + -- returns resulting first character of CurrText + + function SkipNewlines() + + while first(CurrText) = "\\n" or first(CurrText) = "\\r" do + + CurrText := rest(CurrText) + + end while + + return first(CurrText) + + end function + + + -- SkipToUnmatchedRightBrace(after) + + -- skip text to next unmatched right brace + + -- if 'after' is True CurrText will begin after the brace, + + -- otherwise before + + -- deal with \\\{ and \\\} by skipping char after \\ + + function SkipToUnmatchedRightBrace(boolean after) + + marker brace + + integer cnt := 1 + + while cnt > 0 do + + brace := anyof(CurrText, "\{\}\\\\") + + CurrText := extent(finish(brace), CurrText) + + if CurrText = "" then exit function + + elif brace = "\\\\" then CurrText := rest(CurrText) + + elif brace = "\{" then cnt := cnt + 1 + + else cnt := cnt -1 end if + + end while + + if not after then + + CurrText := extent(previous(CurrText), CurrText) + + end if + + end function + + + -- PeelControl(bs) + + -- bs refers to a \\ at the beginning of a control + + -- This function parses a control off CurrText + + -- and sets CurrText, CurrCtl, CurrRand, CurrRandValue + + -- returns major function code in ControlInterpretationTable + + function PeelControl(bs) + + integer neg := 1 + + marker t + + CurrCtl := extent(bs, span(finish(bs), Letters)) + + if CurrCtl = "\\\\" then + + -- must be a control symbol + + CurrCtl := extent(CurrCtl, next(CurrCtl)) + + CurrRand := "" + + CurrText := extent(finish(CurrCtl), CurrText) + + if CurrCtl = "\\\\*" then + + t := PeelControl(first(CurrText)) + + if t /= "" then return t end if -- ignore \\* + + CurrCtl := "\\\\*" -- replace unintelligible control group + + end if + + else + + CurrRand := span(finish(CurrCtl), "+-0123456789") + + if CurrRand /= "" then + + if first(CurrRand) = "-" then neg := -neg end if + + CurrRandValue := neg * parseint(token(CurrRand, "0123456789")) + + else + + CurrRandValue := 0 + + end if + + CurrText := extent(finish(CurrRand), CurrText) + + if front(CurrText) = " " then CurrText := rest(CurrText) end if + + end if + + return next(search(ControlInterpretationTable, CurrCtl ~ "-")) + + end function + + + --------------------------------------------- + + -- font routines + + + -- ParseOldFonttbl() + + -- some \\rtf0 files have a non-group format for fonttbls. + + -- Each font entry is text like: + + -- \\f1\\froman Times; + + -- the semicolon on the last entry is followed by a \} to match the one before + \\fonttbl + + function ParseOldFonttbl() + + marker c := first(CurrText) + + marker tkey, font + + while c = "\\\\" do + + PeelControl(c) -- get font code: \\fnn + + if CurrCtl /= "\\\\f" then -- error: no \\f + + exit function + + end if + + tkey := CurrRand -- save nn + + c := SkipNewlines() + + if c /= "\\\\" then exit function end if -- error: no control for font + family + + font := PeelControl(c) -- get font family: \\fnil, etc. + + if font /= "f" then exit function end if -- error, no font family + + FontTbl ~:= tkey ~ " ," + + replace (previous(last(FontTbl)), font) + + c := anyof(CurrText, ";\}\\\\") + + if c /= ";" then exit function end if -- error no font name + + CurrText := extent(finish(c), CurrText) + + c := SkipNewlines() + + end while + + end function + + + -- ParseFontTbl() + + -- parses the \\fonttbl, building table in FontTbl + + -- assumes CurrText begins just after \\fonttbl + + -- Output is string containing sequence of "nnf," where nn is font number + + -- and f has the appropriate style + + -- We utilize the font family code and ignore the font name. + + function ParseFontTbl() + + marker c + + marker tkey, font + + c := SkipNewlines() + + if c /= "\{" then + + return ParseOldFonttbl() + + end if + + while c = "\{" do + + CurrText := rest(CurrText) + + c := SkipNewlines() + + if c /= "\\\\" then exit function end if -- error: no \\ for \\f + + tkey := PeelControl(c) -- get font code: \\fnn + + if CurrCtl /= "\\\\f" then -- error: no \\f + + exit function + + end if + + tkey := CurrRand -- save nn + + c := SkipNewlines() + + if c /= "\\\\" then exit function end if -- error: no control for font + family + + font := PeelControl(c) -- get font family: \\fnil, etc. + + if font /= "f" then exit function end if -- error, no font family + + FontTbl ~:= tkey ~ " ," + + replace (previous(last(FontTbl)), font) + + + + SkipToUnmatchedRightBrace(True) -- skip fontname & \} + + c := SkipNewlines() + + end while + + end function + + + -- GenerateFontSize(integer fs) + + -- fs is size in half points + + -- generate a character having a font size style setting of fs + + -- Algorithm: start with size 1 or 2 and advance with Bigger, Plus6, and + Plus18 + + + function GenerateFontSize(integer fs) + + marker s := copy("T") -- byte to be styled + + integer currsize := DEFAULTFONTSIZE + + + -- convert to points by dividing by two. + + -- round extra half point to nearest even number. + + if fs % 4 = 3 then fs := fs + 1 elif fs % 4 = 1 then fs := fs -1 end if + + fs := fs / 2 + + if fs %2 = 1 then + + addstyles(s, "\min1{$}"); currsize := currsize - 1 + + end if + + while currsize > fs do addstyles(s, "\smaller{$}"); currsize := currsize - 2 + end while + + while currsize+18 <= fs do addstyles(s, "\plus18{$}"); currsize := + currsize + 18 end while + + while currsize+6 <= fs do addstyles(s, "\plus6{$}"); currsize := currsize + + 6 end while + + while currsize+2 <= fs do addstyles(s, "\bigger{$}"); currsize := + currsize + 2 end while + + return s + + end function + + + --------------------------------------------- + + -- style routines + + + -- RemoveStyles(style sts) + + -- remove from style the styles coded by sts + + function RemoveStyles(style, sts) + + marker m + + while sts /= "" do + + if first(sts) /= " " then + + m := search(style, first(sts)) + + if m /= "" then + + replace(extent(m, next(m)), "") + + end if + + end if + + sts := rest(sts) + + end while + + end function + + + -- adjustindent() + + -- addstyles(target, code) enough times to come closer to the desired value + + integer function adjustindent(target, integer desired, code, integer val) + + integer times := desired / val + + if times < 0 then return desired end if -- opposite signs + + desired := desired - val * times + + while times > 0 do + + addstyles(target, code); times := times - 1 + + end while + + return desired + + end function + + + function IndentUnits(style, code, integer first, integer second, + + integer third, integer fourth, integer fifth) + + -- convert twips to points and round to nearest 12 points + + integer desired := (CurrRandValue + 120) / 20 + + marker target + + RemoveStyles(style, code) + + style ~:= code ~ " " + + target := previous(last(style)) + + clearstyles(target) + + desired := adjustindent(target, desired, code, first) code := next(code) + + desired := adjustindent(target, desired, code, second) code := next(code) + + desired := adjustindent(target, desired, code, third) code := next(code) + + desired := adjustindent(target, desired, code, fourth) code := next(code) + + desired := adjustindent(target, desired, code, fifth) code := next(code) + + return style + + end function + + + function RoundUnits(style, code, integer base) + + integer twips := base * 20; -- measurements are in points/20 + + if CurrRandValue < 0 then + + code := next(code) + + CurrRandValue := - CurrRandValue + + end if + + RemoveStyles(style, code) + + style ~:= code ~ " " + + CurrRandValue := CurrRandValue - twips*3/2 -- count first one and round + + while CurrRandValue > 0 do + + addstyles(previous(last(style)), code) + + CurrRandValue := CurrRandValue - twips + + end while + + return style + + end function + + + -- ModifyStyle(code, style) + + -- Modify 'style' to have or remove the style of 'code' + + -- A CurrRand of 0 turns off the option if already in 'style'. + + -- Other numeric rands are ignored. + + -- If code is "$", the style is specially handled as coded by next(code): + + -- Q round to 12 points + + -- R round to 2 points + + -- U round to 2 points + + -- S \\s# search StyleSheet + + -- T \\fs# set font size + + -- f \\f# set font + + -- V \\ulnone undoes any underline + + -- W \\plain undoes \\b \\i \\f \\fs \\ul \\ulw \\uld \\uldb \\up \\dn " + + -- X \\pard sets style string to empty + + + -- assumption, the styles are represented each with a unique byte + + + function ModifyStyle(code, style) + + marker m + + code := next(code) + + if CurrRand /= "" and CurrRandValue = 0 then + + -- turn off the style + + if code = "$" then code := next(code) end if + + RemoveStyles(style, code) + + elif code /= "$" then + + RemoveStyles(style, code) + + style ~:= " " -- two blanks + + replace(previous(last(style)), code) + + else + + code := next(code) + + --printline("s$" ~ code) + + if code = "T" then -- \\fs + + RemoveStyles(style, "T") + + style ~:= " " -- two blanks + + replace(previous(last(style)), + + GenerateFontSize(CurrRandValue)) + + elif code = "f" then -- \\f + + RemoveStyles(style, "f") + + m := search(FontTbl, CurrRand) + + if m /= "" then + + style ~:= " " -- two blanks + + replace(previous(last(style)), next(m)) + + end if + + elif code = "S" then -- \\s + + -- change style to that found in StyleSheet + + m := search(StyleSheet, "\\\\" ~ CurrRand ~ "-") + + if m /= "" then + + m := finish(m) + + style := copy(extent(m, start(search(m, ",")))) + + --printdump("change to style \\\\s" ~ CurrRand, style) + + end if + + elif code = "P" then -- \\li \\ri round to 12 points + + style := IndentUnits(style, next(code), -36, 72, -12, 36, 12) + + elif code = "Q" then -- \\fi round to 12 points + + style := IndentUnits(style, next(code), -72, 36, -36, 12, -12) + + elif code = "R" then -- \\up \\dn round to 2 points + + style := RoundUnits(style, next(code), 2) + + elif code = "U" then -- \\sa \\sb \\sl 6, 12, or 24 points, but cancel + for 0 + + code := next(code) + + RemoveStyles(style, code) + + if CurrRandValue /= 0 then + + if CurrRandValue >= 360 then + + -- 18 points or more, use 24 + + code := next(next(code)) + + elif CurrRandValue >= 180 then + + -- 9 points or more, use 12 + + code := next(code) + + else + + -- less than 9 points, use 6 + + end if + + style ~:= " " -- two blanks + + replace(previous(last(style)), code) + + end if + + elif code = "X" then -- \\pard + + style := newbase() + + elif code = "W" then -- \\plain + + RemoveStyles(style, "GHIJKLMNfT") + + elif code = "V" then -- \\ulnone + + RemoveStyles(style, "IJKL") + + end if + + end if + + return style + + end function + + + -- ParseStyle() + + -- parse controls off the front of CurrText + + -- call ModifyStyle to append style definitions to style + + -- leave CurrText at the beginning of the style name + + -- Returns "\\snn," where nn is stylenum and is a style + string + + -- for \\sbasedon, call ModifyStyle for each elt of the basis style + + -- (order of definition matters) + + function ParseStyle() + + marker stynum := "999" + + marker m, code, xcode + + marker style := newbase() + + while first(CurrText) = "\\\\" do + + code := PeelControl(first(CurrText)) + + xcode := extent(code, next(next(code))) + + if CurrCtl = "\\\\s" then + + stynum := CurrRand + + elif CurrCtl = "\\\\snext" and stynum = "999" then -- \\snext + + -- this is BOGUS, based on rule that \\snext gives + + -- own number if is the "last" XXX + + stynum := CurrRand + + elif CurrCtl = "\\\\sbasedon" then -- \\sbasedon + + m := search(StyleSheet, "\\\\" ~ CurrRand ~ "-") + + if m /= "" then + + m := copy(extent(next(m), start(search(finish(m), ",")))) + + RemoveStyles(m, style) -- remove styles already + + -- specified in 'style' + + style ~:= m + + -- printdump("basedon " ~ CurrRand, style) + + end if + + elif code = "s" then + + style := ModifyStyle(code, style) + + end if + + SkipNewlines() + + end while + + return "\\\\" ~ stynum ~ "-" ~ style ~ "," + + end function + + + -- ParseStyleSheet() + + -- parse stylesheet, build StyleSheet value + + -- CurrText begins just after \\stylesheet + + function ParseStyleSheet() + + marker t + + t := SkipNewlines() + + while t = "\{" do + + CurrText := rest(CurrText) + + SkipNewlines() + + StyleSheet ~:= ParseStyle() + + SkipToUnmatchedRightBrace(True) -- skip style name & \} + + t := SkipNewlines() + + end while + + -- printdump("stylesheet", StyleSheet) + + end function + + + -- ApplyStyle(tstart, tend, style) + + -- Apply style to extent(tstart, base(tend)) + + -- Return ref to tend + + -- + + function ApplyStyle(tstart, tend, style) + + marker subject + + subject := extent(tstart, base(tend)) + + if subject = "" then + + -- no text to be styled + + return finish(subject) + + end if + + while style /= "" do + + addstyles(subject, style) + + style := rest(rest(style)) + + end while + + return finish(subject) + + end function + + + + --------------------------------------------- + + -- Headers and Footers + + + -- Every header and footer is included, but only the most recent of each + + -- will apply. Simplex printing is specified for header or footer. + + -- Duplex printing is specified for headerl, headerr, footerl, footerr. + + -- Each tab in the text separates one of the three parts of the title. + + -- (Maximum of two tabs). Styles are ignored. + + --Example input: + + -- \{\\footerl \\pard\\plain \\s243\\tqc\\tx4320\\tqr\\tx8640 + + -- \{\\f14\\fs20 Sun OS 4.0 Installation Procedures\\tab \\chdate + + -- \\tab Page \\chpgn \\par \}\} + + -- Example output (all wrapped in FormatNote) + + -- .duplex + + -- .\\" Footer + + -- .ds LB Sun OS 4.0 Installation Procedures + + -- .ds CB \\\\n(dy/\\\\n(mo/\\\\n(yr + + -- .ds RB \\\\n(PN + + -- + + + -- ComputeExtremiter(text, footer) + + -- create lines for left, right, and center + + -- break text at tabs or newlines, using the non-blank segments + + -- 3 or more non-blank segs: use first three as L, C, and R + + -- 2 segs: L and R + + -- 1 seg: C + + function ComputeExtremiter(text, boolean footer) + + marker tab, segL, segC, segR, where + + integer nsegs := 0 + + while text /= ""and nsegs < 3 do + + tab := anyof(text, "\\t\\n") + + segR := extent(text, start(tab)) + + if segR /= "" then + + -- grab a seg + + nsegs := nsegs + 1 + + if nsegs = 1 then segL := segR + + elif nsegs = 2 then segC := segR end if + + end if + + -- skip tab + + text := extent(finish(tab), text) + + end while + + if nsegs = 1 then + + segC := segL; segL := ""; segR := "" + + elif nsegs = 2 then + + segC := "" + + elif nsegs = 0 then + + segC := ""; segL := ""; segR := "" + + end if + + if footer then where := "B " else where := "T " end if + + return (".ds L" ~ where ~ segL ~ "\\n") + + ~ (".ds C" ~ where ~ segC ~ "\\n") + + ~ (".ds R" ~ where ~ segR ~ "\\n") + + end function + + + -- ~ "\\\\footer-qEfs,\\\\footerl-qEfd,\\\\footerr-qEfd," + + -- ~ "\\\\header-qEhs,\\\\headerl-qEhd,\\\\headerr-qEhd," + + + function ParseExtremiter(code) + + boolean footer + + marker text := newbase() ~ "\\n" -- initial newline + + + code := next(code) -- f or h + + footer := code = "f" + + + code := next(code) -- to s or d + + if code = "d" then text ~:= ".duplex\\n" else text ~:= ".simplex\\n" end if + + if footer then text ~:= ".\\\\\\" Footer\\n" + + else text ~:= ".\\\\\\" Header\\n" end if + + text ~:= ComputeExtremiter(clearstyles(parseGroup("")), footer) + + if not footer then DefinedHeader := True + + elif footer and not DefinedHeader then + + -- undefine the standard header with page number at top + + text ~:= ".ds CT\\n" + + end if + + + return addstyles(text, "\formatnote{%}") -- formatnote + + end function + + + --------------------------------------------- + + -- Footnotes + + + marker annotator := "" + + + function parseEmbeddedObject(code) + + marker m, t, SaveState + + if next(code) = "A" then + + -- \\footnote + + -- m := + copy("\footnote{\ + \begindata{fnote,268948544} + \textdsversion{12} + \enddata{fnote,268948544} + \view{fnotev,268948544,2,0,0} }") -- footnote object and two footnote blanks + + -- the above fails because all footnotes get the same object + + m := copy(" ") + + replacewithobject(first(m), new(class("fnote")), "fnotev") + + addstyles(m, + "\footnote{\ + \begindata{fnote,269248448} + \textdsversion{12} + \enddata{fnote,269248448} + \view{fnotev,269248448,3,0,0}}") + + m := replace (previous(last(m)), clearstyles(parseGroup(""))) + + if first(m) = "\\n" then replace(first(m), "") end if + + replace(next(m), "") + + return base(m) + + elif next(code) = "C" then -- \\annotation. append (annotator) + + m := parseGroup("") + + if annotator /= "" then m := m ~ " (" ~ annotator ~ ")" end if + + annotator := "" + + addstyles(m, Hidden) + + return m + + elif next(code) = "D" then -- \\atnid. save author + + annotator := parseGroup("") + + return "" + + elif next(code) = "E" then -- \\field - minimal processing. + + -- convert page to \\chpgn or use \\fldrslt (if not \\fldpriv) + + -- ignore \\flddirty \\fldedit \\fldlock \\*\\fldinst + + m := CurrText + + SkipToUnmatchedRightBrace(False) + + m := extent(m, start(CurrText)) -- the contents of the \\field group + + if search(m, "page") /= "" then -- assume it is page number + + return "\formatnote{\\\\\\\\n(PN}" + + end if + + t := search(m, "\\\\fldrslt") + + if t /= "" then + + -- return contents of \\fldrslt + + SaveState := CurrText + + PeelControl(first(t)) -- sets CurrText + + m := parseGroup("") + + CurrText := SaveState + + return m + + end if + + return "" + + elif next(code) = "F" then -- xe text goes into document + + --(possibly hidden ala \\v) \\: -> : + + -- ignore \\bxe \\ixe \\rxe \\txe + + SaveState := Hidden + + Hidden := "\indexi{InvisibleIndex}" + + m := parseGroup("") + + if not hasstyles(m, Hidden) then + + addstyles(m, "\index{Index}") + + end if + + Hidden := SaveState + + return m + + elif next(code) = "G" then -- \\tc + + -- ATK entries for T/C are based on which style is chosen + + -- to implement this, we would have to choose which style + + -- sequences map to each ATK title style. + + -- For now we just include the text. + + return parseGroup("") + + else + + -- must be a pict, field, index entry, or tc entry + + SkipToUnmatchedRightBrace(False) + + return "" + + end if + + end function + + + + --------------------------------------------- + + -- Control and Block Processing + + + -- MapHex() + + -- Do mapping for \\'xx + + -- First check CurrMap, then just generate the hex byte + + -- + + function MapHex() + + marker t + + marker m := next(CurrCtl) + + m := extent(m, next(m)) -- the two hex bytes + + CurrText := extent(finish(m), CurrText) + + t := search(CurrMap, m ~ "-") + + if t /= "" then return next(t) + + else return nextn(first(hextran), parseint("0x" ~ m)) + + end if + + end function + + + function pageNFmt(fmt, fmtname) + + if currPageNFmt = fmt then return "" end if + + currPageNFmt := fmt + + return ".\\\\\\" format page number as " ~ fmtname ~ "\\n'af PN " ~ fmt + + end function + + + function Pagination(code) + + marker t + + marker troff := newbase() + + -- printline("Pagination code " ~ code) + + if code = "a" then -- a-\\pgnstart# + + CurrRandValue := CurrRandValue + 1 -- kludge + + t := textimage(CurrRandValue) + + troff ~:= "\\n.\\\\\\" set page number to " ~ t ~ "\\n'pn " ~ t + + pageNumberSupplied := True + + elif code = "b" then -- b-\\pgnstarts# + + CurrRandValue := CurrRandValue + 1 -- kludge + + sectFirstPageNum := CurrRandValue + + return "" + + elif code = "c" then -- c-\\pgnrestart + + -- it is incorrect to output the new page number here, + + -- but it works since pgnrestart is only given + + -- at the beginning of a section + + restartpgnumpersect := True + + t := textimage(sectFirstPageNum) + + troff := pageNFmt("1", "decimal") + + ~ ".\\\\\\" reset page number for new section to " ~ t + + ~ "\\n'pn " ~ t + + pageNumberSupplied := True + + elif code = "d" then -- \\pgncont + + restartpgnumpersect := False + + return "" + + elif code = "e" then -- \\pgnucrm + + troff := pageNFmt("I", "upper case roman") + + elif code = "f" then -- \\pgnlcrm + + troff := pageNFmt("i", "lower case roman") + + elif code = "g" then -- \\pgnucltr + + troff := pageNFmt("A", "upper case letter") + + elif code = "h" then -- \\pgnlcltr + + troff := pageNFmt("a", "lower case letter") + + elif code = "i" then -- \\pgndec + + troff := pageNFmt("1", "decimal") + + elif code = "j" then -- \\sect: add newline or page break + + -- and perhaps restart page numbers + + if not restartpgnumpersect then + + if sectBreakPage then return copy("\\f") + + else return "" end if + + end if + + t := textimage(sectFirstPageNum) + + troff := "\\n.\\\\\\" set page number for new section to " ~ t ~ "\\n'pn " ~ + t + + pageNumberSupplied := True + + if sectBreakPage then troff := "\\f" ~ troff end if + + elif code = "k" then -- \\sectd + + -- reset all section styles (we only have those for pagination) + + sectBreakPage := True + + restartpgnumpersect := False + + sectFirstPageNum := 1 + + -- assume we just had a \\sect, so we reformat page numbers + + troff := pageNFmt("1", "decimal") + + elif code = "l" then -- \\sbknone + + sectBreakPage := False + + return "" + + elif code = "m" then -- \\sbkcol \\sbkpage \\sbkeven \\sbkodd + + -- all set page break before section + + sectBreakPage := True + + return "" + + elif code = "p" then -- \\page + + return copy("\\f") -- signal to do page break before next text + + end if + + if troff = "" or troff = "\\n" then return "" end if + + return addstyles(troff ~ "\\n", "\formatnote{FormatNote}") + + end function + + + -- parseDocumentControl(code) + + -- major function code "q" + + -- process a group with a block code + + -- each function called to handle a group + + -- leaves its trailing \} on the front of CurrText + + + function parseDocumentControl(code) + + marker m + + --printline("parseDocumentControl " ~ CurrCtl ~ CurrRand) + + code := next(code) + + if code = "*" then -- \\* ignorable destination + + SkipToUnmatchedRightBrace(False) + + elif code = "P" then -- page numbering options + + return Pagination(next(code)) + + elif code = "R" then --\\rtf + + -- fine, accept rtf XXX probably should check CurrRand + + elif code = "F" then -- \\fonttbl + + ParseFontTbl() + + elif code = "S" then -- \\stylesheet + + ParseStyleSheet() + + elif code = "E" then -- \\header or \\footer + + return ParseExtremiter(code) + + elif code = "I" then -- \\info (make it hidden) + + m := CurrText + + SkipToUnmatchedRightBrace(False) + + m := copy(extent(m, start(CurrText))) + + return addstyles(m, Hidden) + + elif code = "C" then -- \\mac \\pc \\ansi \\pca + + -- map characters + + code := next(code) + + if code = "A" then CurrMap := macmap + + elif code = "B" then CurrMap := pcmap + + elif code = "C" then CurrMap := ansimap + + elif code = "D" then CurrMap := pcamap + + end if + + else -- skip all others + + SkipToUnmatchedRightBrace(False) + + end if + + return "" + + end function + + + boolean NewPage := False -- kludge return value from AppendTo + + + -- AppendTo(target, src, pagewanted, hadtext) + + -- specialized version of ~:= to avoid a bug in styles + + -- if pagewanted is true and the src is non-empty, + + -- set NewPage and generate a page break if hadtext is True + + function AppendTo(target, src, boolean pagewanted, boolean hadtext) + + -- printline("Append: " ~ src ~ " " ~ textimage(pagewanted) ~ " " ~ + textimage(hadtext)) + + if pagewanted and src /= "" then + + NewPage := True -- tell parsegroup to turn off pagewanted + + target ~:= " " + + if hadtext then + + replace(last(target), PageBreak) + + elif pageNumberSupplied then + + replace(last(target), + + ".\\\\\\" increment page number for inital page break\\n" + + ~ "\formatnote{'pn \\\\n%+1\\n}") + + end if + + pageNumberSupplied := False + + end if + + target ~:= " " + + replace (last(target), src) + + return base(target) + + end function + + + -- parseGroup(CurrStyle) + + -- parses the text in CurrText, using the argument as the base style + + -- returns the translated text + + -- + + -- the input is a sequence of operators and blocks + + -- where an operator begins with \\ and a block begins with \{ + + -- spaces and newlines are ignored + + -- some blocks are control blocks, others are text blocks, + + -- depending on the first operator in the block + + -- The AppendTo function is used instead of ~:= to avoid + + -- a bug in ATK styles code. + + -- The "\}" which terminates the group is left on the front of CurrText. + + -- + + function parseGroup(CurrStyle) + + marker c, t, func, OutText, TStart, StyleStack + + boolean pagePending := False + + boolean hadText := False + + integer depth := 0 + + OutText := newbase() + + TStart := OutText + + StyleStack := "" + + CurrStyle := copy(CurrStyle) + + while CurrText /= "" do + + c := anyof(CurrText, "\{\}\\n\\r\\\\") + + t := extent(CurrText, start(c)) + + if t /= "" then + + OutText := AppendTo(OutText, t, pagePending, hadText) + + hadText := True + + end if + + CurrText := extent(finish(c), CurrText) + + if NewPage then + + PagePending := False + + NewPage := False + + end if + + if c = "\{" then + + -- OutText := AppendTo(OutText, parseGroup(CurrStyle)) + + -- CurrText := rest(CurrText) -- discard "\}" + + -- instead of explicitly recurring, we push + + -- (this avoids copying OutText) + + TStart := ApplyStyle(TStart, OutText, CurrStyle) + + depth := depth + 1 + + StyleStack := CurrStyle ~ ";" ~ StyleStack + + elif c = "\}" then + + -- we are finished, at least at this level of nesting + + if depth <= 0 then + + CurrText := extent(c, CurrText) -- keep the "\}" + + exit while + + else + + TStart := ApplyStyle(TStart, OutText, CurrStyle) + + -- pop + + depth := depth - 1 + + c := search(StyleStack, ";") + + CurrStyle := copy(extent(StyleStack, start(c))) + + StyleStack := extent(finish(c), StyleStack) + + end if + + elif c = "\\\\" then + + func := PeelControl(c) + + -- printline(CurrCtl ~ ": " ~ func) + + if func = "s" then + + -- style change + + TStart := ApplyStyle(TStart, OutText, CurrStyle) + + CurrStyle := ModifyStyle(func, CurrStyle) + + -- printline("New style : " ~ CurrStyle) + + elif func = "r" then + + -- replace control with text + + OutText := AppendTo(OutText, extent(next(func), + + start(search(finish(func), ","))), + + pagePending, hadText) + + elif func = "p" then + + -- footnote (or pict) + + TStart := ApplyStyle(TStart, OutText, CurrStyle) + + OutText := AppendTo(OutText, + + parseEmbeddedObject(func), + + pagePending, hadText) + + TStart := finish(OutText) + + elif func = "m" then + + -- \\'xx hex code to map. must unset font + + if search(CurrStyle, "f") /= "" then + + t := copy(CurrStyle) + + RemoveStyles(t, "f") + + TStart := ApplyStyle(TStart, OutText, CurrStyle) + + OutText := AppendTo(OutText, MapHex(), + + pagePending, hadText) + + TStart := ApplyStyle(TStart, OutText, t) + + else + + OutText := AppendTo(OutText, MapHex(), + + pagePending, hadText) + + end if + + elif func = "q" then + + -- major block or document format + + TStart := ApplyStyle(TStart, OutText, CurrStyle) + + t := parseDocumentControl(func) + + if first(t) = "\\f" then + + PagePending := True + + -- t := rest(t) -- fails due to bug in styles + + replace(first(t), "") + + end if + + if first(t) = "\\n" and (last(OutText) = "\\n" + + or OutText ="") then + + -- t := rest(t) -- fails due to bug in styles + + replace(first(t), "") + + end if + + OutText := AppendTo(OutText, t, False, hadText) + + TStart := finish(OutText) + + else + + -- ignore other controls + + end if + + else -- c = "\\n" or c = "\\r" then + + -- skip newline or carriage return + + end if + + if NewPage then + + PagePending := False + + NewPage := False + + end if + + end while + + ApplyStyle(TStart, OutText, CurrStyle) + + return base(OutText) + + end function + + + --------------------------------------------- + + -- central conversion routine + + + -- convert(s) + + -- Initialize global variables and parse the input by calling parsegroup. + + -- ParseGroup ends leaving CurrText starting with the trailing "\}" + + -- Convert continues processing if there is more CurrText and the + + -- "\}" is not followed by a zero byte. + + -- + + function convert(s) + + marker t := newbase() + + -- init globals + + StyleSheet := newbase() + + FontTbl := newbase() + + CurrMap := ansimap + + DefinedHeader := False + + + if first(s) = "\{" then s := rest(s) end if + + CurrText := s + + while CurrText /= "" and first(CurrText) /= "\\000" do + + t := AppendTo (t, parseGroup(""), False, True) + + CurrText := rest(CurrText) -- skip "\}" + + end while + + return base(t) + + end function + + + + -------------------------------------------------- + + -- the following provide the four different methods of invoking conversion + + + -- this function can be called from other Ness scripts + + function fromrtf_to_atk(t) + + return convert(t) + + end function + + + -- this function can be called from the 'Ness:' prompt + + function fromrtf_convert() + + marker s := currentselection(defaulttext) + + replace (s, convert(s)) + + end function + + + -- add an item to the menu for all "textview" objects + + extend "view:textview" + + on menu "RTF to ATK" + + marker s := currentselection(defaulttext) + + replace (s, convert(s)) + + end menu + + end extend + + + + -- this main function executes if this file is invoked with nessrun + + function main(args) + + marker filename, outname, ext, m, text, outtext + + filename := token(args, Letters ~ "./_0123456789") + + ext := filename + + while ext /= "" do + + m := anyof (ext, "./") + + if m = "" then exit while + + else ext := extent(next(m), ext) + + end if + + end while + + -- now ext is the extension if preceded by "." + + if ext = "" then + + printline("You must supply a filename as argument.") + + exit function + + elif previous(ext) = "." and ext /= "d" then + + outname := extent(filename, start(ext)) ~ "d" + + else + + outname := filename ~ ".d" + + end if + + text := readfile(filename) + + if text = "" then + + printline("empty input file: " ~ filename) + + exit function + + end if + + m := search(text, "\{\\\\rtf") + + if m = "" then + + printline("Input file does not contain \\"\{\\\\rtf\\"") + + exit function + + end if + + + printline("fromrtf(" ~Version ~ "): " ~ filename ~ " -> " ~ outname) + + outtext := convert(extent(m, text)) + + if match(system("if test -f "~outname ~ ";" + + ~ "then mv " ~ outname ~ " " ~ outname ~ ".BAK;" + + ~ "echo moved;fi"), "moved") /= "" then + + printline("Moved old " ~ outname ~ " to " ~ outname ~ ".BAK") + + end if + + writefile(outname, outtext) + + end function + + + \enddata{text,269274372} *** atk/ness/nesslib/fileconvert.n Thu May 30 20:02:27 1991 --- atk/ness/nesslib/fileconvert.n.NEW Wed Jan 30 16:55:15 1991 *************** *** 0 **** --- 1,98 ---- + -- fileconvert.n + -- $$$ This is a prototypical file conversion program + -- $$$ To make a specific file converter, it is only necessary to + -- $$$ revise the parts marked $$$ + -- + -- Author: WJHansen + + -- $$$ invent a name for your converter and + -- $$$ change all appearances of "fileconvert" below to the new name + + -- HERE'S HOW + + -- To convert a piece of a document: + -- - Select the piece, type ESC-ESC, and at the 'Ness:' prompt type + -- fileconvert_convert() + + -- To convert an entire file give the command + -- nessrun /usr/andrew/lib/ness/fileconvert.n + -- The output will be in a file having the same prefix and the extension '.d' + -- An existing file with the name generated for the output will be moved to + -- the same name with the extension '.old' + + -- To have the conversion as a menu option, add to your ~/.atkinit (or other .XYZinit): + -- load ness + -- call ness-load FILENAME + -- where FILENAME is the full pathname of this file + -- and where the "load ness" line is only needed once in the entire .XYZinit file + + + marker Letters := "qwertyuiopasdfghjklzxcvbnm_" + ~ "QWERTYUIOPASDFGHJKLZXCVBNM" + marker IdChars := Letters ~ "0123456789" + + + function convert(s) + marker cvted := newbase() + + -- $$$ parse 's' producing the output version in 'cvted' + + return cvted + end function + + + ----------------------------------------------------------------- + -- the following provide the three different methods of invoking conversion + + + -- this function can be called from the Ness: prompt + function fileconvert_convert() + marker s := currentselection(defaulttext) + replace (s, convert(s)) + end function + + -- add an item to the menu for all "textview" objects + extend "view:textview" + on menu "Convert" -- $$$ change this to change the menu option that will appear + marker s := currentselection(defaulttext) + replace (s, convert(s)) + end menu + end extend + + -- this main function executes if this file is invoked with nessrun + function main(args) + marker filename, outname, ext, m, text, outtext + + filename := token(args, IdChars ~ "./") + ext := filename + while ext /= "" do + m := anyof (ext, "./") + if m = "" then exit while + else ext := extent(next(m), ext) + end if + end while + -- now ext is the extension if preceded by "." + if ext = "" then + printline("You must supply a filename as argument.") + exit function + elif previous(ext) = "." and ext /= "d" then + outname := extent(filename, start(ext)) ~ "d" + else + outname := filename ~ ".d" + end if + text := readfile(filename) + if text = "" then + printline("empty input file: " ~ filename) + exit function + end if + + printline("fileconvert: " ~ filename ~ " -> " ~ outname) + outtext := convert(text) + if match(system("if test -f "~outname ~ ";" + ~ "then mv " ~ outname ~ " " ~ outname ~ ".old;" + ~ "echo moved;fi"), "moved") /= "" then + printline("Moved old " ~ outname ~ " to " ~ outname ~ ".old") + end if + writefile(outname, outtext) + end function + *** atk/ness/nesslib/octalimage.n Thu May 30 20:02:36 1991 --- atk/ness/nesslib/octalimage.n.NEW Wed Jan 30 16:55:19 1991 *************** *** 0 **** --- 1,14 ---- + + -- octalimage_cvt (integer i) + -- converts the integer value to an octal string + function octalimage_cvt (integer i) + marker m := newbase() + while i /= 0 do + m := textimage(i % 8) ~ m + i := i / 8 + end while + while length(m) < 3 do + m := "0" ~ m + end while + return m + end function *** atk/ness/nesslib/gnutranspose.n Thu Jun 6 16:24:18 1991 --- atk/ness/nesslib/gnutranspose.n.NEW Thu Jun 6 17:34:40 1991 *************** *** 0 **** --- 1,18 ---- + -- Gnu Emacs style character transpose + -- + -- Installation: + -- 1. install this file in + -- 2. change ~/.atkinit to include + -- load ness + -- call ness-load + -- (after patch 10, this file will be in $ANDREWDIR/lib/ness) + -- + -- Usage: + -- In any textview, type control-t. + -- The two characters adjacent to the caret will be interchanged + -- and the caret will advance to after the second. + + extend "view:textview" on keys "\024" + textview_forward_character(currentinset) + textview_twiddle_chars(currentinset) + end keys end extend *** atk/ness/demos/Imakefile Wed Nov 22 12:22:54 1989 --- atk/ness/demos/Imakefile.NEW Thu Mar 21 14:39:03 1991 *************** *** 4,10 **** \* ********************************************************************** */ DFILES = bank.d calcr.d happybday.d volume.d calc.d capstest.d startez.d xmas.d ! NFILES = badsub.n gendoc.n DBFILES = birth.db DOCPROTOS = docheader.d docbody.d qrheader.d qrbody.d --- 4,10 ---- \* ********************************************************************** */ DFILES = bank.d calcr.d happybday.d volume.d calc.d capstest.d startez.d xmas.d ! NFILES = badsub.n gendoc.n happybday.n DBFILES = birth.db DOCPROTOS = docheader.d docbody.d qrheader.d qrbody.d *** atk/ness/doc/nessfunc.d Fri Dec 21 14:57:29 1990 --- atk/ness/doc/nessfunc.d.NEW Wed Feb 13 16:53:12 1991 *************** *** 1,4 **** ! \begindata{text,269507256} \textdsversion{12} \template{default} \define{index --- 1,4 ---- ! \begindata{text,269903968} \textdsversion{12} \template{default} \define{index *************** *** 74,82 **** document. }}\bold{ ! \begindata{bp,269009216} ! \enddata{bp,269009216} ! \view{bpv,269009216,0,0,0}} Copyright IBM Corporation 1988, 1989 - All Rights Reserved --- 74,82 ---- document. }}\bold{ ! \begindata{bp,270056336} ! \enddata{bp,270056336} ! \view{bpv,270056336,0,0,0}} Copyright IBM Corporation 1988, 1989 - All Rights Reserved *************** *** 102,113 **** /* $ACIS:$ */ ! /* $Source: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/ness/doc/RCS/nessfunc.d,v $ */ /* $Log: nessfunc.d,v $ ! Revision 1.8 90/10/12 20:48:36 wjh ! added documentation for regSearch and regSearchReverse ! Revision 1.7 90/09/16 21:18:27 wjh see atk/ness/objects/changes.sept.90 --- 102,117 ---- /* $ACIS:$ */ ! /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/ness/doc/RCS/nessfunc.d,v $ */ /* $Log: nessfunc.d,v $ ! Revision 1.11 91/02/08 14:39:33 wjh ! changed definitions of readfile and writefile ! Revision 1.10 91/01/28 11:40:18 wjh added ! documentation for fileconvert.n, ctype.n, and octalimage.n Revision 1.9 ! 90/12/04 14:56:07 wjh Improved the general description of the search ! commands. Revision 1.8 90/10/12 20:48:36 wjh added documentation for ! regSearch and regSearchReverse Revision 1.7 90/09/16 21:18:27 wjh see atk/ness/objects/changes.sept.90 *************** *** 120,128 **** nessauth.d: give example of a long string nessfunc.d: illustrate neststylegroup and nextstylesegment */ ! \begindata{bp,269356388} ! \enddata{bp,269356388} ! \view{bpv,269356388,1,0,0}} Ness provides a variety of functions and access to functions defined outside --- 124,132 ---- nessauth.d: give example of a long string nessfunc.d: illustrate neststylegroup and nextstylesegment */ ! \begindata{bp,270034036} ! \enddata{bp,270034036} ! \view{bpv,270034036,1,0,0}} Ness provides a variety of functions and access to functions defined outside *************** *** 330,353 **** 1.3 \index{Search functions}} ! Search functions in Ness search through the base of their first argument ! looking for some substring as described by the second argument. The return ! value is a marker referring to a substring of the first argument. ! By convention, the string searched is delimited by the precise details of the ! first argument: If it is a zero-length substring, the search extends from it ! to the end of the base; but if non-zero, the search occurs only within the ! substring delimited by that first argument. For a search that does not ! succeed, the value returned is a zero-length marker at the position of the end ! of the first argument. Thus a first argument of start(x) differs from one of ! toend(x) in the location of the empty marker returned for a failing search. Two of the search functions, \italic{search}() and \italic{match}() treat ! their second argument as a string to be matched exactly in the first (white space and the case of characters must all match exactly). The other three ! treat their second argument as a set of characters. For instance, in the expression --- 334,368 ---- 1.3 \index{Search functions}} ! Search functions have two arguments, a subject and a pattern. They scan ! through the subject looking for the first substring described by the pattern. ! The return value is a marker referring to a suitable substring of the ! subject. ! ! ! By convention, the first argument controls both how much of the subject is ! searched and what value is returned if the search fails. If the subject is ! zero-length, the search is made over extent(subject, base(subject)); but if ! non-zero, the search is limitied to the subject substring itself. When a ! search succeeds it matches a portion of the subject, and returns a marker for ! that portion; when a search fails it returns the empty substring at ! finish(subject). ! + For example, consider ! marker m := "abcdef" + Now search(m, "d") returns a marker for the fourth element of m and + search(start(m), "d") returns the same value. But search(m, "q") returns the + empty string finish(m) while search(start(m), "q") returns the empty string + start(m). + Two of the search functions, \italic{search}() and \italic{match}() treat ! their pattern argument as a string to be matched exactly in the subject (white space and the case of characters must all match exactly). The other three ! functions treat their pattern as a set of characters. For instance, in the expression *************** *** 355,363 **** the set has three characters and the expression will return a marker for the ! first character in base(x) after start(x) which is a period, question mark or ! exclamation point. If there is no such character, the expression returns an ! empty marker at the end of toend(x), which is the end of base(x). \indexi{search()}\description{\italic{search}(x, pat) - find the first --- 370,378 ---- the set has three characters and the expression will return a marker for the ! first character in toend(x) which is a period, question mark or exclamation ! point. If there is no such character, the expression returns an empty marker ! at finish(toend(x)), which is also the end of base(x). \indexi{search()}\description{\italic{search}(x, pat) - find the first *************** *** 364,375 **** instance of pat after start(x). ! \indexi{match()}\italic{match}(x, pat) - match pat only if it begins at ! start(x). ! \indexi{anyof()}\italic{anyof}(x, set) - find the first (single) character ! after start(x) that is one of the characters in the set. \indexi{span()}\italic{span}(x, set) - match start(x) and all contiguous --- 379,390 ---- instance of pat after start(x). ! \indexi{match()}\italic{match}(x, pat) - see if x begins with pat. This ! function succeeds only if all of pat is found. ! \indexi{anyof()}\italic{anyof}(x, set) - find the first character after ! start(x) that is one of the characters in the set. \indexi{span()}\italic{span}(x, set) - match start(x) and all contiguous *************** *** 379,401 **** \indexi{token()}\italic{token}(x, set) - find the first substring after start(x) which is composed of characters from set. This is equivalent to: ! \leftindent{\leftindent{function token(x, set) ! \leftindent{marker m := anyof (x, set) ! if m = "" then return m end if ! if x = "" then ! \leftindent{return span(toend(m), set)} ! else ! \leftindent{return span(extent(m, x), set)} ! end if} ! end function}}} regSearch(x, pat) - searches x for the regular expression pat. The regular --- 394,416 ---- \indexi{token()}\italic{token}(x, set) - find the first substring after start(x) which is composed of characters from set. This is equivalent to: ! \leftindent{\leftindent{\italic{function} \bold{token}(x, set) ! \leftindent{\italic{marker} m := anyof (x, set) ! \italic{if} m = "" \italic{then return} m \italic{end if} ! \italic{if} x = "" \italic{then} ! \leftindent{\italic{return} span(toend(m), set)} ! \italic{else} ! \leftindent{\italic{return} span(extent(m, x), set)} ! \italic{end if}} ! \italic{end function}}}} regSearch(x, pat) - searches x for the regular expression pat. The regular *************** *** 411,417 **** as documented with the `help search` command ($ANDREWDIR/help/search.help). In imitation of the usual Ness search convention, the search is delimited to x if it is non-empty BUT otherwise to extent(base(x), x), that is everything ! BEFORE x. \{\{Future: various sets of characters are provided as predefined identifiers: --- 426,432 ---- as documented with the `help search` command ($ANDREWDIR/help/search.help). In imitation of the usual Ness search convention, the search is delimited to x if it is non-empty BUT otherwise to extent(base(x), x), that is everything ! \italic{before} x. \{\{Future: various sets of characters are provided as predefined identifiers: *************** *** 1159,1169 **** name of a file, reads the file, and returns a marker for the entirety of a new string containing the contents. Note: if the file is read-only, the resulting string will be read-only. To convert a readonly string x to read-write, you ! can copy it with copy(x). \indexi{writefile()}\italic{writefile}(f, x) - interprets f as a filename, ! opens it, and writes to it the string referenced by x. Subsequent \italic{writefile}() calls to the same f will overwrite the file. --- 1174,1187 ---- name of a file, reads the file, and returns a marker for the entirety of a new string containing the contents. Note: if the file is read-only, the resulting string will be read-only. To convert a readonly string x to read-write, you ! can copy it with copy(x). If the file cannot be read or is not in ATK format, ! a message is written to standard error and the program continues with whatever ! could be read from the file. \indexi{writefile()}\italic{writefile}(f, x) - interprets f as a filename, ! opens it, and writes to it the string referenced by x. Returns the value x. ! If the file cannot written, the return value is start(x). Subsequent \italic{writefile}() calls to the same f will overwrite the file. *************** *** 1581,1587 **** name with updated enumeration values. } - \bold{\index{tokens.n}}: scans tokens from source files \leftindent{ --- 1599,1604 ---- *************** *** 1626,1632 **** views. This menu option wraps lines in the text of the current selection.} - \bold{\index{swap.n}}: This is a demonstration package. --- 1643,1648 ---- *************** *** 1634,1640 **** selected text from defaulttext to be after the word that formerly preceded it.} - \bold{\index{sort.n}}: sort the records of a data base. See the comments in the file for the format of records. See /usr/andrew/lib/ness/demos/Birth.db for an example. --- 1650,1655 ---- *************** *** 1656,1664 **** If -f is omitted, records are sorted by their whole text. The output file is written to the same name as the input, but with the additional ! extension ".sorted". - } \bold{\index{unscribe.n}}: convert Scribe styles to ATK styles. There is a table in the program so users can copy the program and change the styles to --- 1671,1678 ---- If -f is omitted, records are sorted by their whole text. The output file is written to the same name as the input, but with the additional ! extension ".sorted".} \bold{\index{unscribe.n}}: convert Scribe styles to ATK styles. There is a table in the program so users can copy the program and change the styles to *************** *** 1674,1680 **** ".d", a new ".d" is appended to the name. The old version of the output file is saved as filename.d.BAK - } \bold{\index{wc.n}}: count words --- 1688,1693 ---- *************** *** 1714,1723 **** instead of doing a backspace.} - \bold{date.n} - convert dates to and from a canonical form - \leftindent{The function date_canonical() converts many forms of date into a canonical representation. Four other functions convert the canonical form to convenient forms. --- 1727,1735 ---- instead of doing a backspace.} + \bold{date.n}: convert dates to and from a canonical form \leftindent{The function date_canonical() converts many forms of date into a canonical representation. Four other functions convert the canonical form to convenient forms. *************** *** 1832,1835 **** 32340 -- canonical date integer ! \enddata{text,269507256} --- 1844,1875 ---- 32340 -- canonical date integer ! ! \bold{octalimage.n}: convert integer to octal string ! ! \leftindent{\italic{ ! octalimage_cvt}(integer i) - returns string for i, padded on left with zeroes ! to at least three digits} ! ! ! \bold{fileconvert.n}: skeleton fileconversion package ! ! ! \leftindent{This file is a prototypical file converter. To specialize it for ! any specific conversion, the porition identified with $$$ need to be replaced. ! ! ! \italic{fileconvert_convert}() - converts currentselection(defaulttext) ! ! } ! \bold{ctype.n}: case translation functions ! ! ! \leftindent{\italic{ctype_tolower}(m) - Modifies the text referenced by m, ! replacing all upper case letters with the corresponding lower case letters. ! ! ! \italic{ctype_toupper}(m) - Modifies the text referenced by m, replacing all ! lower case letters with the corresponding upper case letters.} ! ! \enddata{text,269903968} *** atk/raster/cmd/Imakefile Fri Dec 21 14:57:39 1990 --- atk/raster/cmd/Imakefile.NEW Thu Jun 13 16:21:01 1991 *************** *** 2,7 **** --- 2,11 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ + #if defined(sys_ps_aix12) || defined(sys_ps_aix11) + CDEBUGFLAGS = + #endif + DOBJS = raster.do rastimg.do rasterv.do IHFILES = raster.ih rastimg.ih rasterv.ih *** atk/raster/cmd/rasterv.c Fri Dec 21 14:57:54 1990 --- atk/raster/cmd/rasterv.c.NEW Thu May 23 12:25:23 1991 *************** *** 2,13 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/raster/cmd/RCS/rasterv.c,v 2.25 90/11/07 14:10:45 gk5g Exp $ */ /* $ACIS:rasterv.c 1.3$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/raster/cmd/RCS/rasterv.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/raster/cmd/RCS/rasterv.c,v 2.25 90/11/07 14:10:45 gk5g Exp $"; #endif /* lint */ /* Added X Window Dump read/write menu options -paul@athena.mit.edu 3/7/90; Added X Bitmap read/write menu options - paul@athena.mit.edu 5/16/90 */ --- 2,13 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/raster/cmd/RCS/rasterv.c,v 2.26 90/11/28 14:42:23 susan Exp $ */ /* $ACIS:rasterv.c 1.3$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/raster/cmd/RCS/rasterv.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/raster/cmd/RCS/rasterv.c,v 2.26 90/11/28 14:42:23 susan Exp $"; #endif /* lint */ /* Added X Window Dump read/write menu options -paul@athena.mit.edu 3/7/90; Added X Bitmap read/write menu options - paul@athena.mit.edu 5/16/90 */ *************** *** 49,54 **** --- 49,55 ---- */ + #include /* strings.h */ #include #include #include *************** *** 57,63 **** #include #include - #include /* strings.h */ #include /* Defines MAXPATHLEN among other things */ #include --- 58,63 ---- *** atk/raster/cmd/rastvaux.c Fri Dec 21 14:58:03 1990 --- atk/raster/cmd/rastvaux.c.NEW Wed Apr 3 21:21:11 1991 *************** *** 2,11 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/raster/cmd/RCS/rastvaux.c,v 1.1 90/11/07 14:11:49 gk5g Exp $ */ /* $ACIS: $ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/raster/cmd/RCS/rastvaux.c,v $ */ #include #define AUXMODULE 1 #include --- 2,12 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/raster/cmd/RCS/rastvaux.c,v 1.2 90/11/28 14:42:48 susan Exp $ */ /* $ACIS: $ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/raster/cmd/RCS/rastvaux.c,v $ */ + #include /* strings.h */ #include #define AUXMODULE 1 #include *************** *** 15,21 **** #include #include #include - #include /* strings.h */ #include /* Defines MAXPATHLEN among other things */ #include #include --- 16,21 ---- *** atk/raster/convert/Imakefile Thu Jan 10 14:57:49 1991 --- atk/raster/convert/Imakefile.NEW Wed Apr 3 21:21:16 1991 *************** *** 4,13 **** --- 4,21 ---- \* ********************************************************************** */ OBJS = convrast.o + #ifdef RESOLVER_ENV + #ifdef LIBDL_ENV + SYS_LIBS = -lresolv + RESOLVER_LIB = + #else RESOLVER_LIB = $(RESOLVLIB) + SYS_LIBS = + #endif /* LIBDL_ENV */ #else RESOLVER_LIB = + SYS_LIBS = #endif LIBS = $(BASEDIR)/lib/atk/libbasics.a \ *************** *** 19,25 **** NormalObjectRule() ! ProgramTarget(convertraster, convrast.o, $(LIBS), ) InstallProgram(convertraster, $(DESTDIR)/bin) --- 27,33 ---- NormalObjectRule() ! ProgramTarget(convertraster, convrast.o, $(LIBS), $(SYS_LIBS) $(NETLIBS)) InstallProgram(convertraster, $(DESTDIR)/bin) *** atk/raster/convert/convras.help Wed Apr 11 14:20:24 1990 --- atk/raster/convert/convras.help.NEW Wed Feb 13 16:53:27 1991 *************** *** 1,4 **** ! \begindata{text,269004988} \textdsversion{12} \template{help} \define{index --- 1,4 ---- ! \begindata{text,269344660} \textdsversion{12} \template{help} \define{index *************** *** 27,44 **** MacPaint (can be abbreviated mp, macp) \bold{RF} the old ITC binary RasterFile format (can be abbreviated RF, ! rasterfile, ras) }}\leftindent{\leftindent{ \bold{raster} the Andrew Toolkit raster format (can be abbreviated raster, be2) \bold{PostScript} print data stream (can be abbreviated ps); supported only ! for output}} ! \bold{Xwd} the X Window Dump format produced by xwd (can be abbreviated xwd) ! } \section{Using Convertraster} --- 27,46 ---- MacPaint (can be abbreviated mp, macp) \bold{RF} the old ITC binary RasterFile format (can be abbreviated RF, ! rasterfile, ras) \bold{raster} the Andrew Toolkit raster format (can be abbreviated raster, be2) \bold{PostScript} print data stream (can be abbreviated ps); supported only ! for output ! \bold{Xwindow} the X Window Dump format produced by xwd (can be abbreviated xwd) ! \bold{Xbitmap} the X bitmap format as used in the creation of icons etc. ! ! }}} \section{Using Convertraster} *************** *** 153,169 **** The extension on the filename must match the \bold{outtype} argument: ! \leftindent{.raster for Andrew Toolkit (be2) format ! .ras for old RasterFile format ! .mp for MacPaint format} ! \leftindent{.xwd for X Window Dump format} ! \leftindent{.ps for Postscript} ! } \section{Bugs} --- 155,173 ---- The extension on the filename must match the \bold{outtype} argument: ! \leftindent{.raster for Andrew Toolkit (be2) format ! .ras for old RasterFile format ! .mp for MacPaint format ! .xwd for X Window Dump format ! .bitmap for X bitmap format. ! .ps for Postscript ! ! }} \section{Bugs} *************** *** 198,201 **** xwd ! }}\enddata{text,269004988} --- 202,206 ---- xwd ! }} ! \enddata{text,269344660} *** atk/raster/lib/Imakefile Fri Dec 21 14:58:10 1990 --- atk/raster/lib/Imakefile.NEW Wed Apr 3 21:21:23 1991 *************** *** 30,35 **** --- 30,36 ---- NormalATKRule() DynamicObject(heximage, , -lm) + DynamicObject(oldrf, , ${NETLIBS}) InstallClassFiles($(DOBJS),$(IHFILES)) *** atk/raster/lib/xwdio.c Fri Dec 21 14:58:11 1990 --- atk/raster/lib/xwdio.c.NEW Wed Feb 13 16:53:35 1991 *************** *** 1,3 **** --- 1,17 ---- + /* + Copyright MIT 1990, 1991 - All Rights Reserved + */ + + /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/raster/lib/RCS/xwdio.c,v 1.6 91/02/12 15:18:50 gk5g Exp $ */ + /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/raster/lib/RCS/xwdio.c,v $ */ + /* $Author: gk5g $ */ + + #ifndef lint + static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/raster/lib/RCS/xwdio.c,v 1.6 91/02/12 15:18:50 gk5g Exp $"; + #endif /* lint */ + + #include + /* Enable import and export of X Window Dump (version 7) files paul@athena.mit.edu 1/90 *************** *** 4,13 **** "...it becomes natural, like a third sense." -- Homer Simpson */ - #include #include #include - #include /* NECESSARY? */ #include #include #include --- 18,26 ---- "...it becomes natural, like a third sense." -- Homer Simpson */ #include + #include #include #include #include #include *************** *** 30,45 **** return dataobject_NOREADERROR; } ! void xwdio__WriteRow(ClassID, file, row, nbits) struct classhdr *ClassID; FILE *file; unsigned char *row; ! long nbits; { unsigned char reversebuf[BUFBITS >> 3]; - long nbytes = (nbits + 7) >> 3; reverse_video(row, reversebuf, nbytes); fwrite(reversebuf, nbytes, 1, file); --- 43,57 ---- return dataobject_NOREADERROR; } ! void xwdio__WriteRow(ClassID, file, row, nbytes) struct classhdr *ClassID; FILE *file; unsigned char *row; ! long nbytes; { unsigned char reversebuf[BUFBITS >> 3]; reverse_video(row, reversebuf, nbytes); fwrite(reversebuf, nbytes, 1, file); *************** *** 79,90 **** if (swap) _swaplong((char *) &hdr, sizeof(hdr)); - /* Waiting for pixmap_to_bitmap to be incorporated */ - /* Dither color pixmaps to bitmaps, - NOT DONE YET */ - /* Pur error messages for common unsupported types, - NOT DONE YET */ - if (hdr.pixmap_depth == 8 && hdr.pixmap_format == ZPixmap) reduce_pixmap = TRUE; else if (hdr.pixmap_depth == 8 && hdr.pixmap_format == XYPixmap) --- 91,96 ---- *************** *** 109,127 **** - #if 0 - - /* Complain about unsupported types of xwd */ - - if (hdr.pixmap_depth != 1) - { - fprintf(stderr, "Window dump has %d bits per pixel -- only 1 bit per pixel is supported \n",hdr.pixmap_depth); - fflush(stderr); - return dataobject_BADFORMAT; - } - - #endif - win_name_size = (hdr.header_size - sizeof(hdr)); fread(win_name, sizeof(char), win_name_size, file); --- 115,120 ---- *************** *** 151,167 **** pixelimage_Resize(pix, (rowsize * 8), hdr.pixmap_height); row = pixelimage_GetBitsPtr(pix); ! /* read the actual pixelimage */ if (reduce_pixmap) { /* 8-bit ZPixmap version */ for (rownum = 0; rownum < hdr.pixmap_height; ! rownum++, row += hdr.pixmap_width) { xwdio_ReadRow(file, row, rowsize); ! if (!hdr.bitmap_bit_order) ! reverse_bit_order(row, row, rowsize); pixmap_to_bitmap(row, row, rowsize); } } --- 144,164 ---- pixelimage_Resize(pix, (rowsize * 8), hdr.pixmap_height); row = pixelimage_GetBitsPtr(pix); ! /* read the actual pixelimage ! Note that rows must be padded out to short-word (16-bit) multiples since pixelimage__Create does so when setting size for efficient handling, otherwise image would be skewed by eight bits per line */ + if (reduce_pixmap) { /* 8-bit ZPixmap version */ for (rownum = 0; rownum < hdr.pixmap_height; ! rownum++, row += ((rowsize + 1) / 2) * 2) { xwdio_ReadRow(file, row, rowsize); ! pixmap_to_bitmap(row, row, rowsize); + reverse_bit_order(row, row, rowsize); + + } } *************** *** 168,174 **** else { /* bitmap version */ for (rownum = 0; rownum < hdr.pixmap_height; ! rownum++, row += rowsize) { /* modify image directly, since it is useless in byte-swapped negative-image form --- 165,171 ---- else { /* bitmap version */ for (rownum = 0; rownum < hdr.pixmap_height; ! rownum++, row += ((rowsize +1) / 2) * 2) { /* modify image directly, since it is useless in byte-swapped negative-image form *************** *** 285,291 **** for (row = top; row < top + height; row++) { pixelimage_GetRow(pix, left, row, width, buf); ! xwdio_WriteRow(file, (unsigned char *)buf, width); } } --- 282,288 ---- for (row = top; row < top + height; row++) { pixelimage_GetRow(pix, left, row, width, buf); ! xwdio_WriteRow(file, (unsigned char *)buf, bytes_per_row); } } *************** *** 371,377 **** } - /* This routine comes from Brian Michon and hasn't been modified and incorporated yet. It converts 8-bit pixmaps to bitmaps */ pixmap_to_bitmap(location, output, nbytes) unsigned char *location, *output; --- 368,373 ---- *************** *** 379,392 **** { register int x, c, b; ! /* ! * The slow but robust brute force method of converting the image: ! */ c = 0; b = 1; for (x = 0; x < nbytes;) { ! if (*(location + x)) ! c |= b; b <<= 1; if (!(++x & 7)) { --- 375,388 ---- { register int x, c, b; ! /* Simple method: take each byte (which represents a pixel), and convert ! it to a 0 if it is 0 or a 1 if it is any othre value, and make one byte out ! of each eight such converted values */ ! c = 0; b = 1; for (x = 0; x < nbytes;) { ! if (*(location + x)) c |= b; b <<= 1; if (!(++x & 7)) { *** atk/raster/lib/xwdio.ch Fri Aug 3 16:41:40 1990 --- atk/raster/lib/xwdio.ch.NEW Wed Feb 13 16:53:37 1991 *************** *** 2,26 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/raster/lib/RCS/xwdio.ch,v 1.1 90/03/15 12:43:40 gk5g Exp $ */ /* $ACIS:xwdio.ch 1.3$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/raster/lib/RCS/xwdio.ch,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsidxwdio_H = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/raster/lib/RCS/xwdio.ch,v 1.1 90/03/15 12:43:40 gk5g Exp $"; #endif /* !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) */ ! /* xwdio.H ! xwdio package - Routines for reading and writing rasters in the old ITC format - as defined by rastfile.h - - The data stream begins with a 14 or 16 byte header, - which is followed by the bits of the data. - */ #include --- 2,22 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/raster/lib/RCS/xwdio.ch,v 1.2 91/02/12 15:19:27 gk5g Exp $ */ /* $ACIS:xwdio.ch 1.3$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/raster/lib/RCS/xwdio.ch,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsidxwdio_H = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/raster/lib/RCS/xwdio.ch,v 1.2 91/02/12 15:19:27 gk5g Exp $"; #endif /* !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) */ + /* xwdio.ch ! xwdio package ! Routines for reading and writing rasters in X Window Dump (V7) ! as defined by XWDFile.h */ #include *************** *** 31,51 **** package xwdio[xwdio] { ! classprocedures: ! ! WriteRow(FILE *file, unsigned char *byteaddr, long nbytes); ! /* write to 'file' the xwdio form representation of the 'nbytes' ! bytes starting at location 'byteaddr' */ ! ! ReadRow(FILE *file, unsigned char *row, long length) returns long; ! /* Reads from 'file' the encoding of bytes to fill in 'row'. Row will be ! truncated or padded (with WHITE) to exactly 'length' bytes. ! */ ! ReadImage(FILE *file, struct pixelimage *pix) returns long; ! /* Read a raster image from 'file' and put it in 'pix' ! return error code */ ! WriteImage(FILE *file, struct pixelimage *pix, struct rectangle *sub); ! /* Write a raster image to 'file' from 'pix' */ }; --- 27,50 ---- package xwdio[xwdio] { ! classprocedures: ! WriteRow(FILE *file, unsigned char *byteaddr, long nbytes); ! /* Write 'nbytes' bytes starting at 'byteaddr' ! into 'file' in X Window Dump image format, ! after the header is written. */ ! ! ReadRow(FILE *file, unsigned char *row, long nbytes) returns long; ! /* Read 'nbytes' bytes from 'file' into ! positions starting at 'row', after the ! header is read; there is usually some ! padding in the last byte of each row, ! but the image is resized after all rows ! are read to remove it. */ ! ReadImage(FILE *file, struct pixelimage *pix) returns long; ! /* Read an X Window Dump from 'file' and ! put it in 'pix,' return error code */ ! WriteImage(FILE *file, struct pixelimage *pix, struct rectangle *sub); ! /* Write an X Window Dump to 'file' from subrectangle 'sub' of pixelimage 'pix' */ }; *** atk/raster/lib/xbm.c Fri Dec 21 14:58:15 1990 --- atk/raster/lib/xbm.c.NEW Wed Feb 13 16:53:38 1991 *************** *** 5,18 **** most of this code was stolen from the old 'x2wm' and wm2x' programs */ - #include #include #include #include - #include - #include #include #include #if !defined(vax) /* --- 5,18 ---- most of this code was stolen from the old 'x2wm' and wm2x' programs */ #include + #include + #include #include #include #include #include + #include #if !defined(vax) /* *************** *** 67,74 **** unsigned char *location; long width, height, byte, value,bytewidth, i; char name[64], bits[64], *t; - char *rindex(); - /* get width (in pixels) and height fields from top of bitmap file */ for (i=0; i<2; i++) --- 67,72 ---- *************** *** 113,121 **** } *location++ = flipbits[(unsigned char)byte]; ! /*pixelimage_create rounds row widths to short-word multiples (16 bits) for more efficient handling. ! Bitmap files only round to nearest byte (8 bits), so ! if the row ends somewhere in the first 8 bits of a word, the bitmap file will not have a second empty byte to pad that word out -- we must insert one into the end of the row or the image will be skewed left by one pixel per subsequent line */ if ( i % bytewidth == (bytewidth - 1) && 0 < width % 16 && 8 >= width % 16) --- 111,117 ---- } *location++ = flipbits[(unsigned char)byte]; ! /* pixelimage_create rounds row widths to short-word (16-bit) multiples for more efficient handling. Bitmap files only round to nearest byte (8 bits), so if the row ends somewhere in the first 8 bits of a word, pad that row out to the next 16-bit multiple */ if ( i % bytewidth == (bytewidth - 1) && 0 < width % 16 && 8 >= width % 16)