1 /***************************************************************************
2  *   Copyright (C) 2008-2021 by Andrzej Rybczak                            *
3  *   andrzej@rybczak.net                                                   *
4  *                                                                         *
5  *   This program is free software; you can redistribute it and/or modify  *
6  *   it under the terms of the GNU General Public License as published by  *
7  *   the Free Software Foundation; either version 2 of the License, or     *
8  *   (at your option) any later version.                                   *
9  *                                                                         *
10  *   This program is distributed in the hope that it will be useful,       *
11  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
12  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
13  *   GNU 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, write to the                         *
17  *   Free Software Foundation, Inc.,                                       *
18  *   51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.              *
19  ***************************************************************************/
20 
21 #ifndef NCMPCPP_SETTINGS_H
22 #define NCMPCPP_SETTINGS_H
23 
24 #include <boost/date_time/posix_time/posix_time_types.hpp>
25 #include <boost/optional.hpp>
26 #include <boost/regex.hpp>
27 #include <cassert>
28 #include <vector>
29 #include <mpd/client.h>
30 
31 #include "curses/formatted_color.h"
32 #include "curses/strbuffer.h"
33 #include "enums.h"
34 #include "format.h"
35 #include "lyrics_fetcher.h"
36 #include "screens/screen_type.h"
37 
38 struct Column
39 {
ColumnColumn40 	Column() : stretch_limit(-1), right_alignment(0), display_empty_tag(1) { }
41 
42 	std::wstring name;
43 	std::string type;
44 	int width;
45 	int stretch_limit;
46 	NC::Color color;
47 	bool fixed;
48 	bool right_alignment;
49 	bool display_empty_tag;
50 };
51 
52 struct Configuration
53 {
ConfigurationConfiguration54 	Configuration()
55 	: playlist_disable_highlight_delay(0)
56 	{ }
57 
58 	bool read(const std::vector<std::string> &config_paths, bool ignore_errors);
59 
60 	std::string ncmpcpp_directory;
61 	std::string lyrics_directory;
62 
63 	std::string mpd_music_dir;
64 	std::string visualizer_fifo_path; // deprecated
65 	std::string visualizer_data_source;
66 	std::string visualizer_output_name;
67 	std::string empty_tag;
68 
69 	Format::AST<char> song_list_format;
70 	Format::AST<char> song_window_title_format;
71 	Format::AST<char> song_library_format;
72 	Format::AST<char> song_columns_mode_format;
73 	Format::AST<char> browser_sort_format;
74 	Format::AST<char> song_status_format;
75 	Format::AST<wchar_t> song_status_wformat;
76 	Format::AST<wchar_t> new_header_first_line;
77 	Format::AST<wchar_t> new_header_second_line;
78 
79 	std::string external_editor;
80 	std::string system_encoding;
81 	std::string execute_on_song_change;
82 	std::string execute_on_player_state_change;
83 	std::string lastfm_preferred_language;
84 	std::wstring progressbar;
85 	std::wstring visualizer_chars;
86 	size_t visualizer_fps;
87 	bool visualizer_autoscale;
88 	bool visualizer_spectrum_smooth_look;
89 	uint32_t visualizer_spectrum_dft_size;
90 	double visualizer_spectrum_gain;
91 	double visualizer_spectrum_hz_min;
92 	double visualizer_spectrum_hz_max;
93 
94 	std::string pattern;
95 
96 	std::vector<Column> columns;
97 
98 	DisplayMode playlist_display_mode;
99 	DisplayMode browser_display_mode;
100 	DisplayMode search_engine_display_mode;
101 	DisplayMode playlist_editor_display_mode;
102 
103 	NC::Buffer browser_playlist_prefix;
104 	NC::Buffer selected_item_prefix;
105 	NC::Buffer selected_item_suffix;
106 	NC::Buffer now_playing_prefix;
107 	NC::Buffer now_playing_suffix;
108 	NC::Buffer modified_item_prefix;
109 	NC::Buffer current_item_prefix;
110 	NC::Buffer current_item_suffix;
111 	NC::Buffer current_item_inactive_column_prefix;
112 	NC::Buffer current_item_inactive_column_suffix;
113 
114 	NC::Color header_color;
115 	NC::Color main_color;
116 	NC::Color statusbar_color;
117 
118 	NC::FormattedColor color1;
119 	NC::FormattedColor color2;
120 	NC::FormattedColor empty_tags_color;
121 	NC::FormattedColor volume_color;
122 	NC::FormattedColor state_line_color;
123 	NC::FormattedColor state_flags_color;
124 	NC::FormattedColor progressbar_color;
125 	NC::FormattedColor progressbar_elapsed_color;
126 	NC::FormattedColor player_state_color;
127 	NC::FormattedColor statusbar_time_color;
128 	NC::FormattedColor alternative_ui_separator_color;
129 
130 	std::vector<NC::FormattedColor> visualizer_colors;
131 	VisualizerType visualizer_type;
132 
133 	NC::Border window_border;
134 	NC::Border active_window_border;
135 
136 	Design design;
137 
138 	SpaceAddMode space_add_mode;
139 
140 	mpd_tag_type media_lib_primary_tag;
141 
142 	bool colors_enabled;
143 	bool playlist_show_mpd_host;
144 	bool playlist_show_remaining_time;
145 	bool playlist_shorten_total_times;
146 	bool playlist_separate_albums;
147 	bool set_window_title;
148 	bool header_visibility;
149 	bool header_text_scrolling;
150 	bool statusbar_visibility;
151 	bool connected_message_on_startup;
152 	bool titles_visibility;
153 	bool centered_cursor;
154 	bool screen_switcher_previous;
155 	bool autocenter_mode;
156 	bool wrapped_search;
157 	bool incremental_seeking;
158 	bool now_playing_lyrics;
159 	bool fetch_lyrics_in_background;
160 	bool local_browser_show_hidden_files;
161 	bool search_in_db;
162 	bool jump_to_now_playing_song_at_start;
163 	bool clock_display_seconds;
164 	bool display_volume_level;
165 	bool display_bitrate;
166 	bool display_remaining_time;
167 	bool ignore_leading_the;
168 	bool ignore_diacritics;
169 	bool block_search_constraints_change;
170 	bool use_console_editor;
171 	bool use_cyclic_scrolling;
172 	bool ask_before_clearing_playlists;
173 	bool ask_before_shuffling_playlists;
174 	bool mouse_support;
175 	bool mouse_list_scroll_whole_page;
176 	bool visualizer_in_stereo;
177 	bool data_fetching_delay;
178 	bool media_library_sort_by_mtime;
179 	bool media_lib_hide_album_dates;
180 	bool tag_editor_extended_numeration;
181 	bool discard_colors_if_item_is_selected;
182 	bool store_lyrics_in_song_dir;
183 	bool generate_win32_compatible_filenames;
184 	bool ask_for_locked_screen_width_part;
185 	bool allow_for_physical_item_deletion;
186 	bool media_library_albums_split_by_date;
187 	bool startup_slave_screen_focus;
188 
189 	unsigned mpd_connection_timeout;
190 	unsigned crossfade_time;
191 	unsigned seek_time;
192 	unsigned volume_change_step;
193 	unsigned message_delay_time;
194 	unsigned lyrics_db;
195 	unsigned lines_scrolled;
196 	unsigned search_engine_default_search_mode;
197 
198 	boost::regex::flag_type regex_type;
199 
200 	boost::posix_time::seconds playlist_disable_highlight_delay;
201 
202 	double locked_screen_width_part;
203 
204 	size_t selected_item_prefix_length;
205 	size_t selected_item_suffix_length;
206 	size_t now_playing_prefix_length;
207 	size_t now_playing_suffix_length;
208 	size_t current_item_prefix_length;
209 	size_t current_item_suffix_length;
210 	size_t current_item_inactive_column_prefix_length;
211 	size_t current_item_inactive_column_suffix_length;
212 
213 	ScreenType startup_screen_type;
214 	boost::optional<ScreenType> startup_slave_screen_type;
215 	std::vector<ScreenType> screen_sequence;
216 
217 	std::string random_exclude_pattern;
218 	SortMode browser_sort_mode;
219 
220 	LyricsFetchers lyrics_fetchers;
221 };
222 
223 extern Configuration Config;
224 
225 #endif // NCMPCPP_SETTINGS_H
226