3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Asger Alstrup Nielsen
7 * \author Jean-Marc Lasgouttes
8 * \author Lars Gullik Bjønnes
9 * \author Jürgen Spitzmüller
11 * Full author contact details are available in file CREDITS.
16 #include "InsetSpace.h"
18 #include "BufferView.h"
20 #include "Dimension.h"
21 #include "FuncRequest.h"
22 #include "FuncStatus.h"
24 #include "LaTeXFeatures.h"
27 #include "MetricsInfo.h"
28 #include "OutputParams.h"
29 #include "output_xhtml.h"
30 #include "texstream.h"
32 #include "support/debug.h"
33 #include "support/docstream.h"
34 #include "support/gettext.h"
35 #include "support/lassert.h"
36 #include "support/lstrings.h"
38 #include "frontends/Application.h"
39 #include "frontends/FontMetrics.h"
40 #include "frontends/Painter.h"
47 InsetSpace::InsetSpace(InsetSpaceParams const & params)
48 : Inset(0), params_(params)
52 InsetSpaceParams::Kind InsetSpace::kind() const
58 GlueLength InsetSpace::length() const
60 return params_.length;
64 docstring InsetSpace::toolTip(BufferView const &, int, int) const
67 switch (params_.kind) {
68 case InsetSpaceParams::NORMAL:
69 message = _("Interword Space");
71 case InsetSpaceParams::PROTECTED:
72 message = _("Protected Space");
74 case InsetSpaceParams::VISIBLE:
75 message = _("Visible Space");
77 case InsetSpaceParams::THIN:
78 message = _("Thin Space");
80 case InsetSpaceParams::MEDIUM:
81 message = _("Medium Space");
83 case InsetSpaceParams::THICK:
84 message = _("Thick Space");
86 case InsetSpaceParams::QUAD:
87 message = _("Quad Space");
89 case InsetSpaceParams::QQUAD:
90 message = _("Double Quad Space");
92 case InsetSpaceParams::ENSPACE:
93 message = _("Enspace");
95 case InsetSpaceParams::ENSKIP:
96 message = _("Enskip");
98 case InsetSpaceParams::NEGTHIN:
99 message = _("Negative Thin Space");
101 case InsetSpaceParams::NEGMEDIUM:
102 message = _("Negative Medium Space");
104 case InsetSpaceParams::NEGTHICK:
105 message = _("Negative Thick Space");
107 case InsetSpaceParams::HFILL:
108 message = _("Horizontal Fill");
110 case InsetSpaceParams::HFILL_PROTECTED:
111 message = _("Protected Horizontal Fill");
113 case InsetSpaceParams::DOTFILL:
114 message = _("Horizontal Fill (Dots)");
116 case InsetSpaceParams::HRULEFILL:
117 message = _("Horizontal Fill (Rule)");
119 case InsetSpaceParams::LEFTARROWFILL:
120 message = _("Horizontal Fill (Left Arrow)");
122 case InsetSpaceParams::RIGHTARROWFILL:
123 message = _("Horizontal Fill (Right Arrow)");
125 case InsetSpaceParams::UPBRACEFILL:
126 message = _("Horizontal Fill (Up Brace)");
128 case InsetSpaceParams::DOWNBRACEFILL:
129 message = _("Horizontal Fill (Down Brace)");
131 case InsetSpaceParams::CUSTOM:
133 message = support::bformat(_("Horizontal Space (%1$s)"),
134 from_ascii(params_.length.asString()));
136 case InsetSpaceParams::CUSTOM_PROTECTED:
138 message = support::bformat(_("Protected Horizontal Space (%1$s)"),
139 from_ascii(params_.length.asString()));
146 void InsetSpace::doDispatch(Cursor & cur, FuncRequest & cmd)
148 switch (cmd.action()) {
150 case LFUN_INSET_MODIFY: {
152 string arg = to_utf8(cmd.argument());
153 if (arg == "space \\hspace{}")
154 arg += params_.length.len().empty()
155 ? " \\length 1" + string(stringFromUnit(Length::defaultUnit()))
156 : " \\length " + params_.length.asString();
157 string2params(arg, params_);
161 case LFUN_INSET_DIALOG_UPDATE:
162 cur.bv().updateDialog("space", params2string(params()));
166 Inset::doDispatch(cur, cmd);
172 bool InsetSpace::getStatus(Cursor & cur, FuncRequest const & cmd,
173 FuncStatus & status) const
175 switch (cmd.action()) {
177 case LFUN_INSET_MODIFY:
178 if (cmd.getArg(0) == "space") {
179 InsetSpaceParams params;
180 string2params(to_utf8(cmd.argument()), params);
181 status.setOnOff(params_.kind == params.kind);
182 status.setEnabled(true);
184 status.setEnabled(false);
187 case LFUN_INSET_DIALOG_UPDATE:
188 status.setEnabled(true);
191 return Inset::getStatus(cur, cmd, status);
197 int const arrow_size = 8;
201 void InsetSpace::metrics(MetricsInfo & mi, Dimension & dim) const
204 // The width for hfills is calculated externally in
205 // TextMetrics::setRowAlignment. The value of 5 is the
206 // minimal value when the hfill is not active.
207 dim = Dimension(5, 10, 10);
211 frontend::FontMetrics const & fm = theFontMetrics(mi.base.font);
212 dim.asc = fm.maxAscent();
213 dim.des = fm.maxDescent();
214 int const em = fm.em();
216 switch (params_.kind) {
217 case InsetSpaceParams::THIN:
218 case InsetSpaceParams::NEGTHIN:
221 case InsetSpaceParams::MEDIUM:
222 case InsetSpaceParams::NEGMEDIUM:
225 case InsetSpaceParams::THICK:
226 case InsetSpaceParams::NEGTHICK:
229 case InsetSpaceParams::PROTECTED:
230 case InsetSpaceParams::VISIBLE:
231 case InsetSpaceParams::NORMAL:
232 dim.wid = fm.width(char_type(' '));
234 case InsetSpaceParams::QUAD:
237 case InsetSpaceParams::QQUAD:
240 case InsetSpaceParams::ENSPACE:
241 case InsetSpaceParams::ENSKIP:
242 dim.wid = int(0.5 * em);
244 case InsetSpaceParams::CUSTOM:
245 case InsetSpaceParams::CUSTOM_PROTECTED: {
246 int const w = mi.base.inPixels(params_.length.len());
247 int const minw = (w < 0) ? 3 * arrow_size : 4;
248 dim.wid = max(minw, abs(w));
251 case InsetSpaceParams::HFILL:
252 case InsetSpaceParams::HFILL_PROTECTED:
253 case InsetSpaceParams::DOTFILL:
254 case InsetSpaceParams::HRULEFILL:
255 case InsetSpaceParams::LEFTARROWFILL:
256 case InsetSpaceParams::RIGHTARROWFILL:
257 case InsetSpaceParams::UPBRACEFILL:
258 case InsetSpaceParams::DOWNBRACEFILL:
265 void InsetSpace::draw(PainterInfo & pi, int x, int y) const
267 Dimension const dim = dimension(*pi.base.bv);
269 if (isHfill() || params_.length.len().value() < 0) {
270 int const asc = theFontMetrics(pi.base.font).ascent('M');
271 int const desc = theFontMetrics(pi.base.font).descent('M');
272 // Pixel height divisible by 2 for prettier fill graphics:
273 int const oddheight = (asc ^ desc) & 1;
274 int const x0 = x + 1;
275 int const x1 = x + dim.wid - 2;
276 int const y0 = y + desc - 1;
277 int const y1 = y - asc + oddheight - 1;
278 int const y2 = (y0 + y1) / 2;
279 int xoffset = (y0 - y1) / 2;
281 // Two tests for very narrow insets
282 if (xoffset > x1 - x0
283 && (params_.kind == InsetSpaceParams::LEFTARROWFILL
284 || params_.kind == InsetSpaceParams::RIGHTARROWFILL))
286 if (xoffset * 6 > (x1 - x0)
287 && (params_.kind == InsetSpaceParams::UPBRACEFILL
288 || params_.kind == InsetSpaceParams::DOWNBRACEFILL))
289 xoffset = (x1 - x0) / 6;
291 int const x2 = x0 + xoffset;
292 int const x3 = x1 - xoffset;
293 int const xm = (x0 + x1) / 2;
294 int const xml = xm - xoffset;
295 int const xmr = xm + xoffset;
297 if (params_.kind == InsetSpaceParams::HFILL) {
298 pi.pain.line(x0, y1, x0, y0, Color_added_space);
299 pi.pain.line(x0, y2, x1, y2, Color_added_space,
300 frontend::Painter::line_onoffdash);
301 pi.pain.line(x1, y1, x1, y0, Color_added_space);
302 } else if (params_.kind == InsetSpaceParams::HFILL_PROTECTED) {
303 pi.pain.line(x0, y1, x0, y0, Color_latex);
304 pi.pain.line(x0, y2, x1, y2, Color_latex,
305 frontend::Painter::line_onoffdash);
306 pi.pain.line(x1, y1, x1, y0, Color_latex);
307 } else if (params_.kind == InsetSpaceParams::DOTFILL) {
308 pi.pain.line(x0, y1, x0, y0, Color_special);
309 pi.pain.line(x0, y0, x1, y0, Color_special,
310 frontend::Painter::line_onoffdash);
311 pi.pain.line(x1, y1, x1, y0, Color_special);
312 } else if (params_.kind == InsetSpaceParams::HRULEFILL) {
313 pi.pain.line(x0, y1, x0, y0, Color_special);
314 pi.pain.line(x0, y0, x1, y0, Color_special);
315 pi.pain.line(x1, y1, x1, y0, Color_special);
316 } else if (params_.kind == InsetSpaceParams::LEFTARROWFILL) {
317 pi.pain.line(x2, y1 + 1 , x0 + 1, y2, Color_special);
318 pi.pain.line(x0 + 1, y2 + 1 , x2, y0, Color_special);
319 pi.pain.line(x0, y2 , x1, y2, Color_special);
320 } else if (params_.kind == InsetSpaceParams::RIGHTARROWFILL) {
321 pi.pain.line(x3 + 1, y1 + 1 , x1, y2, Color_special);
322 pi.pain.line(x1, y2 + 1 , x3 + 1, y0, Color_special);
323 pi.pain.line(x0, y2 , x1, y2, Color_special);
324 } else if (params_.kind == InsetSpaceParams::UPBRACEFILL) {
325 pi.pain.line(x0 + 1, y1 + 1 , x2, y2, Color_special);
326 pi.pain.line(x2, y2 , xml, y2, Color_special);
327 pi.pain.line(xml + 1, y2 + 1 , xm, y0, Color_special);
328 pi.pain.line(xm + 1, y0 , xmr, y2 + 1, Color_special);
329 pi.pain.line(xmr, y2 , x3, y2, Color_special);
330 pi.pain.line(x3 + 1, y2 , x1, y1 + 1, Color_special);
331 } else if (params_.kind == InsetSpaceParams::DOWNBRACEFILL) {
332 pi.pain.line(x0 + 1, y0 , x2, y2 + 1, Color_special);
333 pi.pain.line(x2, y2 , xml, y2, Color_special);
334 pi.pain.line(xml + 1, y2 , xm, y1 + 1, Color_special);
335 pi.pain.line(xm + 1, y1 + 1 , xmr, y2, Color_special);
336 pi.pain.line(xmr, y2 , x3, y2, Color_special);
337 pi.pain.line(x3 + 1, y2 + 1 , x1, y0, Color_special);
338 } else if (params_.kind == InsetSpaceParams::CUSTOM) {
339 pi.pain.line(x0, y1 + 1 , x2 + 1, y2, Color_special);
340 pi.pain.line(x2 + 1, y2 + 1 , x0, y0, Color_special);
341 pi.pain.line(x1 + 1, y1 + 1 , x3, y2, Color_special);
342 pi.pain.line(x3, y2 + 1 , x1 + 1, y0, Color_special);
343 pi.pain.line(x2, y2 , x3, y2, Color_special);
344 } else if (params_.kind == InsetSpaceParams::CUSTOM_PROTECTED) {
345 pi.pain.line(x0, y1 + 1 , x2 + 1, y2, Color_latex);
346 pi.pain.line(x2 + 1, y2 + 1 , x0, y0, Color_latex);
347 pi.pain.line(x1 + 1, y1 + 1 , x3, y2, Color_latex);
348 pi.pain.line(x3, y2 + 1 , x1 + 1, y0, Color_latex);
349 pi.pain.line(x2, y2 , x3, y2, Color_latex);
354 int const w = dim.wid;
355 int const h = theFontMetrics(pi.base.font).xHeight();
359 yp[0] = y - max(h / 4, 1);
360 if (params_.kind == InsetSpaceParams::NORMAL ||
361 params_.kind == InsetSpaceParams::PROTECTED ||
362 params_.kind == InsetSpaceParams::VISIBLE) {
363 xp[1] = x + 1; yp[1] = y;
364 xp[2] = x + w - 2; yp[2] = y;
366 xp[1] = x + 1; yp[1] = y + max(h / 4, 1);
367 xp[2] = x + w - 2; yp[2] = y + max(h / 4, 1);
370 yp[3] = y - max(h / 4, 1);
372 Color col = Color_special;
373 if (params_.kind == InsetSpaceParams::PROTECTED ||
374 params_.kind == InsetSpaceParams::ENSPACE ||
375 params_.kind == InsetSpaceParams::NEGTHIN ||
376 params_.kind == InsetSpaceParams::NEGMEDIUM ||
377 params_.kind == InsetSpaceParams::NEGTHICK ||
378 params_.kind == InsetSpaceParams::CUSTOM_PROTECTED)
380 else if (params_.kind == InsetSpaceParams::VISIBLE)
381 col = Color_foreground;
383 pi.pain.lines(xp, yp, 4, col);
387 void InsetSpaceParams::write(ostream & os) const
390 case InsetSpaceParams::NORMAL:
393 case InsetSpaceParams::PROTECTED:
396 case InsetSpaceParams::VISIBLE:
397 os << "\\textvisiblespace{}";
399 case InsetSpaceParams::THIN:
400 os << "\\thinspace{}";
402 case InsetSpaceParams::MEDIUM:
403 os << "\\medspace{}";
405 case InsetSpaceParams::THICK:
406 os << "\\thickspace{}";
408 case InsetSpaceParams::QUAD:
411 case InsetSpaceParams::QQUAD:
414 case InsetSpaceParams::ENSPACE:
417 case InsetSpaceParams::ENSKIP:
420 case InsetSpaceParams::NEGTHIN:
421 os << "\\negthinspace{}";
423 case InsetSpaceParams::NEGMEDIUM:
424 os << "\\negmedspace{}";
426 case InsetSpaceParams::NEGTHICK:
427 os << "\\negthickspace{}";
429 case InsetSpaceParams::HFILL:
432 case InsetSpaceParams::HFILL_PROTECTED:
433 os << "\\hspace*{\\fill}";
435 case InsetSpaceParams::DOTFILL:
438 case InsetSpaceParams::HRULEFILL:
439 os << "\\hrulefill{}";
441 case InsetSpaceParams::LEFTARROWFILL:
442 os << "\\leftarrowfill{}";
444 case InsetSpaceParams::RIGHTARROWFILL:
445 os << "\\rightarrowfill{}";
447 case InsetSpaceParams::UPBRACEFILL:
448 os << "\\upbracefill{}";
450 case InsetSpaceParams::DOWNBRACEFILL:
451 os << "\\downbracefill{}";
453 case InsetSpaceParams::CUSTOM:
456 case InsetSpaceParams::CUSTOM_PROTECTED:
461 if (!length.len().empty())
462 os << "\n\\length " << length.asString();
466 void InsetSpaceParams::read(Lexer & lex)
468 lex.setContext("InsetSpaceParams::read");
472 // The tests for math might be disabled after a file format change
473 if (command == "\\space{}")
474 kind = InsetSpaceParams::NORMAL;
475 else if (command == "~")
476 kind = InsetSpaceParams::PROTECTED;
477 else if (command == "\\textvisiblespace{}")
478 kind = InsetSpaceParams::VISIBLE;
479 else if (command == "\\thinspace{}")
480 kind = InsetSpaceParams::THIN;
481 else if (math && command == "\\medspace{}")
482 kind = InsetSpaceParams::MEDIUM;
483 else if (math && command == "\\thickspace{}")
484 kind = InsetSpaceParams::THICK;
485 else if (command == "\\quad{}")
486 kind = InsetSpaceParams::QUAD;
487 else if (command == "\\qquad{}")
488 kind = InsetSpaceParams::QQUAD;
489 else if (command == "\\enspace{}")
490 kind = InsetSpaceParams::ENSPACE;
491 else if (command == "\\enskip{}")
492 kind = InsetSpaceParams::ENSKIP;
493 else if (command == "\\negthinspace{}")
494 kind = InsetSpaceParams::NEGTHIN;
495 else if (command == "\\negmedspace{}")
496 kind = InsetSpaceParams::NEGMEDIUM;
497 else if (command == "\\negthickspace{}")
498 kind = InsetSpaceParams::NEGTHICK;
499 else if (command == "\\hfill{}")
500 kind = InsetSpaceParams::HFILL;
501 else if (command == "\\hspace*{\\fill}")
502 kind = InsetSpaceParams::HFILL_PROTECTED;
503 else if (command == "\\dotfill{}")
504 kind = InsetSpaceParams::DOTFILL;
505 else if (command == "\\hrulefill{}")
506 kind = InsetSpaceParams::HRULEFILL;
507 else if (command == "\\hspace{}")
508 kind = InsetSpaceParams::CUSTOM;
509 else if (command == "\\leftarrowfill{}")
510 kind = InsetSpaceParams::LEFTARROWFILL;
511 else if (command == "\\rightarrowfill{}")
512 kind = InsetSpaceParams::RIGHTARROWFILL;
513 else if (command == "\\upbracefill{}")
514 kind = InsetSpaceParams::UPBRACEFILL;
515 else if (command == "\\downbracefill{}")
516 kind = InsetSpaceParams::DOWNBRACEFILL;
517 else if (command == "\\hspace*{}")
518 kind = InsetSpaceParams::CUSTOM_PROTECTED;
520 lex.printError("InsetSpace: Unknown kind: `$$Token'");
522 if (lex.checkFor("\\length"))
527 void InsetSpace::write(ostream & os) const
534 void InsetSpace::read(Lexer & lex)
537 lex >> "\\end_inset";
541 void InsetSpace::latex(otexstream & os, OutputParams const & runparams) const
543 switch (params_.kind) {
544 case InsetSpaceParams::NORMAL:
545 os << (runparams.free_spacing ? " " : "\\ ");
547 case InsetSpaceParams::PROTECTED:
548 if (runparams.local_font &&
549 runparams.local_font->language()->lang() == "polutonikogreek")
550 // in babel's polutonikogreek, ~ is active
551 os << (runparams.free_spacing ? " " : "\\nobreakspace{}");
553 os << (runparams.free_spacing ? ' ' : '~');
555 case InsetSpaceParams::VISIBLE:
556 os << (runparams.free_spacing ? " " : "\\textvisiblespace{}");
558 case InsetSpaceParams::THIN:
559 os << (runparams.free_spacing ? " " : "\\,");
561 case InsetSpaceParams::MEDIUM:
562 os << (runparams.free_spacing ? " " : "\\:");
564 case InsetSpaceParams::THICK:
565 os << (runparams.free_spacing ? " " : "\\;");
567 case InsetSpaceParams::QUAD:
568 os << (runparams.free_spacing ? " " : "\\quad{}");
570 case InsetSpaceParams::QQUAD:
571 os << (runparams.free_spacing ? " " : "\\qquad{}");
573 case InsetSpaceParams::ENSPACE:
574 os << (runparams.free_spacing ? " " : "\\enspace{}");
576 case InsetSpaceParams::ENSKIP:
577 os << (runparams.free_spacing ? " " : "\\enskip{}");
579 case InsetSpaceParams::NEGTHIN:
580 os << (runparams.free_spacing ? " " : "\\negthinspace{}");
582 case InsetSpaceParams::NEGMEDIUM:
583 os << (runparams.free_spacing ? " " : "\\negmedspace{}");
585 case InsetSpaceParams::NEGTHICK:
586 os << (runparams.free_spacing ? " " : "\\negthickspace{}");
588 case InsetSpaceParams::HFILL:
589 os << (runparams.free_spacing ? " " : "\\hfill{}");
591 case InsetSpaceParams::HFILL_PROTECTED:
592 os << (runparams.free_spacing ? " " : "\\hspace*{\\fill}");
594 case InsetSpaceParams::DOTFILL:
595 os << (runparams.free_spacing ? " " : "\\dotfill{}");
597 case InsetSpaceParams::HRULEFILL:
598 os << (runparams.free_spacing ? " " : "\\hrulefill{}");
600 case InsetSpaceParams::LEFTARROWFILL:
601 os << (runparams.free_spacing ? " " : "\\leftarrowfill{}");
603 case InsetSpaceParams::RIGHTARROWFILL:
604 os << (runparams.free_spacing ? " " : "\\rightarrowfill{}");
606 case InsetSpaceParams::UPBRACEFILL:
607 os << (runparams.free_spacing ? " " : "\\upbracefill{}");
609 case InsetSpaceParams::DOWNBRACEFILL:
610 os << (runparams.free_spacing ? " " : "\\downbracefill{}");
612 case InsetSpaceParams::CUSTOM:
613 if (runparams.free_spacing)
616 os << "\\hspace{" << from_ascii(params_.length.asLatexString()) << "}";
618 case InsetSpaceParams::CUSTOM_PROTECTED:
619 if (runparams.free_spacing)
622 os << "\\hspace*{" << from_ascii(params_.length.asLatexString()) << "}";
628 int InsetSpace::plaintext(odocstringstream & os,
629 OutputParams const &, size_t) const
631 switch (params_.kind) {
632 case InsetSpaceParams::HFILL:
633 case InsetSpaceParams::HFILL_PROTECTED:
636 case InsetSpaceParams::DOTFILL:
639 case InsetSpaceParams::HRULEFILL:
642 case InsetSpaceParams::LEFTARROWFILL:
645 case InsetSpaceParams::RIGHTARROWFILL:
648 case InsetSpaceParams::UPBRACEFILL:
651 case InsetSpaceParams::DOWNBRACEFILL:
654 case InsetSpaceParams::VISIBLE:
657 case InsetSpaceParams::ENSKIP:
660 case InsetSpaceParams::ENSPACE:
661 os.put(0x2060); // WORD JOINER, makes the breakable en space unbreakable
663 os.put(0x2060); // WORD JOINER, makes the breakable en space unbreakable
665 case InsetSpaceParams::QUAD:
668 case InsetSpaceParams::QQUAD:
672 case InsetSpaceParams::THIN:
675 case InsetSpaceParams::MEDIUM:
676 os.put(0x200b); // ZERO WIDTH SPACE, makes the unbreakable medium space breakable
678 os.put(0x200b); // ZERO WIDTH SPACE, makes the unbreakable medium space breakable
680 case InsetSpaceParams::THICK:
681 os.put(0x200b); // ZERO WIDTH SPACE, makes the unbreakable thick space breakable
683 os.put(0x200b); // ZERO WIDTH SPACE, makes the unbreakable thick space breakable
685 case InsetSpaceParams::PROTECTED:
686 case InsetSpaceParams::CUSTOM_PROTECTED:
689 case InsetSpaceParams::NEGTHIN:
690 case InsetSpaceParams::NEGMEDIUM:
691 case InsetSpaceParams::NEGTHICK:
700 int InsetSpace::docbook(odocstream & os, OutputParams const &) const
702 switch (params_.kind) {
703 case InsetSpaceParams::NORMAL:
706 case InsetSpaceParams::QUAD:
709 case InsetSpaceParams::QQUAD:
710 os << "  ";
712 case InsetSpaceParams::ENSKIP:
715 case InsetSpaceParams::PROTECTED:
718 case InsetSpaceParams::VISIBLE:
721 case InsetSpaceParams::ENSPACE:
722 os << "⁠ ⁠";
724 case InsetSpaceParams::THIN:
727 case InsetSpaceParams::MEDIUM:
730 case InsetSpaceParams::THICK:
733 case InsetSpaceParams::NEGTHIN:
734 case InsetSpaceParams::NEGMEDIUM:
735 case InsetSpaceParams::NEGTHICK:
739 case InsetSpaceParams::HFILL:
740 case InsetSpaceParams::HFILL_PROTECTED:
743 case InsetSpaceParams::DOTFILL:
747 case InsetSpaceParams::HRULEFILL:
751 case InsetSpaceParams::LEFTARROWFILL:
752 case InsetSpaceParams::RIGHTARROWFILL:
753 case InsetSpaceParams::UPBRACEFILL:
754 case InsetSpaceParams::DOWNBRACEFILL:
755 case InsetSpaceParams::CUSTOM:
756 case InsetSpaceParams::CUSTOM_PROTECTED:
765 docstring InsetSpace::xhtml(XHTMLStream & xs, OutputParams const &) const
768 switch (params_.kind) {
769 case InsetSpaceParams::NORMAL:
772 case InsetSpaceParams::ENSKIP:
775 case InsetSpaceParams::ENSPACE:
776 output ="⁠ ⁠";
778 case InsetSpaceParams::QQUAD:
779 output ="  ";
781 case InsetSpaceParams::THICK:
784 case InsetSpaceParams::QUAD:
787 case InsetSpaceParams::MEDIUM:
790 case InsetSpaceParams::THIN:
793 case InsetSpaceParams::PROTECTED:
794 case InsetSpaceParams::NEGTHIN:
795 case InsetSpaceParams::NEGMEDIUM:
796 case InsetSpaceParams::NEGTHICK:
799 // no XHTML entity, only unicode code for space character exists
800 case InsetSpaceParams::VISIBLE:
803 case InsetSpaceParams::HFILL:
804 case InsetSpaceParams::HFILL_PROTECTED:
805 case InsetSpaceParams::DOTFILL:
806 case InsetSpaceParams::HRULEFILL:
807 case InsetSpaceParams::LEFTARROWFILL:
808 case InsetSpaceParams::RIGHTARROWFILL:
809 case InsetSpaceParams::UPBRACEFILL:
810 case InsetSpaceParams::DOWNBRACEFILL:
812 // Can we do anything with those in HTML?
814 case InsetSpaceParams::CUSTOM:
816 // Probably we could do some sort of blank span?
818 case InsetSpaceParams::CUSTOM_PROTECTED:
820 // Probably we could do some sort of blank span?
824 // don't escape the entities!
825 xs << XHTMLStream::ESCAPE_NONE << from_ascii(output);
830 void InsetSpace::validate(LaTeXFeatures & features) const
832 if (params_.kind == InsetSpaceParams::NEGMEDIUM ||
833 params_.kind == InsetSpaceParams::NEGTHICK)
834 features.require("amsmath");
838 void InsetSpace::toString(odocstream & os) const
840 odocstringstream ods;
841 plaintext(ods, OutputParams(0));
846 void InsetSpace::forOutliner(docstring & os, size_t const, bool const) const
848 // There's no need to be cute here.
853 bool InsetSpace::isHfill() const
855 return params_.kind == InsetSpaceParams::HFILL
856 || params_.kind == InsetSpaceParams::HFILL_PROTECTED
857 || params_.kind == InsetSpaceParams::DOTFILL
858 || params_.kind == InsetSpaceParams::HRULEFILL
859 || params_.kind == InsetSpaceParams::LEFTARROWFILL
860 || params_.kind == InsetSpaceParams::RIGHTARROWFILL
861 || params_.kind == InsetSpaceParams::UPBRACEFILL
862 || params_.kind == InsetSpaceParams::DOWNBRACEFILL;
866 string InsetSpace::contextMenuName() const
868 return "context-space";
872 void InsetSpace::string2params(string const & in, InsetSpaceParams & params)
874 params = InsetSpaceParams();
878 istringstream data(in);
881 lex.setContext("InsetSpace::string2params");
883 string const name = lex.getString();
884 if (name == "mathspace")
888 // we can try to read this even if the name is wrong
889 LATTEST(name == "space");
892 // There are cases, such as when we are called via getStatus() from
893 // Dialog::canApply(), where we are just called with "space" rather
894 // than a full "space \type{}\n\\end_inset".
900 string InsetSpace::params2string(InsetSpaceParams const & params)
905 data << "space" << ' ';