1 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
2 /* hack.topl.c - version 1.0.2 */
11 xchar tlx, tly; /* set by pline; used by addtopl */
14 struct topl *next_topl;
16 } *old_toplines, *last_redone_topl;
17 #define OTLMAX 20 /* max nr of old toplines remembered */
21 last_redone_topl = last_redone_topl->next_topl;
23 last_redone_topl = old_toplines;
25 (void) strcpy(toplines, last_redone_topl->topl_text);
33 if(index(toplines, '\n')) cl_end();
46 if(last_redone_topl &&
47 !strcmp(toplines, last_redone_topl->topl_text)) return;
49 !strcmp(toplines, old_toplines->topl_text)) return;
52 alloc((unsigned)(strlen(toplines) + sizeof(struct topl) + 1));
53 tl->next_topl = old_toplines;
54 tl->topl_text = (char *)(tl + 1);
55 (void) strcpy(tl->topl_text, toplines);
61 if(tl && tl->next_topl){
62 free((char *) tl->next_topl);
69 if(tlx + strlen(s) > CO) putsym('\n');
77 char *s; /* allowed chars besides space/return */
81 if(tlx + 8 > CO) putsym('\n'), tly++;
91 if(flags.toplin && tly > 1) {
113 if(tly > 1) docorner(1, tly-1);
120 pline(line,arg1,arg2,arg3,arg4,arg5,arg6)
121 char *line,*arg1,*arg2,*arg3,*arg4,*arg5,*arg6;
124 char *bp = pbuf, *tl;
127 if(!line || !*line) return;
128 if(!index(line, '%')) (void) strcpy(pbuf,line); else
129 (void) sprintf(pbuf,line,arg1,arg2,arg3,arg4,arg5,arg6);
130 if(flags.toplin == 1 && !strcmp(pbuf, toplines)) return;
133 /* If there is room on the line, print message on same line */
134 /* But messages like "You die..." deserve their own line */
136 if(flags.toplin == 1 && tly == 1 &&
137 n0 + strlen(toplines) + 3 < CO-8 && /* leave room for --More-- */
138 strncmp(bp, "You ", 4)) {
139 (void) strcat(toplines, " ");
140 (void) strcat(toplines, bp);
145 if(flags.toplin == 1) more();
150 /* look for appropriate cut point */
152 for(n = 0; n < CO; n++) if(bp[n] == ' ')
154 if(!n0) for(n = 0; n < CO-1; n++)
155 if(!letter(bp[n])) n0 = n;
158 (void) strncpy((tl = eos(toplines)), bp, n0);
162 /* remove trailing spaces, but leave one */
163 while(n0 > 1 && tl[n0-1] == ' ' && tl[n0-2] == ' ')
167 if(n0 && tl[0]) (void) strcat(tl, "\n");
180 if(cury > tly) tly = cury;
184 putsym('\n'); /* 1 <= curx <= CO; avoid CO */
192 while(*s) putsym(*s++);