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 InsetSpace::~InsetSpace()
65 hideDialogs("space", this);
69 docstring InsetSpace::toolTip(BufferView const &, int, int) const
72 switch (params_.kind) {
73 case InsetSpaceParams::NORMAL:
74 message = _("Interword Space");
76 case InsetSpaceParams::PROTECTED:
77 message = _("Protected Space");
79 case InsetSpaceParams::THIN:
80 message = _("Thin Space");
82 case InsetSpaceParams::MEDIUM:
83 message = _("Medium Space");
85 case InsetSpaceParams::THICK:
86 message = _("Thick Space");
88 case InsetSpaceParams::QUAD:
89 message = _("Quad Space");
91 case InsetSpaceParams::QQUAD:
92 message = _("QQuad Space");
94 case InsetSpaceParams::ENSPACE:
95 message = _("Enspace");
97 case InsetSpaceParams::ENSKIP:
98 message = _("Enskip");
100 case InsetSpaceParams::NEGTHIN:
101 message = _("Negative Thin Space");
103 case InsetSpaceParams::NEGMEDIUM:
104 message = _("Negative Medium Space");
106 case InsetSpaceParams::NEGTHICK:
107 message = _("Negative Thick Space");
109 case InsetSpaceParams::HFILL:
110 message = _("Horizontal Fill");
112 case InsetSpaceParams::HFILL_PROTECTED:
113 message = _("Protected Horizontal Fill");
115 case InsetSpaceParams::DOTFILL:
116 message = _("Horizontal Fill (Dots)");
118 case InsetSpaceParams::HRULEFILL:
119 message = _("Horizontal Fill (Rule)");
121 case InsetSpaceParams::LEFTARROWFILL:
122 message = _("Horizontal Fill (Left Arrow)");
124 case InsetSpaceParams::RIGHTARROWFILL:
125 message = _("Horizontal Fill (Right Arrow)");
127 case InsetSpaceParams::UPBRACEFILL:
128 message = _("Horizontal Fill (Up Brace)");
130 case InsetSpaceParams::DOWNBRACEFILL:
131 message = _("Horizontal Fill (Down Brace)");
133 case InsetSpaceParams::CUSTOM:
135 message = support::bformat(_("Horizontal Space (%1$s)"),
136 from_ascii(params_.length.asString()));
138 case InsetSpaceParams::CUSTOM_PROTECTED:
140 message = support::bformat(_("Protected Horizontal Space (%1$s)"),
141 from_ascii(params_.length.asString()));
148 void InsetSpace::doDispatch(Cursor & cur, FuncRequest & cmd)
150 switch (cmd.action) {
152 case LFUN_INSET_MODIFY:
153 string2params(to_utf8(cmd.argument()), params_);
156 case LFUN_INSET_DIALOG_UPDATE:
157 cur.bv().updateDialog("space", params2string(params()));
161 Inset::doDispatch(cur, cmd);
167 bool InsetSpace::getStatus(Cursor & cur, FuncRequest const & cmd,
168 FuncStatus & status) const
170 switch (cmd.action) {
172 case LFUN_INSET_MODIFY:
173 if (cmd.getArg(0) == "space") {
174 InsetSpaceParams params;
175 string2params(to_utf8(cmd.argument()), params);
176 status.setOnOff(params_.kind == params.kind);
179 case LFUN_INSET_DIALOG_UPDATE:
180 status.setEnabled(true);
183 return Inset::getStatus(cur, cmd, status);
188 bool InsetSpace::showInsetDialog(BufferView * bv) const
190 bv->showDialog("space", params2string(params()),
191 const_cast<InsetSpace *>(this));
197 int const arrow_size = 8;
201 void InsetSpace::metrics(MetricsInfo & mi, Dimension & dim) const
203 if (isStretchableSpace()) {
204 // The metrics for this kinds are calculated externally in
205 // \c TextMetrics::computeRowMetrics. Those are dummy value:
206 dim = Dimension(10, 10, 10);
210 frontend::FontMetrics const & fm = theFontMetrics(mi.base.font);
211 dim.asc = fm.maxAscent();
212 dim.des = fm.maxDescent();
214 switch (params_.kind) {
215 case InsetSpaceParams::THIN:
216 case InsetSpaceParams::NEGTHIN:
217 dim.wid = fm.width(char_type('M')) / 6;
219 case InsetSpaceParams::MEDIUM:
220 case InsetSpaceParams::NEGMEDIUM:
221 dim.wid = fm.width(char_type('M')) / 4;
223 case InsetSpaceParams::THICK:
224 case InsetSpaceParams::NEGTHICK:
225 dim.wid = fm.width(char_type('M')) / 2;
227 case InsetSpaceParams::PROTECTED:
228 case InsetSpaceParams::NORMAL:
229 dim.wid = fm.width(char_type(' '));
231 case InsetSpaceParams::QUAD:
232 dim.wid = fm.width(char_type('M'));
234 case InsetSpaceParams::QQUAD:
235 dim.wid = 2 * fm.width(char_type('M'));
237 case InsetSpaceParams::ENSPACE:
238 case InsetSpaceParams::ENSKIP:
239 dim.wid = int(0.5 * fm.width(char_type('M')));
241 case InsetSpaceParams::CUSTOM:
242 case InsetSpaceParams::CUSTOM_PROTECTED: {
244 params_.length.len().inPixels(mi.base.textwidth,
245 fm.width(char_type('M')));
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 (isStretchableSpace() || 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 xp[1] = x; yp[1] = y;
364 xp[2] = x + w; yp[2] = y;
366 xp[1] = x; yp[1] = y + max(h / 4, 1);
367 xp[2] = x + w; yp[2] = y + max(h / 4, 1);
370 yp[3] = y - max(h / 4, 1);
372 if (params_.kind == InsetSpaceParams::PROTECTED ||
373 params_.kind == InsetSpaceParams::ENSPACE ||
374 params_.kind == InsetSpaceParams::NEGTHIN ||
375 params_.kind == InsetSpaceParams::NEGMEDIUM ||
376 params_.kind == InsetSpaceParams::NEGTHICK ||
377 params_.kind == InsetSpaceParams::CUSTOM_PROTECTED)
378 pi.pain.lines(xp, yp, 4, Color_latex);
380 pi.pain.lines(xp, yp, 4, Color_special);
384 void InsetSpaceParams::write(ostream & os) const
388 case InsetSpaceParams::NORMAL:
391 case InsetSpaceParams::PROTECTED:
394 case InsetSpaceParams::THIN:
395 os << "\\thinspace{}";
397 case InsetSpaceParams::MEDIUM:
398 os << "\\medspace{}";
400 case InsetSpaceParams::THICK:
401 os << "\\thickspace{}";
403 case InsetSpaceParams::QUAD:
406 case InsetSpaceParams::QQUAD:
409 case InsetSpaceParams::ENSPACE:
412 case InsetSpaceParams::ENSKIP:
415 case InsetSpaceParams::NEGTHIN:
416 os << "\\negthinspace{}";
418 case InsetSpaceParams::NEGMEDIUM:
419 os << "\\negmedspace{}";
421 case InsetSpaceParams::NEGTHICK:
422 os << "\\negthickspace{}";
424 case InsetSpaceParams::HFILL:
427 case InsetSpaceParams::HFILL_PROTECTED:
428 os << "\\hspace*{\\fill}";
430 case InsetSpaceParams::DOTFILL:
433 case InsetSpaceParams::HRULEFILL:
434 os << "\\hrulefill{}";
436 case InsetSpaceParams::LEFTARROWFILL:
437 os << "\\leftarrowfill{}";
439 case InsetSpaceParams::RIGHTARROWFILL:
440 os << "\\rightarrowfill{}";
442 case InsetSpaceParams::UPBRACEFILL:
443 os << "\\upbracefill{}";
445 case InsetSpaceParams::DOWNBRACEFILL:
446 os << "\\downbracefill{}";
448 case InsetSpaceParams::CUSTOM:
451 case InsetSpaceParams::CUSTOM_PROTECTED:
456 if (!length.len().empty())
457 os << "\n\\length " << length.asString();
461 void InsetSpaceParams::read(Lexer & lex)
463 lex.setContext("InsetSpaceParams::read");
467 // The tests for math might be disabled after a file format change
468 if (command == "\\space{}")
469 kind = InsetSpaceParams::NORMAL;
470 else if (command == "~")
471 kind = InsetSpaceParams::PROTECTED;
472 else if (command == "\\thinspace{}")
473 kind = InsetSpaceParams::THIN;
474 else if (math && command == "\\medspace{}")
475 kind = InsetSpaceParams::MEDIUM;
476 else if (math && command == "\\thickspace{}")
477 kind = InsetSpaceParams::THICK;
478 else if (command == "\\quad{}")
479 kind = InsetSpaceParams::QUAD;
480 else if (command == "\\qquad{}")
481 kind = InsetSpaceParams::QQUAD;
482 else if (command == "\\enspace{}")
483 kind = InsetSpaceParams::ENSPACE;
484 else if (command == "\\enskip{}")
485 kind = InsetSpaceParams::ENSKIP;
486 else if (command == "\\negthinspace{}")
487 kind = InsetSpaceParams::NEGTHIN;
488 else if (math && command == "\\negmedspace{}")
489 kind = InsetSpaceParams::NEGMEDIUM;
490 else if (math && command == "\\negthickspace{}")
491 kind = InsetSpaceParams::NEGTHICK;
492 else if (command == "\\hfill{}")
493 kind = InsetSpaceParams::HFILL;
494 else if (command == "\\hspace*{\\fill}")
495 kind = InsetSpaceParams::HFILL_PROTECTED;
496 else if (command == "\\dotfill{}")
497 kind = InsetSpaceParams::DOTFILL;
498 else if (command == "\\hrulefill{}")
499 kind = InsetSpaceParams::HRULEFILL;
500 else if (command == "\\hspace{}")
501 kind = InsetSpaceParams::CUSTOM;
502 else if (command == "\\leftarrowfill{}")
503 kind = InsetSpaceParams::LEFTARROWFILL;
504 else if (command == "\\rightarrowfill{}")
505 kind = InsetSpaceParams::RIGHTARROWFILL;
506 else if (command == "\\upbracefill{}")
507 kind = InsetSpaceParams::UPBRACEFILL;
508 else if (command == "\\downbracefill{}")
509 kind = InsetSpaceParams::DOWNBRACEFILL;
510 else if (command == "\\hspace*{}")
511 kind = InsetSpaceParams::CUSTOM_PROTECTED;
513 lex.printError("InsetSpace: Unknown kind: `$$Token'");
515 if (lex.checkFor("\\length"))
520 void InsetSpace::write(ostream & os) const
527 void InsetSpace::read(Lexer & lex)
530 lex >> "\\end_inset";
534 int InsetSpace::latex(odocstream & os, OutputParams const & runparams) const
536 switch (params_.kind) {
537 case InsetSpaceParams::NORMAL:
538 os << (runparams.free_spacing ? " " : "\\ ");
540 case InsetSpaceParams::PROTECTED:
541 if (runparams.local_font &&
542 runparams.local_font->language()->lang() == "polutonikogreek")
543 // in babel's polutonikogreek, ~ is active
544 os << (runparams.free_spacing ? " " : "\\nobreakspace{}");
546 os << (runparams.free_spacing ? ' ' : '~');
548 case InsetSpaceParams::THIN:
549 os << (runparams.free_spacing ? " " : "\\,");
551 case InsetSpaceParams::MEDIUM:
552 os << (runparams.free_spacing ? " " : "\\:");
554 case InsetSpaceParams::THICK:
555 os << (runparams.free_spacing ? " " : "\\;");
557 case InsetSpaceParams::QUAD:
558 os << (runparams.free_spacing ? " " : "\\quad{}");
560 case InsetSpaceParams::QQUAD:
561 os << (runparams.free_spacing ? " " : "\\qquad{}");
563 case InsetSpaceParams::ENSPACE:
564 os << (runparams.free_spacing ? " " : "\\enspace{}");
566 case InsetSpaceParams::ENSKIP:
567 os << (runparams.free_spacing ? " " : "\\enskip{}");
569 case InsetSpaceParams::NEGTHIN:
570 os << (runparams.free_spacing ? " " : "\\negthinspace{}");
572 case InsetSpaceParams::NEGMEDIUM:
573 os << (runparams.free_spacing ? " " : "\\negmedspace{}");
575 case InsetSpaceParams::NEGTHICK:
576 os << (runparams.free_spacing ? " " : "\\negthickspace{}");
578 case InsetSpaceParams::HFILL:
579 os << (runparams.free_spacing ? " " : "\\hfill{}");
581 case InsetSpaceParams::HFILL_PROTECTED:
582 os << (runparams.free_spacing ? " " : "\\hspace*{\\fill}");
584 case InsetSpaceParams::DOTFILL:
585 os << (runparams.free_spacing ? " " : "\\dotfill{}");
587 case InsetSpaceParams::HRULEFILL:
588 os << (runparams.free_spacing ? " " : "\\hrulefill{}");
590 case InsetSpaceParams::LEFTARROWFILL:
591 os << (runparams.free_spacing ? " " : "\\leftarrowfill{}");
593 case InsetSpaceParams::RIGHTARROWFILL:
594 os << (runparams.free_spacing ? " " : "\\rightarrowfill{}");
596 case InsetSpaceParams::UPBRACEFILL:
597 os << (runparams.free_spacing ? " " : "\\upbracefill{}");
599 case InsetSpaceParams::DOWNBRACEFILL:
600 os << (runparams.free_spacing ? " " : "\\downbracefill{}");
602 case InsetSpaceParams::CUSTOM:
603 if (runparams.free_spacing)
606 os << "\\hspace{" << from_ascii(params_.length.asLatexString()) << "}";
608 case InsetSpaceParams::CUSTOM_PROTECTED:
609 if (runparams.free_spacing)
612 os << "\\hspace*{" << from_ascii(params_.length.asLatexString()) << "}";
619 int InsetSpace::plaintext(odocstream & os, OutputParams const &) const
621 switch (params_.kind) {
622 case InsetSpaceParams::HFILL:
623 case InsetSpaceParams::HFILL_PROTECTED:
626 case InsetSpaceParams::DOTFILL:
629 case InsetSpaceParams::HRULEFILL:
632 case InsetSpaceParams::LEFTARROWFILL:
635 case InsetSpaceParams::RIGHTARROWFILL:
638 case InsetSpaceParams::UPBRACEFILL:
641 case InsetSpaceParams::DOWNBRACEFILL:
651 int InsetSpace::docbook(odocstream & os, OutputParams const &) const
653 switch (params_.kind) {
654 case InsetSpaceParams::NORMAL:
655 case InsetSpaceParams::QUAD:
656 case InsetSpaceParams::QQUAD:
657 case InsetSpaceParams::ENSKIP:
660 case InsetSpaceParams::PROTECTED:
661 case InsetSpaceParams::ENSPACE:
662 case InsetSpaceParams::THIN:
663 case InsetSpaceParams::MEDIUM:
664 case InsetSpaceParams::THICK:
665 case InsetSpaceParams::NEGTHIN:
666 case InsetSpaceParams::NEGMEDIUM:
667 case InsetSpaceParams::NEGTHICK:
670 case InsetSpaceParams::HFILL:
671 case InsetSpaceParams::HFILL_PROTECTED:
673 case InsetSpaceParams::DOTFILL:
676 case InsetSpaceParams::HRULEFILL:
679 case InsetSpaceParams::LEFTARROWFILL:
680 case InsetSpaceParams::RIGHTARROWFILL:
681 case InsetSpaceParams::UPBRACEFILL:
682 case InsetSpaceParams::DOWNBRACEFILL:
683 case InsetSpaceParams::CUSTOM:
684 case InsetSpaceParams::CUSTOM_PROTECTED:
692 docstring InsetSpace::xhtml(XHTMLStream & xs, OutputParams const &) const
695 switch (params_.kind) {
696 case InsetSpaceParams::NORMAL:
699 case InsetSpaceParams::ENSKIP:
700 case InsetSpaceParams::ENSPACE:
703 case InsetSpaceParams::QQUAD:
705 case InsetSpaceParams::THICK:
706 case InsetSpaceParams::QUAD:
709 case InsetSpaceParams::THIN:
712 case InsetSpaceParams::PROTECTED:
713 case InsetSpaceParams::MEDIUM:
714 case InsetSpaceParams::NEGTHIN:
715 case InsetSpaceParams::NEGMEDIUM:
716 case InsetSpaceParams::NEGTHICK:
719 case InsetSpaceParams::HFILL:
720 case InsetSpaceParams::HFILL_PROTECTED:
721 case InsetSpaceParams::DOTFILL:
722 case InsetSpaceParams::HRULEFILL:
723 case InsetSpaceParams::LEFTARROWFILL:
724 case InsetSpaceParams::RIGHTARROWFILL:
725 case InsetSpaceParams::UPBRACEFILL:
726 case InsetSpaceParams::DOWNBRACEFILL:
728 // Can we do anything with those in HTML?
730 case InsetSpaceParams::CUSTOM:
731 case InsetSpaceParams::CUSTOM_PROTECTED:
733 // Probably we could do some sort of blank span?
736 // don't escape the entities!
737 xs << XHTMLStream::NextRaw() << from_ascii(output);
742 void InsetSpace::validate(LaTeXFeatures & features) const
744 if (params_.kind == InsetSpaceParams::NEGMEDIUM ||
745 params_.kind == InsetSpaceParams::NEGTHICK)
746 features.require("amsmath");
750 void InsetSpace::tocString(odocstream & os) const
752 plaintext(os, OutputParams(0));
756 bool InsetSpace::isStretchableSpace() const
758 return params_.kind == InsetSpaceParams::HFILL
759 || params_.kind == InsetSpaceParams::HFILL_PROTECTED
760 || params_.kind == InsetSpaceParams::DOTFILL
761 || params_.kind == InsetSpaceParams::HRULEFILL
762 || params_.kind == InsetSpaceParams::LEFTARROWFILL
763 || params_.kind == InsetSpaceParams::RIGHTARROWFILL
764 || params_.kind == InsetSpaceParams::UPBRACEFILL
765 || params_.kind == InsetSpaceParams::DOWNBRACEFILL;
769 docstring InsetSpace::contextMenu(BufferView const &, int, int) const
771 return from_ascii("context-space");
775 void InsetSpace::string2params(string const & in, InsetSpaceParams & params)
777 params = InsetSpaceParams();
781 istringstream data(in);
784 lex.setContext("InsetSpace::string2params");
786 string const name = lex.getString();
787 if (name == "mathspace")
791 LASSERT(name == "space", /**/);
794 // There are cases, such as when we are called via getStatus() from
795 // Dialog::canApply(), where we are just called with "space" rather
796 // than a full "space \type{}\n\\end_inset".
802 string InsetSpace::params2string(InsetSpaceParams const & params)
807 data << "space" << ' ';