]>
git.cameronkatri.com Git - bsdgames-darwin.git/blob - hack/hack.topl.c
1 /* $NetBSD: hack.topl.c,v 1.6 2002/05/26 00:12:12 wiz Exp $ */
4 * Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985.
9 __RCSID("$NetBSD: hack.topl.c,v 1.6 2002/05/26 00:12:12 wiz Exp $");
17 xchar tlx
, tly
; /* set by pline; used by addtopl */
20 struct topl
*next_topl
;
22 } *old_toplines
, *last_redone_topl
;
23 #define OTLMAX 20 /* max nr of old toplines remembered */
29 last_redone_topl
= last_redone_topl
->next_topl
;
30 if (!last_redone_topl
)
31 last_redone_topl
= old_toplines
;
32 if (last_redone_topl
) {
33 (void) strcpy(toplines
, last_redone_topl
->topl_text
);
43 if (strchr(toplines
, '\n'))
59 if (last_redone_topl
&&
60 !strcmp(toplines
, last_redone_topl
->topl_text
))
63 !strcmp(toplines
, old_toplines
->topl_text
))
67 alloc((unsigned) (strlen(toplines
) + sizeof(struct topl
) + 1));
68 tl
->next_topl
= old_toplines
;
69 tl
->topl_text
= (char *) (tl
+ 1);
70 (void) strcpy(tl
->topl_text
, toplines
);
76 if (tl
&& tl
->next_topl
) {
77 free((char *) tl
->next_topl
);
87 if (tlx
+ strlen(s
) > CO
)
97 const char *s
; /* allowed chars besides space/return */
111 if (flags
.toplin
&& tly
> 1) {
114 docorner(1, tly
- 1);
139 docorner(1, tly
- 1);
146 pline(const char *fmt
, ...)
161 char *bp
= pbuf
, *tl
;
166 if (!strchr(line
, '%'))
167 (void) strcpy(pbuf
, line
);
169 (void) vsprintf(pbuf
, line
, ap
);
170 if (flags
.toplin
== 1 && !strcmp(pbuf
, toplines
))
174 /* If there is room on the line, print message on same line */
175 /* But messages like "You die..." deserve their own line */
177 if (flags
.toplin
== 1 && tly
== 1 &&
178 n0
+ strlen(toplines
) + 3 < CO
- 8 && /* leave room for
180 strncmp(bp
, "You ", 4)) {
181 (void) strcat(toplines
, " ");
182 (void) strcat(toplines
, bp
);
187 if (flags
.toplin
== 1)
193 /* look for appropriate cut point */
195 for (n
= 0; n
< CO
; n
++)
199 for (n
= 0; n
< CO
- 1; n
++)
205 (void) strncpy((tl
= eos(toplines
)), bp
, n0
);
209 /* remove trailing spaces, but leave one */
210 while (n0
> 1 && tl
[n0
- 1] == ' ' && tl
[n0
- 2] == ' ')
215 (void) strcat(tl
, "\n");
236 putsym('\n'); /* 1 <= curx <= CO; avoid CO */