]>
git.cameronkatri.com Git - bsdgames-darwin.git/blob - hack/hack.topl.c
2 * Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985.
6 static char rcsid
[] = "$NetBSD: hack.topl.c,v 1.3 1995/03/23 08:31:40 cgd Exp $";
15 xchar tlx
, tly
; /* set by pline; used by addtopl */
18 struct topl
*next_topl
;
20 } *old_toplines
, *last_redone_topl
;
21 #define OTLMAX 20 /* max nr of old toplines remembered */
25 last_redone_topl
= last_redone_topl
->next_topl
;
27 last_redone_topl
= old_toplines
;
29 (void) strcpy(toplines
, last_redone_topl
->topl_text
);
37 if(index(toplines
, '\n')) cl_end();
48 register struct topl
*tl
;
49 register int cnt
= OTLMAX
;
50 if(last_redone_topl
&&
51 !strcmp(toplines
, last_redone_topl
->topl_text
)) return;
53 !strcmp(toplines
, old_toplines
->topl_text
)) return;
56 alloc((unsigned)(strlen(toplines
) + sizeof(struct topl
) + 1));
57 tl
->next_topl
= old_toplines
;
58 tl
->topl_text
= (char *)(tl
+ 1);
59 (void) strcpy(tl
->topl_text
, toplines
);
65 if(tl
&& tl
->next_topl
){
66 free((char *) tl
->next_topl
);
73 if(tlx
+ strlen(s
) > CO
) putsym('\n');
81 char *s
; /* allowed chars besides space/return */
85 if(tlx
+ 8 > CO
) putsym('\n'), tly
++;
95 if(flags
.toplin
&& tly
> 1) {
117 if(tly
> 1) docorner(1, tly
-1);
124 pline(line
,arg1
,arg2
,arg3
,arg4
,arg5
,arg6
)
125 register char *line
,*arg1
,*arg2
,*arg3
,*arg4
,*arg5
,*arg6
;
128 register char *bp
= pbuf
, *tl
;
131 if(!line
|| !*line
) return;
132 if(!index(line
, '%')) (void) strcpy(pbuf
,line
); else
133 (void) sprintf(pbuf
,line
,arg1
,arg2
,arg3
,arg4
,arg5
,arg6
);
134 if(flags
.toplin
== 1 && !strcmp(pbuf
, toplines
)) return;
137 /* If there is room on the line, print message on same line */
138 /* But messages like "You die..." deserve their own line */
140 if(flags
.toplin
== 1 && tly
== 1 &&
141 n0
+ strlen(toplines
) + 3 < CO
-8 && /* leave room for --More-- */
142 strncmp(bp
, "You ", 4)) {
143 (void) strcat(toplines
, " ");
144 (void) strcat(toplines
, bp
);
149 if(flags
.toplin
== 1) more();
154 /* look for appropriate cut point */
156 for(n
= 0; n
< CO
; n
++) if(bp
[n
] == ' ')
158 if(!n0
) for(n
= 0; n
< CO
-1; n
++)
159 if(!letter(bp
[n
])) n0
= n
;
162 (void) strncpy((tl
= eos(toplines
)), bp
, n0
);
166 /* remove trailing spaces, but leave one */
167 while(n0
> 1 && tl
[n0
-1] == ' ' && tl
[n0
-2] == ' ')
171 if(n0
&& tl
[0]) (void) strcat(tl
, "\n");
184 if(cury
> tly
) tly
= cury
;
188 putsym('\n'); /* 1 <= curx <= CO; avoid CO */
195 putstr(s
) register char *s
; {
196 while(*s
) putsym(*s
++);