diff options
author | John Ankarström <john@ankarstrom.se> | 2022-04-27 16:06:42 +0200 |
---|---|---|
committer | John Ankarström <john@ankarstrom.se> | 2022-04-27 16:06:42 +0200 |
commit | 00d22febd2c73f5ccb058ca2211294b1a1d99e9c (patch) | |
tree | 02612dd2181b5e1abafc0da663f1141dfb05adff /pl | |
parent | dd855b6091c1eb9835cd2466ed2e225dd4f850a4 (diff) | |
download | EpisodeBrowser-00d22febd2c73f5ccb058ca2211294b1a1d99e9c.tar.gz |
Press left/right to select next/previous unwatched episode.
Diffstat (limited to 'pl')
-rw-r--r-- | pl/track_episodes.pl | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/pl/track_episodes.pl b/pl/track_episodes.pl index f18e85c..1973a75 100644 --- a/pl/track_episodes.pl +++ b/pl/track_episodes.pl @@ -2,7 +2,9 @@ toggle_episode/1, forget_episode/1, most_recently_watched/1, - watched/1]). + watched/1, + next_unwatched/2, + previous_unwatched/2]). :- use_module(library(dcg/basics)). :- use_module(library(registry)). @@ -94,3 +96,17 @@ most_recently_watched(Ep) :- watched(Ep) :- episode_watched(Ep, true). + +next_unwatched(Ep0, Ep) :- + Ep1 is Ep0 + 1, + ( \+ watched(Ep1) + -> Ep = Ep1 + ; next_unwatched(Ep1, Ep) + ). + +previous_unwatched(Ep0, Ep) :- + Ep1 is Ep0 - 1, + ( \+ watched(Ep1) + -> Ep = Ep1 + ; previous_unwatched(Ep1, Ep) + ). |