summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 271507f)
raw | patch | inline | side by side (parent: 271507f)
author | Max Kellermann <max@duempel.org> | |
Sun, 11 Oct 2009 12:53:28 +0000 (14:53 +0200) | ||
committer | Max Kellermann <max@duempel.org> | |
Sun, 11 Oct 2009 12:53:28 +0000 (14:53 +0200) |
With the function list_window_paint2(), callers can customize how a
row is painted. The usual callback function is not used anymore.
row is painted. The usual callback function is not used anymore.
diff --git a/src/list_window.c b/src/list_window.c
index 0b6031483e8854fc86bc410070fe9089bd45d540..f8ab8e9a708ccd0d996c26443d7a7f126f64ecdc 100644 (file)
--- a/src/list_window.c
+++ b/src/list_window.c
}
}
+void
+list_window_paint2(const struct list_window *lw,
+ list_window_paint_callback_t paint_callback,
+ void *callback_data)
+{
+ bool show_cursor = !lw->hide_cursor &&
+ (!options.hardware_cursor || lw->range_selection);
+ struct list_window_range range;
+
+ if (show_cursor)
+ list_window_get_range(lw, &range);
+
+ for (unsigned i = 0; i < lw->rows; i++) {
+ bool selected;
+
+ wmove(lw->w, i, 0);
+
+ if (lw->start + i >= lw->length) {
+ wclrtobot(lw->w);
+ break;
+ }
+
+ selected = show_cursor &&
+ lw->start + i >= range.start &&
+ lw->start + i < range.end;
+
+ paint_callback(lw->w, lw->start + i, i, lw->cols,
+ selected, callback_data);
+
+ if (selected)
+ wattroff(lw->w, A_REVERSE);
+ }
+
+ if (options.hardware_cursor && lw->selected >= lw->start &&
+ lw->selected < lw->start + lw->rows) {
+ curs_set(1);
+ wmove(lw->w, lw->selected - lw->start, 0);
+ }
+}
+
bool
list_window_find(struct list_window *lw,
list_window_callback_fn_t callback,
diff --git a/src/list_window.h b/src/list_window.h
index 98fcfbef7fc44327cd7ab07f704f51154b2b5d06..8ffe40f9bd5ca0cf79d11b3a82c11b16e51f0744 100644 (file)
--- a/src/list_window.h
+++ b/src/list_window.h
#include "config.h"
#include "command.h"
+#include "colors.h"
#include <glib.h>
#include <stdbool.h>
char **second_column,
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;
unsigned rows, cols;
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);
diff --git a/src/screen_artist.c b/src/screen_artist.c
index 116f4b64cf8fd164f6f788e40948c1b77227576d..847bed045286f3a73c3dc3d0d193ded91751a6f5 100644 (file)
--- a/src/screen_artist.c
+++ b/src/screen_artist.c
switch (mode) {
case LIST_ARTISTS:
screen_jump(browser.lw, screen_artist_lw_callback,
- artist_list);
+ NULL, artist_list);
artist_repaint();
return true;
case LIST_ALBUMS:
screen_jump(browser.lw, screen_artist_lw_callback,
- album_list);
+ NULL, album_list);
artist_repaint();
return true;
diff --git a/src/screen_browser.c b/src/screen_browser.c
index 994ea2dd5f61150ec95bcd758785897fc86d14e7..3b0fc00ccf2a5610880c06cde0ece8e8e93f4649 100644 (file)
--- a/src/screen_browser.c
+++ b/src/screen_browser.c
browser->filelist);
return true;
case CMD_LIST_JUMP:
- screen_jump(browser->lw, browser_lw_callback, browser->filelist);
+ screen_jump(browser->lw, browser_lw_callback,
+ NULL, browser->filelist);
return true;
#ifdef HAVE_GETMOUSE
diff --git a/src/screen_find.c b/src/screen_find.c
index 79115edfa07f92573bc03b3eec6aa05b70612b0e..531fe499d62072df4297f757ac8e32d8c7b1ef38 100644 (file)
--- a/src/screen_find.c
+++ b/src/screen_find.c
void
screen_jump(struct list_window *lw,
list_window_callback_fn_t callback_fn,
+ list_window_paint_callback_t paint_callback,
void *callback_data)
{
char *search_str, *iter;
++iter;
}
list_window_jump(lw, callback_fn, callback_data, search_str);
+
/* repaint the list_window */
- list_window_paint(lw, callback_fn, callback_data);
+ if (paint_callback != NULL)
+ list_window_paint2(lw, paint_callback, callback_data);
+ else
+ list_window_paint(lw, callback_fn, callback_data);
wrefresh(lw->w);
}
diff --git a/src/screen_find.h b/src/screen_find.h
index 7753e228b87ffbe6dfbc85bec1dd9f831584f666..780aff1e631f80f881454b207dddaac792362d4d 100644 (file)
--- a/src/screen_find.h
+++ b/src/screen_find.h
* which begins with this string while the users types */
void screen_jump(struct list_window *lw,
list_window_callback_fn_t callback_fn,
+ list_window_paint_callback_t paint_callback,
void *callback_data);
#endif
diff --git a/src/screen_play.c b/src/screen_play.c
index d1261c66ee418d7210c76c06cdead50b9dafe50c..882dd7a9e46b5f87df4e00624bfbd25f4f716d63 100644 (file)
--- a/src/screen_play.c
+++ b/src/screen_play.c
playlist_repaint();
return true;
case CMD_LIST_JUMP:
- screen_jump(lw, list_callback, NULL);
+ screen_jump(lw, list_callback, NULL, NULL);
playlist_save_selection();
playlist_repaint();
return true;