1 /* ncmpc (Ncurses MPD Client)
2 * (c) 2004-2010 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.
51 unsigned range_base
; /* represents the base item. */
52 bool range_selection
; /* range selection activated */
58 * The bounds of a range selection, see list_window_get_range().
60 struct list_window_range
{
62 * The index of the first selected item.
67 * The index after the last selected item. The selection is
68 * empty when this is the same as "start".
73 /* create a new list window */
74 struct list_window
*list_window_init(WINDOW
*w
,
75 unsigned width
, unsigned height
);
77 /* destroy a list window */
78 void list_window_free(struct list_window
*lw
);
80 /* reset a list window (selected=0, start=0) */
81 void list_window_reset(struct list_window
*lw
);
84 list_window_resize(struct list_window
*lw
, unsigned width
, unsigned height
);
87 list_window_set_length(struct list_window
*lw
, unsigned length
);
89 /* paint a list window */
90 void list_window_paint(const struct list_window
*lw
,
91 list_window_callback_fn_t callback
,
95 list_window_paint2(const struct list_window
*lw
,
96 list_window_paint_callback_t paint_callback
,
99 /* perform basic list window commands (movement) */
101 list_window_cmd(struct list_window
*lw
, command_t cmd
);
104 * Scroll the window. Returns true if the command has been
108 list_window_scroll_cmd(struct list_window
*lw
, command_t cmd
);
112 * The mouse was clicked. Check if the list should be scrolled
113 * Returns non-zero if the mouse event has been handled.
116 list_window_mouse(struct list_window
*lw
, unsigned long bstate
, int y
);
120 * Centers the visible range around item n on the list.
123 list_window_center(struct list_window
*lw
, unsigned n
);
126 * Scrolls the view to item n, as if the cursor would have been moved
130 list_window_scroll_to(struct list_window
*lw
, unsigned n
);
133 * Sets the position of the cursor. Disables range selection.
136 list_window_set_cursor(struct list_window
*lw
, unsigned i
);
139 * Moves the cursor. Modifies the range if range selection is
143 list_window_move_cursor(struct list_window
*lw
, unsigned n
);
146 * Ensures that the cursor is visible on the screen, i.e. it is not
147 * outside the current scrolling range.
150 list_window_fetch_cursor(struct list_window
*lw
);
153 * Determines the lower and upper bound of the range selection. If
154 * range selection is disabled, it returns the cursor position (range
158 list_window_get_range(const struct list_window
*lw
,
159 struct list_window_range
*range
);
161 /* find a string in a list window */
163 list_window_find(struct list_window
*lw
,
164 list_window_callback_fn_t callback
,
170 /* find a string in a list window (reversed) */
172 list_window_rfind(struct list_window
*lw
,
173 list_window_callback_fn_t callback
,
179 /* find a string in a list window which begins with the given characters in *str */
181 list_window_jump(struct list_window
*lw
,
182 list_window_callback_fn_t callback
,