summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: bcb11a8)
raw | patch | inline | side by side (parent: bcb11a8)
author | jefromi <jefromi@gmail.com> | |
Wed, 4 Feb 2009 15:30:00 +0000 (16:30 +0100) | ||
committer | Max Kellermann <max@duempel.org> | |
Mon, 9 Feb 2009 16:00:17 +0000 (17:00 +0100) |
NCMPC triggers a bell whenever a search wraps. (Note that this means a
double-bell whenever a wrapped search finds nothing.) I can see this
being reasonable, if the playlist is short and the user is aware of
which direction they want to search in. However if you predominantly
use long playlists and don't know which direction your target is in,
this means you get bells on half your searches.
Since I could see people wanting it either way, my best idea is making
the bell optional. Here's a patch to do that, defaulting to the
current behavior. (I'm a little confused about defaults - looks like
there are only default values for some in options.c - but it looks
like this behaves as desired.)
double-bell whenever a wrapped search finds nothing.) I can see this
being reasonable, if the playlist is short and the user is aware of
which direction they want to search in. However if you predominantly
use long playlists and don't know which direction your target is in,
this means you get bells on half your searches.
Since I could see people wanting it either way, my best idea is making
the bell optional. Here's a patch to do that, defaulting to the
current behavior. (I'm a little confused about defaults - looks like
there are only default values for some in options.c - but it looks
like this behaves as desired.)
src/conf.c | patch | blob | history | |
src/list_window.c | patch | blob | history | |
src/list_window.h | patch | blob | history | |
src/options.c | patch | blob | history | |
src/options.h | patch | blob | history | |
src/screen_utils.c | patch | blob | history |
diff --git a/src/conf.c b/src/conf.c
index 67d048ae6972eb43dec841e85ef56d5e2e588e2d..13dc5d50c5cdeb1c4ddd8891c49560cf902944f3 100644 (file)
--- a/src/conf.c
+++ b/src/conf.c
#define CONF_FIND_SHOW_LAST "find-show-last"
#define CONF_AUDIBLE_BELL "audible-bell"
#define CONF_VISIBLE_BELL "visible-bell"
+#define CONF_BELL_ON_WRAP "bell-on-wrap"
#define CONF_XTERM_TITLE "set-xterm-title"
#define CONF_ENABLE_MOUSE "enable-mouse"
#define CONF_CROSSFADE_TIME "crossfade-time"
options.audible_bell = str2bool(value);
else if (!strcasecmp(CONF_VISIBLE_BELL, name))
options.visible_bell = str2bool(value);
+ else if (!strcasecmp(CONF_BELL_ON_WRAP, name))
+ options.bell_on_wrap = str2bool(value);
else if (!strcasecmp(CONF_XTERM_TITLE, name))
options.enable_xterm_title = str2bool(value);
else if (!strcasecmp(CONF_ENABLE_MOUSE, name))
diff --git a/src/list_window.c b/src/list_window.c
index 8ab35b10670d4d45e4d1c205500a234035cc99e8..f7da79ea147973f67db1b44acc86e791bd3076b3 100644 (file)
--- a/src/list_window.c
+++ b/src/list_window.c
list_window_callback_fn_t callback,
void *callback_data,
const char *str,
- bool wrap)
+ bool wrap,
+ bool bell_on_wrap)
{
bool h;
unsigned i = lw->selected + 1;
if (i == 0) /* empty list */
return 1;
i=0; /* first item */
- screen_bell();
+ if (bell_on_wrap) {
+ screen_bell();
+ }
}
} while (wrap);
void *callback_data,
const char *str,
bool wrap,
+ bool bell_on_wrap,
unsigned rows)
{
bool h;
}
if (wrap) {
i = rows - 1; /* last item */
- screen_bell();
+ if (bell_on_wrap) {
+ screen_bell();
+ }
}
} while (wrap);
diff --git a/src/list_window.h b/src/list_window.h
index 5506f8c77e8eb7e68a5761db1fd94d5a34b59c75..a103af2608c8c8cce2d8b2eaadd43f94551a97b8 100644 (file)
--- a/src/list_window.h
+++ b/src/list_window.h
list_window_callback_fn_t callback,
void *callback_data,
const char *str,
- bool wrap);
+ bool wrap,
+ bool bell_on_wrap);
/* find a string in a list window (reversed) */
bool
void *callback_data,
const char *str,
bool wrap,
+ bool bell_on_wrap,
unsigned rows);
#endif
diff --git a/src/options.c b/src/options.c
index 3f784d11cc9c00ab23b84a1be23af8f7690790ba..83ae5ff6a63ab57456ef7568a8432f38b478a859 100644 (file)
--- a/src/options.c
+++ b/src/options.c
.find_wrap = true,
.wide_cursor = true,
.audible_bell = true,
+ .bell_on_wrap = true,
#ifndef NCMPC_MINI
.scroll = DEFAULT_SCROLL,
.welcome_screen_list = true,
diff --git a/src/options.h b/src/options.h
index c48d1b39044ff2495d9d239c66e7902913dd54b7..48a12f2b81e3eba8b89085f8670e858b51322abe 100644 (file)
--- a/src/options.h
+++ b/src/options.h
#endif
bool audible_bell;
bool visible_bell;
+ bool bell_on_wrap;
#ifndef NCMPC_MINI
bool enable_xterm_title;
#endif
diff --git a/src/screen_utils.c b/src/screen_utils.c
index dd5afee0f17a4efc9350fb6420cf508e6b5e74b4..26f8811a7bb9fc901379a0d8a0f7f960160a7bc8 100644 (file)
--- a/src/screen_utils.c
+++ b/src/screen_utils.c
callback_fn, callback_data,
screen.findbuf,
options.find_wrap,
+ options.bell_on_wrap,
rows)
: list_window_find(lw,
callback_fn, callback_data,
screen.findbuf,
- options.find_wrap);
+ options.find_wrap,
+ options.bell_on_wrap);
if (!found) {
screen_status_printf(_("Unable to find \'%s\'"),
screen.findbuf);