1 /***************************************************************************
2 * Copyright (C) 2008-2009 by Andrzej Rybczak *
3 * electricityispower@gmail.com *
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. *
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. *
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 ***************************************************************************/
24 # include <sys/stat.h>
34 #ifdef HAVE_LANGINFO_H
35 # include <langinfo.h>
38 const std::string config_file
= config_dir
+ "config";
39 const std::string keys_config_file
= config_dir
+ "keys";
41 ncmpcpp_config Config
;
46 void GetKeys(std::string
&line
, int *key
)
48 size_t i
= line
.find("=")+1;
49 line
= line
.substr(i
, line
.length()-i
);
52 while (line
[++i
] == ' ') { }
53 line
= line
.substr(i
, line
.length()-i
);
57 if (i
!= std::string::npos
)
59 one
= line
.substr(0, i
);
61 two
= line
.substr(i
, line
.length()-i
);
65 key
[0] = !one
.empty() && one
[0] == '\'' ? one
[1] : (atoi(one
.c_str()) == 0 ? null_key
: atoi(one
.c_str()));
66 key
[1] = !two
.empty() && two
[0] == '\'' ? two
[1] : (atoi(two
.c_str()) == 0 ? null_key
: atoi(two
.c_str()));
69 Border
IntoBorder(const std::string
&color
)
71 return Border(IntoColor(color
));
75 void CreateConfigDir()
77 mkdir(config_dir
.c_str()
84 void SetWindowsDimensions(size_t &header_height
, size_t &footer_start_y
, size_t &footer_height
)
86 Global::MainStartY
= Config
.new_design
? 5 : 2;
87 Global::MainHeight
= LINES
-(Config
.new_design
? 7 : 4);
89 if (!Config
.header_visibility
)
91 Global::MainStartY
-= 2;
92 Global::MainHeight
+= 2;
94 if (!Config
.statusbar_visibility
)
97 header_height
= Config
.new_design
? (Config
.header_visibility
? 5 : 3) : 1;
98 footer_start_y
= LINES
-(Config
.statusbar_visibility
? 2 : 1);
99 footer_height
= Config
.statusbar_visibility
? 2 : 1;
102 void DefaultKeys(ncmpcpp_keys
&keys
)
105 keys
.Down
[0] = KEY_DOWN
;
106 keys
.PageUp
[0] = KEY_PPAGE
;
107 keys
.PageDown
[0] = KEY_NPAGE
;
108 keys
.Home
[0] = KEY_HOME
;
109 keys
.End
[0] = KEY_END
;
112 keys
.Delete
[0] = KEY_DC
;
113 keys
.VolumeUp
[0] = KEY_RIGHT
;
114 keys
.VolumeDown
[0] = KEY_LEFT
;
115 keys
.ScreenSwitcher
[0] = 9;
117 keys
.Playlist
[0] = '2';
118 keys
.Browser
[0] = '3';
119 keys
.SearchEngine
[0] = '4';
120 keys
.MediaLibrary
[0] = '5';
121 keys
.PlaylistEditor
[0] = '6';
122 keys
.TagEditor
[0] = '7';
123 keys
.Outputs
[0] = '8';
124 keys
.Visualizer
[0] = '9';
126 keys
.ServerInfo
[0] = '@';
131 keys
.SeekForward
[0] = 'f';
132 keys
.SeekBackward
[0] = 'b';
133 keys
.ToggleRepeat
[0] = 'r';
134 keys
.ToggleRandom
[0] = 'z';
135 keys
.ToggleSingle
[0] = 'y';
136 keys
.ToggleConsume
[0] = 'R';
137 keys
.ToggleReplayGainMode
[0] = 'Y';
138 keys
.ToggleSpaceMode
[0] = 't';
139 keys
.ToggleAddMode
[0] = 'T';
140 keys
.ToggleMouse
[0] = '|';
141 keys
.Shuffle
[0] = 'Z';
142 keys
.ToggleCrossfade
[0] = 'x';
143 keys
.SetCrossfade
[0] = 'X';
144 keys
.UpdateDB
[0] = 'u';
145 keys
.SortPlaylist
[0] = 22;
146 keys
.ApplyFilter
[0] = 6;
147 keys
.FindForward
[0] = '/';
148 keys
.FindBackward
[0] = '?';
149 keys
.NextFoundPosition
[0] = '.';
150 keys
.PrevFoundPosition
[0] = ',';
151 keys
.ToggleFindMode
[0] = 'w';
152 keys
.EditTags
[0] = 'e';
153 keys
.SongInfo
[0] = 'i';
154 keys
.ArtistInfo
[0] = 'I';
155 keys
.GoToPosition
[0] = 'g';
156 keys
.Lyrics
[0] = 'l';
157 keys
.ReverseSelection
[0] = 'v';
158 keys
.DeselectAll
[0] = 'V';
159 keys
.AddSelected
[0] = 'A';
162 keys
.MvSongUp
[0] = 'm';
163 keys
.MvSongDown
[0] = 'n';
164 keys
.MoveTo
[0] = 'M';
166 keys
.SavePlaylist
[0] = 'S';
167 keys
.GoToNowPlaying
[0] = 'o';
168 keys
.GoToContainingDir
[0] = 'G';
169 keys
.GoToMediaLibrary
[0] = '~';
170 keys
.ToggleAutoCenter
[0] = 'U';
171 keys
.ToggleDisplayMode
[0] = 'p';
172 keys
.ToggleInterface
[0] = '\\';
173 keys
.ToggleLyricsDB
[0] = 'L';
174 keys
.GoToParentDir
[0] = KEY_BACKSPACE
;
175 keys
.SwitchTagTypeList
[0] = '`';
180 keys
.PageUp
[1] = null_key
;
181 keys
.PageDown
[1] = null_key
;
182 keys
.Home
[1] = null_key
;
183 keys
.End
[1] = null_key
;
184 keys
.Space
[1] = null_key
;
185 keys
.Enter
[1] = null_key
;
186 keys
.Delete
[1] = 'd';
187 keys
.VolumeUp
[1] = '+';
188 keys
.VolumeDown
[1] = '-';
189 keys
.ScreenSwitcher
[1] = null_key
;
191 keys
.Playlist
[1] = 266;
192 keys
.Browser
[1] = 267;
193 keys
.SearchEngine
[1] = 268;
194 keys
.MediaLibrary
[1] = 269;
195 keys
.PlaylistEditor
[1] = 270;
196 keys
.TagEditor
[1] = 271;
197 keys
.Outputs
[1] = 272;
198 keys
.Visualizer
[1] = 273;
200 keys
.ServerInfo
[1] = null_key
;
201 keys
.Stop
[1] = null_key
;
202 keys
.Pause
[1] = null_key
;
203 keys
.Next
[1] = null_key
;
204 keys
.Prev
[1] = null_key
;
205 keys
.SeekForward
[1] = null_key
;
206 keys
.SeekBackward
[1] = null_key
;
207 keys
.ToggleRepeat
[1] = null_key
;
208 keys
.ToggleRandom
[1] = null_key
;
209 keys
.ToggleSingle
[1] = null_key
;
210 keys
.ToggleConsume
[1] = null_key
;
211 keys
.ToggleReplayGainMode
[1] = null_key
;
212 keys
.ToggleSpaceMode
[1] = null_key
;
213 keys
.ToggleAddMode
[1] = null_key
;
214 keys
.ToggleMouse
[1] = null_key
;
215 keys
.Shuffle
[1] = null_key
;
216 keys
.ToggleCrossfade
[1] = null_key
;
217 keys
.SetCrossfade
[1] = null_key
;
218 keys
.UpdateDB
[1] = null_key
;
219 keys
.SortPlaylist
[1] = null_key
;
220 keys
.ApplyFilter
[1] = null_key
;
221 keys
.FindForward
[1] = null_key
;
222 keys
.FindBackward
[1] = null_key
;
223 keys
.NextFoundPosition
[1] = null_key
;
224 keys
.PrevFoundPosition
[1] = null_key
;
225 keys
.ToggleFindMode
[1] = null_key
;
226 keys
.EditTags
[1] = null_key
;
227 keys
.SongInfo
[1] = null_key
;
228 keys
.ArtistInfo
[1] = null_key
;
229 keys
.GoToPosition
[1] = null_key
;
230 keys
.Lyrics
[1] = null_key
;
231 keys
.ReverseSelection
[1] = null_key
;
232 keys
.DeselectAll
[1] = null_key
;
233 keys
.AddSelected
[1] = null_key
;
234 keys
.Clear
[1] = null_key
;
235 keys
.Crop
[1] = null_key
;
236 keys
.MvSongUp
[1] = null_key
;
237 keys
.MvSongDown
[1] = null_key
;
238 keys
.MoveTo
[1] = null_key
;
239 keys
.Add
[1] = null_key
;
240 keys
.SavePlaylist
[1] = null_key
;
241 keys
.GoToNowPlaying
[1] = null_key
;
242 keys
.GoToContainingDir
[1] = null_key
;
243 keys
.GoToMediaLibrary
[1] = null_key
;
244 keys
.ToggleAutoCenter
[1] = null_key
;
245 keys
.ToggleDisplayMode
[1] = null_key
;
246 keys
.ToggleInterface
[1] = null_key
;
247 keys
.ToggleLyricsDB
[1] = null_key
;
248 keys
.GoToParentDir
[1] = 127;
249 keys
.SwitchTagTypeList
[1] = null_key
;
253 void DefaultConfiguration(ncmpcpp_config
&conf
)
255 conf
.mpd_host
= "localhost";
256 conf
.empty_tag
= "<empty>";
257 conf
.song_list_columns_format
= "(7f)[green]{l} (25)[cyan]{a} (40)[]{t} (30)[red]{b}";
258 conf
.song_list_format
= "{{%a - }{%t}|{$8%f$9}$R{$3(%l)$9}}";
259 conf
.song_status_format
= "{{{%a{ \"%b\"{ (%y)}} - }{%t}}|{%f}}";
260 conf
.song_status_format_no_colors
= conf
.song_status_format
;
261 conf
.song_window_title_format
= "{{%a - }{%t}|{%f}}";
262 conf
.song_library_format
= "{{%n - }{%t}|{%f}}";
263 conf
.tag_editor_album_format
= "{{(%y) }%b}";
264 conf
.new_header_first_line
= "{$b$1$aqqu$/a$9 {%t}|{%f} $1$atqq$/a$9$/b}";
265 conf
.new_header_second_line
= "{{{$4$b%a$/b$9}{ - $7%b$9}{ ($4%y$9)}}|{%D}}";
266 conf
.browser_playlist_prefix
<< clRed
<< "(playlist)" << clEnd
<< ' ';
267 conf
.progressbar
= U("=>");
268 conf
.pattern
= "%n - %t";
269 conf
.selected_item_prefix
<< clMagenta
;
270 conf
.selected_item_suffix
<< clEnd
;
271 conf
.now_playing_prefix
<< fmtBold
;
272 conf
.now_playing_suffix
<< fmtBoldEnd
;
273 conf
.color1
= clWhite
;
274 conf
.color2
= clGreen
;
275 conf
.empty_tags_color
= clCyan
;
276 conf
.header_color
= clDefault
;
277 conf
.volume_color
= clDefault
;
278 conf
.state_line_color
= clDefault
;
279 conf
.state_flags_color
= clDefault
;
280 conf
.main_color
= clYellow
;
281 conf
.main_highlight_color
= conf
.main_color
;
282 conf
.progressbar_color
= clDefault
;
283 conf
.statusbar_color
= clDefault
;
284 conf
.alternative_ui_separator_color
= clBlack
;
285 conf
.active_column_color
= clRed
;
286 conf
.window_border
= brGreen
;
287 conf
.active_window_border
= brRed
;
288 conf
.media_lib_primary_tag
= MPD_TAG_ARTIST
;
289 conf
.enable_idle_notifications
= false;
290 conf
.colors_enabled
= true;
291 conf
.fancy_scrolling
= true;
292 conf
.playlist_show_remaining_time
= false;
293 conf
.columns_in_playlist
= false;
294 conf
.columns_in_browser
= false;
295 conf
.columns_in_search_engine
= false;
296 conf
.header_visibility
= true;
297 conf
.header_text_scrolling
= true;
298 conf
.statusbar_visibility
= true;
299 conf
.centered_cursor
= false;
300 conf
.screen_switcher_browser_only
= true;
301 conf
.autocenter_mode
= false;
302 conf
.wrapped_search
= true;
303 conf
.space_selects
= false;
304 conf
.ncmpc_like_songs_adding
= false;
305 conf
.albums_in_tag_editor
= false;
306 conf
.incremental_seeking
= true;
307 conf
.now_playing_lyrics
= false;
308 conf
.local_browser_show_hidden_files
= false;
309 conf
.search_in_db
= true;
310 conf
.display_screens_numbers_on_start
= true;
311 conf
.jump_to_now_playing_song_at_start
= true;
312 conf
.clock_display_seconds
= false;
313 conf
.display_bitrate
= false;
314 conf
.display_remaining_time
= false;
315 conf
.ignore_leading_the
= false;
316 conf
.block_search_constraints_change
= true;
317 conf
.use_console_editor
= false;
318 conf
.use_cyclic_scrolling
= false;
319 conf
.allow_physical_files_deletion
= false;
320 conf
.allow_physical_directories_deletion
= false;
321 conf
.ask_before_clearing_main_playlist
= false;
322 conf
.mouse_support
= true;
323 conf
.mouse_list_scroll_whole_page
= true;
324 conf
.new_design
= false;
325 conf
.visualizer_use_wave
= true;
326 conf
.browser_sort_by_mtime
= false;
327 conf
.tag_editor_extended_numeration
= false;
328 conf
.media_library_display_date
= true;
329 conf
.set_window_title
= true;
330 conf
.mpd_port
= 6600;
331 conf
.mpd_connection_timeout
= 15;
332 conf
.crossfade_time
= 5;
334 conf
.playlist_disable_highlight_delay
= 5;
335 conf
.message_delay_time
= 4;
338 conf
.lines_scrolled
= 2;
339 conf
.search_engine_default_search_mode
= 0;
340 conf
.selected_item_suffix_length
= 0;
341 # ifdef HAVE_LANGINFO_H
342 conf
.system_encoding
= nl_langinfo(CODESET
);
343 if (conf
.system_encoding
== "UTF-8") // mpd uses utf-8 by default so no need to convert
344 conf
.system_encoding
.clear();
345 # endif // HAVE_LANGINFO_H
348 void ReadKeys(ncmpcpp_keys
&keys
)
350 std::ifstream
f(keys_config_file
.c_str());
359 if (!key
.empty() && key
[0] != '#')
361 if (key
.find("key_up ") != std::string::npos
)
362 GetKeys(key
, keys
.Up
);
363 else if (key
.find("key_down ") != std::string::npos
)
364 GetKeys(key
, keys
.Down
);
365 else if (key
.find("key_page_up ") != std::string::npos
)
366 GetKeys(key
, keys
.PageUp
);
367 else if (key
.find("key_page_down ") != std::string::npos
)
368 GetKeys(key
, keys
.PageDown
);
369 else if (key
.find("key_home ") != std::string::npos
)
370 GetKeys(key
, keys
.Home
);
371 else if (key
.find("key_end ") != std::string::npos
)
372 GetKeys(key
, keys
.End
);
373 else if (key
.find("key_space ") != std::string::npos
)
374 GetKeys(key
, keys
.Space
);
375 else if (key
.find("key_enter ") != std::string::npos
)
376 GetKeys(key
, keys
.Enter
);
377 else if (key
.find("key_delete ") != std::string::npos
)
378 GetKeys(key
, keys
.Delete
);
379 else if (key
.find("key_volume_up ") != std::string::npos
)
380 GetKeys(key
, keys
.VolumeUp
);
381 else if (key
.find("key_volume_down ") != std::string::npos
)
382 GetKeys(key
, keys
.VolumeDown
);
383 else if (key
.find("key_screen_switcher ") != std::string::npos
)
384 GetKeys(key
, keys
.ScreenSwitcher
);
385 else if (key
.find("key_help ") != std::string::npos
)
386 GetKeys(key
, keys
.Help
);
387 else if (key
.find("key_playlist ") != std::string::npos
)
388 GetKeys(key
, keys
.Playlist
);
389 else if (key
.find("key_browser ") != std::string::npos
)
390 GetKeys(key
, keys
.Browser
);
391 else if (key
.find("key_search_engine ") != std::string::npos
)
392 GetKeys(key
, keys
.SearchEngine
);
393 else if (key
.find("key_media_library ") != std::string::npos
)
394 GetKeys(key
, keys
.MediaLibrary
);
395 else if (key
.find("key_playlist_editor ") != std::string::npos
)
396 GetKeys(key
, keys
.PlaylistEditor
);
397 else if (key
.find("key_tag_editor ") != std::string::npos
)
398 GetKeys(key
, keys
.TagEditor
);
399 else if (key
.find("key_outputs ") != std::string::npos
)
400 GetKeys(key
, keys
.Outputs
);
401 else if (key
.find("key_music_visualizer ") != std::string::npos
)
402 GetKeys(key
, keys
.Visualizer
);
403 else if (key
.find("key_clock ") != std::string::npos
)
404 GetKeys(key
, keys
.Clock
);
405 else if (key
.find("key_server_info ") != std::string::npos
)
406 GetKeys(key
, keys
.ServerInfo
);
407 else if (key
.find("key_stop ") != std::string::npos
)
408 GetKeys(key
, keys
.Stop
);
409 else if (key
.find("key_pause ") != std::string::npos
)
410 GetKeys(key
, keys
.Pause
);
411 else if (key
.find("key_next ") != std::string::npos
)
412 GetKeys(key
, keys
.Next
);
413 else if (key
.find("key_prev ") != std::string::npos
)
414 GetKeys(key
, keys
.Prev
);
415 else if (key
.find("key_seek_forward ") != std::string::npos
)
416 GetKeys(key
, keys
.SeekForward
);
417 else if (key
.find("key_seek_backward ") != std::string::npos
)
418 GetKeys(key
, keys
.SeekBackward
);
419 else if (key
.find("key_toggle_repeat ") != std::string::npos
)
420 GetKeys(key
, keys
.ToggleRepeat
);
421 else if (key
.find("key_toggle_random ") != std::string::npos
)
422 GetKeys(key
, keys
.ToggleRandom
);
423 else if (key
.find("key_toggle_single ") != std::string::npos
)
424 GetKeys(key
, keys
.ToggleSingle
);
425 else if (key
.find("key_toggle_consume ") != std::string::npos
)
426 GetKeys(key
, keys
.ToggleConsume
);
427 else if (key
.find("key_toggle_replay_gain_mode ") != std::string::npos
)
428 GetKeys(key
, keys
.ToggleReplayGainMode
);
429 else if (key
.find("key_toggle_space_mode ") != std::string::npos
)
430 GetKeys(key
, keys
.ToggleSpaceMode
);
431 else if (key
.find("key_toggle_add_mode ") != std::string::npos
)
432 GetKeys(key
, keys
.ToggleAddMode
);
433 else if (key
.find("key_toggle_mouse ") != std::string::npos
)
434 GetKeys(key
, keys
.ToggleMouse
);
435 else if (key
.find("key_shuffle ") != std::string::npos
)
436 GetKeys(key
, keys
.Shuffle
);
437 else if (key
.find("key_toggle_crossfade ") != std::string::npos
)
438 GetKeys(key
, keys
.ToggleCrossfade
);
439 else if (key
.find("key_set_crossfade ") != std::string::npos
)
440 GetKeys(key
, keys
.SetCrossfade
);
441 else if (key
.find("key_update_db ") != std::string::npos
)
442 GetKeys(key
, keys
.UpdateDB
);
443 else if (key
.find("key_sort_playlist ") != std::string::npos
)
444 GetKeys(key
, keys
.SortPlaylist
);
445 else if (key
.find("key_apply_filter ") != std::string::npos
)
446 GetKeys(key
, keys
.ApplyFilter
);
447 else if (key
.find("key_find_forward ") != std::string::npos
)
448 GetKeys(key
, keys
.FindForward
);
449 else if (key
.find("key_find_backward ") != std::string::npos
)
450 GetKeys(key
, keys
.FindBackward
);
451 else if (key
.find("key_next_found_position ") != std::string::npos
)
452 GetKeys(key
, keys
.NextFoundPosition
);
453 else if (key
.find("key_prev_found_position ") != std::string::npos
)
454 GetKeys(key
, keys
.PrevFoundPosition
);
455 else if (key
.find("key_toggle_find_mode ") != std::string::npos
)
456 GetKeys(key
, keys
.ToggleFindMode
);
457 else if (key
.find("key_edit_tags ") != std::string::npos
)
458 GetKeys(key
, keys
.EditTags
);
459 else if (key
.find("key_go_to_position ") != std::string::npos
)
460 GetKeys(key
, keys
.GoToPosition
);
461 else if (key
.find("key_song_info ") != std::string::npos
)
462 GetKeys(key
, keys
.SongInfo
);
463 else if (key
.find("key_artist_info ") != std::string::npos
)
464 GetKeys(key
, keys
.ArtistInfo
);
465 else if (key
.find("key_lyrics ") != std::string::npos
)
466 GetKeys(key
, keys
.Lyrics
);
467 else if (key
.find("key_reverse_selection ") != std::string::npos
)
468 GetKeys(key
, keys
.ReverseSelection
);
469 else if (key
.find("key_deselect_all ") != std::string::npos
)
470 GetKeys(key
, keys
.DeselectAll
);
471 else if (key
.find("key_add_selected_items ") != std::string::npos
)
472 GetKeys(key
, keys
.AddSelected
);
473 else if (key
.find("key_clear ") != std::string::npos
)
474 GetKeys(key
, keys
.Clear
);
475 else if (key
.find("key_crop ") != std::string::npos
)
476 GetKeys(key
, keys
.Crop
);
477 else if (key
.find("key_move_song_up ") != std::string::npos
)
478 GetKeys(key
, keys
.MvSongUp
);
479 else if (key
.find("key_move_song_down ") != std::string::npos
)
480 GetKeys(key
, keys
.MvSongDown
);
481 else if (key
.find("key_move_to ") != std::string::npos
)
482 GetKeys(key
, keys
.MoveTo
);
483 else if (key
.find("key_add ") != std::string::npos
)
484 GetKeys(key
, keys
.Add
);
485 else if (key
.find("key_save_playlist ") != std::string::npos
)
486 GetKeys(key
, keys
.SavePlaylist
);
487 else if (key
.find("key_go_to_now_playing ") != std::string::npos
)
488 GetKeys(key
, keys
.GoToNowPlaying
);
489 else if (key
.find("key_toggle_auto_center ") != std::string::npos
)
490 GetKeys(key
, keys
.ToggleAutoCenter
);
491 else if (key
.find("key_toggle_display_mode ") != std::string::npos
)
492 GetKeys(key
, keys
.ToggleDisplayMode
);
493 else if (key
.find("key_toggle_lyrics_db ") != std::string::npos
)
494 GetKeys(key
, keys
.ToggleLyricsDB
);
495 else if (key
.find("key_go_to_containing_directory ") != std::string::npos
)
496 GetKeys(key
, keys
.GoToContainingDir
);
497 else if (key
.find("key_go_to_media_library ") != std::string::npos
)
498 GetKeys(key
, keys
.GoToMediaLibrary
);
499 else if (key
.find("key_go_to_parent_dir ") != std::string::npos
)
500 GetKeys(key
, keys
.GoToParentDir
);
501 else if (key
.find("key_switch_tag_type_list ") != std::string::npos
)
502 GetKeys(key
, keys
.SwitchTagTypeList
);
503 else if (key
.find("key_quit ") != std::string::npos
)
504 GetKeys(key
, keys
.Quit
);
510 void ReadConfiguration(ncmpcpp_config
&conf
)
512 std::ifstream
f(config_file
.c_str());
515 while (f
.is_open() && !f
.eof())
518 if (!cl
.empty() && cl
[0] != '#')
520 v
= GetLineValue(cl
);
521 if (cl
.find("mpd_host") != std::string::npos
)
526 else if (cl
.find("mpd_music_dir") != std::string::npos
)
530 // if ~ is used at the beginning, replace it with user's home folder
532 v
.replace(0, 1, home_path
);
533 conf
.mpd_music_dir
= v
+ "/";
536 else if (cl
.find("visualizer_fifo_path") != std::string::npos
)
539 conf
.visualizer_fifo_path
= v
;
541 else if (cl
.find("visualizer_output_name") != std::string::npos
)
544 conf
.visualizer_output_name
= v
;
546 else if (cl
.find("mpd_port") != std::string::npos
)
549 conf
.mpd_port
= StrToInt(v
);
551 else if (cl
.find("mpd_connection_timeout") != std::string::npos
)
554 conf
.mpd_connection_timeout
= StrToInt(v
);
556 else if (cl
.find("mpd_crossfade_time") != std::string::npos
)
559 conf
.crossfade_time
= StrToInt(v
);
561 else if (cl
.find("seek_time") != std::string::npos
)
564 conf
.seek_time
= StrToInt(v
);
566 else if (cl
.find("playlist_disable_highlight_delay") != std::string::npos
)
568 if (StrToInt(v
) >= 0)
569 conf
.playlist_disable_highlight_delay
= StrToInt(v
);
571 else if (cl
.find("message_delay_time") != std::string::npos
)
574 conf
.message_delay_time
= StrToInt(v
);
576 else if (cl
.find("song_list_format") != std::string::npos
)
580 MPD::Song::ValidateFormat("song_list_format", v
);
581 conf
.song_list_format
= '{';
582 conf
.song_list_format
+= v
;
583 conf
.song_list_format
+= '}';
586 else if (cl
.find("song_columns_list_format") != std::string::npos
)
589 conf
.song_list_columns_format
= v
;
591 else if (cl
.find("song_status_format") != std::string::npos
)
595 MPD::Song::ValidateFormat("song_status_format", v
);
596 conf
.song_status_format
= '{';
597 conf
.song_status_format
+= v
;
598 conf
.song_status_format
+= '}';
599 // make version without colors
600 if (conf
.song_status_format
.find("$") != std::string::npos
)
602 Buffer status_no_colors
;
603 String2Buffer(conf
.song_status_format
, status_no_colors
);
604 conf
.song_status_format_no_colors
= status_no_colors
.Str();
607 conf
.song_status_format_no_colors
= conf
.song_status_format
;
610 else if (cl
.find("song_library_format") != std::string::npos
)
614 MPD::Song::ValidateFormat("song_library_format", v
);
615 conf
.song_library_format
= '{';
616 conf
.song_library_format
+= v
;
617 conf
.song_library_format
+= '}';
620 else if (cl
.find("tag_editor_album_format") != std::string::npos
)
624 MPD::Song::ValidateFormat("tag_editor_album_format", v
);
625 conf
.tag_editor_album_format
= '{';
626 conf
.tag_editor_album_format
+= v
;
627 conf
.tag_editor_album_format
+= '}';
630 else if (cl
.find("external_editor") != std::string::npos
)
633 conf
.external_editor
= v
;
635 else if (cl
.find("system_encoding") != std::string::npos
)
638 conf
.system_encoding
= v
+ "//TRANSLIT";
640 else if (cl
.find("execute_on_song_change") != std::string::npos
)
643 conf
.execute_on_song_change
= v
;
645 else if (cl
.find("alternative_header_first_line_format") != std::string::npos
)
649 MPD::Song::ValidateFormat("alternative_header_first_line_format", v
);
650 conf
.new_header_first_line
= '{';
651 conf
.new_header_first_line
+= v
;
652 conf
.new_header_first_line
+= '}';
655 else if (cl
.find("alternative_header_second_line_format") != std::string::npos
)
659 MPD::Song::ValidateFormat("alternative_header_second_line_format", v
);
660 conf
.new_header_second_line
= '{';
661 conf
.new_header_second_line
+= v
;
662 conf
.new_header_second_line
+= '}';
665 else if (cl
.find("browser_playlist_prefix") != std::string::npos
)
669 conf
.browser_playlist_prefix
.Clear();
670 String2Buffer(v
, conf
.browser_playlist_prefix
);
673 else if (cl
.find("progressbar_look") != std::string::npos
)
675 conf
.progressbar
= TO_WSTRING(v
);
676 if (conf
.progressbar
.length() != 2)
677 FatalError("the length of progressbar_look is not two characters long!");
679 else if (cl
.find("default_tag_editor_pattern") != std::string::npos
)
684 else if (cl
.find("selected_item_prefix") != std::string::npos
)
688 conf
.selected_item_prefix
.Clear();
689 String2Buffer(v
, conf
.selected_item_prefix
);
692 else if (cl
.find("selected_item_suffix") != std::string::npos
)
696 conf
.selected_item_suffix
.Clear();
697 String2Buffer(v
, conf
.selected_item_suffix
);
698 conf
.selected_item_suffix_length
= Window::Length(TO_WSTRING(conf
.selected_item_suffix
.Str()));
701 else if (cl
.find("now_playing_prefix") != std::string::npos
)
705 conf
.now_playing_prefix
.Clear();
706 String2Buffer(v
, conf
.now_playing_prefix
);
709 else if (cl
.find("now_playing_suffix") != std::string::npos
)
713 conf
.now_playing_suffix
.Clear();
714 String2Buffer(TO_WSTRING(v
), conf
.now_playing_suffix
);
717 else if (cl
.find("color1") != std::string::npos
)
720 conf
.color1
= IntoColor(v
);
722 else if (cl
.find("color2") != std::string::npos
)
725 conf
.color2
= IntoColor(v
);
727 else if (cl
.find("mpd_communication_mode") != std::string::npos
)
729 conf
.enable_idle_notifications
= v
== "notifications";
731 else if (cl
.find("colors_enabled") != std::string::npos
)
733 conf
.colors_enabled
= v
== "yes";
735 else if (cl
.find("fancy_scrolling") != std::string::npos
)
737 conf
.fancy_scrolling
= v
== "yes";
739 else if (cl
.find("cyclic_scrolling") != std::string::npos
)
741 conf
.use_cyclic_scrolling
= v
== "yes";
743 else if (cl
.find("playlist_show_remaining_time") != std::string::npos
)
745 conf
.playlist_show_remaining_time
= v
== "yes";
747 else if (cl
.find("playlist_display_mode") != std::string::npos
)
749 conf
.columns_in_playlist
= v
== "columns";
751 else if (cl
.find("browser_display_mode") != std::string::npos
)
753 conf
.columns_in_browser
= v
== "columns";
755 else if (cl
.find("search_engine_display_mode") != std::string::npos
)
757 conf
.columns_in_search_engine
= v
== "columns";
759 else if (cl
.find("header_visibility") != std::string::npos
)
761 conf
.header_visibility
= v
== "yes";
763 else if (cl
.find("header_text_scrolling") != std::string::npos
)
765 conf
.header_text_scrolling
= v
== "yes";
767 else if (cl
.find("statusbar_visibility") != std::string::npos
)
769 conf
.statusbar_visibility
= v
== "yes";
771 else if (cl
.find("screen_switcher_browser_only") != std::string::npos
)
773 conf
.screen_switcher_browser_only
= v
== "yes";
775 else if (cl
.find("autocenter_mode") != std::string::npos
)
777 conf
.autocenter_mode
= v
== "yes";
779 else if (cl
.find("centered_cursor") != std::string::npos
)
781 conf
.centered_cursor
= v
== "yes";
783 else if (cl
.find("default_find_mode") != std::string::npos
)
785 conf
.wrapped_search
= v
== "wrapped";
787 else if (cl
.find("default_space_mode") != std::string::npos
)
789 conf
.space_selects
= v
== "select";
791 else if (cl
.find("default_tag_editor_left_col") != std::string::npos
)
793 conf
.albums_in_tag_editor
= v
== "albums";
795 else if (cl
.find("incremental_seeking") != std::string::npos
)
797 conf
.incremental_seeking
= v
== "yes";
799 else if (cl
.find("show_hidden_files_in_local_browser") != std::string::npos
)
801 conf
.local_browser_show_hidden_files
= v
== "yes";
803 else if (cl
.find("follow_now_playing_lyrics") != std::string::npos
)
805 conf
.now_playing_lyrics
= v
== "yes";
807 else if (cl
.find("ncmpc_like_songs_adding") != std::string::npos
)
809 conf
.ncmpc_like_songs_adding
= v
== "yes";
811 else if (cl
.find("default_place_to_search_in") != std::string::npos
)
813 conf
.search_in_db
= v
== "database";
815 else if (cl
.find("display_screens_numbers_on_start") != std::string::npos
)
817 conf
.display_screens_numbers_on_start
= v
== "yes";
819 else if (cl
.find("jump_to_now_playing_song_at_start") != std::string::npos
)
821 conf
.jump_to_now_playing_song_at_start
= v
== "yes";
823 else if (cl
.find("clock_display_seconds") != std::string::npos
)
825 conf
.clock_display_seconds
= v
== "yes";
827 else if (cl
.find("display_bitrate") != std::string::npos
)
829 conf
.display_bitrate
= v
== "yes";
831 else if (cl
.find("display_remaining_time") != std::string::npos
)
833 conf
.display_remaining_time
= v
== "yes";
835 else if (cl
.find("ignore_leading_the") != std::string::npos
)
837 conf
.ignore_leading_the
= v
== "yes";
839 else if (cl
.find("use_console_editor") != std::string::npos
)
841 conf
.use_console_editor
= v
== "yes";
843 else if (cl
.find("block_search_constraints_change_if_items_found") != std::string::npos
)
845 conf
.block_search_constraints_change
= v
== "yes";
847 else if (cl
.find("allow_physical_files_deletion") != std::string::npos
)
849 conf
.allow_physical_files_deletion
= v
== "yes";
851 else if (cl
.find("allow_physical_directories_deletion") != std::string::npos
)
853 conf
.allow_physical_directories_deletion
= v
== "yes";
855 else if (cl
.find("ask_before_clearing_main_playlist") != std::string::npos
)
857 conf
.ask_before_clearing_main_playlist
= v
== "yes";
859 else if (cl
.find("visualizer_type") != std::string::npos
)
861 conf
.visualizer_use_wave
= v
== "wave";
863 else if (cl
.find("mouse_support") != std::string::npos
)
865 conf
.mouse_support
= v
== "yes";
867 else if (cl
.find("mouse_list_scroll_whole_page") != std::string::npos
)
869 conf
.mouse_list_scroll_whole_page
= v
== "yes";
871 else if (cl
.find("user_interface") != std::string::npos
)
873 conf
.new_design
= v
== "alternative";
875 else if (cl
.find("tag_editor_extended_numeration") != std::string::npos
)
877 conf
.tag_editor_extended_numeration
= v
== "yes";
879 else if (cl
.find("media_library_display_date") != std::string::npos
)
881 conf
.media_library_display_date
= v
== "yes";
883 else if (cl
.find("enable_window_title") != std::string::npos
)
885 conf
.set_window_title
= v
== "yes";
887 else if (cl
.find("regular_expressions") != std::string::npos
)
889 conf
.regex_type
= REG_EXTENDED
* (v
!= "basic");
891 # ifdef HAVE_CURL_CURL_H
892 else if (cl
.find("lyrics_database") != std::string::npos
)
896 unsigned n
= StrToInt(v
)-1;
897 conf
.lyrics_db
= n
< Lyrics::DBs
? n
: 0;
900 # endif // HAVE_CURL_CURL_H
901 else if (cl
.find("lines_scrolled") != std::string::npos
)
904 conf
.lines_scrolled
= StrToInt(v
);
906 else if (cl
.find("search_engine_default_search_mode") != std::string::npos
)
910 unsigned mode
= StrToInt(v
);
912 conf
.search_engine_default_search_mode
= mode
;
915 else if (cl
.find("song_window_title_format") != std::string::npos
)
919 MPD::Song::ValidateFormat("song_window_title_format", v
);
920 conf
.song_window_title_format
= '{';
921 conf
.song_window_title_format
+= v
;
922 conf
.song_window_title_format
+= '}';
925 else if (cl
.find("empty_tag_marker") != std::string::npos
)
927 conf
.empty_tag
= v
; // is this case empty string is allowed
929 else if (cl
.find("empty_tag_color") != std::string::npos
)
932 conf
.empty_tags_color
= IntoColor(v
);
934 else if (cl
.find("header_window_color") != std::string::npos
)
937 conf
.header_color
= IntoColor(v
);
939 else if (cl
.find("volume_color") != std::string::npos
)
942 conf
.volume_color
= IntoColor(v
);
944 else if (cl
.find("state_line_color") != std::string::npos
)
947 conf
.state_line_color
= IntoColor(v
);
949 else if (cl
.find("state_flags_color") != std::string::npos
)
952 conf
.state_flags_color
= IntoColor(v
);
954 else if (cl
.find("main_window_color") != std::string::npos
)
957 conf
.main_color
= IntoColor(v
);
959 else if (cl
.find("main_window_highlight_color") != std::string::npos
)
962 conf
.main_highlight_color
= IntoColor(v
);
964 else if (cl
.find("progressbar_color") != std::string::npos
)
967 conf
.progressbar_color
= IntoColor(v
);
969 else if (cl
.find("statusbar_color") != std::string::npos
)
972 conf
.statusbar_color
= IntoColor(v
);
974 else if (cl
.find("alternative_ui_separator_color") != std::string::npos
)
977 conf
.alternative_ui_separator_color
= IntoColor(v
);
979 else if (cl
.find("active_column_color") != std::string::npos
)
982 conf
.active_column_color
= IntoColor(v
);
984 else if (cl
.find("window_border_color ") != std::string::npos
)
987 conf
.window_border
= IntoBorder(v
);
989 else if (cl
.find("active_window_border") != std::string::npos
)
992 conf
.active_window_border
= IntoBorder(v
);
994 else if (cl
.find("media_library_left_column") != std::string::npos
)
997 conf
.media_lib_primary_tag
= IntoTagItem(v
[0]);
1003 for (std::string width
= GetLineValue(conf
.song_list_columns_format
, '(', ')', 1); !width
.empty(); width
= GetLineValue(conf
.song_list_columns_format
, '(', ')', 1))
1006 col
.color
= IntoColor(GetLineValue(conf
.song_list_columns_format
, '[', ']', 1));
1007 std::string tag_type
= GetLineValue(conf
.song_list_columns_format
, '{', '}', 1);
1008 if (tag_type
.length() > 0) // at least tag type was specified
1009 col
.type
= tag_type
[0];
1013 col
.display_empty_tag
= 0;
1015 col
.fixed
= *width
.rbegin() == 'f';
1016 for (std::string::const_iterator it
= tag_type
.begin()+(tag_type
.length() > 0); it
!= tag_type
.end(); ++it
)
1021 col
.right_alignment
= 1;
1024 col
.display_empty_tag
= 0;
1028 col
.width
= StrToInt(width
);
1029 conf
.columns
.push_back(col
);