Skip to content
This repository was archived by the owner on Feb 9, 2021. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions TODO
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ Graphical user interface:
- Allow numeric multipliers just like vi
- Add copy/paste functionality to playlist
- Use different colors for files, playlists and directories
- Recursive searching
- Show whether repeat is turned on
- Make startup-configuration of repeat-switch configurable
- Allow Herrie to be controlled outside the interface through /tmp
- Add the ability to show the filename of the song that's currently playing
- Allow randomized playback in XMMS mode without shuffling the list
Expand Down Expand Up @@ -41,3 +39,6 @@ Virtual filesystem:
Documentation:
- Usage guide
- Write a developers guide?

Other:
- Raise an error if you have errors in your configuration file
2 changes: 2 additions & 0 deletions herrie/ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
* Changed: Go to home directory when pressing ~ when defaultpath is unset
* Added: vfs.cache to cache file system entries
* Added: GStreamer format module - Bas Westerbaan
* Added: Czech translation - Jakub Podlaha
* Added: Reverse searching - Jille Timmermans

2008-10-14 -- Herrie 2.2:
* Added: Ukranian translation - Viacheslav Chumushuk
Expand Down
10 changes: 10 additions & 0 deletions herrie/man/00-man
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,18 @@ first matching entry below the current selection. If no match is found,
the search will continue at the top of the list. As a final attempt, the
other window is searched as well.
.TP
.B ?
Search the entries for a specified regular expression and select the
first matching entry above the current selection. If no match is found,
the search will continue at the bottom of the list. As a final attempt, the
other window is searched as well.
.TP
.B n
Perform another search for the last entered search string.
.TP
.B N
Perform another search for the last entered search string in the
opposite direction.
.PP
There are also some bindings that only apply to the playlist:
.TP
Expand Down
2 changes: 1 addition & 1 deletion herrie/src/audio_file.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ struct audio_file {

/**
* @brief An audio format for opening, closing and reading
* the audio file.
* the audio file.
*/
struct audio_format *drv;
/**
Expand Down
1 change: 1 addition & 0 deletions herrie/src/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ static struct config_entry configlist[] = {
{ "gui.vfslist.scrollpages", "no", valid_bool, NULL },
{ "playq.autoplay", "no", valid_bool, NULL },
{ "playq.dumpfile", CONFHOMEDIR PLAYQ_DUMPFILE, NULL, NULL },
{ "playq.repeat", "no", valid_bool, NULL },
{ "playq.xmms", "no", valid_bool, NULL },
#ifdef BUILD_SCROBBLER
{ "scrobbler.dumpfile", CONFHOMEDIR "scrobbler.queue", NULL, NULL },
Expand Down
4 changes: 2 additions & 2 deletions herrie/src/gui_browser.c
Original file line number Diff line number Diff line change
Expand Up @@ -352,9 +352,9 @@ gui_browser_playq_add_before(void)
}

int
gui_browser_searchnext(const struct vfsmatch *vm)
gui_browser_search(const struct vfsmatch *vm, int reverse)
{
return gui_vfslist_searchnext(win_browser, vm);
return gui_vfslist_search(win_browser, vm, reverse);
}

/**
Expand Down
86 changes: 70 additions & 16 deletions herrie/src/gui_input.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ static int gui_input_curfocus = GUI_FOCUS_BROWSER;
* @brief Indicator of the current search string.
*/
static struct vfsmatch *cursearch = NULL;
/**
* @brief Indicator whether the current search should be applied in
* reverse.
*/
static int cursearch_reverse = 0;
/**
* @brief The last seek string that has been entered.
*/
Expand Down Expand Up @@ -179,7 +184,7 @@ gui_input_switchfocus(void)
* @brief Ask the user to enter a new search string.
*/
static int
gui_input_asksearch(void)
gui_input_promptsearch(void)
{
char *str;
const char *old = NULL;
Expand Down Expand Up @@ -216,34 +221,38 @@ gui_input_asksearch(void)

/**
* @brief Ask the user to enter a search string when none was given and
* search for the next item matching the search string.
* search for the next item matching the search string in the
* direction specified.
*/
static void
gui_input_searchnext(void)
do_gui_input_search(int reverse)
{
int nfocus = GUI_FOCUS_PLAYQ;

if (cursearch == NULL) {
/* No search string yet */
if (gui_input_asksearch() != 0)
if (gui_input_promptsearch() != 0)
return;
cursearch_reverse = 0;
}

/* Search up or down? */
reverse = !reverse != !cursearch_reverse;
/*
* We want to change our search order depending on which dialog
* We want to change our dialog order depending on which dialog
* is currently focused. This code is quite awful, but does the
* thing. When the playq is focused, it only performs the first
* two searches. If the browser is focused, it only performs the
* last two.
*/
if (gui_input_curfocus == GUI_FOCUS_PLAYQ &&
gui_playq_searchnext(cursearch) == 0) {
gui_playq_search(cursearch, reverse) == 0) {
goto found;
} else if (gui_browser_searchnext(cursearch) == 0) {
} else if (gui_browser_search(cursearch, reverse) == 0) {
nfocus = GUI_FOCUS_BROWSER;
goto found;
} else if (gui_input_curfocus != GUI_FOCUS_PLAYQ &&
gui_playq_searchnext(cursearch) == 0) {
gui_playq_search(cursearch, reverse) == 0) {
goto found;
}

Expand All @@ -258,18 +267,60 @@ gui_input_searchnext(void)
}

/**
* @brief Ask the user to enter a new search string and perform the
* first search.
* @brief Ask the user to enter a search string when none was given and
* search for the next item matching the search string.
*/
static void
gui_input_search(void)
{
do_gui_input_search(0);
}

/**
* @brief Ask the user to enter a search string when none was given and
* search for the next item matching the search string in the
* reverse direction.
*/
static void
gui_input_search_reverse(void)
{
do_gui_input_search(1);
}

/**
* @brief Ask the user to enter a new search string and perform the
* first search in the direction specified.
*/
static void
do_gui_input_asksearch(int reverse)
{
/* Always ask for a search string */
if (gui_input_asksearch() != 0)
if (gui_input_promptsearch() != 0)
return;
cursearch_reverse = reverse;

/* Just simulate a 'n' button */
gui_input_searchnext();
gui_input_search();
}

/**
* @brief Ask the user to enter a new search string and perform the
* first search.
*/
static void
gui_input_asksearch(void)
{
do_gui_input_asksearch(0);
}

/**
* @brief Ask the user to enter a new search string and perform the
* first search in the reverse direction.
*/
static void
gui_input_asksearch_reverse(void)
{
do_gui_input_asksearch(1);
}

/**
Expand All @@ -280,8 +331,9 @@ static void
gui_input_locate(void)
{
/* Always ask for a search string */
if (gui_input_asksearch() != 0)
if (gui_input_promptsearch() != 0)
return;
cursearch_reverse = 0;

/* Perform the serach */
if (gui_browser_locate(cursearch) != 0)
Expand Down Expand Up @@ -478,10 +530,12 @@ static struct gui_binding kbdbindings[] = {
{ -1, '{', gui_playq_song_move_head },
{ -1, '}', gui_playq_song_move_tail },
{ -1, '~', gui_browser_gotohome },
{ -1, '\t', gui_input_switchfocus },
{ -1, '\t', gui_input_switchfocus },
{ -1, CTRL('W'), gui_input_switchfocus },
{ -1, '/', gui_input_search },
{ -1, 'n', gui_input_searchnext },
{ -1, '/', gui_input_asksearch },
{ -1, '?', gui_input_asksearch_reverse },
{ -1, 'n', gui_input_search },
{ -1, 'N', gui_input_search_reverse },
{ -1, KEY_LEFT, gui_browser_dir_parent },
{ -1, KEY_RIGHT, gui_browser_dir_enter },

Expand Down
6 changes: 3 additions & 3 deletions herrie/src/gui_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ char *gui_input_askstring(const char *question, const char *defstr,
*/
/**
* @brief Create a bar at the bottom of the terminal displaying
* messages and questions.
* messages and questions.
*/
void gui_msgbar_init(void);
/**
Expand Down Expand Up @@ -252,7 +252,7 @@ void gui_playq_song_select(void);
* @brief Search for the next item matching gui_input_cursearch in the
* playlist.
*/
int gui_playq_searchnext(const struct vfsmatch *vm);
int gui_playq_search(const struct vfsmatch *vm, int reverse);
/**
* @brief Focus or unfocus the playlist.
*/
Expand Down Expand Up @@ -362,7 +362,7 @@ void gui_browser_playq_add_before(void);
* @brief Search for the next item matching gui_input_cursearch in the
* file browser.
*/
int gui_browser_searchnext(const struct vfsmatch *vm);
int gui_browser_search(const struct vfsmatch *vm, int reverse);
/**
* @brief Change to a directory, filled in by the user.
*/
Expand Down
4 changes: 2 additions & 2 deletions herrie/src/gui_playq.c
Original file line number Diff line number Diff line change
Expand Up @@ -486,12 +486,12 @@ gui_playq_song_select(void)
}

int
gui_playq_searchnext(const struct vfsmatch *vm)
gui_playq_search(const struct vfsmatch *vm, int reverse)
{
int ret;

playq_lock();
ret = gui_vfslist_searchnext(win_playq, vm);
ret = gui_vfslist_search(win_playq, vm, reverse);
playq_unlock();

return (ret);
Expand Down
56 changes: 41 additions & 15 deletions herrie/src/gui_vfslist.c
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,8 @@ gui_vfslist_notify_done(struct gui_vfslist *gv)
}

int
gui_vfslist_searchnext(struct gui_vfslist *gv, const struct vfsmatch *vm)
gui_vfslist_search(struct gui_vfslist *gv, const struct vfsmatch *vm,
int reverse)
{
struct vfsref *vr;
unsigned int idx;
Expand All @@ -571,22 +572,47 @@ gui_vfslist_searchnext(struct gui_vfslist *gv, const struct vfsmatch *vm)
if (gv->vr_selected == NULL)
return (-1);

/* Step 1: search from selection to end */
for (vr = vfs_list_next(gv->vr_selected), idx = gv->idx_selected + 1;
vr != NULL; vr = vfs_list_next(vr), idx++) {
if (vfs_match_compare(vm, vfs_name(vr))) {
gui_msgbar_flush();
goto found;
/* Search from top to bottom or vice versa? */
if (!reverse) {
/* Step 1: search from selection to end */
for (vr = vfs_list_next(gv->vr_selected),
idx = gv->idx_selected + 1; vr != NULL;
vr = vfs_list_next(vr), idx++) {
if (vfs_match_compare(vm, vfs_name(vr))) {
gui_msgbar_flush();
goto found;
}
}

/* Step 2: search from beginning to selection */
for (vr = vfs_list_first(gv->list), idx = 1;
vr != vfs_list_next(gv->vr_selected);
vr = vfs_list_next(vr), idx++) {
if (vfs_match_compare(vm, vfs_name(vr))) {
gui_msgbar_warn(_("Search wrapped to top."));
goto found;
}
}
} else {
/* Step 1: search from selection to beginning */
for (vr = vfs_list_prev(gv->vr_selected),
idx = gv->idx_selected - 1; vr != NULL;
vr = vfs_list_prev(vr), idx--) {
if (vfs_match_compare(vm, vfs_name(vr))) {
gui_msgbar_flush();
goto found;
}
}
}

/* Step 2: search from beginning to selection */
for (vr = vfs_list_first(gv->list), idx = 1;
vr != vfs_list_next(gv->vr_selected);
vr = vfs_list_next(vr), idx++) {
if (vfs_match_compare(vm, vfs_name(vr))) {
gui_msgbar_warn(_("Search wrapped to top."));
goto found;
/* Step 2: search from end to selection */
for (vr = vfs_list_last(gv->list),
idx = vfs_list_items(gv->list);
vr != vfs_list_prev(gv->vr_selected);
vr = vfs_list_prev(vr), idx--) {
if (vfs_match_compare(vm, vfs_name(vr))) {
gui_msgbar_warn(_("Search wrapped to bottom."));
goto found;
}
}
}

Expand Down
3 changes: 2 additions & 1 deletion herrie/src/gui_vfslist.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,8 @@ void gui_vfslist_notify_done(struct gui_vfslist *gv);
* @brief Change the selection to the first item that matches the
* globally defined search string gui_input_cursearch.
*/
int gui_vfslist_searchnext(struct gui_vfslist *gv, const struct vfsmatch *vm);
int gui_vfslist_search(struct gui_vfslist *gv, const struct vfsmatch *vm,
int reverse);
/**
* @brief Show the full pathname of the selected entry in the message
* bar.
Expand Down
8 changes: 4 additions & 4 deletions herrie/src/playq.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ static struct playq_funcs xmms_funcs = {
static struct playq_funcs *funcs = &party_funcs;

struct vfslist playq_list = VFSLIST_INITIALIZER;
GMutex *playq_mtx;
GMutex *playq_mtx;
/**
* @brief Conditional variable used to kick the playq alive when it was
* waiting for a new song to be added to the playlist or when
Expand Down Expand Up @@ -254,10 +254,10 @@ playq_init(int autoplay, int xmms, int load_dumpfile)
if (autoplay || config_getopt_bool("playq.autoplay"))
playq_flags &= ~PF_STOP;

if (xmms || config_getopt_bool("playq.xmms")) {
if (xmms || config_getopt_bool("playq.xmms"))
funcs = &xmms_funcs;
playq_repeat = 1;
}

playq_repeat = config_getopt_bool("playq.repeat");

filename = config_getopt("playq.dumpfile");
if (load_dumpfile && filename[0] != '\0') {
Expand Down
2 changes: 1 addition & 1 deletion herrie/src/scrobbler.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ static char scrobbler_enabled = 0;
/**
* @brief Lock used to provide safe access to the AudioScrobbler queue.
*/
static GMutex *scrobbler_lock;
static GMutex *scrobbler_lock;
/**
* @brief Conditional variable used to notify the avaiability of new
* tracks ready for submission to AudioScrobbler.
Expand Down
2 changes: 1 addition & 1 deletion herrie/src/vfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ void vfs_cache_add(const struct vfsref *vr);
/**
* @brief Obtain entry from the VFS cache.
*/
struct vfsref *vfs_cache_lookup(const char *filename);
struct vfsref *vfs_cache_lookup(const char *filename);
/**
* @brief Purge the VFS cache.
*/
Expand Down