ncmpc  0.29
list_window.h
Go to the documentation of this file.
1 /* ncmpc (Ncurses MPD Client)
2  * (c) 2004-2017 The Music Player Daemon Project
3  * Project homepage: http://musicpd.org
4  *
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.
9  *
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.
14  *
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.
18  */
19 
20 #ifndef LIST_WINDOW_H
21 #define LIST_WINDOW_H
22 
23 #include "config.h"
24 #include "command.h"
25 #include "colors.h"
26 #include "ncmpc_curses.h"
27 
28 #include <glib.h>
29 #include <stdbool.h>
30 
31 typedef const char *
32 (*list_window_callback_fn_t)(unsigned i, void *data);
33 
34 typedef void
35 (*list_window_paint_callback_t)(WINDOW *w, unsigned i,
36  unsigned y, unsigned width,
37  bool selected,
38  const void *data);
39 
40 struct list_window {
41  WINDOW *w;
42  unsigned rows, cols;
43 
47  unsigned length;
48 
49  unsigned start;
50  unsigned selected;
51 
55  unsigned range_base;
56 
61 
63 };
64 
72  unsigned start;
73 
78  unsigned end;
79 };
80 
81 /* create a new list window */
82 struct list_window *list_window_init(WINDOW *w,
83  unsigned width, unsigned height);
84 
85 /* destroy a list window */
86 void list_window_free(struct list_window *lw);
87 
88 /* reset a list window (selected=0, start=0) */
89 void list_window_reset(struct list_window *lw);
90 
91 void
92 list_window_resize(struct list_window *lw, unsigned width, unsigned height);
93 
94 void
95 list_window_set_length(struct list_window *lw, unsigned length);
96 
97 /* paint a list window */
98 void list_window_paint(const struct list_window *lw,
100  void *callback_data);
101 
102 void
103 list_window_paint2(const struct list_window *lw,
104  list_window_paint_callback_t paint_callback,
105  const void *callback_data);
106 
107 /* perform basic list window commands (movement) */
108 bool
109 list_window_cmd(struct list_window *lw, command_t cmd);
110 
115 bool
117 
118 #ifdef HAVE_GETMOUSE
119 
123 bool
124 list_window_mouse(struct list_window *lw, unsigned long bstate, int y);
125 #endif
126 
130 void
131 list_window_center(struct list_window *lw, unsigned n);
132 
137 void
138 list_window_scroll_to(struct list_window *lw, unsigned n);
139 
143 void
144 list_window_set_cursor(struct list_window *lw, unsigned i);
145 
150 void
151 list_window_move_cursor(struct list_window *lw, unsigned n);
152 
157 void
159 
165 void
166 list_window_get_range(const struct list_window *lw,
167  struct list_window_range *range);
168 
169 /* find a string in a list window */
170 bool
171 list_window_find(struct list_window *lw,
172  list_window_callback_fn_t callback,
173  void *callback_data,
174  const char *str,
175  bool wrap,
176  bool bell_on_wrap);
177 
178 /* find a string in a list window (reversed) */
179 bool
180 list_window_rfind(struct list_window *lw,
181  list_window_callback_fn_t callback,
182  void *callback_data,
183  const char *str,
184  bool wrap,
185  bool bell_on_wrap);
186 
187 /* find a string in a list window which begins with the given characters in *str */
188 bool
189 list_window_jump(struct list_window *lw,
190  list_window_callback_fn_t callback,
191  void *callback_data,
192  const char *str);
193 
194 #endif
unsigned range_base
Definition: list_window.h:55
void list_window_center(struct list_window *lw, unsigned n)
void list_window_reset(struct list_window *lw)
const char *(* list_window_callback_fn_t)(unsigned i, void *data)
Definition: list_window.h:32
unsigned start
Definition: list_window.h:49
bool range_selection
Definition: list_window.h:60
Definition: list_window.h:68
unsigned selected
Definition: list_window.h:50
bool list_window_jump(struct list_window *lw, list_window_callback_fn_t callback, void *callback_data, const char *str)
void list_window_get_range(const struct list_window *lw, struct list_window_range *range)
unsigned start
Definition: list_window.h:72
bool list_window_scroll_cmd(struct list_window *lw, command_t cmd)
void list_window_paint(const struct list_window *lw, list_window_callback_fn_t callback, void *callback_data)
void list_window_paint2(const struct list_window *lw, list_window_paint_callback_t paint_callback, const void *callback_data)
command_t
Definition: command.h:36
WINDOW * w
Definition: list_window.h:41
void list_window_move_cursor(struct list_window *lw, unsigned n)
void list_window_free(struct list_window *lw)
unsigned end
Definition: list_window.h:78
unsigned cols
Definition: list_window.h:42
bool list_window_rfind(struct list_window *lw, list_window_callback_fn_t callback, void *callback_data, const char *str, bool wrap, bool bell_on_wrap)
void list_window_scroll_to(struct list_window *lw, unsigned n)
void list_window_resize(struct list_window *lw, unsigned width, unsigned height)
void(* list_window_paint_callback_t)(WINDOW *w, unsigned i, unsigned y, unsigned width, bool selected, const void *data)
Definition: list_window.h:35
struct list_window * list_window_init(WINDOW *w, unsigned width, unsigned height)
unsigned length
Definition: list_window.h:47
Definition: list_window.h:40
void list_window_fetch_cursor(struct list_window *lw)
void list_window_set_cursor(struct list_window *lw, unsigned i)
bool list_window_cmd(struct list_window *lw, command_t cmd)
bool hide_cursor
Definition: list_window.h:62
bool list_window_find(struct list_window *lw, list_window_callback_fn_t callback, void *callback_data, const char *str, bool wrap, bool bell_on_wrap)
unsigned rows
Definition: list_window.h:42
void list_window_set_length(struct list_window *lw, unsigned length)