lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Jul 14, 2010, at 10:38 PM, Luiz Henrique de Figueiredo wrote:

>> I just can't seem to find any reference to \r in PIL or the reference manual. I thought that it is a type of carriage return but I don't understand how it would keep from the screen from scrolling if it was
> 
> \r is mentioned in http://www.lua.org/manual/5.1/manual.html#2.1 in the
> paragraph that starts "Literal strings..."
> 
> The interpretation of \r after it is outpout is done by the terminal emulation
> program you are using and it's a standard interpretation that it moves the
> cursor to the beginning of the line. 

Luiz is right, but I'd already traveled down memory lane, so here is some historical perspective...

Back in the days of real TTYs [1] there were two Baudot [2] control characters to position the paper(!). One was CR for Carriage Return; it moved the print head to the left side of the paper. The other was LF or Line Feed; it rolled the paper up one line but didn't do anything to the position of the print head. To go to the beginning of the next line, you had to send CR LF. HTTP still requires this two character sequence to terminate a line.

Sometime in the 60s people making glass TTYs [3] decided that CR LF was so common that to save transmission time (and typing) it should be possible to use just one control character for CR LF; some chose LF and called it newline [4]; C named it \n in strings. We won't speak of the others who made different choices. CR is named \r in C strings. 

Wikipedia says "The first power carriage return was added to electric typewriters by Smith Corona in 1960. The key for this was usually labelled "carriage return" or "return". [5] Too bad it wasn't called "new line."

e

[1] http://en.wikipedia.org/wiki/Teleprinter
[2] http://en.wikipedia.org/wiki/Baudot_code
[3] http://catb.org/jargon/html/tv-typewriters.html
[4] http://en.wikipedia.org/wiki/Newline
[5] http://en.wikipedia.org/wiki/Carriage_return