Fix whitespace inconsistencies.
[herrie-working.git] / herrie / src / gui_vfslist.h
blobd41e9045a0f8df54d0ce599505ef0ee2eff81358
1 /*
2 * Copyright (c) 2006-2011 Ed Schouten <ed@80386.nl>
3 * All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
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
24 * SUCH DAMAGE.
26 /**
27 * @file gui_vfslist.h
28 * @brief Generic directory/playlist display for textual user interface.
31 #include CURSES_HEADER
33 struct vfslist;
34 struct vfsref;
35 struct vfsmatch;
37 /**
38 * @brief Graphical presentation of a vfslist.
40 struct gui_vfslist {
41 /**
42 * @brief Curses window used to draw entries.
44 WINDOW *win;
45 /**
46 * @brief Height of the Curses window.
48 unsigned int winheight;
49 /**
50 * @brief Focus state of window to determine selection color.
52 unsigned int winfocused;
53 /**
54 * @brief Show index numbers before each entry.
56 int shownumbers;
58 /**
59 * @brief List that should be used for display.
61 const struct vfslist *list;
62 /**
63 * @brief Item currently at the top of the screen.
65 struct vfsref *vr_top;
66 /**
67 * @brief Index number of vr_top.
69 unsigned int idx_top;
70 /**
71 * @brief Item selected with the cursor.
73 struct vfsref *vr_selected;
74 /**
75 * @brief Index number of vr_selected.
77 unsigned int idx_selected;
79 /**
80 * @brief String containing a percentual notation of the
81 * progress in the list.
83 char percent[8];
85 /**
86 * @brief Callback function that should be run after a refresh.
88 void (*callback)(void);
91 /**
92 * @brief Allocate and initialize a new gui_vfslist.
94 struct gui_vfslist *gui_vfslist_new(int shownumbers);
95 /**
96 * @brief Deallocate a gui_vfslist.
98 void gui_vfslist_destroy(struct gui_vfslist *gv);
99 /**
100 * @brief Set the list that should be shown in the dialog.
102 void gui_vfslist_setlist(struct gui_vfslist *gv, const struct vfslist *vl);
104 * @brief Warn the user when the list is empty.
106 int gui_vfslist_warn_isempty(struct gui_vfslist *gv);
108 * @brief Move the dialog to a specified position in the terminal.
110 void gui_vfslist_move(struct gui_vfslist *gv, int x, int y,
111 int width, int height);
113 * @brief Focus or unfocus the dialog. This causes the selected item to
114 * change its color.
116 void gui_vfslist_setfocus(struct gui_vfslist *gv, int focus);
118 * @brief Change which item is currently selected.
120 void gui_vfslist_setselected(struct gui_vfslist *gv, struct vfsref *vr,
121 unsigned int index);
124 * @brief Read which item is currently selected.
126 static inline struct vfsref *
127 gui_vfslist_getselected(struct gui_vfslist *gv)
129 return (gv->vr_selected);
133 * @brief Read the index number of the currently selected item.
135 static inline unsigned int
136 gui_vfslist_getselectedidx(struct gui_vfslist *gv)
138 return (gv->idx_selected);
142 * @brief Move the cursor one item up.
144 void gui_vfslist_cursor_up(struct gui_vfslist *gv);
146 * @brief Move the cursor one item down.
148 void gui_vfslist_cursor_down(struct gui_vfslist *gv, int silent);
150 * @brief Move the cursor to the top of the list.
152 void gui_vfslist_cursor_head(struct gui_vfslist *gv);
154 * @brief Move the cursor to the bottom of the list.
156 void gui_vfslist_cursor_tail(struct gui_vfslist *gv);
158 * @brief Move the cursor one page up.
160 void gui_vfslist_cursor_pageup(struct gui_vfslist *gv);
162 * @brief Move the cursor one page down.
164 void gui_vfslist_cursor_pagedown(struct gui_vfslist *gv);
167 * @brief Return the percentage string.
169 static inline const char *
170 gui_vfslist_getpercentage(struct gui_vfslist *gv)
172 return (gv->percent);
176 * @brief Set a callback that is run each time the dialog is refreshed.
178 static inline void
179 gui_vfslist_setcallback(struct gui_vfslist *gv, void (*func)(void))
181 gv->callback = func;
185 * @brief Notify the gui_vfslist that an item is about to be removed
186 * from the list.
188 void gui_vfslist_notify_pre_removal(struct gui_vfslist *gv,
189 unsigned int index);
191 * @brief Notify the gui_vfslist that an item has been inserted to the
192 * list.
194 void gui_vfslist_notify_post_insertion(struct gui_vfslist *gv,
195 unsigned int index);
197 * @brief Notify the gui_vfslist that the list has been randomized.
199 void gui_vfslist_notify_post_randomization(struct gui_vfslist *gv);
201 * @brief Notify the gui_vfslist that all changes to the list itself are
202 * finished. This causes the list to be redrawn.
204 void gui_vfslist_notify_done(struct gui_vfslist *gv);
206 * @brief Change the selection to the first item that matches the
207 * globally defined search string gui_input_cursearch.
209 int gui_vfslist_searchnext(struct gui_vfslist *gv, const struct vfsmatch *vm);
211 * @brief Show the full pathname of the selected entry in the message
212 * bar.
214 void gui_vfslist_fullpath(struct gui_vfslist *gv);