Anonymous avatar Anonymous committed 78b313c

update man page

Comments (0)

Files changed (2)

 
 .SH SYNOPSIS
 .SY life
-.OP \-c
 .OP \-f fps
-.OP \-g
 .OP \-i infile
 .OP \-o outfile
 .OP \-p
-.OP \-r
 .OP \-s size
+.OP \-t
 .YS
 
 .SH OPTIONS
 .TP
-.B \-c
-show the cursor position in the top left corner
-.TP
 .BI \-f " fps"
 run at fps frames per second (defaults to 15)
 .TP
-.B \-g
-show the current generation number in the bottom left corner
-.TP
 .BI \-i " infile"
 read infile for starting position (defaults to /dev/urandom) (HINT: use /dev/zero for blank)
 .TP
 .B \-p
 start paused instead of running
 .TP
-.B \-r
-show frame rate at top right
-.TP
 .BI \-s " size"
 set the size of the board (defaults to 32) (HINT: can be as large as malloc will give you)
+.TP
+.B \-t
+don't show the status bar
 
 .SH USAGE
 .SS general
 .TP
-.I c
-toggle coordinate display
-.TP
-.I r
-toggle frame rate display
-.TP
-.I g
-toggle generation display
+.I t
+toggle status bar
 .TP
 .I q
 quit
 
 
 static void print(void);
-static void print_coord(int i, int j);
-static void print_fps(void);
-static void print_gen(void);
-static void print_pop(void);
+static void print_status(int i, int j);
 static void quit(int sig);
 static void run(void);
 static void sigwinch(int unused);
 static struct termios set, dfl;
 static char *outfile = NULL, *infile = "/dev/urandom";
 static int fps = 15, size = 32, paused = 0;
-static int show_coord = 0, show_fps = 0, show_gen = 0, show_pop = 0;
+static int show_status = 1;
 
 void print(void)
 {
 		if (i < size - 1  && i < i_org + rows - 1)
 			fputc('\n', stdout);
 	}
-	print_gen();
-	print_pop();
-	print_coord(i_org, j_org);
-	print_fps();
+	print_status(i_org, j_org);
 }
 
-void print_coord(int i, int j)
+void print_status(int i, int j)
 {
-	if (!show_coord)
+	if (!show_status)
 		return;
-	cursor_org();
-	printf("(%d, %d)", j, i);
-	fflush(stdout);
-}
 
-void print_fps(void)
-{
-	if (!show_fps)
-		return;
-	cursor_crd(0, MIN(cols, size) * 2 - (int)strlen("fps: xxx"));
-	printf("fps: %03d", fps);
-	fflush(stdout);
-}
-
-void print_gen(void)
-{
-	if (!show_gen)
-		return;
 	cursor_crd(MIN(rows, size), 1);
-	printf("Generation: %d", gen);
-	fflush(stdout);
-}
-
-void print_pop(void)
-{
-	if (!show_pop)
-		return;
-	cursor_crd(MIN(rows, size), MIN(cols, size) * 2 - (int)strlen("pop: xxxxxxx"));
-	printf("pop: %07d", pop);
+	printf("Coordinates: (%d, %d) ", j, i);
+	printf("Generation: %d ", gen);
+	printf("Population: %d ", pop);
+	printf("Framerate: %d fps", fps);
 	fflush(stdout);
 }
 
 	if (ioctl(1, TIOCGWINSZ, &ws) < 0)
 		err(1, "failed ioctl");
 
+	cursor_org();
+	cursor_clr();
+	fflush(stdout);
+
 	cols = ws.ws_col / 2;
 	rows = ws.ws_row;
 
 		usleep(1000000 / fps);
 		while (!paused && read(0, &c, sizeof(c)) > 0) {
 			switch (c) {
-				case 'c' : show_coord = !show_coord; break;
-				case 'r' : show_fps   = !show_fps;   break;
-				case 'g' : show_gen   = !show_gen;   break;
-				case 'u' : show_pop   = !show_pop;   break;
 				case 'j' : i_org += (i_org + rows < size) ? 1 : 0; break;
 				case 'k' : i_org -= (i_org > 0)           ? 1 : 0; break;
 				case 'h' : j_org -= (j_org > 0)           ? 1 : 0; break;
 				case '+' : fps++;      break;
 				case '-' : fps--;      break;
 				case 'q' : quit(0);
+				case 't' : show_status = !show_status; break;
 			}
 		}
 		if (paused)
 	tcsetattr(0, TCSANOW, &set);
 
 	print();
-	print_coord(i, j);
+	print_status(i, j);
 
 	cursor_crd(i - i_org + 1, (j - j_org + 1) * 2 - 1);
 	fflush(stdout);
 
 	while (read(0, &c, sizeof(c)) > 0) {
 		switch (c) {
+			case 't' : show_status = !show_status;           print_flag = 1; break;
 			case '+' : fps++;                                print_flag = 1; break;
 			case '-' : fps--;                                print_flag = 1; break;
 			case ' ' : BITXOR(cur + i * BITNSLOTS(size), j); print_flag = 1; break;
-			case 'c' : show_coord = !show_coord;             print_flag = 1; break;
-			case 'r' : show_fps   = !show_fps;               print_flag = 1; break;
-			case 'g' : show_gen   = !show_gen;               print_flag = 1; break;
-			case 'u' : show_pop   = !show_pop;               print_flag = 1; break;
 			case 'J' : BITXOR(cur + i * BITNSLOTS(size), j); print_flag = 1; // fall through
 			case 'j' : i = MIN(i + 1, size - 1);
 					   if (i >= i_org + rows) {
 			print_flag = 0;
 			print();
 		}
-		print_coord(i, j);
+		print_status(i, j);
 		cursor_crd(i - i_org + 1, (j - j_org + 1) * 2 - 1);
 		fflush(stdout);
 	}
 		if (argv[i][0] != '-' || argv[i][1] == '\0' || argv[i][2] != '\0')
 			return 1;
 		switch (argv[i][1]) {
-			case 'c' : show_coord = 1;         break; // default 0
 			case 'f' : fps = atoi(argv[++i]);  break; // default 15
-			case 'g' : show_gen = 1;           break; // default 0
 			case 'i' : infile = argv[++i];     break; // default "/dev/urandom"
 			case 'o' : outfile = argv[++i];    break; // default NULL
 			case 'p' : paused = 1;             break; // default 0
-			case 'r' : show_fps = 1;           break; // default 0
 			case 's' : size = atoi(argv[++i]); break; // default 32
-			case 'u' : show_pop = 1;           break; // default 0
+			case 't' : show_status = 0;        break; // default 1
 			default  : return 1;
 		}
 	}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.