From b44651364f7038b5936fed6140dc0c3eefa75cec Mon Sep 17 00:00:00 2001
From: Frederic Culot <calcurse@culot.org>
Date: Mon, 11 Sep 2006 13:42:57 +0000
Subject: apoint_check_next() created

---
 src/apoint.c | 33 ++++++++++++++++++++++++++++++++-
 1 file changed, 32 insertions(+), 1 deletion(-)

(limited to 'src')

diff --git a/src/apoint.c b/src/apoint.c
index 5cbc62e..84663d0 100755
--- a/src/apoint.c
+++ b/src/apoint.c
@@ -1,4 +1,4 @@
-/*	$calcurse: apoint.c,v 1.1 2006/07/31 21:00:03 culot Exp $	*/
+/*	$calcurse: apoint.c,v 1.2 2006/09/11 13:42:57 culot Exp $	*/
 
 /*
  * Calcurse - text-based organizer
@@ -37,6 +37,7 @@
 #include "day.h"
 #include "custom.h"
 #include "utils.h"
+#include "notify.h"
 
 struct apoint_s *apointlist;
 
@@ -233,3 +234,33 @@ void scroll_pad_up(int item_nb, int nb_events_inday)
 	if (item_first_line < apad->first_onscreen)
 		apad->first_onscreen = item_first_line;
 }
+
+/*
+ * Look in the appointment list if we have an item which starts before the item
+ * stored in the notify_app structure (which is the next item to be notified).
+ */
+struct notify_app_s *apoint_check_next(struct notify_app_s *app, long start)
+{
+	struct apoint_s *i;
+
+	if (!apointlist) 
+		return app;
+	for (i = apointlist; i != 0; i = i->next) { 
+		if (i->start > app->time) {
+			return app;
+		} else {
+			if (i->start > start) {
+				app->time = i->start;	
+				if (strlen(i->mesg) < NOTIFY_FIELD_LENGTH) {
+					strncpy(app->txt, i->mesg, 
+						strlen(i->mesg) + 1);
+				} else {
+					strncpy(app->txt, i->mesg, 
+						NOTIFY_FIELD_LENGTH-3);	
+					strncat(app->txt, "..", 2);
+				}
+			} 
+		}
+	}
+	return app;
+}
-- 
cgit v1.2.3-70-g09d2