add :refresh command
[cmus.git] / format_print.h
blob45f74aa0978bf4b611ed648982ccd9ffbdb58922
1 /*
2 * Copyright 2004-2005 Timo Hirvonen
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; either version 2 of the
7 * License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * 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
17 * 02111-1307, USA.
20 #ifndef _FORMAT_PRINT_H
21 #define _FORMAT_PRINT_H
23 struct format_option {
24 union {
25 /* NULL is treated like "" */
26 const char *fo_str;
27 int fo_int;
28 /* [h:]mm:ss. can be negative */
29 int fo_time;
31 /* set to 1 if you want to disable printing */
32 unsigned int empty : 1;
33 enum { FO_STR, FO_INT, FO_TIME } type;
34 char ch;
37 #define DEF_FO_STR(ch) { { .fo_str = NULL }, 0, FO_STR, ch }
38 #define DEF_FO_INT(ch) { { .fo_int = 0 }, 0, FO_INT, ch }
39 #define DEF_FO_TIME(ch) { { .fo_time = 0 }, 0, FO_TIME, ch }
40 #define DEF_FO_END { { .fo_str = NULL }, 0, 0, 0 }
42 int format_print(char *str, int width, const char *format, const struct format_option *fopts);
43 int format_valid(const char *format);
45 #endif