*** atk/rofftext/Imakefile Wed Nov 22 12:27:54 1989 --- atk/rofftext/Imakefile.NEW Thu Jun 13 15:34:45 1991 *************** *** 2,14 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! DOBJS = hash.do rofftext.do rofftxta.do ! IHFILES = hash.ih rofftext.ih rofftxta.ih NormalObjectRule() NormalATKRule() NormalYaccRule() DynamicMultiObject(rofftext.do, rofftext.o roffcmds.o roffutil.o roffstyl.o num.o roffchrs.o,,) InstallClassFiles($(DOBJS),$(IHFILES)) --- 2,20 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! DOBJS = hash.do rofftext.do rofftxta.do mmtext.do mantext.do ! IHFILES = hash.ih rofftext.ih rofftxta.ih mmtext.ih mantext.ih NormalObjectRule() NormalATKRule() NormalYaccRule() + tmac.m: tmac.mm + tr "~" "\7" tmac.m + + clean:: + rm tmac.m + DynamicMultiObject(rofftext.do, rofftext.o roffcmds.o roffutil.o roffstyl.o num.o roffchrs.o,,) InstallClassFiles($(DOBJS),$(IHFILES)) *************** *** 16,22 **** --- 22,32 ---- InstallLink(runapp, ${DESTDIR}/bin/rofftext) InstallFile(roff.tpl, ${INSTINCFLAGS}, ${DESTDIR}/lib/tpls) + InstallFile(mmtext.tpl, ${INSTINCFLAGS}, ${DESTDIR}/lib/tpls) + InstallFile(mantext.tpl, ${INSTINCFLAGS}, ${DESTDIR}/lib/tpls) + InstallFile(tmac.m, ${INSTINCFLAGS}, ${DESTDIR}/lib/tmac) + DependTarget() MkdirTarget(${DESTDIR}/doc/atk/rofftext) NormalHelpRule() *************** *** 33,36 **** num.o: ${BASEDIR}/include/atk/text.ih num.o: ${BASEDIR}/include/atk/dataobj.ih num.o: ${BASEDIR}/include/atk/observe.ih - --- 43,45 ---- *** atk/rofftext/roffcmds.c Wed Apr 11 14:20:48 1990 --- atk/rofftext/roffcmds.c.NEW Mon May 6 20:57: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/rofftext/RCS/roffcmds.c,v 2.8 90/03/22 11:23:40 ajp Exp $ */ /* $ACIS: $ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/rofftext/RCS/roffcmds.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/rofftext/RCS/roffcmds.c,v 2.8 90/03/22 11:23:40 ajp Exp $ "; #endif /* lint */ /* rofftext --- 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/rofftext/RCS/roffcmds.c,v 2.10 1991/05/06 19:01:32 rr2b Exp $ */ /* $ACIS: $ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/rofftext/RCS/roffcmds.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/rofftext/RCS/roffcmds.c,v 2.10 1991/05/06 19:01:32 rr2b Exp $ "; #endif /* lint */ /* rofftext *************** *** 15,24 **** * Commands */ #include #include #include ! #include /* strings.h */ #include #include #include --- 15,27 ---- * Commands */ + #include /* strings.h */ #include #include #include ! #include ! #include ! #include #include #include #include *************** *** 64,71 **** Add2Buf(b,'\0'); self->v_CopyMode = tmp; ! DEBUG((stderr,"Defining string (%s) as (%s)\n",name,Buf2Str(b))); putstring(self,name,Buf2Str(b)); } /* rename or remove request, string, macro */ --- 67,118 ---- Add2Buf(b,'\0'); self->v_CopyMode = tmp; ! DEBUG(1, (stderr,"Defining string (%s) as (%s)\n",name,Buf2Str(b))); ! putstring(self,name,Buf2Str(b)); ! } ! ! /* append to string */ ! as_cmd(self,t,br,argc,argv) ! struct rofftext *self; ! Trickle t; ! boolean br; ! int argc; ! char *argv[]; ! { ! register int c; ! static BUF b = NULL; ! char name[3]; ! char *init; ! boolean tmp = self->v_CopyMode; ! ! b = NewBuf(); ! ! getarg(self,t,name,2,0); ! if (*name == '\n') ! return; ! ! ClearBuf(b); ! init = getstring(self, name); ! while(*init) Add2Buf(b, *init++); ! ! self->v_CopyMode = TRUE; ! /* read whitespace */ ! while((c = get(self,t)) == ' ' || c == '\t'); ! ! if (c == '\"') /* strip leading quote */ ! c = get(self,t); ! ! /* read string */ ! while((c != '\n') && (c != EOF)) { ! Add2Buf(b,c); ! c = get(self,t); ! } ! Add2Buf(b,'\0'); ! self->v_CopyMode = tmp; ! ! DEBUG(1, (stderr,"Appending to string (%s) becoming (%s)\n",name,Buf2Str(b))); putstring(self,name,Buf2Str(b)); + FreeBuf(b); } /* rename or remove request, string, macro */ *************** *** 86,92 **** value = hash_Lookup(self->Macros,argv[1]); if (value) { ! DEBUG((stderr,"%s string (%s)",str,argv[1])); if (rename) { v=hash_Rename(self->Macros,argv[1],argv[2]); v += (int)hash_Rename(self->Commands,argv[1],argv[2]); --- 133,139 ---- value = hash_Lookup(self->Macros,argv[1]); if (value) { ! DEBUG(1, (stderr,"%s string (%s)",str,argv[1])); if (rename) { v=hash_Rename(self->Macros,argv[1],argv[2]); v += (int)hash_Rename(self->Commands,argv[1],argv[2]); *************** *** 96,107 **** v += (int)hash_Delete(self->Commands,argv[1]); free(value); } ! DEBUG((stderr,"%s\n",(v?"succeeded":"FAILED ***"))); return; } value = hash_Lookup(self->Commands,argv[1]); if (value) { ! DEBUG((stderr,"%s string (%s)",str,argv[1])); if (rename) v=hash_Rename(self->Commands,argv[1],argv[2]); else { --- 143,154 ---- v += (int)hash_Delete(self->Commands,argv[1]); free(value); } ! DEBUG(1, (stderr,"%s\n",(v?"succeeded":"FAILED ***"))); return; } value = hash_Lookup(self->Commands,argv[1]); if (value) { ! DEBUG(1, (stderr,"%s string (%s)",str,argv[1])); if (rename) v=hash_Rename(self->Commands,argv[1],argv[2]); else { *************** *** 108,117 **** v=hash_Delete(self->Commands,argv[1]); free(value); } ! DEBUG((stderr,"%s\n",(v?"succeeded":"FAILED ***"))); return; } ! DEBUG((stderr,"RENAME/DELETE: (%s) NOT FOUND\n",argv[1])); } --- 155,164 ---- v=hash_Delete(self->Commands,argv[1]); free(value); } ! DEBUG(1, (stderr,"%s\n",(v?"succeeded":"FAILED ***"))); return; } ! DEBUG(1, (stderr,"RENAME/DELETE: (%s) NOT FOUND\n",argv[1])); } *************** *** 133,139 **** else inc = 0; ! DEBUG((stderr,"Defining register (%s) as (%d)\n",argv[1],value)); putregister(self,argv[1],value,0,inc,relative); } --- 180,186 ---- else inc = 0; ! DEBUG(1, (stderr,"Defining register (%s) as (%d) inc (%d) rel (%d)\n",argv[1],value, inc, relative)); putregister(self,argv[1],value,0,inc,relative); } *************** *** 187,194 **** boolean br; int argc; char *argv[]; ! { ! } --- 234,241 ---- boolean br; int argc; char *argv[]; ! { ! hash_Delete(self->Registers, argv[1]); } *************** *** 213,220 **** int argc; char *argv[]; { ! if (br) ! DoBreak(self); } /* exit be2roff ??? */ --- 260,266 ---- int argc; char *argv[]; { ! DoBreak(self); } /* exit be2roff ??? */ *************** *** 238,244 **** { char *macro = hash_Lookup(self->Macros,argv[0]); ! DEBUG((stderr,"v-----Calling Macro named (%s)-------v\n",argv[0])); tpush(self,t,NULL,NULL,macro,TRUE,argc,argv); } --- 284,290 ---- { char *macro = hash_Lookup(self->Macros,argv[0]); ! DEBUG(1, (stderr,"v-----Calling Macro named (%s)-------v\n",argv[0])); tpush(self,t,NULL,NULL,macro,TRUE,argc,argv); } *************** *** 257,273 **** static BUF b = NULL; char *oldValue; ! if (b == NULL) ! b = NewBuf(); ! ClearBuf(b); self->v_CopyMode = TRUE; ! self->v_SnarfOutput = b; Scan(self,t,((argc<3)?".":end)); ! self->v_SnarfOutput = NULL; self->v_CopyMode = FALSE; Add2Buf(b,'\0'); --- 303,317 ---- static BUF b = NULL; char *oldValue; ! b = NewBuf(); ClearBuf(b); self->v_CopyMode = TRUE; ! self->CurrentDiversion->SnarfOutput = b; Scan(self,t,((argc<3)?".":end)); ! self->CurrentDiversion->SnarfOutput = NULL; self->v_CopyMode = FALSE; Add2Buf(b,'\0'); *************** *** 278,284 **** if (existing) free(existing); ! DEBUG((stderr,"--Defining Macro (%s)--\n",name)); oldValue = hash_Delete(self->Macros, name); if (oldValue != NULL) { --- 322,328 ---- if (existing) free(existing); ! DEBUG(1, (stderr,"--Defining Macro (%s)--\n",name)); oldValue = hash_Delete(self->Macros, name); if (oldValue != NULL) { *************** *** 285,297 **** free(oldValue); } hash_Store(self->Macros,name,macro); - hash_Delete(self->Commands, name); hash_Store(self->Commands,name,DoMacro); free(name); free(end); ! /* DEBUG((stderr,"%s\n<----------------\n",macro));*/ } /* divert output into a macro */ --- 329,385 ---- free(oldValue); } hash_Store(self->Macros,name,macro); hash_Store(self->Commands,name,DoMacro); free(name); free(end); ! FreeBuf(b); ! /* DEBUG(1, (stderr,"%s\n<----------------\n",macro));*/ } + /* append to macro */ + am_cmd(self,t,br,argc,argv) + struct rofftext *self; + Trickle t; + boolean br; + int argc; + char *argv[]; + { + char *macro,*existing,*name = StrDup(argv[1]); + char *end = StrDup(argv[2]); + char *init; + BUF b; + + b = NewBuf(); + + ClearBuf(b); + init = getstring(self, name); + while(*init) Add2Buf(b, *init++); + + self->v_CopyMode = TRUE; + self->CurrentDiversion->SnarfOutput = b; + + Scan(self,t,((argc<3)?".":end)); + + self->CurrentDiversion->SnarfOutput = NULL; + self->v_CopyMode = FALSE; + Add2Buf(b,'\0'); + + macro = StrDup(Buf2Str(b)); + + hash_Delete(self->Commands,name); + existing = hash_Delete(self->Macros,name); + if (existing) + free(existing); + + DEBUG(1, (stderr,"--Appending To Macro (%s)--\n",name)); + + hash_Store(self->Macros,name,macro); + hash_Store(self->Commands,name,DoMacro); + free(name); + free(end); + FreeBuf(b); + /* DEBUG(1, stderr,"---%s\n<----------------\n",macro);*/ + } /* divert output into a macro */ *************** *** 306,329 **** static BUF b = NULL; char *existing; ! if (b == NULL) ! b = NewBuf(); if (argc > 1) { ClearBuf(b); ! DEBUG((stderr,"--Diverting to Macro (%s)------>\n",argv[1])); /* tmp = self->v_CopyMode; self->v_CopyMode = TRUE;*/ - self->v_SnarfOutput = b; PushDiversion(self); self->CurrentDiversion->name = StrDup(argv[1]); } else{ if (self->v_DiversionLevel > 0) { ! self->v_SnarfOutput = NULL; /* self->v_CopyMode = tmp;*/ Add2Buf(b,'\0'); --- 394,417 ---- static BUF b = NULL; char *existing; ! b = NewBuf(); if (argc > 1) { ClearBuf(b); ! DEBUG(1, (stderr,"--Diverting to Macro (%s)------>\n",argv[1])); /* tmp = self->v_CopyMode; self->v_CopyMode = TRUE;*/ PushDiversion(self); + self->CurrentDiversion->SnarfOutput = b; self->CurrentDiversion->name = StrDup(argv[1]); } else{ if (self->v_DiversionLevel > 0) { ! b = self->CurrentDiversion->SnarfOutput; ! self->CurrentDiversion->SnarfOutput = NULL; /* self->v_CopyMode = tmp;*/ Add2Buf(b,'\0'); *************** *** 336,347 **** hash_Store(self->Macros,self->CurrentDiversion->name,macro); hash_Store(self->Commands,self->CurrentDiversion->name,DoMacro); ! DEBUG((stderr,"\n<----------------divert (%s)\n",self->CurrentDiversion->name)); PopDiversion(self); } } } /* debugging */ c0_cmd(self,t,br,argc,argv) --- 424,490 ---- hash_Store(self->Macros,self->CurrentDiversion->name,macro); hash_Store(self->Commands,self->CurrentDiversion->name,DoMacro); ! DEBUG(1, (stderr,"\n<----------------divert (%s)\n",self->CurrentDiversion->name)); PopDiversion(self); + FreeBuf(b); + putregister(self, "dn", 1, reg_Single, 0, 0); } } } + /* divert and append output into a macro */ + da_cmd(self,t,br,argc,argv) + struct rofftext *self; + Trickle t; + boolean br; + int argc; + char *argv[]; + { + char *macro; + char *existing; + char *init; + BUF b; + + b = NewBuf(); + + if (argc > 1) { + + ClearBuf(b); + + init = getstring(self, argv[1]); + while(*init) Add2Buf(b, *init++); + DEBUG(1, (stderr,"--Diverting and appending to Macro (%s)---(%d)--->\n",argv[1], self->v_DiversionLevel)); + + /* tmp = self->v_CopyMode; + self->v_CopyMode = TRUE;*/ + PushDiversion(self); + self->CurrentDiversion->SnarfOutput = b; + self->CurrentDiversion->name = StrDup(argv[1]); + } + else{ + if (self->v_DiversionLevel > 0) { + b = self->CurrentDiversion->SnarfOutput; + self->CurrentDiversion->SnarfOutput = NULL; + /* self->v_CopyMode = tmp;*/ + Add2Buf(b,'\0'); + + macro = StrDup(Buf2Str(b)); + + existing = (char *)hash_Delete(self->Macros,self->CurrentDiversion->name); + if (existing) + free(existing); + hash_Delete(self->Commands,self->CurrentDiversion->name); + + hash_Store(self->Macros,self->CurrentDiversion->name,macro); + hash_Store(self->Commands,self->CurrentDiversion->name,DoMacro); + DEBUG(1, (stderr,"\n<----------------divert (%s)\n",self->CurrentDiversion->name)); + PopDiversion(self); + FreeBuf(b); + putregister(self, "dn", 1, reg_Single, 0, 0); + } + } + } + /* debugging */ c0_cmd(self,t,br,argc,argv) *************** *** 380,387 **** int dresult; static BUF b = NULL; ! if (b == NULL) ! b = NewBuf(); /* read leading whitespace */ do { --- 523,529 ---- int dresult; static BUF b = NULL; ! b = NewBuf(); /* read leading whitespace */ do { *************** *** 396,402 **** c = get(self,t); } while((c==' ')||(c=='\t')); } ! if (isdigit(c)) { /* numeric compare */ ClearBuf(b); while((c!= ' ') && (c != '\t') && (c != '\n')) { Add2Buf(b,c); --- 538,544 ---- c = get(self,t); } while((c==' ')||(c=='\t')); } ! if (isdigit(c) || c == '(') { /* numeric compare */ ClearBuf(b); while((c!= ' ') && (c != '\t') && (c != '\n')) { Add2Buf(b,c); *************** *** 404,410 **** } Add2Buf(b,'\0'); str = Buf2Str(b); ! DEBUG((stderr,"Comparing numeric value (%s)\n",str)); EvalString(self,str,&dresult,scale_u,NULL,NULL); result = (dresult > 0); } --- 546,552 ---- } Add2Buf(b,'\0'); str = Buf2Str(b); ! DEBUG(1, (stderr,"Comparing numeric value (%s)\n",str)); EvalString(self,str,&dresult,scale_u,NULL,NULL); result = (dresult > 0); } *************** *** 435,441 **** } Add2Buf(b,'\0'); str = Buf2Str(b); ! DEBUG((stderr,"====>if: delim '%c', string argument is (%s)\n",delim,str)); string2 = index(str,delim); --- 577,583 ---- } Add2Buf(b,'\0'); str = Buf2Str(b); ! DEBUG(1, (stderr,"====>if: delim '%c', string argument is (%s)\n",delim,str)); string2 = index(str,delim); *************** *** 444,450 **** else { *string2++ = '\0'; } ! DEBUG((stderr,"Comparing (%s) (%s)\n",str,string2)); result = (strcmp(str,string2)==0); break; --- 586,592 ---- else { *string2++ = '\0'; } ! DEBUG(1, (stderr,"Comparing (%s) (%s)\n",str,string2)); result = (strcmp(str,string2)==0); break; *************** *** 453,467 **** } ClearBuf(b); ! DEBUG((stderr,"if: sense %d, result %d\n",sense,result)); /* if condition is false, munch to end of conditional input */ if (result == sense) { self->v_RawMode = TRUE; ! DEBUG((stderr,"-->Munch->")); ! while(c != EOF && ((c != '\n') || (self->v_InCond > 0))) { c = get(self,t); } ! DEBUG((stderr,"<-Munch<--")); self->v_RawMode = FALSE; } else { --- 595,610 ---- } ClearBuf(b); ! DEBUG(1, (stderr,"if: sense %d, result %d\n",sense,result)); /* if condition is false, munch to end of conditional input */ if (result == sense) { + int oldlev = self->v_InCond; self->v_RawMode = TRUE; ! DEBUG(1, (stderr,"-->Munch->")); ! while(c != EOF && ((c != '\n') || (self->v_InCond > oldlev))) { c = get(self,t); } ! DEBUG(1, (stderr,"<-Munch<--")); self->v_RawMode = FALSE; } else { *************** *** 473,478 **** --- 616,622 ---- } self->v_LastIfResult = (sense != result); + FreeBuf(b); } *************** *** 499,512 **** { int c; ! DEBUG((stderr,"else: previous result was %d\n",self->v_LastIfResult)); if (self->v_LastIfResult) { /* munch to end of conditional input */ self->v_RawMode = TRUE; ! DEBUG((stderr,"-->Munch->")); do { c = get(self,t); ! } while(c != EOF && ((c != '\n') || (self->v_InCond > 0))); ! DEBUG((stderr,"<-Munch<--")); self->v_RawMode = FALSE; } else { --- 643,657 ---- { int c; ! DEBUG(1, (stderr,"else: previous result was %d\n",self->v_LastIfResult)); if (self->v_LastIfResult) { /* munch to end of conditional input */ + int oldlev = self->v_InCond; self->v_RawMode = TRUE; ! DEBUG(1, (stderr,"-->Munch->")); do { c = get(self,t); ! } while(c != EOF && ((c != '\n') || (self->v_InCond > oldlev))); ! DEBUG(1, (stderr,"<-Munch<--")); self->v_RawMode = FALSE; } else { *************** *** 521,526 **** --- 666,1020 ---- + /* table macros */ + + /* create a table */ + Ct_cmd(self,t,br,argc,argv) + struct rofftext *self; + Trickle t; + boolean br; + int argc; + char *argv[]; + { + int i; + self->Tbl = table_New(); + table_ChangeSize(self->Tbl, 0, 0); + self->v_TblMode = 1; + self->v_TblTab = '\t'; + for (i = 0; i < MAX_COLS; i++) self->colWidth[i] = 1; + } + + static char gettblopts(argc, argv) + int argc; + char argv[80][80]; { + int i; + for (i = 0; i < argc; i++) { + if (strncmp(argv[i], "tab(", 4) == 0) + return argv[i][4]; + } + return '\t'; + } + + static void gettblfmt(argc, argv) + int argc; + char argv[80][80]; { + } + + static char *parsetbl(line, sep, multi, out) + char *line; /* the input */ + char *sep; /* separators */ + int multi; /* if 1, skip multiple separators */ + char *out; { /* the output */ + char *p = line; + *out = *p; + if (*p == '\0') return NULL; + while (*p != '\0' && !strchr(sep, *p)) *out++ = *p++; /* copy till separator */ + *out = '\0'; + if (!multi) { + if (*p != '\0') p++; /* skip one separator */ + } else { + while (*p != '\0' && strchr(sep, *p)) p++; /* skip all separators */ + } + return p; + } + + + /* insert a row in the table */ + InsertTbl(self,t) + struct rofftext *self; + Trickle t; + { + int row, col, colmax; + char line[500], tabstr[10]; + char argv[80][80]; static int argc = 0; + char c, last, *p = line; + if (self->v_TblMode == 0 || self->Tbl == NULL) return; + + while ((c = get(self, t)) != '\n') *p++ = self->Berliz[(int)c]; /* copy the line */ + *p-- = '\0'; + DEBUG(1, (stderr, "Tbl reading [%s] in state %d\n", line, self->v_TblMode)); + while (p > line && (*p == ' ' || *p == '\t')) p--; + if (p <= line) last = '\0'; /* remember the last char */ + else last = *p; + p = line; + if (self->v_TblMode == 1) { /* look for global options */ + self->v_TblMode = 2; + if (last == ';') { + while ((p = parsetbl(p, " \t,", TRUE, argv[argc])) != NULL) argc++; /* parse it */ + self->v_TblTab = gettblopts(argc, argv); + argc = 0; + return; + } + } + if (self->v_TblMode == 2) { /* look for formats */ + while ((p = parsetbl(p, " \t", TRUE, argv[argc])) != NULL) { + argc++; /* parse it */ + } + gettblfmt(argc, argv); + if (last == '.') { + self->v_TblMode = 3; + } + argc = 0; + return; + } + if ((strcmp(line, "=") == 0) || (strcmp(line, "_") == 0)) return; /* ignore horiz lines */ + tabstr[0] = self->v_TblTab; /* to parse table */ + tabstr[1] = '\0'; + DEBUG(1, (stderr, "about to parse [%s]\n", line)); + while ((p = parsetbl(p, tabstr, FALSE, argv[argc])) != NULL) { + if(!strcmp(argv[argc], "T{") || !strcmp(argv[argc], "T}")) + return; /* skip it -- string inside a "T{...}T" construct */ + else argc++; /* parse it */ + } + row = table_NumberOfRows(self->Tbl)+1; /* size the table */ + colmax = table_NumberOfColumns(self->Tbl); + if (colmax < argc) colmax = argc; + table_ChangeSize(self->Tbl, row, colmax); + for (col = 0; col < argc; col++) { + struct cell *c = table_GetCell(self->Tbl, row-1, col); + char buf[2000]; + int width = strlen(argv[col]); + if (width > self->colWidth[col]) self->colWidth[col] = width; + buf[0]='\"'; + strcpy(buf+1, argv[col]); /* force to string */ + table_ParseCell(self->Tbl, c, buf); + } + argc = 0; /* reset argc when we drop through because it's static */ + } + + /* end the table */ + Et_cmd(self,t,br,argc,argv) + struct rofftext *self; + Trickle t; + boolean br; + int argc; + char *argv[]; + { + int colmax = table_NumberOfColumns(self->Tbl); + int col; + for (col = 0; col < colmax; col++) + self->Tbl->col[col].thickness = self->colWidth[col]*9; + + text_AddView(self->text, self->pos++, table_ViewName(self->Tbl), self->Tbl); + text_InsertCharacters(self->text, self->pos++, "\n", 1); + self->v_TblMode = 0; + } + + /* Heading command */ + Hd_cmd(self,t,br,argc,argv) + struct rofftext *self; + Trickle t; + boolean br; + int argc; + char *argv[]; + { + int style = 0; + int lev; + char *p; + char *str; + if (argc < 3) return; + lev = atoi(argv[1]); + switch (lev) { + case 0: + case 1: str = "chapter"; + break; + case 2: str = "section"; + break; + case 3: str = "subsection"; + break; + case 4: + case 5: str = "paragraph"; + break; + case 6: + case 7: + break; + case 8: str = "majorheading"; + break; + case 9: str = "heading"; + break; + default: str = ""; + break; + } + if (str[0] != '\0') style = BeginStyle(self, str); + p = argv[2]; + while (*p != '\0') put(self, *p++); + if (str[0] != '\0') EndStyle(self, style); + } + + /* Begin Page command */ + bp_cmd(self,t,br,argc,argv) + struct rofftext *self; + Trickle t; + boolean br; + int argc; + char *argv[]; + { + put(self, '\n'); /* this is necessary; otherwise font changes are one off */ + text_InsertObject(self->text, self->pos++, "bp", "bpv"); + put(self, '\n'); + } + + /* Footnote command */ + Fn_cmd(self,t,br,argc,argv) + struct rofftext *self; + Trickle t; + boolean br; + int argc; + char *argv[]; + { + int sw = 0; + if (argc > 1) sw = atoi(argv[1]); + if (sw != 0) { /* start a footnote */ + self->Fn = fnote_New(); + self->fnpos = 0; + } else if (self->Fn != NULL) { /* end a footnote */ + text_AddView(self->text, self->pos++, fnote_ViewName(self->Fn), self->Fn); + self->Fn = NULL; + } + } + + /* Turn off escape processing in GC mode */ + Gc_cmd(self,t,br,argc,argv) + struct rofftext *self; + Trickle t; + boolean br; + int argc; + char *argv[]; + { + int newval = 1; + if (argc > 1) newval = atoi(argv[1]); + self->gc_mode = newval; + } + + /* Pic command */ + Ps_cmd(self,t,br,argc,argv) + struct rofftext *self; + Trickle t; + boolean br; + int argc; + char *argv[]; + { + struct link *l; + int open = 0; + if (argc > 1) open = atoi(argv[1]); + if (!open) { + /* closing */ + char cmd[400]; + char filename[400]; + if (self->filename != NULL) strcpy(filename, self->filename); + else if (class_IsTypeByName(class_GetTypeName(self), "mmtext")) { + struct mmtext *doc = (struct mmtext *) self; + mmtext_GetFilename(doc, filename); + } else filename[0] = '\0'; + sprintf(cmd, "$tail <%s +%d|head -%d|pic|troff|preview", filename, + self->picBegin, t->t->LineNumber - self->picBegin+1); /* include .PE */ + link_SetLink(self->picButton, cmd); + return; + } + /* opening */ + l = link_New(); + link_SetText(l, "Click here to see PIC figure"); + self->picBegin = t->t->LineNumber - 1; /* include the .PS */ + self->picButton= l; + text_AddView(self->text, self->pos++, link_ViewName(l), l); + } + + /* Hypertext link buttons */ + Bu_cmd(self,t,br,argc,argv) + struct rofftext *self; + Trickle t; + boolean br; + int argc; + char *argv[]; + { + struct link * l; + if (argc < 3) return; + l = link_New(); + link_SetText(l, argv[1]); + link_SetLink(l, argv[2]); + text_AddView(self->text, self->pos++, link_ViewName(l), l); + } + + #ifdef TROFF_TAGS_ENV + /* Tag command -- definition */ + Tag_cmd(self,t,br,argc,argv) + struct rofftext *self; + Trickle t; + boolean br; + int argc; + char *argv[]; + { + char *tag; + int count; + /* definition -- make table entry */ + /* fix up references later */ + /* argv[1] is "G", because the command is actually .TAG */ + if (argc < 3) return; + tag = malloc(strlen(argv[2])+1); + if (tag == NULL) return; + strcpy(tag, argv[2]); + if (self->tag_count >= MAX_TAG) return; + count = self->tag_count++; + self->tags[count].tag = tag; + self->tags[count].def = TRUE; + self->tags[count].pos = self->pos; + } + + /* Tag reference */ + Tag_ref(self,t, sym) + struct rofftext *self; + Trickle t; + char *sym; + { + struct link * l; + char *tag; + int count; + char filename[200]; + char taglabel[100]; + /* tag being referred to -- put in a button */ + /* need to do SetPos to put in destination */ + tag = malloc(strlen(sym)+1); + if (tag == NULL) return; + strcpy(tag, sym); + if (self->tag_count >= MAX_TAG) return; + if (self->filename != NULL) strcpy(filename, self->filename); + else if (class_IsTypeByName(class_GetTypeName(self), "mmtext")) { + struct mmtext *doc = (struct mmtext *) self; + mmtext_GetFilename(doc, filename); + } else strcpy(filename, t->t->filename); + count = self->tag_count++; + self->tags[count].tag = tag; + l = link_New(); + self->tags[count].def = FALSE; + self->tags[count].l = l; + sprintf(taglabel, " [-->>%s] ", tag); + link_SetText(l, taglabel); + link_SetLink(l, filename); + text_AddView(self->text, self->pos++, link_ViewName(l), l); + } + + /* + * Fix up tags + */ + Tag_fixup(self) + struct rofftext *self; { + int i; + for (i = 0; i < self->tag_count; i++) { + if (! self->tags[i].def) { + /* search for the definition */ + int j; + for (j = 0; j < self->tag_count; j++) { + if (self->tags[j].def && strcmp(self->tags[j].tag, self->tags[i].tag) == 0) { + /* found definition matching the reference */ + /* j points to the def, i to the ref */ + /* link_SetPos(self->tags[i].l, self->tags[j].pos); */ + } + } + } + } + } + #endif /* TROFF_TAGS_ENV */ + /* print macro -- for debugging */ PM_cmd(self,t,br,argc,argv) struct rofftext *self; *************** *** 567,574 **** int tmp = self->CurrentDiversion->OutputDone; static BUF b = NULL; ! if (b == NULL) ! b = NewBuf(); ClearBuf(b); c = get(self,t); /* read leading whitespace */ --- 1061,1067 ---- int tmp = self->CurrentDiversion->OutputDone; static BUF b = NULL; ! b = NewBuf(); ClearBuf(b); c = get(self,t); /* read leading whitespace */ *************** *** 620,630 **** put(self,'\n'); } EndStyle(self,style); self->CurrentDiversion->OutputDone = tmp; /* don't screw up breaks */ } - SortTraps(trap1,trap2) struct trap *trap1,*trap2; { --- 1113,1123 ---- put(self,'\n'); } EndStyle(self,style); + FreeBuf(b); self->CurrentDiversion->OutputDone = tmp; /* don't screw up breaks */ } SortTraps(trap1,trap2) struct trap *trap1,*trap2; { *************** *** 649,658 **** /* check location for trap */ EvalString(self,argv[1],&result,scale_u,&absolute,&relative); if (!relative && !absolute && (result == 0)) { ! DEBUG((stderr,"Setting beginning trap\n")); ! if (self->v_Trap != NULL) { ! free(self->v_Trap); ! } self->v_Trap = StrDup(argv[2]); } /* foo */ --- 1142,1148 ---- /* check location for trap */ EvalString(self,argv[1],&result,scale_u,&absolute,&relative); if (!relative && !absolute && (result == 0)) { ! DEBUG(1, (stderr,"Setting beginning trap\n")); self->v_Trap = StrDup(argv[2]); } /* foo */ *************** *** 674,680 **** char *argv[]; { if (self->CurrentDiversion->NoSpaceMode) { ! DEBUG((stderr,"Space: no space mode is on...\n")); return; } else --- 1164,1170 ---- char *argv[]; { if (self->CurrentDiversion->NoSpaceMode) { ! DEBUG(1, (stderr,"Space: no space mode is on...\n")); return; } else *************** *** 703,709 **** else lines = 0; } ! DEBUG((stderr,"SPACE: spacing %d from a result of %g\n",lines,result)); if (lines > 0) { while(lines-- > 0) put(self,'\n'); --- 1193,1199 ---- else lines = 0; } ! DEBUG(1, (stderr,"SPACE: spacing %d from a result of %g\n",lines,result)); if (lines > 0) { while(lines-- > 0) put(self,'\n'); *************** *** 728,736 **** self->CurrentEnviron->NextInputTrap = 0; } else { - if (self->CurrentEnviron->InputTrapCmd != NULL) { - free(self->CurrentEnviron->InputTrapCmd); - } self->CurrentEnviron->InputTrapCmd = StrDup(argv[2]); EvalString(self,argv[1], &result, scale_u,NULL,NULL); self->CurrentEnviron->NextInputTrap = result + self->v_InputLineCount; --- 1218,1223 ---- *************** *** 747,768 **** char *argv[]; { char *font; ! if (argc<2)return; if (self->v_DiversionLevel>0) { /* yuck-o, handle fonts in diversions */ int tmp = self->CurrentDiversion->OutputDone; put(self,'\\'); put(self,'f'); ! put(self,*argv[1]); self->CurrentDiversion->OutputDone = tmp; return; } - font = argv[1]; if (isdigit(font[0])) { int digit = font[0]-'1'; ! if ((digit >= 0) && (digit <= 3)) font = self->Fonts[digit]; else { ! DEBUG((stderr,"********WARNING: bogus font (%s)********\n)",font)); font = self->Fonts[0]; } } --- 1234,1255 ---- char *argv[]; { char *font; ! font = "P"; ! if (argc>1)font=argv[1]; if (self->v_DiversionLevel>0) { /* yuck-o, handle fonts in diversions */ int tmp = self->CurrentDiversion->OutputDone; put(self,'\\'); put(self,'f'); ! put(self,*font); self->CurrentDiversion->OutputDone = tmp; return; } if (isdigit(font[0])) { int digit = font[0]-'1'; ! if ((digit >= 0) && (digit <= 5)) font = self->Fonts[digit]; else { ! DEBUG(1, (stderr,"********WARNING: bogus font (%s)********\n)",font)); font = self->Fonts[0]; } } *************** *** 776,781 **** --- 1263,1269 ---- break; case 'P': font = self->CurrentEnviron->prevFont; break; + case 'G': case 'L': font = "typewriter"; break; default: font = "roman"; *************** *** 803,814 **** int temp; if (br) ! DoBreak(self); temp = self->CurrentEnviron->indent; if (argc>1) { ! DEBUG((stderr,"Indenting (%s)\n",argv[1])); EvalString(self,argv[1],&result,scale_m,NULL,&relative); if (relative) --- 1291,1302 ---- int temp; if (br) ! DoBreak(self); temp = self->CurrentEnviron->indent; if (argc>1) { ! DEBUG(1, (stderr,"Indenting (%s)\n",argv[1])); EvalString(self,argv[1],&result,scale_m,NULL,&relative); if (relative) *************** *** 842,848 **** DoBreak(self); if (argc>1) { ! DEBUG((stderr,"Temp. indenting (%s)\n",argv[1])); EvalString(self,argv[1],&result,scale_m,&absolute,&relative); if (relative) --- 1330,1336 ---- DoBreak(self); if (argc>1) { ! DEBUG(1, (stderr,"Temp. indenting (%s)\n",argv[1])); EvalString(self,argv[1],&result,scale_m,&absolute,&relative); if (relative) *************** *** 868,874 **** { if (br) DoBreak(self); ! self->v_FillMode = FALSE; } /* fill mode */ --- 1356,1362 ---- { if (br) DoBreak(self); ! self->CurrentEnviron->fill = FALSE; } /* fill mode */ *************** *** 881,887 **** { if (br) DoBreak(self); ! self->v_FillMode = TRUE; } --- 1369,1375 ---- { if (br) DoBreak(self); ! self->CurrentEnviron->fill = TRUE; } *************** *** 893,899 **** int argc; char *argv[]; { ! DEBUG((stderr,"===Turning on no-space mode===\n")); self->CurrentDiversion->NoSpaceMode = TRUE; } --- 1381,1387 ---- int argc; char *argv[]; { ! DEBUG(1, (stderr,"===Turning on no-space mode===\n")); self->CurrentDiversion->NoSpaceMode = TRUE; } *************** *** 906,912 **** int argc; char *argv[]; { ! DEBUG((stderr,"=Resetting Space Mode=\n")); self->CurrentDiversion->NoSpaceMode = FALSE; } --- 1394,1400 ---- int argc; char *argv[]; { ! DEBUG(1, (stderr,"=Resetting Space Mode=\n")); self->CurrentDiversion->NoSpaceMode = FALSE; } *************** *** 923,928 **** --- 1411,1440 ---- DoBreak(self); } + /* center text */ + Ce_cmd(self,t,br,argc,argv) + struct rofftext *self; + Trickle t; + boolean br; + int argc; + char *argv[]; + { + int result; + static int styleID = 0; + + if (br) + DoBreak(self); + DEBUG(1, (stderr, "Center command argc (%d) \n", argc)); + if (argc > 1) { + EvalString(self,argv[1],&result,scale_u,NULL,NULL); + if (result > 0) { + styleID = BeginStyle(self, "center"); + return; + } + } + if (styleID) EndStyle(self, styleID); + styleID = 0; + } /* ignore input */ ig_cmd(self,t,br,argc,argv) *************** *** 935,953 **** char *end = StrDup(argv[1]); static BUF b = NULL; ! if (b == NULL) ! b = NewBuf(); ClearBuf(b); self->v_CopyMode = TRUE; ! self->v_SnarfOutput = b; Scan(self,t,((argc<2)?".":end)); ! self->v_SnarfOutput = NULL; self->v_CopyMode = FALSE; /* ignore completely! */ free(end); } --- 1447,1465 ---- char *end = StrDup(argv[1]); static BUF b = NULL; ! b = NewBuf(); ClearBuf(b); self->v_CopyMode = TRUE; ! self->CurrentDiversion->SnarfOutput = b; Scan(self,t,((argc<2)?".":end)); ! self->CurrentDiversion->SnarfOutput = NULL; self->v_CopyMode = FALSE; /* ignore completely! */ + FreeBuf(b); free(end); } *************** *** 980,986 **** name[0] = get(self,t); name[1] = get(self,t); name[2] = '\0'; ! DEBUG((stderr,"tr: found special char %s\n",name)); /* change special char */ } else { --- 1492,1498 ---- name[0] = get(self,t); name[1] = get(self,t); name[2] = '\0'; ! DEBUG(1, (stderr,"tr: found special char %s\n",name)); /* change special char */ } else { *************** *** 991,997 **** self->v_RawMode = FALSE; c = get(self,t); name[0] = '\0'; ! DEBUG((stderr,"tr: found special char %s, which maps to %c\n",temp,c)); } } else --- 1503,1509 ---- self->v_RawMode = FALSE; c = get(self,t); name[0] = '\0'; ! DEBUG(1, (stderr,"tr: found special char %s, which maps to %c\n",temp,c)); } } else *************** *** 1007,1013 **** if (new == '\n') new = ' '; if (name[0] == '\0') { ! DEBUG((stderr,"tr: translating %c to %c\n",source,new)); self->Berliz[source] = new; } else { --- 1519,1525 ---- if (new == '\n') new = ' '; if (name[0] == '\0') { ! DEBUG(1, (stderr,"tr: translating %c to %c\n",source,new)); self->Berliz[source] = new; } else { *************** *** 1015,1024 **** temp[1] = '\0'; /* we won't worry about keeping track of mallocs here */ hash_Store(self->SpecialChars,name,StrDup(temp)); ! DEBUG((stderr,"tr: renaming %s to %s\n",name,temp)); } self->v_RawMode = TRUE; ! c = get(self,t); } self->v_RawMode = FALSE; } --- 1527,1536 ---- temp[1] = '\0'; /* we won't worry about keeping track of mallocs here */ hash_Store(self->SpecialChars,name,StrDup(temp)); ! DEBUG(1, (stderr,"tr: renaming %s to %s\n",name,temp)); } self->v_RawMode = TRUE; ! if (c != '\n') c = get(self,t); } self->v_RawMode = FALSE; } *** atk/rofftext/roffcmds.h Wed Nov 22 12:27:40 1989 --- atk/rofftext/roffcmds.h.NEW Tue Feb 5 18:03:16 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/rofftext/RCS/roffcmds.h,v 2.3 89/02/17 17:05:24 ghoti Exp $ */ /* $ACIS: $ */ ! /* $Source: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/rofftext/RCS/roffcmds.h,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsid_h = "$Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/rofftext/RCS/roffcmds.h,v 2.3 89/02/17 17:05:24 ghoti Exp $ "; #endif /* !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) */ /* be2roff cmds --- 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/rofftext/RCS/roffcmds.h,v 2.4 91/02/05 17:42:56 gk5g Exp $ */ /* $ACIS: $ */ ! /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/rofftext/RCS/roffcmds.h,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsid_h = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/rofftext/RCS/roffcmds.h,v 2.4 91/02/05 17:42:56 gk5g Exp $ "; #endif /* !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) */ /* be2roff cmds *************** *** 18,23 **** --- 18,24 ---- int rm_cmd(); int ds_cmd(); + int as_cmd(); int nr_cmd(); int af_cmd(); int rr_cmd(); *************** *** 25,31 **** --- 26,34 ---- int ex_cmd(); int br_cmd(); int de_cmd(); + int am_cmd(); int di_cmd(); + int da_cmd(); int c0_cmd(); int c1_cmd(); int if_cmd(); *************** *** 49,51 **** --- 52,64 ---- int ig_cmd(); int tr_cmd(); int ev_cmd(); + int Ct_cmd(); + int Et_cmd(); + int Hd_cmd(); + int Gc_cmd(); + int Bu_cmd(); + int Tag_cmd(); + int bp_cmd(); + int Fn_cmd(); + int Ce_cmd(); + int Ps_cmd(); *** atk/rofftext/roffstyl.c Mon Mar 12 13:16:16 1990 --- atk/rofftext/roffstyl.c.NEW Tue Feb 5 18:03: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/andrew/atk/rofftext/RCS/roffstyl.c,v 2.10 90/02/09 13:59:54 susan Exp $ */ /* $ACIS: $ */ ! /* $Source: /afs/andrew.cmu.edu/itc/src/andrew/atk/rofftext/RCS/roffstyl.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/andrew/atk/rofftext/RCS/roffstyl.c,v 2.10 90/02/09 13:59:54 susan Exp $ "; #endif /* lint */ /* styles */ --- 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/rofftext/RCS/roffstyl.c,v 2.11 91/02/05 17:42:59 gk5g Exp $ */ /* $ACIS: $ */ ! /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/rofftext/RCS/roffstyl.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/rofftext/RCS/roffstyl.c,v 2.11 91/02/05 17:42:59 gk5g Exp $ "; #endif /* lint */ /* styles */ *************** *** 46,52 **** { int l, newid; ! DEBUG((stderr,"ChangeStyle: , changing %d to (%s)\n",self->stack->ID,id,(st?st:""))); if (id == 0) { return (BeginStyle(self,st)); --- 46,52 ---- { int l, newid; ! DEBUG(1, (stderr,"ChangeStyle: , changing %d to (%s)\n",self->stack->ID,id,(st?st:""))); if (id == 0) { return (BeginStyle(self,st)); *************** *** 65,71 **** for(l=self->tempstack->level;l>=0;l--) { self->stack++; self->stack->pos = self->pos; ! self->stack->env = environment_InsertStyle((self->stack-1)->env, self->pos - (self->stack-1)->pos, self->tempstack->style, TRUE); self->stack->level = (self->stack-1)->level+1; self->stack->ID = self->tempstack->ID; self->tempstack--; --- 65,71 ---- for(l=self->tempstack->level;l>=0;l--) { self->stack++; self->stack->pos = self->pos; ! self->stack->env = environment_InsertStyle((self->stack-1)->env, self->pos - (self->stack-1)->pos, self->tempstack->style, TRUE); self->stack->level = (self->stack-1)->level+1; self->stack->ID = self->tempstack->ID; self->tempstack--; *************** *** 79,88 **** CloseStyle(self) struct rofftext *self; { ! DEBUG((stderr,"Closing style %d (%d to %d, length %d)\n", self->stack->ID, self->stack->pos, self->pos, (self->pos - self->stack->pos))); if (self->stack->level < 0) { ! DEBUG((stderr,"rofftext: WARNING: tried to close bottom-level style\n")); return; } --- 79,88 ---- CloseStyle(self) struct rofftext *self; { ! DEBUG(1, (stderr,"Closing style %d (%d to %d, length %d)\n", self->stack->ID, self->stack->pos, self->pos, (self->pos - self->stack->pos))); if (self->stack->level < 0) { ! DEBUG(1, (stderr,"rofftext: WARNING: tried to close bottom-level style\n")); return; } *************** *** 91,97 **** environment_SetStyle(self->stack->env,FALSE,FALSE); } else { ! DEBUG((stderr,"(Removing the 0-length style)\n")); environment_Delete(self->stack->env); } self->stack--; --- 91,97 ---- environment_SetStyle(self->stack->env,FALSE,FALSE); } else { ! DEBUG(1, (stderr,"(Removing the 0-length style)\n")); environment_Delete(self->stack->env); } self->stack--; *************** *** 112,123 **** style = stylesheet_Find(self->text->styleSheet,st); if (style == NULL) { ! DEBUG((stderr,"BeginStyle: opening non-existent style (%s)\n",st)); return 0; /* null style */ } self->stack++; self->stack->pos = self->pos; self->stack->env = environment_InsertStyle((self->stack-1)->env, self->pos - (self->stack-1)->pos, style, TRUE); self->stack->level = (self->stack-1)->level+1; self->stack->ID = self->styleID++; --- 112,124 ---- style = stylesheet_Find(self->text->styleSheet,st); if (style == NULL) { ! DEBUG(1, (stderr,"BeginStyle: opening non-existent style (%s)\n",st)); return 0; /* null style */ } self->stack++; self->stack->pos = self->pos; self->stack->env = environment_InsertStyle((self->stack-1)->env, self->pos - (self->stack-1)->pos, style, TRUE); + DEBUG(4, (stderr, "Inserting style %s at pos %d offset %d\n", st, self->pos, self->pos - (self->stack-1)->pos)); self->stack->level = (self->stack-1)->level+1; self->stack->ID = self->styleID++; *************** *** 124,130 **** if (self->styleID == 0) /* make sure we don't get a '0' style id */ self->styleID = 1; ! DEBUG((stderr,"BeginStyle: opening style %d (%s)\n",self->stack->ID,st)); return self->stack->ID; } --- 125,131 ---- if (self->styleID == 0) /* make sure we don't get a '0' style id */ self->styleID = 1; ! DEBUG(1, (stderr,"BeginStyle: opening style %d (%s)\n",self->stack->ID,st)); return self->stack->ID; } *************** *** 136,142 **** { int l; ! DEBUG((stderr,"EndStyle: current %d, closing %d\n",self->stack->ID,ID)); if (ID == 0) return; /* null style */ --- 137,143 ---- { int l; ! DEBUG(1, (stderr,"EndStyle: current %d, closing %d\n",self->stack->ID,ID)); if (ID == 0) return; /* null style */ *** atk/rofftext/roffstyl.h Mon Aug 6 11:08:51 1990 --- atk/rofftext/roffstyl.h.NEW Tue Feb 5 18:03:10 1991 *************** *** 2,17 **** * 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/rofftext/RCS/roffstyl.h,v 2.6 90/06/06 14:48:01 gk5g Exp $ */ /* $ACIS: $ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/rofftext/RCS/roffstyl.h,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsid_h = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/rofftext/RCS/roffstyl.h,v 2.6 90/06/06 14:48:01 gk5g Exp $ "; #endif /* !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) */ ! #ifndef _AIX /* style code for be2roff */ InitText(); --- 2,17 ---- * 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/rofftext/RCS/roffstyl.h,v 2.7 91/02/05 17:28:50 gk5g Exp $ */ /* $ACIS: $ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/rofftext/RCS/roffstyl.h,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsid_h = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/rofftext/RCS/roffstyl.h,v 2.7 91/02/05 17:28:50 gk5g Exp $ "; #endif /* !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) */ ! #ifndef AIX /* style code for be2roff */ InitText(); *************** *** 20,23 **** ChangeStyle(); CloseStyle(); CloseAllStyles(); ! #endif /* _AIX */ --- 20,23 ---- ChangeStyle(); CloseStyle(); CloseAllStyles(); ! #endif /* AIX */ *** atk/rofftext/rofftext.c Wed Apr 11 14:20:51 1990 --- atk/rofftext/rofftext.c.NEW Mon May 6 20:57:47 1991 *************** *** 2,18 **** * 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/rofftext/RCS/rofftext.c,v 2.16 90/03/22 09:33:27 ajp Exp $ */ /* $ACIS: $ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/rofftext/RCS/rofftext.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/rofftext/RCS/rofftext.c,v 2.16 90/03/22 09:33:27 ajp Exp $ "; #endif /* lint */ /* rofftext * * a text object to interpret troff code */ #include --- 2,21 ---- * 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/rofftext/RCS/rofftext.c,v 2.20 1991/05/06 19:01:32 rr2b Exp $ */ /* $ACIS: $ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/rofftext/RCS/rofftext.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/rofftext/RCS/rofftext.c,v 2.20 1991/05/06 19:01:32 rr2b Exp $ "; #endif /* lint */ /* rofftext * * a text object to interpret troff code + * + * modified to keep track of line numbers for mmtext + * cch@mtgzx.att.com 1/26/90 */ #include *************** *** 25,36 **** #include #include #include - #include #include #include #include #include /*#include "rofftext.h"*/ #include --- 28,41 ---- #include #include #include #include #include #include + #include + #include + #include /*#include "rofftext.h"*/ #include *************** *** 60,74 **** * */ - FreeTrap(trap) - struct trap *trap; - { - if (trap->macro != NULL) - free(trap->macro); - - free(trap); - } - SetIndent(self,u) struct rofftext *self; int u; --- 65,70 ---- *************** *** 77,91 **** int indentcm = ((u+85)/170); /* convert units to centimeters, round to nearest */ int i; ! DEBUG((stderr,"Indenting %d cm\n",indentcm)); for(i=0;i> 1) { if (indentcm & 1) { ! DEBUG((stderr,"Opening indent %d\n",i)); self->IndentStyle[i] = ChangeStyle(self,self->IndentStyle[i],self->IndentName[i]); } else { ! DEBUG((stderr,"Closing indent %d\n",i)); self->IndentStyle[i] = ChangeStyle(self,self->IndentStyle[i],NULL); } } --- 73,87 ---- int indentcm = ((u+85)/170); /* convert units to centimeters, round to nearest */ int i; ! DEBUG(1, (stderr,"Indenting %d cm\n",indentcm)); for(i=0;i> 1) { if (indentcm & 1) { ! DEBUG(1, (stderr,"Opening indent %d\n",i)); self->IndentStyle[i] = ChangeStyle(self,self->IndentStyle[i],self->IndentName[i]); } else { ! DEBUG(1, (stderr,"Closing indent %d\n",i)); self->IndentStyle[i] = ChangeStyle(self,self->IndentStyle[i],NULL); } } *************** *** 104,110 **** char **name; if (self->CurrentEnviron->indent > u) { ! DEBUG((stderr,"(negative indent)\n")); u = self->CurrentEnviron->indent - u; style1 = self->MinusTempIndentStyle; style2 = self->TempIndentStyle; --- 100,106 ---- char **name; if (self->CurrentEnviron->indent > u) { ! DEBUG(1, (stderr,"(negative indent)\n")); u = self->CurrentEnviron->indent - u; style1 = self->MinusTempIndentStyle; style2 = self->TempIndentStyle; *************** *** 111,117 **** name = self->MinusTempIndentName; } else { ! DEBUG((stderr,"(positive indent)\n")); u = u - self->CurrentEnviron->indent; style1 = self->TempIndentStyle; style2 = self->MinusTempIndentStyle; --- 107,113 ---- name = self->MinusTempIndentName; } else { ! DEBUG(1, (stderr,"(positive indent)\n")); u = u - self->CurrentEnviron->indent; style1 = self->TempIndentStyle; style2 = self->MinusTempIndentStyle; *************** *** 118,132 **** name = self->TempIndentName; } indentcm = ((u+85)/170); /* convert units to centimeters, round to nearest */ ! DEBUG((stderr,"Temp Indenting %d cm\n",indentcm)); for(i=0;i> 1) { if (indentcm & 1) { ! DEBUG((stderr,"Opening temp indent %d (%s)\n",i,name[i])); style1[i] = ChangeStyle(self,style1[i],name[i]); } else { ! DEBUG((stderr,"Closing temp indent %d\n",i)); style1[i] = ChangeStyle(self,style1[i],NULL); } style2[i] = ChangeStyle(self,style2[i],NULL); --- 114,128 ---- name = self->TempIndentName; } indentcm = ((u+85)/170); /* convert units to centimeters, round to nearest */ ! DEBUG(1, (stderr,"Temp Indenting %d cm\n",indentcm)); for(i=0;i> 1) { if (indentcm & 1) { ! DEBUG(1, (stderr,"Opening temp indent %d (%s)\n",i,name[i])); style1[i] = ChangeStyle(self,style1[i],name[i]); } else { ! DEBUG(1, (stderr,"Closing temp indent %d\n",i)); style1[i] = ChangeStyle(self,style1[i],NULL); } style2[i] = ChangeStyle(self,style2[i],NULL); *************** *** 154,169 **** DestroyContext(c) IC c; { - int i; - - if (c->argv != NULL) { - for (i = 0; i < c->argc; i++) { - if (c->argv[i] != NULL && *c->argv[i] != '\0') { - free(c->argv[i]); - } - } - free(c->argv); - } free(c); } --- 150,155 ---- *************** *** 248,255 **** switch (cur->type) { case trickle_File: c = getc(cur->u.f); ! if (c == '\n') cur->LineNumber++; break; case trickle_String: c = *cur->u.s++; --- 234,251 ---- switch (cur->type) { case trickle_File: c = getc(cur->u.f); ! /* modified to keep track of line numbers */ ! if (c == '\n') { ! if (strcmp(class_GetTypeName(self), "mmtext") == 0) { ! struct mmtext *doc = (struct mmtext *) self; ! mmtext_SetLinePos(doc, cur->LineNumber, self->pos); ! } ! else if (strcmp(class_GetTypeName(self), "mantext") == 0) { ! struct mantext *doc = (struct mantext *) self; ! mantext_SetLinePos(doc, cur->LineNumber, self->pos); ! } cur->LineNumber++; + } break; case trickle_String: c = *cur->u.s++; *************** *** 257,274 **** c = EOF; break; default: ! DEBUG((stderr,"HELP! Unknown trickle type in (%x)!!\n",cur)); exit(1); break; } if ((c == EOF) && (cur->prev != NULL)) { t->t = cur->prev; ! if (cur->type == trickle_File) { fclose(cur->u.f); - if (cur->filename != NULL) { - free(cur->filename); - } - } else { if (cur->pop) { /* pop macro argument stack */ --- 253,266 ---- c = EOF; break; default: ! DEBUG(1, (stderr,"HELP! Unknown trickle type in (%x)!!\n",cur)); exit(1); break; } if ((c == EOF) && (cur->prev != NULL)) { t->t = cur->prev; ! if (cur->type == trickle_File) fclose(cur->u.f); else { if (cur->pop) { /* pop macro argument stack */ *************** *** 275,292 **** /* pop args */ DestroyContext(self->CurrentContext); self->CurrentContext = (IC)glist_Pop(self->ArgStack); - DEBUG((stderr, "Popping input stream\n")); } free(cur->buf); ! } free(cur); c = g(self,t); } ! /* for debugging */ ! #ifdef DEBUG2 ! putc(c,stderr); ! #endif /* DEBUG2 */ return c; } --- 267,280 ---- /* pop args */ DestroyContext(self->CurrentContext); self->CurrentContext = (IC)glist_Pop(self->ArgStack); } free(cur->buf); ! } free(cur); c = g(self,t); } ! DEBUG(2, (stderr, "%c", c)); return c; } *************** *** 310,315 **** --- 298,305 ---- strcpy((temp+1),cur->u.s); free(cur->u.s); cur->u.s = temp; + /* see if this fixes it */ + cur->buf = temp; } else *(--cur->u.s)=c; *************** *** 333,340 **** { struct _trickle *temp = (struct _trickle *)malloc(sizeof(struct _trickle)); static char fn[512] = "/usr/man/"; ! ! DEBUG((stderr,"filename: %s t->t->filename:%s\n",filename,t->t->filename)); if (filename != NULL) { #if 0 --- 323,329 ---- { struct _trickle *temp = (struct _trickle *)malloc(sizeof(struct _trickle)); static char fn[512] = "/usr/man/"; ! DEBUG(1, (stderr,"filename: %s t->t->filename:%s\n",filename,t->t->filename)); if (filename != NULL) { #if 0 *************** *** 343,351 **** *s1 = '\0'; if (s2 = rindex(fn,'/')) { *(s2+1) = '\0'; ! DEBUG((stderr,"root name:%s\n",fn)); strcat(fn,filename); ! DEBUG((stderr,"new name:%s\n",fn)); exit(1); } } --- 332,340 ---- *s1 = '\0'; if (s2 = rindex(fn,'/')) { *(s2+1) = '\0'; ! DEBUG(1, (stderr,"root name:%s\n",fn)); strcat(fn,filename); ! DEBUG(1, (stderr,"new name:%s\n",fn)); exit(1); } } *************** *** 359,365 **** * HORRIBLE HACK TO GET THIS TO WORK WITH MAN PAGES */ strcpy(fn + sizeof("/usr/man/") - 1, filename); ! DEBUG((stderr,"fn:%s\n",fn)); if ((temp->u.f = fopen(fn,"r")) != NULL) { temp->type = trickle_File; } --- 348,354 ---- * HORRIBLE HACK TO GET THIS TO WORK WITH MAN PAGES */ strcpy(fn + sizeof("/usr/man/") - 1, filename); ! DEBUG(1, (stderr,"fn:%s\n",fn)); if ((temp->u.f = fopen(fn,"r")) != NULL) { temp->type = trickle_File; } *************** *** 391,397 **** } } else { ! DEBUG((stderr,"********tpush: called with null arguments\n")); temp->type = trickle_String; temp->buf = temp->u.s = ""; temp->filename = "(NULL!)"; --- 380,386 ---- } } else { ! DEBUG(1, (stderr,"********tpush: called with null arguments\n")); temp->type = trickle_String; temp->buf = temp->u.s = ""; temp->filename = "(NULL!)"; *************** *** 406,416 **** self->CurrentContext->argv = (char **)malloc(sizeof(char *)*10); self->CurrentContext->argc = argc; ! for(i=0;iCurrentContext->argv[i] = StrDup(argv[i]); ! else ! self->CurrentContext->argv[i] = ""; } while(i<10) self->CurrentContext->argv[i++] = ""; --- 395,402 ---- self->CurrentContext->argv = (char **)malloc(sizeof(char *)*10); self->CurrentContext->argc = argc; ! for(i=0;iCurrentContext->argv[i] = StrDup(argv[i]); } while(i<10) self->CurrentContext->argv[i++] = ""; *************** *** 463,469 **** if ((digit >= 0) && (digit <= 3)) font = self->Fonts[digit]; else { ! DEBUG((stderr,"********WARNING: bogus font (%s)********\n)",font)); font = self->Fonts[0]; } } --- 449,455 ---- if ((digit >= 0) && (digit <= 3)) font = self->Fonts[digit]; else { ! DEBUG(1, (stderr,"********WARNING: bogus font (%s)********\n)",font)); font = self->Fonts[0]; } } *************** *** 489,494 **** --- 475,493 ---- self->CurrentEnviron->fontStyle = ChangeStyle(self,self->CurrentEnviron->fontStyle,font); } + /* do sub/super scripts */ + setbase(self, inc) + struct rofftext *self; + int inc; /* up: 1; down: -1 */ + { + if (self->basestyle != 0) EndStyle(self, self->basestyle); + self->baseline += inc; + DEBUG(1, (stderr, "setting baseline to %d\n", self->baseline)); + if (self->baseline > 0) self->basestyle = BeginStyle(self, "superscript"); + if (self->baseline < 0) self->basestyle = BeginStyle(self, "subscript"); + if (self->baseline == 0) self->basestyle = 0; + } + /* get the width of a string */ getwidth(self,t) *************** *** 503,509 **** while(((c = get(self,t)) != delim) && (c != EOF) && (c != '\n')) length++; PopEnviron(self); ! sprintf(temp,"%d",length); tpush(self,t,NULL,NULL,temp,FALSE,NULL,NULL); } --- 502,557 ---- while(((c = get(self,t)) != delim) && (c != EOF) && (c != '\n')) length++; PopEnviron(self); ! sprintf(temp,"%d",length*self->ScaleFactor[(int)scale_m]); ! DEBUG(1, (stderr, "got width of %d\n", length*self->ScaleFactor[scale_m])); ! tpush(self,t,NULL,NULL,temp,FALSE,NULL,NULL); ! } ! ! /* get alpha characters up to white space */ ! getsym ! (self, t, str) ! struct rofftext *self; ! Trickle t; ! char *str; ! { ! register int c; ! while ((c = g(self,t)) != '\n' && c != EOF) { ! if ((c >= 'a' && c <= 'z') || ! (c >= 'A' && c <= 'Z') || ! (c >= '0' && c <= '9') || ! (c == '_')) *str++ = c; ! else break; ! } ! *str = '\0'; ! ung(self,c,t); ! ! } ! ! dohmove(self,t) ! struct rofftext *self; ! Trickle t; ! { ! static BUF Buffer = NULL; ! register int c,delim = get(self,t); ! int result; ! int i = 0; ! char temp[500]; ! ! if (Buffer == NULL) ! Buffer = NewBuf(); ! ! ClearBuf(Buffer); ! DEBUG(1, (stderr,"{{dohmove->}}")); ! while(((c = get(self,t)) != delim) && (c != EOF) && (c != '\n')) ! Add2Buf(Buffer,c); ! DEBUG(1, (stderr,"{{<-dohmove}}")); ! Add2Buf(Buffer,'\0'); ! /* do movement here, if you want to */ ! EvalString(self, Buffer->begin, &result, scale_u, NULL, NULL); ! result = result / self->ScaleFactor[(int)scale_m]; ! DEBUG(1, (stderr, "movement buffer: %d\n", result)); ! while (result-- > 0) temp[i++] = ' '; ! temp[i] = '\0'; tpush(self,t,NULL,NULL,temp,FALSE,NULL,NULL); } *************** *** 515,532 **** { static BUF Buffer = NULL; register int c,delim = get(self,t); if (Buffer == NULL) Buffer = NewBuf(); ClearBuf(Buffer); ! DEBUG((stderr,"{{munchmove->}}")); while(((c = get(self,t)) != delim) && (c != EOF) && (c != '\n')) Add2Buf(Buffer,c); ! DEBUG((stderr,"{{<-munchmove}}")); Add2Buf(Buffer,'\0'); /* do movement here, if you want to */ ! } --- 563,585 ---- { static BUF Buffer = NULL; register int c,delim = get(self,t); + int result; if (Buffer == NULL) Buffer = NewBuf(); ClearBuf(Buffer); ! DEBUG(1, (stderr,"{{munchmove->}}")); while(((c = get(self,t)) != delim) && (c != EOF) && (c != '\n')) Add2Buf(Buffer,c); ! DEBUG(1, (stderr,"{{<-munchmove}}")); Add2Buf(Buffer,'\0'); /* do movement here, if you want to */ ! DEBUG(1, (stderr, "movement buffer: %s\n", Buffer->begin)); ! EvalString(self, Buffer->begin, &result, scale_u, NULL, NULL); ! result = result / self->ScaleFactor[(int)scale_m]; ! DEBUG(1, (stderr, "movement buffer: %d\n", result)); ! return result; } *************** *** 562,568 **** } d = (c-'0'); ! if ((d==6)||(d==7)||(d==8)||(d==9)) { return d; } else { --- 615,621 ---- } d = (c-'0'); ! if ((d==0)||(d==6)||(d==7)||(d==8)||(d==9)) { return d; } else { *************** *** 603,614 **** *ptr++ = c; *ptr = '\0'; r = (Reg)hash_Lookup(self->Registers,temp); if (r == NULL) { ! DEBUG((stderr, "Register (%s) not found\n",temp)); return "0"; } ! DEBUG((stderr,"Accessing register %s\n",temp)); switch(r->format) { case reg_Single: fmtstring = "%d"; --- 656,696 ---- *ptr++ = c; *ptr = '\0'; + if (strcmp(temp, ".$") == 0) { + sprintf(temp, "%d", self->CurrentContext->argc-1); + DEBUG(1, (stderr, "value of .$ is %s\n", temp)); + return temp; + } else if (strcmp(temp, ".f") == 0) { + int fontnum; + switch (self->CurrentEnviron->font[0]) { + case 'r': fontnum = 1; break; + case 'i': fontnum = 2; break; + case 'b': fontnum = 3; break; + case 's': fontnum = 4; break; + case 't': fontnum = 5; break; + default: fontnum = 1; break; + } + sprintf(temp, "%d", fontnum); + return temp; + } else if (strcmp(temp, ".u") == 0) { + sprintf(temp, "%d", self->CurrentEnviron->fill); + return temp; + } else if (strcmp(temp, ".i") == 0) { + sprintf(temp, "%d", self->CurrentEnviron->indent); + return temp; + } else if (strcmp(temp, ".z") == 0) { + if (self->CurrentDiversion->name == NULL) + strcpy(temp, ""); + else sprintf(temp, "%s", self->CurrentDiversion->name); + DEBUG(1, (stderr, "CurrentDiversion (%s)\n", temp)); + return temp; + } else r = (Reg)hash_Lookup(self->Registers,temp); if (r == NULL) { ! DEBUG(1, (stderr, "Register (%s) not found\n",temp)); return "0"; } ! DEBUG(1, (stderr,"Accessing register %s\n",temp)); switch(r->format) { case reg_Single: fmtstring = "%d"; *************** *** 661,673 **** char *name; { char *str; ! DEBUG((stderr,"Name = (%s)\n",name)); if ((str = hash_Lookup(self->Macros,name)) == NULL) { ! DEBUG((stderr,"String was Null\n")); return ""; } else { ! DEBUG((stderr,"String was (%s)\n",str)); return str; } } --- 743,755 ---- char *name; { char *str; ! DEBUG(1, (stderr,"Name = (%s)\n",name)); if ((str = hash_Lookup(self->Macros,name)) == NULL) { ! DEBUG(1, (stderr,"String was Null\n")); return ""; } else { ! DEBUG(1, (stderr,"String was (%s)\n",str)); return str; } } *************** *** 678,684 **** { char *v = StrDup(value), *existing; ! DEBUG((stderr,"Storing string (%s) (%s)\n",name,v)); hash_Delete(self->Commands,name); existing = hash_Delete(self->Macros,name); if (existing) --- 760,766 ---- { char *v = StrDup(value), *existing; ! DEBUG(1, (stderr,"Storing string (%s) (%s)\n",name,v)); hash_Delete(self->Commands,name); existing = hash_Delete(self->Macros,name); if (existing) *************** *** 743,748 **** --- 825,834 ---- self->v_CopyMode = tmp; *buf = '\0'; ung(self,c,t); /* push back space or newline */ + /* cch There is a problem here if the next thing after the arg was \\, which + gets translated to \. Only one \ gets put back, the other is lost. + Try another ung (is that legal ?) */ + if (c == '\\') ung(self, c, t); /* cch */ } /* Put a character on the output */ *************** *** 751,758 **** struct rofftext *self; unsigned char c; { ! if (self->v_SnarfOutput!=NULL) ! Add2Buf(self->v_SnarfOutput,c); else { /* beginning of page trap */ if (!self->v_TrapBlown && self->v_Trap) { --- 837,844 ---- struct rofftext *self; unsigned char c; { ! if (self->CurrentDiversion->SnarfOutput!=NULL) ! Add2Buf(self->CurrentDiversion->SnarfOutput,c); else { /* beginning of page trap */ if (!self->v_TrapBlown && self->v_Trap) { *************** *** 776,782 **** } if (c != NULCHAR) ! text_AddInCharacter(self->text,self->pos++,self->Berliz[(int)c]); } /* 80 chars is completely arbitrary */ if(self->CurrentDiversion->OutputDone++ > 0) { --- 862,887 ---- } if (c != NULCHAR) ! { ! unsigned char w = self->Berliz[(int)c]; ! if (self->Fn) { ! fnote_AddInCharacter(self->Fn, self->fnpos++, w); ! } ! else { ! if (w == '\n') self->out_column = 0; ! if (!self->CurrentEnviron->fill && w == '\t') { ! do { ! text_AddInCharacter(self->text, self->pos++, ' '); ! self->out_column++; ! } while (self->out_column % 8 != 1); ! } else { ! DEBUG(4, (stderr, "output %c at pos %d\n", w, self->pos)); ! text_AddInCharacter(self->text, self->pos++, w); ! self->out_column++; ! } ! ! } ! } } /* 80 chars is completely arbitrary */ if(self->CurrentDiversion->OutputDone++ > 0) { *************** *** 799,807 **** self->CurrentDiversion->OutputDone = 0; self->v_MultiSpace = FALSE; if (self->CurrentDiversion->NoSpaceMode) ! DEBUG((stderr, "Break: turning off no-space-mode - ")); self->CurrentDiversion->NoSpaceMode = FALSE; ! DEBUG((stderr,"<>")); /* handle temporary indent */ if (self->CurrentEnviron->tempIndent != self->CurrentEnviron->indent) { --- 904,912 ---- self->CurrentDiversion->OutputDone = 0; self->v_MultiSpace = FALSE; if (self->CurrentDiversion->NoSpaceMode) ! DEBUG(1, (stderr, "Break: turning off no-space-mode - ")); self->CurrentDiversion->NoSpaceMode = FALSE; ! DEBUG(1, (stderr,"<>")); /* handle temporary indent */ if (self->CurrentEnviron->tempIndent != self->CurrentEnviron->indent) { *************** *** 809,815 **** SetTempIndent(self,self->CurrentEnviron->indent); } } ! DEBUG((stderr, "Did break\n")); } /* Get a character, translating quoted characters */ --- 914,920 ---- SetTempIndent(self,self->CurrentEnviron->indent); } } ! DEBUG(1, (stderr, "Did break\n")); } /* Get a character, translating quoted characters */ *************** *** 843,849 **** case '}': /* end conditional input */ self->v_InCond -= 1; if (self->v_InCond<0) { ! DEBUG((stderr,"**Conditional Nesting Error**\n")); self->v_InCond = 0; } c = get(self,t); --- 948,954 ---- case '}': /* end conditional input */ self->v_InCond -= 1; if (self->v_InCond<0) { ! DEBUG(1, (stderr,"**Conditional Nesting Error**\n")); self->v_InCond = 0; } c = get(self,t); *************** *** 901,914 **** case 'w': /* width of string */ getwidth(self,t); c = get(self,t); break; case 'v': /* vert. and horiz. movement */ ! case 'h': munchmove(self,t); c = get(self,t); break; ! case 'u': /* ignore movement */ ! case 'd': case 'r': c = get(self,t); break; --- 1006,1043 ---- case 'w': /* width of string */ getwidth(self,t); c = get(self,t); + break; + + #ifdef TROFF_TAGS_ENV + case '_': { /* tag reference */ + char sym[50]; + getsym(self, t, sym); + if (sym[0] != '\0') Tag_ref(self, t, sym); + } + #endif /* TROFF_TAGS_ENV */ + + case 'h': { + int r = munchmove(self,t); + char s[500]; + int i = 0; + while (r-- > 0) s[i++] = ' '; + s[i] = '\0'; + tpush(self, t, NULL, NULL, s, FALSE, NULL, NULL); + c = get(self,t); break; + } case 'v': /* vert. and horiz. movement */ ! case 'l': ! case 'L': munchmove(self,t); c = get(self,t); break; ! case 'u': setbase(self, 1); ! c = get(self,t); ! break; ! case 'd': setbase(self, -1); ! c = get(self,t); ! break; case 'r': c = get(self,t); break; *************** *** 917,924 **** c = get(self,t); break; case 'c': /* continuation */ ! c = get(self,t); ! break; default: translated = FALSE; break; --- 1046,1055 ---- c = get(self,t); break; case 'c': /* continuation */ ! c = g(self, t); /* throw away cr */ ! self->v_NextBOL = (c == '\n'); ! c = get(self,t); ! return c; default: translated = FALSE; break; *************** *** 931,936 **** --- 1062,1072 ---- translated = TRUE; if (c != self->EscChar) { /* always translate escape */ switch(c) { + case '.': /* always translate . */ + break; + case '\'': /* escaped quote */ + self->v_BOL=FALSE; /* don't consider it a command */ + break; case '"': /* comment */ munch(self,t); c = get(self,t); *************** *** 961,968 **** tpush(self,t,NULL,NULL,self->CurrentContext->argv[atoi(temp)],FALSE,NULL,NULL); c = get(self,t); break; - case '.': /* escaped period */ - break; /* translates to just a period */ default: /* oops, it wasn't translatable */ translated = FALSE; break; --- 1097,1102 ---- *************** *** 974,980 **** /* if in normal mode, just print the char */ /* otherwise, put out the escape char + char */ ! if (!translated && (self->v_RawMode || self->v_CopyMode)) { ung(self,c,t); c = self->EscChar; } --- 1108,1114 ---- /* if in normal mode, just print the char */ /* otherwise, put out the escape char + char */ ! if (!translated && (self->v_RawMode || self->v_CopyMode || self->gc_mode)) { ung(self,c,t); c = self->EscChar; } *************** *** 1000,1008 **** --- 1134,1145 ---- CMD(af,af_cmd); CMD(rr,rr_cmd); CMD(ds,ds_cmd); + CMD(as,as_cmd); CMD(so,so_cmd); CMD(de,de_cmd); + CMD(am,am_cmd); CMD(di,di_cmd); + CMD(da,da_cmd); CMD(c0,c0_cmd); CMD(c1,c1_cmd); CMD(PM,PM_cmd); *************** *** 1021,1026 **** --- 1158,1181 ---- CMD(sv,sv_cmd); CMD(ig,ig_cmd); CMD(ev,ev_cmd); + /* + CMD(Ct, Ct_cmd); + CMD(Et, Et_cmd); + */ + CMD(TS, Ct_cmd); + CMD(TE, Et_cmd); + CMD(Hd, Hd_cmd); + CMD(Gc, Gc_cmd); + CMD(Ps, Ps_cmd); + CMD(Bu, Bu_cmd); + + #ifdef TROFF_TAGS_ENV + CMD(TA, Tag_cmd); + #endif /* TROFF_TAGS_ENV */ + + CMD(bp, bp_cmd); + CMD(Fn, Fn_cmd); + CMD(Ce, Ce_cmd); /* these commands do nothing but cause a line break */ CMD(bp,br_cmd); /* ?? */ *************** *** 1030,1035 **** --- 1185,1191 ---- GOOFY(ie,ie_cmd); GOOFY(el,el_cmd); GOOFY(ds,ds_cmd); + GOOFY(as,as_cmd); GOOFY(tl,tl_cmd); GOOFY(tr,tr_cmd); /* GOOFY(tm,tm_cmd);*/ *************** *** 1044,1068 **** struct classheader *classID; struct rofftext *self; { struct timeval tv; struct tm *tm; int i,mult; char temp[64]; ! DEBUG((stderr, "ENTER Starting")); self->Registers = hash_New(); ! DEBUG((stderr, "doing time")); gettimeofday(&tv,NULL); tm = localtime(&tv.tv_sec); putregister(self,"dw",(int)tm->tm_wday+1,reg_Single,0,0); putregister(self,"dy",(int)tm->tm_mday,reg_Single,0,0); putregister(self,"mo",(int)tm->tm_mon+1,reg_Single,0,0); putregister(self,"yr",(int)tm->tm_year,reg_Single,0,0); putregister(self,"%",(int)1,reg_Single,0,0); ! DEBUG((stderr, "init stuff")); /* initialize commands and macros */ self->Commands = hash_New(); self->Macros = hash_New(); --- 1200,1240 ---- struct classheader *classID; struct rofftext *self; { + #if defined(M_UNIX) + time_t seconds; + #else struct timeval tv; + #endif /* defined(M_UNIX) */ + struct tm *tm; int i,mult; char temp[64]; ! DEBUG(1, (stderr, "ENTER Starting\n")); self->Registers = hash_New(); ! DEBUG(1, (stderr, "doing time\n")); ! #if defined(M_UNIX) ! seconds = time(0); ! tm = localtime(seconds); ! #else gettimeofday(&tv,NULL); tm = localtime(&tv.tv_sec); + #endif /* M_UNIX */ + putregister(self,"dw",(int)tm->tm_wday+1,reg_Single,0,0); putregister(self,"dy",(int)tm->tm_mday,reg_Single,0,0); putregister(self,"mo",(int)tm->tm_mon+1,reg_Single,0,0); putregister(self,"yr",(int)tm->tm_year,reg_Single,0,0); putregister(self,"%",(int)1,reg_Single,0,0); + putregister(self, ".h", 0, reg_Single, 0, 0); + putregister(self, ".p", 10000, reg_Single, 0, 0); + putregister(self, ".t", 10000, reg_Single, 0, 0); + putregister(self, "nl", 1, reg_Single, 0, 0); + putregister(self, ".k", 1, reg_Single, 0, 0); ! DEBUG(1, (stderr, "init stuff\n")); /* initialize commands and macros */ self->Commands = hash_New(); self->Macros = hash_New(); *************** *** 1073,1079 **** CreateDefaultCommands(self); /* initialize arguments */ ! DEBUG((stderr, "context")); self->CurrentContext = (IC)malloc(sizeof(struct InputContext)); self->CurrentContext->argv = (char **)malloc(sizeof(char *)*10); for(i=0;i<10;i++) { --- 1245,1251 ---- CreateDefaultCommands(self); /* initialize arguments */ ! DEBUG(1, (stderr, "context\n")); self->CurrentContext = (IC)malloc(sizeof(struct InputContext)); self->CurrentContext->argv = (char **)malloc(sizeof(char *)*10); for(i=0;i<10;i++) { *************** *** 1083,1089 **** self->CurrentContext->argc = 0; ! DEBUG((stderr, "indents")); /* initialize indents */ for (i=0,mult=1;iIndentStyle[i]= self->TempIndentStyle[i] = self->MinusTempIndentStyle[i] = 0; --- 1255,1261 ---- self->CurrentContext->argc = 0; ! DEBUG(1, (stderr, "indents\n")); /* initialize indents */ for (i=0,mult=1;iIndentStyle[i]= self->TempIndentStyle[i] = self->MinusTempIndentStyle[i] = 0; *************** *** 1095,1101 **** self->MinusTempIndentName[i] = StrDup(temp); } ! DEBUG((stderr, "environment")); /* environment stack */ CreateEnvirons(self); self->EnvironStack = glist_New(); --- 1267,1273 ---- self->MinusTempIndentName[i] = StrDup(temp); } ! DEBUG(1, (stderr, "environment\n")); /* environment stack */ CreateEnvirons(self); self->EnvironStack = glist_New(); *************** *** 1102,1108 **** self->DiversionStack = glist_New(); self->CurrentDiversion = CreateDiversion(self,NULL); ! DEBUG((stderr, "xlation table")); /* translation table */ for(i=0;i<256;i++) self->Berliz[i] = i; --- 1274,1280 ---- self->DiversionStack = glist_New(); self->CurrentDiversion = CreateDiversion(self,NULL); ! DEBUG(1, (stderr, "xlation table\n")); /* translation table */ for(i=0;i<256;i++) self->Berliz[i] = i; *************** *** 1112,1118 **** self->v_InCond = 0; self->v_TrapBlown = FALSE; self->v_CopyMode = FALSE; ! self->v_SnarfOutput = NULL; self->v_ReadEscapes = TRUE; self->v_RawMode = FALSE; self->v_LastIfResult = TRUE; --- 1284,1299 ---- self->v_InCond = 0; self->v_TrapBlown = FALSE; self->v_CopyMode = FALSE; ! self->v_TblMode = 0; ! self->v_TblTab = '\t'; ! self->Tbl = NULL; ! self->baseline = 0; ! self->basestyle = 0; ! self->Fn = NULL; ! self->fnpos = 0; ! self->gc_mode = FALSE; ! self->out_column = 0; ! self->tag_count = 0; self->v_ReadEscapes = TRUE; self->v_RawMode = FALSE; self->v_LastIfResult = TRUE; *************** *** 1127,1133 **** self->v_TempIndentTrap = 0; self->v_BlankLine = TRUE; self->v_DiversionLevel = 0; - self->v_FillMode = TRUE; self->current = '\n'; for(i=0;i<8;i++) { self->ScaleFactor[i] = SCALE[i]; --- 1308,1313 ---- *************** *** 1138,1148 **** self->CurrentFontSize = 10; ! DEBUG((stderr, "template")); rofftext_ReadTemplate(self,"roff",FALSE); self->text = (struct text *)self; ! DEBUG((stderr, "stacks")); self->stack = (struct stackelt *)malloc(STACKSIZE*sizeof(struct stackelt)); self->tempstack = (struct tempelt *)malloc(STACKSIZE*sizeof(struct tempelt)); self->stack->env = environment_GetEnclosing(self->text->rootEnvironment, 0L); --- 1318,1328 ---- self->CurrentFontSize = 10; ! DEBUG(1, (stderr, "template\n")); rofftext_ReadTemplate(self,"roff",FALSE); self->text = (struct text *)self; ! DEBUG(1, (stderr, "stacks\n")); self->stack = (struct stackelt *)malloc(STACKSIZE*sizeof(struct stackelt)); self->tempstack = (struct tempelt *)malloc(STACKSIZE*sizeof(struct tempelt)); self->stack->env = environment_GetEnclosing(self->text->rootEnvironment, 0L); *************** *** 1157,1164 **** self->filename = NULL; self->HelpMode = FALSE; self->BeCompletelyBogus = FALSE; ! self->EndMacros = glist_Create(FreeTrap); self->PrintWarnings = FALSE; return TRUE; } --- 1337,1346 ---- self->filename = NULL; self->HelpMode = FALSE; self->BeCompletelyBogus = FALSE; ! self->EndMacros = glist_New(); self->PrintWarnings = FALSE; + + rofftext_SetCopyAsText(self,TRUE); return TRUE; } *************** *** 1182,1191 **** procedure cmd = NULL; char *Arg[MAXARGS]; ! DEBUG((stderr,"\n",temp)); if ((cmd = (procedure)(long)hash_Lookup(self->Goofy,temp)) == NULL) { --- 1364,1373 ---- procedure cmd = NULL; char *Arg[MAXARGS]; ! DEBUG(1, (stderr,"\n",temp)); if ((cmd = (procedure)(long)hash_Lookup(self->Goofy,temp)) == NULL) { *************** *** 1209,1223 **** for(j=i;jv_CopyMode; + self->v_CopyMode = TRUE; + while ((c = get(self, t)) != EOF) { + put(self, c); + if (c == '\n') break; + } + self->v_CopyMode = oldcopy; + continue; + } + else ung(self, x, t); + } + /* in copy mode, pass everything straight through */ /* until you reach 'cmd' or .. */ *************** *** 1300,1306 **** self->v_BlankLine = TRUE; /* handle no-fill mode here*/ ! if (self->v_FillMode) { if (Is_BOL(self)) { DoBreak(self); --- 1498,1504 ---- self->v_BlankLine = TRUE; /* handle no-fill mode here*/ ! if (self->CurrentEnviron->fill) { if (Is_BOL(self)) { DoBreak(self); *************** *** 1322,1328 **** case ' ': case '\t': /* handle no-fill mode here*/ ! if (self->v_FillMode) { if (!self->v_MultiSpace) put(self,c); self->v_MultiSpace = TRUE; --- 1520,1526 ---- case ' ': case '\t': /* handle no-fill mode here*/ ! if (self->CurrentEnviron->fill) { if (!self->v_MultiSpace) put(self,c); self->v_MultiSpace = TRUE; *************** *** 1331,1336 **** --- 1529,1539 ---- put(self,c); break; default: + if (self->v_TblMode) { + ung(self, c, t); + InsertTbl(self, t); + break; + } self->v_BlankLine = FALSE; self->v_MultiSpace = FALSE; put(self,c); *************** *** 1340,1345 **** --- 1543,1636 ---- } } + + /* This is called if it is determined that the file has already + * been formatted. It takes care of overstruck (bold) and underlines (italic) + * things that nroff likes to put in. + */ + #define M_PLAIN 1 + #define M_BOLD 2 + #define M_ITALIC 3 + static int setmode(self, oldmode, newmode) + struct rofftext *self; + int oldmode, newmode; { + char *font; + if (oldmode == newmode) return oldmode; + if (newmode == M_PLAIN) font = "typewriter"; + if (newmode == M_BOLD) font = "bold"; + if (newmode == M_ITALIC) font = "italic"; + self->CurrentEnviron->prevFont = self->CurrentEnviron->font; + self->CurrentEnviron->font = font; + self->CurrentEnviron->fontStyle = ChangeStyle(self,self->CurrentEnviron->fontStyle,font); + return newmode; + } + + static long ReadFormatted(self, file, id) + struct rofftext *self; + FILE *file; + long id; + { + int c, lastc; + int mode = 0, newmode = M_PLAIN; + mode = setmode(self, mode, newmode); + self->Input = topen(self,NULL,file,NULL); + lastc = get(self,self->Input); + while ((lastc != EOF) && (c = g(self,self->Input)) != EOF) { + if (c != '\b') { + mode = setmode(self, mode, newmode); + put(self, lastc); + lastc = c; + newmode = M_PLAIN; + continue; + } + c = g(self, self->Input); + if (c == EOF) break; + if (lastc == '_') { + newmode = M_ITALIC; + lastc = c; + } + else if (c == lastc) { + newmode = M_BOLD; + } + else { + put(self, lastc); + newmode = M_PLAIN; + lastc = c; + } + + } + put(self, lastc); + put(self,'\n'); + CloseAllStyles(self); + return dataobject_NOREADERROR; + } + + static boolean istroff(fp) + FILE *fp; { + long pos; + long textpos; + int i; + char line[250]; + int found = FALSE; + if (fp == NULL) return TRUE; + textpos = pos = ftell(fp); + for (i = 0; i < 40; i++) { + if (fgets(line, 250, fp) == NULL) break; + if (strncmp(line, ". #", 3) == 0) { + textpos = ftell(fp); + continue; + } + if (line[0] == '.' || line[0] == '\'') { + found = TRUE; + break; + } + } + if (found) fseek(fp, pos, 0); + else fseek(fp, textpos, 0); + return found; + } + + long rofftext__Read(self,file,id) struct rofftext *self; FILE *file; *************** *** 1355,1360 **** --- 1646,1653 ---- fprintf(stderr,"rofftext: could not open input file\n"); } + if (! istroff(file)) return ReadFormatted(self, file, id); + self->Input = topen(self,NULL,file,NULL); *************** *** 1384,1391 **** cmd = (procedure)(long)hash_Lookup(self->Commands,t->macro); self->Nullarg[0] = t->macro; if (cmd) ! (*cmd)(self,self->Input,0,1,self->Nullarg); ! FreeTrap(t); } } Set_BOL(self); --- 1677,1683 ---- cmd = (procedure)(long)hash_Lookup(self->Commands,t->macro); self->Nullarg[0] = t->macro; if (cmd) ! (*cmd)(self,self->Input,0,1,self->Nullarg); } } Set_BOL(self); *************** *** 1395,1405 **** put(self,'\n'); CloseAllStyles(self); ! if (self->Input->t != NULL) { ! free(self->Input->t); ! } ! free(self->Input); ! self->Input = NULL; return dataobject_NOREADERROR; } --- 1687,1697 ---- put(self,'\n'); CloseAllStyles(self); ! ! #ifdef TROFF_TAGS_ENV ! Tag_fixup(self); ! #endif /* TROFF_TAGS_ENV */ ! return dataobject_NOREADERROR; } *************** *** 1414,1421 **** struct classheader *classID; { #ifdef DEBUGGING ! if ((char *)getenv("ROFFDEBUG") != (char *) NULL) ! ROFFDEBUG = 1; #endif /* DEBUGGING */ return TRUE; } --- 1706,1714 ---- struct classheader *classID; { #ifdef DEBUGGING ! char *debval = (char *)getenv("ROFFDEBUG"); ! if (debval != NULL) ! ROFFDEBUG = atoi(debval); #endif /* DEBUGGING */ return TRUE; } *************** *** 1423,1494 **** void rofftext__FinalizeObject(classID,self) struct classheader *classID; struct rofftext *self; ! { ! int i; ! ! if (self->v_Trap != NULL) { ! free(self->v_Trap); ! } ! ! if (self->Registers != NULL) { ! hash_Clear(self->Registers, free); ! hash_Destroy(self->Registers); ! } ! if (self->Commands != NULL) { ! /* Need to clear out the keys */ ! hash_Clear(self->Commands, NULL); ! hash_Destroy(self->Commands); ! } ! if (self->Macros != NULL) { ! /* Need to clear out both the keys and the values */ ! hash_Clear(self->Macros, free); ! hash_Destroy(self->Macros); ! } ! if (self->Goofy) { ! /* Need to clear out the keys */ ! hash_Clear(self->Goofy, NULL); ! hash_Destroy(self->Goofy); ! } ! if (self->ArgStack != NULL) { ! glist_Destroy(self->ArgStack); ! } ! if (self->SpecialChars != NULL) { ! /* Need top clear out both the key and the values */ ! hash_Clear(self->SpecialChars, free); ! hash_Destroy(self->SpecialChars); ! } ! ! if (self->CurrentContext != NULL) { ! DestroyContext(self->CurrentContext); ! } ! ! /* initialize indents */ ! for (i=0;iIndentName[i]); ! free(self->TempIndentName[i]); ! free(self->MinusTempIndentName[i]); ! } ! ! if (self->EnvironStack != NULL) ! glist_Destroy(self->EnvironStack); ! if (self->DiversionStack != NULL) ! glist_Destroy(self->DiversionStack); ! if (self->CurrentDiversion != NULL) ! DestroyDiversion(self, self->CurrentDiversion); - DestroyEnvirons(self); - - if (self->stack != NULL) { - free(self->stack); - } - if (self->tempstack != NULL) { - free(self->tempstack); - } - if (self->EndMacros != NULL) { - glist_Destroy(self->EndMacros); - } - } void rofftext__SetAttributes(self,atts) --- 1716,1724 ---- void rofftext__FinalizeObject(classID,self) struct classheader *classID; struct rofftext *self; ! {} void rofftext__SetAttributes(self,atts) *************** *** 1499,1505 **** while(atts!=NULL){ ! DEBUG((stderr,"Found attribute (%s)\n",atts->key)); if (strncmp(atts->key,"filename",8) == 0) { self->filename = StrDup(atts->value.string); } --- 1729,1735 ---- while(atts!=NULL){ ! DEBUG(1, (stderr,"Found attribute (%s)\n",atts->key)); if (strncmp(atts->key,"filename",8) == 0) { self->filename = StrDup(atts->value.string); } *** atk/rofftext/rofftxta.c Wed Nov 22 12:27:53 1989 --- atk/rofftext/rofftxta.c.NEW Thu May 23 12:26: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/sm/releases/X.V11R4/andrew/atk/rofftext/RCS/rofftxta.c,v 2.7 89/05/16 11:10:14 ghoti Exp $ */ /* $ACIS: $ */ ! /* $Source: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/rofftext/RCS/rofftxta.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/rofftext/RCS/rofftxta.c,v 2.7 89/05/16 11:10:14 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/rofftext/RCS/rofftxta.c,v 2.9 91/02/05 18:58:37 gk5g Exp Locker: gk5g $ */ /* $ACIS: $ */ ! /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/rofftext/RCS/rofftxta.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/rofftext/RCS/rofftxta.c,v 2.9 91/02/05 18:58:37 gk5g Exp Locker: gk5g $ "; #endif /* lint */ /* *************** *** 70,76 **** int argc; char **argv; { ! char temp2[128]; if(!super_ParseArgs(self,argc,argv)) return FALSE; --- 70,77 ---- int argc; char **argv; { ! char temp2[128], *andrewdir, *getenv(); ! boolean slash = FALSE; if(!super_ParseArgs(self,argc,argv)) return FALSE; *************** *** 102,110 **** self->RoffType = TRUE; break; case 'm': ! GETARGSTR(temp); ! sprintf(temp2,"/usr/lib/tmac/tmac.%s",temp); ! self->macrofile = StrDup(temp2); break; case 'o': GETARGSTR(self->outputfile); --- 103,123 ---- self->RoffType = TRUE; break; case 'm': ! GETARGSTR(temp); ! switch(*temp) { ! case 'm': ! if((andrewdir = getenv("ANDREWDIR")) == NULL) ! andrewdir = "/usr/andrew"; ! else if(andrewdir[strlen(andrewdir) - 1] == '/') ! slash = TRUE; ! sprintf(temp2,"%s%slib/tmac/tmac.%s", andrewdir, ! (slash ? "" : "/"), temp); ! break; ! case 'a': ! sprintf(temp2,"/usr/lib/tmac/tmac.%s", temp); ! break; ! } ! self->macrofile = StrDup(temp2); break; case 'o': GETARGSTR(self->outputfile); *** atk/rofftext/rofftext.ch Wed Nov 22 12:27:42 1989 --- atk/rofftext/rofftext.ch.NEW Wed Feb 13 16:53: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/sm/releases/X.V11R4/andrew/atk/rofftext/RCS/rofftext.ch,v 2.6 89/04/04 13:27:32 mp1w Exp $ */ /* $ACIS: $ */ ! /* $Source: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/rofftext/RCS/rofftext.ch,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsid_rofftext_H = "$Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/rofftext/RCS/rofftext.ch,v 2.6 89/04/04 13:27:32 mp1w Exp $ "; #endif /* !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) */ /* rofftext - translate troff/nroff to ATK text object --- 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/rofftext/RCS/rofftext.ch,v 2.8 91/02/12 15:26:52 gk5g Exp $ */ /* $ACIS: $ */ ! /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/rofftext/RCS/rofftext.ch,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsid_rofftext_H = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/rofftext/RCS/rofftext.ch,v 2.8 91/02/12 15:26:52 gk5g Exp $ "; #endif /* !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) */ /* rofftext - translate troff/nroff to ATK text object *************** *** 14,19 **** --- 14,29 ---- * */ + #include + #include + #define MAX_COLS 40 + #define MAX_TAG 200 + struct tag_tbl { + char *tag; /* tag value */ + int def; /* TRUE if def, FALSE if ref */ + long pos; /* position of definition */ + struct link *l; /* for ref only */ + }; /* environment: point size *************** *** 79,85 **** int blocksize; }; typedef struct MagicBuf *BUF; - #define BUFSIZ 1024 #define ClearBuf(b) ((b)->ptr = (b)->begin) #define Buf2Str(b) ((b)->begin) BUF NewBuf(); --- 89,94 ---- *************** *** 121,126 **** --- 130,136 ---- struct roffEnviron{ int pointSize; + boolean fill; char *font; /* name of the font */ char *prevFont; int fontStyle; /* style ID for font */ *************** *** 137,145 **** #ifdef DEBUGGING extern int ROFFDEBUG; ! #define DEBUG(arg) if (ROFFDEBUG != 0) fprintf arg #else /* DEBUGGING */ ! #define DEBUG(arg) #endif /* DEBUGGING */ --- 147,155 ---- #ifdef DEBUGGING extern int ROFFDEBUG; ! #define DEBUG(lev, arg) if (ROFFDEBUG > (lev)) fprintf arg #else /* DEBUGGING */ ! #define DEBUG(lev, arg) #endif /* DEBUGGING */ *************** *** 152,157 **** --- 162,168 ---- int level; /* diversion level */ boolean NoSpaceMode; int OutputDone; + BUF SnarfOutput; }; *************** *** 196,202 **** int v_InCond; /* inside conditional input */ boolean v_TrapBlown; /* TRUE after trap is sprung */ boolean v_CopyMode; /* inside macro definition */ ! BUF v_SnarfOutput; /* save output in a buffer */ boolean v_ReadEscapes; /* escape mechanism is turned on */ boolean v_RawMode; /* interpret only \{ and \} */ boolean v_LastIfResult; /* for .el requests */ --- 207,226 ---- int v_InCond; /* inside conditional input */ boolean v_TrapBlown; /* TRUE after trap is sprung */ boolean v_CopyMode; /* inside macro definition */ ! int v_TblMode; ! char v_TblTab; ! int colWidth[MAX_COLS]; ! struct table *Tbl; ! int baseline; ! int basestyle; ! struct fnote *Fn; ! int fnpos; ! int gc_mode; ! int out_column; ! long picBegin; ! struct link *picButton; ! int tag_count; ! struct tag_tbl tags[MAX_TAG]; boolean v_ReadEscapes; /* escape mechanism is turned on */ boolean v_RawMode; /* interpret only \{ and \} */ boolean v_LastIfResult; /* for .el requests */ *************** *** 219,225 **** int v_DiversionLevel; struct diversionLevel *CurrentDiversion; struct glist *DiversionStack; - boolean v_FillMode; unsigned char Berliz[256]; /* translation table */ --- 243,248 ---- *** atk/rofftext/rofftext.h Mon Aug 6 11:08:52 1990 --- atk/rofftext/rofftext.h.NEW Tue Feb 5 18:03:18 1991 *************** *** 2,16 **** * 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/rofftext/RCS/rofftext.h,v 2.4 90/06/06 14:48:15 gk5g Exp $ */ /* $ACIS: $ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/rofftext/RCS/rofftext.h,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsid_h = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/rofftext/RCS/rofftext.h,v 2.4 90/06/06 14:48:15 gk5g Exp $ "; #endif /* !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) */ ! #ifndef _AIX /* type checking */ SetIndent(/*struct rofftext *self,int u*/); SetTempIndent(/*struct rofftext *self,int u*/); --- 2,16 ---- * 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/rofftext/RCS/rofftext.h,v 2.5 91/02/05 17:29:02 gk5g Exp $ */ /* $ACIS: $ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/rofftext/RCS/rofftext.h,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsid_h = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/rofftext/RCS/rofftext.h,v 2.5 91/02/05 17:29:02 gk5g Exp $ "; #endif /* !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) */ ! #ifndef AIX /* type checking */ SetIndent(/*struct rofftext *self,int u*/); SetTempIndent(/*struct rofftext *self,int u*/); *************** *** 38,41 **** get(/*struct rofftext *self, Trickle t*/); DoCommand(/*struct rofftext *self, Trickle t, char *name, boolean br*/); Scan(/*struct rofftext *self, Trickle t, char *cmd*/); ! #endif /* _AIX */ --- 38,41 ---- get(/*struct rofftext *self, Trickle t*/); DoCommand(/*struct rofftext *self, Trickle t, char *name, boolean br*/); Scan(/*struct rofftext *self, Trickle t, char *cmd*/); ! #endif /* AIX */ *** atk/rofftext/roffutil.c Wed Nov 22 12:27:55 1989 --- atk/rofftext/roffutil.c.NEW Tue Feb 5 18:03:25 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/rofftext/RCS/roffutil.c,v 2.4 89/02/17 17:06:09 ghoti Exp $ */ /* $ACIS: $ */ ! /* $Source: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/rofftext/RCS/roffutil.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/rofftext/RCS/roffutil.c,v 2.4 89/02/17 17:06:09 ghoti Exp $ "; #endif /* lint */ /* utility stuff for rofftext --- 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/rofftext/RCS/roffutil.c,v 2.5 91/02/05 17:43:25 gk5g Exp $ */ /* $ACIS: $ */ ! /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/rofftext/RCS/roffutil.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/rofftext/RCS/roffutil.c,v 2.5 91/02/05 17:43:25 gk5g Exp $ "; #endif /* lint */ /* utility stuff for rofftext *************** *** 29,34 **** --- 29,41 ---- return b; } + FreeBuf(b) + BUF b; + { + free(b->begin); + free(b); + } + Add2Buf(b,c) BUF b; char c; *************** *** 35,45 **** { char *temp; if (b->ptr >= b->end) { ! DEBUG((stderr,"<>",b,b->begin,b->ptr,b->end)); b->size += b->blocksize; temp = realloc(b->begin,b->size); if (temp == NULL) ! DEBUG((stderr,"rofftext: HELP! Buffer couldn't grow!\n")); b->end = (temp + b->size - 1); b->ptr = (b->ptr - b->begin + temp); b->begin = temp; --- 42,52 ---- { char *temp; if (b->ptr >= b->end) { ! DEBUG(1, (stderr,"<>",b,b->begin,b->ptr,b->end)); b->size += b->blocksize; temp = realloc(b->begin,b->size); if (temp == NULL) ! DEBUG(1, (stderr,"rofftext: HELP! Buffer couldn't grow!\n")); b->end = (temp + b->size - 1); b->ptr = (b->ptr - b->begin + temp); b->begin = temp; *************** *** 58,63 **** --- 65,71 ---- for (i=0;i<4;i++) { e = self->Environs[i] = (struct roffEnviron *)malloc(sizeof(struct roffEnviron)); e->pointSize = 10; + e->fill = TRUE; e->font = "roman"; e->fontStyle = 0; e->prevFont = e->font; *************** *** 92,98 **** int env; { int indent; ! DEBUG((stderr,"<<>>\n")); glist_Push(self->EnvironStack,self->CurrentEnviron); indent = self->CurrentEnviron->indent; --- 100,106 ---- int env; { int indent; ! DEBUG(1, (stderr,"<<>>\n")); glist_Push(self->EnvironStack,self->CurrentEnviron); indent = self->CurrentEnviron->indent; *************** *** 111,117 **** struct rofftext *self; { int indent; ! DEBUG((stderr,"<<>>\n")); indent = self->CurrentEnviron->indent; EndStyle(self,self->CurrentEnviron->fontStyle); self->CurrentEnviron = (struct roffEnviron *)glist_Pop(self->EnvironStack); --- 119,125 ---- struct rofftext *self; { int indent; ! DEBUG(1, (stderr,"<<>>\n")); indent = self->CurrentEnviron->indent; EndStyle(self,self->CurrentEnviron->fontStyle); self->CurrentEnviron = (struct roffEnviron *)glist_Pop(self->EnvironStack); *************** *** 134,139 **** --- 142,148 ---- d->level = 0; d->NoSpaceMode = FALSE; d->OutputDone = 0; + d->SnarfOutput = NULL; } else { d->NextDiversionTrap = c->NextDiversionTrap; *************** *** 144,149 **** --- 153,159 ---- d->level = c->level+1; d->NoSpaceMode = c->NoSpaceMode; d->OutputDone = c->OutputDone; + d->SnarfOutput = c->SnarfOutput; } return d; *** atk/rofftext/roffutil.h Mon Aug 6 11:08:53 1990 --- atk/rofftext/roffutil.h.NEW Tue Feb 5 18:03:23 1991 *************** *** 2,16 **** * 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/rofftext/RCS/roffutil.h,v 2.4 90/06/06 14:48:27 gk5g Exp $ */ /* $ACIS: $ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/rofftext/RCS/roffutil.h,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsid_h = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/rofftext/RCS/roffutil.h,v 2.4 90/06/06 14:48:27 gk5g Exp $ "; #endif /* !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) */ ! #ifndef _AIX /* utilities for rofftext */ Add2Buf(); BUF NewBuf(); --- 2,16 ---- * 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/rofftext/RCS/roffutil.h,v 2.5 91/02/05 17:29:06 gk5g Exp $ */ /* $ACIS: $ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/rofftext/RCS/roffutil.h,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsid_h = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/rofftext/RCS/roffutil.h,v 2.5 91/02/05 17:29:06 gk5g Exp $ "; #endif /* !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) */ ! #ifndef AIX /* utilities for rofftext */ Add2Buf(); BUF NewBuf(); *************** *** 22,25 **** DestroyDiversion(); PushDiversion(); PopDiversion(); ! #endif /* _AIX */ --- 22,25 ---- DestroyDiversion(); PushDiversion(); PopDiversion(); ! #endif /* AIX */ *** atk/rofftext/README Thu May 30 20:06:37 1991 --- atk/rofftext/README.NEW Tue Feb 5 18:03:26 1991 *************** *** 0 **** --- 1,11 ---- + Rofftext enhancement + Author: Charles Hayden cch@mtgzx.att.com 4/20/90 + + Extensively modified to support additional troff macros. + Also included is an extensively-modified mm macro package that eliminates a lot of the + garbage that mm goes through for no useful purpose, and which just generates extraneous stuff anyway. + + This package handles footnotes and references by turning them into Andrew footnotes; tables by turning them into spreadsheets; and tags and PIC by turning them into links. It has an experimental hypertext button macro, .BU. + Headings (using the .H macro) are marked so that they show up in the Table of Contents. + Several bugs in original rofftext are fixed, but otherwise it is upwardly compatible. + *** atk/rofftext/mantext.c Thu May 30 20:06:46 1991 --- atk/rofftext/mantext.c.NEW Tue Feb 5 18:03:28 1991 *************** *** 0 **** --- 1,80 ---- + + /* mantext: link to rofftext -man. */ + + #include + + #include + #include + + #include + + #define INITIAL 100 + #define INCREMENT 1000 + + boolean mantext__InitializeObject(classID,self) + struct classheader *classID; + struct mantext *self; + { + self->nLines = 0; + self->nAlloc = INITIAL; + self->filename[0] = '\0'; + self->lineMark = (struct mark **)malloc(self->nAlloc*sizeof(struct mark *)); + if (self->lineMark == NULL) return FALSE; + mantext_SetLinePos(self, 0L, 0L); + return TRUE; + } + + long mantext__Read(self, file, id) + struct mantext *self; + FILE *file; + long id; { + long tmpRetValue; + struct rofftext *r = (struct rofftext *)self; + + /* copy the filename that was put into rofftext via SetAttributes */ + if (r->filename != NULL) strcpy(self->filename, r->filename); + r->inputfiles = (char **)malloc(2 * sizeof(char *)); + r->inputfiles[0] = NULL; + r->inputfiles[1] = NULL; + r->filename = NULL; + + r->macrofile = "/usr/lib/tmac/tmac.an"; + r->RoffType = FALSE; + r->HelpMode = FALSE; + + tmpRetValue = super_Read(r, file, (long)r); + + return tmpRetValue; + + } + + long mantext__GetLinePos(self, line) + struct mantext *self; + long line; { + line -= 2; + if (line > self->nLines) line = self->nLines; + if (line < 0) line = 0; + return mark_GetPos(self->lineMark[line]); + } + + void mantext__SetLinePos(self, line, pos) + struct mantext *self; + long line; + long pos; { + if (line < 0) return; + if (line >= self->nAlloc) { + self->nAlloc += INCREMENT; + self->lineMark = (struct mark **)realloc(self->lineMark, self->nAlloc*sizeof(struct mark *)); + } + if (self->lineMark == NULL) return; + self->lineMark[line] = mantext_CreateMark(self, pos, 0); + self->nLines = line; + /* must make sure we have not skipped some */ + } + + + void mantext__GetFilename(self, filename) + struct mantext *self; + char *filename; { + strcpy(filename, self->filename); + } *** atk/rofftext/mantext.ch Thu May 30 20:06:54 1991 --- atk/rofftext/mantext.ch.NEW Tue Feb 5 18:03:29 1991 *************** *** 0 **** --- 1,18 ---- + /* mantext.ch: link to rofftext -man */ + + #include + + class mantext: rofftext { + classprocedures: + InitializeObject(struct mantext *self) returns boolean; + overrides: + Read(FILE *file, long id) returns long; + methods: + GetLinePos(long line) returns long; + SetLinePos(long line, long pos); + GetFilename(char *filename); + data: + int nLines, nAlloc; + struct mark **lineMark; + char filename[500]; + }; *** atk/rofftext/mantext.tpl Thu May 30 20:07:03 1991 --- atk/rofftext/mantext.tpl.NEW Tue Feb 5 18:03:29 1991 *************** *** 0 **** --- 1,18 ---- + \begindata{text, 1} + \textdsversion{12} + \define{comment + attr:[FontFace Italic Int Set] + attr:[FontFace FixedFace Int Clear] + attr:[FontSize PreviousFontSize Point 2] + attr:[FontFamily Andy 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} *** atk/rofftext/mmtext.c Fri Jun 7 13:53:53 1991 --- atk/rofftext/mmtext.c.NEW Fri Jun 7 13:50:22 1991 *************** *** 0 **** --- 1,93 ---- + + /* mmtext: link to rofftext -mm. */ + + #include + + #include + #include + #include + #include + #include + + #include + + #define INITIAL 100 + #define INCREMENT 1000 + + boolean mmtext__InitializeObject(classID,self) + struct classheader *classID; + struct mmtext *self; + { + self->nLines = 0; + self->nAlloc = INITIAL; + self->filename[0] = '\0'; + self->lineMark = (struct mark **)malloc(self->nAlloc*sizeof(struct mark *)); + if (self->lineMark == NULL) return FALSE; + mmtext_SetLinePos(self, 0L, 0L); + return TRUE; + } + + long mmtext__Read(self, file, id) + struct mmtext *self; + FILE *file; + long id; { + long tmpRetValue; + struct rofftext *r = (struct rofftext *)self; + struct buffer *buf = buffer_FindBufferByData(self); + + /* copy the filename that was put into rofftext via SetAttributes */ + if (r->filename != NULL) strcpy(self->filename, r->filename); + r->inputfiles = (char **)malloc(2 * sizeof(char *)); + r->inputfiles[0] = NULL; + r->inputfiles[1] = NULL; + r->filename = NULL; + + r->macrofile = environ_AndrewDir("/lib/tmac/tmac.m"); + r->RoffType = FALSE; + r->HelpMode = FALSE; + + tmpRetValue = super_Read(r, file, (long)r); + + /* set read-only for buffer */ + if (buf != NULL) { + struct text *text = (struct text *)buffer_GetData(buf); + buffer_SetReadOnly(buf, TRUE); + if (class_IsTypeByName(class_GetTypeName(text), "text")) { + text_SetReadOnly(text, TRUE); + } + } + + return tmpRetValue; + + } + + long mmtext__GetLinePos(self, line) + struct mmtext *self; + long line; { + line -= 2; + if (line > self->nLines) line = self->nLines; + if (line < 0) line = 0; + return mark_GetPos(self->lineMark[line]); + } + + void mmtext__SetLinePos(self, line, pos) + struct mmtext *self; + long line; + long pos; { + if (line < 0) return; + if (line >= self->nAlloc) { + self->nAlloc += INCREMENT; + self->lineMark = (struct mark **)realloc(self->lineMark, self->nAlloc*sizeof(struct mark *)); + } + if (self->lineMark == NULL) return; + self->lineMark[line] = mmtext_CreateMark(self, pos, 0); + self->nLines = line; + /* must make sure we have not skipped some */ + } + + + void mmtext__GetFilename(self, filename) + struct mmtext *self; + char *filename; { + strcpy(filename, self->filename); + } *** atk/rofftext/mmtext.ch Thu May 30 20:07:19 1991 --- atk/rofftext/mmtext.ch.NEW Tue Feb 5 18:03:31 1991 *************** *** 0 **** --- 1,18 ---- + /* mmtext.ch: link to rofftext -mm */ + + #include + + class mmtext: rofftext { + classprocedures: + InitializeObject(struct mmtext *self) returns boolean; + overrides: + Read(FILE *file, long id) returns long; + methods: + GetLinePos(long line) returns long; + SetLinePos(long line, long pos); + GetFilename(char *filename); + data: + int nLines, nAlloc; + struct mark **lineMark; + char filename[500]; + }; *** atk/rofftext/mmtext.tpl Thu May 30 20:07:27 1991 --- atk/rofftext/mmtext.tpl.NEW Tue Feb 5 18:03:31 1991 *************** *** 0 **** --- 1,18 ---- + \begindata{text, 1} + \textdsversion{12} + \define{comment + attr:[FontFace Italic Int Set] + attr:[FontFace FixedFace Int Clear] + attr:[FontSize PreviousFontSize Point 2] + attr:[FontFamily Andy 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} *** atk/rofftext/tmac.an Thu May 30 20:07:36 1991 --- atk/rofftext/tmac.an.NEW Tue Feb 5 18:03:32 1991 *************** *** 0 **** --- 1,25 ---- + .\" + .\" 5799-WZQ (C) COPYRIGHT = NONE + .\" LICENSED MATERIALS - PROPERTY OF IBM + .\" + .\" $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/rofftext/RCS/tmac.an,v 1.1 91/02/05 17:32:40 gk5g Exp $ + .\" $ACIS:tmac.an 9.1$ + .\" $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/rofftext/RCS/tmac.an,v $ + .\" + .\" Copyright (c) 1980 Regents of the University of California. + .\" All rights reserved. The Berkeley software License Agreement + .\" specifies the terms and conditions for redistribution. + .\" + .\" @(#)tmac.an 6.1 (Berkeley) 5/28/85 + .\" + .de th + .if t .so /usr/lib/tmac/tmac.an6t + .if n .so /usr/lib/tmac/tmac.an6n + .t1 "\\$1" "\\$2" "\\$3" + .. + .de TH + .rn TH xx + .so /usr/lib/tmac/tmac.an.new + .TH "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" + .rm xx + .. *** atk/rofftext/tmac.mm Fri Jun 7 13:53:15 1991 --- atk/rofftext/tmac.mm.NEW Fri Jun 7 13:50:25 1991 *************** *** 0 **** --- 1,536 ---- + .nr:a 0 1 + .nr:b 0 + .nr:f 0 + .nr:g 0 1 + .nr!N 0 + .dsBU o + .dsEM \%-- + .dsF \u[\\n+(:p]\d + .dsRf \u[\\n+(:R]\d + .dsTm \uTM\d + .nrEc 0 1 + .nrEx 0 1 + .nrFg 0 1 + .nrTb 0 1 + .nrH1 0 1 + .nrH2 0 1 + .nrH3 0 1 + .nrH4 0 1 + .nrH5 0 1 + .nrH6 0 1 + .nrH7 0 1 + .nrHu 2 + .nrNp 0 + .nrRf 0 + '\" ------------- FONTS ----------------- + .deB + .ie\\n(.$ .nr ;G \\n(.f + .el.ft 3 + .if\\n(.$ .if !\\n(.$-2 \&\f3\\$1\fP\\$2 + .if\\n(.$-2 \{.ds }i + .if~\\n(.f~2~ .ds }i \^ + .ds}I \&\f3\\$1\fP\\$2\\*(}i + 'br\} + .if\\n(.$-2 .if !\\n(.$-4 \\*(}I\f3\\$3\fP\\$4 + .if\\n(.$-4 \\*(}I\f3\\$3\fP\\$4\\*(}i\f3\\$5\fP\\$6\\$7\\$8\\$9 + .if\\n(.$ .ft \\n(;G + .. + .deI + .ie\\n(.$ .nr ;G \\n(.f + .el.ft 2 + .if\\n(.$ .if !\\n(.$-1 \&\f2\\$1 + .if\\n(.$-1 \{.ds }i \^ + .if~\\n(.f~2~ .ds }i + .ds}I \& + .if\w~\\$1~ .ds }I \&\f2\\$1\fP\\*(}i + 'br\} + .if\\n(.$-1 .if !\\n(.$-3 \\*(}I\\$2\f2\\$3 + .if\\n(.$-3 .if !\\n(.$-5 \\*(}I\\$2\f2\\$3\fP\\*(}i\\$4\f2\\$5 + .if\\n(.$-5 \\*(}I\\$2\f2\\$3\fP\\*(}i\\$4\f2\\$5\fP\\*(}i\\$6\\$7\\$8\\$9 + .if\\n(.$ .ft \\n(;G + .. + .deRI + .nr;G \\n(.f + .}S 1 2 \& "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6\\$7\\$8\\$9" + .. + .deRB + .nr;G \\n(.f + .}S 1 3 \& "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6\\$7\\$8\\$9" + .. + .deIR + .nr;G \\n(.f + .}S 2 1 \& "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6\\$7\\$8\\$9" + .. + .deIB + .nr;G \\n(.f + .}S 2 3 \& "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6\\$7\\$8\\$9" + .. + .deBR + .nr;G \\n(.f + .}S 3 1 \& "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6\\$7\\$8\\$9" + .. + .deBI + .nr;G \\n(.f + .}S 3 2 \& "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6\\$7\\$8\\$9" + .. + .de}S + .ds}i + .if~\\$1~2~ .if !~\\$5~~ .ds }i\^ + .ie!~\\$4~~ .}S \\$2 \\$1 "\\$3\f\\$1\\$4\\*(}i" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9" + .el\\$3 + .ft\\n(;G + .. + '\" ROMAN + .deR + .ft1 + .. + '\" --------------- HEADINGS ------------------- + .deH + .if\\n(:F .FE + .if\\n(:y .DE + .LC 0 + .ft1 + .br + .)R + .nr;1 0\\$1 + .if!0\\$1 .nr ;1 \\n(Hu + .if2-\\n(;1 .nr H2 0 1 + .if3-\\n(;1 .nr H3 0 1 + .if4-\\n(;1 .nr H4 0 1 + .if5-\\n(;1 .nr H5 0 1 + .if6-\\n(;1 .nr H6 0 1 + .if7-\\n(;1 .nr H7 0 1 + .nr H\\n(;1 +1 + .if!\\n(;1-1 .sp 2 + .ds}0 \\n(H1. + .if0\\$1-1 .as }0 \\n(H2 + .if0\\$1-2 .as }0 .\\n(H3 + .if0\\$1-3 .as }0 .\\n(H4 + .if0\\$1-4 .as }0 .\\n(H5 + .if0\\$1-5 .as }0 .\\n(H6 + .if0\\$1-6 .as }0 .\\n(H7 + .as}0 \ \ + .if!0\\$1 .ds }0 + .Hd 0\\$1 "\\*(}0\\$2" + 'br + .. + .deHU + .H 0 "\\$1" "\\$2" + .. + '\" -------------- LISTS ---------------- + .deLB + .)L 0\\$1n 0\\$2n 0\\$3n "\\$4" "\\$5" "\\$6" "\\$7" + .. + .de)L + .if\\n(:g .)A + .if!\\n+(:g-1 .ds ]b \\n(.i + .nr:b \\n(.iu+0\\$1u + .nr:e 0\\$4 + .nr:f 0\\$6 + .if!\w~\\$6~ .nr :f 1 + .ds]g \\$5 + .if!\w~\\$5~ \{.ds ]g \& + .if\\n(:e .ds ]g 1 + 'br\} + .nr:a 0 1 + .fi + .in\\n(:bu + .ti\\n(:bu + .. + .deLC + .if\\n(:g-0\\$1 .)B + .if\\n(:g-0\\$1 .LC 0\\$1 + .. + .deLE + .ie!\\n(:g<1 .)B + .if(\\n(:g<=6)&(\\n(.$>0) .sp + .. + '\" PUSHDOWN STACK SAVE + .de)A + .ds]a \\n(:a \\*(]a + .ds]b \\n(:b \\*(]b + .ds]e \\n(:e \\*(]e + .ds]f \\n(:f \\*(]f + .ds]h \\*(]g \\*(]h + .. + '\" PUSHDOWN STACK RESTORE + .de)B + .br + .nr:g -1 1 + .)C nr :a ]a \\*(]a + .nr :a \\n(:a 1 + .)C nr :b ]b \\*(]b + 'in\\n(:bu + 'ti\\n(:bu + .)C nr :e ]e \\*(]e + .)C nr :f ]f \\*(]f + .)C ds ]g ]h \\*(]h + .. + .de)C + .\\$1 \\$2 \\$4 + .ds\\$3 \\$5 \\$6 \\$7 \\$8 \\$9 + .. + '\" ---------- LIST MEMBER ------------- + .deLI + .in\\n(:bu + .if\\n(:F 'in 0 + .ds}0 \\*(]g + .if\\n(:e .ds }0 \\n+(:a. + .if\\n(:e-1 .ds }0 \\n(:a) + .if\\n(:e-2 .ds }0 (\\n(:a) + .if\\n(:e-3 .ds }0 [\\n(:a] + .if\\n(:e-4 .ds }0 <\\n(:a> + .if\\n(:e-5 .ds }0 {\\n(:a} + .if\\n(.$-1 .ds }0 \\$1\ \\*(}0 + .if\\n(.$=1 .ds }0 \\$1 + .nr;0 \w~\\*(}0~ + .nr;1 0 + .nr ;1 \\n(:bu-\\n(;0u-2n + .if!\\n(;1 .nr ;1 0 + .nr;0 \\n(:bu-\\n(;1u-\\n(;0u + .ti\\n(;1u + .if\w~\\*(}0~ \&\\*(}0\\ \\ \&\c + .. + '\" -------------- LIST START MACRO ------------ + .deAL + .if\\n(.$<3 \{.ie \w~\\$2~=0 .LB 10 0 0 1 "\\$1" + .el.LB 0\\$2 0 0 1 "\\$1" \} + .. + .deBL + .nr;0 10 + .if(\\n(.$>0)&(\w~\\$1~>0) .nr ;0 0\\$1 + .LB \\n(;0 0 0 0 "\\*(BU" + .rr;0 + .. + .deDL + .nr;0 10 + .if(\\n(.$>0)&(\w~\\$1~>0) .nr ;0 0\\$1 + .LB \\n(;0 0 0 0 "\(em" + .rr;0 + .. + .deML + .nr;0 \w~\\$1~u/3u/\\n(.su+1u + .ie\\n(.$<2 .LB \\n(;0 0 0 0 "\\$1" + .el .LB 0\\$2 0 0 0 "\\$1" + .. + .deRL + .nr;0 12 + .if(\\n(.$>0)&(\w~\\$1~>0).nr ;0 0\\$1 + .LB \\n(;0 0 0 4 + .rr;0 + .. + .deVL + .LB 0\\$1 0\\$2 0 0 + .. + '\" -------------- PARAGRAPH -------------------- + .deP + .br + .. + .denP + .P + .. + '\" -------------- PAGES ---------------- + .deSK + .bp + .br + .. + '\" -------------- SPACE ---------------- + .deSP + .br + .sp \\$1 + .. + '\" --------------- TABLES -------------- + .deTS + .if\\n(;t .TE + .nr;t 1 + .nr;i \\n(.i + .nr;q \\n(.u + .nf + .in0 + .Ct + .. + .deTH + .. + .deTE + .Et + .br + .sp1 + .in\\n(;iu + .fi + .if!\\n(;q .nf + .nr;t 0 + .. + '\" ------------ CAPTIONS ----------- + .deEC + .)F Equation \\n+(Ec "\\$1" "\\$2" + .. + .deEX + .)F Exhibit \\n+(Ex "\\$1" "\\$2" + .. + .deFG + .)F Figure \\n+(Fg "\\$1" "\\$2" + .. + .deTB + .)F TABLE \\n+(Tb "\\$1" "\\$2" + .. + .de)F + .in0 + .Ce1 + \f3\\$1 \\$2.\ \ \fP\\$3 + .in + .Ce0 + .. + '\" ----------- DATE ----------- + .deND + .dsDT "\\$1 + .. + '\" ------------ TITLE --------------- + .deTL + .nr;z 0 + 'nr;y 1 + 'fi + .br + .rs + .sp1 + .ft3 + AT&T Bell Laboratories + 'ft1 + .br + 'sp + .in 25 + .ti -7 + subject: + .ft3 + .. + '\" -------------- AUTHOR ---------------- + .deAU + .if\\n(;y .>9 + .rmTL + .in 25 + .ie!\\n(;z \{ + 'br + .ti -7 + .ft 1 + from:\ \ \ + .ft 3 \} + .el .sp + \\$1 + .br + \\$3\ \\$4 + .br + \\$6\\ x\\$5 + 'br + .if\\n(.$-6 \\$7 + .if\\n(.$-7 \\$8 + .if\\n(.$-8 \\$9 + .br + .nr;z 1 + .. + .de>9 + 'br + .fi + .sp + 'ft1 + .in25 + .ti -7 + date: + .ft3 + \\*(DT + 'ft1 + .nr;y 0 + .rm>9 + .. + '\" --------------- ABSTRACT -------------- + .deAS + .if\\n(;y .>9 + .rmTL + .sp3 + .in 0 + .ft 1 + .Hd 8 ABSTRACT + .nf + .br + .fi + .rmAS + .. + .deAE + .br + .rs + .in + .rmAE + .. + '\" --------------- NOTATIONS ----------- + .deNS + .)R + .sp + .ie!\\n(!N Copy to: + .el .sp + .nf + .nr!N 1 + .. + .deNE + .br + .nr!N 2 + .)R + .. + '\" -------------- MEMORANDUM TYPE -------------- + .deMT + .if\\n(!N=1 .NE + .if!\\n(;y 'nf + .if\\n(;y .>9 + .rmTL + .rmAS + .rmAE + .rmAU + .if!\\n(.$ .>6 "TECHNICAL MEMORANDUM" + .if\\n(.$ .if \w~\\$1~u-\w'0'u .>6 "\\$1" + .if\\n(.$ .nr ;y 0\\$1 + .if\\n(.$ .if !\\n(;y .>6 "" + .if\\n(.$ .if \\n(;y-4 .>6 "TYPE 4" + .if\\n(.$ .if \\n(;y-3 .>6 "TYPE 5" + .if\\n(.$ .if \\n(;y-2 .>6 "ADMINISTRATIVE MEMORANDUM" + .if\\n(.$ .if \\n(;y-1 .>6 "INTERNAL MEMORANDUM" + .if\\n(.$ .if \\n(;y .>6 "TECHNICAL MEMORANDUM" + .)R + .ns + .]N \\nP+1 + .rmMT + .. + .de>6 + .Hd 8 "\\$1" + .sp3 + .rm>6 + .. + '\" ----------- FOOTNOTES --------- + .deFS + 'nr:s +1 + .if\\n(:F .FE + .if\\n(:y .DE + .nr:F 1 + .if!\\n(!F .nr !F 1 + .Fn 1 + .. + .deFE + .Fn 0 + .nr:F 0 + .. + .deFD + .. + '\" ----------- GC ------------ + .deGS + .if!\\n(:y \{ .nr :G 1 + .DS \} + .ft L + .Gc 1 + .. + .deGE + .if\\n(:G \{ .nr :G 0 + .DE \} + .ft + .Gc 0 + .. + '\" ----------- PIC ------------ + .dePS + .if!\\n(:P \{ .nr :P 1 + .br + .Ps 1 + .di >D \} + .. + .dePE + .if\\n(:P \{ .nr :P 0 + .di + .Ps 0 + .br \} + .. + '\" ------------- DISPLAYS ----------- + .deDS + .)J "\\$1" "\\$2" + .. + .deDF + .)J "\\$1" "\\$2" + .. + .de)J + .if\\n(:F .FE + .if\\n(:y .DE + .nr;i \\n(.i + .nr;q \\n(.u + .nr ;H \\n(.f + .ft L + .nr:y 1 + .br + .)R + .if~\\$1~I~ .in 5n + .if~\\$1~C~ .Ce1 + .if~\\$1~CB~ .in 5n + .nf + .if~\\$2~F~ .fi + .. + .deDE + .Ce0 + .fi + .in\\n(;iu + .if!\\n(;q .nf + .ft\\n(;H + .nr:y 0 + .. + '\" ---------- GENERAL RESET FUNCTION ----------- + .de)R + 'fi + 'in0 + 'ti0 + .. + '\" ----------- CONSTANT WIDTH ------------ + .deCW + .DS I + .. + .deCN + .DE + .. + '\" ----------- REFERENCES ------------ + .deRS + .if\\n(;R=2 .RF + .nr;R 2 + .nrRf +1 + .Fn 1 + .. + .deRF + .Fn 0 + .nr;R 1 + .. + .deRP + .if\\n(;R=2 .RF + .if!(0\\$1) .nr :R 0 1 + .)R + .sp1 + .Ce1 + .ft2 + REFERENCES + .ft + .Ce0 + .sp2 + .)R + 'br + .. + .dePM + .. + .nr:y 0 + .nr:P 0 + .nr:F 0 + .nr:R 0 1 + .ds]r \\n(:R + .nr:p 0 1 + .ds]y \\n(:p + .nr W 6.0i + .if\n(mo-0 .ds DT January + .if\n(mo-1 .ds DT February + .if\n(mo-2 .ds DT March + .if\n(mo-3 .ds DT April + .if\n(mo-4 .ds DT May + .if\n(mo-5 .ds DT June + .if\n(mo-6 .ds DT July + .if\n(mo-7 .ds DT August + .if\n(mo-8 .ds DT September + .if\n(mo-9 .ds DT October + .if\n(mo-10 .ds DT November + .if\n(mo-11 .ds DT December + .asDT " \n(dy, 19\n(yr *** atk/support/buffer.c Fri Dec 21 14:58:19 1990 --- atk/support/buffer.c.NEW Thu Feb 21 15:38:39 1991 *************** *** 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/support/RCS/buffer.c,v 2.27 90/11/05 15:48:43 gk5g Exp $ */ /* $ACIS:buffer.c 1.6$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/support/RCS/buffer.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/support/RCS/buffer.c,v 2.27 90/11/05 15:48:43 gk5g Exp $"; #endif /* lint */ /* Fixed problem in buffer_WriteToFile 3/2/90 cch@mtgzx.att.com. --- 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/support/RCS/buffer.c,v 2.29 91/02/21 15:25:39 gk5g Exp $ */ /* $ACIS:buffer.c 1.6$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/support/RCS/buffer.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/support/RCS/buffer.c,v 2.29 91/02/21 15:25:39 gk5g Exp $"; #endif /* lint */ /* Fixed problem in buffer_WriteToFile 3/2/90 cch@mtgzx.att.com. *************** *** 27,34 **** site.h file. */ - #include #include /* sys/types.h sys/file.h */ #include #include --- 27,34 ---- site.h file. */ #include /* sys/types.h sys/file.h */ + #include #include #include *************** *** 48,53 **** --- 48,54 ---- #ifndef MAXPATHLEN #include #endif + extern int errno; static struct bufferlist *allBuffers; static char *backupExtension = NULL; *************** *** 68,77 **** if (checkpointDirectory != NULL) { #ifdef USESHORTFILENAMES ! if (FALSE) { #else ! if (checkpointGawdyNames) { #endif /* USESHORTFILENAMES */ int i; char tname[MAXPATHLEN]; sprintf (tname, "#%d%s#", getuid(), (self->filename ? self->filename : self->bufferName) ); --- 69,79 ---- if (checkpointDirectory != NULL) { #ifdef USESHORTFILENAMES ! if (FALSE) #else ! if (checkpointGawdyNames) #endif /* USESHORTFILENAMES */ + { int i; char tname[MAXPATHLEN]; sprintf (tname, "#%d%s#", getuid(), (self->filename ? self->filename : self->bufferName) ); *************** *** 122,127 **** --- 124,130 ---- self->readOnly = FALSE; self->madeBackup = FALSE; self->isModified = FALSE; + self->isRawFile = FALSE; self->viewname = NULL; return TRUE; *************** *** 273,284 **** free(self->filename); if(filename != NULL && *filename != '\0') { filetype_CanonicalizeFilename(realName, filename, sizeof(realName) - 1); ! filename = realName; ! len = strlen(filename); ! self->filename = malloc(len + 1); ! strcpy(self->filename, filename); } ! else self->filename = NULL; buffer_SetCheckpointFilename(self); self->lastTouchDate = buffer_GetFileDate(self); buffer_NotifyObservers(self, 0);/* Tuck it into slot. */ --- 276,289 ---- free(self->filename); if(filename != NULL && *filename != '\0') { filetype_CanonicalizeFilename(realName, filename, sizeof(realName) - 1); ! } ! else { ! realName[0] = '\0'; } ! filename = realName; ! len = strlen(filename); ! self->filename = malloc(len + 1); ! strcpy(self->filename, filename); buffer_SetCheckpointFilename(self); self->lastTouchDate = buffer_GetFileDate(self); buffer_NotifyObservers(self, 0);/* Tuck it into slot. */ *************** *** 466,471 **** --- 471,484 ---- bufferlist_GuessBufferName(allBuffers, filename, bufferName, nameSize); } + void buffer__GetUniqueBufferName (classID, proposedBufferName, bufferName, nameSize) + struct classheader *classID; + char *proposedBufferName, *bufferName; + int nameSize; + { + bufferlist_GuessBufferName(allBuffers, proposedBufferName, bufferName, nameSize); + } + int buffer__WriteToFile(self, filename, flags) struct buffer *self; char *filename; *************** *** 580,585 **** --- 593,602 ---- closeCode = -1; } else { + /* Now for GNU-Emacs compatibility, we chmod the file. */ + /* This is so that we preserve the modes of the original */ + /* file, un-modified by umask. */ + if (fileExists) chmod(filename, originalMode); #ifdef AFS_ENV if (flags & buffer_ReliableWrite) { /* Go for the expensive but safe operation. */ if ((closeCode = vclose(fileno(outFile))) < 0) /* stdio can trash errno. */ *************** *** 730,734 **** --- 747,759 ---- boolean value; { self->isModified = value; + buffer_NotifyObservers(self, observable_OBJECTCHANGED); + } + + void buffer__SetIsRawFile(self, value) + struct buffer *self; + boolean value; + { + self->isRawFile = value; buffer_NotifyObservers(self, observable_OBJECTCHANGED); } *** atk/support/buffer.ch Fri Dec 21 14:58:20 1990 --- atk/support/buffer.ch.NEW Fri Dec 14 16:54:21 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/support/RCS/buffer.ch,v 2.9 90/10/29 14:21:02 ajp Exp $ */ /* $ACIS:buffer.ch 1.4$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/support/RCS/buffer.ch,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsidbuffer_H = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/support/RCS/buffer.ch,v 2.9 90/10/29 14:21:02 ajp Exp $"; #endif /* !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) */ struct bufferContents { /* May not have to be in this file. */ --- 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/support/RCS/buffer.ch,v 2.10 90/12/14 14:59:01 ajp Exp $ */ /* $ACIS:buffer.ch 1.4$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/support/RCS/buffer.ch,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsidbuffer_H = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/support/RCS/buffer.ch,v 2.10 90/12/14 14:59:01 ajp Exp $"; #endif /* !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) */ struct bufferContents { /* May not have to be in this file. */ *************** *** 21,26 **** --- 21,27 ---- #define buffer_MustExist 1 /* File must exist for operation to succeed. */ #define buffer_ForceNew 2 /* Make a new buffer even if one already exists. */ #define buffer_ReadOnly 4 /* Buffer will be readonly regardless of file status. */ + #define buffer_RawMode 8 /* REad in in raw mode using a text object */ /* Flag values for buffer_WriteToFile function. */ #define buffer_ReliableWrite 1 /* Use vclose to ensure the file is written to server or an error code is returned. */ *************** *** 52,57 **** --- 53,59 ---- SetLastTouchDate(long dataStamp); SetCheckpointFilename(); SetIsModified(boolean value); + SetIsRawFile(boolean value); macromethods: GetData() ((self)->bufferData) GetName() ((self)->bufferName) *************** *** 68,74 **** GetLastTouchDate() ((self)->lastTouchDate) GetDefaultViewname() ((self)->viewname) GetReadOnly() (self->readOnly) ! GetIsModified() (self->isModified) classprocedures: Enumerate(procedure mapFunction, long functionData) returns struct buffer *; Create(char *bufferName, char *fileName, char *objetName, struct dataobject *data) returns struct buffer *; --- 70,77 ---- GetLastTouchDate() ((self)->lastTouchDate) GetDefaultViewname() ((self)->viewname) GetReadOnly() (self->readOnly) ! GetIsModified() (self->isModified) ! GetIsRawFile() (self->isRawFile) classprocedures: Enumerate(procedure mapFunction, long functionData) returns struct buffer *; Create(char *bufferName, char *fileName, char *objetName, struct dataobject *data) returns struct buffer *; *************** *** 84,89 **** --- 87,93 ---- /* File functions. */ GetBufferOnFile(char *filename, long flags) returns struct buffer *; GuessBufferName( char *filename, char *bufferName, int nameSize); + GetUniqueBufferName(char *proposedBufferName, char *bufferName, int nameSize); FinalizeObject(struct buffer *self); InitializeObject(struct buffer *self) returns boolean; SetDefaultObject(char *objectname); *************** *** 101,106 **** --- 105,111 ---- boolean scratch; /* Indicates that this buffer is temporary in nature. Namely, don't checkpoint it. */ boolean readOnly; /* This is only a hint. If the dataobject ignores the read only attribute, this won't be true. */ boolean madeBackup; /* This is used to tell if we have made a backup file yet this session. */ + boolean isRawFile; /* This is set to indicate that the file read in was read in in raw mode */ boolean isModified; char *viewname; }; *** atk/support/complete.c Wed Sep 26 16:06:44 1990 --- atk/support/complete.c.NEW Wed Apr 3 21:21:40 1991 *************** *** 4,18 **** * 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/support/RCS/complete.c,v 2.11 90/08/13 13:55:40 ajp Exp $ */ /* $ACIS:complete.c 1.2$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/support/RCS/complete.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/support/RCS/complete.c,v 2.11 90/08/13 13:55:40 ajp Exp $"; #endif /* lint */ ! #include #include #include #include --- 4,18 ---- * 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/support/RCS/complete.c,v 2.14 91/04/02 16:58:33 susan Exp $ */ /* $ACIS:complete.c 1.2$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/support/RCS/complete.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/support/RCS/complete.c,v 2.14 91/04/02 16:58:33 susan Exp $"; #endif /* lint */ ! #include /* sys/types.h */ #include #include #include *************** *** 24,39 **** #include - #include /* sys/types.h */ #include #include #include static boolean useCurrentWorkingDirectory = FALSE; static struct cursor *waitCursor; - extern char *rindex(); - #define min(x, y) (((x) < (y)) ? (x) : (y)) static long completion__FindCommon(classID, string1, string2) --- 24,41 ---- #include #include #include + #ifdef M_UNIX + #include + #define direct dirent + #else #include + #endif static boolean useCurrentWorkingDirectory = FALSE; static struct cursor *waitCursor; #define min(x, y) (((x) < (y)) ? (x) : (y)) static long completion__FindCommon(classID, string1, string2) *************** *** 40,46 **** struct classheader *classID; char *string1, *string2; { - long i = 0; while (*string1++ == *string2++ && (*(string1 - 1) != '\0')) --- 42,47 ---- *************** *** 205,211 **** static enum message_CompletionCode FileComplete(pathname, directory, buffer, bufferSize) char *pathname; ! boolean directory; char *buffer; int bufferSize; { --- 206,212 ---- static enum message_CompletionCode FileComplete(pathname, directory, buffer, bufferSize) char *pathname; ! long directory; char *buffer; int bufferSize; { *************** *** 325,331 **** char *buffer; int bufferSize; { ! return FileComplete(pathname, directory, buffer, bufferSize); } struct fileRock { --- 326,332 ---- char *buffer; int bufferSize; { ! return FileComplete(pathname, (long) directory, buffer, bufferSize); } struct fileRock { *** atk/support/nstdmark.c Fri Dec 21 14:58:24 1990 --- atk/support/nstdmark.c.NEW Mon Mar 11 16:19:53 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/support/RCS/nstdmark.c,v 2.13 90/10/11 12:05:11 ajp Exp $ */ /* $ACIS:nstdmark.c 1.4$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/support/RCS/nstdmark.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/support/RCS/nstdmark.c,v 2.13 90/10/11 12:05:11 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/support/RCS/nstdmark.c,v 2.14 91/03/11 16:18:29 rr2b Exp $ */ /* $ACIS:nstdmark.c 1.4$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/support/RCS/nstdmark.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/support/RCS/nstdmark.c,v 2.14 91/03/11 16:18:29 rr2b Exp $"; #endif /* lint */ #include *************** *** 350,356 **** struct nestedmark *ptp = (struct nestedmark *) tree23int_FindL(self->children,0,pos - 1); long peleft; ! if (ptp != NULL && ((peleft = tree23int_Eval(ptp->position)) + ptp->length) == pos && ptp->includeEnding) { tp = nestedmark_GetEnclosing(ptp,pos-peleft); lastSelf = self; lastPos = pos; --- 350,357 ---- struct nestedmark *ptp = (struct nestedmark *) tree23int_FindL(self->children,0,pos - 1); long peleft; ! /* Changed to take Global Isolation into account -rr2b */ ! if (ptp != NULL && ((peleft = tree23int_Eval(ptp->position)) + ptp->length) == pos && ptp->includeEnding && (!GlobalIsolation)) { tp = nestedmark_GetEnclosing(ptp,pos-peleft); lastSelf = self; lastPos = pos; *************** *** 358,364 **** } } ! if ((pos > eleft && pos < eleft+tp->length) || (pos == eleft && tp->includeBeginning) || (pos == eleft + tp->length && tp->includeEnding)) { tp = nestedmark_GetEnclosing(tp,pos-eleft); lastSelf = self; lastPos = pos; --- 359,366 ---- } } ! /* Changed to take Global Isolation into account -rr2b */ ! if ((pos > eleft && pos < eleft+tp->length) || (pos == eleft && tp->includeBeginning && (!GlobalIsolation)) || (pos == eleft + tp->length && tp->includeEnding && (!GlobalIsolation))) { tp = nestedmark_GetEnclosing(tp,pos-eleft); lastSelf = self; lastPos = pos; *** atk/support/print.c Fri Dec 21 14:58:26 1990 --- atk/support/print.c.NEW Sun May 5 18:54:26 1991 *************** *** 2,20 **** * 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/support/RCS/print.c,v 2.23 90/09/20 19:50:42 gk5g Exp $ */ /* $ACIS:print.c 1.3$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/support/RCS/print.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/support/RCS/print.c,v 2.23 90/09/20 19:50:42 gk5g Exp $"; #endif /* lint */ #include #include - #include - #include #include #include #include --- 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/support/RCS/print.c,v 2.26 1991/02/12 17:28:52 gk5g Exp $ */ /* $ACIS:print.c 1.3$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/support/RCS/print.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/support/RCS/print.c,v 2.26 1991/02/12 17:28:52 gk5g Exp $"; #endif /* lint */ + #include #include #include #include #include #include *************** *** 22,27 **** --- 21,27 ---- #include #include + /* The following defaults are used by the print software */ #define print_INDEXTROFF 42424 /* produce troff index */ *************** *** 189,195 **** char *p,*pp; char *q; char dname[400]; ! char *dnameptr,*rindex(); FILE *outf; char pt[128] ; struct stat buf; --- 189,195 ---- char *p,*pp; char *q; char dname[400]; ! char *dnameptr; FILE *outf; char pt[128] ; struct stat buf; *************** *** 377,383 **** #else /* hpux */ setpgrp(0, pg = getpid()); #endif /* hpux */ ! #ifndef AIX setpriority(PRIO_PGRP, pg, 10); #endif /* #ifndef AIX */ execlp("/bin/sh", "sh", "-c", PrintCommand, 0); --- 377,383 ---- #else /* hpux */ setpgrp(0, pg = getpid()); #endif /* hpux */ ! #if !SY_AIX221 setpriority(PRIO_PGRP, pg, 10); #endif /* #ifndef AIX */ execlp("/bin/sh", "sh", "-c", PrintCommand, 0); *************** *** 386,392 **** } else { FILE *temp,*popen(); ! #if SY_AIX221 signal(SIGCLD, SIG_DFL); #endif if ((temp = popen(PrintCommand, "w"))) { --- 386,392 ---- } else { FILE *temp,*popen(); ! #if SY_AIX221 || SY_AIX12 || SY_AIX31 signal(SIGCLD, SIG_DFL); #endif if ((temp = popen(PrintCommand, "w"))) { *** atk/support/style.c Fri Dec 21 14:58:29 1990 --- atk/support/style.c.NEW Fri Dec 14 16:54:25 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/support/RCS/style.c,v 2.13 90/09/10 11:25:24 tpn Exp Locker: ajp $ */ /* $ACIS:style.c 1.4$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/support/RCS/style.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/support/RCS/style.c,v 2.13 90/09/10 11:25:24 tpn Exp Locker: ajp $"; #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/support/RCS/style.c,v 2.14 90/12/14 14:59:50 ajp Exp $ */ /* $ACIS:style.c 1.4$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/support/RCS/style.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/support/RCS/style.c,v 2.14 90/12/14 14:59:50 ajp Exp $"; #endif /* lint */ #include *************** *** 197,202 **** --- 197,203 ---- "NoFill", "KeepPriorNL", "KeepNextNL", + "TabsCharacters", NULL }; *************** *** 231,236 **** --- 232,238 ---- style_NoFillIndex=11, style_KeepPriorNLIndex=12, style_KeepNextNLIndex=13, + style_TabsCharactersIndex=14 }; /* The following must be kept in sync with the flag defs in style.ch */ *************** *** 262,267 **** --- 264,270 ---- self->FontFamily = NULL; self->TabChangeList = NULL; + self->NumTabChanges = 0; self->CounterName = NULL; self->CounterParent = NULL; self->CounterStyles = NULL; *************** *** 387,393 **** dest->OutFontFaces= (long) self->OutFontFaces; style_ClearTabChanges(dest); ! dest->NumTabChanges= self->NumTabChanges; dest->TabChangeList=NULL; for (i = 0, tabchange = self->TabChangeList; i < self->NumTabChanges; i++, tabchange++) style_AddTabChange(dest, tabchange->TabOpcode, tabchange->Location, tabchange->LocationUnit); --- 390,396 ---- dest->OutFontFaces= (long) self->OutFontFaces; style_ClearTabChanges(dest); ! dest->NumTabChanges= 0; dest->TabChangeList=NULL; for (i = 0, tabchange = self->TabChangeList; i < self->NumTabChanges; i++, tabchange++) style_AddTabChange(dest, tabchange->TabOpcode, tabchange->Location, tabchange->LocationUnit); *************** *** 839,844 **** --- 842,868 ---- long Where; enum style_Unit Unit; { + if (TabOp == style_AllClear) { + self->NumTabChanges = 0; + if (self->TabChangeList != NULL) { + free(self->TabChangeList); + } + } + else { + long loc = CVDots(Where, Unit); + long i; + + for (i = 0; i < self->NumTabChanges; i++) { + if (self->TabChangeList[i].DotLocation == loc && + self->TabChangeList[i].TabOpcode != style_AllClear) { + self->TabChangeList[i].TabOpcode = TabOp; + self->TabChangeList[i].Location = Where; + self->TabChangeList[i].LocationUnit = Unit; + return; + } + } + } + if (self->NumTabChanges == 0) self->TabChangeList = (struct tabentry *) malloc(sizeof(struct tabentry)); else *************** *** 1037,1055 **** style_GetNewInterlineSpacing(self, &newspacing, &operand, &unit); if (newspacing != style_InterlineSpacing || operand != 0 || unit != style_Points) ! fprintf(fp, AttrD, AttributeAlias[(int) style_SpacingAttr], SpacingValueAlias[(int) newjust], OptypeAlias[(int) unit], operand); style_GetNewAbove(self, &newspacing, &operand, &unit); if (newspacing != style_AboveSpacing || operand != 0 || unit != style_Points) ! fprintf(fp, AttrD, AttributeAlias[(int) style_AboveAttr], SpacingValueAlias[(int) newjust], OptypeAlias[(int) unit], operand); style_GetNewBelow(self, &newspacing, &operand, &unit); if (newspacing != style_BelowSpacing || operand != 0 || unit != style_Points) ! fprintf(fp, AttrD, AttributeAlias[(int) style_BelowAttr], SpacingValueAlias[(int) newjust], OptypeAlias[(int) unit], operand); style_GetNewInterparagraphSpacing(self, &newspacing, &operand, &unit); if (newspacing != style_InterparagraphSpacing || operand != 0 || unit != style_Points) ! fprintf(fp, AttrD, AttributeAlias[(int) style_SpreadAttr], SpacingValueAlias[(int) newjust], OptypeAlias[(int) unit], operand); style_GetTabChangeList(self, &numtabchanges, &tabchanges); if (numtabchanges != 0) { --- 1061,1079 ---- style_GetNewInterlineSpacing(self, &newspacing, &operand, &unit); if (newspacing != style_InterlineSpacing || operand != 0 || unit != style_Points) ! fprintf(fp, AttrD, AttributeAlias[(int) style_SpacingAttr], SpacingValueAlias[(int) newspacing], OptypeAlias[(int) unit], operand); style_GetNewAbove(self, &newspacing, &operand, &unit); if (newspacing != style_AboveSpacing || operand != 0 || unit != style_Points) ! fprintf(fp, AttrD, AttributeAlias[(int) style_AboveAttr], SpacingValueAlias[(int) newspacing], OptypeAlias[(int) unit], operand); style_GetNewBelow(self, &newspacing, &operand, &unit); if (newspacing != style_BelowSpacing || operand != 0 || unit != style_Points) ! fprintf(fp, AttrD, AttributeAlias[(int) style_BelowAttr], SpacingValueAlias[(int) newspacing], OptypeAlias[(int) unit], operand); style_GetNewInterparagraphSpacing(self, &newspacing, &operand, &unit); if (newspacing != style_InterparagraphSpacing || operand != 0 || unit != style_Points) ! fprintf(fp, AttrD, AttributeAlias[(int) style_SpreadAttr], SpacingValueAlias[(int) newspacing], OptypeAlias[(int) unit], operand); style_GetTabChangeList(self, &numtabchanges, &tabchanges); if (numtabchanges != 0) { *************** *** 1100,1105 **** --- 1124,1132 ---- if (style_TestAddFlag(self, style_KeepNextNL)) fprintf(fp, AttrS, AttributeAlias[(int) style_FlagsAttr], FlagAlias[(int) style_KeepNextNLIndex], OptypeAlias[(int) style_RawDots], OpcodeAlias[style_OPSET]); + if (style_TestAddFlag(self, style_TabsCharacters)) + fprintf(fp, AttrS, AttributeAlias[(int) style_FlagsAttr], FlagAlias[(int) style_TabsCharactersIndex], OptypeAlias[(int) style_RawDots], OpcodeAlias[style_OPSET]); + } if (self->OutMiscFlags != ~ style_NoFlags) { *************** *** 1144,1149 **** --- 1171,1179 ---- if (style_TestRemoveFlag(self, style_KeepNextNL)) fprintf(fp, AttrS, AttributeAlias[(int) style_FlagsAttr], FlagAlias[(int) style_KeepNextNLIndex], OptypeAlias[(int) style_RawDots], OpcodeAlias[style_OPCLEAR]); + + if (style_TestRemoveFlag(self, style_TabsCharacters)) + fprintf(fp, AttrS, AttributeAlias[(int) style_FlagsAttr], FlagAlias[(int) style_TabsCharactersIndex], OptypeAlias[(int) style_RawDots], OpcodeAlias[style_OPCLEAR]); } if (style_GetAddedFontFaces(self)) { if (style_IsAnyAddedFontFace(self, fontdesc_Bold)) *************** *** 1539,1545 **** operand = atoi(Operand); ! style_AddTabChange(self, newtabalign, operand<<16, unit); break; case style_FlagsAttr: --- 1569,1575 ---- operand = atoi(Operand); ! style_AddTabChange(self, newtabalign, operand, unit); break; case style_FlagsAttr: *************** *** 1616,1621 **** --- 1646,1657 ---- style_AddFlag(self, style_KeepNextNL); if (operand == style_OPCLEAR) style_RemoveFlag(self, style_KeepNextNL); + break; + case style_TabsCharacters: + if (operand == style_OPSET) + style_AddFlag(self, style_TabsCharacters); + if (operand == style_OPCLEAR) + style_RemoveFlag(self, style_TabsCharacters); break; default: return -1; *** atk/support/style.ch Fri Dec 21 14:58:32 1990 --- atk/support/style.ch.NEW Thu Dec 20 18:40:21 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/support/RCS/style.ch,v 2.6 90/08/13 14:13:47 ajp Exp Locker: ajp $ */ /* $ACIS:style.ch 1.4$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/support/RCS/style.ch,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsidstyle_H = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/support/RCS/style.ch,v 2.6 90/08/13 14:13:47 ajp Exp Locker: ajp $"; #endif /* !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) */ #define style_VERSION 1 --- 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/support/RCS/style.ch,v 2.8 90/12/20 18:36:05 ajp Exp $ */ /* $ACIS:style.ch 1.4$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/support/RCS/style.ch,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsidstyle_H = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/support/RCS/style.ch,v 2.8 90/12/20 18:36:05 ajp Exp $"; #endif /* !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) */ #define style_VERSION 1 *************** *** 173,180 **** #define style_NoFill (1<<11) #define style_KeepPriorNL (1<<12) #define style_KeepNextNL (1<<13) - /************************************************************** * Style Class **************************************************************/ --- 173,180 ---- #define style_NoFill (1<<11) #define style_KeepPriorNL (1<<12) #define style_KeepNextNL (1<<13) + #define style_TabsCharacters (1<<14) /************************************************************** * Style Class **************************************************************/ *************** *** 382,387 **** --- 382,414 ---- IsNoWrapRemoved() style_TestRemoveFlag((self), style_NoWrap) IsNoWrapUnchange() style_TestUseOldFlag((self), style_NoWrap) + AddNoFill() style_AddFlag((self), style_NoFill) + RemoveNoFill() style_RemoveFlag((self), style_NoFill) + UseOldNoFill() style_UseOldFlag((self), style_NoFill) + IsNoFillAdded() style_TestAddFlag((self), style_NoFill) + IsNoFillRemoved() style_TestRemoveFlag((self), style_NoFill) + IsNoFillUnchange() style_TestUseOldFlag((self), style_NoFill) + + AddKeepPriorNL() style_AddFlag((self), style_KeepPriorNL) + RemoveKeepPriorNL() style_RemoveFlag((self), style_KeepPriorNL) + UseOldKeepPriorNL() style_UseOldFlag((self), style_KeepPriorNL) + IsKeepPriorNLAdded() style_TestAddFlag((self), style_KeepPriorNL) + IsKeepPriorNLRemoved() style_TestRemoveFlag((self), style_KeepPriorNL) + IsKeepPriorNLUnchange() style_TestUseOldFlag((self), style_KeepPriorNL) + + AddKeepNextNL() style_AddFlag((self), style_KeepNextNL) + RemoveKeepNextNL() style_RemoveFlag((self), style_KeepNextNL) + UseOldKeepNextNL() style_UseOldFlag((self), style_KeepNextNL) + IsKeepNextNLAdded() style_TestAddFlag((self), style_KeepNextNL) + IsKeepNextNLRemoved() style_TestRemoveFlag((self), style_KeepNextNL) + IsKeepNextNLUnchange() style_TestUseOldFlag((self), style_KeepNextNL) + + AddTabsCharacters() style_AddFlag((self), style_TabsCharacters) + RemoveTabsCharacters() style_RemoveFlag((self), style_TabsCharacters) + UseOldTabsCharacters() style_UseOldFlag((self), style_TabsCharacters) + IsTabsCharactersAdded() style_TestAddFlag((self), style_TabsCharacters) + IsTabsCharactersRemoved() style_TestRemoveFlag((self), style_TabsCharacters) + IsTabsCharactersUnchange() style_TestUseOldFlag((self), style_TabsCharacters) data: char *name; char *menuName; /* e.g. "Font~1,Italic~11" */ *** atk/support/stylesht.c Wed Nov 22 12:28:56 1989 --- atk/support/stylesht.c.NEW Fri Dec 14 16:54:33 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/support/RCS/stylesht.c,v 2.5 89/03/10 16:49:33 cm26 Exp $ */ /* $ACIS:stylesht.c 1.4$ */ ! /* $Source: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/support/RCS/stylesht.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/support/RCS/stylesht.c,v 2.5 89/03/10 16:49:33 cm26 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/support/RCS/stylesht.c,v 2.6 90/12/14 15:00:14 ajp Exp $ */ /* $ACIS:stylesht.c 1.4$ */ ! /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/support/RCS/stylesht.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/support/RCS/stylesht.c,v 2.6 90/12/14 15:00:14 ajp Exp $"; #endif /* lint */ #include *************** *** 187,200 **** if ((styleptr = stylesheet_Find(self, styleName)) != NULL) { style_Finalize(styleptr); style_Initialize(styleptr); - style_SetName(styleptr, styleName); - styleptr->template = template; } else { styleptr = style_New(); - style_SetName(styleptr, styleName); - styleptr->template = template; stylesheet_Add(self, styleptr); } style_Read(styleptr, fp); --- 187,199 ---- if ((styleptr = stylesheet_Find(self, styleName)) != NULL) { style_Finalize(styleptr); style_Initialize(styleptr); } else { styleptr = style_New(); stylesheet_Add(self, styleptr); } + + style_SetName(styleptr, styleName); + styleptr->template = template; style_Read(styleptr, fp); *** atk/support/bufferlist.c Fri Dec 21 14:58:41 1990 --- atk/support/bufferlist.c.NEW Wed Feb 13 16:54:05 1991 *************** *** 2,21 **** * 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/support/RCS/bufferlist.c,v 1.6 90/10/29 14:22:58 ajp Exp $ */ /* $ACIS:bufferlist.c 1.6$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/support/RCS/bufferlist.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/support/RCS/bufferlist.c,v 1.6 90/10/29 14:22:58 ajp Exp $"; #endif /* lint */ - #include #include /* sys/types.h sys/file.h */ #include #include - #include #include #include #include --- 2,20 ---- * 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/support/RCS/bufferlist.c,v 1.8 91/02/12 17:28:36 gk5g Exp $ */ /* $ACIS:bufferlist.c 1.6$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/support/RCS/bufferlist.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/support/RCS/bufferlist.c,v 1.8 91/02/12 17:28:36 gk5g Exp $"; #endif /* lint */ #include /* sys/types.h sys/file.h */ + #include #include #include #include #include #include *************** *** 261,267 **** boolean readOnly; char bufferName[100], *objectName; FILE *thisFile; ! struct attributes *attributes, *tempAttribute, readOnlyAttribute; filetype_CanonicalizeFilename(realName, filename, sizeof (realName) - 1); filename = realName; --- 260,266 ---- boolean readOnly; char bufferName[100], *objectName; FILE *thisFile; ! struct attributes *attributes, *tempAttribute, readOnlyAttribute, rawModeAttribute; filetype_CanonicalizeFilename(realName, filename, sizeof (realName) - 1); filename = realName; *************** *** 274,280 **** } } ! if (fileIsDir) { struct attributes attr; struct dataobject *dobj; /* Force filename to not end in '/' before visiting directories. */ --- 273,280 ---- } } ! ! if (fileIsDir && ((flags & buffer_RawMode) == 0)) { struct attributes attr; struct dataobject *dobj; /* Force filename to not end in '/' before visiting directories. */ *************** *** 325,331 **** if ((thisFile = fopen(filename, "r")) == NULL) { if (access(filename, W_OK) < 0) { - extern char *rindex(); char *slash; if (errno != ENOENT) return NULL; --- 325,330 ---- *************** *** 340,346 **** } } ! objectName = filetype_Lookup(thisFile, filename, &objectID, &attributes); readOnly = FALSE; for (tempAttribute = attributes; tempAttribute != NULL; tempAttribute = tempAttribute->next) --- 339,356 ---- } } ! if ((flags & buffer_RawMode) != 0) { ! objectName = "text"; ! objectID = 0; ! attributes = &rawModeAttribute; ! rawModeAttribute.next = NULL; ! rawModeAttribute.key = "datastream"; ! rawModeAttribute.value.string = "no"; ! readOnly = TRUE; ! } ! else { ! objectName = filetype_Lookup(thisFile, filename, &objectID, &attributes); ! } readOnly = FALSE; for (tempAttribute = attributes; tempAttribute != NULL; tempAttribute = tempAttribute->next) *************** *** 377,404 **** buffer_SetCkpClock(thisBuffer, 0); buffer_SetCkpVersion(thisBuffer, version); buffer_SetWriteVersion(thisBuffer, version); return thisBuffer; } ! void bufferlist__GuessBufferName (self, filename, bufferName, nameSize) ! struct bufferlist *self; ! char *filename, *bufferName; ! int nameSize; { - register int uniquefier, nameLength; - char *slash; - extern char *rindex(); ! slash = rindex(filename, '/'); ! if (slash != NULL) ! strncpy(bufferName, ++slash, nameSize - 2); /* Save room for uniquefier. */ ! else ! strncpy(bufferName, filename, nameSize - 2); /* Save room for uniquefier. */ /* Find out if buffer exists. */ if (buffer_FindBufferByName(bufferName) == NULL) return; /* Otherwise we must uniquify it. * This is a bug, it may overflow the string buffer we were given... */ --- 387,410 ---- buffer_SetCkpClock(thisBuffer, 0); buffer_SetCkpVersion(thisBuffer, version); buffer_SetWriteVersion(thisBuffer, version); + buffer_SetIsRawFile(thisBuffer, (flags & buffer_RawMode) != 0); return thisBuffer; } ! void bufferlist__GetUniqueBufferName(self, proposedName, bufferName, nameSize) ! struct bufferlist *self; ! char *proposedName; ! char *bufferName; ! int nameSize; { register int uniquefier, nameLength; ! strcpy(bufferName, proposedName); /* Find out if buffer exists. */ if (buffer_FindBufferByName(bufferName) == NULL) return; + /* Otherwise we must uniquify it. * This is a bug, it may overflow the string buffer we were given... */ *************** *** 410,415 **** --- 416,441 ---- } *bufferName = '\0'; /* Make sure we don't return a non-unique buffername. */ return; + } + + void bufferlist__GuessBufferName (self, filename, bufferName, nameSize) + struct bufferlist *self; + char *filename, *bufferName; + int nameSize; + { + char *slash; + char newBufferName[MAXPATHLEN]; + + slash = rindex(filename, '/'); + if (slash != NULL) + strncpy(newBufferName, ++slash, nameSize - 3); /* Save room for uniquefier. */ + else + strncpy(newBufferName, filename, nameSize - 3); /* Save room for uniquefier. */ + + newBufferName[nameSize-3] = '\0'; + + bufferlist_GetUniqueBufferName(self, newBufferName, bufferName, nameSize); + } *** atk/support/bufferlist.ch Fri Dec 21 14:58:42 1990 --- atk/support/bufferlist.ch.NEW Fri Dec 14 16:54:35 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/support/RCS/bufferlist.ch,v 1.3 90/10/29 14:24:18 ajp Exp $ */ /* $ACIS:bufferlist.ch 1.4$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/support/RCS/bufferlist.ch,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsidbufferlist_H = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/support/RCS/bufferlist.ch,v 1.3 90/10/29 14:24:18 ajp Exp $"; #endif /* !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) */ class bufferlist : 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/support/RCS/bufferlist.ch,v 1.4 90/12/14 14:59:28 ajp Exp $ */ /* $ACIS:bufferlist.ch 1.4$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/support/RCS/bufferlist.ch,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsidbufferlist_H = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/support/RCS/bufferlist.ch,v 1.4 90/12/14 14:59:28 ajp Exp $"; #endif /* !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) */ class bufferlist : observable[observe] { *************** *** 27,32 **** --- 27,33 ---- /* File functions. */ GetBufferOnFile(char *filename, long flags) returns struct buffer *; GuessBufferName( char *filename, char *bufferName, int nameSize); + GetUniqueBufferName( char *proposedBufferName, char *bufferName, int nameSize); SetDefaultObject(char *objectname); classprocedures: FinalizeObject(struct bufferlist *self); *** contrib/mit/util/strinput.c Thu May 30 20:09:21 1991 --- contrib/mit/util/strinput.c.NEW Thu May 30 18:38:49 1991 *************** *** 0 **** --- 1,168 ---- + /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/supportviews/RCS/strinput.c,v 1.3 91/05/07 00:44:51 gk5g Exp $ */ + /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/supportviews/RCS/strinput.c,v $ */ + /* $Author: gk5g $ */ + + #ifndef lint + static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/supportviews/RCS/strinput.c,v 1.3 91/05/07 00:44:51 gk5g Exp $"; + #endif /* lint */ + /* + * strinput.c + * + * String input dialogue box thingie. + */ + + #include + + #include + #include + #include + #include + #include + #include + #include + #include + #include + + #define debug(x) /* printf x ; fflush(stdin); */ + static struct style *promptStyle = NULL; + + boolean strinput__InitializeClass(classID) + struct classheader classID; + { + if (!promptStyle && !(promptStyle = style_New())) + return FALSE; + style_AddNewFontFace(promptStyle, fontdesc_Bold); + return TRUE; + } + + + boolean strinput__InitializeObject(classID, self) + struct classheader *classID; + struct strinput *self; + { + self->textobj = text_New(); + self->textv = textview_New(); + self->prompt = NULL; + textview_SetDataObject(self->textv, self->textobj); + return TRUE; + } + + void strinput__FinalizeObject(classID, self) + struct classheader *classID; + struct strinput *self; + { + if (self->textv) textview_Destroy(self->textv); + if (self->textobj) text_Destroy(self->textobj); + if (self->prompt) free(self->prompt); + } + + char *strinput__GetInput(self, length) + struct strinput *self; + int length; + { + int len,pos; + char *string; + + len = text_GetLength(self->textobj); + pos = text_GetFence(self->textobj); + len = len - pos; + if (length <= 0) return NULL; + + if (length < len) len = length; + string = (char *) malloc(len + 1); + + text_CopySubString(self->textobj, pos, len, string, TRUE); + + return string; + } + + void strinput__SetPrompt(self, string) + struct strinput *self; + char *string; + { + int fence, len; + + len = (string ? strlen(string) : 0); + if (string != self->prompt) { + if(self->prompt) + free(self->prompt); + self->prompt = (char *) malloc((len+1)); + strcpy(self->prompt, (string ? string : "")); + } + + /* Now to change the text */ + fence = text_GetFence(self->textobj); + text_ClearFence(self->textobj); + text_ReplaceCharacters(self->textobj, 0, fence, string, len); + text_SetFence(self->textobj, len); + text_AlwaysAddStyle(self->textobj, 0, len - 1, promptStyle); + /* Now to change the view, iff it's linked into the viewTree */ + textview_SetDotPosition(self->textv, text_GetLength(self->textobj)); + strinput_WantUpdate(self, self->textv); + } + + void strinput__ClearInput(self) + struct strinput *self; + { + text_Clear(self->textobj); + strinput_SetPrompt(self, self->prompt); + /* Now to change the view, iff it's linked into the viewTree */ + textview_SetDotPosition(self->textv, text_GetLength(self->textobj)); + } + + void strinput__SetInput(self, string) + struct strinput *self; + char *string; + { + text_Clear(self->textobj); + strinput_SetPrompt(self, self->prompt); + + text_InsertCharacters(self->textobj, text_GetLength(self->textobj), + (string ? string : ""), + (string ? strlen(string) : 0)); + /* Now to change the view, iff it's linked into the viewTree */ + textview_SetDotPosition(self->textv, text_GetLength(self->textobj)); + } + + void strinput__FullUpdate(self, type, left, top, width, height) + struct strinput *self; + enum view_UpdateType type; + long left, top, width, height; + { + struct rectangle child; + + strinput_GetLogicalBounds(self, &child); + textview_InsertView(self->textv, self, &child); + textview_FullUpdate(self->textv, type, 0, 0, child.width, child.height); + } + + struct view *strinput__Hit(self, action, x, y, clicks) + struct strinput *self; + enum view_MouseAction action; + long x, y, clicks; + { + return textview_Hit(self->textv, action, x, y, clicks); + } + + boolean strinput__HaveYouGotTheFocus(self) + struct strinput *self; + { + return(self->textv->hasInputFocus); + } + + void strinput__ReceiveInputFocus(self) + struct strinput *self; + { + super_ReceiveInputFocus(self); + strinput_WantInputFocus(self, self->textv); + } + + void + strinput__LinkTree( self, parent ) + register struct strinput *self; + register struct view *parent; + { + super_LinkTree(self, parent); + if(self->textv) + textview_LinkTree(self->textv, self); + } *** atk/supportviews/Imakefile Tue Dec 5 22:08:33 1989 --- atk/supportviews/Imakefile.NEW Thu May 30 18:38:51 1991 *************** *** 56,62 **** InstallDocs(mttproc.help,${DESTDIR}/help) InstallHelpAlias(mttproc,matteproc matteprocs) InstallDocs(scroll.help,${DESTDIR}/help) ! InstallHelpAlias(scroll, scrollbar scrollbar-tutorial) InstallDocs(bpair.doc,${DESTDIR}/doc/atk/supportviews) InstallDocs(label.doc,${DESTDIR}/doc/atk/supportviews) InstallDocs(labelv.doc,${DESTDIR}/doc/atk/supportviews) --- 56,62 ---- InstallDocs(mttproc.help,${DESTDIR}/help) InstallHelpAlias(mttproc,matteproc matteprocs) InstallDocs(scroll.help,${DESTDIR}/help) ! InstallHelpAlias(scroll, scrollbar scrolling scrollbar-tutorial) InstallDocs(bpair.doc,${DESTDIR}/doc/atk/supportviews) InstallDocs(label.doc,${DESTDIR}/doc/atk/supportviews) InstallDocs(labelv.doc,${DESTDIR}/doc/atk/supportviews) *** atk/supportviews/matte.c Wed Apr 11 14:20:57 1990 --- atk/supportviews/matte.c.NEW Fri Mar 29 00:06:27 1991 *************** *** 2,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/supportviews/RCS/matte.c,v 2.9 90/04/03 11:19:14 gk5g Exp $ */ /* $ACIS:matte.c 1.8$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/supportviews/RCS/matte.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/supportviews/RCS/matte.c,v 2.9 90/04/03 11:19:14 gk5g Exp $"; #endif /* lint */ #define UNSET 0 #define FUDGE 2 #define matte_ChangeWidth 1 --- 2,16 ---- * 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/supportviews/RCS/matte.c,v 2.12 91/03/29 00:05:28 rr2b Exp $ */ /* $ACIS:matte.c 1.8$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/supportviews/RCS/matte.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/supportviews/RCS/matte.c,v 2.12 91/03/29 00:05:28 rr2b Exp $"; #endif /* lint */ + #define UNSET 0 #define FUDGE 2 #define matte_ChangeWidth 1 *************** *** 25,39 **** #include #include #include #define RESIZING TRUE #define DRAWING FALSE - #ifdef USEMENUS struct menulist *matteMenus; static struct keymap *matteKeyMap; - #endif /* USEMENUS */ static void UpdateCursors(self) struct matte *self; --- 26,40 ---- #include #include + #include + #include #define RESIZING TRUE #define DRAWING FALSE struct menulist *matteMenus; static struct keymap *matteKeyMap; static void UpdateCursors(self) struct matte *self; *************** *** 243,249 **** long left,top,width,height; { struct rectangle enclosingRect; ! if(type == view_FullRedraw && self->ref && self->desw != self->ref->desw || self->desh != self->ref->desh){ self->desw = self->ref->desw ; self->desh = self->ref->desh ; if(!self->sizepending) { --- 244,250 ---- long left,top,width,height; { struct rectangle enclosingRect; ! if(type == view_FullRedraw && self->ref && (self->desw != self->ref->desw || self->desh != self->ref->desh)){ self->desw = self->ref->desw ; self->desh = self->ref->desh ; if(!self->sizepending) { *************** *** 328,342 **** cursor_SetStandard(self->widthcursor,Cursor_VerticalBars); self->Moving = 0; self->WasMoving = 0; ! self->resizing = RESIZING; self->WasResizing = 0; self->ref = NULL; self->child = NULL; self->desw = self->desh = UNSET; - #ifdef USEMENUS self->menus = menulist_DuplicateML(matteMenus, self); ! #endif /* USEMENUS */ ! self->drawing = DRAWING; self->sizepending = TRUE; return TRUE; } --- 329,341 ---- cursor_SetStandard(self->widthcursor,Cursor_VerticalBars); self->Moving = 0; self->WasMoving = 0; ! self->resizing = environ_GetProfileSwitch("ResizeInset", RESIZING); self->WasResizing = 0; self->ref = NULL; self->child = NULL; self->desw = self->desh = UNSET; self->menus = menulist_DuplicateML(matteMenus, self); ! self->drawing = environ_GetProfileSwitch("DrawInsetBorder", DRAWING); self->sizepending = TRUE; return TRUE; } *************** *** 364,376 **** struct matte *self; struct menulist *menulist; { - #ifdef USEMENUS menulist_ClearChain(self->menus); ! menulist_ChainBeforeML(self->menus, menulist, menulist); ! view_PostMenus(self->header.view.parent, self->menus); ! #else /* USEMENUS */ ! super_PostMenus(self, menulist); ! #endif /* USEMENUS */ } void matte__WantNewSize(self,requestor) struct matte *self; --- 363,371 ---- struct matte *self; struct menulist *menulist; { menulist_ClearChain(self->menus); ! menulist_ChainBeforeML(self->menus, menulist, (long) menulist); ! super_PostMenus(self, self->menus); } void matte__WantNewSize(self,requestor) struct matte *self; *************** *** 388,410 **** } } - #ifdef USEMENUS static struct bind_Description matteBindings[]={ ! {"Allow-resizing",NULL,0,"matte,Toggle Resize",0,0,matte__SetResizing,"Allow view to resize" }, ! {"Allow-drawing",NULL,0,"matte,Toggle Draw",0,0,matte__SetDrawing,"Draw the view's border" }, NULL }; - #endif /* USEMENUS */ boolean matte__InitializeClass(classID) struct classheader *classID; { - #ifdef USEMENUS - matteMenus = menulist_New(); matteKeyMap = keymap_New(); bind_BindList(matteBindings, matteKeyMap , matteMenus, &matte_classinfo); - #endif /* USEMENUS */ return TRUE; } void matte__ObservedChanged(self, changed, value) --- 383,400 ---- } } static struct bind_Description matteBindings[]={ ! {"matte-allow-resizing",NULL,0,NULL,0,0,matte__SetResizing,"Allow view to resize" }, ! {"matte-allow-drawing",NULL,0,NULL,0,0,matte__SetDrawing,"Draw the view's border" }, NULL }; boolean matte__InitializeClass(classID) struct classheader *classID; { matteMenus = menulist_New(); matteKeyMap = keymap_New(); bind_BindList(matteBindings, matteKeyMap , matteMenus, &matte_classinfo); return TRUE; } void matte__ObservedChanged(self, changed, value) *************** *** 463,470 **** } cursor_Destroy(self->widthcursor); cursor_Destroy(self->heightcursor); - #ifdef USEMENUS menulist_Destroy(self->menus); - #endif /* USEMENUS */ - } --- 453,457 ---- *** atk/supportviews/scroll.c Fri Dec 21 14:58:45 1990 --- atk/supportviews/scroll.c.NEW Thu Apr 25 16:17:24 1991 *************** *** 2,17 **** * 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/supportviews/RCS/scroll.c,v 2.22 90/11/07 16:30:34 tpn Exp $ */ /* $ACIS:scroll.c 1.4$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/supportviews/RCS/scroll.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/supportviews/RCS/scroll.c,v 2.22 90/11/07 16:30:34 tpn Exp $"; #endif /* lint */ /* Scrollbar code for be2. */ #include --- 2,18 ---- * 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/supportviews/RCS/scroll.c,v 2.25 1991/04/12 13:48:37 rr2b Exp $ */ /* $ACIS:scroll.c 1.4$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/supportviews/RCS/scroll.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/supportviews/RCS/scroll.c,v 2.25 1991/04/12 13:48:37 rr2b Exp $"; #endif /* lint */ /* Scrollbar code for be2. */ + #define DEBUG(X) #include *************** *** 28,41 **** #include #include /* The physical aspects of the scrollbar that cannot be changed dynamically */ ! #define ENDZONELENGTH 12 #define ENDTOBARSPACE 4 ! #define BARWIDTH 20 ! #define DOTWIDTH 6 #define MINDOTLENGTH 6 #define SMALLDIST 5 #define PIXELSPERINCH 75 --- 29,51 ---- #include #include + /* The physical aspects of the scrollbar that cannot be changed dynamically */ + /* percentage overlap when thumbing using the endzones */ + #define THUMBPCT 10 /* The physical aspects of the scrollbar that cannot be changed dynamically */ ! ! #define SBORDER (TD_GAP + TD_DEPTH) ! /* size of border around scrollbar */ ! ! #define INNERWIDTH 15 /* width of the thumb and arrows */ ! #define ENDZONELENGTH (emulation?INNERWIDTH+TD_GAP:12) #define ENDTOBARSPACE 4 ! #define BARWIDTH (emulation?INNERWIDTH:20) ! #define DOTWIDTH 7 #define MINDOTLENGTH 6 #define SMALLDIST 5 + #define REALBARWIDTH(self) ((self)->barWidth+(emulation?2*SBORDER:0)) #define PIXELSPERINCH 75 *************** *** 44,50 **** LeftChange[scroll_SIDES] = {1, 0, 0, 0}, TopChange[scroll_SIDES] = {0, 0, 1, 0}, WidthChange[scroll_SIDES] = {-1, -1, 0, 0}, ! HeightChange[scroll_SIDES] = {0, 0, -1, -1}; static char *InterfaceName[scroll_TYPES] = {"scroll,vertical", "scroll,horizontal"}; --- 54,64 ---- LeftChange[scroll_SIDES] = {1, 0, 0, 0}, TopChange[scroll_SIDES] = {0, 0, 1, 0}, WidthChange[scroll_SIDES] = {-1, -1, 0, 0}, ! HeightChange[scroll_SIDES] = {0, 0, -1, -1}, NoLeftChange[scroll_SIDES] = {TD_GAP, 0, 0, 0}, ! NoTopChange[scroll_SIDES] = {0, 0, TD_GAP, 0}, ! NoWidthChange[scroll_SIDES] = {-TD_GAP, -TD_GAP, 0, 0}, ! NoHeightChange[scroll_SIDES] = {0, 0, -TD_GAP, -TD_GAP}; ! static char *InterfaceName[scroll_TYPES] = {"scroll,vertical", "scroll,horizontal"}; *************** *** 94,104 **** } range[2]; static long seen_top, seen_bot, left, right; /* Creation and Destruction routines. */ boolean scroll__InitializeClass(classID) struct classheader *classID; ! { CursorIcon[scroll_VERT] = Cursor_VerticalArrows; CursorIcon[scroll_HORIZ] = Cursor_HorizontalArrows; ThumbIcon = Cursor_Octagon; --- 108,138 ---- } range[2]; static long seen_top, seen_bot, left, right; + /* Motif Emulation variables and #defines */ + + static int emulation=0; + static short NormalIcon; + static int current_end_state = 0; + + + /* The thumb direction codes */ + #define scroll_UP 1 + #define scroll_DOWN 2 + #define scroll_NEITHER 3 + + + + #define FILLPAT (scroll_BlackPattern(self)) + + /* Creation and Destruction routines. */ boolean scroll__InitializeClass(classID) struct classheader *classID; ! { ! emulation = environ_GetProfileSwitch("MotifScrollBars", FALSE); ! if(emulation) NormalIcon = Cursor_Arrow; ! CursorIcon[scroll_VERT] = Cursor_VerticalArrows; CursorIcon[scroll_HORIZ] = Cursor_HorizontalArrows; ThumbIcon = Cursor_Octagon; *************** *** 135,158 **** self->pending_update = 0; self->updatelist = updatelist_New(); self->left = self->top = self->width = self->height = 0; self->ideal_location = scroll_LEFT; self->endzone_threshold = 80; self->bar_threshold = 0; self->endzoneLength = ENDZONELENGTH; self->endbarSpace = ENDTOBARSPACE; ! self->barWidth = BARWIDTH; ! self->dotWidth = DOTWIDTH; self->min_elevator[0] = 5; self->min_elevator[1] = 18; self->button = NEITHER; self->force_full_update = FALSE; self->force_get_interface = FALSE; - for (i = 0; i < scroll_SIDES; i++) { - self->cursor[i] = cursor_Create(self); - cursor_SetStandard(self->cursor[i], CursorIcon[Type[i]]); - } self->scrollEvent = NULL; return TRUE; } --- 169,208 ---- self->pending_update = 0; self->updatelist = updatelist_New(); self->left = self->top = self->width = self->height = 0; + self->ideal_location = scroll_LEFT; + self->endzone_threshold = 80; self->bar_threshold = 0; self->endzoneLength = ENDZONELENGTH; self->endbarSpace = ENDTOBARSPACE; ! self->barWidth = environ_GetProfileInt("ScrollBarWidth",BARWIDTH); ! self->dotWidth = environ_GetProfileInt("DotWidth", DOTWIDTH); self->min_elevator[0] = 5; self->min_elevator[1] = 18; self->button = NEITHER; self->force_full_update = FALSE; self->force_get_interface = FALSE; self->scrollEvent = NULL; + if(self->dotWidth<4) self->dotWidth=4; + if(self->barWidth<8) self->barWidth=8; + + if(self->dotWidth>self->barWidth-4) { + self->dotWidth=self->barWidth-4; + } + + if(!emulation) { + for (i = 0; i < scroll_SIDES; i++) { + self->cursor[i] = cursor_Create(self); + cursor_SetStandard(self->cursor[i], CursorIcon[Type[i]]); + } + } else { + self->direction = scroll_NEITHER; + self->cursor[0] = cursor_Create(self); + cursor_SetStandard(self->cursor[0], NormalIcon); + } + return TRUE; } *************** *** 165,172 **** if (self->child != NULL) view_UnlinkTree(self->child); updatelist_Destroy(self->updatelist); ! for (i = 0; i < scroll_SIDES; i++) ! cursor_Destroy(self->cursor[i]); } struct scroll *scroll__Create(classID, scrollee, location) --- 215,227 ---- if (self->child != NULL) view_UnlinkTree(self->child); updatelist_Destroy(self->updatelist); ! ! if(!emulation) { ! for (i = 0; i < scroll_SIDES; i++) ! cursor_Destroy(self->cursor[i]); ! } else { ! cursor_Destroy(self->cursor[0]); ! } } struct scroll *scroll__Create(classID, scrollee, location) *************** *** 239,246 **** struct scroll *self; int location; { self->ideal_location = location; ! scroll_WantUpdate(self, self); } int scroll__GetLocation(self) --- 294,302 ---- struct scroll *self; int location; { + if(emulation && self->ideal_location != location) self->force_full_update = TRUE; self->ideal_location = location; ! scroll_WantUpdate(self, self); } int scroll__GetLocation(self) *************** *** 283,288 **** --- 339,345 ---- long newWidth; { self->barWidth = newWidth; + if (self->dotWidth > newWidth - 2) { scroll_SetDotWidth(self, newWidth - 2); } *************** *** 299,312 **** struct scroll *self; long newWidth; { ! if (newWidth > self->barWidth - 2) { ! newWidth = self->barWidth - 2; ! } ! if (newWidth < 0) { ! newWidth = 0; } - self->dotWidth = newWidth; - scroll_WantUpdate(self, self); } long scroll__GetDotWidth(self) --- 356,372 ---- struct scroll *self; long newWidth; { ! if(!emulation) { ! /* NORMAL SCROLLBARS */ ! if (newWidth > self->barWidth - 2) { ! newWidth = self->barWidth - 2; ! } ! if (newWidth < 0) { ! newWidth = 0; ! } ! self->dotWidth = newWidth; ! scroll_WantUpdate(self, self); } } long scroll__GetDotWidth(self) *************** *** 319,329 **** struct scroll *self; long newLength; { ! self->endzoneLength = newLength; ! if ((self->endzoneLength + self->endbarSpace) * 2 > self->endzone_threshold) { ! self->endzone_threshold = (self->endzoneLength + self->endbarSpace) * 2; } - scroll_WantUpdate(self, self); } long scroll__GetEndZoneLength(self) --- 379,392 ---- struct scroll *self; long newLength; { ! if(!emulation) { ! /* NORMAL SCROLLBARS */ ! self->endzoneLength = newLength; ! if ((self->endzoneLength + self->endbarSpace) * 2 > self->endzone_threshold) { ! self->endzone_threshold = (self->endzoneLength + self->endbarSpace) * 2; ! } ! scroll_WantUpdate(self, self); } } long scroll__GetEndZoneLength(self) *************** *** 336,346 **** struct scroll *self; long newSpace; { ! self->endbarSpace = newSpace; ! if ((self->endzoneLength + self->endbarSpace) * 2 > self->endzone_threshold) { ! self->endzone_threshold = (self->endzoneLength + self->endbarSpace) * 2; } - scroll_WantUpdate(self, self); } --- 399,412 ---- struct scroll *self; long newSpace; { ! if(!emulation) { ! /* NORMAL SCROLLBARS */ ! self->endbarSpace = newSpace; ! if ((self->endzoneLength + self->endbarSpace) * 2 > self->endzone_threshold) { ! self->endzone_threshold = (self->endzoneLength + self->endbarSpace) * 2; ! } ! scroll_WantUpdate(self, self); } } *************** *** 388,398 **** { void (*real_setframe)(); int type = Type[side]; ! get_interface(self, type); ! if (self->fns[type] != NULL && (real_setframe = self->fns[type]->SetFrame) != NULL) ! real_setframe(self->scrollee, posn, coord, type == scroll_VERT ? self->height : self->width); } /* Calculation routines. */ --- 454,502 ---- { void (*real_setframe)(); int type = Type[side]; + int realposn = posn; + static int old[scroll_SIDES][2]; /* Type x {posn, coord} */ ! if(!emulation) { ! /* NORMAL SCROLLBARS */ ! get_interface(self, type); ! ! if (self->fns[type] != NULL && (real_setframe = self->fns[type]->SetFrame) != NULL) ! real_setframe(self->scrollee, posn, coord, type == scroll_VERT ? self->height : self->width); ! } else { ! /* MOTIF SCROLLBARS */ ! DEBUG(("set_frame: side: %d posn: %d num: %d dem: %d\n",side,posn,coord, ! (type == scroll_VERT) ? self->height : self->width)); ! DEBUG(("set_frame: oldposn: %d oldnum: %d\n",old[side][0],old[side][1])); ! ! if (updatelist_UpdatesPending(self->updatelist)) { ! /* delete the list and add us once */ ! /* updatelist_Clear(self->updatelist); */ ! updatelist_DeleteTree(self->updatelist, (struct view *)self); ! if (self->child) { ! updatelist_AddTo(self->updatelist, self->child); ! } ! } ! get_interface(self, type); ! ! ! old[side][0] = posn; ! old[side][1] = coord; ! ! DEBUG(("end: %d %d\n", ! self->desired.bar[type].seen.end, ! self->desired.bar[type].total.end)); ! ! ! DEBUG(("realposn: %d\n", realposn)); ! ! if (self->fns[type] != NULL && ! (real_setframe = self->fns[type]->SetFrame) != NULL) ! real_setframe(self->scrollee, realposn, coord, type == scroll_VERT ? ! self->height : self->width); ! } ! } /* Calculation routines. */ *************** *** 415,430 **** { void (*real_endzone)(); int type = Type[side]; get_interface(self, type); ! if (self->fns[type] != NULL && (real_endzone = self->fns[type]->EndZone) != NULL) ! real_endzone(self->scrollee, end, action); ! else { ! if (end == scroll_TOPENDZONE) ! set_frame(self, side, self->desired.bar[type].total.beg, 0); ! else ! set_frame(self, side, self->desired.bar[type].total.end, bar_height(self, side) >> 2); } } --- 519,554 ---- { void (*real_endzone)(); int type = Type[side]; + int didSC = FALSE; get_interface(self, type); ! if(!emulation) { ! /* NORMAL SCROLLBARS */ ! if (self->fns[type] != NULL && (real_endzone = self->fns[type]->EndZone) != NULL) ! real_endzone(self->scrollee, end, action); ! else { ! if (end == scroll_TOPENDZONE) ! set_frame(self, side, self->desired.bar[type].total.beg, 0); ! else ! set_frame(self, side, self->desired.bar[type].total.end, bar_height(self, side) >> 2); ! } ! } else { ! /* MOTIF SCROLLBARS */ ! ! if (self->fns[type] != NULL && ! (real_endzone = self->fns[type]->EndZone) != NULL) ! real_endzone(self->scrollee, end, action); ! else { ! if (end == scroll_TOPENDZONE) { ! set_frame(self, side, self->desired.bar[type].seen.beg, ! bar_height(self, side) * (100 - THUMBPCT) / 100); ! } else ! if (didSC) ! set_frame(self, side,self->desired.bar[type].seen.end - 100, bar_height(self, side) * THUMBPCT / 100); ! else ! set_frame(self, side, self->desired.bar[type].seen.end, bar_height(self, side) * THUMBPCT / 100); ! } } } *************** *** 454,474 **** *scroll_x = x; *scroll_y = self->top + y; break; ! case scroll__RIGHT: ! *scroll_x = scroll_GetLogicalWidth(self) - 1 - x; ! *scroll_y = self->top + y; ! break; case scroll__TOP: *scroll_x = self->left + y; *scroll_y = x; break; ! case scroll__BOTTOM: ! *scroll_x = self->left + y; ! *scroll_y = scroll_GetLogicalHeight(self) - 1 - x; break; } } static long from_range_to_bar(self, side, bar, posn) struct scroll *self; int side; --- 578,600 ---- *scroll_x = x; *scroll_y = self->top + y; break; ! case scroll__RIGHT: ! *scroll_x = scroll_GetLogicalWidth(self) - 1 - x; ! *scroll_y = self->top + y; ! break; case scroll__TOP: *scroll_x = self->left + y; *scroll_y = x; break; ! case scroll__BOTTOM: ! *scroll_x = self->left + y; ! *scroll_y = scroll_GetLogicalHeight(self) - 1 - x; break; } } + + static long from_range_to_bar(self, side, bar, posn) struct scroll *self; int side; *************** *** 477,487 **** { int endzones = bar->endzones ? self->endzoneLength : 0; long cords = bar_height(self, side) - 2*(endzones + self->endbarSpace) - 1; ! long retval = endzones + self->endbarSpace ! + ((posn - bar->total.beg) * cords + (bar->total.end - bar->total.beg) / 2) / (bar->total.end - bar->total.beg); return retval; } static long from_bar_to_range(self, side, bar, posn, status) struct scroll *self; int side, *status; --- 603,623 ---- { int endzones = bar->endzones ? self->endzoneLength : 0; long cords = bar_height(self, side) - 2*(endzones + self->endbarSpace) - 1; ! long retval; ! ! /* chosen because 1M x 2k pixels will just about overflow in 32 bits */ ! if (bar->total.end < 1000000) { ! retval = endzones + self->endbarSpace ! + ((posn - bar->total.beg) * cords + (bar->total.end - bar->total.beg) / 2) / (bar->total.end - bar->total.beg); ! } ! else { ! retval = endzones + self->endbarSpace ! + ((long)(((double)(posn - bar->total.beg)) * (double)cords / ((double)(bar->total.end - bar->total.beg)) + .5)); ! } return retval; } + static long from_bar_to_range(self, side, bar, posn, status) struct scroll *self; int side, *status; *************** *** 491,497 **** --- 627,643 ---- int endzones = bar->endzones ? self->endzoneLength : 0; long height = bar_height(self, side), cords = height - 2*(endzones + self->endbarSpace), + retval; + + if (bar->total.end < 1000000) { retval = bar->total.beg + (((bar->total.end - bar->total.beg) * (posn - self->endbarSpace - endzones) + cords / 2) / cords); + } + else { + retval = ((long) ((double)(bar->total.beg) + + ((((double)(bar->total.end - bar->total.beg)) * + ((double)(posn - self->endbarSpace - endzones))) / (double)cords) + + .5)); + } if (posn < 0 || posn >= height) *status = OUTSIDEBAR; *************** *** 505,510 **** --- 651,657 ---- return retval; } + static void calc_location(self) struct scroll *self; { *************** *** 525,530 **** --- 672,686 ---- self->height = scroll_GetLogicalHeight(self); lastlocation = self->desired.location; + if(emulation) { + /* MOTIF SCROLLBARS */ + /* give some room for the borders */ + self->left += TD_BORDER; + self->top += TD_BORDER; + self->width -= (2*TD_BORDER); + self->height -= (2*TD_BORDER); + } + for (i = 0; i < scroll_SIDES; i++) if (self->desired.location & (1<bar_threshold) { *************** *** 533,544 **** } else { /* Otherwise allocate it's space. */ ! self->left += LeftChange[i] * self->barWidth; ! self->top += TopChange[i] * self->barWidth; ! self->width += WidthChange[i] * self->barWidth; ! self->height += HeightChange[i] * self->barWidth; } ! } if (self->width < 0 || self->height < 0) { /* Turn off all scrollbars if there is no area left over. Happens when you have a very tall and narrow window, for example */ --- 689,706 ---- } else { /* Otherwise allocate it's space. */ ! self->left += LeftChange[i] * REALBARWIDTH(self); ! self->top += TopChange[i] * REALBARWIDTH(self); ! self->width += WidthChange[i] * REALBARWIDTH(self); ! self->height += HeightChange[i] * REALBARWIDTH(self); } ! } else if(emulation) { ! /* allocate the space for when the bar ISN'T there */ ! self->left += NoLeftChange[i]; ! self->top += NoTopChange[i]; ! self->width += NoWidthChange[i]; ! self->height += NoHeightChange[i]; ! } if (self->width < 0 || self->height < 0) { /* Turn off all scrollbars if there is no area left over. Happens when you have a very tall and narrow window, for example */ *************** *** 586,593 **** *y1 = from_range_to_bar(self, side, bar, bar->dot.beg); *y2 = from_range_to_bar(self, side, bar, bar->dot.end); ! *x1 = (self->barWidth - self->dotWidth + 1) / 2; ! *x2 = *x1 + self->dotWidth; if (bar->dot.beg == bar->dot.end) { *y1--; --- 748,755 ---- *y1 = from_range_to_bar(self, side, bar, bar->dot.beg); *y2 = from_range_to_bar(self, side, bar, bar->dot.end); ! *x1 = (REALBARWIDTH(self) - self->dotWidth) / 2; ! *x2 = *x1 + self->dotWidth - 1; if (bar->dot.beg == bar->dot.end) { *y1--; *************** *** 617,624 **** *y1 = from_range_to_bar(self, side, bar, bar->seen.beg); *y2 = from_range_to_bar(self, side, bar, bar->seen.end); ! *x1 = 0; ! *x2 = self->barWidth - 2; if (bar->endzones) min = self->min_elevator[1]; --- 779,793 ---- *y1 = from_range_to_bar(self, side, bar, bar->seen.beg); *y2 = from_range_to_bar(self, side, bar, bar->seen.end); ! if(!emulation) { ! /* NORMAL SCROLLBARS */ ! *x1 = 0; ! *x2 = REALBARWIDTH(self) - 2; ! } else { ! /* MOTIF SCROLLBARS */ ! *x1 = SBORDER; ! *x2 = REALBARWIDTH(self) - SBORDER; ! } if (bar->endzones) min = self->min_elevator[1]; *************** *** 653,662 **** rectangle_SetRectSize(&rect, MIN(x1,x2), MIN(y1,y2), ABS(x1-x2) + 1, ABS(y1-y2) + 1); scroll_SetTransferMode(self, graphic_COPY); ! /* scroll_FillRectSize(self, MIN(x1,x2), MIN(y1,y2), ABS(x1-x2) + 1, ABS(y1-y2) + 1, tile); */ scroll_FillRect(self, &rect, tile); } static void draw_elevator(self, side) struct scroll *self; int side; --- 822,1095 ---- rectangle_SetRectSize(&rect, MIN(x1,x2), MIN(y1,y2), ABS(x1-x2) + 1, ABS(y1-y2) + 1); scroll_SetTransferMode(self, graphic_COPY); ! scroll_FillRect(self, &rect, tile); } + + /* MOTIF SCROLLBARS */ + static void draw_bar(self, side, tt, tb) + struct scroll *self; + int side; + long tt, tb; /* top and bottom of thumb in already-rotated + coordianates */ + { + struct scrollbar *bar = &self->desired.bar[Type[side]]; + long height; + long x1, y1, x2, y2; + + height = bar_height(self, side); + + /* draw bar above thumb*/ + rotate(self, side, SBORDER , (bar->endzones ? self->endzoneLength : 0), + &x1, &y1); + rotate(self, side, REALBARWIDTH(self) - SBORDER, 0, /* don't care */ + &x2, &y2); + + if (Type[side] == scroll_VERT) + rectangle(self, x1, y1, x2 - 1, tt, FILLPAT); + else + rectangle(self, x1, y1 - 1, tt, y2, FILLPAT); + + + /* draw bar below thumb */ + rotate(self, side, SBORDER, 0, /* don't care */ + &x1, &y1); + rotate(self, side, REALBARWIDTH(self) - SBORDER, + height - (bar->endzones ? self->endzoneLength : 0), + &x2, &y2); + + if (Type[side] == scroll_VERT) + rectangle(self, x1, tb, x2 - 1, y2, FILLPAT); + else + rectangle(self, tb, y1 - 1, x2, y2, FILLPAT); + } + + static void draw_thumb_and_bar(self, side, force) + struct scroll *self; + int side; + boolean force; + { + long x1, y1, x2, y2; + static long ox1 = 0, oy1 = 0, ox2 = 0, oy2 = 0; + int ret; + struct scrollbar *bar = &self->desired.bar[Type[side]]; + + ret = calc_elevator(self, side, bar, &x1, &y1, &x2, &y2); + + if (force || ret) { + if (ret == 0) { /* use old numbers */ + x1 = ox1; y1 = oy1; + x2 = ox2; y2 = oy2; + } + + if (!force && (x1 == ox1) && (y1 == oy1) && (x2 == ox2) && (y2 == oy2)) + return; + else { + ox1=x1; oy1=y1; + ox2=x2; oy2=y2; + } + + rotate(self, side, x1, y1, &x1, &y1); + rotate(self, side, x2, y2, &x2, &y2); + + motif_Draw3dBorder((struct view *)self, x1, y1, x2, y2, + TRUE, TD_BACKPAT(self)); + /* pass in the top/left and bottom/right of the new thumb */ + if ((Type[side]) == scroll_VERT) + draw_bar(self, side, y1, y2); + else + draw_bar(self, side, x1, x2); + } + } + + + #define COPY_PT(s, d) (d).x = (s).x; (d).y = (s).y + #define SWAP_COPY_PT(s, d) (d).x = self->endzoneLength - (s).y; \ + (d).y = REALBARWIDTH(self) - (s).x; + + + static void init_arrows(self) + struct scroll *self; + { + struct arrow *a, *b; + int scale3d = TD_DEPTH * 1.84; + + /* do the up-pointing arrow */ + a = &self->arrows[ARROW_UP]; + a->pa[0].x = (REALBARWIDTH(self) >> 1); a->pa[0].y = INNERWIDTH + scale3d; + a->pa[1].x = a->pa[0].x; a->pa[1].y = a->pa[0].y - + 2 * TD_DEPTH; + a->pa[4].x = SBORDER; a->pa[4].y = TD_DEPTH; + a->pa[2].x = a->pa[4].x + scale3d; a->pa[2].y = a->pa[4].y + + TD_DEPTH; + a->pa[5].x = REALBARWIDTH(self)-SBORDER; a->pa[5].y = TD_DEPTH; + a->pa[3].x = a->pa[5].x - scale3d; a->pa[3].y = a->pa[5].y + + TD_DEPTH; + /* now the left-pointing arrow, a -90 degree rotation of the up. */ + b = &self->arrows[ARROW_LEFT]; + SWAP_COPY_PT(a->pa[0], b->pa[0]); SWAP_COPY_PT(a->pa[1], b->pa[1]); + SWAP_COPY_PT(a->pa[2], b->pa[2]); SWAP_COPY_PT(a->pa[3], b->pa[3]); + SWAP_COPY_PT(a->pa[4], b->pa[4]); SWAP_COPY_PT(a->pa[5], b->pa[5]); + } + + static void draw_endzones(self, side, height, state) + struct scroll *self; + int side, height; + int state; /* which arrow on or off */ + { + long x1, y1, x2, y2; + struct point pa[6]; + struct point t[4]; /* used for drawing the 3 traps and 1 tri */ + struct graphic *lt, *dk; + struct arrow *a = NULL; + static int arrows_inited = FALSE; + struct scrollbar *bar = &self->desired.bar[Type[side]]; + + if (!bar->endzones) + return; + + if (!arrows_inited) + init_arrows(self); + + dk = TD_FGPAT(self); + lt = TD_BGPAT(self); + + /* get a bounding box for the first arrow */ + rotate(self, side, 0, 0, &x1, &y1); + rotate(self, side, REALBARWIDTH(self), self->endzoneLength, &x2, &y2); + + /* get a set of offsets to use */ + switch (Type[side]) { + case scroll_VERT: + a = &self->arrows[ARROW_UP]; + break; + case scroll_HORIZ: + a = &self->arrows[ARROW_LEFT]; + break; + } + + pa[0].x = a->pa[0].x + MIN(x1,x2); + pa[0].y = MAX(y1,y2) - a->pa[0].y; + pa[1].x = a->pa[1].x + MIN(x1,x2); + pa[1].y = MAX(y1,y2) - a->pa[1].y; + pa[2].x = a->pa[2].x + MIN(x1,x2); + pa[2].y = MAX(y1,y2) - a->pa[2].y; + pa[3].x = a->pa[3].x + MIN(x1,x2); + pa[3].y = MAX(y1,y2) - a->pa[3].y; + pa[4].x = a->pa[4].x + MIN(x1,x2); + pa[4].y = MAX(y1,y2) - a->pa[4].y; + pa[5].x = a->pa[5].x + MIN(x1,x2); + pa[5].y = MAX(y1,y2) - a->pa[5].y; + + /* draw it */ + COPY_PT(pa[0], t[0]); COPY_PT(pa[1], t[1]); + COPY_PT(pa[3], t[2]); COPY_PT(pa[5], t[3]); + scroll_FillPolygon(self, t, 4, (state == INTOPZONE) ? lt : dk); + + COPY_PT(pa[4], t[0]); COPY_PT(pa[2], t[1]); + scroll_FillPolygon(self, t, 4, (state == INTOPZONE) ? lt : dk); + + COPY_PT(pa[1], t[2]); COPY_PT(pa[0], t[3]); + scroll_FillPolygon(self, t, 4, (state == INTOPZONE) ? dk : lt); + + COPY_PT(pa[1], t[1]); COPY_PT(pa[2], t[2]); COPY_PT(pa[3],t[0]); + scroll_FillPolygon(self, t, 3, TD_BACKPAT(self)); + + + /* get a bounding box for the second arrow */ + rotate(self, side, 0, height - self->endzoneLength, &x1, &y1); + rotate(self, side, REALBARWIDTH(self), height, &x2, &y2); + + + /* translate the offsets from the other arrow to the + other end of the scrollbar */ + switch(Type[side]) { + + case scroll_VERT: + /* x's set from above */ + a = &self->arrows[ARROW_UP]; + pa[0].y = y1 + a->pa[0].y; + pa[1].y = y1 + a->pa[1].y; + pa[2].y = y1 + a->pa[2].y; + pa[3].y = y1 + a->pa[3].y; + pa[4].y = y1 + a->pa[4].y; + pa[5].y = y1 + a->pa[5].y; + break; + + case scroll_HORIZ: + /* y's set from above */ + a = &self->arrows[ARROW_LEFT]; + pa[0].x = x2 - a->pa[0].x; + pa[1].x = x2 - a->pa[1].x; + pa[2].x = x2 - a->pa[2].x; + pa[3].x = x2 - a->pa[3].x; + pa[4].x = x2 - a->pa[4].x; + pa[5].x = x2 - a->pa[5].x; + break; + } + + /* draw it */ + COPY_PT(pa[0], t[0]); COPY_PT(pa[1], t[1]); + COPY_PT(pa[3], t[2]); COPY_PT(pa[5], t[3]); + scroll_FillPolygon(self, t, 4, (state == INBOTZONE) ? lt : dk); + + COPY_PT(pa[4], t[0]); COPY_PT(pa[2], t[1]); + scroll_FillPolygon(self, t, 4, (state == INBOTZONE) ? dk : lt); + + COPY_PT(pa[1], t[2]); COPY_PT(pa[0], t[3]); + scroll_FillPolygon(self, t, 4, (state == INBOTZONE) ? dk : lt); + + COPY_PT(pa[1], t[1]); COPY_PT(pa[2], t[2]); COPY_PT(pa[3],t[0]); + scroll_FillPolygon(self, t, 3, TD_BACKPAT(self)); + } + + static void motif_draw_whole_bar(self, side) + struct scroll *self; + int side; + { + struct scrollbar *bar = &self->desired.bar[Type[side]]; + int height = bar_height(self, side); + long x1, y1, x2, y2; + + /* clear out area around the scrollbar */ + rotate(self, side, 0, -TD_BORDER - TD_GAP, &x1, &y1); + rotate(self, side, REALBARWIDTH(self), height + TD_BORDER + TD_GAP, &x2, &y2); + rectangle(self, x1, y1, x2, y2, TD_BACKPAT(self)); + + if (bar->endzones) { + rotate(self, side, SBORDER, -TD_DEPTH, &x1, &y1); + rotate(self, side, REALBARWIDTH(self) - SBORDER, self->endzoneLength + SBORDER, &x2, &y2); + rectangle(self, x1, y1, x2, y2, FILLPAT); + + rotate(self, side, SBORDER, height - SBORDER - self->endzoneLength, &x1, &y1); + rotate(self, side, REALBARWIDTH(self) - SBORDER, height + TD_DEPTH - 1, &x2, &y2); + rectangle(self, x1, y1, x2, y2, FILLPAT); + + draw_endzones(self, side, height, current_end_state); + } + + draw_thumb_and_bar(self, side, FALSE); + + /* draw bar border */ + + switch (Type[side]) { + case scroll_VERT: + rotate(self, side, TD_GAP, -TD_BORDER, + &x1, &y1); + rotate(self, side, REALBARWIDTH(self) - TD_GAP, height + TD_BORDER, + &x2, &y2); + break; + case scroll_HORIZ: + rotate(self, side, TD_GAP, -TD_BORDER, + &x1, &y1); + rotate(self, side, REALBARWIDTH(self) - TD_GAP, height + TD_BORDER, + &x2, &y2); + break; + } + motif_Draw3dBorder(self, x1, y1, x2, y2, FALSE, NULL); + } + static void draw_elevator(self, side) struct scroll *self; int side; *************** *** 715,721 **** } } ! static void draw_whole_bar(self, side) struct scroll *self; int side; { --- 1148,1154 ---- } } ! static void normal_draw_whole_bar(self, side) struct scroll *self; int side; { *************** *** 726,748 **** scroll_SetTransferMode(self, graphic_COPY); /* line between bar and child */ ! rotate(self, side, self->barWidth - 1, 0, &x1, &y1); scroll_MoveTo(self, x1, y1); ! rotate(self, side, self->barWidth - 1, height /*- 1*/, &x1, &y1); scroll_DrawLineTo(self, x1, y1); if (bar->endzones) { rotate(self, side, 0, 0, &x1, &y1); ! rotate(self, side, self->barWidth - 2, self->endzoneLength - 1, &x2, &y2); rectangle(self, x1, y1, x2, y2, self->endzoneFill); rotate(self, side, 0, height - self->endzoneLength, &x1, &y1); ! rotate(self, side, self->barWidth - 2, height - 1, &x2, &y2); rectangle(self, x1, y1, x2, y2, self->endzoneFill); } rotate(self, side, 0, bar->endzones ? self->endzoneLength : 0, &x1, &y1); ! rotate(self, side, self->barWidth - 2, height - (bar->endzones ? self->endzoneLength : 0) - 1, &x2, &y2); rectangle(self, x1, y1, x2, y2, self->barFill); --- 1159,1181 ---- scroll_SetTransferMode(self, graphic_COPY); /* line between bar and child */ ! rotate(self, side, REALBARWIDTH(self) - 1, 0, &x1, &y1); scroll_MoveTo(self, x1, y1); ! rotate(self, side, REALBARWIDTH(self) - 1, height /*- 1*/, &x1, &y1); scroll_DrawLineTo(self, x1, y1); if (bar->endzones) { rotate(self, side, 0, 0, &x1, &y1); ! rotate(self, side, REALBARWIDTH(self) - 2, self->endzoneLength - 1, &x2, &y2); rectangle(self, x1, y1, x2, y2, self->endzoneFill); rotate(self, side, 0, height - self->endzoneLength, &x1, &y1); ! rotate(self, side, REALBARWIDTH(self) - 2, height - 1, &x2, &y2); rectangle(self, x1, y1, x2, y2, self->endzoneFill); } rotate(self, side, 0, bar->endzones ? self->endzoneLength : 0, &x1, &y1); ! rotate(self, side, REALBARWIDTH(self) - 2, height - (bar->endzones ? self->endzoneLength : 0) - 1, &x2, &y2); rectangle(self, x1, y1, x2, y2, self->barFill); *************** *** 750,755 **** --- 1183,1189 ---- draw_dot(self, side); } + static void erase_dot(self, side, top, bot) struct scroll *self; int side; *************** *** 843,864 **** rectangle(self, ul_x, ul_y, lr_x, lr_y, self->elevatorFill); scroll_SetTransferMode(self, graphic_COPY); /* One last pixel hack works for vertical scroll bars but I don't know about horizontal -- these calculations confuse me as to how they work horizontally -- maybe the rotations do work correctly, but it seems strange. */ - #if 0 - /* Old way that almost works */ - OneLastYPixel = (seen_bot != range[i].bot); - scroll_MoveTo(self, ul_x, ul_y); - scroll_DrawLineTo(self, ll_x, ll_y + OneLastYPixel ); /* +OneLastYPixel X change */ - scroll_MoveTo(self, ur_x, ur_y); - scroll_DrawLineTo(self, lr_x, lr_y + OneLastYPixel); /* +OneLastYPixel x change */ - if (seen_top == range[i].top) { - scroll_MoveTo(self, ul_x, ul_y); - scroll_DrawLineTo(self, ur_x, ur_y); - } - if (seen_bot == range[i].bot) { - scroll_MoveTo(self, ll_x, ll_y); - scroll_DrawLineTo(self, lr_x, lr_y); - } - #endif /* 0 */ /* end of old way that almost works */ /* beginning of new way to be tested */ /* See which of four cases we are interested in: two sides, top U, bottom U, all four -- note that because of the rotation transform, the hints "ul" for upper left, etc, have meaning only for vertical scrollbars */ --- 1277,1282 ---- *************** *** 949,955 **** static void ! full_update(self, type, left, top, width, height) struct scroll *self; enum view_UpdateType type; long left, top, width, height; --- 1367,1373 ---- static void ! normal_full_update(self, type, left, top, width, height) struct scroll *self; enum view_UpdateType type; long left, top, width, height; *************** *** 999,1017 **** for (i = 0; i < scroll_SIDES; i++) if (self->desired.location & (1<desired.bar[Type[i]].endzones = bar_height(self, i) >= self->endzone_threshold; ! draw_whole_bar(self, i); switch (i) { case scroll__LEFT: ! rectangle_SetRectSize(&rect, 0, self->top, self->barWidth, self->height); break; case scroll__RIGHT: ! rectangle_SetRectSize(&rect, self->left + self->width, self->top, self->barWidth, self->height); break; case scroll__TOP: ! rectangle_SetRectSize(&rect, self->left, 0, self->width, self->barWidth); break; case scroll__BOTTOM: ! rectangle_SetRectSize(&rect, self->left, self->top + self->height, self->width, self->barWidth); break; } scroll_PostCursor(self, &rect, self->cursor[i]); --- 1417,1435 ---- for (i = 0; i < scroll_SIDES; i++) if (self->desired.location & (1<desired.bar[Type[i]].endzones = bar_height(self, i) >= self->endzone_threshold; ! normal_draw_whole_bar(self, i); switch (i) { case scroll__LEFT: ! rectangle_SetRectSize(&rect, 0, self->top, REALBARWIDTH(self), self->height); break; case scroll__RIGHT: ! rectangle_SetRectSize(&rect, self->left + self->width, self->top, REALBARWIDTH(self), self->height); break; case scroll__TOP: ! rectangle_SetRectSize(&rect, self->left, 0, self->width, REALBARWIDTH(self)); break; case scroll__BOTTOM: ! rectangle_SetRectSize(&rect, self->left, self->top + self->height, self->width, REALBARWIDTH(self)); break; } scroll_PostCursor(self, &rect, self->cursor[i]); *************** *** 1025,1030 **** --- 1443,1611 ---- } } + + static void motif_full_update(self, type, left, top, width, height) + struct scroll *self; + enum view_UpdateType type; + long left, top, width, height; + { + int i; + struct rectangle rect, crect, VB; + + scroll_GetVisualBounds(self, &VB); + self->force_full_update = FALSE; + if (self->force_get_interface) + for (i = 0; i < scroll_TYPES; i++) + self->fns[i] = NULL; + + /* clear out space between views' border and the view */ + + motif_DrawBorder(self, self->left - TD_BORDER + TD_DEPTH + 0, + self->top - TD_BORDER + TD_DEPTH + 0, + self->left + self->width + TD_BORDER - TD_DEPTH - 0, + self->top + self->height + TD_BORDER - TD_DEPTH - 0, + scroll_WhitePattern(self), scroll_WhitePattern(self), + NULL, TD_BORDER + TD_DEPTH); + + /* do the border around the view */ + + motif_Draw3dBorder(self, self->left - TD_BORDER + 0, + self->top - TD_BORDER + 0, + self->left + self->width + TD_BORDER - 0, + self->top + self->height + TD_BORDER - 0, + FALSE, NULL); + + if (self->child) { + rectangle_SetRectSize(&rect, self->left, self->top, self->width, + self->height); + view_InsertView(self->child, self, &rect); + rectangle_SetRectSize(&crect, left, top, width, height); + rectangle_IntersectRect(&crect, &crect, &rect); + + view_FullUpdate(self->child, type, crect.left - self->left, + crect.top - self->top, crect.width, crect.height); + /* Is it possible that the scrollee has changed his mind about the + scrollbar locations now that he has been redrawn? If so, we need to + account for his area changing, and recalling his full update. Then + what if he changes his mind again? */ + calc_desired(self); + } + + /* If visual rectangle is bogus-- leave. */ + if(type == view_Remove || rectangle_IsEmptyRect(&VB) ) + return; + + if (type != view_FullRedraw && type != view_LastPartialRedraw) + return; + + /* First, draw the border and background */ + for (i = 0; i < scroll_SIDES; i++) + if (self->desired.location & (1<desired.bar[Type[i]].endzones = bar_height(self, i) >= + self->endzone_threshold; + switch (i) { + case scroll__LEFT: + rectangle_SetRectSize(&rect, SBORDER, self->top, + REALBARWIDTH(self), self->height); + break; + case scroll__RIGHT: + rectangle_SetRectSize(&rect, self->left + self->width + TD_BORDER + SBORDER, self->top, + REALBARWIDTH(self), self->height); + break; + case scroll__TOP: + rectangle_SetRectSize(&rect, self->left - TD_BORDER, SBORDER, + self->width, REALBARWIDTH(self)); + break; + case scroll__BOTTOM: + rectangle_SetRectSize(&rect, self->left - TD_BORDER, self->top + self->height + TD_BORDER + SBORDER, + self->width, REALBARWIDTH(self)); + break; + } + scroll_PostCursor(self, &rect, self->cursor[0]); + } else { /* the bar isn't there */ + scroll_RetractCursor(self, self->cursor[0]); + switch (i) { + case scroll__LEFT: + rectangle(self, 0, 0, + TD_GAP, scroll_GetLogicalHeight(self), + TD_BACKPAT(self)); + break; + case scroll__RIGHT: + rectangle(self, scroll_GetLogicalWidth(self), 0, + scroll_GetLogicalWidth(self) - TD_GAP, + scroll_GetLogicalHeight(self), TD_BACKPAT(self)); + break; + case scroll__TOP: + rectangle(self, 0, 0, scroll_GetLogicalWidth(self), + TD_GAP, TD_BACKPAT(self)); + break; + case scroll__BOTTOM: + rectangle(self, 0, scroll_GetLogicalHeight(self), + scroll_GetLogicalWidth(self), + scroll_GetLogicalHeight(self) - TD_GAP, + TD_BACKPAT(self)); + } + } + + + /* Next, fill in the corners */ + + if (self->left - TD_BORDER > 0) { + if (self->top - TD_BORDER > 0) { + rectangle(self, 0, 0, self->left - TD_BORDER, self->top - TD_BORDER, + TD_BACKPAT(self)); + } + + if (self->height+self->top+2*TD_BORDER < scroll_GetLogicalHeight(self)) { + rectangle(self, 0, self->height + self->top + TD_BORDER, + self->left - TD_BORDER, + scroll_GetLogicalHeight(self), TD_BACKPAT(self)); + } + } + + if (self->width + self->left + 2*TD_BORDER< scroll_GetLogicalWidth(self)) { + int left = self->width + self->left + TD_BORDER; + + if (self->top - TD_BORDER > 0) { + rectangle(self, left, 0, scroll_GetLogicalWidth(self), + self->top - TD_BORDER, TD_BACKPAT(self)); + } + + if (self->height + self->top + TD_BORDER< scroll_GetLogicalHeight(self)) { + rectangle(self, left, self->height + self->top + TD_BORDER, + scroll_GetLogicalWidth(self), + scroll_GetLogicalHeight(self), TD_BACKPAT(self)); + } + } + + + /* Now, draw the scrollbars themselves */ + + for (i = 0; i < scroll_SIDES; i++) + if (self->desired.location & (1<current = self->desired; + scroll_FlushGraphics(self); + } + + + static void full_update(self, type, left, top, width, height) + struct scroll *self; + enum view_UpdateType type; + long left, top, width, height; + { + if(!emulation) { + /* NORMAL SCROLLBARS */ + normal_full_update(self, type, left, top, width, height); + } else { + /* MOTIF SCROLLBARS */ + motif_full_update(self, type, left, top, width, height); + } + } + /* Overrides of the view routines: */ void scroll__FullUpdate(self, type, left, top, width, height) *************** *** 1035,1045 **** self->pending_update = 0; if (type == view_FullRedraw || type == view_LastPartialRedraw) { ! self->cornerFill = scroll_GrayPattern(self,8,16); ! self->endzoneFill = scroll_GrayPattern(self,2,16); ! self->barFill = scroll_GrayPattern(self,4,16); ! self->whiteFill =self->elevatorFill = scroll_WhitePattern(self); ! calc_location(self); calc_desired(self); } --- 1616,1626 ---- self->pending_update = 0; if (type == view_FullRedraw || type == view_LastPartialRedraw) { ! self->cornerFill = scroll_GrayPattern(self,environ_GetProfileInt("CornerShade",8),16); ! self->endzoneFill = scroll_GrayPattern(self,environ_GetProfileInt("EndZoneShade",2),16); ! self->barFill = scroll_GrayPattern(self,environ_GetProfileInt("BackgroundShade",4),16); ! self->whiteFill =scroll_WhitePattern(self); ! self->elevatorFill = scroll_GrayPattern(self,environ_GetProfileInt("ElevatorShade",0),16); calc_location(self); calc_desired(self); } *************** *** 1046,1052 **** full_update(self, type, left, top, width, height); } ! void scroll__Update(self) struct scroll *self; { int i; --- 1627,1633 ---- full_update(self, type, left, top, width, height); } ! void normal_scroll__Update(self) struct scroll *self; { int i; *************** *** 1071,1077 **** /* Is the change so drastic that we need to start from scratch? */ if (self->current.location != self->desired.location || self->force_full_update) { ! rectangle(self, l, t, w, h, self->whiteFill); full_update(self, view_FullRedraw, l, t, w, h); } else { --- 1652,1658 ---- /* Is the change so drastic that we need to start from scratch? */ if (self->current.location != self->desired.location || self->force_full_update) { ! rectangle(self, l, t, w, h, self->whiteFill); full_update(self, view_FullRedraw, l, t, w, h); } else { *************** *** 1082,1088 **** if (des->endzones != cur->endzones) /* The entire scrollbar need redrawing? */ ! draw_whole_bar(self, i); else if (des->total.beg != cur->total.beg || des->total.end != cur->total.end || des->seen.beg != cur->seen.beg || des->dot.beg != cur->dot.beg || des->seen.end != cur->seen.end || des->dot.end != cur->dot.end) { move_elevator(self, i); } --- 1663,1669 ---- if (des->endzones != cur->endzones) /* The entire scrollbar need redrawing? */ ! normal_draw_whole_bar(self, i); else if (des->total.beg != cur->total.beg || des->total.end != cur->total.end || des->seen.beg != cur->seen.beg || des->dot.beg != cur->dot.beg || des->seen.end != cur->seen.end || des->dot.end != cur->dot.end) { move_elevator(self, i); } *************** *** 1091,1096 **** --- 1672,1728 ---- } } + void motif_scroll__Update(self) + struct scroll *self; + { + int i; + long l, t, w, h; + + l = scroll_GetVisualLeft(self); + t = scroll_GetVisualRight(self); + w = scroll_GetVisualWidth(self); + h = scroll_GetVisualHeight(self); + + if (w == 0 || h == 0) return; + + self->pending_update = 0; + /* Let the children modify their state however they want. */ + updatelist_Clear(self->updatelist); + + if (self->thumbing == YES) { + return; + } + calc_location(self); + calc_desired(self); + + /* Is the change so drastic that we need to start from scratch? */ + if (self->current.location != self->desired.location || + self->force_full_update) { + rectangle(self, l, t, w, h, TD_BACKPAT(self)); + full_update(self, view_FullRedraw, l, t, w, h); + } + else { + for (i = 0; i < scroll_SIDES; i++) + if (self->desired.location & (1<current = self->desired; + } + } + + void scroll__Update(self) + struct scroll *self; + { + if(!emulation) { + /* NORMAL SCROLLBARS */ + normal_scroll__Update(self); + } else { + /* MOTIF SCROLLBARS */ + motif_scroll__Update(self); + } + } + + void scroll__WantUpdate(self, requestor) struct scroll *self; struct view *requestor; *************** *** 1103,1108 **** --- 1735,1778 ---- super_WantUpdate(self, self); } } + /* + * What to do every time the timer repeat fires. + * We separate this from RepeatScroll so that we can call + * it right when we get a mouse hit. This way there is + * no scroll latency. + */ + static void RepeatEvent(self) + struct scroll *self; + { + struct scrollbar *cur = NULL; + static long lastcoord = 0; + + + if (lastcoord == 0) + lastcoord = self->hitcoord; + + if (self->side != -1) { + cur = &self->current.bar[Type[self->side]]; + } + + if (current_end_state != 0) { + endzone(self, self->side, (current_end_state == INTOPZONE ? + scroll_TOPENDZONE : scroll_BOTTOMENDZONE), + view_LeftDown); + } else { + switch (self->direction) { + case scroll_DOWN: + set_frame(self, self->side, what_is_at(self, self->side, self->hitcoord), 0); + break; + case scroll_UP: + set_frame(self, self->side, what_is_at(self, self->side, self->hitcoord), bar_height(self, self->side)); + break; + } + } + + draw_thumb_and_bar(self, self->side, TRUE); + + } static void RepeatScroll(self, cTime) struct scroll *self; *************** *** 1111,1143 **** struct scrollbar *cur = NULL; long timeInterval; ! self->button |= SMOOTH; ! timeInterval = minContScrollTime + (((maxContScrollTime - minContScrollTime) * self->hitcoord) / (PIXELSPERINCH * 10)); ! self->scrollEvent = im_EnqueueEvent((procedure) RepeatScroll, (char *) self, event_MSECtoTU(timeInterval)); ! if (self->side != -1) { ! cur = &self->current.bar[Type[self->side]]; ! } ! if (self->button == (LEFT | SMOOTH)) ! set_frame(self, self->side, what_is_at(self, self->side, self->hitcoord), 0); ! else if (self->button == (RIGHT | SMOOTH)) ! set_frame(self, self->side, cur->seen.beg, self->hitcoord); ! self->thumbing = NOPE; ! im_ForceUpdate(); } ! struct view *scroll__Hit(self, action, x, y, num_clicks) struct scroll *self; enum view_MouseAction action; long x, y, num_clicks; { ! int posn = 0, status, side = 0, length, delta, i, endzones; long coord = 0, temp, y1, y2; struct scrollbar *cur = NULL, *des = NULL; long logicalTop, logicalHeight, logicalPos; --- 1781,1831 ---- struct scrollbar *cur = NULL; long timeInterval; ! if(!emulation) { ! /* NORMAL SCROLLBARS */ ! self->button |= SMOOTH; ! timeInterval = minContScrollTime + (((maxContScrollTime - minContScrollTime) * self->hitcoord) / (PIXELSPERINCH * 10)); ! self->scrollEvent = im_EnqueueEvent((procedure) RepeatScroll, (char *) self, event_MSECtoTU(timeInterval)); ! if (self->side != -1) { ! cur = &self->current.bar[Type[self->side]]; ! } ! if (self->button == (LEFT | SMOOTH)) ! set_frame(self, self->side, what_is_at(self, self->side, self->hitcoord), 0); ! else if (self->button == (RIGHT | SMOOTH)) ! set_frame(self, self->side, cur->seen.beg, self->hitcoord); ! self->thumbing = NOPE; ! ! } else { ! timeInterval = minContScrollTime + ! (((maxContScrollTime - minContScrollTime) * self->hitcoord) / ! (PIXELSPERINCH * 10)); ! ! /* try and stop re-entrancy */ ! if (self->scrollEvent != NULL) { ! event_Cancel(self->scrollEvent); ! self->scrollEvent = NULL; ! } ! ! self->scrollEvent = im_EnqueueEvent(RepeatScroll, self, ! event_MSECtoTU(timeInterval)); ! ! RepeatEvent(self); ! } } ! struct view *normal_scroll__Hit(self, action, x, y, num_clicks) struct scroll *self; enum view_MouseAction action; long x, y, num_clicks; { ! int posn = 0, status, side = 0, delta, i, endzones; long coord = 0, temp, y1, y2; struct scrollbar *cur = NULL, *des = NULL; long logicalTop, logicalHeight, logicalPos; *************** *** 1238,1244 **** endzones = (cur->endzones ? self->endzoneLength : 0) + self->endbarSpace; switch (self->thumbing) { ! long newPos, x1, y1, x2, y2; case MAYBE: if (ABS(coord - self->hitcoord) <= SMALLDIST) { --- 1926,1932 ---- endzones = (cur->endzones ? self->endzoneLength : 0) + self->endbarSpace; switch (self->thumbing) { ! long newPos; case MAYBE: if (ABS(coord - self->hitcoord) <= SMALLDIST) { *************** *** 1393,1398 **** --- 2081,2416 ---- return (struct view *)self; } + struct view *motif_scroll__Hit(self, action, x, y, num_clicks) + struct scroll *self; + enum view_MouseAction action; + long x, y, num_clicks; + { + int posn = 0, status, side = 0, delta, i, endzones; + long coord = 0, temp, y1, y2; + struct scrollbar *cur = NULL, *des = NULL; + long logicalTop, logicalHeight, logicalPos; + static int last_hit_side = 0; + + if (action == view_LeftDown || action == view_RightDown) { + if (self->button != NEITHER) + /* We already are dealing with the other button. */ + return (struct view *)self; + + if (x >= self->left + && y >= self->top + && x < self->left + self->width + && y < self->top + self->height + && self->child) { + struct view *retval = view_Hit(self->child, action, x - self->left, + y - self->top, num_clicks); + return retval; + } + else if (action == view_RightDown) + return (struct view *)self; + + else if (x < self->left && (self->current.location & scroll_LEFT)) { + cur = &self->current.bar[Type[side = scroll__LEFT]]; + self->hitcoord = y - self->top; + posn = from_bar_to_range(self, side, cur, self->hitcoord, &status); + } + else if (x >= self->left + self->width && + (self->current.location & scroll_RIGHT)) { + cur = &self->current.bar[Type[side = scroll__RIGHT]]; + self->hitcoord = y - self->top; + posn = from_bar_to_range(self, side, cur, self->hitcoord, &status); + } + else if (y < self->top && (self->current.location & scroll_TOP)) { + cur = &self->current.bar[Type[side = scroll__TOP]]; + self->hitcoord = x - self->left; + posn = from_bar_to_range(self, side, cur, self->hitcoord, &status); + } + else if (y >= self->top + self->height && + (self->current.location & scroll_BOTTOM)) { + cur = &self->current.bar[Type[side = scroll__BOTTOM]]; + self->hitcoord = x - self->left; + posn = from_bar_to_range(self, side, cur, self->hitcoord, &status); + } + else + status = OUTSIDEBAR; + + current_end_state = 0; + + switch (status) { + case OUTSIDEBAR: + self->thumbing = NOPE; + /* These -1's are dangerous. I am fairly certain they don't get used outside + * of this routine, and that they are handled properly within it. But you never + * know... + */ + self->side = -1; + self->button = NEITHER; + break; + case INTOPZONE: + case INBOTZONE: + self->direction = (status == INTOPZONE) ? + scroll_UP : scroll_DOWN; + + current_end_state = status; + last_hit_side = side; + if ((&self->desired.bar[Type[side]])->endzones) + draw_endzones(self, side, bar_height(self, side), + current_end_state); + endzone(self, side, (current_end_state == INTOPZONE ? + scroll_TOPENDZONE : scroll_BOTTOMENDZONE), + action); + case INSIDEBAR: + last_hit_side = side; + if (calc_elevator(self, side, cur, &temp, &y1, &temp, &y2) + && y1 <= self->hitcoord && self->hitcoord <= y2) { + self->thumbing = MAYBE; + self->seenLength = cur->seen.end - cur->seen.beg; + } else + self->thumbing = NOPE; + + self->side = side; + + /* above or below thumb ? */ + self->direction = scroll_NEITHER; + + /* determine if above or below thumb */ + if (self->hitcoord < y1) + self->direction = scroll_UP; + + if (self->hitcoord > y2) + self->direction = scroll_DOWN; + + self->side = side; + + if (action == view_LeftDown) + self->button = LEFT; + else + self->button = RIGHT; + + self->hitposn = posn; + + RepeatEvent(self); + + if (startScrollTime > 0) { + self->scrollEvent = + im_EnqueueEvent(RepeatScroll, self, + event_MSECtoTU(startScrollTime)); + } + + break; + } + return (struct view *)self; + } + + /* Assure that we have the correct button */ + if (((action == view_LeftMovement || action == view_LeftUp) && + ((self->button & LEFT) == 0))) + return (struct view *)self; + + if (self->side != -1) { + cur = &self->current.bar[Type[self->side]]; + des = &self->desired.bar[Type[self->side]]; + if (self->side == scroll__LEFT || self->side == scroll__RIGHT) { + logicalTop = self->top; + logicalHeight = self->height; + logicalPos = y; + /* coord = y - self->top; */ + } else { + logicalTop = self->top; + logicalHeight = self->height; + logicalPos = x; + /* coord = x - self->left; */ + } + coord = logicalPos - logicalTop; + } + + if (action == view_LeftMovement) { + endzones = (cur->endzones ? self->endzoneLength : 0); + + switch (self->thumbing) { + long newPos; + + case YES: + DEBUG(("YES hitc: %d coord: %d lt: %d lh: %d lp: %d\n", self->hitcoord, coord, logicalTop, logicalHeight, logicalPos)); + + self->direction = scroll_NEITHER; + if (coord == self->hitcoord) { + /* no movement, punt */ + break; + } + if (coord < self->hitcoord) { + if (self->hitposn == 0) { + /* thumb at top, want to reset hitcoord */ + if (coord < logicalTop + endzones) { + self->hitcoord = logicalTop + endzones; + } else { + self->hitcoord = coord; + } + break; + } else if (logicalPos > (logicalTop + logicalHeight - + endzones)) { + /* + We are moving back up from below the scroll bar + Do not start moving backwards until we are back in + the scroll bar area + */ + self->hitcoord = coord; + break; + } + } + newPos = from_range_to_bar(self, self->side, cur, + cur->seen.beg) + coord - + self->hitcoord; + if (newPos < logicalTop + endzones - 9) + newPos = logicalTop + endzones - 9; + if (newPos > logicalTop + logicalHeight - endzones) + newPos = logicalTop + logicalHeight - endzones; + posn = from_bar_to_range(self, self->side, cur, newPos, + &status); + + + if (status == INSIDEBAR || status == INBOTZONE) { + + delta = posn - self->hitposn; + if (delta != 0) { + DEBUG(("\tdelta: %d newPos: %d posn: %d y: %d\n", delta, newPos, posn, y)); + des->seen.beg += delta; + if (des->seen.beg < des->total.beg) { + des->seen.beg = des->total.beg; + des->seen.end = MIN(des->total.end, + des->seen.beg + + self->seenLength); + } else if (des->seen.beg > des->total.end) { + des->seen.beg = des->total.end; + des->seen.end = des->total.end; + } else + des->seen.end = MIN(des->total.end, + des->seen.beg + + self->seenLength); + DEBUG(("des.seen.beg: %d\n", des->seen.beg)); + + for (i = 0; i < scroll_SIDES; i++) { + if ((self->current.location & (1<side]) { + draw_thumb_and_bar(self, i, FALSE); + if (thumbScroll) { + set_frame(self, self->side, des->seen.beg, 0); + } + } + } + *cur = *des; + self->hitposn = posn; + self->hitcoord = coord; + } else if (self->hitposn == 0 && coord < self->hitcoord) { + self->hitcoord = coord; + } + } + break; + case MAYBE: + self->direction = scroll_NEITHER; + if (ABS(coord - self->hitcoord) > SMALLDIST) { + self->hitcoord = coord; + self->hitposn = + self->current.bar[Type[self->side]].seen.beg; + DEBUG(("MAYBE hc: %d hp: %d y: %d\n", self->hitcoord, self->hitposn, y)); + self->thumbing = YES; + if (self->scrollEvent != NULL) { + event_Cancel(self->scrollEvent); + self->scrollEvent = NULL; + } + } + break; + + case NOPE: + if (adjustScroll) { + self->hitcoord = coord; + } + break; + } + return (struct view *)self; + } + + /* The action must be an up transition to get to here. */ + + current_end_state = 0; + + if ((&self->desired.bar[Type[last_hit_side]])->endzones) + DEBUG(("last hit side %d\n",last_hit_side)); + draw_endzones(self, last_hit_side, bar_height(self, last_hit_side), + current_end_state); + + if (self->scrollEvent != NULL) { + event_Cancel(self->scrollEvent); + self->scrollEvent = NULL; + } + + if (self->thumbing != NOPE) { + cursor_SetStandard(self->cursor[0], NormalIcon); + im_SetWindowCursor(self->header.view.imPtr, NULL); + + if (ABS(coord - self->hitcoord) > SMALLDIST) { + long newPos = from_range_to_bar(self, self->side, cur, + cur->seen.beg) + coord - + self->hitcoord; + + posn = from_bar_to_range(self, self->side, cur, newPos, &status); + + if (status == INSIDEBAR || status == INBOTZONE) { + delta = posn - self->hitposn; + des->seen.beg += delta; + if (des->seen.beg < des->total.beg) + des->seen.beg = des->total.beg; + else if (des->seen.beg > des->total.end) { + des->seen.beg = des->total.end; + } + } + + set_frame(self, self->side, des->seen.beg, 0); + DEBUG(("beg: %d\n", des->seen.beg)); + scroll_WantUpdate(self, self); + + self->button = NEITHER; + self->thumbing = NOPE; + + return (struct view *)self; + } + } + + self->thumbing = NOPE; + + if (self->thumbing != YES) { + if (adjustScroll) { + self->hitcoord = coord; + } + } + + if (self->button == LEFT && (action == view_LeftDown || + action == view_LeftMovement)) + set_frame(self, self->side, what_is_at(self, self->side, + self->hitcoord), 0); + else if (self->button == RIGHT) + set_frame(self, self->side, cur->seen.beg, self->hitcoord); + + self->button = NEITHER; + self->thumbing = NOPE; + + return (struct view *)self; + } + + struct view *scroll__Hit(self, action, x, y, num_clicks) + struct scroll *self; + enum view_MouseAction action; + long x, y, num_clicks; + { + if(!emulation) { + /* NORMAL SCROLLBARS */ + return normal_scroll__Hit(self, action, x, y, num_clicks); + } else { + /* MOTIF SCROLLBARS */ + return motif_scroll__Hit(self, action, x, y, num_clicks); + } + } + void scroll__LinkTree(self, parent) struct scroll *self; struct view *parent; *************** *** 1410,1413 **** --- 2428,2496 ---- updatelist_DeleteTree(self->updatelist, unlinkedTree); super_UnlinkNotification(self, unlinkedTree); + } + + /* The 3-D drawing routines */ + + void motif_Draw3dBorder(v, x1, y1, x2, y2, sense, fillp) + struct view *v; + long x1, y1, x2, y2; + boolean sense; /* "innie" or "outtie" */ + struct graphic *fillp; /* center fill pattern, NULL for none */ + { + motif_DrawBorder(v, x1, y1, x2, y2, + (sense) ? view_GrayPattern(v, TD_BGPATVAL, 16) : + view_GrayPattern(v, TD_FGPATVAL, 16), + (sense) ? view_GrayPattern(v, TD_FGPATVAL, 16) : + view_GrayPattern(v, TD_BGPATVAL, 16), + fillp, + TD_DEPTH); + } + + + void motif_DrawBorder(v, x1, y1, x2, y2, lt, dk, fillp, depth) + struct view *v; + long x1, y1, x2, y2; /* enclosing coords */ + struct graphic *lt, *dk, *fillp; /* patterns for light, dark and center */ + int depth; /* depth of border */ + { + + long left, top, width, height; + long left2, top2, width2, height2; + long r2_bot, r_bot; + + left = (x1 + #define scroll_VERSION 3 /* The different locations scrollbars can appear in. For more than one scrollbar, or the values of the single underscore constants together. */ *************** *** 33,38 **** --- 35,47 ---- #define scroll_TOPENDZONE 1 #define scroll_BOTTOMENDZONE 2 + /* the arrows in the arrow array */ + #define ARROW_UP 0 + #define ARROW_LEFT 1 + + struct arrow { + struct point pa[6]; + }; struct scrollfns { void (*GetInfo)(/* self, total, seen, dot */); *************** *** 145,151 **** --- 154,184 ---- struct graphic *elevatorFill; struct graphic *whiteFill; struct event *scrollEvent; + int direction; /* used for the endzone arrows */ + /* array[2] of array[6] of points for a left-pointing and an up-pointing + arrow. w.r.t. a (0,0) origin at the lower left of a bouding box. + Basically, offsets to be used when drawing the arrows */ + struct arrow arrows[2]; }; /* Fake a get view routine. */ #define scroll_GetView scroll_GetScrollee + + void motif_Draw3dBorder(); + void motif_DrawBorder(); + + /* package of routines for doing 3-D boxes and stuff like that */ + + #define TD_DEPTH 2 /* width of 3d border */ + #define TD_GAP 7 /* space from edge of view to 3d border */ + #define TD_BORDER TD_DEPTH/* distance from edge of view's border to */ + /* edge of view */ + /* 8, 12, 16 */ + + #define TD_FGPATVAL 8 /* recommended foreground pattern */ + #define TD_BACKPATVAL 4 /* recommended nominal background pattern */ + #define TD_BGPATVAL 0 /* recommended background pattern */ + + #define TD_FGPAT(self) (graphic_GrayPattern(((&(self)->header.view))->drawable,TD_FGPATVAL,16)) + #define TD_BGPAT(self) (graphic_GrayPattern(((&(self)->header.view))->drawable,TD_BGPATVAL,16)) + #define TD_BACKPAT(self) (graphic_GrayPattern(((&(self)->header.view))->drawable,TD_BACKPATVAL,16)) *** atk/supportviews/scroll.help Wed Nov 22 12:30:56 1989 --- atk/supportviews/scroll.help.NEW Sun May 5 18:54:32 1991 *************** *** 1,4 **** ! \begindata{text,269136484} \textdsversion{12} \template{help} \chapter{The Scroll Bar} --- 1,4 ---- ! \begindata{text,268761888} \textdsversion{12} \template{help} \chapter{The Scroll Bar} *************** *** 7,16 **** \section{What is the Scroll Bar?} ! \leftindent{The scroll bar is the column on the left of your Typescript, EZ, ! Help and other windows. It represents the entire document that is in the ! window. When a document is too long to show its entire contents in a window, ! you can use the scroll bar to bring different parts of the document into view.} \section{Moving Around in a Window} --- 7,17 ---- \section{What is the Scroll Bar?} ! \leftindent{The scroll bar is (usually) the column on the left of your ! Typescript, EZ, Help and other windows. It represents the entire document ! that is in the window. When a document is too long to show its entire ! contents in a window, you can use the scroll bar to bring different parts of ! the document into view.} \section{Moving Around in a Window} *************** *** 117,125 **** Right click means move what is at the left edge of the window to above the ! cursor.} \section{Related Tools} --- 118,217 ---- Right click means move what is at the left edge of the window to above the ! cursor. ! ! } ! \section{Preferences}\leftindent{ ! ! \bold{MotifScrollBars:}\italic{\bold{ no} ! ! }\leftindent{ Determines if "Motif" style scrollbars are desired. ! ! } ! \bold{ScrollbarWidth:}\italic{\bold{ }\bold{20} }\bold{(for normal scrollbars ! )}\italic{,\bold{ 15 }}\bold{(for "Motif" style scrollbars)}\italic{ ! ! }\leftindent{ Determines the width of the scrollbar. ! ! } ! \bold{DotWidth:}\italic{\bold{ 7} ! ! }\leftindent{ The width of the rectangle which indicates where the cursor is ! or where the selection is. ! ! } ! \bold{CornerShade:}\italic{\bold{ 8} ! ! }\leftindent{ A number from 0 (white) to 16 (black) indicating what shade ! pattern should be used for the corners of the window which are left when two ! scrollbars are being used (for instance when viewing a raster or table). ! ! } ! \bold{EndZoneShade:}\italic{\bold{ 2} ! ! }\leftindent{ Same as CornerShade but for the end regions of the scrollbars. ! ! } ! \bold{BackgroundShade:}\italic{\bold{ 4} ! ! }\leftindent{Same as CornerShade but for the region of the scrollbar not ! covered by the elevator (the normally white rectangle which indicated what ! portion of the document is visible). ! ! } ! \bold{ElevatorShade:}\italic{\bold{ 0} ! ! }\leftindent{Same as CornerShade but for the interior of the rectangle which ! shows which portion of the document is visible. ! ! } ! \bold{ScrollbarPosition: (no default)} ! ! \leftindent{For text scrollbars this determines whether the scrollbar appears ! on the left or the right. If it is set to be "right"(capitalization matters ! here) the scrollbar will appear on the right of the text, if it is set to ! anything else the scrollbar will appear to the left. ! ! ! }}\leftindent{\bold{StartScrollTime: \italic{integer}} ! ! \leftindent{This value is used to set the time interval before repeat ! scrolling kicks in. The value is in milliseconds. A value of 0 (the default) ! indicates that no repeat scrolling is to be used.} ! ! ! \bold{ContScrollTime:\italic{ 500}} ! ! \leftindent{This controls how fast repeat scrolling in small increments (line ! size) occurs. Again it is in milliseconds.} ! ! ! \bold{MaxContScrollTime:\italic{ integer} ! ! MinContScrollTime: \italic{integer}} ! ! \leftindent{This controls how fast repeat scrolling in large (page size) ! increments occurs. Again it is in milliseconds. Increments between these two ! amounts is done by interpolating between those two values.} ! ! ! \bold{AdjustScroll: \italic{no}} ! ! \leftindent{If this is set to "yes," then the increment for repeat scrolling ! is constantly recalculated relative to the position of the mouse. With it on ! you can start scrolling by pages and then move the cursor up toward the top of ! the scroll bar to do more fine scrolling when they get close. If it is false ! then the repeat scrolling increment is determined by where you first press the ! mouse down in the scroll bar and can not be readjusted.} ! ! ! \bold{ThumbScroll: \italic{no}} + \leftindent{If this is set to "yes," then the image being scrolled will be + updated as the user thumbs in the scroll bar with the left mouse down. The + right mouse down will always thumb without updating the image. + }} \section{Related Tools} *************** *** 132,135 **** \leftindent{\italic{selecting menus\ ! }}\enddata{text,269136484} --- 224,227 ---- \leftindent{\italic{selecting menus\ ! }}\enddata{text,268761888} *** atk/supportviews/strtbl.c Wed Sep 26 16:07:42 1990 --- atk/supportviews/strtbl.c.NEW Wed Dec 19 13:27:49 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/supportviews/RCS/strtbl.c,v 2.7 90/08/13 16:04:47 ajp Exp $ */ /* $ACIS:strtbl.c 1.3$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/supportviews/RCS/strtbl.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/supportviews/RCS/strtbl.c,v 2.7 90/08/13 16:04:47 ajp 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/supportviews/RCS/strtbl.c,v 2.8 90/12/19 13:25:41 ajp Exp $ */ /* $ACIS:strtbl.c 1.3$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/supportviews/RCS/strtbl.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/supportviews/RCS/strtbl.c,v 2.8 90/12/19 13:25:41 ajp Exp $"; #endif /* lint */ *************** *** 131,137 **** } static short ! FindString(self, s) register struct stringtbl *self; register unsigned char *s; /* Finds string s in self and returns its index. returns -1 for failure.*/ --- 131,137 ---- } static short ! FindString(self, s, startIndex) register struct stringtbl *self; register unsigned char *s; /* Finds string s in self and returns its index. returns -1 for failure.*/ *************** *** 138,146 **** { register short i; if (s == NULL || *s == '\0') return (-2); ! for (i = self->used; i-- > 0; ) if (strcmp(s, self->item[i]) == 0) return (i); return (-1); } static void --- 138,147 ---- { register short i; if (s == NULL || *s == '\0') return (-2); ! for (i = startIndex; i < self->used; i++) { if (strcmp(s, self->item[i]) == 0) return (i); + } return (-1); } static void *************** *** 162,167 **** --- 163,181 ---- } } + short stringtbl__GetEntryOfString(self, s, startIndex) + register struct stringtbl *self; + register unsigned char *s; + short startIndex; + { + register short i; + + i = FindString(self, s, startIndex); + if (i >= 0) { + return self->accmap[i]; + } + return -1; + } short stringtbl__AddString(self, s) *************** *** 192,198 **** t = s; while ((t=(unsigned char *) index(t, '}'))) /* delete right brackets */ strcpy(t, t+1); ! if ((i=FindString(self, s)) >= 0) /* duplicate entry */ return self->accmap[i]; if (i == -2) return (0); /* NULL or \0 */ --- 206,212 ---- t = s; while ((t=(unsigned char *) index(t, '}'))) /* delete right brackets */ strcpy(t, t+1); ! if ((i=FindString(self, s, 0)) >= 0) /* duplicate entry */ return self->accmap[i]; if (i == -2) return (0); /* NULL or \0 */ *************** *** 219,225 **** stringtbl_Clear(self); self->ContainsInitialStrings = FALSE; } ! i = FindString(self, s); if (i < 0) /* string not found */ return; free(self->item[i]); /* free the string store */ --- 233,239 ---- stringtbl_Clear(self); self->ContainsInitialStrings = FALSE; } ! i = FindString(self, s, 0); if (i < 0) /* string not found */ return; free(self->item[i]); /* free the string store */ *************** *** 245,251 **** /* finds the named string in the table and sets its associated bit to the given val */ { ! SetIthBit(self, FindString(self, s), val); } boolean --- 259,265 ---- /* finds the named string in the table and sets its associated bit to the given val */ { ! SetIthBit(self, FindString(self, s, 0), val); } boolean *************** *** 257,263 **** { register short i; register unsigned long mask; ! i = FindString(self, s); if (i < 0) /* string not found */ return FALSE; mask = ((unsigned long)1)<WhitePattern = strtblview_WhitePattern(self); self->BlackPattern = strtblview_BlackPattern(self); + self->sizeknown = FALSE; } if ( ! self->GaveSize) strtblview_WantNewSize(self, self); *** contrib/mit/util/strinput.ch Thu May 30 20:10:38 1991 --- contrib/mit/util/strinput.ch.NEW Thu May 30 18:38:52 1991 *************** *** 0 **** --- 1,26 ---- + /* Changed June 1990 njw */ + /* A simple string input view, with a fenced prompt */ + + class strinput : view { + classprocedures: + InitializeObject(struct thisobject *self) returns boolean; + FinalizeObject(struct thisobject *self); + InitializeClass() returns boolean; + overrides: + FullUpdate(enum view_UpdateType type, long left, long top, long width, long height); + Hit(enum view_mouseAction action, long x, long y, long clicks) returns struct view *; + ReceiveInputFocus(); + LinkTree(struct view *parent); + methods: + GetInput(int length) returns char *; + SetInput(char *string); + ClearInput(); + SetPrompt(char *string); + HaveYouGotTheFocus() returns boolean; + macromethods: + IsLinked() ((self)->header.view.parent && (self)->header.view.imPtr) + data: + struct text *textobj; + struct textview *textv; + char *prompt; + }; *** atk/table/Imakefile Wed Nov 22 12:31:26 1989 --- atk/table/Imakefile.NEW Wed Apr 10 16:22:08 1991 *************** *** 2,7 **** --- 2,13 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ + #ifdef SCOunix + SYSLIBS = -lm ${SUPLIBS} ${XLIBDIR} -lX11 + #else /* SCOunix */ + SYSLIBS = -lm ${SUPLIBS} + #endif /* SCOunix */ + DOBJS = spread.do table.do IHFILES = spread.ih table.ih *************** *** 10,16 **** DynamicMultiObject(spread.do, spread.o print.o menu.o update.o hit.o keyboard.o, ${BASEDIR}/lib/atk/libbasics.a, -lm) ! DynamicMultiObject(table.do, table.o eval.o tabio.o funs.o, , -lm) InstallClassFiles($(DOBJS),$(IHFILES)) --- 16,22 ---- DynamicMultiObject(spread.do, spread.o print.o menu.o update.o hit.o keyboard.o, ${BASEDIR}/lib/atk/libbasics.a, -lm) ! DynamicMultiObject(table.do, table.o eval.o tabio.o funs.o, , ${SYSLIBS}) InstallClassFiles($(DOBJS),$(IHFILES)) *** atk/table/tabio.c Fri Dec 21 14:58:48 1990 --- atk/table/tabio.c.NEW Wed Apr 3 21:21: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/table/RCS/tabio.c,v 1.11 90/09/13 15:11:40 jhh Exp $ */ /* $ACIS:tabio.c 1.2$ */ ! /* $Source: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/table/RCS/tabio.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/table/RCS/tabio.c,v 1.11 90/09/13 15:11:40 jhh Exp $"; #endif /* lint */ /* tabio.c - input/output for table */ --- 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/table/RCS/tabio.c,v 1.12 91/03/29 00:28:29 rr2b Exp $ */ /* $ACIS:tabio.c 1.2$ */ ! /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/table/RCS/tabio.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/table/RCS/tabio.c,v 1.12 91/03/29 00:28:29 rr2b Exp $"; #endif /* lint */ /* tabio.c - input/output for table */ *************** *** 283,289 **** /* if f is NULL, we are simply scanning a line buffer with cp; buff and cl are meaningless */ /* in any case, the buffer is terminated with a null */ ! #define advance(f, buff, cp, cl) {cp++; if (*cp == '\0') refill(f, buff, &cp, cl);} /* read an input line */ --- 283,289 ---- /* if f is NULL, we are simply scanning a line buffer with cp; buff and cl are meaningless */ /* in any case, the buffer is terminated with a null */ ! #define advance(f, buff, cp, cl) {if(*cp) cp++; if (*cp == '\0') refill(f, buff, &cp, cl);} /* read an input line */ *** atk/table/table.c Fri Dec 21 14:58:50 1990 --- atk/table/table.c.NEW Fri Dec 14 16:55:04 1990 *************** *** 4,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/table/RCS/table.c,v 1.15 90/09/13 15:11:01 jhh Exp $ */ /* $ACIS:table.c 1.5$ */ ! /* $Source: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/table/RCS/table.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/table/RCS/table.c,v 1.15 90/09/13 15:11:01 jhh Exp $"; #endif /* lint */ - #include #include #include #include #include --- 4,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/table/RCS/table.c,v 1.17 90/12/06 23:31:59 gk5g Exp $ */ /* $ACIS:table.c 1.5$ */ ! /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/table/RCS/table.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/table/RCS/table.c,v 1.17 90/12/06 23:31:59 gk5g Exp $"; #endif /* lint */ #include + #include #include #include #include *************** *** 24,32 **** #ifndef _IBMR2 extern char * malloc (); - #endif /* _IBMR2 */ - extern char * realloc (); extern double atof(); --- 24,31 ---- #ifndef _IBMR2 extern char * malloc (); extern char * realloc (); + #endif /* _IBMR2 */ extern double atof(); *** atk/text/Imakefile Fri Dec 21 14:58:53 1990 --- atk/text/Imakefile.NEW Thu Jun 13 15:54:00 1991 *************** *** 16,21 **** --- 16,22 ---- fnotev.do \ bp.do \ bpv.do \ + tabs.do \ tindex.do \ texttag.do \ textref.do \ *************** *** 29,34 **** --- 30,36 ---- search.ih \ smpltext.ih \ text.ih \ + tabs.ih \ txttroff.ih \ textv.ih \ cltextv.ih \ *************** *** 50,60 **** --- 52,67 ---- readscr.o \ search.o \ smpltext.o \ + tabs.o \ tpllist.o \ text.o \ txttroff.o \ textv.o \ txtvcmds.o \ + txtvcmod.o \ + txtvcmv.o \ + txtvcmsc.o \ + txtvcsrch.o \ txtvcsty.o \ cltextv.o \ content.o \ *************** *** 78,84 **** DynamicObject(smpltext, ${UTILLIB},) DynamicMultiObject(text.do, text.o tpllist.o,,) ! DynamicMultiObject(textv.do, textv.o drawtxtv.o txtvcmds.o txtvcsty.o,,) InstallClassFiles($(DOBJS),$(IHFILES)) --- 85,91 ---- DynamicObject(smpltext, ${UTILLIB},) DynamicMultiObject(text.do, text.o tpllist.o,,) ! DynamicMultiObject(textv.do, textv.o drawtxtv.o txtvcmds.o txtvcmod.o txtvcmv.o txtvcmsc.o txtvcsrch.o txtvcsty.o ,,) InstallClassFiles($(DOBJS),$(IHFILES)) *************** *** 96,101 **** --- 103,111 ---- InstallFile(comps,$(INSTINCFLAGS),$(DESTDIR)/lib/compchar) + install.doc:: + /bin/sh -c 'if test -r txtstvc.doc; then mv -f txtstvc.doc txtstvec.doc; fi; exit 0'; + InstallFile(txtstvec.h, ${INSTINCFLAGS}, ${DESTDIR}/include/atk) DependTarget() *************** *** 142,147 **** --- 152,159 ---- InstallHelpAlias(crossrf,ez-crossreferences) InstallHelpAlias(crossrf,ez-ref) InstallHelpAlias(crossrf,ez-refs) + InstallDocs(vi.help,${DESTDIR}/help) + InstallDocs(be1be2.doc,${DESTDIR}/doc/atk/text) InstallDocs(bp.doc,${DESTDIR}/doc/atk/text) InstallDocs(bpv.doc,${DESTDIR}/doc/atk/text) *************** *** 154,159 **** --- 166,172 ---- InstallDocs(readscr.doc,${DESTDIR}/doc/atk/text) InstallDocs(search.doc,${DESTDIR}/doc/atk/text) InstallDocs(smpltext.doc,${DESTDIR}/doc/atk/text) + InstallDocs(tabs.doc,${DESTDIR}/doc/atk/text) InstallDocs(subdirs.doc,${DESTDIR}/doc/atk/text) InstallDocs(textref.doc,${DESTDIR}/doc/atk/text) InstallDocs(textrefv.doc,${DESTDIR}/doc/atk/text) *** atk/text/content.help Wed Nov 22 12:34:24 1989 --- atk/text/content.help.NEW Tue May 21 18:17:15 1991 *************** *** 1,4 **** ! \begindata{text,268823596} \textdsversion{12} \template{help} \define{footnote --- 1,4 ---- ! \begindata{text,269909760} \textdsversion{12} \template{help} \define{footnote *************** *** 94,100 **** corresponding title in the Table of Contents window. The text in the original document window scrolls to reveal that title. In this manner, you can move directly to different portions of a document without fumbling with the scroll ! bar. \bold{Closing the Table of Contents window}. To close the Table of Contents --- 94,105 ---- corresponding title in the Table of Contents window. The text in the original document window scrolls to reveal that title. In this manner, you can move directly to different portions of a document without fumbling with the scroll ! bar. Once the TOC window has the input focus, it is then possible to use the ! keyboard to traverse the contents. Each time you position the text caret on a ! new procedure name, the associated procedure in the source document is brought ! into view. For even greater viewing pleasure, see the description of the ! ContentsScrollTop preference in the section \bold{\italic{Preferences for the ! Table of Contents}} below. \bold{Closing the Table of Contents window}. To close the Table of Contents *************** *** 302,307 **** --- 307,325 ---- window. + \bold{Automatically scrolling a selected procedure to the top of the screen}. + To automatically scroll a selected procedure to the top of the screen, add + the line + + + *.ContentsScrollTop:yes + + + to your preferences file. Whenever you place the text caret on a new + procedure in the TOC window, the associated procedure in the source document + will be scrolled to the top of the window. + + }\section{Pop-up menu meanings }\leftindent{ *************** *** 395,398 **** printing preferences\ ! }}\enddata{text,268823596} --- 413,416 ---- printing preferences\ ! }}\enddata{text,269909760} *** atk/text/drawtxtv.c Fri Dec 21 14:58:57 1990 --- atk/text/drawtxtv.c.NEW Wed Apr 3 21:22: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/text/RCS/drawtxtv.c,v 2.29 90/09/20 15:56:11 gk5g Exp Locker: ajp $ */ /* $ACIS:drawtxtv.c 1.6$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/text/RCS/drawtxtv.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/text/RCS/drawtxtv.c,v 2.29 90/09/20 15:56:11 gk5g Exp Locker: ajp $"; #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/text/RCS/drawtxtv.c,v 2.37 91/04/01 13:06:00 gk5g Exp $ */ /* $ACIS:drawtxtv.c 1.6$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/text/RCS/drawtxtv.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/text/RCS/drawtxtv.c,v 2.37 91/04/01 13:06:00 gk5g Exp $"; #endif /* lint */ #include *************** *** 24,33 **** #include #include #include #include #define textview_MOVEVIEW 99999999 static struct graphic *pat; ! #define Text(self) \ ((struct text *) ((self)->header.view.dataobject)) --- 24,34 ---- #include #include #include + #include #include #define textview_MOVEVIEW 99999999 static struct graphic *pat; ! #define FGC 1 #define Text(self) \ ((struct text *) ((self)->header.view.dataobject)) *************** *** 39,46 **** #define TABBASE ((int) 'n') /* the max number of pixels a char can overhang its bounding box */ #define MAXOVERHANG 4 ! #define MIN(a, b) \ ! (((a) < (b)) ? (a) : (b)) static long StringWidth(widths, s) register short *widths; --- 40,48 ---- #define TABBASE ((int) 'n') /* the max number of pixels a char can overhang its bounding box */ #define MAXOVERHANG 4 ! #ifndef MIN ! #define MIN(a, b) (((a) < (b)) ? (a) : (b)) ! #endif /* MIN */ static long StringWidth(widths, s) register short *widths; *************** *** 65,70 **** --- 67,110 ---- *s = '\0'; } + static long GetNextTabPosition(v, width, sv, info) + struct textview *v; + int width; + struct text_statevector *sv; + struct formattinginfo *info; + { + int tabWidth = 8* (v->tabWidth); + if (sv->SpecialFlags & style_TabsCharacters) + return ((width + tabWidth)/tabWidth) * tabWidth; + else { + long lm = (sv->CurLeftMargin * v->ScreenScaleMul + v->ScreenScaleDiv / 2) / v->ScreenScaleDiv; + + if (width < lm) { + return lm; + } + else { + long t; + int i; + int m = v->ScreenScaleMul; + long nwidth = width * v->ScreenScaleDiv; + long marginwidth = v->ScreenScaleDiv * info->bLM; + + if (sv->tabs->Positions) { + for(i = 0; i < sv->tabs->number; i++) { + if ((t = (marginwidth + m * sv->tabs->Positions[i])) > nwidth) { + return (t + v->ScreenScaleDiv / 2) / v->ScreenScaleDiv; + } + } + } + } + } + /* No more tabs defined - hence should *not* perform tab */ + /* Will change tab into the width of a space */ + + return width + info->myWidths[(int) ' ']; + + } + static long ParagraphIndent(self, text, pos, info) struct textview *self; struct text *text; *************** *** 73,97 **** { struct environment *myEnv; struct text_statevector mysv; ! int tabWidth, spaceWidth; register int width = 0; register int c; struct fontdesc *font; short *widthTable; ! while (--pos >= 0 && text_GetChar(text, pos) != '\n') ! ; ! pos++; myEnv = textview_GetStyleInformation(self, &mysv, pos, NULL); font = fontdesc_Create(mysv.CurFontFamily, ! mysv.CurFontAttributes, mysv.CurFontSize); widthTable = fontdesc_WidthTable(font, textview_GetDrawable(self)); spaceWidth = widthTable[(int) ' ']; - tabWidth = 8 * self->tabWidth; while ((c = text_GetChar(text, pos)) == ' ' || c == '\t') { pos++; --- 113,134 ---- { struct environment *myEnv; struct text_statevector mysv; ! int spaceWidth; register int width = 0; register int c; struct fontdesc *font; short *widthTable; ! pos = text_GetBeginningOfLine(text, pos); myEnv = textview_GetStyleInformation(self, &mysv, pos, NULL); font = fontdesc_Create(mysv.CurFontFamily, ! mysv.CurFontAttributes, mysv.CurFontSize); widthTable = fontdesc_WidthTable(font, textview_GetDrawable(self)); spaceWidth = widthTable[(int) ' ']; while ((c = text_GetChar(text, pos)) == ' ' || c == '\t') { pos++; *************** *** 98,104 **** if (c == ' ') width += spaceWidth; else ! width = ((width + tabWidth) / tabWidth) * tabWidth; } textview_ReleaseStyleInformation(self, myEnv); --- 135,141 ---- if (c == ' ') width += spaceWidth; else ! width = GetNextTabPosition(self, width, &mysv, info); } textview_ReleaseStyleInformation(self, myEnv); *************** *** 106,122 **** return width; } ! static long MovePast(self, width, widths, bump, string) struct textview *self; register long width; register short *widths; ! register long bump; register unsigned char *string; { - int tabWidth; register unsigned char tc; ! ! tabWidth = 8 * self->tabWidth; while (1) { if ((tc = *string++) == '\0') --- 143,157 ---- return width; } ! static long MovePast(self, width, widths, info, string) struct textview *self; register long width; register short *widths; ! struct formattinginfo *info; register unsigned char *string; { register unsigned char tc; ! register long bump = info->spaceBump; while (1) { if ((tc = *string++) == '\0') *************** *** 124,132 **** if (tc == ' ') width += bump; if (tc == '\t') ! width = ((width + tabWidth) / tabWidth) * tabWidth; else ! width += widths[tc]; } } --- 159,167 ---- if (tc == ' ') width += bump; if (tc == '\t') ! width = GetNextTabPosition(self, width, &info->sv, info); else ! width += widths[(int) tc]; } } *************** *** 163,173 **** } if (tc == ' ') startX += spaceShim; ! if (tc == '\t') { ! int tabWidth = 8 * self->tabWidth; ! startX = (((startX - bx) + tabWidth) / tabWidth) ! * tabWidth + bx; ! } else startX += widths[tc]; startPos++; } --- 198,206 ---- } if (tc == ' ') startX += spaceShim; ! if (tc == '\t') ! startX = GetNextTabPosition(self, startX - bx, &info->sv, info) + bx; ! else startX += widths[tc]; startPos++; } *************** *** 202,212 **** tc = (unsigned char) info->lineBuffer[linePos++]; if (tc == ' ') endX += spaceShim; ! if (tc == '\t') { ! int tabWidth = 8 * self->tabWidth; ! endX = (((endX - bx) + tabWidth) / tabWidth) * ! tabWidth + bx; ! } else endX += widths[tc]; /* Now we have the start (startX) and end (endX) of char */ --- 235,243 ---- tc = (unsigned char) info->lineBuffer[linePos++]; if (tc == ' ') endX += spaceShim; ! if (tc == '\t') ! endX = GetNextTabPosition(self, endX-bx, &info->sv, info) + bx; ! else endX += widths[tc]; /* Now we have the start (startX) and end (endX) of char */ *************** *** 276,281 **** --- 307,313 ---- textview_GetDrawable(self)); tlp->ti_styleFlags = tsv->SpecialFlags; tlp->ti_hasTab = 0; + tlp->ti_color = tsv->CurColor; } else { register struct view *view = tsv->CurView; long desw, desh; *************** *** 288,295 **** view_DesiredSize(view, info->xDim - info->totalWidth, 16384, view_NoSet, &desw, &desh); ! tlp->vi_width = (info->xDim - info->totalWidth < desw) ? ! info->xDim - info->totalWidth : desw; tlp->vi_height = desh; if (tlp->vi_height > info->lineBelow) { --- 320,326 ---- view_DesiredSize(view, info->xDim - info->totalWidth, 16384, view_NoSet, &desw, &desh); ! tlp->vi_width = (desw > info->xDim) ? info->xDim: desw; tlp->vi_height = desh; if (tlp->vi_height > info->lineBelow) { *************** *** 467,472 **** --- 498,504 ---- textview_ReleaseStyleInformation(self, startEnv); } + /* Note: When trying to speed up redisplay, GenerateLineItems is a */ /* very important place to begin. */ *************** *** 485,491 **** struct environment *myEnv; long lastEnvPos = 0; register unsigned char *tp, tc; ! long nChars, pos, bufEnd, tabWidth; long pi; /* Value from ParagraphIndent */ long i, localWidth, initPos, localRubber; int lastWidth = 0; /* Width just before the last rubber space */ --- 517,523 ---- struct environment *myEnv; long lastEnvPos = 0; register unsigned char *tp, tc; ! long nChars, pos, bufEnd; long pi; /* Value from ParagraphIndent */ long i, localWidth, initPos, localRubber; int lastWidth = 0; /* Width just before the last rubber space */ *************** *** 497,502 **** --- 529,535 ---- boolean FoundmarkPos = FALSE, FounddotPos = FALSE, oncePerLine; long bufLen; unsigned char *buf = NULL; + char *color = NULL; if (self->predrawn && mark_GetLength(self->predrawn) > 0 && mark_GetPos(self->predrawn) == mark_GetPos(currentLine)) *************** *** 518,532 **** while (1) { int envStart = pos, envLength; /* Remember beginning pos */ struct text_statevector *tsv = &info->sv; if (info->lineIP == NTITEMS) { /* Trouble: out of line items. Just wrap before EOL */ ! info->endOfPara = FALSE; return; } myEnv = textview_GetStyleInformation(self, tsv, pos, &nChars); envLength = environment_GetLength(myEnv); /* The hidden flag handling probably does not work. */ --- 551,568 ---- while (1) { int envStart = pos, envLength; /* Remember beginning pos */ struct text_statevector *tsv = &info->sv; + long lastLineSpacing; if (info->lineIP == NTITEMS) { /* Trouble: out of line items. Just wrap before EOL */ ! info->endOfPara = FALSE; ! info->below = info->lineBelow; return; } myEnv = textview_GetStyleInformation(self, tsv, pos, &nChars); + color = tsv->CurColor; envLength = environment_GetLength(myEnv); /* The hidden flag handling probably does not work. */ *************** *** 586,600 **** pi = ParagraphIndent(self, text, pos, info); else pi = 0; ! info->bIndent=tsv->CurIndentation; ! info->bLM=tsv->CurLeftMargin + pi; info->just = tsv->CurJustification; ! info->xDim = info->xDim - tsv->CurLeftMargin - ! tsv->CurRightMargin - pi; ! if (info->pBreak) ! info->xDim = info->xDim - tsv->CurIndentation; lastEnvPos = -1; oncePerLine = 0; } info->myWidths = fontdesc_WidthTable(tsv->CurCachedFont, --- 622,639 ---- pi = ParagraphIndent(self, text, pos, info); else pi = 0; ! if (info->pBreak) { ! info->bIndent=(tsv->CurIndentation)*self->ScreenScaleMul / self->ScreenScaleDiv; ! } ! else { ! info->bIndent = 0; ! } ! info->bLM=(tsv->CurLeftMargin + pi) * self->ScreenScaleMul / self->ScreenScaleDiv; info->just = tsv->CurJustification; ! info->xDim = info->xDim - info->bLM - info->bIndent - tsv->CurRightMargin; lastEnvPos = -1; oncePerLine = 0; + lastLineSpacing = tsv->CurSpacing; } info->myWidths = fontdesc_WidthTable(tsv->CurCachedFont, *************** *** 615,620 **** --- 654,660 ---- if (info->totalWidth + width > info->xDim) { info->endOfPara = FALSE; /* Wrapped the line */ info->lineBP = oldLineBP; + info->below = info->lineBelow + lastLineSpacing; return; /* That's it for now */ } *************** *** 631,636 **** --- 671,677 ---- tlp->ti_fontWidths = info->myWidths; tlp->ti_styleFlags = tsv->SpecialFlags; tlp->ti_hasTab = 0; + tlp->ti_color = color; /* lineBP advanced in ComputeStyleItem */ *************** *** 643,650 **** /* Always go once around. */ if (passes > 0) { ! if (pos >= bufEnd) ! return; } else passes = 1; --- 684,693 ---- /* Always go once around. */ if (passes > 0) { ! if (pos >= bufEnd) { ! info->below = info->lineBelow; ! return; ! } } else passes = 1; *************** *** 664,833 **** FounddotPos = FALSE; } ! if (info->clp->type == li_View) { ! info->totalWidth += info->clp->vi_width; ! if (info->xDim < info->totalWidth) { ! info->totalWidth -= info->clp->vi_width; ! info->lineIP--; /* We'll start again on the next line */ ! info->endOfPara = FALSE; /* Wrapped the line */ ! return; ! } ! info->lineLength += nChars; ! pos += nChars; ! } else { ! /* Process all of the characters into line items */ ! ! localWidth = info->totalWidth; ! localRubber = 0; ! tp = &(info->lineBuffer[info->lineBP]); ! ! bufLen = 0; /* Refresh GetBuf since pos may have changed */ ! ! for (i = 0; ; i++) { ! if (info->xDim < localWidth) { ! int noWrap = tsv->SpecialFlags & style_NoWrap; ! /* Wrap line */ ! ! info->endOfPara = FALSE; ! if (noWrap || (localRubber <= 0 && ! info->rubberSpaces <= 0)) { ! /* Here on word too long to fit on line; */ ! /* should really push last char to next line */ ! ! if (noWrap) { ! /* No wrapping, skip to end of line (so it */ ! /* never gets displayed), or the end of the env. */ ! int end = envStart + envLength; ! ! info->endOfPara = TRUE; ! do { ! if (pos >= bufEnd) ! break; ! if (pos >= end) { ! info->endOfPara = FALSE; ! break; ! } ! if (bufLen == 0) /* filbuf */ ! buf = (unsigned char *) text_GetBuf(Text(self), ! pos, 1024, &bufLen); ! tc = *buf++, bufLen--, pos++; ! } while (tc != '\n'); ! } ! *tp++ = 0; ! info->lineBP = (int)(tp - info->lineBuffer); ! info->totalWidth = localWidth; ! info->lineLength = pos - initPos; ! /* No rubber spaces, otherwise we'd wrap the line there */ info->clp->ti_rSpaces = 0; ! return; ! } ! if (lastBP == 0) { /* Is this necessary? */ ! info->lineIP--; ! info->endOfPara = FALSE; ! info->lineLength = info->clp->docPos - initPos; ! return; ! } ! info->totalWidth = lastWidth; ! /* How far we've gone, less the last word */ ! info->markLength = pos - initPos; ! info->lineLength = lastPos - initPos; ! info->lineIP = lastIP; ! *lastBP++ = NULL; ! info->lineBP = (int)(lastBP - info->lineBuffer); ! localRubber--; /* Include deleted one */ ! info->rubberSpaces += localRubber; info->clp->ti_rSpaces = localRubber; ! return; ! } ! if (i >= nChars) ! break; /* are we done yet? */ ! if (bufLen == 0) /* filbuf */ ! buf = (unsigned char *) text_GetBuf(Text(self), pos, 1024, &bufLen); ! tc = *buf++, bufLen--, pos++; ! ! if (tc == ' ') { ! localRubber++; ! lastWidth = localWidth; ! lastBP = tp; /* Points at the space! */ ! lastPos = pos - 1; ! lastIP = info->lineIP; ! *tp++ = tc; ! localWidth += info->myWidths[(int) tc]; ! } else if (tc == '\n') { ! *tp++ = '\0'; ! info->lineBP = (int)(tp - info->lineBuffer); ! info->totalWidth = localWidth; ! info->lineLength = pos - initPos; ! info->markLength = info->lineLength; ! info->rubberSpaces += localRubber; ! info->clp->ti_rSpaces = localRubber; ! if (FoundmarkPos) ! info->predrawnEnd = info->totalWidth; ! return; ! } else if (tc == '\t') { ! *tp++ = tc; ! tabWidth = 8 * self->tabWidth; ! localWidth += info->bIndent + info->bLM; ! localWidth = ((localWidth + tabWidth) / ! tabWidth) * tabWidth; ! localWidth -= info->bIndent + info->bLM; ! info->sawTab = TRUE; ! info->clp->ti_hasTab = 1; ! /* Tabs end processing of a line item */ break; ! } else if (info->myWidths[(int) tc] == 0 || ! ! fontdesc_CharValid(tsv->CurCachedFont, tc)) { ! if (i == 0) { ! long width; ! /* Gets its own lineitem. It's not very */ ! /* efficient when there is a whole screenful */ ! /* of octal codes in a row. */ ! CharToOctal(tp, tc); ! width = StringWidth(info->myWidths, tp); ! if (info->totalWidth + width > info->xDim) { ! info->endOfPara = FALSE; /* Wrapped line */ ! info->lineIP--; /* Retract this item */ ! return; ! } ! /* AllocateLineItem has set most item params */ ! info->lineItems[info->lineIP - 1].type = li_Octal; ! tp += 5; ! localWidth += width; ! break; ! } ! /* Unprintable char ends processing of line item; */ ! /* Back up one. Octal will be placed in its own line */ ! /* item next time around outer loop. */ ! pos--; ! break; ! } else { /* Plain char */ ! *tp++ = tc; ! localWidth += info->myWidths[tc]; ! } ! /* End of handling of the character */ ! } ! info->rubberSpaces += localRubber; info->clp->ti_rSpaces = localRubber; ! info->lineLength = pos - initPos; ! info->totalWidth = localWidth; ! *tp++ = 0; ! info->lineBP = (int)(tp - info->lineBuffer); ! } if (FoundmarkPos) { info->predrawnEnd = info->totalWidth; FoundmarkPos = FALSE; } } } --- 707,887 ---- FounddotPos = FALSE; } ! /* Process all of the characters into line items */ ! localWidth = info->totalWidth; ! localRubber = 0; ! tp = &(info->lineBuffer[info->lineBP]); ! ! bufLen = 0; /* Refresh GetBuf since pos may have changed */ ! ! for (i = 0; ; i++) { ! if (info->xDim < localWidth) { ! int noWrap = tsv->SpecialFlags & style_NoWrap; ! /* Wrap line */ ! ! info->endOfPara = FALSE; ! ! if (noWrap || (localRubber <= 0 && ! info->rubberSpaces <= 0)) { ! /* Here on word too long to fit on line; */ ! /* should really push last char to next line */ ! ! if (noWrap) { ! /* No wrapping, skip to end of line (so it */ ! /* never gets displayed), or the end of the env. */ ! int end = envStart + envLength; ! int count = 0; ! ! info->endOfPara = TRUE; ! do { ! if (pos >= bufEnd) ! break; ! if (pos >= end) { ! info->endOfPara = FALSE; ! break; ! } ! if (bufLen == 0) /* filbuf */ ! buf = (unsigned char *) text_GetBuf(Text(self), pos, 1024, &bufLen); ! tc = *buf++, bufLen--, pos++; ! if(tc != ' ') count++; ! } while (tc != '\n' && tc != '\r'); ! ! /* only put up continued mark ! if real characters remain */ ! if (count > 1) ! info->continued = TRUE; ! } ! *tp++ = 0; ! info->lineBP = (int)(tp - info->lineBuffer); ! info->totalWidth = localWidth; ! info->lineLength = pos - initPos; ! /* No rubber spaces, otherwise we'd wrap the line there */ ! if (info->clp->type != li_View) info->clp->ti_rSpaces = 0; ! info->below = info->lineBelow + tsv->CurSpacing; ! return; ! } ! if (lastBP == 0) { /* Is this necessary? */ ! info->lineIP--; ! info->endOfPara = FALSE; ! info->lineLength = info->clp->docPos - initPos; ! info->below = info->lineBelow + lastLineSpacing; ! return; ! } ! info->totalWidth = lastWidth; ! /* How far we've gone, less the last word */ ! info->markLength = pos - initPos; ! info->lineLength = lastPos - initPos; ! info->lineIP = lastIP; ! *lastBP++ = NULL; ! info->lineBP = (int)(lastBP - info->lineBuffer); ! localRubber--; /* Include deleted one */ ! info->rubberSpaces += localRubber; ! if (info->clp->type != li_View) info->clp->ti_rSpaces = localRubber; ! info->below = info->lineBelow + lastLineSpacing; ! return; ! } ! if (i >= nChars) ! break; /* are we done yet? */ ! if (bufLen == 0) /* filbuf */ ! buf = (unsigned char *) text_GetBuf(Text(self), pos, 1024, &bufLen); ! tc = *buf++, bufLen--, pos++; ! ! if (info->clp->type == li_View) { ! localWidth += info->clp->vi_width; ! } else if (tc == ' ') { ! localRubber++; ! lastWidth = localWidth; ! lastBP = tp; /* Points at the space! */ ! lastPos = pos - 1; ! lastIP = info->lineIP; ! *tp++ = tc; ! localWidth += info->myWidths[(int) tc]; ! } else if (tc == '\n' || tc == '\r') { ! *tp++ = '\0'; ! info->lineBP = (int)(tp - info->lineBuffer); ! info->totalWidth = localWidth; ! info->lineLength = pos - initPos; ! info->markLength = info->lineLength; ! info->rubberSpaces += localRubber; ! info->clp->ti_rSpaces = localRubber; ! if (FoundmarkPos) ! info->predrawnEnd = info->totalWidth; ! if (tc == '\r') { ! info->endOfPara = FALSE; ! info->below = info->lineBelow + tsv->CurSpacing; ! } ! else { ! info->below = info->lineBelow + ((tsv->CurSpacing > tsv->CurSpread) ? tsv->CurSpacing : tsv->CurSpread); ! } ! return; ! } else if (tc == '\t') { ! *tp++ = tc; ! localWidth += (info->bLM + info->bIndent); ! localWidth = GetNextTabPosition(self, localWidth, tsv, info); ! localWidth -= (info->bLM + info->bIndent); ! info->sawTab = TRUE; ! info->clp->ti_hasTab = 1; ! /* Tabs end processing of a line item */ ! break; ! } else if (info->myWidths[(int) tc] == 0 || ! ! fontdesc_CharValid(tsv->CurCachedFont, tc)) { ! if (i == 0) { ! long width; ! /* Gets its own lineitem. It's not very */ ! /* efficient when there is a whole screenful */ ! /* of octal codes in a row. */ ! CharToOctal(tp, tc); ! width = StringWidth(info->myWidths, tp); ! if (info->totalWidth + width > info->xDim) { ! info->endOfPara = FALSE; /* Wrapped line */ ! info->lineIP--; /* Retract this item */ ! info->below = info->lineBelow + lastLineSpacing; ! return; ! } ! /* AllocateLineItem has set most item params */ ! info->lineItems[info->lineIP - 1].type = li_Octal; ! tp += 5; ! localWidth += width; break; ! } ! /* Unprintable char ends processing of line item; */ ! /* Back up one. Octal will be placed in its own line */ ! /* item next time around outer loop. */ ! pos--; ! break; ! } else { /* Plain char */ ! *tp++ = tc; ! localWidth += info->myWidths[tc]; ! } ! /* End of handling of the character */ ! } ! info->rubberSpaces += localRubber; ! if (info->clp->type != li_View) { info->clp->ti_rSpaces = localRubber; ! } ! info->lineLength = pos - initPos; ! info->totalWidth = localWidth; ! *tp++ = 0; ! info->lineBP = (int)(tp - info->lineBuffer); if (FoundmarkPos) { info->predrawnEnd = info->totalWidth; FoundmarkPos = FALSE; } + + lastLineSpacing = tsv->CurSpacing; } } *************** *** 888,893 **** --- 942,977 ---- textview_DrawString(self, xbuf, graphic_ATBASELINE); } + static void drawcontinued(self,info,by) + struct textview *self; + register struct formattinginfo *info; + long by; + { /* draw a pointer at the end of the line + to indicate that unwrapped text is + beyond the end of the page */ + struct rectangle clearRect; + struct point pt[3]; + long x,ht,twid,sx ; + twid = (self->hasApplicationLayer) ? self->bx : self->ebx; + if(twid < 2) return; + x = textview_GetLogicalWidth(self) ; + by += info->textBelow; + ht = info->lineAbove + info->textBelow; + sx = x - 15; + rectangle_SetRectSize(&clearRect,sx, by - ht,15,ht); + by += -6; ht += -6; + /* height of the pointer is dependent on the height of the text */ + /* width of the pointer is fixed */ + pt[0].x= sx; pt[0].y = by; + pt[1].x = sx + 10 ; pt[1].y = by - (ht / 2); + pt[2].x = sx; pt[2].y = by - ht; + textview_SetTransferMode(self, graphic_COPY); + textview_FillRect(self, &clearRect, textview_WhitePattern(self)); + textview_FillPolygon(self,pt, 3,textview_GrayPattern(self,12,16)); + textview_SetTransferMode(self, graphic_BLACK); + textview_DrawPolygon(self,pt, 3); + } + long textview__LineRedraw(self, type, currentLine, x, y, xSize, ySize, search, cont, txheight, info) struct textview *self; enum textview_LineRedrawType type; *************** *** 907,912 **** --- 991,1007 ---- struct fontdesc *fontID = textview_GetFont(self); register int i, j = 0; register struct lineitem *tt, *tlp; + int leftmost, leftmostchar; + int currentBump; + char *color = NULL; + char *rcolor = NULL; + #ifdef FGC + long c1, c2, c3; + #else + double c1,c2,c3; + #endif + char cbuf[64]; + boolean colordefined = FALSE; int SkipPredrawn; int initialIndent; *************** *** 919,924 **** --- 1014,1020 ---- info->lineBelow = 0; info->textBelow = 0; info->lineAbove = 0; + info->continued = FALSE; info->foundView = NULL; zapMe = -1; info->cursorY = y; *************** *** 954,960 **** /* Advance the marker over any blanks absorbed by a line-wrap */ ! if (! info->endOfPara) { long endPos; for (endPos = info->lineLength + pos; --- 1050,1056 ---- /* Advance the marker over any blanks absorbed by a line-wrap */ ! if (! info->endOfPara && text_GetChar(text, info->lineLength + pos - 1) != '\r') { long endPos; for (endPos = info->lineLength + pos; *************** *** 990,995 **** --- 1086,1140 ---- } } + /* Taking care of tabs... */ + /* We really are going to justify this line... BUT */ + /* We want to remove all rubber spaces to the left of the tab */ + /* Coz you don't justify left of a tab */ + /* So if all of the conditions for justification are satisfied */ + /* Scan backwards through the line items, until we hit a tab */ + /* Continue scanning backwards, but from then on, 'unmark' all */ + /* of the rubber spaces. -njw */ + leftmost = 0; + leftmostchar = 0; + if (info->sawTab && info->just == style_LeftAndRightJustified && info->rubberSpaces > 0 && !info->endOfPara) { + /* burning has three states: + * 0 = not burning + * 1 = burning as soon as tab seen + * >1 = burning unconditionally + */ + register int burning = 0; /* Whether or not we are burning rubber */ + + i = info->lineBP - 2; /* Before nul at end of last item */ + for (lli = info->lineIP - 1; lli >= 0; lli--) { + tlp = &(info->lineItems[lli]); + if (tlp->type == li_View) continue; /* don't touch rSpaces unless it exists */ + if (tlp->ti_hasTab) + burning++; /* Pick up the heat */ + if (burning) { + j = tlp->ti_lineBufPos; /* The start pos for this item */ + /* Scan through the characters in the line item... */ + while (i >= j) { + if(info->lineBuffer[i] == '\t') { + if (burning == 1) { + /* This is the rightmost tab! */ + /* We mark where justifying activates */ + leftmost = lli; + leftmostchar = i; + } + burning++; + } else if (info->lineBuffer[i] == ' ' && burning > 1) { + tlp->ti_rSpaces--; /* one less rubber space */ + info->rubberSpaces--; + } + i--; + } + } + } + } + /* The computations for delta and spaceBump are unchanged w.r.t tabs */ + /* the line length has not changed, after all... Only the number of */ + /* rubberSpaces to bump has decreased */ + /* Now all of the rubber spaces at the start and end of */ /* the line are gone. Next compute the amount of space */ /* per rubber space that has to be inserted. Delta is the left */ *************** *** 998,1004 **** if (info->just == style_LeftAndRightJustified && info->rubberSpaces > 0) { ! if (info->endOfPara) { info->spaceBump = 0; delta = 0; } else { --- 1143,1149 ---- if (info->just == style_LeftAndRightJustified && info->rubberSpaces > 0) { ! if (info->endOfPara || text_GetChar(text, info->lineLength + pos - 1) == '\r') { info->spaceBump = 0; delta = 0; } else { *************** *** 1013,1023 **** delta = 0; } - if (info->sawTab) { - info->spaceBump = 0; - delta = 0; - } - /* If delta is non-zero, it is how much space to jam in */ /* after seeing (rubberspaces - delta) rubberspaces. Find */ /* the lineitem containing this space, and set zapPos to point */ --- 1158,1163 ---- *************** *** 1027,1039 **** if (delta != 0) { foundSpaces = info->rubberSpaces - delta; ! for (i = 0; i < info->lineIP; i++) { tlp = &info->lineItems[i]; if (tlp->type == li_Plain) { if (tlp->ti_rSpaces > foundSpaces) { /* Found the guy to hit */ zapMe = i; ! j = tlp->ti_lineBufPos; k = foundSpaces; /* Skip k spaces */ while (1) { if (info->lineBuffer[j] == ' ') { --- 1167,1182 ---- if (delta != 0) { foundSpaces = info->rubberSpaces - delta; ! for (i = leftmost; i < info->lineIP; i++) { tlp = &info->lineItems[i]; if (tlp->type == li_Plain) { if (tlp->ti_rSpaces > foundSpaces) { /* Found the guy to hit */ zapMe = i; ! if (info->sawTab) /* Only look right of the tabs */ ! j = (leftmostchar > tlp->ti_lineBufPos) ? leftmostchar : tlp->ti_lineBufPos; ! else ! j = tlp->ti_lineBufPos; k = foundSpaces; /* Skip k spaces */ while (1) { if (info->lineBuffer[j] == ' ') { *************** *** 1057,1065 **** } } ! /* Next draw all of the lineitems. Set initial space shim. */ ! ! textview_SetSpaceShim(self, info->spaceBump); i = 0; --- 1200,1206 ---- } } ! /* Next draw all of the lineitems */ i = 0; *************** *** 1073,1082 **** if (info->just == style_LeftAndRightJustified || info->just == style_LeftJustified) { ! if (info->pBreak) ! j = info->bIndent + info->bLM; ! else ! j = info->bLM; } else if (info->just == style_Centered) j = info->bLM + (info->xDim-info->totalWidth) / 2; else if (info->just == style_RightJustified) --- 1214,1220 ---- if (info->just == style_LeftAndRightJustified || info->just == style_LeftJustified) { ! j = info->bIndent + info->bLM; } else if (info->just == style_Centered) j = info->bLM + (info->xDim-info->totalWidth) / 2; else if (info->just == style_RightJustified) *************** *** 1119,1127 **** rectangle_SetRectSize(&clearRect, SkipPredrawn, info->cursorY, textview_GetLogicalWidth(self)- SkipPredrawn, ! MIN(ySize, info->lineAbove + info->lineBelow)); pat = textview_WhitePattern(self); textview_FillRect(self, &clearRect, pat); isBlack = FALSE; } --- 1257,1269 ---- rectangle_SetRectSize(&clearRect, SkipPredrawn, info->cursorY, textview_GetLogicalWidth(self)- SkipPredrawn, ! MIN(ySize, info->lineAbove + info->below)); pat = textview_WhitePattern(self); textview_FillRect(self, &clearRect, pat); + if (SkipPredrawn != 0 && info->endOfPara && info->lineBelow != info->below) { + rectangle_SetRectSize(&clearRect, 0, info->cursorY + info->lineAbove + info->lineBelow, SkipPredrawn, info->below - info->lineBelow); + textview_FillRect(self, &clearRect, pat); + } isBlack = FALSE; } *************** *** 1132,1137 **** --- 1274,1286 ---- while (i < info->lineIP) { /* Print each line item */ tt = &info->lineItems[i]; + if (info->sawTab && i <= leftmost) { + textview_SetSpaceShim(self, 0); /* No justification left of tab */ + currentBump =0; + } else { + textview_SetSpaceShim(self, info->spaceBump); + currentBump = info->spaceBump; + } bx = j + tt->xPos; sPtr = &info->lineBuffer[tt->ti_lineBufPos]; /* by = Superscript + y coord + line "above" */ *************** *** 1169,1174 **** --- 1318,1356 ---- info->locateX = bx + tt->vi_width; } } else { /* Textual item */ + if(color != tt->ti_color){ + if(!colordefined){ + /* first time we need color, find out the current one */ + colordefined = TRUE; + #ifdef FGC + textview_GetForegroundColor(self,&rcolor,&c1,&c2,&c3); + if(rcolor != NULL){ + if (strcmp(tt->ti_color,rcolor) == 0) + /* foreground already set*/ + color = tt->ti_color; + strncpy(cbuf,rcolor,64); + cbuf[63] = '\0'; + rcolor = cbuf; + } + #else + textview_GetFGColor(self,&c1,&c2,&c3); + #endif + } + if(color != tt->ti_color){ + color = tt->ti_color; + if(color == NULL){ + /* go back to the original color */ + #ifdef FGC + textview_SetForegroundColor(self,rcolor,c1,c2,c3); + #else + textview_SetFGColor(self,c1,c2,c3); + #endif + } + else { + textview_SetForegroundColor(self,color,NULL,NULL,NULL); + } + } + } if (tt->ti_font != fontID) { fontID = tt->ti_font; textview_SetFont(self, fontID); *************** *** 1196,1202 **** style_OverBar)) { DrawBar(self, tt, bx, by, StringWidth(tt->ti_fontWidths, sPtr) + ! tt->ti_rSpaces * info->spaceBump); } } } --- 1378,1384 ---- style_OverBar)) { DrawBar(self, tt, bx, by, StringWidth(tt->ti_fontWidths, sPtr) + ! tt->ti_rSpaces * currentBump); } } } *************** *** 1203,1209 **** } else if (type == textview_GetPosition) { /* Looking for a cursor hit */ if (tt->type == li_Plain) ! LocateHit(self, bx, info->spaceBump, tt->docPos, tt->ti_fontWidths, tt->ti_lineBufPos, search, info); else if (tt->type == li_Octal) { --- 1385,1391 ---- } else if (type == textview_GetPosition) { /* Looking for a cursor hit */ if (tt->type == li_Plain) ! LocateHit(self, bx, currentBump, tt->docPos, tt->ti_fontWidths, tt->ti_lineBufPos, search, info); else if (tt->type == li_Octal) { *************** *** 1215,1221 **** /* li_Expose are ignored */ } else { /* textview_GetCoordinate */ if (tt->type == li_Plain) ! LocateCursor(self, bx, info->spaceBump, tt->docPos, tt->ti_fontWidths, tt->ti_lineBufPos, search, info); else if (tt->type == li_Expose || --- 1397,1403 ---- /* li_Expose are ignored */ } else { /* textview_GetCoordinate */ if (tt->type == li_Plain) ! LocateCursor(self, bx, currentBump, tt->docPos, tt->ti_fontWidths, tt->ti_lineBufPos, search, info); else if (tt->type == li_Expose || *************** *** 1228,1246 **** StringWidth(tt->ti_fontWidths, sPtr); } } ! j += tt->ti_rSpaces * info->spaceBump; } else { /* i == zapMe */ if (type == textview_GetPosition) { /* Looking for document pos */ info->lineBuffer[zapPos] = '\0'; ! LocateHit(self, bx, info->spaceBump, tt->docPos, tt->ti_fontWidths, tt->ti_lineBufPos, search, info); bx = MovePast(self, bx, tt->ti_fontWidths, ! info->spaceBump, sPtr); info->spaceBump++; info->lineBuffer[zapPos] = ' '; ! LocateHit(self, bx, info->spaceBump, tt->docPos + zapPos - tt->ti_lineBufPos, tt->ti_fontWidths, zapPos, search, info); } else if (type == textview_GetCoordinate || --- 1410,1429 ---- StringWidth(tt->ti_fontWidths, sPtr); } } ! j += tt->ti_rSpaces * currentBump; } else { /* i == zapMe */ if (type == textview_GetPosition) { /* Looking for document pos */ info->lineBuffer[zapPos] = '\0'; ! LocateHit(self, bx, currentBump, tt->docPos, tt->ti_fontWidths, tt->ti_lineBufPos, search, info); bx = MovePast(self, bx, tt->ti_fontWidths, ! info, sPtr); info->spaceBump++; + currentBump++; info->lineBuffer[zapPos] = ' '; ! LocateHit(self, bx, currentBump, tt->docPos + zapPos - tt->ti_lineBufPos, tt->ti_fontWidths, zapPos, search, info); } else if (type == textview_GetCoordinate || *************** *** 1247,1260 **** type == textview_GetHeight) { /* Looking for a hit */ info->lineBuffer[zapPos] = '\0'; ! LocateCursor(self, bx, info->spaceBump, tt->docPos, tt->ti_fontWidths, tt->ti_lineBufPos, search, info); bx = MovePast(self, bx, tt->ti_fontWidths, ! info->spaceBump, sPtr); info->spaceBump++; info->lineBuffer[zapPos] = ' '; ! LocateCursor(self, bx, info->spaceBump, tt->docPos + zapPos - tt->ti_lineBufPos, tt->ti_fontWidths, zapPos, search, info); } else { --- 1430,1444 ---- type == textview_GetHeight) { /* Looking for a hit */ info->lineBuffer[zapPos] = '\0'; ! LocateCursor(self, bx, currentBump, tt->docPos, tt->ti_fontWidths, tt->ti_lineBufPos, search, info); bx = MovePast(self, bx, tt->ti_fontWidths, ! info, sPtr); info->spaceBump++; + currentBump++; info->lineBuffer[zapPos] = ' '; ! LocateCursor(self, bx, currentBump, tt->docPos + zapPos - tt->ti_lineBufPos, tt->ti_fontWidths, zapPos, search, info); } else { *************** *** 1265,1271 **** (style_Underline | style_ChangeBar | style_OverBar)) DrawBar(self, tt, bx, by, StringWidth(tt->ti_fontWidths, sPtr) + ! tt->ti_rSpaces * (info->spaceBump + 1) - foundSpaces); info->lineBuffer[zapPos] = '\0'; if (info->lineAbove + info->textBelow <= ySize) { --- 1449,1455 ---- (style_Underline | style_ChangeBar | style_OverBar)) DrawBar(self, tt, bx, by, StringWidth(tt->ti_fontWidths, sPtr) + ! tt->ti_rSpaces * (currentBump + 1) - foundSpaces); info->lineBuffer[zapPos] = '\0'; if (info->lineAbove + info->textBelow <= ySize) { *************** *** 1277,1284 **** sPtr, graphic_ATBASELINE); } bx = MovePast(self, bx, tt->ti_fontWidths, ! info->spaceBump, sPtr); textview_SetSpaceShim(self, ++info->spaceBump); info->lineBuffer[zapPos] = ' '; /* Put ' ' back */ if (info->lineAbove + info->textBelow <= ySize) { textview_MoveTo(self, bx, by); --- 1461,1469 ---- sPtr, graphic_ATBASELINE); } bx = MovePast(self, bx, tt->ti_fontWidths, ! info, sPtr); textview_SetSpaceShim(self, ++info->spaceBump); + currentBump++; /* keep in sync with spaceBump */ info->lineBuffer[zapPos] = ' '; /* Put ' ' back */ if (info->lineAbove + info->textBelow <= ySize) { textview_MoveTo(self, bx, by); *************** *** 1293,1299 **** } /* spaceBump has already been incremented */ ! j += (tt->ti_rSpaces * info->spaceBump - foundSpaces); } } i++; --- 1478,1484 ---- } /* spaceBump has already been incremented */ ! j += (tt->ti_rSpaces * currentBump - foundSpaces); } } i++; *************** *** 1307,1317 **** rectangle_SetRectSize(&clearRect, info->totalWidth + initialIndent, info->cursorY, SkipPredrawn - info->totalWidth - initialIndent, ! MIN(ySize, info->lineAbove + info->lineBelow)); pat = textview_WhitePattern(self); textview_FillRect(self, &clearRect, pat); textview_SetTransferMode(self, graphic_BLACK); } /* Finally, set the mark length */ --- 1492,1504 ---- rectangle_SetRectSize(&clearRect, info->totalWidth + initialIndent, info->cursorY, SkipPredrawn - info->totalWidth - initialIndent, ! MIN(ySize, info->lineAbove + info->below)); pat = textview_WhitePattern(self); textview_FillRect(self, &clearRect, pat); textview_SetTransferMode(self, graphic_BLACK); } + if(type == textview_FullLineRedraw && info->continued) + drawcontinued(self,info,by); /* Finally, set the mark length */ *************** *** 1407,1413 **** self->predrawn->modified = 1; } } ! if (txheight) *txheight = info->lineAbove + info->textBelow; --- 1594,1607 ---- self->predrawn->modified = 1; } } ! if(color != NULL){ ! /* reset the original color */ ! #ifdef FGC ! textview_SetForegroundColor(self,rcolor,c1,c2,c3); ! #else ! textview_SetFGColor(self,c1,c2,c3); ! #endif ! } if (txheight) *txheight = info->lineAbove + info->textBelow; *************** *** 1419,1425 **** type == textview_GetCoordinate) return info->locateX; /* We were just looking */ ! return info->lineAbove + info->lineBelow; } void textview__ViewMove(self, lineStructure, movement) --- 1613,1619 ---- type == textview_GetCoordinate) return info->locateX; /* We were just looking */ ! return info->lineAbove + info->below; } void textview__ViewMove(self, lineStructure, movement) *** atk/text/indexpro.c Wed Nov 22 12:33:25 1989 --- atk/text/indexpro.c.NEW Thu Apr 25 16:17:41 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/text/RCS/indexpro.c,v 1.3 89/08/03 12:10:12 ghoti Exp $ */ /* $ACIS:$ */ ! /* $Source: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/text/RCS/indexpro.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/text/RCS/indexpro.c,v 1.3 89/08/03 12:10:12 ghoti Exp $"; #endif /* lint */ #include #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/text/RCS/indexpro.c,v 1.5 1991/04/25 11:11:29 tpn Exp $ */ /* $ACIS:$ */ ! /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/text/RCS/indexpro.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/text/RCS/indexpro.c,v 1.5 1991/04/25 11:11:29 tpn Exp $"; #endif /* lint */ #include #include *************** *** 59,65 **** head++; } if(np > n + 2) qsort((char *)n,np - n,sizeof(int),cmp); ! if((lc = (char *)index(buf,DCHAR)) != NULL && lc[1] == DCHAR){ int len = lc - buf; if((strlen(lbuf) == len) && strncmp(lbuf,buf,(len)) == 0){ buf = lc + 2; --- 59,66 ---- head++; } if(np > n + 2) qsort((char *)n,np - n,sizeof(int),cmp); ! if((lc = (char *)index(buf,DCHAR)) != NULL && lc[1] == DCHAR && ! lc[2] != ' ' && lc[2] != '\0'){ int len = lc - buf; if((strlen(lbuf) == len) && strncmp(lbuf,buf,(len)) == 0){ buf = lc + 2; *************** *** 67,79 **** else { strncpy(lbuf,buf,len); lbuf[len] = '\0'; puts(lbuf); buf = lc + 2; } putchar(' '); } ! else if (head == 0) puts(".XX\n"); fputs(buf,stdout); putchar(',');putchar(' '); while(n < np){ --- 68,83 ---- else { strncpy(lbuf,buf,len); lbuf[len] = '\0'; + if (head == 0) puts(".XX\n"); puts(lbuf); buf = lc + 2; } putchar(' '); } ! else { if (head == 0) puts(".XX\n"); + strcpy(lbuf,buf); + } fputs(buf,stdout); putchar(',');putchar(' '); while(n < np){ *************** *** 101,107 **** int argc; char *argv[]; { ! char buf[BUFSIZE],rbuf[BUFSIZE],*begin, *end,*rindex(),*c; int num[NUMSIZE],*np; puts(header); *buf = '\0'; --- 105,111 ---- int argc; char *argv[]; { ! char buf[BUFSIZE],rbuf[BUFSIZE],*begin, *end,*c; int num[NUMSIZE],*np; puts(header); *buf = '\0'; *** atk/text/readscr.c Wed Nov 22 12:32:17 1989 --- atk/text/readscr.c.NEW Wed Apr 3 21:22: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/sm/releases/X.V11R4/andrew/atk/text/RCS/readscr.c,v 2.10 89/10/05 11:22:53 cfe Exp $ */ /* $ACIS:readscr.c 1.4$ */ ! /* $Source: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/text/RCS/readscr.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/text/RCS/readscr.c,v 2.10 89/10/05 11:22:53 cfe Exp $"; #endif /* lint */ /* ** readscr.c - converts an ASCII file containing Scribe commands to --- 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/text/RCS/readscr.c,v 2.11 91/04/02 16:59:03 susan Exp $ */ /* $ACIS:readscr.c 1.4$ */ ! /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/text/RCS/readscr.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/text/RCS/readscr.c,v 2.11 91/04/02 16:59:03 susan Exp $"; #endif /* lint */ /* ** readscr.c - converts an ASCII file containing Scribe commands to *************** *** 14,24 **** a base editor II document ** */ #include #include #include #include - #include /* sys/file.h */ #ifdef hpux #include #endif /* hpux */ --- 14,24 ---- a base editor II document ** */ + #include /* sys/file.h */ #include #include #include #include #ifdef hpux #include #endif /* hpux */ *** atk/text/search.c Wed Sep 26 16:08:01 1990 --- atk/text/search.c.NEW Mon Dec 17 12:01:45 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/text/RCS/search.c,v 2.7 90/08/23 11:43:19 ajp Exp $ */ /* $ACIS:search.c 1.2$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/text/RCS/search.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/text/RCS/search.c,v 2.7 90/08/23 11:43:19 ajp 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/text/RCS/search.c,v 2.9 90/12/16 22:45:19 ajp Exp $ */ /* $ACIS:search.c 1.2$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/text/RCS/search.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/text/RCS/search.c,v 2.9 90/12/16 22:45:19 ajp Exp $"; #endif /* lint */ *************** *** 77,82 **** --- 77,133 ---- s = SkipOp (s); return s; } + } + + char *search__GetQuotedSearchString(classID, string, resString, resStrLen) + struct classheader *classID; + char *string; + char *resString; + long resStrLen; + { + long resultMaxLen; + long resultLen = 0; + char *result; + char *res; + + if (resString == NULL) { + resultMaxLen = strlen(string) + 10; + result = (char *) malloc(resultMaxLen + 1); + } + else { + resultMaxLen = resStrLen; + result = resString; + } + res = result; + + while (*string != '\0') { + switch (*string) { + case '.': + case '\\': + case '*': + case '[': + case ']': + *res++ = '\\'; + resultLen++; + break; + } + + if (resultLen >= resultMaxLen - 2) { + if (resString != NULL) { + *res = '\0'; + return NULL; + } + resultMaxLen *= 2; + result = (char *) realloc(result, resultMaxLen); + res = &result[resultLen]; + } + + *res++ = *string; + resultLen++; + string++; + } + *res = '\0'; + return result; } char * *** atk/text/search.ch Wed Sep 26 16:08:02 1990 --- atk/text/search.ch.NEW Mon Dec 17 12:01:47 1990 *************** *** 11,14 **** --- 11,15 ---- MatchPattern(struct simpletext *d, long pos, struct SearchPattern *p) returns int; MatchPatternReverse(struct simpletext *d, long pos, struct SearchPattern *p) returns int; GetMatchLength() returns int; + GetQuotedSearchString(char *string, char *resString, long resStrLen) returns char *; }; *** atk/text/smpltext.c Mon Aug 6 11:09:55 1990 --- atk/text/smpltext.c.NEW Fri Dec 14 16:55:58 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/text/RCS/smpltext.c,v 2.17 90/02/23 13:52:02 gk5g Exp $ */ /* $ACIS:smpltext.c 1.6$ */ ! /* $Source: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/text/RCS/smpltext.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/text/RCS/smpltext.c,v 2.17 90/02/23 13:52:02 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/text/RCS/smpltext.c,v 2.18 90/12/14 15:01:30 ajp Exp $ */ /* $ACIS:smpltext.c 1.6$ */ ! /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/text/RCS/smpltext.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/text/RCS/smpltext.c,v 2.18 90/12/14 15:01:30 ajp Exp $"; #endif /* lint */ #include *************** *** 590,595 **** --- 590,655 ---- return self->string + pos; } + + long simpletext__GetPosForLine(self, line) + struct simpletext *self; + long line; + { + long len = simpletext_GetLength(self); + long pos = 0; + long i; + + i = 1; + while (i < line) { + if (pos >= len) + break; + if (simpletext_GetChar(self, pos) == '\012') + i++; + pos++; + } + return pos; + } + + long simpletext__GetLineForPos(self, pos) + struct simpletext *self; + long pos; + { + long line=1; + + while (pos >= 0) { + if (simpletext_GetChar(self,pos) == '\012') + line++; + pos--; + } + + return line; + } + + long simpletext__GetBeginningOfLine(self, pos) + struct simpletext *self; + long pos; + { + while (pos > 0 && simpletext_GetChar(self, pos-1) != '\n') { + pos--; + } + return pos; + } + + long simpletext__GetEndOfLine(self, pos) + struct simpletext *self; + long pos; + { + long len = simpletext_GetLength(self); + + while (pos < len) { + if (simpletext_GetChar(self, pos) == '\n') { + break; + } + pos++; + } + return pos; + } + void simpletext__AddInCharacter(self, pos, c) struct simpletext *self; *** atk/text/smpltext.ch Wed Sep 26 16:08:04 1990 --- atk/text/smpltext.ch.NEW Fri Dec 14 16:56:00 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/text/RCS/smpltext.ch,v 2.10 90/08/23 11:43:30 ajp Exp $ */ /* $ACIS:smpltext.ch 1.4$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/text/RCS/smpltext.ch,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsidsimpletext_H = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/text/RCS/smpltext.ch,v 2.10 90/08/23 11:43:30 ajp Exp $"; #endif /* !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) */ /* Simple text conatins a string of text that can be manipulated. --- 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/text/RCS/smpltext.ch,v 2.11 90/12/14 15:01:19 ajp Exp $ */ /* $ACIS:smpltext.ch 1.4$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/text/RCS/smpltext.ch,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsidsimpletext_H = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/text/RCS/smpltext.ch,v 2.11 90/12/14 15:01:19 ajp Exp $"; #endif /* !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) */ /* Simple text conatins a string of text that can be manipulated. *************** *** 70,75 **** --- 70,80 ---- returns char *; GetGap(long pos, long len) returns char *; + + GetPosForLine(long line) returns long; + GetLineForPos(long pos) returns long; + GetBeginningOfLine(long pos) returns long; + GetEndOfLine(long pos) returns long; CopyText(long pos, struct thisobject *srctext, long srcpos, long len) returns boolean; /* FALSE if read-only */ *** atk/text/text.c Fri Dec 21 14:59:00 1990 --- atk/text/text.c.NEW Mon Mar 4 13:45: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/src/projects/andrew/atk/text/RCS/text.c,v 2.29 90/10/11 12:09:37 ajp Exp Locker: ajp $ */ /* $ACIS:text.c 1.7$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/text/RCS/text.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/text/RCS/text.c,v 2.29 90/10/11 12:09:37 ajp Exp Locker: ajp $"; #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/text/RCS/text.c,v 2.35 91/02/25 17:05:24 tpn Exp $ */ /* $ACIS:text.c 1.7$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/text/RCS/text.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/text/RCS/text.c,v 2.35 91/02/25 17:05:24 tpn Exp $"; #endif /* lint */ #include *************** *** 26,31 **** --- 26,32 ---- #include #include #include + #include #include #include *************** *** 77,82 **** --- 78,84 ---- self->exportEnvs = TRUE; self->WriteAsText = FALSE; self->CopyAsText = FALSE; + self->writeStyle = text_DefaultWrite; #if 0 if (DataStreamVersion == 0) { char *buf; *************** *** 122,128 **** { super_SetAttributes(self, attributes); ! while (attributes) if (strcmp(attributes->key, "template") == 0) { if (self->templateName != NULL) free(self->templateName); --- 124,130 ---- { super_SetAttributes(self, attributes); ! while (attributes) { if (strcmp(attributes->key, "template") == 0) { if (self->templateName != NULL) free(self->templateName); *************** *** 129,137 **** self->templateName = malloc(strlen(attributes->value.string) + 1); strcpy(self->templateName, attributes->value.string); text_ReadTemplate(self, self->templateName, (text_GetLength(self) == 0)); ! break; ! } else ! attributes = attributes->next; } struct viewref *text__InsertObject(self, pos, name, viewname) --- 131,148 ---- self->templateName = malloc(strlen(attributes->value.string) + 1); strcpy(self->templateName, attributes->value.string); text_ReadTemplate(self, self->templateName, (text_GetLength(self) == 0)); ! } ! else if (strcmp(attributes->key, "datastream") == 0) { ! if (strcmp(attributes->value.string, "no") == 0) { ! text_SetWriteStyle(self, text_NoDataStream); ! } ! else if (strcmp(attributes->value.string, "yes") == 0) { ! text_SetWriteStyle(self, text_DataStream); ! } ! } ! ! attributes = attributes->next; ! } } struct viewref *text__InsertObject(self, pos, name, viewname) *************** *** 790,796 **** length = 0; } else { dataobject_Read(dat, file, dataobject_UniqueID(dat)); ! dictionary_Insert(NULL, objectID, dataobject_UniqueID(dat)); text_AlwaysAddView(self, position, dataobject_ViewName(dat), dat); length = 1; } --- 801,807 ---- length = 0; } else { dataobject_Read(dat, file, dataobject_UniqueID(dat)); ! dictionary_Insert(NULL, (char *) objectID, (char *) dataobject_UniqueID(dat)); text_AlwaysAddView(self, position, dataobject_ViewName(dat), dat); length = 1; } *************** *** 908,913 **** --- 919,930 ---- return TRUE; } + static boolean TestForNoTemplate(style) + struct style *style; + { + return ! style->template; + } + long text__Write(self, file, writeID, level) struct text *self; FILE *file; *************** *** 921,933 **** if (level != 0) /* Text object is a child */ quoteCharacters = TRUE; ! if (self->exportEnvs) if (environment_NumberOfChildren(self->rootEnvironment) > 0) ! quoteCharacters = TRUE; /* There's at least one style */ if (StringMatch(self, 0, "\\begindata")) quoteCharacters = TRUE; if (self->header.dataobject.writeID != writeID) { if (quoteCharacters) { self->header.dataobject.writeID = writeID; --- 938,963 ---- if (level != 0) /* Text object is a child */ quoteCharacters = TRUE; ! if (self->exportEnvs) { if (environment_NumberOfChildren(self->rootEnvironment) > 0) ! quoteCharacters = TRUE; /* There's at least one style */ ! else if (stylesheet_EnumerateStyles(self->styleSheet, (procedure) TestForNoTemplate, 0) != NULL) { ! quoteCharacters = TRUE; ! } ! } if (StringMatch(self, 0, "\\begindata")) quoteCharacters = TRUE; + switch (text_GetWriteStyle(self)) { + case text_NoDataStream: + quoteCharacters = FALSE; + break; + case text_DataStream: + quoteCharacters = TRUE; + break; + } + if (self->header.dataobject.writeID != writeID) { if (quoteCharacters) { self->header.dataobject.writeID = writeID; *************** *** 1200,1206 **** } else lastblankset = FALSE; } ! } else realcount++; i++; --- 1230,1236 ---- } else lastblankset = FALSE; } ! if (outbuf == outp) realcount = 0; } else realcount++; i++; *************** *** 1425,1435 **** sv->CurFontSize = 12; sv->CurJustification = style_LeftAndRightJustified; sv->CurFontFamily = "andysans"; - sv->CurTabStops = NULL; - sv->CurTabTypes = NULL; - sv->CurNumTabs = 0; sv->CurCachedFont = NULL; sv->CurView = NULL; }; void text__FinalizeStateVector(classID,sv) --- 1455,1465 ---- sv->CurFontSize = 12; sv->CurJustification = style_LeftAndRightJustified; sv->CurFontFamily = "andysans"; sv->CurCachedFont = NULL; sv->CurView = NULL; + sv->CurColor = NULL; + + sv->tabs = tabs_Create(); }; void text__FinalizeStateVector(classID,sv) *************** *** 1436,1524 **** struct classheader *classID; struct text_statevector *sv; { ! #if 0 ! ClearTabs(sv); ! #endif /* 0 */ ! } ! ! #if 0 /* Tabs unimplemented so not wasting space & time (2%!) -cm26 */ ! static ClearTabs(sv) ! struct text_statevector * sv; { ! if (sv->CurTabStops) ! free(sv->CurTabStops); ! if (sv->CurTabTypes) ! free(sv->CurTabTypes); ! sv->CurTabStops = NULL; ! sv->CurTabTypes = NULL; ! sv->CurNumTabs = 0; ! } ! ! long FindPrevTab(sv, Pos) ! struct text_statevector * sv; ! long Pos; ! { ! long i; ! ! if (sv->CurNumTabs == 0) ! return -1; ! ! for(i = 0; i < sv->CurNumTabs; i++) ! if (Pos < sv->CurTabStops[i]) ! return i - 1; ! ! return sv->CurNumTabs; ! } ! ! static PlayTabChange(sv, tabChange) ! struct text_statevector *sv; ! struct tabentry *tabChange; ! { ! /* Make a single change in the state vector for tabs */ ! ! long Pos; /* Position for current tab */ ! long PrevTab; /* Tab location at or immediately before proposed tab */ ! ! Pos = tabChange->DotLocation; ! PrevTab = FindPrevTab(sv,Pos); ! ! if (PrevTab<0) { ! /* Must prepend it */ ! } ! else if (PrevTab == sv->CurNumTabs) { ! /* Must append it */ ! } ! else if (tabChange->DotLocation == sv->CurTabStops[PrevTab]){ ! /* Must replace it */ ! } ! else { ! /* Must insert at an appropriate place */ ! } ! ! switch(tabChange->TabOpcode) { ! case style_LeftAligned: ! break; ! case style_RightAligned: ! break; ! case style_CenteredOnTab: ! break; ! case style_CenteredBetweenTab: ! break; ! case style_TabDivide: ! /* First get rid of old tabs */ ! ClearTabs(sv); ! /* Calculate where new tab stops should go */ ! break; ! case style_CharAligned: ! break; ! case style_TabClear: ! break; ! case style_AllClear: ! ClearTabs(sv); ! break; ! default: ! /* Unknown -- should return error */ ! return; ! } } static PlayTabs(sv, oldsv, styleptr) --- 1466,1472 ---- struct classheader *classID; struct text_statevector *sv; { ! tabs_Death(sv->tabs); } static PlayTabs(sv, oldsv, styleptr) *************** *** 1526,1557 **** struct style * styleptr; { /* Tab updating is defined as copying over all of the old tabs and then */ ! /* applying the modifiers in the style to the new tabs. Note: we are */ ! /* tempted to special the usual case where no tab modifications are */ ! /* specified. However, to do this would require some mechanism to know */ ! /* when no more references the tabs were done so that we know when */ ! /* they could be released. Unfortunately, this is not easily done, so */ ! /* instead we play the malloc overhead price. */ long numTabChanges; ! struct tabentry *TabChangeArray; long i; ! /* See if any tabs to copy. If not, initialized values of 0 are ok */ ! ! if (oldsv->CurNumTabs) { ! sv->CurTabStops = (long *) malloc(sizeof(long) * oldsv->CurNumTabs); ! sv->CurTabTypes = (long *) malloc(sizeof(long) * oldsv->CurNumTabs); ! sv->CurNumTabs = oldsv->CurNumTabs; ! } ! bcopy(oldsv->CurTabStops, sv->CurTabStops, sizeof(long) * oldsv->CurNumTabs); ! bcopy(oldsv->CurTabTypes, sv->CurTabTypes, sizeof(long) * oldsv->CurNumTabs); style_GetTabChangeList(styleptr, &numTabChanges, &TabChangeArray); for (i = 0; i < numTabChanges; i++) ! PlayTabChange(sv, &TabChangeArray[i]); } - #endif /* 0 */ /* This routine takes a pointer to a state vector, a pointer and the */ /* style to use, and plays that style over the state vector. */ --- 1474,1496 ---- struct style * styleptr; { /* Tab updating is defined as copying over all of the old tabs and then */ ! /* applying the modifiers in the style to the new tabs. */ long numTabChanges; ! struct tabentry **TabChangeArray; long i; ! if (oldsv->tabs) ! sv->tabs = tabs_Copy(oldsv->tabs); ! else ! sv->tabs = tabs_Create(); style_GetTabChangeList(styleptr, &numTabChanges, &TabChangeArray); for (i = 0; i < numTabChanges; i++) ! sv->tabs = tabs_ApplyChange(sv->tabs, TabChangeArray[i]); ! if (TabChangeArray) ! free(TabChangeArray); } /* This routine takes a pointer to a state vector, a pointer and the */ /* style to use, and plays that style over the state vector. */ *************** *** 1562,1568 **** { register long delta; struct text_statevector oldvalues; ! /* Using new style system. Store old values for use in calculations. */ oldvalues = *sv; --- 1501,1507 ---- { register long delta; struct text_statevector oldvalues; ! char *color; /* Using new style system. Store old values for use in calculations. */ oldvalues = *sv; *************** *** 1764,1774 **** sv->SpecialFlags |= styleptr->AddMiscFlags; sv->SpecialFlags &= styleptr->OutMiscFlags; ! /* Tabs */ ! #if 0 PlayTabs(sv, &oldvalues, styleptr); - #endif /* 0 */ } /* Takes a pointer to a state vector, and a pointer to an */ --- 1703,1715 ---- sv->SpecialFlags |= styleptr->AddMiscFlags; sv->SpecialFlags &= styleptr->OutMiscFlags; ! /* Color */ ! if( ( color = style_GetAttribute(styleptr,"color")) != NULL) ! sv->CurColor = color; ! ! /* Tabs */ PlayTabs(sv, &oldvalues, styleptr); } /* Takes a pointer to a state vector, and a pointer to an */ *** atk/text/text.ch Fri Dec 21 14:59:03 1990 --- atk/text/text.ch.NEW Fri Dec 14 16:56:13 1990 *************** *** 2,17 **** * 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/text/RCS/text.ch,v 2.12 90/10/11 12:14:19 ajp Exp $ */ /* $ACIS:text.ch 1.4$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/text/RCS/text.ch,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsidtext_H = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/text/RCS/text.ch,v 2.12 90/10/11 12:14:19 ajp Exp $"; #endif /* !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) */ #define text_VERSION 1 class text: simpletext[smpltext] { overrides: SetAttributes(struct attributes *attributes); --- 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/text/RCS/text.ch,v 2.13 90/12/14 15:01:42 ajp Exp $ */ /* $ACIS:text.ch 1.4$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/text/RCS/text.ch,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsidtext_H = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/text/RCS/text.ch,v 2.13 90/12/14 15:01:42 ajp Exp $"; #endif /* !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) */ #define text_VERSION 1 + enum textwritestyle {text_DefaultWrite, text_NoDataStream, text_DataStream}; + class text: simpletext[smpltext] { overrides: SetAttributes(struct attributes *attributes); *************** *** 52,57 **** --- 54,61 ---- GetWriteAsText() ((self)->WriteAsText) SetCopyAsText(TorF) ((self)->CopyAsText = TorF) GetCopyAsText() ((self)->CopyAsText) + GetWriteStyle() ((self)->writeStyle) + SetWriteStyle(style) ((self)->writeStyle = style) classprocedures: FinalizeObject(struct text *self); *************** *** 67,70 **** --- 71,75 ---- boolean exportEnvs; boolean executingGetModified; boolean WriteAsText,CopyAsText; + enum textwritestyle writeStyle; }; *** atk/text/text.doc Wed Nov 22 12:33:45 1989 --- atk/text/text.doc.NEW Wed Apr 3 21:22:13 1991 *************** *** 1,4 **** ! \begindata{text,268753092} \textdsversion{12} \define{formatnote menu:[Region~4,FormatNote~60] --- 1,4 ---- ! \begindata{text,269451196} \textdsversion{12} \define{formatnote menu:[Region~4,FormatNote~60] *************** *** 178,186 **** for dealing with C code. ! \begindata{bp,268720936} ! \enddata{bp,268720936} ! \view{bpv,268720936,0,0,0} \section{\italic{text} functions} --- 178,186 ---- for dealing with C code. ! \begindata{bp,269892204} ! \enddata{bp,269892204} ! \view{bpv,269892204,76,0,0} \section{\italic{text} functions} *************** *** 271,279 **** \}} }\ ! \begindata{bp,268745532} ! \enddata{bp,268745532} ! \view{bpv,268745532,1,0,0} ______________________________________________________ --- 271,279 ---- \}} }\ ! \begindata{bp,269817788} ! \enddata{bp,269817788} ! \view{bpv,269817788,77,0,0} ______________________________________________________ *************** *** 351,357 **** text_AddView(text, pos,"fnotev",fnote);} }\ ! \view{bpv,268745532,2,0,0} ______________________________________________________ --- 351,357 ---- text_AddView(text, pos,"fnotev",fnote);} }\ ! \view{bpv,269817788,78,0,0} ______________________________________________________ *************** *** 417,423 **** }(atk/support/stylesht.doc) and \italic{environment_SetStyle} (atk/support/envrment.doc).} ! \view{bpv,268745532,3,0,0} ______________________________________________________ --- 417,423 ---- }(atk/support/stylesht.doc) and \italic{environment_SetStyle} (atk/support/envrment.doc).} ! \view{bpv,269817788,79,0,0} ______________________________________________________ *************** *** 482,488 **** default view, see \italic{dataobject_ViewName} (atk/basics/common/dataobj.doc).} ! \view{bpv,268745532,4,0,0} ______________________________________________________ --- 482,488 ---- default view, see \italic{dataobject_ViewName} (atk/basics/common/dataobj.doc).} ! \view{bpv,269817788,80,0,0} ______________________________________________________ *************** *** 534,542 **** \fieldtext{See also \paramname{simpletext_CopyText} (atk/text/smpltext.doc).} ! \begindata{bp,268745820} ! \enddata{bp,268745820} ! \view{bpv,268745820,5,0,0}_ ______________________________________________________ --- 534,542 ---- \fieldtext{See also \paramname{simpletext_CopyText} (atk/text/smpltext.doc).} ! \begindata{bp,269444676} ! \enddata{bp,269444676} ! \view{bpv,269444676,81,0,0}_ ______________________________________________________ *************** *** 613,622 **** \paramname{simpletext_SetObjectInsertionFlag} (atk/text/smpltext.doc).} ! \begindata{bp,268741276} ! \enddata{bp,268741276} ! \view{bpv,268741276,6,548,0}___________________________________________________\ ! __ \paragraph{text_AlwaysReplaceCharacters}\indexi{\italic{text_AlwaysReplaceChara\ --- 613,622 ---- \paramname{simpletext_SetObjectInsertionFlag} (atk/text/smpltext.doc).} ! \begindata{bp,269839456} ! \enddata{bp,269839456} ! \view{bpv,269839456,82,548,0}__________________________________________________\ ! ___ \paragraph{text_AlwaysReplaceCharacters}\indexi{\italic{text_AlwaysReplaceChara\ *************** *** 683,691 **** textview_GetDotLength(textvptr), wordBuffer, strlen(wordBuffer));}} ! \begindata{bp,268847616} ! \enddata{bp,268847616} ! \view{bpv,268847616,7,0,0} ______________________________________________________ --- 683,691 ---- textview_GetDotLength(textvptr), wordBuffer, strlen(wordBuffer));}} ! \begindata{bp,269540436} ! \enddata{bp,269540436} ! \view{bpv,269540436,83,0,0} ______________________________________________________ *************** *** 726,735 **** \fieldtext{\paramname{textview_GetDefaultStyle}.} ! \begindata{bp,268847524} ! \enddata{bp,268847524} ! \view{bpv,268847524,8,0,0}_____________________________________________________\ ! _ \paragraph{text_Clear} \indexi{ \italic{text_Clear}} --- 726,735 ---- \fieldtext{\paramname{textview_GetDefaultStyle}.} ! \begindata{bp,269602508} ! \enddata{bp,269602508} ! \view{bpv,269602508,84,0,0}____________________________________________________\ ! __ \paragraph{text_Clear} \indexi{ \italic{text_Clear}} *************** *** 756,764 **** \fieldtext{Clears the buffer associated with \paramname{text} of all characters and styles.} ! \begindata{bp,268847396} ! \enddata{bp,268847396} ! \view{bpv,268847396,9,0,0} ______________________________________________________ --- 756,764 ---- \fieldtext{Clears the buffer associated with \paramname{text} of all characters and styles.} ! \begindata{bp,269519352} ! \enddata{bp,269519352} ! \view{bpv,269519352,85,0,0} ______________________________________________________ *************** *** 793,801 **** \fieldtext{Only used in \bold{messages} to take care of core leaks.} ! \begindata{bp,268847268} ! \enddata{bp,268847268} ! \view{bpv,268847268,10,0,0} ______________________________________________________ --- 793,801 ---- \fieldtext{Only used in \bold{messages} to take care of core leaks.} ! \begindata{bp,269860608} ! \enddata{bp,269860608} ! \view{bpv,269860608,86,0,0} ______________________________________________________ *************** *** 849,857 **** \fieldtext{Could use this to implement a search function that would look for everything in bold.} ! \begindata{bp,268847140} ! \enddata{bp,268847140} ! \view{bpv,268847140,11,0,0}____________________________________________________\ ___ --- 849,857 ---- \fieldtext{Could use this to implement a search function that would look for everything in bold.} ! \begindata{bp,269892160} ! \enddata{bp,269892160} ! \view{bpv,269892160,87,0,0}____________________________________________________\ ___ *************** *** 891,899 **** \fieldtext{\paramname{FinalizeObject} in class/doc/class.doc.} ! \begindata{bp,268847048} ! \enddata{bp,268847048} ! \view{bpv,268847048,12,0,0}____________________________________________________\ __ --- 891,899 ---- \fieldtext{\paramname{FinalizeObject} in class/doc/class.doc.} ! \begindata{bp,269817744} ! \enddata{bp,269817744} ! \view{bpv,269817744,88,0,0}____________________________________________________\ __ *************** *** 919,929 **** \fieldheading{Description} ! \fieldtext{Make the state vector go away.} ! \begindata{bp,268846956} ! \enddata{bp,268846956} ! \view{bpv,268846956,13,0,0}____________________________________________________\ _ --- 919,938 ---- \fieldheading{Description} ! \fieldtext{Make the state vector go away. Actually, it just calls tabs_Death ! on the tabs component.} ! ! \fieldheading{ ! Usage} ! \fieldtext{Call \italic{text_FinalizeStateVector} when you are through with ! using a state vector. Call it only on a state vector that has been ! initialized with \italic{text_InitializeStateVector}. Otherwise a nonexistant ! tabs component will be destroyed.} ! ! \begindata{bp,269819480} ! \enddata{bp,269819480} ! \view{bpv,269819480,89,0,0}____________________________________________________\ _ *************** *** 961,969 **** \fieldtext{The found view reference; NULL if none found.} ! \begindata{bp,268846864} ! \enddata{bp,268846864} ! \view{bpv,268846864,14,0,0}_ ______________________________________________________ --- 970,978 ---- \fieldtext{The found view reference; NULL if none found.} ! \begindata{bp,269444632} ! \enddata{bp,269444632} ! \view{bpv,269444632,90,0,0}_ ______________________________________________________ *************** *** 1012,1020 **** \fieldtext{\paramname{text_SetExportEnvironments}.} ! \begindata{bp,268846772} ! \enddata{bp,268846772} ! \view{bpv,268846772,15,0,0}____________________________________________________\ _ --- 1021,1029 ---- \fieldtext{\paramname{text_SetExportEnvironments}.} ! \begindata{bp,269838264} ! \enddata{bp,269838264} ! \view{bpv,269838264,91,0,0}____________________________________________________\ _ *************** *** 1055,1063 **** \fieldtext{\paramname{text_SetGlobalStyle}; \paramname{environment_GetRootEnvironment} (atk/support/envrment.doc).} ! \begindata{bp,268846680} ! \enddata{bp,268846680} ! \view{bpv,268846680,16,0,0}____________________________________________________\ __ --- 1064,1072 ---- \fieldtext{\paramname{text_SetGlobalStyle}; \paramname{environment_GetRootEnvironment} (atk/support/envrment.doc).} ! \begindata{bp,269444192} ! \enddata{bp,269444192} ! \view{bpv,269444192,92,0,0}____________________________________________________\ __ *************** *** 1106,1114 **** \fieldtext{\paramname{dataobject_SetModified}; \paramname{dataobject_GetModified} (atk/basics/common/dataobj.doc).} ! \begindata{bp,268888196} ! \enddata{bp,268888196} ! \view{bpv,268888196,17,0,0} ______________________________________________________ --- 1115,1123 ---- \fieldtext{\paramname{dataobject_SetModified}; \paramname{dataobject_GetModified} (atk/basics/common/dataobj.doc).} ! \begindata{bp,269837756} ! \enddata{bp,269837756} ! \view{bpv,269837756,93,0,0} ______________________________________________________ *************** *** 1143,1151 **** \fieldtext{The style sheet associated with text.} ! \begindata{bp,268846552} ! \enddata{bp,268846552} ! \view{bpv,268846552,18,0,0} ______________________________________________________ --- 1152,1160 ---- \fieldtext{The style sheet associated with text.} ! \begindata{bp,270065400} ! \enddata{bp,270065400} ! \view{bpv,270065400,94,0,0} ______________________________________________________ *************** *** 1201,1209 **** \fieldtext{\paramname{dataobject_HandleCloseWord} (atk/basics/common/dataobj.doc).} ! \begindata{bp,268846484} ! \enddata{bp,268846484} ! \view{bpv,268846484,19,0,0}____________________________________________________\ __ --- 1210,1218 ---- \fieldtext{\paramname{dataobject_HandleCloseWord} (atk/basics/common/dataobj.doc).} ! \begindata{bp,269817700} ! \enddata{bp,269817700} ! \view{bpv,269817700,95,0,0}____________________________________________________\ __ *************** *** 1273,1281 **** \fieldtext{\italic{text_HandleKeyWord (txt, 0, "dversion", \smaller{NULL})} inserts \italic{\\dversion \{} at the beginning of \italic{txt}'s buffer. } ! \begindata{bp,268846416} ! \enddata{bp,268846416} ! \view{bpv,268846416,20,0,0}_ ______________________________________________________ --- 1282,1290 ---- \fieldtext{\italic{text_HandleKeyWord (txt, 0, "dversion", \smaller{NULL})} inserts \italic{\\dversion \{} at the beginning of \italic{txt}'s buffer. } ! \begindata{bp,269444588} ! \enddata{bp,269444588} ! \view{bpv,269444588,96,0,0}_ ______________________________________________________ *************** *** 1307,1315 **** tabs.}\fieldtext{ }\ ! \begindata{bp,268887948} ! \enddata{bp,268887948} ! \view{bpv,268887948,21,0,0} ______________________________________________________ --- 1316,1324 ---- tabs.}\fieldtext{ }\ ! \begindata{bp,269561444} ! \enddata{bp,269561444} ! \view{bpv,269561444,97,0,0} ______________________________________________________ *************** *** 1386,1394 **** \paramname{simpletext_SetObjectInsertionFlag} (atk/text/smpltext.doc).} ! \begindata{bp,268887876} ! \enddata{bp,268887876} ! \view{bpv,268887876,22,0,0} ______________________________________________________ --- 1395,1403 ---- \paramname{simpletext_SetObjectInsertionFlag} (atk/text/smpltext.doc).} ! \begindata{bp,269444148} ! \enddata{bp,269444148} ! \view{bpv,269444148,98,0,0} ______________________________________________________ *************** *** 1446,1454 **** \fieldtext{Should be AlwaysInsertObject, but there isn't?} ! \begindata{bp,268908884} ! \enddata{bp,268908884} ! \view{bpv,268908884,23,0,0}____________________________________________________\ _ --- 1455,1463 ---- \fieldtext{Should be AlwaysInsertObject, but there isn't?} ! \begindata{bp,269972368} ! \enddata{bp,269972368} ! \view{bpv,269972368,99,0,0}____________________________________________________\ _ *************** *** 1522,1530 **** \fieldtext{Concrete example.} ! \begindata{bp,268887780} ! \enddata{bp,268887780} ! \view{bpv,268887780,24,0,0} ______________________________________________________ --- 1531,1539 ---- \fieldtext{Concrete example.} ! \begindata{bp,269226276} ! \enddata{bp,269226276} ! \view{bpv,269226276,100,0,0} ______________________________________________________ *************** *** 1600,1608 **** \fieldtext{Concrete example.} ! \begindata{bp,268887736} ! \enddata{bp,268887736} ! \view{bpv,268887736,25,0,0} ______________________________________________________ --- 1609,1617 ---- \fieldtext{Concrete example.} ! \begindata{bp,269444544} ! \enddata{bp,269444544} ! \view{bpv,269444544,101,0,0} ______________________________________________________ *************** *** 1672,1680 **** \fieldtext{\italic{text_ReadSubString; text_Write.}} ! \begindata{bp,268887692} ! \enddata{bp,268887692} ! \view{bpv,268887692,26,0,0}_ ______________________________________________________ --- 1681,1689 ---- \fieldtext{\italic{text_ReadSubString; text_Write.}} ! \begindata{bp,269520164} ! \enddata{bp,269520164} ! \view{bpv,269520164,102,0,0}_ ______________________________________________________ *************** *** 1734,1742 **** \fieldtext{\paramname{text_Read}.} ! \begindata{bp,268887648} ! \enddata{bp,268887648} ! \view{bpv,268887648,27,0,0}_ ______________________________________________________ --- 1743,1751 ---- \fieldtext{\paramname{text_Read}.} ! \begindata{bp,269540132} ! \enddata{bp,269540132} ! \view{bpv,269540132,103,0,0}_ ______________________________________________________ *************** *** 1793,1802 **** boldStyle = stylesheet_Find (commandLogptr->styleSheet, "bold");}} ! \begindata{bp,268887604} ! \enddata{bp,268887604} ! \view{bpv,268887604,28,0,0}____________________________________________________\ ! \paragraph{text_ReplaceCharacters} \indexi{ \italic{text_ReplaceCharacters}} --- 1802,1811 ---- boldStyle = stylesheet_Find (commandLogptr->styleSheet, "bold");}} ! \begindata{bp,269995728} ! \enddata{bp,269995728} ! \view{bpv,269995728,104,0,0}___________________________________________________\ ! _ \paragraph{text_ReplaceCharacters} \indexi{ \italic{text_ReplaceCharacters}} *************** *** 1863,1871 **** textview_GetDotLength(textvptr), wordBuffer, strlen(wordBuffer));}} ! \begindata{bp,268887560} ! \enddata{bp,268887560} ! \view{bpv,268887560,29,0,0} ______________________________________________________ --- 1872,1880 ---- textview_GetDotLength(textvptr), wordBuffer, strlen(wordBuffer));}} ! \begindata{bp,269736036} ! \enddata{bp,269736036} ! \view{bpv,269736036,105,0,0} ______________________________________________________ *************** *** 1929,1937 **** \}} ! \begindata{bp,268982856} ! \enddata{bp,268982856} ! \view{bpv,268982856,30,0,0} ______________________________________________________ --- 1938,1946 ---- \}} ! \begindata{bp,269444500} ! \enddata{bp,269444500} ! \view{bpv,269444500,106,0,0} ______________________________________________________ *************** *** 2015,2023 **** \fieldtext{Concrete example.} ! \begindata{bp,268887492} ! \enddata{bp,268887492} ! \view{bpv,268887492,31,0,0} ______________________________________________________ --- 2024,2032 ---- \fieldtext{Concrete example.} ! \begindata{bp,269520120} ! \enddata{bp,269520120} ! \view{bpv,269520120,107,0,0} ______________________________________________________ *************** *** 2063,2072 **** \fieldtext{\paramname{text_GetExportEnvironments}.} ! \begindata{bp,268974652} ! \enddata{bp,268974652} ! \view{bpv,268974652,32,0,0}____________________________________________________\ ! __ \paragraph{text_SetGlobalStyle} \indexi{ \italic{text_GetGlobalStyle}} --- 2072,2081 ---- \fieldtext{\paramname{text_GetExportEnvironments}.} ! \begindata{bp,269860464} ! \enddata{bp,269860464} ! \view{bpv,269860464,108,0,0}___________________________________________________\ ! ___ \paragraph{text_SetGlobalStyle} \indexi{ \italic{text_GetGlobalStyle}} *************** *** 2109,2115 **** \fieldtext{\paramname{text_GetGlobalStyle}.} ! \view{bpv,268982856,33,0,0} ______________________________________________________ --- 2118,2124 ---- \fieldtext{\paramname{text_GetGlobalStyle}.} ! \view{bpv,269444500,109,0,0} ______________________________________________________ *************** *** 2178,2186 **** \fieldtext{\italic{text_WriteSubString}; \paramname{dataobject_Write} (atk/basics/common/dataobj.doc).} ! \begindata{bp,268866792} ! \enddata{bp,268866792} ! \view{bpv,268866792,34,0,0} ______________________________________________________ --- 2187,2195 ---- \fieldtext{\italic{text_WriteSubString}; \paramname{dataobject_Write} (atk/basics/common/dataobj.doc).} ! \begindata{bp,269735992} ! \enddata{bp,269735992} ! \view{bpv,269735992,110,0,0} ______________________________________________________ *************** *** 2231,2234 **** \fieldtext{\paramname{text_Write}; \paramname{dataobject_WriteSubString} (atk/basics/common/dataobj.doc).\ ! }\enddata{text,268753092} --- 2240,2243 ---- \fieldtext{\paramname{text_Write}; \paramname{dataobject_WriteSubString} (atk/basics/common/dataobj.doc).\ ! }\enddata{text,269451196} *** atk/text/textv.c Fri Dec 21 14:59:07 1990 --- atk/text/textv.c.NEW Wed May 1 13:25:00 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/text/RCS/textv.c,v 2.24 90/10/11 12:14:35 ajp Exp Locker: ajp $ */ /* $ACIS:textv.c 1.7$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/text/RCS/textv.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/text/RCS/textv.c,v 2.24 90/10/11 12:14:35 ajp Exp Locker: ajp $"; #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/text/RCS/textv.c,v 2.31 1991/05/01 16:49:46 dba Exp $ */ /* $ACIS:textv.c 1.7$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/text/RCS/textv.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/text/RCS/textv.c,v 2.31 1991/05/01 16:49:46 dba Exp $"; #endif /* lint */ #include *************** *** 49,58 **** #define MAXPARA 200 #define REMOVEDCURSOR 32765 #define TABBASE ((int) 'n') static struct fontdesc *iconFont = NULL; ! static struct keymap *textviewKeymap; static struct menulist *viewMenus; static boolean initialExposeStyles; static boolean alwaysDisplayStyleMenus; --- 49,63 ---- #define MAXPARA 200 #define REMOVEDCURSOR 32765 #define TABBASE ((int) 'n') + #define FINESCROLL 7 + #define FINEMASK 127 /* 2 ^ FINESCROLL - 1 */ + #define FINEGRID 12 static struct fontdesc *iconFont = NULL; ! static struct keymap *textviewEmacsKeymap; ! static struct keymap *textviewViInputModeKeymap; ! static struct keymap *textviewViCommandModeKeymap; static struct menulist *viewMenus; static boolean initialExposeStyles; static boolean alwaysDisplayStyleMenus; *************** *** 76,81 **** --- 81,87 ---- long fontStyle = fontdesc_Plain; struct style *defaultStyle; boolean justify; + char *editorPtr; self->displayLength = 0; self->hasInputFocus = FALSE; *************** *** 91,97 **** self->ebx = EBX; self->eby = EBY; self->hasApplicationLayer = FALSE; ! self->keystate = keystate_Create(self, textviewKeymap); self->styleMenus = NULL; self->menus = menulist_DuplicateML(viewMenus, self); menulist_SetMask(self->menus, textview_NoMenus); --- 97,122 ---- self->ebx = EBX; self->eby = EBY; self->hasApplicationLayer = FALSE; ! self->editor = EMACS; ! self->keystate = self->emacsKeystate = keystate_Create(self, textviewEmacsKeymap); ! self->viCommandModeKeystate = keystate_Create(self, textviewViCommandModeKeymap); ! self->viInputModeKeystate = keystate_Create(self, textviewViInputModeKeymap); ! /* Look first at preference, then at shell variables to determine editor */ ! /* if VI user, set initial keystate to VI command mode */ ! if ( (editorPtr = environ_GetProfile("editor")) != NULL || ! (editorPtr = environ_Get("EDITOR")) != NULL || ! (editorPtr = environ_Get("EDIT")) != NULL || ! (editorPtr = environ_Get("ED")) != NULL || ! (editorPtr = environ_Get("FCEDIT")) != NULL || ! (editorPtr = environ_Get("VISUAL")) != NULL ) ! { ! if ( strlen(editorPtr) >= 2 && !strcmp(editorPtr + strlen(editorPtr) - 2, "vi" ) ) ! { ! self->editor = VI; ! self->viMode = COMMAND; ! self->keystate = self->viCommandModeKeystate; ! } ! } self->styleMenus = NULL; self->menus = menulist_DuplicateML(viewMenus, self); menulist_SetMask(self->menus, textview_NoMenus); *************** *** 120,125 **** --- 145,153 ---- defaultStyle = style_New(); style_SetName(defaultStyle, "default"); + self->ScreenScaleMul = environ_GetProfileInt("TabScalingMultiplier", 14); + self->ScreenScaleDiv = environ_GetProfileInt("TabScalingDivisor", 12); + if ((font = environ_GetProfile("bodyfont")) == NULL || ! fontdesc_ExplodeFontName(font, bodyFont, sizeof(bodyFont), &fontStyle, &fontSize)) { strcpy(bodyFont, "Andy"); } *************** *** 133,138 **** --- 161,171 ---- self->insertStack = NULL; self->insertEnvMark = NULL; + + self->pixelsShownOffTop = 0; + self->pixelsReadyToBeOffTop = 0; + self->pixelsComingOffTop = 0; + return TRUE; } *************** *** 239,245 **** FreeTextData(self); style_Destroy(self->defaultStyle); ! keystate_Destroy(self->keystate); if (self->menus != NULL) { menulist_Destroy(self->menus); } --- 272,280 ---- FreeTextData(self); style_Destroy(self->defaultStyle); ! keystate_Destroy(self->emacsKeystate); ! keystate_Destroy(self->viInputModeKeystate); ! keystate_Destroy(self->viCommandModeKeystate); if (self->menus != NULL) { menulist_Destroy(self->menus); } *************** *** 343,351 **** struct view *textview__GetApplicationLayer(self) struct textview *self; { ! self->hasApplicationLayer = TRUE; ! return (struct view *) scroll_Create(self, scroll_LEFT); } void textview__DeleteApplicationLayer(self, scrollbar) --- 378,393 ---- struct view *textview__GetApplicationLayer(self) struct textview *self; { ! long scrollpos=scroll_LEFT; ! char *pos=environ_GetProfile("ScrollbarPosition"); ! self->hasApplicationLayer = TRUE; ! ! if(pos) { ! if(!strcmp(pos,"right")) scrollpos=scroll_RIGHT; ! } else if(environ_GetProfileSwitch("MotifScrollbars", FALSE)) scrollpos=scroll_RIGHT; ! ! return (struct view *) scroll_Create(self, scrollpos); } void textview__DeleteApplicationLayer(self, scrollbar) *************** *** 523,528 **** --- 565,593 ---- UpdateCursor(self, FALSE); } + static void CopyLineInfo(self, newline, line, movement) + struct textview *self; + struct linedesc *newline; + struct linedesc *line; + int movement; + { + if (line != newline) { + mark_SetPos(newline->data, mark_GetPos(line->data)); + mark_SetLength(newline->data, mark_GetLength(line->data)); + mark_SetStyle(newline->data, mark_IncludeBeginning(line->data), mark_IncludeEnding(line->data)); + newline->nChars = line->nChars; + mark_SetModified(newline->data, FALSE); + mark_SetObjectFree(newline->data, mark_ObjectFree(line->data)); + newline->height = line->height; + newline->xMax = line->xMax; + newline->containsView = line->containsView; + } + newline->y = line->y + movement; + if (newline->containsView) { + /* Put code for moving inset here */ + textview_ViewMove(self, newline, movement); + } + } /* This routine redraws that which must change. The key concept is this: marks have a modified flag that can be cleared, and which is set whenever the text within a marker is modified. A view consists of a set of lines and the marks representing the corresponding text. When we are supposed to update a view, we redraw the lines which correspond to modified marks. *//* *************** *** 542,548 **** boolean cursorVisible = 0; boolean changed; int cont; /* force continuation of redraw */ ! enum textview_ScrollDirection scrolling = textview_NoScroll; /* set to v->scroll if this is a scrolling update */ boolean zapRest; struct rectangle tempSrcRect; struct point tempDstOrigin; /* Temps for graphics operations */ --- 607,614 ---- boolean cursorVisible = 0; boolean changed; int cont; /* force continuation of redraw */ ! /* set to v->scroll if this is a scrolling update */ ! enum textview_ScrollDirection scrolling = textview_NoScroll; boolean zapRest; struct rectangle tempSrcRect; struct point tempDstOrigin; /* Temps for graphics operations */ *************** *** 582,587 **** --- 648,655 ---- xs = textview_GetLogicalWidth(self) - 2 * bx; ys = textview_GetLogicalHeight(self) - 2 * by; + cury -= self->pixelsReadyToBeOffTop; + lob = self->top; /* the first char on the screen */ lobChars = 0; mark_SetLength(lob,0); /* ignore the length part, which can grow at random */ *************** *** 589,598 **** if (self->scroll == textview_ScrollForward || self->scroll == textview_ScrollBackward) { for (line = 0; line < self->nLines && ! mark_GetModified(self->lines[line].data); line++); ! if (line == self->nLines && line > 1) { /* At this point we know that only scrolling has occurred and we can just do the bit blt and continue formatting */ ! int sy, dy, h, newLine, movement, lasty, extendedTop = 0; scrolling = self->scroll; --- 657,666 ---- if (self->scroll == textview_ScrollForward || self->scroll == textview_ScrollBackward) { for (line = 0; line < self->nLines && ! mark_GetModified(self->lines[line].data); line++); ! if (line == self->nLines && line >= 1) { /* was > */ /* At this point we know that only scrolling has occurred and we can just do the bit blt and continue formatting */ ! int sy, dy, h, newLine, movement, lasty, yoff, extendedTop = 0; scrolling = self->scroll; *************** *** 601,619 **** /* Determine area that has to be moved */ ! if(self->lines[self->nLines - 1].height > self->lines[self->nLines - 1].textheight) { /* last line contains a view that will probably need a full redraw */ stopline = self->nLines - 2; redrawline = stopline + 1; ! mark_SetModified(self->lines[redrawline].data,TRUE); } ! else{ stopline = self->nLines - 1; redrawline = -1; } sy = self->lines[self->scrollLine].y; ! dy = self->lines[0].y; ! /* lasty = self->lines[self->nLines - 1].y + self->lines[self->nLines - 1].height; */ lasty = self->lines[stopline].y + self->lines[stopline].height; if (self->ceyPos >= lasty && self->ceyPos == self->csyPos && self->cexPos == self->csxPos) { /* We are viewing the end of the file with the carat at the end. */ --- 669,687 ---- /* Determine area that has to be moved */ ! if (self->lines[self->nLines - 1].height > self->lines[self->nLines - 1].textheight) { /* last line contains a view that will probably need a full redraw */ stopline = self->nLines - 2; redrawline = stopline + 1; ! mark_SetModified(self->lines[redrawline].data, TRUE); } ! else { stopline = self->nLines - 1; redrawline = -1; } + sy = self->lines[self->scrollLine].y; ! dy = cury; lasty = self->lines[stopline].y + self->lines[stopline].height; if (self->ceyPos >= lasty && self->ceyPos == self->csyPos && self->cexPos == self->csxPos) { /* We are viewing the end of the file with the carat at the end. */ *************** *** 625,671 **** /* Remove Cursor if it is on the scroll-1 line */ ! if (cursorVisible && mark_GetLength(self->dot) == 0 && ! mark_GetPos(self->dot) >= mark_GetPos(self->lines[self->scrollLine-1].data) && mark_GetPos(self->dot) < mark_GetPos(self->lines[self->scrollLine].data)) { textview_SetTransferMode(self,graphic_XOR); XorCursor(self); ! } ! textview_SetTransferMode(self,graphic_COPY); ! rectangle_SetRectSize(&tempSrcRect,0,sy,textview_GetLogicalWidth(self),h); ! point_SetPt(&tempDstOrigin,0,dy); ! textview_BitBlt(self, &tempSrcRect, self,&tempDstOrigin, (struct rectangle *) NULL); - rectangle_SetRectSize(&tempSrcRect,0,dy+h,textview_GetLogicalWidth(self),textview_GetLogicalHeight(self) - (dy+h)); - pat = textview_WhitePattern(self); - textview_FillRect(self,&tempSrcRect,pat); - /* remove scrolled off views */ ! for(line = 0; line < self->scrollLine; line++) ! if(self->lines[line].containsView){ ! textview_ViewMove(self,&self->lines[line],textview_REMOVEVIEW); ! /* mark_SetModified(self->lines[line].data, TRUE); */ } ! for (newLine = 0, line = self->scrollLine; line <= stopline; line++, newLine++) { ! mark_SetPos(self->lines[newLine].data, mark_GetPos(self->lines[line].data)); ! mark_SetLength(self->lines[newLine].data, mark_GetLength(self->lines[line].data)); ! mark_SetStyle(self->lines[newLine].data, mark_IncludeBeginning(self->lines[line].data), mark_IncludeEnding(self->lines[line].data)); ! self->lines[newLine].nChars = self->lines[line].nChars; ! mark_SetModified(self->lines[newLine].data, FALSE); ! mark_SetObjectFree(self->lines[newLine].data, mark_ObjectFree(self->lines[line].data)); ! self->lines[newLine].y = self->lines[line].y - movement; ! self->lines[newLine].height = self->lines[line].height; ! self->lines[newLine].xMax = self->lines[line].xMax; ! self->lines[newLine].containsView = self->lines[line].containsView; ! if (self->lines[newLine].containsView) { ! /* Put code for moving inset here */ ! textview_ViewMove(self,&self->lines[newLine],-movement); ! /* cont = 0; ! textview_LineRedraw(self, textview_MoveView, self->lines[newLine].data, curx, self->lines[newLine].y , xs, ysleft, force, &cont, &info); */ ! } ! } ! self->nLines -= self->scrollLine; if (self->csxPos != BADCURPOS) { extendedTop = (self->csyPos - self->cshPos) < by; if (self->ceyPos > lasty) { --- 693,736 ---- /* Remove Cursor if it is on the scroll-1 line */ ! if (cursorVisible && mark_GetLength(self->dot) == 0 && self->scrollLine > 0 && ! mark_GetPos(self->dot) >= mark_GetPos(self->lines[self->scrollLine-1].data) && mark_GetPos(self->dot) < mark_GetPos(self->lines[self->scrollLine].data)) { textview_SetTransferMode(self,graphic_XOR); XorCursor(self); ! } ! textview_SetTransferMode(self, graphic_COPY); ! yoff = (dy < 0) ? dy : 0; /* clip */ ! rectangle_SetRectSize(&tempSrcRect, 0, sy - yoff, textview_GetLogicalWidth(self), h - yoff); ! point_SetPt(&tempDstOrigin, 0, dy - yoff); ! textview_BitBlt(self, &tempSrcRect, self, &tempDstOrigin, (struct rectangle *) NULL); ! ! rectangle_SetRectSize(&tempSrcRect, 0, dy+h, textview_GetLogicalWidth(self), textview_GetLogicalHeight(self) - (dy+h)); ! pat = textview_WhitePattern(self); ! textview_FillRect(self, &tempSrcRect, pat); ! ! /* if there was something going off the top, ! and now there isn't, clear that little bit of spoog */ ! if (self->pixelsReadyToBeOffTop == 0 && self->pixelsShownOffTop != 0) { ! rectangle_SetRectSize(&tempSrcRect, 0, 0, textview_GetLogicalWidth(self), by); ! pat = textview_WhitePattern(self); ! textview_FillRect(self, &tempSrcRect, pat); ! } /* remove scrolled off views */ ! for (line = 0; line < self->scrollLine; line++) { ! if (self->lines[line].containsView) { ! textview_ViewMove(self,&self->lines[line], textview_REMOVEVIEW); ! /* mark_SetModified(self->lines[line].data, TRUE); */ } + } ! for (newLine = 0, line = self->scrollLine; line <= stopline; line++, newLine++) { ! CopyLineInfo(self, &self->lines[newLine], &self->lines[line], -movement); ! } ! ! self->nLines -= self->scrollLine; ! if (self->csxPos != BADCURPOS) { extendedTop = (self->csyPos - self->cshPos) < by; if (self->ceyPos > lasty) { *************** *** 672,678 **** self->cehPos -= self->ceyPos - lasty; self->ceyPos = lasty; ! rectangle_SetRectSize(&tempSrcRect,0,lasty,textview_GetLogicalWidth(self), textview_GetVisualHeight(self) - lasty); pat = textview_WhitePattern(self); textview_FillRect(self,&tempSrcRect, pat); } --- 737,743 ---- self->cehPos -= self->ceyPos - lasty; self->ceyPos = lasty; ! rectangle_SetRectSize(&tempSrcRect, 0, lasty, textview_GetLogicalWidth(self), textview_GetVisualHeight(self) - lasty); pat = textview_WhitePattern(self); textview_FillRect(self,&tempSrcRect, pat); } *************** *** 696,705 **** else if ((self->csyPos - self->cshPos) < by) { if (! extendedTop) { /* Just moved into the border, so color it black */ ! rectangle_SetRectSize(&tempSrcRect,0,0, ! textview_GetLogicalWidth(self),by); pat = textview_BlackPattern(self); ! textview_FillRect(self,&tempSrcRect, pat); } self->csyPos = by; self->csxPos = 0; --- 761,770 ---- else if ((self->csyPos - self->cshPos) < by) { if (! extendedTop) { /* Just moved into the border, so color it black */ ! rectangle_SetRectSize(&tempSrcRect, 0, 0, ! textview_GetLogicalWidth(self), by); pat = textview_BlackPattern(self); ! textview_FillRect(self, &tempSrcRect, pat); } self->csyPos = by; self->csxPos = 0; *************** *** 734,747 **** h += self->lines[lastLine].height; } ! textview_SetTransferMode(self, graphic_COPY); ! rectangle_SetRectSize(&tempSrcRect,0,sy,textview_GetLogicalWidth(self),h); ! point_SetPt(&tempDstOrigin,0,dy); ! textview_BitBlt(self,&tempSrcRect,self,&tempDstOrigin, (struct rectangle *) NULL); ! rectangle_SetRectSize(&tempSrcRect,0,0, textview_GetLogicalWidth(self),dy); pat = textview_WhitePattern(self); ! textview_FillRect(self,&tempSrcRect,pat); rectangle_SetRectSize(&tempSrcRect, 0, dy+h, textview_GetLogicalWidth(self), textview_GetLogicalHeight(self) - (dy + h)); pat = textview_WhitePattern(self); --- 799,813 ---- h += self->lines[lastLine].height; } ! textview_SetTransferMode(self, graphic_COPY); ! yoff = (sy < 0) ? sy : 0; /* clip */ ! rectangle_SetRectSize(&tempSrcRect, 0, sy - yoff, textview_GetLogicalWidth(self), h - yoff); ! point_SetPt(&tempDstOrigin, 0, dy - yoff); ! textview_BitBlt(self, &tempSrcRect, self, &tempDstOrigin, (struct rectangle *) NULL); ! rectangle_SetRectSize(&tempSrcRect, 0, 0, textview_GetLogicalWidth(self), (sy < 0) ? self->scrollDist : dy); pat = textview_WhitePattern(self); ! textview_FillRect(self, &tempSrcRect, pat); rectangle_SetRectSize(&tempSrcRect, 0, dy+h, textview_GetLogicalWidth(self), textview_GetLogicalHeight(self) - (dy + h)); pat = textview_WhitePattern(self); *************** *** 754,778 **** /* remove scrolled off views */ for(line = lastLine + 1; line < newLine ; line++) if(self->lines[line].containsView){ ! textview_ViewMove(self,&self->lines[line],textview_REMOVEVIEW); ! /* mark_SetModified(self->lines[line].data, TRUE); */ } ! for (newLine = self->nLines - 1, line = lastLine-1; line >= 0; line--, newLine--) { ! mark_SetPos(self->lines[newLine].data, mark_GetPos(self->lines[line].data)); ! mark_SetLength(self->lines[newLine].data, mark_GetLength(self->lines[line].data)); ! mark_SetStyle(self->lines[newLine].data, mark_IncludeBeginning(self->lines[line].data), mark_IncludeEnding(self->lines[line].data)); ! self->lines[newLine].nChars = self->lines[line].nChars; ! mark_SetModified(self->lines[newLine].data, FALSE); ! mark_SetObjectFree(self->lines[newLine].data, mark_ObjectFree(self->lines[line].data)); ! self->lines[newLine].y = self->lines[line].y + movement; ! self->lines[newLine].height = self->lines[line].height; ! self->lines[newLine].xMax = self->lines[line].xMax; ! self->lines[newLine].containsView = self->lines[line].containsView; ! if (self->lines[newLine].containsView) { ! /* Put code for moving inset here */ ! textview_ViewMove(self,&self->lines[newLine],movement); ! } } if (self->csxPos != BADCURPOS) { --- 820,830 ---- /* remove scrolled off views */ for(line = lastLine + 1; line < newLine ; line++) if(self->lines[line].containsView){ ! textview_ViewMove(self, &self->lines[line], textview_REMOVEVIEW); } ! for (newLine = self->nLines - 1, line = lastLine-1; line >= 0; line--, newLine--) { ! CopyLineInfo(self, &self->lines[newLine], &self->lines[line], movement); } if (self->csxPos != BADCURPOS) { *************** *** 826,856 **** } line = 0; while (line < self->nLines) { ! if(self->lines[line].containsView) ! textview_ViewMove(self,&self->lines[line],textview_REMOVEVIEW); mark_SetModified(self->lines[line++].data, TRUE); } textview_SetTransferMode(self, graphic_COPY); ! textview_GetVisualBounds(self,&tempSrcRect); pat = textview_WhitePattern(self); ! textview_FillRect(self,&tempSrcRect,pat); } cStart = mark_GetPos(self->dot); cEnd = cStart + mark_GetLength(self->dot); ! textview_SetTransferMode(self,graphic_COPY); csx = BADCURPOS; csy = BADCURPOS; cex = BADCURPOS; cey = BADCURPOS; csh = 0; csb = 0; ceh = 0; ceb = 0; ! ysleft=ys; ! zapRest=TRUE; line = 0; cont = 0; ! while (line < NLINES) { /* for each potential line on the screen */ EnsureSize(self, line); tl = &(self->lines[line]); tob = tl->data; --- 878,909 ---- } line = 0; while (line < self->nLines) { ! if(self->lines[line].containsView) { ! textview_ViewMove(self, &self->lines[line], textview_REMOVEVIEW); ! } mark_SetModified(self->lines[line++].data, TRUE); } textview_SetTransferMode(self, graphic_COPY); ! textview_GetVisualBounds(self, &tempSrcRect); pat = textview_WhitePattern(self); ! textview_FillRect(self, &tempSrcRect, pat); } cStart = mark_GetPos(self->dot); cEnd = cStart + mark_GetLength(self->dot); ! textview_SetTransferMode(self, graphic_COPY); csx = BADCURPOS; csy = BADCURPOS; cex = BADCURPOS; cey = BADCURPOS; csh = 0; csb = 0; ceh = 0; ceb = 0; ! ysleft = ys + self->pixelsReadyToBeOffTop; ! zapRest = TRUE; line = 0; cont = 0; ! while (line < NLINES) { /* for each potential line on the screen */ EnsureSize(self, line); tl = &(self->lines[line]); tob = tl->data; *************** *** 857,863 **** /* move next mark to follow last redisplayed line, if necessary this sets the modified flag on the mark iff a change was performed ! inline expansion of doc_makefollow(lob,tob) */ if (reformat && mark_GetPos(tob) != mark_GetPos(lob) + lobChars) { /* if(tl->containsView) --- 910,916 ---- /* move next mark to follow last redisplayed line, if necessary this sets the modified flag on the mark iff a change was performed ! inline expansion of doc_makefollow(lob, tob) */ if (reformat && mark_GetPos(tob) != mark_GetPos(lob) + lobChars) { /* if(tl->containsView) *************** *** 869,897 **** /* next check to see if the line must be redrawn */ ! if (reformat && ((cont && scrolling != textview_ScrollBackward) || line >= self->nLines || mark_GetModified(tob) || cury != tl->y || (scrolling == textview_ScrollBackward && line < self->scrollLine))) { ! /* zap cursor if need to */ ! if (cursorVisible && self->ceyPos >= cury && (! scrolling || (self->csxPos == self->cexPos && self->csyPos == self->ceyPos && self->ceyPos == self->lines[self->nLines - 1].y + self->lines[self->nLines - 1].height))) { XorCursor(self); cursorVisible = FALSE; } ! #if 1 ! height = textview_LineRedraw(self, textview_FullLineRedraw, tob, curx, cury, xs, ysleft, force, &cont,&textheight, &info); ! #else /* 1 */ ! height = textview_LineRedraw(self, textview_FullLineRedraw, tob, curx, cury, xs, ysleft, force, &cont,&tl->textheight, &info); ! #endif /* 1 */ tl->containsView = (info.foundView != NULL); tl->height = height; /* set the new length */ - #if 1 tl->textheight = textheight; ! #endif /* 1 */ ! tl->nChars = info.lineLength; ! tl->y = cury; ! ysleft -= height; ! mark_SetModified(tob,0); /* clear the mod flag */ ! } else { ysleft -= tl->height; cont = 0; --- 922,958 ---- /* next check to see if the line must be redrawn */ ! if (reformat && ! ((cont && scrolling != textview_ScrollBackward) ! || line >= self->nLines ! || mark_GetModified(tob) ! || cury != tl->y ! || (scrolling == textview_ScrollBackward ! && (line < self->scrollLine ! || (line == self->scrollLine ! && self->pixelsReadyToBeOffTop ! < self->pixelsShownOffTop))))) { ! /* zap cursor if need to */ ! if (cursorVisible && self->ceyPos >= cury && ! (! scrolling || (self->csxPos == self->cexPos && ! self->csyPos == self->ceyPos && ! self->ceyPos == self->lines[self->nLines - 1].y + ! self->lines[self->nLines - 1].height))) { XorCursor(self); cursorVisible = FALSE; } ! height = textview_LineRedraw(self, textview_FullLineRedraw, tob, curx, cury, xs, ysleft, force, &cont, &textheight, &info); tl->containsView = (info.foundView != NULL); tl->height = height; /* set the new length */ tl->textheight = textheight; ! tl->nChars = info.lineLength; ! tl->y = cury; ! ! ysleft -= height; ! mark_SetModified(tob,0); /* clear the mod flag */ ! } else { ysleft -= tl->height; cont = 0; *************** *** 1003,1009 **** mark_SetPos(self->frameDot, -1); /* prevent recursive loops */ t = textview_MoveBack(self, line, textview_GetLogicalHeight(self)/3, textview_MoveByPixels, 0, 0); /* our new top */ ! textview_SetTopPosition(self, t); /* adjust the frame */ } else mark_SetPos(self->frameDot, -1); } --- 1064,1070 ---- mark_SetPos(self->frameDot, -1); /* prevent recursive loops */ t = textview_MoveBack(self, line, textview_GetLogicalHeight(self)/3, textview_MoveByPixels, 0, 0); /* our new top */ ! textview_SetTopOffTop(self, t, self->pixelsComingOffTop); /* adjust the frame */ } else mark_SetPos(self->frameDot, -1); } *************** *** 1025,1030 **** --- 1086,1092 ---- textview_PostMenus(self, self->menus); } } + self->pixelsShownOffTop = self->pixelsReadyToBeOffTop; } void textview__FullUpdate(self, type, left, top, width, height) *************** *** 1175,1180 **** --- 1237,1247 ---- self->keystate->next = NULL; menulist_SetMask(self->menus, textview_NoMenus); textview_PostKeyState(self, self->keystate); + if ( self->editor == VI ) + if ( self->viMode == COMMAND ) + message_DisplayString(self, 0, "Command Mode"); + else + message_DisplayString(self, 0, "Input Mode"); textview_WantUpdate(self, self); } *************** *** 1230,1283 **** return mark_GetPos(self->top); } ! void textview__SetTopPosition(self, newTopPosition) struct textview *self; long newTopPosition; { long len; long curTop; ! ! if (newTopPosition < 0) ! newTopPosition = 0; else { ! if (newTopPosition > (len = text_GetLength(Text(self)))) ! newTopPosition = len; } ! if ((curTop = mark_GetPos(self->top)) != newTopPosition) { long line; ! mark_SetPos(self->top, newTopPosition); ! if (curTop < newTopPosition) { if (self->scroll != textview_ScrollBackward) { line = textview_FindLineNumber(self, newTopPosition); if (line != -1) { - if (line == 0) return; self->scroll = textview_ScrollForward; self->force = FALSE; ! self->scrollLine = line; } else { self->scroll = textview_NoScroll; ! self->force = TRUE; } } ! else ! self->scroll = textview_MultipleScroll; } ! else if (self->scroll != textview_ScrollForward) { if (self->scrollDist != -1) { self->scroll = textview_ScrollBackward; self->force = FALSE; } ! else { self->force = TRUE; self->scroll = textview_NoScroll; } } ! else ! self->scroll = textview_MultipleScroll; } if (self->scroll == textview_MultipleScroll) { self->force = TRUE; --- 1297,1359 ---- return mark_GetPos(self->top); } ! void textview__SetTopOffTop(self, newTopPosition, pixelsOffTop) struct textview *self; long newTopPosition; + long pixelsOffTop; { long len; long curTop; + long curPixel; ! if (newTopPosition < 0) { ! newTopPosition = 0; ! } else { ! if (newTopPosition > (len = text_GetLength(Text(self)))) { ! newTopPosition = len; ! } } ! if ((curTop = mark_GetPos(self->top)) != newTopPosition || pixelsOffTop != self->pixelsReadyToBeOffTop) { long line; ! if (curTop != newTopPosition) { ! mark_SetPos(self->top, newTopPosition); ! } ! curPixel = self->pixelsReadyToBeOffTop; ! self->pixelsReadyToBeOffTop = pixelsOffTop; ! ! if (curTop < newTopPosition || ((curTop == newTopPosition) && (curPixel < pixelsOffTop))) { if (self->scroll != textview_ScrollBackward) { line = textview_FindLineNumber(self, newTopPosition); if (line != -1) { self->scroll = textview_ScrollForward; self->force = FALSE; ! self->scrollLine = line; } else { self->scroll = textview_NoScroll; ! self->force = TRUE; } } ! else { ! self->scroll = textview_MultipleScroll; ! } } ! else if (self->scroll != textview_ScrollForward) { if (self->scrollDist != -1) { self->scroll = textview_ScrollBackward; self->force = FALSE; } ! else { self->force = TRUE; self->scroll = textview_NoScroll; } } ! else { ! self->scroll = textview_MultipleScroll; ! } } if (self->scroll == textview_MultipleScroll) { self->force = TRUE; *************** *** 1285,1290 **** --- 1361,1373 ---- textview_WantUpdate(self, self); } + void textview__SetTopPosition(self, newTopPosition) + struct textview *self; + long newTopPosition; + { + textview_SetTopOffTop(self, newTopPosition, 0); + } + void textview__SetBorder(self, xBorder, yBorder) struct textview *self; long xBorder; *************** *** 1307,1313 **** /* Have to do some update here for resetting the border. */ } ! void textview__CollapseDot(self) struct textview *self; { long pos; --- 1390,1396 ---- /* Have to do some update here for resetting the border. */ } ! long textview__CollapseDot(self) struct textview *self; { long pos; *************** *** 1316,1321 **** --- 1399,1405 ---- mark_SetPos(self->dot, pos); mark_SetLength(self->dot, 0); textview_WantUpdate(self, self); + return pos; } void textview__GetClickPosition(self, position, numberOfClicks, action, startLeft, startRight, leftPos, rightPos) *************** *** 1329,1334 **** --- 1413,1419 ---- long *rightPos; { register int pos; + register int testType; struct text *text = Text(self); register int textLength = text_GetLength(text); int extEnd; *************** *** 1343,1362 **** case 2: /* Double Click - word select */ ! if (position < textLength && isalnum(text_GetChar(text,position)) != 0) { /* Inside a word */ pos = position - 1; ! for (pos = position - 1; pos >= 0 && isalnum(text_GetChar(text,pos)) != 0; pos--); *leftPos = ++pos; ! for (pos = position + 1; pos < textLength && isalnum(text_GetChar(text, pos)) != 0; pos++); *rightPos = pos; } ! else if (position > 0 && isalnum(text_GetChar(text, position - 1)) != 0) { /* Right of Word */ *rightPos = position; ! for (pos = position - 1; pos >= 0 && isalnum(text_GetChar(text, pos)) != 0; pos--); *leftPos = pos + 1; } else { --- 1428,1447 ---- case 2: /* Double Click - word select */ ! if (position < textLength && (testType = charType(text_GetChar(text,position))) != WHITESPACE) { /* Inside a word */ pos = position - 1; ! for (pos = position - 1; pos >= 0 && charType(text_GetChar(text,pos)) == testType; pos--); *leftPos = ++pos; ! for (pos = position + 1; pos < textLength && charType(text_GetChar(text, pos)) == testType; pos++); *rightPos = pos; } ! else if (position > 0 && (testType = charType(text_GetChar(text, position - 1))) != WHITESPACE) { /* Right of Word */ *rightPos = position; ! for (pos = position - 1; pos >= 0 && charType(text_GetChar(text, pos)) == testType; pos--); *leftPos = pos + 1; } else { *************** *** 1367,1378 **** } else { if (position <= startLeft) { ! for (pos = position + 1; pos < textLength && isalnum(text_GetChar(text, pos)) == 0; pos++); for (pos -= 1; pos >= 0 && isspace(text_GetChar(text, pos)) == 0; pos--); pos += 1; } else { ! for (pos = position - 1; pos >= 0 && isalnum(text_GetChar(text, pos)) == 0; pos--); for (pos += 1; pos < textLength && isspace(text_GetChar(text, pos)) == 0; pos++); } *rightPos = *leftPos = pos; --- 1452,1463 ---- } else { if (position <= startLeft) { ! for (pos = position + 1; pos < textLength && charType(text_GetChar(text, pos)) != WORD; pos++); for (pos -= 1; pos >= 0 && isspace(text_GetChar(text, pos)) == 0; pos--); pos += 1; } else { ! for (pos = position - 1; pos >= 0 && charType(text_GetChar(text, pos)) != WORD; pos--); for (pos += 1; pos < textLength && isspace(text_GetChar(text, pos)) == 0; pos++); } *rightPos = *leftPos = pos; *************** *** 1387,1396 **** if (position < textLength && text_GetChar(text,position) != '\n') { /* Inside a paragraph */ ! pos = position - 1; ! for (pos = position - 1; pos >= 0 && text_GetChar(text,pos) != '\n'; pos--); ! *leftPos = ++pos; ! for (pos = position + 1; pos < textLength && text_GetChar(text,pos) != '\n'; pos++); *rightPos = (extEnd && pos < textLength) ? pos + 1 : pos; } else if (position > 0 && text_GetChar(text,position - 1) != '\n') { --- 1472,1479 ---- if (position < textLength && text_GetChar(text,position) != '\n') { /* Inside a paragraph */ ! *leftPos = text_GetBeginningOfLine(text, position - 1); ! pos = text_GetEndOfLine(text, position + 1); *rightPos = (extEnd && pos < textLength) ? pos + 1 : pos; } else if (position > 0 && text_GetChar(text,position - 1) != '\n') { *************** *** 1397,1404 **** /* Right of a paragraph */ *rightPos = (extEnd && position < textLength) ? position + 1 : position; ! for (pos = position - 1; pos >= 0 && text_GetChar(text, pos) != '\n'; pos--); ! *leftPos = pos + 1; } else { /* Between two new lines */ --- 1480,1486 ---- /* Right of a paragraph */ *rightPos = (extEnd && position < textLength) ? position + 1 : position; ! *leftPos = text_GetBeginningOfLine(text, position - 1); } else { /* Between two new lines */ *************** *** 1418,1425 **** register long len = self->displayLength; register long endMark; ! if (self->nLines <= 0 || pos < mark_GetPos(self->top) || (pos == mark_GetPos(self->top) && ((pos != 0) && (text_GetChar(Text(self), pos - 1)) != '\n'))) return FALSE; lineMark = self->lines[self->nLines - 1].data; if (pos < (endMark = mark_GetPos(lineMark) + self->lines[self->nLines-1].nChars)) return TRUE; --- 1500,1508 ---- register long len = self->displayLength; register long endMark; ! if (self->nLines <= 0 || pos < mark_GetPos(self->top)) { return FALSE; + } lineMark = self->lines[self->nLines - 1].data; if (pos < (endMark = mark_GetPos(lineMark) + self->lines[self->nLines-1].nChars)) return TRUE; *************** *** 1457,1463 **** for (i = 0; i < end ; i++) { if (y >= self->lines[i].y && y < self->lines[i].y + self->lines[i].height) { ! pos = textview_LineRedraw(self, textview_GetPosition, self->lines[i].data, bx, by, textview_GetLogicalWidth(self) - 2 * bx, textview_GetLogicalHeight(self) - 2 * by, x, NULL,NULL, &info); if (foundView) *foundView = info.foundView; return pos; --- 1540,1546 ---- for (i = 0; i < end ; i++) { if (y >= self->lines[i].y && y < self->lines[i].y + self->lines[i].height) { ! pos = textview_LineRedraw(self, textview_GetPosition, self->lines[i].data, bx, by, textview_GetLogicalWidth(self) - 2 * bx, textview_GetLogicalHeight(self) - 2 * by, x, NULL, NULL, &info); if (foundView) *foundView = info.foundView; return pos; *************** *** 1484,1490 **** *height = textview_GetLogicalHeight(self) - 2 * by; } ! long textview__MoveBack(self, pos, units, type, distMoved, linesAdded) struct textview *self; long pos; long units; --- 1567,1668 ---- *height = textview_GetLogicalHeight(self) - 2 * by; } ! static long CalculateBltToTop(self, pos, distMoved, linesAdded) ! struct textview *self; ! long pos; ! long *distMoved; ! long *linesAdded; ! { ! struct mark *tm; ! struct text *text = Text(self); ! long textLength = text_GetLength(text); ! long vxs, vys, length; ! long height, tpos; ! register int tp; ! struct formattinginfo info; ! ! textview_GetTextSize(self, &vxs, &vys); ! tm = mark_New(); ! tpos = textview_GetTopPosition(self); ! ! if (pos > textLength) { ! pos = textLength; ! } ! ! for (tp = pos-1; tp >= 0; tp--) { ! unsigned char c = text_GetChar(text,tp); ! ! if (c == '\n'|| c == '\r') { ! break; ! } ! } ! ! /* tp is -1 if paragraph starts document */ ! ! tp++; /* skip forward to first char in paragraph */ ! ! while (TRUE) { /* scan lines in the paragraph */ ! mark_SetPos(tm, tp); /* start mark at paragraph start */ ! height = textview_LineRedraw(self, textview_GetHeight, tm, 0, 0, vxs, vys, 0, NULL, NULL, &info); ! length = info.lineLength; ! ! /* handle stopping prematurely at end of file, instead of at a newline */ ! ! if (tp+length == textLength && text_GetChar(text, textLength-1) != '\n') length++; ! ! if (pos == tp || (pos >= tp && pos < tp+length)) { ! /* we've stumbled over pos again */ ! long accumHeight = height; ! long numLines = 1; ! long newTop = tp; ! ! while (TRUE) { ! tp += length; ! mark_SetPos(tm,tp); /* start mark at paragraph start */ ! height = textview_LineRedraw(self, textview_GetHeight, tm, 0, 0, vxs, vys, 0, NULL,NULL, &info); ! length = info.lineLength; ! if (tp+length == textLength && text_GetChar(text, textLength-1) != '\n') length ++; ! if (tpos == tp || (tpos >= tp && tpos < tp+length)) { ! if (distMoved != NULL) { ! *distMoved = accumHeight + self->pixelsReadyToBeOffTop; ! } ! if (linesAdded != NULL) { ! *linesAdded = numLines; ! } ! mark_Destroy(tm); ! return newTop; ! } ! ! accumHeight += height; ! numLines++; ! ! if (accumHeight >= vys) { ! if (distMoved != NULL) { ! *distMoved = -1; ! } ! if (linesAdded != NULL) { ! *linesAdded = -1; ! } ! mark_Destroy(tm); ! return newTop; ! } ! } ! } ! tp += length; ! } ! } ! ! #define PSEUDOLINEHEIGHT 24 ! #define VIEWTOOSMALL 36 ! #define PLines(height) (((height) == 0) ? 0 : (((height) <= VIEWTOOSMALL) ? 1 : \ ! ((height) + PSEUDOLINEHEIGHT - 1) / PSEUDOLINEHEIGHT)) ! ! /* ! Return the pos that would be at the top of the screen ! if we were to move pos down by units. ! */ ! ! static long BackSpace(self, pos, units, type, distMoved, linesAdded) struct textview *self; long pos; long units; *************** *** 1495,1637 **** struct mark *tm; long lastn [MAXPARA]; long posn[MAXPARA]; struct text *text = Text(self); long textLength = text_GetLength(text); long pp, vxs, vys, length; ! long totalHeight, height, accumHeight, numLines, tpos, spos, newTop; register int tp, px; struct formattinginfo info; ! if (units < 0) return pos; ! ! accumHeight = 0; ! numLines = 0; textview_GetTextSize(self, &vxs, &vys); tm=mark_New(); - tpos = textview_GetTopPosition(self); - spos = pos; pp = pos; ! for (;;) { /* first move tp back to start of paragraph */ ! if (pp > 0) { ! tp = pp-1; ! while (tp >= 0 && text_GetChar(text,tp) != '\012') tp = tp-1; } ! else tp = -1; ! ! /* tp is -1 if paragraph starts document */ tp++; /* skip forward to first char in paragraph */ pp = tp; /* remember paragraph start */ px = 0; totalHeight = 0; ! while (px < MAXPARA) { /* scan lines in the paragraph */ lastn[px] = tp; ! posn[px] = totalHeight; ! mark_SetPos(tm,tp); /* start mark at paragraph start */ ! height = textview_LineRedraw(self, textview_GetHeight, tm, 0, 0, vxs, vys, 0, NULL,NULL, &info); length = info.lineLength; /* handle stopping prematurely at end of file, instead of at a newline */ ! if (tp+length == textLength && text_GetChar(text, textLength-1) != '\012') length ++; ! if (pos == tp || (pos >= tp && pos < tp+length)) { /* we've stumbled over pos again */ ! if (spos < tpos) { ! /* Thumbing backwards */ ! accumHeight = height; ! numLines = 1; ! newTop = tp; ! while (1) { ! tp += length; ! mark_SetPos(tm,tp); /* start mark at paragraph start */ ! height = textview_LineRedraw(self, textview_GetHeight, tm, 0, 0, vxs, vys, 0, NULL,NULL, &info); ! length = info.lineLength; ! if (tp+length == textLength && text_GetChar(text, textLength-1) != '\012') length ++; ! if (tpos == tp || (tpos >= tp && tpos < tp+length)) { ! if (distMoved != NULL) { ! *distMoved = accumHeight; ! } ! if (linesAdded != NULL) { ! *linesAdded = numLines; ! } ! return newTop; ! } ! ! accumHeight += height; ! numLines++; ! ! if (accumHeight >= vys) { ! if (distMoved != NULL) { ! *distMoved = -1; ! } ! if (linesAdded != NULL) { ! *linesAdded = -1; ! } ! ! return newTop; ! } ! } ! } ! ! if (type == textview_MoveByLines) { if (units <= px) { mark_Destroy(tm); ! if (distMoved) *distMoved = accumHeight + totalHeight - posn[px-units]; ! if (linesAdded) *linesAdded = numLines - (px - units); return lastn[px-units]; } else break; ! } ! else { ! if (units <= totalHeight + height) { ! register int i; mark_Destroy(tm); ! for (i = 0; i <= px && totalHeight + height - posn[i] >= units; i++); ! if (distMoved) ! *distMoved = accumHeight + totalHeight - posn[i-1]; ! if (linesAdded) ! *linesAdded = numLines - (i - 1); return lastn[i-1]; } else break; } ! } if (tp >= textLength) break; tp += length; totalHeight += height; numLines++; ! px++; ! } ! /* here we've moved back px lines, but still haven't made it ! move back one more paragraph and try again */ accumHeight += totalHeight; if (pp <= 0) { mark_Destroy(tm); ! if (distMoved) ! *distMoved = accumHeight; ! if (linesAdded) ! *linesAdded = numLines; return 0; /* can't go any farther */ } ! if (type == textview_MoveByLines) ! units -= px; ! else ! units -= totalHeight; pos = pp; pp--; /* looking at LF that terminated preceding para */ } } long textview__MoveForward(self, pos, units, type, distMoved, linesAdded) struct textview *self; long pos; --- 1673,1905 ---- struct mark *tm; long lastn [MAXPARA]; long posn[MAXPARA]; + long pseudo[MAXPARA]; struct text *text = Text(self); long textLength = text_GetLength(text); long pp, vxs, vys, length; ! long totalHeight, height, accumHeight, numLines; ! long pseudoLines; ! long plines; register int tp, px; struct formattinginfo info; + long ounits = units; ! if (type == textview_MoveByPseudoLines) { ! units -= PLines(self->pixelsReadyToBeOffTop); ! if (units <= 0) { ! self->pixelsComingOffTop = self->pixelsReadyToBeOffTop - ounits * PSEUDOLINEHEIGHT; ! if (self->pixelsComingOffTop < PSEUDOLINEHEIGHT / 2) { ! self->pixelsComingOffTop = 0; ! } ! if (distMoved) { ! *distMoved = self->pixelsReadyToBeOffTop - self->pixelsComingOffTop; ! } ! if (linesAdded) { ! *linesAdded = 0; ! } ! return pos; ! } ! } ! ! if (type == textview_MoveByPixels) { ! units -= self->pixelsReadyToBeOffTop; ! if (units <= 0) { ! self->pixelsComingOffTop = self->pixelsReadyToBeOffTop - ounits; ! if (distMoved) { ! *distMoved = self->pixelsReadyToBeOffTop - self->pixelsComingOffTop; ! } ! if (linesAdded) { ! *linesAdded = 0; ! } ! return pos; ! } ! } ! ! self->pixelsComingOffTop = 0; ! accumHeight = -self->pixelsReadyToBeOffTop; ! textview_GetTextSize(self, &vxs, &vys); tm=mark_New(); pp = pos; ! numLines = 0; ! ! for (;;) { ! /* first move tp back to start of paragraph */ + if (pp > 0) { + for (tp = pp-1; tp >= 0; tp--) { + unsigned char c = text_GetChar(text, tp); ! if (c == '\n' || c == '\r') { ! break; ! } ! } } ! else tp = -1; /* tp is -1 if paragraph starts document */ tp++; /* skip forward to first char in paragraph */ pp = tp; /* remember paragraph start */ px = 0; totalHeight = 0; ! pseudoLines = 0; ! while (px < MAXPARA) { /* scan lines in the paragraph */ lastn[px] = tp; ! posn[px] = totalHeight; ! pseudo[px] = pseudoLines; ! mark_SetPos(tm, tp); /* start mark at paragraph start */ ! height = textview_LineRedraw(self, textview_GetHeight, tm, 0, 0, vxs, vys, 0, NULL, NULL, &info); length = info.lineLength; + plines = PLines(height); /* handle stopping prematurely at end of file, instead of at a newline */ ! if (tp+length == textLength && text_GetChar(text, textLength-1) != '\012') length++; ! if (pos == tp || (pos >= tp && pos < tp+length)) { /* we've stumbled over pos again */ ! if (type == textview_MoveByLines) { if (units <= px) { mark_Destroy(tm); ! if (distMoved) { *distMoved = accumHeight + totalHeight - posn[px-units]; ! } ! if (linesAdded) { *linesAdded = numLines - (px - units); + } return lastn[px-units]; } else break; ! } ! else if (type == textview_MoveByPseudoLines) { ! if (units <= pseudoLines) { ! int i; ! ! mark_Destroy(tm); ! ! for (i = 0; (i <= px) && (pseudoLines - pseudo[i] >= units); i++) { ! } ! ! self->pixelsComingOffTop = (pseudoLines - pseudo[i-1] - units) * PSEUDOLINEHEIGHT; ! ! if (distMoved) { ! *distMoved = accumHeight + totalHeight - posn[i-1] - self->pixelsComingOffTop; ! } ! if (linesAdded) { ! *linesAdded = numLines - (i-1); ! } ! return lastn[i-1]; ! } ! else break; ! } ! else { /* textview_MoveByPixels */ ! if (units <= totalHeight) { ! int i; mark_Destroy(tm); ! for (i = 0; (i <= px) && (totalHeight - posn[i] >= units); i++) { ! } ! self->pixelsComingOffTop = totalHeight - posn[i-1] - units; ! if (self->pixelsComingOffTop < PSEUDOLINEHEIGHT) { ! self->pixelsComingOffTop = 0; ! } ! if (distMoved) { ! *distMoved = accumHeight + totalHeight - posn[i-1] - self->pixelsComingOffTop; ! } ! if (linesAdded) { ! *linesAdded = numLines - (i-1); ! } return lastn[i-1]; } else break; } ! } if (tp >= textLength) break; tp += length; totalHeight += height; numLines++; ! px++; ! pseudoLines += plines; ! } ! /* ! Here we've moved back px lines, but still haven't made it. ! Move back one more paragraph and try again. ! */ accumHeight += totalHeight; if (pp <= 0) { mark_Destroy(tm); ! if (distMoved) { ! *distMoved = accumHeight; ! } ! if (linesAdded) { ! *linesAdded = numLines; ! } return 0; /* can't go any farther */ } ! if (type == textview_MoveByLines) { ! units -= px; ! } ! else if (type == textview_MoveByPseudoLines) { ! units -= pseudoLines; ! } ! else { ! units -= totalHeight; ! } pos = pp; pp--; /* looking at LF that terminated preceding para */ } } + long textview__MoveBack(self, pos, units, type, distMoved, linesAdded) + struct textview *self; + long pos; + long units; + enum textview_MovementUnits type; + long *distMoved; + long *linesAdded; + { + long accumHeight = 0; + long numLines = 0; + long newPos; + + if (units < 0) return pos; + + if (pos < textview_GetTopPosition(self)) { + /* Get the distance that we need to blt in order to move + pos to the top of the view. This only needs to be + calculated when we are above the top position. */ + + pos = CalculateBltToTop(self, pos, &accumHeight, &numLines); + } + + /* Now determine how much space we need to add in if we want to move + pos down by units */ + + newPos = BackSpace(self, pos, units, type, distMoved, linesAdded); + + if (distMoved) { + if (accumHeight >= 0) { + *distMoved += accumHeight; + } + else { + *distMoved = -1; + } + } + if (linesAdded) { + if (accumHeight >= 0) { + *linesAdded += numLines; + } + else { + *linesAdded = -1; + } + } + + return newPos; + } + long textview__MoveForward(self, pos, units, type, distMoved, linesAdded) struct textview *self; long pos; *************** *** 1641,1664 **** long *linesAdded; { struct mark *tm; ! long vxs, vys, length; register int i; struct formattinginfo info; if (units < 0) return pos; tm = mark_New(); textview_GetTextSize(self, &vxs, &vys); ! i=0; ! while (ipixelsComingOffTop = self->pixelsReadyToBeOffTop; ! if (type == textview_MoveByPixels) { ! i = -self->pixelsReadyToBeOffTop; ! } ! else { ! i = 0; ! } ! ! while (i < units) { ! mark_SetPos(tm, pos); ! viewHeight = textview_LineRedraw(self, textview_GetHeight, tm, 0, 0, vxs, vys, 0, NULL, NULL, &info); ! if (type == textview_MoveByPseudoLines && viewHeight > VIEWTOOSMALL) { ! long pixelsLeft = viewHeight - self->pixelsComingOffTop; ! long pseudoLines = (pixelsLeft + PSEUDOLINEHEIGHT - 1) / PSEUDOLINEHEIGHT; ! ! if (pos + info.lineLength == textlen && pixelsLeft <= VIEWTOOSMALL) { ! break; /* there's nothing left; give up */ ! } ! ! if (pseudoLines <= units - i) { ! /* gobble up the whole line, and keep going */ ! pos += info.lineLength; ! i += pseudoLines; ! self->pixelsComingOffTop = 0; ! } ! else { ! /* take what we need and stop */ ! self->pixelsComingOffTop += (pixelsLeft / pseudoLines) * (units - i); ! break; ! } ! } ! else if (type == textview_MoveByPixels) { ! if (viewHeight < VIEWTOOSMALL || viewHeight <= units - i) { ! pos += info.lineLength; ! i += viewHeight; ! self->pixelsComingOffTop = 0; ! if (pos == textlen) break; ! } ! else { ! self->pixelsComingOffTop += units - i; ! break; ! } ! } ! else { ! pos += info.lineLength; ! i++; ! self->pixelsComingOffTop = 0; ! if (pos == textlen) break; ! } } mark_Destroy(tm); return pos; } + #define DEFAULTHEIGHT 20 static int CalculateLineHeight(self) struct textview *self; *************** *** 1681,1686 **** --- 1994,2000 ---- return DEFAULTHEIGHT; return fontSummary->maxHeight + by + by; } + #define MAXWIDTH 1024 #define MINWIDTH 125 #define UNLIMITED 3000000 *************** *** 1816,1835 **** return -1; } static void getinfo(self, total, seen, dot) ! struct textview *self; ! struct range *total, *seen, *dot; { total->beg = 0; ! total->end = text_GetLength(Text(self)); ! seen->beg = textview_GetTopPosition(self); ! if (self->nLines != 0) ! seen->end = mark_GetPos(self->lines[self->nLines - 1].data) + self->lines[self->nLines - 1].nChars; ! else ! seen->end = 0; ! dot->beg = textview_GetDotPosition(self); ! dot->end = dot->beg + textview_GetDotLength(self); } static long whatisat(self, numerator, denominator) --- 2130,2196 ---- return -1; } + static long position(pos, theline, coord) + long pos; + struct linedesc *theline; + long coord; + { + long off; + + if (theline == NULL || !theline->containsView) { + off = 0; + } + else { + off = coord - theline->y; + } + + /* with FINEGRID at 12, this will break with + views taller than 1524 pixels */ + off = (off + FINEGRID/2) / FINEGRID; + + /* off has to fit in 7 bits */ + if (off > FINEMASK) { + off = FINEMASK; + } + + return (pos << FINESCROLL) + off; + } + static void getinfo(self, total, seen, dot) ! struct textview *self; ! struct range *total, *seen, *dot; { + struct linedesc *last; + long lastpos; + long lastcoord; + long tl = text_GetLength(Text(self)); total->beg = 0; ! total->end = (tl << FINESCROLL); ! ! if (self->nLines > 0) { ! seen->beg = position(textview_GetTopPosition(self), &self->lines[0], 0); ! last = &self->lines[self->nLines - 1]; ! lastpos = mark_GetPos(last->data); ! if (textview_GetLogicalHeight(self) >= last->y + last->height) { ! lastcoord = last->y; ! lastpos += last->nChars; ! if (lastpos > tl) { ! lastpos = tl; ! } ! } ! else { ! lastcoord = textview_GetLogicalHeight(self); ! } ! seen->end = position(lastpos, last, lastcoord); ! } ! else { ! seen->beg = (textview_GetTopPosition(self) << FINESCROLL); ! seen->end = seen->beg; ! } ! ! dot->beg = (textview_GetDotPosition(self) << FINESCROLL); ! dot->end = dot->beg + (textview_GetDotLength(self) << FINESCROLL); } static long whatisat(self, numerator, denominator) *************** *** 1836,1850 **** struct textview *self; long numerator, denominator; { - long coord; coord = numerator * textview_GetLogicalHeight(self); coord /= denominator; ! return textview_Locate(self, 0, coord, NULL); } static void setframe(self, position, numerator, denominator) struct textview *self; long position, numerator, denominator; --- 2197,2217 ---- struct textview *self; long numerator, denominator; { long coord; + long pos; + long linenum; coord = numerator * textview_GetLogicalHeight(self); coord /= denominator; ! pos = textview_Locate(self, 0, coord, NULL); ! linenum = textview_FindLineNumber(self, pos); ! ! return position(pos, (linenum >= 0) ? &self->lines[linenum] : NULL, coord); } + /* move the text at position to be on screen at numerator/denominator */ + static void setframe(self, position, numerator, denominator) struct textview *self; long position, numerator, denominator; *************** *** 1851,1861 **** { long dist, lines, coord; long newpos; coord = numerator * textview_GetLogicalHeight(self); coord /= denominator; ! newpos = textview_MoveBack(self, position, coord, textview_MoveByPixels, &dist, &lines); if (newpos < textview_GetTopPosition(self) && self->scroll != textview_ScrollForward && self->scroll != textview_MultipleScroll) { if (dist == -1) { self->scrollDist = -1; --- 2218,2237 ---- { long dist, lines, coord; long newpos; + long off; + boolean forceup = FALSE; coord = numerator * textview_GetLogicalHeight(self); coord /= denominator; ! off = (position & FINEMASK) * FINEGRID; ! position >>= FINESCROLL; ! ! newpos = textview_MoveBack(self, position, 0, textview_MoveByLines, 0, 0); ! if (newpos != position) { ! forceup = TRUE; ! } ! newpos = textview_MoveBack(self, newpos, coord, textview_MoveByPixels, &dist, &lines); if (newpos < textview_GetTopPosition(self) && self->scroll != textview_ScrollForward && self->scroll != textview_MultipleScroll) { if (dist == -1) { self->scrollDist = -1; *************** *** 1873,1879 **** self->scrollLine += lines; } } ! textview_SetTopPosition(self, newpos); } char *textview__GetInterface(self, interfaceName) --- 2249,2284 ---- self->scrollLine += lines; } } ! if (numerator != 0) { ! off = self->pixelsComingOffTop; ! } ! else { ! if (off != 0) { ! long line = textview_FindLineNumber(self, newpos); ! long height; ! ! if (line >= 0) { ! height = self->lines[line].height; ! } ! else { ! struct mark *tm = mark_New(); ! long vxs, vys; ! struct formattinginfo info; ! ! mark_SetPos(tm, newpos); ! textview_GetTextSize(self, &vxs, &vys); ! height = textview_LineRedraw(self, textview_GetHeight, tm, 0, 0, vxs, vys, 0, NULL, NULL, &info); ! } ! ! if (height < VIEWTOOSMALL) { ! off = 0; ! } ! else if (forceup || off > height) { ! off = height; ! } ! } ! } ! textview_SetTopOffTop(self, newpos, off); } char *textview__GetInterface(self, interfaceName) *************** *** 1889,1900 **** boolean textview__InitializeClass(classID) struct classheader *classID; { ! extern struct keymap *textview_InitKeyMap(); ! ! textviewKeymap = textview_InitKeyMap(&textview_classinfo, &viewMenus); initialExposeStyles = environ_GetProfileSwitch("ExposeStylesOnStartup", FALSE); ! alwaysDisplayStyleMenus = environ_GetProfileSwitch("AlwaysDisplayStyleMenus", FALSE); InitializeMod(); return TRUE; --- 2294,2310 ---- boolean textview__InitializeClass(classID) struct classheader *classID; { ! extern struct keymap *textview_InitEmacsKeyMap(); ! extern struct keymap *textview_InitViInputModeKeyMap(); ! extern struct keymap *textview_InitViCommandModeKeyMap(); ! ! /* these init functions should be called in this specific order */ ! textviewEmacsKeymap = textview_InitEmacsKeyMap(&textview_classinfo, &viewMenus); ! textviewViCommandModeKeymap = textview_InitViCommandModeKeyMap(&textview_classinfo, NULL); ! textviewViInputModeKeymap = textview_InitViInputModeKeyMap(&textview_classinfo, NULL); initialExposeStyles = environ_GetProfileSwitch("ExposeStylesOnStartup", FALSE); ! alwaysDisplayStyleMenus = environ_GetProfileSwitch("AlwaysDisplayStyleMenus", TRUE); InitializeMod(); return TRUE; *************** *** 2023,2025 **** --- 2433,2468 ---- { } + /* functions added to support VI interface - FAS */ + + void textview__ToggleVIMode(self) + struct textview *self; + { + /* switch between VI input/command mode */ + + self->viMode = self->viMode ^ 1; + if ( self->viMode == COMMAND ) + self->keystate = self->viCommandModeKeystate; + else + self->keystate = self->viInputModeKeystate; + textview_ReceiveInputFocus(self); + } + + void textview__ToggleEditor(self) + struct textview *self; + { + /* switch between emacs and vi editors */ + self->editor = self->editor ^ 1; + if ( self->editor == EMACS ) + { + self->keystate = self->emacsKeystate; + message_DisplayString(self, 0, "EMACS interface in effect."); + } + else + { + self->keystate = self->viCommandModeKeystate; + self->viMode = COMMAND; + message_DisplayString(self, 0, "VI interface in effect."); + } + textview_ReceiveInputFocus(self); + } *** atk/text/textv.ch Fri Dec 21 14:59:10 1990 --- atk/text/textv.ch.NEW Mon Feb 18 18:02:48 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/text/RCS/textv.ch,v 2.11 90/10/11 12:15:54 ajp Exp Locker: ajp $ */ /* $ACIS:textv.ch 1.7$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/text/RCS/textv.ch,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsidtextview_H = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/text/RCS/textv.ch,v 2.11 90/10/11 12:15:54 ajp Exp Locker: ajp $"; #endif /* !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) */ #define textview_VERSION 1 --- 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/text/RCS/textv.ch,v 2.14 91/02/18 17:45:28 dba Exp $ */ /* $ACIS:textv.ch 1.7$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/text/RCS/textv.ch,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsidtextview_H = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/text/RCS/textv.ch,v 2.14 91/02/18 17:45:28 dba Exp $"; #endif /* !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) */ #define textview_VERSION 1 *************** *** 14,20 **** enum textview_MovementUnits { textview_MoveByPixels, ! textview_MoveByLines }; enum textview_ScrollDirection { --- 14,21 ---- enum textview_MovementUnits { textview_MoveByPixels, ! textview_MoveByLines, ! textview_MoveByPseudoLines }; enum textview_ScrollDirection { *************** *** 96,102 **** SetTopPosition(long newTopPosition); SetBorder(long xBorder, long yBorder); SetEmbeddedBorder(long xBorder, long yBorder); ! CollapseDot(); GetClickPosition(long position, long numberOfClicks, enum view_MouseAction action, long startLeft, long startRight, long *leftPos, long *rightPos); Visible(long pos) returns boolean; Locate(long x, long y, struct view **view) returns long; --- 97,103 ---- SetTopPosition(long newTopPosition); SetBorder(long xBorder, long yBorder); SetEmbeddedBorder(long xBorder, long yBorder); ! CollapseDot() returns long; GetClickPosition(long position, long numberOfClicks, enum view_MouseAction action, long startLeft, long startRight, long *leftPos, long *rightPos); Visible(long pos) returns boolean; Locate(long x, long y, struct view **view) returns long; *************** *** 118,124 **** FinishDeletion(); DeleteCharacters(long pos, long len); ! PrepareInsertion(); FinishInsertion(); GetEnclosingEnvironment(long pos) returns struct environment *; --- 119,125 ---- FinishDeletion(); DeleteCharacters(long pos, long len); ! PrepareInsertion(boolean insertingNewLine); FinishInsertion(); GetEnclosingEnvironment(long pos) returns struct environment *; *************** *** 134,139 **** --- 135,153 ---- LeftInsertEnvironment(); RightInsertEnvironment(); + DoCopyRegion(long pos, long len, boolean append, boolean copyAsText); + + ToggleVIMode(); /* toggle input/command modes for vi editor FAS */ + ToggleEditor(); /* toggle between editors (vi/emacs) FAS */ + + SetTopOffTop(long newTopPosition, long pixelsOffTop); + + macromethods: + GetEditor() (self->editor) + GetVIMode() (self->viMode) + EncodePosition(pos) ((pos) << 7) + DecodePosition(pos) ((pos) >> 7) + classprocedures: FinalizeObject(struct textview *self); InitializeClass() returns boolean; *************** *** 179,189 **** long tabWidth; boolean exposeStyles; long predrawnY,predrawnX; ! struct mark *predrawn; /* text preceding the dot that may avoid redrawing */ ! struct mark *prepredrawn; /* text preceeding predrawn that may avoid redrawing, ! used if the predrawn mark is modified */ struct environment *insertEnvironment; struct mark *insertEnvMark; struct InsertStack *insertStack; ! }; --- 193,230 ---- long tabWidth; boolean exposeStyles; long predrawnY,predrawnX; ! struct mark *predrawn; /* text preceding the dot that may avoid redrawing */ ! struct mark *prepredrawn; /* text preceeding predrawn that may avoid redrawing, ! used if the predrawn mark is modified */ ! ! int editor; /* 0->emacs, 1->vi */ ! int viMode; /* 0->command, 1->input */ ! struct keystate *emacsKeystate; ! struct keystate *viInputModeKeystate; ! struct keystate *viCommandModeKeystate; ! struct environment *insertEnvironment; struct mark *insertEnvMark; struct InsertStack *insertStack; ! ! /* The next two params are to get tabs looking correct. Good values are ! * Andy12 = Adobe14 -> Mul = 14, Div = 12 -njw. ! */ ! int ScreenScaleMul; ! int ScreenScaleDiv; ! ! /* These three are used to keep track of insets that are partially ! * scrolled off the top of the view. -dba. ! */ ! int pixelsShownOffTop; ! int pixelsReadyToBeOffTop; ! int pixelsComingOffTop; ! }; ! ! #define EMACS 0 ! #define VI 1 ! ! /* VI mode values FAS */ ! #define COMMAND 0 ! #define INPUT 1 *** atk/text/tindex.c Wed Sep 26 16:08:22 1990 --- atk/text/tindex.c.NEW Wed Feb 13 16:54: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/text/RCS/tindex.c,v 1.6 90/08/23 11:44:11 ajp Exp $ */ /* $ACIS:$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/text/RCS/tindex.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/text/RCS/tindex.c,v 1.6 90/08/23 11:44:11 ajp Exp $"; #endif /* lint */ #include #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/text/RCS/tindex.c,v 1.7 91/02/12 17:30:58 gk5g Exp $ */ /* $ACIS:$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/text/RCS/tindex.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/text/RCS/tindex.c,v 1.7 91/02/12 17:30:58 gk5g Exp $"; #endif /* lint */ #include #include *************** *** 395,401 **** struct text *d; FILE *f; { ! char buf[512],*error,*nl,*index(); while(fgets(buf,511,f) != NULL){ if((nl = index(buf,'\n')) != NULL) *nl = '\0'; if(tindex_IndexTerm(d,buf,&error) < 0){ --- 395,401 ---- struct text *d; FILE *f; { ! char buf[512],*error,*nl; while(fgets(buf,511,f) != NULL){ if((nl = index(buf,'\n')) != NULL) *nl = '\0'; if(tindex_IndexTerm(d,buf,&error) < 0){ *** atk/text/tmac.atk Mon Mar 12 13:16:48 1990 --- atk/text/tmac.atk.NEW Mon Mar 4 13:45:11 1991 *************** *** 119,124 **** --- 119,129 ---- .de Si .if '\\$1'mplex' .nr DP 1 .. + . \" Du -- silly macro, if called as .Duplex + . \" it will turn to duplex mode + .de Du + .if '\\$1'plex' .nr DP 0 + .. . \" OH -- the recto (odd page) header or default header .de OH .tl '\\*(LT'\\*(CT'\\*(RT' *************** *** 350,355 **** --- 355,362 ---- .\" Begin of the PSmacros, coutesy of fred hansen (I believe) .\" .nr zT 0 + '\" CCH added next line for post printer type + .if "\*(.T"post" 'nr zT 1 .if "\*(.T"postscript" 'nr zT 1 .if "\*(.T"psc" 'nr zT 1 .de PB *** atk/text/tpllist.c Fri Dec 21 14:59:11 1990 --- atk/text/tpllist.c.NEW Sat Dec 15 17:22:24 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/text/RCS/tpllist.c,v 2.11 90/09/27 18:15:53 gk5g Exp $ */ /* $ACIS:tpllist.c 1.4$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/text/RCS/tpllist.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/text/RCS/tpllist.c,v 2.11 90/09/27 18:15:53 gk5g 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/text/RCS/tpllist.c,v 2.13 90/12/15 17:21:41 ajp Exp $ */ /* $ACIS:tpllist.c 1.4$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/text/RCS/tpllist.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/text/RCS/tpllist.c,v 2.13 90/12/15 17:21:41 ajp Exp $"; #endif /* lint */ *************** *** 89,94 **** --- 89,110 ---- ssptr->version++; } + static void SetGlobalStyleInText(self) + struct text *self; + { + struct style *styleptr = stylesheet_GetGlobalStyle(self->styleSheet); + + if (styleptr == NULL) { + /* Need to add global style to template */ + + styleptr = style_New(); + style_SetName(styleptr, "global"); + styleptr->template = 1; + stylesheet_Add(self->styleSheet, styleptr); + } + text_SetGlobalStyle(self, styleptr); + } + /* This routine parses the contents of a template file */ long text__ReadTemplate(self, templateName, inserttemplatetext) struct text *self; *************** *** 109,116 **** else { /* probably should stat file here to see if it's changed */ text_OverrideStyles(self->styleSheet, templateptr); ! styleptr = stylesheet_GetGlobalStyle(self->styleSheet); ! text_SetGlobalStyle(self, styleptr); return NULL; } } --- 125,131 ---- else { /* probably should stat file here to see if it's changed */ text_OverrideStyles(self->styleSheet, templateptr); ! SetGlobalStyleInText(self); return NULL; } } *************** *** 198,205 **** } else text_OverrideStyles(self->styleSheet, templateptr); ! styleptr = stylesheet_GetGlobalStyle(self->styleSheet); ! text_SetGlobalStyle(self, styleptr); return NULL; } i = 0; --- 213,219 ---- } else text_OverrideStyles(self->styleSheet, templateptr); ! SetGlobalStyleInText(self); return NULL; } i = 0; *************** *** 269,276 **** } fclose(fileptr); text_OverrideStyles(self->styleSheet, templateptr); ! styleptr = stylesheet_GetGlobalStyle(self->styleSheet); ! text_SetGlobalStyle(self, styleptr); return NULL; } --- 283,289 ---- } fclose(fileptr); text_OverrideStyles(self->styleSheet, templateptr); ! SetGlobalStyleInText(self); return NULL; } *** atk/text/txtstvc.doc Mon Jun 17 12:10:01 1991 --- atk/text/txtstvc.doc.NEW Thu Jun 6 15:46:07 1991 *************** *** 0 **** --- 1,280 ---- + \begindata{text,269166232} + \textdsversion{12} + \template{default} + \define{fixedindent + } + \define{fixedtext + } + \define{paramname + } + \define{fieldheading + } + \define{fieldtext + } + \chapter{text state vector} + + + The text state vector holds a complete snapshot of text formatting, It is + used by the printing routines to hold the current formatting and the + formatting of the newly entered style. It is also used as a convenient way to + view a formatting environment. + + + \section{About this section} + + + This section currently contains only the most important information on using + tabs in conjunction with text state vectors. It really should contain more + details. + + + \section{About \italic{struct text_statevector}} + + + \fixedindent{struct text_statevector \{ + + long CurLeftMargin; + + long CurRightMargin; + + long CurRightEdge; + + long CurLeftEdge; + + long CurTopMargin; + + long CurBottomMargin; + + long CurFontAttributes; + + long CurScriptMovement; + + long CurFontSize; + + long CurIndentation; + + enum style_Justification CurJustification; + + long CurSpacing; + + long CurSpread; + + long SpecialFlags; + + struct fontdesc *CurCachedFont; + + char *CurFontFamily; + + /* + + struct dfamily * CurFontFamily; + + struct dfont * CurCachedFont; + + */ + + struct tabs *tabs; + + struct view * CurView; /* Pointer to view wrapped in the environment */ + + char *CurColor; /* Color for embedded text */ + + \}; + + + } + + \section{Related classes} + + + The text_statevector structure is related to the \italic{style} class and the + \italic{text} class. It is used to implement \italic{text} and + \italic{textview} objects. + + + \section{Using \italic{struct text_statevector}} + + + The most common use of tabs occurs within the text_statevector structure. It + is vitally important that care is exercised when using tabs and state vectors. + You should do subtly different things for the three cases: initialized state + vectors, copied read-only state vectors, and copied read-write state vectors. + + + When a state vector is initialized with text_InitStateVector, it receives a + default tabs structure. It is a good idea to call text_FinalizeState vector + when you are finished with a state vector initialized in this way so that the + link count of tabs will be kept correctly. + + + A common use of the text_statevector structure is to receive details about a + style environment. In the read-only case, copying in its contents as follows: + + + + \fixedindent{struct text_statevector oldsv, newsv; + + newsv = oldsv; + + } + is perfectly fine. Such state vectors as newsv can be created on the stack + and allowed to dissappear with no ill effects on tabs. + + + If, however, it is expected that either the old or new state vectors are to be + modified, it is important to take care of the tabs link counts through proper + use of tabs_Death and text_FinalizeStateVector. + + + Moving the above example into the read-write case: if + \italic{text_FinalizeStateVector} is called on \typewriter{oldsv}, the tabs + structure of \typewriter{newsv} may dissappear. For this reason, the state + vector should be copied as follows: + + + \fixedindent{text_InitializeStateVector(&newsv); \italic{/* give newsv its own + tabs */} + + text_InitializeStateVector(&oldsv); \italic{/* give oldsv its own tabs */} + + \italic{/* Code goes here that modifies the tabs of newsv */} + + tabs_Death(newsv.tabs); \italic{/* newsv's tabs are going away */} + + newsv = oldsv; /* copy everything else */ + + newsv.tabs = tabs_Copy(oldsv.tabs); \italic{/* copy in the tabs */} + + text_FinalizeStateVector(&oldsv); \italic{/* We're done with oldsv */} + + \italic{/* Code goes here that uses newsv */} + + text_FinalizeStateVector(&newsv); \italic{/* We're totally done with newsv */} + + } + \section{Author + + } + Bill Cattey, + + wdc@athena.mit.edu + + + \begindata{bp,269220084} + \enddata{bp,269220084} + \view{bpv,269220084,3,0,0} + \section{\italic{text} functions} (taken from text.doc) + + + ______________________________________________________ + + + \paragraph{text_ApplyEnvironment} \indexi{ \italic{text_ApplyEnvironment}} + + + \majorheading{Function description} + + ______________________________________________________ + + + \fixedtext{void \bold{text_ApplyEnvironment }(} + + \fixedindent{struct text_statevector *\paramname{sv}, + + struct style *\paramname{defaultStyle}, + + struct environment *\paramname{env});} + + + \fieldheading{Category} + + \fieldtext{Classprocedure} + + + + \fieldheading{Description} + + \fieldtext{Takes the state vector, \paramname{sv}, and the environment, + \paramname{env}, and modifies \paramname{sv} so that it reflects the + application of \paramname{env}. The parameter \paramname{defaultStyle} + specifies the default style; it can be NULL.} + + + + \fieldheading{See Also} + + \fieldtext{\paramname{textview_GetDefaultStyle}.} + + \begindata{bp,269219780} + \enddata{bp,269219780} + \view{bpv,269219780,4,0,0}_____________________________________________________\ + __ + + + \paragraph{text_FinalizeStateVector}\indexi{\italic{text_FinalizeStateVector}} + + + + \majorheading{Finalize the state vector} + + ______________________________________________________ + + + \fixedtext{void \bold{text_FinalizeStateVector }(} + + \fixedindent{struct text_statevector *\paramname{sv});} + + + \fieldheading{Category} + + \fieldtext{Classprocedure} + + + + \fieldheading{Description} + + \fieldtext{Make the state vector go away. Actually, it just calls tabs_Death + on the tabs component.} + + \fieldheading{ + Usage} + + \fieldtext{Call \italic{text_FinalizeStateVector} when you are through with + using a state vector. Call it only on a state vector that has been + initialized with \italic{text_InitializeStateVector}. Otherwise a nonexistant + tabs component will be destroyed.} + + \begindata{bp,268859344} + \enddata{bp,268859344} + \view{bpv,268859344,5,0,0}_____________________________________________________\ + __ + + + \paragraph{text_InitStateVector} \indexi{ \italic{text_InitStateVector}} + + + \majorheading{Initialize the state vector} + + ______________________________________________________ + + + \fixedtext{void \bold{text_InitStateVector }(} + + \fixedindent{struct text_statevector *\paramname{sv});} + + + \fieldheading{Category} + + \fieldtext{Classprocedure} + + + + \fieldheading{Description} + + \fieldtext{Initializes the environment state vector for text and controls + formatting of the text. Attributes set by this procedure include margins, + indentations, spacings, spread, flags, fonts, justifications, + tabs.}\fieldtext{ + + } + \enddata{text,269166232} *** atk/text/txtstvec.h Fri Dec 21 14:59:12 1990 --- atk/text/txtstvec.h.NEW Fri Dec 14 16:56:30 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/text/RCS/txtstvec.h,v 2.5 90/08/23 14:34:45 tpn Exp Locker: ajp $ */ /* $ACIS:txtstvec.h 1.2$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/text/RCS/txtstvec.h,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsidtextstatevector = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/text/RCS/txtstvec.h,v 2.5 90/08/23 14:34:45 tpn Exp Locker: ajp $"; #endif /* !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) */ #ifndef TEXTSTATEVECTOR_DEFINED --- 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/text/RCS/txtstvec.h,v 2.6 90/12/14 15:03:05 ajp Exp $ */ /* $ACIS:txtstvec.h 1.2$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/text/RCS/txtstvec.h,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsidtextstatevector = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/text/RCS/txtstvec.h,v 2.6 90/12/14 15:03:05 ajp Exp $"; #endif /* !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) */ #ifndef TEXTSTATEVECTOR_DEFINED *************** *** 37,49 **** struct dfamily * CurFontFamily; struct dfont * CurCachedFont; */ ! long * CurTabStops; /* Pointer to array of tab stops in points */ ! long * CurTabTypes; /* Pointer to array of tab descriptors (see below)*/ ! long CurNumTabs; /* Number of entries in the tab arrays */ struct view * CurView; /* Pointer to view wrapped in the environment */ char *CurColor; /* Color for embedded text */ }; - /* Comment on CurTabTypes. The types are the same values as in the enumeration type for tabentry except when a character-around justifictain is used. In that case, the character to be used is the enumeration value + 128*character to use. Thus, to get the actual value, one should mask off the CurTabType with 0x177 */ #endif /* TEXTSTATEVECTOR_DEFINED */ --- 37,46 ---- struct dfamily * CurFontFamily; struct dfont * CurCachedFont; */ ! struct tabs *tabs; struct view * CurView; /* Pointer to view wrapped in the environment */ char *CurColor; /* Color for embedded text */ }; #endif /* TEXTSTATEVECTOR_DEFINED */ *** atk/text/txttroff.c Fri Dec 21 14:59:26 1990 --- atk/text/txttroff.c.NEW Tue May 7 16:53: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/src/projects/andrew/atk/text/RCS/txttroff.c,v 2.34 90/07/30 11:34:00 susan Exp Locker: ajp $ */ /* $ACIS:txttroff.c 1.3$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/text/RCS/txttroff.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/text/RCS/txttroff.c,v 2.34 90/07/30 11:34:00 susan Exp Locker: ajp $"; #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/text/RCS/txttroff.c,v 2.42 1991/05/07 20:43:49 dba Exp $ */ /* $ACIS:txttroff.c 1.3$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/text/RCS/txttroff.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/text/RCS/txttroff.c,v 2.42 1991/05/07 20:43:49 dba Exp $"; #endif /* lint */ /* *************** *** 27,36 **** * Passthru not handled (should set needNewLine ) */ #include #include - #include #include #include #include --- 27,36 ---- * Passthru not handled (should set needNewLine ) */ + #include #include #include #include #include #include *************** *** 37,42 **** --- 37,43 ---- #include #include #include + #include #include #include #include *************** *** 48,56 **** #include #include struct tran { ! char out[2]; }; /* The following two translation tables use the array index --- 49,59 ---- #include #include + #define BOGUS3812 1 /* avoids new bug in psdit */ + struct tran { ! char out[3]; }; /* The following two translation tables use the array index *************** *** 59,64 **** --- 62,68 ---- and andysymbola fonts and the escape sequences used by troff to represent these symbols */ + struct tran symtran[128] = { "xx","xx","xx","xx","xx","xx","xx","xx","xx","xx","xx","xx","xx","xx","xx","xx", *************** *** 86,93 **** #define ENDNOTESONLY FALSE /* Administrators should define as TRUE if local troff can't support footnotes */ ! #define CONTENTSBYDEFAULT FALSE /* define the default behavior regarding the printing of tables ! of contents if the appropriate styles are present */ #define ENUMERATE #define INDENTSPACE 6 #ifdef ENUMERATE --- 90,100 ---- #define ENDNOTESONLY FALSE /* Administrators should define as TRUE if local troff can't support footnotes */ ! #define CONTENTSBYDEFAULT FALSE /* define the default behavior ! regarding the printing of tables ! of contents if the appropriate styles are present */ ! #define DUPLEXBYDEFAULT FALSE /* default behavior: simplex printing or duplex printing */ ! #define ENUMERATE #define INDENTSPACE 6 #ifdef ENUMERATE *************** *** 116,124 **** --- 123,134 ---- static int symbola; /* >0 if the current font is a special symbol font */ #define NegOffset 36 /* Negative offset for use in faking troff */ + static boolean resetTabs = FALSE; static long currentVS; static long latestVS; static long extraVS; + static long currentSpread; + static long latestSpread; struct content_chapentry *lastcentry; static struct style *defaultStyle = NULL; *************** *** 126,131 **** --- 136,142 ---- static struct text_statevector sv, nsv; /* Current and new state vectors */ static boolean printContents; /* Flag to indicate if we are printing a table of contents */ + static boolean printDuplex; /* Flag to indicate if we process for duplex printing. */ static struct { char *fontname; char *fontcodes[9]; *************** *** 134,139 **** --- 145,151 ---- /* fixed-bold, fixed-bolditalic, shadow. */ /* All shadowface is bold for now */ } fonttable[] = { + #if !defined(TROFF_FONTS_ENV) || defined(EROFF_ENV) {"timesroman", {"R", "I", "B", "BI", "C", "CO", "CB", "CD", "B"}}, {"helvetica", {"H", "HO", "HB", "HD", "C", "CO", "CB", "CD", "B"}}, {"andy", {"R", "I", "B", "BI", "C", "CO", "CB", "CD", "B"}}, *************** *** 141,148 **** {"andytype", {"C", "CO", "CB", "CD", "C", "CO", "CB", "CD", "C"}}, {"gacha", {"C", "CO", "CB", "CD", "C", "CO", "CB", "CD", "C"}}, {0, {"R", "I", "B", "BI", "C", "CO", "CB", "CD", "B"}} ! /* default for unknown family */ ! }; static struct { char *fontname; --- 153,168 ---- {"andytype", {"C", "CO", "CB", "CD", "C", "CO", "CB", "CD", "C"}}, {"gacha", {"C", "CO", "CB", "CD", "C", "CO", "CB", "CD", "C"}}, {0, {"R", "I", "B", "BI", "C", "CO", "CB", "CD", "B"}} ! #else ! {"timesroman", {"R", "I", "B", "BI", "CO", "CI", "CB", "CX", "B"}}, ! {"helvetica", {"H", "HI", "HB", "HX", "CO", "CI", "CB", "CX", "B"}}, ! {"andy", {"R", "I", "B", "BI", "CO", "CI", "CB", "CX", "B"}}, ! {"andysans", {"H", "HI", "HB", "HX", "CO", "CI", "CB", "CX", "B"}}, ! {"andytype", {"CO", "CI", "CB", "CX", "CO", "CI", "CB", "CX", "CO"}}, ! {"gacha", {"CO", "CI", "CB", "CX", "CO", "CI", "CB", "CX", "CO"}}, ! {0, {"R", "I", "B", "BI", "CO", "CI", "CB", "CX", "B"}} ! #endif /* !defined(TROFF_FONTS_ENV) || defined(EROFF_ENV) */ ! }; static struct { char *fontname; *************** *** 175,180 **** --- 195,238 ---- #ifndef text_INLINEMACROS #define text_INLINEMACROS FALSE #endif + + #ifdef COLORPRINTINGWORKS + #define COLORPTN "'Ca\n'if \\n(zT \\{\\\n\\! %f %f %f setrgbcolor\n\\}\n'Cz\n" + + /* #define COLORPTN "\\!%%\n\\!%%!\n\\! %f %f %f setrgbcolor\n\\!.\n" */ + + #define pushcolor(R,B,G,F) fprintf(F,COLORPTN, R , G , B ) + #ifndef RGB_TXT + #define RGB_TXT "/usr/lib/X11/rgb.txt" + #endif + + + setcolor(color,f) + char *color; + FILE *f; + { + FILE *fc; + int r,g,b; + char colorname[128],*c,cc[256],*cp; + if(color == NULL || *color == '\0'){ + pushcolor(0.,0.,0.,f); + return; + } + for(c = color,cp = cc;*c != NULL; c++,cp++) + *cp = isupper(*c)? tolower(*c):*c; + *cp= '\0'; + + if((fc = fopen(RGB_TXT,"r")) == NULL) + return ; + while (fscanf(fc, "%d %d %d %[^\n]\n", &r, &g, &b, colorname) == 4) { + if(strcmp(colorname,cc) == 0){ + pushcolor((((float)r)/255.), (((float)g)/255.), (((float)b)/255.), f); + break; + } + } + fclose(fc); + } + #endif /* COLORPRINTINGWORKS */ static char *speclookup(c,f) long c,f; { *************** *** 290,298 **** static void ChangeState() { ! int recomputefont; static int cstatus = 0; ! recomputefont = 0; /* Figure out what to do for each change in state vector */ --- 348,356 ---- static void ChangeState() { ! int recomputefont = 0; static int cstatus = 0; ! int changetabs = 0; /* Figure out what to do for each change in state vector */ *************** *** 299,306 **** if (sv.CurLeftMargin != nsv.CurLeftMargin) { PutNewlineIfNeeded(); fprintf(troffFile, "'in %dp\n", NegOffset + nsv.CurLeftMargin); } ! if (sv.CurRightMargin != nsv.CurRightMargin) { PutNewlineIfNeeded(); --- 357,370 ---- if (sv.CurLeftMargin != nsv.CurLeftMargin) { PutNewlineIfNeeded(); fprintf(troffFile, "'in %dp\n", NegOffset + nsv.CurLeftMargin); + changetabs = 1; } ! #ifdef COLORPRINTINGWORKS ! if(sv.CurColor != nsv.CurColor){ ! PutNewlineIfNeeded(); ! setcolor(nsv.CurColor,troffFile); ! } ! #endif /* COLORPRINTINGWORKS */ if (sv.CurRightMargin != nsv.CurRightMargin) { PutNewlineIfNeeded(); *************** *** 346,363 **** if (nsv.CurIndentation < 0) fprintf(troffFile, ".ti %dp\n", nsv.CurIndentation); else ! fprintf(troffFile, ".ti +%dp\n", nsv.CurIndentation); } if (sv.CurJustification != nsv.CurJustification) ChangeJustification(sv.CurJustification, nsv.CurJustification,TRUE); - if (sv.CurSpacing != nsv.CurSpacing) { - } - - if (sv.CurSpread != nsv.CurSpread) { - } - if (sv.SpecialFlags != nsv.SpecialFlags) { if(passthru && !(nsv.SpecialFlags & style_PassThru)) PutNewlineIfNeeded(); --- 410,422 ---- if (nsv.CurIndentation < 0) fprintf(troffFile, ".ti %dp\n", nsv.CurIndentation); else ! fprintf(troffFile, ".ti +%dp\n", nsv.CurIndentation); ! changetabs = TRUE; } if (sv.CurJustification != nsv.CurJustification) ChangeJustification(sv.CurJustification, nsv.CurJustification,TRUE); if (sv.SpecialFlags != nsv.SpecialFlags) { if(passthru && !(nsv.SpecialFlags & style_PassThru)) PutNewlineIfNeeded(); *************** *** 371,380 **** if (sv.CurFontFamily != nsv.CurFontFamily) recomputefont = 1; ! /* Check for tab stop changes (UNIMPLEMENTED) */ ! /* sv.CurTabStops, sv.CurTabTypes */ sv = nsv; if (recomputefont) { ComputeTroffFont(sv.CurFontFamily, sv.CurFontAttributes, sv.CurFontSize); /* Sets dFont, dFace, dSize */ --- 430,467 ---- if (sv.CurFontFamily != nsv.CurFontFamily) recomputefont = 1; ! /* Check for tab stop changes */ ! /* The changetabs state variable is used to force ! reinitializing of tabs after the margin moved. This is ! unnecessary if we are tabbing with spaces. -wdc */ ! /* Actions: ! nsv.tabchars == 1 && sv.tabchars == 1: do nothing ! nsv.tabchars == 1 && sv.tabchars == 0: do space tabs ! nsv.tabchars == 0 && sv.tabchars == 1: force regular tabs ! nsv.tabchars == 0 && sv.tabchars == 0: do regular tabs if necessary */ ! ! if (nsv.SpecialFlags & style_TabsCharacters) { ! if (!(sv.SpecialFlags & style_TabsCharacters)) { ! /* only output tabstops if we havent done so already */ ! fprintf (troffFile, "'.ta 8n\n"); ! } ! } else { ! if (sv.SpecialFlags & style_TabsCharacters) changetabs = TRUE; /* Force change tabs if we just stopped tabbing with spaces */ ! if (!changetabs) ! changetabs = tabs_Different(sv.tabs, nsv.tabs); + if (changetabs) { + if (needNewLine) fprintf(troffFile,"\\c"); + PutNewlineIfNeeded(); + tabs_OutputTroff(nsv.tabs, nsv.CurIndentation, troffFile); + resetTabs = FALSE; + } + } + + tabs_Death(sv.tabs); sv = nsv; + sv.tabs = tabs_Copy(nsv.tabs); + if (recomputefont) { ComputeTroffFont(sv.CurFontFamily, sv.CurFontAttributes, sv.CurFontSize); /* Sets dFont, dFace, dSize */ *************** *** 385,402 **** else fprintf(troffFile, ".ps %d\n", dSize); /* set point size */ ! cSize = dSize; ! latestVS = (dSize <= 12) ? (dSize + 2) : (dSize * 14 / 12); ! if (currentVS < latestVS) { ! extraVS = latestVS - currentVS; ! } ! else { ! extraVS = 0; ! } ! } } } --- 472,496 ---- else fprintf(troffFile, ".ps %d\n", dSize); /* set point size */ ! cSize = dSize; ! } ! } ! latestVS = ((cSize <= 12) ? (cSize + 2) : (cSize * 14 / 12)) + sv.CurSpacing; ! ! if (currentVS < latestVS) { ! extraVS = latestVS - currentVS; ! } ! else { ! extraVS = 0; ! } ! if (sv.CurSpread > sv.CurSpacing) { ! latestSpread = sv.CurSpread - sv.CurSpacing; ! } ! else { ! latestSpread = 0; } } *************** *** 527,535 **** fprintf(f, ".ps \\n(PS\n"); cSize = dSize; ! currentVS = (dSize <= 12) ? (dSize + 2) : (dSize * 14 / 12); latestVS = currentVS; extraVS = 0; fprintf(f, ".nr VS %dp\n", currentVS); /* Set interline spacing and tabs */ fprintf(f, ".vs \\n(VSu\n"); fprintf(f, ".nr EN 8n\n"); --- 621,636 ---- fprintf(f, ".ps \\n(PS\n"); cSize = dSize; ! currentVS = ((dSize <= 12) ? (dSize + 2) : (dSize * 14 / 12)) + sv.CurSpacing; latestVS = currentVS; extraVS = 0; + if (sv.CurSpread > sv.CurSpacing) { + currentSpread = sv.CurSpread - sv.CurSpacing; + } + else { + currentSpread = 0; + } + fprintf(f, ".nr VS %dp\n", currentVS); /* Set interline spacing and tabs */ fprintf(f, ".vs \\n(VSu\n"); fprintf(f, ".nr EN 8n\n"); *************** *** 536,543 **** if (toplevel) { fputs(".sp 0.5i\n", f); /* Space down for start of page */ ! fputs(".nr DP 0\n", f); /* one or two char font name? */ i = strlen(fonttable[dFont].fontcodes[dFace]); /* set font for footnote number in text, I assume here that --- 637,655 ---- if (toplevel) { + char *val; + fputs(".sp 0.5i\n", f); /* Space down for start of page */ ! ! if((val = environ_Get("Duplex")) != NULL){ ! printDuplex = (*val == 'n' || *val == 'N')? FALSE:TRUE; ! } ! else { ! printDuplex = environ_GetProfileSwitch("Duplex",DUPLEXBYDEFAULT); ! } ! if (printDuplex) fputs(".nr DP 0\n", f); ! else fputs(".nr DP 1\n", f); ! /* one or two char font name? */ i = strlen(fonttable[dFont].fontcodes[dFace]); /* set font for footnote number in text, I assume here that *************** *** 551,556 **** --- 663,679 ---- fprintf(f, ".ds FF %s\n", fonttable[dFont].fontcodes[dFace]); fputs(".nr FS \\n(.s\n", f); fprintf(f, ".RS\n"); /* init real defaults */ + if (sv.CurLeftMargin != 0) { + fprintf(troffFile, ".in %dp\n", NegOffset + sv.CurLeftMargin); + } + if (sv.CurRightMargin != 0) { + fprintf(troffFile, ".ll \\n(.lu-(%dp)\n", sv.CurRightMargin); + } + if (sv.SpecialFlags & style_TabsCharacters) { + fprintf (troffFile, "'.ta 8n\n"); + } else { + tabs_OutputTroff(sv.tabs, sv.CurIndentation, troffFile); + } if (sv.CurIndentation < 0) fprintf(troffFile, ".ti %dp\n", sv.CurIndentation); else if (sv.CurIndentation > 0) *************** *** 591,615 **** return 0; } ! static void FlushLineSpacing(cs,hitchars) int cs; { /* Put out .sp for subsequent new lines */ PutNewlineIfNeeded(); ! fputs(".OC\n", troffFile); ! if (cs == 1) ! fputs(".br\n", troffFile); else if (cs > 1) { if(hitchars == 0) /* space past trap */ ! fprintf(troffFile, ".sv %d\n", --cs); ! else fprintf(troffFile, ".sp %d\n", --cs); } - if (sv.CurIndentation < 0) - fprintf(troffFile, ".ti %dp\n", sv.CurIndentation); - else if (sv.CurIndentation > 0) - fprintf(troffFile, ".ti +%dp\n", sv.CurIndentation); if (latestVS != currentVS) { fprintf(troffFile, ".vs %d\n", latestVS); currentVS = latestVS; --- 714,759 ---- return 0; } ! static void FlushLineSpacing(cs, hitchars, needbreak) int cs; + int hitchars; + boolean needbreak; { /* Put out .sp for subsequent new lines */ PutNewlineIfNeeded(); ! if (needbreak) { ! fputs(".OC\n", troffFile); ! } ! if (cs == 1) { ! if (currentSpread != 0) { ! fprintf(troffFile, ".sp %dp\n", currentVS - latestVS + currentSpread); ! } ! } else if (cs > 1) { + cs--; if(hitchars == 0) /* space past trap */ ! fprintf(troffFile, ".sv %d\n", cs); ! else fprintf(troffFile, ".sp %dp\n", cs * (currentVS + currentSpread) + currentVS - latestVS + currentSpread); ! } ! currentSpread = latestSpread; ! ! /* Restore tabs after temporary setting of indent to 0. ! If we're doing character spaced tabs, resetTabs wasnt set by ! us. We save it for who ever DID set it. ! I'm unwilling to say that it will never be set under these ! conditions. -wdc */ ! if (sv.CurIndentation != 0) { ! if (resetTabs && !(sv.SpecialFlags & style_TabsCharacters)) { ! tabs_OutputTroff(sv.tabs, sv.CurIndentation, troffFile); ! resetTabs = FALSE; ! } ! if (sv.CurIndentation < 0) ! fprintf(troffFile, "'ti %dp\n", sv.CurIndentation); ! else ! fprintf(troffFile, "'ti +%dp\n", sv.CurIndentation); } if (latestVS != currentVS) { fprintf(troffFile, ".vs %d\n", latestVS); currentVS = latestVS; *************** *** 797,802 **** --- 941,956 ---- case UNMATCHED : /* fprintf(stderr,"Returning Normal\n"); */ return NORMAL; + #ifdef REFER + case REFER: + PutNewlineIfNeeded(); + if(len > 255) len = 255; + text_CopySubString(d,pos,len,buf,TRUE); + deletenewlines(buf); + quote(buf,'"',255); + fprintf(troffFile,".[ [\n%s\n.]]\n",buf); + return NOPRINT ; + #endif case FOOTNOTE : fprintf(troffFile, "\\**\n"); /* automatic footnote counter string */ needNewLine = 0; *************** *** 1027,1037 **** if(toplevel) addindex = (environ_Get("IndexOnly") != NULL); if(toplevel == TRUE || (class_IsTypeByName(class_GetTypeName(dd),"fnote") == FALSE)){ ! if(toplevel != TRUE) safesv = sv; OutputInitialTroff(f, toplevel, cenv); } else { safesv = sv; if (defaultStyle == NULL) InitializeStyle(); --- 1181,1210 ---- if(toplevel) addindex = (environ_Get("IndexOnly") != NULL); if(toplevel == TRUE || (class_IsTypeByName(class_GetTypeName(dd),"fnote") == FALSE)){ ! if(toplevel != TRUE) { ! /* don't kill safesv tabs - safesv is uninitialized */ ! safesv = sv; ! /* Clever optimization: ! We're done with sv's tabs. We could: ! safesv.tabs = tabs_Copy(sv.tabs); ! text_FinalizeStateVector(&sv); ! but since that just has the effect of an increment ! and a decrement of the link count, we cleverly ! do nothing -wdc */ ! } OutputInitialTroff(f, toplevel, cenv); } else { + /* don't kill safesv tabs - safesv is uninitialized */ safesv = sv; + /* Clever optimization: + We're done with sv's tabs. We could: + safesv.tabs = tabs_Copy(sv.tabs); + text_FinalizeStateVector(&sv); + but since that just has the effect of an increment + and a decrement of the link count, we cleverly + do nothing -wdc */ + if (defaultStyle == NULL) InitializeStyle(); *************** *** 1100,1106 **** ChangeState(); if(i == 0){ if(environment_GetLength(nenv) == doclen) setdefaultstate(); ! FlushLineSpacing(0,hitchars); /* sets vertical spacing */ } } else if(flag == NOPRINT){ --- 1273,1279 ---- ChangeState(); if(i == 0){ if(environment_GetLength(nenv) == doclen) setdefaultstate(); ! FlushLineSpacing(0,hitchars,FALSE); /* sets vertical spacing */ } } else if(flag == NOPRINT){ *************** *** 1125,1131 **** if (sv.CurView != NULL) { if(strcmp(vr->viewType,"fnotev") == 0){ if (cs) { ! FlushLineSpacing(cs,hitchars); cs = 0; } needNewLine = 0; --- 1298,1304 ---- if (sv.CurView != NULL) { if(strcmp(vr->viewType,"fnotev") == 0){ if (cs) { ! FlushLineSpacing(cs,hitchars,TRUE); cs = 0; } needNewLine = 0; *************** *** 1133,1139 **** } else if(strcmp(vr->viewType,"bpv") == 0){ if(cs){ ! FlushLineSpacing(1,hitchars);/* throw away unneeded newlines */ cs = 0; } needta = FALSE; --- 1306,1312 ---- } else if(strcmp(vr->viewType,"bpv") == 0){ if(cs){ ! FlushLineSpacing(1,hitchars,TRUE);/* throw away unneeded newlines */ cs = 0; } needta = FALSE; *************** *** 1142,1148 **** } else { if (cs) { ! FlushLineSpacing(cs,hitchars); cs = 0; } needta = TRUE; --- 1315,1321 ---- } else { if (cs) { ! FlushLineSpacing(cs,hitchars,TRUE); cs = 0; } needta = TRUE; *************** *** 1149,1158 **** PutNewlineIfNeeded(); } view_Print(sv.CurView, f, "troff", "PostScript", 0); ! if(needta) fprintf(f,".TA\n"); /* reset tab stops, as table is want to mess them up */ ! } } } /* End change environment */ elen += i; /* Bump by current position */ --- 1322,1337 ---- PutNewlineIfNeeded(); } view_Print(sv.CurView, f, "troff", "PostScript", 0); ! if(needta) ! /* reset tab stops, as table is want to mess them up */ ! if (sv.SpecialFlags & style_TabsCharacters) { ! fprintf (troffFile, "'.ta 8n\n"); ! } else { ! tabs_OutputTroff(sv.tabs, (resetTabs) ? 0 : sv.CurIndentation, troffFile); ! } } } + text_FinalizeStateVector(&nsv); } /* End change environment */ elen += i; /* Bump by current position */ *************** *** 1178,1184 **** while (i < elen) { if (passthru){ if (cs) { ! FlushLineSpacing(cs,hitchars); cs = 0; } /* Put out passthru stuff as we see it */ --- 1357,1363 ---- while (i < elen) { if (passthru){ if (cs) { ! FlushLineSpacing(cs,hitchars,TRUE); cs = 0; } /* Put out passthru stuff as we see it */ *************** *** 1203,1209 **** } if (cs) { ! FlushLineSpacing(cs,hitchars); cs = 0; quotespace = TRUE; } --- 1382,1388 ---- } if (cs) { ! FlushLineSpacing(cs,hitchars,TRUE); cs = 0; quotespace = TRUE; } *************** *** 1281,1287 **** } ln++; } ! if((!isascii(c) || !isprint(c)) && c != '\t'){ char *ccp= pcompch_CharacterToTroff(c,nenv,&sv); if(ccp) { while(*ccp) { --- 1460,1477 ---- } ln++; } ! if (c == '\r') { ! fputs("\n.br\n", f); ! if (sv.CurIndentation != 0) { ! if (sv.SpecialFlags & style_TabsCharacters) { ! fprintf (troffFile, "'.ta 8n\n"); ! } else { ! tabs_OutputTroff(sv.tabs, 0, f); ! resetTabs = TRUE; ! } ! } ! } ! else if((!isascii(c) || !isprint(c)) && c != '\t') { char *ccp= pcompch_CharacterToTroff(c,nenv,&sv); if(ccp) { while(*ccp) { *************** *** 1354,1362 **** --- 1544,1574 ---- } else { /* write troff to return to parents state */ + + /* + * nsv may not have been initialized. + * (if we're not toplevel and there are no style changes?) + * Until this is figured out, don't garbage collect. -dba + */ + #if 0 + tabs_Death(nsv.tabs); + #endif + nsv = safesv; + nsv.tabs = tabs_Copy(safesv.tabs); + if(flags&texttroff_Revert) ChangeState(); + tabs_Death(sv.tabs); sv = safesv; + + /* Clever optimization: + We're done with safesv's tabs. We could: + sv.tabs = tabs_Copy(safesv.tabs); + tabs_Death(safesv.tabs); + but since that just has the effect of an increment + and a decrement of the link count, we cleverly + do nothing -wdc */ + } #endif /* ENUMERATE */ *** atk/text/txtvcmds.c Fri Dec 21 14:59:35 1990 --- atk/text/txtvcmds.c.NEW Fri May 24 15:12:13 1991 *************** *** 3,2796 **** * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/text/RCS/txtvcmds.c,v 2.51 90/11/05 20:08:40 gk5g Exp $ */ /* $ACIS:txtvcmds.c 1.7$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/text/RCS/txtvcmds.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/text/RCS/txtvcmds.c,v 2.51 90/11/05 20:08:40 gk5g Exp $"; #endif /* lint */ #include #define AUXMODULE 1 #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 ! static long lcKill; ! static long lcYank; ! static long lcMove; ! static long lcDisplayEnvironment; long lcInsertEnvironment; long lcNewLine; ! #define Text(v) (struct text *) ((v)->header.view.dataobject) ! ! #define TEXT_VIEWREFCHAR '\377' ! #define textview_GetLines(self) ((self)->nLines) ! static void textview_InsertEnvironment(); ! /* Added safety for views --cm26 */ ! static boolean ConfirmViewDeletion(self, pos, len) ! struct textview *self; ! long pos, len; ! { ! struct text *d; ! boolean hasViews; ! static char *yesOrNo[] = {"Yes", "No", NULL}; ! long answer; ! struct environment *env; ! ! d = Text(self); ! ! for (hasViews = FALSE; len--; pos++) ! if (text_GetChar(d, pos) == TEXT_VIEWREFCHAR) { ! env = textview_GetStyleInformation(self, NULL, pos, NULL); ! if (env->type == environment_View) { ! hasViews = TRUE; ! textview_ReleaseStyleInformation(self, env); ! break; ! } ! textview_ReleaseStyleInformation(self, env); ! } ! if (! hasViews) ! return TRUE; ! if (message_MultipleChoiceQuestion(self, 80, ! "Really delete inset(s)?", 1, &answer, ! yesOrNo, NULL) < 0 || answer != 0) { ! message_DisplayString(self, 0, "Cancelled.\n"); ! return FALSE; ! } ! return TRUE; ! } ! /* Added friendly read-only behavior 04/27/89 --cm26 */ ! static boolean ConfirmReadOnly(self) ! struct textview *self; ! { ! if (text_GetReadOnly(Text(self))) { ! message_DisplayString(self, 0, ! "Document is read only."); ! return TRUE; ! } else ! return FALSE; ! } ! void textview_ForwardWordCmd(); ! void textview_BackwardWordCmd(); ! void textview_SelfInsertCmd(); ! void textview_BeginningOfLineCmd(); ! void textview_LineToTopCmd(self) ! register struct textview *self; ! { ! long pos; ! pos = textview_GetDotPosition(self) + textview_GetDotLength(self); ! pos = textview_MoveBack(self, pos, 0, textview_MoveByLines, 0, 0); ! textview_SetTopPosition(self, pos); ! textview_WantUpdate(self, self); ! } ! void textview_ForwardParaCmd(self) ! register struct textview *self; ! { ! register int j, ct, pos, dlen; ! register struct text *d; ! j = 0; ! ct = im_Argument(textview_GetIM(self)); ! d = Text(self); ! dlen = text_GetLength(d); ! pos =textview_GetDotPosition(self); ! while (j 0) pos--; ! while (pos>0 && text_GetChar(d,pos-1) != '\n') pos--; ! j++; ! } ! textview_SetDotPosition(self,pos); ! textview_WantUpdate(self, self); ! } ! void textview_OpenLineCmd(self) ! register struct textview *self; ! { ! register int i, pos, ct; ! char tc; ! struct text *d; ! ! if (ConfirmReadOnly(self)) ! return; ! textview_CollapseDot(self); ! d=Text(self); ! pos = textview_GetDotPosition(self); ! tc = '\012'; ! i = 0; ! ct = im_Argument(textview_GetIM(self)); ! textview_PrepareInsertion(self); ! for (i = 0; i < ct; i++) { ! text_InsertCharacters(d,pos,&tc,1); ! } ! textview_FinishInsertion(self); ! text_NotifyObservers(d, observable_OBJECTCHANGED); ! if (im_GetLastCmd(textview_GetIM(self)) == lcInsertEnvironment) { ! im_SetLastCmd(textview_GetIM(self), lcInsertEnvironment); ! } ! } ! /* This is no longer a command you can type; ! * it is now called from a menu item */ ! void textview__LookCmd(self, look) ! register struct textview *self; ! int look; ! { ! register struct text *d; ! struct stylesheet *ss; ! struct style *styleptr; ! char *name; ! ! if (ConfirmReadOnly(self)) ! return; ! ! d = Text(self); ! ss = text_GetStyleSheet(d); ! ! if (ss != NULL) { ! styleptr = ss->styles[look]; ! if ((name = style_GetName(styleptr)) != NULL) { ! textview_InsertEnvironment(self, name); ! return; ! } ! } ! message_DisplayString(self, 0, "Sorry; can't add style."); ! } ! void textview_PlainerCmd(self, type) ! register struct textview *self; ! char *type; ! { ! register struct text *d; ! register struct environment *env; ! int pos, len; ! ! if (ConfirmReadOnly(self)) ! return; ! ! d = Text(self); ! pos = textview_GetDotPosition(self); ! len = textview_GetDotLength(self); ! if (im_GetLastCmd(textview_GetIM(self)) == lcDisplayEnvironment && (env = self->displayEnvironment) != NULL && env != d->rootEnvironment) { ! pos = environment_Eval(env); ! len = env->header.nestedmark.length; ! environment_Delete(env); ! text_SetModified(d); ! im_SetLastCmd(textview_GetIM(self), lcDisplayEnvironment); ! self->displayEnvironment = NULL; ! message_DisplayString(self, 0, ""); ! } ! else if (len == 0) { ! if (strcmp(type, "old") == 0) { ! env = environment_GetInnerMost(d->rootEnvironment, pos); ! if (env == NULL || env == d->rootEnvironment) return; ! pos = environment_Eval(env); ! len = env->header.nestedmark.length; ! environment_Delete(env); ! text_SetModified(d); ! } ! else { ! textview_UpInsertEnvironment(self); ! im_SetLastCmd(textview_GetIM(self), lcInsertEnvironment); ! return; ! } ! } ! else { ! if (environment_Remove(d->rootEnvironment, pos, len, environment_Style, FALSE)) ! text_SetModified(d); ! } ! text_RegionModified(d, pos, len); ! text_NotifyObservers(d, observable_OBJECTCHANGED); ! } ! void textview_PlainestCmd(self) ! register struct textview *self; ! { ! register struct text *d; ! int pos, len; ! if (ConfirmReadOnly(self)) ! return; ! d = Text(self); ! pos = textview_GetDotPosition(self); ! len = textview_GetDotLength(self); ! if (len == 0) { ! textview_PlainInsertEnvironment(self); ! im_SetLastCmd(textview_GetIM(self), lcInsertEnvironment); ! return; ! } ! else if (environment_Remove(d->rootEnvironment, ! pos, len, environment_Style, TRUE)) ! text_SetModified(d); ! text_RegionModified(d, pos, len); ! text_NotifyObservers(d, observable_OBJECTCHANGED); ! } ! static objecttest(self,name,desiredname) ! register struct textview *self; ! char *name,*desiredname; ! { ! if(class_Load(name) == NULL){ ! char foo[640]; ! sprintf(foo,"Can't load %s",name); ! message_DisplayString(self, 0, foo); ! return(FALSE); ! } ! if(! class_IsTypeByName(name,desiredname)){ ! char foo[640]; ! sprintf(foo,"%s is not a %s",name,desiredname); ! message_DisplayString(self, 0, foo); ! return(FALSE); ! } ! return(TRUE); ! } ! void textview_InsertInsetCmd (self) ! register struct textview *self; ! { ! char iname[100]; ! char viewname[200]; ! long pf; ! boolean promptforname = im_ArgProvided(view_GetIM((&self->header.view))); ! im_ClearArg(textview_GetIM(self)); ! viewname[0] = '\0'; ! if (ConfirmReadOnly(self)) ! return; ! if(text_GetObjectInsertionFlag(Text(self)) == FALSE){ ! message_DisplayString(self, 0, "Object Insertion Not Allowed!"); ! return; ! } ! pf = message_AskForString(self, 0, "Data object to insert here: ", 0, iname, sizeof(iname)); ! if (pf < 0){ ! message_DisplayString(self, 0, "Punt!"); ! return; ! } ! if(strlen(iname)==0){ ! message_DisplayString(self, 0, "No name specified"); ! return; ! } ! if(objecttest(self,iname,"dataobject") == FALSE) return; ! if(promptforname){ ! if( message_AskForString (self, 0, "View to place here ", 0, viewname, 200) < 0) return; ! if(objecttest(self,viewname,"view") == FALSE) return; ! } ! textview_PrepareInsertion(self); ! self->currentViewreference = text_InsertObject(Text(self), textview_GetDotPosition(self), iname,viewname); ! textview_FinishInsertion(self); ! text_NotifyObservers(Text(self), observable_OBJECTCHANGED); ! if (im_GetLastCmd(textview_GetIM(self)) == lcInsertEnvironment) { ! im_SetLastCmd(textview_GetIM(self), lcInsertEnvironment); ! } ! } ! /* Inserts a lookz view in front of the current paragraph. */ ! void textview_ExposeStyleEditor(self) ! struct textview *self; ! { ! register int pos; ! register struct text *d; ! if(objecttest(self, "lookzview", "view") == FALSE) ! return; ! if(objecttest(self, "lookz", "dataobject") == FALSE) ! return; ! if(text_GetObjectInsertionFlag(Text(self)) == FALSE){ ! message_DisplayString(self, 0, "Object Insertion Not Allowed!"); ! return; ! } ! d = Text(self); ! /* Find the beginning of the current paragraph. */ ! pos = textview_GetDotPosition(self) + textview_GetDotLength(self); ! while (pos > 0 && text_GetChar(d, pos) != '\n') ! pos--; ! /* If we can insert it between two carriage returns (or at the beginning of the ! * document) do so, otherwise insert it at the start of this paragraph. */ ! if (pos > 0 && text_GetChar(d, pos - 1) != '\n') ! pos += 1; ! textview_PrepareInsertion(self); ! self->currentViewreference = ! text_InsertObject(Text(self), pos, "lookz", "lookzview"); ! textview_FinishInsertion(self); ! textview_FrameDot(self, pos); ! text_NotifyObservers(d, observable_OBJECTCHANGED); ! if (im_GetLastCmd(textview_GetIM(self)) == lcInsertEnvironment) { ! im_SetLastCmd(textview_GetIM(self), lcInsertEnvironment); ! } ! } ! void textview_GotoParagraphCmd(self) ! register struct textview *self; ! { ! char temp[100]; ! int line, len, gf; ! register int i, pos; ! register struct text *d; ! ! d = Text(self); ! ! if (im_ArgProvided(textview_GetIM(self))) ! line = im_Argument(textview_GetIM(self)); ! else { ! gf = message_AskForString(self, 0, "What paragraph? ", 0, temp, 100); ! if (gf < 0) ! return; ! line = atoi(temp); ! } ! len = text_GetLength(d); ! pos = 0; ! i = 1; ! while (i < line) { ! if (pos >= len) ! break; ! if (text_GetChar(d, pos) == '\012') ! i++; ! pos++; ! } ! textview_SetDotPosition(self, pos); ! textview_SetDotLength(self, 0); ! textview_FrameDot(self, pos); ! textview_WantUpdate(self, self); ! } ! void textview_WhatParagraphCmd (v) ! register struct textview *v; ! { ! char temp[100]; ! register int i, pos; ! register struct text *d; ! ! d=Text(v); ! pos = textview_GetDotPosition(v)-1; ! i=1; ! while (pos >= 0) { ! if (text_GetChar(d,pos) == '\012') ! i++; ! pos--; ! } ! sprintf(temp,"Paragraph %d.",i); ! message_DisplayString(v, 0, temp); ! } ! /* Serach command statics. */ ! #define SRCHSTRLEN 100 ! char *lastPattern = NULL; ! static char searchString[SRCHSTRLEN] = ""; ! boolean forwardSearch = TRUE; /* TRUE if last search was forward. */ ! int textview_SearchCmd(self) ! register struct textview *self; ! { ! char defSrchString[SRCHSTRLEN], *tp, messageBuf[120], *prompt; ! int pos = 0, gf, ct; ! register int j; ! register struct text *d; ! boolean defaultExists = FALSE; ! ! d = Text(self); ! ct = im_Argument(textview_GetIM(self)); ! if (*searchString != '\0'){ ! defaultExists = TRUE; ! strcpy(defSrchString, searchString); ! } ! if (defaultExists) { ! sprintf(messageBuf, "Search for [%s] : ", defSrchString); ! prompt = messageBuf; ! } ! else ! prompt = "Search for: "; ! gf = message_AskForString(self, 0, prompt, NULL, searchString, sizeof(searchString)); ! if (gf < 0) return(-1); ! if (defaultExists && *searchString == '\0') ! strcpy(searchString, defSrchString); ! textview_SetDotPosition(self, ! textview_GetDotPosition(self)+textview_GetDotLength(self)); ! if (!defaultExists || *searchString != '\0') { ! tp = search_CompilePattern(searchString,&lastPattern); ! if (tp != 0) { ! message_DisplayString(self, 0, tp); ! return(-2); ! } ! } ! j = 0; ! while (j 0) textview_SetDotPosition(self,orgpos-1); ! if (!defaultExists || *searchString != '\0') { ! tp = search_CompilePattern(searchString,&lastPattern); ! if (tp != 0) { ! message_DisplayString(self, 0, tp); ! return -2; ! } ! } ! j=0; ! while (j 0) ! textview_SetDotPosition(self, --pos); ! pos = search_MatchPatternReverse(d, pos, lastPattern); ! } ! if (pos < 0) ! message_DisplayString(self, 0, "Search failed."); ! 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 textview_GlitchUpCmd(self) ! register struct textview *self; ! { ! register int n; ! register int pos; ! n = im_Argument(textview_GetIM(self)); ! pos = textview_GetTopPosition(self); ! pos = textview_MoveBack(self, pos, 0, textview_MoveByLines, 0, 0); ! pos = textview_MoveForward(self, pos, n, textview_MoveByLines, 0, 0); ! if (self->scroll == textview_ScrollBackward) ! self->scroll = textview_MultipleScroll; ! textview_SetTopPosition(self, pos); ! textview_WantUpdate(self, self); ! } ! void textview_GlitchDownCmd(self) ! register struct textview *self; { ! register int n,pos; ! long dist, lines; ! n = im_Argument(textview_GetIM(self)); ! pos = textview_GetTopPosition(self); ! pos = textview_MoveBack(self, pos, n, textview_MoveByLines, &dist, &lines); ! if (self->scroll == textview_ScrollForward) ! self->scroll = textview_MultipleScroll; ! else { ! if (self->scrollDist == -1) { ! self->scrollDist = dist; ! self->scrollLine = lines; } ! else { ! self->scrollDist += dist; ! if (self->scrollDist >= textview_GetLogicalHeight(self)) ! self->scrollDist = -1; ! else ! self->scrollLine += lines; } } - - textview_SetTopPosition(self, pos); - textview_WantUpdate(self, self); - } - - /* Number of lines below which we use one line overlaps instead of two line overlaps. */ ! #define SMALLWINDOW 4 ! void textview_NextScreenCmd(self) ! struct textview *self; { ! int argument = im_Argument(textview_GetIM(self)); ! int count; ! ! im_ClearArg(textview_GetIM(self)); ! for (count = 0; count < argument; ++count) { ! int numLines = textview_GetLines(self); ! long pos; ! long viewHeight = textview_GetLogicalHeight(self) - self->by; ! if (numLines == 0) /* Do nothing is no text on the screen. */ ! return; ! ! if (numLines == 1) ! textview_GlitchUpCmd(self); ! else { ! /* If more than SMALLWINDOW lines on the screen. */ ! if (numLines > SMALLWINDOW || ! (self->lines[numLines - 1].y + 2 * self->lines[numLines - 1].height) < viewHeight) ! numLines -= 2; else ! --numLines; ! pos = textview_GetTopPosition(self); ! pos = textview_MoveBack(self, pos, 0, textview_MoveByLines, 0, 0); /* get line aligned */ ! pos = textview_MoveForward(self, pos, numLines, textview_MoveByLines, 0, 0); /* move forward */ ! if (self->scroll == textview_ScrollBackward) ! self->scroll = textview_MultipleScroll; ! textview_SetTopPosition(self, pos); } } ! textview_WantUpdate(self, self); } ! void textview_PrevScreenCmd(self) ! register struct textview *self; { ! int argument = im_Argument(textview_GetIM(self)); ! int count; ! ! im_ClearArg(textview_GetIM(self)); ! ! for (count = 0; count < argument; ++count) { ! long numLines = textview_GetLines(self); ! long pos; ! long viewHeight = textview_GetLogicalHeight(self) - self->by; ! long dist; ! long lines; ! long overlapHeight; ! ! if (numLines == 1) ! textview_GlitchDownCmd(self); ! else { ! /* If more than SMALLWINDOW lines on the screen. */ ! if (numLines > SMALLWINDOW || (numLines > 1) && ! (self->lines[numLines - 1].y + 2 * self->lines[numLines - 1].height) < viewHeight) ! overlapHeight = self->lines[1].y + self->lines[1].height; ! else if (numLines > 0) ! overlapHeight = self->lines[0].y + self->lines[0].height; ! else ! overlapHeight = 0; ! ! pos = textview_GetTopPosition(self); ! pos = textview_MoveBack(self, pos, viewHeight - overlapHeight, textview_MoveByPixels, &dist, &lines); ! ! if (self->scroll == textview_ScrollForward) ! self->scroll = textview_MultipleScroll; ! else if (self->scrollDist == -1) { ! self->scrollDist = dist; ! self->scrollLine = lines; ! } ! else { ! self->scrollDist = -1; } ! ! textview_SetTopPosition(self,pos); } ! } ! textview_WantUpdate(self, self); ! } ! ! #ifdef CONVERSIONERROR ! void textview_PrintFile(self) ! struct textview *self; ! { ! register struct text *d = Text(self); ! register struct buffer *b = (struct buffer *) buffer_FindData(d); ! char *filename = b->fname; ! ! if (! filename || ! filename[0]) { ! filename = b->bname; ! if (! filename || ! filename[0]) ! filename = "unknown"; ! } ! ! doctroff_PrintDoc(d, 1, 1, filename, ""); ! } ! void textview_PreviewCmd(self) ! register struct textview *self; ! { ! register struct text *d = Text(self); ! register struct buffer *b = buffer_finddata(d); ! char *filename = b->fname; ! ! if (! filename || ! filename[0]) { ! filename = b->bname; ! if (! filename || ! filename[0]) ! filename = "unknown"; ! } ! ! doctroff_PrintDoc(d, 0, 1, filename, ""); ! } ! void textview_SetPrinterCmd(self) ! struct textview *self; ! { ! char p[200]; ! char *currentprinter; ! char str[300]; ! ! currentprinter = (char *) environ_Get("PRINTER"); ! if (currentprinter == NULL) ! currentprinter = environ_GetProfile("print.spooldir"); ! if (message_AskForString(self, 0, ! "Set Printer to: ", currentprinter, p, 200) < 0) { ! if (p[0] == '\0') { ! environ_Delete("PRINTER"); ! strcpy(p, environ_GetProfile("print.spooldir")); ! } ! else ! environ_Put("PRINTER", p); } else ! strcpy(p, currentprinter); ! sprintf(str, "Printer now set to %s", p); ! message_DisplayString(self, 0, str); ! } ! #endif /* CONVERSIONERROR */ ! ! #define SHOWSIZE 250 ! ! void textview_ShowStylesCmd(self) ! register struct textview *self; ! { ! char tbuf[SHOWSIZE]; ! register char *tp; ! struct environment *te; ! struct environment *de = NULL; ! struct text *d; ! int curLen, flag; ! long pos; ! ! curLen = 1; /* the null at the end */ ! if (im_GetLastCmd(textview_GetIM(self)) == lcDisplayEnvironment) { ! de = self->displayEnvironment; ! pos = self->displayEnvironmentPosition; ! } ! else { ! textview_ReleaseStyleInformation(self, self->displayEnvironment); ! self->displayEnvironment = NULL; ! textview_CollapseDot(self); ! pos = textview_GetDotPosition(self); ! } ! ! strcpy(tbuf, "Styles: "); ! flag = 0; ! d = Text(self); ! te = textview_GetEnclosedStyleInformation(self, pos, NULL); ! if (te) { ! if (te == d->rootEnvironment) { ! strcat(tbuf, "None"); ! } ! else { ! while (te != d->rootEnvironment) { ! tp = te->data.style->name; ! ! if(tp == NULL) tp = "(Unnamed Style)"; ! if (flag) ! strcat(tbuf, " <- "); ! ! if (de == NULL) ! de = te; ! else if (de == te) ! de = NULL; ! ! curLen += 4+strlen(tp); ! if (curLen >= SHOWSIZE) break; ! if (de == te) ! strcat(tbuf, "**"); ! strcat(tbuf,tp); ! if (de == te) { ! strcat(tbuf, "**"); ! textview_SetDotPosition(self, environment_Eval(te)); ! textview_SetDotLength(self, environment_GetLength(te)); ! } ! te = (struct environment *) te->header.nestedmark.parent; ! flag = 1; ! } ! } ! if (de == NULL) { ! textview_SetDotPosition(self, pos); ! textview_SetDotLength(self, 0); ! } ! message_DisplayString(self, 0, tbuf); ! im_SetLastCmd(textview_GetIM(self), lcDisplayEnvironment); ! self->displayEnvironment = de; ! self->displayEnvironmentPosition = pos; ! } ! else message_DisplayString(self, 0, "Error"); ! textview_WantUpdate(self, self); } ! void textview_QueryReplaceCmd(self) ! struct textview *self; { ! boolean defaultExists = FALSE; ! boolean keepAsking = TRUE; ! boolean keepRunning = TRUE; ! boolean returnPosition = TRUE; ! char *lastPattern = NULL; ! char *prompt = NULL; ! char *searchError = NULL; ! char casedString[SRCHSTRLEN]; ! char promptBuf[SRCHSTRLEN +20]; ! int numFound = 0; ! int numReplaced = 0; ! int replacementLen = 0; ! int reply = 0; ! long fencePos = 0; ! long originalLength = 0; ! long originalPos = 0; ! long pos = 0; ! long searchPos = 0; ! static char replacement[SRCHSTRLEN] = ""; ! static char defSrchString[SRCHSTRLEN] = ""; ! static int expertReplace = -999999; ! struct mark *area = NULL; ! struct text *d = NULL; ! ! if (ConfirmReadOnly(self)) ! return; ! casedString[0] = '\0'; ! promptBuf[0] = '\0'; ! if (expertReplace == -999999) ! expertReplace = environ_GetProfileSwitch("ExpertMode", 0); ! ! d = Text(self); ! ! if (*searchString != '\0'){ ! defaultExists = TRUE; ! sprintf(defSrchString, "%s", searchString); ! } ! if (defaultExists) { ! sprintf(promptBuf, "Replace [%s] : ", defSrchString); ! if (*searchString == '\0') ! sprintf(searchString, "%s", defSrchString); ! prompt = promptBuf; ! } ! else ! prompt = "Replace: "; ! ! if (message_AskForString(self, 0, prompt, NULL, searchString, sizeof(searchString)) < 0) ! return; ! if (defaultExists && *searchString == '\0') ! sprintf(searchString, "%s", defSrchString); ! ! prompt = "New string: "; ! if (message_AskForString(self, 0, prompt, NULL, replacement, sizeof(replacement)) < 0) ! return; ! replacementLen = strlen(replacement); ! ! if (!defaultExists || *searchString != '\0') ! if ((searchError = search_CompilePattern(searchString, &lastPattern)) != NULL) { ! message_DisplayString(self, 0, searchError); ! return; ! } ! ! originalPos = searchPos = textview_GetDotPosition(self); ! originalLength = textview_GetDotLength(self); ! ! area = (originalLength != 0) ? text_CreateMark(d, originalPos, originalLength) : NULL; ! ! if (searchPos < (fencePos = text_GetFence(d))) searchPos = fencePos; ! ! while ((pos = search_MatchPattern(d, searchPos, lastPattern)) >= 0 ! && keepRunning ! && (area == NULL || pos < mark_GetPos(area) + mark_GetLength(area))) { ! ! long matchLen = search_GetMatchLength(); ! /* length can change between matches on RE searches */ ! ! ++numFound; ! ! textview_SetDotPosition(self, pos); ! textview_SetDotLength(self, matchLen); ! textview_FrameDot(self, pos); ! ! if (keepAsking) { ! textview_Update(self); ! reply = im_GetCharacter(textview_GetIM(self)); ! } ! else ! reply = ' '; ! ! switch (reply) { ! case 'q': ! case '\007': ! case EOF: /* Interrupted im_GetChar */ ! keepRunning = FALSE; ! break; ! case '-': /* WHAT IS THIS?? -- GHOTI */ ! { ! int i; ! ! if (isupper(text_GetChar(d, pos))) { ! for (i = 1; i < matchLen; i++) ! if (islower(text_GetChar(d, pos + i))) break; ! if (i >= matchLen) { ! for (i = 0; i < replacementLen; i++) ! casedString[i] = (islower(replacement[i])) ? toupper(replacement[i]) : replacement[i]; ! casedString[i] = '\0'; ! } ! else { /* Upcase first letter. */ ! for (i = 0; i < replacementLen; i++) ! casedString[i] = replacement[i]; ! casedString[i] = '\0'; ! casedString[0] = (islower(replacement[0])) ? toupper(replacement[0]) : replacement[0]; } ! } ! else ! strncpy(casedString, replacement, replacementLen); ! ! text_ReplaceCharacters(d, pos, matchLen, casedString, replacementLen); ! searchPos = pos + replacementLen; ! ++numReplaced; ! } ! break; ! case '!': ! case '.': ! case ',': ! case '=': ! if (reply == '!') ! keepAsking = FALSE; ! else { ! keepRunning = FALSE; ! if (reply == ',') ! returnPosition = FALSE; ! else if (reply == '='){ ! returnPosition = FALSE; ! searchPos = pos + matchLen; ! break; } } ! /* Fall through. */ ! case ' ': ! text_ReplaceCharacters(d, pos, matchLen, replacement, replacementLen); ! searchPos = pos + replacementLen; ! ++numReplaced; ! break; ! case 'n': ! searchPos = pos + 1; ! break; ! case 'r': ! if (expertReplace) { ! message_DisplayString(self, 0, "Recursive editing; ^C exits."); ! im_KeyboardProcessor(); ! break; ! } ! /* Otherwise, fall through to the default */ ! default: ! message_DisplayString(self, 0, expertReplace ? ! "One of ' ', '.', 'n', 'r', '!', 'q' '-' ',' '='" : ! "One of ' ', '.', 'n', '!', 'q' '-' ',' '='"); ! im_ForceUpdate(); ! break; ! } ! ! if (keepAsking) ! textview_Update(self); ! } ! if (numFound > 0) { ! char messageString[100]; ! if (returnPosition){ ! if (area != NULL) { ! textview_SetDotPosition(self, mark_GetPos(area)); ! textview_SetDotLength(self, mark_GetLength(area)); ! } else { ! textview_SetDotPosition(self, originalPos); ! textview_SetDotLength(self, originalLength); ! } ! textview_FrameDot(self, originalPos); ! text_NotifyObservers(d, observable_OBJECTCHANGED); ! } ! sprintf(messageString, "Found %d occurrences; replaced %d.", ! numFound, numReplaced); ! message_DisplayString(self, 0, messageString); ! } ! else ! message_DisplayString(self, 0, "No occurrences found."); ! ! if (area != NULL) { ! text_RemoveMark(d, area); ! mark_Destroy(area); } - - return; } ! void textview_QuoteCmd(self) ! register struct textview *self; { register long i; ! long count; ! register struct text *d; ! char tc; ! long where; ! ! if (ConfirmReadOnly(self)) ! return; ! count = im_Argument(textview_GetIM(self)); ! d = Text(self); ! tc = im_GetCharacter(textview_GetIM(self)); ! if (tc >= '0' && tc <= '7') { ! char c1 = im_GetCharacter(textview_GetIM(self)) - '0', ! c2 = im_GetCharacter(textview_GetIM(self)) - '0'; ! tc = ((tc - '0' << 3) + c1 << 3) + c2; ! } ! where = textview_GetDotPosition(self); ! textview_PrepareInsertion(self); ! for (i = 0; i < count; i++) { ! text_InsertCharacters(d, where+i, &tc, 1); ! } ! textview_FinishInsertion(self); ! textview_SetDotPosition(self, where+count); ! text_NotifyObservers(d, observable_OBJECTCHANGED); ! if (im_GetLastCmd(textview_GetIM(self)) == lcInsertEnvironment) { ! im_SetLastCmd(textview_GetIM(self), lcInsertEnvironment); ! } ! } ! ! void textview_InsertFile(self) ! struct textview *self; ! { ! char filename[MAXPATHLEN]; ! FILE *inputFile; ! long initialPos; ! long pos; ! struct stat buf; ! ! if (ConfirmReadOnly(self)) ! return; ! if (im_GetDirectory(filename) != NULL) /* Use CWD for now */ ! strcat(filename, "/"); ! if (completion_GetFilename(self, "Insert file: ", filename, filename, sizeof(filename), FALSE, TRUE) == -1 ) ! return; ! stat(filename,&buf); ! if(buf.st_mode & S_IFDIR) { ! message_DisplayString(self, 0, "Can't insert a directory"); ! return; ! } ! if ((inputFile = fopen(filename, "r")) == NULL) { ! message_DisplayString(self, 0, "Could not insert file."); /* Really should give a more informative error message. */ ! return; ! } ! ! textview_CollapseDot(self); ! initialPos = pos = textview_GetDotPosition(self); ! ! textview_PrepareInsertion(self); ! text_InsertFile(Text(self), inputFile,filename, pos); ! textview_FinishInsertion(self); ! ! fclose(inputFile); ! ! textview_SetDotPosition(self,initialPos); ! textview_SetDotLength(self, pos - initialPos); ! /* im_SetLastCmd(textview_GetIM(self), lcYank); */ ! text_NotifyObservers(Text(self), observable_OBJECTCHANGED); ! } ! ! void textview_YankCmd(self) ! register struct textview *self; ! { ! long ct; ! long initialPos; ! long pos; ! struct text *d; ! FILE *pasteFile; ! ! if (ConfirmReadOnly(self)) ! return; ! ct = im_Argument(textview_GetIM(self)); ! if (ct > 100) { ! message_DisplayString(self, 0, "Yank argument limit: 100"); ! return; ! } ! ! d = Text(self); ! ! textview_CollapseDot(self); ! initialPos = pos = textview_GetDotPosition(self); ! ! textview_PrepareInsertion(self); ! while (ct--) { ! pasteFile = im_FromCutBuffer(textview_GetIM(self)); ! pos += text_InsertFile(d, pasteFile, NULL, pos); ! im_CloseFromCutBuffer(textview_GetIM(self), pasteFile); ! } ! textview_FinishInsertion(self); ! ! textview_SetDotPosition(self,initialPos); ! textview_SetDotLength(self, pos - initialPos); ! im_SetLastCmd(textview_GetIM(self), lcYank); ! text_NotifyObservers(d, observable_OBJECTCHANGED); ! } ! ! static textview_DoRotatePaste(self, count) ! register struct textview *self; ! int count; ! { ! register struct text *d = Text(self); ! ! im_ClearArg(textview_GetIM(self)); /* Make it safe to call yank. */ ! ! if (ConfirmReadOnly(self)) ! return; ! text_DeleteCharacters(d, /* Get rid of what is there now. */ ! textview_GetDotPosition(self), textview_GetDotLength(self)); ! if (im_GetLastCmd(textview_GetIM(self)) != lcYank) /* If not following yank. */ ! count--; /* Make it get top thing off of ring, instead of one down on ring. */ ! im_RotateCutBuffers(textview_GetIM(self), count); /* Put the ring in the right place. */ ! textview_YankCmd(self); /* Snag it in off the ring. */ ! } ! ! ! void textview_BackwardsRotatePasteCmd(self) ! struct textview *self; ! { ! textview_DoRotatePaste(self, - im_Argument(textview_GetIM(self))); ! } ! ! void textview_RotatePasteCmd(self) ! struct textview *self; ! { ! textview_DoRotatePaste(self, im_Argument(textview_GetIM(self))); ! } ! ! void textview_InsertNLCmd(self) ! register struct textview *self; ! { ! textview_SelfInsertCmd(self,'\012'); ! if (im_GetLastCmd(textview_GetIM(self)) != lcInsertEnvironment) { ! im_SetLastCmd(textview_GetIM(self), lcNewLine); ! } ! } ! ! static int stringmatch(d,pos,c) ! register struct text *d; ! register long pos; ! register char *c; ! { ! /* Tests if the text begins with the given string */ ! while(*c != '\0') { ! if(text_GetChar(d,pos) != *c) return FALSE; ! pos++; c++; ! } ! return TRUE; ! } ! ! static void DoCopyRegion(self, pos, len, appendFlag) ! struct textview *self; ! long pos, len; ! boolean appendFlag; ! { ! struct text *d; ! register long nextChange; ! FILE *cutFile; ! int UseDataStream; ! ! d = Text(self); ! environment_GetInnerMost(d->rootEnvironment, pos); ! nextChange = environment_GetNextChange(d->rootEnvironment, pos); ! ! cutFile = im_ToCutBuffer(textview_GetIM(self)); ! if (UseDataStream = ((nextChange <= len|| stringmatch(d,pos,"\\begindata")) && text_GetExportEnvironments(d))) ! fprintf(cutFile, "\\begindata{%s, %d}\n", ! (d->CopyAsText)?"text": class_GetTypeName(d), ! /* d->header.dataobject.id */ 999999); ! d->header.dataobject.writeID = im_GetWriteID(); ! text_WriteSubString(d, pos, len, cutFile, UseDataStream); ! if (UseDataStream) ! fprintf(cutFile, "\\enddata{%s,%d}\n", ! (d->CopyAsText)?"text": class_GetTypeName(d), /* d->header.dataobject.id */ 999999); ! ! if (appendFlag) ! im_AppendToCutBuffer(textview_GetIM(self), cutFile); ! else ! im_CloseToCutBuffer(textview_GetIM(self), cutFile); ! } ! ! void textview_ZapRegionCmd(self) ! register struct textview *self; ! { ! long pos, len; ! ! if (ConfirmReadOnly(self)) ! return; ! pos = textview_GetDotPosition(self); ! len = textview_GetDotLength(self); ! ! DoCopyRegion(self, pos, len, FALSE); ! textview_DeleteCharacters(self, pos, len); ! textview_SetDotLength(self, 0); ! im_SetLastCmd(textview_GetIM(self), lcKill); ! text_NotifyObservers(Text(self), observable_OBJECTCHANGED); ! } ! /* In order to safely allow killing multiple lines of text, each possibly */ ! /* including ATK objects, the cutbuffer contents are pasted back and then */ ! /* a larger area is re-cut. This isn't visible and wouldn't be so bad were */ ! /* it not for the extreme inefficiency of cutbuffer transfers. */ ! void textview_KillLineCmd(self) ! register struct textview *self; ! { ! register int count, pos, endpos, lastpos; ! register struct text *d; ! if (ConfirmReadOnly(self)) ! return; ! d = Text(self); ! count = im_Argument(textview_GetIM(self)); ! textview_CollapseDot(self); ! endpos = pos = textview_GetDotPosition(self); ! lastpos = text_GetLength(d); ! ! while (count-- > 0 && endpos < lastpos) { ! if (text_GetChar(d, endpos) == '\012') ! endpos++; ! else ! while (text_GetChar(d, endpos) != '\012' && endpos < lastpos) ! endpos++; ! } ! if (im_GetLastCmd(textview_GetIM(self)) == lcKill) { ! FILE *pasteFile; ! pasteFile = im_FromCutBuffer(textview_GetIM(self)); ! endpos += text_InsertFile(d, pasteFile, NULL, pos); ! im_CloseFromCutBuffer(textview_GetIM(self), pasteFile); } ! ! if (endpos > pos) { ! DoCopyRegion(self, pos, endpos - pos, FALSE); ! textview_DeleteCharacters(self, pos, endpos - pos); ! im_SetLastCmd(textview_GetIM(self), lcInsertEnvironment); ! textview_SetDotLength(self, 0); ! im_SetLastCmd(textview_GetIM(self), lcKill); } ! } ! ! /* This routine will, if immediately followed by a text cutting commnd, cause ! * the cut to append to the current buffer instead of placing it in a new ! * buffer. */ ! ! void textview_AppendNextCut(self) ! struct textview *self; ! { ! im_SetLastCmd(textview_GetIM(self), lcKill); /* mark us as a text killing command */ ! } ! ! void textview_CopyRegionCmd (self) ! register struct textview *self; ! { ! DoCopyRegion(self, ! textview_GetDotPosition(self), ! textview_GetDotLength(self), FALSE); ! } ! void textview_GetToCol (self, col) ! register struct textview *self; ! register int col; ! { ! register struct text *d; ! register int pos; ! d = Text(self); ! pos = textview_GetDotPosition (self); ! textview_PrepareInsertion(self); ! while (col > 0) { ! if (col >= 8) { ! col -= 8; ! text_InsertCharacters (d,pos,"\011",1); ! } ! else { ! col--; ! text_InsertCharacters(d,pos," ",1); ! } ! pos++; } - textview_FinishInsertion(self); - textview_SetDotPosition (self,pos); - text_NotifyObservers(d, observable_OBJECTCHANGED); - if (im_GetLastCmd(textview_GetIM(self)) == lcInsertEnvironment) { - im_SetLastCmd(textview_GetIM(self), lcInsertEnvironment); - } - } - - void textview_StartOfParaCmd (self) - register struct textview *self; - { - register struct text *d; - register int pos; - - d = Text(self); - pos = textview_GetDotPosition(self); - while (--pos >= 0 && text_GetChar(d, pos) != '\n'); - ++pos; - textview_SetDotPosition(self, pos); - textview_SetDotLength(self, 0); - view_WantUpdate((struct view *)self, self); - } - - void textview_EndOfParaCmd (self) - register struct textview *self; - { - register struct text *d; - register int pos; - register int dlen; - - d = Text(self); - pos = textview_GetDotPosition(self); - dlen = text_GetLength(d); - while (pos < dlen && text_GetChar(d, pos) != '\n') - ++pos; - textview_SetDotPosition(self, pos); - textview_SetDotLength(self, 0); - view_WantUpdate((struct view *) self, self); - } - - void textview_MyLfCmd(self) - register struct textview *self; - { - register int indentation; - - if (ConfirmReadOnly(self)) - return; - textview_StartOfParaCmd(self); - indentation = textview_GetSpace (self,textview_GetDotPosition(self)); - textview_EndOfParaCmd(self); - textview_InsertNLCmd(self); - textview_GetToCol(self,indentation); - } - - void textview_DeleteCmd (self) - register struct textview *self; - { - register int pos, len; ! if (ConfirmReadOnly(self)) ! return; ! textview_CollapseDot(self); ! ! pos = textview_GetDotPosition(self); ! len = im_Argument(textview_GetIM(self)); ! ! if (ConfirmViewDeletion(self, pos, len)) { ! textview_DeleteCharacters(self, pos, len); ! im_SetLastCmd(textview_GetIM(self), lcInsertEnvironment); ! textview_FrameDot(self, pos); ! } } ! void textview_KillWhiteSpaceCmd(self) ! register struct textview *self; ! { ! register struct text *d; ! register int p, tc, ep; ! /* First move back until no longer looking at whitespace */ ! /* Then delete forward white space. */ ! if (ConfirmReadOnly(self)) ! return; ! d = Text(self); ! textview_CollapseDot(self); ! p = textview_GetDotPosition(self); ! while (p > 0) { ! tc = 0xff & text_GetChar (d,p-1); ! if (tc == 9 || tc == 32) ! p--; ! else ! break; ! } ! textview_SetDotPosition(self,p); ! for (ep = p; ! ((tc = text_GetChar (d,ep)) != EOF) && (tc =='\t' || tc == ' '); ep++) ! ; ! textview_DeleteCharacters(self, p, ep - p); ! im_SetLastCmd(textview_GetIM(self), lcInsertEnvironment); ! } ! int textview_GetSpace(self, pos) ! struct textview *self; ! register int pos; ! { ! register int rval; ! register int tc; ! register struct text *d; ! register long len; ! d = Text(self); ! rval = 0; ! len = text_GetLength(d); ! while (pos < len) { ! tc = 0xff & text_GetChar(d,pos); ! if (tc == 32) rval++; ! else if (tc == 9) ! rval += 8; ! else ! return rval; ! pos++; ! } ! return rval; ! } ! ! static void AdjustIndentation(self, amount) ! struct textview *self; ! { ! int indentation; ! ! if (ConfirmReadOnly(self)) ! return; ! ! textview_StartOfParaCmd(self); ! indentation = textview_GetSpace(self, ! textview_GetDotPosition(self)); ! textview_KillWhiteSpaceCmd(self); ! indentation += amount; ! textview_GetToCol(self, indentation); ! textview_EndOfParaCmd(self); ! } ! ! void textview_UnindentCmd(self) ! struct textview *self; ! { ! AdjustIndentation(self, -4); ! } ! ! void textview_IndentCmd(self) ! struct textview *self; ! { ! AdjustIndentation(self, 4); ! } ! ! void textview_SelectRegionCmd(self) ! register struct textview *self; ! { ! register int i; ! register int dot, mark; ! ! mark = mark_GetPos(self->atMarker); ! dot = textview_GetDotPosition(self); ! if (mark > dot) { ! i = dot; ! dot = mark; ! mark = i; ! } ! /* Now assume that mark <= dot */ ! textview_SetDotLength(self,dot-mark); ! textview_SetDotPosition(self,mark); ! textview_WantUpdate(self, self); ! } ! ! void textview_ExchCmd(self) ! register struct textview *self; ! { ! register long p; ! register long len; ! ! p = textview_GetDotPosition(self); ! len = textview_GetDotLength(self); ! textview_SetDotPosition(self, mark_GetPos(self->atMarker)); ! textview_SetDotLength(self, mark_GetLength(self->atMarker)); ! mark_SetPos(self->atMarker,p); ! mark_SetLength(self->atMarker, len); ! textview_FrameDot(self, textview_GetDotPosition(self)); ! textview_WantUpdate(self, self); ! } ! ! void textview_CtrlAtCmd(self) ! register struct textview *self; ! { ! mark_SetPos(self->atMarker,textview_GetDotPosition(self)); ! mark_SetLength(self->atMarker,textview_GetDotLength(self)); ! message_DisplayString(self, 0, "Mark set."); ! } ! ! void textview_SelfInsertCmd(self, a) ! register struct textview *self; ! char a; ! { ! register int ct, i, pos; ! register struct text *d; ! ! if (ConfirmReadOnly(self)) ! return; ! ! d = Text(self); ! ct=im_Argument(textview_GetIM(self)); ! textview_CollapseDot(self); ! pos=textview_GetDotPosition(self); ! textview_PrepareInsertion(self); ! for (i = 0; i < ct; i++) { ! text_InsertCharacters(d,pos++,&a,1); ! } ! textview_FinishInsertion(self); ! textview_SetDotPosition(self,pos); ! textview_FrameDot(self, pos); ! text_NotifyObservers(d, observable_OBJECTCHANGED); ! if (im_GetLastCmd(textview_GetIM(self)) == lcInsertEnvironment) { ! im_SetLastCmd(textview_GetIM(self), lcInsertEnvironment); ! } ! } ! ! void textview_RuboutCmd (self) ! register struct textview *self; ! { ! register long endpos, len; ! ! if (ConfirmReadOnly(self)) ! return; ! ! textview_CollapseDot(self); ! ! endpos = textview_GetDotPosition(self); ! len = im_Argument(textview_GetIM(self)); ! ! if (endpos == 0) ! return; ! ! if (endpos - len < 0) ! len = endpos; ! ! if (ConfirmViewDeletion(self, endpos - len, len)) { ! textview_DeleteCharacters(self, endpos, -len); ! im_SetLastCmd(textview_GetIM(self), lcInsertEnvironment); ! textview_SetDotPosition(self, endpos - len); ! textview_FrameDot(self, endpos - len); ! } ! } ! ! void textview_BackwardCmd(self) ! register struct textview *self; ! { ! register long pos; ! register long newPos; ! ! textview_CollapseDot(self); ! pos = textview_GetDotPosition(self); ! textview_SetDotPosition(self,newPos = (pos-im_Argument(textview_GetIM(self)))); ! textview_FrameDot(self, newPos); ! textview_WantUpdate(self, self); ! } ! ! void textview_ForwardCmd(self) ! register struct textview *self; ! { ! register long pos; ! register long newPos; ! ! textview_CollapseDot(self); ! pos = textview_GetDotPosition(self); ! textview_SetDotPosition(self, (newPos = pos + im_Argument(textview_GetIM(self)))); ! if (pos != textview_GetDotPosition(self)) { ! textview_FrameDot(self, newPos); ! textview_WantUpdate(self, self); ! } ! } ! ! void textview_PreviousLineCmd (self) ! register struct textview *self; ! { ! register int npos; ! int xpos; ! struct mark tm; /* note this mark is not on the document's marker chain */ ! long pos, dist, lines, currentline, startPos; ! ! startPos = textview_GetDotPosition(self); ! textview_CollapseDot(self); ! pos = textview_GetDotPosition(self); ! if (im_GetLastCmd(textview_GetIM(self)) == lcMove) ! xpos = self->movePosition; ! else ! self->movePosition = xpos = self->cexPos; ! currentline = textview_FindLineNumber(self, pos); ! npos = textview_MoveBack(self, pos, im_Argument(textview_GetIM(self)), textview_MoveByLines, &dist, &lines); ! if (lines > currentline) { ! /* Have moved back off the screen */ ! if (self->scroll == textview_ScrollForward) ! self->scroll = textview_MultipleScroll; ! if (self->scrollDist == -1 ) { ! if (currentline != -1) { ! self->scrollDist = dist - (self->lines[currentline].y - self->lines[0].y); ! self->scrollLine = lines - currentline; ! textview_SetTopPosition(self, npos); ! } ! else { ! long topPos; ! ! currentline = textview_FindLineNumber(self, startPos); ! if (currentline != -1 || (startPos <= (topPos = textview_GetTopPosition(self)) && pos >= topPos)) ! textview_FrameDot(self, npos); ! } ! } ! else { ! self->scrollDist += dist; ! self->scrollLine += lines; ! textview_SetTopPosition(self, npos); ! } ! } ! else ! textview_FrameDot(self, npos); ! mark_SetPos(&tm, npos); ! mark_SetLength(&tm, 0); ! if (self->csxPos != -1) { ! struct formattinginfo info; ! ! npos = textview_LineRedraw (self, textview_GetPosition, &tm, self->bx, ! self->by, textview_GetLogicalWidth(self) - 2 * self->bx, ! textview_GetLogicalHeight(self) - 2 * self->by, xpos, (int *) 0, NULL, &info); ! } ! textview_SetDotPosition(self, npos); ! im_SetLastCmd(textview_GetIM(self), lcMove); ! textview_WantUpdate(self, self); ! } ! ! void textview_NextLineCmd (self) ! register struct textview *self; ! { ! register int npos; ! int xpos; ! struct mark tm; /* note this mark is not on the document's marker chain */ ! long pos, currentline, nlines, newline, startPos; ! static int linetomove; ! ! startPos = textview_GetDotPosition(self); ! textview_CollapseDot(self); ! pos = textview_GetDotPosition(self); ! ! if (im_GetLastCmd(textview_GetIM(self)) == lcMove) ! xpos = self->movePosition; ! else ! self->movePosition = xpos = self->cexPos; ! currentline = textview_FindLineNumber(self, pos); ! npos = textview_MoveBack(self,pos,0, textview_MoveByLines, NULL, NULL); ! npos = textview_MoveForward(self,npos, nlines = im_Argument(textview_GetIM(self)), textview_MoveByLines, NULL, NULL); ! if (currentline != -1) { ! /* Current Position is on the screen */ ! ! newline = textview_FindLineNumber(self, npos); ! if (newline == -1) { ! linetomove = nlines - (self->nLines - currentline - 1); ! ! if (linetomove < self->nLines && linetomove > 0) { ! if (self->scroll == textview_ScrollBackward) self->scroll = textview_MultipleScroll; ! textview_SetTopPosition(self, mark_GetPos(self->lines[linetomove].data)); ! } ! else ! textview_FrameDot(self, npos); ! } ! } ! else { ! /* Current Position is off the screen */ ! if (self->scroll == textview_ScrollForward) { ! linetomove += nlines; ! if (linetomove < self->nLines) ! textview_SetTopPosition(self, mark_GetPos(self->lines[linetomove].data)); ! else ! textview_FrameDot(self, npos); ! } ! else { ! long topPos; ! ! currentline = textview_FindLineNumber(self, startPos); ! if (currentline != -1 || (startPos <= (topPos = textview_GetTopPosition(self)) && pos >= topPos)) ! textview_FrameDot(self, npos); ! } ! } ! ! mark_SetPos(&tm, npos); ! mark_SetLength(&tm, 0); ! if (self->csxPos != -1) { ! struct formattinginfo info; ! ! npos = textview_LineRedraw (self, textview_GetPosition, &tm, self->bx, ! self->by, textview_GetLogicalWidth(self)-2*self->bx, ! textview_GetLogicalHeight(self)-2*self->by, xpos, (int *) 0, NULL, &info); ! } ! textview_SetDotPosition(self,npos); ! im_SetLastCmd(textview_GetIM(self), lcMove); ! textview_WantUpdate(self, self); ! } ! ! void textview_EndOfTextCmd(self) ! register struct textview *self; ! { ! register struct text *d; ! register int e; ! ! textview_CtrlAtCmd(self); ! d = Text(self); ! e = text_GetLength(d); ! textview_SetDotPosition(self,e); ! textview_SetDotLength(self,0); ! textview_FrameDot(self,e); ! textview_WantUpdate(self, self); ! } ! ! void textview_BeginningOfTextCmd(self) ! register struct textview *self; ! { ! textview_CtrlAtCmd(self); ! textview_SetDotPosition(self,0); ! textview_SetDotLength(self,0); ! textview_FrameDot(self,0); ! textview_WantUpdate(self, self); ! } ! ! void textview_EndOfLineCmd (self) ! register struct textview *self; ! { ! register int startpos, npos, dsize; ! register struct text *d; ! /* lie for now */ ! ! d = Text(self); ! if ((dsize = textview_GetDotLength(self)) > 0) { ! textview_SetDotPosition(self, dsize+textview_GetDotPosition(self)); ! textview_SetDotLength(self, 0); ! textview_WantUpdate(self, self); ! return; ! } ! dsize = text_GetLength(d); ! npos = textview_MoveBack(self, startpos=textview_GetDotPosition(self), 0 , textview_MoveByLines, NULL, NULL); ! npos = textview_MoveForward(self, npos, 1, textview_MoveByLines, NULL, NULL); ! if (npos > 0) { ! if (npos == dsize) { ! if (text_GetChar(d, npos-1) == '\n') npos--; ! if (npos < startpos) npos = startpos; ! } ! else if (text_GetChar(d, npos-1) == ' ' ) ! while (npos > startpos && (text_GetChar(d, npos-1)) == ' ') npos--; ! else if (text_GetChar(d, npos-1) == '\n') npos--; ! } ! textview_SetDotPosition(self, npos); ! textview_SetDotLength(self, 0); ! textview_FrameDot(self, npos); ! textview_WantUpdate(self, self); ! } ! ! void textview_BeginningOfLineCmd(self) ! register struct textview *self; ! { ! register int pos; ! ! if (textview_GetDotLength(self) != 0) { ! textview_SetDotLength(self,0); ! pos = textview_GetDotPosition(self); ! } ! else { ! pos = textview_MoveBack(self, textview_GetDotPosition(self),0, textview_MoveByLines, 0, 0); ! textview_SetDotPosition(self,pos); ! } ! textview_FrameDot(self, pos); ! textview_WantUpdate(self, self); ! } ! /* Switches the two characters before the dot. */ ! void textview_TwiddleCmd (self) ! register struct textview *self; ! { ! long pos; ! register struct text *text; ! char char1, char2; ! struct environment *env1, *env2; ! struct viewref *vr1, *vr2; ! ! if (ConfirmReadOnly(self)) ! return; ! ! textview_CollapseDot(self); ! text = Text(self); ! pos = textview_GetDotPosition(self); ! ! if (pos < 2 || text_GetReadOnly(text) == TRUE) ! return; ! ! char1 = text_GetChar(text, pos - 2); ! char2 = text_GetChar(text, pos - 1); ! ! text_ReplaceCharacters(text, pos - 2, 1, &char2, 1); ! text_ReplaceCharacters(text, pos - 1, 1, &char1, 1); ! ! /* Code to deal with VIEWREFCHARS -cm26 */ ! /* If a view must be moved, it's deleted then reinserted */ ! /* (environment_Update does not seem to work) */ ! /* The order of the following is kind of important */ ! ! env1 = environment_GetInnerMost(text->rootEnvironment, pos - 2); ! if (env1 != NULL) ! if (env1->type != environment_View) ! env1 = NULL; ! else { ! vr1 = env1->data.viewref; ! env1->data.viewref = NULL; /* Protect viewref from Delete */ ! environment_Delete(env1); ! } ! ! env2 = environment_GetInnerMost(text->rootEnvironment, pos - 1); ! if (env2 != NULL) ! if (env2->type != environment_View) ! env2 = NULL; ! else { ! vr2 = env2->data.viewref; ! env2->data.viewref = NULL; /* Protect viewref from Delete */ ! environment_Delete(env2); ! } ! if (env1 != NULL) ! environment_WrapView(text->rootEnvironment, ! pos - 1, 1, vr1); ! ! if (env2 != NULL) ! environment_WrapView(text->rootEnvironment, ! pos - 2, 1, vr2); ! textview_FrameDot(self, pos); ! text_NotifyObservers(text, observable_OBJECTCHANGED); ! } ! void textview_DeleteWordCmd (self) ! register struct textview *self; ! { ! register int count, pos, len; ! if (ConfirmReadOnly(self)) ! return; ! textview_CollapseDot(self); ! count = im_Argument(textview_GetIM(self)); ! im_ClearArg(textview_GetIM(self)); /* Don't want Fwd Word to use it! */ ! pos = textview_GetDotPosition(self); ! while (count--) ! textview_ForwardWordCmd(self); ! len = textview_GetDotPosition(self) - pos; ! if (ConfirmViewDeletion(self, pos, len)) { ! textview_DeleteCharacters(self, pos, len); ! im_SetLastCmd(textview_GetIM(self), lcInsertEnvironment); ! textview_FrameDot(self, pos); ! } ! } ! void textview_RuboutWordCmd (self) ! register struct textview *self; ! { ! register int count, endpos, len; ! if (ConfirmReadOnly(self)) ! return; ! textview_CollapseDot(self); ! count = im_Argument(textview_GetIM(self)); ! im_ClearArg(textview_GetIM(self)); /* Don't want Bkwd Word to use it! */ ! endpos = textview_GetDotPosition(self); ! while (count--) ! textview_BackwardWordCmd(self); ! len = endpos - textview_GetDotPosition(self); ! if (ConfirmViewDeletion(self, endpos - len, len)) { ! textview_DeleteCharacters(self, endpos, -len); ! im_SetLastCmd(textview_GetIM(self), lcInsertEnvironment); ! textview_FrameDot(self, endpos - len); ! } ! } ! void textview_ForwardWordCmd (self) ! register struct textview *self; ! { ! register int j, count, pos, dlen; ! register struct text *d; ! textview_CollapseDot(self); ! j = 0; ! count = im_Argument(textview_GetIM(self)); ! d=Text(self); ! pos=textview_GetDotPosition(self); ! dlen= text_GetLength(d); ! while (j0 && isalnum(text_GetChar(d,pos-1))==0) pos--; ! while (pos>0 && isalnum(text_GetChar(d,pos-1))!=0) pos--; ! j++; ! } ! textview_SetDotPosition(self,pos); ! textview_FrameDot(self, pos); ! textview_WantUpdate(self, self); ! } ! static void ShowArg(self) ! struct textview *self; ! { ! char buf[SRCHSTRLEN]; ! struct im_ArgState *as = im_GetArgState(textview_GetIM(self)); ! sprintf(buf, "Arg: %d", as->argument); ! message_DisplayString(self, 0, buf); ! } ! void textview_SetArgumentCmd (self) ! struct textview *self; ! { ! register struct im_ArgState *as; ! register long lcstate; ! long newArg; ! ! lcstate = im_GetLastCmd(textview_GetIM(self)); ! as = im_GetArgState(textview_GetIM(self)); ! as->argDigit = FALSE; ! newArg = 4; ! if (as->argProvided) { ! newArg = as->argument * 4; ! if (newArg > 65536) ! newArg = 65536; ! } ! im_ProvideArg(textview_GetIM(self), newArg); ! im_SetLastCmd(textview_GetIM(self), lcstate); /* be transparent */ ! ShowArg(self); ! } ! void textview_DigitCmd(self, c) ! struct textview *self; ! register char c; ! { ! register struct im_ArgState *as; ! register long lcstate; ! as = im_GetArgState(textview_GetIM(self)); ! if (as->argProvided) { ! long newArg; ! lcstate = im_GetLastCmd(textview_GetIM(self)); ! if (! as->argDigit) { ! as->argDigit = TRUE; ! as->argument = 0; ! } ! newArg = as->argument * 10 + (c - '0'); ! if (newArg > 65536) ! newArg = 65536; ! im_ProvideArg(textview_GetIM(self), newArg); ! im_SetLastCmd(textview_GetIM(self), lcstate); ! ShowArg(self); ! } else ! textview_SelfInsertCmd(self, c); ! } ! void textview_ChangeTemplate(self) ! struct textview *self; ! { ! char tname[150]; ! register struct text *d; ! int gf; ! ! if (ConfirmReadOnly(self)) ! return; ! ! d = Text(self); ! gf = message_AskForString(self, 0, ! "Add styles from template: ", 0, tname, 100); ! if (gf < 0) ! return; ! if (tname[0] == '\0') { /* no name specified */ ! message_DisplayString(self, 0, "No name specified."); ! return; ! } ! if (text_ReadTemplate(d, tname, text_GetLength(d) == 0) < 0) ! message_DisplayString(self, 100, "Could not read template file."); ! else { ! text_RegionModified(d, 0, text_GetLength(d)); ! text_NotifyObservers(d, observable_OBJECTCHANGED); ! message_DisplayString(self, 0, "Done."); ! } ! } ! static void AdjustCase(self, upper, firstOnly) ! struct textview *self; ! boolean upper, firstOnly; ! { ! long pos, len, count, i; ! boolean capitalize; ! if (ConfirmReadOnly(self)) ! return; ! pos = textview_GetDotPosition(self); ! len = textview_GetDotLength(self); ! count = len; ! ! if (len == 0) ! while (pos > 0 && isalnum(text_GetChar(Text(self), pos - 1))) ! pos--; ! ! capitalize = TRUE; ! ! while (pos < text_GetLength(Text(self))) { ! i = text_GetChar(Text(self), pos); ! if (len == 0) { ! if (! isalnum(i)) ! break; ! } else { ! if (--count < 0) ! break; ! } ! if (upper) { ! if ((capitalize || ! firstOnly) && islower(i)) { ! char new = toupper(i); ! text_ReplaceCharacters(Text(self), pos, 1, &new, 1); ! } ! else if(!capitalize && firstOnly && isupper(i)){ ! char new = tolower(i); ! text_ReplaceCharacters(Text(self), pos, 1, &new, 1); ! } ! } else if (isupper(i)) { ! char new = tolower(i); ! text_ReplaceCharacters(Text(self), pos, 1, &new, 1); ! } ! capitalize = isspace(i); ! pos++; ! } ! text_NotifyObservers(Text(self), observable_OBJECTCHANGED); ! } ! void textview_UppercaseWord(self, key) ! struct textview *self; ! long key; ! { ! AdjustCase(self, TRUE, FALSE); ! } ! void textview_LowercaseWord(self, key) ! struct textview *self; ! long key; ! { ! AdjustCase(self, FALSE, FALSE); ! } ! void textview_CapitalizeWord(self, key) ! struct textview *self; ! long key; ! { ! AdjustCase(self, TRUE, TRUE); ! } ! void textview_ToggleCase(self, key) ! struct textview *self; ! long key; ! { ! long pos = textview_GetDotPosition(self); ! int i; ! char new; ! ! if (ConfirmReadOnly(self)) ! return; ! ! i = text_GetChar(Text(self), pos); ! ! if (isupper(i)) ! new = tolower(i); ! else if (islower(i)) ! new = toupper(i); ! else ! new = i; ! text_ReplaceCharacters(Text(self), pos, 1, &new, 1); ! text_NotifyObservers(Text(self), observable_OBJECTCHANGED); ! textview_SetDotPosition(self, pos + 1); ! } ! void textview_CursorToLine(self, line) ! struct textview *self; ! long line; ! { ! if (line > 0 && line <= self->nLines) { ! textview_SetDotPosition(self, mark_GetPos(self->lines[line - 1].data)); ! textview_SetDotLength(self, 0); ! textview_WantUpdate(self, self); ! } ! } ! /* Useful commands for our editor. */ ! void textview_CursorToTop(self, key) ! struct textview *self; ! long key; ! { ! textview_CursorToLine(self, 1); ! } ! void textview_CursorToCenter(self, key) ! struct textview *self; ! long key; ! { ! textview_CursorToLine(self, self->nLines / 2); ! } ! void textview_CursorToBottom(self, key) ! struct textview *self; ! long key; ! { ! textview_CursorToLine(self, self->nLines); ! } ! void textview_GrabReference(self,key) ! struct textview *self; ! long key; ! { ! long pos,len; ! struct viewref *vr; ! struct text *d = Text(self); ! pos = textview_GetDotPosition(self); ! len = textview_GetDotLength(self); ! if (len == 0) len = text_GetLength(d) - pos; ! if ((vr = text_FindViewreference(d, pos, len)) == NULL) ! message_DisplayString(self, 0, "No References Found"); ! else ! d->currentViewreference = vr; ! } ! void textview_PlaceReference(self,key) ! struct textview *self; ! long key; ! { ! long pos; ! char p[250]; ! struct text *d = Text(self); ! boolean promptforname = im_ArgProvided(textview_GetIM(self)); ! ! im_ClearArg(textview_GetIM(self)); ! ! if (ConfirmReadOnly(self)) ! return; ! if(text_GetObjectInsertionFlag(Text(self)) == FALSE){ ! message_DisplayString(self, 0, "Object Insertion Not Allowed!"); ! return; ! } ! *p = '\0'; ! if(d->currentViewreference == NULL) { ! message_DisplayString(self, 0, "No References Found"); ! return; ! } ! pos = textview_GetDotPosition(self) + textview_GetDotLength(self); ! if(promptforname && message_AskForString (self, 0, "View to place here ", d->currentViewreference->viewType, p, 200) < 0) return; ! if (p[0] == '\0') strcpy(p,d->currentViewreference->viewType); ! if(objecttest(self,p,"view") == FALSE) return; ! text_AddView(d,pos,p, d->currentViewreference->dataObject); ! text_NotifyObservers(d,observable_OBJECTCHANGED); ! } ! void textview_CheckSpelling(self) ! struct textview *self; ! { ! message_DisplayString(self, 0, ! "Sorry; \"Check Spelling\" is not implemented."); ! } ! void textview_ToggleReadOnly(self) ! struct textview *self; ! { ! boolean argp = im_ArgProvided(textview_GetIM(self)), arg; ! struct text *myText = Text(self); ! if (argp) ! arg = im_Argument(textview_GetIM(self)); ! if ((argp && arg) || (!argp && text_GetReadOnly(myText))) /* In readonly mode. */ ! text_SetReadOnly(myText, FALSE); ! else ! text_SetReadOnly(myText, TRUE); ! if (text_GetReadOnly(myText)) ! message_DisplayString(self, 0, "Text is now read only."); ! else ! message_DisplayString(self, 0, "Text is now writable."); ! text_NotifyObservers(myText, observable_OBJECTCHANGED); /* Handles updating of menus on read only transition. */ ! } ! #define BADCURPOS -1 ! void textview_ToggleExposeStyles(self) ! struct textview *self; ! { ! self->exposeStyles = ! self->exposeStyles; ! self->force = TRUE; ! self->csxPos = BADCURPOS; /* Indication that cursor is not visible */ ! self->cexPos = BADCURPOS; ! textview_WantUpdate(self, self); ! } ! static void textview_InsertPageBreak (self) ! register struct textview *self; ! { ! long pos; ! struct text *d; ! d = Text(self); ! if(text_GetObjectInsertionFlag(d) == FALSE){ ! message_DisplayString(self, 0, "Object Insertion Not Allowed!"); ! return; ! } ! pos = textview_GetDotPosition(self); ! textview_PrepareInsertion(self); ! if(text_GetChar(d,pos) != '\n'){ ! text_InsertCharacters(d,pos,"\n",1); ! } ! if(text_GetChar(d,pos - 1) != '\n'){ ! text_InsertCharacters(d,pos,"\n",1); ! pos++; ! } ! /* self->currentViewreference = */ ! text_InsertObject(d, pos,"bp","bpv"); ! textview_FinishInsertion(self); ! text_NotifyObservers(d,observable_OBJECTCHANGED); ! if (im_GetLastCmd(textview_GetIM(self)) == lcInsertEnvironment) { ! im_SetLastCmd(textview_GetIM(self), lcInsertEnvironment); ! } ! } ! static void textview_NextPage (self) ! register struct textview *self; ! { ! long pos,len; ! struct text *d; ! struct viewref *vr; ! d = Text(self); ! len = text_GetLength(d); ! pos = textview_GetDotPosition(self); ! while ( pos <= len && (pos = text_Index(d,pos,TEXT_VIEWREFCHAR,len - pos)) != EOF){ ! if((vr = text_FindViewreference(d,pos,1)) != NULL && ! *(vr->viewType) == 'b' && ! strcmp(vr->viewType,"bpv") == 0){ ! textview_SetDotPosition(self,pos + 2); ! textview_SetTopPosition(self,pos + 2); ! break; ! } ! pos++; ! } ! } ! static long text_rindex(txt,pos,c) ! register struct text *txt; ! register long pos; ! register char c; ! { ! for(;pos > 0;pos--){ ! if(text_GetChar(txt,pos) == c) return pos; ! } ! return EOF; ! } ! static void textview_LastPage (self) ! register struct textview *self; ! { ! long pos,cnt; ! struct text *d; ! struct viewref *vr; ! d = Text(self); ! pos = textview_GetDotPosition(self); ! for ( cnt = 0;pos > 0 && (pos = text_rindex(d,pos,TEXT_VIEWREFCHAR)) != EOF;pos--){ ! if((vr = text_FindViewreference(d,pos,1)) != NULL && ! *(vr->viewType) == 'b' && ! strcmp(vr->viewType,"bpv") == 0){ ! if(cnt++ == 0) continue; ! textview_SetDotPosition(self,pos + 2); ! textview_SetTopPosition(self,pos + 2); ! return; ! } ! } ! textview_SetDotPosition(self,0); ! textview_SetTopPosition(self,0); ! } ! #if 0 ! static boolean lookforfootnote(self,text,pos,env) ! struct textview *self; ! struct text *text; ! long pos; ! struct environment *env; ! { ! struct style *st; ! char *sn; ! if(env->type == environment_Style) { ! st = env->data.style; ! if(st != NULL && ((sn = style_GetName(st)) != NULL) && ! *sn == 'f' && strcmp(sn,"footnote") == 0) return TRUE; ! } ! return FALSE; ! } ! #endif ! static void textview_InsertFootnote(self) ! register struct textview *self; ! { ! long pos; ! struct fnote *fn; ! if(text_GetObjectInsertionFlag(Text(self)) == FALSE){ ! message_DisplayString(self, 0, "Object Insertion Not Allowed!"); ! return; ! } ! pos = textview_GetDotPosition(self); ! #if 0 ! if(text_EnumerateEnvironments(Text(self),pos,0,lookforfootnote,NULL) != NULL){ ! message_DisplayString(self,0,"footnotes in footnotes not supported"); ! return; ! } ! #endif ! fn = fnote_New(); ! /* self->currentViewreference = text_InsertObject(Text(self), pos,"fnote","fnotev"); */ ! text_AddView(Text(self), pos,"fnotev",fn); ! fnote_addenv(fn,Text(self),pos); ! text_NotifyObservers(Text(self),observable_OBJECTCHANGED); ! textview_SetDotPosition(self,pos + 1); ! } ! static void textview_OpenFootnotes(self) ! register struct textview *self; ! { ! fnote_OpenAll(Text(self)); ! } ! static void textview_CloseFootnotes(self) ! register struct textview *self; ! { ! fnote_CloseAll(Text(self)); ! } ! static void textview_WriteFootnotes(self) ! register struct textview *self; ! { ! FILE *f,*fopen(); ! struct text *tmpt; ! f = fopen("/tmp/notes","w"); ! tmpt = text_New(); ! fnote_CopyAll(Text(self),tmpt,1,TRUE); ! text_Write(tmpt,f,0,0); ! fclose(f); ! text_Destroy(tmpt); ! } ! ! static void DoDisplayInsertEnvironment(self) ! struct textview *self; ! { ! struct text *d = Text(self); ! if (self->insertStack != NULL) { ! char outstr[1000]; ! char *name; ! ! name = self->insertStack->name; ! if (name == NULL) { ! name = "unknown"; ! } ! ! sprintf(outstr, "Current Insertion Style: %s (new)", name); ! message_DisplayString(self, 0, outstr); ! } ! else if (self->insertEnvironment == NULL) { ! message_DisplayString(self, 0, "Current Insertion Style: none"); ! } ! else if (self->insertEnvironment == d->rootEnvironment) { ! message_DisplayString(self, 0, "Current Insertion Style: default"); ! } ! else { ! char outstr[1000]; ! char *name; ! ! if (self->insertEnvironment->type != environment_Style) { ! name = "inset - need to fix this"; ! } ! else if ((name = self->insertEnvironment->data.style->name) == NULL) { ! name = "unknown"; ! } ! ! sprintf(outstr, "Current Insertion Style: %s", name); ! message_DisplayString(self, 0, outstr); ! } ! } ! ! static void textview_DisplayInsertEnvironment(self) ! struct textview *self; ! { ! long pos; ! ! if (ConfirmReadOnly(self)) ! return; ! ! textview_CollapseDot(self); ! ! pos = textview_GetDotPosition(self); ! ! self->insertEnvironment = textview_GetInsertEnvironment(self, pos); ! ! DoDisplayInsertEnvironment(self); ! ! im_SetLastCmd(textview_GetIM(self), lcInsertEnvironment); ! } ! ! ! static void textview_PlainInsertEnvironmentCmd(self) ! struct textview *self; ! { ! if (ConfirmReadOnly(self)) ! return; ! ! textview_CollapseDot(self); ! ! textview_PlainInsertEnvironment(self); ! ! im_SetLastCmd(textview_GetIM(self), lcInsertEnvironment); ! ! DoDisplayInsertEnvironment(self); ! } ! ! static void textview_UpInsertEnvironmentCmd(self) ! struct textview *self; ! { ! if (ConfirmReadOnly(self)) ! return; ! ! textview_CollapseDot(self); ! ! textview_UpInsertEnvironment(self); ! ! im_SetLastCmd(textview_GetIM(self), lcInsertEnvironment); ! DoDisplayInsertEnvironment(self); ! } ! static void textview_DownInsertEnvironmentCmd(self) ! struct textview *self; ! { ! if (ConfirmReadOnly(self)) ! return; ! textview_CollapseDot(self); ! textview_DownInsertEnvironment(self); ! im_SetLastCmd(textview_GetIM(self), lcInsertEnvironment); ! DoDisplayInsertEnvironment(self); ! } ! static void textview_LeftInsertEnvironmentCmd(self) ! struct textview *self; ! { ! if (ConfirmReadOnly(self)) ! return; ! textview_CollapseDot(self); ! textview_LeftInsertEnvironment(self); ! im_SetLastCmd(textview_GetIM(self), lcInsertEnvironment); ! DoDisplayInsertEnvironment(self); ! } ! static void textview_RightInsertEnvironmentCmd(self) ! struct textview *self; ! { ! if (ConfirmReadOnly(self)) ! return; ! textview_CollapseDot(self); ! textview_RightInsertEnvironment(self); ! ! im_SetLastCmd(textview_GetIM(self), lcInsertEnvironment); ! DoDisplayInsertEnvironment(self); ! } ! static boolean StyleCompletionWork(style, data) ! struct style *style; ! struct result *data; ! { ! completion_CompletionWork(style_GetName(style), data); ! return FALSE; ! } ! static enum message_CompletionCode StyleComplete(partial, styleSheet, resultStr, resultSize) ! char *partial; ! struct stylesheet *styleSheet; ! char *resultStr; ! int resultSize; ! { ! struct result result; ! char textBuffer[100]; ! *textBuffer = '\0'; ! result.partial = partial; ! result.partialLen = strlen(partial); ! result.bestLen = 0; ! result.code = message_Invalid; ! result.best = textBuffer; ! result.max = sizeof(textBuffer) - 1; /* Leave extra room for a NUL. */ ! ! stylesheet_EnumerateStyles(styleSheet, (procedure) StyleCompletionWork, (long) &result); ! ! strncpy(resultStr, result.best, resultSize); ! if (result.bestLen == resultSize) /* Now make sure buffer ends in a NUL. */ ! resultStr[result.bestLen] = '\0'; ! return result.code; ! } ! struct helpData { ! char *partial; ! int (*textFunction)(); ! long textRock; ! }; ! static boolean StyleHelpWork(style, helpData) ! struct style *style; ! struct helpData *helpData; ! { ! char infoBuffer[1024]; ! char strippedMenuName[1000]; ! char *p; ! char *q; ! char *r; ! ! if (completion_FindCommon(helpData->partial, ! style_GetName(style)) == strlen(helpData->partial)) { ! char *menuName; ! ! strippedMenuName[0] = '\0'; ! r = strippedMenuName; ! if ((menuName = style_GetMenuName(style)) != NULL) { ! q = menuName; ! while ((p = index(q, '~')) != NULL) { ! while (q != p) { ! *r++ = *q++; ! } ! while (*++p != ',' && *p != '\0') { ! } ! q = p; ! } ! *r = '\0'; ! } ! sprintf(infoBuffer, "%-16s %s", style_GetName(style), strippedMenuName); ! (*helpData->textFunction)(helpData->textRock, ! message_HelpListItem, infoBuffer, NULL); ! } ! return FALSE; /* Keep on enumerating. */ ! } ! static void StyleHelp(partial, styleSheet, helpTextFunction, helpTextRock) ! char *partial; ! struct stylesheet *styleSheet; ! int (*helpTextFunction)(); ! long helpTextRock; ! { ! struct helpData helpData; ! helpData.partial = partial; ! helpData.textFunction = helpTextFunction; ! helpData.textRock = helpTextRock; ! stylesheet_EnumerateStyles(styleSheet, (procedure) StyleHelpWork, (long) &helpData); ! } ! static void textview_InsertEnvironment(self, sName) ! struct textview *self; ! char *sName; ! { ! struct text *d = Text(self); ! struct stylesheet *ss = text_GetStyleSheet(d); ! char styleName[100]; ! struct style *style; ! long pos = textview_GetDotPosition(self); ! long len = textview_GetDotLength(self); ! long lastCmd; ! ! if (ConfirmReadOnly(self)) ! return; ! ! lastCmd = im_GetLastCmd(textview_GetIM(self)); ! self->insertEnvironment = textview_GetInsertEnvironment(self, pos + len); ! ! if (sName == NULL) { ! if (message_AskForStringCompleted(self, 0, "Insert style: ", ! NULL, styleName, ! sizeof(styleName), NULL, (procedure) StyleComplete, ! (procedure) StyleHelp, (long) ss, ! message_MustMatch | ! message_NoInitialString) == -1) { ! return; ! } ! } ! else { ! strcpy(styleName, sName); ! } ! style = stylesheet_Find(ss, styleName); ! if (style != NULL) { ! if (lastCmd != lcInsertEnvironment && len != 0) { ! /* We want to wrap the environment here and now */ ! if (text_AddStyle(d, pos, len, style) == NULL) { ! message_DisplayString(self, 0, ! "Sorry; can't add style."); ! } ! else { ! char message[200]; ! ! sprintf(message, "Added the style %s", styleName); ! message_DisplayString(self, 0, message); ! text_NotifyObservers(d, observable_OBJECTCHANGED); ! } ! } ! else { ! textview_AddStyleToInsertStack(self, styleName); ! im_SetLastCmd(textview_GetIM(self), lcInsertEnvironment); ! DoDisplayInsertEnvironment(self); ! } ! } ! else { ! char message[200]; ! sprintf(message, "Could not find the style %s", styleName); ! message_DisplayString(self, 0, message); ! } ! } ! char styleString[] = "textview-insert-environment"; ! static struct bind_Description textviewBindings[]={ ! {"textview-insert-environment", "\033s\033l", 0, NULL, 0, 0, textview_InsertEnvironment, "Prompt for a style to use for inserting characters."}, ! {"textview-show-insert-environment", "\033s\033?", 0, NULL, 0, 0, textview_DisplayInsertEnvironment, "Show the environment thet will be used for inserting characters."}, ! {"textview-left-insert-environment", "\033s\033D", 0, NULL, 0, 0, textview_LeftInsertEnvironmentCmd, "Move to the left the environment that will be used for inserting characters."}, ! {"textview-right-insert-environment", "\033s\033C", 0, NULL, 0, 0, textview_RightInsertEnvironmentCmd, "Move to the right the environment thet will be used for inserting characters."}, ! {"textview-up-insert-environment", "\033s\033A", 0, NULL, 0, 0, textview_UpInsertEnvironmentCmd, "Move up environment thet will be used for inserting characters."}, ! {"textview-down-insert-environment", "\033s\033B", 0, NULL, 0, 0, textview_DownInsertEnvironmentCmd, "Move down environment thet will be used for inserting characters."}, ! {"textview-up-insert-environment", "\033s\033u"}, ! {"textview-down-insert-environment", "\033s\033d"}, ! ! {styleString, "\033s\033i", (long) "italic"}, ! {styleString, "\033s\033b", (long) "bold"}, ! {styleString, "\033s\033^", (long) "superscript"}, ! {styleString, "\033s\033!", (long) "subscript"}, ! {styleString, "\033s\033_", (long) "underline"}, ! {styleString, "\033s\033t", (long) "typewriter"}, ! {styleString, "\033s\033+", (long) "bigger"}, ! {styleString, "\033s\033-", (long) "smaller"}, ! {styleString, "\033s\033=", (long) "center"}, ! {styleString, "\033s\033<", (long) "flushleft"}, ! {styleString, "\033s\033>", (long) "flushright"}, ! {styleString, "\033s\033\011", (long) "leftindent"}, ! {"textview-plainer", "\033s\033p", (long) "new", "Plainer~40", (long) "new", textview_NotReadOnlyMenus, textview_PlainerCmd, "Remove style."}, ! {"textview-plainer", "\030\020", (long) "new"}, ! {"textview-plainest","\033s\033P", 0,"Plainest~41", 0, textview_NotReadOnlyMenus, textview_PlainestCmd, "Remove all enclosing styles."}, ! {"textview-show-styles", "\033s\033s",0,NULL,0,0,textview_ShowStylesCmd,"Show styles at dot."}, - {"textview-beginning-of-line", "\001",0,NULL,0,0,textview_BeginningOfLineCmd,"Move to beginning of current line."}, - {"textview-beginning-of-line", "\033H",0}, - {"textview-backward-character", "\002",0,NULL,0,0,textview_BackwardCmd,"Move backward one character."}, - {"textview-backward-character", "\033D",0}, - {"textview-delete-next-character", "\004",0,NULL,0,0,textview_DeleteCmd,"Delete the next character."}, - {"textview-end-of-line", "\005",0,NULL,0,0,textview_EndOfLineCmd,"Move to end of the current line."}, - {"textview-end-of-line", "\033F",0}, - {"textview-forward-character", "\006",0,NULL,0,0,textview_ForwardCmd,"Move forward one character."}, - {"textview-forward-character", "\033C",0}, - {"textview-delete-previous-character", "\010",0,NULL,0,0,textview_RuboutCmd,"Delete the previous character."}, - {"textview-delete-previous-character", "\177",0}, - {"textview-insert-newline", "\015",0,NULL,0,0,textview_InsertNLCmd,"Insert a newline character."}, - {"textview-next-line", "\016",0,NULL,0,0,textview_NextLineCmd,"Move to next line."}, - {"textview-next-line", "\033B",0}, - {"textview-previous-line", "\020",0,NULL,0,0,textview_PreviousLineCmd,"Move to previous line."}, - {"textview-previous-line", "\033A",0}, - {"textview-set-argument", "\025",0,NULL,0,0,textview_SetArgumentCmd,"Set argument count."}, {"textview-indent", "\033i",0,NULL,0,0,textview_IndentCmd,"Indent current line."}, - {"textview-GrabReference", "\030w",0,NULL,0,0,textview_GrabReference,"Grab the next viewref"}, - - {"textview-PlaceReference", "\030y",0,NULL,0,0,textview_PlaceReference,"Create a new viewref"}, - {"textview-unindent", "\033u",0,NULL,0,0,textview_UnindentCmd,"Un-indent current line."}, - {"textview-exch", "\030\030",0,NULL,0,0,textview_ExchCmd,"Exchange dot and mark."}, - {"textview-select-region", "\033\200",0,NULL,0,0,textview_SelectRegionCmd,"Select between dot and mark."}, - {"textview-copy-region", "\033w",0,"Copy~11",0,textview_SelectionMenus,textview_CopyRegionCmd,"Copy region to kill-buffer."}, - - {"textview-mylf", "\012",0,NULL,0,0,textview_MyLfCmd,"Skip to next line and indent."}, - - {"textview-zap-region", "\027",0,"Cut~10",0, textview_SelectionMenus | textview_NotReadOnlyMenus,textview_ZapRegionCmd,"Remove the text within the selection region and place it in a cutbuffer."}, - {"textview-append-next-cut", "\033\027",0,NULL,0,0,textview_AppendNextCut, "Make next cut command append to the cutbuffer as opposed to making a new buffer."}, - {"textview-yank", "\031",0,"Paste~10",0,textview_NotReadOnlyMenus | textview_NoSelectionMenus,textview_YankCmd,"Yank text back from kill-buffer."}, - - {"textview-insert-file", "\030\t", 0,"File~10,Insert File~10",0,textview_NotReadOnlyMenus,textview_InsertFile,"Prompt for a filename and insert that file's contents into the document."}, - {"textview-rotate-backward-paste", "\033\031",0,NULL,0,0,textview_BackwardsRotatePasteCmd,"Rotate kill-buffer backwards."}, {"textview-line-to-top", "\033!",0,NULL,0,0,textview_LineToTopCmd,"Move current line to top of screen."}, --- 3,765 ---- * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/text/RCS/txtvcmds.c,v 2.61 1991/05/24 19:04:45 susan Exp $ */ /* $ACIS:txtvcmds.c 1.7$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/text/RCS/txtvcmds.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/text/RCS/txtvcmds.c,v 2.61 1991/05/24 19:04:45 susan Exp $"; #endif /* lint */ + #include + #include + #include #define AUXMODULE 1 #include + #include #include #include #include #include ! #include ! #include ! long lcKill; ! long lcYank; ! long lcMove; ! long lcDisplayEnvironment; long lcInsertEnvironment; long lcNewLine; ! extern void textview_AppendNextCut(); ! extern void textview_BackwardCmd(); ! extern void textview_BackwardParaCmd(); ! extern void textview_BackwardWSWordCmd(); ! extern void textview_BackwardWordCmd(); ! extern void textview_BackwardsRotatePasteCmd(); ! extern void textview_BalanceCmd(); ! extern void textview_BeginningOfFirstWordCmd(); ! extern void textview_BeginningOfLineCmd(); ! extern void textview_BeginningOfNextLineCmd(); ! extern void textview_BeginningOfPreviousLineCmd(); ! extern void textview_BeginningOfTextCmd(); ! extern void textview_CapitalizeWord(); ! extern void textview_ChangeLineCmd(); ! extern void textview_ChangeRestOfLineCmd(); ! extern void textview_ChangeSelectionCmd(); ! extern void textview_ChangeTemplate(); ! extern void textview_ChangeWordCmd(); ! extern void textview_CheckSpelling(); ! extern void textview_CloseFootnotes(); ! extern void textview_CopyRegionCmd(); ! extern void textview_CtrlAtCmd(); ! extern void textview_CursorToBottom(); ! extern void textview_CursorToCenter(); ! extern void textview_CursorToTop(); ! extern void textview_DeleteBackwardWSWordCmd(); ! extern void textview_DeleteBackwardWordCmd(); ! extern void textview_DeleteCmd(); ! extern void textview_DeleteEndOfWSWordCmd(); ! extern void textview_DeleteEndOfWordCmd(); ! extern void textview_DeleteWSWordCmd(); ! extern void textview_DeleteWordCmd(); ! extern void textview_ForeKillWordCmd(); ! extern void textview_DigitCmd(); ! extern void textview_DisplayInsertEnvironment(); ! extern void textview_DownCmd(); ! extern void textview_DownInsertEnvironmentCmd(); ! extern void textview_EndOfLineCmd(); ! extern void textview_EndOfTextCmd(); ! extern void textview_EndOfWSWordCmd(); ! extern void textview_EndOfWordCmd(); ! extern void textview_ExchCmd(); ! extern void textview_ExposeStyleEditor(); ! extern void textview_ForwardCmd(); ! extern void textview_ForwardParaCmd(); ! extern void textview_ForwardWSWordCmd(); ! extern void textview_ForwardWordCmd(); ! extern void textview_GlitchDownCmd(); ! extern void textview_GlitchUpCmd(); ! extern void textview_GoToLineCmd(); ! extern void textview_GotoParagraphCmd(); ! extern void textview_GrabReference(); ! extern void textview_IndentCmd(); ! extern void textview_InsertAtBeginningCmd(); ! extern void textview_InsertAtEndCmd(); ! extern void textview_InsertEnvironment(); ! extern void textview_InsertFile(); ! extern void textview_InsertFootnote(); ! extern void textview_InsertInsetCmd(); ! extern void textview_InsertNLCmd(); ! extern void textview_InsertPageBreak(); ! extern void textview_InsertSoftNewLineCmd(); ! extern void textview_JoinCmd(); ! extern void textview_KillLineCmd(); ! extern void textview_KillWhiteSpaceCmd(); ! extern void textview_LastPage(); ! extern void textview_LeftInsertEnvironmentCmd(); ! extern void textview_LineToTopCmd(); ! extern void textview_LowercaseWord(); ! extern void textview_MITKillLineCmd(); ! extern void textview_MyLfCmd(); ! extern void textview_MySoftLfCmd(); ! extern void textview_NextLineCmd(); ! extern void textview_NextPage(); ! extern void textview_NextScreenCmd(); ! extern void textview_OpenFootnotes(); ! extern void textview_OpenLineAfterCmd(); ! extern void textview_OpenLineBeforeCmd(); ! extern void textview_OpenLineCmd(); ! extern void textview_PlaceReference(); ! extern void textview_PlainerCmd(); ! extern void textview_PlainestCmd(); ! extern void textview_PrevScreenCmd(); ! extern void textview_PreviousLineCmd(); ! extern void textview_PutAfterCmd(); ! extern void textview_PutBeforeCmd(); ! extern void textview_QueryReplaceCmd(); ! extern void textview_QuoteCmd(); ! extern void textview_RSearchCmd(); ! extern void textview_ReplaceCharCmd(); ! extern void textview_RightInsertEnvironmentCmd(); ! extern void textview_RotatePasteCmd(); ! extern void textview_RuboutCmd(); ! extern void textview_RuboutWordCmd(); ! extern void textview_BackKillWordCmd(); ! extern void textview_SearchAgain(); ! extern void textview_SearchAgainOppositeCmd(); ! extern void textview_SearchCmd(); ! extern void textview_SelectRegionCmd(); ! extern void textview_SelfInsertCmd(); ! extern void textview_ShowStylesCmd(); ! extern void textview_SubstituteCharCmd(); ! extern void textview_ToggleCase(); ! extern void textview_ToggleEditorCmd(); ! extern void textview_ToggleExposeStyles(); ! extern void textview_ToggleReadOnly(); ! extern void textview_ToggleViModeCmd(); ! extern void textview_TwiddleCmd(); ! extern void textview_UnindentCmd(); ! extern void textview_UpCmd(); ! extern void textview_UpInsertEnvironmentCmd(); ! extern void textview_UppercaseWord(); ! extern void textview_ViCommandCmd(); ! extern void textview_ViDeleteCmd(); ! extern void textview_ViDeleteLineCmd(); ! extern void textview_ViYankLineCmd(); ! extern void textview_WhatParagraphCmd(); ! extern void textview_WriteFootnotes(); ! extern void textview_YankBackwardWSWordCmd(); ! extern void textview_YankBackwardWordCmd(); ! extern void textview_YankCmd(); ! extern void textview_YankEndOfWSWordCmd(); ! extern void textview_YankEndOfWordCmd(); ! extern void textview_YankLineCmd(); ! extern void textview_YankWSWordCmd(); ! extern void textview_YankWordCmd(); ! extern void textview_ZapRegionCmd(); ! ! void textview_NOOPCmd (self) ! register struct textview *self; ! { ! /* Do nothing. Used to rebind keys for no operation */ ! } ! ! /* ! * CharType determines what kind of character has been passed ! * and is used or forward/backward word operations ! */ ! ! charType(c) ! register char c; ! { ! ! if (isspace(c)) ! return (WHITESPACE); ! else if ( isalpha(c) || isdigit(c) || c == '_' ) ! return (WORD); ! else ! return(SPECIAL); ! } ! char styleString[] = "textview-insert-environment"; ! /****** EMACS key bindings ********/ ! static struct bind_Description textviewEmacsBindings[]={ ! {"textview-show-styles", "\033s",0,NULL,0,0,textview_ShowStylesCmd,"Show styles at dot."}, ! {"textview-show-styles", "\033'\033s", 0, NULL, 0, 0, textview_ShowStylesCmd, "Show styles at dot."}, ! {"textview-noop", NULL, 0, NULL, 0, 0, textview_NOOPCmd, "Do absolutely nothing."}, ! {"textview-insert-environment", "\033'\033l", 0, NULL, 0, 0, textview_InsertEnvironment, "Prompt for a style to use for inserting characters."}, ! {"textview-show-insert-environment", "\033'\033?", 0, NULL, 0, 0, textview_DisplayInsertEnvironment, "Show the environment that will be used for inserting characters."}, ! {"textview-left-insert-environment", "\033'\033D", 0, NULL, 0, 0, textview_LeftInsertEnvironmentCmd, "Move to the left the environment that will be used for inserting characters."}, ! {"textview-right-insert-environment", "\033'\033C", 0, NULL, 0, 0, textview_RightInsertEnvironmentCmd, "Move to the right the environment that will be used for inserting characters."}, ! {"textview-up-insert-environment", "\033'\033A", 0, NULL, 0, 0, textview_UpInsertEnvironmentCmd, "Move up environment that will be used for inserting characters."}, ! {"textview-down-insert-environment", "\033'\033B", 0, NULL, 0, 0, textview_DownInsertEnvironmentCmd, "Move down environment that will be used for inserting characters."}, ! {"textview-up-insert-environment", "\033'\033u"}, ! {"textview-down-insert-environment", "\033'\033d"}, ! ! {styleString, "\033'\033i", (long) "italic"}, ! {styleString, "\033'\033b", (long) "bold"}, ! {styleString, "\033'\033^", (long) "superscript"}, ! {styleString, "\033'\033!", (long) "subscript"}, ! {styleString, "\033'\033_", (long) "underline"}, ! {styleString, "\033'\033t", (long) "typewriter"}, ! {styleString, "\033'\033+", (long) "bigger"}, ! {styleString, "\033'\033-", (long) "smaller"}, ! {styleString, "\033'\033=", (long) "center"}, ! {styleString, "\033'\033<", (long) "flushleft"}, ! {styleString, "\033'\033>", (long) "flushright"}, ! {styleString, "\033'\033\011", (long) "leftindent"}, ! {"textview-plainer", "\033'\033p", (long) "new", "Plainer~40", (long) "new", textview_NotReadOnlyMenus, textview_PlainerCmd, "Remove style."}, ! {"textview-plainer", "\030\020", (long) "new"}, ! {"textview-plainest","\033'\033P", 0,"Plainest~41", 0, textview_NotReadOnlyMenus, textview_PlainestCmd, "Remove all enclosing styles."}, ! {"textview-beginning-of-line", "\001",0,NULL,0,0,textview_BeginningOfLineCmd,"Move to beginning of current line."}, ! {"textview-beginning-of-line", "\033H",0}, ! {"textview-backward-character", "\002",0,NULL,0,0,textview_BackwardCmd,"Move backward one character."}, ! {"textview-backward-character", "\033D",0}, ! {"textview-delete-next-character", "\004",0,NULL,0,0,textview_DeleteCmd,"Delete the next character."}, ! {"textview-end-of-line", "\005",0,NULL,0,0,textview_EndOfLineCmd,"Move to end of the current line."}, ! {"textview-end-of-line", "\033F",0}, ! {"textview-forward-character", "\006",0,NULL,0,0,textview_ForwardCmd,"Move forward one character."}, ! {"textview-forward-character", "\033C",0}, ! {"textview-delete-previous-character", "\010",0,NULL,0,0,textview_RuboutCmd,"Delete the previous character."}, ! {"textview-delete-previous-character", "\177",0}, ! {"textview-insert-newline", "\015",0,NULL,0,0,textview_InsertNLCmd,"Insert a newline character."}, ! {"textview-insert-soft-newline", "\033\015",0,NULL,0,0,textview_InsertSoftNewLineCmd,"Insert a soft newline character."}, ! {"textview-next-line", "\016",0,NULL,0,0,textview_NextLineCmd,"Move to next line."}, ! {"textview-next-line", "\033B",0}, ! {"textview-previous-line", "\020",0,NULL,0,0,textview_PreviousLineCmd,"Move to previous line."}, ! {"textview-previous-line", "\033A",0}, ! {"textview-indent", "\033i",0,NULL,0,0,textview_IndentCmd,"Indent current line."}, ! {"textview-GrabReference", "\030w",0,NULL,0,0,textview_GrabReference,"Grab the next viewref"}, ! {"textview-PlaceReference", "\030y",0,NULL,0,0,textview_PlaceReference,"Create a new viewref"}, ! {"textview-unindent", "\033u",0,NULL,0,0,textview_UnindentCmd,"Un-indent current line."}, ! {"textview-exch", "\030\030",0,NULL,0,0,textview_ExchCmd,"Exchange dot and mark."}, ! {"textview-select-region", "\033\200",0,NULL,0,0,textview_SelectRegionCmd,"Select between dot and mark."}, ! {"textview-copy-region", "\033w",0,"Copy~11",0,textview_SelectionMenus,textview_CopyRegionCmd,"Copy region to kill-buffer."}, ! {"textview-mylf", "\012",0,NULL,0,0,textview_MyLfCmd,"Skip to next line and indent."}, ! {"textview-my-soft-lf", "\033j",0,NULL,0,0,textview_MySoftLfCmd,"Skip to next line/soft return and indent."}, ! {"textview-zap-region", "\027",0,"Cut~10",0, textview_SelectionMenus | textview_NotReadOnlyMenus,textview_ZapRegionCmd,"Remove the text within the selection region and place it in a cutbuffer."}, ! {"textview-append-next-cut", "\033\027",0,NULL,0,0,textview_AppendNextCut, "Make next cut command append to the kill-buffer as opposed to making a new buffer."}, + {"textview-yank", "\031",0,"Paste~10",0,textview_NotReadOnlyMenus | textview_NoSelectionMenus,textview_YankCmd,"Yank text back from kill-buffer."}, ! {"textview-insert-file", "\030\t", 0,"File~10,Insert File~10",0,textview_NotReadOnlyMenus,textview_InsertFile,"Prompt for a filename and insert that file's contents into the document."}, ! {"textview-rotate-backward-paste", "\033\031",0,NULL,0,0,textview_BackwardsRotatePasteCmd,"Rotate kill-buffer backwards."}, ! {"textview-line-to-top", "\033!",0,NULL,0,0,textview_LineToTopCmd,"Move current line to top of screen."}, ! {"textview-rotate-paste", "\033y",0,NULL,0,0,textview_RotatePasteCmd,"Rotate kill-buffer."}, ! ! {"textview-forward-para", "\033]",0,NULL,0,0,textview_ForwardParaCmd,"Move to the next paragraph."}, ! {"textview-backward-para", "\033[",0,NULL,0,0,textview_BackwardParaCmd,"Move to the previous paragraph."}, ! {"textview-open-line", "\017",0,NULL,0,0,textview_OpenLineCmd,"Insert blank line at dot"}, ! {"textview-prev-screen", "\033v",0,NULL,0,0,textview_PrevScreenCmd,"Move back to previous screen"}, ! {"textview-prev-screen", "\033G",0}, ! {"textview-next-screen", "\026",0,NULL,0,0,textview_NextScreenCmd,"Move forward to next screen"}, ! {"textview-next-screen", "\033E",0}, ! {"textview-glitch-down", "\021",0,NULL,0,0,textview_GlitchDownCmd,"Glitch screen down one line."}, ! {"textview-glitch-down", "\033z",0}, ! {"textview-glitch-up", "\032",0,NULL,0,0,textview_GlitchUpCmd,"Glitch screen up one line."}, ! {"textview-twiddle-chars", "\024",0,NULL,0,0,textview_TwiddleCmd,"Exchange previous two chars."}, ! {"textview-kill-line", "\013",0,NULL,0,0,textview_KillLineCmd,"Kill rest of line."}, ! {"textview-MIT-kill-line", NULL,0,NULL,0,0,textview_MITKillLineCmd,"Kill rest of line."}, ! {"textview-search", "\023",0,"Search/Spell~1,Forward~10",0,0,(void (*)())textview_SearchCmd,"Search forward."}, ! {"textview-reverse-search", "\022",0,"Search/Spell~1,Backward~11",0,0,(void (*)())textview_RSearchCmd,"Search backward."}, ! {"textview-search-again",NULL,0,"Search/Spell~1,Search Again~12",0,0,textview_SearchAgain,"Repeat last search."}, ! {"textview-insert-inset-here", "\033\t",0,NULL,0,0,textview_InsertInsetCmd,"Add inset at this location."}, ! {"textview-what-paragraph", "\033N",0,NULL,0,0,textview_WhatParagraphCmd,"Print current paragraph number."}, ! {"textview-goto-paragraph", "\033n",0,NULL,0,0,textview_GotoParagraphCmd,"Go to specific paragraph."}, ! {"textview-query-replace", "\033q",0,"Search/Spell~1,Query Replace~20",0,textview_NotReadOnlyMenus,textview_QueryReplaceCmd,"Query replace."}, ! #ifdef IBM ! {"spell-check-document",NULL,0,"Search/Spell~1,Check Spelling~30", 0,textview_NotReadOnlyMenus,textview_CheckSpelling,"Checks spelling from the caret on.", "spell"}, ! #else /* IBM */ ! {"spell-check-document",NULL,0,"Search/Spell~1,Check Spelling~30", 0,textview_NotReadOnlyMenus,NULL,"Checks spelling from dot to end.", "spell"}, ! #endif /* IBM */ ! {"textview-quote", "\030\021",0,NULL,0,0,textview_QuoteCmd,"Uninterpreted insert of any char or octal code."}, ! {"textview-kill-white-space", "\033k",0,NULL,0,0,textview_KillWhiteSpaceCmd,"Delete spaces and tabs around dot"}, ! {"textview-ctrl-at", "\200",0,NULL,0,0,textview_CtrlAtCmd,"Set a mark."}, ! {"textview-backward-word", "\033b",0,NULL,0,0,textview_BackwardWordCmd,"Move backward to beginning of word."}, ! {"textview-delete-next-word", "\033d",0,NULL,0,0,textview_DeleteWordCmd,"Delete the next word."}, ! {"textview-kill-next-word", NULL,0,NULL,0,0,textview_ForeKillWordCmd,"Kill the next word, saving it on the kill ring."}, ! {"textview-forward-word", "\033f",0,NULL,0,0,textview_ForwardWordCmd,"Move forward to end of word."}, ! {"textview-delete-previous-word", "\033h",0,NULL,0,0,textview_RuboutWordCmd,"Delete the previous word."}, ! {"textview-delete-previous-word", "\033\b",0,NULL,0,0,textview_RuboutWordCmd,NULL}, ! {"textview-delete-previous-word", "\033\177",0,NULL,0,0,textview_RuboutWordCmd,NULL}, ! {"textview-kill-previous-word", NULL,0,NULL,0,0,textview_BackKillWordCmd,"Kill the previous word, saving it on the kill ring."}, ! {"textview-end-of-text", "\033>",0,NULL,0,0,textview_EndOfTextCmd,"Move to end of text."}, ! {"textview-beginning-of-text", "\033<",0,NULL,0,0,textview_BeginningOfTextCmd,"Move to beginning of text."}, ! {"textview-toggle-character-case", "\036",0,NULL,0,0,textview_ToggleCase,"Toggle the case of the character at the dot."}, ! {"textview-lowercase-word", "\033l",0,NULL,0,0,textview_LowercaseWord,"Convert word (or region) to lower case."}, ! {"textview-uppercase-word",NULL,0,NULL,0,0,textview_UppercaseWord,"Convert word (or region) to upper case."}, ! {"textview-capitalize-word",NULL,0,NULL,0,0,textview_CapitalizeWord,"Capitalize word (or all words within a region)."}, ! {"textview-cursor-to-top", "\033,",0,NULL,0,0,textview_CursorToTop,"Moves cursor to the beginning of the line currently at the top of the screen."}, ! {"textview-cursor-to-bottom", "\033.",0,NULL,0,0,textview_CursorToBottom,"Moves cursor to the beginning of the line currently at the bottom of the screen."}, ! {"textview-cursor-to-center", "\033/",0,NULL,0,0,textview_CursorToCenter,"Moves cursor to the beginning of the line currently at the center of the screen."}, ! {"textview-change-template",NULL,0,"File~10,Add Template~31",0,textview_NotReadOnlyMenus,textview_ChangeTemplate, "Change to named template."}, ! {"textview-toggle-read-only", "\033~",0,NULL,0,0,textview_ToggleReadOnly,"Change read only status of text object."}, ! {"textview-toggle-expose-styles", NULL,0,NULL,0,0,textview_ToggleExposeStyles,"Expose/hide style information"}, ! {"textview-edit-styles", NULL, 0, NULL, 0, textview_NotReadOnlyMenus, textview_ExposeStyleEditor,"Expose style editor"}, ! {"lookzview-edit-styles", NULL, 0, "File~10,Edit Styles~30", 0, textview_NotReadOnlyMenus, NULL,"Bring up style editor in separate window", "lookzview"}, ! {"textview-insert-pagebreak", NULL,0,"Page~9,Insert Pagebreak~11",0,textview_NotReadOnlyMenus,textview_InsertPageBreak,"Add page break at this location."}, ! {"textview-next-page", NULL,0,"Page~9,Next Page~12",0,0,textview_NextPage,"Frame text at next page break object"}, ! {"textview-last-page", NULL,0,"Page~9,Previous Page~13",0,0,textview_LastPage,"Frame text at last page break object"}, ! {"textview-insert-footnote", NULL,0,"Page~9,Insert Footnote~20",0,textview_NotReadOnlyMenus,textview_InsertFootnote,"Add footnote at this location."}, ! {"contentv-make-window", NULL,0,"Page~9,Table of Contents~30",0,0,NULL,"Make a table of contents window","contentv"}, ! {"textview-open-footnotes",NULL,0,"Page~9,Open Footnotes~22",0,0,textview_OpenFootnotes,"Open all footnotes"}, ! {"textview-close-footnotes",NULL,0,"Page~9,Close Footnotes~23",0,0,textview_CloseFootnotes,"Close all footnotes"}, ! {"textview-write-footnotes",NULL,0,NULL,0,0,textview_WriteFootnotes,"Write all footnotes"}, ! {"textview-toggle-editor", "\033t",0,NULL,0,0,textview_ToggleEditorCmd, "Switch to vi editor."}, ! {"textview-balance", "\033m",0,NULL,0,0,textview_BalanceCmd,"Balance parentheses, brackets, or braces."}, ! NULL ! }; ! static void CheckStylePreferences(newKeymap, normalMenus) ! struct keymap *newKeymap; ! struct menulist **normalMenus; { ! struct proctable_Entry *pl; ! ! /* ! This code is here to handle allow users to select which style ! of plainer that they want to use: old or new ! */ ! if (! environ_GetProfileSwitch("UseNewStylePlainer", TRUE)) { ! pl = proctable_Lookup("textview-plainer"); ! keymap_BindToKey(newKeymap, "\030\020", pl, (long) "old"); ! if (normalMenus != NULL && *normalMenus != NULL) { ! menulist_AddToML(*normalMenus, "Plainer~40", pl, (long) "old", textview_NotReadOnlyMenus); } ! pl = proctable_Lookup("textview-plainest"); ! if (normalMenus != NULL && *normalMenus != NULL) { ! menulist_AddToML(*normalMenus, "Plainest~40", pl, 0, textview_SelectionMenus | textview_NotReadOnlyMenus); } } ! /* Override binding of our stylizing prefix char with noop */ ! if (! environ_GetProfileSwitch("UseStyleKeybindings", TRUE)) { ! pl = proctable_Lookup("textview-noop"); ! keymap_BindToKey(newKeymap, "\033'", pl, NULL); ! } ! } ! /* These two procs ripped out of basics/common/init.c */ ! /* Translate a key sequence that has ^A, \ddd, and \c conventions. */ ! static int TranslateKeySequence(from, to) ! char *from; ! char *to; { ! while (*from != '\0') { ! if (*from == '\\') { ! int temp = parseBackslashed(&from); ! if (temp == -1) ! return -1; else ! *to++ = temp; ! } ! else if (*from == '^') { ! ++from; ! if (*from == 0) ! return -1; ! *to++ = (*from++) & 0x1f; } + else + *to++ = *from++; } ! *to++ = 0; ! return 0; } ! static int parseBackslashed(fromChars) ! char **fromChars; { ! int returnChar; ! char *from = *fromChars; ! static char *bsSource = "ebrnt"; ! static char *bsDest = "\033\b\r\n\t"; ! ! if (*from == '\\') { ! ++from; ! if (*from == 0) ! return -1; ! if (isdigit(*from)) { ! ! int sum = 0, i; ! ! for (i = 0; i < 3; ++i) { ! if (!isdigit(*from)) ! break; ! if (*from == '8' || *from == '9') ! return -1; ! sum = sum * 8 + *from - '0'; ! ++from; } ! returnChar = sum; } ! else { ! char *p; ! p = index(bsSource, *from); ! if (p != NULL) ! returnChar = bsDest[p-bsSource]; ! else ! returnChar = *from; ! ++from; ! } } else ! return -1; ! *fromChars = from; ! return returnChar; } ! static adjustBindings(bindings) ! struct bind_Description *bindings; { ! struct bind_Description *bd; ! char *stylePrefixPref; ! char stylePrefixStr[100]; ! ! stylePrefixPref = environ_GetProfile("StyleCommandPrefix"); ! if (stylePrefixPref != NULL) { ! if (TranslateKeySequence(stylePrefixPref, stylePrefixStr) >= 0) { ! long plen = strlen(stylePrefixStr); ! ! for (bd = bindings; bd != NULL && (bd->procName || bd->keyVector || bd->menuEntry); bd++) { ! if (bd->keyVector != NULL){ ! if (strcmp(bd->keyVector, stylePrefixStr) == 0) { ! bd->keyVector = NULL; } ! else if (bd->keyVector[0] == '\033' && bd->keyVector[1] == '\'') { ! long vlen = strlen(bd->keyVector); ! char *oldVector = bd->keyVector; ! ! if (bd->keyVector = (char *) malloc(plen + vlen - 1)) { ! strcpy(bd->keyVector, stylePrefixStr); ! strcat(bd->keyVector, &oldVector[2]); ! } } } ! } ! } } } ! struct keymap *textview_InitEmacsKeyMap(classInfo, normalMenus) ! struct textview_classinfo *classInfo; ! struct menulist **normalMenus; { + struct keymap *newKeymap = keymap_New(); register long i; ! char str[2]; ! struct proctable_Entry *si; ! if(normalMenus!=NULL) ! *normalMenus=menulist_New(); ! lcKill = im_AllocLastCmd(); ! lcYank = im_AllocLastCmd(); ! lcMove = im_AllocLastCmd(); ! lcDisplayEnvironment = im_AllocLastCmd(); ! lcInsertEnvironment = im_AllocLastCmd(); ! lcNewLine = im_AllocLastCmd(); ! adjustBindings(textviewEmacsBindings); ! bind_BindList(textviewEmacsBindings, newKeymap, *normalMenus, classInfo); ! si=proctable_DefineProc("textview-self-insert", (procedure) textview_SelfInsertCmd, classInfo, NULL, "Insert a character."); ! str[0] = ' '; ! str[1] = '\0'; ! for (i = 32; i < 127; i++) { ! keymap_BindToKey(newKeymap, str, si, i); ! str[0]++; } ! /* add bindings for iso keyboards */ ! str[0] = (unsigned char ) 160; ! for (i = 160 ; i < 256; i++) { ! keymap_BindToKey(newKeymap, str, si, i); ! str[0]++; } ! keymap_BindToKey(newKeymap, "\t", si, '\t'); ! CheckStylePreferences(newKeymap, normalMenus); ! /* Disable keystroke conversion to VI commands unless preference specifically allows it. */ ! if (! environ_GetProfileSwitch("AllowKeyToggleToVIMode", FALSE)) { ! si = proctable_Lookup("textview-noop"); ! keymap_BindToKey(newKeymap, "\033t", si, NULL); } ! return newKeymap; } ! /*************** VI Command mode key bindings *********************/ ! static struct bind_Description textviewViCommandModeBindings[]={ ! {"textview-noop", NULL, 0, NULL, 0, 0, textview_NOOPCmd, "Do absolutely nothing."}, ! {"textview-vi-command", ":",0,NULL,0,0,textview_ViCommandCmd, "Execute a vi command via commmand line."}, ! {"textview-input-mode", "a",0,NULL,0,0,textview_ToggleViModeCmd, "Switch to input mode."}, ! {"textview-input-mode", "i",0}, ! {"textview-toggle-editor", "\033t",0,NULL,0,0,textview_ToggleEditorCmd, "Switch to emacs editor."}, ! {"textview-open-line-before", "O",0,NULL,0,0,textview_OpenLineBeforeCmd, "Insert a new line before the current line."}, ! {"textview-open-line-after", "o",0,NULL,0,0,textview_OpenLineAfterCmd, "Insert a new line after the current line."}, ! {"textview-insert-at-beginning", "I",0,NULL,0,0,textview_InsertAtBeginningCmd,"Insert at beginning of current line."}, ! {"textview-insert-at-end", "A",0,NULL,0,0,textview_InsertAtEndCmd,"Insert at end of current line."}, ! {"textview-change-rest-of-line", "C",0,NULL,0,0,textview_ChangeRestOfLineCmd,"Replace rest of current line."}, ! {"textview-change-rest-of-line", "S",0}, ! {"textview-change-line", "cc",0,NULL,0,0,textview_ChangeLineCmd,"Replace current line."}, ! {"textview-change-word", "cw",0,NULL,0,0,textview_ChangeWordCmd,"Replace current word."}, ! {"textview-change-selection", "cs",0,NULL,0,0,textview_ChangeSelectionCmd,"Replace current selection."}, ! {"textview-replace-char", "r",0,NULL,0,0,textview_ReplaceCharCmd,"Replace character after cursor."}, ! {"textview-substitute-char", "s",0,NULL,0,0,textview_SubstituteCharCmd,"Insert over character after cursor."}, ! {"textview-beginning-of-previous-line", "-",0,NULL,0,0,textview_BeginningOfPreviousLineCmd,"Move to beginning of previous line."}, ! {"textview-beginning-of-next-line", "+",0,NULL,0,0,textview_BeginningOfNextLineCmd,"Move to beginning of next line."}, ! {"textview-beginning-of-next-line", "\015",0}, ! {"textview-beginning-of-first-word", "^",0,NULL,0,0,textview_BeginningOfFirstWordCmd,"Move to beginning of first word on current line."}, ! {"textview-backward-character", "\010",0,NULL,0,0,textview_BackwardCmd,"Move backward one character."}, ! {"textview-backward-character", "h",0}, ! {"textview-backward-character", "\177",0}, ! {"textview-backward-character", "\033D",0}, ! ! {"textview-vi-delete-next-character", "x",0,NULL,0,0,textview_ViDeleteCmd,"Delete the next character."}, ! {"textview-end-of-line", "$",0,NULL,0,0,textview_EndOfLineCmd,"Move to end of the current line."}, ! {"textview-end-of-line", "\033F",0}, ! {"textview-beginning-of-line", "0",0,NULL,0,0,textview_BeginningOfLineCmd,"Move to beginning of current line."}, ! {"textview-beginning-of-line", "\033H",0}, ! {"textview-forward-character", "040",0,NULL,0,0,textview_ForwardCmd,"Move forward one character."}, ! {"textview-forward-character", "l",0}, + {"textview-forward-character", "\011",0}, ! {"textview-forward-character", " ",0}, ! {"textview-forward-character", "\033C",0}, ! {"textview-delete-previous-character", "X",0,NULL,0,0,textview_RuboutCmd,"Delete the previous character."}, ! {"textview-next-line", "\016",0,NULL,0,0,textview_NextLineCmd,"Move to next line."}, ! {"textview-next-line", "\012",0}, ! {"textview-next-line", "j",0}, ! {"textview-next-line", "\033B",0}, ! {"textview-previous-line", "\020",0,NULL,0,0,textview_PreviousLineCmd,"Move to previous line."}, ! {"textview-previous-line", "\013",0}, ! {"textview-previous-line", "k",0}, ! {"textview-previous-line", "\033A",0}, ! {"textview-shift-up", "\005",0,NULL,0,0,textview_GlitchUpCmd,"Shift display up one line."}, ! {"textview-shift-down", "\031",0,NULL,0,0,textview_GlitchDownCmd,"Shift display down one line."}, ! {"textview-GrabReference", "\030w",0,NULL,0,0,textview_GrabReference,"Grab the next viewref"}, ! {"textview-PlaceReference", "\030y",0,NULL,0,0,textview_PlaceReference,"Create a new viewref"}, ! {"textview-exch", "\030\030",0,NULL,0,0,textview_ExchCmd,"Exchange dot and mark."}, ! {"textview-copy-region", "ys",0,"Copy~11",0,textview_SelectionMenus,textview_CopyRegionCmd,"Yank region to kill-buffer."}, ! {"textview-zap-region", "ds",0,"Cut~10",0, textview_SelectionMenus | textview_NotReadOnlyMenus,textview_ZapRegionCmd,"Remove the text within the selection region and place it in a cutbuffer."}, ! {"textview-yank", NULL,0,"Paste~10",0,textview_NotReadOnlyMenus | textview_NoSelectionMenus,textview_YankCmd,"Yank text back from kill-buffer."}, ! {"textview-put-before", "P",0,NULL,0,0,textview_PutBeforeCmd,"Put text back from kill-buffer, before current line."}, ! {"textview-put-after", "p",0,NULL,0,0,textview_PutAfterCmd,"Put text back from kill-buffer, after current line."}, ! {"textview-insert-file", ":r", 0,"File~10,Insert File~10",0,textview_NotReadOnlyMenus,textview_InsertFile,"Prompt for a filename and insert that file's contents into the document."}, ! {"textview-forward-para", "}",0,NULL,0,0,textview_ForwardParaCmd,"Move to the next paragraph."}, ! {"textview-backward-para", "{",0,NULL,0,0,textview_BackwardParaCmd,"Move to the next paragraph."}, ! {"textview-prev-screen", "\002",0,NULL,0,0,textview_PrevScreenCmd,"Move forward to previous screen"}, ! {"textview-prev-screen", "\033G",0}, ! {"textview-next-screen", "\006",0,NULL,0,0,textview_NextScreenCmd,"Move forward to next screen"}, ! {"textview-next-screen", "\033E",0}, ! {"textview-down", "\004",0,NULL,0,0,textview_DownCmd,"Move down. "}, ! {"textview-up", "\025",0,NULL,0,0,textview_UpCmd,"Move up. "}, ! {"textview-go-to", "G",0,NULL,0,0,textview_GoToLineCmd,"Go to line number."}, ! {"textview-go-to", "g",0}, ! {"textview-balance", "%",0,NULL,0,0,textview_BalanceCmd,"Balnce parentheses, brackets, or braces."}, ! {"textview-twiddle-chars", "\024",0,NULL,0,0,textview_TwiddleCmd,"Exchange previous two chars."}, ! {"textview-kill-line", "D",0,NULL,0,0,textview_KillLineCmd,"Kill rest of line."}, ! {"textview-kill-line", "d$",0}, ! {"textview-yank-line", "y$",0,NULL,0,0,textview_YankLineCmd,"Yank rest of line."}, ! {"textview-vi-delete-line", "dd",0,NULL,0,0,textview_ViDeleteLineCmd,"Delete line."}, ! {"textview-vi-yank-line", "yy",0,NULL,0,0,textview_ViYankLineCmd,"Yank line."}, ! {"textview-vi-yank-line", "Y",0}, ! {"textview-join", "J",0,NULL,0,0,textview_JoinCmd,"Join current and next line."}, ! {"textview-backward-word", "b",0,NULL,0,0,textview_BackwardWordCmd,"Move backward to beginning of word."}, ! {"textview-backward-whitespace-word", "B",0,NULL,0,0,textview_BackwardWSWordCmd,"Move backward to beginning of word separateded by whitespace."}, ! {"textview-end-of-word", "e",0,NULL,0,0,textview_EndOfWordCmd,"Move forward to end of word."}, ! {"textview-end-of-whitespace-word", "E",0,NULL,0,0,textview_EndOfWSWordCmd,"Move forward to end of word separated by whitespace."}, ! {"textview-forward-beginning-of-word", "w",0,NULL,0,0,textview_ForwardWordCmd,"Move forward to beginning of word."}, ! {"textview-forward-whitespace-word", "W",0,NULL,0,0,textview_ForwardWSWordCmd,"Move forward to beginning of word separated space."}, ! {"textview-delete-next-word", "dw",0,NULL,0,0,textview_DeleteWordCmd,"Delete the next word."}, ! {"textview-yank-next-word", "yw",0,NULL,0,0,textview_YankWordCmd,"Yank the next word."}, ! {"textview-delete-end-of-word", "de",0,NULL,0,0,textview_DeleteEndOfWordCmd,"Delete end of word."}, ! {"textview-yank-end-of-word", "ye",0,NULL,0,0,textview_YankEndOfWordCmd,"Yank end of word."}, ! {"textview-delete-backward-word", "db",0,NULL,0,0,textview_DeleteBackwardWordCmd,"Delete the previous word."}, ! {"textview-yank-previous-word", "yb",0,NULL,0,0,textview_YankBackwardWordCmd,"Yank the previous word."}, ! {"textview-delete-next-whitespace-word", "dW",0,NULL,0,0,textview_DeleteWSWordCmd,"Delete the next word separated by whitespace."}, ! {"textview-yank-next-whitespace-word", "yW",0,NULL,0,0,textview_YankWSWordCmd,"Yank the next word separated by whitespace."}, ! {"textview-delete-end-of-whitespace-word", "dE",0,NULL,0,0,textview_DeleteEndOfWSWordCmd,"Delete end of word separated by whitespace."}, ! {"textview-yank-end-of-whitespace-word", "yE",0,NULL,0,0,textview_YankEndOfWSWordCmd,"Yank end of word separated by whitespace."}, ! {"textview-delete-previous-whitespace-word", "dB",0,NULL,0,0,textview_DeleteBackwardWSWordCmd,"Delete the previous word separated by whitespace."}, ! {"textview-yank-previous-whitespace-word", "yB",0,NULL,0,0,textview_YankBackwardWSWordCmd,"Yank the previous word separated by whitespace."}, ! {"dynsearch-search-forward", "/",0,"Search/Spell~1,Forward~10",0,0,NULL,NULL}, ! {"dynsearch-search-backward", "?",0,"Search/Spell~1,Backward~11",0,0, NULL, NULL}, ! {"dynsearch-search-again","n",0,"Search/Spell~1,Search Again~12",0,0, NULL, NULL}, ! {"dynsearch-search-again-opposite", "N", 0, NULL, 0, 0, NULL, NULL}, ! {"textview-query-replace", "\033q",0,"Search/Spell~1,Query Replace~20",0,textview_NotReadOnlyMenus,textview_QueryReplaceCmd,"Query replace."}, ! #ifdef IBM ! {"spell-check-document",NULL,0,"Search/Spell~1,Check Spelling~30", 0,textview_NotReadOnlyMenus,textview_CheckSpelling,"Checks spelling from the caret on.", "spell"}, ! #else ! {"spell-check-document",NULL,0,"Search/Spell~1,Check Spelling~30", 0,textview_NotReadOnlyMenus,NULL,"Checks spelling from the caret on.", "spell"}, ! #endif ! {"textview-ctrl-at", "\200",0,NULL,0,0,textview_CtrlAtCmd,"Set a mark."}, ! {"textview-cursor-to-top", "H",0,NULL,0,0,textview_CursorToTop,"Moves cursor to the beggining of the line currently at the top of the screen."}, ! {"textview-cursor-to-bottom", "L",0,NULL,0,0,textview_CursorToBottom,"Moves cursor to the beginning of the line currently at the bottom of the screen."}, ! {"textview-cursor-to-center", "M",0,NULL,0,0,textview_CursorToCenter,"Moves cursor to the beginning of the line currently at the center of the screen."}, ! {"textview-change-template",NULL,0,"File~10,Add Template~31",0,textview_NotReadOnlyMenus,textview_ChangeTemplate, NULL, "Change to named template."}, + /*************** from original textview **************/ {"textview-indent", "\033i",0,NULL,0,0,textview_IndentCmd,"Indent current line."}, {"textview-unindent", "\033u",0,NULL,0,0,textview_UnindentCmd,"Un-indent current line."}, {"textview-select-region", "\033\200",0,NULL,0,0,textview_SelectRegionCmd,"Select between dot and mark."}, {"textview-append-next-cut", "\033\027",0,NULL,0,0,textview_AppendNextCut, "Make next cut command append to the cutbuffer as opposed to making a new buffer."}, {"textview-rotate-backward-paste", "\033\031",0,NULL,0,0,textview_BackwardsRotatePasteCmd,"Rotate kill-buffer backwards."}, {"textview-line-to-top", "\033!",0,NULL,0,0,textview_LineToTopCmd,"Move current line to top of screen."}, *************** *** 2797,2829 **** {"textview-rotate-paste", "\033y",0,NULL,0,0,textview_RotatePasteCmd,"Rotate kill-buffer."}, - {"textview-forward-para", "\033]",0,NULL,0,0,textview_ForwardParaCmd,"Move to the next paragraph."}, - - {"textview-backward-para", "\033[",0,NULL,0,0,textview_BackwardParaCmd,"Move to the next paragraph."}, - - {"textview-open-line", "\017",0,NULL,0,0,textview_OpenLineCmd,"Insert blank line at current pos."}, - - {"textview-prev-screen", "\033v",0,NULL,0,0,textview_PrevScreenCmd,"Move forward to previous screen"}, - {"textview-prev-screen", "\033G",0}, - - {"textview-next-screen", "\026",0,NULL,0,0,textview_NextScreenCmd,"Move forward to next screen"}, - {"textview-next-screen", "\033E",0}, - - {"textview-glitch-down", "\021",0,NULL,0,0,textview_GlitchDownCmd,"Glitch screen down one line."}, - {"textview-glitch-down", "\033z",0}, - - {"textview-glitch-up", "\032",0,NULL,0,0,textview_GlitchUpCmd,"Glitch screen up one line."}, - - {"textview-twiddle-chars", "\024",0,NULL,0,0,textview_TwiddleCmd,"Exchange previous two chars."}, - - {"textview-kill-line", "\013",0,NULL,0,0,textview_KillLineCmd,"Kill rest of line."}, - - {"textview-search", "\023",0,"Search/Spell~1,Forward~10",0,0,(void (*)())textview_SearchCmd,"Search forward."}, - - {"textview-reverse-search", "\022",0,"Search/Spell~1,Backward~11",0,0,(void (*)())textview_RSearchCmd,"Search backward."}, - - {"textview-search-again",NULL,0,"Search/Spell~1,Search Again~12",0,0,textview_SearchAgain,"Repeat last search."}, - {"textview-insert-inset-here", "\033\t",0,NULL,0,0,textview_InsertInsetCmd,"Add inset at this location."}, {"textview-what-paragraph", "\033N",0,NULL,0,0,textview_WhatParagraphCmd,"Print current paragraph number."}, --- 766,771 ---- *************** *** 2830,2837 **** {"textview-goto-paragraph", "\033n",0,NULL,0,0,textview_GotoParagraphCmd,"Go to specific paragraph."}, - {"textview-query-replace", "\033q",0,"Search/Spell~1,Query Replace~20",0,textview_NotReadOnlyMenus,textview_QueryReplaceCmd,"Query replace."}, - #ifdef IBM {"spell-check-document",NULL,0,"Search/Spell~1,Check Spelling~30", 0,textview_NotReadOnlyMenus,textview_CheckSpelling,"Checks spelling from the caret on.", "spell"}, #else /* IBM */ --- 772,777 ---- *************** *** 2838,2866 **** {"spell-check-document",NULL,0,"Search/Spell~1,Check Spelling~30", 0,textview_NotReadOnlyMenus,NULL,"Checks spelling from the caret on.", "spell"}, #endif /* IBM */ - {"textview-quote", "\030\021",0,NULL,0,0,textview_QuoteCmd,"Uninterpreted insert of any char or octal code."}, - {"textview-kill-white-space", "\033k",0,NULL,0,0,textview_KillWhiteSpaceCmd,"Delete spaces and tabs around the current pos."}, - {"textview-ctrl-at", "\200",0,NULL,0,0,textview_CtrlAtCmd,"Set a mark."}, - - {"textview-backward-word", "\033b",0,NULL,0,0,textview_BackwardWordCmd,"Move backward to beginning of word."}, - {"textview-delete-next-word", "\033d",0,NULL,0,0,textview_DeleteWordCmd,"Delete the next word."}, - {"textview-forward-word", "\033f",0,NULL,0,0,textview_ForwardWordCmd,"Move forward to end of word."}, - {"textview-delete-previous-word", "\033h",0,NULL,0,0,textview_RuboutWordCmd,"Delete the previous word."}, - {"textview-delete-previous-word", "\033\b",0,NULL,0,0,textview_RuboutWordCmd,NULL}, - {"textview-delete-previous-word", "\033\177",0,NULL,0,0,textview_RuboutWordCmd,NULL}, - {"textview-end-of-text", "\033>",0,NULL,0,0,textview_EndOfTextCmd,"Move to end of text."}, - {"textview-beginning-of-text", "\033<",0,NULL,0,0,textview_BeginningOfTextCmd,"Move to beginning of text."}, {"textview-toggle-character-case", "\036",0,NULL,0,0,textview_ToggleCase,"Toggle the case of the character at the dot."}, {"textview-lowercase-word", "\033l",0,NULL,0,0,textview_LowercaseWord,"Convert word (or region) to lower case."}, {"textview-uppercase-word",NULL,0,NULL,0,0,textview_UppercaseWord,"Convert word (or region) to upper case."}, {"textview-capitalize-word",NULL,0,NULL,0,0,textview_CapitalizeWord,"Capitalize word (or all words within a region)."}, - {"textview-cursor-to-top", "\033,",0,NULL,0,0,textview_CursorToTop,"Moves cursor to the beginning of the line currently at the top of the screen."}, - {"textview-cursor-to-bottom", "\033.",0,NULL,0,0,textview_CursorToBottom,"Moves cursor to the beginning of the line currently at the bottom of the screen."}, - {"textview-cursor-to-center", "\033/",0,NULL,0,0,textview_CursorToCenter,"Moves cursor to the beginning of the line currently at the center of the screen."}, - - {"textview-change-template",NULL,0,"File~10,Add Template~31",0,textview_NotReadOnlyMenus,textview_ChangeTemplate, NULL, "Change to named template."}, {"textview-toggle-read-only", "\033~",0,NULL,0,0,textview_ToggleReadOnly,"Change read only status of text object."}, {"textview-toggle-expose-styles", NULL,0,NULL,0,0,textview_ToggleExposeStyles,"Expose/hide style information"}, --- 778,789 ---- *************** *** 2871,2914 **** {"textview-insert-footnote", NULL,0,"Page~9,Insert Footnote~20",0,textview_NotReadOnlyMenus,textview_InsertFootnote,"Add footnote at this location."}, {"contentv-make-window", NULL,0,"Page~9,Table of Contents~30",0,0,NULL,"Make a table of contents window","contentv"}, {"textview-open-footnotes",NULL,0,"Page~9,Open Footnotes~22",0,0,textview_OpenFootnotes,"Open all footnotes"}, ! {"textview-close-footnotes",NULL,0,"Page~9,Close Footnotes~23",0,0,textview_CloseFootnotes,"Close all footnotes"}, ! {"textview-write-footnotes",NULL,0,NULL,0,0,textview_WriteFootnotes,"Write all footnotes"}, NULL ! }; ! struct keymap *textview_InitKeyMap(classInfo, normalMenus) struct textview_classinfo *classInfo; ! struct menulist **normalMenus; { struct keymap *newKeymap = keymap_New(); register long i; ! unsigned char str[2]; ! struct proctable_Entry *si,*dig, *pl; ! ! if(normalMenus!=NULL) ! *normalMenus=menulist_New(); ! lcKill = im_AllocLastCmd(); ! lcYank = im_AllocLastCmd(); ! lcMove = im_AllocLastCmd(); ! lcDisplayEnvironment = im_AllocLastCmd(); ! lcInsertEnvironment = im_AllocLastCmd(); ! lcNewLine = im_AllocLastCmd(); ! bind_BindList(textviewBindings, newKeymap, *normalMenus, classInfo); ! si=proctable_DefineProc("textview-self-insert", (procedure) textview_SelfInsertCmd, classInfo, NULL, "Insert a character."); ! dig=proctable_DefineProc("textview-digit", (procedure) textview_DigitCmd, classInfo, NULL, "Insert a character."); str[0] = ' '; str[1] = '\0'; for (i = 32; i < 127; i++) { ! if (i < '0' || i > '9') ! keymap_BindToKey(newKeymap, str, si, i); ! else ! keymap_BindToKey(newKeymap, str, dig, i); str[0]++; } /* add bindings for iso keyboards */ --- 794,924 ---- {"textview-insert-footnote", NULL,0,"Page~9,Insert Footnote~20",0,textview_NotReadOnlyMenus,textview_InsertFootnote,"Add footnote at this location."}, {"contentv-make-window", NULL,0,"Page~9,Table of Contents~30",0,0,NULL,"Make a table of contents window","contentv"}, {"textview-open-footnotes",NULL,0,"Page~9,Open Footnotes~22",0,0,textview_OpenFootnotes,"Open all footnotes"}, ! {"textview-close-footnotes",NULL,0,"Page~9,Close Footnotes~23",0,0, textview_CloseFootnotes,"Close all footnotes"}, ! {"textview-write-footnotes", NULL,0,NULL,0,0, textview_WriteFootnotes,"Write all footnotes"}, ! ! ! {"textview-show-styles", "\033s",0,NULL,0,0,textview_ShowStylesCmd,"Show styles at dot."}, ! {"textview-show-styles", "\033'\033s", 0, NULL, 0, 0, textview_ShowStylesCmd, "Show styles at dot."}, ! ! {"textview-insert-environment", "\033'\033l", 0, NULL, 0, 0, textview_InsertEnvironment, "Prompt for a style to use for inserting characters."}, ! {"textview-show-insert-environment", "\033'\033?", 0, NULL, 0, 0, textview_DisplayInsertEnvironment, "Show the environment that will be used for inserting characters."}, ! {"textview-left-insert-environment", "\033'\033D", 0, NULL, 0, 0, textview_LeftInsertEnvironmentCmd, "Move to the left the environment that will be used for inserting characters."}, ! {"textview-right-insert-environment", "\033'\033C", 0, NULL, 0, 0, textview_RightInsertEnvironmentCmd, "Move to the right the environment that will be used for inserting characters."}, ! {"textview-up-insert-environment", "\033'\033A", 0, NULL, 0, 0, textview_UpInsertEnvironmentCmd, "Move up environment that will be used for inserting characters."}, ! {"textview-down-insert-environment", "\033'\033B", 0, NULL, 0, 0, textview_DownInsertEnvironmentCmd, "Move down environment that will be used for inserting characters."}, ! {"textview-up-insert-environment", "\033'\033u"}, ! {"textview-down-insert-environment", "\033'\033d"}, ! ! {styleString, "\033'\033i", (long) "italic"}, ! {styleString, "\033'\033b", (long) "bold"}, ! {styleString, "\033'\033^", (long) "superscript"}, ! {styleString, "\033'\033!", (long) "subscript"}, ! {styleString, "\033'\033_", (long) "underline"}, ! {styleString, "\033'\033t", (long) "typewriter"}, ! {styleString, "\033'\033+", (long) "bigger"}, ! {styleString, "\033'\033-", (long) "smaller"}, ! {styleString, "\033'\033=", (long) "center"}, ! {styleString, "\033'\033<", (long) "flushleft"}, ! {styleString, "\033'\033>", (long) "flushright"}, ! {styleString, "\033'\033\011", (long) "leftindent"}, ! ! {"textview-plainer", "\033'\033p", (long) "new", "Plainer~40", (long) "new", textview_NotReadOnlyMenus, textview_PlainerCmd, "Remove style."}, ! {"textview-plainer", "\030\020", (long) "new"}, ! {"textview-plainest","\033'\033P", 0,"Plainest~41", 0, textview_NotReadOnlyMenus, textview_PlainestCmd, "Remove all enclosing styles."}, ! NULL ! }; ! struct keymap *textview_InitViCommandModeKeyMap(classInfo, Menus) struct textview_classinfo *classInfo; ! struct menulist **Menus; { struct keymap *newKeymap = keymap_New(); register long i; ! char str[2]; ! struct proctable_Entry *dig; ! adjustBindings(textviewViCommandModeBindings); ! bind_BindList(textviewViCommandModeBindings, newKeymap, NULL, classInfo); + dig=proctable_DefineProc("textview-digit", (procedure) textview_DigitCmd, classInfo, NULL, "Insert a character."); + + str[0] = ' '; + str[1] = '\0'; + for (i = str[0] = '0'; i <= '9'; i = ++str[0]) + keymap_BindToKey(newKeymap, str, dig, i); ! CheckStylePreferences(newKeymap, Menus); ! return newKeymap; ! } ! ! /*************** VI Input mode key bindings *********************/ ! static struct bind_Description textviewViInputModeBindings[]={ ! ! {"textview-noop", NULL, 0, NULL, 0, 0, textview_NOOPCmd, "Do absolutely nothing."}, ! ! {"textview-delete-previous-character", "\010",0,NULL,0,0,textview_RuboutCmd,"Delete the previous character."}, ! ! {"textview-delete-previous-character", "\177",0}, ! ! {"textview-insert-newline", "\015",0,NULL,0,0,textview_InsertNLCmd,"Insert a newline."}, ! ! {"textview-toggle-mode", "\033\033",0,NULL,0,0,textview_ToggleViModeCmd,"Switch to command mode. "}, ! ! {"textview-toggle-mode", "\005",0}, ! ! {"textview-show-styles", "\033s",0,NULL,0,0,textview_ShowStylesCmd,"Show styles at dot."}, ! {"textview-show-styles", "\033'\033s", 0, NULL, 0, 0, textview_ShowStylesCmd, "Show styles at dot."}, ! ! {"textview-insert-environment", "\033'\033l", 0, NULL, 0, 0, textview_InsertEnvironment, "Prompt for a style to use for inserting characters."}, ! {"textview-show-insert-environment", "\033'\033?", 0, NULL, 0, 0, textview_DisplayInsertEnvironment, "Show the environment that will be used for inserting characters."}, ! {"textview-left-insert-environment", "\033'\033D", 0, NULL, 0, 0, textview_LeftInsertEnvironmentCmd, "Move to the left the environment that will be used for inserting characters."}, ! {"textview-right-insert-environment", "\033'\033C", 0, NULL, 0, 0, textview_RightInsertEnvironmentCmd, "Move to the right the environment that will be used for inserting characters."}, ! {"textview-up-insert-environment", "\033'\033A", 0, NULL, 0, 0, textview_UpInsertEnvironmentCmd, "Move up environment that will be used for inserting characters."}, ! {"textview-down-insert-environment", "\033'\033B", 0, NULL, 0, 0, textview_DownInsertEnvironmentCmd, "Move down environment that will be used for inserting characters."}, ! {"textview-up-insert-environment", "\033'\033u"}, ! {"textview-down-insert-environment", "\033'\033d"}, ! ! {styleString, "\033'\033i", (long) "italic"}, ! {styleString, "\033'\033b", (long) "bold"}, ! {styleString, "\033'\033^", (long) "superscript"}, ! {styleString, "\033'\033!", (long) "subscript"}, ! {styleString, "\033'\033_", (long) "underline"}, ! {styleString, "\033'\033t", (long) "typewriter"}, ! {styleString, "\033'\033+", (long) "bigger"}, ! {styleString, "\033'\033-", (long) "smaller"}, ! {styleString, "\033'\033=", (long) "center"}, ! {styleString, "\033'\033<", (long) "flushleft"}, ! {styleString, "\033'\033>", (long) "flushright"}, ! {styleString, "\033'\033\011", (long) "leftindent"}, ! ! {"textview-plainer", "\033'\033p", (long) "new", "Plainer~40", (long) "new", textview_NotReadOnlyMenus, textview_PlainerCmd, "Remove style."}, ! {"textview-plainer", "\030\020", (long) "new"}, ! {"textview-plainest","\033'\033P", 0,"Plainest~41", 0, textview_NotReadOnlyMenus, textview_PlainestCmd, "Remove all enclosing styles."}, ! ! NULL ! }; ! ! struct keymap *textview_InitViInputModeKeyMap(classInfo, Menus) ! struct textview_classinfo *classInfo; ! struct menulist **Menus; ! { ! struct keymap *newKeymap = keymap_New(); ! register long i; ! unsigned char str[2]; ! struct proctable_Entry *si, *proc; + adjustBindings(textviewViInputModeBindings); + bind_BindList(textviewViInputModeBindings, newKeymap, NULL, classInfo); + + si=proctable_DefineProc("textview-self-insert", (procedure) textview_SelfInsertCmd, classInfo, NULL, "Insert a character."); str[0] = ' '; str[1] = '\0'; for (i = 32; i < 127; i++) { ! keymap_BindToKey(newKeymap, str, si, i); str[0]++; } /* add bindings for iso keyboards */ *************** *** 2919,2942 **** } keymap_BindToKey(newKeymap, "\t", si, '\t'); ! /* ! This code is here to handle allow users to select which style ! of plainer that they want to use: old or new ! */ ! ! ! if (! environ_GetProfileSwitch("UseNewStylePlainer", FALSE)) { ! pl = proctable_Lookup("textview-plainer"); ! keymap_BindToKey(newKeymap, "\030\020", pl, (long) "old"); ! menulist_AddToML(*normalMenus, "Plainer~40", pl, (long) "old", textview_NotReadOnlyMenus); ! pl = proctable_Lookup("textview-plainest"); ! menulist_AddToML(*normalMenus, "Plainest~40", pl, 0, textview_SelectionMenus | textview_NotReadOnlyMenus); ! } ! ! if (! environ_GetProfileSwitch("UseStyleKeybindings", FALSE)) { ! pl = proctable_Lookup("textview-show-styles"); ! keymap_BindToKey(newKeymap, "\033s", pl, NULL); ! } return newKeymap; } --- 929,936 ---- } keymap_BindToKey(newKeymap, "\t", si, '\t'); ! CheckStylePreferences(newKeymap, Menus); return newKeymap; } + *** atk/text/txtvinfo.h Fri Dec 21 14:35:19 1990 --- atk/text/txtvinfo.h.NEW Fri Dec 14 16:56:43 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/text/RCS/txtvinfo.h,v 2.10 90/08/23 14:43:08 tpn Exp $ */ /* $ACIS:txtvinfo.h 1.3$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/text/RCS/txtvinfo.h,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsidtextviewinfo = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/text/RCS/txtvinfo.h,v 2.10 90/08/23 14:43:08 tpn 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/text/RCS/txtvinfo.h,v 2.11 90/12/14 15:04:19 ajp Exp $ */ /* $ACIS:txtvinfo.h 1.3$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/text/RCS/txtvinfo.h,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsidtextviewinfo = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/text/RCS/txtvinfo.h,v 2.11 90/12/14 15:04:19 ajp Exp $"; #endif /* !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) */ #include *************** *** 77,82 **** --- 77,83 ---- short *myWidths; /* Width table for current font */ boolean pBreak; /* True if char is first in a paragraph */ boolean endOfPara; /* True if line is last line in a para. */ + int below; /* Below of line including spacing/spread */ int lineBelow; /* Below of tallest font/view on line */ int textBelow; /* Below of tallest font on line */ int lineAbove; /* Above of tallest font on line */ *************** *** 98,101 **** --- 99,109 ---- long predrawnEnd; struct lineitem *itemAtDot; long lastFontPos; + boolean continued; /* True if line extends past the end of page */ }; + + /* defines used by charType in txtvcmds.c */ + #define WHITESPACE 0 + #define WORD 1 + #define SPECIAL 2 + *** atk/text/txtvcsty.c Fri Dec 21 14:59:42 1990 --- atk/text/txtvcsty.c.NEW Thu May 9 16:35:17 1991 *************** *** 3,19 **** * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/text/RCS/txtvcsty.c,v 1.2 90/10/18 17:03:39 ajp Exp $ */ ! /* $ACIS:txtvcsty.c 1.7$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/text/RCS/txtvcsty.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/text/RCS/txtvcsty.c,v 1.2 90/10/18 17:03:39 ajp Exp $"; #endif /* lint */ #include #define AUXMODULE 1 #include #include #include --- 3,21 ---- * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/text/RCS/txtvcsty.c,v 1.4 1991/05/09 17:10:54 dba Exp $ */ ! /* $ACIS:txtvmod.c 1.7$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/text/RCS/txtvcsty.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/text/RCS/txtvcsty.c,v 1.4 1991/05/09 17:10:54 dba Exp $"; #endif /* lint */ + #include #include #define AUXMODULE 1 #include + #include #include #include *************** *** 27,33 **** #include #include - #include #include #include #include --- 29,34 ---- *************** *** 37,42 **** --- 38,44 ---- #define DELETE_RIGHT 2 #define Text(v) (struct text *) ((v)->header.view.dataobject) + void textview_InsertEnvironment(); extern long lcNewLine; extern long lcInsertEnvironment; *************** *** 305,312 **** } } ! void textview__PrepareInsertion(self) struct textview *self; { long pos = textview_GetDotPosition(self) + textview_GetDotLength(self); long ePos; --- 307,315 ---- } } ! void textview__PrepareInsertion(self, insertingNewLine) struct textview *self; + boolean insertingNewLine; { long pos = textview_GetDotPosition(self) + textview_GetDotLength(self); long ePos; *************** *** 363,369 **** } } else if (lastCmd != lcNewLine) { ! if (pos == 0 || text_GetChar(d, pos - 1) == '\n') { /* Need to turn off the endings of any environments that stop at pos and turn on the beginnings of any environments --- 366,372 ---- } } else if (lastCmd != lcNewLine) { ! if (! insertingNewLine && (pos == 0 || text_GetChar(d, pos - 1) == '\n')) { /* Need to turn off the endings of any environments that stop at pos and turn on the beginnings of any environments *************** *** 634,640 **** self->insertEnvironment = te; } ! InitializeMod() { flipEndMax = 4; flipEndEnvs = (struct environment **) malloc(sizeof(struct environment *) * flipEndMax); --- 637,1179 ---- self->insertEnvironment = te; } ! /* This is no longer a command you can type; ! * it is now called from a menu item */ ! ! void textview__LookCmd(self, look) ! register struct textview *self; ! int look; ! { ! register struct text *d; ! struct stylesheet *ss; ! struct style *styleptr; ! char *name; ! ! if (ConfirmReadOnly(self)) ! return; ! ! d = Text(self); ! ss = text_GetStyleSheet(d); ! ! if (ss != NULL) { ! styleptr = ss->styles[look]; ! if ((name = style_GetName(styleptr)) != NULL) { ! textview_InsertEnvironment(self, name); ! return; ! } ! } ! ! message_DisplayString(self, 0, "Sorry; can't add style."); ! } ! ! void textview_PlainerCmd(self, type) ! register struct textview *self; ! char *type; ! { ! register struct text *d; ! register struct environment *env; ! int pos, len; ! ! if (ConfirmReadOnly(self)) ! return; ! ! d = Text(self); ! pos = textview_GetDotPosition(self); ! len = textview_GetDotLength(self); ! if (im_GetLastCmd(textview_GetIM(self)) == lcDisplayEnvironment && (env = self->displayEnvironment) != NULL && env != d->rootEnvironment) { ! pos = environment_Eval(env); ! len = env->header.nestedmark.length; ! environment_Delete(env); ! text_SetModified(d); ! im_SetLastCmd(textview_GetIM(self), lcDisplayEnvironment); ! self->displayEnvironment = NULL; ! message_DisplayString(self, 0, ""); ! } ! else if (len == 0) { ! if (strcmp(type, "old") == 0) { ! env = environment_GetInnerMost(d->rootEnvironment, pos); ! if (env == NULL || env == d->rootEnvironment) return; ! pos = environment_Eval(env); ! len = env->header.nestedmark.length; ! environment_Delete(env); ! text_SetModified(d); ! } ! else { ! textview_UpInsertEnvironment(self); ! im_SetLastCmd(textview_GetIM(self), lcInsertEnvironment); ! return; ! } ! } ! else { ! if (environment_Remove(d->rootEnvironment, pos, len, environment_Style, FALSE)) ! text_SetModified(d); ! } ! text_RegionModified(d, pos, len); ! text_NotifyObservers(d, observable_OBJECTCHANGED); ! } ! ! void textview_PlainestCmd(self) ! register struct textview *self; ! { ! register struct text *d; ! int pos, len; ! ! if (ConfirmReadOnly(self)) ! return; ! ! d = Text(self); ! pos = textview_GetDotPosition(self); ! len = textview_GetDotLength(self); ! if (len == 0) { ! textview_PlainInsertEnvironment(self); ! im_SetLastCmd(textview_GetIM(self), lcInsertEnvironment); ! return; ! } ! else if (environment_Remove(d->rootEnvironment, ! pos, len, environment_Style, TRUE)) ! text_SetModified(d); ! text_RegionModified(d, pos, len); ! text_NotifyObservers(d, observable_OBJECTCHANGED); ! } ! ! /* Inserts a lookz view in front of the current paragraph. */ ! ! void textview_ExposeStyleEditor(self) ! struct textview *self; ! { ! register int pos; ! register struct text *d; ! ! if(objecttest(self, "lookzview", "view") == FALSE) ! return; ! if(objecttest(self, "lookz", "dataobject") == FALSE) ! return; ! if(text_GetObjectInsertionFlag(Text(self)) == FALSE){ ! message_DisplayString(self, 0, "Object Insertion Not Allowed!"); ! return; ! } ! ! d = Text(self); ! pos = text_GetBeginningOfLine(d, textview_GetDotPosition(self) + textview_GetDotLength(self)); ! ! /* If we can insert it between two carriage returns (or at the beginning of the ! * document) do so, otherwise insert it at the start of this paragraph. */ ! if (pos > 0 && text_GetChar(d, pos - 1) != '\n') ! pos += 1; ! ! textview_PrepareInsertion(self, FALSE); ! self->currentViewreference = ! text_InsertObject(Text(self), pos, "lookz", "lookzview"); ! textview_FinishInsertion(self); ! textview_FrameDot(self, pos); ! text_NotifyObservers(d, observable_OBJECTCHANGED); ! if (im_GetLastCmd(textview_GetIM(self)) == lcInsertEnvironment) { ! im_SetLastCmd(textview_GetIM(self), lcInsertEnvironment); ! } ! } ! ! #define SHOWSIZE 250 ! ! void textview_ShowStylesCmd(self) ! register struct textview *self; ! { ! char tbuf[SHOWSIZE]; ! register char *tp; ! struct environment *te; ! struct environment *de = NULL; ! struct text *d; ! int curLen, flag; ! long pos; ! ! curLen = 1; /* the null at the end */ ! if (im_GetLastCmd(textview_GetIM(self)) == lcDisplayEnvironment) { ! de = self->displayEnvironment; ! pos = self->displayEnvironmentPosition; ! } ! else { ! textview_ReleaseStyleInformation(self, self->displayEnvironment); ! self->displayEnvironment = NULL; ! pos = textview_CollapseDot(self); ! } ! ! strcpy(tbuf, "Styles: "); ! flag = 0; ! d = Text(self); ! te = textview_GetEnclosedStyleInformation(self, pos, NULL); ! if (te) { ! if (te == d->rootEnvironment) { ! strcat(tbuf, "None"); ! } ! else { ! while (te != d->rootEnvironment) { ! tp = te->data.style->name; ! ! if(tp == NULL) tp = "(Unnamed Style)"; ! if (flag) ! strcat(tbuf, " <- "); ! ! if (de == NULL) ! de = te; ! else if (de == te) ! de = NULL; ! ! curLen += 4+strlen(tp); ! if (curLen >= SHOWSIZE) break; ! if (de == te) ! strcat(tbuf, "**"); ! strcat(tbuf,tp); ! if (de == te) { ! strcat(tbuf, "**"); ! textview_SetDotPosition(self, environment_Eval(te)); ! textview_SetDotLength(self, environment_GetLength(te)); ! } ! te = (struct environment *) te->header.nestedmark.parent; ! flag = 1; ! } ! } ! if (de == NULL) { ! textview_SetDotPosition(self, pos); ! textview_SetDotLength(self, 0); ! } ! message_DisplayString(self, 0, tbuf); ! im_SetLastCmd(textview_GetIM(self), lcDisplayEnvironment); ! self->displayEnvironment = de; ! self->displayEnvironmentPosition = pos; ! } ! else message_DisplayString(self, 0, "Error"); ! textview_WantUpdate(self, self); ! } ! ! ! void textview_ChangeTemplate(self) ! struct textview *self; ! { ! char tname[150]; ! register struct text *d; ! int gf; ! ! if (ConfirmReadOnly(self)) ! return; ! ! d = Text(self); ! gf = message_AskForString(self, 0, ! "Add styles from template: ", 0, tname, 100); ! if (gf < 0) ! return; ! if (tname[0] == '\0') { /* no name specified */ ! message_DisplayString(self, 0, "No name specified."); ! return; ! } ! if (text_ReadTemplate(d, tname, text_GetLength(d) == 0) < 0) ! message_DisplayString(self, 100, "Could not read template file."); ! else { ! text_RegionModified(d, 0, text_GetLength(d)); ! text_NotifyObservers(d, observable_OBJECTCHANGED); ! message_DisplayString(self, 0, "Done."); ! } ! } ! ! #define BADCURPOS -1 ! ! void textview_ToggleExposeStyles(self) ! struct textview *self; ! { ! self->exposeStyles = ! self->exposeStyles; ! self->force = TRUE; ! self->csxPos = BADCURPOS; /* Indication that cursor is not visible */ ! self->cexPos = BADCURPOS; ! textview_WantUpdate(self, self); ! } ! ! static void DoDisplayInsertEnvironment(self) ! struct textview *self; ! { ! struct text *d = Text(self); ! ! if (self->insertStack != NULL) { ! char outstr[1000]; ! char *name; ! ! name = self->insertStack->name; ! if (name == NULL) { ! name = "unknown"; ! } ! ! sprintf(outstr, "Current Insertion Style: %s (new)", name); ! message_DisplayString(self, 0, outstr); ! } ! else if (self->insertEnvironment == NULL) { ! message_DisplayString(self, 0, "Current Insertion Style: none"); ! } ! else if (self->insertEnvironment == d->rootEnvironment) { ! message_DisplayString(self, 0, "Current Insertion Style: default"); ! } ! else { ! char outstr[1000]; ! char *name; ! ! if (self->insertEnvironment->type != environment_Style) { ! name = "inset - need to fix this"; ! } ! else if ((name = self->insertEnvironment->data.style->name) == NULL) { ! name = "unknown"; ! } ! ! sprintf(outstr, "Current Insertion Style: %s", name); ! message_DisplayString(self, 0, outstr); ! } ! } ! ! void textview_DisplayInsertEnvironment(self) ! struct textview *self; ! { ! long pos; ! ! if (ConfirmReadOnly(self)) ! return; ! ! pos = textview_CollapseDot(self); ! ! self->insertEnvironment = textview_GetInsertEnvironment(self, pos); ! ! DoDisplayInsertEnvironment(self); ! ! im_SetLastCmd(textview_GetIM(self), lcInsertEnvironment); ! } ! ! ! void textview_PlainInsertEnvironmentCmd(self) ! struct textview *self; ! { ! if (ConfirmReadOnly(self)) ! return; ! ! textview_CollapseDot(self); ! ! textview_PlainInsertEnvironment(self); ! ! im_SetLastCmd(textview_GetIM(self), lcInsertEnvironment); ! ! DoDisplayInsertEnvironment(self); ! } ! ! void textview_UpInsertEnvironmentCmd(self) ! struct textview *self; ! { ! if (ConfirmReadOnly(self)) ! return; ! ! textview_CollapseDot(self); ! ! textview_UpInsertEnvironment(self); ! ! im_SetLastCmd(textview_GetIM(self), lcInsertEnvironment); ! ! DoDisplayInsertEnvironment(self); ! } ! ! void textview_DownInsertEnvironmentCmd(self) ! struct textview *self; ! { ! if (ConfirmReadOnly(self)) ! return; ! ! textview_CollapseDot(self); ! ! textview_DownInsertEnvironment(self); ! ! im_SetLastCmd(textview_GetIM(self), lcInsertEnvironment); ! ! DoDisplayInsertEnvironment(self); ! } ! ! void textview_LeftInsertEnvironmentCmd(self) ! struct textview *self; ! { ! if (ConfirmReadOnly(self)) ! return; ! ! textview_CollapseDot(self); ! ! textview_LeftInsertEnvironment(self); ! ! im_SetLastCmd(textview_GetIM(self), lcInsertEnvironment); ! ! DoDisplayInsertEnvironment(self); ! } ! ! void textview_RightInsertEnvironmentCmd(self) ! struct textview *self; ! { ! if (ConfirmReadOnly(self)) ! return; ! ! textview_CollapseDot(self); ! ! textview_RightInsertEnvironment(self); ! ! im_SetLastCmd(textview_GetIM(self), lcInsertEnvironment); ! ! DoDisplayInsertEnvironment(self); ! } ! ! static boolean StyleCompletionWork(style, data) ! struct style *style; ! struct result *data; ! { ! completion_CompletionWork(style_GetName(style), data); ! return FALSE; ! } ! ! static enum message_CompletionCode StyleComplete(partial, styleSheet, resultStr, resultSize) ! char *partial; ! struct stylesheet *styleSheet; ! char *resultStr; ! int resultSize; ! { ! struct result result; ! char textBuffer[100]; ! ! *textBuffer = '\0'; ! result.partial = partial; ! result.partialLen = strlen(partial); ! result.bestLen = 0; ! result.code = message_Invalid; ! result.best = textBuffer; ! result.max = sizeof(textBuffer) - 1; /* Leave extra room for a NUL. */ ! ! stylesheet_EnumerateStyles(styleSheet, (procedure) StyleCompletionWork, (long) &result); ! ! strncpy(resultStr, result.best, resultSize); ! if (result.bestLen == resultSize) /* Now make sure buffer ends in a NUL. */ ! resultStr[result.bestLen] = '\0'; ! ! return result.code; ! } ! ! struct helpData { ! char *partial; ! int (*textFunction)(); ! long textRock; ! }; ! ! static boolean StyleHelpWork(style, helpData) ! struct style *style; ! struct helpData *helpData; ! { ! char infoBuffer[1024]; ! char strippedMenuName[1000]; ! char *p; ! char *q; ! char *r; ! ! if (completion_FindCommon(helpData->partial, ! style_GetName(style)) == strlen(helpData->partial)) { ! char *menuName; ! ! strippedMenuName[0] = '\0'; ! r = strippedMenuName; ! if ((menuName = style_GetMenuName(style)) != NULL) { ! q = menuName; ! while ((p = index(q, '~')) != NULL) { ! while (q != p) { ! *r++ = *q++; ! } ! while (*++p != ',' && *p != '\0') { ! } ! q = p; ! } ! *r = '\0'; ! } ! ! sprintf(infoBuffer, "%-16s %s", style_GetName(style), strippedMenuName); ! ! (*helpData->textFunction)(helpData->textRock, ! message_HelpListItem, infoBuffer, NULL); ! } ! return FALSE; /* Keep on enumerating. */ ! } ! ! static void StyleHelp(partial, styleSheet, helpTextFunction, helpTextRock) ! char *partial; ! struct stylesheet *styleSheet; ! int (*helpTextFunction)(); ! long helpTextRock; ! { ! struct helpData helpData; ! ! helpData.partial = partial; ! helpData.textFunction = helpTextFunction; ! helpData.textRock = helpTextRock; ! ! stylesheet_EnumerateStyles(styleSheet, (procedure) StyleHelpWork, (long) &helpData); ! } ! ! void textview_InsertEnvironment(self, sName) ! struct textview *self; ! char *sName; ! { ! struct text *d = Text(self); ! struct stylesheet *ss = text_GetStyleSheet(d); ! char styleName[100]; ! struct style *style; ! long pos = textview_GetDotPosition(self); ! long len = textview_GetDotLength(self); ! long lastCmd; ! ! if (ConfirmReadOnly(self)) ! return; ! ! lastCmd = im_GetLastCmd(textview_GetIM(self)); ! self->insertEnvironment = textview_GetInsertEnvironment(self, pos + len); ! ! if (sName == NULL || sName[0] == '\0') { ! if (message_AskForStringCompleted(self, 0, "Insert style: ", ! NULL, styleName, ! sizeof(styleName), NULL, (procedure) StyleComplete, ! (procedure) StyleHelp, (long) ss, ! message_MustMatch | ! message_NoInitialString) == -1) { ! return; ! } ! } ! else { ! strcpy(styleName, sName); ! } ! ! style = stylesheet_Find(ss, styleName); ! ! if (style != NULL) { ! ! if (lastCmd != lcInsertEnvironment && len != 0) { ! /* We want to wrap the environment here and now */ ! if (text_AddStyle(d, pos, len, style) == NULL) { ! message_DisplayString(self, 0, ! "Sorry; can't add style."); ! } ! else { ! char message[200]; ! ! sprintf(message, "Added the style %s", styleName); ! message_DisplayString(self, 0, message); ! text_NotifyObservers(d, observable_OBJECTCHANGED); ! } ! } ! else { ! textview_AddStyleToInsertStack(self, styleName); ! im_SetLastCmd(textview_GetIM(self), lcInsertEnvironment); ! ! DoDisplayInsertEnvironment(self); ! } ! } ! else { ! char message[200]; ! ! sprintf(message, "Could not find the style %s", styleName); ! message_DisplayString(self, 0, message); ! } ! } ! void InitializeMod() { flipEndMax = 4; flipEndEnvs = (struct environment **) malloc(sizeof(struct environment *) * flipEndMax); *** atk/text/pcompch.c Fri Dec 21 14:59:38 1990 --- atk/text/pcompch.c.NEW Mon Dec 17 12:01:49 1990 *************** *** 3,11 **** * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ #include #include - #include /* sys/file.h and string(s).h */ #include #include --- 3,11 ---- * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ + #include /* sys/file.h and string(s).h */ #include #include #include #include *** atk/text/comps Fri Dec 21 14:59:39 1990 --- atk/text/comps.NEW Mon Mar 4 13:45:26 1991 *************** *** 68,73 **** --- 68,74 ---- D- 208 \*(D- + "#" 163 \(ps SS 223 \*8 Ss 223 \*8 *************** *** 140,146 **** m= 61 ! symbol m* 42 ! symbol ms 86 ! symbola ! me 96 ! symbol >= 51 ! symbola <= 35 ! symbola == 58 ! symbola --- 141,147 ---- m= 61 ! symbol m* 42 ! symbol ms 86 ! symbola ! me 78 ! symbola >= 51 ! symbola <= 35 ! symbola == 58 ! symbola *************** *** 153,158 **** --- 154,160 ---- |^ 47 ! symbola xx 52 ! symbola // 56 ! symbola + de 48 ! symbola +- 49 ! symbola un 72 ! symbola in 71 ! symbola *************** *** 162,173 **** iS 74 ! symbola if 37 ! symbola pd 54 ! symbola ! gr 81 ! symbola no 88 ! symbola it 114 ! symbola pt 53 ! symbola es 70 ! symbola ! mo 78 ! symbola br 61 ! symbola --- 164,176 ---- iS 74 ! symbola if 37 ! symbola pd 54 ! symbola ! bu 55 ! symbola ! dl 81 ! symbola no 88 ! symbola it 114 ! symbola pt 53 ! symbola es 70 ! symbola ! mo 96 ! symbol br 61 ! symbola *** atk/text/txtvcmod.c Thu May 30 20:16:08 1991 --- atk/text/txtvcmod.c.NEW Sun May 5 18:54:51 1991 *************** *** 0 **** --- 1,1582 ---- + /* ********************************************************************** *\ + * 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/text/RCS/txtvcmod.c,v 1.9 1991/05/05 20:21:58 gk5g Exp $ */ + /* $ACIS:txtvcmod.c 1.7$ */ + /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/text/RCS/txtvcmod.c,v $ */ + + #ifndef lint + static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/text/RCS/txtvcmod.c,v 1.9 1991/05/05 20:21:58 gk5g Exp $"; + #endif /* lint */ + + #include + #include + #include + #define AUXMODULE 1 + #include + #include + #include + + #include + #include + #include + #include + #include + #include + + #include + #include + + extern void textview_ForwardWordCmd(); + extern void textview_EndOfWordCmd(); + extern void textview_BackwardWordCmd(); + extern void textview_ForwardWSWordCmd(); + extern void textview_BackwardWSWordCmd(); + extern void textview_EndOfWSWordCmd(); + + int textview_GetNextNonSpacePos(self, pos) + struct textview *self; + int pos; + { + struct text *d = Text(self); + long len = text_GetLength(d); + + while (pos < len) { + long tc = 0xff & text_GetChar(d,pos); + if (tc != ' ' && tc != '\t') { + return pos; + } + pos++; + } + return pos; + } + + void textview_AddSpaces(self, pos, startPos, len) + struct textview *self; + long pos; + long startPos; + long len; + { + struct text *d = Text(self); + + if (len > 0) { + char *buf = (char *) malloc(len + 1); + + text_CopySubString(d, startPos, len, buf, FALSE); + text_InsertCharacters(d, pos, buf, len); + free(buf); + } + } + + boolean ConfirmViewDeletion(self, pos, len) + struct textview *self; + long pos, len; + { + struct text *d; + boolean hasViews; + static char *yesOrNo[] = {"Yes", "No", NULL}; + long answer; + struct environment *env; + + d = Text(self); + + for (hasViews = FALSE; len--; pos++) + if (text_GetChar(d, pos) == TEXT_VIEWREFCHAR) { + env = textview_GetStyleInformation(self, NULL, pos, NULL); + if (env->type == environment_View) { + hasViews = TRUE; + textview_ReleaseStyleInformation(self, env); + break; + } + textview_ReleaseStyleInformation(self, env); + } + + if (! hasViews) + return TRUE; + + if (message_MultipleChoiceQuestion(self, 80, + "Really delete inset(s)?", 1, &answer, + yesOrNo, NULL) < 0 || answer != 0) { + message_DisplayString(self, 0, "Cancelled.\n"); + return FALSE; + } + + return TRUE; + } + + /* Added friendly read-only behavior 04/27/89 --cm26 */ + + boolean ConfirmReadOnly(self) + struct textview *self; + { + if (text_GetReadOnly(Text(self))) { + message_DisplayString(self, 0, + "Document is read only."); + return TRUE; + } else + return FALSE; + } + + void textview_SelfInsertCmd(self, a) + register struct textview *self; + char a; + { + register int ct, i, pos; + register struct text *d; + + if (ConfirmReadOnly(self)) + return; + + d = Text(self); + ct=im_Argument(textview_GetIM(self)); + pos = textview_CollapseDot(self); + textview_PrepareInsertion(self, FALSE); + for (i = 0; i < ct; i++) { + text_InsertCharacters(d,pos++,&a,1); + } + textview_FinishInsertion(self); + textview_SetDotPosition(self,pos); + textview_FrameDot(self, pos); + text_NotifyObservers(d, observable_OBJECTCHANGED); + if (im_GetLastCmd(textview_GetIM(self)) == lcInsertEnvironment) { + im_SetLastCmd(textview_GetIM(self), lcInsertEnvironment); + } + } + + void textview_DeleteWordCmd (self) + register struct textview *self; + { + register int count, pos, len; + + + if ( self->editor == VI ) + yankDeleteWord(self, DELETE, textview_ForwardWordCmd); + else { + if (ConfirmReadOnly(self)) + return; + + pos = textview_CollapseDot(self); + + count = im_Argument(textview_GetIM(self)); + im_ClearArg(textview_GetIM(self)); /* Don't want Fwd Word to use it! */ + + while (count--) + textview_ForwardWordCmd(self); + + len = textview_GetDotPosition(self) - pos; + + if (ConfirmViewDeletion(self, pos, len)) { + textview_DeleteCharacters(self, pos, len); + im_SetLastCmd(textview_GetIM(self), lcInsertEnvironment); + textview_FrameDot(self, pos); + } + } + } + + void textview_ForeKillWordCmd (self) + register struct textview *self; + { + register int count, pos, len; + register struct text *d; + + if ( self->editor == VI ) + yankDeleteWord(self, DELETE, textview_ForwardWordCmd); + else { + if (ConfirmReadOnly(self)) + return; + + d = Text(self); + + pos = textview_CollapseDot(self); + + count = im_Argument(textview_GetIM(self)); + im_ClearArg(textview_GetIM(self)); /* Don't want Fwd Word to use it! */ + + while (count--) + textview_ForwardWordCmd(self); + + len = textview_GetDotPosition(self) - pos; + + if (ConfirmViewDeletion(self, pos, len)) { + if (im_GetLastCmd(textview_GetIM(self)) == lcKill) { + FILE *pasteFile; + pasteFile = im_FromCutBuffer(textview_GetIM(self)); + len += text_InsertFile(d, pasteFile, NULL, pos); + im_CloseFromCutBuffer(textview_GetIM(self), pasteFile); + /* hack! Back up the ring so we overwrite old with new. */ + im_RotateCutBuffers(textview_GetIM(self), 1); + } + + textview_DoCopyRegion(self, pos, len, FALSE, d->CopyAsText); + textview_DeleteCharacters(self, pos, len); + im_SetLastCmd(textview_GetIM(self), lcInsertEnvironment); + textview_FrameDot(self, pos); + im_SetLastCmd(textview_GetIM(self), lcKill); + } + } + } + + void textview_OpenLineCmd(self) + register struct textview *self; + { + register int i, pos, ct; + char tc; + struct text *d; + + if (ConfirmReadOnly(self)) + return; + pos = textview_CollapseDot(self); + d=Text(self); + tc = '\012'; + i = 0; + ct = im_Argument(textview_GetIM(self)); + textview_PrepareInsertion(self, TRUE); + for (i = 0; i < ct; i++) { + text_InsertCharacters(d,pos,&tc,1); + } + textview_FinishInsertion(self); + + if ( self->editor == VI ) + textview_NextLineCmd(self); + + text_NotifyObservers(d, observable_OBJECTCHANGED); + if (im_GetLastCmd(textview_GetIM(self)) == lcInsertEnvironment) { + im_SetLastCmd(textview_GetIM(self), lcInsertEnvironment); + } + } + + void textview_JoinCmd(self) + register struct textview *self; + { + struct text *text; + register int i, ct; + long pos; + char blank = ' '; + + if (ConfirmReadOnly(self)) + return; + ct = im_Argument(self->header.view.imPtr); + im_ClearArg(self->header.view.imPtr); + text = Text(self); + for (i = 0; i < ct; i++) + { + textview_EndOfLineCmd(self); + pos = textview_GetDotPosition(self); + if (pos < text_GetLength(text) ) + { + if ( text_GetChar(text, pos) == '\n' ) + { + text_ReplaceCharacters(text, pos, 1, &blank, 1); + textview_SetDotPosition(self, ++pos); + } + if ( charType(text_GetChar(text, pos)) == WHITESPACE ) + textview_DeleteWordCmd(self); + } + } + } + + /* In order to append to ATK datastream in the cutbuffer, + we must yank it into text, and then cut the larger datastream + back out in place of the old. Otherwise we might get two nested + text obejcts instead of one long text object. */ + + static void yankKillLine (self, action) + register struct textview *self; + int action; + { + register int count, pos, endpos, lastpos, numNLs, applen = 0; + register struct text *d; + + endpos = pos = textview_CollapseDot(self); + d = Text(self); + if ( text_GetChar(d,pos) == '\012') + return; + count = im_Argument(self->header.view.imPtr); + lastpos = text_GetLength(d); + + /* find end of line range to be deleted/yanked */ + for (numNLs = 0; endpos < lastpos && numNLs < count; endpos++) + if (text_GetChar(d, endpos) == '\012') + numNLs++; + + if (im_GetLastCmd(textview_GetIM(self)) == lcKill) { + FILE *pasteFile; + pasteFile = im_FromCutBuffer(textview_GetIM(self)); + applen = text_InsertFile(d, pasteFile, NULL, pos); + im_CloseFromCutBuffer(textview_GetIM(self), pasteFile); + /* hack! back up the ring so we overwrite old with new. */ + im_RotateCutBuffers(textview_GetIM(self), 1); + } + + textview_DoCopyRegion(self, pos, endpos + applen - pos, FALSE, d->CopyAsText); + + /* If this is not a deletion operation, we still have to + remove the chars we inserted for our append operation */ + if ( action == DELETE ) + textview_DeleteCharacters(self, pos, endpos + applen - pos); + else + textview_DeleteCharacters(self, pos, applen); + + im_SetLastCmd(self->header.view.imPtr, lcKill); /* mark us as a text killing command */ + text_NotifyObservers(d, observable_OBJECTCHANGED); + } + + void textview_YankLineCmd(self) + register struct textview *self; + { + yankKillLine(self, YANK); + } + + boolean objecttest(self,name,desiredname) + register struct textview *self; + char *name,*desiredname; + { + if(class_Load(name) == NULL){ + char foo[640]; + sprintf(foo,"Can't load %s",name); + message_DisplayString(self, 0, foo); + return(FALSE); + } + if(! class_IsTypeByName(name,desiredname)){ + char foo[640]; + sprintf(foo,"%s is not a %s",name,desiredname); + message_DisplayString(self, 0, foo); + return(FALSE); + } + return(TRUE); + } + + void textview_InsertInsetCmd (self) + register struct textview *self; + { + char iname[100]; + char viewname[200]; + long pf; + boolean promptforname = im_ArgProvided(textview_GetIM(self)); + + im_ClearArg(textview_GetIM(self)); + viewname[0] = '\0'; + if (ConfirmReadOnly(self)) + return; + if(text_GetObjectInsertionFlag(Text(self)) == FALSE){ + message_DisplayString(self, 0, "Object Insertion Not Allowed!"); + return; + } + pf = message_AskForString(self, 0, "Data object to insert here: ", 0, iname, sizeof(iname)); + if (pf < 0){ + message_DisplayString(self, 0, "Punt!"); + return; + } + if(strlen(iname)==0){ + message_DisplayString(self, 0, "No name specified"); + return; + } + if(objecttest(self,iname,"dataobject") == FALSE) return; + if(promptforname){ + if( message_AskForString (self, 0, "View to place here ", 0, viewname, 200) < 0) return; + if(objecttest(self,viewname,"view") == FALSE) return; + } + textview_PrepareInsertion(self, FALSE); + self->currentViewreference = text_InsertObject(Text(self), textview_GetDotPosition(self), iname,viewname); + textview_FinishInsertion(self); + text_NotifyObservers(Text(self), observable_OBJECTCHANGED); + if (im_GetLastCmd(textview_GetIM(self)) == lcInsertEnvironment) { + im_SetLastCmd(textview_GetIM(self), lcInsertEnvironment); + } + } + + void textview_InsertFile(self) + struct textview *self; + { + char filename[MAXPATHLEN]; + FILE *inputFile; + long initialPos; + long pos; + struct stat buf; + + if (ConfirmReadOnly(self)) + return; + if (im_GetDirectory(filename) != NULL) /* Use CWD for now */ + strcat(filename, "/"); + if (completion_GetFilename(self, "Insert file: ", filename, filename, sizeof(filename), FALSE, TRUE) == -1 ) + return; + stat(filename,&buf); + if(buf.st_mode & S_IFDIR) { + message_DisplayString(self, 0, "Can't insert a directory"); + return; + } + if ((inputFile = fopen(filename, "r")) == NULL) { + message_DisplayString(self, 0, "Could not insert file."); /* Really should give a more informative error message. */ + return; + } + + textview_CollapseDot(self); + + if ( self->editor == VI ) + { + textview_EndOfLineCmd(self); + textview_OpenLineCmd(self); + } + + initialPos = pos = textview_GetDotPosition(self); + + textview_PrepareInsertion(self, FALSE); + text_InsertFile(Text(self), inputFile,filename, pos); + textview_FinishInsertion(self); + + fclose(inputFile); + + textview_SetDotPosition(self,initialPos); + textview_SetDotLength(self, pos - initialPos); + /* im_SetLastCmd(textview_GetIM(self), lcYank); */ + text_NotifyObservers(Text(self), observable_OBJECTCHANGED); + } + + void textview_YankCmd(self) + register struct textview *self; + { + long ct; + long initialPos; + long pos; + struct text *d; + FILE *pasteFile; + + if (ConfirmReadOnly(self)) + return; + ct = im_Argument(textview_GetIM(self)); + if (ct > 100) { + message_DisplayString(self, 0, "Yank argument limit: 100"); + return; + } + + d = Text(self); + + initialPos = pos = textview_CollapseDot(self); + + textview_PrepareInsertion(self, FALSE); + while (ct--) { + pasteFile = im_FromCutBuffer(textview_GetIM(self)); + pos += text_InsertFile(d, pasteFile, NULL, pos); + im_CloseFromCutBuffer(textview_GetIM(self), pasteFile); + } + textview_FinishInsertion(self); + + textview_SetDotPosition(self,initialPos); + textview_SetDotLength(self, pos - initialPos); + im_SetLastCmd(textview_GetIM(self), lcYank); + text_NotifyObservers(d, observable_OBJECTCHANGED); + } + + static textview_DoRotatePaste(self, count) + register struct textview *self; + int count; + { + register struct text *d = Text(self); + + im_ClearArg(textview_GetIM(self)); /* Make it safe to call yank. */ + + if (ConfirmReadOnly(self)) + return; + text_DeleteCharacters(d, /* Get rid of what is there now. */ + textview_GetDotPosition(self), textview_GetDotLength(self)); + if (im_GetLastCmd(textview_GetIM(self)) != lcYank) /* If not following yank. */ + count--; /* Make it get top thing off of ring, instead of one down on ring. */ + im_RotateCutBuffers(textview_GetIM(self), count); /* Put the ring in the right place. */ + textview_YankCmd(self); /* Snag it in off the ring. */ + } + + + + void textview_PutAfterCmd(self) + register struct textview *self; + { + FILE *pasteFile; + char cutChar; + long oldPos; + + oldPos = textview_CollapseDot(self); + + pasteFile = im_FromCutBuffer(textview_GetIM(self)); + while ( (cutChar = getc(pasteFile)) != EOF && cutChar != '\n' ); + im_CloseFromCutBuffer(textview_GetIM(self), pasteFile); + if ( cutChar == '\n' ) + { + /* lines are being pasted - insert text after CURRENT LINE */ + textview_NextLineCmd(self); + textview_BeginningOfLineCmd(self); + if ( textview_GetDotPosition(self) <= oldPos ) + { + /* at end of file and no NL - add one */ + textview_EndOfLineCmd(self); + textview_OpenLineCmd(self); + } + } + /* otherwise insert at current cursor position */ + textview_YankCmd(self); + } + + void textview_PutBeforeCmd(self) + register struct textview *self; + { + FILE *pasteFile; + char cutChar; + + textview_CollapseDot(self); + + pasteFile = im_FromCutBuffer(textview_GetIM(self)); + while ( (cutChar = getc(pasteFile)) != EOF && cutChar != '\n' ); + im_CloseFromCutBuffer(textview_GetIM(self), pasteFile); + if ( cutChar == '\n' ) + /* lines are being pasted - insert text before CURRENT LINE */ + textview_BeginningOfLineCmd(self); + /* otherwise insert at current cursor position */ + textview_YankCmd(self); + } + + void textview_BackwardsRotatePasteCmd(self) + struct textview *self; + { + textview_DoRotatePaste(self, - im_Argument(textview_GetIM(self))); + } + + void textview_RotatePasteCmd(self) + struct textview *self; + { + textview_DoRotatePaste(self, im_Argument(textview_GetIM(self))); + } + + void textview_InsertNLCmd(self) + register struct textview *self; + { + textview_SelfInsertCmd(self,'\012'); + if (im_GetLastCmd(textview_GetIM(self)) != lcInsertEnvironment) { + im_SetLastCmd(textview_GetIM(self), lcNewLine); + } + } + + static int stringmatch(d,pos,c) + register struct text *d; + register long pos; + register char *c; + { + /* Tests if the text begins with the given string */ + while(*c != '\0') { + if(text_GetChar(d,pos) != *c) return FALSE; + pos++; c++; + } + return TRUE; + } + + /* NOTE! If you call this routine with the appendFlag set, + if what is already in the cutFile is ATK datastream, + and if what is in the region is formatted as ATK datastream, + the cutFile will contain TWO nested datastreams. + + You must yank the old into the region and cut the larger region + if you want one datastream. + */ + + void textview__DoCopyRegion(self, pos, len, appendFlag, copyAsText) + struct textview *self; + long pos, len; + boolean appendFlag; + { + struct text *d; + register long nextChange; + FILE *cutFile; + int UseDataStream; + + d = Text(self); + environment_GetInnerMost(d->rootEnvironment, pos); + nextChange = environment_GetNextChange(d->rootEnvironment, pos); + + cutFile = im_ToCutBuffer(textview_GetIM(self)); + if (UseDataStream = ((nextChange <= len|| stringmatch(d,pos,"\\begindata")) && text_GetExportEnvironments(d))) + fprintf(cutFile, "\\begindata{%s, %d}\n", + copyAsText ? "text": class_GetTypeName(d), + /* d->header.dataobject.id */ 999999); + d->header.dataobject.writeID = im_GetWriteID(); + text_WriteSubString(d, pos, len, cutFile, UseDataStream); + + if (UseDataStream) + fprintf(cutFile, "\\enddata{%s,%d}\n", + copyAsText ? "text": class_GetTypeName(d), /* d->header.dataobject.id */ 999999); + + if (appendFlag) + im_AppendToCutBuffer(textview_GetIM(self), cutFile); + else + im_CloseToCutBuffer(textview_GetIM(self), cutFile); + } + + void textview_ZapRegionCmd(self) + register struct textview *self; + { + long pos, len; + struct text *d = Text(self); + + if (ConfirmReadOnly(self)) + return; + pos = textview_GetDotPosition(self); + len = textview_GetDotLength(self); + + textview_DoCopyRegion(self, pos, len, FALSE, d->CopyAsText); + textview_DeleteCharacters(self, pos, len); + textview_SetDotLength(self, 0); + im_SetLastCmd(textview_GetIM(self), lcKill); + text_NotifyObservers(Text(self), observable_OBJECTCHANGED); + } + + /* In order to safely allow killing multiple lines of text, each possibly */ + /* including ATK objects, the cutbuffer contents are pasted back and then */ + /* a larger area is re-cut. This isn't visible and wouldn't be so bad were */ + /* it not for the extreme inefficiency of cutbuffer transfers. */ + + void textview_KillLineCmd(self) + register struct textview *self; + { + register int count, pos, endpos, lastpos; + register struct text *d; + + + if ( self->editor == VI ) + yankKillLine(self, DELETE); + else { + if (ConfirmReadOnly(self)) + return; + d = Text(self); + count = im_Argument(textview_GetIM(self)); + endpos = pos = textview_CollapseDot(self); + lastpos = text_GetLength(d); + + while (count-- > 0 && endpos < lastpos) { + if (text_GetChar(d, endpos) == '\012') + endpos++; + else + while (text_GetChar(d, endpos) != '\012' && endpos < lastpos) + endpos++; + } + + if (im_GetLastCmd(textview_GetIM(self)) == lcKill) { + FILE *pasteFile; + pasteFile = im_FromCutBuffer(textview_GetIM(self)); + endpos += text_InsertFile(d, pasteFile, NULL, pos); + im_CloseFromCutBuffer(textview_GetIM(self), pasteFile); + } + + if (endpos > pos) { + textview_DoCopyRegion(self, pos, endpos - pos, FALSE, d->CopyAsText); + textview_DeleteCharacters(self, pos, endpos - pos); + im_SetLastCmd(textview_GetIM(self), lcInsertEnvironment); + textview_SetDotLength(self, 0); + im_SetLastCmd(textview_GetIM(self), lcKill); + } + } + } + + /* At MIT They think of subsequent kills as part of one + user command. + Multiple kills will overwrite one cut buffer element. + Multiple kills interrupted by a cut in another + window will result in the latter cut being appended to + the other window's cut. */ + + void textview_MITKillLineCmd(self) + register struct textview *self; + { + register int count, pos, endpos, lastpos; + register struct text *d; + + + if ( self->editor == VI ) + yankKillLine(self, DELETE); + else { + if (ConfirmReadOnly(self)) + return; + d = Text(self); + count = im_Argument(textview_GetIM(self)); + endpos = pos = textview_CollapseDot(self); + lastpos = text_GetLength(d); + + while (count-- > 0 && endpos < lastpos) { + if (text_GetChar(d, endpos) == '\012') + endpos++; + else + while (text_GetChar(d, endpos) != '\012' && endpos < lastpos) + endpos++; + } + + if (im_GetLastCmd(textview_GetIM(self)) == lcKill) { + FILE *pasteFile; + pasteFile = im_FromCutBuffer(textview_GetIM(self)); + endpos += text_InsertFile(d, pasteFile, NULL, pos); + im_CloseFromCutBuffer(textview_GetIM(self), pasteFile); + /* hack! back up the ring so we overwrite old with new. */ + im_RotateCutBuffers(textview_GetIM(self), 1); + } + + if (endpos > pos) { + textview_DoCopyRegion(self, pos, endpos - pos, FALSE, d->CopyAsText); + textview_DeleteCharacters(self, pos, endpos - pos); + im_SetLastCmd(textview_GetIM(self), lcInsertEnvironment); + textview_SetDotLength(self, 0); + im_SetLastCmd(textview_GetIM(self), lcKill); + } + } + } + + /* This routine will, if immediately followed by a text cutting commnd, cause + * the cut to append to the current buffer instead of placing it in a new + * buffer. */ + + void textview_AppendNextCut(self) + struct textview *self; + { + im_SetLastCmd(textview_GetIM(self), lcKill); /* mark us as a text killing command */ + } + + void textview_CopyRegionCmd (self) + register struct textview *self; + { + struct text *d = Text(self); + + textview_DoCopyRegion(self, + textview_GetDotPosition(self), + textview_GetDotLength(self), FALSE, d->CopyAsText); + } + + void textview_GetToCol (self, col) + register struct textview *self; + register int col; + { + register struct text *d; + register int pos; + + d = Text(self); + pos = textview_GetDotPosition (self); + textview_PrepareInsertion(self, FALSE); + while (col > 0) { + if (col >= 8) { + col -= 8; + text_InsertCharacters (d,pos,"\011",1); + } + else { + col--; + text_InsertCharacters(d,pos," ",1); + } + pos++; + } + textview_FinishInsertion(self); + textview_SetDotPosition (self,pos); + text_NotifyObservers(d, observable_OBJECTCHANGED); + if (im_GetLastCmd(textview_GetIM(self)) == lcInsertEnvironment) { + im_SetLastCmd(textview_GetIM(self), lcInsertEnvironment); + } + } + + void textview_InsertSoftNewLineCmd(self) + register struct textview *self; + { + textview_SelfInsertCmd(self,'\r'); + } + + void textview_MyLfCmd(self) + register struct textview *self; + { + register struct text *d = Text(self); + register int pos, startPos, endPos; + + if (ConfirmReadOnly(self)) + return; + pos = textview_CollapseDot(self); + startPos = text_GetBeginningOfLine(d, pos); + endPos = textview_GetNextNonSpacePos(self, startPos); + pos = text_GetEndOfLine(d, pos); + textview_SetDotPosition(self, pos); + textview_InsertNLCmd(self); + textview_AddSpaces(self, textview_GetDotPosition(self), startPos, endPos - startPos); + textview_SetDotPosition(self, textview_GetDotPosition(self) + endPos - startPos); + } + + void textview_MySoftLfCmd(self) + struct textview *self; + { + register struct text *d; + register int pos, len, endPos, startPos; + long c; + + if (ConfirmReadOnly(self)) + return; + + d = Text(self); + pos = textview_CollapseDot(self); + for (startPos = pos; startPos > 0 && (c = text_GetChar(d, startPos - 1)) != '\r' && c != '\n'; startPos--) { + } + + endPos = textview_GetNextNonSpacePos(self, startPos); + len = text_GetLength(d); + while (pos < len && (c = text_GetChar(d, pos)) != '\r' && c != '\n') { + pos++; + } + + textview_SetDotPosition(self, pos); + textview_InsertSoftNewLineCmd(self); + textview_AddSpaces(self, textview_GetDotPosition(self), startPos, endPos - startPos); + textview_SetDotPosition(self, textview_GetDotPosition(self) + endPos - startPos); + } + + void textview_DeleteCmd (self) + register struct textview *self; + { + register int pos, len; + + if (ConfirmReadOnly(self)) + return; + pos = textview_CollapseDot(self); + + len = im_Argument(textview_GetIM(self)); + + if (ConfirmViewDeletion(self, pos, len)) { + textview_DeleteCharacters(self, pos, len); + im_SetLastCmd(textview_GetIM(self), lcInsertEnvironment); + textview_FrameDot(self, pos); + } + } + + void textview_ViDeleteCmd (self) + register struct textview *self; + { + register struct text *d; + register int pos, len, j; + int dsize; + + if (ConfirmReadOnly(self)) + return; + d = Text(self); + pos = textview_CollapseDot(self); + + if ( text_GetChar(d, pos - 1) == '\n' && text_GetChar(d, pos) == '\n' ) + return; + + dsize = text_GetLength(d); + len = im_Argument(self->header.view.imPtr); + + if (ConfirmViewDeletion(self, pos, len)) { + for (j = 0; j < len; j++) + { + if ( text_GetChar(d, pos) != '\n' && pos < dsize) + { + textview_DeleteCharacters(self, pos, 1); + } + else + if ( pos-- >= 0 ) + { + textview_DeleteCharacters(self, pos, 1); + } + else + { + pos = 0; + break; + } + dsize--; + } + textview_FrameDot(self, pos); + text_NotifyObservers(d, observable_OBJECTCHANGED); + } + } + + void textview_KillWhiteSpaceCmd(self) + register struct textview *self; + { + register struct text *d; + register int p, tc, ep; + + /* First move back until no longer looking at whitespace */ + /* Then delete forward white space. */ + + if (ConfirmReadOnly(self)) + return; + d = Text(self); + p = textview_CollapseDot(self); + while (p > 0) { + tc = 0xff & text_GetChar (d,p-1); + if (tc == 9 || tc == 32) + p--; + else + break; + } + textview_SetDotPosition(self,p); + for (ep = p; + ((tc = text_GetChar (d,ep)) != EOF) && (tc =='\t' || tc == ' '); ep++) + ; + textview_DeleteCharacters(self, p, ep - p); + im_SetLastCmd(textview_GetIM(self), lcInsertEnvironment); + } + + int textview_GetSpace(self, pos) + struct textview *self; + register int pos; + { + register int rval; + register int tc; + register struct text *d; + register long len; + + d = Text(self); + rval = 0; + len = text_GetLength(d); + while (pos < len) { + tc = 0xff & text_GetChar(d,pos); + if (tc == 32) rval++; + else if (tc == 9) + rval += 8; + else + return rval; + pos++; + } + return rval; + } + + static void AdjustIndentation(self, amount) + struct textview *self; + { + int indentation; + + if (ConfirmReadOnly(self)) + return; + + textview_StartOfParaCmd(self); + indentation = textview_GetSpace(self, + textview_GetDotPosition(self)); + textview_KillWhiteSpaceCmd(self); + indentation += amount; + textview_GetToCol(self, indentation); + textview_EndOfParaCmd(self); + } + + void textview_UnindentCmd(self) + struct textview *self; + { + AdjustIndentation(self, -4); + } + + void textview_IndentCmd(self) + struct textview *self; + { + AdjustIndentation(self, 4); + } + + void textview_ExchCmd(self) + register struct textview *self; + { + register long p; + register long len; + + p = textview_GetDotPosition(self); + len = textview_GetDotLength(self); + textview_SetDotPosition(self, mark_GetPos(self->atMarker)); + textview_SetDotLength(self, mark_GetLength(self->atMarker)); + mark_SetPos(self->atMarker,p); + mark_SetLength(self->atMarker, len); + textview_FrameDot(self, textview_GetDotPosition(self)); + textview_WantUpdate(self, self); + } + + void textview_RuboutCmd (self) + register struct textview *self; + { + register long endpos, len; + struct text *d = Text(self); + + if (ConfirmReadOnly(self)) + return; + + endpos = textview_CollapseDot(self); + + len = im_Argument(textview_GetIM(self)); + + if (endpos == 0) + return; + + if (endpos - len < 0) + len = endpos; + + if (ConfirmViewDeletion(self, endpos - len, len)) { + if ( self->editor == VI ) + for ( ; endpos > 0 && len > 0 && text_GetChar(d, endpos - 1) != '\n' ; endpos--) + { + text_DeleteCharacters(d,endpos - 1, 1); + len--; + } + else { + textview_DeleteCharacters(self, endpos -= len, len); + } + textview_SetDotPosition(self, endpos); + textview_FrameDot(self, endpos); + } + } + + /* Switches the two characters before the dot. */ + + void textview_TwiddleCmd (self) + register struct textview *self; + { + long pos; + register struct text *text; + char char1, char2; + struct environment *env1, *env2; + struct viewref *vr1, *vr2; + + if (ConfirmReadOnly(self)) + return; + + pos = textview_CollapseDot(self); + text = Text(self); + + if (pos < 2 || text_GetReadOnly(text) == TRUE) + return; + + char1 = text_GetChar(text, pos - 2); + char2 = text_GetChar(text, pos - 1); + + text_ReplaceCharacters(text, pos - 2, 1, &char2, 1); + text_ReplaceCharacters(text, pos - 1, 1, &char1, 1); + + /* Code to deal with VIEWREFCHARS -cm26 */ + /* If a view must be moved, it's deleted then reinserted */ + /* (environment_Update does not seem to work) */ + /* The order of the following is kind of important */ + + env1 = environment_GetInnerMost(text->rootEnvironment, pos - 2); + if (env1 != NULL) + if (env1->type != environment_View) + env1 = NULL; + else { + vr1 = env1->data.viewref; + env1->data.viewref = NULL; /* Protect viewref from Delete */ + environment_Delete(env1); + } + + env2 = environment_GetInnerMost(text->rootEnvironment, pos - 1); + if (env2 != NULL) + if (env2->type != environment_View) + env2 = NULL; + else { + vr2 = env2->data.viewref; + env2->data.viewref = NULL; /* Protect viewref from Delete */ + environment_Delete(env2); + } + + if (env1 != NULL) + environment_WrapView(text->rootEnvironment, + pos - 1, 1, vr1); + + if (env2 != NULL) + environment_WrapView(text->rootEnvironment, + pos - 2, 1, vr2); + + textview_FrameDot(self, pos); + text_NotifyObservers(text, observable_OBJECTCHANGED); + } + + void textview_RuboutWordCmd (self) + register struct textview *self; + { + register int count, endpos, len; + + if (ConfirmReadOnly(self)) + return; + + endpos = textview_CollapseDot(self); + + count = im_Argument(textview_GetIM(self)); + im_ClearArg(textview_GetIM(self)); /* Don't want Bkwd Word to use it! */ + + while (count--) + textview_BackwardWordCmd(self); + + len = endpos - textview_GetDotPosition(self); + + if (ConfirmViewDeletion(self, endpos - len, len)) { + textview_DeleteCharacters(self, endpos, -len); + im_SetLastCmd(textview_GetIM(self), lcInsertEnvironment); + textview_FrameDot(self, endpos - len); + } + } + + /* The safest way to prepend 'back killed' text is to yank it and kill the larger region. */ + + void textview_BackKillWordCmd (self) + register struct textview *self; + { + register int count, endpos, pos, startpos; + register struct text *d; + + if (ConfirmReadOnly(self)) + return; + + d = Text(self); + + endpos = pos = textview_CollapseDot(self); + + count = im_Argument(textview_GetIM(self)); + im_ClearArg(textview_GetIM(self)); /* Don't want Bkwd Word to use it! */ + + while (count--) + textview_BackwardWordCmd(self); + + startpos = textview_GetDotPosition(self); + + if (ConfirmViewDeletion(self, startpos, endpos - startpos)) { + if ((im_GetLastCmd(textview_GetIM(self)) == lcKill)) { + FILE *pasteFile; + pasteFile = im_FromCutBuffer(textview_GetIM(self)); + endpos += text_InsertFile(d, pasteFile, NULL, pos); + im_CloseFromCutBuffer(textview_GetIM(self), pasteFile); + /* hack! Back up the ring so we overwrite old with new. */ + im_RotateCutBuffers(textview_GetIM(self), 1); + } + textview_DoCopyRegion(self, startpos, endpos - startpos, FALSE, d->CopyAsText); + textview_DeleteCharacters(self, startpos, endpos - startpos); + im_SetLastCmd(textview_GetIM(self), lcInsertEnvironment); + textview_FrameDot(self, startpos); + im_SetLastCmd(textview_GetIM(self), lcKill); + } + } + + static yankDeleteWord (self, action, moveFunction) + register struct textview *self; + int action; + void (*moveFunction) (); + { + register int i, ct, pos, npos, cutpos; + boolean backward = FALSE; + FILE *cutFile; + register struct text *text; + + if (ConfirmReadOnly(self)) + return; + + text = Text(self); + textview_CollapseDot(self); + i = 0; + ct = im_Argument(textview_GetIM(self)); + im_ClearArg(textview_GetIM(self)); + cutFile = im_ToCutBuffer(textview_GetIM(self)); + while (i 0 && text_GetChar(d, pos - 1) != '\012') + pos--; + + endpos = pos; + + /* find end of line range to be deleted/yanked */ + for (numNLs = 0; endpos < lastpos && numNLs < count; endpos++) + if (text_GetChar(d, endpos) == '\012') + numNLs++; + + if (im_GetLastCmd(textview_GetIM(self)) == lcKill) { + FILE *pasteFile; + pasteFile = im_FromCutBuffer(textview_GetIM(self)); + applen = text_InsertFile(d, pasteFile, NULL, pos); + im_CloseFromCutBuffer(textview_GetIM(self), pasteFile); + /* hack! back up the ring so we overwrite old with new. */ + im_RotateCutBuffers(textview_GetIM(self), 1); + } + + textview_DoCopyRegion(self, pos, endpos + applen - pos, FALSE, d->CopyAsText); + + /* If this is not a deletion operation, we still have to + remove the chars we inserted for our append operation */ + if ( action == DELETE ) { + textview_DeleteCharacters(self, pos, endpos + applen - pos); + if (pos == text_GetLength(d) && pos > 0 ) + { + textview_SetDotPosition(self, pos - 1); + im_ClearArg(self->header.view.imPtr); + textview_BeginningOfFirstWordCmd(self); + pos = textview_GetDotPosition(self); + } + text_NotifyObservers(d, observable_OBJECTCHANGED); + textview_SetDotPosition(self, pos); + textview_FrameDot(self, pos); + textview_WantUpdate(self, self); + } + else + textview_DeleteCharacters(self, pos, applen); + + im_SetLastCmd(self->header.view.imPtr, lcKill); /* mark us as a text killing command */ + } + + void textview_ViDeleteLineCmd(self) + struct textview *self; + { + viYankDeleteLine(self, DELETE); + } + + void textview_ViYankLineCmd(self) + struct textview *self; + { + viYankDeleteLine(self, YANK); + } + + void textview_OpenLineBeforeCmd(self) + struct textview *self; + { + long oldPos; + char nlChar = '\n'; + + oldPos = textview_GetDotPosition(self); + textview_PreviousLineCmd(self); + im_ClearArg(textview_GetIM(self)); + if ( oldPos == textview_GetDotPosition(self) ) + { + textview_PrepareInsertion(self, TRUE); + text_InsertCharacters(Text(self), 0, &nlChar, 1); + textview_FinishInsertion(self); + textview_SetDotPosition(self, 0); + } + else + { + textview_EndOfLineCmd(self); + textview_OpenLineCmd(self); + } + textview_ToggleVIMode(self); + } + + void textview_OpenLineAfterCmd(self) + struct textview *self; + { + im_ClearArg(self->header.view.imPtr); + textview_EndOfLineCmd(self); + textview_OpenLineCmd(self); + textview_ToggleVIMode(self); + } + + void textview_InsertAtBeginningCmd(self) + struct textview *self; + { + textview_BeginningOfLineCmd(self); + textview_ToggleVIMode(self); + } + + void textview_InsertAtEndCmd(self) + struct textview *self; + { + textview_EndOfLineCmd(self); + textview_ToggleVIMode(self); + } + + void textview_ChangeRestOfLineCmd(self) + struct textview *self; + { + im_ClearArg(self->header.view.imPtr); + textview_KillLineCmd(self); + textview_ToggleVIMode(self); + } + + void textview_ChangeLineCmd(self) + struct textview *self; + { + int dsize; + struct text *text; + + text = Text(self); + dsize = text_GetLength(text); + + textview_ViDeleteLineCmd(self); + if ( text_GetEndOfLine(text, textview_GetDotPosition(self)) == dsize ) + textview_OpenLineAfterCmd(self); + else + textview_OpenLineBeforeCmd(self); + } + + void textview_ChangeWordCmd(self) + struct textview *self; + { + textview_DeleteEndOfWordCmd(self); + textview_ToggleVIMode(self); + } + + void textview_ChangeSelectionCmd(self) + struct textview *self; + { + textview_ZapRegionCmd(self); + textview_ToggleVIMode(self); + } + + void textview_ReplaceCharCmd(self) + struct textview *self; + { + char tc; + long pos; + + + im_ClearArg(self->header.view.imPtr); + pos = textview_GetDotPosition(self); + tc = im_GetCharacter(textview_GetIM(self)); + text_ReplaceCharacters(Text(self), pos, 1, &tc, 1); + text_NotifyObservers(Text(self), observable_OBJECTCHANGED); + } + + void textview_SubstituteCharCmd(self) + struct textview *self; + { + + textview_ViDeleteCmd(self); + textview_ToggleVIMode(self); + } + + void textview_DigitCmd(self, c) + struct textview *self; + register char c; + { + struct im *im = textview_GetIM(self); + + if ( self->editor == VI && self->viMode == COMMAND ) + { + if (im_ArgProvided(im) || c != '0') { + im_BumpArg(im, c-'0'); + im_DisplayArg(im); + } + else { + /* kludge to handle "0" vi command */ + textview_BeginningOfLineCmd(self); + } + return; + } + textview_SelfInsertCmd(self, c); + } + + static void AdjustCase(self, upper, firstOnly) + struct textview *self; + boolean upper, firstOnly; + { + long pos, len, count, i; + boolean capitalize; + + if (ConfirmReadOnly(self)) + return; + + pos = textview_GetDotPosition(self); + len = textview_GetDotLength(self); + count = len; + + if (len == 0) + while (pos > 0 && isalnum(text_GetChar(Text(self), pos - 1))) + pos--; + + capitalize = TRUE; + + while (pos < text_GetLength(Text(self))) { + i = text_GetChar(Text(self), pos); + if (len == 0) { + if (! isalnum(i)) + break; + } else { + if (--count < 0) + break; + } + if (upper) { + if ((capitalize || ! firstOnly) && islower(i)) { + char new = toupper(i); + text_ReplaceCharacters(Text(self), pos, 1, &new, 1); + } + else if(!capitalize && firstOnly && isupper(i)){ + char new = tolower(i); + text_ReplaceCharacters(Text(self), pos, 1, &new, 1); + } + } else if (isupper(i)) { + char new = tolower(i); + text_ReplaceCharacters(Text(self), pos, 1, &new, 1); + } + capitalize = isspace(i); + pos++; + } + + text_NotifyObservers(Text(self), observable_OBJECTCHANGED); + } + + void textview_UppercaseWord(self, key) + struct textview *self; + long key; + { + AdjustCase(self, TRUE, FALSE); + } + + void textview_LowercaseWord(self, key) + struct textview *self; + long key; + { + AdjustCase(self, FALSE, FALSE); + } + + void textview_CapitalizeWord(self, key) + struct textview *self; + long key; + { + AdjustCase(self, TRUE, TRUE); + } + + void textview_ToggleCase(self, key) + struct textview *self; + long key; + { + long pos = textview_GetDotPosition(self); + int i; + char new; + + if (ConfirmReadOnly(self)) + return; + + i = text_GetChar(Text(self), pos); + + if (isupper(i)) + new = tolower(i); + else if (islower(i)) + new = toupper(i); + else + new = i; + + text_ReplaceCharacters(Text(self), pos, 1, &new, 1); + text_NotifyObservers(Text(self), observable_OBJECTCHANGED); + + textview_SetDotPosition(self, pos + 1); + } + + void textview_QuoteCmd(self) + register struct textview *self; + { + register long i; + long count; + register struct text *d; + char tc; + long where; + + if (ConfirmReadOnly(self)) + return; + count = im_Argument(textview_GetIM(self)); + d = Text(self); + tc = im_GetCharacter(textview_GetIM(self)); + if (tc >= '0' && tc <= '7') { + char c1 = im_GetCharacter(textview_GetIM(self)) - '0', + c2 = im_GetCharacter(textview_GetIM(self)) - '0'; + tc = ((tc - '0' << 3) + c1 << 3) + c2; + } + where = textview_GetDotPosition(self); + textview_PrepareInsertion(self, tc == '\n'); + for (i = 0; i < count; i++) { + text_InsertCharacters(d, where+i, &tc, 1); + } + textview_FinishInsertion(self); + textview_SetDotPosition(self, where+count); + text_NotifyObservers(d, observable_OBJECTCHANGED); + if (im_GetLastCmd(textview_GetIM(self)) == lcInsertEnvironment) { + im_SetLastCmd(textview_GetIM(self), lcInsertEnvironment); + } + } + *** atk/text/tabs.ch Sun May 12 21:13:36 1991 --- atk/text/tabs.ch.NEW Fri Dec 14 16:56:48 1990 *************** *** 0 **** --- 1,27 ---- + /* Nick Williams, August 1990 */ + + /* tabs are a package. + * However, we want to be able to define methods and data, + * so we have it as a basic class. + */ + + class tabs { + classprocedures: + InitializeObject(struct tabs *self) returns boolean; + FinalizeObject(struct tabs *self); + Create() returns struct tabs *; + Death(struct tabs *self); + methods: + OutputTroff(long indent, FILE *file); + Different(struct tabs *b) returns int; + Delete(int n) returns struct tabs *; + Add(long pos, enum style_TabAlignment op) returns struct tabs *; + Clear() returns struct tabs *; + ApplyChange(struct tabentry *change) returns struct tabs *; + Copy() returns struct tabs *; + data: + long *Positions; + long *Types; + int number; + int links; + }; *** atk/text/tabs.c Sun May 12 21:13:31 1991 --- atk/text/tabs.c.NEW Tue May 21 12:25:47 1991 *************** *** 0 **** --- 1,390 ---- + /* ********************************************************************** *\ + * Copyright MIT 1990 - All Rights Reserved * + * For full copyright information see:'andrew/config/COPYRITE' * + \* ********************************************************************** */ + /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/text/RCS/tabs.c,v 1.5 1991/05/21 16:25:07 susan Exp $ */ + /* $ACIS:tabs.c 1.3$ */ + /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/text/RCS/tabs.c,v $ */ + + #ifndef lint + static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/text/RCS/tabs.c,v 1.5 1991/05/21 16:25:07 susan Exp $"; + #endif /* lint */ + + #ifdef hpux + #include + #endif /* hpux */ + + #include + + #include + #include + #include + + #include + + static struct tabs *DefaultTabs = NULL; + + int + FindPrevTab(tabs, pos) + struct tabs *tabs; + long pos; + /* Post: returns... + * -1 if no tabs + * n if found + * NumTabs if not found in list + */ + { + register int i; + + if (tabs->number == 0) + return -1; + + for(i = 0; i < tabs->number; i++) + if (pos < tabs->Positions[i]) + return i - 1; + + return tabs->number; + } + + /* This is to take account of Andrew lying about the size of fonts */ + #define RealityHack(x) ((x)*14) + + + void + tabs__OutputTroff(self, indent, file) + struct tabs *self; + long indent; + FILE *file; + /* Output all tabs past indent, with a tab at indent */ + { + int i; + + if (indent < 0) { + fprintf(file, "'ta %dp", -indent); + } + else{ + fprintf(file, "'ta"); + } + + for (i = 0; i < self->number; i++) + if (self->Positions[i] > indent) + switch(self->Types[i]) { + case style_LeftAligned: + fprintf(file, " %dp", self->Positions[i] - indent); + break; + case style_RightAligned: + fprintf(file, " %dpR", self->Positions[i] - indent); + break; + case style_CenteredOnTab: + fprintf(file, " %dpC", self->Positions[i] - indent); + break; + default: + ; /* Ignoring all others for now... XXX */ + } + fprintf(file, "\n"); + } + + + int + tabs__Different(a, b) + struct tabs *a, *b; + /* returns 1 if different, 0 if same */ + { + if (a->number == b->number) { + int i; + for (i = 0; i < a->number; i++) + if (!(a->Positions[i] == b->Positions[i] && + a->Types[i] == b->Types[i])) + return 1; + } else + return 1; + return 0; + } + + + struct tabs * + tabs__Delete(self, n) + struct tabs *self; + int n; + /* delete the n'th tab */ + /* precondition: n represents a valid tab: 0 <= n < CurNumTabs */ + /* post: the original tabs are destroyed, if links > 1 */ + { + register struct tabs *nt; + + register int num = self->number; + + if (num == 1) { + /* Last tab in this list */ + /* Before we throw away the list, is it someone elses? */ + if (self->links > 1) { + nt = tabs_New(); + nt->links = 1; + self->links--; + return nt; + } else { + free(self->Positions); + free(self->Types); + self->Positions = NULL; + self->Types = NULL; + self->number = 0; + return self; + } + } else { + /* create new tablist.. + * copy tabs from 0..n-1 into newlist[0..n-1] (That's n elements); + * copy tabs from n+1..NumTabs into newlist[n..NumTabs-1] + * free the old tab lists + * dec(NumTabs) + */ + nt = tabs_New(); + nt->Positions = (long *) malloc(sizeof(long) * (num-1)); + nt->Types = (long *) malloc(sizeof(long) * (num-1)); + if (n) { + bcopy(self->Positions, nt->Positions, sizeof(long) * n); + bcopy(self->Types, nt->Types, sizeof(long) * n); + } + if (n != num - 1) { + bcopy(&(self->Positions[n+1]), &(nt->Positions[n]), sizeof(long) * (num-n-1)); + bcopy(&(self->Types[n+1]), &(nt->Types[n]), sizeof(long) * (num-n-1)); + } + + self->links--; + if (self->links == 0) { + free(self->Positions); + free(self->Types); + free(self); + } + + nt->links = 1; + nt->number = num-1; + return nt; + } + } + + + struct tabs * + tabs__Add(self, pos, op) + struct tabs *self; + long pos; + enum style_TabAlignment op; + { + /* Add tab into the list */ + /* The original lists ARE DESTROYED */ + register struct tabs *nt; + register int PrevTab; + register int num = self->number; + + /* Find out what tab is before the destination spot */ + PrevTab = FindPrevTab(self, pos); + /* If there is already a tab at pos, then let's just overwrite it */ + if (PrevTab >= 0 && self->Positions[PrevTab] == pos) + /* There is one at this spot */ { + if (self->Types[PrevTab] == (long) op) { + /* But no change... */ + self->links++; + return self; + } + + if (self->links > 1) { /* But someone else is using this list, so we need to copy */ + nt = tabs_New(); + nt->Positions = (long *) malloc(sizeof(long) * num); + nt->Types = (long *) malloc(sizeof(long) * num); + bcopy(self->Positions, nt->Positions, sizeof(long)*num); + bcopy(self->Types, nt->Types, sizeof(long)*num); + nt->Types[PrevTab] = (long) op; + self->links--; + nt->links = 1; + nt->number = num; + return nt; + } else { + self->Types[PrevTab] = (long) op; + return self; + } + } else { + /* newpos is where in the array to place the new tabstop - it + * is similar to PrevTab, but takes into account the case + * where PrevTab indicates the new pos is outside the old array bounds + */ + register int newpos = PrevTab; + if (newpos < num) + newpos++; + + /* malloc new arrays */ + nt = tabs_New(); + nt->Positions = (long *) malloc(sizeof(long) * (num+1)); + nt->Types = (long *) malloc(sizeof(long) * (num+1)); + + /* Copy all the old tabs before this new one */ + if (PrevTab >= 0) { + bcopy(self->Positions, nt->Positions, sizeof(long) * (newpos)); + bcopy(self->Types, nt->Types, sizeof(long) * (newpos)); + } + + /* Put in the new one */ + nt->Positions[newpos] = pos; + nt->Types[newpos] = (long) op; + + /* Put in all the old tabs after the new one */ + if (PrevTab != num) { + bcopy(&(self->Positions[newpos]), &(nt->Positions[newpos+1]), sizeof(long) * (num-newpos)); + bcopy(&(self->Types[newpos]), &(nt->Types[newpos+1]), sizeof(long) * (num-newpos)); + } + /* And get rid off all the old tabs */ + if (self->links == 1) { + if (num) { + free(self->Positions); + free(self->Types); + } + free(self); + } + nt->number = num+1; + nt->links = 1; + return nt; + } + } + + struct tabs * + tabs__Clear(self) + struct tabs *self; + /* + * Post: if links == 1, then list is destroyed, else links is kept + */ + { + if (self->number == 0) + /* Tabs are already cleared */ + return self; + + if (self->links == 1) { + free(self->Positions); + free(self->Types); + self->number = 0; + self->Positions = NULL; + self->Types = NULL; + return self; + } else { + struct tabs *nt = tabs_New(); + nt->links = 1; + return nt; + } + } + + + struct tabs * + tabs__Create(classID) + struct classheader *classID; + { + register long x; + register int i; + /* + * We are using: + * Default Tabs, every 1/2 inch, for the first 10inches; + * equiv: every 36 pts, from 36 .. 720 + */ + + if (DefaultTabs) { + DefaultTabs->links++; + return DefaultTabs; + } + + DefaultTabs = tabs_New(); + DefaultTabs->links = 1; + DefaultTabs->Positions = (long *) malloc(sizeof(long)*19); + DefaultTabs->Types = (long *) malloc(sizeof(long)*19); + + for (x = 36,i=0; x < 720; x+=36, i++) { + DefaultTabs->Positions[i] = x; + DefaultTabs->Types[i] = (long) style_LeftAligned; + } + DefaultTabs->number = i; + + return DefaultTabs; + } + + boolean + tabs__InitializeObject(classID, self) + struct classheader *classID; + struct tabs *self; + { + self->Positions = NULL; + self->Types = NULL; + self->links = 0; + self->number = 0; + return TRUE; + } + + void + tabs__FinalizeObject(classID, self) + struct classheader *classID; + struct tabs *self; + { + if (self->Positions) free(self->Positions); + if (self->Types) free(self->Types); + } + + void + tabs__Death(classID, self) + struct classheader *classID; + struct tabs *self; + { + if (--self->links > 0) + return; + else + tabs_Destroy(self); + } + + + struct tabs * + tabs__ApplyChange(self, tabChange) + struct tabs *self; + struct tabentry *tabChange; + { + long Pos; /* Position for current tab */ + int PrevTab; /* Tab location at or immediately before proposed tab */ + struct tabs *tabs = self; + + Pos = tabChange->DotLocation; + /* DotLocation is in the units style_RawDots... (calculated by style.c) + */ + + switch(tabChange->TabOpcode) { + case style_LeftAligned: + case style_RightAligned: + case style_CenteredOnTab: + case style_CenteredBetweenTab: + case style_CharAligned: + tabs = tabs_Add(self, Pos, tabChange->TabOpcode); + break; + case style_TabDivide: + /* First get rid of old tabs */ + tabs = tabs_Clear(self); + /* Calculate where new tab stops should go */ + /* XXX - what is TabDivide supposed to *DO* ???!! */ + break; + case style_TabClear: + PrevTab = FindPrevTab(self, Pos); + if (PrevTab >= 0 && tabChange->DotLocation == self->Positions[PrevTab]) + /* There is a tab at this postion, so we get rid of it */ + tabs = tabs_Delete(self, PrevTab); + /* If there is no tab at the precise position specified, then + * this operation is ignored. Perhaps it should find another + * tab within a certain tolerance? + */ + break; + case style_AllClear: + tabs = tabs_Clear(self); + break; + default: + /* Unknown -- should return error */ + return tabs; + } + return tabs; + } + + struct tabs * + tabs__Copy(self) + struct tabs *self; + { + self->links++; + return self; + } *** atk/text/vi.help Fri May 17 16:07:32 1991 --- atk/text/vi.help.NEW Fri May 17 16:05:57 1991 *************** *** 0 **** --- 1,199 ---- + \begindata{text,270239212} + \textdsversion{12} + \template{help} + \chapter{Vi Interface for Andrew Text Views\chapter{ + + }} + \section{What the Vi Interface is + + + }\leftindent{All andrew based applications that display text normally default + to an \italic{emacs} style editing interface for navigating and editing. The + \italic{vi} interface has been added to allow people familiar with the this + interface to navigate and do simple text editing. If it proves useful, + additional commands and features will be added. The interface can be made + available on a per-application basis, or can be made to apply to all text + viewed under andrew. + + }\indent{ + }\section{Switching to the Vi Interface + + + }\leftindent{There are three ways to get the \italic{vi }interface. To + activate it dynamically in any andrew application you happen to be in, make + sure the text cursor is in the text object for which you want the \italic{vi} + interface and type ESC-t. The message "Command Mode" will appear in the + message line. You can toggle back to the \italic{emacs} interface using the + same sequence. So, you can experiment with which interface you like better + for particular views/applications by using this dynamic switching capability. + The second way is to specify \italic{vi} in a preference (see preferences + section). This way you can have the \italic{vi }interface automatically when + particular (or all) applications come up. Thirdly, if no preferences are are + specified, the shell variables VISUAL, EDITOR, and ED will be examined in + order. The value of the first variable that is set will be used to determine + the interface. + + + When switching to \italic{vi} for an application, any text view in it will + have the \italic{vi} interface. This includes dialogues and the message line + at the bottom of every window, so you'll have VI line editing available while + answering prompts. Application windows that contain several text views, such + as the header and body sections of AMS/sendmessage and the document body and + inserted annotations in the inspector are treated as separate \italic{vi} + editor views with their own input/command modes. The message line at the + bottom of the window will indicate the current mode for the view which has + the input focus. If a particular text view seems awkward to use with a + \italic{vi} interface, you can dynamically switch it to \italic{emacs} again. + + } + \section{Warnings + + }\leftindent{ + }\leftindent{Normally, the ESC key is used in \italic{vi} to terminate input + mode. Unfortunately, "ESC" is a heavily used and in some cases a special + character in Andrew. Many of the Andrew classes use ESC-something in their + key-bindings, and it appears that the basic interaction manager makes a + special case of not allowing a single ESC to be bound to a command. So,the + following key bindings have been implemented to terminate input mode: + + + \indent{ESC-ESC + + CTL-e + + }}\indent{ + }\section{Commands Supported:\section{ + + }}\section{\section{ + }}\leftindent{Cursor motion: + + \leftindent{, h, , , l, + + + ^N, j, , ^P, k + + + -, +, + + + ^, 0, $ + + + w, W, b, B, e, E + + + ^D, ^U, ^F, ^B, G + + (Unlike the \italic{emacs }interface, paging forward and backward (^F, ^B, ^U, + ^D) DO change the carat position. + + + L, M, H + + } + Searching: + + \leftindent{/, ?, n, N + + } + Text Deletion: + + \leftindent{x, X, d[wWbBeEd$], D + + } + Text Replacement: + + \leftindent{r, s, S, c[wWbBeEc$], C + + } + Moving Text: + + \leftindent{y[wWbBeEy$], p, P + + } + Text insertion: + + \leftindent{a\leftindent{, A, i, I, o, O}} + + \leftindent{(since the carat is positioned BETWEEN characters "a" and "i" are + equivalent commands.) + + }Misc: + + \leftindent{:r + + % (will inverse video all text containing matching [], \{\}, or () ) + + } + All of the above commands will work with a count parameter, where it makes + + sense (e.g., 30G means "go to line 30, 5cw means substitute text for the + + following five words, 5dd means delete 5 lines, etc.). + + + Obviously "repeat" and "undo" would be high priority commands to + + add in the future. + + } + \section{Additional Features\section{ + + }} + \leftindent{Some additional features, based on the fact that you now have a + \italic{vi} which is Andrew-based and has mouse input: + + + \leftindent{1. Several new commands have been added that operate on the + currently selected text: ds, cs, and ys will delete, change, and yank, + respectively, the current selection. + + + 2. While in input mode, you can move the cursor and position the carat + anyplace in the window, and continue inserting text (or deleting text by + backspacing). You can also use the cut/copy/paste menu items while in input + mode. + + + 3. You can search forward and backward by selecting some text and issuing + "/" and "?". In this case you won't be prompted for the search string - the + search will be executed immediately. You can use this to rapidly repeat + searches, since you need only type "/" and "?", without the . + + + }}\section{Preferences + + } + \leftindent{After you have experimented enough to know where you want the + \italic{vi} interface to be used, you can use a preference specification to + make it come up automatically for that application. For instance, if you want + it for all text views in application "app" then put: + + + app.editor: vi + + + into your preferences file. If you want \italic{vi} for ALL andrew + application, then specify: + + + editor: vi + + + Of course, at any time in an application, you can type ESC-t to dynamically + switch between \italic{emacs} and \italic{vi} editor interfaces. + + }\indent{\indent{ + }}\section{Program Author} + + \leftindent{ + F. A. Schmidt (fas%mtgzx@att.com)} + + + \section{Recent changes to Vi Interface} + + + \indent{First release (3/15/90).} + + + \enddata{text,270239212} *** atk/text/txtvcmv.c Thu May 30 20:16:42 1991 --- atk/text/txtvcmv.c.NEW Thu Apr 25 16:18:00 1991 *************** *** 0 **** --- 1,998 ---- + /* ********************************************************************** *\ + * 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/text/RCS/txtvcmv.c,v 1.6 1991/04/24 13:20:30 gk5g Exp $ */ + /* $ACIS:txtvcmv.c 1.7$ */ + /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/text/RCS/txtvcmv.c,v $ */ + + #ifndef lint + static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/text/RCS/txtvcmv.c,v 1.6 1991/04/24 13:20:30 gk5g Exp $"; + #endif /* lint */ + + #include + #include + #include + #define AUXMODULE 1 + #include + #include + #include + + #include + #include + #include + #include + + void textview_EndOfWordCmd (self) + register struct textview *self; + {/**/ + register int j, ct, pos, dlen, testType; + register struct text *d; + char c; + /****/ + pos = textview_CollapseDot(self); + ct = im_Argument(textview_GetIM(self)); + d=Text(self); + dlen= text_GetLength(d); + for ( j = 0; j < ct; j++ ) + { + while ( pos < dlen && (testType = charType(c = text_GetChar(d, pos))) == WHITESPACE ) + { + if ( c == '\n' && text_GetChar(d, pos + 1) == '\n' ) + { + /* stop at blank lines */ + break; + } + pos++; + } + pos++; + + if ( c != '\n' ) + while (pos < dlen && charType(text_GetChar(d, pos))== testType ) pos++; + } + textview_SetDotPosition(self,pos); + textview_FrameDot(self, pos); + textview_WantUpdate(self, self); + } + + void textview_ForwardWordCmd (self) + register struct textview *self; + { + register int j, count, pos, dlen; + register struct text *d; + + pos = textview_CollapseDot(self); + count = im_Argument(textview_GetIM(self)); + d=Text(self); + dlen= text_GetLength(d); + for ( j = 0; j < count; j++ ) + { + if ( self->editor == EMACS ) + { + while (poseditor == EMACS ) + { + while (pos>0 && isalnum(text_GetChar(d,pos-1))==0) pos--; + while (pos>0 && isalnum(text_GetChar(d,pos-1))!=0) pos--; + } + else + { + register int testType; + char c; + + pos--; + while ( pos > 0 && (testType = charType(c = text_GetChar(d, pos))) == WHITESPACE ) + { + if ( c == '\n' && text_GetChar(d, pos - 1) == '\n' ) + { + /* stop at blank lines */ + break; + } + pos--; + } + if ( c != '\n' ) + while ( pos > 0 && charType(text_GetChar(d, pos - 1))== testType ) pos--; + } + } + textview_SetDotPosition(self,pos); + textview_FrameDot(self, pos); + textview_WantUpdate(self, self); + } + + void textview_LineToTopCmd(self) + register struct textview *self; + { + long pos; + + pos = textview_GetDotPosition(self) + textview_GetDotLength(self); + pos = textview_MoveBack(self, pos, 0, textview_MoveByLines, 0, 0); + + textview_SetTopPosition(self, pos); + textview_WantUpdate(self, self); + } + + void textview_ForwardParaCmd(self) + register struct textview *self; + { + register int j, ct, pos, dlen; + register struct text *d; + + j = 0; + ct = im_Argument(textview_GetIM(self)); + d = Text(self); + dlen = text_GetLength(d); + pos =textview_GetDotPosition(self); + while (j 0) pos--; + while (pos>0 && text_GetChar(d,pos-1) != '\n') pos--; + j++; + } + textview_SetDotPosition(self,pos); + textview_WantUpdate(self, self); + } + + void textview_GotoParagraphCmd(self) + register struct textview *self; + { + char temp[100]; + int line, gf; + register int pos; + register struct text *d; + + d = Text(self); + + if (im_ArgProvided(textview_GetIM(self))) + line = im_Argument(textview_GetIM(self)); + else { + gf = message_AskForString(self, 0, "What paragraph? ", 0, temp, 100); + if (gf < 0) + return; + line = atoi(temp); + } + + pos = text_GetPosForLine(d, line); + + textview_SetDotPosition(self, pos); + textview_SetDotLength(self, 0); + textview_FrameDot(self, pos); + textview_WantUpdate(self, self); + } + + void textview_WhatParagraphCmd (v) + register struct textview *v; + { + char temp[100]; + register int i, pos; + register struct text *d; + + d=Text(v); + pos = textview_GetDotPosition(v)-1; + + i = text_GetLineForPos(d, pos); + + sprintf(temp,"Paragraph %d.",i); + message_DisplayString(v, 0, temp); + } + + void textview_ViGlitchUpCmd(self) + register struct textview *self; + { + register int n; + register int pos; + long dotPos; + long dist, lines; + + n = im_Argument(self->header.view.imPtr); + pos = textview_GetTopPosition(self); + pos = textview_MoveBack(self, pos, 0, textview_MoveByLines, 0, 0); + pos = textview_MoveForward(self, pos, n, textview_MoveByLines, 0, 0); + if (self->scroll == textview_ScrollBackward) + self->scroll = textview_MultipleScroll; + dotPos = textview_GetDotPosition(self); + if ( textview_Visible(self, dotPos) ) + dotPos = textview_MoveForward(self, dotPos, n, textview_MoveByLines, &dist, &lines); + else + dotPos = pos; + textview_SetDotPosition(self, pos); + textview_SetTopPosition(self, pos); + textview_WantUpdate(self, self); + } + + void textview_ViGlitchDownCmd(self) + register struct textview *self; + { + register int n,pos; + long dotPos; + long dist, lines; + + n = im_Argument(self->header.view.imPtr); + pos = textview_GetTopPosition(self); + pos = textview_MoveBack(self, pos, n, textview_MoveByLines, &dist, &lines); + if (self->scroll == textview_ScrollForward) + self->scroll = textview_MultipleScroll; + else { + if (self->scrollDist == -1) { + self->scrollDist = dist; + self->scrollLine = lines; + } + else { + self->scrollDist += dist; + if (self->scrollDist >= textview_GetLogicalHeight(self)) + self->scrollDist = -1; + else + self->scrollLine += lines; + } + } + dotPos = textview_GetDotPosition(self); + if ( textview_Visible(self, dotPos) ) + dotPos = textview_MoveBack(self, dotPos, n, textview_MoveByLines, &dist, &lines); + else + dotPos = pos; + textview_SetDotPosition(self, pos); + textview_SetTopPosition(self, pos); + textview_WantUpdate(self, self); + } + + void textview_DownCmd(self) + register struct textview *self; + { + if ( im_Argument(self->header.view.imPtr) == 1 ) + { + /* default is half the screen */ + (self->header.view.imPtr)->argState.argProvided = TRUE; + (self->header.view.imPtr)->argState.argument = textview_GetLines(self)/2; + } + textview_ViGlitchUpCmd(self); + } + + void textview_UpCmd(self) + register struct textview *self; + { + if ( im_Argument(self->header.view.imPtr) == 1 ) + { + /* default is half the screen */ + (self->header.view.imPtr)->argState.argProvided = TRUE; + (self->header.view.imPtr)->argState.argument = textview_GetLines(self)/2; + } + textview_ViGlitchDownCmd(self); + } + + void textview_GlitchUpCmd(self) + register struct textview *self; + { + register int n; + register int pos; + + n = im_Argument(textview_GetIM(self)); + pos = textview_GetTopPosition(self); + pos = textview_MoveBack(self, pos, 0, textview_MoveByLines, 0, 0); + pos = textview_MoveForward(self, pos, n, textview_MoveByPseudoLines, 0, 0); + if (self->scroll == textview_ScrollBackward) { + self->scroll = textview_MultipleScroll; + } + textview_SetTopOffTop(self, pos, self->pixelsComingOffTop); + textview_WantUpdate(self, self); + } + + void textview_GlitchDownCmd(self) + register struct textview *self; + { + register int n,pos; + long dist, lines; + + n = im_Argument(textview_GetIM(self)); + pos = textview_GetTopPosition(self); + pos = textview_MoveBack(self, pos, n, textview_MoveByPseudoLines, &dist, &lines); + if (self->scroll == textview_ScrollForward) { + self->scroll = textview_MultipleScroll; + } + else { + if (self->scrollDist == -1) { + self->scrollDist = dist; + self->scrollLine = lines; + } + else { + self->scrollDist += dist; + if (self->scrollDist >= textview_GetLogicalHeight(self)) + self->scrollDist = -1; + else + self->scrollLine += lines; + } + } + + textview_SetTopOffTop(self, pos, self->pixelsComingOffTop); + textview_WantUpdate(self, self); + } + + static long PageOverlap(viewHeight) + long viewHeight; + { + return (viewHeight < 147) ? viewHeight / 3 : 49; + } + + void textview_NextScreenCmd(self) + struct textview *self; + { + int argument = im_Argument(textview_GetIM(self)); + int count; + + im_ClearArg(textview_GetIM(self)); + for (count = 0; count < argument; ++count) { + int numLines = textview_GetLines(self); + long pos; + long overlap; + long viewHeight; + + if (numLines == 0) { + /* Do nothing; there is no text on the screen. */ + return; + } + + viewHeight = textview_GetLogicalHeight(self) - self->by; + overlap = PageOverlap(viewHeight); + + pos = textview_GetTopPosition(self); + /* get line aligned */ + pos = textview_MoveBack(self, pos, 0, textview_MoveByLines, 0, 0); + pos = textview_MoveForward(self, pos, viewHeight - overlap, textview_MoveByPixels, 0, 0); + if (self->scroll == textview_ScrollBackward) { + self->scroll = textview_MultipleScroll; + } + textview_SetTopOffTop(self, pos, self->pixelsComingOffTop); + + if ( self->editor == VI ) { + textview_SetDotPosition(self, pos); + } + } + textview_WantUpdate(self, self); + } + + void textview_PrevScreenCmd(self) + register struct textview *self; + { + int argument = im_Argument(textview_GetIM(self)); + int count; + + im_ClearArg(textview_GetIM(self)); + + for (count = 0; count < argument; ++count) { + long numLines = textview_GetLines(self); + long pos; + long viewHeight; + long dist; + long lines; + long overlapHeight; + + viewHeight = textview_GetLogicalHeight(self) - self->by; + if (numLines == 0) { + overlapHeight = 0; + } + else { + overlapHeight = PageOverlap(viewHeight); + } + + pos = textview_GetTopPosition(self); + pos = textview_MoveBack(self, pos, viewHeight - overlapHeight, textview_MoveByPixels, &dist, &lines); + + if (self->scroll == textview_ScrollForward) + self->scroll = textview_MultipleScroll; + else if (self->scrollDist == -1) { + self->scrollDist = dist; + self->scrollLine = lines; + } + else { + self->scrollDist = -1; + } + + textview_SetTopOffTop(self, pos, self->pixelsComingOffTop); + + if ( self->editor == VI ) { + textview_SetDotPosition(self, textview_MoveForward(self, pos, lines + 1, textview_MoveByLines, &dist, &lines)); + } + } + textview_WantUpdate(self, self); + } + + void textview_StartOfParaCmd (self) + register struct textview *self; + { + register struct text *d; + register int pos; + + d = Text(self); + pos = textview_GetDotPosition(self); + pos = text_GetBeginningOfLine(d, pos); + textview_SetDotPosition(self, pos); + textview_SetDotLength(self, 0); + textview_WantUpdate(self, self); + } + + void textview_EndOfParaCmd (self) + register struct textview *self; + { + register struct text *d; + register int pos; + + d = Text(self); + pos = text_GetEndOfLine(d, textview_GetDotPosition(self)); + textview_SetDotPosition(self, pos); + textview_SetDotLength(self, 0); + textview_WantUpdate(self, self); + } + + void textview_SelectRegionCmd(self) + register struct textview *self; + { + register int i; + register int dot, mark; + + mark = mark_GetPos(self->atMarker); + dot = textview_GetDotPosition(self); + if (mark > dot) { + i = dot; + dot = mark; + mark = i; + } + /* Now assume that mark <= dot */ + textview_SetDotLength(self,dot-mark); + textview_SetDotPosition(self,mark); + textview_WantUpdate(self, self); + } + + void textview_CtrlAtCmd(self) + register struct textview *self; + { + mark_SetPos(self->atMarker,textview_GetDotPosition(self)); + mark_SetLength(self->atMarker,textview_GetDotLength(self)); + message_DisplayString(self, 0, "Mark set."); + } + + void textview_BackwardCmd(self) + register struct textview *self; + { + register long endpos, len; + register struct text *d; + + endpos = textview_CollapseDot(self); + d = Text(self); + len = im_Argument(textview_GetIM(self)); + + if (endpos == 0) + return; + if (endpos - len < 0) + len = endpos; + + if ( self->editor == VI ) + for ( ; endpos > 0 && len > 0 && text_GetChar(d, endpos - 1) != '\n' ; endpos--) + len--; + else + endpos -= len; + + textview_SetDotPosition(self,endpos); + textview_FrameDot(self, endpos); + textview_WantUpdate(self, self); + } + + void textview_ForwardCmd(self) + register struct textview *self; + { + register long pos; + register long newPos; + + pos = textview_CollapseDot(self); + textview_SetDotPosition(self, (newPos = pos + im_Argument(textview_GetIM(self)))); + if (pos != textview_GetDotPosition(self)) { + textview_FrameDot(self, newPos); + textview_WantUpdate(self, self); + } + } + + void textview_PreviousLineCmd (self) + register struct textview *self; /**/ + { + register int npos, j; + int xpos; + struct mark tm; /* note this mark is not on the document's marker chain */ + long pos, dist, lines, cumLines, currentline, startPos, nlPos, prevPos; + struct text *text; + + startPos = textview_GetDotPosition(self); + pos = textview_CollapseDot(self); + text = Text(self); + if (im_GetLastCmd(textview_GetIM(self)) == lcMove) + xpos = self->movePosition; + else + self->movePosition = xpos = self->cexPos; + if ( self->editor == VI ) + { + currentline = textview_FindLineNumber(self, startPos); + /* ignore wrap-around lines */ + cumLines = lines = 0; + npos = startPos; + for (j = im_Argument(self->header.view.imPtr); j > 0; j--) + { + nlPos = text_GetBeginningOfLine(text, text_GetBeginningOfLine(text, npos) - 1); + do + { + prevPos = npos; + npos = textview_MoveBack(self, prevPos, 1, textview_MoveByLines, &dist, &lines); + cumLines++; + } while ( npos > nlPos && prevPos != npos); + } + } + else { + currentline = textview_FindLineNumber(self, pos); + npos = textview_MoveBack(self, pos, im_Argument(textview_GetIM(self)), textview_MoveByLines, &dist, &cumLines); + } + if (cumLines > currentline) { + /* Have moved back off the screen */ + if (self->scroll == textview_ScrollForward) + self->scroll = textview_MultipleScroll; + if (self->scrollDist == -1 ) { + if (currentline != -1) { + self->scrollDist = dist - (self->lines[currentline].y - self->lines[0].y); + self->scrollLine = cumLines - currentline; + textview_SetTopPosition(self, npos); + } + else { + long topPos; + + currentline = textview_FindLineNumber(self, startPos); + if (currentline != -1 || (startPos <= (topPos = textview_GetTopPosition(self)) && startPos >= topPos)) + { + if ( self->editor == VI ) + { + (self->header.view.imPtr)->argState.argProvided = TRUE; + (self->header.view.imPtr)->argState.argument = cumLines; + textview_ViGlitchDownCmd(self); + } + else + textview_FrameDot(self, npos); + } + } + } + else { + self->scrollDist += dist; + self->scrollLine += cumLines; + textview_SetTopPosition(self, npos); + } + } + else + textview_FrameDot(self, npos); + mark_SetPos(&tm, npos); + mark_SetLength(&tm, 0); + if (self->csxPos != -1) { + struct formattinginfo info; + + npos = textview_LineRedraw (self, textview_GetPosition, &tm, self->bx, + self->by, textview_GetLogicalWidth(self) - 2 * self->bx, + textview_GetLogicalHeight(self) - 2 * self->by, xpos, (int *) 0, NULL, &info); + } + textview_SetDotPosition(self, npos); + im_SetLastCmd(self->header.view.imPtr, lcMove); + textview_WantUpdate(self, self); + } + + void textview_NextLineCmd (self) + register struct textview *self; /**/ + { + register int npos, j; + int xpos; + struct mark tm; /* note this mark is not on the document's marker chain */ + long currentline, pos, lines, nlines, newline, startPos, nlPos, dsize; + static int linetomove; + + startPos = textview_GetDotPosition(self); + pos = textview_CollapseDot(self); + dsize = text_GetLength(Text(self)); + + if (im_GetLastCmd(self->header.view.imPtr) == lcMove) + xpos = self->movePosition; + else + self->movePosition = xpos = self->cexPos; + if ( self->editor == VI ) + { + currentline = textview_FindLineNumber(self, startPos); + npos = textview_MoveBack(self,startPos,0, textview_MoveByLines, NULL, NULL); + + /* ignore wrap-around lines */ + nlines = 0; + npos = startPos; + for (j = im_Argument(textview_GetIM(self)); j > 0; j--) + { + if ( (nlPos = text_GetEndOfLine(Text(self), npos) + 1) == dsize ) + break; + do + { + npos = textview_MoveForward(self,npos, 1, textview_MoveByLines, NULL, &lines); + nlines++; + + } while ( npos < nlPos && npos < dsize ); + } + } + else { + currentline = textview_FindLineNumber(self, pos); + npos = textview_MoveBack(self,pos,0, textview_MoveByLines, NULL, NULL); + npos = textview_MoveForward(self,npos, nlines = im_Argument(textview_GetIM(self)), textview_MoveByLines, NULL, NULL); + } + if (currentline != -1) { + /* Current Position is on the screen */ + + newline = textview_FindLineNumber(self, npos); + if (newline == -1) { + linetomove = nlines - (self->nLines - currentline - 1); + + if (linetomove < self->nLines && linetomove > 0) { + if (self->scroll == textview_ScrollBackward) self->scroll = textview_MultipleScroll; + textview_SetTopPosition(self, mark_GetPos(self->lines[linetomove].data)); + } + else + if ( self->editor == VI ) + { + (self->header.view.imPtr)->argState.argProvided = TRUE; + (self->header.view.imPtr)->argState.argument = nlines; + textview_ViGlitchUpCmd(self); + } + else + textview_FrameDot(self, npos); + } + } + else { + /* Current Position is off the screen */ + if (self->scroll == textview_ScrollForward) { + linetomove += nlines; + if (linetomove < self->nLines) + textview_SetTopPosition(self, mark_GetPos(self->lines[linetomove].data)); + else + textview_FrameDot(self, npos); + } + else { + long topPos; + + currentline = textview_FindLineNumber(self, startPos); + if (currentline != -1 || (startPos <= (topPos = textview_GetTopPosition(self)) && startPos >= topPos)) + textview_FrameDot(self, npos); + } + } + + mark_SetPos(&tm, npos); + mark_SetLength(&tm, 0); + if (self->csxPos != -1) { + struct formattinginfo info; + + npos = textview_LineRedraw (self, textview_GetPosition, &tm, self->bx, + self->by, textview_GetLogicalWidth(self)-2*self->bx, + textview_GetLogicalHeight(self)-2*self->by, xpos, (int *) 0, NULL, &info); + } + textview_SetDotPosition(self,npos); + im_SetLastCmd(textview_GetIM(self), lcMove); + textview_WantUpdate(self, self); + } + + void textview_EndOfTextCmd(self) + register struct textview *self; + { + register struct text *d; + register int e; + + textview_CtrlAtCmd(self); + d = Text(self); + e = text_GetLength(d); + textview_SetDotPosition(self,e); + textview_SetDotLength(self,0); + textview_FrameDot(self,e); + textview_WantUpdate(self, self); + } + + void textview_BeginningOfTextCmd(self) + register struct textview *self; + { + textview_CtrlAtCmd(self); + textview_SetDotPosition(self,0); + textview_SetDotLength(self,0); + textview_FrameDot(self,0); + textview_WantUpdate(self, self); + } + + void textview_EndOfLineCmd (self) + register struct textview *self; + { + register int startpos, npos, dsize; + register struct text *d; + /* lie for now */ + + d = Text(self); + + if ( self->editor == VI ) + npos = text_GetEndOfLine(d, textview_GetDotPosition(self)); + else { + if ((dsize = textview_GetDotLength(self)) > 0) { + textview_SetDotPosition(self, dsize+textview_GetDotPosition(self)); + textview_SetDotLength(self, 0); + textview_WantUpdate(self, self); + return; + } + dsize = text_GetLength(d); + npos = textview_MoveBack(self, startpos=textview_GetDotPosition(self), 0 , textview_MoveByLines, NULL, NULL); + npos = textview_MoveForward(self, npos, 1, textview_MoveByLines, NULL, NULL); + if (npos > 0) { + if (npos == dsize) { + if (text_GetChar(d, npos-1) == '\n') npos--; + if (npos < startpos) npos = startpos; + } + else if (text_GetChar(d, npos-1) == ' ' ) + while (npos > startpos && (text_GetChar(d, npos-1)) == ' ') npos--; + else if (text_GetChar(d, npos-1) == '\n') npos--; + } + } + textview_SetDotPosition(self, npos); + textview_SetDotLength(self, 0); + textview_FrameDot(self, npos); + textview_WantUpdate(self, self); + } + + void textview_BeginningOfLineCmd(self) + register struct textview *self; + { + register int pos; + + if ( self->editor == VI ) + { + pos = text_GetBeginningOfLine(Text(self), textview_GetDotPosition(self)); + textview_SetDotPosition(self, pos); + textview_SetDotLength(self, 0); + } + else { + if (textview_GetDotLength(self) != 0) { + textview_SetDotLength(self,0); + pos = textview_GetDotPosition(self); + } + else { + pos = textview_MoveBack(self, textview_GetDotPosition(self),0, textview_MoveByLines, 0, 0); + textview_SetDotPosition(self,pos); + } + } + textview_FrameDot(self, pos); + textview_WantUpdate(self, self); + } + + void textview_EndOfWSWordCmd(self) + register struct textview *self; + {/**/ + long pos, textSize; + register int j, ct; + /***/ + ct = im_Argument(textview_GetIM(self)); + im_ClearArg(textview_GetIM(self)); + textSize = text_GetLength(Text(self)); + for (j = 0; j < ct; j++) + { + do + { + textview_EndOfWordCmd(self); + pos = textview_GetDotPosition(self); + } while ( pos < textSize && charType(text_GetChar(Text(self), pos)) != WHITESPACE ); + } + } + + void textview_ForwardWSWordCmd(self) + register struct textview *self; + {/**/ + long pos, textSize; + register int j, ct; + /***/ + ct = im_Argument(textview_GetIM(self)); + im_ClearArg(textview_GetIM(self)); + textSize = text_GetLength(Text(self)); + for (j = 0; j < ct; j++) + { + do + { + textview_ForwardWordCmd(self); + pos = textview_GetDotPosition(self); + } while ( pos < textSize && charType(text_GetChar(Text(self), pos - 1)) != WHITESPACE ); + } + } + + void textview_BackwardWSWordCmd(self) + register struct textview *self; + {/**/ + long pos; + register int j, ct; + /***/ + ct = im_Argument(textview_GetIM(self)); + im_ClearArg(textview_GetIM(self)); + for (j = 0; j < ct; j++) + { + do + { + textview_BackwardWordCmd(self); + pos = textview_GetDotPosition(self); + } while ( pos > 0 && charType(text_GetChar(Text(self), pos - 1)) != WHITESPACE ); + } + } + + void textview_BeginningOfFirstWordCmd(self) + struct textview *self; + { + register struct text *d; + char c; + + im_ClearArg(textview_GetIM(self)); + d=Text(self); + + textview_BeginningOfLineCmd(self); + c = text_GetChar(d, textview_GetDotPosition(self)); + if ( charType(c) == WHITESPACE && c != '\n' ) + textview_ForwardWordCmd(self); + } + + void textview_BeginningOfPreviousLineCmd(self) + struct textview *self; + { + int ct; + register int j; + + ct = im_Argument(textview_GetIM(self)); + im_ClearArg(textview_GetIM(self)); + + for (j = 0; j < ct; j++) + { + textview_PreviousLineCmd(self); + textview_BeginningOfFirstWordCmd(self); + } + } + + void textview_BeginningOfNextLineCmd(self) + struct textview *self; + { + int ct; + register int j; + + ct = im_Argument(self->header.view.imPtr); + im_ClearArg(self->header.view.imPtr); + + for (j = 0; j < ct; j++) + { + textview_NextLineCmd(self); + textview_BeginningOfFirstWordCmd(self); + } + } + + void textview_CursorToLine(self, line) + struct textview *self; + long line; + { + if (line > 0 && line <= self->nLines) { + textview_SetDotPosition(self, mark_GetPos(self->lines[line - 1].data)); + textview_SetDotLength(self, 0); + textview_WantUpdate(self, self); + } + } + + /* Useful commands for our editor. */ + + void textview_CursorToTop(self, key) + struct textview *self; + long key; + { + textview_CursorToLine(self, 1); + } + + void textview_CursorToCenter(self, key) + struct textview *self; + long key; + { + textview_CursorToLine(self, self->nLines / 2); + } + + void textview_CursorToBottom(self, key) + struct textview *self; + long key; + { + textview_CursorToLine(self, self->nLines); + } + + void textview_GoToLineCmd(self) + register struct textview *self; + { + + int argument, pos; + register struct text *text; + + argument = im_Argument(textview_GetIM(self)); + if ( !im_ArgProvided(textview_GetIM(self)) ) + textview_EndOfTextCmd(self); + else + { + text = (struct text *) self->header.view.dataobject; + textview_SetDotLength(self, 0); + pos = text_GetPosForLine(text, argument); + textview_SetDotPosition(self, pos); + textview_FrameDot(self, pos); + textview_WantUpdate(self, self); + } + } + + *** atk/text/txtvcsrch.c Thu May 30 20:16:51 1991 --- atk/text/txtvcsrch.c.NEW Wed Feb 13 16:54:55 1991 *************** *** 0 **** --- 1,568 ---- + /* ********************************************************************** *\ + * 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/text/RCS/txtvcsrch.c,v 1.3 91/02/13 10:28:19 dba Exp $ */ + /* $ACIS:txtvcsrch.c 1.7$ */ + /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/text/RCS/txtvcsrch.c,v $ */ + + #ifndef lint + static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/text/RCS/txtvcsrch.c,v 1.3 91/02/13 10:28:19 dba Exp $"; + #endif /* lint */ + + #include + #include + #include + #define AUXMODULE 1 + #include + #include + + #include + #include + #include + #include + #include + #include + + /* Search command statics. */ + + #define SRCHSTRLEN 100 + char *lastPattern = NULL; + static char searchString[SRCHSTRLEN] = ""; + boolean forwardSearch = TRUE; /* TRUE if last search was forward. */ + + boolean Quoted(doc, pos) + struct text *doc; + long pos; + { + /* returns true iff the character at pos is quoted (ie. "\"). Takes into account the slash being quoted. (ie "\\"). */ + + boolean retval = FALSE; + + pos--; + while (text_GetChar(doc, pos) == '\\' && pos > 0) { + retval = !retval; + pos--; + } + + return retval; + } + + int textview_SearchCmd(self) + register struct textview *self; + { + char defSrchString[SRCHSTRLEN], *tp, messageBuf[120], *prompt; + int pos = 0, gf, ct; + register int j; + register struct text *d; + boolean defaultExists = FALSE; + + d = Text(self); + ct = im_Argument(textview_GetIM(self)); + + if (*searchString != '\0'){ + defaultExists = TRUE; + strcpy(defSrchString, searchString); + } + if (defaultExists) { + sprintf(messageBuf, "Search for [%s] : ", defSrchString); + prompt = messageBuf; + } + else + prompt = "Search for: "; + gf = message_AskForString(self, 0, prompt, NULL, searchString, sizeof(searchString)); + if (gf < 0) return(-1); + if (defaultExists && *searchString == '\0') + strcpy(searchString, defSrchString); + textview_SetDotPosition(self, + textview_GetDotPosition(self)+textview_GetDotLength(self)); + if (!defaultExists || *searchString != '\0') { + tp = search_CompilePattern(searchString,&lastPattern); + if (tp != 0) { + message_DisplayString(self, 0, tp); + return(-2); + } + } + j = 0; + while (j 0) textview_SetDotPosition(self,orgpos-1); + if (!defaultExists || *searchString != '\0') { + tp = search_CompilePattern(searchString,&lastPattern); + if (tp != 0) { + message_DisplayString(self, 0, tp); + return -2; + } + } + j=0; + while (j 0) + textview_SetDotPosition(self, --pos); + pos = search_MatchPatternReverse(d, pos, lastPattern); + } + if (pos < 0) + { + message_DisplayString(self, 0, "Search failed."); + if ( !forwardSearch ) + 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 textview_SearchAgainOppositeCmd(self) + register struct textview *self; + { + forwardSearch ^= TRUE; + textview_SearchAgain(self); + } + + void textview_QueryReplaceCmd(self) + struct textview *self; + { + boolean defaultExists = FALSE; + boolean keepAsking = TRUE; + boolean keepRunning = TRUE; + boolean returnPosition = TRUE; + char *lastPattern = NULL; + char *prompt = NULL; + char *searchError = NULL; + char casedString[SRCHSTRLEN]; + char promptBuf[SRCHSTRLEN +20]; + int numFound = 0; + int numReplaced = 0; + int replacementLen = 0; + int reply = 0; + long fencePos = 0; + long originalLength = 0; + long originalPos = 0; + long pos = 0; + long searchPos = 0; + static char replacement[SRCHSTRLEN] = ""; + static char defSrchString[SRCHSTRLEN] = ""; + static int expertReplace = -999999; + struct mark *area = NULL; + struct text *d = NULL; + + if (ConfirmReadOnly(self)) + return; + casedString[0] = '\0'; + promptBuf[0] = '\0'; + if (expertReplace == -999999) + expertReplace = environ_GetProfileSwitch("ExpertMode", 0); + + d = Text(self); + + if (*searchString != '\0'){ + defaultExists = TRUE; + sprintf(defSrchString, "%s", searchString); + } + if (defaultExists) { + sprintf(promptBuf, "Replace [%s] : ", defSrchString); + if (*searchString == '\0') + sprintf(searchString, "%s", defSrchString); + prompt = promptBuf; + } + else + prompt = "Replace: "; + + if (message_AskForString(self, 0, prompt, NULL, searchString, sizeof(searchString)) < 0) + return; + if (defaultExists && *searchString == '\0') + sprintf(searchString, "%s", defSrchString); + + prompt = "New string: "; + if (message_AskForString(self, 0, prompt, NULL, replacement, sizeof(replacement)) < 0) + return; + replacementLen = strlen(replacement); + + if (!defaultExists || *searchString != '\0') + if ((searchError = search_CompilePattern(searchString, &lastPattern)) != NULL) { + message_DisplayString(self, 0, searchError); + return; + } + + originalPos = searchPos = textview_GetDotPosition(self); + originalLength = textview_GetDotLength(self); + + area = (originalLength != 0) ? text_CreateMark(d, originalPos, originalLength) : NULL; + + if (searchPos < (fencePos = text_GetFence(d))) searchPos = fencePos; + + while ((pos = search_MatchPattern(d, searchPos, lastPattern)) >= 0 + && keepRunning + && (area == NULL || pos < mark_GetPos(area) + mark_GetLength(area))) { + + long matchLen = search_GetMatchLength(); + /* length can change between matches on RE searches */ + + ++numFound; + + textview_SetDotPosition(self, pos); + textview_SetDotLength(self, matchLen); + textview_FrameDot(self, pos); + + if (keepAsking) { + textview_Update(self); + reply = im_GetCharacter(textview_GetIM(self)); + } + else + reply = ' '; + + switch (reply) { + case 'q': + case '\007': + case EOF: /* Interrupted im_GetChar */ + keepRunning = FALSE; + break; + case '-': /* WHAT IS THIS?? -- GHOTI */ + { + int i; + + if (isupper(text_GetChar(d, pos))) { + for (i = 1; i < matchLen; i++) + if (islower(text_GetChar(d, pos + i))) break; + if (i >= matchLen) { + for (i = 0; i < replacementLen; i++) + casedString[i] = (islower(replacement[i])) ? toupper(replacement[i]) : replacement[i]; + casedString[i] = '\0'; + } + else { /* Upcase first letter. */ + for (i = 0; i < replacementLen; i++) + casedString[i] = replacement[i]; + casedString[i] = '\0'; + casedString[0] = (islower(replacement[0])) ? toupper(replacement[0]) : replacement[0]; + } + } + else + strncpy(casedString, replacement, replacementLen); + + text_ReplaceCharacters(d, pos, matchLen, casedString, replacementLen); + searchPos = pos + replacementLen; + ++numReplaced; + } + break; + case '!': + case '.': + case ',': + case '=': + if (reply == '!') + keepAsking = FALSE; + else { + keepRunning = FALSE; + if (reply == ',') + returnPosition = FALSE; + else if (reply == '='){ + returnPosition = FALSE; + searchPos = pos + matchLen; + break; + } + } + /* Fall through. */ + case ' ': + text_ReplaceCharacters(d, pos, matchLen, replacement, replacementLen); + searchPos = pos + replacementLen; + ++numReplaced; + break; + case 'n': + searchPos = pos + 1; + break; + case 'r': + if (expertReplace) { + message_DisplayString(self, 0, "Recursive editing; ^C exits."); + im_KeyboardProcessor(); + break; + } + /* Otherwise, fall through to the default */ + default: + message_DisplayString(self, 0, expertReplace ? + "One of ' ', '.', 'n', 'r', '!', 'q' '-' ',' '='" : + "One of ' ', '.', 'n', '!', 'q' '-' ',' '='"); + im_ForceUpdate(); + break; + } + + if (keepAsking) + textview_Update(self); + } + if (numFound > 0) { + char messageString[100]; + if (returnPosition){ + if (area != NULL) { + textview_SetDotPosition(self, mark_GetPos(area)); + textview_SetDotLength(self, mark_GetLength(area)); + } else { + textview_SetDotPosition(self, originalPos); + textview_SetDotLength(self, originalLength); + } + textview_FrameDot(self, originalPos); + text_NotifyObservers(d, observable_OBJECTCHANGED); + } + sprintf(messageString, "Found %d occurrences; replaced %d.", + numFound, numReplaced); + message_DisplayString(self, 0, messageString); + } + else + message_DisplayString(self, 0, "No occurrences found."); + + if (area != NULL) { + text_RemoveMark(d, area); + mark_Destroy(area); + } + + return; + } + + struct paren_node { + long type; + struct paren_node *next; + }; + + long skipToNextBalanceSymbol(doc, pos, direction) + struct text *doc; + long pos; + int direction; + { + /* + * skip to next paren, bracket, or brace, ignoring + * quoted strings and comments. Search direction specified in "direction" + */ + boolean incomment = FALSE, instring = FALSE, doublestring; + int thischar, nextChar; + static char *opens = "({[", *closes = ")}]"; + long docLength = text_GetLength(doc); + long limit; + int increment; + + if ( pos < 0 || pos >= docLength ) + return EOF; + if ( direction == FORWARD ) + { + increment = 1; + limit = docLength; + } + else + { + increment = -1; + limit = 0; + } + while ( pos != limit ) + { + pos += increment; + thischar = text_GetChar(doc, pos); + nextChar = (pos == limit) ? 0 : text_GetChar(doc, pos + increment); + + if (incomment) { + if(thischar == '*' && nextChar == '/') { + incomment = FALSE; + } + } + else if (!Quoted(doc, pos)) { + if (instring) { + if ((thischar == '"' && doublestring) || (thischar == '\'' && !doublestring)) { + instring = FALSE; + } + } + else if (thischar == '"') { + instring = TRUE; + doublestring = TRUE; + } + else if (thischar == '\'') { + instring = TRUE; + doublestring = FALSE; + } + else if (thischar == '/' && nextChar == '*') { + incomment = TRUE; + } + else if ( (index(opens, thischar) != NULL || + index(closes, thischar) != NULL) && + !incomment && !instring ) + return pos; + } + } + return EOF; + } + + long balance(doc, pos) + struct text *doc; + long pos; + { + /* + * Returns the pos of the balancing symbol to the one + * pointed to by the passed value of pos + */ + char *parentype; + struct paren_node *parenstack = NULL; + static char *opens = "({[", *closes = ")}]"; + char *closeTable, *openTable; + + if ( pos <= 0 || pos >= text_GetLength(doc) ) + return EOF; + if ( index(opens, text_GetChar(doc, pos)) != NULL ) + { + /* searching forward */ + openTable = opens; + closeTable = closes; + } + else + if ( index(closes, text_GetChar(doc, pos)) != NULL ) + { + /* searching backward */ + openTable = closes; + closeTable = opens; + } + do + { + if ( (parentype = index(closeTable, text_GetChar(doc, pos))) != NULL ) + { + if ( parenstack == NULL || parenstack->type != (parentype - closeTable) ) + break; + else + { + struct paren_node *temp = parenstack; + + parenstack = parenstack->next; + free(temp); + if (parenstack == NULL) + return pos; /* found matching symbol */ + } + } + else if ((parentype = index(openTable, text_GetChar(doc, pos))) != NULL ) + { + struct paren_node *temp = NEW(struct paren_node); + + temp->type = parentype - openTable; + temp->next = parenstack; + parenstack = temp; + } + } while ( parenstack != NULL && + (pos = skipToNextBalanceSymbol(doc, pos, openTable == opens ? FORWARD : BACKWARD)) != EOF ); + + return EOF; + } + + void textview_BalanceCmd(self) + struct textview *self; + { + register struct text *doc; + long pos, docLength; + long leftBalancedPos = EOF, rightBalancedPos = EOF; + static char balanceSymbols[] = "[{()}]"; + + doc = Text(self); + docLength = text_GetLength(doc); + pos = textview_GetDotPosition(self); + while ( pos < docLength) + { + if ( (pos = skipToNextBalanceSymbol(doc, pos - 1, FORWARD)) == EOF ) + break; + if ( index(balanceSymbols, text_GetChar(doc, pos)) - balanceSymbols > 2 ) + { + leftBalancedPos = balance(doc, pos); + rightBalancedPos = pos; + break; + } + else + if ( (pos = balance(doc, pos)) != EOF ) + pos++; + else + break; + } + if ( leftBalancedPos == EOF || rightBalancedPos == EOF ) + { + message_DisplayString(self, 0, "Sorry, could not balance."); + return; + } + textview_SetDotPosition(self, leftBalancedPos); + textview_SetDotLength(self, rightBalancedPos - leftBalancedPos + 1); + textview_FrameDot(self, leftBalancedPos); + textview_WantUpdate(self, self); + } + + *** atk/text/txtvcmsc.c Sun May 12 21:13:49 1991 --- atk/text/txtvcmsc.c.NEW Fri Dec 14 16:57:01 1990 *************** *** 0 **** --- 1,345 ---- + /* ********************************************************************** *\ + * 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/text/RCS/txtvcmsc.c,v 1.1 90/12/14 14:57:01 ajp Exp $ */ + /* $ACIS:txtvcmcs.c 1.7$ */ + /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/text/RCS/txtvcmsc.c,v $ */ + + #ifndef lint + static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/text/RCS/txtvcmsc.c,v 1.1 90/12/14 14:57:01 ajp Exp $"; + #endif /* lint */ + + #include + #include + #define AUXMODULE 1 + #include + #include + + #include + #include + #include + #include + #include + #include + #include + + #ifdef CONVERSIONERROR + void textview_PrintFile(self) + struct textview *self; + { + register struct text *d = Text(self); + register struct buffer *b = (struct buffer *) buffer_FindData(d); + char *filename = b->fname; + + if (! filename || ! filename[0]) { + filename = b->bname; + if (! filename || ! filename[0]) + filename = "unknown"; + } + + doctroff_PrintDoc(d, 1, 1, filename, ""); + } + + void textview_PreviewCmd(self) + register struct textview *self; + { + register struct text *d = Text(self); + register struct buffer *b = buffer_finddata(d); + char *filename = b->fname; + + if (! filename || ! filename[0]) { + filename = b->bname; + if (! filename || ! filename[0]) + filename = "unknown"; + } + + doctroff_PrintDoc(d, 0, 1, filename, ""); + } + + void textview_SetPrinterCmd(self) + struct textview *self; + { + char p[200]; + char *currentprinter; + char str[300]; + + currentprinter = (char *) environ_Get("PRINTER"); + if (currentprinter == NULL) + currentprinter = environ_GetProfile("print.spooldir"); + if (message_AskForString(self, 0, + "Set Printer to: ", currentprinter, p, 200) < 0) { + if (p[0] == '\0') { + environ_Delete("PRINTER"); + strcpy(p, environ_GetProfile("print.spooldir")); + } + else + environ_Put("PRINTER", p); + } + else + strcpy(p, currentprinter); + sprintf(str, "Printer now set to %s", p); + message_DisplayString(self, 0, str); + } + #endif /* CONVERSIONERROR */ + + void textview_ToggleViModeCmd(self) + struct textview *self; + { + long lcstate = im_GetLastCmd(textview_GetIM(self)); + + textview_ToggleVIMode(self); + im_SetLastCmd(textview_GetIM(self), lcstate); /* be transparent */ + } + + void textview_ViCommandCmd(self, key) + struct textview *self; + long key; + { + char tc; + + tc = im_GetCharacter(self->header.view.imPtr); + switch (tc ) + { + case 'r': + textview_InsertFile(self, key); + break; + case 'q': + message_DisplayString(self, 0, "Please use Quit menu item."); + break; + case 'w': + message_DisplayString(self, 0, "Please use Save or File/Save-As menu items."); + break; + case 'e': + message_DisplayString(self, 0, "Please use Switch File menu item."); + break; + } + } + + void textview_ToggleEditorCmd(self) + struct textview *self; + { + textview_ToggleEditor(self); + } + + void textview_GrabReference(self,key) + struct textview *self; + long key; + { + long pos,len; + struct viewref *vr; + struct text *d = Text(self); + pos = textview_GetDotPosition(self); + len = textview_GetDotLength(self); + if (len == 0) len = text_GetLength(d) - pos; + if ((vr = text_FindViewreference(d, pos, len)) == NULL) + message_DisplayString(self, 0, "No References Found"); + else + d->currentViewreference = vr; + } + + void textview_PlaceReference(self,key) + struct textview *self; + long key; + { + long pos; + char p[250]; + struct text *d = Text(self); + boolean promptforname = im_ArgProvided(textview_GetIM(self)); + + im_ClearArg(textview_GetIM(self)); + + if (ConfirmReadOnly(self)) + return; + if(text_GetObjectInsertionFlag(Text(self)) == FALSE){ + message_DisplayString(self, 0, "Object Insertion Not Allowed!"); + return; + } + + *p = '\0'; + if(d->currentViewreference == NULL) { + message_DisplayString(self, 0, "No References Found"); + return; + } + pos = textview_GetDotPosition(self) + textview_GetDotLength(self); + if(promptforname && message_AskForString (self, 0, "View to place here ", d->currentViewreference->viewType, p, 200) < 0) return; + if (p[0] == '\0') strcpy(p,d->currentViewreference->viewType); + if(objecttest(self,p,"view") == FALSE) return; + text_AddView(d,pos,p, d->currentViewreference->dataObject); + text_NotifyObservers(d,observable_OBJECTCHANGED); + } + + void textview_CheckSpelling(self) + struct textview *self; + { + message_DisplayString(self, 0, + "Sorry; \"Check Spelling\" is not implemented."); + } + + void textview_ToggleReadOnly(self) + struct textview *self; + { + boolean argp = im_ArgProvided(textview_GetIM(self)), arg; + struct text *myText = Text(self); + + if (argp) + arg = im_Argument(textview_GetIM(self)); + if ((argp && arg) || (!argp && text_GetReadOnly(myText))) /* In readonly mode. */ + text_SetReadOnly(myText, FALSE); + else + text_SetReadOnly(myText, TRUE); + if (text_GetReadOnly(myText)) + message_DisplayString(self, 0, "Text is now read only."); + else + message_DisplayString(self, 0, "Text is now writable."); + text_NotifyObservers(myText, observable_OBJECTCHANGED); /* Handles updating of menus on read only transition. */ + } + + void textview_InsertPageBreak (self) + register struct textview *self; + { + long pos; + struct text *d; + + d = Text(self); + if(text_GetObjectInsertionFlag(d) == FALSE){ + message_DisplayString(self, 0, "Object Insertion Not Allowed!"); + return; + } + pos = textview_GetDotPosition(self); + textview_PrepareInsertion(self, TRUE); + if(text_GetChar(d,pos) != '\n'){ + text_InsertCharacters(d,pos,"\n",1); + } + if(text_GetChar(d,pos - 1) != '\n'){ + text_InsertCharacters(d,pos,"\n",1); + pos++; + } + + /* self->currentViewreference = */ + text_InsertObject(d, pos,"bp","bpv"); + textview_FinishInsertion(self); + text_NotifyObservers(d,observable_OBJECTCHANGED); + if (im_GetLastCmd(textview_GetIM(self)) == lcInsertEnvironment) { + im_SetLastCmd(textview_GetIM(self), lcInsertEnvironment); + } + } + + void textview_NextPage (self) + register struct textview *self; + { + long pos,len; + struct text *d; + struct viewref *vr; + d = Text(self); + len = text_GetLength(d); + pos = textview_GetDotPosition(self); + while ( pos <= len && (pos = text_Index(d,pos,TEXT_VIEWREFCHAR,len - pos)) != EOF){ + if((vr = text_FindViewreference(d,pos,1)) != NULL && + *(vr->viewType) == 'b' && + strcmp(vr->viewType,"bpv") == 0){ + textview_SetDotPosition(self,pos + 2); + textview_SetTopPosition(self,pos + 2); + break; + } + pos++; + } + } + long text_rindex(txt,pos,c) + register struct text *txt; + register long pos; + register char c; + { + for(;pos > 0;pos--){ + if(text_GetChar(txt,pos) == c) return pos; + } + return EOF; + } + void textview_LastPage (self) + register struct textview *self; + { + long pos,cnt; + struct text *d; + struct viewref *vr; + d = Text(self); + pos = textview_GetDotPosition(self); + for ( cnt = 0;pos > 0 && (pos = text_rindex(d,pos,TEXT_VIEWREFCHAR)) != EOF;pos--){ + if((vr = text_FindViewreference(d,pos,1)) != NULL && + *(vr->viewType) == 'b' && + strcmp(vr->viewType,"bpv") == 0){ + if(cnt++ == 0) continue; + textview_SetDotPosition(self,pos + 2); + textview_SetTopPosition(self,pos + 2); + return; + } + } + textview_SetDotPosition(self,0); + textview_SetTopPosition(self,0); + } + #if 0 + boolean lookforfootnote(self,text,pos,env) + struct textview *self; + struct text *text; + long pos; + struct environment *env; + { + struct style *st; + char *sn; + if(env->type == environment_Style) { + st = env->data.style; + if(st != NULL && ((sn = style_GetName(st)) != NULL) && + *sn == 'f' && strcmp(sn,"footnote") == 0) return TRUE; + } + return FALSE; + } + #endif + + void textview_InsertFootnote(self) + register struct textview *self; + { + long pos; + struct fnote *fn; + + if(text_GetObjectInsertionFlag(Text(self)) == FALSE){ + message_DisplayString(self, 0, "Object Insertion Not Allowed!"); + return; + } + pos = textview_GetDotPosition(self); + #if 0 + if(text_EnumerateEnvironments(Text(self),pos,0,lookforfootnote,NULL) != NULL){ + message_DisplayString(self,0,"footnotes in footnotes not supported"); + return; + } + #endif + fn = fnote_New(); + /* self->currentViewreference = text_InsertObject(Text(self), pos,"fnote","fnotev"); */ + text_AddView(Text(self), pos,"fnotev",fn); + fnote_addenv(fn,Text(self),pos); + + text_NotifyObservers(Text(self),observable_OBJECTCHANGED); + textview_SetDotPosition(self,pos + 1); + } + void textview_OpenFootnotes(self) + register struct textview *self; + { + fnote_OpenAll(Text(self)); + } + void textview_CloseFootnotes(self) + register struct textview *self; + { + fnote_CloseAll(Text(self)); + } + void textview_WriteFootnotes(self) + register struct textview *self; + { + FILE *f,*fopen(); + struct text *tmpt; + f = fopen("/tmp/notes","w"); + tmpt = text_New(); + fnote_CopyAll(Text(self),tmpt,1,TRUE); + text_Write(tmpt,f,0,0); + fclose(f); + text_Destroy(tmpt); + } + *** atk/text/txtvcmds.h Sun May 12 21:13:46 1991 --- atk/text/txtvcmds.h.NEW Fri Dec 14 16:57:02 1990 *************** *** 0 **** --- 1,32 ---- + /* ********************************************************************** *\ + * 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/text/RCS/txtvcmds.h,v 1.1 90/12/14 14:57:06 ajp Exp $ */ + /* $ACIS:txtvcmds.h 1.7$ */ + /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/text/RCS/txtvcmds.h,v $ */ + + extern long lcKill; + extern long lcYank; + extern long lcMove; + extern long lcDisplayEnvironment; + extern long lcInsertEnvironment; + extern long lcNewLine; + + /* yank/delete text flags in txtvcmds.c */ + #define YANK 0 + #define DELETE 1 + + /* search direction flag values used in txtvcmds.c */ + #define FORWARD 0 + #define BACKWARD 1 + + #define NEW(type) (type *) malloc(sizeof(type)) + + #define Text(v) (struct text *) ((v)->header.view.dataobject) + + #define TEXT_VIEWREFCHAR '\377' + + #define textview_GetLines(self) ((self)->nLines) + *** atk/text/tabs.doc Thu May 30 20:17:15 1991 --- atk/text/tabs.doc.NEW Wed Apr 3 21:22:22 1991 *************** *** 0 **** --- 1,664 ---- + \begindata{text,269519856} + \textdsversion{12} + \template{default} + \define{chapter + menu:[Title~3,Chapter~20] + attr:[Justification LeftJustified Point 0] + attr:[Flags KeepPriorNL Int Set] + attr:[Flags KeepNextNL Int Set] + attr:[FontFace Bold Int Set] + attr:[FontFamily AndySans Int 0] + attr:[FontSize ConstantFontSize Point 16]} + \define{section + menu:[Title~3,Section~21] + attr:[Justification LeftJustified Point 0] + attr:[Flags KeepPriorNL Int Set] + attr:[Flags KeepNextNL Int Set] + attr:[FontFace Bold Int Set] + attr:[FontFamily AndySans Int 0] + attr:[FontSize ConstantFontSize Point 14]} + \define{paragraph + menu:[Title~3,Paragraph~23] + attr:[Justification LeftJustified Point 0] + attr:[Flags KeepPriorNL Int Set] + attr:[FontFace Bold Int Set] + attr:[FontFamily AndySans Int 0] + attr:[FontSize ConstantFontSize Point 12]} + \define{majorheading + menu:[Title~3,MajorHeading~10] + attr:[Justification LeftJustified Point 0] + attr:[Flags KeepPriorNL Int Set] + attr:[Flags KeepNextNL Int Set] + attr:[FontFace Italic Int Set] + attr:[FontFamily AndySans Int 0] + attr:[FontSize ConstantFontSize Point 12]} + \define{fixedtext + menu:[Region~4,Fixedtext] + attr:[Justification LeftJustified Point 0] + attr:[FontFace FixedFace Int Set] + attr:[FontFamily AndyType Int 0] + attr:[FontSize ConstantFontSize Point 10]} + \define{fixedindent + menu:[Region~4,Fixedindent] + attr:[LeftMargin LeftMargin Cm 83230] + attr:[Justification LeftJustified Point 0] + attr:[FontFace FixedFace Int Set] + attr:[FontFamily AndyType Int 0] + attr:[FontSize ConstantFontSize Point 10]} + \define{paramname + menu:[Font~1,Paramname] + attr:[FontFace Italic Int Set]} + \define{fieldheading + menu:[Region~4,Fieldheading] + attr:[Justification LeftJustified Point 0] + attr:[FontFace Bold Int Set] + attr:[FontFamily AndySans Int 0] + attr:[FontSize ConstantFontSize Point 10]} + \define{fieldtext + menu:[Region~4,Fieldtext] + attr:[LeftMargin LeftMargin Cm 83230] + attr:[Justification LeftJustified Point 0] + attr:[FontFamily AndySans Int 0] + attr:[FontSize ConstantFontSize Point 10]} + \chapter{tabs} + + + This class provides routines for handling a list of tabstops. It is used in + the files text.c, drawtxtv.c, txttroff.c, lookzv.c and tabrulv.c + + + \section{About this section} + + + The class \italic{tabs} is a self-contained module, the only major external + reference being the text_statevector. + + + \section{About \italic{tabs}} + + + A tabs object maintains two arrays: \paramname{Positions} and + \paramname{Types}. These arrays define each tabstop precisely - + \paramname{Positions} is the position of the tabstop in points, and + \paramname{Types} is the type of tabstop, as allowed in style.ch. The number + of tabs in these arrays is held in the variable \italic{number}. Whenever you + change styles, you typically want to create a new list of tabstops, so to + prevent using too much memory, references to \paramname{tabs} objects are + copied instead of creating new tabstops. The access methods all use a + "copy-on-write" policy, such that when there is a need to change tabstops + within a \paramname{tabs} structure, then is when new tablists are created. + Reference counts are kept for each \paramname{tabs} object so that they can + be free'd when possible. + + The access methods provided allow you to get a handle on a default tablist and + copy tablists (neither routine will use new memory - they will just copy + references to other structures). For operating on the tablists, you can clear + all tabs, add or delete individual tabs, compare two tablists, and output a + troff description of the list. + + + \section{Using \italic{tabs}} + + + The class is probably useless outside of the text and textview objects. + + To create an instance, the preferred method is to use \italic{tabs_Create()} + which will return a tabs structure with a list of tabstops in the default + position. No new memory will be allocated when calling this routine - it will + just give you a handle on a default listing. If you ever call a tabs method + which needs to change the structure, it will allocate memory and copy it into + a new structure at that time. + + + The most common use of tabs occurs within the text_statevector structure. It + is vitally important that care is exercised when using tabs and state vectors. + You should do subtly different things for the three cases: initialized state + vectors, copied read-only state vectors, and copied read-write state vectors. + + + For details on this see the txtstvec.doc file. + + + \section{Author + + } + Nick Williams, + + njw@athena.mit.edu + + + + \begindata{bp,270071724} + \enddata{bp,270071724} + \view{bpv,270071724,129,0,0} + ______________________________________________________ + + + \paragraph{tabs_Add} + + + + \majorheading{Add a tabstop + + }______________________________________________________ + + + \fixedtext{struct tabs *\bold{tabs_Add }(}\fixedindent{ + + struct tabs *\paramname{tabs}, + + long \paramname{pos}, + + enum style_TabAlignment \paramname{op});} + + + \fieldheading{Category} + + \fieldtext{Method + + } + + \fieldheading{Description} + + \fieldtext{Adds a tabstop at position pos points across of type op. pos + should not be negative. + + } + + \fieldheading{Return Value} + + \fieldtext{It returns a handle to a possibly new tabs structure. If the tabs + structure passed in was merely a link to another tabs structure, the link will + be broken and a new tabs structure created. + + } + + \fieldheading{Usage} + + \fieldtext{Whenever you want to add a tabstop into a list of currently + existing tabstops, call this.\fieldtext{ + + }} + + \fieldheading{Example} + + + \fieldtext{\fixedtext{struct tabs *tabs; + + tabs = tabs_Create(); + + tabs = tabs_Add(tabs, 12, style_LeftAligned);\fieldtext{ + + }}} + \begindata{bp,270063008} + \enddata{bp,270063008} + \view{bpv,270063008,130,0,0} + ______________________________________________________ + + + \paragraph{tabs_ApplyChange} + + + + \majorheading{Change tabstops + + }______________________________________________________ + + + \fixedtext{struct tabs *\bold{tabs_ApplyChange }(}\fixedindent{ + + struct tabs *\paramname{tabs}, + + struct tabentry *\paramname{change});} + + + \fieldheading{Category} + + \fieldtext{Method + + } + + \fieldheading{Description} + + \fieldtext{Changes a tabs structure by the operations defined in tabentry. + + } + + \fieldheading{Return Value} + + \fieldtext{A pointer to the changed tabs. + + } + + \fieldheading{Usage} + + \fieldtext{Used in conjunction with \italic{style_GetTabChangeList}, which + gives you a list of these tabentry's.\fieldtext{ + + }} + + \fieldheading{Side Effects} + + \fieldtext{A new tabs tructure might be created if the entry passed in was + referenced by anyone else. + + } + + \fieldheading{See Also} + + \fieldtext{style_GetTabChangeList (atk/support/style.c) + + } + + \fieldheading{Example} + + + \fieldtext{\fixedtext{long numTabChanges; + + struct tabentry **TabChangeArray;\fieldtext{ + + }int i; + + + style_GetTabChangeList(style, &numTabChanges, &TabChangeArray); + + for (i = 0; i < numTabChanges; i++) + + tabs = tabs_ApplyChange(tabs, TabChangeArray[i]); + + if (TabChangeArray) + + free(TabChangeArray); + + }} + \begindata{bp,270082940} + \enddata{bp,270082940} + \view{bpv,270082940,131,0,0} + ______________________________________________________ + + + \paragraph{tabs_Clear} + + + + \majorheading{Clear All Tabs + + }______________________________________________________ + + + \fixedtext{struct tabs *\bold{tabs_Clear }(}\fixedindent{ + + struct tabs *\paramname{tabs});} + + + \fieldheading{Category} + + \fieldtext{Method + + } + + \fieldheading{Description} + + \fieldtext{Clears all tabstops defined in the list. \fieldtext{ + + }} + + \fieldheading{Return Value} + + \fieldtext{A pointer to the new tabs structure. + + } + + \fieldheading{Usage} + + \fieldtext{Whenever you want to clear all the tabs, e.g. after a + style_AllClear.\fieldtext{ + + }} + + \fieldheading{Side Effects} + + \fieldtext{A new tabs structure may be created, if the old is being referenced + by someone else. + + } + + \fieldheading{Example} + + + \fieldtext{\fixedtext{if (op == style_AllClear) + + tabs = tabs_Clear(tabs);\fieldtext{ + + }}} + \begindata{bp,270079620} + \enddata{bp,270079620} + \view{bpv,270079620,132,0,0} + ______________________________________________________ + + + \paragraph{tabs_Copy} + + + + \majorheading{Get a copy of another set of tabstops. + + }______________________________________________________ + + + \fixedtext{struct tabs *\bold{tabs_Copy }(}\fixedindent{ + + struct tabs *\paramname{tabs});} + + + \fieldheading{Category} + + \fieldtext{Method + + } + + \fieldheading{Description} + + \fieldtext{Copies the tabs structure passed in and returns you a handle. + Actually, all it really does, is pass you back the same pointer that came in, + but you don't know that. (It also increments the count of observers on the + tabs structure, so it is useful, honest!) + + } + + \fieldheading{Return Value} + + \fieldtext{A pointer to the copy. + + } + + \fieldheading{Usage} + + \fieldtext{Whenever you want to get a new list of tabs which has the same + initial tabstops defined as another tabs structure.\fieldtext{ + + }} + + \fieldheading{See Also} + + \fieldtext{tabs_Create() + + } + + \fieldheading{Example} + + + \fieldtext{\fixedtext{if (oldtabs) + + newtabs = tabs_Copy(oldtabs); + + else + + newtabs = tabs_Create();\fieldtext{ + + }}} + \begindata{bp,269890732} + \enddata{bp,269890732} + \view{bpv,269890732,133,0,0} + ______________________________________________________ + + + \paragraph{tabs_Create} + + + + \majorheading{Return a set of default tabstops + + }______________________________________________________ + + + \fixedtext{struct tabs *\bold{tabs_Create }(}\fixedindent{);} + + + \fieldheading{Category} + + \fieldtext{Classprocedure} + + + + \fieldheading{Description} + + \fieldtext{Returns you a tabs structure which contains tabstops at all the + default positions (every 1/2 inch + + } + \fieldheading{Return Value} + + \fieldtext{A pointer to a tabs structure. + + } + + \fieldheading{Usage} + + \fieldtext{Use this whenever you want to create new tabs - By using this + instead of \italic{tabs_New}(), you are saving loadsa memory. You should not + use \italic{tabs_New}().\fieldtext{ + + }} + + \fieldheading{See Also} + + \fieldtext{tabs_Copy + + } + \begindata{bp,270084584} + \enddata{bp,270084584} + \view{bpv,270084584,134,0,0} + ______________________________________________________ + + + \paragraph{tabs_Death} + + + + \majorheading{Destroy a tablist + + }______________________________________________________ + + + \fixedtext{void \bold{tabs_Death }(}\fixedindent{ + + \fixedindent{struct tabs *tabs} + + }\fixedindent{);} + + + \fieldheading{Category} + + \fieldtext{Classprocedure} + + + + \fieldheading{Description} + + \fieldtext{Destroys a tablist, ensuring that if it is referenced by other tab + structures, nothing gets broken.\fieldtext{ + + }} + + \fieldheading{Usage} + + \fieldtext{Use this whenever you want to destroy a tabs structure.\fieldtext{ + + }} + + \begindata{bp,270082896} + \enddata{bp,270082896} + \view{bpv,270082896,135,0,0} + ______________________________________________________ + + + \paragraph{tabs_Delete} + + + + \majorheading{Remove one tab from the tabstops + + }______________________________________________________ + + + \fixedtext{struct tabs *\bold{tabs_Delete }(}\fixedindent{ + + struct tabs *\paramname{tabs}, + + int \paramname{n});} + + + \fieldheading{Category} + + \fieldtext{Method + + } + + \fieldheading{Description} + + \fieldtext{Deletes the \italic{n'th} tab from the list of tabstops. + \paramname{n} must be between 0 and \italic{number}, where \italic{number} is + the number of tabs in the list. + + } + + \fieldheading{Return Value} + + \fieldtext{A pointer to the new list of tabs. + + } + + \fieldheading{Usage} + + \fieldtext{Whenever you want to get rid of a tab from the list.\fieldtext{ + + }} + + \fieldheading{Error Conditions} + + \fieldtext{Undefined if you pass in an illegal value of n. + + } + + \fieldheading{Side Effects} + + \fieldtext{May create a new tab structure if the old is being referenced by + someone else. + + } + \begindata{bp,269224436} + \enddata{bp,269224436} + \view{bpv,269224436,136,0,0} + ______________________________________________________ + + + \paragraph{tabs_Different + + } + + \majorheading{Compare two sets of tabstops + + }______________________________________________________ + + + \fixedtext{int \bold{tabs_Different }(}\fixedindent{ + + struct tabs *\paramname{tabs}, + + struct tabs *\paramname{b});} + + + \fieldheading{Category} + + \fieldtext{Method + + } + + \fieldheading{Description} + + \fieldtext{Compares two tabs structures to see if all the tabs defined are at + the same positions and of the same types. + + } + + \fieldheading{Return Value} + + \fieldtext{Returns 1 if the number of tabs in each is different or if any one + tab is either of a different type or at a different position from the other. + + Else returns 0. + + } + + \fieldheading{Usage} + + \fieldtext{When you want to find out if the tabs have changed of course! + :-)\fieldtext{ + + }} + + \fieldheading{Example} + + + \fieldtext{\fixedtext{if (tabs_Different(oldtabs, newtabs)) + + tabs_OutputTroff(newtabs); + + }} + \begindata{bp,269955156} + \enddata{bp,269955156} + \view{bpv,269955156,137,0,0} + ______________________________________________________ + + + \paragraph{tabs_OutputTroff + + } + + \majorheading{Output troff command to set tabstops + + }______________________________________________________ + + + \fixedtext{void \bold{tabs_OutputTroff }(}\fixedindent{ + + struct tabs *\paramname{tabs}, + + long \paramname{left}, + + FILE *\paramname{file});} + + + \fieldheading{Category} + + \fieldtext{Method + + } + + \fieldheading{Description} + + \fieldtext{Outputs a troff description to \paramname{file}, of the tabs + defined. Only tabstops at positions greater than \paramname{left} will be + output, and a left-aligned tab will be placed at position \paramname{left} if + it is non-zero. + + } + + \fieldheading{Known Bugs} + + \fieldtext{Only \italic{LeftAligned}, \italic{RightAligned} and + \italic{CenteredOnTab} types are output at present (that's all that troff + understands). If it is any other type, it will get ignored. + + } + + \fieldheading{See Also} + + \fieldtext{atk/text/drawtxtv.c + + } + + + + \enddata{text,269519856} *** atk/textaux/compchar.c Fri Dec 21 14:59:46 1990 --- atk/textaux/compchar.c.NEW Tue Dec 4 09:01:54 1990 *************** *** 2,18 **** * 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/textaux/RCS/compchar.c,v 1.12 90/11/03 13:01:21 rr2b Exp $ */ /* $ACIS:$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/textaux/RCS/compchar.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/textaux/RCS/compchar.c,v 1.12 90/11/03 13:01:21 rr2b Exp $"; #endif /* lint */ #include #include - #include /* sys/file.h and string(s).h */ #include #include --- 2,18 ---- * 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/textaux/RCS/compchar.c,v 1.13 90/11/28 14:46:50 susan Exp $ */ /* $ACIS:$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/textaux/RCS/compchar.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/textaux/RCS/compchar.c,v 1.13 90/11/28 14:46:50 susan Exp $"; #endif /* lint */ + #include /* sys/file.h and string(s).h */ #include #include #include #include *** atk/textaux/contentv.c Fri Dec 21 14:59:48 1990 --- atk/textaux/contentv.c.NEW Tue May 21 18:17:25 1991 *************** *** 2,24 **** * 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/textaux/RCS/contentv.c,v 1.15 90/10/30 16:14:22 gk5g Exp $ */ /* $ACIS:$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/textaux/RCS/contentv.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/textaux/RCS/contentv.c,v 1.15 90/10/30 16:14:22 gk5g Exp $"; #endif /* lint */ ! #include "class.h" ! #include "ctype.h" ! #include "bind.ih" ! #include "view.ih" ! #include "menulist.ih" ! #include "keymap.ih" ! #include "content.ih" ! #include "message.ih" ! #include "mark.ih" #include #include #include --- 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/textaux/RCS/contentv.c,v 1.18 1991/05/21 20:19:44 gk5g Exp $ */ /* $ACIS:$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/textaux/RCS/contentv.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/textaux/RCS/contentv.c,v 1.18 1991/05/21 20:19:44 gk5g Exp $"; #endif /* lint */ ! /* Modified 3/15/90 cch@mtgzx.att.com ! * Made it so that any change in dot position scrolls other window. ! Modified so that scrolls to main window put selection on top line. ! */ ! #include ! #include ! #include ! #include ! #include ! #include ! #include ! #include ! #include #include #include #include *************** *** 36,41 **** --- 40,46 ---- #include "contentv.eh" struct menulist *contentvMenus; static struct keymap *contentvKeyMap; + int ScrollTop = FALSE; #define Data(self) ((struct content *)(((struct view *) self)->dataobject)) #define Text(v) (struct text *) ((v)->header.view.dataobject) #define Srctext(self) (Data(self)->srctext) *************** *** 114,120 **** struct textview *tv = (struct textview *)v2; textview_SetDotPosition(tv,mark_GetPos(m)); textview_SetDotLength(tv,mark_GetLength(m)); ! textview_FrameDot(tv,mark_GetPos(m)); } return 0; /* go through all views */ } --- 119,127 ---- struct textview *tv = (struct textview *)v2; textview_SetDotPosition(tv,mark_GetPos(m)); textview_SetDotLength(tv,mark_GetLength(m)); ! if (ScrollTop) ! textview_SetTopPosition(tv, mark_GetPos(m)); ! else textview_FrameDot(tv,mark_GetPos(m)); } return 0; /* go through all views */ } *************** *** 186,191 **** --- 193,199 ---- struct proctable_Entry *pr; int (*proc)(); struct contentv_cntr cc; + struct content *content = (struct content*) contentv_GetDataObject(self); if((pr = proctable_Lookup("frame-delete-window")) != NULL && proctable_Defined(pr) && (buffer = buffer_FindBufferByData(Data(self))) != NULL && *************** *** 194,203 **** cc.tc = cc.bc = 0; cc.buf = buffer; frame_Enumerate(check, &cc); (*proc)(fr,0); if(cc.tc > 1 && cc.bc == 1) { buffer_Destroy(buffer); ! content_Destroy(Data(self)); } } } --- 202,213 ---- cc.tc = cc.bc = 0; cc.buf = buffer; frame_Enumerate(check, &cc); + frame_SetBuffer(fr,NULL,0); (*proc)(fr,0); if(cc.tc > 1 && cc.bc == 1) { + content_RemoveObserver(content, buffer); buffer_Destroy(buffer); ! content_Destroy(content); } } } *************** *** 304,309 **** --- 314,320 ---- contentvKeyMap = keymap_New(); bind_BindList(contentvBindings, contentvKeyMap , contentvMenus, &contentv_classinfo); proctable_DefineProc("contentv-make-window",contentv_MakeContents,textviewtype,NULL,"Make a table of contents window"); + ScrollTop = environ_GetProfileSwitch("ContentsScrollTop", FALSE); return TRUE; } *************** *** 325,331 **** return; } content_SetSourceText(ct,txt); - buffer = buffer_Create(buf,NULL,"contentv",ct); if((buffer = buffer_Create(buf,NULL,"contentv",ct)) == NULL) { fprintf(stderr,"Could not allocate enough memory.\n"); return; --- 336,341 ---- *************** *** 343,346 **** --- 353,363 ---- if(buffer) buffer_Destroy(buffer); if(ct) content_Destroy(ct); } + } + + void contentv__SetDotPosition(self, newpos) + struct contentview *self; + long newpos; { + super_SetDotPosition(self, newpos); + locate(self, 0); } *** atk/textaux/contentv.ch Wed Nov 22 12:35:23 1989 --- atk/textaux/contentv.ch.NEW Tue May 21 18:17:27 1991 *************** *** 2,18 **** * 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/textaux/RCS/contentv.ch,v 1.2 89/10/26 17:30:01 tpn Exp $ */ /* $ACIS:$ */ ! /* $Source: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/textaux/RCS/contentv.ch,v $ */ #ifndef lint ! static char *rcsidcontentv_ch = "$Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/textaux/RCS/contentv.ch,v 1.2 89/10/26 17:30:01 tpn Exp $"; #endif /* lint */ class contentv : textview [textv] { overrides: PostMenus(struct menulist *menulist); GetClickPosition(long position, long numberOfClicks, enum view_MouseAction action, long startLeft, long startRight, long *leftPos, long *rightPos); classprocedures: InitializeClass() returns boolean; --- 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/textaux/RCS/contentv.ch,v 1.3 1991/05/21 20:19:44 gk5g Exp $ */ /* $ACIS:$ */ ! /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/textaux/RCS/contentv.ch,v $ */ #ifndef lint ! static char *rcsidcontentv_ch = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/textaux/RCS/contentv.ch,v 1.3 1991/05/21 20:19:44 gk5g Exp $"; #endif /* lint */ class contentv : textview [textv] { overrides: PostMenus(struct menulist *menulist); + SetDotPosition(long newpos); GetClickPosition(long position, long numberOfClicks, enum view_MouseAction action, long startLeft, long startRight, long *leftPos, long *rightPos); classprocedures: InitializeClass() returns boolean; *** atk/toez/readscrb.c Mon Aug 6 11:10:45 1990 --- atk/toez/readscrb.c.NEW Mon Jan 21 12:47:37 1991 *************** *** 2,12 **** * Copyright IBM Corporation 1986,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/toez/RCS/readscrb.c,v 1.8 90/06/22 11:38:22 wjh Exp $ */ /* $ACIS:$ */ ! /* $Source: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/toez/RCS/readscrb.c,v $ */ #ifndef lint ! char *ReadScribe_rcsid = "$Header: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/toez/RCS/readscrb.c,v 1.8 90/06/22 11:38:22 wjh Exp $"; #endif /* lint */ --- 2,12 ---- * Copyright IBM Corporation 1986,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/toez/RCS/readscrb.c,v 1.9 91/01/16 15:22:32 wjh Exp $ */ /* $ACIS:$ */ ! /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/toez/RCS/readscrb.c,v $ */ #ifndef lint ! char *ReadScribe_rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/toez/RCS/readscrb.c,v 1.9 91/01/16 15:22:32 wjh Exp $"; #endif /* lint */ *************** *** 16,21 **** --- 16,24 ---- /* $Log: readscrb.c,v $ + * Revision 1.9 91/01/16 15:22:32 wjh + * fixed bug which inserted newlines in the middle of paragraphs if a previous line of the same length ended with a style that has the KeepNextNL flag + * * Revision 1.8 90/06/22 11:38:22 wjh * modified to ignore \r and ^Z, both of which are useless DOS-ian artifacts * *************** *** 1161,1165 **** --- 1164,1169 ---- LineEndCommand = FALSE; StartsWhite = HaveNonWhiteSpace = FALSE; EmbeddedWhiteSpace = 0; + LatestEndLoc = NULL; } *** atk/typescript/Imakefile Wed Nov 22 12:35:57 1989 --- atk/typescript/Imakefile.NEW Wed Apr 3 21:22:36 1991 *************** *** 24,35 **** NormalObjectRule() NormalATKRule() ! DynamicObject(tscript, ${UTILLIB},) InstallClassFiles($(DOBJS),$(IHFILES)) ! LibraryTarget(libtypescript.a,$(OBJS)) ! InstallLibrary(libtypescript.a,${DESTDIR}/lib/atk) InstallFile(shmenu,${INSTINCFLAGS},${DESTDIR}/lib) --- 24,35 ---- NormalObjectRule() NormalATKRule() ! DynamicObject(tscript, ${UTILLIB},${SUPLIBS}) InstallClassFiles($(DOBJS),$(IHFILES)) ! LibraryTarget(libtscript.a,$(OBJS)) ! InstallLibrary(libtscript.a,${DESTDIR}/lib/atk) InstallFile(shmenu,${INSTINCFLAGS},${DESTDIR}/lib) *** atk/typescript/fcomp.c Wed Nov 22 12:36:02 1989 --- atk/typescript/fcomp.c.NEW Mon Jun 3 17:11:17 1991 *************** *** 7,14 **** * August 1988 */ - #include #include #include #include #include --- 7,14 ---- * August 1988 */ #include + #include #include #include #include *************** *** 37,44 **** #include #include - extern char *rindex(); static struct cursor *waitCursor; static int (*typescript_GrabLastCmd) (); --- 37,44 ---- #include #include static struct cursor *waitCursor; + static long searchCmd; static int (*typescript_GrabLastCmd) (); *************** *** 46,57 **** #define MyEnvinfo(text,pos) environment_GetInnerMost(text->rootEnvironment, pos) #define min(x, y) (((x) < (y)) ? (x) : (y)) CompleteFname(ts, key) register struct typescript *ts; long key; { ! register long pos; ! register long fname; register struct text *theText; char pathname[MAXPATHLEN]; char buffer[MAXPATHLEN]; --- 46,58 ---- #define MyEnvinfo(text,pos) environment_GetInnerMost(text->rootEnvironment, pos) #define min(x, y) (((x) < (y)) ? (x) : (y)) + #define DEFAULTCHARWIDTH 12 + CompleteFname(ts, key) register struct typescript *ts; long key; { ! register long startpos, endpos, ch, textLen; register struct text *theText; char pathname[MAXPATHLEN]; char buffer[MAXPATHLEN]; *************** *** 58,93 **** char canonical[MAXPATHLEN]; register char *insert; char *msg = NULL; - pos = typescript_GetDotPosition(ts); theText = Text(ts); ! if (pos == text_GetLength(theText)) { ! fname = pos; ! while(text_GetChar(theText, fname) != ' ') fname--; ! fname++; ! text_CopySubString(theText, fname, pos-fname, pathname, FALSE); ! pathname[pos-fname] = 0; ! switch (completion_FileComplete(pathname, FALSE, buffer, MAXPATHLEN)) { ! case message_Complete: ! msg = "[Unique]"; ! break; ! case message_CompleteValid: ! msg = "[Others]"; ! break; ! case message_Valid: ! msg = "[Incomplete]"; ! break; ! case message_Invalid: ! msg = "[No Match]"; ! break; ! } ! message_DisplayString(ts, 0, msg); ! filetype_CanonicalizeFilename(canonical, pathname, MAXPATHLEN); ! insert = buffer + strlen(canonical); ! text_InsertCharacters(theText, pos, insert, strlen(insert)); ! typescript_SetDotPosition(ts, pos+strlen(insert)); ! text_NotifyObservers(theText, 0); } } --- 59,101 ---- char canonical[MAXPATHLEN]; register char *insert; char *msg = NULL; + boolean select = FALSE; theText = Text(ts); ! textLen = text_GetLength(theText); ! startpos = endpos = typescript_GetDotPosition(ts); ! ! while((startpos > 0) && ((isascii(ch = text_GetChar(theText, startpos)) && !isspace(ch)) || (ch == EOF))) { ! startpos--; ! } ! if(isspace(ch)) startpos++; ! ! text_CopySubString(theText, startpos, endpos-startpos, pathname, FALSE); ! pathname[endpos-startpos] = 0; ! switch (completion_FileComplete(pathname, FALSE, buffer, MAXPATHLEN)) { ! case message_Complete: ! msg = "[Unique]"; ! break; ! case message_CompleteValid: ! msg = "[Others]"; ! break; ! case message_Valid: ! msg = "[Incomplete]"; ! break; ! case message_Invalid: ! msg = "[No Match]"; ! break; } + message_DisplayString(ts, 0, msg); + filetype_CanonicalizeFilename(canonical, pathname, MAXPATHLEN); + insert = buffer + strlen(canonical); + text_InsertCharacters(theText, endpos, insert, strlen(insert)); + if(select) { + typescript_SetDotPosition(ts, startpos); + typescript_SetDotLength(ts, strlen(buffer) - 1); + } + else typescript_SetDotPosition(ts, endpos+strlen(insert)); + text_NotifyObservers(theText, 0); } *************** *** 123,129 **** struct repCookie { boolean refusedot; ! char *report; long columns; long colwidth; long rows; --- 131,137 ---- struct repCookie { boolean refusedot; ! char **report; long columns; long colwidth; long rows; *************** *** 131,141 **** long repcolwidth; long reprowlen; long widthinchar; long count; }; #define COLSPACE 1 - #define repspot(cookie, s) ((s) * cookie->repcolwidth) static MakeReport(cookie, itemtype, item, dummy) struct repCookie *cookie; --- 139,151 ---- long repcolwidth; long reprowlen; long widthinchar; + long maxwidthinpix; long count; + struct graphic *ts; + struct fontdesc *font; }; #define COLSPACE 1 static MakeReport(cookie, itemtype, item, dummy) struct repCookie *cookie; *************** *** 143,154 **** char *item; long dummy; /* along for the ride */ { if (acceptitem(cookie, item, itemtype)) { ! strcpy(&cookie->report[repspot(cookie, cookie->count)], item); ! cookie->count++; } } PossibleCompletions(ts, key) register struct typescript *ts; --- 153,211 ---- char *item; long dummy; /* along for the ride */ { + long widthinpix; + if (acceptitem(cookie, item, itemtype)) { ! cookie->report[cookie->count] = (char*)malloc(strlen(item) + 1); ! strcpy(cookie->report[cookie->count++], item); ! widthinpix = fontdesc_StringSize(cookie->font, (struct graphic*) cookie->ts, item, NULL, NULL); ! if(widthinpix > cookie->maxwidthinpix) { ! cookie->maxwidthinpix = widthinpix; ! } ! } ! } ! ! static char * ! SaveLastCommand(td) ! struct typescript *td; ! { ! long len, spos; ! struct text *mydoc; ! char *textBuf; ! char *cmdStr; ! long retLen; ! ! mydoc = Text(td); ! spos = mark_GetPos(td->cmdStart); ! len = text_GetLength(mydoc); ! ! if (spos == len) ! return NULL; ! ! cmdStr = (char *) malloc(len - spos + 1); ! *cmdStr = '\0'; ! ! while(spos < len) { ! textBuf = text_GetBuf(mydoc, spos, len - spos, &retLen); ! if(textBuf != NULL) { ! strncpy(cmdStr,textBuf,retLen); ! cmdStr[retLen] = '\0'; ! spos += retLen; ! } ! else ! break; } + return cmdStr; } + static int + mystrcmp(s1,s2) + register char **s1,**s2; + { + if(s1 && *s1 && s2 && *s2) + return(strcmp(*s1,*s2)); + else return(0); + } PossibleCompletions(ts, key) register struct typescript *ts; *************** *** 159,172 **** pos = typescript_GetDotPosition(ts); theText = Text(ts); ! if (pos == text_GetLength(theText)) { register long fname; char pathname[MAXPATHLEN]; ! long pathlen; ! boolean emptycmd; struct helpstat rock; ! emptycmd = (mark_GetPos(ts->cmdStart) == pos); fname = pos; while(text_GetChar(theText, fname) != ' ') fname--; fname++; --- 216,229 ---- pos = typescript_GetDotPosition(ts); theText = Text(ts); ! if(pos == text_GetLength(theText)) { register long fname; char pathname[MAXPATHLEN]; ! long pathlen; ! char *cmdStr; struct helpstat rock; ! cmdStr = SaveLastCommand(ts); fname = pos; while(text_GetChar(theText, fname) != ' ') fname--; fname++; *************** *** 178,254 **** rock.itemcnt = rock.maxitemlen = rock.errorcnt = 0; pathlen = strlen(pathname); rock.refusedot = FALSE; ! if (pathlen == 0) rock.refusedot = TRUE; else { ! if (pathname[pathlen-1] == '/') rock.refusedot = TRUE; } ! completion_FileHelp((*pathname) ? pathname : "./", 0, GatherStats, &rock); ! if (rock.errorcnt || rock.itemcnt == 0) { message_DisplayString(ts, 0, "[No Match]"); } else { ! struct style *tsStyle; enum style_FontSize dummy; char ffamily[MAXPATHLEN]; long tssize; - struct fontdesc *tsfont; char spaces[MAXPATHLEN]; long windowwidth; - long charwidth; struct repCookie cookie; ! register long i; ! register long j; ! ! tsStyle = typescript_GetDefaultStyle(ts); ! style_GetFontSize(tsStyle, &dummy, &tssize); ! style_GetFontFamily(tsStyle, ffamily, MAXPATHLEN); ! tsfont = fontdesc_Create(ffamily, fontdesc_Fixed, tssize); - charwidth = fontdesc_FontSummary(tsfont, ts)->maxSpacing; - windowwidth = typescript_GetVisualRight(ts); cookie.refusedot = rock.refusedot; ! cookie.widthinchar = windowwidth/charwidth - 1; cookie.colwidth = rock.maxitemlen + COLSPACE; ! /* how many columns could fit? */ ! cookie.columns = (cookie.widthinchar + COLSPACE) / cookie.colwidth; if (cookie.columns == 0) cookie.columns = 1; ! /* min number of rows required */ ! cookie.rows = (rock.itemcnt + cookie.columns - 1) / cookie.columns; ! /* how many columns are actually needed? */ ! cookie.columns = (rock.itemcnt + cookie.rows - 1) / cookie.rows; ! /* round out the columns to use the available space */ ! cookie.colwidth = (cookie.widthinchar + COLSPACE) / cookie.columns; cookie.repcolwidth = rock.maxitemlen + 1; cookie.reprowlen = cookie.repcolwidth * cookie.columns; - cookie.count = 0; - cookie.report = (char *) malloc(rock.itemcnt * (rock.maxitemlen+1)); ! completion_FileHelp((*pathname) ? pathname : "./", 0, MakeReport, &cookie); ! qsort(cookie.report, rock.itemcnt, rock.maxitemlen+1, strcmp); ! for (i=0; ireadOnlyLen = -1; typescript_SetDotPosition(ts, pos); typescript_SetDotLength(ts, 0); ! ts->lastEnv = NULL; mark_SetPos(ts->cmdStart, pos); mark_SetLength(ts->cmdStart, 0); text_SetFence(theText, pos); typescript_FrameDot(ts, pos); - text_NotifyObservers(theText, 0); - write(ts->SubChannel, "\n", 1); ! if (!emptycmd) { ! typescript_GrabLastCmd(ts); ! typescript_CollapseDot(ts); } } } - #ifdef COMMANDCOMPLETION static struct SearchPattern *pattern = 0; static char lastcmd[MAXPATHLEN]; - static long lastbegin = 0; static long lastmatch; ! CompleteCmd(ts, key) register struct typescript *ts; ! long key; { register long pos; register struct text *theText; register long begincmd; ! pos = typescript_GetDotPosition(ts); theText = Text(ts); begincmd = mark_GetPos(ts->cmdStart); ! if (pos == text_GetLength(theText) && begincmd < pos) { ! char cmd[MAXPATHLEN]; ! register long match; ! struct style *boldStyle; ! char *patcode; ! ! boldStyle = stylesheet_Find(theText->styleSheet, "bold"); ! text_CopySubString(theText, begincmd, pos-begincmd, cmd, FALSE); ! cmd[pos-begincmd] = 0; ! if (begincmd == lastbegin && strcmp(cmd, lastcmd) == 0) { ! match = lastmatch; ! } ! else { ! match = begincmd; ! } if (patcode = search_CompilePattern(cmd, &pattern)) { ! message_DisplayString(ts, 0, patcode); ! } ! else { ! while ((match = search_MatchPatternReverse(theText, match-1, pattern)) >= 0) { ! if (MyEnvinfo(theText, match)->data.style == boldStyle) { ! if (MyEnvinfo(theText, match-1)->data.style != boldStyle) break; ! } ! } ! lastmatch = match; ! strcpy(lastcmd, cmd); ! lastbegin = begincmd; ! if (match >= 0) { ! register long endmatch; ! ! text_DeleteCharacters(theText, begincmd, pos-begincmd); ! pos = begincmd; ! for (endmatch = match; text_GetChar(theText, endmatch) != '\n'; endmatch++); ! text_CopySubString(theText, match, endmatch-match, cmd, FALSE); ! text_InsertCharacters(theText, pos, cmd, endmatch-match); ! pos += endmatch-match; ! typescript_SetDotPosition(ts, pos); ! text_NotifyObservers(theText, 0); ! } ! else message_DisplayString(ts, 0, "[No matching command]"); } } } - #endif /* COMMANDCOMPLETION */ boolean fcomp__InitializeClass(classID) struct classheader *classID; --- 309,445 ---- ts->readOnlyLen = -1; typescript_SetDotPosition(ts, pos); typescript_SetDotLength(ts, 0); ! ts->lastCmdPos = text_GetLength(ts->cmdText); mark_SetPos(ts->cmdStart, pos); mark_SetLength(ts->cmdStart, 0); text_SetFence(theText, pos); typescript_FrameDot(ts, pos); write(ts->SubChannel, "\n", 1); ! if (cmdStr != NULL) { ! text_InsertCharacters(theText, text_GetLength(theText), cmdStr, strlen(cmdStr)); ! pos = text_GetLength(theText); ! typescript_SetDotPosition(ts, pos); ! typescript_SetDotLength(ts, 0); ! typescript_FrameDot(ts, pos); ! free(cmdStr); } + + text_NotifyObservers(theText, 0); } } static struct SearchPattern *pattern = 0; static char lastcmd[MAXPATHLEN]; static long lastmatch; ! CompleteCmdWork(ts, forward) register struct typescript *ts; ! boolean forward; { register long pos; register struct text *theText; register long begincmd; + long lastEventCmd; + char cmd[MAXPATHLEN]; + register long match; + char *patcode; ! ! lastEventCmd = im_GetLastCmd(typescript_GetIM(ts)); theText = Text(ts); + + pos = typescript_GetDotPosition(ts); begincmd = mark_GetPos(ts->cmdStart); ! ! if (lastEventCmd == searchCmd) { ! match = lastmatch; ! strcpy(cmd, lastcmd); ! } ! else { ! char unquotedCmd[MAXPATHLEN]; ! long len = pos - begincmd; ! ! if (len >= sizeof(unquotedCmd) - 1) { ! len = sizeof(unquotedCmd) -1; ! } ! ! text_CopySubString(theText, begincmd, len, unquotedCmd, FALSE); ! search_GetQuotedSearchString(unquotedCmd, cmd, sizeof(cmd)); ! match = text_GetLength(ts->cmdText); ! } ! ! if (strlen(cmd) != 0) { if (patcode = search_CompilePattern(cmd, &pattern)) { ! message_DisplayString(ts, 0, patcode); ! return; } + else { + while (TRUE) { + if (forward) { + match = search_MatchPattern(ts->cmdText, match+1, pattern); + } + else { + match = search_MatchPatternReverse(ts->cmdText, match-1, pattern); + } + if (match <= 0 || text_GetChar(ts->cmdText, match - 1) == '\n') { + break; + } + } + } } + else { + if (forward) { + if (match < text_GetLength(ts->cmdText)) { + match = text_GetEndOfLine(ts->cmdText, match) + 1; + } + else { + match = -1; + } + } + else { + if (match > 0) { + match = text_GetBeginningOfLine(ts->cmdText, match - 1); + } + else { + match = -1; + } + } + } + + if (match >= 0 && match != text_GetLength(ts->cmdText)) { + register long endmatch; + + lastmatch = match; + strcpy(lastcmd, cmd); + text_DeleteCharacters(theText, begincmd, mark_GetLength(ts->cmdStart)); + pos = begincmd; + endmatch = text_GetEndOfLine(ts->cmdText, match); + text_CopySubString(ts->cmdText, match, endmatch-match, cmd, FALSE); + text_InsertCharacters(theText, pos, cmd, endmatch-match); + pos += endmatch-match; + typescript_SetDotPosition(ts, pos); + text_NotifyObservers(theText, 0); + } + else message_DisplayString(ts, 0, "[No matching command]"); + + im_SetLastCmd(typescript_GetIM(ts), searchCmd); + } + + CompleteCmdForward(ts, key) + register struct typescript *ts; + long key; + { + CompleteCmdWork(ts, TRUE); } + CompleteCmdBackward(ts, key) + register struct typescript *ts; + long key; + { + CompleteCmdWork(ts, FALSE); + } boolean fcomp__InitializeClass(classID) struct classheader *classID; *************** *** 343,352 **** waitCursor = cursor_Create(NULL); cursor_SetStandard(waitCursor, Cursor_Wait); ! #ifdef COMMANDCOMPLETION lastcmd[0] = 0; class_Load("search"); - #endif /* COMMANDCOMPLETION */ class_Load("completion"); --- 449,458 ---- waitCursor = cursor_Create(NULL); cursor_SetStandard(waitCursor, Cursor_Wait); ! searchCmd = im_AllocLastCmd(); ! lastcmd[0] = 0; class_Load("search"); class_Load("completion"); *************** *** 355,363 **** proctable_DefineProc("fcomp-complete-filename", CompleteFname, imc, NULL, "Filename completion (typescript)"); proctable_DefineProc("fcomp-possible-completions", PossibleCompletions, imc, NULL, "Display possible filename completions (typescript)"); ! #ifdef COMMANDCOMPLETION ! proctable_DefineProc("fcomp-complete-command", CompleteCmd, imc, NULL, "Complete partial command (typescript)"); ! #endif /* COMMANDCOMPLETION */ typescript_GrabLastCmd = proctable_GetFunction(proctable_Lookup("typescript-Grab-Last-Cmd")); --- 461,468 ---- proctable_DefineProc("fcomp-complete-filename", CompleteFname, imc, NULL, "Filename completion (typescript)"); proctable_DefineProc("fcomp-possible-completions", PossibleCompletions, imc, NULL, "Display possible filename completions (typescript)"); ! proctable_DefineProc("fcomp-complete-command-backward", CompleteCmdBackward, imc, NULL, "Complete partial command - searching backwards (typescript)"); ! proctable_DefineProc("fcomp-complete-command-forward", CompleteCmdForward, imc, NULL, "Complete partial command - searching forwards (typescript)"); typescript_GrabLastCmd = proctable_GetFunction(proctable_Lookup("typescript-Grab-Last-Cmd")); *** atk/typescript/tscript.c Fri Dec 21 14:59:54 1990 --- atk/typescript/tscript.c.NEW Mon Jun 3 17:30:04 1991 *************** *** 2,16 **** * 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/typescript/RCS/tscript.c,v 2.40 90/11/01 15:38:19 gk5g Exp $ */ /* $ACIS:tscript.c 1.5$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/typescript/RCS/tscript.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/typescript/RCS/tscript.c,v 2.40 90/11/01 15:38:19 gk5g Exp $"; #endif /* lint */ ! #include #include #include --- 2,16 ---- * 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/typescript/RCS/tscript.c,v 2.55 1991/06/03 21:27:54 gk5g Exp $ */ /* $ACIS:tscript.c 1.5$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/typescript/RCS/tscript.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/typescript/RCS/tscript.c,v 2.55 1991/06/03 21:27:54 gk5g Exp $"; #endif /* lint */ ! #include /* sys/types.h sys/time.h */ #include #include #include *************** *** 35,41 **** #include #include - #include /* sys/types.h sys/time.h */ #include #include #ifdef hpux --- 35,40 ---- *************** *** 43,50 **** --- 42,58 ---- #include #endif /* hpux */ + #ifdef M_UNIX + #include + #include + #include + #endif + #include + #ifdef POSIX_ENV + #include + #else #if SY_AIX221 #include #include *************** *** 53,83 **** #else /* #if SY_AIX221 */ #include #endif /* #if SY_AIX221 */ #if SY_AIX12 - #include - #include - static char io_buffer[4096]; - #define write ps2_write_pty - static int ps2_write_pty(); - /* WARNING: This assumes all writes go to a pty, which is not true. - The write after execlp is the only exception at the time this was written. - AIX/PS2 has a serious bug in the pty driver (REMOTE doesn't work). - Delete this crud once REMOTE works. - */ - FILE *myfile; #endif /* SY_AIX12 */ /* #define DONTCUTSTYLES */ ! #define MyEnvinfo(text,pos) environment_GetInnerMost(text->rootEnvironment, pos) ! #define TEXT(A) ((struct text *)(A->header.view.dataobject)) #define TEXTOBJ(A) A->header.view.dataobject - static char *DefaultArgList[] = { - 0, 0 - }; #define ISPIPESCRIPT(self) (self->pipescript) /* #define SENDRAW 1 */ static char **myarglist = NULL; --- 61,87 ---- #else /* #if SY_AIX221 */ #include #endif /* #if SY_AIX221 */ + #endif /* POSIX_ENV */ #if SY_AIX12 static char io_buffer[4096]; #endif /* SY_AIX12 */ + #if SY_AIX31 || SY_AIX31 + #define UTMP_MUNGE 1 + #endif + + #ifdef UTMP_MUNGE + #include + #endif /* #define DONTCUTSTYLES */ ! #define MyEnvinfo(text,pos) environment_GetInnerMost(text->rootEnvironment,pos) ! #define TEXT(A) ((struct text*)(A->header.view.dataobject)) #define TEXTOBJ(A) A->header.view.dataobject #define ISPIPESCRIPT(self) (self->pipescript) + + static char *DefaultArgList[] = { 0, 0 }; /* #define SENDRAW 1 */ static char **myarglist = NULL; *************** *** 90,95 **** --- 94,102 ---- static void Typescript_SelfInsertCmd(); static void MyCanOutHandler(); + static void SendSig(); + static int WritePty(); + /* The following are initialized from the proctable by our InitializeClass * routine. There may well be a better way of doing this. The routines * should certainly be void instead of int, but the proctable package *************** *** 109,115 **** static int (*typescript_ZapRegionCmd)(); #ifndef _IBMR2 ! extern char *realloc(); #endif /* _IBMR2 */ static long maxSize; --- 116,122 ---- static int (*typescript_ZapRegionCmd)(); #ifndef _IBMR2 ! extern char *realloc(); #endif /* _IBMR2 */ static long maxSize; *************** *** 117,222 **** static char *cmd; static int CmdSize; static boolean FileMenu = FALSE; ! #define SetCmdSize(A) if(A > CmdSize) cmd = (char *) realloc(cmd,(CmdSize = 64 + A)) ! static ! typescriptAddMenu (nbuf,proc) char *nbuf; struct proctable_Entry *proc; { ! char *c,*bf,*cp,*retstr; ! retstr = NULL; ! bf = (char *)malloc(strlen(nbuf) + 1); ! for(c = bf,cp = nbuf; *cp != '\0'; cp++ ,c++){ ! if( *cp == ':'){ ! *c = '\0'; ! retstr = c + 1; ! } ! else *c = *cp; ! } ! *c = '\0'; ! if(retstr && *retstr){ ! menulist_AddToML(typescriptMenus,bf,proc,(long) retstr,0); ! } ! else free( bf); } ! static typescript_PreviewCmd(self) ! struct typescript *self; { doprint(self,0); } ! static typescript_PrintCmd(self) ! struct typescript *self; { doprint(self,1); } ! static doprint(self,porp) struct typescript *self; int porp; { - - message_DisplayString(self, 0, "Processing request."); im_ForceUpdate(); ! ! if (class_Load("print") == NULL) { message_DisplayString(self, 0, "Print aborted: could not load class \"print\"."); return; } ! print_ProcessView((struct view *)self, porp, 1,"pipescript", ""); message_DisplayString(self, 0, "Print request submitted; watch console for results."); } ! static typescript_SaveAs(self) ! struct typescript *self; { ! char frs[256],mes[256]; FILE *f; int failed = 0; ! if(message_AskForString(self,0,"File Name: ","",frs,256) == -1) return; ! filetype_CanonicalizeFilename(mes,frs,256); ! if((f = fopen(mes,"w")) == NULL) failed++; else { ! text_Write(TEXT(self),f,im_GetWriteID(),0); ! if (vclose(fileno(f)) < 0) failed++; ! } ! if(failed) ! { ! sprintf(frs,"Can't write %s",mes); ! message_DisplayString(self,0,frs); return; } ! sprintf(frs,"wrote %s",mes); ! message_DisplayString(self, 0,frs); } ! static typescript_SetPrinterCmd(self) struct typescript *self; { struct msghandler *messageLine = (struct msghandler *) typescript_WantHandler(self, "message"); char *currentPrinter, *defaultPrinter, answer[256], prompt[sizeof("Current printer is . Set printer to []: ") + 128]; ! if (messageLine == NULL) return; currentPrinter = environ_Get("PRINTER"); defaultPrinter = environ_GetProfile("print.spooldir"); ! if (currentPrinter != NULL && defaultPrinter != NULL) sprintf(prompt, "Current printer is %.64s. Set printer to [%.64s]: ", currentPrinter, defaultPrinter); ! else if (defaultPrinter != NULL) sprintf(prompt, "Set printer to [%.64s]: ", defaultPrinter); else strcpy(prompt, "Set printer to: "); ! if (msghandler_AskForString(messageLine, 0, prompt, NULL, answer, sizeof(answer)) == -1) return; ! if (*answer != '\0') { environ_Put("PRINTER", answer); defaultPrinter = answer; } ! else ! environ_Delete("PRINTER"); ! if (defaultPrinter != NULL) { sprintf(prompt, "Printer set to %.64s.", defaultPrinter); msghandler_DisplayString(messageLine, 0, prompt); } --- 124,278 ---- static char *cmd; static int CmdSize; static boolean FileMenu = FALSE; ! #define SetCmdSize(A) if(A>CmdSize) cmd = (char*)realloc(cmd,(CmdSize = 64 + A)) ! static int ! typescriptAddMenu(nbuf, proc) char *nbuf; struct proctable_Entry *proc; { ! char *c, *bf, *cp, *retstr; ! ! retstr = NULL; ! bf = (char*) malloc(strlen(nbuf) + 1); ! for(c = bf,cp = nbuf; *cp != '\0'; cp++ ,c++) { ! if(*cp == ':') { ! *c = '\0'; ! retstr = c + 1; ! } ! else ! *c = *cp; ! } ! *c = '\0'; ! if(retstr && *retstr) ! menulist_AddToML(typescriptMenus, bf, proc, (long)retstr, 0); ! else free(bf); } ! static int ! typescript_PreviewCmd(self) ! struct typescript *self; { doprint(self,0); } ! static int ! typescript_PrintCmd(self) ! struct typescript *self; { doprint(self,1); } ! ! static int ! doprint(self, porp) struct typescript *self; int porp; { message_DisplayString(self, 0, "Processing request."); im_ForceUpdate(); ! if(class_Load("print") == NULL) { message_DisplayString(self, 0, "Print aborted: could not load class \"print\"."); return; } ! print_ProcessView((struct view *)self, porp, 1, "pipescript", ""); message_DisplayString(self, 0, "Print request submitted; watch console for results."); } ! ! static int ! typescript_SaveAs(self) ! struct typescript *self; { ! char frs[256], mes[256]; FILE *f; int failed = 0; ! ! if(message_AskForString(self, 0, "File Name: ", "", frs, 256) == -1) ! return; ! filetype_CanonicalizeFilename(mes, frs, 256); ! if((f = fopen(mes, "w")) == NULL) ! failed++; else { ! text_Write(TEXT(self), f, im_GetWriteID(), 0); ! if(vclose(fileno(f)) < 0) ! failed++; ! } ! if(failed) { ! sprintf(frs, "Can't write %s", mes); ! message_DisplayString(self, 0, frs); return; } ! sprintf(frs, "wrote %s", mes); ! message_DisplayString(self, 0, frs); } ! #ifdef PRINTCLASSIFICATION_ENV ! void ! typescript_SetPrtClassification(self) struct typescript *self; { + long i, answer, choicenum = 1; + char *currentclass, prompt[256]; + char *nochange = "No Change"; + static char *values[] = printclassification_VALUES; + static char *meanings[] = printclassification_MEANINGS; + char *choices[sizeof(meanings)/sizeof(char*) + 1]; + + /* Create the choices by prepending the no change choice to the meanings array */ + choices[0] = nochange; + for(i=0; meanings[i] != NULL; i++) + choices[i+1] = meanings[i]; + choices[i+1] = NULL; + + if(currentclass = environ_Get(PRINTCLASSIFICATION_ENV)) { + for(i = 0; ULstrcmp(currentclass, values[i]) && values[i]; i++); + /* If the environment variable was set, but wasn't found in the values list - default value will be the first entry in the values list. If it was found, choicenum is set to i+1 because the ith value in the values array corresponds to the (i+1)th value in the choices array.*/ + if(values[i] == NULL) + choicenum = 1; + else + choicenum = i + 1; + } + + sprintf(prompt, "Current print classification is '%s.'\nSet print classification to:", choices[choicenum]); + if(message_MultipleChoiceQuestion(self, 99, prompt, 0, &answer, choices, NULL) == -1) return; + + if(answer > 0) /* Chose a new classification */ { + environ_Put(PRINTCLASSIFICATION_ENV, values[answer-1]); + sprintf(prompt, "Print classification set to %.64s.", choices[answer]); + } + else + strcpy(prompt, "Print classification unchanged."); + + message_DisplayString(self, 0, prompt); + + } + #endif + static int + typescript_SetPrinterCmd(self) + struct typescript *self; + { struct msghandler *messageLine = (struct msghandler *) typescript_WantHandler(self, "message"); char *currentPrinter, *defaultPrinter, answer[256], prompt[sizeof("Current printer is . Set printer to []: ") + 128]; ! if(messageLine == NULL) return; currentPrinter = environ_Get("PRINTER"); defaultPrinter = environ_GetProfile("print.spooldir"); ! if(currentPrinter && defaultPrinter) sprintf(prompt, "Current printer is %.64s. Set printer to [%.64s]: ", currentPrinter, defaultPrinter); ! else if(defaultPrinter) sprintf(prompt, "Set printer to [%.64s]: ", defaultPrinter); else strcpy(prompt, "Set printer to: "); ! if(msghandler_AskForString(messageLine, 0, prompt, NULL, answer, sizeof(answer)) == -1) return; ! if(*answer != '\0') { environ_Put("PRINTER", answer); defaultPrinter = answer; } ! else ! environ_Delete("PRINTER"); ! if(defaultPrinter) { sprintf(prompt, "Printer set to %.64s.", defaultPrinter); msghandler_DisplayString(messageLine, 0, prompt); } *************** *** 224,307 **** msghandler_DisplayString(messageLine, 0, "Printer not set."); } ! static typescriptAddSearchMenu () { struct proctable_Entry *tempProc; - if((tempProc = proctable_Lookup("textview-search")) != NULL){ - menulist_AddToML(typescriptMenus,"Search~20,Forward~10",tempProc,NULL,0); - } ! if((tempProc = proctable_Lookup("textview-reverse-search")) != NULL){ ! menulist_AddToML(typescriptMenus,"Search~20,Backward~11",tempProc,NULL,0); ! } } ! static typescriptAddFileMenu () { struct proctable_Entry *tempProc; struct classinfo *classInfo = &typescript_classinfo; tempProc=proctable_DefineProc("typescript-Save-As", typescript_SaveAs, classInfo, NULL, "Prompt for file name to save"); ! menulist_AddToML(typescriptMenus,"File~30,Save As~10",tempProc,NULL,0); tempProc=proctable_DefineProc("typescript-Print", typescript_PrintCmd, classInfo, NULL, "Print typescript"); ! menulist_AddToML(typescriptMenus,"File~30,Print~21",tempProc,NULL,0); tempProc=proctable_DefineProc("typescript-Preview", typescript_PreviewCmd, classInfo, NULL, "Preview typescript"); ! menulist_AddToML(typescriptMenus,"File~30,Preview~22",tempProc,NULL,0); ! tempProc=proctable_DefineProc("typescript-SetPrinter", typescript_SetPrinterCmd, classInfo, NULL, "Set Printer"); ! menulist_AddToML(typescriptMenus,"File~30,Set Printer~20",tempProc,NULL,0); } ! static AnounceDeath(self) struct typescript *self; { char buf[512]; char *shell = environ_Get("SHELL"); ! if(shell == NULL) shell = "/bin/csh"; ! if(ISPIPESCRIPT(self)){ sprintf(buf, "EOF on pipe"); ! message_DisplayString(self, 15,buf); } else if(strcmp(self->progname,shell) == 0) { sprintf(buf,"This process died. Start new typescript to continue work."); ! message_DisplayString(self, 100,buf); } else { sprintf(buf,"The %s process died.",self->progname); ! message_DisplayString(self, 100,buf); } } ! static struct environment *GetCommandEnv(self,pos,start,end) register struct typescript *self; register long pos; long *start, *end; { ! register struct environment *te; ! te = MyEnvinfo(TEXT(self), pos); ! if (te->data.style != staticBoldStyle && pos > 0){ ! /* cursor may be at end of environment */ ! te = MyEnvinfo(TEXT(self), pos - 1); ! } ! if (te->data.style != staticBoldStyle){ ! return NULL; ! } ! /* here we are in the command's bold region */ ! *start = environment_Eval(te); ! *end = *start + te->header.nestedmark.length; ! return te; } ! static void typescript_RuboutCmd (self) ! register struct typescript *self; { ! if ((self->readOnlyLen != -1)){ #ifdef SENDRAW ! write (self->SubChannel, "\010" , 1); #else ! if(self->readOnlyLen > 0) self->readOnlyLen--; #endif } else if(typescript_GetDotPosition(self) + typescript_GetDotLength(self) > text_GetFence(TEXT(self))) --- 280,375 ---- msghandler_DisplayString(messageLine, 0, "Printer not set."); } ! static int ! typescriptAddSearchMenu() { struct proctable_Entry *tempProc; ! if(tempProc = proctable_Lookup("textview-search")) ! menulist_AddToML(typescriptMenus, "Search~20,Forward~10", tempProc, NULL, 0); ! ! if(tempProc = proctable_Lookup("textview-reverse-search")) ! menulist_AddToML(typescriptMenus, "Search~20,Backward~11", tempProc, NULL, 0); } ! static int ! typescriptAddFileMenu() { struct proctable_Entry *tempProc; struct classinfo *classInfo = &typescript_classinfo; tempProc=proctable_DefineProc("typescript-Save-As", typescript_SaveAs, classInfo, NULL, "Prompt for file name to save"); ! menulist_AddToML(typescriptMenus, "File~30,Save As~10", tempProc, NULL, 0); tempProc=proctable_DefineProc("typescript-Print", typescript_PrintCmd, classInfo, NULL, "Print typescript"); ! menulist_AddToML(typescriptMenus, "File~30,Print~21", tempProc, NULL, 0); tempProc=proctable_DefineProc("typescript-Preview", typescript_PreviewCmd, classInfo, NULL, "Preview typescript"); ! menulist_AddToML(typescriptMenus, "File~30,Preview~22", tempProc, NULL, 0); ! ! tempProc = proctable_DefineProc("typescript-SetPrinter", typescript_SetPrinterCmd, classInfo, NULL, "Set Printer"); ! menulist_AddToML(typescriptMenus, "File~30,Set Printer~20", tempProc, NULL, 0); ! #ifdef PRINTCLASSIFICATION_ENV ! tempProc = proctable_DefineProc("typescript-SetPrtClassif", typescript_SetPrtClassification, classInfo, NULL, "Set Print Classification"); ! menulist_AddToML(typescriptMenus, "File~30,Set Print Classification~22", tempProc, NULL, 0); ! #endif } ! static int ! AnounceDeath(self) struct typescript *self; { char buf[512]; char *shell = environ_Get("SHELL"); ! if(shell == NULL) ! shell = "/bin/csh"; ! if(ISPIPESCRIPT(self)) { sprintf(buf, "EOF on pipe"); ! message_DisplayString(self, 15, buf); } else if(strcmp(self->progname,shell) == 0) { sprintf(buf,"This process died. Start new typescript to continue work."); ! message_DisplayString(self, 100, buf); } else { sprintf(buf,"The %s process died.",self->progname); ! message_DisplayString(self, 100, buf); } } ! ! static struct environment * ! GetCommandEnv(self, pos, start, end) register struct typescript *self; register long pos; long *start, *end; { ! register struct environment *te; ! te = MyEnvinfo(TEXT(self), pos); ! if((te->data.style != staticBoldStyle) && (pos > 0)) { ! /* cursor may be at end of environment */ ! te = MyEnvinfo(TEXT(self), pos - 1); ! } ! if(te->data.style != staticBoldStyle) ! return NULL; ! /* here we are in the command's bold region */ ! *start = environment_Eval(te); ! *end = *start + te->header.nestedmark.length; ! return te; } ! ! static void ! typescript_RuboutCmd(self) ! register struct typescript *self; { ! if(self->readOnlyLen != -1) { #ifdef SENDRAW ! write(self->SubChannel, "\010" , 1); #else ! if(self->readOnlyLen > 0) ! self->readOnlyLen--; #endif } else if(typescript_GetDotPosition(self) + typescript_GetDotLength(self) > text_GetFence(TEXT(self))) *************** *** 308,314 **** textview_RuboutCmd((struct textview *)self); } ! struct typescript *typescript__Create(classID, arglist,diskf,filemenu) struct classheader *classID; char **arglist; FILE *diskf; --- 376,383 ---- textview_RuboutCmd((struct textview *)self); } ! struct typescript * ! typescript__Create(classID, arglist, diskf, filemenu) struct classheader *classID; char **arglist; FILE *diskf; *************** *** 317,332 **** struct typescript *self; struct typetext *tt; if(arglist == NULL) Pipescript = TRUE; ! else if( *arglist) myarglist = arglist; df = diskf; FileMenu = filemenu; tt = typetext_New(); self = typescript_New(); ! typescript_SetDataObject(self,(struct dataobject *)tt); return(self); } ! struct typescript *typescript__CreatePipescript(classID, indiskf, outdiskf, filemenu) struct classheader *classID; FILE *indiskf; FILE *outdiskf; --- 386,402 ---- struct typescript *self; struct typetext *tt; if(arglist == NULL) Pipescript = TRUE; ! else if(*arglist) myarglist = arglist; df = diskf; FileMenu = filemenu; tt = typetext_New(); self = typescript_New(); ! typescript_SetDataObject(self, (struct dataobject *)tt); return(self); } ! struct typescript * ! typescript__CreatePipescript(classID, indiskf, outdiskf, filemenu) struct classheader *classID; FILE *indiskf; FILE *outdiskf; *************** *** 336,349 **** self = typescript_Create(NULL, indiskf, filemenu); odf = outdiskf; - return self; } static void ! MaintainLastEnv (td) ! struct typescript *td; { ! long len, spos; struct text *mydoc; struct environment *te; --- 406,418 ---- self = typescript_Create(NULL, indiskf, filemenu); odf = outdiskf; return self; } static void ! MaintainLastEnv(td) ! struct typescript *td; ! { long len, spos; struct text *mydoc; struct environment *te; *************** *** 351,376 **** mydoc = TEXT(td); spos = mark_GetPos(td->cmdStart); len = text_GetLength(mydoc); ! if (spos < len) { te = MyEnvinfo(mydoc, spos); ! if (te->data.style != staticBoldStyle){ te = environment_InsertStyle(mydoc->rootEnvironment, spos, staticBoldStyle, TRUE); ! } ! environment_SetStyle(te, FALSE , FALSE); environment_SetLength(te, len - spos); } } static void TypescriptLeftCommand(tsv) ! register struct typescript *tsv; { register long pos; long start,end; pos = typescript_GetDotPosition(tsv); ! if( typescript_GetDotLength(tsv)== 0) { ! if(mark_GetPos(tsv->cmdStart) == pos) return; ! if(GetCommandEnv(tsv,pos,&start,&end)!= NULL){ ! if(start == pos) return; typescript_SetDotPosition(tsv, start); typescript_WantUpdate(tsv, tsv); return; --- 420,474 ---- mydoc = TEXT(td); spos = mark_GetPos(td->cmdStart); len = text_GetLength(mydoc); ! if(spos < len) { te = MyEnvinfo(mydoc, spos); ! if(te->data.style != staticBoldStyle) te = environment_InsertStyle(mydoc->rootEnvironment, spos, staticBoldStyle, TRUE); ! environment_SetStyle(te, FALSE, FALSE); environment_SetLength(te, len - spos); } } + + void + SaveCommand(td) + struct typescript *td; + { + long len, spos; + struct text *mydoc; + char *textBuf; + long retLen; + + mydoc = TEXT(td); + spos = mark_GetPos(td->cmdStart); + len = text_GetLength(mydoc); + if(spos < len) { + while(spos < len) { + textBuf = text_GetBuf(mydoc, spos, len - spos, &retLen); + if(textBuf) { + text_InsertCharacters(td->cmdText, text_GetLength(td->cmdText), textBuf, retLen); + spos += retLen; + } + else break; + } + text_InsertCharacters(td->cmdText, text_GetLength(td->cmdText), "\n", 1); + } + } + static void TypescriptLeftCommand(tsv) ! register struct typescript *tsv; ! { register long pos; long start,end; + pos = typescript_GetDotPosition(tsv); ! if(typescript_GetDotLength(tsv)== 0) { ! if(mark_GetPos(tsv->cmdStart) == pos) ! return; ! if(GetCommandEnv(tsv,pos,&start,&end) != NULL) { ! if(start == pos) ! return; typescript_SetDotPosition(tsv, start); typescript_WantUpdate(tsv, tsv); return; *************** *** 378,469 **** } textview_BeginningOfLineCmd((struct textview *)tsv); } static void TypescriptEndOfLineCommand(tsv) ! register struct typescript *tsv; { register long pos; long start,end; pos = typescript_GetDotPosition(tsv); ! if( typescript_GetDotLength(tsv) == 0 && GetCommandEnv(tsv,pos,&start,&end)!= NULL){ ! if(end== pos) return; typescript_SetDotPosition(tsv, end); ! typescript_WantUpdate(tsv, tsv); ! } else textview_EndOfLineCmd((struct textview *)tsv); } static void ! TypescriptEOTCommand (tv) ! struct typescript *tv; { ! static struct timeval t = { 0, 0}; ! int wfds = 1<SubChannel; ! if(tv->SubChannel < 0 ) return; select(32, 0, &wfds, 0, &t); ! if (!wfds) { ! message_DisplayString(tv, 0,"Process not ready for input"); return; } ! if (typescript_GetDotPosition(tv) >= text_GetLength(TEXT(tv)) ){ ! write (tv->SubChannel, "", 0); } ! else{ textview_DeleteCmd(tv); - } } static void ! TypescriptINTCommand (tv) ! register struct typescript *tv; { ! SendSig (tv, SIGINT); } static void TypescriptSTOPCommand (tv) ! register struct typescript *tv; { #if SY_AIX221 /* %%%%%% must changed if AIX supports the STOP signal */ ! SendSig (tv, 0); #else /* if SY_AIX221 */ ! SendSig (tv, SIGTSTP); #endif /* if SY_AIX221 */ } static void - TypescriptEXITCommand (tv) - register struct typescript *tv; { - SendSig (tv, SIGKILL); - exit(0); - } - - static void TypescriptQUITCommand (tv) ! register struct typescript *tv; { ! SendSig (tv, SIGQUIT); } ! static int ! SendSig (tv, sig) register struct typescript *tv; { int pgrp = 0; ! if(tv->SubChannel < 0 ) return 0; #if SY_AIX221 pgrp = tv->pgrpid; /* get saved process group */ #else ! ioctl (tv->SubChannel, TIOCGPGRP, &pgrp); #endif ! if (pgrp == 0){ ! message_DisplayString(tv, 0, "Can't send signal to subprocess"); ! } ! else killpg (pgrp, sig); } ! static void TypescriptUnboundCommand(tv) register struct typescript *tv; { } ! static void smashReadOnlyBuf(tv) register struct typescript *tv; { /* Clear out the buf when no longer needed since it probably contains a password */ register char *c; register int i = READONLYMAX; for(c = tv->readOnlyBuf; i > 0; i-- ) *c++ = 'X'; } --- 476,615 ---- } textview_BeginningOfLineCmd((struct textview *)tsv); } + static void TypescriptEndOfLineCommand(tsv) ! register struct typescript *tsv; ! { register long pos; long start,end; + pos = typescript_GetDotPosition(tsv); ! if(typescript_GetDotLength(tsv) == 0 && GetCommandEnv(tsv, pos, &start, &end) != NULL) { ! if(end == pos) ! return; typescript_SetDotPosition(tsv, end); ! typescript_WantUpdate(tsv, tsv); ! } else textview_EndOfLineCmd((struct textview *)tsv); } + static void ! TypescriptEOTCommand(tv) ! struct typescript *tv; ! { ! static struct timeval t = { 0, 0 }; ! int wfds = 1 << tv->SubChannel; ! ! if(tv->SubChannel < 0) ! return; select(32, 0, &wfds, 0, &t); ! if(!wfds) { ! message_DisplayString(tv, 0, "Process not ready for input"); return; } ! if(typescript_GetDotPosition(tv) >= text_GetLength(TEXT(tv))) { ! #ifdef POSIX_ENV ! /* POSIX pty is in cooked mode. Give it an EOF char. */ ! { ! struct termios tios; ! tcgetattr(tv->SubChannel, &tios); ! WritePty(tv, &tios.c_cc[VEOF], 1); ! } ! #else /* POSIX_ENV */ ! WritePty(tv, "", 0); ! #endif /* POSIX_ENV */ } ! else textview_DeleteCmd(tv); } static void ! TypescriptINTCommand(tv) ! register struct typescript *tv; ! { ! SendSig(tv, SIGINT); } + static void TypescriptSTOPCommand (tv) ! register struct typescript *tv; ! { #if SY_AIX221 /* %%%%%% must changed if AIX supports the STOP signal */ ! SendSig(tv, 0); #else /* if SY_AIX221 */ ! SendSig(tv, SIGTSTP); #endif /* if SY_AIX221 */ } static void TypescriptQUITCommand (tv) ! register struct typescript *tv; ! { ! SendSig(tv, SIGQUIT); } ! static void ! SendSig (tv, sig) ! register struct typescript *tv; ! { ! #ifdef POSIX_ENV ! /* The POSIX pty is in cooked mode, so query the ! * pty for signal chars, then write that signal ! * char to the pty. The pty will deliver the ! * signal. ! */ ! struct termios tios; ! char intchar; ! ! /* Get interrupt chars each time in case the user mucks with them. */ ! tcgetattr(tv->SubChannel, &tios); ! switch(sig) { ! case SIGINT: ! intchar = tios.c_cc[VINTR]; ! break; ! case SIGQUIT: ! intchar = tios.c_cc[VQUIT]; ! break; ! case SIGTSTP: ! intchar = tios.c_cc[VSUSP]; ! break; ! default: ! return; ! } ! WritePty(tv, &intchar, 1); ! return; ! #else /* POSIX_ENV */ int pgrp = 0; ! if(tv->SubChannel < 0) ! return; #if SY_AIX221 pgrp = tv->pgrpid; /* get saved process group */ #else ! ioctl(tv->SubChannel, TIOCGPGRP, &pgrp); #endif ! if(pgrp == 0) ! message_DisplayString(tv, 0, "Can't send signal to subprocess"); ! else ! killpg(pgrp, sig); ! return; ! #endif /* POSIX_ENV */ } ! static void ! TypescriptUnboundCommand(tv) register struct typescript *tv; { } ! static void ! smashReadOnlyBuf(tv) register struct typescript *tv; { /* Clear out the buf when no longer needed since it probably contains a password */ register char *c; register int i = READONLYMAX; + for(c = tv->readOnlyBuf; i > 0; i-- ) *c++ = 'X'; } *************** *** 475,512 **** register long endpos; { register struct text *d; ! int maxpos, vfp, wfds; ! register stpos, len; static struct timeval t = { 0, 0}; if(tv->SubChannel < 0) { AnounceDeath(tv); return; } MaintainLastEnv(tv); wfds = 1 << tv->SubChannel; d = TEXT(tv); maxpos = text_GetLength(d); select(32, 0, &wfds, 0, &t); ! if (!wfds || tv->OutputWait) { ! if (!tv->OutputWait) { /* add an output handler */ ! im_AddCanOutHandler(tv->SCFile, (procedure) MyCanOutHandler, (char *) tv, 6); tv->OutputWait = 1; } /* force newline addition to end of input during typeahead, as it is forced in the normal case */ ! text_InsertCharacters (d, maxpos, "\n", 1); ! mark_SetPos(tv->cmdStart,maxpos + 1); ! typescript_SetDotPosition(tv,maxpos + 1); ! return; } /* compute end of stuff to send */ ! if (maxpos > (vfp=mark_GetPos(tv->cmdStart))) { stpos = vfp; len = maxpos - stpos; ! if (len < 0) len = 0; } else { --- 621,661 ---- register long endpos; { register struct text *d; ! int maxpos, vfp, wfds; ! register stpos, len; static struct timeval t = { 0, 0}; + if(tv->SubChannel < 0) { AnounceDeath(tv); return; } MaintainLastEnv(tv); + SaveCommand(tv); + tv->lastCmdPos = text_GetLength(tv->cmdText); + wfds = 1 << tv->SubChannel; d = TEXT(tv); maxpos = text_GetLength(d); select(32, 0, &wfds, 0, &t); ! if(!wfds || tv->OutputWait) { ! if(!tv->OutputWait) { /* add an output handler */ ! im_AddCanOutHandler(tv->SCFile, (procedure) MyCanOutHandler, (char*) tv, 6); tv->OutputWait = 1; } /* force newline addition to end of input during typeahead, as it is forced in the normal case */ ! text_InsertCharacters(d, maxpos, "\n", 1); ! mark_SetPos(tv->cmdStart, maxpos + 1); ! typescript_SetDotPosition(tv, maxpos + 1); return; } /* compute end of stuff to send */ ! if(maxpos > (vfp = mark_GetPos(tv->cmdStart))) { stpos = vfp; len = maxpos - stpos; ! if(len < 0) len = 0; } else { *************** *** 516,547 **** SetCmdSize(len + 1); #ifdef SENDRAW ! if (tv->readOnlyLen == 0) { write(tv->SubChannel,"\n",1); - } #else ! if (tv->readOnlyLen > 0) { ! if (len > 0){ text_CopySubString(d, stpos, len , cmd, FALSE); ! write (tv->SubChannel, cmd, len); } tv->readOnlyBuf[tv->readOnlyLen] = '\n'; ! write(tv->SubChannel, tv->readOnlyBuf, tv->readOnlyLen + 1); text_InsertCharacters (d, stpos + len++, "\n", 1); smashReadOnlyBuf(tv); } #endif else { ! text_InsertCharacters (d, stpos + len++, "\n", 1); text_CopySubString(d, stpos, len, cmd, FALSE); if(len < 100) ! write (tv->SubChannel, cmd , len); else { int tl; char *cc; ! for(cc = cmd,tl = len;tl >= 100; cc += 100, tl -= 100) ! write (tv->SubChannel, cc , 100); ! if(tl > 0) write (tv->SubChannel, cc , tl); } } tv->readOnlyLen = -1; --- 665,696 ---- SetCmdSize(len + 1); #ifdef SENDRAW ! if(tv->readOnlyLen == 0) write(tv->SubChannel,"\n",1); #else ! if(tv->readOnlyLen > 0) { ! if(len > 0) { text_CopySubString(d, stpos, len , cmd, FALSE); ! WritePty(tv, cmd, len); } tv->readOnlyBuf[tv->readOnlyLen] = '\n'; ! WritePty(tv, tv->readOnlyBuf, tv->readOnlyLen + 1); text_InsertCharacters (d, stpos + len++, "\n", 1); smashReadOnlyBuf(tv); } #endif else { ! text_InsertCharacters(d, stpos + len++, "\n", 1); text_CopySubString(d, stpos, len, cmd, FALSE); if(len < 100) ! WritePty(tv, cmd , len); else { int tl; char *cc; ! for(cc = cmd,tl = len; tl >= 100; cc += 100, tl -= 100) ! WritePty(tv, cc , 100); ! if(tl > 0) ! WritePty(tv, cc , tl); } } tv->readOnlyLen = -1; *************** *** 548,604 **** stpos += len; if(endpos < 0) typescript_SetDotPosition(tv, stpos); ! else typescript_SetDotPosition(tv, endpos); typescript_SetDotLength(tv, 0); ! tv->lastEnv = NULL; mark_SetPos(tv->cmdStart, stpos); mark_SetLength(tv->cmdStart, 0); text_SetFence(d, stpos); typescript_FrameDot(tv, stpos); text_NotifyObservers(d , 0); ! if (text_GetLength(d) > maxSize) ! typetext_AlwaysDeleteCharacters ((struct typetext *) d, 0, text_GetLength(d) - maxSize + extraRoom); } static void TypescriptReturnCommand (tv) ! register struct typescript *tv; { ! TypescriptDoReturnCommand (tv,-1); } ! static void TypescriptReturnAndPositionCommand(self, data) ! struct typescript *self; ! long data; { ! TypescriptDoReturnCommand(self,text_GetFence(TEXT(self))); ! textview_LineToTop((struct textview *)self,data); } ! static ! typescript_HandleMenus(self,data) struct typescript *self; long data; { ! char *s = (char *) data; ! while(*s){ ! if(*s == '\n' || *s == '\r') ! TypescriptReturnCommand(self); ! else Typescript_SelfInsertCmd(self,*s); ! s++; ! } } static void ! TypescriptZapCommand (tv) ! register struct typescript *tv; { register struct text *d; ! int maxpos; ! register stpos; #ifdef SENDRAW ! if (tv->readOnlyLen == 0) { write(tv->SubChannel,"\025",1); return; } #else ! if (tv->readOnlyLen != -1) { tv->readOnlyLen = 0; return; } --- 697,761 ---- stpos += len; if(endpos < 0) typescript_SetDotPosition(tv, stpos); ! else ! typescript_SetDotPosition(tv, endpos); typescript_SetDotLength(tv, 0); ! tv->lastCmdPos = text_GetLength(tv->cmdText); mark_SetPos(tv->cmdStart, stpos); mark_SetLength(tv->cmdStart, 0); text_SetFence(d, stpos); typescript_FrameDot(tv, stpos); text_NotifyObservers(d , 0); ! if(text_GetLength(d) > maxSize) ! typetext_AlwaysDeleteCharacters((struct typetext*) d, 0, text_GetLength(d) - maxSize + extraRoom); } + static void TypescriptReturnCommand (tv) ! register struct typescript *tv; ! { ! TypescriptDoReturnCommand(tv, -1); } ! ! static void ! TypescriptReturnAndPositionCommand(self, data) ! struct typescript *self; ! long data; { ! TypescriptDoReturnCommand(self, text_GetFence(TEXT(self))); ! textview_LineToTop((struct textview*)self, data); } ! static int ! typescript_HandleMenus(self, data) struct typescript *self; long data; { ! char *s = (char*) data; ! ! while(*s) { ! if((*s == '\n') || (*s == '\r')) ! TypescriptReturnCommand(self); ! else ! Typescript_SelfInsertCmd(self, *s); ! s++; ! } } + static void ! TypescriptZapCommand(tv) ! register struct typescript *tv; { register struct text *d; ! int maxpos; ! register stpos; #ifdef SENDRAW ! if(tv->readOnlyLen == 0) { write(tv->SubChannel,"\025",1); return; } #else ! if(tv->readOnlyLen != -1) { tv->readOnlyLen = 0; return; } *************** *** 606,630 **** d = TEXT(tv); maxpos = text_GetLength(d); stpos = mark_GetPos(tv->cmdStart); ! if (maxpos > stpos) { ! text_DeleteCharacters(d, stpos, maxpos-stpos); typescript_SetDotPosition(tv, stpos); typescript_SetDotLength(tv, 0); ! tv->lastEnv = NULL; } text_NotifyObservers(d , 0); } static void ! GrabCommandHere (tv, where) long where; ! register struct typescript *tv; { register int i; long start, size,len; struct environment *te; i = where; ! if (i<0) i=0; te = MyEnvinfo(TEXT(tv), i); ! if (te->data.style != staticBoldStyle) return; /* here we are in the command's bold region */ start = environment_Eval(te); size = te->header.nestedmark.length; --- 763,791 ---- d = TEXT(tv); maxpos = text_GetLength(d); stpos = mark_GetPos(tv->cmdStart); ! if(maxpos > stpos) { ! text_DeleteCharacters(d, stpos, maxpos - stpos); typescript_SetDotPosition(tv, stpos); typescript_SetDotLength(tv, 0); ! tv->lastCmdPos = text_GetLength(tv->cmdText); } text_NotifyObservers(d , 0); } + static void ! GrabCommandHere(tv, where) long where; ! register struct typescript *tv; ! { register int i; long start, size,len; struct environment *te; + i = where; ! if(i <0 ) i = 0; te = MyEnvinfo(TEXT(tv), i); ! if(te->data.style != staticBoldStyle) ! return; /* here we are in the command's bold region */ start = environment_Eval(te); size = te->header.nestedmark.length; *************** *** 634,640 **** text_CopySubString(TEXT(tv), start, size , cmd, FALSE); if((len = typescript_GetDotLength(tv)) > 0) /* deletecharacters will check the fence for us */ ! text_DeleteCharacters(TEXT(tv),typescript_GetDotPosition(tv),len); start = text_GetLength(TEXT(tv)); text_InsertCharacters(TEXT(tv), start, cmd, size); typescript_SetDotPosition(tv, start); --- 795,801 ---- text_CopySubString(TEXT(tv), start, size , cmd, FALSE); if((len = typescript_GetDotLength(tv)) > 0) /* deletecharacters will check the fence for us */ ! text_DeleteCharacters(TEXT(tv), typescript_GetDotPosition(tv), len); start = text_GetLength(TEXT(tv)); text_InsertCharacters(TEXT(tv), start, cmd, size); typescript_SetDotPosition(tv, start); *************** *** 642,725 **** typescript_FrameDot(tv, start); text_NotifyObservers(TEXT(tv), 0); } static void GrabLastCommand (tv) ! register struct typescript *tv; { ! register int i; ! struct environment *te; ! struct text *sstxt = TEXT(tv); ! i = mark_GetPos(tv->cmdStart); ! /* i starts off somewhere to the right of the last command's bold region */ ! for (;;) { ! te = environment_GetPreviousChild(sstxt->rootEnvironment, tv->lastEnv, i); ! if (te != NULL) { ! tv->lastEnv = te; ! if (te->header.nestedmark.length != 0) { ! i = environment_Eval(te); ! GrabCommandHere(tv, i); ! return; ! } ! } ! else ! return; ! } } static void GrabNextCommand (tv) ! register struct typescript *tv; { ! register long i; ! struct environment *te; ! struct text *sstxt = TEXT(tv); ! i = mark_GetPos(tv->cmdStart); ! /* i starts off somewhere to the left of the last command's bold region */ ! for (;;) { ! te = environment_GetNextChild(sstxt->rootEnvironment, tv->lastEnv, i); ! if (te != NULL ) { ! i = environment_Eval(te); ! if (i < mark_GetPos(tv->cmdStart)) { ! tv->lastEnv = te; ! if (te->header.nestedmark.length != 0) { ! GrabCommandHere(tv, i); ! return; ! } ! } ! else ! return; ! } ! else ! return; ! } } static void GrabCurrentCommand(tv) ! struct typescript *tv; { register int i; register struct text *d; struct environment *te; ! int dlen; register long lineBegin, lineEnd; d = TEXT(tv); dlen = text_GetLength(d); ! if ((i=typescript_GetDotLength(tv)) == 0) { ! for(i = typescript_GetDotPosition(tv); i < dlen; i++) { ! if (text_GetChar(d, i) == '\n') break; ! } ! lineEnd = i; ! i = typescript_GetDotPosition(tv); ! if (text_GetChar(d, i) == '\n') i--; /* don't look at this end of line */ ! for(;i>=0;i--) { ! if (text_GetChar(d, i)=='\n') break; ! } ! lineBegin = i+1; ! for (i=lineBegin;idata.style == staticBoldStyle) { ! GrabCommandHere(tv, i); return; } } } --- 803,887 ---- typescript_FrameDot(tv, start); text_NotifyObservers(TEXT(tv), 0); } + + static int + GrabCommand(tv, fromText, start, end) + register struct typescript *tv; + struct text *fromText; + long start; + long end; + { + long size, len, pos; + + size = end - start; + /* now copy the bits out */ + SetCmdSize(size); + text_CopySubString(fromText, start, size, cmd, FALSE); + if((len = typescript_GetDotLength(tv)) > 0) { + /* deletecharacters will check the fence for us */ + text_DeleteCharacters(TEXT(tv),typescript_GetDotPosition(tv),len); + } + pos = text_GetLength(TEXT(tv)); + text_InsertCharacters(TEXT(tv), pos, cmd, size); + typescript_SetDotPosition(tv, pos); + typescript_SetDotLength(tv, size); + typescript_FrameDot(tv, pos); + text_NotifyObservers(TEXT(tv), 0); + } + static void GrabLastCommand (tv) ! register struct typescript *tv; ! { ! long cmdEnd; ! if(tv->lastCmdPos == 0) ! return; ! cmdEnd = tv->lastCmdPos - 1; ! tv->lastCmdPos = text_GetBeginningOfLine(tv->cmdText, cmdEnd); ! GrabCommand(tv, tv->cmdText, tv->lastCmdPos, cmdEnd); } static void GrabNextCommand (tv) ! register struct typescript *tv; ! { ! long cmdEnd; ! ! if(tv->lastCmdPos >= text_GetLength(tv->cmdText)) ! return; ! tv->lastCmdPos = text_GetEndOfLine(tv->cmdText, tv->lastCmdPos) + 1; ! cmdEnd = text_GetEndOfLine(tv->cmdText, tv->lastCmdPos); ! if(tv->lastCmdPos != cmdEnd) ! GrabCommand(tv, tv->cmdText, tv->lastCmdPos, cmdEnd); } static void GrabCurrentCommand(tv) ! struct typescript *tv; ! { register int i; register struct text *d; struct environment *te; ! int dlen; register long lineBegin, lineEnd; d = TEXT(tv); dlen = text_GetLength(d); ! if((i = typescript_GetDotLength(tv)) == 0) { ! lineEnd = text_GetEndOfLine(d, typescript_GetDotPosition(tv)); ! lineBegin = text_GetBeginningOfLine(d, lineEnd); ! for(i = lineBegin; i < lineEnd; i++) { te = MyEnvinfo(d, i); ! if(te->data.style == staticBoldStyle) { ! long start, size; ! ! /* here we are in the command's bold region */ ! start = environment_Eval(te); ! size = te->header.nestedmark.length; ! GrabCommand(tv, d, start, start + size); ! return; } } } *************** *** 726,737 **** else { /* i still has the length */ lineBegin = typescript_GetDotPosition(tv); ! lineEnd = lineBegin+i; } /* now send from lineBegin to lineEnd inclusive */ SetCmdSize(lineEnd - lineBegin); ! text_CopySubString(d, lineBegin,lineEnd - lineBegin , cmd, FALSE); ! text_InsertCharacters(d, dlen, cmd, i = lineEnd-lineBegin); typescript_SetDotPosition(tv, dlen); typescript_SetDotLength(tv, i); typescript_FrameDot(tv, dlen); --- 888,899 ---- else { /* i still has the length */ lineBegin = typescript_GetDotPosition(tv); ! lineEnd = lineBegin + i; } /* now send from lineBegin to lineEnd inclusive */ SetCmdSize(lineEnd - lineBegin); ! text_CopySubString(d, lineBegin, lineEnd - lineBegin , cmd, FALSE); ! text_InsertCharacters(d, dlen, cmd, i = lineEnd - lineBegin); typescript_SetDotPosition(tv, dlen); typescript_SetDotLength(tv, i); typescript_FrameDot(tv, dlen); *************** *** 742,760 **** static void ExecuteCurrentCommand(tv) ! struct typescript *tv; { if(typescript_GetDotPosition(tv) < text_GetFence(TEXT(tv))) GrabCurrentCommand(tv); TypescriptReturnCommand (tv); } ! static void SetTitle(self,titleLine) ! struct typescript *self; char *titleLine; { #define WMTITLELEN 40 /* Can you say "Magic hack?" */ ! char titleBuffer[1000],*index(); int len, maxLen = WMTITLELEN - 1; char *tb; --- 904,925 ---- static void ExecuteCurrentCommand(tv) ! struct typescript *tv; ! { if(typescript_GetDotPosition(tv) < text_GetFence(TEXT(tv))) GrabCurrentCommand(tv); TypescriptReturnCommand (tv); } ! ! static void ! SetTitle(self, titleLine) ! struct typescript *self; char *titleLine; { #define WMTITLELEN 40 /* Can you say "Magic hack?" */ ! char titleBuffer[1000], *index(); int len, maxLen = WMTITLELEN - 1; char *tb; *************** *** 761,769 **** *titleBuffer = '\0'; tb = titleBuffer; ! if (self->title != NULL) { len = strlen(self->title); ! if (len < WMTITLELEN - 3) { strcpy(titleBuffer, self->title); strcat(titleBuffer, ": "); maxLen -= (len + 2); --- 926,934 ---- *titleBuffer = '\0'; tb = titleBuffer; ! if(self->title) { len = strlen(self->title); ! if(len < WMTITLELEN - 3) { strcpy(titleBuffer, self->title); strcat(titleBuffer, ": "); maxLen -= (len + 2); *************** *** 775,798 **** } } ! if (titleLine!= NULL){ ! char *home=environ_Get("HOME"); ! if(home!=NULL){ ! int hlen=strlen(home); ! if(strncmp(titleLine,home,hlen)==0){ strcpy(tb,"~"); --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... */ --- 940,963 ---- } } ! if(titleLine) { ! char *home = environ_Get("HOME"); ! if(home) { ! int hlen = strlen(home); ! if(strncmp(titleLine,home,hlen) == 0) { strcpy(tb,"~"); --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... */ *************** *** 802,854 **** else strcat(tb, titleLine); } ! im_SetTitle(typescript_GetIM(self), titleBuffer); } #define StartMagicChar 1 /* Ctrl A */ #define EndMagicChar 2 /* Ctrl B */ ! static char * ReadDirName(self,f,buf,bufsiz) struct typescript *self; FILE *f; char *buf; int *bufsiz; { ! register char *cp; ! register c; ! register int i = *bufsiz; ! for(cp = buf;--i && f->_cnt>0; cp++){ ! if((c = getc(f))== EOF) { ! im_RemoveFileHandler(f); ! self->SubChannel = -1; ! AnounceDeath(self); ! break; ! } ! if((*cp = c) == '\n'){ ! cp++; ! break; ! } ! if(*cp == EndMagicChar){ ! *cp = '\0'; ! if(im_ChangeDirectory(buf) == 0){ ! SetTitle(self,buf); ! } ! return(NULL); ! } } ! *bufsiz = i; ! return(cp); } static void ! ReadFromProcess (f, td) ! FILE *f; ! register struct typescript *td; { - char buf[4000]; register char *bp = buf; register long dotpos, vfp; ! register c = getc(f), i = 3999; int reframe = 0; char *input; int cpos; --- 967,1019 ---- else strcat(tb, titleLine); } ! im_SetTitle(typescript_GetIM(self), titleBuffer); } #define StartMagicChar 1 /* Ctrl A */ #define EndMagicChar 2 /* Ctrl B */ ! ! static char * ! ReadDirName(self, f, buf, bufsiz) struct typescript *self; FILE *f; char *buf; int *bufsiz; { ! register char *cp; ! register c; ! register int i = *bufsiz; ! for(cp = buf; --i && f->_cnt > 0; cp++) { ! if((c = getc(f)) == EOF) { ! im_RemoveFileHandler(f); ! self->SubChannel = -1; ! AnounceDeath(self); ! break; ! } ! if((*cp = c) == '\n') { ! cp++; ! break; ! } ! if(*cp == EndMagicChar) { ! *cp = '\0'; ! if(im_ChangeDirectory(buf) == 0) ! SetTitle(self,buf); ! return(NULL); } ! } ! *bufsiz = i; ! return(cp); } static void ! ReadFromProcess(f, td) ! FILE *f; ! register struct typescript *td; { char buf[4000]; register char *bp = buf; register long dotpos, vfp; ! register c = getc(f), i = 3999; int reframe = 0; char *input; int cpos; *************** *** 856,938 **** mark_IncludeBeginning(td->cmdStart) = FALSE; dotpos = typescript_GetDotPosition(td); ! if (td->lastPosition == -1) td->lastPosition = dotpos; ! ! if (c!=EOF) { ! if (odf != NULL) putc(c, odf); ! ! if(c == StartMagicChar && !td->pipescript){ cpos = i; ! if((input = ReadDirName(td,f,bp,&cpos)) != NULL){ bp = input; i = cpos; } } ! else if(c != '\015') *bp++ = c; ! while (--i && f->_cnt>0) { ! if((c = getc(f)) == EOF) { break; ! } ! if (odf != NULL) { putc(c, odf); - } *bp = c; ! if(*bp == StartMagicChar && !td->pipescript){ cpos = i; ! if ((input = ReadDirName(td,f,bp,&cpos)) != NULL){ bp = input; i = cpos; ! if(i == 0) break; /* we could lose some output this way, but only if someone is cat-ing a binary or something else bogus. Even then , I doubt the reads will be this big. */ } } ! else if(*bp != '\015') bp++; } ! if(bp != buf){ vfp = text_GetFence(d); ! if(vfp <= dotpos){ dotpos += bp - buf; reframe++; } ! text_InsertCharacters (d, vfp, buf, bp-buf); ! text_SetFence(d, vfp = vfp+(bp-buf)); ! if (mark_GetPos(td->cmdStart) < vfp) { mark_SetPos(td->cmdStart, vfp); mark_SetLength(td->cmdStart, 0); } ! if (reframe){ typescript_SetDotPosition(td,dotpos); ! /* typescript_FrameDot(td,dotpos); ! */ } text_NotifyObservers(d, 0); } ! #ifndef OLD_ULTRIX_ENV /* this prevents vax from inserting chars in doc ! */ ! if (td->readOnlyLen == -1) { #if SY_AIX221 struct termio ThisTerm; ! ioctl (fileno(f), TCGETA, &ThisTerm); ! if ( ! (ThisTerm.c_lflag & ECHO)) { ! td->readOnlyLen = 0; ! } #else /* #if SY_AIX221 */ struct sgttyb sgttyb; ! ioctl (fileno(f), TIOCGETP, &sgttyb); ! if ( ! (sgttyb.sg_flags & ECHO)) { ! td->readOnlyLen = 0; ! } #endif /* #if SY_AIX221 */ } ! #endif /* OLD_ULTRIX_ENV */ } ! if(c == EOF){ ! if (odf != NULL) ! fclose(odf); im_RemoveFileHandler(f); td->SubChannel = -1; AnounceDeath(td); --- 1021,1115 ---- mark_IncludeBeginning(td->cmdStart) = FALSE; dotpos = typescript_GetDotPosition(td); ! if(td->lastPosition == -1) td->lastPosition = dotpos; ! if(c != EOF) { ! if(odf) putc(c, odf); ! if(c == StartMagicChar && !td->pipescript) { cpos = i; ! if(input = ReadDirName(td, f, bp, &cpos)) { bp = input; i = cpos; } } ! else if(c != '\015') ! *bp++ = c; ! while(--i && f->_cnt > 0) { ! if((c = getc(f)) == EOF) break; ! if(odf) putc(c, odf); *bp = c; ! if(*bp == StartMagicChar && !td->pipescript) { cpos = i; ! if(input = ReadDirName(td, f, bp, &cpos)) { bp = input; i = cpos; ! if(i == 0) ! break; /* we could lose some output this way, but only if someone is cat-ing a binary or something else bogus. Even then , I doubt the reads will be this big. */ } } ! else if(*bp != '\015') ! bp++; } ! if(bp != buf) { vfp = text_GetFence(d); ! if(vfp <= dotpos) { dotpos += bp - buf; reframe++; } ! text_InsertCharacters (d, vfp, buf, bp - buf); ! text_SetFence(d, vfp = vfp + (bp - buf)); ! if(mark_GetPos(td->cmdStart) < vfp) { mark_SetPos(td->cmdStart, vfp); mark_SetLength(td->cmdStart, 0); } ! if(reframe) { typescript_SetDotPosition(td,dotpos); ! /* typescript_FrameDot(td,dotpos); */ ! } text_NotifyObservers(d, 0); } ! #ifdef POSIX_ENV ! { ! struct termios tios; ! ! tcgetattr(td->SlaveChannel, &tios); ! if(tios.c_lflag & ECHO) ! td->readOnlyLen = -1; /* echo should be on */ ! else if(td->readOnlyLen == -1) ! td->readOnlyLen = 0; /* no echo just started */ ! } ! #else /* POSIX_ENV */ ! #if (!vax | vax2) && (!defined(M_UNIX)) /* everything but vax_11 */ /* this prevents vax from inserting chars in doc ! */ ! { #if SY_AIX221 struct termio ThisTerm; ! ioctl(fileno(f), TCGETA, &ThisTerm); ! if(ThisTerm.c_lflag & ECHO) ! td->readOnlyLen = -1; /* echo should be on */ ! else if(td->readOnlyLen == -1) ! td->readOnlyLen = 0; /* noecho mode just started... */ #else /* #if SY_AIX221 */ struct sgttyb sgttyb; ! ioctl(fileno(f), TIOCGETP, &sgttyb); ! if(sgttyb.sg_flags & ECHO) ! td->readOnlyLen = -1; /* echo should be on */ ! else if(td->readOnlyLen == -1) ! td->readOnlyLen = 0; /* noecho mode just started... */ #endif /* #if SY_AIX221 */ } ! #endif /* (!vax | vax2) */ ! #endif /* POSIX_ENV */ } ! if(c == EOF) { ! if(odf) fclose(odf); im_RemoveFileHandler(f); td->SubChannel = -1; AnounceDeath(td); *************** *** 941,1006 **** } static void ! ClearTypescript (tv) ! struct typescript *tv; { ! struct text *d = TEXT(tv); ! int p; ! ! for (p = mark_GetPos(tv->cmdStart); --p >= 0;) { ! if (text_GetChar(d,p) == '\n') { ! typetext_AlwaysDeleteCharacters((struct typetext *)d, 0, p + 1); ! text_NotifyObservers(d, 0); ! return; ! } ! } } static void ! NoEchoCommand(tv) ! struct typescript *tv; { ! if (tv->readOnlyLen == -1) tv->readOnlyLen = 0; } boolean ! typescript__InitializeObject (classID, tp) struct classheader *classID; struct typescript *tp; ! { ! int pid; ! char **arglist = NULL; int pgrp = getpgrp(0); int ptyChannel; int masterChannel; ! #if SY_AIX221 || SY_AIX12 ! char ptyname[MAXPATHLEN]; ! #endif /* if SY_AIX221 */ ! #ifndef hpux /* Disassociate this process from its controling tty. Must be done after opening the childs pty because that will become the controlling tty if we don't have one. */ { int fd; ! #if !SY_AIX221 ! (void)signal(SIGTTOU,SIG_IGN); /* For handling signals when changing the window size */ ! #endif /* !SY_AIX221 */ ! fd = open ("/dev/tty", O_RDWR); ! if (fd >= 0) { ! ioctl (fd, TIOCNOTTY, 0); ! close (fd); ! } ! #if SY_AIX221 ! else { ! ioctl(0, TIOCNOTTY, 0); /* might help when /dev/tty is hosed */ ! setpgrp(); ! } ! #else ! else setpgrp(0, 0); - #endif } ! #endif /* hpux */ tp->pipescript = FALSE; --- 1118,1183 ---- } static void ! ClearTypescriptText(tv) ! struct typescript *tv; ! { ! struct text *d = TEXT(tv); ! int p; ! ! p = text_GetBeginningOfLine(d, mark_GetPos(tv->cmdStart)); ! if(p != 0) { ! typetext_AlwaysDeleteCharacters((struct typetext*)d, 0, p); ! text_NotifyObservers(d, 0); } + } + static void ! ClearTypescript(tv) ! struct typescript *tv; { + ClearTypescriptText(tv); + text_Clear(tv->cmdText); + tv->lastCmdPos = 0; + } ! static void ! NoEchoCommand(tv) ! struct typescript *tv; ! { ! if(tv->readOnlyLen == -1) tv->readOnlyLen = 0; } boolean ! typescript__InitializeObject(classID, tp) struct classheader *classID; struct typescript *tp; ! { ! int pid; ! char **arglist = NULL; int pgrp = getpgrp(0); int ptyChannel; int masterChannel; ! char ptyname[64]; ! ! #if !(defined(POSIX_ENV) || defined(hpux)) /* Disassociate this process from its controling tty. Must be done after opening the childs pty because that will become the controlling tty if we don't have one. */ { int fd; ! #ifdef SIGTTOU ! (void)signal(SIGTTOU, SIG_IGN); /* For handling signals when changing the window size */ ! #endif ! fd = open("/dev/tty", O_RDWR); ! if(fd >= 0) { ! ioctl(fd, TIOCNOTTY, 0); ! close(fd); ! } ! else setpgrp(0, 0); } ! #endif tp->pipescript = FALSE; *************** *** 1008,1019 **** tp->pipescript = TRUE; Pipescript = FALSE; } ! else if(myarglist != NULL) { arglist = myarglist; myarglist = NULL; } ! else { ! char *shell = environ_Get("SHELL"); DefaultArgList[0] = (shell != NULL) ? shell : "/bin/csh"; --- 1185,1195 ---- tp->pipescript = TRUE; Pipescript = FALSE; } ! else if(myarglist) { arglist = myarglist; myarglist = NULL; } ! else { char *shell = environ_Get("SHELL"); DefaultArgList[0] = (shell != NULL) ? shell : "/bin/csh"; *************** *** 1024,1033 **** typescript_SetBorder(tp, 5, 5); tp->readOnlyLen = -1; tp->lastPosition = -1; - #if SY_AIX221 tp->pgrpid = 0; ! #endif ! if(tp->pipescript){ tp->SCFile = df; tp->SubChannel = -1; typescriptAddSearchMenu (); --- 1200,1209 ---- typescript_SetBorder(tp, 5, 5); tp->readOnlyLen = -1; tp->lastPosition = -1; tp->pgrpid = 0; ! tp->ptyname = NULL; ! ! if(tp->pipescript) { tp->SCFile = df; tp->SubChannel = -1; typescriptAddSearchMenu (); *************** *** 1038,1057 **** return TRUE; } ! tp->progname = malloc (strlen(*arglist) + 1); ! strcpy(tp->progname,*arglist); ! #if SY_AIX221 || SY_AIX12 ! if (! GetPtyandName(&masterChannel, &ptyChannel,ptyname,MAXPATHLEN)) { ! #else /*if SY_AIX221 */ ! if (! GetPty(&masterChannel, &ptyChannel)) { ! #endif /*if SY_AIX221 */ ! printf ("Can't connect subchannel\n"); return FALSE; } tp->SubChannel = masterChannel; ! ! #if SY_AIX221 || SY_AIX12 { int mode; --- 1214,1237 ---- return TRUE; } ! tp->progname = malloc(strlen(*arglist) + 1); ! strcpy(tp->progname, *arglist); ! if(!GetPtyandName(&masterChannel, &ptyChannel, ptyname, sizeof(ptyname))) { ! printf("Can't connect subchannel\n"); return FALSE; } tp->SubChannel = masterChannel; ! tp->SlaveChannel = ptyChannel; ! tp->ptyname = malloc(strlen(ptyname) + 1); ! if(tp->ptyname) ! strcpy(tp->ptyname, ptyname); ! ! #ifndef POSIX_ENV ! /* On a POSIX system we do not put the pty into REMOTE mode. ! * Instead we leave the pty in cooked mode. ! */ ! #if SY_AIX221 { int mode; *************** *** 1077,1114 **** with the ioctl.h from either 4.2 or 4.3. What can you do? Note that the ON flag is passed by reference in 4.3, by value in 4.2 */ #if defined(__STDC__) && !defined(__HIGHC__) || defined(_IBMR2) || defined(hpux) ! if (ioctl (tp->SubChannel, _IOW('t', TIOCREMOTE&0xff, int), &ON) == -1) ! ioctl (tp->SubChannel, _IO('t', TIOCREMOTE&0xff), ON); #else /* defined(__STDC__) && !defined(__HIGHC__) */ ! if (ioctl (tp->SubChannel, _IOW(t, TIOCREMOTE&0xff, int), &ON) == -1) ioctl (tp->SubChannel, _IO(t, TIOCREMOTE&0xff), ON); #endif /* defined(__STDC__) && !defined(__HIGHC__) */ ! ! ioctl (tp->SubChannel, FIOCLEX, 0); } ! #endif /* #if SY_AIX221 || SY_AIX12 */ ! if ((pid = osi_vfork ()) < 0) { ! printf ("Fork failed\n"); return FALSE; } ! if (pid == 0) { ! int pid = getpid (); #ifdef hpux setpgrp2(0, pid); #else /* hpux */ ! #if SY_AIX221 || SY_AIX12 setpgrp(); /* reopen the terminal so it becomes the controlling terminal */ ! if ((ptyChannel = open(ptyname, 2)) < 0) { fprintf(stderr, "Could not open %s.\n", ptyname); exit(1); } #else /* if !SY_AIX221 */ ! setpgrp (0, pid); #endif /* if SY_AIX221 */ #endif /* hpux */ dup2(ptyChannel, 0); dup2(ptyChannel, 1); dup2(ptyChannel, 2); --- 1257,1309 ---- with the ioctl.h from either 4.2 or 4.3. What can you do? Note that the ON flag is passed by reference in 4.3, by value in 4.2 */ #if defined(__STDC__) && !defined(__HIGHC__) || defined(_IBMR2) || defined(hpux) ! if(ioctl(tp->SubChannel, _IOW('t', TIOCREMOTE&0xff, int), &ON) == -1) ! ioctl(tp->SubChannel, _IO('t', TIOCREMOTE&0xff), ON); #else /* defined(__STDC__) && !defined(__HIGHC__) */ ! if(ioctl (tp->SubChannel, _IOW(t, TIOCREMOTE&0xff, int), &ON) == -1) ioctl (tp->SubChannel, _IO(t, TIOCREMOTE&0xff), ON); #endif /* defined(__STDC__) && !defined(__HIGHC__) */ ! ioctl(tp->SubChannel, FIOCLEX, 0); } ! #endif /* #if SY_AIX221 */ ! #endif /* !POSIX_ENV */ ! if((pid = osi_vfork ()) < 0) { ! printf("Fork failed\n"); return FALSE; } ! if(pid == 0) { ! int pid = getpid (); ! #ifdef POSIX_ENV ! /* Become a session leader. */ ! if(setsid() < 0) ! perror("setsid"); ! /* Re-open the pty so that it becomes the controlling terminal. ! * NOTE: GetPtyandName must open the pty with the O_NOCTTY flag, ! * otherwise the parent (typescript) process will have the controlling ! * terminal and we (the shell) won't be able to get it. ! */ ! if((ptyChannel = open(ptyname, O_RDWR)) < 0) { ! fprintf(stderr, "Could not open %s.\n", ptyname); ! exit(1); ! } ! #else #ifdef hpux setpgrp2(0, pid); #else /* hpux */ ! #if SY_AIX221 setpgrp(); /* reopen the terminal so it becomes the controlling terminal */ ! if((ptyChannel = open(ptyname, 2)) < 0) { fprintf(stderr, "Could not open %s.\n", ptyname); exit(1); } #else /* if !SY_AIX221 */ ! setpgrp(0, pid); #endif /* if SY_AIX221 */ #endif /* hpux */ + #endif /* !POSIX_ENV */ dup2(ptyChannel, 0); dup2(ptyChannel, 1); dup2(ptyChannel, 2); *************** *** 1115,1206 **** /* Don't leave any unnecessary open file descriptors for child. */ { ! #ifndef hpux extern int getdtablesize(); #endif /* hpux */ int numfds = getdtablesize(); int fd; ! for (fd = 3; fd < numfds; fd++) close(fd); } ! #if !SY_AIX221 ! ioctl (0, TIOCSPGRP, &pid); #endif /* if SY_AIX221 */ environ_Put("TERM", "wm"); environ_Delete("TERMCAP"); #if SY_AIX221 { struct termio ThisTerm; ! ioctl (fileno(stdin), TCGETA, &ThisTerm); ThisTerm.c_iflag &= ~ICRNL; ThisTerm.c_oflag &= ~OPOST; /* turn all this stuff off */ ThisTerm.c_lflag |= ECHO; ThisTerm.c_cflag |= ISIG; /* enable signals */ ThisTerm.c_cflag &= ~ICANON; /* turn off the editing */ ! ioctl (fileno(stdin), TCSETAW, &ThisTerm); } #else /* #if SY_AIX221 */ { /* kernel doesn't reset pty's */ struct sgttyb sgttyb; ! ioctl (0, TIOCGETP, &sgttyb); sgttyb.sg_flags &= ~CRMOD; ! #ifndef OLD_ULTRIX_ENV /* causes echoing on the vax; needed on RT and sun so the test in ReadFromProcess will work */ sgttyb.sg_flags |= ECHO; ! #endif /* OLD_ULTRIX_ENV */ /* Run in raw mode to fix select problems. */ sgttyb.sg_flags |= RAW; ioctl (0, TIOCSETP, &sgttyb); } #endif /* #if SY_AIX221 */ ! execvp (tp->progname, arglist); ! { char buf[200]; sprintf(buf, "Couldn't exec %s\n", tp->progname); ! write (1, buf, strlen(buf)); ! _exit (1); } } #if SY_AIX221 tp->pgrpid = pid; /* save pid for sending quit and intr signals */ ! #else #ifdef hpux setpgrp2(0, pgrp); #else /* hpux */ - #if !SY_AIX12 setpgrp(0, pgrp); - #endif /* !SY_AIX12 */ #endif /* hpux */ ! #endif /* #if !SY_AIX221 */ tp->SCFile = fdopen(tp->SubChannel, "r"); #if SY_AIX12 setvbuf(tp->SCFile, io_buffer, _IOLBF, sizeof(io_buffer)); - myfile = tp->SCFile; #endif ! if(df){ struct proctable_Entry *UserMenuProc; char nbuf[512]; ! UserMenuProc = proctable_DefineProc("Read-User-Menus", typescript_HandleMenus, &typescript_classinfo, NULL, "Handle user supplied menus"); ! while (fgets (nbuf, sizeof nbuf, df)) { ! register pos = strlen(nbuf)-1; ! if (pos > 0) { ! if (nbuf[pos-1] == '\\') ! nbuf[pos-1] = '\0'; ! else ! nbuf[pos] = '\r'; ! typescriptAddMenu (nbuf,UserMenuProc); ! } } ! fclose (df); df = NULL; } typescriptAddtypescriptMenus(); typescriptAddSearchMenu (); ! if(FileMenu){ typescriptAddFileMenu(); FileMenu = FALSE; } --- 1310,1440 ---- /* Don't leave any unnecessary open file descriptors for child. */ { ! #if !defined(hpux) && !defined(M_UNIX) extern int getdtablesize(); #endif /* hpux */ int numfds = getdtablesize(); int fd; ! for(fd = 3; fd < numfds; fd++) close(fd); } ! ! #ifdef POSIX_ENV ! /* Set current terminal process group. */ ! if(tcsetpgrp(0, pid) < 0) ! perror("tcsetpgrp failed"); ! #else #if !SY_AIX221 ! ioctl(0, TIOCSPGRP, &pid); #endif /* if SY_AIX221 */ + #endif /* POSIX_ENV */ environ_Put("TERM", "wm"); environ_Delete("TERMCAP"); + #ifdef POSIX_ENV + /* Reset pty with Posix termios ioctl's */ + /* The pty runs in cooked mode. Set everything to a known state + * se we can send signals, etc. + */ + { + struct termios tios; + + tcgetattr(0, &tios); + tios.c_iflag = ICRNL; + #ifdef ONLCR + tios.c_oflag = ONLCR; + #else + tios.c_oflag = 0; + #endif + tios.c_cflag = B9600|CS8|HUPCL|CREAD; + tios.c_lflag = ISIG|ICANON|ECHO; + tios.c_cc[VINTR] = '\003'; /* ^C */ + tios.c_cc[VQUIT] = '\034'; /* ^\ */ + tios.c_cc[VERASE] = '\010'; /* ^h */ + tios.c_cc[VKILL] = '\025'; /* ^u */ + tios.c_cc[VEOF] = '\004'; /* ^d */ + tios.c_cc[VSTART] = '\021'; /* ^q */ + tios.c_cc[VSTOP] = '\023'; /* ^s */ + tios.c_cc[VSUSP] = '\032'; /* ^z */ + + if(tcsetattr(0, TCSANOW, &tios) < 0) + perror("typescript: failed to set terminal characteristics"); + } + #else #if SY_AIX221 { struct termio ThisTerm; ! ioctl(fileno(stdin), TCGETA, &ThisTerm); ThisTerm.c_iflag &= ~ICRNL; ThisTerm.c_oflag &= ~OPOST; /* turn all this stuff off */ ThisTerm.c_lflag |= ECHO; ThisTerm.c_cflag |= ISIG; /* enable signals */ ThisTerm.c_cflag &= ~ICANON; /* turn off the editing */ ! ioctl(fileno(stdin), TCSETAW, &ThisTerm); } #else /* #if SY_AIX221 */ { /* kernel doesn't reset pty's */ struct sgttyb sgttyb; ! ioctl(0, TIOCGETP, &sgttyb); sgttyb.sg_flags &= ~CRMOD; ! #if (!vax | vax2) /* everything but vax_11 */ /* causes echoing on the vax; needed on RT and sun so the test in ReadFromProcess will work */ sgttyb.sg_flags |= ECHO; ! #endif /* (!vax | vax2) */ /* Run in raw mode to fix select problems. */ sgttyb.sg_flags |= RAW; ioctl (0, TIOCSETP, &sgttyb); } #endif /* #if SY_AIX221 */ ! #endif /* POSIX_ENV */ ! execvp(tp->progname, arglist); ! { ! char buf[200]; ! sprintf(buf, "Couldn't exec %s\n", tp->progname); ! write(1, buf, strlen(buf)); ! _exit(1); } } + #ifndef POSIX_ENV #if SY_AIX221 tp->pgrpid = pid; /* save pid for sending quit and intr signals */ ! #else /* SY_AIX221 */ #ifdef hpux setpgrp2(0, pgrp); #else /* hpux */ setpgrp(0, pgrp); #endif /* hpux */ ! #endif /* SY_AIX221 */ ! #endif /* !POSIX_ENV */ tp->SCFile = fdopen(tp->SubChannel, "r"); #if SY_AIX12 setvbuf(tp->SCFile, io_buffer, _IOLBF, sizeof(io_buffer)); #endif ! if(df) { struct proctable_Entry *UserMenuProc; char nbuf[512]; ! ! UserMenuProc = proctable_DefineProc("Read-User-Menus", typescript_HandleMenus, &typescript_classinfo, NULL, "Handle user supplied menus"); ! while(fgets(nbuf, sizeof nbuf, df)) { ! register pos = strlen(nbuf) - 1; ! if(pos > 0) { ! if(nbuf[pos-1] == '\\') ! nbuf[pos-1] = '\0'; ! else ! nbuf[pos] = '\r'; ! typescriptAddMenu(nbuf, UserMenuProc); } ! } ! fclose(df); df = NULL; } typescriptAddtypescriptMenus(); typescriptAddSearchMenu (); ! if(FileMenu) { typescriptAddFileMenu(); FileMenu = FALSE; } *************** *** 1207,1212 **** --- 1441,1451 ---- tp->menulist = menulist_DuplicateML(typescriptMenus, tp); tp->keystate = keystate_Create(tp, ssmap); tp->title = NULL; + tp->cmdText = text_New(); + tp->lastCmdPos = 0; + #ifdef UTMP_MUNGE + utmp_add(ptyname, pid); + #endif return TRUE; } *************** *** 1214,1234 **** /* Called when can send to pty. Removes handler when no more data remains to be sent. */ ! static void MyCanOutHandler(afile, ad) ! FILE *afile; ! struct typescript *ad; { long start; register struct text *myd; register long i, end; register char *tp, tc; char buffer[COBSIZE]; ! if(ad->SubChannel < 0 ) return; myd = TEXT(ad); start = text_GetFence(myd); end = text_GetLength(myd); ! if (start >= end) { ! if (ad->readOnlyLen > 0) { ! write(ad->SubChannel, ad->readOnlyBuf, ad->readOnlyLen); smashReadOnlyBuf(ad); ad->readOnlyLen = -1; } --- 1453,1477 ---- /* Called when can send to pty. Removes handler when no more data remains to be sent. */ ! static void ! MyCanOutHandler(afile, ad) ! FILE *afile; ! struct typescript *ad; ! { long start; register struct text *myd; register long i, end; register char *tp, tc; char buffer[COBSIZE]; ! ! if(ad->SubChannel < 0) ! return; myd = TEXT(ad); start = text_GetFence(myd); end = text_GetLength(myd); ! if(start >= end) { ! if(ad->readOnlyLen > 0) { ! WritePty(ad, ad->readOnlyBuf, ad->readOnlyLen); smashReadOnlyBuf(ad); ad->readOnlyLen = -1; } *************** *** 1237,1307 **** return; } tp = buffer; ! for(i=start; i= start+COBSIZE-2) break; } text_SetFence(myd, i); ! write(ad->SubChannel, buffer, tp-buffer); } void typescript__FinalizeObject(classID, ap) struct classheader *classID; ! struct typescript *ap; { /* dataobject_Destroy(TEXTOBJ(ap)); */ /* the doc will destroy it's own marks */ ! if (ap->title != NULL) { free(ap->title); } } ! void typescript__ObservedChanged(ap,ov, value) register struct typescript *ap; struct observable *ov; ! long value; { register long fencepos; /* after output has arrived, make sure view's dot is >= fence */ ! if (ov == (struct observable *) TEXT(ap)) { ! if (value == observable_OBJECTDESTROYED) /* the typescript can't do much without it's text */ typescript_Destroy(ap); ! else{ ! MaintainLastEnv(ap); ! fencepos = text_GetFence(TEXT(ap)); ! if ((fencepos <= typescript_GetDotPosition(ap)) && typescript_Visible(ap, ap->lastPosition) ) { ! typescript_FrameDot(ap, fencepos); ! } ! typescript_WantUpdate(ap, ap); } } } ! void typescript__PostMenus(self, menulist) ! struct typescript *self; ! struct menulist *menulist; { ! /* Ignore the textviews menus, ! but take advantage of the fact that it knows when to ! post (and retract) the selection menus */ ! if (self->header.textview.hasInputFocus) { ! long mask; ! boolean readonly = typescript_GetDotPosition(self) < text_GetFence(TEXT(self)); ! mask = ((typescript_GetDotLength(self) > 0) ? typescript_SelectionMenus : typescript_NoSelectionMenus) | ! (readonly ? 0 : typescript_AfterFenceMenus); ! ! if (menulist_SetMask(self->menulist, mask)) { ! super_PostMenus(self, self->menulist); ! } } } ! void typescript__ReceiveInputFocus(me) ! register struct typescript *me; { super_ReceiveInputFocus(me); me->keystate->next = NULL; me->header.textview.keystate->next = NULL; --- 1480,1563 ---- return; } tp = buffer; ! for(i = start; i < end;) { tc = *tp++ = text_GetChar(myd, i); i++; /* text_GetChar may become macro, so don't do this inside */ ! if(tc == '\n') ! break; ! if(i >= start + COBSIZE - 2) ! break; } text_SetFence(myd, i); ! WritePty(ad, buffer, tp-buffer); } void typescript__FinalizeObject(classID, ap) struct classheader *classID; ! struct typescript *ap; ! { /* dataobject_Destroy(TEXTOBJ(ap)); */ /* the doc will destroy it's own marks */ ! if(ap->title) free(ap->title); + if(ap->cmdText) + text_Destroy(ap->cmdText); + if(ap->ptyname) { + #ifdef UTMP_MUNGE + utmp_delete(ap->ptyname); + #endif + free(ap->ptyname); } } ! void ! typescript__ObservedChanged(ap, ov, value) register struct typescript *ap; struct observable *ov; ! long value; ! { register long fencepos; /* after output has arrived, make sure view's dot is >= fence */ ! if(ov == (struct observable*) TEXT(ap)) { ! if(value == observable_OBJECTDESTROYED) /* the typescript can't do much without it's text */ typescript_Destroy(ap); ! else { ! MaintainLastEnv(ap); ! fencepos = text_GetFence(TEXT(ap)); ! if((fencepos <= typescript_GetDotPosition(ap)) && typescript_Visible(ap, ap->lastPosition)) { ! typescript_FrameDot(ap, fencepos); ! } ! typescript_WantUpdate(ap, ap); } } } ! void ! typescript__PostMenus(self, menulist) ! struct typescript *self; ! struct menulist *menulist; { ! /* Ignore the textviews menus, ! but take advantage of the fact that it knows when to ! post (and retract) the selection menus */ ! if(self->header.textview.hasInputFocus) { ! long mask; ! boolean readonly = typescript_GetDotPosition(self) < text_GetFence(TEXT(self)); ! mask = ((typescript_GetDotLength(self) > 0) ? typescript_SelectionMenus : typescript_NoSelectionMenus) | ! (readonly ? 0 : typescript_AfterFenceMenus); ! if(menulist_SetMask(self->menulist, mask)) ! super_PostMenus(self, self->menulist); } } ! void ! typescript__ReceiveInputFocus(me) ! register struct typescript *me; ! { super_ReceiveInputFocus(me); me->keystate->next = NULL; me->header.textview.keystate->next = NULL; *************** *** 1309,1314 **** --- 1565,1571 ---- typescript_PostKeyState(me , me->keystate); menulist_SetMask(me->menulist, textview_NoMenus); } + static void typescript_handlereadonly(self ,c) register struct typescript *self; *************** *** 1318,1331 **** #ifdef SENDRAW write(self->SubChannel,&c,1); #else ! if (isprint(c)) { ! if (self->readOnlyLen < (READONLYMAX - 1)) { /* Make sure to leave space for ending carriage return. */ self->readOnlyBuf[self->readOnlyLen++] = c; } } #endif } ! static PositionDot(self) register struct typescript *self; { register long dotpos,markpos; --- 1575,1590 ---- #ifdef SENDRAW write(self->SubChannel,&c,1); #else ! if(isprint(c)) { ! if(self->readOnlyLen < (READONLYMAX - 1)) { /* Make sure to leave space for ending carriage return. */ self->readOnlyBuf[self->readOnlyLen++] = c; } } #endif } ! ! static int ! PositionDot(self) register struct typescript *self; { register long dotpos,markpos; *************** *** 1333,1339 **** if((dotpos = typescript_GetDotPosition(self)) < (markpos = text_GetFence(d))){ while(dotpos < markpos) { ! if (text_GetChar(d,dotpos) == '\n'){ textview_EndOfTextCmd(self); return; } --- 1592,1598 ---- if((dotpos = typescript_GetDotPosition(self)) < (markpos = text_GetFence(d))){ while(dotpos < markpos) { ! if(text_GetChar(d,dotpos) == '\n') { textview_EndOfTextCmd(self); return; } *************** *** 1341,1388 **** } typescript_SetDotPosition(self,dotpos); } ! if(dotpos == markpos){ /* modify environment style so environment doesn't get fragmented */ struct environment *te = MyEnvinfo(TEXT(self), dotpos); ! if (te->data.style == staticBoldStyle) environment_SetStyle(te, TRUE , FALSE); } } static void ! typescript_YankCmd (self) register struct typescript *self; { PositionDot(self); textview_YankCmd(self); } ! static void Typescript_SelfInsertCmd(self, a) ! register struct typescript *self; ! register char a; { PositionDot(self); ! ! if ((self->readOnlyLen != -1)){ ! typescript_handlereadonly(self,a); ! } ! else { textview_SelfInsertCmd(self, a); - } } ! static void Typescript_DigitCmd(self, a) ! register struct typescript *self; ! char a; { PositionDot(self); ! ! if ((self->readOnlyLen != -1)){ ! typescript_handlereadonly(self,a); ! } ! else { ! textview_DigitCmd(self, a); ! } } ! static typescript_BackwardsRotatePasteCmd(self) struct typescript *self; { --- 1600,1646 ---- } typescript_SetDotPosition(self,dotpos); } ! if(dotpos == markpos) { /* modify environment style so environment doesn't get fragmented */ struct environment *te = MyEnvinfo(TEXT(self), dotpos); ! if(te->data.style == staticBoldStyle) environment_SetStyle(te, TRUE , FALSE); } } + static void ! typescript_YankCmd(self) register struct typescript *self; { PositionDot(self); textview_YankCmd(self); } ! ! static void ! Typescript_SelfInsertCmd(self, a) ! register struct typescript *self; ! register char a; { PositionDot(self); ! if(self->readOnlyLen != -1) ! typescript_handlereadonly(self, a); ! else textview_SelfInsertCmd(self, a); } ! ! static void ! Typescript_DigitCmd(self, a) ! register struct typescript *self; ! char a; { PositionDot(self); ! if(self->readOnlyLen != -1) ! typescript_handlereadonly(self, a); ! else ! textview_DigitCmd(self, a); } ! static int typescript_BackwardsRotatePasteCmd(self) struct typescript *self; { *************** *** 1390,1398 **** return; textview_BackwardsRotatePasteCmd(self); } ! static typescript_RotatePasteCmd(self) ! struct typescript *self; { if(typescript_GetDotPosition(self) < text_GetFence(TEXT(self))) return; --- 1648,1657 ---- return; textview_BackwardsRotatePasteCmd(self); } ! ! static int typescript_RotatePasteCmd(self) ! struct typescript *self; { if(typescript_GetDotPosition(self) < text_GetFence(TEXT(self))) return; *************** *** 1400,1414 **** } /* What to do when the textview hasn't defined something... */ ! int typescript_NoTextviewKey(self, key) ! struct typescript *self; ! long key; { message_DisplayString(self, 0, "Could not execute command. Failure in looking up textview command."); return 0; } ! static typescriptAddtypescriptMenus() { struct proctable_Entry *tempProc; struct classinfo *classInfo = &typescript_classinfo; --- 1659,1675 ---- } /* What to do when the textview hasn't defined something... */ ! int ! typescript_NoTextviewKey(self, key) ! struct typescript *self; ! long key; { message_DisplayString(self, 0, "Could not execute command. Failure in looking up textview command."); return 0; } ! static int ! typescriptAddtypescriptMenus() { struct proctable_Entry *tempProc; struct classinfo *classInfo = &typescript_classinfo; *************** *** 1415,1428 **** tempProc = proctable_DefineProc("typescript-yank", (procedure) typescript_YankCmd, classInfo, NULL, "Yank text back from kill-buffer."); keymap_BindToKey(ssmap, "\031", tempProc, 0); - menulist_AddToML(typescriptMenus,"Paste~11",tempProc,NULL,typescript_AfterFenceMenus | typescript_NoSelectionMenus); ! tempProc=proctable_DefineProc("typescript-rotate-backward-paste", (procedure) typescript_BackwardsRotatePasteCmd, classInfo, NULL, "Rotate kill-buffer backwards."); keymap_BindToKey(ssmap, "\033\031", tempProc, 0); tempProc = proctable_DefineProc("typescript-rotate-paste", (procedure) typescript_RotatePasteCmd, classInfo, NULL, "Rotate kill-buffer."); keymap_BindToKey(ssmap, "\033y", tempProc, 0); ! tempProc=proctable_DefineProc("typescript-Grab-Last-Cmd", (procedure) GrabLastCommand, classInfo, NULL, "Grab Last Command"); keymap_BindToKey(ssmap, "\033=", tempProc, 0); tempProc = proctable_DefineProc("typescript-Grab-Current-Cmd", (procedure) GrabCurrentCommand, classInfo, NULL, "Grab Current Command"); --- 1676,1691 ---- tempProc = proctable_DefineProc("typescript-yank", (procedure) typescript_YankCmd, classInfo, NULL, "Yank text back from kill-buffer."); keymap_BindToKey(ssmap, "\031", tempProc, 0); ! menulist_AddToML(typescriptMenus,"Paste~11",tempProc,NULL, typescript_AfterFenceMenus | typescript_NoSelectionMenus); ! ! tempProc = proctable_DefineProc("typescript-rotate-backward-paste", (procedure) typescript_BackwardsRotatePasteCmd, classInfo, NULL, "Rotate kill-buffer backwards."); keymap_BindToKey(ssmap, "\033\031", tempProc, 0); tempProc = proctable_DefineProc("typescript-rotate-paste", (procedure) typescript_RotatePasteCmd, classInfo, NULL, "Rotate kill-buffer."); keymap_BindToKey(ssmap, "\033y", tempProc, 0); ! ! tempProc = proctable_DefineProc("typescript-Grab-Last-Cmd", (procedure) GrabLastCommand, classInfo, NULL, "Grab Last Command"); keymap_BindToKey(ssmap, "\033=", tempProc, 0); tempProc = proctable_DefineProc("typescript-Grab-Current-Cmd", (procedure) GrabCurrentCommand, classInfo, NULL, "Grab Current Command"); *************** *** 1433,1444 **** keymap_BindToKey(ssmap, "\033\015", tempProc, 0); menulist_AddToML(typescriptMenus,"Execute~31",tempProc,NULL,0); ! tempProc=proctable_DefineProc("typescript-Grab-Next-Cmd", (procedure) GrabNextCommand, classInfo, NULL, "Grab Next Command"); keymap_BindToKey(ssmap, "\033`", tempProc, 0); } ! boolean typescript__InitializeClass(classID) ! struct classheader *classID; { struct proctable_Entry *tempProc, *si, *dig; struct classinfo *classInfo = &typescript_classinfo; --- 1696,1708 ---- keymap_BindToKey(ssmap, "\033\015", tempProc, 0); menulist_AddToML(typescriptMenus,"Execute~31",tempProc,NULL,0); ! tempProc = proctable_DefineProc("typescript-Grab-Next-Cmd", (procedure) GrabNextCommand, classInfo, NULL, "Grab Next Command"); keymap_BindToKey(ssmap, "\033`", tempProc, 0); } ! boolean ! typescript__InitializeClass(classID) ! struct classheader *classID; { struct proctable_Entry *tempProc, *si, *dig; struct classinfo *classInfo = &typescript_classinfo; *************** *** 1448,1460 **** extraRoom = maxSize / 10; CmdSize = 256; ! cmd = (char *)malloc(CmdSize); ssmap = keymap_New(); typescriptMenus = menulist_New(); /* Initialize our pointers to textview command routines. */ class_Load("textview"); /* Make sure the textview is loaded first. */ ! if ((tempProc = proctable_Lookup("textview-line-to-top")) != NULL) { proctable_ForceLoaded(tempProc); textview_LineToTop = proctable_GetFunction(tempProc); } --- 1712,1724 ---- extraRoom = maxSize / 10; CmdSize = 256; ! cmd = (char*) malloc(CmdSize); ssmap = keymap_New(); typescriptMenus = menulist_New(); /* Initialize our pointers to textview command routines. */ class_Load("textview"); /* Make sure the textview is loaded first. */ ! if(tempProc = proctable_Lookup("textview-line-to-top")) { proctable_ForceLoaded(tempProc); textview_LineToTop = proctable_GetFunction(tempProc); } *************** *** 1461,1574 **** else textview_LineToTop = typescript_NoTextviewKey; ! if ((tempProc = proctable_Lookup("textview-end-of-text")) != NULL) { textview_EndOfTextCmd = proctable_GetFunction(tempProc); } else textview_EndOfTextCmd = typescript_NoTextviewKey; ! if ((tempProc = proctable_Lookup("textview-self-insert")) != NULL) textview_SelfInsertCmd = proctable_GetFunction(tempProc); else textview_SelfInsertCmd = typescript_NoTextviewKey; ! if ((tempProc = proctable_Lookup("textview-digit")) != NULL) textview_DigitCmd = proctable_GetFunction(tempProc); else textview_DigitCmd = typescript_NoTextviewKey; ! if ((tempProc = proctable_Lookup("textview-beginning-of-line")) != NULL) textview_BeginningOfLineCmd = proctable_GetFunction(tempProc); else textview_BeginningOfLineCmd = typescript_NoTextviewKey; ! if ((tempProc = proctable_Lookup("textview-end-of-line")) != NULL) textview_EndOfLineCmd = proctable_GetFunction(tempProc); else textview_EndOfLineCmd = typescript_NoTextviewKey; ! if ((tempProc = proctable_Lookup("textview-yank")) != NULL) textview_YankCmd = proctable_GetFunction(tempProc); else textview_YankCmd = typescript_NoTextviewKey; ! if ((tempProc = proctable_Lookup("textview-rotate-backward-paste")) != NULL) textview_BackwardsRotatePasteCmd = proctable_GetFunction(tempProc); else textview_BackwardsRotatePasteCmd = typescript_NoTextviewKey; ! if ((tempProc = proctable_Lookup("textview-rotate-paste")) != NULL) textview_RotatePasteCmd = proctable_GetFunction(tempProc); else textview_RotatePasteCmd = typescript_NoTextviewKey; ! if ((tempProc = proctable_Lookup("textview-delete-next-character")) != NULL) textview_DeleteCmd = proctable_GetFunction(tempProc); else textview_DeleteCmd = typescript_NoTextviewKey; ! if ((tempProc = proctable_Lookup("textview-copy-region")) != NULL) typescript_CopyRegionCmd = proctable_GetFunction(tempProc); else typescript_CopyRegionCmd = typescript_NoTextviewKey; ! if ((tempProc = proctable_Lookup("textview-zap-region")) != NULL) typescript_ZapRegionCmd = proctable_GetFunction(tempProc); else typescript_ZapRegionCmd = typescript_NoTextviewKey; ! ! if ((tempProc = proctable_Lookup("textview-delete-previous-character")) != NULL) textview_RuboutCmd = proctable_GetFunction(tempProc); else textview_RuboutCmd = typescript_NoTextviewKey; ! tempProc=proctable_DefineProc("typescript-interupt-command", (procedure) TypescriptINTCommand, classInfo, NULL, "Handle ^C"); keymap_BindToKey(ssmap, "\003", tempProc, 0); #if SY_AIX221 keymap_BindToKey(ssmap, "\177", tempProc, 0); /* bind DEL too! */ #endif /* #if SY_AIX221 */ ! tempProc=proctable_DefineProc("typescript-beginning-of-line", (procedure) TypescriptLeftCommand, classInfo, NULL, "Move to line beginning"); keymap_BindToKey(ssmap, "\001", tempProc, 0); ! tempProc=proctable_DefineProc("typescript-end-of-line", (procedure) TypescriptEndOfLineCommand, classInfo, NULL, "Move to line end"); keymap_BindToKey(ssmap, "\005", tempProc, 0); ! tempProc=proctable_DefineProc("typescript-EOT-command", (procedure) TypescriptEOTCommand, classInfo, NULL, "Handle ^D"); keymap_BindToKey(ssmap, "\004", tempProc, 0); ! tempProc=proctable_DefineProc("typescript-return-cmd", (procedure) TypescriptReturnCommand, classInfo, NULL, "Handle enter key"); keymap_BindToKey(ssmap, "\015", tempProc, 0); ! tempProc=proctable_DefineProc("typescript-return-and-position", (procedure) TypescriptReturnAndPositionCommand, classInfo, NULL, "Handle enter key and place command at top of the screen"); keymap_BindToKey(ssmap, "\012", tempProc, 0); ! tempProc=proctable_DefineProc("typescript-ZAP-command", (procedure) TypescriptZapCommand, classInfo, NULL, "handles ^U line clearing"); keymap_BindToKey(ssmap, "\025", tempProc, 0); ! tempProc=proctable_DefineProc("typescript-Stop-cmd", (procedure) TypescriptSTOPCommand, classInfo, NULL, "Handle ^Z Stop cmd"); keymap_BindToKey(ssmap, "\032", tempProc, 0); ! tempProc=proctable_DefineProc("typescript-unbound", (procedure) TypescriptUnboundCommand, classInfo, NULL, "Does nothing."); keymap_BindToKey(ssmap, "\033~", tempProc, 0); tempProc = proctable_DefineProc("typescript-zap-region", (procedure) typescript_ZapRegionCmd, classInfo, NULL, "Cut region to kill-buffer."); keymap_BindToKey(ssmap, "\027", tempProc, 0); ! menulist_AddToML(typescriptMenus,"Cut~11",tempProc,NULL,typescript_AfterFenceMenus | typescript_SelectionMenus); tempProc = proctable_DefineProc("typescript-copy-region", (procedure) typescript_CopyRegionCmd, classInfo, NULL, "Copy region to kill-buffer."); keymap_BindToKey(ssmap, "\033w", tempProc, 0); ! menulist_AddToML(typescriptMenus,"Copy~12",tempProc,NULL,typescript_SelectionMenus); ! tempProc=proctable_DefineProc("typescript-QUIT-command", (procedure) TypescriptQUITCommand, classInfo, NULL, "handles quit cmd"); keymap_BindToKey(ssmap, "\034", tempProc, 0); ! tempProc=proctable_DefineProc("typescript-No-Echo-Cmd", (procedure) NoEchoCommand, classInfo, NULL, "Turn Off Echoing"); keymap_BindToKey(ssmap, "\030\014", tempProc, 0); ! tempProc=proctable_DefineProc("typescript-delete-previous-character", (procedure) typescript_RuboutCmd, classInfo, NULL, "Delete the previous character."); keymap_BindToKey(ssmap, "\010", tempProc, 0); keymap_BindToKey(ssmap, "\177", tempProc, 0); ! ! si=proctable_DefineProc("Typescript-self-insert", (procedure) Typescript_SelfInsertCmd, classInfo, NULL, "Insert a character."); ! dig=proctable_DefineProc("Typescript-digit", (procedure) Typescript_DigitCmd, classInfo, NULL, "Insert a character."); str[0] = ' '; str[1] = '\0'; ! for (i = 32; i < 127; i++) { ! if (i < 48 || i > 57) keymap_BindToKey(ssmap, str, si, i); else keymap_BindToKey(ssmap, str, dig, i); --- 1725,1845 ---- else textview_LineToTop = typescript_NoTextviewKey; ! if(tempProc = proctable_Lookup("textview-end-of-text")) { textview_EndOfTextCmd = proctable_GetFunction(tempProc); } else textview_EndOfTextCmd = typescript_NoTextviewKey; ! if(tempProc = proctable_Lookup("textview-self-insert")) textview_SelfInsertCmd = proctable_GetFunction(tempProc); else textview_SelfInsertCmd = typescript_NoTextviewKey; ! if(tempProc = proctable_Lookup("textview-digit")) textview_DigitCmd = proctable_GetFunction(tempProc); else textview_DigitCmd = typescript_NoTextviewKey; ! if(tempProc = proctable_Lookup("textview-beginning-of-line")) textview_BeginningOfLineCmd = proctable_GetFunction(tempProc); else textview_BeginningOfLineCmd = typescript_NoTextviewKey; ! if(tempProc = proctable_Lookup("textview-end-of-line")) textview_EndOfLineCmd = proctable_GetFunction(tempProc); else textview_EndOfLineCmd = typescript_NoTextviewKey; ! if(tempProc = proctable_Lookup("textview-yank")) textview_YankCmd = proctable_GetFunction(tempProc); else textview_YankCmd = typescript_NoTextviewKey; ! if(tempProc = proctable_Lookup("textview-rotate-backward-paste")) textview_BackwardsRotatePasteCmd = proctable_GetFunction(tempProc); else textview_BackwardsRotatePasteCmd = typescript_NoTextviewKey; ! if(tempProc = proctable_Lookup("textview-rotate-paste")) textview_RotatePasteCmd = proctable_GetFunction(tempProc); else textview_RotatePasteCmd = typescript_NoTextviewKey; ! if(tempProc = proctable_Lookup("textview-delete-next-character")) textview_DeleteCmd = proctable_GetFunction(tempProc); else textview_DeleteCmd = typescript_NoTextviewKey; ! if(tempProc = proctable_Lookup("textview-copy-region")) typescript_CopyRegionCmd = proctable_GetFunction(tempProc); else typescript_CopyRegionCmd = typescript_NoTextviewKey; ! ! if(tempProc = proctable_Lookup("textview-zap-region")) typescript_ZapRegionCmd = proctable_GetFunction(tempProc); else typescript_ZapRegionCmd = typescript_NoTextviewKey; ! if(tempProc = proctable_Lookup("textview-delete-previous-character") ) textview_RuboutCmd = proctable_GetFunction(tempProc); else textview_RuboutCmd = typescript_NoTextviewKey; ! ! tempProc = proctable_DefineProc("typescript-interupt-command", (procedure) TypescriptINTCommand, classInfo, NULL, "Handle ^C"); keymap_BindToKey(ssmap, "\003", tempProc, 0); #if SY_AIX221 keymap_BindToKey(ssmap, "\177", tempProc, 0); /* bind DEL too! */ #endif /* #if SY_AIX221 */ ! ! tempProc = proctable_DefineProc("typescript-beginning-of-line", (procedure) TypescriptLeftCommand, classInfo, NULL, "Move to line beginning"); keymap_BindToKey(ssmap, "\001", tempProc, 0); ! tempProc = proctable_DefineProc("typescript-end-of-line", (procedure) TypescriptEndOfLineCommand, classInfo, NULL, "Move to line end"); keymap_BindToKey(ssmap, "\005", tempProc, 0); ! tempProc = proctable_DefineProc("typescript-EOT-command", (procedure) TypescriptEOTCommand, classInfo, NULL, "Handle ^D"); keymap_BindToKey(ssmap, "\004", tempProc, 0); ! ! tempProc = proctable_DefineProc("typescript-return-cmd", (procedure) TypescriptReturnCommand, classInfo, NULL, "Handle enter key"); keymap_BindToKey(ssmap, "\015", tempProc, 0); ! ! tempProc = proctable_DefineProc("typescript-return-and-position", (procedure) TypescriptReturnAndPositionCommand, classInfo, NULL, "Handle enter key and place command at top of the screen"); keymap_BindToKey(ssmap, "\012", tempProc, 0); ! ! tempProc = proctable_DefineProc("typescript-ZAP-command", (procedure) TypescriptZapCommand, classInfo, NULL, "handles ^U line clearing"); keymap_BindToKey(ssmap, "\025", tempProc, 0); ! ! tempProc = proctable_DefineProc("typescript-Stop-cmd", (procedure) TypescriptSTOPCommand, classInfo, NULL, "Handle ^Z Stop cmd"); keymap_BindToKey(ssmap, "\032", tempProc, 0); ! ! tempProc = proctable_DefineProc("typescript-unbound", (procedure) TypescriptUnboundCommand, classInfo, NULL, "Does nothing."); keymap_BindToKey(ssmap, "\033~", tempProc, 0); tempProc = proctable_DefineProc("typescript-zap-region", (procedure) typescript_ZapRegionCmd, classInfo, NULL, "Cut region to kill-buffer."); keymap_BindToKey(ssmap, "\027", tempProc, 0); ! menulist_AddToML(typescriptMenus, "Cut~11", tempProc, NULL, typescript_AfterFenceMenus | typescript_SelectionMenus); tempProc = proctable_DefineProc("typescript-copy-region", (procedure) typescript_CopyRegionCmd, classInfo, NULL, "Copy region to kill-buffer."); keymap_BindToKey(ssmap, "\033w", tempProc, 0); ! menulist_AddToML(typescriptMenus, "Copy~12", tempProc, NULL, typescript_SelectionMenus); ! tempProc = proctable_DefineProc("typescript-QUIT-command", (procedure) TypescriptQUITCommand, classInfo, NULL, "handles quit cmd"); keymap_BindToKey(ssmap, "\034", tempProc, 0); ! tempProc = proctable_DefineProc("typescript-No-Echo-Cmd", (procedure) NoEchoCommand, classInfo, NULL, "Turn Off Echoing"); keymap_BindToKey(ssmap, "\030\014", tempProc, 0); ! ! tempProc = proctable_DefineProc("typescript-delete-previous-character", (procedure) typescript_RuboutCmd, classInfo, NULL, "Delete the previous character."); keymap_BindToKey(ssmap, "\010", tempProc, 0); keymap_BindToKey(ssmap, "\177", tempProc, 0); ! si = proctable_DefineProc("Typescript-self-insert", (procedure) Typescript_SelfInsertCmd, classInfo, NULL, "Insert a character."); ! dig = proctable_DefineProc("Typescript-digit", (procedure) Typescript_DigitCmd, classInfo, NULL, "Insert a character."); str[0] = ' '; str[1] = '\0'; ! for(i = 32; i < 127; i++) { ! if(i < 48 || i > 57) keymap_BindToKey(ssmap, str, si, i); else keymap_BindToKey(ssmap, str, dig, i); *************** *** 1577,1587 **** tempProc = proctable_DefineProc("typescript-Clear", (procedure) ClearTypescript, classInfo, NULL, "Clear Typescript"); menulist_AddToML(typescriptMenus,"Clear~51",tempProc,NULL,0); return TRUE; } ! void typescript__Update(self) ! struct typescript *self; { self->lastPosition = -1; super_Update(self); --- 1848,1861 ---- tempProc = proctable_DefineProc("typescript-Clear", (procedure) ClearTypescript, classInfo, NULL, "Clear Typescript"); menulist_AddToML(typescriptMenus,"Clear~51",tempProc,NULL,0); + + tempProc = proctable_DefineProc("typescript-Clear-Text", (procedure) ClearTypescriptText, classInfo, NULL, "Clear the text of the typescript"); return TRUE; } ! void ! typescript__Update(self) ! struct typescript *self; { self->lastPosition = -1; super_Update(self); *************** *** 1588,1605 **** } #ifdef TIOCGWINSZ ! static NullWinSizeProc() { } #endif /* TIOCGWINSZ */ ! void typescript__FullUpdate(self, type, left, top, width, height) ! struct typescript *self; ! enum view_UpdateType type; ! long left; ! long top; ! long width; ! long height; { self->lastPosition = -1; super_FullUpdate(self, type, left, top, width, height); --- 1862,1881 ---- } #ifdef TIOCGWINSZ ! static int ! NullWinSizeProc() { } #endif /* TIOCGWINSZ */ ! void ! typescript__FullUpdate(self, type, left, top, width, height) ! struct typescript *self; ! enum view_UpdateType type; ! long left; ! long top; ! long width; ! long height; { self->lastPosition = -1; super_FullUpdate(self, type, left, top, width, height); *************** *** 1611,1616 **** --- 1887,1893 ---- char ffamily[1000]; long tssize; struct fontdesc *tsfont; + struct FontSummary *fontSummary; long widthinchar; struct winsize winSize; *************** *** 1619,1630 **** tsStyle = typescript_GetDefaultStyle(self); style_GetFontSize(tsStyle, &dummy, &tssize); style_GetFontFamily(tsStyle, ffamily, 1000); tsfont = fontdesc_Create(ffamily, style_GetAddedFontFaces(tsStyle), tssize); - widthinchar = (width / fontdesc_FontSummary(tsfont, self)->maxSpacing) - 1; - ioctl (self->SubChannel, TIOCGWINSZ, &winSize); ! if (winSize.ws_col != widthinchar) { winSize.ws_col = widthinchar; ioctl(self->SubChannel, TIOCSWINSZ, &winSize); } --- 1896,1909 ---- tsStyle = typescript_GetDefaultStyle(self); style_GetFontSize(tsStyle, &dummy, &tssize); style_GetFontFamily(tsStyle, ffamily, 1000); + style_AddTabsCharacters(tsStyle); tsfont = fontdesc_Create(ffamily, style_GetAddedFontFaces(tsStyle), tssize); + fontSummary = fontdesc_FontSummary(tsfont, self); + if(fontSummary) widthinchar = (width / fontSummary->maxSpacing) - 1; + else widthinchar = 12; ioctl (self->SubChannel, TIOCGWINSZ, &winSize); ! if(winSize.ws_col != widthinchar) { winSize.ws_col = widthinchar; ioctl(self->SubChannel, TIOCSWINSZ, &winSize); } *************** *** 1632,1673 **** #endif /* TIOCGWINSZ */ } ! void typescript__GetClickPosition(self, position, numberOfClicks, action, startLeft, startRight, leftPos, rightPos) ! struct typescript *self; ! long position; ! long numberOfClicks; ! enum view_MouseAction action; ! long startLeft; ! long startRight; ! long *leftPos; ! long *rightPos; { ! if(numberOfClicks%3 ) { ! super_GetClickPosition(self, position, numberOfClicks, action, startLeft, startRight, leftPos, rightPos); ! return; ! } ! if(GetCommandEnv(self,position,leftPos,rightPos)== NULL) ! super_GetClickPosition(self, position, numberOfClicks, action, startLeft, startRight, leftPos, rightPos); } ! #if SY_AIX12 ! /* This is a workaround for the pty REMOTE bug. */ ! static int ! ps2_write_pty(fd, buf, len) ! int fd; char *buf; int len; { ! struct ptywrraw praw; ! ! praw.ptr = buf; ! praw.cnt = len; ! return(ioctl(fd, PTYWRRAW, &praw)); } - #endif /* SY_AIX12 */ ! void typescript__SetDataObject(tp,obj) struct typescript *tp; struct dataobject *obj; { --- 1911,1966 ---- #endif /* TIOCGWINSZ */ } ! void ! typescript__GetClickPosition(self, position, numberOfClicks, action, startLeft, startRight, leftPos, rightPos) ! struct typescript *self; ! long position; ! long numberOfClicks; ! enum view_MouseAction action; ! long startLeft; ! long startRight; ! long *leftPos; ! long *rightPos; { ! if(numberOfClicks %3) { ! super_GetClickPosition(self, position, numberOfClicks, action, startLeft, startRight, leftPos, rightPos); ! return; ! } ! if(GetCommandEnv(self, position, leftPos, rightPos) == NULL) ! super_GetClickPosition(self, position, numberOfClicks, action, startLeft, startRight, leftPos, rightPos); } ! static int ! WritePty(tv, buf, len) ! struct typescript *tv; char *buf; int len; { ! #ifdef POSIX_ENV ! /* Write to a POSIX pty. Turn off echo before the write, ! * then reset echo to its previous state after the write. */ ! int ret; ! struct termios tios, new_tios; ! ! /* Save flags. */ ! tcgetattr(tv->SlaveChannel, &tios); ! new_tios = tios; ! new_tios.c_lflag &= ~ECHO; /* turn off echo for a moment */ ! tcsetattr(tv->SlaveChannel, TCSANOW, &new_tios); ! /* Write the data */ ! ret = write(tv->SubChannel, buf, len); ! /* Put echo back */ ! tcsetattr(tv->SlaveChannel, TCSANOW, &tios); ! return ret; ! #else /* POSIX_ENV */ ! /* Non-POSIX...just write to the pty. */ ! return write(tv->SubChannel, buf, len); ! #endif /* POSIX_ENV */ } ! void ! typescript__SetDataObject(tp, obj) struct typescript *tp; struct dataobject *obj; { *************** *** 1677,1699 **** long fontStyle = fontdesc_Fixed; char *font; long stpos; ! struct typetext *shtext = (struct typetext *)obj; ! struct text *SsText = (struct text *) shtext; ! super_SetDataObject(tp,obj); ! if (!staticBoldStyle) { ! if ((staticBoldStyle = stylesheet_Find(SsText->styleSheet, "bold")) == NULL){ ! staticBoldStyle = style_New(); ! style_SetName(staticBoldStyle, "bold"); ! stylesheet_Add(SsText->styleSheet, staticBoldStyle); } style_AddNewFontFace(staticBoldStyle, fontdesc_Bold); } ! ! if ((defaultStyle = typescript_GetDefaultStyle(tp)) == NULL) { ! defaultStyle = style_New(); ! style_SetName(defaultStyle, "default"); } ! if ((font = environ_GetProfile("bodyfont")) == NULL || ! fontdesc_ExplodeFontName(font, bodyFont, sizeof(bodyFont), &fontStyle, &fontSize)) { strcpy(bodyFont, "AndyType"); fontSize = 10; fontStyle = fontdesc_Fixed; --- 1970,1992 ---- long fontStyle = fontdesc_Fixed; char *font; long stpos; ! struct typetext *shtext = (struct typetext*) obj; ! struct text *SsText = (struct text*) shtext; ! ! super_SetDataObject(tp, obj); ! if(!staticBoldStyle) { ! if((staticBoldStyle = stylesheet_Find(SsText->styleSheet, "bold")) == NULL) { ! staticBoldStyle = style_New(); ! style_SetName(staticBoldStyle, "bold"); ! stylesheet_Add(SsText->styleSheet, staticBoldStyle); } style_AddNewFontFace(staticBoldStyle, fontdesc_Bold); } ! if((defaultStyle = typescript_GetDefaultStyle(tp)) == NULL) { ! defaultStyle = style_New(); ! style_SetName(defaultStyle, "default"); } ! if((font = environ_GetProfile("typescript.bodyfont")) == NULL || ! fontdesc_ExplodeFontName(font, bodyFont, sizeof(bodyFont), &fontStyle, &fontSize)) { strcpy(bodyFont, "AndyType"); fontSize = 10; fontStyle = fontdesc_Fixed; *************** *** 1710,1717 **** tp->cmdStart = text_CreateMark(SsText,stpos,0); text_SetFence(SsText, stpos); mark_IncludeBeginning(tp->cmdStart) = TRUE; ! if(!shtext->hashandler){ ! im_AddFileHandler (tp->SCFile, (procedure) ReadFromProcess, (char *) tp, 6); shtext->hashandler = TRUE; } typescript_SetDotPosition(tp,stpos); --- 2003,2010 ---- tp->cmdStart = text_CreateMark(SsText,stpos,0); text_SetFence(SsText, stpos); mark_IncludeBeginning(tp->cmdStart) = TRUE; ! if(!shtext->hashandler) { ! im_AddFileHandler(tp->SCFile, (procedure) ReadFromProcess, (char*) tp, 6); shtext->hashandler = TRUE; } typescript_SetDotPosition(tp,stpos); *************** *** 1718,1745 **** im_ForceUpdate(); } ! void typescript__SetTitle(self, title) struct typescript *self; char *title; { ! if (self->title != NULL) { free(self->title); ! } ! if (title != NULL || *title != '\0') { ! self->title = (char *) malloc(strlen(title) + 1); ! if (self->title != NULL) { strcpy(self->title, title); - } } ! else { self->title = NULL; - } } ! char *typescript__GetTitle(self) struct typescript *self; { return self->title; } ! --- 2011,2089 ---- im_ForceUpdate(); } ! void ! typescript__SetTitle(self, title) struct typescript *self; char *title; { ! if(self->title != NULL) free(self->title); ! if(title || *title != '\0') { ! self->title = (char*) malloc(strlen(title) + 1); ! if(self->title) strcpy(self->title, title); } ! else self->title = NULL; } ! char * ! typescript__GetTitle(self) struct typescript *self; { return self->title; } ! #ifdef UTMP_MUNGE ! /* ! * The following establishes a utmp entry if /etc/utmp is writeable. ! * Since typescript should never be setuid root (implying ez and everything else is), ! * this will only work on relaxed systems where /etc/utmp is open. ! */ ! int ! utmp_add(ptyname, pid) ! char *ptyname; ! int pid; ! { ! struct utmp utmp; ! char *username; ! ! bzero(&utmp, sizeof(utmp)); ! username = cuserid(NULL); ! if(username) { ! strncpy(utmp.ut_user, username, sizeof(utmp.ut_user)); ! ! /* skip /dev/ */ ! strncpy(utmp.ut_line, ptyname + 5, sizeof(utmp.ut_line)); ! ! /* skip /dev/ */ ! strncpy(utmp.ut_id, ptyname + 5, sizeof(utmp.ut_id)); ! ! utmp.ut_type = USER_PROCESS; ! utmp.ut_pid = pid; /* pid of shell or command */ ! utmp.ut_time = time(NULL); ! strncpy(utmp.ut_host, "typescript", sizeof(utmp.ut_host)); ! setutent(); ! pututline(&utmp); /* This may fail on secure systems. */ ! } ! } ! ! int ! utmp_delete(ptyname) ! char *ptyname; ! { ! struct utmp utmp; ! ! bzero(&utmp, sizeof(utmp)); ! setutent(); ! ! /* skip /dev/ */ ! strncpy(utmp.ut_line, ptyname+5, sizeof(utmp.ut_line)); ! ! /* skip /dev/ */ ! strncpy(utmp.ut_id, ptyname+5, sizeof(utmp.ut_id)); ! ! utmp.ut_type = DEAD_PROCESS; ! pututline(&utmp); /* This may fail on secure systems. */ ! } ! #endif *** atk/typescript/tscript.ch Mon Aug 6 11:10:52 1990 --- atk/typescript/tscript.ch.NEW Tue Jan 22 14:27:53 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/typescript/RCS/tscript.ch,v 2.9 90/05/10 14:10:22 ajp Exp $ */ /* $ACIS:tscript.ch 1.4$ */ ! /* $Source: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/typescript/RCS/tscript.ch,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsidtypescript_H = "$Header: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/typescript/RCS/tscript.ch,v 2.9 90/05/10 14:10:22 ajp 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/typescript/RCS/tscript.ch,v 2.11 91/01/21 18:00:12 gk5g Exp $ */ /* $ACIS:tscript.ch 1.4$ */ ! /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/typescript/RCS/tscript.ch,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsidtypescript_H = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/typescript/RCS/tscript.ch,v 2.11 91/01/21 18:00:12 gk5g Exp $"; #endif /* !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) */ *************** *** 43,53 **** FinalizeObject(struct typescript *ap); data: struct mark *cmdStart; /* last place a new command was started */ - struct mark *lastCommand; /* last place $= went to */ - struct environment *lastEnv; /* last environment $- went to */ long lastPosition; /* used for deciding to frame the dot when reading from the process */ FILE *SCFile; /* Sub Channel file * for BE 2file handler. */ short SubChannel; /* File descriptor of sub process i/o channel. */ short readOnlyLen; /* Number of charaters in read only buffer. -1 if not in read only mode. */ char readOnlyBuf[READONLYMAX]; /* Place to gather characters when in read only (no echo) mode. */ char OutputWait; --- 43,52 ---- FinalizeObject(struct typescript *ap); data: struct mark *cmdStart; /* last place a new command was started */ long lastPosition; /* used for deciding to frame the dot when reading from the process */ FILE *SCFile; /* Sub Channel file * for BE 2file handler. */ short SubChannel; /* File descriptor of sub process i/o channel. */ + int SlaveChannel; /* File descriptor of slave side of the pty. */ short readOnlyLen; /* Number of charaters in read only buffer. -1 if not in read only mode. */ char readOnlyBuf[READONLYMAX]; /* Place to gather characters when in read only (no echo) mode. */ char OutputWait; *************** *** 54,67 **** char ChopLines; struct keystate *keystate; struct menulist *menulist; - #if 0 - struct menulist *selmenulist; - struct menulist *fencedmenulist; - #endif /* 0 */ char *progname; boolean pipescript; ! #ifdef AIX ! int pgrpid; /* process group id for signalling */ ! #endif char *title; }; --- 53,63 ---- char ChopLines; struct keystate *keystate; struct menulist *menulist; char *progname; boolean pipescript; ! int pgrpid; /* process group id for signaling in no job-control systems */ ! char *ptyname; /* Name of the slave side pty device. */ char *title; + struct text *cmdText; + long lastCmdPos; }; *** atk/typescript/tscripta.c Fri Dec 21 14:59:56 1990 --- atk/typescript/tscripta.c.NEW Tue Jan 22 14:27:54 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/typescript/RCS/tscripta.c,v 2.13 90/09/12 13:05:07 gk5g Exp $ */ /* $ACIS:tscripta.c 1.5$ */ ! /* $Source: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/typescript/RCS/tscripta.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/typescript/RCS/tscripta.c,v 2.13 90/09/12 13:05:07 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/typescript/RCS/tscripta.c,v 2.14 91/01/21 18:03:11 gk5g Exp $ */ /* $ACIS:tscripta.c 1.5$ */ ! /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/typescript/RCS/tscripta.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/typescript/RCS/tscripta.c,v 2.14 91/01/21 18:03:11 gk5g Exp $"; #endif /* lint */ #include *************** *** 100,105 **** --- 100,111 ---- return TRUE; } + void typescriptapp__FinalizeObject(classID,self) + struct classheader *classID; + struct typescriptapp *self; + { + } + boolean typescriptapp__Start(self) struct typescriptapp *self; { *************** *** 176,179 **** --- 182,194 ---- DontSwapMeOut(); /* Start eviction protection measures. */ return TRUE; + } + + + void typescriptapp__Stop(self) + struct typescriptapp *self; + { + if (self->ss) + typescript_Destroy(self->ss); + super_Stop(self); } *** atk/typescript/tscripta.ch Wed Nov 22 12:35:47 1989 --- atk/typescript/tscripta.ch.NEW Tue Jan 22 14:27:55 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/sm/releases/X.V11R4/andrew/atk/typescript/RCS/tscripta.ch,v 2.6 89/06/22 13:05:31 ghoti Exp $ */ /* $ACIS:tscripta.ch 1.2$ */ ! /* $Source: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/typescript/RCS/tscripta.ch,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsidtscriptapp_H = "$Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/typescript/RCS/tscripta.ch,v 2.6 89/06/22 13:05:31 ghoti Exp $"; #endif /* !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) */ class typescriptapp[tscripta] : application[app] { overrides: ParseArgs(int argc, char **argv) returns boolean; Start() returns boolean; data: struct typescript *ss; struct frame *frame; --- 2,23 ---- * 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/typescript/RCS/tscripta.ch,v 2.7 91/01/21 18:01:46 gk5g Exp $ */ /* $ACIS:tscripta.ch 1.2$ */ ! /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/typescript/RCS/tscripta.ch,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsidtscriptapp_H = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/typescript/RCS/tscripta.ch,v 2.7 91/01/21 18:01:46 gk5g Exp $"; #endif /* !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) */ class typescriptapp[tscripta] : application[app] { + classprocedures: + InitializeObject(struct typescriptapp *self) returns boolean; + FinalizeObject(struct typescriptapp *self); overrides: ParseArgs(int argc, char **argv) returns boolean; Start() returns boolean; + Stop(); data: struct typescript *ss; struct frame *frame; *** atk/typescript/typetext.c Wed Nov 22 12:36:00 1989 --- atk/typescript/typetext.c.NEW Mon Feb 18 18:03: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/typescript/RCS/typetext.c,v 2.9 89/11/02 10:24:18 tpn Exp $ */ /* $ACIS:typetext.c 1.2$ */ ! /* $Source: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/typescript/RCS/typetext.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/typescript/RCS/typetext.c,v 2.9 89/11/02 10:24:18 tpn Exp $"; #endif /* lint */ /* typetext.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/typescript/RCS/typetext.c,v 2.10 91/02/14 16:44:40 dba Exp $ */ /* $ACIS:typetext.c 1.2$ */ ! /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/typescript/RCS/typetext.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/typescript/RCS/typetext.c,v 2.10 91/02/14 16:44:40 dba Exp $"; #endif /* lint */ /* typetext.c *************** *** 61,66 **** --- 61,67 ---- { return "typescript"; } + boolean typetext__InitializeObject(classID, self) struct classheader *classID; struct typetext *self; *************** *** 71,73 **** --- 72,81 ---- typetext_SetObjectInsertionFlag(self,FALSE); return TRUE; } + + long typetext__GetModified(self) + struct typetext *self; + { + return 0; + } + *** atk/typescript/typetext.ch Wed Nov 22 12:36:03 1989 --- atk/typescript/typetext.ch.NEW Mon Feb 18 18:03:06 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/typescript/RCS/typetext.ch,v 2.5 89/10/09 13:49:07 tpn Exp $ */ /* $ACIS:typetext.ch 1.2$ */ ! /* $Source: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/typescript/RCS/typetext.ch,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsidtypetext_H = "$Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/typescript/RCS/typetext.ch,v 2.5 89/10/09 13:49:07 tpn Exp $"; #endif /* !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) */ /* typetext.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/typescript/RCS/typetext.ch,v 2.6 91/02/14 16:44:33 dba Exp $ */ /* $ACIS:typetext.ch 1.2$ */ ! /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/typescript/RCS/typetext.ch,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsidtypetext_H = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/typescript/RCS/typetext.ch,v 2.6 91/02/14 16:44:33 dba Exp $"; #endif /* !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) */ /* typetext.H *************** *** 21,26 **** --- 21,27 ---- HandleKeyWord(long pos, char *keyword, FILE *file) returns long; HandleCloseBrace(long pos, FILE *file) returns long; ViewName() returns char *; + GetModified() returns long; data: int hashandler; }; *** atk/textobjects/Imakefile Wed Nov 22 12:36:16 1989 --- atk/textobjects/Imakefile.NEW Wed Apr 3 21:22:45 1991 *************** *** 13,20 **** InstallFile(dired.tpl, ${INSTINCFLAGS}, ${DESTDIR}/lib/tpls) ! LibraryTarget(libtextobjects.a, $(OBJS)) ! InstallLibrary(libtextobjects.a, ${DESTDIR}/lib/atk) DependTarget() --- 13,20 ---- InstallFile(dired.tpl, ${INSTINCFLAGS}, ${DESTDIR}/lib/tpls) ! LibraryTarget(libtextobj.a, $(OBJS)) ! InstallLibrary(libtextobj.a, ${DESTDIR}/lib/atk) DependTarget() *** atk/textobjects/dired.c Mon Aug 6 11:10:56 1990 --- atk/textobjects/dired.c.NEW Wed Apr 3 21:22:46 1991 *************** *** 4,10 **** --- 4,15 ---- \* ********************************************************************** */ #include #include + #ifdef M_UNIX + #include + #define direct dirent + #else #include + #endif #include #include *** atk/textobjects/panel.c Fri Dec 21 14:36:25 1990 --- atk/textobjects/panel.c.NEW Fri Dec 14 16:34:26 1990 *************** *** 23,32 **** #include static struct keymap *classKeymap; - static struct style *defaultHighlightStyle; - static struct style *defaultOverallStyle; - static struct fontdesc *defaultIconFont = NULL; - static char defaultIcon; /* * Statics --- 23,28 ---- *************** *** 152,169 **** boolean panel__InitializeClass(classID) struct classheader *classID; { - defaultHighlightStyle = style_New(); - style_AddNewFontFace(defaultHighlightStyle, fontdesc_Bold); - - defaultOverallStyle = style_New(); - style_SetJustification(defaultOverallStyle, style_LeftJustified); - style_SetFontSize(defaultOverallStyle, style_ConstantFontSize, 10); - style_SetNewLeftMargin(defaultOverallStyle, style_LeftMargin, 16384, style_Inches); - style_SetNewIndentation(defaultOverallStyle, style_LeftEdge, -16384, style_Inches); - - defaultIconFont = fontdesc_Create("icon", fontdesc_Plain, 12); - defaultIcon = 'R'; - classKeymap = keymap_New(); { --- 148,153 ---- *************** *** 185,190 **** --- 169,188 ---- struct classheader *classID; register struct panel *self; { + struct style *defaultOverallStyle; + + self->highlightStyle = style_New(); + style_AddNewFontFace(self->highlightStyle, fontdesc_Bold); + + defaultOverallStyle = style_New(); + style_SetJustification(defaultOverallStyle, style_LeftJustified); + style_SetFontSize(defaultOverallStyle, style_ConstantFontSize, 10); + style_SetNewLeftMargin(defaultOverallStyle, style_LeftMargin, 16384, style_Inches); + style_SetNewIndentation(defaultOverallStyle, style_LeftEdge, -16384, style_Inches); + + self->iconFont = fontdesc_Create("icon", fontdesc_Plain, 12); + self->icon = 'R'; + self->panelList = NULL; self->keyList = NULL; self->keystate = keystate_Create(self, classKeymap); *************** *** 192,201 **** super_SetDataObject(self,self->text); self->ourText = TRUE; self->handler = NULL; - self->iconFont = defaultIconFont; - self->icon = defaultIcon; self->cursor = cursor_Create(self); - self->highlightStyle = defaultHighlightStyle; self->highlightEntry = NULL; self->highlightEnv = NULL; --- 190,196 ---- *************** *** 227,233 **** keystate_Destroy(self->keystate); if(self->ourText) text_Destroy(self->text); - fontdesc_Destroy(self->iconFont); cursor_Destroy(self->cursor); style_Destroy(self->highlightStyle); } --- 222,227 ---- *** atk/value/Imakefile Wed Nov 22 12:37:48 1989 --- atk/value/Imakefile.NEW Tue May 7 12:51:28 1991 *************** *** 5,10 **** --- 5,11 ---- DOBJS = getrecv.do \ bargrphv.do \ buttonv.do \ + checkv.do \ controlv.do \ entrstrv.do \ entrtext.do \ *************** *** 23,33 **** updateq.do \ value.do \ valuev.do \ ! clklistv.do IHFILES = getrecv.ih \ bargrphv.ih \ buttonv.ih \ controlv.ih \ entrstrv.ih \ entrtext.ih \ --- 24,61 ---- updateq.do \ value.do \ valuev.do \ ! clklistv.do \ ! mbuttonv.do + OBJS = getrecv.o \ + bargrphv.o \ + buttonv.o \ + checkv.o \ + controlv.o \ + entrstrv.o \ + entrtext.o \ + etextv.o \ + fourwayv.o \ + mentstrv.o \ + menttext.o \ + metextv.o \ + onoffv.o \ + pianov.o \ + sliderv.o \ + slidstrv.o \ + stringv.o \ + thumbv.o \ + thmbstrv.o \ + updateq.o \ + value.o \ + valuev.o \ + clklistv.o \ + mbuttonv.o + IHFILES = getrecv.ih \ bargrphv.ih \ buttonv.ih \ + checkv.ih \ controlv.ih \ entrstrv.ih \ entrtext.ih \ *************** *** 46,52 **** updateq.ih \ value.ih \ valuev.ih \ ! clklistv.ih DependTarget() NormalObjectRule() --- 74,81 ---- updateq.ih \ value.ih \ valuev.ih \ ! clklistv.ih \ ! mbuttonv.ih DependTarget() NormalObjectRule() *************** *** 59,64 **** --- 88,95 ---- FontRule() DeclareFont(values25) + LibraryTarget(libvalue.a, $(OBJS)) + InstallLibrary(libvalue.a, ${DESTDIR}/lib/atk) NormalHelpRule() InstallDocs(valproc.help, ${DESTDIR}/help) *** atk/value/clklistv.c Mon Aug 6 11:11:03 1990 --- atk/value/clklistv.c.NEW Wed Feb 13 16:55: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/src/projects/andrew/atk/value/RCS/clklistv.c,v 1.10 90/06/05 12:25:34 gk5g Exp $ */ /* $ACIS: $ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/value/RCS/clklistv.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/value/RCS/clklistv.c,v 1.10 90/06/05 12:25:34 gk5g Exp $ "; #endif /* lint */ #include #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/value/RCS/clklistv.c,v 1.11 91/02/12 17:40:07 gk5g Exp $ */ /* $ACIS: $ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/value/RCS/clklistv.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/value/RCS/clklistv.c,v 1.11 91/02/12 17:40:07 gk5g Exp $ "; #endif /* lint */ #include #include *************** *** 20,26 **** #include - static void handleclicks(self,cv,position, numberOfClicks, action, startLeft, startRight, leftPos, rightPos,which,type) struct clicklistV *self; struct cltextview *cv; --- 20,25 ---- *************** *** 41,47 **** return; } if(*action == view_LeftUp){ ! char *cp,*index(); int start,end,len,tlen; val = clicklistV_Value(self); if(*numberOfClicks == 1){ --- 40,46 ---- return; } if(*action == view_LeftUp){ ! char *cp; int start,end,len,tlen; val = clicklistV_Value(self); if(*numberOfClicks == 1){ *** atk/value/menttext.c Wed Nov 22 12:37:55 1989 --- atk/value/menttext.c.NEW Wed Feb 13 16:55:37 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/sm/releases/X.V11R4/andrew/atk/value/RCS/menttext.c,v 2.11 89/10/16 11:55:59 cfe Exp $ */ /* $ACIS: $ */ ! /* $Source: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/value/RCS/menttext.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/value/RCS/menttext.c,v 2.11 89/10/16 11:55:59 cfe Exp $ "; #endif /* lint */ - #include #include ! #include #include #include #include #include #define INITIALSIZE 64 #define Root(self) (((struct text *)self)->rootEnvironment) #define MyEnvinfo(text,pos) environment_GetInnerMost(Root(self), pos) #define Enclosed(text,pos) Root(self) != MyEnvinfo(text,pos) boolean mentertext__InitializeObject(classID,self) struct classheader *classID; struct mentertext *self; --- 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/value/RCS/menttext.c,v 2.12 91/02/12 17:40:13 gk5g Exp $ */ /* $ACIS: $ */ ! /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/value/RCS/menttext.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/value/RCS/menttext.c,v 2.12 91/02/12 17:40:13 gk5g Exp $ "; #endif /* lint */ #include ! #include #include #include #include #include + #include #define INITIALSIZE 64 #define Root(self) (((struct text *)self)->rootEnvironment) #define MyEnvinfo(text,pos) environment_GetInnerMost(Root(self), pos) #define Enclosed(text,pos) Root(self) != MyEnvinfo(text,pos) + boolean mentertext__InitializeObject(classID,self) struct classheader *classID; struct mentertext *self; *************** *** 55,61 **** long i,fin,elen,count; struct environment *newenv; boolean foundlast = FALSE; ! char *c,*index(); count = i = 0; fin = mentertext_GetLength(self); while(i < fin && count < 127){ --- 56,62 ---- long i,fin,elen,count; struct environment *newenv; boolean foundlast = FALSE; ! char *c; count = i = 0; fin = mentertext_GetLength(self); while(i < fin && count < 127){ *** atk/value/mbuttonv.c Thu May 30 20:21:18 1991 --- atk/value/mbuttonv.c.NEW Tue May 7 12:51:35 1991 *************** *** 0 **** --- 1,672 ---- + /* ********************************************************************** *\ + * 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/value/RCS/mbuttonv.c,v 1.1 1991/05/07 15:42:46 tpn Exp $ */ + /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/value/RCS/mbuttonv.c,v $ */ + + #ifndef lint + static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/value/RCS/mbuttonv.c,v 1.1 1991/05/07 15:42:46 tpn Exp $ "; + #endif /* lint */ + + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + static struct atomlist * AL_bodyfont; + static struct atomlist * AL_bodyfont_size; + static struct atomlist * AL_label; + static struct atomlist * AL_placement; + static struct atom * A_long; + static struct atom * A_string; + #define InternAtoms ( \ + AL_bodyfont = atomlist_StringToAtomlist("bodyfont") ,\ + AL_bodyfont_size = atomlist_StringToAtomlist("bodyfont-size") ,\ + AL_label = atomlist_StringToAtomlist("label") ,\ + AL_placement = atomlist_StringToAtomlist("placement") ,\ + A_long = atom_Intern("long") ,\ + A_string = atom_Intern("string") ) + struct mbuttonv_rl { + struct rectangle rect; + char *string; + boolean pushed; + long key,len; + long width; + }; + #define mbuttonv_SetUpperShade(SELF,P){\ + if(P) mbuttonv_setShade(SELF,200);\ + else mbuttonv_setShade(SELF,(self->mono ?25:45));\ + } + #define mbuttonv_SetLowerShade(SELF,P){\ + if(!P) mbuttonv_setShade(SELF,200);\ + else mbuttonv_setShade(SELF,(self->mono ?25:45));\ + } + #define FORESHADE 30 + + #define Min(X,Y) ((X) < (Y) ? (X) : (Y)) + #define Graphic(A) (((struct view *)(A))->drawable) + #define CLOSEBUTTON TRUE + /****************************************************************/ + /* private functions */ + /**************************************************************** + + #define DEFAULTPCT 10 + + #define MINSIZE 3 + /* Rect2 is the inner (Text) region */ + + #define PROMPTFONT "andysans12b" + #define FONT "andysans" + #define FONTTYPE fontdesc_Bold + #define FONTSIZE 12 + #define BUTTONDEPTH 3 + #define BUTTONPRESSDEPTH 2 + #define TEXTPAD 2 + #define mbuttonv_STRING_END ':' + #define mbuttonv_STRING_ESCAPE '\\' + + #define FGCOLOR "white" + #define BGCOLOR "blue" + /* #define TEXTCOLOR "black" */ + + #define CFGCOLOR "white" + #define CBGCOLOR "blue" + + #define BWFGCOLOR "black" + #define BWBGCOLOR "white" + + + static void mbuttonv_setShade(self, val) + struct mbuttonv *self; + int val; /* 0 - 200*/ + { + double pct; + if(val > 100){ + /* mbuttonv_SetFGColor(self,.95,.95,.95); */ + if (self->mono) pct = .75; + else { + /* mbuttonv_SetFGColor(self,.95,.95,.95); */ + mbuttonv_SetForegroundColor(self,"Dark Gray",0,0,0); + return; + } + } + else if(val == 100){ + mbuttonv_SetFGColor(self, + self->foreground_color[0], + self->foreground_color[1], + self->foreground_color[2]); + return ; + } + else if(val == 0){ + mbuttonv_SetFGColor(self, + self->background_color[0], + self->background_color[1], + self->background_color[2]); + return; + } + + else pct = (double)val/ 100.; + mbuttonv_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)); + + } /* mbuttonv_setShade */ + + + static boolean clearrl(rl,self) + struct mbuttonv_rl *rl; + struct mbuttonv *self; + { + if(rl->len > 0) free(rl->string); + free(rl); + return TRUE; + } + static vsetrec(rl,self) + struct mbuttonv_rl *rl; + struct mbuttonv *self; + { + self->rtl += -self->rhw; + rectangle_SetRectSize(&(rl->rect),self->header.valueview.x,self->rtl, + self->header.valueview.width, self->rhw); + } + static wsetrec(rl,self) + struct mbuttonv_rl *rl; + struct mbuttonv *self; + { + rectangle_SetRectSize(&(rl->rect),self->rtl,self->header.valueview.y, + self->rhw,self->header.valueview.height); + self->rtl += self->rhw; + } + static calcRec(self) + struct mbuttonv * self; + { + if(self->vertical){ + self->rtl = self->header.valueview.height; + self->rhw = self->header.valueview.height / self->count; + list_Enumerate(self->list,vsetrec,self); + } + else { + self->rtl = 0; + self->rhw = self->header.valueview.width / self->count; + list_Enumerate(self->list,wsetrec,self); + } + } + + static mbuttonv_CacheSettings(self) + struct mbuttonv *self; + { + char *fgcolor, *bgcolor,tmp[256],*t,*chr; + unsigned char fg_rgb[3], bg_rgb[3]; + struct graphic *my_graphic; + struct mbuttonv_rl *rl; + long i,j; + long max = 0l; + self->activefont = fontdesc_Create( self->fontname, fontdesc_Plain, self->fontsize ); + my_graphic = (struct graphic *)mbuttonv_GetDrawable(self); + + fgcolor = FGCOLOR; + bgcolor = BGCOLOR; + self->FontSummary = fontdesc_FontSummary(self->activefont, my_graphic); + list_Enumerate(self->list,clearrl,self) ; + list_Clear(self->list); + i = 0; + chr = self->label; + self->mono = (mbuttonv_DisplayClass(self ) & graphic_Monochrome); + do{ + j = 0; + rl = (struct mbuttonv_rl *) + malloc(sizeof(struct mbuttonv_rl)); + rl->string = ""; + t = tmp; + if(chr != NULL){ + while(*chr != mbuttonv_STRING_END && *chr != '\0'){ + if(*chr == mbuttonv_STRING_ESCAPE && *(chr + 1) == mbuttonv_STRING_END){ + chr++; + } + *t++ = *chr++; + j++; + } + } + rl->len = j; + *t = '\0'; + if(j > 0){ + rl->string = malloc(j + 1); + strcpy(rl->string,tmp); + } + list_InsertEnd(self->list,(char *)rl); + rl->width = fontdesc_StringSize(self->activefont,my_graphic, tmp,NULL,NULL); + if(rl->width > max) max = rl->width; + rl->pushed = FALSE; + rl->key = i; + if(chr == NULL || *chr == '\0') break; + chr++; + }while (++i < 128); + self->current = NULL; + self->count = i + 1; + self->max = max; + if ( self->mono ){ + fgcolor = BWFGCOLOR; + bgcolor = BWBGCOLOR; + } + else { + fgcolor = CFGCOLOR; + bgcolor = CBGCOLOR; + } + + if (mbuttonv_GetIM(self) != NULL) { + /* these calls don't make sense if there is no IM, + (in fact they seg fault!) */ + + mbuttonv_SetForegroundColor(self, fgcolor, fg_rgb[0]*256L, fg_rgb[1]*256L, fg_rgb[2]*256L); + mbuttonv_SetBackgroundColor(self, bgcolor, bg_rgb[0]*256L, bg_rgb[1]*256L, bg_rgb[2]*256L); + + mbuttonv_GetFGColor(self, + &(self->foreground_color[0]), + &(self->foreground_color[1]), + &(self->foreground_color[2])); + mbuttonv_GetBGColor(self, + &(self->background_color[0]), + &(self->background_color[1]), + &(self->background_color[2])); + } + } + static void drawRecButton(self,rect,text,len,pushed,borderonly,blit) + struct mbuttonv * self; + struct rectangle *rect; + char *text; + long len; + boolean pushed; + boolean borderonly; + boolean blit; + { + + struct rectangle Rect2; + int r2_bot, r_bot; + int tx = 0, ty = 0; + short t_op; + long offset; + offset = 0; + mbuttonv_SetFont(self, self->activefont); + + mbuttonv_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); + + mbuttonv_SetTransferMode(self, graphic_COPY); + if(!borderonly && (!self->mono || !blit)){ + /* mbuttonv_setShade(self, ((self->mono) ? .0:((pushed)? .0: FORESHADE))); */ + if(self->mono){ + mbuttonv_setShade(self, 0); + } + else mbuttonv_setShade(self, ((pushed)? 0: FORESHADE)); + mbuttonv_FillRect(self, &Rect2, NULL); /* the middle box */ + if(text && *text){ + mbuttonv_setShade(self, 100); + mbuttonv_SetTransferMode(self, graphic_COPY); + if(len == 1){ + /* special case drawing an icon */ + struct fontdesc_charInfo ci; + fontdesc_CharSummary(self->activefont,Graphic(self),*text,&ci); + tx = ci.width + 4; + ty = ci.height + 4; + mbuttonv_MoveTo( self, rect->left + (rect->width >> 1) - (tx / 2) + ci.xOriginOffset + 2,rect->top + (rect->height >> 1) - (ty / 2) + ci.yOriginOffset + 2); + mbuttonv_DrawText(self,text,len,0 ); + } + else + { + tx = Rect2.left + (Rect2.width/ 2); + ty = Rect2.top + ( Rect2.height/ 2); + mbuttonv_MoveTo(self, tx, ty); + mbuttonv_DrawText(self, text, len,t_op); + } + mbuttonv_SetTransferMode(self, graphic_COPY); + } + } + if(self->mono && (blit || ((!blit) && pushed))){ + mbuttonv_SetTransferMode(self, graphic_INVERT); + mbuttonv_FillRect(self, &Rect2, NULL); /* the middle box */ + mbuttonv_SetTransferMode(self, graphic_COPY); + } + mbuttonv_SetUpperShade(self,pushed) ; + mbuttonv_FillRectSize(self, rect->left, rect->top, BUTTONDEPTH + offset, rect->height, NULL); /* left bar */ + + mbuttonv_SetLowerShade(self,pushed) ; + mbuttonv_FillRectSize(self, rect->left + rect->width - BUTTONDEPTH + offset, rect->top, BUTTONDEPTH - offset, rect->height, NULL); /* right bar */ + mbuttonv_FillTrapezoid(self, Rect2.left, r2_bot, Rect2.width, rect->left, r_bot, rect->width, NULL); /* lower trapz */ + + mbuttonv_SetUpperShade(self,pushed) ; + + mbuttonv_FillTrapezoid(self, rect->left, rect->top, rect->width, Rect2.left, Rect2.top, Rect2.width, NULL); /* upper trapz */ + mbuttonv_SetTransferMode(self, graphic_COPY); + if(self->mono){ + mbuttonv_setShade(self, 100); + mbuttonv_DrawRect(self,rect); + /* mbuttonv_DrawRect(self,&Rect2); */ + } + #if 0 + else { + mbuttonv_setShade(self, ((self->mono) ? 0:50)); + mbuttonv_FillRectSize(self, rect->left, rect->top, BUTTONDEPTH + offset, rect->height, NULL); /* left bar */ + + mbuttonv_FillRectSize(self, rect->left + rect->width - BUTTONDEPTH + offset, rect->top, BUTTONDEPTH - offset, rect->height, NULL); /* right bar */ + mbuttonv_FillTrapezoid(self, Rect2.left, r2_bot, Rect2.width, rect->left, r_bot, rect->width, NULL); /* lower trapz */ + + mbuttonv_FillTrapezoid(self, rect->left, rect->top, rect->width, Rect2.left, Rect2.top, Rect2.width, NULL); /* upper trapz */ + if(self->mono) { + mbuttonv_setShade(self,100); + mbuttonv_DrawRect(self, rect); + } + } + mbuttonv_SetTransferMode(self, graphic_BLACK); + #endif + } + + static void DrawButton(self,rl,left,top,width,height,borderonly,blit) + struct mbuttonv * self; + struct mbuttonv_rl *rl; + long left,top,width,height; + boolean borderonly,blit; + { + struct rectangle Rect,*rect; + char *text ; + boolean ped ; + long textlen; + + if(rl == NULL) { + rect = &Rect; + rectangle_SetRectSize(rect,left,top,width,height); + ped = (self->pushed); + text = ""; + textlen = 0l; + } + else{ + rect = &(rl->rect); + ped = (rl->pushed); + text = rl->string; + textlen = rl->len; + } + drawRecButton(self,rect,text,textlen,ped,borderonly,blit); + } + static boolean enclosed(rl,x,y) + struct mbuttonv_rl *rl; + long x,y; + { + if(x < rl->rect.left || + y < rl->rect.top || + x >= rl->rect.left + rl->rect.width || + y >= rl->rect.top + rl->rect.height) + return FALSE; + return TRUE; + } + + static drl(rl,self) + struct mbuttonv_rl *rl; + struct mbuttonv *self; + { + DrawButton(self,rl,0,0,0,0,FALSE,FALSE); + return TRUE; + } + static findcurrent(rl,self) + struct mbuttonv_rl *rl; + struct mbuttonv *self; + { + return !enclosed(rl,self->x,self->y); + } + static findkey(rl,i) + struct mbuttonv_rl *rl; + long i; + { + return !(i == rl->key); + } + static DrawAllButtons(self) + struct mbuttonv * self; + { + list_Enumerate(self->list,drl,self); + } + + /****************************************************************/ + /* class procedures */ + /****************************************************************/ + + + + + boolean mbuttonv__InitializeClass(classID) + struct classheader *classID; + { + InternAtoms; + return TRUE; + } + + + + + + /****************************************************************/ + /* instance methods */ + /****************************************************************/ + boolean mbuttonv__InitializeObject(classID, self ) + struct classheader *classID; + struct mbuttonv * self; + { + self->label = NULL; + self->fontname = NULL; + self->fontsize = 0; + self->buttontype = mbuttonv_EITHER; + self->pushed = FALSE; + self->list = list_New(); + self->current = NULL; + return TRUE; + } + + + void mbuttonv__LookupParameters(self) + struct mbuttonv * self; + { + char * fontname; + long fontsize; + struct resourceList parameters[5]; + char *plc; + parameters[0].name = AL_label; + parameters[0].type = A_string; + parameters[1].name = AL_bodyfont; + parameters[1].type = A_string; + parameters[2].name = AL_bodyfont_size; + parameters[2].type = A_long; + parameters[3].name = AL_placement; + parameters[3].type = A_string; + parameters[4].name = NULL; + parameters[4].type = NULL; + + mbuttonv_GetManyParameters(self, parameters, NULL, NULL); + + if (parameters[0].found) + self->label = (char *)parameters[0].data; + else + self->label = NULL; + + if (parameters[1].found) + fontname = (char *)parameters[1].data; + else + fontname = "andytype"; + + if (parameters[2].found) + fontsize = parameters[2].data; + else + fontsize = 10; + + if (parameters[3].found) + plc = (char *)parameters[3].data; + else + plc = NULL; + + if(plc != NULL && (*plc == 'h' || *plc == 'H')) self->vertical = FALSE; + else self->vertical = TRUE; + self->fontsize = fontsize; + self->fontname = fontname; + mbuttonv_CacheSettings(self); + + } + + + void mbuttonv__DrawFromScratch(self,x,y,width,height) + struct mbuttonv * self; + long x,y,width,height; + { + if (width > 0 && height > 0) + { + calcRec(self); + DrawAllButtons(self); + mbuttonv_DrawNewValue( self ); + } + } + + + void mbuttonv__DrawDehighlight(self) + struct mbuttonv * self; + { + } + + void mbuttonv__DrawHighlight(self) + struct mbuttonv * self; + { + + } + + + void mbuttonv__DrawNewValue( self ) + struct mbuttonv * self; + { + long i= value_GetValue(mbuttonv_Value(self)); + struct mbuttonv_rl *rl = self->current; + if(self->count > 1){ + if(rl == NULL || i != rl->key){ + if(rl){ + rl->pushed = FALSE; + DrawButton(self,rl,0,0,0,0,FALSE,TRUE); + } + rl = (struct mbuttonv_rl *) list_Enumerate(self->list,findkey,i); + if(rl){ + rl->pushed = TRUE; + DrawButton(self,rl,0,0,0,0,FALSE,TRUE); + } + self->current = rl; + } + } + self->valueset = TRUE; + } + + struct mbuttonv * mbuttonv__DoHit( self,type,x,y,hits ) + struct mbuttonv * self; + enum view_MouseAction type; + long x,y,hits; + { + struct mbuttonv_rl *rl; + long v; + rl = self->current; + if(self->count == 1){ + struct valueview *vself = (struct valueview *) self; + switch(type){ + case view_RightUp: + case view_LeftUp: + if(rl){ + rl->pushed = FALSE; + DrawButton(self,rl,0,0,0,0,FALSE,TRUE); + } + value_SetValue(mbuttonv_Value(self),value_GetValue(mbuttonv_Value(self)) + 1); + self->current = NULL; + return self; + case view_LeftDown: + case view_RightDown: + break; + case view_LeftMovement: + case view_RightMovement: + if(rl && !vself->mouseIsOnTarget){ + rl->pushed = FALSE; + DrawButton(self,rl,0,0,0,0,FALSE,TRUE); + self->current = NULL; + } + return self; + } + } + switch(type){ + case view_RightUp: + case view_LeftUp: + if(rl) v = rl->key; + else v = -1; + if(value_GetValue(mbuttonv_Value(self)) != v) + value_SetValue(mbuttonv_Value(self),v); + break; + case view_LeftMovement: + case view_RightMovement: + case view_LeftDown: + case view_RightDown: + if(rl == NULL || !enclosed(rl,x,y)){ + self->x = x; + self->y = y; + if(rl){ + rl->pushed = FALSE; + DrawButton(self,rl,0,0,0,0,FALSE,TRUE); + } + self->valueset = FALSE; + rl = (struct mbuttonv_rl *) list_Enumerate(self->list,findcurrent,self); + if(rl == NULL){ + self->current = NULL; + mbuttonv_DrawNewValue( self ); + break; + } + if(rl){ + rl->pushed = TRUE; + DrawButton(self,rl,0,0,0,0,FALSE,TRUE); + } + self->current = rl; + } + break; + } + return self; + } + + struct view * mbuttonv__Hit(self, type, x, y, numberOfClicks) + struct mbuttonv * self; + enum view_MouseAction type; + long x, y, numberOfClicks; + {/* should probably just restore this functionality to valueview, + with a way to optionly set it */ + register short sendEvent; + struct valueview *vself = (struct valueview *) self; + if (vself->active) + { + switch (type) + { + case view_NoMouseEvent: + sendEvent = FALSE; + break; + case view_LeftDown: + vself->mouseState = valueview_LeftIsDown; + mbuttonv_Highlight(self); + sendEvent = TRUE; + self->movedoff = FALSE; + break; + case view_RightDown: + vself->mouseState = valueview_RightIsDown; + mbuttonv_Highlight(self); + sendEvent = TRUE; + self->movedoff = FALSE; + break; + case view_LeftUp: + case view_RightUp: + if(self->movedoff) sendEvent = FALSE; + else if (vself->mouseIsOnTarget) + { + mbuttonv_Dehighlight(self); + sendEvent = TRUE; + } + else sendEvent = TRUE; + break; + case view_LeftMovement: + case view_RightMovement: + if(self->movedoff) sendEvent = FALSE; + else if(mbuttonv_OnTarget(self,x,y)) + { + mbuttonv_Highlight(self); + sendEvent = TRUE; + } + else + { + mbuttonv_Dehighlight(self); + self->movedoff = TRUE; + if(self->valueset) sendEvent = FALSE; + else + sendEvent = TRUE; + + } + break; + } + } + else + sendEvent = FALSE; + if (sendEvent){ + return (struct view *) mbuttonv_DoHit(self, type, x, y, numberOfClicks); + } + else + return (struct view *) self; + } *** atk/value/checkv.c Thu May 30 20:21:28 1991 --- atk/value/checkv.c.NEW Tue Jan 22 14:28:08 1991 *************** *** 0 **** --- 1,254 ---- + /* ********************************************************************** *\ + * 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/value/RCS/checkv.c,v 1.1 91/01/21 17:32:34 gk5g Exp $ */ + /* $ACIS: $ */ + /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/value/RCS/checkv.c,v $ */ + + #ifndef lint + static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/value/RCS/checkv.c,v 1.1 91/01/21 17:32:34 gk5g Exp $ "; + #endif /* lint */ + + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + static struct atomlist * AL_bodyfont; + static struct atomlist * AL_bodyfont_size; + static struct atomlist * AL_label; + static struct atomlist * AL_checktype; + + static struct atom * A_long; + static struct atom * A_string; + + #define InternAtoms ( \ + AL_bodyfont = atomlist_StringToAtomlist("bodyfont") ,\ + AL_bodyfont_size = atomlist_StringToAtomlist("bodyfont-size") ,\ + AL_label = atomlist_StringToAtomlist("label") ,\ + AL_checktype = atomlist_StringToAtomlist("checktype") ,\ + A_long = atom_Intern("long") ,\ + A_string = atom_Intern("string") ) + + + #define Min(X,Y) ((X) < (Y) ? (X) : (Y)) + #define FUDGE 2 + + + /****************************************************************/ + /* private functions */ + /****************************************************************/ + + static void CarveFonts(self) + struct checkv * self; + { + self->normalfont = fontdesc_Create( self->fontname, fontdesc_Plain, self->fontsize ); + } + + static Drawcheck(self) + struct checkv * self; + { + register int side; + register int gap; + struct rectangle r; + char ch; + checkv_SetTransferMode( self, graphic_COPY ); + + if (!self->BlackPattern) + self->BlackPattern = checkv_BlackPattern(self); + side = Min(self->width, self->height); + gap = FUDGE; + side = side - (gap*2) + 1; + checkv_EraseRectSize( self,self->x,self->y,self->width,self->height); + checkv_SetTransferMode( self, graphic_BLACK ); + checkv_MoveTo(self, self->x + gap, self->y + gap); + + /* Box */ + checkv_DrawLineTo(self, self->x + gap, self->y + side); + checkv_DrawLineTo(self, self->x + side, self->y + side); + checkv_DrawLineTo(self, self->x + side, self->y + gap); + checkv_DrawLineTo(self, self->x + gap, self->y + gap); + + /* Check */ + if (self->tmpval) + switch(self->checktype) { + case 2: /* Solid */ + r.top = self->y + gap*2; + r.left = self->x + gap*2; + r.width = side - gap*2 - 1; + r.height = side - gap*2 - 1; + checkv_SetTransferMode( self, graphic_COPY ); + checkv_FillRect(self, &r, self->BlackPattern); + break; + default: /* Cross */ + checkv_DrawLineTo(self, self->x + side, self->y + side); + checkv_MoveTo(self, self->x + gap, self->y +side); + checkv_DrawLineTo(self, self->x + side, self->y + gap); + break; + } + + if(self->label){ + checkv_MoveTo(self, self->x + side + gap*2, self->y + (side+gap)/2); + checkv_SetFont(self, self->normalfont); + checkv_DrawString(self,self->label,graphic_ATLEFT | graphic_BETWEENTOPANDBASELINE); + } + } + + + + /****************************************************************/ + /* class procedures */ + /****************************************************************/ + + + + + boolean checkv__InitializeClass(classID) + struct classheader *classID; + { + InternAtoms; + return TRUE; + } + + + #define BADVAL -22222 + /****************************************************************/ + /* instance methods */ + /****************************************************************/ + boolean checkv__InitializeObject(classID, self ) + struct classheader *classID; + struct checkv * self; + { + self->label = NULL; + self->fontname = NULL; + self->fontsize = 0; + self->tmpval = BADVAL; + self->BlackPattern = NULL; + return TRUE; + } + + void checkv__LookupParameters(self) + struct checkv * self; + { + char * fontname; + long fontsize; + struct resourceList parameters[5]; + + parameters[0].name = AL_label; + parameters[0].type = A_string; + parameters[1].name = AL_bodyfont; + parameters[1].type = A_string; + parameters[2].name = AL_bodyfont_size; + parameters[2].type = A_long; + parameters[3].name = AL_checktype; + parameters[3].type = A_long; + parameters[4].name = NULL; + parameters[4].type = NULL; + + checkv_GetManyParameters(self, parameters, NULL, NULL); + + if (parameters[0].found) + self->label = (char *)parameters[0].data; + else + self->label = NULL ; + + if (parameters[1].found) + fontname = (char *)parameters[1].data; + else + fontname = "andysansb"; + + if (parameters[2].found) + fontsize = parameters[2].data; + else + fontsize = 10; + + if (parameters[3].found) + self->checktype = (short) parameters[3].data; + else + self->checktype = 1; + + if (fontsize != self->fontsize || fontname != self->fontname) + { + self->fontsize = fontsize; + self->fontname = fontname; + CarveFonts(self); + } + } + + + void checkv__DrawFromScratch(self,x,y,width,height) + struct checkv * self; + long x,y,width,height; + { + self->x = x; + self->y = y; + self->width = width; + self->height = height; + if (width > 0 && height > 0) + { + struct value *w = checkv_Value(self); + if(self->tmpval == BADVAL){ + self->tmpval = value_GetValue(w); + } + Drawcheck(self); + } + } + + + void checkv__DrawDehighlight(self) + struct checkv * self; + { + + struct value *w = checkv_Value(self); + self->tmpval = value_GetValue(w); + Drawcheck(self); + + } + + void checkv__DrawHighlight(self) + struct checkv * self; + { + } + + + void checkv__DrawNewValue( self ) + struct checkv * self; + { + struct value *w = checkv_Value(self); + self->tmpval = value_GetValue(w); + Drawcheck(self); + } + + + + struct checkv * checkv__DoHit( self,type,x,y,hits ) + struct checkv * self; + enum view_MouseAction type; + long x,y,hits; + { + struct value *tt = checkv_Value(self); + switch(type){ + case view_LeftDown: + self->tmpval = !value_GetValue(tt); + Drawcheck(self); + break; + case view_LeftUp: + value_SetValue(tt,self->tmpval); + break; + } + + return self; + } + + + + + *** atk/value/checkv.ch Thu May 30 20:21:37 1991 --- atk/value/checkv.ch.NEW Tue Jan 22 14:28:09 1991 *************** *** 0 **** --- 1,27 ---- + #include + #include + + class checkv[checkv] : valueview[valuev] + { + overrides: + DrawFromScratch(long x,y,width,height); + DrawHighlight(); + DrawDehighlight(); + DrawNewValue(); + DoHit(enum view_MouseAction type, long x,y,hits) + returns struct checkv *; + LookupParameters(); + macromethods: + GetTmpVal() (self->tmpval) + classprocedures: + InitializeClass() returns boolean; + data: + char *label; + char *fontname; + struct fontdesc *normalfont; + struct graphic *BlackPattern; + short fontsize; + long tmpval; + short checktype; + long x,y,width,height; + }; *** atk/value/mbuttonv.ch Thu May 30 20:21:48 1991 --- atk/value/mbuttonv.ch.NEW Tue May 7 12:51:39 1991 *************** *** 0 **** --- 1,53 ---- + /* ********************************************************************** *\ + * 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/value/RCS/mbuttonv.ch,v 1.1 1991/05/07 15:42:46 tpn Exp $ */ + /* $ACIS: $ */ + /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/value/RCS/mbuttonv.ch,v $ */ + #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) + static char *rcsid_mbuttonv_H = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/value/RCS/mbuttonv.ch,v 1.1 1991/05/07 15:42:46 tpn Exp $ "; + #endif /* !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) */ + + #include + #define mbuttonv_NONE 0 + #define mbuttonv_SURROUND 1 + #define mbuttonv_ADJACENT 2 + #define mbuttonv_EITHER 3 + class mbuttonv[mbuttonv] : valueview[valuev] + { + overrides: + Hit(enum view_MouseAction type, long x, long y, long numberOfClicks) + returns struct view *; + DrawFromScratch(long x,y,width,height); + DrawHighlight(); + DrawDehighlight(); + DrawNewValue(); + DoHit(enum view_MouseAction type, long x,y,hits) + returns struct mbuttonv *; + LookupParameters(); + classprocedures: + InitializeClass() returns boolean; + macromethods: + SetButtonType(TYPE) (self->buttontype = TYPE) + GetButtonType() (self->buttontype) + data: + char * label; + char * fontname; + short fontsize; + short buttontype; + short count; + long max,rtl,rhw,x,y; + struct fontdesc * activefont; + double foreground_color[3], background_color[3]; + boolean pushed,mono,valueset,movedoff,vertical; + struct FontSummary *FontSummary; + struct list *list; + struct mbuttonv_rl *current; + }; + + /* parameters to spst + label string Defaults to NULL + bodyfont string Defaults to "andytype" + bodyfont-size long Defaults to 10 + */ *** atk/zip/lib/Imakefile Wed Nov 22 12:40:45 1989 --- atk/zip/lib/Imakefile.NEW Wed Apr 10 16:22:45 1991 *************** *** 63,69 **** DynamicMultiObject(zip.do, zip.o zipd000.o zipdf00.o zipdf01.o zipdi00.o zipds00.o zipds01.o zipds02.o, , -lm) DynamicMultiObject(zipv.do, zipv.o zipv000.o zipvf00.o zipvi00.o zipvs00.o zipvp00.o zipvp01.o zipvp02.o zipvp03.o, , -lm) ! DynamicMultiObject(zipedit.do, zipedit.o zipve00.o zipve01.o zipve02.o zipve03.o, , -lm) DynamicMultiObject(zipprint.do, zipprint.o zipvr00.o, , -lm) DynamicObject(zipstat, , -lm) DynamicObject(zipobj, , -lm) --- 63,69 ---- DynamicMultiObject(zip.do, zip.o zipd000.o zipdf00.o zipdf01.o zipdi00.o zipds00.o zipds01.o zipds02.o, , -lm) DynamicMultiObject(zipv.do, zipv.o zipv000.o zipvf00.o zipvi00.o zipvs00.o zipvp00.o zipvp01.o zipvp02.o zipvp03.o, , -lm) ! DynamicMultiObject(zipedit.do, zipedit.o zipve00.o zipve01.o zipve02.o zipve03.o, , -lm ${SUPLIBS}) DynamicMultiObject(zipprint.do, zipprint.o zipvr00.o, , -lm) DynamicObject(zipstat, , -lm) DynamicObject(zipobj, , -lm) *************** *** 70,76 **** DynamicObject(zipocapt, , -lm) DynamicObject(ziporect, , -lm) DynamicObject(ziporang, , -lm) ! DynamicObject(ziposym, , -lm) DynamicObject(zipocirc, , -lm) DynamicObject(zipoelli, ,-lm) DynamicObject(zipotrap, , -lm) --- 70,76 ---- DynamicObject(zipocapt, , -lm) DynamicObject(ziporect, , -lm) DynamicObject(ziporang, , -lm) ! DynamicObject(ziposym, , -lm ${SUPLIBS}) DynamicObject(zipocirc, , -lm) DynamicObject(zipoelli, ,-lm) DynamicObject(zipotrap, , -lm) *** atk/zip/lib/ziposym.c Wed Jan 17 16:39:20 1990 --- atk/zip/lib/ziposym.c.NEW Mon Jun 10 14:05:25 1991 *************** *** 6,12 **** /* Author TC Peters */ /* Information Technology Center Carnegie-Mellon University */ ! static char rcsid[] = "$Header: /afs/.andrew.cmu.edu/itc/src/andrew/atk/zip/lib/RCS/ziposym.c,v 2.19 89/11/20 12:51:16 gk5g Exp $"; /** SPECIFICATION -- Internal Facility Suite ********************************* --- 6,12 ---- /* Author TC Peters */ /* Information Technology Center Carnegie-Mellon University */ ! static char rcsid[] = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/zip/lib/RCS/ziposym.c,v 2.21 1991/06/10 17:31:39 gk5g Exp $"; /** SPECIFICATION -- Internal Facility Suite ********************************* *************** *** 46,52 **** #include #include ! extern long sys_nerr; extern char *sys_errlist[]; static char *symbol_library_path = NULL; --- 46,54 ---- #include #include ! #ifndef M_UNIX ! extern int sys_nerr; ! #endif extern char *sys_errlist[]; static char *symbol_library_path = NULL; *** atk/zip/lib/zipvp00.c Wed Nov 22 12:40:47 1989 --- atk/zip/lib/zipvp00.c.NEW Mon Mar 4 13:49:20 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/zip/lib/RCS/zipvp00.c,v 2.10 89/06/14 17:46:39 sg08 Exp $ */ ! /* $Source: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/zip/lib/RCS/zipvp00.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/zip/lib/RCS/zipvp00.c,v 2.10 89/06/14 17:46:39 sg08 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/zip/lib/RCS/zipvp00.c,v 2.10 89/06/14 17:46:39 sg08 Exp Locker: sg08 $ */ ! /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/zip/lib/RCS/zipvp00.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/zip/lib/RCS/zipvp00.c,v 2.10 89/06/14 17:46:39 sg08 Exp Locker: sg08 $"; #endif /* lint */ /* *** atk/zip/utility/ltapp.c Fri Dec 21 15:00:06 1990 --- atk/zip/utility/ltapp.c.NEW Tue Dec 4 09:02:49 1990 *************** *** 1,3 **** --- 1,4 ---- + #include #include #include #include *************** *** 12,18 **** #include #include #include - #include #include --- 13,18 ---- *** atk/zip/utility/schedapp.c Fri Dec 21 15:00:08 1990 --- atk/zip/utility/schedapp.c.NEW Tue Dec 4 09:02:51 1990 *************** *** 1,4 **** --- 1,5 ---- + #include #include #include #include *************** *** 10,16 **** #include #include #include - #include #include --- 11,16 ---- *** atkams/messages/cmd/Imakefile Wed Nov 22 12:42:39 1989 --- atkams/messages/cmd/Imakefile.NEW Wed Apr 10 16:22:58 1991 *************** *** 8,14 **** DeclareFont(msgs10) DeclareFont(msgs14) - TEMPLATE = messages.tpl T_DIR = lib/tpls --- 8,13 ---- *** atkams/messages/doc/folders.help Wed Nov 22 12:42:48 1989 --- atkams/messages/doc/folders.help.NEW Thu Apr 25 16:18:40 1991 *************** *** 1,4 **** ! \begindata{text,268743956} \textdsversion{12} \template{help} \chapter{Manipulating Message folders --- 1,4 ---- ! \begindata{text,269247192} \textdsversion{12} \template{help} \chapter{Manipulating Message folders *************** *** 136,143 **** Once you have marked some messages by right clicking on their captions, you can manipulate the marked messages from the \italic{Marked Messages} pop-up ! menu. To file marked messages, use the \bold{File All Into} menu option from ! the \italic{Marked Messages} menu. Messages prompts you for a folder name. Notice that you can not mark messages across folders. Once you select another --- 136,146 ---- Once you have marked some messages by right clicking on their captions, you can manipulate the marked messages from the \italic{Marked Messages} pop-up ! menu. You can also mark several messages at once by clicking and dragging ! with the right mouse button. Messages that are already marked are left marked ! if you do this. To file marked messages, use the \bold{File All Into} menu ! option from the \italic{Marked Messages} menu. Messages prompts you for a ! folder name. Notice that you can not mark messages across folders. Once you select another *************** *** 192,195 **** SendMessage VUI\ ! }}\enddata{text,268743956} --- 195,198 ---- SendMessage VUI\ ! }}\enddata{text,269247192} *** atkams/messages/doc/msgs.help Wed Nov 22 12:42:45 1989 --- atkams/messages/doc/msgs.help.NEW Thu Apr 25 16:18:45 1991 *************** *** 1,4 **** ! \begindata{text,268781080} \textdsversion{12} \template{help} \define{index --- 1,4 ---- ! \begindata{text,268700724} \textdsversion{12} \template{help} \define{index *************** *** 96,105 **** }\section{The first time you use Messages }\leftindent{ ! The first time you use Messages, your Messages window is divided into three ! horizontal scrollable regions. In the top region is the "folder" you are ! subscribed to which has new messages. When you start Messages, the first folder with new messages (in this case, your mail folder) is automatically selected. When a folder is "selected" it --- 96,109 ---- }\section{The first time you use Messages }\leftindent{ ! Upon startup of Messages, the folders area gives the program version number, ! description and lists the program authors. Also, the captions area is ! initialized with the /etc/motd file. ! + The first time you use Messages, your Messages window is divided into three + horizontal scrollable regions. After initialization, the top region is the + "folder" you are subscribed to which has new messages. When you start Messages, the first folder with new messages (in this case, your mail folder) is automatically selected. When a folder is "selected" it *************** *** 295,301 **** --right clicking on a caption marks a single message --dragging over a number of captions while holding down the right button marks ! the messages you drag over Once you have marked messages, you can use the addition Marked Message Menu --- 299,306 ---- --right clicking on a caption marks a single message --dragging over a number of captions while holding down the right button marks ! the messages you drag over. Messages that are already marked are left marked ! if you do this. Once you have marked messages, you can use the addition Marked Message Menu *************** *** 320,328 **** \italic{Right} clicking on the Punt button \italic{only} moves the underline ! icon down below the last message. It does not move you on to the next folder.}} \section{Preferences and Options } --- 325,339 ---- \italic{Right} clicking on the Punt button \italic{only} moves the underline ! icon down below the last message. It does not move you on to the next folder. ! + }}\indent{When the folders area is very narrow, the Punt/Commit buttons should + be on the top. This is automatically adjusting, with a preference to set the + threshold for the adjustment. You can alter the threshold by using \bold{Set + Options} on the \italic{Other }menu card. } + \section{Preferences and Options } *************** *** 420,429 **** \bold{Set Options:} Brings up list of options with switches to set them in ! the body region of the Messages window. In the captions region is a click ! list of the options; clicking on an option in the captions region scrolls the ! body region to that option. See the \italic{messages-customization} help ! document for descriptions of the options. \bold{Set Printer:} Prompts you for a printer name in the message line at the --- 431,442 ---- \bold{Set Options:} Brings up list of options with switches to set them in ! the body region of the Messages window. In the captions region is a list of ! switches of the options. A click list appears in the captions region to let ! you move easily within the list of options. Clicking on an option in the ! captions region scrolls the body region to that option. See the ! \italic{messages-customization} help document for descriptions of the ! options. \bold{Set Printer:} Prompts you for a printer name in the message line at the *************** *** 462,470 **** search is successful, Messages scrolls to display and highlight the item that is matched. ! } ! \italic{Message Folders}\italic{\italic{ }Menu Card}\bold{ } \leftindent{\bold{Expose Changed:} Exposes a list of the folders to which you are subscribed which have new messages in them since you last used Messages. --- 475,493 ---- search is successful, Messages scrolls to display and highlight the item that is matched. ! ! \bold{Body Forward:} Searches the currently selected message forward (i.e. - ! down). If the search is successful, Messages scrolls to display and ! highlight the region that is matched. + + \bold{Body Backward:} Searches the currently selected message backward (i.e. + - up). If the search is successful, Messages scrolls to display and + highlight the region that is matched. + + + }\italic{Message Folders}\italic{\italic{ }Menu Card}\bold{ + } \leftindent{\bold{Expose Changed:} Exposes a list of the folders to which you are subscribed which have new messages in them since you last used Messages. *************** *** 578,584 **** filenames. If the file you specify already exists, Messages appends the displayed message to it. If the file does not exist, Messages creates it. The initial default file is "~/SavedMessages". After the first time you use ! this command, the default is whatever file to which you last appended. \bold{Descramble:} (this menu option does not appear unless you have turned it --- 601,610 ---- filenames. If the file you specify already exists, Messages appends the displayed message to it. If the file does not exist, Messages creates it. The initial default file is "~/SavedMessages". After the first time you use ! this command, the default is whatever file to which you last appended. You ! can append more than one message to a file, as long as the file is made up of ! other messages. Appending a message to a file containing anything other than ! previously appended messages is not recommended. \bold{Descramble:} (this menu option does not appear unless you have turned it *************** *** 685,691 **** all old marks before beginning the search. ! \bold{Find Related Messages: } (This menu option only shows up when you have a message on display.) Searches through all the captions in the currently selected folder, marking all the messages which are part of the same in-reply-to/references chain as the displayed message. --- 711,717 ---- all old marks before beginning the search. ! \bold{Mark Related Messages: } (This menu option only shows up when you have a message on display.) Searches through all the captions in the currently selected folder, marking all the messages which are part of the same in-reply-to/references chain as the displayed message. *************** *** 803,809 **** \bold{Append to Folder:} Appends all marked messages to a file you specify by placing them at the very end of the folder, instead of placing them in the ! folder by date.} \italic{Other Menu Card} --- 829,838 ---- \bold{Append to Folder:} Appends all marked messages to a file you specify by placing them at the very end of the folder, instead of placing them in the ! folder by date. ! ! ! \bold{Append to File: } Appends all marked messages to a file you specify. } \italic{Other Menu Card} *************** *** 893,896 **** } } ! \enddata{text,268781080} --- 922,925 ---- } } ! \enddata{text,268700724} *** atkams/messages/doc/sendmsg.help Wed Nov 22 12:42:53 1989 --- atkams/messages/doc/sendmsg.help.NEW Thu Apr 25 16:18:48 1991 *************** *** 1,4 **** ! \begindata{text,268972052} \textdsversion{12} \template{help} \chapter{SendMessage 7.0: --- 1,4 ---- ! \begindata{text,268995396} \textdsversion{12} \template{help} \chapter{SendMessage 7.0: *************** *** 386,399 **** "Won't Hide" toggles with "Will Hide." This button tells whether or not the ! SendMessage window will be hidden after your message is delivered. The ! Messages window also expands out to fill the screen after the SendMessage ! window hides. "Won't Sign" toggles with "Will Sign." This button tells whether or not the contents of ~/.signature will be appended to your message before it is ! delivered. "Reset" button, in addition to clearing the window, resets the other buttons --- 386,401 ---- "Won't Hide" toggles with "Will Hide." This button tells whether or not the ! SendMessage window will be hidden after your message is delivered. You can ! choose \bold{Set Options} from the \italic{Other} menu card to have the ! Messages window expand out to fill the screen after the SendMessage window ! hides. "Won't Sign" toggles with "Will Sign." This button tells whether or not the contents of ~/.signature will be appended to your message before it is ! delivered. You can choose \bold{Set Options} from the \italic{Other} menu ! card to change its default value from "Won't" to "Will". "Reset" button, in addition to clearing the window, resets the other buttons *************** *** 778,781 **** white-pages} } ! \enddata{text,268972052} --- 780,783 ---- white-pages} } ! \enddata{text,268995396} *** atkams/messages/lib/Imakefile Thu Jan 10 14:58:03 1991 --- atkams/messages/lib/Imakefile.NEW Wed Apr 3 21:23:34 1991 *************** *** 52,71 **** NormalObjectRule() NormalATKRule() DynamicObject(msgsa,,) ! DynamicMultiObject(captions.do, captions.o capaux.o,,) ! DynamicMultiObject(folders.do, folders.o foldaux.o,,) ! DynamicMultiObject(sendmsg.do, sendmsg.o sendaux.o,,) DynamicMultiObject(messages.do, messages.o messaux.o,,) DynamicObject(text822,,) DynamicObject(text822v,,) ! DynamicObject(amsutil, ${LIBS},) DynamicObject(ams, ${UTILLIB},) DynamicObject(options,,) DynamicObject(messwind,,) ! DynamicMultiObject(amsn.do, amsn.o stubs.o, ${NLIBS},) #ifdef SNAP_ENV ! DynamicMultiObject(amss.do, amss.o stubs.o, ${SLIBS},) #endif /* SNAP_ENV */ DependTarget() --- 52,75 ---- NormalObjectRule() NormalATKRule() DynamicObject(msgsa,,) ! DynamicMultiObject(captions.do, captions.o capaux.o,,${NETLIBS} ${SUPLIBS}) ! DynamicMultiObject(folders.do, folders.o foldaux.o,,${SUPLIBS}) ! DynamicMultiObject(sendmsg.do, sendmsg.o sendaux.o,,${SUPLIBS}) DynamicMultiObject(messages.do, messages.o messaux.o,,) DynamicObject(text822,,) DynamicObject(text822v,,) ! DynamicObject(amsutil, ${LIBS},${NETLIBS}) DynamicObject(ams, ${UTILLIB},) DynamicObject(options,,) DynamicObject(messwind,,) ! #ifdef USE_MMDF_ENV ! DynamicMultiObject(amsn.do, amsn.o stubs.o, ${NLIBS},${NETLIBS} ${SUPLIBS} ${MMDFLIBS}) ! #else ! DynamicMultiObject(amsn.do, amsn.o stubs.o, ${NLIBS},${NETLIBS} ${SUPLIBS}) ! #endif #ifdef SNAP_ENV ! DynamicMultiObject(amss.do, amss.o stubs.o, ${SLIBS},${NETLIBS} ${SUPLIBS}) #endif /* SNAP_ENV */ DependTarget() *** atkams/messages/lib/capaux.c Fri Dec 21 15:00:34 1990 --- atkams/messages/lib/capaux.c.NEW Sat Apr 27 02:06: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/atkams/messages/lib/RCS/capaux.c,v 1.16 90/09/24 14:14:31 gk5g Exp $ */ /* $ACIS: $ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atkams/messages/lib/RCS/capaux.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atkams/messages/lib/RCS/capaux.c,v 1.16 90/09/24 14:14:31 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/atkams/messages/lib/RCS/capaux.c,v 1.22 1991/04/27 06:00:22 gk5g Exp $ */ /* $ACIS: $ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atkams/messages/lib/RCS/capaux.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atkams/messages/lib/RCS/capaux.c,v 1.22 1991/04/27 06:00:22 gk5g Exp $ "; #endif /* lint */ #include *************** *** 14,215 **** #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 - #undef AUXMODULE - - - extern void PreviousCaptionLine(), CapScrollBack(), CapGlitchDown(), CapBeginText(), captions__SimulateClick(), SimulateLeftClick(), SimulateRightClick(); - - extern char *index(); - - static struct keymap *captions_privkeymap; - static struct menulist *captions_privmenulist; - - extern char *GetLastResendName(); - - extern int (*textview_PreviousLineCmd)(), - (*textview_ReverseSearchCmd)(), - (*textview_ScrollScreenFwdCmd)(), - (*textview_ScrollScreenBackCmd)(), - (*textview_BeginningOfTextCmd)(), - (*textview_BeginningOfLineCmd)(), - (*textview_EndOfLineCmd)(), - (*textview_GlitchDownCmd)(); - - boolean captions__InitializeObject(c, captions) - struct classheader *c; - struct captions *captions; - { - char *fontname; - int fontsize, mailfontbloat = (amsutil_GetOptBit(EXP_WHITESPACE)) ? 2 : 0; - - captions_SetWhatIAm(captions, WHATIAM_CAPTIONS); - InitKeysMenus(captions); - captions->CommentText = NULL; - captions->myframe = NULL; - captions->MenusExpanded = FALSE; - captions->mycursor = NULL; - captions->MarkCount = 0; - captions->FolderSize = captions->FetchedFromStart = captions->FetchedFromEnd = 0; - - captions->CaptText = text_New(); - captions_SetDataObject(captions, captions->CaptText); - captions->textscrollinterface = (struct scrollfns *) super_GetInterface(captions, "scroll,vertical"); - - captions->ActiveCaptionStyle = style_New(); - captions->ActiveDeletedStyle = style_New(); - captions->DeletedStyle = style_New(); - captions->FixedStyle = style_New(); - captions->GlobalCapStyle = style_New(); - captions->HighlightStyle = style_New(); - captions->IconicStyle = style_New(); - captions->UnderlinedIconicStyle = style_New(); - captions->MailStyle = style_New(); - captions->NormalCaptionStyle = style_New(); - - style_AddNewFontFace(captions->FixedStyle, (long) fontdesc_Fixed); - style_AddNewFontFace(captions->HighlightStyle, (long) fontdesc_Italic); - style_SetFontFamily(captions->FixedStyle, "andytype"); - style_SetFontFamily(captions->IconicStyle, "msgs"); - style_SetFontFamily(captions->UnderlinedIconicStyle, "msgs"); - style_SetFontSize(captions->IconicStyle, style_ConstantFontSize, 10); - style_SetFontSize(captions->UnderlinedIconicStyle, style_ConstantFontSize, 10); - style_SetFontSize(captions->MailStyle, style_PreviousFontSize, mailfontbloat); - style_SetJustification(captions->GlobalCapStyle, style_LeftJustified); - style_SetJustification(captions->HighlightStyle, style_LeftJustified); - style_SetName(captions->FixedStyle, "Typewriter"); - style_SetNewIndentation(captions->ActiveCaptionStyle, style_ConstantMargin, -10, style_RawDots); - style_SetNewIndentation(captions->ActiveDeletedStyle, style_ConstantMargin, -10, style_RawDots); - style_SetNewIndentation(captions->GlobalCapStyle, style_ConstantMargin, -10, style_RawDots); - style_SetNewInterlineSpacing(captions->GlobalCapStyle, style_ConstantSpacing,10, style_RawDots); - style_SetNewLeftMargin(captions->ActiveCaptionStyle, style_ConstantMargin, 20, style_RawDots); - style_SetNewLeftMargin(captions->ActiveDeletedStyle, style_ConstantMargin, 20, style_RawDots); - style_SetNewLeftMargin(captions->GlobalCapStyle, style_ConstantMargin, 20, style_RawDots); - style_AddFlag(captions->UnderlinedIconicStyle, style_Underline); - if (amsutil_GetOptBit(EXP_FIXCAPTIONS)) { - style_AddNewFontFace(captions->ActiveCaptionStyle, (long) fontdesc_Bold | fontdesc_Fixed); - style_AddNewFontFace(captions->ActiveDeletedStyle, (long) fontdesc_Bold | fontdesc_Fixed); - style_AddNewFontFace(captions->DeletedStyle, (long) fontdesc_Fixed); - style_AddNewFontFace(captions->GlobalCapStyle, (long) fontdesc_Fixed); - style_AddNewFontFace(captions->HighlightStyle, (long) fontdesc_Fixed); - style_AddNewFontFace(captions->MailStyle, (long) fontdesc_Fixed); - style_AddNewFontFace(captions->NormalCaptionStyle, (long) fontdesc_Fixed); - } else { - style_AddNewFontFace(captions->ActiveCaptionStyle, (long) fontdesc_Bold); - style_AddNewFontFace(captions->ActiveDeletedStyle, (long) fontdesc_Bold); - } - text_SetGlobalStyle(captions->CaptText, captions->GlobalCapStyle); - - captions->SouthPoint = NULL; ! captions->VisibleCUID = -1; ! bzero(captions->VisibleSnapshot, AMS_SNAPSHOTSIZE); ! captions->HighlightStartPos = 0; ! captions->HighlightLen = 0; ! captions->HighlightEnv = NULL; ! captions->OldMarkCount = 0; ! captions->OldMarks = NULL; ! captions->capcache = (struct CaptionCache *) malloc(25 *sizeof(struct CaptionCache)); ! captions->captioncachesize = 25; ! captions->captioncachecount = 0; ! captions->FullName = NULL; ! captions->ShortName = NULL; ! captions->firstcuid = -1; ! ams_AddCheckpointCaption(captions); ! ! captions->myfold = NULL; ! ! fontsize = environ_GetProfileInt("messages.fontsize", 12); ! style_SetFontSize(captions->DeletedStyle, style_ConstantFontSize, fontsize - 4); ! style_SetFontSize(captions->ActiveDeletedStyle, style_ConstantFontSize, fontsize - 4); ! style_SetFontSize(captions->GlobalCapStyle, style_ConstantFontSize, fontsize); ! ! fontname = amsutil_GetDefaultFontName(); ! if (amsutil_GetOptBit(EXP_FIXCAPTIONS)) fontname = "andytype"; ! style_SetFontFamily(captions->ActiveCaptionStyle, fontname); ! style_SetFontFamily(captions->ActiveDeletedStyle, fontname); ! style_SetFontFamily(captions->DeletedStyle, fontname); ! style_SetFontFamily(captions->GlobalCapStyle, fontname); ! style_SetFontFamily(captions->HighlightStyle, fontname); ! style_SetFontFamily(captions->MailStyle, fontname); ! style_SetFontFamily(captions->NormalCaptionStyle, fontname); ! ! captions->BodView = NULL; ! ! captions_ShowHelp(captions); ! text_SetReadOnly(captions->CaptText, TRUE); ! return(TRUE); ! } ! ! void captions__FinalizeObject(c, self) ! struct classheader *c; ! struct captions *self; ! { ! ams_RemoveCheckpointCaption(self); ! text_Destroy(self->CaptText); ! if (self->CommentText) { ! free(self->CommentText); ! self->CommentText = NULL; ! } ! if (self->myfold) { ! folders_SetCaptions(self->myfold, NULL); ! } ! if (self->BodView) { ! t822view_SetCaptions(self->BodView, NULL); ! } ! style_Destroy(self->ActiveCaptionStyle); ! style_Destroy(self->NormalCaptionStyle); ! style_Destroy(self->HighlightStyle); ! style_Destroy(self->GlobalCapStyle); ! style_Destroy(self->DeletedStyle); ! style_Destroy(self->ActiveDeletedStyle); ! style_Destroy(self->IconicStyle); ! style_Destroy(self->UnderlinedIconicStyle); ! style_Destroy(self->MailStyle); ! style_Destroy(self->FixedStyle); ! FinalizeProcStuff(self); ! if (self->OldMarks) { ! free(self->OldMarks); ! self->OldMarks = NULL; ! } ! if (self->capcache) { ! free(self->capcache); ! self->capcache = NULL; ! } ! if (self->FullName) { ! free(self->FullName); ! self->FullName = NULL; ! } ! if (self->ShortName) { ! free(self->ShortName); ! self->ShortName = NULL; ! } ! } void CaptionsCompound(self, cmds) struct captions *self; --- 14,45 ---- #include #include #include ! #include ! #include ! #include ! #include ! #include #include #include ! #include #include ! #include ! #include #include #include #include #define AUXMODULE 1 #include ! extern int (*textv_PreviousLineCmd)(), ! (*textv_ReverseSearchCmd)(), ! (*textv_ScrollScreenFwdCmd)(), ! (*textv_ScrollScreenBackCmd)(), ! (*textv_BeginningOfTextCmd)(), ! (*textv_BeginningOfLineCmd)(), ! (*textv_GlitchDownCmd)(); void CaptionsCompound(self, cmds) struct captions *self; *************** *** 239,251 **** ams_GenericCompoundAction(ams_GetAMS(), captions_GetBodView(self), "t822view", cmds); } ! static void DownFocus(self) struct captions *self; { ams_Focus(captions_GetBodView(self)); } ! static void UpFocus(self) struct captions *self; { ams_Focus(captions_GetFolders(self)); --- 69,81 ---- ams_GenericCompoundAction(ams_GetAMS(), captions_GetBodView(self), "t822view", cmds); } ! void DownFocus(self) struct captions *self; { ams_Focus(captions_GetBodView(self)); } ! void UpFocus(self) struct captions *self; { ams_Focus(captions_GetFolders(self)); *************** *** 279,629 **** ams_WaitCursor(FALSE); } ! static struct bind_Description privbindings [] = { ! {"captions-previous-caption", "\020", NULL, NULL, 0, NULL, PreviousCaptionLine, "Go to previous caption"}, ! {"captions-scroll-back", "\033v", NULL, NULL, NULL, 0, CapScrollBack, "Scroll back captions"}, ! {"captions-glitch-down", "\033z", NULL, NULL, NULL, 0, CapGlitchDown, "Glitch down captions"}, ! {"captions-glitch-down", "\021", NULL, NULL, NULL, 0, CapGlitchDown, "Glitch down captions"}, ! {"captions-beginning-of-text", "\033<", NULL, NULL, NULL, 0, CapBeginText, "Move to top of captions"}, ! {"captions-left-click-here", "!", TRUE, NULL, NULL, 0, SimulateLeftClick, "Display what I am pointing at"}, ! {"captions-right-click-here", "@", FALSE, NULL, NULL, 0, SimulateRightClick, "Simulate right click on what I am pointing at"}, ! {"captions-compound-operation", NULL, NULL, NULL, NULL, 0, CaptionsCompound, "Execute a compound captions operation"}, ! {"captions-textview-compound", NULL, NULL, NULL, NULL, 0, CaptionsTextviewCommand, "Execute a compound 'textview' operation on the captions"}, ! {"captions-folders-compound", NULL, NULL, NULL, NULL, 0, CaptionsFoldersCommand, "Execute a compound 'folders' operation."}, ! {"captions-bodies-compound", NULL, NULL, NULL, NULL, 0, CaptionsBodiesCommand, "Execute a compound 't822view' operation."}, ! {"captions-down-focus", "\030n", NULL, NULL, NULL, 0, DownFocus, "Move input focus to bodies"}, ! {"captions-up-focus", "\030p", NULL, NULL, NULL, 0, UpFocus, "Move input focus to folders"}, ! {"captions-down-focus", "\030\016", NULL, NULL, NULL, 0, DownFocus, "Move input focus to bodies"}, ! {"captions-up-focus", "\030\020", NULL, NULL, NULL, 0, UpFocus, "Move input focus to folders"}, ! {NULL, "\033~", NULL, NULL, NULL, 0, NULL, NULL, NULL}, /* Preserve read onliness */ ! {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL} ! }; ! InitKeysMenus(captions) ! struct captions *captions; { ! captions->privkeys = keystate_Create(captions, captions_privkeymap); ! captions->privmenus = menulist_DuplicateML(captions_privmenulist, captions); } ! OneTimeInitKeyMenus(c) ! struct classheader *c; { ! struct proctable_Entry *tempProc; ! if ((tempProc = proctable_Lookup("textview-previous-line")) != NULL) { ! textview_PreviousLineCmd = proctable_GetFunction(tempProc); ! } ! if ((tempProc = proctable_Lookup("textview-reverse-search")) != NULL) { ! textview_ReverseSearchCmd = proctable_GetFunction(tempProc); } ! if ((tempProc = proctable_Lookup("textview-next-screen")) != NULL) { ! textview_ScrollScreenFwdCmd = proctable_GetFunction(tempProc); } ! if ((tempProc = proctable_Lookup("textview-prev-screen")) != NULL) { ! textview_ScrollScreenBackCmd = proctable_GetFunction(tempProc); } ! if ((tempProc = proctable_Lookup("textview-beginning-of-text")) != NULL) { ! textview_BeginningOfTextCmd = proctable_GetFunction(tempProc); } ! if ((tempProc = proctable_Lookup("textview-beginning-of-line")) != NULL) { ! textview_BeginningOfLineCmd = proctable_GetFunction(tempProc); } ! if ((tempProc = proctable_Lookup("textview-end-of-line")) != NULL) { ! textview_EndOfLineCmd = proctable_GetFunction(tempProc); } ! if ((tempProc = proctable_Lookup("textview-glitch-down")) != NULL) { ! textview_GlitchDownCmd = proctable_GetFunction(tempProc); } ! captions_privkeymap = keymap_New(); ! captions_privmenulist = menulist_New(); ! bind_BindList(privbindings, captions_privkeymap, captions_privmenulist, c); } ! void captions__PostMenus(self, ml) struct captions *self; - struct menulist *ml; { ! menulist_ClearChain(self->privmenus); ! if (ml) menulist_ChainAfterML(self->privmenus, ml, ml); ! super_PostMenus(self, self->privmenus); } ! void captions__PostKeyState(self, ks) struct captions *self; - struct keystate *ks; { ! self->privkeys->next = NULL; ! if (amsutil_GetOptBit(EXP_KEYSTROKES)) { ! if (ks) keystate_AddAfter(ks, self->privkeys); ! super_PostKeyState(self, self->privkeys); ! } else { ! super_PostKeyState(self, ks); } } ! ClassifyMarkedByName(self, NameGiven) struct captions *self; - char *NameGiven; { ! int code; ! if (*NameGiven == '*') { ! ++NameGiven; ! code = MARKACTION_APPENDBYNAME; ! } else { ! code = MARKACTION_CLASSIFYBYNAME; } ! captions_ActOnMarkedMessages(self, code, NameGiven); } ! captions__ActOnMarkedMessages(ci, Code, GivenName) struct captions *ci; ! int Code; ! char *GivenName; /* Not always supplied */ { ! char ErrorText[256]; ! struct CaptionCache *hc; ! int j, k, resultcode, OpCode, goodct = 0, len; ! Boolean IsActiveCaption, HadDisaster, errct; ! char HeaderBuf[2000]; ! char *HeadAccum = NULL; ! struct sendmessage *sm = NULL; ! if ((ci->MarkCount <= 0) && (Code != MARKACTION_RESTORE)) { ! message_DisplayString(NULL, 10, "There are no marked messages"); ! return; } ! ams_WaitCursor(TRUE); ! HadDisaster = FALSE; ! errct = 0; ! for (j = 0; j < ci->captioncachecount && !HadDisaster; ++j) { ! hc = &ci->capcache[j]; ! if (hc->IsMarked || (Code == MARKACTION_RESTORE)) { ! if (hc->env->data.style == ci->ActiveDeletedStyle || hc->env->data.style == ci->ActiveCaptionStyle) { ! IsActiveCaption = TRUE; } else { ! IsActiveCaption = FALSE; } ! switch(Code) { ! case MARKACTION_APPENDTOFILE: ! if (captions_AppendOneMessageToFile(ci, hc->cuid, GivenName)) { ! errct++; ! HadDisaster = TRUE; ! } else ++goodct; ! break; ! case MARKACTION_CLASSIFYBYNAME: ! case MARKACTION_APPENDBYNAME: ! case MARKACTION_COPYBYNAME: ! if (Code == MARKACTION_APPENDBYNAME) { ! OpCode = hc->MayModify ? MS_CLONE_APPENDDEL : MS_CLONE_APPEND; ! } else if (Code == MARKACTION_COPYBYNAME) { ! OpCode = MS_CLONE_COPY; ! } else { ! OpCode = hc->MayModify ? MS_CLONE_COPYDEL : MS_CLONE_COPY; ! } ! resultcode = ams_CUI_CloneMessage(ams_GetAMS(), hc->cuid, GivenName, OpCode); ! if (resultcode) { ! errct++; ! HadDisaster = TRUE; ! break; ! } ! if (OpCode == MS_CLONE_APPEND || OpCode == MS_CLONE_COPY) { ! ++goodct; ! break; ! } ! /* FALL THROUGH to delete */ ! case MARKACTION_DELETE: ! if (ams_CUI_DeleteMessage(ams_GetAMS(), hc->cuid) == 0) { ! text_SetEnvironmentStyle(ci->CaptText, hc->env, IsActiveCaption ? ci->ActiveDeletedStyle : ci->DeletedStyle); ! if (IsActiveCaption) { ! AMS_SET_ATTRIBUTE(ci->VisibleSnapshot, AMS_ATT_DELETED); ! } ! captions_AlterDeletedIcon(ci, hc->offset, TRUE); ! ++goodct; ! } else { ! ++errct; ! HadDisaster = TRUE; ! /* Errors were reported by cui routine */ ! } ! break; ! case MARKACTION_UNDELETE: ! if (ams_CUI_UndeleteMessage(ams_GetAMS(), hc->cuid) == 0) { ! text_SetEnvironmentStyle(ci->CaptText, hc->env, IsActiveCaption ? ci->ActiveCaptionStyle : ci->NormalCaptionStyle); ! if (IsActiveCaption) { ! AMS_UNSET_ATTRIBUTE(ci->VisibleSnapshot, AMS_ATT_DELETED); ! } ! captions_AlterDeletedIcon(ci, hc->offset, FALSE); ! ++goodct; ! } else { ! ++errct; ! HadDisaster = TRUE; ! /* Errors were reported by cui routine */ ! } ! break; ! case MARKACTION_PRINT: ! if (ams_CUI_PrintBodyFromCUIDWithFlags(ams_GetAMS(), hc->cuid, 0, NULL)) { ! ++errct; ! } else { ! ++goodct; ! } ! /* Errors were reported by cui routine */ ! break; ! case MARKACTION_RESTORE: ! for (k=0; kOldMarkCount; ++k) { ! if (hc->cuid == ci->OldMarks[k] && (!hc->IsMarked)) { ! captions_ToggleMark(ci, hc, hc->offset); ! ++goodct; ! break; ! } ! } ! break; ! case MARKACTION_EXCERPT: ! if (!sm) { ! sm = folders_ExposeSend(captions_GetFolders(ci)); ! if (!sm) return; ! } ! if (j == (ci->captioncachecount - 1)) { ! len = text_GetLength(ci->CaptText) - hc->offset; ! } else { ! len = ci->capcache[j+1].offset - hc->offset; ! } ! captions_DisplayNewBody(ci, hc->cuid, hc->offset, len, hc->env); ! textview_SetDotPosition(sm->BodyTextview, text_GetLength((struct text *) textview_GetDataObject(sm->BodyTextview))); ! sendmessage_QuoteBody(sm); ! ++goodct; ! break; ! case MARKACTION_REPLYALL: ! case MARKACTION_REPLYSENDERS: ! HeaderBuf[0] = '\0'; ! ams_CUI_GetHeaderContents(ams_GetAMS(), hc->cuid, NULL, (Code == MARKACTION_REPLYSENDERS) ? HP_REPLY_TO : HP_ALLREPLY, HeaderBuf, sizeof(HeaderBuf) - 2); ! if (HeadAccum) { ! HeadAccum = realloc(HeadAccum, strlen(HeadAccum) + strlen(HeaderBuf) + 5); ! strcat(HeadAccum, ",\n\t"); ! strcat(HeadAccum, HeaderBuf); ! } else { ! HeadAccum = malloc(1+strlen(HeaderBuf)); ! strcpy(HeadAccum, HeaderBuf); ! } ! ++goodct; ! break; ! case MARKACTION_RESEND: ! if (ams_CUI_ResendMessage(ams_GetAMS(), hc->cuid, GivenName)) { ! HadDisaster = TRUE; ! } else { ! ++goodct; ! } ! break; ! } ! if (HadDisaster) { ! if (ams_GetBooleanFromUser(ams_GetAMS(), "Do you want to continue with the other marked messages", FALSE)) { ! HadDisaster = FALSE; ! } ! } ! } ! } ! if (HeadAccum) { ! if (!sm) { ! sm = folders_ExposeSend(captions_GetFolders(ci)); ! if (!sm) return; ! } ! sendmessage_AddToToHeader(sm, HeadAccum); ! free(HeadAccum); ! HeadAccum = NULL; ! } ! if (errct) { ! char Foobar[100]; ! sprintf(ErrorText, "Errors were encountered on %s ", amsutil_cvEng(errct, 0, 1000)); ! sprintf(Foobar, "of the %s marked messages.", amsutil_cvEng(ci->MarkCount, 0, 1000)); ! strcat(ErrorText, Foobar); ! message_DisplayString(NULL, 50, ErrorText); ! } else { ! switch (Code) { ! case MARKACTION_RESTORE: ! sprintf(ErrorText, "Restored %s old marks.", amsutil_cvEng(goodct, 0, 1000)); ! break; ! case MARKACTION_RESEND: ! sprintf(ErrorText, "Resent %s messages to %s.", amsutil_cvEng(goodct, 0, 1000), GivenName); ! break; ! case MARKACTION_DELETE: ! sprintf(ErrorText, "Deleted %s messages.", amsutil_cvEng(goodct, 0, 1000)); ! break; ! case MARKACTION_UNDELETE: ! sprintf(ErrorText, "Undeleted %s messages.", amsutil_cvEng(goodct, 0, 1000)); ! break; ! case MARKACTION_CLASSIFYBYNAME: ! sprintf(ErrorText, "Classified %s messages into %s.", amsutil_cvEng(goodct, 0, 1000), GivenName); ! break; ! case MARKACTION_PRINT: ! sprintf(ErrorText, "Printed %s messages.", amsutil_cvEng(goodct, 0, 1000)); ! break; ! case MARKACTION_APPENDBYNAME: ! sprintf(ErrorText, "Appended %s messages to folder %s.", amsutil_cvEng(goodct, 0, 1000), GivenName); ! break; ! case MARKACTION_EXCERPT: ! sprintf(ErrorText, "Excerpted %s messages.", amsutil_cvEng(goodct, 0, 1000)); ! break; ! case MARKACTION_REPLYSENDERS: ! sprintf(ErrorText, "Replying to senders of %s messages.", amsutil_cvEng(goodct, 0, 1000)); ! break; ! case MARKACTION_REPLYALL: ! sprintf(ErrorText, "Replying widely to %s messages.", amsutil_cvEng(goodct, 0, 1000)); ! break; ! case MARKACTION_COPYBYNAME: ! sprintf(ErrorText, "Copied %s messages into folder %s.", amsutil_cvEng(goodct, 0, 1000), GivenName); ! break; ! case MARKACTION_APPENDTOFILE: ! sprintf(ErrorText, "Appended %s messages to file %s.", amsutil_cvEng(goodct, 0, 1000), GivenName); ! break; ! default: ! sprintf(ErrorText, "Did something to %s messages.", amsutil_cvEng(goodct, 0, 1000)); break; } ! message_DisplayString(NULL, 10, ErrorText); ! captions_PostMenus(ci, NULL); ! if (Code == MARKACTION_CLASSIFYBYNAME ! || Code == MARKACTION_APPENDBYNAME ! || Code == MARKACTION_COPYBYNAME) { ! char Nick[1+MAXPATHLEN]; ! ams_CUI_BuildNickName(ams_GetAMS(), GivenName, Nick); ! SetLastClassification(ci, Nick); } } captions_WantUpdate(ci, ci); ! ams_WaitCursor(FALSE); ! return; } ! FinalizeProcStuff(self) ! struct captions *self; { ! keystate_Destroy(self->privkeys); ! menulist_Destroy(self->privmenus); ! cursor_Destroy(self->mycursor); } ! CreateCaptionsCursor(self) ! struct captions *self; { ! struct fontdesc *fd; ! fd = fontdesc_Create("icon", 0, 12); ! self->mycursor = cursor_Create(self); ! cursor_SetGlyph(self->mycursor, fd, 'R'); } ! static void ! SimulateLeftClick( self, rock ) ! struct captions *self; ! long rock; { ! captions_SimulateClick(self, TRUE); } ! static void ! SimulateRightClick( self, rock ) ! struct captions *self; ! long rock; { ! captions_SimulateClick(self, FALSE); } --- 109,758 ---- ams_WaitCursor(FALSE); } ! ClassifyMarkedByName(self, NameGiven) ! struct captions *self; ! char *NameGiven; ! { ! int code; ! if (*NameGiven == '*') { ! ++NameGiven; ! code = MARKACTION_APPENDBYNAME; ! } else { ! code = MARKACTION_CLASSIFYBYNAME; ! } ! captions_ActOnMarkedMessages(self, code, NameGiven); ! } ! ! void SimulateLeftClick( self, rock ) ! struct captions *self; ! long rock; { ! captions_SimulateClick(self, TRUE); } ! void SimulateRightClick( self, rock ) ! struct captions *self; ! long rock; { ! captions_SimulateClick(self, FALSE); ! } ! void captions__PrintVisibleMessage(self) ! struct captions *self; ! { ! int flags = 0; ! ! if (self->VisibleCUID <1) { ! message_DisplayString(NULL, 10, "There is nothing to print."); ! return; } ! ams_WaitCursor(TRUE); ! if (self->CurrentFormatting & MODE822_ROT13) { ! flags |= AMS_PRINT_ROT13; } ! if (self->CurrentFormatting & MODE822_FIXEDWIDTH) { ! flags |= AMS_PRINT_FIXED; } ! message_DisplayString(NULL, 10, "Printing message; please wait..."); ! im_ForceUpdate(); ! if (ams_CUI_PrintBodyFromCUIDWithFlags(ams_GetAMS(), self->VisibleCUID, flags, NULL) == 0) { ! message_DisplayString(NULL, 10, "Message queued for printing."); } ! ams_WaitCursor(FALSE); ! } ! ! ! void captions__PuntCurrent(self, GoToNext) ! struct captions *self; ! Boolean GoToNext; ! { ! int loops = 1; ! struct im *im = captions_GetIM(self); ! char Scratch[100+MAXPATHLEN]; ! ! if (im && im_ArgProvided(im)) { ! loops = im_Argument(im); ! if (loops < 0) { ! loops = 1; ! } else if (loops > 1) { ! sprintf(Scratch, "Do you really want to punt the next %d folders", loops); ! if (!ams_GetBooleanFromUser(ams_GetAMS(), Scratch, FALSE)) { ! return; ! } ! } } ! while (loops--) { ! if (self->captioncachecount > 0) { ! SetSouthernmostPoint(self, self->capcache[self->captioncachecount-1].offset); ! } ! if (GoToNext) { ! folders_NextFolder(captions_GetFolders(self), FALSE); ! } ! if (loops>0) im_ForceUpdate(); } ! } ! ! void captions__ThisIsFlorida(self) ! struct captions *self; ! { ! int pos, len, whichcaption; ! struct environment *env; ! ! im_ForceUpdate(); ! /* The following line makes things work better if this caption is the first one fetched into the caption cache but not the first in the folder */ ! captions_GuaranteeFetchedRange(self, self->FolderSize - self->FetchedFromEnd - 1, self->FolderSize); ! pos = self->HighlightStartPos; ! (void) captions_FindCUIDByDocLocation(self, &pos, &len, &env, &whichcaption); ! SetSouthernmostPoint(self, -1); /* Always needed */ ! if (--whichcaption >= 0) { ! pos = self->capcache[whichcaption].offset; ! (void) captions_FindCUIDByDocLocation(self, &pos, &len, &env, &whichcaption); ! SetSouthernmostPoint(self, pos); } ! im_ForceUpdate(); } ! void CapBeginText(self) struct captions *self; { ! captions_GuaranteeFetchedRange(self, 0, self->FolderSize); ! im_ForceUpdate(); ! textv_BeginningOfTextCmd((struct textview *) self); } ! void CapScrollBack(self) struct captions *self; { ! int min, pos, mylen, whichcaption; ! struct range total, seen, dot; ! struct environment *envptr; ! ! self->textscrollinterface->GetInfo(self, &total, &seen, &dot); ! pos = captions_DecodePosition(self, seen.beg); ! /* The following conservatively assume a 6 pt font, 4 pts spacing, maximum of one screen of scrolling */ ! captions_FindCUIDByDocLocation(self, &pos, &mylen, &envptr, &whichcaption); ! min = self->FolderSize - self->FetchedFromEnd - (captions_GetLogicalHeight(self)/10) + whichcaption - 1; ! if (min < 0) min = 0; ! captions_GuaranteeFetchedRange(self, min, self->FolderSize); ! im_ForceUpdate(); ! textv_ScrollScreenBackCmd((struct textview *) self); ! } ! ! void captions__CapReverseSearch(self) ! struct captions *self; ! { ! captions_GuaranteeFetchedRange(self, 0, self->FolderSize); ! im_ForceUpdate(); ! textv_ReverseSearchCmd((struct textview *) self); ! captions_WantInputFocus(self, self); ! } ! ! void PreviousCaptionLine(self) ! struct captions *self; ! { ! int backupto = self->FolderSize - self->FetchedFromEnd -2; ! struct im *im = captions_GetIM(self); ! ! if (im && im_ArgProvided(im)) { ! backupto -= im_Argument(im); ! } ! if (captions_GetDotPosition(self) < 150) { /* poor heuristic */ ! if (captions_GuaranteeFetchedRange(self, backupto, self->FolderSize)) return; /* error reported */ } + textv_PreviousLineCmd((struct textview *) self); } ! void CapGlitchDown(self) struct captions *self; { ! int backupto = self->FolderSize - self->FetchedFromEnd -2; ! struct im *im = captions_GetIM(self); ! ! if (im && im_ArgProvided(im)) { ! backupto -= im_Argument(im); ! } ! if (captions_GuaranteeFetchedRange(self, backupto, self->FolderSize)) return; ! im_ForceUpdate(); ! textv_GlitchDownCmd((struct textview *) self); ! } ! captions_PurgeDeletions(ci) ! struct captions *ci; ! { ! message_DisplayString(NULL, 10, "Purging deletions; please wait..."); ! im_ForceUpdate(); ! ams_WaitCursor(TRUE); ! if (ams_CUI_PurgeDeletions(ams_GetAMS(), ci->FullName) == 0) { ! message_DisplayString(NULL, 10, "Purging complete."); } ! ams_WaitCursor(FALSE); } ! void captions__ClearAndUpdate(ci, ConsiderPurging, SaveState) struct captions *ci; ! int ConsiderPurging, SaveState; { ! struct text *d; ! d = ci->CaptText; ! if (SaveState) captions_MakeCachedUpdates(ci); ! if (ConsiderPurging ! && ams_CUI_DoesDirNeedPurging(ams_GetAMS(), ci->FullName) ! && (amsutil_GetOptBit(EXP_PURGEONQUIT) ! || ams_GetBooleanFromUser(ams_GetAMS(), "Do you want to purge the deleted messages", FALSE))) { ! captions_PurgeDeletions(ci); ! } ! ResetCaptionNotBody(ci); ! if (ci->MarkCount > 0) { ! /* We clear the marks this way so that they can be restored later if so desired. */ ! captions_ClearMarks(ci); ! ci->MarkCount = 0; ! } ! if (ci->FullName) { ! free(ci->FullName); ! ci->FullName = NULL; ! } ! if (ci->ShortName) { ! free(ci->ShortName); ! ci->ShortName = NULL; ! } ! ci->captioncachecount = 0; ! ci->FetchedFromStart = ci->FetchedFromEnd = ci->FolderSize = 0; ! SetSouthernmostPoint(ci, -1); ! text_ClearCompletely(d); ! text_SetGlobalStyle(d, ci->GlobalCapStyle); ! captions_SetDotPosition(ci, 0); ! captions_SetDotLength(ci, 0); ! captions_PostMenus(ci, NULL); ! captions_WantUpdate(ci, ci); ! im_ForceUpdate(); ! } ! ! int ! captions_InsertCaptions(ci, shortname, dname, StartTime, ShowAll) ! struct captions *ci; ! char *shortname, *dname, *StartTime; ! Boolean ShowAll; ! { ! int totalbytes, numbytes, cuid, status, addlen, highstart, highlen, envstart, inspos, insertct = 0, IsDup, myfirstcuid = 0; ! char date64[AMS_DATESIZE+1], olddate64[AMS_DATESIZE+1], newdate[AMS_DATESIZE+1], firstdate[AMS_DATESIZE+1], captionbuf[100*AMS_SNAPSHOTSIZE], ErrorText[256], *DirName, *ThisCaption, *s; ! Boolean UseHighDensity, MayModify, IsRead; ! struct environment *et, *et2; ! int PositionDot = 1, NewCt, TotalCt, ProtCode; ! long errcode; ! struct CaptionCache *tempcache = NULL; ! int tempcachesize, tempcachecount; ! ! if ((errcode = ams_CUI_DisambiguateDir(ams_GetAMS(), dname, &DirName)) != 0) { ! if (*dname == '/' && ams_AMS_ERRNO(ams_GetAMS()) == ENOENT) { ! ams_CUI_HandleMissingFolder(ams_GetAMS(), dname); ! return(-1); ! } else if (ams_vdown(ams_GetAMS(), ams_AMS_ERRNO(ams_GetAMS()))) { ! sprintf(ErrorText, "%s: temporarily unavailable (net/server problem)", shortname); ! } else if (ams_AMS_ERRNO(ams_GetAMS()) == EACCES) { ! sprintf(ErrorText, "'%s' is private; you don't have read-access or are unauthenticated.", shortname); ! } else { ! sprintf(ErrorText, "The folder %s is not readable.", shortname); ! } ! message_DisplayString(NULL, 75, ErrorText); ! return(-1); } ! UseHighDensity = ! (amsutil_GetOptBit(EXP_WHITESPACE)); ! if (!StartTime) { ! long mytime; ! ! im_ForceUpdate(); ! errcode = ams_MS_GetDirInfo(ams_GetAMS(), DirName, &ProtCode, &TotalCt); ! if (errcode) { ! if (ams_AMS_ERRNO(ams_GetAMS()) == ENOENT) { ! ams_CUI_HandleMissingFolder(ams_GetAMS(), dname); ! return(-1); ! } ! sprintf(ErrorText, "Cannot look up information about %s", DirName); ! ams_ReportError(ams_GetAMS(), ErrorText, ERR_WARNING, TRUE, errcode); ! return(-1); ! } ! ci->IsFullMail = (ProtCode == AMS_DIRPROT_FULLMAIL) ? TRUE : FALSE; ! ci->FolderSize = TotalCt; ! if (errcode = ams_MS_GetNewMessageCount(ams_GetAMS(), DirName, &NewCt, &TotalCt, olddate64, TRUE)) { ! sprintf(ErrorText, "Couldn't get date information for %s", DirName); ! ams_ReportError(ams_GetAMS(), ErrorText, ERR_CRITICAL, TRUE, errcode); ! return(-1); ! } ! if (NewCt == TotalCt) ShowAll = TRUE; ! if (ShowAll) { ! date64[0] = '\0'; ! NewCt = TotalCt; ! } else { ! mytime = amsutil_conv64tolong(olddate64); ! if (mytime>0) { ! strcpy(date64, amsutil_convlongto64(mytime-1, 0)); ! } ! } ! inspos = insertct; ! } else { ! strcpy(date64, StartTime); ! } ! insertct = 0; ! inspos = 0; ! newdate[0] = '\0'; ! totalbytes = 0; ! s = NULL; ! if (StartTime) { ! tempcache = (struct CaptionCache *) malloc(25 * sizeof(struct CaptionCache)); ! tempcachesize = 25; ! tempcachecount = 0; ! } ! do { ! if ((errcode = ams_CUI_GetHeaders(ams_GetAMS(), DirName, date64, captionbuf, sizeof(captionbuf), totalbytes, &numbytes, &status, FALSE)) != 0) { ! captions_WantUpdate(ci, ci); ! if (ams_vdown(ams_GetAMS(), ams_AMS_ERRNO(ams_GetAMS()))) { ! sprintf(ErrorText, "%s: temporarily unavailable (net/server problem)", DirName); ! ams_ReportSuccess(ams_GetAMS(), ErrorText); } else { ! sprintf(ErrorText, "Could not get captions for %s", dname); ! ams_ReportError(ams_GetAMS(), ErrorText, ERR_WARNING, FALSE, 0); } ! if (tempcache) free(tempcache); ! return(-1); ! } ! if (numbytes <= 0) break; ! totalbytes += numbytes; ! for (s=captionbuf; s-captionbuf < numbytes; s+= AMS_SNAPSHOTSIZE) { ! cuid = ams_CUI_GetCuid(ams_GetAMS(), AMS_ID(s), DirName, &IsDup); ! if (ci->firstcuid == cuid) { ! /* All done -- we are back to where we started */ ! status = 0; break; + } + MayModify = AMS_GET_ATTRIBUTE(s, AMS_ATT_MAYMODIFY) ? 1 : 0; + if (MayModify) { + IsRead = AMS_GET_ATTRIBUTE(s, AMS_ATT_UNSEEN) ? FALSE : TRUE; + } else { + IsRead = (!StartTime && (myfirstcuid || ShowAll)) ? FALSE : TRUE; + } + if (!myfirstcuid) { + myfirstcuid = cuid; + strcpy(firstdate, AMS_DATE(s)); + } + MakeCaptionLine(&ThisCaption, cuid, s, amsutil_GetOptBit(EXP_FIXCAPTIONS), &highstart, &highlen, ci->IsFullMail, IsDup, IsRead); + if (!UseHighDensity) { + strcat(ThisCaption, "\n"); + } + addlen = strlen(ThisCaption); + text_AlwaysInsertCharacters(ci->CaptText, inspos, ThisCaption, addlen); + if (!StartTime && PositionDot) { + captions_SetDotPosition(ci, inspos+addlen-1); + captions_FrameDot(ci, inspos); + PositionDot = 0; + } + insertct += addlen; + et2 = environment_InsertStyle(ci->CaptText->rootEnvironment, inspos, ci->IconicStyle, 1); + environment_SetLength(et2, 3); + envstart = inspos + 2; + et = environment_InsertStyle(ci->CaptText->rootEnvironment, envstart, AMS_GET_ATTRIBUTE(s, AMS_ATT_DELETED) ? ci->DeletedStyle : ci->NormalCaptionStyle, 1); + environment_SetLength(et, addlen -3); + if (StartTime) { + AddCaptionToCacheEntry(&tempcache, &tempcachecount, &tempcachesize, cuid, inspos, et, et2, MayModify, s, IsDup); + } else { + AddCaptionToCacheEntry(&ci->capcache, &ci->captioncachecount, &ci->captioncachesize, cuid, inspos, et, et2, MayModify, s, IsDup); + } + ++ci->FetchedFromEnd; /* sometimes from start? */ + if (ci->IsFullMail) { + et = environment_InsertStyle(et, 0, ci->MailStyle, 1); + environment_SetLength(et, addlen - 3); + } + if (highlen) { + et = environment_InsertStyle(et, inspos+highstart - envstart, ci->HighlightStyle, 1); + environment_SetLength(et, highlen); + } + inspos += addlen; + } + } while (status > 0); + if (myfirstcuid) ci->firstcuid = myfirstcuid; + if (GetSouthernmostPoint(ci) == 0) { /* No southernmost point yet */ + int newsouth; + + if ((ci->substatus == AMS_SHOWALLSUBSCRIBED) + || ShowAll + || (ci->captioncachecount <= 0) + || (!StartTime && myfirstcuid && (strcmp(firstdate, olddate64)< 0))) { + newsouth = -1; + captions_SetDotPosition(ci, 0); + } else { + newsouth = ci->capcache[0].offset; } ! SetSouthernmostPoint(ci, newsouth); ! } ! if (status < 0) { ! sprintf(ErrorText, "Couldn't read all of the captions successfully"); ! ams_ReportError(ams_GetAMS(), ErrorText, ERR_CRITICAL, TRUE, errcode); ! if (tempcache) free(tempcache); ! return(-1); ! } ! if (ci->firstcuid) { ! if (s && !StartTime) { ! strcpy(newdate, AMS_DATE(s - AMS_SNAPSHOTSIZE)); } } captions_WantUpdate(ci, ci); ! if (StartTime) { ! if (tempcache) { ! MergeTwoCacheEntries(ci, tempcache, tempcachecount, tempcachesize, inspos); ! free(tempcache); ! } ! } else { ! char CommText[500]; ! ! if (ci->substatus == AMS_SHOWALLSUBSCRIBED) { ! sprintf(CommText, " (%s; All %d shown) ", ams_DescribeProt(ams_GetAMS(), ProtCode), TotalCt); ! } else { ! sprintf(CommText, " (%s; %d new of %d) ", ams_DescribeProt(ams_GetAMS(), ProtCode), NewCt, TotalCt); ! } ! ci->CommentText = malloc(1+strlen(CommText)); ! if (ci->CommentText) { ! strcpy(ci->CommentText, CommText); ! } ! } ! return(0); } ! int captions__InsertUpdatesInDocument(ci, shortname, dname, ShowFirst) ! struct captions *ci; ! char *shortname, *dname; ! Boolean ShowFirst; { ! int code, substatus; ! long errcode; ! char DumBuf[1+MAXPATHLEN]; ! boolean HadFullName = TRUE; ! ! ams_WaitCursor(TRUE); ! captions_ClearAndUpdate(ci, FALSE, TRUE); ! if (!dname || !*dname) { ! HadFullName = FALSE; ! errcode = ams_CUI_DisambiguateDir(ams_GetAMS(), shortname, &dname); ! if (errcode) { ! if (ams_vdown(ams_GetAMS(), ams_AMS_ERRNO(ams_GetAMS()))) { ! sprintf(DumBuf, "%s: temporarily unavailable (net/server problem)", shortname); ! } else if (ams_AMS_ERRNO(ams_GetAMS()) == EACCES) { ! sprintf(DumBuf, "'%s' is private; you don't have read-access or are unauthenticated.", shortname); ! } else { ! sprintf(DumBuf, "The folder %s is not readable.", shortname); ! } ! message_DisplayString(NULL, 75, DumBuf); ! return(-1); ! } ! } ! errcode = ams_MS_GetSubscriptionEntry(ams_GetAMS(), dname, DumBuf, &substatus); ! if (errcode) { ! ams_WaitCursor(FALSE); ! ams_ReportError(ams_GetAMS(), "Could not get subscription entry", ERR_WARNING, TRUE, errcode); ! return(-1); ! } ! if (!HadFullName && ci->myfold) { ! folders_AlterSubscriptionStatus(ci->myfold, dname, substatus, shortname); ! } ! if (substatus == AMS_PRINTSUBSCRIBED) { ! ams_CUI_PrintUpdates(ams_GetAMS(), dname, shortname); ! } ! ci->CommentText = NULL; ! ci->firstcuid = -1; ! ci->FullName = malloc(1+strlen(dname)); ! if (ci->FullName) strcpy(ci->FullName, dname); ! ci->ShortName = malloc(1+strlen(shortname)); ! if (ci->ShortName) strcpy(ci->ShortName, shortname); ! ci->substatus = substatus; ! captions_SetLabel(ci, shortname); ! code = captions_InsertCaptions(ci, shortname, dname, NULL, substatus == AMS_SHOWALLSUBSCRIBED ? TRUE : FALSE); ! if (ci->CommentText) { ! folders_HighlightFolder(captions_GetFolders(ci), dname, ci->CommentText); ! free(ci->CommentText); ! ci->CommentText = NULL; ! } ! ! im_ForceUpdate(); ! if (ShowFirst) { ! if (substatus == AMS_SHOWALLSUBSCRIBED) { ! int len, pos; ! ! pos = ci->capcache[0].offset; ! if (ci->captioncachecount > 1) { ! len = ci->capcache[1].offset - pos; ! } else if (ci->captioncachecount > 0) { ! len = text_GetLength(ci->CaptText) - pos; ! } else { ! len = 0; ! } ! if (len) captions_DisplayNewBody(ci, ci->capcache[0].cuid, pos, len, ci->capcache[0].env); ! } else { ! captions_ShowMore(ci, FALSE, FALSE, FALSE); ! } ! } else { ! /* Pre-fetch the first message */ ! if (ci->captioncachecount > 1) { ! ams_CUI_PrefetchMessage(ams_GetAMS(), ci->capcache[1].cuid, 0); ! } else if (ci->captioncachecount > 0) { ! ams_CUI_PrefetchMessage(ams_GetAMS(), ci->capcache[0].cuid, 0); ! } ! } ! captions_WantInputFocus(ci, ci); ! ams_WaitCursor(FALSE); ! return(code); } ! void captions__ResetVisibleCaption(h) ! struct captions *h; { ! struct t822view *bv = captions_GetBodView(h); ! ResetCaptionNotBody(h); ! text_ClearCompletely(captions_GetBodDoc(h)); ! text822_ResetGlobalStyle(captions_GetBodDoc(h)); ! if (t822view_GetIM(bv) && im_GetInputFocus(t822view_GetIM(bv)) == NULL) t822view_WantInputFocus(bv, bv); ! t822view_SetDotPosition(bv, 0); ! t822view_SetDotLength(bv, 0); ! t822view_FrameDot(bv, 0); ! t822view_WantUpdate(bv, bv); } ! int captions__GetBodyFromCUID(ci, cuid, Mode, ContentTypeOverride) ! struct captions *ci; ! int cuid, Mode; ! char *ContentTypeOverride; { ! struct text *d; ! struct t822view *bv; ! char FileName[1+MAXPATHLEN], ErrorText[500]; ! int ShouldDelete, IgnorePos, len; ! FILE *fp; ! struct im *im; ! ! d = captions_GetBodDoc(ci); ! bv = captions_GetBodView(ci); ! text_ClearCompletely(d); ! text822_ResetGlobalStyle(d); ! im = t822view_GetIM(bv); ! if (im && im_GetInputFocus(im) == NULL) t822view_WantInputFocus(bv, bv); ! if (ams_CUI_ReallyGetBodyToLocalFile(ams_GetAMS(), cuid, FileName, &ShouldDelete, !ams_CUI_SnapIsRunning(ams_GetAMS())) ! || ams_CUI_GetSnapshotFromCUID(ams_GetAMS(), cuid, ci->VisibleSnapshot)) { ! return(-1); /* Error message already reported */ ! } ! fp = fopen(FileName, "r"); ! if (!fp) { ! ams_ReportError(ams_GetAMS(), "Cannot read message body file", ERR_WARNING, FALSE, 0); ! return(-1); ! } ! if (!text822_ReadIntoText(d, fp, Mode, ContentTypeOverride, &len, TRUE, &ci->StartOfRealBody, &IgnorePos, NULL)) { ! ams_ReportError(ams_GetAMS(), "Cannot read text822 object", ERR_WARNING, FALSE, 0); ! fclose(fp); ! return(-1); ! } ! fclose(fp); ! ci->CurrentFormatting = Mode; ! if (ShouldDelete) { ! if (unlink(FileName)) { ! sprintf(ErrorText, "Cannot unlink local file %s (%d)", FileName, errno); ! ams_ReportError(ams_GetAMS(), ErrorText, ERR_WARNING, FALSE, 0); ! } ! } ! t822view_SetTopPosition(bv, IgnorePos+1); ! t822view_SetDotPosition(bv, IgnorePos+1); ! t822view_SetDotLength(bv, 0); ! ! text_SetReadOnly(d, TRUE); ! MarkVisibleMessageSeen(ci); ! t822view_WantUpdate(bv, bv); ! captions_WantUpdate(ci, ci); ! im = t822view_GetIM(bv); ! #ifdef NOWAYJOSE ! if (im) { ! im_ExposeWindow(im); ! } ! #endif /* NOWAYJOSE */ ! im_ForceUpdate(); ! ams_SubtleDialogs(ams_GetAMS(), TRUE); ! ams_CUI_ProcessMessageAttributes(ams_GetAMS(), cuid, ci->VisibleSnapshot); ! ams_SubtleDialogs(ams_GetAMS(), FALSE); ! return (0); } ! int captions__DisplayNewBody(captions, thisCUID, linestart, linelen, env) ! struct captions *captions; ! int thisCUID, linestart, linelen; ! struct environment *env; { ! char *id, *dir; ! int WasDeleted, IsDeleted, checkvis; ! ! if (captions->captioncachecount <= 0) return; ! ams_WaitCursor(TRUE); ! /* Want to increase the likelihood the next line is visible unless this is the last line, in which case we simply want to ensure this line is visible. */ ! if ((linestart + linelen + 1) < text_GetLength(captions->CaptText)) { ! checkvis = linestart+linelen+1; ! } else { ! checkvis = linestart; ! } ! if (!captions_Visible(captions, checkvis)) { ! captions_SetTopPosition(captions, linestart); ! } ! if (captions->HighlightLen) { ! RemoveHighlighting(captions); ! } ! captions->HighlightStartPos = linestart; ! captions->HighlightLen = linelen; ! captions->HighlightEnv = env; ! if (captions->HighlightEnv->data.style == captions->ActiveDeletedStyle ! || captions->HighlightEnv->data.style == captions->DeletedStyle) { ! text_SetEnvironmentStyle(captions->CaptText, captions->HighlightEnv, captions->ActiveDeletedStyle); ! WasDeleted = 1; ! } else { ! text_SetEnvironmentStyle(captions->CaptText, captions->HighlightEnv, captions->ActiveCaptionStyle); ! WasDeleted = 0; ! } ! t822view_WantUpdate(captions_GetBodView(captions), captions_GetBodView(captions)); ! captions_WantUpdate(captions, captions); ! im_ForceUpdate(); ! if (thisCUID == captions->VisibleCUID) { ! SetSouthernmostPoint(captions, linestart); ! ams_WaitCursor(FALSE); ! return(0); ! } ! captions->VisibleCUID = thisCUID; ! if (captions_GetBodyFromCUID(captions, thisCUID, MODE822_NORMAL, NULL)) { ! /* error was reported */ ! ams_WaitCursor(FALSE); ! ResetCaptionNotBody(captions); ! return(-1); ! } ! IsDeleted = AMS_GET_ATTRIBUTE(captions->VisibleSnapshot, AMS_ATT_DELETED) ? 1 : 0; ! if (IsDeleted != WasDeleted) { ! /* Someone else just deleted or undeleted it! */ ! if (IsDeleted) { ! message_DisplayString(NULL, 25, "Someone has just deleted this message, but not yet purged it."); ! text_SetEnvironmentStyle(captions->CaptText, captions->HighlightEnv, captions->ActiveDeletedStyle); ! } else { ! text_SetEnvironmentStyle(captions->CaptText, captions->HighlightEnv, captions->ActiveCaptionStyle); ! message_DisplayString(NULL, 25, "Someone has just undeleted this message."); ! } ! captions_AlterDeletedIcon(captions, captions->HighlightStartPos, IsDeleted); ! captions_WantUpdate(captions, captions); ! } ! SetSouthernmostPoint(captions, linestart); ! im_ForceUpdate(); ! if (!ams_CUI_GetAMSID(ams_GetAMS(), thisCUID, &id, &dir)) { ! ams_MS_PrefetchMessage(ams_GetAMS(), dir, id, 1); ! } ! ams_WaitCursor(FALSE); ! return(0); ! } ! ! void captions__SetLabel(self, label) ! struct captions *self; ! char *label; ! { ! if (self->myframe) { ! frame_SetTitle(self->myframe, label); ! } }