Code

Update copyright notices
[ncmpc.git] / src / list_window.h
index 99f702882a40e1834c27286e6b6e252718ce8eab..a61d24b4e9b3c0cdd0ee7640e673e4dadc2f8966 100644 (file)
@@ -1,5 +1,5 @@
 /* ncmpc (Ncurses MPD Client)
- * (c) 2004-2009 The Music Player Daemon Project
+ * (c) 2004-2010 The Music Player Daemon Project
  * Project homepage: http://musicpd.org
 
  * This program is free software; you can redistribute it and/or modify
@@ -22,6 +22,7 @@
 
 #include "config.h"
 #include "command.h"
+#include "colors.h"
 
 #include <glib.h>
 #include <stdbool.h>
 #include <ncurses.h>
 #endif
 
-typedef const char *(*list_window_callback_fn_t)(unsigned index,
-                                                bool *highlight,
-                                                char **second_column,
-                                                void *data);
+typedef const char *
+(*list_window_callback_fn_t)(unsigned i, void *data);
+
+typedef void
+(*list_window_paint_callback_t)(WINDOW *w, unsigned i,
+                               unsigned y, unsigned width,
+                               bool selected,
+                               void *data);
 
 struct list_window {
        WINDOW *w;
@@ -48,14 +53,28 @@ struct list_window {
 
        unsigned start;
        unsigned selected;
-       unsigned selected_start;     /* for range selection, first selected item */
-       unsigned selected_end;       /* for range selection, last selected item */
        unsigned range_base;        /* represents the base item. */
        bool range_selection;       /* range selection activated */
 
        bool hide_cursor;
 };
 
+/**
+ * The bounds of a range selection, see list_window_get_range().
+ */
+struct list_window_range {
+       /**
+        * The index of the first selected item.
+        */
+       unsigned start;
+
+       /**
+        * The index after the last selected item.  The selection is
+        * empty when this is the same as "start".
+        */
+       unsigned end;
+};
+
 /* create a new list window */
 struct list_window *list_window_init(WINDOW *w,
                                     unsigned width, unsigned height);
@@ -66,14 +85,22 @@ void list_window_free(struct list_window *lw);
 /* reset a list window (selected=0, start=0) */
 void list_window_reset(struct list_window *lw);
 
+void
+list_window_resize(struct list_window *lw, unsigned width, unsigned height);
+
 void
 list_window_set_length(struct list_window *lw, unsigned length);
 
 /* paint a list window */
-void list_window_paint(struct list_window *lw,
+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,
+                  void *callback_data);
+
 /* perform basic list window commands (movement) */
 bool
 list_window_cmd(struct list_window *lw, command_t cmd);
@@ -117,6 +144,15 @@ list_window_move_cursor(struct list_window *lw, unsigned n);
 void
 list_window_fetch_cursor(struct list_window *lw);
 
+/**
+ * Determines the lower and upper bound of the range selection.  If
+ * range selection is disabled, it returns the cursor position (range
+ * length is 1).
+ */
+void
+list_window_get_range(const struct list_window *lw,
+                     struct list_window_range *range);
+
 /* find a string in a list window */
 bool
 list_window_find(struct list_window *lw,