File src/console.c changed (mode: 100644) (index 7fcf19c..87bedbf) |
... |
... |
void console(const char * format, ...) { |
65 |
65 |
time_t t; |
time_t t; |
66 |
66 |
va_list ap; |
va_list ap; |
67 |
67 |
|
|
68 |
|
pthread_mutex_lock(&console_mutex); |
|
69 |
|
|
|
70 |
68 |
line = new_logline(); |
line = new_logline(); |
71 |
69 |
|
|
72 |
70 |
va_start(ap, format); |
va_start(ap, format); |
|
... |
... |
void console(const char * format, ...) { |
93 |
91 |
if (console_window->num_lines < console_window->height || console_window->position + console_window->height + 1 >= console_window->num_lines) { |
if (console_window->num_lines < console_window->height || console_window->position + console_window->height + 1 >= console_window->num_lines) { |
94 |
92 |
console_scroll(1); |
console_scroll(1); |
95 |
93 |
} |
} |
96 |
|
|
|
97 |
|
pthread_mutex_unlock(&console_mutex); |
|
98 |
94 |
} |
} |
99 |
95 |
|
|
100 |
96 |
void console_draw_lines(long start, long end) { |
void console_draw_lines(long start, long end) { |
|
... |
... |
void console_draw_lines(long start, long end) { |
103 |
99 |
long ptr; |
long ptr; |
104 |
100 |
logline_t * line; |
logline_t * line; |
105 |
101 |
|
|
106 |
|
pms_curses_lock(); |
|
107 |
|
|
|
108 |
102 |
ptr = console_window->position + start; |
ptr = console_window->position + start; |
109 |
103 |
for (s = start; s <= end; s++) { |
for (s = start; s <= end; s++) { |
110 |
104 |
if (ptr >= console_window->num_lines) { |
if (ptr >= console_window->num_lines) { |
|
... |
... |
void console_draw_lines(long start, long end) { |
116 |
110 |
} |
} |
117 |
111 |
|
|
118 |
112 |
wrefresh(window_main); |
wrefresh(window_main); |
119 |
|
|
|
120 |
|
pms_curses_unlock(); |
|
121 |
113 |
} |
} |
122 |
114 |
|
|
123 |
115 |
int console_scroll(long delta) { |
int console_scroll(long delta) { |
File src/mpd.c changed (mode: 100644) (index 0305d0d..8fc1fb2) |
... |
... |
struct mpd_connection * pms_mpd_connect(const char * server, unsigned int port, |
45 |
45 |
return connection; |
return connection; |
46 |
46 |
} |
} |
47 |
47 |
|
|
48 |
|
void pms_get_mpd_status(struct mpd_connection * connection, struct pms_state_t * state) { |
|
|
48 |
|
void pms_mpd_get_status(struct mpd_connection * connection, struct pms_state_t * state) { |
49 |
49 |
if (state->status) { |
if (state->status) { |
50 |
50 |
mpd_status_free(state->status); |
mpd_status_free(state->status); |
51 |
51 |
} |
} |
|
... |
... |
void pms_handle_mpd_idle_update(struct mpd_connection * connection, struct pms_s |
82 |
82 |
} |
} |
83 |
83 |
|
|
84 |
84 |
if (flags & (MPD_IDLE_QUEUE | MPD_IDLE_PLAYER | MPD_IDLE_MIXER | MPD_IDLE_OPTIONS)) { |
if (flags & (MPD_IDLE_QUEUE | MPD_IDLE_PLAYER | MPD_IDLE_MIXER | MPD_IDLE_OPTIONS)) { |
85 |
|
pms_get_mpd_status(connection, state); |
|
|
85 |
|
pms_mpd_get_status(connection, state); |
86 |
86 |
} |
} |
87 |
87 |
|
|
88 |
88 |
topbar_draw(); |
topbar_draw(); |
89 |
89 |
|
|
90 |
90 |
} |
} |
91 |
|
|
|
File src/mpd.h changed (mode: 100644) (index 245fe9e..d253068) |
... |
... |
struct pms_state_t; |
23 |
23 |
|
|
24 |
24 |
struct mpd_connection * pms_mpd_connect(const char * server, unsigned int port, unsigned int timeout); |
struct mpd_connection * pms_mpd_connect(const char * server, unsigned int port, unsigned int timeout); |
25 |
25 |
|
|
26 |
|
void pms_get_mpd_status(struct mpd_connection * connection, struct pms_state_t * state); |
|
|
26 |
|
void pms_mpd_get_status(struct mpd_connection * connection, struct pms_state_t * state); |
27 |
27 |
|
|
28 |
28 |
void pms_handle_mpd_idle_update(struct mpd_connection * connection, struct pms_state_t * state, enum mpd_idle flags); |
void pms_handle_mpd_idle_update(struct mpd_connection * connection, struct pms_state_t * state, enum mpd_idle flags); |
File src/pms.c changed (mode: 100644) (index 9c8fca3..c1eb6dc) |
... |
... |
void shutdown() { |
79 |
79 |
|
|
80 |
80 |
void signal_resize(int signal) { |
void signal_resize(int signal) { |
81 |
81 |
console("Resized to %d x %d", LINES, COLS); |
console("Resized to %d x %d", LINES, COLS); |
82 |
|
pms_curses_lock(); |
|
83 |
82 |
curses_destroy_windows(); |
curses_destroy_windows(); |
84 |
83 |
curses_init_windows(); |
curses_init_windows(); |
85 |
|
pms_curses_unlock(); |
|
86 |
84 |
} |
} |
87 |
85 |
|
|
88 |
86 |
void signal_kill(int signal) { |
void signal_kill(int signal) { |
|
... |
... |
int main(int argc, char** argv) { |
187 |
185 |
|
|
188 |
186 |
return PMS_EXIT_SUCCESS; |
return PMS_EXIT_SUCCESS; |
189 |
187 |
} |
} |
190 |
|
|
|
191 |
|
void pms_status_lock() { |
|
192 |
|
pthread_mutex_lock(&status_mutex); |
|
193 |
|
} |
|
194 |
|
|
|
195 |
|
void pms_status_unlock() { |
|
196 |
|
pthread_mutex_unlock(&status_mutex); |
|
197 |
|
} |
|
File src/topbar.c changed (mode: 100644) (index feec7f2..8e9cebd) |
... |
... |
void topbar_draw() { |
29 |
29 |
return; |
return; |
30 |
30 |
} |
} |
31 |
31 |
|
|
32 |
|
pms_curses_lock(); |
|
33 |
|
pms_status_lock(); |
|
34 |
|
|
|
35 |
32 |
mvwprintw(window_topbar, 0, 0, "%s %s %s [%s]", |
mvwprintw(window_topbar, 0, 0, "%s %s %s [%s]", |
36 |
33 |
PACKAGE_NAME, PACKAGE_VERSION, |
PACKAGE_NAME, PACKAGE_VERSION, |
37 |
34 |
topbar_playing_str(), |
topbar_playing_str(), |
38 |
35 |
topbar_mode_str()); |
topbar_mode_str()); |
39 |
36 |
wrefresh(window_topbar); |
wrefresh(window_topbar); |
40 |
|
|
|
41 |
|
pms_status_unlock(); |
|
42 |
|
pms_curses_unlock(); |
|
43 |
|
|
|
44 |
37 |
} |
} |
45 |
38 |
|
|
46 |
39 |
const char * topbar_mode_str() { |
const char * topbar_mode_str() { |
File src/window.c changed (mode: 100644) (index 5ca9b33..4b70a86) |
... |
... |
int window_scroll(window_t * window, long delta) { |
29 |
29 |
return 0; |
return 0; |
30 |
30 |
} |
} |
31 |
31 |
|
|
32 |
|
pms_curses_lock(); |
|
33 |
|
|
|
34 |
32 |
if (delta > 0) { |
if (delta > 0) { |
35 |
33 |
npos = window->position + delta; |
npos = window->position + delta; |
36 |
34 |
if (npos + window->height > window->num_lines) { |
if (npos + window->height > window->num_lines) { |
|
... |
... |
int window_scroll(window_t * window, long delta) { |
49 |
47 |
wscrl(window_main, delta); |
wscrl(window_main, delta); |
50 |
48 |
wrefresh(window_main); |
wrefresh(window_main); |
51 |
49 |
|
|
52 |
|
pms_curses_unlock(); |
|
53 |
|
|
|
54 |
50 |
return delta; |
return delta; |
55 |
51 |
|
|
56 |
52 |
} |
} |