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"
31 #include "support/debug.h"
32 #include "support/docstream.h"
33 #include "support/gettext.h"
34 #include "support/lassert.h"
35 #include "support/lstrings.h"
37 #include "frontends/Application.h"
38 #include "frontends/FontMetrics.h"
39 #include "frontends/Painter.h"
46 InsetSpace::InsetSpace(InsetSpaceParams const & params)
47 : Inset(0), params_(params)
51 InsetSpaceParams::Kind InsetSpace::kind() const
57 GlueLength InsetSpace::length() const
59 return params_.length;
63 docstring InsetSpace::toolTip(BufferView const &, int, int) const
66 switch (params_.kind) {
67 case InsetSpaceParams::NORMAL:
68 message = _("Interword Space");
70 case InsetSpaceParams::PROTECTED:
71 message = _("Protected Space");
73 case InsetSpaceParams::VISIBLE:
74 message = _("Visible Space");
76 case InsetSpaceParams::THIN:
77 message = _("Thin Space");
79 case InsetSpaceParams::MEDIUM:
80 message = _("Medium Space");
82 case InsetSpaceParams::THICK:
83 message = _("Thick Space");
85 case InsetSpaceParams::QUAD:
86 message = _("Quad Space");
88 case InsetSpaceParams::QQUAD:
89 message = _("Double Quad Space");
91 case InsetSpaceParams::ENSPACE:
92 message = _("Enspace");
94 case InsetSpaceParams::ENSKIP:
95 message = _("Enskip");
97 case InsetSpaceParams::NEGTHIN:
98 message = _("Negative Thin Space");
100 case InsetSpaceParams::NEGMEDIUM:
101 message = _("Negative Medium Space");
103 case InsetSpaceParams::NEGTHICK:
104 message = _("Negative Thick Space");
106 case InsetSpaceParams::HFILL:
107 message = _("Horizontal Fill");
109 case InsetSpaceParams::HFILL_PROTECTED:
110 message = _("Protected Horizontal Fill");
112 case InsetSpaceParams::DOTFILL:
113 message = _("Horizontal Fill (Dots)");
115 case InsetSpaceParams::HRULEFILL:
116 message = _("Horizontal Fill (Rule)");
118 case InsetSpaceParams::LEFTARROWFILL:
119 message = _("Horizontal Fill (Left Arrow)");
121 case InsetSpaceParams::RIGHTARROWFILL:
122 message = _("Horizontal Fill (Right Arrow)");
124 case InsetSpaceParams::UPBRACEFILL:
125 message = _("Horizontal Fill (Up Brace)");
127 case InsetSpaceParams::DOWNBRACEFILL:
128 message = _("Horizontal Fill (Down Brace)");
130 case InsetSpaceParams::CUSTOM:
132 message = support::bformat(_("Horizontal Space (%1$s)"),
133 from_ascii(params_.length.asString()));
135 case InsetSpaceParams::CUSTOM_PROTECTED:
137 message = support::bformat(_("Protected Horizontal Space (%1$s)"),
138 from_ascii(params_.length.asString()));
145 void InsetSpace::doDispatch(Cursor & cur, FuncRequest & cmd)
147 switch (cmd.action()) {
149 case LFUN_INSET_MODIFY: {
151 string arg = to_utf8(cmd.argument());
152 if (arg == "space \\hspace{}")
153 arg += params_.length.len().empty()
154 ? " \\length 1" + string(stringFromUnit(Length::defaultUnit()))
155 : " \\length " + params_.length.asString();
156 string2params(arg, params_);
160 case LFUN_INSET_DIALOG_UPDATE:
161 cur.bv().updateDialog("space", params2string(params()));
165 Inset::doDispatch(cur, cmd);
171 bool InsetSpace::getStatus(Cursor & cur, FuncRequest const & cmd,
172 FuncStatus & status) const
174 switch (cmd.action()) {
176 case LFUN_INSET_MODIFY:
177 if (cmd.getArg(0) == "space") {
178 InsetSpaceParams params;
179 string2params(to_utf8(cmd.argument()), params);
180 status.setOnOff(params_.kind == params.kind);
181 status.setEnabled(true);
183 status.setEnabled(false);
186 case LFUN_INSET_DIALOG_UPDATE:
187 status.setEnabled(true);
190 return Inset::getStatus(cur, cmd, status);
196 int const arrow_size = 8;
200 void InsetSpace::metrics(MetricsInfo & mi, Dimension & dim) const
203 // The metrics for this kinds are calculated externally in
204 // \c TextMetrics::computeRowMetrics. Those are dummy value:
205 dim = Dimension(10, 10, 10);
209 frontend::FontMetrics const & fm = theFontMetrics(mi.base.font);
210 dim.asc = fm.maxAscent();
211 dim.des = fm.maxDescent();
212 int const em = fm.em();
214 switch (params_.kind) {
215 case InsetSpaceParams::THIN:
216 case InsetSpaceParams::NEGTHIN:
219 case InsetSpaceParams::MEDIUM:
220 case InsetSpaceParams::NEGMEDIUM:
223 case InsetSpaceParams::THICK:
224 case InsetSpaceParams::NEGTHICK:
227 case InsetSpaceParams::PROTECTED:
228 case InsetSpaceParams::VISIBLE:
229 case InsetSpaceParams::NORMAL:
230 dim.wid = fm.width(char_type(' '));
232 case InsetSpaceParams::QUAD:
235 case InsetSpaceParams::QQUAD:
238 case InsetSpaceParams::ENSPACE:
239 case InsetSpaceParams::ENSKIP:
240 dim.wid = int(0.5 * em);
242 case InsetSpaceParams::CUSTOM:
243 case InsetSpaceParams::CUSTOM_PROTECTED: {
245 params_.length.len().inPixels(mi.base);
246 int const minw = (w < 0) ? 3 * arrow_size : 4;
247 dim.wid = max(minw, abs(w));
250 case InsetSpaceParams::HFILL:
251 case InsetSpaceParams::HFILL_PROTECTED:
252 case InsetSpaceParams::DOTFILL:
253 case InsetSpaceParams::HRULEFILL:
254 case InsetSpaceParams::LEFTARROWFILL:
255 case InsetSpaceParams::RIGHTARROWFILL:
256 case InsetSpaceParams::UPBRACEFILL:
257 case InsetSpaceParams::DOWNBRACEFILL:
261 // Cache the inset dimension.
262 setDimCache(mi, dim);
266 void InsetSpace::draw(PainterInfo & pi, int x, int y) const
268 Dimension const dim = dimension(*pi.base.bv);
270 if (isHfill() || params_.length.len().value() < 0) {
271 int const asc = theFontMetrics(pi.base.font).ascent('M');
272 int const desc = theFontMetrics(pi.base.font).descent('M');
273 // Pixel height divisible by 2 for prettier fill graphics:
274 int const oddheight = (asc ^ desc) & 1;
275 int const x0 = x + 1;
276 int const x1 = x + dim.wid - 2;
277 int const y0 = y + desc - 1;
278 int const y1 = y - asc + oddheight - 1;
279 int const y2 = (y0 + y1) / 2;
280 int xoffset = (y0 - y1) / 2;
282 // Two tests for very narrow insets
283 if (xoffset > x1 - x0
284 && (params_.kind == InsetSpaceParams::LEFTARROWFILL
285 || params_.kind == InsetSpaceParams::RIGHTARROWFILL))
287 if (xoffset * 6 > (x1 - x0)
288 && (params_.kind == InsetSpaceParams::UPBRACEFILL
289 || params_.kind == InsetSpaceParams::DOWNBRACEFILL))
290 xoffset = (x1 - x0) / 6;
292 int const x2 = x0 + xoffset;
293 int const x3 = x1 - xoffset;
294 int const xm = (x0 + x1) / 2;
295 int const xml = xm - xoffset;
296 int const xmr = xm + xoffset;
298 if (params_.kind == InsetSpaceParams::HFILL) {
299 pi.pain.line(x0, y1, x0, y0, Color_added_space);
300 pi.pain.line(x0, y2, x1, y2, Color_added_space,
301 frontend::Painter::line_onoffdash);
302 pi.pain.line(x1, y1, x1, y0, Color_added_space);
303 } else if (params_.kind == InsetSpaceParams::HFILL_PROTECTED) {
304 pi.pain.line(x0, y1, x0, y0, Color_latex);
305 pi.pain.line(x0, y2, x1, y2, Color_latex,
306 frontend::Painter::line_onoffdash);
307 pi.pain.line(x1, y1, x1, y0, Color_latex);
308 } else if (params_.kind == InsetSpaceParams::DOTFILL) {
309 pi.pain.line(x0, y1, x0, y0, Color_special);
310 pi.pain.line(x0, y0, x1, y0, Color_special,
311 frontend::Painter::line_onoffdash);
312 pi.pain.line(x1, y1, x1, y0, Color_special);
313 } else if (params_.kind == InsetSpaceParams::HRULEFILL) {
314 pi.pain.line(x0, y1, x0, y0, Color_special);
315 pi.pain.line(x0, y0, x1, y0, Color_special);
316 pi.pain.line(x1, y1, x1, y0, Color_special);
317 } else if (params_.kind == InsetSpaceParams::LEFTARROWFILL) {
318 pi.pain.line(x2, y1 + 1 , x0 + 1, y2, Color_special);
319 pi.pain.line(x0 + 1, y2 + 1 , x2, y0, Color_special);
320 pi.pain.line(x0, y2 , x1, y2, Color_special);
321 } else if (params_.kind == InsetSpaceParams::RIGHTARROWFILL) {
322 pi.pain.line(x3 + 1, y1 + 1 , x1, y2, Color_special);
323 pi.pain.line(x1, y2 + 1 , x3 + 1, y0, Color_special);
324 pi.pain.line(x0, y2 , x1, y2, Color_special);
325 } else if (params_.kind == InsetSpaceParams::UPBRACEFILL) {
326 pi.pain.line(x0 + 1, y1 + 1 , x2, y2, Color_special);
327 pi.pain.line(x2, y2 , xml, y2, Color_special);
328 pi.pain.line(xml + 1, y2 + 1 , xm, y0, Color_special);
329 pi.pain.line(xm + 1, y0 , xmr, y2 + 1, Color_special);
330 pi.pain.line(xmr, y2 , x3, y2, Color_special);
331 pi.pain.line(x3 + 1, y2 , x1, y1 + 1, Color_special);
332 } else if (params_.kind == InsetSpaceParams::DOWNBRACEFILL) {
333 pi.pain.line(x0 + 1, y0 , x2, y2 + 1, Color_special);
334 pi.pain.line(x2, y2 , xml, y2, Color_special);
335 pi.pain.line(xml + 1, y2 , xm, y1 + 1, Color_special);
336 pi.pain.line(xm + 1, y1 + 1 , xmr, y2, Color_special);
337 pi.pain.line(xmr, y2 , x3, y2, Color_special);
338 pi.pain.line(x3 + 1, y2 + 1 , x1, y0, Color_special);
339 } else if (params_.kind == InsetSpaceParams::CUSTOM) {
340 pi.pain.line(x0, y1 + 1 , x2 + 1, y2, Color_special);
341 pi.pain.line(x2 + 1, y2 + 1 , x0, y0, Color_special);
342 pi.pain.line(x1 + 1, y1 + 1 , x3, y2, Color_special);
343 pi.pain.line(x3, y2 + 1 , x1 + 1, y0, Color_special);
344 pi.pain.line(x2, y2 , x3, y2, Color_special);
345 } else if (params_.kind == InsetSpaceParams::CUSTOM_PROTECTED) {
346 pi.pain.line(x0, y1 + 1 , x2 + 1, y2, Color_latex);
347 pi.pain.line(x2 + 1, y2 + 1 , x0, y0, Color_latex);
348 pi.pain.line(x1 + 1, y1 + 1 , x3, y2, Color_latex);
349 pi.pain.line(x3, y2 + 1 , x1 + 1, y0, Color_latex);
350 pi.pain.line(x2, y2 , x3, y2, Color_latex);
355 int const w = dim.wid;
356 int const h = theFontMetrics(pi.base.font).ascent('x');
360 yp[0] = y - max(h / 4, 1);
361 if (params_.kind == InsetSpaceParams::NORMAL ||
362 params_.kind == InsetSpaceParams::PROTECTED ||
363 params_.kind == InsetSpaceParams::VISIBLE) {
364 xp[1] = x; yp[1] = y;
365 xp[2] = x + w; yp[2] = y;
367 xp[1] = x; yp[1] = y + max(h / 4, 1);
368 xp[2] = x + w; yp[2] = y + max(h / 4, 1);
371 yp[3] = y - max(h / 4, 1);
373 Color col = Color_special;
374 if (params_.kind == InsetSpaceParams::PROTECTED ||
375 params_.kind == InsetSpaceParams::ENSPACE ||
376 params_.kind == InsetSpaceParams::NEGTHIN ||
377 params_.kind == InsetSpaceParams::NEGMEDIUM ||
378 params_.kind == InsetSpaceParams::NEGTHICK ||
379 params_.kind == InsetSpaceParams::CUSTOM_PROTECTED)
381 else if (params_.kind == InsetSpaceParams::VISIBLE)
382 col = Color_foreground;
384 pi.pain.lines(xp, yp, 4, col);
388 void InsetSpaceParams::write(ostream & os) const
391 case InsetSpaceParams::NORMAL:
394 case InsetSpaceParams::PROTECTED:
397 case InsetSpaceParams::VISIBLE:
398 os << "\\textvisiblespace{}";
400 case InsetSpaceParams::THIN:
401 os << "\\thinspace{}";
403 case InsetSpaceParams::MEDIUM:
404 os << "\\medspace{}";
406 case InsetSpaceParams::THICK:
407 os << "\\thickspace{}";
409 case InsetSpaceParams::QUAD:
412 case InsetSpaceParams::QQUAD:
415 case InsetSpaceParams::ENSPACE:
418 case InsetSpaceParams::ENSKIP:
421 case InsetSpaceParams::NEGTHIN:
422 os << "\\negthinspace{}";
424 case InsetSpaceParams::NEGMEDIUM:
425 os << "\\negmedspace{}";
427 case InsetSpaceParams::NEGTHICK:
428 os << "\\negthickspace{}";
430 case InsetSpaceParams::HFILL:
433 case InsetSpaceParams::HFILL_PROTECTED:
434 os << "\\hspace*{\\fill}";
436 case InsetSpaceParams::DOTFILL:
439 case InsetSpaceParams::HRULEFILL:
440 os << "\\hrulefill{}";
442 case InsetSpaceParams::LEFTARROWFILL:
443 os << "\\leftarrowfill{}";
445 case InsetSpaceParams::RIGHTARROWFILL:
446 os << "\\rightarrowfill{}";
448 case InsetSpaceParams::UPBRACEFILL:
449 os << "\\upbracefill{}";
451 case InsetSpaceParams::DOWNBRACEFILL:
452 os << "\\downbracefill{}";
454 case InsetSpaceParams::CUSTOM:
457 case InsetSpaceParams::CUSTOM_PROTECTED:
462 if (!length.len().empty())
463 os << "\n\\length " << length.asString();
467 void InsetSpaceParams::read(Lexer & lex)
469 lex.setContext("InsetSpaceParams::read");
473 // The tests for math might be disabled after a file format change
474 if (command == "\\space{}")
475 kind = InsetSpaceParams::NORMAL;
476 else if (command == "~")
477 kind = InsetSpaceParams::PROTECTED;
478 else if (command == "\\textvisiblespace{}")
479 kind = InsetSpaceParams::VISIBLE;
480 else if (command == "\\thinspace{}")
481 kind = InsetSpaceParams::THIN;
482 else if (math && command == "\\medspace{}")
483 kind = InsetSpaceParams::MEDIUM;
484 else if (math && command == "\\thickspace{}")
485 kind = InsetSpaceParams::THICK;
486 else if (command == "\\quad{}")
487 kind = InsetSpaceParams::QUAD;
488 else if (command == "\\qquad{}")
489 kind = InsetSpaceParams::QQUAD;
490 else if (command == "\\enspace{}")
491 kind = InsetSpaceParams::ENSPACE;
492 else if (command == "\\enskip{}")
493 kind = InsetSpaceParams::ENSKIP;
494 else if (command == "\\negthinspace{}")
495 kind = InsetSpaceParams::NEGTHIN;
496 else if (command == "\\negmedspace{}")
497 kind = InsetSpaceParams::NEGMEDIUM;
498 else if (command == "\\negthickspace{}")
499 kind = InsetSpaceParams::NEGTHICK;
500 else if (command == "\\hfill{}")
501 kind = InsetSpaceParams::HFILL;
502 else if (command == "\\hspace*{\\fill}")
503 kind = InsetSpaceParams::HFILL_PROTECTED;
504 else if (command == "\\dotfill{}")
505 kind = InsetSpaceParams::DOTFILL;
506 else if (command == "\\hrulefill{}")
507 kind = InsetSpaceParams::HRULEFILL;
508 else if (command == "\\hspace{}")
509 kind = InsetSpaceParams::CUSTOM;
510 else if (command == "\\leftarrowfill{}")
511 kind = InsetSpaceParams::LEFTARROWFILL;
512 else if (command == "\\rightarrowfill{}")
513 kind = InsetSpaceParams::RIGHTARROWFILL;
514 else if (command == "\\upbracefill{}")
515 kind = InsetSpaceParams::UPBRACEFILL;
516 else if (command == "\\downbracefill{}")
517 kind = InsetSpaceParams::DOWNBRACEFILL;
518 else if (command == "\\hspace*{}")
519 kind = InsetSpaceParams::CUSTOM_PROTECTED;
521 lex.printError("InsetSpace: Unknown kind: `$$Token'");
523 if (lex.checkFor("\\length"))
528 void InsetSpace::write(ostream & os) const
535 void InsetSpace::read(Lexer & lex)
538 lex >> "\\end_inset";
542 void InsetSpace::latex(otexstream & os, OutputParams const & runparams) const
544 switch (params_.kind) {
545 case InsetSpaceParams::NORMAL:
546 os << (runparams.free_spacing ? " " : "\\ ");
548 case InsetSpaceParams::PROTECTED:
549 if (runparams.local_font &&
550 runparams.local_font->language()->lang() == "polutonikogreek")
551 // in babel's polutonikogreek, ~ is active
552 os << (runparams.free_spacing ? " " : "\\nobreakspace{}");
554 os << (runparams.free_spacing ? ' ' : '~');
556 case InsetSpaceParams::VISIBLE:
557 os << (runparams.free_spacing ? " " : "\\textvisiblespace{}");
559 case InsetSpaceParams::THIN:
560 os << (runparams.free_spacing ? " " : "\\,");
562 case InsetSpaceParams::MEDIUM:
563 os << (runparams.free_spacing ? " " : "\\:");
565 case InsetSpaceParams::THICK:
566 os << (runparams.free_spacing ? " " : "\\;");
568 case InsetSpaceParams::QUAD:
569 os << (runparams.free_spacing ? " " : "\\quad{}");
571 case InsetSpaceParams::QQUAD:
572 os << (runparams.free_spacing ? " " : "\\qquad{}");
574 case InsetSpaceParams::ENSPACE:
575 os << (runparams.free_spacing ? " " : "\\enspace{}");
577 case InsetSpaceParams::ENSKIP:
578 os << (runparams.free_spacing ? " " : "\\enskip{}");
580 case InsetSpaceParams::NEGTHIN:
581 os << (runparams.free_spacing ? " " : "\\negthinspace{}");
583 case InsetSpaceParams::NEGMEDIUM:
584 os << (runparams.free_spacing ? " " : "\\negmedspace{}");
586 case InsetSpaceParams::NEGTHICK:
587 os << (runparams.free_spacing ? " " : "\\negthickspace{}");
589 case InsetSpaceParams::HFILL:
590 os << (runparams.free_spacing ? " " : "\\hfill{}");
592 case InsetSpaceParams::HFILL_PROTECTED:
593 os << (runparams.free_spacing ? " " : "\\hspace*{\\fill}");
595 case InsetSpaceParams::DOTFILL:
596 os << (runparams.free_spacing ? " " : "\\dotfill{}");
598 case InsetSpaceParams::HRULEFILL:
599 os << (runparams.free_spacing ? " " : "\\hrulefill{}");
601 case InsetSpaceParams::LEFTARROWFILL:
602 os << (runparams.free_spacing ? " " : "\\leftarrowfill{}");
604 case InsetSpaceParams::RIGHTARROWFILL:
605 os << (runparams.free_spacing ? " " : "\\rightarrowfill{}");
607 case InsetSpaceParams::UPBRACEFILL:
608 os << (runparams.free_spacing ? " " : "\\upbracefill{}");
610 case InsetSpaceParams::DOWNBRACEFILL:
611 os << (runparams.free_spacing ? " " : "\\downbracefill{}");
613 case InsetSpaceParams::CUSTOM:
614 if (runparams.free_spacing)
617 os << "\\hspace{" << from_ascii(params_.length.asLatexString()) << "}";
619 case InsetSpaceParams::CUSTOM_PROTECTED:
620 if (runparams.free_spacing)
623 os << "\\hspace*{" << from_ascii(params_.length.asLatexString()) << "}";
629 int InsetSpace::plaintext(odocstringstream & os,
630 OutputParams const &, size_t) const
632 switch (params_.kind) {
633 case InsetSpaceParams::HFILL:
634 case InsetSpaceParams::HFILL_PROTECTED:
637 case InsetSpaceParams::DOTFILL:
640 case InsetSpaceParams::HRULEFILL:
643 case InsetSpaceParams::LEFTARROWFILL:
646 case InsetSpaceParams::RIGHTARROWFILL:
649 case InsetSpaceParams::UPBRACEFILL:
652 case InsetSpaceParams::DOWNBRACEFILL:
655 case InsetSpaceParams::VISIBLE:
658 case InsetSpaceParams::ENSKIP:
661 case InsetSpaceParams::ENSPACE:
662 os.put(0x2060); // WORD JOINER, makes the breakable en space unbreakable
664 os.put(0x2060); // WORD JOINER, makes the breakable en space unbreakable
666 case InsetSpaceParams::QUAD:
669 case InsetSpaceParams::QQUAD:
673 case InsetSpaceParams::THIN:
676 case InsetSpaceParams::MEDIUM:
677 os.put(0x200b); // ZERO WIDTH SPACE, makes the unbreakable medium space breakable
679 os.put(0x200b); // ZERO WIDTH SPACE, makes the unbreakable medium space breakable
681 case InsetSpaceParams::THICK:
682 os.put(0x200b); // ZERO WIDTH SPACE, makes the unbreakable thick space breakable
684 os.put(0x200b); // ZERO WIDTH SPACE, makes the unbreakable thick space breakable
686 case InsetSpaceParams::PROTECTED:
687 case InsetSpaceParams::CUSTOM_PROTECTED:
690 case InsetSpaceParams::NEGTHIN:
691 case InsetSpaceParams::NEGMEDIUM:
692 case InsetSpaceParams::NEGTHICK:
701 int InsetSpace::docbook(odocstream & os, OutputParams const &) const
703 switch (params_.kind) {
704 case InsetSpaceParams::NORMAL:
707 case InsetSpaceParams::QUAD:
710 case InsetSpaceParams::QQUAD:
711 os << "  ";
713 case InsetSpaceParams::ENSKIP:
716 case InsetSpaceParams::PROTECTED:
719 case InsetSpaceParams::VISIBLE:
722 case InsetSpaceParams::ENSPACE:
723 os << "⁠ ⁠";
725 case InsetSpaceParams::THIN:
728 case InsetSpaceParams::MEDIUM:
731 case InsetSpaceParams::THICK:
734 case InsetSpaceParams::NEGTHIN:
735 case InsetSpaceParams::NEGMEDIUM:
736 case InsetSpaceParams::NEGTHICK:
740 case InsetSpaceParams::HFILL:
741 case InsetSpaceParams::HFILL_PROTECTED:
744 case InsetSpaceParams::DOTFILL:
748 case InsetSpaceParams::HRULEFILL:
752 case InsetSpaceParams::LEFTARROWFILL:
753 case InsetSpaceParams::RIGHTARROWFILL:
754 case InsetSpaceParams::UPBRACEFILL:
755 case InsetSpaceParams::DOWNBRACEFILL:
756 case InsetSpaceParams::CUSTOM:
757 case InsetSpaceParams::CUSTOM_PROTECTED:
766 docstring InsetSpace::xhtml(XHTMLStream & xs, OutputParams const &) const
769 switch (params_.kind) {
770 case InsetSpaceParams::NORMAL:
773 case InsetSpaceParams::ENSKIP:
776 case InsetSpaceParams::ENSPACE:
777 output ="⁠ ⁠";
779 case InsetSpaceParams::QQUAD:
780 output ="  ";
782 case InsetSpaceParams::THICK:
785 case InsetSpaceParams::QUAD:
788 case InsetSpaceParams::MEDIUM:
791 case InsetSpaceParams::THIN:
794 case InsetSpaceParams::PROTECTED:
795 case InsetSpaceParams::NEGTHIN:
796 case InsetSpaceParams::NEGMEDIUM:
797 case InsetSpaceParams::NEGTHICK:
800 // no XHTML entity, only unicode code for space character exists
801 case InsetSpaceParams::VISIBLE:
804 case InsetSpaceParams::HFILL:
805 case InsetSpaceParams::HFILL_PROTECTED:
806 case InsetSpaceParams::DOTFILL:
807 case InsetSpaceParams::HRULEFILL:
808 case InsetSpaceParams::LEFTARROWFILL:
809 case InsetSpaceParams::RIGHTARROWFILL:
810 case InsetSpaceParams::UPBRACEFILL:
811 case InsetSpaceParams::DOWNBRACEFILL:
813 // Can we do anything with those in HTML?
815 case InsetSpaceParams::CUSTOM:
817 // Probably we could do some sort of blank span?
819 case InsetSpaceParams::CUSTOM_PROTECTED:
821 // Probably we could do some sort of blank span?
825 // don't escape the entities!
826 xs << XHTMLStream::ESCAPE_NONE << from_ascii(output);
831 void InsetSpace::validate(LaTeXFeatures & features) const
833 if (params_.kind == InsetSpaceParams::NEGMEDIUM ||
834 params_.kind == InsetSpaceParams::NEGTHICK)
835 features.require("amsmath");
839 void InsetSpace::toString(odocstream & os) const
841 odocstringstream ods;
842 plaintext(ods, OutputParams(0));
847 void InsetSpace::forOutliner(docstring & os, size_t const, bool const) const
849 // There's no need to be cute here.
854 bool InsetSpace::isHfill() const
856 return params_.kind == InsetSpaceParams::HFILL
857 || params_.kind == InsetSpaceParams::HFILL_PROTECTED
858 || params_.kind == InsetSpaceParams::DOTFILL
859 || params_.kind == InsetSpaceParams::HRULEFILL
860 || params_.kind == InsetSpaceParams::LEFTARROWFILL
861 || params_.kind == InsetSpaceParams::RIGHTARROWFILL
862 || params_.kind == InsetSpaceParams::UPBRACEFILL
863 || params_.kind == InsetSpaceParams::DOWNBRACEFILL;
867 string InsetSpace::contextMenuName() const
869 return "context-space";
873 void InsetSpace::string2params(string const & in, InsetSpaceParams & params)
875 params = InsetSpaceParams();
879 istringstream data(in);
882 lex.setContext("InsetSpace::string2params");
884 string const name = lex.getString();
885 if (name == "mathspace")
889 // we can try to read this even if the name is wrong
890 LATTEST(name == "space");
893 // There are cases, such as when we are called via getStatus() from
894 // Dialog::canApply(), where we are just called with "space" rather
895 // than a full "space \type{}\n\\end_inset".
901 string InsetSpace::params2string(InsetSpaceParams const & params)
906 data << "space" << ' ';