From pdalgd at gmail.com  Thu Nov  7 12:12:56 2013
From: pdalgd at gmail.com (peter dalgaard)
Date: Thu, 7 Nov 2013 12:12:56 +0100
Subject: [Rd] cat with backspace and newline characters
In-Reply-To: <CANVKczNpi9p+c5zkZBj2vjSyVkUcb12XzTrj6+nfbesg84QNig@mail.gmail.com>
References: <CAHavPHGe1A7R6RxD45exQnq7zJXWatiKQ8rR7SiFJBE2RGVQDQ@mail.gmail.com>
	<CADv2QyG6Nvn+YJ46Pz5PF7FqB9Q-LnEeLE4_EAgfVgBKo+EakA@mail.gmail.com>
	<CAHavPHH7VMYxBLjJsDO_2wwS-tC=gwbHiMfXVeP4fhXPZiJwNg@mail.gmail.com>
	<CAH7sKSN6a7ObU8g7xXf+fHq0cdMeKvsr7PSsorhNZ=DP3Pf8Ow@mail.gmail.com>
	<21112.61708.698124.149056@stat.math.ethz.ch>
	<8E2469B4-2A7B-44DD-896F-F409C39F4496@sciviews.org>
	<21113.8847.603856.486049@stat.math.ethz.ch>
	<A750360B-31A8-49EB-B21F-87EE4BA6E412@gmail.com>
	<CANROs4e=Do0ejPc7w=rOzG8zzNdhkmYWFJN=qU61JQRGnLWiPQ@mail.gmail.com>
	<CAHavPHHwsSq05zhDcCVMBo6kbvgBRwetCx45H19knmRU1xs-_Q@mail.gmail.com>
	<15FAF9D3-1BA6-48EA-8B98-1347B97256CD@r-project.org>
	<CAHavPHEOdVJQH_iv3WhxZm65uoJPh+Wn1=B1Vd+O7Fdt3aQnTw@mail.gmail.com>
	<3e624aa3dd724c3aa3d6221fdf0dacf5@EX-0-HT0.lancs.local>
	<CANVKczNpi9p+c5zkZBj2vjSyVkUcb12XzTrj6+nfbesg84QNig@mail.gmail.com>
Message-ID: <6B506EB1-78CB-41A4-8DD3-D6617BC5E55D@gmail.com>


On 07 Nov 2013, at 10:13 , Barry Rowlingson <b.rowlingson at lancaster.ac.uk> wrote:

> On Thu, Nov 7, 2013 at 8:28 AM, Jari Oksanen <jari.oksanen at oulu.fi> wrote:
>> 
>> On 07/11/2013, at 09:35 AM, Renaud Gaujoux wrote:
>> 
>>> I agree that the handling of \b is not that strange, once one agrees
>>> on what \b actually means, i.e. "go back one character" and not
>>> "delete previous character".
> 
> It means, to paraphrase Humpty Dumpty from Alice in Wonderland,
> whatever the terminal chooses it to mean. If you want to do something
> meaningful and consistent across different terminals, you use termcap
> or terminfo:
> 
> http://en.wikipedia.org/wiki/Termcap
> http://en.wikipedia.org/wiki/Terminfo
> 
> or other abstractions probably built on that (eg 'ncurses').
> 
>> As a user DEC LA120 terminal I expect the following:
>> 
>>> cat("a\b^\n")
>> ?
>>> 
>> 
>> Everything else feels like a bug.
> 
> Oh noes! I don't have a terminfo entry for my DEC LA120!
> 
> I don't know what flavour of 'terminal' RStudio, the Windows GUI or
> emacs-ess behave as and whether there's terminfo entries for them....
> 
> Do any R packages link with termcap to do controlled screen output? Hmmmm....

Termcap or terminfo, make up your mind....

AFAIK, the readline library is linked to the term* databases (via ncurses, I suppose), so R-in-a-terminal is (usually) linked to them too. Insofar as there is any sanity left in building terminal interfaces, the sane thing would be to go via ncurses rather than outputting specific escape sequences. 

Of course, there is nothing keeping you from doing silly things like

options(prompt="\033[2J> ")

or

options(prompt="\033[5mI eagerly and patiently await your command, oh Master \033[0m> ")

:-{)

-pd

-- 
Peter Dalgaard, Professor
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd.mes at cbs.dk  Priv: PDalgd at gmail.com



[Rd] cat with backspace and newline characters
peter dalgaard