Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
31cabc75
Commit
31cabc75
authored
Sep 30, 2009
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
command: range support for "delete"
parent
0478a8e2
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
39 additions
and
3 deletions
+39
-3
NEWS
NEWS
+1
-0
command.c
src/command.c
+3
-3
playlist.h
src/playlist.h
+9
-0
playlist_edit.c
src/playlist_edit.c
+26
-0
No files found.
NEWS
View file @
31cabc75
...
...
@@ -4,6 +4,7 @@ ver 0.16 (20??/??/??)
- added "update" idle event
- removed the deprecated "volume" command
- added the "findadd" command
- range support for "delete"
* input:
- lastfm: use metadata
* tags:
...
...
src/command.c
View file @
31cabc75
...
...
@@ -632,13 +632,13 @@ handle_addid(struct client *client, int argc, char *argv[])
static
enum
command_return
handle_delete
(
struct
client
*
client
,
G_GNUC_UNUSED
int
argc
,
char
*
argv
[])
{
int
song
;
unsigned
start
,
end
;
enum
playlist_result
result
;
if
(
!
check_
int
(
client
,
&
song
,
argv
[
1
],
need_positiv
e
))
if
(
!
check_
range
(
client
,
&
start
,
&
end
,
argv
[
1
],
need_rang
e
))
return
COMMAND_RETURN_ERROR
;
result
=
playlist_delete
(
&
g_playlist
,
song
);
result
=
playlist_delete
_range
(
&
g_playlist
,
start
,
end
);
return
print_playlist_result
(
client
,
result
);
}
...
...
src/playlist.h
View file @
31cabc75
...
...
@@ -141,6 +141,15 @@ playlist_append_song(struct playlist *playlist,
enum
playlist_result
playlist_delete
(
struct
playlist
*
playlist
,
unsigned
song
);
/**
* Deletes a range of songs from the playlist.
*
* @param start the position of the first song to delete
* @param end the position after the last song to delete
*/
enum
playlist_result
playlist_delete_range
(
struct
playlist
*
playlist
,
unsigned
start
,
unsigned
end
);
enum
playlist_result
playlist_delete_id
(
struct
playlist
*
playlist
,
unsigned
song
);
...
...
src/playlist_edit.c
View file @
31cabc75
...
...
@@ -280,6 +280,32 @@ playlist_delete(struct playlist *playlist, unsigned song)
}
enum
playlist_result
playlist_delete_range
(
struct
playlist
*
playlist
,
unsigned
start
,
unsigned
end
)
{
const
struct
song
*
queued
;
if
(
start
>=
queue_length
(
&
playlist
->
queue
))
return
PLAYLIST_RESULT_BAD_RANGE
;
if
(
end
>
queue_length
(
&
playlist
->
queue
))
end
=
queue_length
(
&
playlist
->
queue
);
if
(
start
>=
end
)
return
PLAYLIST_RESULT_SUCCESS
;
queued
=
playlist_get_queued_song
(
playlist
);
do
{
playlist_delete_internal
(
playlist
,
--
end
,
&
queued
);
}
while
(
end
!=
start
);
playlist_increment_version
(
playlist
);
playlist_update_queued_song
(
playlist
,
queued
);
return
PLAYLIST_RESULT_SUCCESS
;
}
enum
playlist_result
playlist_delete_id
(
struct
playlist
*
playlist
,
unsigned
id
)
{
int
song
=
queue_id_to_position
(
&
playlist
->
queue
,
id
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment