-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
106 lines (82 loc) · 1.87 KB
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#include "global.h"
#include "utils.h"
#include "windows.h"
#include "basic_info.h"
#include "songs.h"
#include "directory.h"
#include "playlists.h"
#include "visualizer.h"
static void
dynamic_initial(void)
{
conn = setup_connection();
/* initialization require redraw too */
interval_level = 1;
quit_signal = 0;
crt_menu = 0;
/** windows chain initilization **/
wchain_init();
/* check the screen size */
if(stdscr->_maxy < 3 || stdscr->_maxx < 68)
{
endwin();
fprintf(stderr, "screen too small for normally displaying.\n");
exit(1);
}
/** BasicInfo initialization **/
basic_info = basic_info_setup();
/** songlist arguments */
songlist = songlist_setup();
songlist_update();
/** directory arguments **/
directory = directory_setup();
directory_update();
/** playlist arguments **/
playlist = playlist_setup();
playlist_update();
/** the visualizer **/
visualizer = visualizer_setup();
get_fifo_id();
/** windows set initialization **/
being_mode_update(&basic_info->wmode);
//being_mode_update(&songlist->wmode);
}
static
void dynamic_destroy(void)
{
wchain_free();
songlist_free(songlist);
directory_free(directory);
playlist_free(playlist);
visualizer_free(visualizer);
}
static void init_ncurses(void)
{
initscr();
timeout(1); // enable the non block getch()
curs_set(0); // cursor invisible
noecho();
keypad(stdscr, TRUE); // enable getch() get KEY_UP/DOWN
color_init();
}
int main(int argc, char **args)
{
// ncurses for unicode support
setlocale(LC_ALL, "");
// ncurses basic setting
init_ncurses();
dynamic_initial();
/** main loop for keyboard hit daemon */
for(;;)
{
being_mode->listen_keyboard();
if(quit_signal) break;
screen_update_checking();
wchain_size_update();
screen_redraw();
smart_sleep();
}
dynamic_destroy();
endwin();
return 0;
}