Le 15/07/11 22:30, Uwe Stöhr a écrit :
I don't agree that implementing it as part of the space inset is a good
idea. \textvisiblespace is not a space in the sense of the meaning but a
special character. It does not create a space, but a character. I would
therefore like to implement this as special character like an ellipsis.

I still think it is wrong, but I am not going to fight forever on that (what is there a space in "foo bar" and not "foo_bar"???).

Attached is a patch that does this.

The advantage is that we avoid confusions. If we would implement it as
InsetSpace, it is hard for the user to distinguish it within LyX from
the other spaces.

Just output it in black instead of blue.

Remarks on the patch:

+               case VISIBLE_SPACE:
+                       s = "x";
+                       break;

Please use the width of ' ', as we do for protected space.

+       case VISIBLE_SPACE:
+       {
+               frontend::FontMetrics const & fm =
+                       theFontMetrics(font);
+
+               // An "u" the width of an 'x' and the third height of a 'W'
+               int wid = fm.width(char_type('x'));
+               int oxwid = x;
+               int hei = fm.ascent(char_type('W'));
+               int xp[4], yp[4];
+
+               xp[0] = oxwid;                  yp[0] = y - hei/3;
+               xp[1] = oxwid;                  yp[1] = y;
+               xp[2] = oxwid + wid;    yp[2] = y;
+               xp[3] = oxwid + wid;    yp[3] = y - hei/3;
+
+               pi.pain.lines(xp, yp, 4, Color_special);
+               break;

Please use the same code as for protected space. There is no reason to use a different drawing ("the third height of a 'W'" seems especially esoteric to me). I also think color should be black.

+       case VISIBLE_SPACE:
+               os << "\\textvisiblespace{}";
+               break;

For LaTeX output, can't we just output the unicode character and let our stream sort out the right output? We may want unicode to output natively (maybe also for other special characters, actually).

+       case VISIBLE_SPACE:
+               os << "|_|";
+               return 3;

I do not think it makes much sense to use this ascii-art output here. I would use a plain space or an underscore. Or even the unicode character, since we output to utf8 (Hmmm, do we?)

+       case VISIBLE_SPACE:
+               os << "|_|";
+               break;

ditto.

 bool InsetSpecialChar::isLetter() const
 {
        return kind_ == HYPHENATION || kind_ == LIGATURE_BREAK
-               || kind_ == NOBREAKDASH;
+               || kind_ == NOBREAKDASH || kind_ == VISIBLE_SPACE;
 }

This means that "foo_bar" will be only one word. Is it really what you intend?

JMarc

Reply via email to