1 /* ncmpc (Ncurses MPD Client)
2 * (c) 2004-2017 The Music Player Daemon Project
3 * Project homepage: http://musicpd.org
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 along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 #include "ncmpc_curses.h"
32 (*list_window_callback_fn_t
)(unsigned i
, void *data
);
35 (*list_window_paint_callback_t
)(WINDOW
*w
, unsigned i
,
36 unsigned y
, unsigned width
,
45 * Number of items in this list.
53 * Represents the base item.
58 * Range selection activated?
66 * The bounds of a range selection, see list_window_get_range().
68 struct list_window_range
{
70 * The index of the first selected item.
75 * The index after the last selected item. The selection is
76 * empty when this is the same as "start".
81 /* create a new list window */
82 struct list_window
*list_window_init(WINDOW
*w
,
83 unsigned width
, unsigned height
);
85 /* destroy a list window */
86 void list_window_free(struct list_window
*lw
);
88 /* reset a list window (selected=0, start=0) */
89 void list_window_reset(struct list_window
*lw
);
92 list_window_resize(struct list_window
*lw
, unsigned width
, unsigned height
);
95 list_window_set_length(struct list_window
*lw
, unsigned length
);
97 /* paint a list window */
98 void list_window_paint(const struct list_window
*lw
,
99 list_window_callback_fn_t callback
,
100 void *callback_data
);
103 list_window_paint2(const struct list_window
*lw
,
104 list_window_paint_callback_t paint_callback
,
105 const void *callback_data
);
107 /* perform basic list window commands (movement) */
109 list_window_cmd(struct list_window
*lw
, command_t cmd
);
112 * Scroll the window. Returns true if the command has been
116 list_window_scroll_cmd(struct list_window
*lw
, command_t cmd
);
120 * The mouse was clicked. Check if the list should be scrolled
121 * Returns non-zero if the mouse event has been handled.
124 list_window_mouse(struct list_window
*lw
, unsigned long bstate
, int y
);
128 * Centers the visible range around item n on the list.
131 list_window_center(struct list_window
*lw
, unsigned n
);
134 * Scrolls the view to item n, as if the cursor would have been moved
138 list_window_scroll_to(struct list_window
*lw
, unsigned n
);
141 * Sets the position of the cursor. Disables range selection.
144 list_window_set_cursor(struct list_window
*lw
, unsigned i
);
147 * Moves the cursor. Modifies the range if range selection is
151 list_window_move_cursor(struct list_window
*lw
, unsigned n
);
154 * Ensures that the cursor is visible on the screen, i.e. it is not
155 * outside the current scrolling range.
158 list_window_fetch_cursor(struct list_window
*lw
);
161 * Determines the lower and upper bound of the range selection. If
162 * range selection is disabled, it returns the cursor position (range
166 list_window_get_range(const struct list_window
*lw
,
167 struct list_window_range
*range
);
169 /* find a string in a list window */
171 list_window_find(struct list_window
*lw
,
172 list_window_callback_fn_t callback
,
178 /* find a string in a list window (reversed) */
180 list_window_rfind(struct list_window
*lw
,
181 list_window_callback_fn_t callback
,
187 /* find a string in a list window which begins with the given characters in *str */
189 list_window_jump(struct list_window
*lw
,
190 list_window_callback_fn_t callback
,