diff options
Diffstat (limited to '')
-rw-r--r-- | src/list_window.c | 54 | ||||
-rw-r--r-- | src/list_window.h | 25 | ||||
-rw-r--r-- | src/screen_artist.c | 2 | ||||
-rw-r--r-- | src/screen_browser.c | 4 | ||||
-rw-r--r-- | src/screen_browser.h | 2 | ||||
-rw-r--r-- | src/screen_help.c | 4 | ||||
-rw-r--r-- | src/screen_keydef.c | 4 | ||||
-rw-r--r-- | src/screen_lyrics.c | 2 | ||||
-rw-r--r-- | src/screen_play.c | 4 | ||||
-rw-r--r-- | src/screen_search.c | 2 | ||||
-rw-r--r-- | src/screen_song.c | 2 | ||||
-rw-r--r-- | src/screen_utils.c | 28 |
12 files changed, 66 insertions, 67 deletions
diff --git a/src/list_window.c b/src/list_window.c index 46858ee2b..b12e8eb8c 100644 --- a/src/list_window.c +++ b/src/list_window.c @@ -165,8 +165,8 @@ list_window_paint(struct list_window *lw, void *callback_data) { unsigned i; - int fill = options.wide_cursor; - int show_cursor = !(lw->flags & LW_HIDE_CURSOR); + bool fill = options.wide_cursor; + bool show_cursor = !(lw->flags & LW_HIDE_CURSOR); if (show_cursor) { if (lw->selected < lw->start) @@ -177,14 +177,14 @@ list_window_paint(struct list_window *lw, } for (i = 0; i < lw->rows; i++) { - int highlight = 0; + bool highlight = false; const char *label; label = callback(lw->start + i, &highlight, callback_data); wmove(lw->w, i, 0); if (label) { - int selected = lw->start + i == lw->selected; + bool selected = lw->start + i == lw->selected; unsigned len = utf8_width(label); if (highlight) @@ -210,14 +210,14 @@ list_window_paint(struct list_window *lw, } } -int +bool list_window_find(struct list_window *lw, list_window_callback_fn_t callback, void *callback_data, const char *str, - int wrap) + bool wrap) { - int h; + bool h; unsigned i = lw->selected + 1; const char *label; @@ -225,10 +225,10 @@ list_window_find(struct list_window *lw, while ((label = callback(i,&h,callback_data))) { if (str && label && strcasestr(label, str)) { lw->selected = i; - return 0; + return true; } if (wrap && i == lw->selected) - return 1; + return false; i++; } if (wrap) { @@ -239,32 +239,32 @@ list_window_find(struct list_window *lw, } } while (wrap); - return 1; + return false; } -int +bool list_window_rfind(struct list_window *lw, list_window_callback_fn_t callback, void *callback_data, const char *str, - int wrap, + bool wrap, unsigned rows) { - int h; + bool h; int i = lw->selected - 1; const char *label; if (rows == 0) - return 1; + return false; do { while (i >= 0 && (label = callback(i,&h,callback_data))) { if( str && label && strcasestr(label, str) ) { lw->selected = i; - return 0; + return true; } if (wrap && i == (int)lw->selected) - return 1; + return false; i--; } if (wrap) { @@ -273,11 +273,11 @@ list_window_rfind(struct list_window *lw, } } while (wrap); - return 1; + return false; } /* perform basic list window commands (movement) */ -int +bool list_window_cmd(struct list_window *lw, unsigned rows, command_t cmd) { switch (cmd) { @@ -300,13 +300,13 @@ list_window_cmd(struct list_window *lw, unsigned rows, command_t cmd) list_window_previous_page(lw); break; default: - return 0; + return false; } - return 1; + return true; } -int +bool list_window_scroll_cmd(struct list_window *lw, unsigned rows, command_t cmd) { switch (cmd) { @@ -349,14 +349,14 @@ list_window_scroll_cmd(struct list_window *lw, unsigned rows, command_t cmd) break; default: - return 0; + return false; } - return 1; + return true; } #ifdef HAVE_GETMOUSE -int +bool list_window_mouse(struct list_window *lw, unsigned rows, unsigned long bstate, int y) { @@ -368,7 +368,7 @@ list_window_mouse(struct list_window *lw, unsigned rows, list_window_first(lw); else list_window_previous_page(lw); - return 1; + return true; } /* if the even occured below the list window move down */ @@ -377,9 +377,9 @@ list_window_mouse(struct list_window *lw, unsigned rows, list_window_last(lw, rows); else list_window_next_page(lw, rows); - return 1; + return true; } - return 0; + return false; } #endif diff --git a/src/list_window.h b/src/list_window.h index 11c4cddab..bcf3e3228 100644 --- a/src/list_window.h +++ b/src/list_window.h @@ -5,6 +5,7 @@ #include "command.h" #include <glib.h> +#include <stdbool.h> #ifdef HAVE_NCURSESW_NCURSES_H #include <ncursesw/ncurses.h> @@ -15,7 +16,7 @@ #define LW_HIDE_CURSOR 0x01 typedef const char *(*list_window_callback_fn_t)(unsigned index, - int *highlight, + bool *highlight, void *data); typedef struct list_window { @@ -45,13 +46,14 @@ void list_window_paint(struct list_window *lw, void *callback_data); /* perform basic list window commands (movement) */ -int list_window_cmd(struct list_window *lw, unsigned rows, command_t cmd); +bool +list_window_cmd(struct list_window *lw, unsigned rows, command_t cmd); /** * Scroll the window. Returns non-zero if the command has been * consumed. */ -int +bool list_window_scroll_cmd(struct list_window *lw, unsigned rows, command_t cmd); #ifdef HAVE_GETMOUSE @@ -59,7 +61,7 @@ list_window_scroll_cmd(struct list_window *lw, unsigned rows, command_t cmd); * The mouse was clicked. Check if the list should be scrolled * Returns non-zero if the mouse event has been handled. */ -int +bool list_window_mouse(struct list_window *lw, unsigned rows, unsigned long bstate, int y); #endif @@ -72,19 +74,20 @@ void list_window_set_selected(struct list_window *lw, unsigned n); void list_window_check_selected(struct list_window *lw, unsigned length); /* find a string in a list window */ -int list_window_find(struct list_window *lw, - list_window_callback_fn_t callback, - void *callback_data, - const char *str, - int wrap); +bool +list_window_find(struct list_window *lw, + list_window_callback_fn_t callback, + void *callback_data, + const char *str, + bool wrap); /* find a string in a list window (reversed) */ -int +bool list_window_rfind(struct list_window *lw, list_window_callback_fn_t callback, void *callback_data, const char *str, - int wrap, + bool wrap, unsigned rows); #endif diff --git a/src/screen_artist.c b/src/screen_artist.c index 7180c38ed..be951ee6e 100644 --- a/src/screen_artist.c +++ b/src/screen_artist.c @@ -59,7 +59,7 @@ compare_utf8(gconstpointer s1, gconstpointer s2) /* list_window callback */ static const char * -artist_lw_callback(unsigned idx, G_GNUC_UNUSED int *highlight, +artist_lw_callback(unsigned idx, G_GNUC_UNUSED bool *highlight, G_GNUC_UNUSED void *data) { GPtrArray *list = data; diff --git a/src/screen_browser.c b/src/screen_browser.c index 3aeab0b33..4d911e0d7 100644 --- a/src/screen_browser.c +++ b/src/screen_browser.c @@ -119,7 +119,7 @@ browser_playlist_changed(struct screen_browser *browser, mpdclient_t *c, /* list_window callback */ const char * -browser_lw_callback(unsigned idx, int *highlight, void *data) +browser_lw_callback(unsigned idx, bool *highlight, void *data) { static char buf[BUFSIZE]; mpdclient_filelist_t *fl = (mpdclient_filelist_t *) data; @@ -134,7 +134,7 @@ browser_lw_callback(unsigned idx, int *highlight, void *data) entity = entry->entity; #ifndef NCMPC_MINI - *highlight = (entry->flags & HIGHLIGHT); + *highlight = (entry->flags & HIGHLIGHT) != 0; #else *highlight = false; #endif diff --git a/src/screen_browser.h b/src/screen_browser.h index 6ea17cc18..1cc0b2744 100644 --- a/src/screen_browser.h +++ b/src/screen_browser.h @@ -46,7 +46,7 @@ browser_playlist_changed(struct screen_browser *browser, mpdclient_t *c, #endif -const char *browser_lw_callback(unsigned index, int *highlight, void *filelist); +const char *browser_lw_callback(unsigned index, bool *highlight, void *filelist); bool browser_change_directory(struct screen_browser *browser, mpdclient_t *c, diff --git a/src/screen_help.c b/src/screen_help.c index 2f06adacd..0cc15a37a 100644 --- a/src/screen_help.c +++ b/src/screen_help.c @@ -141,7 +141,7 @@ static help_text_row_t help_text[] = { static list_window_t *lw; static const char * -list_callback(unsigned idx, int *highlight, G_GNUC_UNUSED void *data) +list_callback(unsigned idx, bool *highlight, G_GNUC_UNUSED void *data) { static char buf[512]; @@ -149,7 +149,7 @@ list_callback(unsigned idx, int *highlight, G_GNUC_UNUSED void *data) return NULL; if (help_text[idx].highlight) - *highlight = 1; + *highlight = true; if (help_text[idx].command == CMD_NONE) { if (help_text[idx].text) diff --git a/src/screen_keydef.c b/src/screen_keydef.c index 02ef177d8..a8f01b352 100644 --- a/src/screen_keydef.c +++ b/src/screen_keydef.c @@ -187,14 +187,14 @@ assign_new_key(WINDOW *w, int cmd_index, int key_index) } static const char * -list_callback(unsigned idx, int *highlight, G_GNUC_UNUSED void *data) +list_callback(unsigned idx, bool *highlight, G_GNUC_UNUSED void *data) { static char buf[BUFSIZE]; if (subcmd < 0) { if (idx < (unsigned)command_list_length) { if (cmds[idx].flags & COMMAND_KEY_CONFLICT) - *highlight = 1; + *highlight = true; return cmds[idx].name; } else if (idx == LIST_ITEM_APPLY()) return LIST_ITEM_APPLY_LABEL; diff --git a/src/screen_lyrics.c b/src/screen_lyrics.c index 93a47cc8d..d54333d0c 100644 --- a/src/screen_lyrics.c +++ b/src/screen_lyrics.c @@ -223,7 +223,7 @@ static int store_lyr_hd(void) } static const char * -list_callback(unsigned idx, G_GNUC_UNUSED int *highlight, +list_callback(unsigned idx, G_GNUC_UNUSED bool *highlight, G_GNUC_UNUSED void *data) { static char buffer[256]; diff --git a/src/screen_play.c b/src/screen_play.c index 525207618..7ee0a9ff4 100644 --- a/src/screen_play.c +++ b/src/screen_play.c @@ -90,7 +90,7 @@ playlist_changed_callback(mpdclient_t *c, int event, gpointer data) } static const char * -list_callback(unsigned idx, int *highlight, G_GNUC_UNUSED void *data) +list_callback(unsigned idx, bool *highlight, G_GNUC_UNUSED void *data) { static char songname[MAX_SONG_LENGTH]; #ifndef NCMPC_MINI @@ -103,7 +103,7 @@ list_callback(unsigned idx, int *highlight, G_GNUC_UNUSED void *data) song = playlist_get(playlist, idx); if (song->id == current_song_id) - *highlight = 1; + *highlight = true; strfsong(songname, MAX_SONG_LENGTH, options.list_format, song); diff --git a/src/screen_search.c b/src/screen_search.c index 83054123d..3c0a18bf9 100644 --- a/src/screen_search.c +++ b/src/screen_search.c @@ -93,7 +93,7 @@ static struct screen_browser browser; /* search info */ static const char * -lw_search_help_callback(unsigned idx, G_GNUC_UNUSED int *highlight, +lw_search_help_callback(unsigned idx, G_GNUC_UNUSED bool *highlight, G_GNUC_UNUSED void *data) { unsigned text_rows; diff --git a/src/screen_song.c b/src/screen_song.c index bda200ad7..2c73ea6f5 100644 --- a/src/screen_song.c +++ b/src/screen_song.c @@ -56,7 +56,7 @@ screen_song_repaint(void) } static const char * -screen_song_list_callback(unsigned idx, G_GNUC_UNUSED int *highlight, +screen_song_list_callback(unsigned idx, G_GNUC_UNUSED bool *highlight, G_GNUC_UNUSED void *data) { static char buffer[256]; diff --git a/src/screen_utils.c b/src/screen_utils.c index ff3fffa44..20b4be1a4 100644 --- a/src/screen_utils.c +++ b/src/screen_utils.c @@ -159,7 +159,7 @@ screen_find(list_window_t *lw, void *callback_data) { int reversed = 0; - int retval = 0; + bool found; const char *prompt = FIND_PROMPT; char *value = options.find_show_last_pattern ? (char *) -1 : NULL; @@ -189,21 +189,17 @@ screen_find(list_window_t *lw, if (screen.findbuf == NULL) return 1; - if (reversed) - retval = list_window_rfind(lw, - callback_fn, - callback_data, - screen.findbuf, - options.find_wrap, - rows); - else - retval = list_window_find(lw, - callback_fn, - callback_data, - screen.findbuf, - options.find_wrap); - - if (retval != 0) { + found = reversed + ? list_window_rfind(lw, + callback_fn, callback_data, + screen.findbuf, + options.find_wrap, + rows) + : list_window_find(lw, + callback_fn, callback_data, + screen.findbuf, + options.find_wrap); + if (!found) { screen_status_printf(_("Unable to find \'%s\'"), screen.findbuf); screen_bell(); |