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

Re: How come i wrote a NO-BREAK SPACE in xterm+bash ?



On 2015-08-21 07:30:18 +0200, Erwan David wrote:
> On Fri, Aug 21, 2015 at 04:56:54AM CEST, David Wright <deblis@lionunicorn.co.uk> said:
> > Quoting Vincent Lefevre (vincent@vinc17.net):
> > > On 2015-08-19 16:33:09 -0500, David Wright wrote:
> > > > Quoting Thomas Schmitt (scdbackup@gmx.net):
> > > > > But the typographical purpose of NO-BREAK SPACE is to look
> > > > > like space without inviting an automatic line break.
> > > > > So making it look not like space would be absurd.
> > > > 
> > > > But shell input is not a typographical context. Most source code
> > > > isn't, except in literals. Documents generally are because they are
> > > > displayed/printed.
> > > 
> > > The point is that the terminal cannot do the difference between
> > > a NBSP coming from shell input and a NBSP coming from a displayed
> > > document. So, it should render a NBSP exactly like a normal space.
> > > And it is up to the application (the shell, an editor in some
> > > mode, etc.) to render NBSP in a special way if needed.
> > 
> > Why not? Let's substitute TAB TAB for NBSP in your comment.
> > My terminal happily swallows TAB TAB with cat > file, and renders
> > it correctly with cat file. But when I type TAB TAB as shell input,
> > I get "Display all 3402 possibilities? (y or n)". It seems to be able
> > to "do the difference" in this case.
> 
> 1) You're speaking input, Vincent was speaking output

Yes, and for input, there is also a small difference. When one types
"cat > file", the terminal is put in cooked mode:

  https://en.wikipedia.org/wiki/Cooked_mode

The TAB gets interpreted by the terminal as a normal character, before
the whole line is sent to the program (unless interrupted).

As shell input, the terminal is in raw mode, so that the TAB is
*immediately* sent as a normal character to the shell, which
interprets it in a special way.

In both cases, the TAB is sent as a normal character to the program,
but only the way it is sent is different.

Note: just like it is possible to put the terminal in cooked mode or
in raw mode for input, it could be possible for output to to instruct
the terminal how a NBSP should be displayed. This could typically be
done via escape sequences. So, applications would no longer need to
care how to display NBSP; they would just need to send the escape
sequences at the beginning and at the end. But nothing standard.
Well, this would be more complex in practice because programs can
execute other programs or can be killed... But the problem would be
the same as the ones with the other modes (e.g. cursor invisibility,
alternate screen, and so on).

-- 
Vincent Lefèvre <vincent@vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)


Reply to: