Am 01.07.2011 16:48, schrieb Jean-Marc Lasgouttes:

screen rendering is worse. Uwe, does this patch still produce invisible screen 
space on windows?

The problem is the same under any OS. Our user are free to pick the font they 
want (with or without
accents if they are English speakers, limited to latin1++ for western 
countries...) and nobody knows
whether visible space is in there. If we use it in our manuals, then many 
people will be just unable
to view the manual!

Yes, that is why I'm using TeX code in the manual (e.g. the Math manual).

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.

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. Moreover, all other spaces create a space with a certain width, but this one creates a character, no space! And as InsetSpace you couls accidentally click on it and change it e.g. to a real space but on screen it is hard to see the difference/that something was changed. Changing spaced to a character is also unintuitive and I don't see why this would be useful.

regards Uwe
Index: lib/ui/stdmenus.inc
===================================================================
--- lib/ui/stdmenus.inc	(revision 39310)
+++ lib/ui/stdmenus.inc	(working copy)
@@ -384,6 +384,7 @@
 		Item "Breakable Slash|a" "specialchar-insert slash"
 		Item "Menu Separator|M" "specialchar-insert menu-separator"
 		Item "Phonetic Symbols|P" "command-sequence math-insert \text\textipa ; char-forward ;"
+		Item "Visible Space|V" "specialchar-insert visible-space"
 	End
 
 	Menu "insert_formatting"
Index: src/insets/InsetSpecialChar.cpp
===================================================================
--- src/insets/InsetSpecialChar.cpp	(revision 39310)
+++ src/insets/InsetSpecialChar.cpp	(working copy)
@@ -64,6 +64,9 @@
 		case MENU_SEPARATOR:
 			s = " x ";
 			break;
+		case VISIBLE_SPACE:
+			s = "x";
+			break;
 		case HYPHENATION:
 			s = "-";
 			break;
@@ -133,6 +136,25 @@
 		pi.pain.lines(xp, yp, 4, Color_special);
 		break;
 	}
+	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;
+	}
 	case SLASH:
 	{
 		font.setColor(Color_special);
@@ -169,6 +191,9 @@
 	case MENU_SEPARATOR:
 		command = "\\menuseparator";
 		break;
+	case VISIBLE_SPACE:
+		command = "\\textvisiblespace{}";
+		break;
 	case SLASH:
 		command = "\\slash{}";
 		break;
@@ -196,6 +221,8 @@
 		kind_ = LDOTS;
 	else if (command == "\\menuseparator")
 		kind_ = MENU_SEPARATOR;
+	else if (command == "\\textvisiblespace{}")
+		kind_ = VISIBLE_SPACE;
 	else if (command == "\\slash{}")
 		kind_ = SLASH;
 	else if (command == "\\nobreakdash-")
@@ -227,6 +254,9 @@
 		else
 			os << "\\lyxarrow{}";
 		break;
+	case VISIBLE_SPACE:
+		os << "\\textvisiblespace{}";
+		break;
 	case SLASH:
 		os << "\\slash{}";
 		break;
@@ -254,6 +284,9 @@
 	case MENU_SEPARATOR:
 		os << "->";
 		return 2;
+	case VISIBLE_SPACE:
+		os << "|_|";
+		return 3;
 	case SLASH:
 		os << '/';
 		return 1;
@@ -280,6 +313,9 @@
 	case MENU_SEPARATOR:
 		os << "&lyxarrow;";
 		break;
+	case VISIBLE_SPACE:
+		os << "|_|";
+		break;
 	case SLASH:
 		os << '/';
 		break;
@@ -306,6 +342,9 @@
 	case MENU_SEPARATOR:
 		xs << XHTMLStream::ESCAPE_NONE << "&rArr;";
 		break;
+	case VISIBLE_SPACE:
+		xs << XHTMLStream::ESCAPE_NONE << "&#x2423;";
+		break;
 	case SLASH:
 		xs << XHTMLStream::ESCAPE_NONE << "&frasl;";
 		break;
@@ -343,7 +382,7 @@
 bool InsetSpecialChar::isLetter() const
 {
 	return kind_ == HYPHENATION || kind_ == LIGATURE_BREAK
-		|| kind_ == NOBREAKDASH;
+		|| kind_ == NOBREAKDASH || kind_ == VISIBLE_SPACE;
 }
 
 
Index: src/insets/InsetSpecialChar.h
===================================================================
--- src/insets/InsetSpecialChar.h	(revision 39310)
+++ src/insets/InsetSpecialChar.h	(working copy)
@@ -38,6 +38,8 @@
 		END_OF_SENTENCE,
 		/// Menu separator
 		MENU_SEPARATOR,
+		/// visible space
+		VISIBLE_SPACE,
 		/// breakable slash
 		SLASH,
 		/// protected dash
Index: src/LyXAction.cpp
===================================================================
--- src/LyXAction.cpp	(revision 39310)
+++ src/LyXAction.cpp	(working copy)
@@ -497,7 +497,7 @@
  * \li Action: Inserts various characters into the document.
  * \li Syntax: specialchar-insert <CHAR>
  * \li Params: <CHAR>: hyphenation, ligature-break, slash, nobreakdash, dots,
-                       end-of-sentence, menu-separator.
+                       end-of-sentence, menu-separator, visible-space.
  * \li Origin: JSpitzm, 6 Dec 2007
  * \endvar
  */
Index: src/Text3.cpp
===================================================================
--- src/Text3.cpp	(revision 39310)
+++ src/Text3.cpp	(working copy)
@@ -1149,6 +1149,8 @@
 			specialChar(cur, InsetSpecialChar::END_OF_SENTENCE);
 		else if (name == "menu-separator")
 			specialChar(cur, InsetSpecialChar::MENU_SEPARATOR);
+		else if (name == "visible-space")
+			specialChar(cur, InsetSpecialChar::VISIBLE_SPACE);
 		else if (name.empty())
 			lyxerr << "LyX function 'specialchar-insert' needs an argument." << endl;
 		else

Reply via email to