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 width for hfills is calculated externally in
204 // TextMetrics::computeRowMetrics. The value of 5 is the
205 // minimal value when the hfill is not active.
206 dim = Dimension(5, 10, 10);
210 frontend::FontMetrics const & fm = theFontMetrics(mi.base.font);
211 dim.asc = fm.maxAscent();
212 dim.des = fm.maxDescent();
213 int const em = fm.em();
215 switch (params_.kind) {
216 case InsetSpaceParams::THIN:
217 case InsetSpaceParams::NEGTHIN:
220 case InsetSpaceParams::MEDIUM:
221 case InsetSpaceParams::NEGMEDIUM:
224 case InsetSpaceParams::THICK:
225 case InsetSpaceParams::NEGTHICK:
228 case InsetSpaceParams::PROTECTED:
229 case InsetSpaceParams::VISIBLE:
230 case InsetSpaceParams::NORMAL:
231 dim.wid = fm.width(char_type(' '));
233 case InsetSpaceParams::QUAD:
236 case InsetSpaceParams::QQUAD:
239 case InsetSpaceParams::ENSPACE:
240 case InsetSpaceParams::ENSKIP:
241 dim.wid = int(0.5 * em);
243 case InsetSpaceParams::CUSTOM:
244 case InsetSpaceParams::CUSTOM_PROTECTED: {
246 params_.length.len().inPixels(mi.base);
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:
262 // Cache the inset dimension.
263 setDimCache(mi, dim);
267 void InsetSpace::draw(PainterInfo & pi, int x, int y) const
269 Dimension const dim = dimension(*pi.base.bv);
271 if (isHfill() || params_.length.len().value() < 0) {
272 int const asc = theFontMetrics(pi.base.font).ascent('M');
273 int const desc = theFontMetrics(pi.base.font).descent('M');
274 // Pixel height divisible by 2 for prettier fill graphics:
275 int const oddheight = (asc ^ desc) & 1;
276 int const x0 = x + 1;
277 int const x1 = x + dim.wid - 2;
278 int const y0 = y + desc - 1;
279 int const y1 = y - asc + oddheight - 1;
280 int const y2 = (y0 + y1) / 2;
281 int xoffset = (y0 - y1) / 2;
283 // Two tests for very narrow insets
284 if (xoffset > x1 - x0
285 && (params_.kind == InsetSpaceParams::LEFTARROWFILL
286 || params_.kind == InsetSpaceParams::RIGHTARROWFILL))
288 if (xoffset * 6 > (x1 - x0)
289 && (params_.kind == InsetSpaceParams::UPBRACEFILL
290 || params_.kind == InsetSpaceParams::DOWNBRACEFILL))
291 xoffset = (x1 - x0) / 6;
293 int const x2 = x0 + xoffset;
294 int const x3 = x1 - xoffset;
295 int const xm = (x0 + x1) / 2;
296 int const xml = xm - xoffset;
297 int const xmr = xm + xoffset;
299 if (params_.kind == InsetSpaceParams::HFILL) {
300 pi.pain.line(x0, y1, x0, y0, Color_added_space);
301 pi.pain.line(x0, y2, x1, y2, Color_added_space,
302 frontend::Painter::line_onoffdash);
303 pi.pain.line(x1, y1, x1, y0, Color_added_space);
304 } else if (params_.kind == InsetSpaceParams::HFILL_PROTECTED) {
305 pi.pain.line(x0, y1, x0, y0, Color_latex);
306 pi.pain.line(x0, y2, x1, y2, Color_latex,
307 frontend::Painter::line_onoffdash);
308 pi.pain.line(x1, y1, x1, y0, Color_latex);
309 } else if (params_.kind == InsetSpaceParams::DOTFILL) {
310 pi.pain.line(x0, y1, x0, y0, Color_special);
311 pi.pain.line(x0, y0, x1, y0, Color_special,
312 frontend::Painter::line_onoffdash);
313 pi.pain.line(x1, y1, x1, y0, Color_special);
314 } else if (params_.kind == InsetSpaceParams::HRULEFILL) {
315 pi.pain.line(x0, y1, x0, y0, Color_special);
316 pi.pain.line(x0, y0, x1, y0, Color_special);
317 pi.pain.line(x1, y1, x1, y0, Color_special);
318 } else if (params_.kind == InsetSpaceParams::LEFTARROWFILL) {
319 pi.pain.line(x2, y1 + 1 , x0 + 1, y2, Color_special);
320 pi.pain.line(x0 + 1, y2 + 1 , x2, y0, Color_special);
321 pi.pain.line(x0, y2 , x1, y2, Color_special);
322 } else if (params_.kind == InsetSpaceParams::RIGHTARROWFILL) {
323 pi.pain.line(x3 + 1, y1 + 1 , x1, y2, Color_special);
324 pi.pain.line(x1, y2 + 1 , x3 + 1, y0, Color_special);
325 pi.pain.line(x0, y2 , x1, y2, Color_special);
326 } else if (params_.kind == InsetSpaceParams::UPBRACEFILL) {
327 pi.pain.line(x0 + 1, y1 + 1 , x2, y2, Color_special);
328 pi.pain.line(x2, y2 , xml, y2, Color_special);
329 pi.pain.line(xml + 1, y2 + 1 , xm, y0, Color_special);
330 pi.pain.line(xm + 1, y0 , xmr, y2 + 1, Color_special);
331 pi.pain.line(xmr, y2 , x3, y2, Color_special);
332 pi.pain.line(x3 + 1, y2 , x1, y1 + 1, Color_special);
333 } else if (params_.kind == InsetSpaceParams::DOWNBRACEFILL) {
334 pi.pain.line(x0 + 1, y0 , x2, y2 + 1, Color_special);
335 pi.pain.line(x2, y2 , xml, y2, Color_special);
336 pi.pain.line(xml + 1, y2 , xm, y1 + 1, Color_special);
337 pi.pain.line(xm + 1, y1 + 1 , xmr, y2, Color_special);
338 pi.pain.line(xmr, y2 , x3, y2, Color_special);
339 pi.pain.line(x3 + 1, y2 + 1 , x1, y0, Color_special);
340 } else if (params_.kind == InsetSpaceParams::CUSTOM) {
341 pi.pain.line(x0, y1 + 1 , x2 + 1, y2, Color_special);
342 pi.pain.line(x2 + 1, y2 + 1 , x0, y0, Color_special);
343 pi.pain.line(x1 + 1, y1 + 1 , x3, y2, Color_special);
344 pi.pain.line(x3, y2 + 1 , x1 + 1, y0, Color_special);
345 pi.pain.line(x2, y2 , x3, y2, Color_special);
346 } else if (params_.kind == InsetSpaceParams::CUSTOM_PROTECTED) {
347 pi.pain.line(x0, y1 + 1 , x2 + 1, y2, Color_latex);
348 pi.pain.line(x2 + 1, y2 + 1 , x0, y0, Color_latex);
349 pi.pain.line(x1 + 1, y1 + 1 , x3, y2, Color_latex);
350 pi.pain.line(x3, y2 + 1 , x1 + 1, y0, Color_latex);
351 pi.pain.line(x2, y2 , x3, y2, Color_latex);
356 int const w = dim.wid;
357 int const h = theFontMetrics(pi.base.font).ascent('x');
361 yp[0] = y - max(h / 4, 1);
362 if (params_.kind == InsetSpaceParams::NORMAL ||
363 params_.kind == InsetSpaceParams::PROTECTED ||
364 params_.kind == InsetSpaceParams::VISIBLE) {
365 xp[1] = x; yp[1] = y;
366 xp[2] = x + w; yp[2] = y;
368 xp[1] = x; yp[1] = y + max(h / 4, 1);
369 xp[2] = x + w; yp[2] = y + max(h / 4, 1);
372 yp[3] = y - max(h / 4, 1);
374 Color col = Color_special;
375 if (params_.kind == InsetSpaceParams::PROTECTED ||
376 params_.kind == InsetSpaceParams::ENSPACE ||
377 params_.kind == InsetSpaceParams::NEGTHIN ||
378 params_.kind == InsetSpaceParams::NEGMEDIUM ||
379 params_.kind == InsetSpaceParams::NEGTHICK ||
380 params_.kind == InsetSpaceParams::CUSTOM_PROTECTED)
382 else if (params_.kind == InsetSpaceParams::VISIBLE)
383 col = Color_foreground;
385 pi.pain.lines(xp, yp, 4, col);
389 void InsetSpaceParams::write(ostream & os) const
392 case InsetSpaceParams::NORMAL:
395 case InsetSpaceParams::PROTECTED:
398 case InsetSpaceParams::VISIBLE:
399 os << "\\textvisiblespace{}";
401 case InsetSpaceParams::THIN:
402 os << "\\thinspace{}";
404 case InsetSpaceParams::MEDIUM:
405 os << "\\medspace{}";
407 case InsetSpaceParams::THICK:
408 os << "\\thickspace{}";
410 case InsetSpaceParams::QUAD:
413 case InsetSpaceParams::QQUAD:
416 case InsetSpaceParams::ENSPACE:
419 case InsetSpaceParams::ENSKIP:
422 case InsetSpaceParams::NEGTHIN:
423 os << "\\negthinspace{}";
425 case InsetSpaceParams::NEGMEDIUM:
426 os << "\\negmedspace{}";
428 case InsetSpaceParams::NEGTHICK:
429 os << "\\negthickspace{}";
431 case InsetSpaceParams::HFILL:
434 case InsetSpaceParams::HFILL_PROTECTED:
435 os << "\\hspace*{\\fill}";
437 case InsetSpaceParams::DOTFILL:
440 case InsetSpaceParams::HRULEFILL:
441 os << "\\hrulefill{}";
443 case InsetSpaceParams::LEFTARROWFILL:
444 os << "\\leftarrowfill{}";
446 case InsetSpaceParams::RIGHTARROWFILL:
447 os << "\\rightarrowfill{}";
449 case InsetSpaceParams::UPBRACEFILL:
450 os << "\\upbracefill{}";
452 case InsetSpaceParams::DOWNBRACEFILL:
453 os << "\\downbracefill{}";
455 case InsetSpaceParams::CUSTOM:
458 case InsetSpaceParams::CUSTOM_PROTECTED:
463 if (!length.len().empty())
464 os << "\n\\length " << length.asString();
468 void InsetSpaceParams::read(Lexer & lex)
470 lex.setContext("InsetSpaceParams::read");
474 // The tests for math might be disabled after a file format change
475 if (command == "\\space{}")
476 kind = InsetSpaceParams::NORMAL;
477 else if (command == "~")
478 kind = InsetSpaceParams::PROTECTED;
479 else if (command == "\\textvisiblespace{}")
480 kind = InsetSpaceParams::VISIBLE;
481 else if (command == "\\thinspace{}")
482 kind = InsetSpaceParams::THIN;
483 else if (math && command == "\\medspace{}")
484 kind = InsetSpaceParams::MEDIUM;
485 else if (math && command == "\\thickspace{}")
486 kind = InsetSpaceParams::THICK;
487 else if (command == "\\quad{}")
488 kind = InsetSpaceParams::QUAD;
489 else if (command == "\\qquad{}")
490 kind = InsetSpaceParams::QQUAD;
491 else if (command == "\\enspace{}")
492 kind = InsetSpaceParams::ENSPACE;
493 else if (command == "\\enskip{}")
494 kind = InsetSpaceParams::ENSKIP;
495 else if (command == "\\negthinspace{}")
496 kind = InsetSpaceParams::NEGTHIN;
497 else if (command == "\\negmedspace{}")
498 kind = InsetSpaceParams::NEGMEDIUM;
499 else if (command == "\\negthickspace{}")
500 kind = InsetSpaceParams::NEGTHICK;
501 else if (command == "\\hfill{}")
502 kind = InsetSpaceParams::HFILL;
503 else if (command == "\\hspace*{\\fill}")
504 kind = InsetSpaceParams::HFILL_PROTECTED;
505 else if (command == "\\dotfill{}")
506 kind = InsetSpaceParams::DOTFILL;
507 else if (command == "\\hrulefill{}")
508 kind = InsetSpaceParams::HRULEFILL;
509 else if (command == "\\hspace{}")
510 kind = InsetSpaceParams::CUSTOM;
511 else if (command == "\\leftarrowfill{}")
512 kind = InsetSpaceParams::LEFTARROWFILL;
513 else if (command == "\\rightarrowfill{}")
514 kind = InsetSpaceParams::RIGHTARROWFILL;
515 else if (command == "\\upbracefill{}")
516 kind = InsetSpaceParams::UPBRACEFILL;
517 else if (command == "\\downbracefill{}")
518 kind = InsetSpaceParams::DOWNBRACEFILL;
519 else if (command == "\\hspace*{}")
520 kind = InsetSpaceParams::CUSTOM_PROTECTED;
522 lex.printError("InsetSpace: Unknown kind: `$$Token'");
524 if (lex.checkFor("\\length"))
529 void InsetSpace::write(ostream & os) const
536 void InsetSpace::read(Lexer & lex)
539 lex >> "\\end_inset";
543 void InsetSpace::latex(otexstream & os, OutputParams const & runparams) const
545 switch (params_.kind) {
546 case InsetSpaceParams::NORMAL:
547 os << (runparams.free_spacing ? " " : "\\ ");
549 case InsetSpaceParams::PROTECTED:
550 if (runparams.local_font &&
551 runparams.local_font->language()->lang() == "polutonikogreek")
552 // in babel's polutonikogreek, ~ is active
553 os << (runparams.free_spacing ? " " : "\\nobreakspace{}");
555 os << (runparams.free_spacing ? ' ' : '~');
557 case InsetSpaceParams::VISIBLE:
558 os << (runparams.free_spacing ? " " : "\\textvisiblespace{}");
560 case InsetSpaceParams::THIN:
561 os << (runparams.free_spacing ? " " : "\\,");
563 case InsetSpaceParams::MEDIUM:
564 os << (runparams.free_spacing ? " " : "\\:");
566 case InsetSpaceParams::THICK:
567 os << (runparams.free_spacing ? " " : "\\;");
569 case InsetSpaceParams::QUAD:
570 os << (runparams.free_spacing ? " " : "\\quad{}");
572 case InsetSpaceParams::QQUAD:
573 os << (runparams.free_spacing ? " " : "\\qquad{}");
575 case InsetSpaceParams::ENSPACE:
576 os << (runparams.free_spacing ? " " : "\\enspace{}");
578 case InsetSpaceParams::ENSKIP:
579 os << (runparams.free_spacing ? " " : "\\enskip{}");
581 case InsetSpaceParams::NEGTHIN:
582 os << (runparams.free_spacing ? " " : "\\negthinspace{}");
584 case InsetSpaceParams::NEGMEDIUM:
585 os << (runparams.free_spacing ? " " : "\\negmedspace{}");
587 case InsetSpaceParams::NEGTHICK:
588 os << (runparams.free_spacing ? " " : "\\negthickspace{}");
590 case InsetSpaceParams::HFILL:
591 os << (runparams.free_spacing ? " " : "\\hfill{}");
593 case InsetSpaceParams::HFILL_PROTECTED:
594 os << (runparams.free_spacing ? " " : "\\hspace*{\\fill}");
596 case InsetSpaceParams::DOTFILL:
597 os << (runparams.free_spacing ? " " : "\\dotfill{}");
599 case InsetSpaceParams::HRULEFILL:
600 os << (runparams.free_spacing ? " " : "\\hrulefill{}");
602 case InsetSpaceParams::LEFTARROWFILL:
603 os << (runparams.free_spacing ? " " : "\\leftarrowfill{}");
605 case InsetSpaceParams::RIGHTARROWFILL:
606 os << (runparams.free_spacing ? " " : "\\rightarrowfill{}");
608 case InsetSpaceParams::UPBRACEFILL:
609 os << (runparams.free_spacing ? " " : "\\upbracefill{}");
611 case InsetSpaceParams::DOWNBRACEFILL:
612 os << (runparams.free_spacing ? " " : "\\downbracefill{}");
614 case InsetSpaceParams::CUSTOM:
615 if (runparams.free_spacing)
618 os << "\\hspace{" << from_ascii(params_.length.asLatexString()) << "}";
620 case InsetSpaceParams::CUSTOM_PROTECTED:
621 if (runparams.free_spacing)
624 os << "\\hspace*{" << from_ascii(params_.length.asLatexString()) << "}";
630 int InsetSpace::plaintext(odocstringstream & os,
631 OutputParams const &, size_t) const
633 switch (params_.kind) {
634 case InsetSpaceParams::HFILL:
635 case InsetSpaceParams::HFILL_PROTECTED:
638 case InsetSpaceParams::DOTFILL:
641 case InsetSpaceParams::HRULEFILL:
644 case InsetSpaceParams::LEFTARROWFILL:
647 case InsetSpaceParams::RIGHTARROWFILL:
650 case InsetSpaceParams::UPBRACEFILL:
653 case InsetSpaceParams::DOWNBRACEFILL:
656 case InsetSpaceParams::VISIBLE:
659 case InsetSpaceParams::ENSKIP:
662 case InsetSpaceParams::ENSPACE:
663 os.put(0x2060); // WORD JOINER, makes the breakable en space unbreakable
665 os.put(0x2060); // WORD JOINER, makes the breakable en space unbreakable
667 case InsetSpaceParams::QUAD:
670 case InsetSpaceParams::QQUAD:
674 case InsetSpaceParams::THIN:
677 case InsetSpaceParams::MEDIUM:
678 os.put(0x200b); // ZERO WIDTH SPACE, makes the unbreakable medium space breakable
680 os.put(0x200b); // ZERO WIDTH SPACE, makes the unbreakable medium space breakable
682 case InsetSpaceParams::THICK:
683 os.put(0x200b); // ZERO WIDTH SPACE, makes the unbreakable thick space breakable
685 os.put(0x200b); // ZERO WIDTH SPACE, makes the unbreakable thick space breakable
687 case InsetSpaceParams::PROTECTED:
688 case InsetSpaceParams::CUSTOM_PROTECTED:
691 case InsetSpaceParams::NEGTHIN:
692 case InsetSpaceParams::NEGMEDIUM:
693 case InsetSpaceParams::NEGTHICK:
702 int InsetSpace::docbook(odocstream & os, OutputParams const &) const
704 switch (params_.kind) {
705 case InsetSpaceParams::NORMAL:
708 case InsetSpaceParams::QUAD:
711 case InsetSpaceParams::QQUAD:
712 os << "  ";
714 case InsetSpaceParams::ENSKIP:
717 case InsetSpaceParams::PROTECTED:
720 case InsetSpaceParams::VISIBLE:
723 case InsetSpaceParams::ENSPACE:
724 os << "⁠ ⁠";
726 case InsetSpaceParams::THIN:
729 case InsetSpaceParams::MEDIUM:
732 case InsetSpaceParams::THICK:
735 case InsetSpaceParams::NEGTHIN:
736 case InsetSpaceParams::NEGMEDIUM:
737 case InsetSpaceParams::NEGTHICK:
741 case InsetSpaceParams::HFILL:
742 case InsetSpaceParams::HFILL_PROTECTED:
745 case InsetSpaceParams::DOTFILL:
749 case InsetSpaceParams::HRULEFILL:
753 case InsetSpaceParams::LEFTARROWFILL:
754 case InsetSpaceParams::RIGHTARROWFILL:
755 case InsetSpaceParams::UPBRACEFILL:
756 case InsetSpaceParams::DOWNBRACEFILL:
757 case InsetSpaceParams::CUSTOM:
758 case InsetSpaceParams::CUSTOM_PROTECTED:
767 docstring InsetSpace::xhtml(XHTMLStream & xs, OutputParams const &) const
770 switch (params_.kind) {
771 case InsetSpaceParams::NORMAL:
774 case InsetSpaceParams::ENSKIP:
777 case InsetSpaceParams::ENSPACE:
778 output ="⁠ ⁠";
780 case InsetSpaceParams::QQUAD:
781 output ="  ";
783 case InsetSpaceParams::THICK:
786 case InsetSpaceParams::QUAD:
789 case InsetSpaceParams::MEDIUM:
792 case InsetSpaceParams::THIN:
795 case InsetSpaceParams::PROTECTED:
796 case InsetSpaceParams::NEGTHIN:
797 case InsetSpaceParams::NEGMEDIUM:
798 case InsetSpaceParams::NEGTHICK:
801 // no XHTML entity, only unicode code for space character exists
802 case InsetSpaceParams::VISIBLE:
805 case InsetSpaceParams::HFILL:
806 case InsetSpaceParams::HFILL_PROTECTED:
807 case InsetSpaceParams::DOTFILL:
808 case InsetSpaceParams::HRULEFILL:
809 case InsetSpaceParams::LEFTARROWFILL:
810 case InsetSpaceParams::RIGHTARROWFILL:
811 case InsetSpaceParams::UPBRACEFILL:
812 case InsetSpaceParams::DOWNBRACEFILL:
814 // Can we do anything with those in HTML?
816 case InsetSpaceParams::CUSTOM:
818 // Probably we could do some sort of blank span?
820 case InsetSpaceParams::CUSTOM_PROTECTED:
822 // Probably we could do some sort of blank span?
826 // don't escape the entities!
827 xs << XHTMLStream::ESCAPE_NONE << from_ascii(output);
832 void InsetSpace::validate(LaTeXFeatures & features) const
834 if (params_.kind == InsetSpaceParams::NEGMEDIUM ||
835 params_.kind == InsetSpaceParams::NEGTHICK)
836 features.require("amsmath");
840 void InsetSpace::toString(odocstream & os) const
842 odocstringstream ods;
843 plaintext(ods, OutputParams(0));
848 void InsetSpace::forOutliner(docstring & os, size_t const, bool const) const
850 // There's no need to be cute here.
855 bool InsetSpace::isHfill() const
857 return params_.kind == InsetSpaceParams::HFILL
858 || params_.kind == InsetSpaceParams::HFILL_PROTECTED
859 || params_.kind == InsetSpaceParams::DOTFILL
860 || params_.kind == InsetSpaceParams::HRULEFILL
861 || params_.kind == InsetSpaceParams::LEFTARROWFILL
862 || params_.kind == InsetSpaceParams::RIGHTARROWFILL
863 || params_.kind == InsetSpaceParams::UPBRACEFILL
864 || params_.kind == InsetSpaceParams::DOWNBRACEFILL;
868 string InsetSpace::contextMenuName() const
870 return "context-space";
874 void InsetSpace::string2params(string const & in, InsetSpaceParams & params)
876 params = InsetSpaceParams();
880 istringstream data(in);
883 lex.setContext("InsetSpace::string2params");
885 string const name = lex.getString();
886 if (name == "mathspace")
890 // we can try to read this even if the name is wrong
891 LATTEST(name == "space");
894 // There are cases, such as when we are called via getStatus() from
895 // Dialog::canApply(), where we are just called with "space" rather
896 // than a full "space \type{}\n\\end_inset".
902 string InsetSpace::params2string(InsetSpaceParams const & params)
907 data << "space" << ' ';