Evan Gates  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

  • Participants
  • Parent commits 0ac3b78
  • Branches default

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[]  = "<";
-	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_fwd(left_prompt_len + cur - start);
-	fflush(stderr);
+	fflush(stdout);
 void shift_buf(char *buf, int ind, int len, int delta)