Anonymous avatar Anonymous committed 2951395

for late_start, sleep before we measure window size. only read at most 1 buffer full at a time, so user can still input. change save/restore cursor escapes, now works in tmux

Comments (0)

Files changed (1)

 #define ESC         0x1b
 #define DEL         0x7f
 
-#define cursor_scp()  printf("\033[s")
-#define cursor_rcp()  printf("\033[u")
+#define cursor_scp()  printf("\0337")
+#define cursor_rcp()  printf("\0338")
 #define cursor_clr()  printf("\033[J")
 #define cursor_beg()  printf("\033[1G")
 #define cursor_up(n)  printf("\033[%dA", MAX(1, (n)))
 				cursor_rcp();
 				fflush(stdout);
 			}
-			for (rdlen = read(mfd, buf, sizeof(buf)); rdlen > 0; rdlen = read(mfd, buf, sizeof(buf))) {
+
+			rdlen = read(mfd, buf, sizeof(buf));
+			if (rdlen < 0 && errno != EAGAIN) {
+				warn("failed to read from fd %d", mfd);
+			} else {
 				my_write(STDOUT, buf, rdlen);
-				incomplete = buf[rdlen-1] != '\n';
+				incomplete = (buf[rdlen - 1] != '\n');
 			}
-			if (rdlen < 0 && errno != EAGAIN)
-				warn("failed to read from fd %d", mfd);
+
 			if (incomplete) {
 				tcflag_t old = set.c_oflag;
 				set.c_oflag &= ~ONLCR;
 	memcpy(&set, &dfl, sizeof(set));
 	set.c_lflag &= ~ECHO;
 
+	if (late_start)
+		sleep(late_start);
+
 	if (ioctl(STDOUT, TIOCGWINSZ, &ws) < 0)
 		err(1, "failed ioctl");
 
-	if (late_start)
-		sleep(late_start);
-
 	if ((child = forkpty(&mfd, NULL, &set, &ws)) == 0) { //child
 		execvp(argv[i], &argv[i]);
 		err(1, "failed execvp %s", argv[i]);
 		if (signal(sig_table[i].sig, sig_table[i].func) == SIG_ERR)
 			err(1, "failed to install %s handler", sig_table[i].name);
 
-	sigwinch(0);
 	print_usr();
 	run();
 
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.