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::THIN:
74 message = _("Thin Space");
76 case InsetSpaceParams::MEDIUM:
77 message = _("Medium Space");
79 case InsetSpaceParams::THICK:
80 message = _("Thick Space");
82 case InsetSpaceParams::QUAD:
83 message = _("Quad Space");
85 case InsetSpaceParams::QQUAD:
86 message = _("Double Quad Space");
88 case InsetSpaceParams::ENSPACE:
89 message = _("Enspace");
91 case InsetSpaceParams::ENSKIP:
92 message = _("Enskip");
94 case InsetSpaceParams::NEGTHIN:
95 message = _("Negative Thin Space");
97 case InsetSpaceParams::NEGMEDIUM:
98 message = _("Negative Medium Space");
100 case InsetSpaceParams::NEGTHICK:
101 message = _("Negative Thick Space");
103 case InsetSpaceParams::HFILL:
104 message = _("Horizontal Fill");
106 case InsetSpaceParams::HFILL_PROTECTED:
107 message = _("Protected Horizontal Fill");
109 case InsetSpaceParams::DOTFILL:
110 message = _("Horizontal Fill (Dots)");
112 case InsetSpaceParams::HRULEFILL:
113 message = _("Horizontal Fill (Rule)");
115 case InsetSpaceParams::LEFTARROWFILL:
116 message = _("Horizontal Fill (Left Arrow)");
118 case InsetSpaceParams::RIGHTARROWFILL:
119 message = _("Horizontal Fill (Right Arrow)");
121 case InsetSpaceParams::UPBRACEFILL:
122 message = _("Horizontal Fill (Up Brace)");
124 case InsetSpaceParams::DOWNBRACEFILL:
125 message = _("Horizontal Fill (Down Brace)");
127 case InsetSpaceParams::CUSTOM:
129 message = support::bformat(_("Horizontal Space (%1$s)"),
130 from_ascii(params_.length.asString()));
132 case InsetSpaceParams::CUSTOM_PROTECTED:
134 message = support::bformat(_("Protected Horizontal Space (%1$s)"),
135 from_ascii(params_.length.asString()));
142 void InsetSpace::doDispatch(Cursor & cur, FuncRequest & cmd)
144 switch (cmd.action()) {
146 case LFUN_INSET_MODIFY:
148 string2params(to_utf8(cmd.argument()), params_);
151 case LFUN_INSET_DIALOG_UPDATE:
152 cur.bv().updateDialog("space", params2string(params()));
156 Inset::doDispatch(cur, cmd);
162 bool InsetSpace::getStatus(Cursor & cur, FuncRequest const & cmd,
163 FuncStatus & status) const
165 switch (cmd.action()) {
167 case LFUN_INSET_MODIFY:
168 if (cmd.getArg(0) == "space") {
169 InsetSpaceParams params;
170 string2params(to_utf8(cmd.argument()), params);
171 status.setOnOff(params_.kind == params.kind);
174 case LFUN_INSET_DIALOG_UPDATE:
175 status.setEnabled(true);
178 return Inset::getStatus(cur, cmd, status);
184 int const arrow_size = 8;
188 void InsetSpace::metrics(MetricsInfo & mi, Dimension & dim) const
190 if (isStretchableSpace()) {
191 // The metrics for this kinds are calculated externally in
192 // \c TextMetrics::computeRowMetrics. Those are dummy value:
193 dim = Dimension(10, 10, 10);
197 frontend::FontMetrics const & fm = theFontMetrics(mi.base.font);
198 dim.asc = fm.maxAscent();
199 dim.des = fm.maxDescent();
201 switch (params_.kind) {
202 case InsetSpaceParams::THIN:
203 case InsetSpaceParams::NEGTHIN:
204 dim.wid = fm.width(char_type('M')) / 6;
206 case InsetSpaceParams::MEDIUM:
207 case InsetSpaceParams::NEGMEDIUM:
208 dim.wid = fm.width(char_type('M')) / 4;
210 case InsetSpaceParams::THICK:
211 case InsetSpaceParams::NEGTHICK:
212 dim.wid = fm.width(char_type('M')) / 2;
214 case InsetSpaceParams::PROTECTED:
215 case InsetSpaceParams::NORMAL:
216 dim.wid = fm.width(char_type(' '));
218 case InsetSpaceParams::QUAD:
219 dim.wid = fm.width(char_type('M'));
221 case InsetSpaceParams::QQUAD:
222 dim.wid = 2 * fm.width(char_type('M'));
224 case InsetSpaceParams::ENSPACE:
225 case InsetSpaceParams::ENSKIP:
226 dim.wid = int(0.5 * fm.width(char_type('M')));
228 case InsetSpaceParams::CUSTOM:
229 case InsetSpaceParams::CUSTOM_PROTECTED: {
231 params_.length.len().inPixels(mi.base.textwidth,
232 fm.width(char_type('M')));
233 int const minw = (w < 0) ? 3 * arrow_size : 4;
234 dim.wid = max(minw, abs(w));
237 case InsetSpaceParams::HFILL:
238 case InsetSpaceParams::HFILL_PROTECTED:
239 case InsetSpaceParams::DOTFILL:
240 case InsetSpaceParams::HRULEFILL:
241 case InsetSpaceParams::LEFTARROWFILL:
242 case InsetSpaceParams::RIGHTARROWFILL:
243 case InsetSpaceParams::UPBRACEFILL:
244 case InsetSpaceParams::DOWNBRACEFILL:
248 // Cache the inset dimension.
249 setDimCache(mi, dim);
253 void InsetSpace::draw(PainterInfo & pi, int x, int y) const
255 Dimension const dim = dimension(*pi.base.bv);
257 if (isStretchableSpace() || params_.length.len().value() < 0) {
258 int const asc = theFontMetrics(pi.base.font).ascent('M');
259 int const desc = theFontMetrics(pi.base.font).descent('M');
260 // Pixel height divisible by 2 for prettier fill graphics:
261 int const oddheight = (asc ^ desc) & 1;
262 int const x0 = x + 1;
263 int const x1 = x + dim.wid - 2;
264 int const y0 = y + desc - 1;
265 int const y1 = y - asc + oddheight - 1;
266 int const y2 = (y0 + y1) / 2;
267 int xoffset = (y0 - y1) / 2;
269 // Two tests for very narrow insets
270 if (xoffset > x1 - x0
271 && (params_.kind == InsetSpaceParams::LEFTARROWFILL
272 || params_.kind == InsetSpaceParams::RIGHTARROWFILL))
274 if (xoffset * 6 > (x1 - x0)
275 && (params_.kind == InsetSpaceParams::UPBRACEFILL
276 || params_.kind == InsetSpaceParams::DOWNBRACEFILL))
277 xoffset = (x1 - x0) / 6;
279 int const x2 = x0 + xoffset;
280 int const x3 = x1 - xoffset;
281 int const xm = (x0 + x1) / 2;
282 int const xml = xm - xoffset;
283 int const xmr = xm + xoffset;
285 if (params_.kind == InsetSpaceParams::HFILL) {
286 pi.pain.line(x0, y1, x0, y0, Color_added_space);
287 pi.pain.line(x0, y2, x1, y2, Color_added_space,
288 frontend::Painter::line_onoffdash);
289 pi.pain.line(x1, y1, x1, y0, Color_added_space);
290 } else if (params_.kind == InsetSpaceParams::HFILL_PROTECTED) {
291 pi.pain.line(x0, y1, x0, y0, Color_latex);
292 pi.pain.line(x0, y2, x1, y2, Color_latex,
293 frontend::Painter::line_onoffdash);
294 pi.pain.line(x1, y1, x1, y0, Color_latex);
295 } else if (params_.kind == InsetSpaceParams::DOTFILL) {
296 pi.pain.line(x0, y1, x0, y0, Color_special);
297 pi.pain.line(x0, y0, x1, y0, Color_special,
298 frontend::Painter::line_onoffdash);
299 pi.pain.line(x1, y1, x1, y0, Color_special);
300 } else if (params_.kind == InsetSpaceParams::HRULEFILL) {
301 pi.pain.line(x0, y1, x0, y0, Color_special);
302 pi.pain.line(x0, y0, x1, y0, Color_special);
303 pi.pain.line(x1, y1, x1, y0, Color_special);
304 } else if (params_.kind == InsetSpaceParams::LEFTARROWFILL) {
305 pi.pain.line(x2, y1 + 1 , x0 + 1, y2, Color_special);
306 pi.pain.line(x0 + 1, y2 + 1 , x2, y0, Color_special);
307 pi.pain.line(x0, y2 , x1, y2, Color_special);
308 } else if (params_.kind == InsetSpaceParams::RIGHTARROWFILL) {
309 pi.pain.line(x3 + 1, y1 + 1 , x1, y2, Color_special);
310 pi.pain.line(x1, y2 + 1 , x3 + 1, y0, Color_special);
311 pi.pain.line(x0, y2 , x1, y2, Color_special);
312 } else if (params_.kind == InsetSpaceParams::UPBRACEFILL) {
313 pi.pain.line(x0 + 1, y1 + 1 , x2, y2, Color_special);
314 pi.pain.line(x2, y2 , xml, y2, Color_special);
315 pi.pain.line(xml + 1, y2 + 1 , xm, y0, Color_special);
316 pi.pain.line(xm + 1, y0 , xmr, y2 + 1, Color_special);
317 pi.pain.line(xmr, y2 , x3, y2, Color_special);
318 pi.pain.line(x3 + 1, y2 , x1, y1 + 1, Color_special);
319 } else if (params_.kind == InsetSpaceParams::DOWNBRACEFILL) {
320 pi.pain.line(x0 + 1, y0 , x2, y2 + 1, Color_special);
321 pi.pain.line(x2, y2 , xml, y2, Color_special);
322 pi.pain.line(xml + 1, y2 , xm, y1 + 1, Color_special);
323 pi.pain.line(xm + 1, y1 + 1 , xmr, y2, Color_special);
324 pi.pain.line(xmr, y2 , x3, y2, Color_special);
325 pi.pain.line(x3 + 1, y2 + 1 , x1, y0, Color_special);
326 } else if (params_.kind == InsetSpaceParams::CUSTOM) {
327 pi.pain.line(x0, y1 + 1 , x2 + 1, y2, Color_special);
328 pi.pain.line(x2 + 1, y2 + 1 , x0, y0, Color_special);
329 pi.pain.line(x1 + 1, y1 + 1 , x3, y2, Color_special);
330 pi.pain.line(x3, y2 + 1 , x1 + 1, y0, Color_special);
331 pi.pain.line(x2, y2 , x3, y2, Color_special);
332 } else if (params_.kind == InsetSpaceParams::CUSTOM_PROTECTED) {
333 pi.pain.line(x0, y1 + 1 , x2 + 1, y2, Color_latex);
334 pi.pain.line(x2 + 1, y2 + 1 , x0, y0, Color_latex);
335 pi.pain.line(x1 + 1, y1 + 1 , x3, y2, Color_latex);
336 pi.pain.line(x3, y2 + 1 , x1 + 1, y0, Color_latex);
337 pi.pain.line(x2, y2 , x3, y2, Color_latex);
342 int const w = dim.wid;
343 int const h = theFontMetrics(pi.base.font).ascent('x');
347 yp[0] = y - max(h / 4, 1);
348 if (params_.kind == InsetSpaceParams::NORMAL ||
349 params_.kind == InsetSpaceParams::PROTECTED) {
350 xp[1] = x; yp[1] = y;
351 xp[2] = x + w; yp[2] = y;
353 xp[1] = x; yp[1] = y + max(h / 4, 1);
354 xp[2] = x + w; yp[2] = y + max(h / 4, 1);
357 yp[3] = y - max(h / 4, 1);
359 if (params_.kind == InsetSpaceParams::PROTECTED ||
360 params_.kind == InsetSpaceParams::ENSPACE ||
361 params_.kind == InsetSpaceParams::NEGTHIN ||
362 params_.kind == InsetSpaceParams::NEGMEDIUM ||
363 params_.kind == InsetSpaceParams::NEGTHICK ||
364 params_.kind == InsetSpaceParams::CUSTOM_PROTECTED)
365 pi.pain.lines(xp, yp, 4, Color_latex);
367 pi.pain.lines(xp, yp, 4, Color_special);
371 void InsetSpaceParams::write(ostream & os) const
375 case InsetSpaceParams::NORMAL:
378 case InsetSpaceParams::PROTECTED:
381 case InsetSpaceParams::THIN:
382 os << "\\thinspace{}";
384 case InsetSpaceParams::MEDIUM:
385 os << "\\medspace{}";
387 case InsetSpaceParams::THICK:
388 os << "\\thickspace{}";
390 case InsetSpaceParams::QUAD:
393 case InsetSpaceParams::QQUAD:
396 case InsetSpaceParams::ENSPACE:
399 case InsetSpaceParams::ENSKIP:
402 case InsetSpaceParams::NEGTHIN:
403 os << "\\negthinspace{}";
405 case InsetSpaceParams::NEGMEDIUM:
406 os << "\\negmedspace{}";
408 case InsetSpaceParams::NEGTHICK:
409 os << "\\negthickspace{}";
411 case InsetSpaceParams::HFILL:
414 case InsetSpaceParams::HFILL_PROTECTED:
415 os << "\\hspace*{\\fill}";
417 case InsetSpaceParams::DOTFILL:
420 case InsetSpaceParams::HRULEFILL:
421 os << "\\hrulefill{}";
423 case InsetSpaceParams::LEFTARROWFILL:
424 os << "\\leftarrowfill{}";
426 case InsetSpaceParams::RIGHTARROWFILL:
427 os << "\\rightarrowfill{}";
429 case InsetSpaceParams::UPBRACEFILL:
430 os << "\\upbracefill{}";
432 case InsetSpaceParams::DOWNBRACEFILL:
433 os << "\\downbracefill{}";
435 case InsetSpaceParams::CUSTOM:
438 case InsetSpaceParams::CUSTOM_PROTECTED:
443 if (!length.len().empty())
444 os << "\n\\length " << length.asString();
448 void InsetSpaceParams::read(Lexer & lex)
450 lex.setContext("InsetSpaceParams::read");
454 // The tests for math might be disabled after a file format change
455 if (command == "\\space{}")
456 kind = InsetSpaceParams::NORMAL;
457 else if (command == "~")
458 kind = InsetSpaceParams::PROTECTED;
459 else if (command == "\\thinspace{}")
460 kind = InsetSpaceParams::THIN;
461 else if (math && command == "\\medspace{}")
462 kind = InsetSpaceParams::MEDIUM;
463 else if (math && command == "\\thickspace{}")
464 kind = InsetSpaceParams::THICK;
465 else if (command == "\\quad{}")
466 kind = InsetSpaceParams::QUAD;
467 else if (command == "\\qquad{}")
468 kind = InsetSpaceParams::QQUAD;
469 else if (command == "\\enspace{}")
470 kind = InsetSpaceParams::ENSPACE;
471 else if (command == "\\enskip{}")
472 kind = InsetSpaceParams::ENSKIP;
473 else if (command == "\\negthinspace{}")
474 kind = InsetSpaceParams::NEGTHIN;
475 else if (math && command == "\\negmedspace{}")
476 kind = InsetSpaceParams::NEGMEDIUM;
477 else if (math && command == "\\negthickspace{}")
478 kind = InsetSpaceParams::NEGTHICK;
479 else if (command == "\\hfill{}")
480 kind = InsetSpaceParams::HFILL;
481 else if (command == "\\hspace*{\\fill}")
482 kind = InsetSpaceParams::HFILL_PROTECTED;
483 else if (command == "\\dotfill{}")
484 kind = InsetSpaceParams::DOTFILL;
485 else if (command == "\\hrulefill{}")
486 kind = InsetSpaceParams::HRULEFILL;
487 else if (command == "\\hspace{}")
488 kind = InsetSpaceParams::CUSTOM;
489 else if (command == "\\leftarrowfill{}")
490 kind = InsetSpaceParams::LEFTARROWFILL;
491 else if (command == "\\rightarrowfill{}")
492 kind = InsetSpaceParams::RIGHTARROWFILL;
493 else if (command == "\\upbracefill{}")
494 kind = InsetSpaceParams::UPBRACEFILL;
495 else if (command == "\\downbracefill{}")
496 kind = InsetSpaceParams::DOWNBRACEFILL;
497 else if (command == "\\hspace*{}")
498 kind = InsetSpaceParams::CUSTOM_PROTECTED;
500 lex.printError("InsetSpace: Unknown kind: `$$Token'");
502 if (lex.checkFor("\\length"))
507 void InsetSpace::write(ostream & os) const
514 void InsetSpace::read(Lexer & lex)
517 lex >> "\\end_inset";
521 int InsetSpace::latex(odocstream & os, OutputParams const & runparams) const
523 switch (params_.kind) {
524 case InsetSpaceParams::NORMAL:
525 os << (runparams.free_spacing ? " " : "\\ ");
527 case InsetSpaceParams::PROTECTED:
528 if (runparams.local_font &&
529 runparams.local_font->language()->lang() == "polutonikogreek")
530 // in babel's polutonikogreek, ~ is active
531 os << (runparams.free_spacing ? " " : "\\nobreakspace{}");
533 os << (runparams.free_spacing ? ' ' : '~');
535 case InsetSpaceParams::THIN:
536 os << (runparams.free_spacing ? " " : "\\,");
538 case InsetSpaceParams::MEDIUM:
539 os << (runparams.free_spacing ? " " : "\\:");
541 case InsetSpaceParams::THICK:
542 os << (runparams.free_spacing ? " " : "\\;");
544 case InsetSpaceParams::QUAD:
545 os << (runparams.free_spacing ? " " : "\\quad{}");
547 case InsetSpaceParams::QQUAD:
548 os << (runparams.free_spacing ? " " : "\\qquad{}");
550 case InsetSpaceParams::ENSPACE:
551 os << (runparams.free_spacing ? " " : "\\enspace{}");
553 case InsetSpaceParams::ENSKIP:
554 os << (runparams.free_spacing ? " " : "\\enskip{}");
556 case InsetSpaceParams::NEGTHIN:
557 os << (runparams.free_spacing ? " " : "\\negthinspace{}");
559 case InsetSpaceParams::NEGMEDIUM:
560 os << (runparams.free_spacing ? " " : "\\negmedspace{}");
562 case InsetSpaceParams::NEGTHICK:
563 os << (runparams.free_spacing ? " " : "\\negthickspace{}");
565 case InsetSpaceParams::HFILL:
566 os << (runparams.free_spacing ? " " : "\\hfill{}");
568 case InsetSpaceParams::HFILL_PROTECTED:
569 os << (runparams.free_spacing ? " " : "\\hspace*{\\fill}");
571 case InsetSpaceParams::DOTFILL:
572 os << (runparams.free_spacing ? " " : "\\dotfill{}");
574 case InsetSpaceParams::HRULEFILL:
575 os << (runparams.free_spacing ? " " : "\\hrulefill{}");
577 case InsetSpaceParams::LEFTARROWFILL:
578 os << (runparams.free_spacing ? " " : "\\leftarrowfill{}");
580 case InsetSpaceParams::RIGHTARROWFILL:
581 os << (runparams.free_spacing ? " " : "\\rightarrowfill{}");
583 case InsetSpaceParams::UPBRACEFILL:
584 os << (runparams.free_spacing ? " " : "\\upbracefill{}");
586 case InsetSpaceParams::DOWNBRACEFILL:
587 os << (runparams.free_spacing ? " " : "\\downbracefill{}");
589 case InsetSpaceParams::CUSTOM:
590 if (runparams.free_spacing)
593 os << "\\hspace{" << from_ascii(params_.length.asLatexString()) << "}";
595 case InsetSpaceParams::CUSTOM_PROTECTED:
596 if (runparams.free_spacing)
599 os << "\\hspace*{" << from_ascii(params_.length.asLatexString()) << "}";
606 int InsetSpace::plaintext(odocstream & os, OutputParams const &) const
608 switch (params_.kind) {
609 case InsetSpaceParams::HFILL:
610 case InsetSpaceParams::HFILL_PROTECTED:
613 case InsetSpaceParams::DOTFILL:
616 case InsetSpaceParams::HRULEFILL:
619 case InsetSpaceParams::LEFTARROWFILL:
622 case InsetSpaceParams::RIGHTARROWFILL:
625 case InsetSpaceParams::UPBRACEFILL:
628 case InsetSpaceParams::DOWNBRACEFILL:
638 int InsetSpace::docbook(odocstream & os, OutputParams const &) const
640 switch (params_.kind) {
641 case InsetSpaceParams::NORMAL:
642 case InsetSpaceParams::QUAD:
643 case InsetSpaceParams::QQUAD:
644 case InsetSpaceParams::ENSKIP:
647 case InsetSpaceParams::PROTECTED:
648 case InsetSpaceParams::ENSPACE:
649 case InsetSpaceParams::THIN:
650 case InsetSpaceParams::MEDIUM:
651 case InsetSpaceParams::THICK:
652 case InsetSpaceParams::NEGTHIN:
653 case InsetSpaceParams::NEGMEDIUM:
654 case InsetSpaceParams::NEGTHICK:
657 case InsetSpaceParams::HFILL:
658 case InsetSpaceParams::HFILL_PROTECTED:
660 case InsetSpaceParams::DOTFILL:
663 case InsetSpaceParams::HRULEFILL:
666 case InsetSpaceParams::LEFTARROWFILL:
667 case InsetSpaceParams::RIGHTARROWFILL:
668 case InsetSpaceParams::UPBRACEFILL:
669 case InsetSpaceParams::DOWNBRACEFILL:
670 case InsetSpaceParams::CUSTOM:
671 case InsetSpaceParams::CUSTOM_PROTECTED:
679 docstring InsetSpace::xhtml(XHTMLStream & xs, OutputParams const &) const
682 switch (params_.kind) {
683 case InsetSpaceParams::NORMAL:
686 case InsetSpaceParams::ENSKIP:
687 case InsetSpaceParams::ENSPACE:
690 case InsetSpaceParams::QQUAD:
692 case InsetSpaceParams::THICK:
693 case InsetSpaceParams::QUAD:
696 case InsetSpaceParams::THIN:
699 case InsetSpaceParams::PROTECTED:
700 case InsetSpaceParams::MEDIUM:
701 case InsetSpaceParams::NEGTHIN:
702 case InsetSpaceParams::NEGMEDIUM:
703 case InsetSpaceParams::NEGTHICK:
706 case InsetSpaceParams::HFILL:
707 case InsetSpaceParams::HFILL_PROTECTED:
708 case InsetSpaceParams::DOTFILL:
709 case InsetSpaceParams::HRULEFILL:
710 case InsetSpaceParams::LEFTARROWFILL:
711 case InsetSpaceParams::RIGHTARROWFILL:
712 case InsetSpaceParams::UPBRACEFILL:
713 case InsetSpaceParams::DOWNBRACEFILL:
715 // Can we do anything with those in HTML?
717 case InsetSpaceParams::CUSTOM:
718 case InsetSpaceParams::CUSTOM_PROTECTED:
720 // Probably we could do some sort of blank span?
723 // don't escape the entities!
724 xs << XHTMLStream::ESCAPE_NONE << from_ascii(output);
729 void InsetSpace::validate(LaTeXFeatures & features) const
731 if (params_.kind == InsetSpaceParams::NEGMEDIUM ||
732 params_.kind == InsetSpaceParams::NEGTHICK)
733 features.require("amsmath");
737 void InsetSpace::toString(odocstream & os) const
739 plaintext(os, OutputParams(0));
743 void InsetSpace::forToc(docstring & os, size_t) const
745 // There's no need to be cute here.
750 bool InsetSpace::isStretchableSpace() const
752 return params_.kind == InsetSpaceParams::HFILL
753 || params_.kind == InsetSpaceParams::HFILL_PROTECTED
754 || params_.kind == InsetSpaceParams::DOTFILL
755 || params_.kind == InsetSpaceParams::HRULEFILL
756 || params_.kind == InsetSpaceParams::LEFTARROWFILL
757 || params_.kind == InsetSpaceParams::RIGHTARROWFILL
758 || params_.kind == InsetSpaceParams::UPBRACEFILL
759 || params_.kind == InsetSpaceParams::DOWNBRACEFILL;
763 docstring InsetSpace::contextMenuName() const
765 return from_ascii("context-space");
769 void InsetSpace::string2params(string const & in, InsetSpaceParams & params)
771 params = InsetSpaceParams();
775 istringstream data(in);
778 lex.setContext("InsetSpace::string2params");
780 string const name = lex.getString();
781 if (name == "mathspace")
785 LASSERT(name == "space", /**/);
788 // There are cases, such as when we are called via getStatus() from
789 // Dialog::canApply(), where we are just called with "space" rather
790 // than a full "space \type{}\n\\end_inset".
796 string InsetSpace::params2string(InsetSpaceParams const & params)
801 data << "space" << ' ';