[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[mgp-users 01446] Re: Repeating sequence of slides



Holla aficionados,

Keith Bates <keith@new-life.org.au> writes:

> On Sun, 11 Sep 2005 10:51:55 +0200
> Michael Welle <m.welle@gmx.net> wrote:
[...]
>> Iirc mgp can't restart the presentation after the last slide. Perhaps
>> you can use some shell scripting.
it is sunday, it is raining. So we can do a little hacking ;). It is a
crude hack, a proof of concept if you like ;). Maybe with this patch
the earlier discussed mem leaks comes to focus again, too. 

I have introduced a new command line switch to mgp: -L [num]. In
conjunction with -d mgp loops the presentation num times (0 < num <
n) or even forever (if num is absent or num = 0).

Examples:
  
  Do a one-time presentation:
    mgp -xm17n  -d5 -g800x600 icsm2003.mgp
    mgp -xm17n -L1 -d5 -g800x600 icsm2003.mgp

  Loop forever:
    mgp -xm17n  -L -d5 -g800x600 icsm2003.mgp
    mgp -xm17n  -L0 -d5 -g800x600 icsm2003.mgp

  loop exactly 4 times:
    mgp -xm17n  -L4 -d5 -g800x600 icsm2003.mgp

Maybe it is more insightful to eliminate the -L again and introduce a
second arg to -d? 

Michael


--- mgp.h.org	2005-09-11 14:36:50.000000000 +0200
+++ mgp.h	2005-09-11 14:37:12.000000000 +0200
@@ -189,6 +189,7 @@
 #define	FL_FRDCACHE		0x8000
 #define	FL_NOXFT		0x10000
 #define	FL_NOM17N		0x20000
+#define FL_LOOP         0x40000
 
 /* 	page attribute flags 	*/
 #define PGFLAG_NODEF	0x01	/* nodefault */

--- mgp.c.org	2005-09-11 14:36:50.000000000 +0200
+++ mgp.c	2005-09-11 14:37:12.000000000 +0200
@@ -66,6 +66,9 @@
 	"black", "black", "black", "black", "gray", "gray",
 };
 static int demointerval = 0;	/* XXX define option for this */
+static int num_of_loops = 1;
+
+#define LOOP_FOREVER -1
 
 u_long depth_mask;
 
@@ -255,7 +258,7 @@
 	argv=tmp_argv;
 	argc=tmp_argc;
 
-#define ACCEPTOPTS	"Bd:vVob:c:eg:f:hlGp:qt:Q:PSUT:D:CORw:X:x:nF:E:"
+#define ACCEPTOPTS	"BL:d:vVob:c:eg:f:hlGp:qt:Q:PSUT:D:CORw:X:x:nF:E:"
 	while ((opt = getopt(argc, argv, ACCEPTOPTS)) != -1) {
 #undef ACCEPTOPTS
 		switch (opt) {
@@ -269,6 +272,16 @@
 			else optind --;
 			break;
 
+		case 'L':
+			mgp_flag |= FL_LOOP;
+			if (isdigit(optarg[0])) num_of_loops = atoi(optarg);
+			else {
+			    num_of_loops = LOOP_FOREVER;
+			    optind --;
+			}
+			if ( num_of_loops == 0 ) num_of_loops = LOOP_FOREVER;
+			break;
+
 		case 'V':
 			mgp_flag |= FL_VERBOSE;
 			verbose++;
@@ -470,12 +483,24 @@
 		state.target = window;	/*XXX*/
 		state.width = window_width;
 		state.height = window_height;
-		while (start_page <= maxpage) {
+
+		int sp = start_page;
+		
+		do {
+		    while (start_page <= maxpage) {
 			state_goto(&state, start_page, 0);
 			draw_page(&state, NULL);
 			start_page++;
 			sleep(demointerval);	/*XXX*/
-		}
+		    }
+
+		    start_page = sp;
+
+		    if ( num_of_loops > 0 ) num_of_loops--;
+
+		} while ( ( num_of_loops > 0 ) ||
+			  ( num_of_loops == LOOP_FOREVER ) );
+
 	} else {
 		init_win3();
 		main_loop(start_page);
-- 
We're back to the times when men were men and wrote their own device drivers
                                                              Linus Torvalds