1 /* 2 * Copyright 2008-2013 Various Authors 3 * Copyright 2005 Timo Hirvonen 4 * 5 * This program is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU General Public License as 7 * published by the Free Software Foundation; either version 2 of the 8 * License, or (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, but 11 * WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program; if not, see <http://www.gnu.org/licenses/>. 17 */ 18 19 #ifndef CMUS_OPTIONS_H 20 #define CMUS_OPTIONS_H 21 22 #include "list.h" 23 24 #define OPTION_MAX_SIZE 4096 25 26 typedef void (*opt_get_cb)(void *data, char *buf, size_t size); 27 typedef void (*opt_set_cb)(void *data, const char *buf); 28 typedef void (*opt_toggle_cb)(void *data); 29 30 enum { 31 OPT_PROGRAM_PATH = 1 << 0, 32 }; 33 34 struct cmus_opt { 35 struct list_head node; 36 37 const char *name; 38 39 /* If there are many similar options you should write generic get(), 40 * set() and optionally toggle() and distinguish the concrete option 41 * via this pointer. 42 */ 43 void *data; 44 45 opt_get_cb get; 46 opt_set_cb set; 47 48 /* NULL if not toggle-able */ 49 opt_toggle_cb toggle; 50 51 unsigned int flags; 52 }; 53 54 extern struct list_head option_head; 55 extern int nr_options; 56 57 enum { 58 TREE_VIEW, 59 SORTED_VIEW, 60 PLAYLIST_VIEW, 61 QUEUE_VIEW, 62 BROWSER_VIEW, 63 FILTERS_VIEW, 64 HELP_VIEW, 65 NR_VIEWS 66 }; 67 68 enum { 69 COLOR_CMDLINE_BG, 70 COLOR_CMDLINE_FG, 71 COLOR_ERROR, 72 COLOR_INFO, 73 74 COLOR_SEPARATOR, 75 COLOR_STATUSLINE_BG, 76 COLOR_STATUSLINE_FG, 77 COLOR_TITLELINE_BG, 78 79 COLOR_TITLELINE_FG, 80 COLOR_WIN_BG, 81 COLOR_WIN_CUR, 82 COLOR_WIN_CUR_SEL_BG, 83 84 COLOR_WIN_CUR_SEL_FG, 85 COLOR_WIN_DIR, 86 COLOR_WIN_FG, 87 COLOR_WIN_INACTIVE_CUR_SEL_BG, 88 89 COLOR_WIN_INACTIVE_CUR_SEL_FG, 90 COLOR_WIN_INACTIVE_SEL_BG, 91 COLOR_WIN_INACTIVE_SEL_FG, 92 COLOR_WIN_SEL_BG, 93 94 COLOR_WIN_SEL_FG, 95 COLOR_WIN_TITLE_BG, 96 COLOR_WIN_TITLE_FG, 97 COLOR_TRACKWIN_ALBUM_BG, 98 99 COLOR_TRACKWIN_ALBUM_FG, 100 NR_COLORS 101 }; 102 103 enum { 104 COLOR_CMDLINE_ATTR, 105 COLOR_STATUSLINE_ATTR, 106 COLOR_TITLELINE_ATTR, 107 COLOR_WIN_ATTR, 108 COLOR_WIN_CUR_SEL_ATTR, 109 COLOR_CUR_SEL_ATTR, 110 COLOR_WIN_INACTIVE_CUR_SEL_ATTR, 111 COLOR_WIN_INACTIVE_SEL_ATTR, 112 COLOR_WIN_SEL_ATTR, 113 COLOR_WIN_TITLE_ATTR, 114 COLOR_TRACKWIN_ALBUM_ATTR, 115 COLOR_WIN_CUR_ATTR, 116 NR_ATTRS 117 }; 118 119 #define BRIGHT (1 << 3) 120 121 extern char *cdda_device; 122 extern char *output_plugin; 123 extern char *status_display_program; 124 extern char *server_password; 125 extern int auto_expand_albums_follow; 126 extern int auto_expand_albums_search; 127 extern int auto_expand_albums_selcur; 128 extern int show_all_tracks; 129 extern int auto_reshuffle; 130 extern int confirm_run; 131 extern int resume_cmus; 132 extern int show_hidden; 133 extern int show_current_bitrate; 134 extern int show_playback_position; 135 extern int show_remaining_time; 136 extern int set_term_title; 137 extern int wrap_search; 138 extern int play_library; 139 extern int repeat; 140 extern int shuffle; 141 extern int follow; 142 extern int display_artist_sort_name; 143 extern int smart_artist_sort; 144 extern int scroll_offset; 145 extern int rewind_offset; 146 extern int skip_track_info; 147 extern int mouse; 148 extern int mpris; 149 extern int time_show_leading_zero; 150 extern int start_view; 151 extern int stop_after_queue; 152 extern int tree_width_percent; 153 extern int tree_width_max; 154 155 extern const char * const aaa_mode_names[]; 156 extern const char * const view_names[NR_VIEWS + 1]; 157 158 extern int colors[NR_COLORS]; 159 extern int attrs[NR_ATTRS]; 160 161 /* format string for tree window (tree view) */ 162 extern char *tree_win_format; 163 extern char *tree_win_artist_format; 164 165 /* format string for track window (tree view) */ 166 extern char *track_win_album_format; 167 extern char *track_win_format; 168 extern char *track_win_format_va; 169 extern char *track_win_alt_format; 170 171 /* format string for shuffle, sorted and play queue views */ 172 extern char *list_win_format; 173 extern char *list_win_format_va; 174 extern char *list_win_alt_format; 175 176 /* format string for currently playing track */ 177 extern char *current_format; 178 extern char *current_alt_format; 179 180 /* format string for status line */ 181 extern char *statusline_format; 182 183 /* format string for window title */ 184 extern char *window_title_format; 185 extern char *window_title_alt_format; 186 187 extern char *id3_default_charset; 188 extern char *icecast_default_charset; 189 190 /* build option list */ 191 void options_add(void); 192 193 /* load options from the config file */ 194 void options_load(void); 195 196 int source_file(const char *filename); 197 198 /* save options */ 199 void options_exit(void); 200 201 /* load resume file */ 202 void resume_load(void); 203 /* save resume file */ 204 void resume_exit(void); 205 206 void option_add(const char *name, const void *data, opt_get_cb get, 207 opt_set_cb set, opt_toggle_cb toggle, unsigned int flags); 208 struct cmus_opt *option_find(const char *name); 209 struct cmus_opt *option_find_silent(const char *name); 210 void option_set(const char *name, const char *value); 211 int parse_enum(const char *buf, int minval, int maxval, const char * const names[], int *val); 212 213 void update_mouse(void); 214 215 #endif 216