case InsetSpaceParams::PROTECTED:
message = _("Protected Space");
break;
+ case InsetSpaceParams::VISIBLE:
+ message = _("Visible Space");
+ break;
case InsetSpaceParams::THIN:
message = _("Thin Space");
break;
message = _("Quad Space");
break;
case InsetSpaceParams::QQUAD:
- message = _(" Double Quad Space");
+ message = _("Double Quad Space");
break;
case InsetSpaceParams::ENSPACE:
message = _("Enspace");
{
switch (cmd.action()) {
- case LFUN_INSET_MODIFY:
- string2params(to_utf8(cmd.argument()), params_);
+ case LFUN_INSET_MODIFY: {
+ cur.recordUndo();
+ string arg = to_utf8(cmd.argument());
+ if (arg == "space \\hspace{}")
+ arg += params_.length.len().empty()
+ ? " \\length 1" + string(stringFromUnit(Length::defaultUnit()))
+ : " \\length " + params_.length.asString();
+ string2params(arg, params_);
break;
+ }
case LFUN_INSET_DIALOG_UPDATE:
cur.bv().updateDialog("space", params2string(params()));
InsetSpaceParams params;
string2params(to_utf8(cmd.argument()), params);
status.setOnOff(params_.kind == params.kind);
- }
- // fall through
+ status.setEnabled(true);
+ } else
+ status.setEnabled(false);
+ return true;
+
case LFUN_INSET_DIALOG_UPDATE:
status.setEnabled(true);
return true;
dim.wid = fm.width(char_type('M')) / 2;
break;
case InsetSpaceParams::PROTECTED:
+ case InsetSpaceParams::VISIBLE:
case InsetSpaceParams::NORMAL:
dim.wid = fm.width(char_type(' '));
break;
xp[0] = x;
yp[0] = y - max(h / 4, 1);
if (params_.kind == InsetSpaceParams::NORMAL ||
- params_.kind == InsetSpaceParams::PROTECTED) {
+ params_.kind == InsetSpaceParams::PROTECTED ||
+ params_.kind == InsetSpaceParams::VISIBLE) {
xp[1] = x; yp[1] = y;
xp[2] = x + w; yp[2] = y;
} else {
xp[3] = x + w;
yp[3] = y - max(h / 4, 1);
+ Color col = Color_special;
if (params_.kind == InsetSpaceParams::PROTECTED ||
params_.kind == InsetSpaceParams::ENSPACE ||
params_.kind == InsetSpaceParams::NEGTHIN ||
params_.kind == InsetSpaceParams::NEGMEDIUM ||
params_.kind == InsetSpaceParams::NEGTHICK ||
params_.kind == InsetSpaceParams::CUSTOM_PROTECTED)
- pi.pain.lines(xp, yp, 4, Color_latex);
- else
- pi.pain.lines(xp, yp, 4, Color_special);
+ col = Color_latex;
+ else if (params_.kind == InsetSpaceParams::VISIBLE)
+ col = Color_foreground;
+
+ pi.pain.lines(xp, yp, 4, col);
}
case InsetSpaceParams::PROTECTED:
os << "~";
break;
+ case InsetSpaceParams::VISIBLE:
+ os << "\\textvisiblespace{}";
+ break;
case InsetSpaceParams::THIN:
os << "\\thinspace{}";
break;
kind = InsetSpaceParams::NORMAL;
else if (command == "~")
kind = InsetSpaceParams::PROTECTED;
+ else if (command == "\\textvisiblespace{}")
+ kind = InsetSpaceParams::VISIBLE;
else if (command == "\\thinspace{}")
kind = InsetSpaceParams::THIN;
else if (math && command == "\\medspace{}")
kind = InsetSpaceParams::ENSKIP;
else if (command == "\\negthinspace{}")
kind = InsetSpaceParams::NEGTHIN;
- else if (math && command == "\\negmedspace{}")
+ else if (command == "\\negmedspace{}")
kind = InsetSpaceParams::NEGMEDIUM;
- else if (math && command == "\\negthickspace{}")
+ else if (command == "\\negthickspace{}")
kind = InsetSpaceParams::NEGTHICK;
else if (command == "\\hfill{}")
kind = InsetSpaceParams::HFILL;
}
-int InsetSpace::latex(odocstream & os, OutputParams const & runparams) const
+void InsetSpace::latex(otexstream & os, OutputParams const & runparams) const
{
switch (params_.kind) {
case InsetSpaceParams::NORMAL:
else
os << (runparams.free_spacing ? ' ' : '~');
break;
+ case InsetSpaceParams::VISIBLE:
+ os << (runparams.free_spacing ? " " : "\\textvisiblespace{}");
+ break;
case InsetSpaceParams::THIN:
os << (runparams.free_spacing ? " " : "\\,");
break;
os << "\\hspace*{" << from_ascii(params_.length.asLatexString()) << "}";
break;
}
- return 0;
}
-int InsetSpace::plaintext(odocstream & os, OutputParams const &) const
+int InsetSpace::plaintext(odocstringstream & os,
+ OutputParams const &, size_t) const
{
switch (params_.kind) {
case InsetSpaceParams::HFILL:
case InsetSpaceParams::DOWNBRACEFILL:
os << "/-^-\\";
return 5;
+ case InsetSpaceParams::VISIBLE:
+ os.put(0x2423);
+ return 1;
+ case InsetSpaceParams::ENSKIP:
+ os.put(0x2002);
+ return 1;
+ case InsetSpaceParams::ENSPACE:
+ os.put(0x2060); // WORD JOINER, makes the breakable en space unbreakable
+ os.put(0x2002);
+ os.put(0x2060); // WORD JOINER, makes the breakable en space unbreakable
+ return 3;
+ case InsetSpaceParams::QUAD:
+ os.put(0x2003);
+ return 1;
+ case InsetSpaceParams::QQUAD:
+ os.put(0x2003);
+ os.put(0x2003);
+ return 2;
+ case InsetSpaceParams::THIN:
+ os.put(0x202f);
+ return 1;
+ case InsetSpaceParams::MEDIUM:
+ os.put(0x200b); // ZERO WIDTH SPACE, makes the unbreakable medium space breakable
+ os.put(0x2005);
+ os.put(0x200b); // ZERO WIDTH SPACE, makes the unbreakable medium space breakable
+ return 1;
+ case InsetSpaceParams::THICK:
+ os.put(0x200b); // ZERO WIDTH SPACE, makes the unbreakable thick space breakable
+ os.put(0x2004);
+ os.put(0x200b); // ZERO WIDTH SPACE, makes the unbreakable thick space breakable
+ return 1;
+ case InsetSpaceParams::PROTECTED:
+ case InsetSpaceParams::CUSTOM_PROTECTED:
+ os.put(0x00a0);
+ return 1;
+ case InsetSpaceParams::NEGTHIN:
+ case InsetSpaceParams::NEGMEDIUM:
+ case InsetSpaceParams::NEGTHICK:
+ return 0;
default:
os << ' ';
return 1;
case InsetSpaceParams::ENSKIP:
os << " ";
break;
+ // FIXME For spaces and dashes look here:
+ // http://oreilly.com/catalog/docbook/book2/iso-pub.html
case InsetSpaceParams::PROTECTED:
+ // FIXME ␣ ?
+ case InsetSpaceParams::VISIBLE:
case InsetSpaceParams::ENSPACE:
+ // FIXME   ?
case InsetSpaceParams::THIN:
case InsetSpaceParams::MEDIUM:
case InsetSpaceParams::THICK:
case InsetSpaceParams::HFILL:
case InsetSpaceParams::HFILL_PROTECTED:
os << '\n';
+ break;
case InsetSpaceParams::DOTFILL:
// FIXME
os << '\n';
+ break;
case InsetSpaceParams::HRULEFILL:
// FIXME
os << '\n';
+ break;
case InsetSpaceParams::LEFTARROWFILL:
case InsetSpaceParams::RIGHTARROWFILL:
case InsetSpaceParams::UPBRACEFILL:
case InsetSpaceParams::CUSTOM_PROTECTED:
// FIXME
os << '\n';
+ break;
}
return 0;
}
output = " ";
break;
case InsetSpaceParams::ENSKIP:
- case InsetSpaceParams::ENSPACE:
output =" ";
break;
+ case InsetSpaceParams::ENSPACE:
+ output ="⁠ ⁠";
+ break;
case InsetSpaceParams::QQUAD:
- output =" ";
+ output ="  ";
+ break;
case InsetSpaceParams::THICK:
+ output =" ";
+ break;
case InsetSpaceParams::QUAD:
output =" ";
break;
+ case InsetSpaceParams::MEDIUM:
+ output =" ";
+ break;
case InsetSpaceParams::THIN:
output =" ";
break;
case InsetSpaceParams::PROTECTED:
- case InsetSpaceParams::MEDIUM:
case InsetSpaceParams::NEGTHIN:
case InsetSpaceParams::NEGMEDIUM:
case InsetSpaceParams::NEGTHICK:
output =" ";
break;
+ // no XHTML entity, only unicode code for space character exists
+ case InsetSpaceParams::VISIBLE:
+ output ="␣";
+ break;
case InsetSpaceParams::HFILL:
case InsetSpaceParams::HFILL_PROTECTED:
case InsetSpaceParams::DOTFILL:
// Can we do anything with those in HTML?
break;
case InsetSpaceParams::CUSTOM:
+ // FIXME XHTML
+ // Probably we could do some sort of blank span?
+ break;
case InsetSpaceParams::CUSTOM_PROTECTED:
// FIXME XHTML
// Probably we could do some sort of blank span?
+ output =" ";
break;
}
// don't escape the entities!
- xs << XHTMLStream::NextRaw() << from_ascii(output);
+ xs << XHTMLStream::ESCAPE_NONE << from_ascii(output);
return docstring();
}
}
-void InsetSpace::tocString(odocstream & os) const
+void InsetSpace::toString(odocstream & os) const
+{
+ odocstringstream ods;
+ plaintext(ods, OutputParams(0));
+ os << ods.str();
+}
+
+
+void InsetSpace::forOutliner(docstring & os, size_t) const
{
- plaintext(os, OutputParams(0));
+ // There's no need to be cute here.
+ os += " ";
}
}
-docstring InsetSpace::contextMenu(BufferView const &, int, int) const
+string InsetSpace::contextMenuName() const
{
- return from_ascii("context-space");
+ return "context-space";
}
params.math = true;
else {
params.math = false;
- LASSERT(name == "space", /**/);
+ // we can try to read this even if the name is wrong
+ LATTEST(name == "space");
}
// There are cases, such as when we are called via getStatus() from