4 Commits

Author SHA1 Message Date
24449fe721 Make global search match on filenames
All checks were successful
Alpine 3.20 Success
OpenBSD 7.5 Success
Arch Linux AUR Success
2024-08-07 22:12:43 +02:00
60171cc5a3 Bump liberty 2024-08-07 22:05:29 +02:00
20502200d9 Make global search indicate the search terms
All checks were successful
Alpine 3.20 Success
Arch Linux AUR Success
OpenBSD 7.5 Success
2024-07-21 21:04:17 +02:00
e6de4f11e7 Be actually able to use a system Termo library
All checks were successful
Alpine 3.19 Success
Arch Linux AUR Success
OpenBSD 7.3 Success
2024-04-10 17:31:40 +02:00
5 changed files with 52 additions and 11 deletions

View File

@@ -121,7 +121,8 @@ add_custom_command (OUTPUT ${actions}
# Build the main executable and link it
add_executable (${PROJECT_NAME} ${PROJECT_NAME}.c ${actions})
target_link_libraries (${PROJECT_NAME} ${Unistring_LIBRARIES}
${Ncursesw_LIBRARIES} termo-static ${curl_LIBRARIES} ${extra_libraries})
${Ncursesw_LIBRARIES} ${Termo_LIBRARIES} ${curl_LIBRARIES}
${extra_libraries})
add_threads (${PROJECT_NAME})
# Installation

View File

@@ -1,4 +1,4 @@
Copyright (c) 2016 - 2023, Přemysl Eric Janouch <p@janouch.name>
Copyright (c) 2016 - 2024, Přemysl Eric Janouch <p@janouch.name>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.

5
NEWS
View File

@@ -1,3 +1,8 @@
Unreleased
* Made global search indicate the search terms, and match on filenames
2.1.1 (2024-02-27)
* Fixed installation of Info tab plugins

Submodule liberty updated: 969a4cfc3e...8a8437634a

View File

@@ -1,7 +1,7 @@
/*
* nncmpp -- the MPD client you never knew you needed
*
* Copyright (c) 2016 - 2023, Přemysl Eric Janouch <p@janouch.name>
* Copyright (c) 2016 - 2024, Přemysl Eric Janouch <p@janouch.name>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted.
@@ -3599,17 +3599,36 @@ static void
library_tab_on_search_data (const struct mpd_response *response,
const struct strv *data, void *user_data)
{
(void) user_data;
char *filter = user_data;
if (!g_library_tab.searching)
return;
goto out;
if (!response->success)
{
print_error ("cannot search: %s", response->message_text);
return;
else
{
cstr_set (&g_library_tab.super.header,
xstrdup_printf ("%s: %s", "Global search", filter));
library_tab_load_data (data);
}
library_tab_load_data (data);
out:
free (filter);
}
static char *
mpd_quoted_filter_string (const char *value)
{
struct str quoted = str_make ();
str_append_c (&quoted, '\'');
for (const char *p = value; *p; p++)
{
if (mpd_client_must_escape_in_quote (*p))
str_append_c (&quoted, '\\');
str_append_c (&quoted, *p);
}
str_append_c (&quoted, '\'');
return str_steal (&quoted);
}
static void
@@ -3619,10 +3638,26 @@ search_on_changed (void)
size_t len;
char *u8 = (char *) u32_to_u8 (g.editor.line, g.editor.len + 1, NULL, &len);
mpd_client_list_begin (c);
mpd_client_send_command (c, "search", "any", u8, NULL);
free (u8);
mpd_client_add_task (c, library_tab_on_search_data, NULL);
// Just tag search doesn't consider filenames.
// Older MPD can do `search any X file X` but without the negation,
// which is necessary to avoid duplicates. Neither syntax supports OR.
// XXX: We should parse this, but it's probably not going to reach 100 soon,
// and it is not really documented what this should even look like.
if (strcmp (c->got_hello, "0.21.") > 1)
{
char *quoted = mpd_quoted_filter_string (u8);
char *expression = xstrdup_printf ("((!(any contains %s)) AND "
"(file contains %s))", quoted, quoted);
mpd_client_send_command (c, "search", expression, NULL);
free (expression);
free (quoted);
}
mpd_client_list_end (c);
mpd_client_add_task (c, library_tab_on_search_data, u8);
mpd_client_idle (c, 0);
}