From bf7448dbe910bf34a8c0830c5f1bda5d7042328f Mon Sep 17 00:00:00 2001
From: Alexander Sedov <alex0player@gmail.com>
Date: Mon, 25 Feb 2013 04:39:19 +0400
Subject: [st] [PATCH] Replacing linefeeds with returns in ttywrite().
To: dev@suckless.org

This is to work around buggy behaviour in applications such as nano,
and seems to work fine with all other applications.
---
 st.c |    3 +++
 1 file changed, 3 insertions(+)

diff --git a/st.c b/st.c
index afa6813..5aae132 100644
--- a/st.c
+++ b/st.c
@@ -1109,6 +1109,9 @@ ttyread(void) {
 
 void
 ttywrite(const char *s, size_t n) {
+	char *p;
+	for(p = memchr(s, '\n', n); p != NULL; p = memchr(p, '\n', s + n - p))
+		*p = '\r';
 	if(write(cmdfd, s, n) == -1)
 		die("write error on tty: %s\n", SERRNO);
 }
-- 
1.7.10.4

