1 /* CAVE (Character Animation Viewer for Everyone)
2 Copyright (C) 2001-2002 Ben Kibbey <bjk@arbornet.org>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 int message(const char *title
, const char *prompt
, const char *format
, ...)
32 char *line
, *s
, *tmp
, buf
[LINE_MAX
];
35 int x
, y
, c
= 0, i
= 0;
37 if (!format
&& !title
&& !prompt
) {
45 vasprintf(&line
, format
, ap
);
47 line
= Malloc(LINE_MAX
);
48 vsnprintf(line
, LINE_MAX
, format
, ap
);
56 while ((s
= strsep(&tmp
, "\n")) != NULL
) {
69 if (prompt
&& strlen(prompt
) > i
)
70 x
= CALCWIDTH(prompt
);
74 if (title
&& x
< strlen(title
))
86 win
= newwin(y
, x
, CALCPOSY(y
), CALCPOSX(x
));
87 box(win
, ACS_VLINE
, ACS_HLINE
);
88 panel
= new_panel(win
);
91 mvwprintw(win
, 0, CENTERX(x
, title
), "%s", title
);
95 while ((s
= strsep(&tmp
, "\n")) != NULL
)
96 mvwaddstr(win
, i
++, CENTERX(x
, s
), s
);
102 mvwprintw(win
, y
- 2, CENTERX(x
, prompt
), "%s", prompt
);