From 00d22febd2c73f5ccb058ca2211294b1a1d99e9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Ankarstr=C3=B6m?= Date: Wed, 27 Apr 2022 16:06:42 +0200 Subject: Press left/right to select next/previous unwatched episode. --- pl/track_episodes.pl | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'pl') 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) + ). -- cgit v1.2.3