Anonymous avatar Anonymous committed 44e9aa3

change line editing back to stdout. the whole srw tail -f > in idea was wrong, seeing as tail doesn't cat. that being said i made a simple program that did tail -f with inotify and echoed from stdin to stdout, but it turns out you can't tell the difference between stdin and stdout from a pty

Comments (0)

Files changed (1)

 #define ESC         0x1b
 #define DEL         0x7f
 
-#define cursor_clr()  fprintf(stderr, "\033[J")
-#define cursor_beg()  fprintf(stderr, "\033[1G")
-#define cursor_fwd(n) fprintf(stderr, "\033[%dC", MAX(1, (n)))
-#define cursor_bak(n) fprintf(stderr, "\033[%dD", MAX(1, (n)))
+#define cursor_clr()  printf("\033[J")
+#define cursor_beg()  printf("\033[1G")
+#define cursor_fwd(n) printf("\033[%dC", MAX(1, (n)))
+#define cursor_bak(n) printf("\033[%dD", MAX(1, (n)))
 
 char  buf[4096], usrbuf[4096];
 char  scrl_prompt_left[]  = "<";
 {
 	cursor_beg();
 	cursor_clr();
-	fflush(stderr);
+	fflush(stdout);
 }
 
 int start_pos(int start, int cur, int len, int cols)
 
 	if (start > 0) {
 		left_prompt_len = strlen(scrl_prompt_left);
-		my_write(STDERR, scrl_prompt_left, left_prompt_len);
+		my_write(STDOUT, scrl_prompt_left, left_prompt_len);
 		cols = ws.ws_col - 1 - left_prompt_len;
 		start = start_pos(start, cur, len, cols);
 	} else {
-		my_write(STDERR, nrml_prompt, left_prompt_len);
+		my_write(STDOUT, nrml_prompt, left_prompt_len);
 	}
 
 	if (start + cols < len) {
 		start = start_pos(start, cur, len, cols);
 	}
 
-	my_write(STDERR, usrbuf + start, MIN(cols, len));
+	my_write(STDOUT, usrbuf + start, MIN(cols, len));
 
 	if (start + cols < len)
-		my_write(STDERR, scrl_prompt_right, right_prompt_len);
+		my_write(STDOUT, scrl_prompt_right, right_prompt_len);
 
 	cursor_beg();
 	cursor_fwd(left_prompt_len + cur - start);
-	fflush(stderr);
+	fflush(stdout);
 }
 
 void shift_buf(char *buf, int ind, int len, int delta)
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.