1 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
2 /* hack.topl.c - version 1.0.2 */
3 /* $FreeBSD: src/games/hack/hack.topl.c,v 1.3 1999/11/16 02:57:12 billf Exp $ */
4 /* $DragonFly: src/games/hack/hack.topl.c,v 1.2 2003/06/17 04:25:24 dillon Exp $ */
12 xchar tlx
, tly
; /* set by pline; used by addtopl */
15 struct topl
*next_topl
;
17 } *old_toplines
, *last_redone_topl
;
18 #define OTLMAX 20 /* max nr of old toplines remembered */
22 last_redone_topl
= last_redone_topl
->next_topl
;
24 last_redone_topl
= old_toplines
;
26 (void) strcpy(toplines
, last_redone_topl
->topl_text
);
34 if(index(toplines
, '\n')) cl_end();
47 if(last_redone_topl
&&
48 !strcmp(toplines
, last_redone_topl
->topl_text
)) return;
50 !strcmp(toplines
, old_toplines
->topl_text
)) return;
53 alloc((unsigned)(strlen(toplines
) + sizeof(struct topl
) + 1));
54 tl
->next_topl
= old_toplines
;
55 tl
->topl_text
= (char *)(tl
+ 1);
56 (void) strcpy(tl
->topl_text
, toplines
);
62 if(tl
&& tl
->next_topl
){
63 free((char *) tl
->next_topl
);
70 if(tlx
+ strlen(s
) > CO
) putsym('\n');
78 char *s
; /* allowed chars besides space/return */
82 if(tlx
+ 8 > CO
) putsym('\n'), tly
++;
92 if(flags
.toplin
&& tly
> 1) {
114 if(tly
> 1) docorner(1, tly
-1);
121 pline(line
,arg1
,arg2
,arg3
,arg4
,arg5
,arg6
)
122 char *line
,*arg1
,*arg2
,*arg3
,*arg4
,*arg5
,*arg6
;
125 char *bp
= pbuf
, *tl
;
128 if(!line
|| !*line
) return;
129 if(!index(line
, '%')) (void) strcpy(pbuf
,line
); else
130 (void) sprintf(pbuf
,line
,arg1
,arg2
,arg3
,arg4
,arg5
,arg6
);
131 if(flags
.toplin
== 1 && !strcmp(pbuf
, toplines
)) return;
134 /* If there is room on the line, print message on same line */
135 /* But messages like "You die..." deserve their own line */
137 if(flags
.toplin
== 1 && tly
== 1 &&
138 n0
+ strlen(toplines
) + 3 < CO
-8 && /* leave room for --More-- */
139 strncmp(bp
, "You ", 4)) {
140 (void) strcat(toplines
, " ");
141 (void) strcat(toplines
, bp
);
146 if(flags
.toplin
== 1) more();
151 /* look for appropriate cut point */
153 for(n
= 0; n
< CO
; n
++) if(bp
[n
] == ' ')
155 if(!n0
) for(n
= 0; n
< CO
-1; n
++)
156 if(!letter(bp
[n
])) n0
= n
;
159 (void) strncpy((tl
= eos(toplines
)), bp
, n0
);
163 /* remove trailing spaces, but leave one */
164 while(n0
> 1 && tl
[n0
-1] == ' ' && tl
[n0
-2] == ' ')
168 if(n0
&& tl
[0]) (void) strcat(tl
, "\n");
181 if(cury
> tly
) tly
= cury
;
185 putsym('\n'); /* 1 <= curx <= CO; avoid CO */
193 while(*s
) putsym(*s
++);