[Rd] cat with backspace and newline characters
peter dalgaard
pdalgd at gmail.com
Thu Nov 7 12:12:56 CET 2013
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
More information about the R-devel
mailing list