2 * Copyright (c) 2006-2011 Ed Schouten <ed@80386.nl>
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * @file gui_internal.h
28 * @brief Internal textual user interface routines.
31 #include CURSES_HEADER
37 * @brief Determine whether our terminal is black or white or color.
39 extern int gui_draw_colors
;
41 * @brief Height percentage of the playlist.
43 extern int gui_draw_ratio
;
45 * @brief Refresh the curses GUI after a terminal resize.
47 void gui_draw_resize(void);
49 * @brief Write all altered data back to the physical terminal.
51 void gui_draw_done(void);
53 * @brief The mutex that locks the GUI down.
55 extern GMutex
*gui_mtx
;
58 * @brief Acquire a lock on the GUI.
63 g_mutex_lock(gui_mtx
);
67 * @brief Release a lock on the GUI.
72 g_mutex_unlock(gui_mtx
);
75 /* Display size ratios */
77 * @brief Height of playlist window.
79 #define GUI_SIZE_PLAYQ_HEIGHT (((LINES * gui_draw_ratio) / 100) - 1)
81 * @brief Offset of the window containing the filebrowser's directory
84 #define GUI_SIZE_BROWSER_DIRNAME_TOP (GUI_SIZE_PLAYQ_HEIGHT + 1)
86 * @brief Offset of the filebrowser window.
88 #define GUI_SIZE_BROWSER_TOP (GUI_SIZE_BROWSER_DIRNAME_TOP + 1)
90 * @brief Height of the filebrowser window.
92 #define GUI_SIZE_BROWSER_HEIGHT (LINES - GUI_SIZE_BROWSER_TOP - 1)
94 * @brief Offset of the message bar window.
96 #define GUI_SIZE_MSGBAR_TOP (LINES - 1)
99 * @brief Curses colour code used to draw bars (status, dirname).
101 #define GUI_COLOR_BAR 2
103 * @brief Curses colour code used to draw blocks (playlist, browser).
105 #define GUI_COLOR_BLOCK 3
107 * @brief Curses colour code used to draw focused selections.
109 #define GUI_COLOR_SELECT 4
111 * @brief Curses colour code used to draw unfocused selections.
113 #define GUI_COLOR_DESELECT 5
115 * @brief Curses colour code used to draw marked items (song currenty
118 #define GUI_COLOR_MARKED 6
121 * @brief Display a standard Yes/No question at the bottom of the screen
122 * and return the user response.
124 int gui_input_askyesno(const char *question
);
126 * @brief Display a string input question at the bottom of the screen
127 * and return the user response.
129 char *gui_input_askstring(const char *question
, const char *defstr
,
130 int (*validator
)(const char *str
, char c
));
136 * @brief Create a bar at the bottom of the terminal displaying
137 * messages and questions.
139 void gui_msgbar_init(void);
141 * @brief Destroy the message bar at the bottom of the screen.
143 void gui_msgbar_destroy(void);
145 * @brief Set the proper size of the message bar after a terminal
148 void gui_msgbar_resize(void);
150 * @brief Redraw the message bar after its contents have been altered.
152 void gui_msgbar_refresh(void);
154 * @brief Flush the text in the message bar.
156 void gui_msgbar_flush(void);
158 * @brief Show a message in the message bar that will only be
159 * overwritten by other messages with this priority. This
160 * routine will also unhide the cursor and show it right after
163 void gui_msgbar_ask(const char *msg
);
169 * @brief Initialize the playlist window.
171 void gui_playq_init(void);
173 * @brief Destroy the playlist window.
175 void gui_playq_destroy(void);
177 * @brief Redraw the playlist window, because of a terminal resize.
179 void gui_playq_resize(void);
182 * @brief Move the cursor of the playlist one item up.
184 void gui_playq_cursor_up(void);
186 * @brief Move the cursor of the playlist one item down.
188 void gui_playq_cursor_down(void);
190 * @brief Move the cursor and the viewport of the playlist one page up.
192 void gui_playq_cursor_pageup(void);
194 * @brief Move the cursor and the viewport of the playlist one page down.
196 void gui_playq_cursor_pagedown(void);
198 * @brief Move the cursor and the viewport of the playlist to the top of
201 void gui_playq_cursor_head(void);
203 * @brief Move the cursor and the viewport of the playlist to the bottom
206 void gui_playq_cursor_tail(void);
208 * @brief Remove the currently selected song from the playlist.
210 void gui_playq_song_remove(void);
212 * @brief Remove all songs from the playlist after presenting the user
215 void gui_playq_song_remove_all(void);
217 * @brief Randomize all songs in the playlist after presenting the user
220 void gui_playq_song_randomize(void);
223 * @brief Add a song before the selected item in the playlist.
225 void gui_playq_song_add_before(struct vfsref
*ve
);
227 * @brief Add a song after the selected item in the playlist.
229 void gui_playq_song_add_after(struct vfsref
*ve
);
231 * @brief Move the currently selected song one up.
233 void gui_playq_song_move_up(void);
235 * @brief Move the currently selected song one down.
237 void gui_playq_song_move_down(void);
239 * @brief Move the currently selected song to the top of the playlist.
241 void gui_playq_song_move_head(void);
243 * @brief Move the currently selected song to the bottom of the
246 void gui_playq_song_move_tail(void);
248 * @brief Start playback on the currently selected song.
250 void gui_playq_song_select(void);
252 * @brief Search for the next item matching gui_input_cursearch in the
255 int gui_playq_searchnext(const struct vfsmatch
*vm
);
257 * @brief Focus or unfocus the playlist.
259 void gui_playq_setfocus(int focus
);
261 * @brief Write the full pathname of the selected item in the message
264 void gui_playq_fullpath(void);
267 * @brief Increment the volume and display the new value.
269 void gui_playq_volume_up(void);
271 * @brief Decrement the volume and display the new value.
273 void gui_playq_volume_down(void);
274 #endif /* BUILD_VOLUME */
276 * @brief Go to the directory containing the selected item.
278 void gui_playq_gotofolder(void);
280 * @brief Go to the current user's home directory.
282 void gui_browser_gotohome(void);
284 * @brief Go to the parent directory of the VFS reference and select the
285 * item which shares the same filename.
287 void gui_browser_gotofile(struct vfsref
*vr
);
293 * @brief Initialize the filebrowser window.
295 void gui_browser_init(void);
297 * @brief Destroy the filebrowser window.
299 void gui_browser_destroy(void);
301 * @brief Redraw the filebrowser, because of a terminal resize.
303 void gui_browser_resize(void);
306 * @brief Move the cursor of the filebrowser one position up.
308 void gui_browser_cursor_up(void);
310 * @brief Move the cursor of the filebrowser one position down.
312 void gui_browser_cursor_down(void);
314 * @brief Move the cursor and the viewport of the filebrowser one page
317 void gui_browser_cursor_pageup(void);
319 * @brief Move the cursor and the viewport of the filebrowser one page
322 void gui_browser_cursor_pagedown(void);
324 * @brief Move the cursor and the viewport of the filebrowser to the top
325 * of the current directory.
327 void gui_browser_cursor_head(void);
329 * @brief Move the cursor and the viewport of the filebrowser to the
330 * bottom of the current directory.
332 void gui_browser_cursor_tail(void);
334 * @brief Change the current working directory of the filebrowser to the
337 void gui_browser_dir_parent(void);
339 * @brief Change the current working directory of the filebrowser to the
340 * currently selected item.
342 void gui_browser_dir_enter(void);
344 * @brief Add the current selection to the tail of the playlist.
346 void gui_browser_playq_add_tail(void);
348 * @brief Add the current selection to the head of the playlist.
350 void gui_browser_playq_add_head(void);
352 * @brief Add the current selection after the selected item in the
355 void gui_browser_playq_add_after(void);
357 * @brief Add the current selection before the selected item in the
360 void gui_browser_playq_add_before(void);
362 * @brief Search for the next item matching gui_input_cursearch in the
365 int gui_browser_searchnext(const struct vfsmatch
*vm
);
367 * @brief Change to a directory, filled in by the user.
369 void gui_browser_chdir(void);
371 * @brief Focus or unfocus the filebrowser.
373 void gui_browser_setfocus(int focus
);
375 * @brief Write the playlist to a file.
377 void gui_browser_write_playlist(void);
379 * @brief Write the full pathname of the selected item in the message
382 void gui_browser_fullpath(void);
384 * @brief Apply a recursive search filter on the current directory.
386 int gui_browser_locate(const struct vfsmatch
*vm
);
388 * @brief Go to the directory containing the selected item.
390 void gui_browser_gotofolder(void);