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"
30 #include "support/debug.h"
31 #include "support/docstream.h"
32 #include "support/gettext.h"
33 #include "support/lassert.h"
34 #include "support/lstrings.h"
36 #include "frontends/Application.h"
37 #include "frontends/FontMetrics.h"
38 #include "frontends/Painter.h"
45 InsetSpace::InsetSpace(InsetSpaceParams const & params)
50 InsetSpaceParams::Kind InsetSpace::kind() const
56 Length InsetSpace::length() const
58 return params_.length;
62 InsetSpace::~InsetSpace()
64 hideDialogs("space", this);
68 docstring InsetSpace::toolTip(BufferView const &, int, int) const
71 switch (params_.kind) {
72 case InsetSpaceParams::NORMAL:
73 message = _("Interword Space");
75 case InsetSpaceParams::PROTECTED:
76 message = _("Protected Space");
78 case InsetSpaceParams::THIN:
79 message = _("Thin Space");
81 case InsetSpaceParams::MEDIUM:
82 message = _("Medium Space");
84 case InsetSpaceParams::THICK:
85 message = _("Thick Space");
87 case InsetSpaceParams::QUAD:
88 message = _("Quad Space");
90 case InsetSpaceParams::QQUAD:
91 message = _("QQuad Space");
93 case InsetSpaceParams::ENSPACE:
94 message = _("Enspace");
96 case InsetSpaceParams::ENSKIP:
97 message = _("Enskip");
99 case InsetSpaceParams::NEGTHIN:
100 message = _("Negative Thin Space");
102 case InsetSpaceParams::NEGMEDIUM:
103 message = _("Negative Medium Space");
105 case InsetSpaceParams::NEGTHICK:
106 message = _("Negative Thick Space");
108 case InsetSpaceParams::HFILL:
109 message = _("Horizontal Fill");
111 case InsetSpaceParams::HFILL_PROTECTED:
112 message = _("Protected Horizontal Fill");
114 case InsetSpaceParams::DOTFILL:
115 message = _("Horizontal Fill (Dots)");
117 case InsetSpaceParams::HRULEFILL:
118 message = _("Horizontal Fill (Rule)");
120 case InsetSpaceParams::LEFTARROWFILL:
121 message = _("Horizontal Fill (Left Arrow)");
123 case InsetSpaceParams::RIGHTARROWFILL:
124 message = _("Horizontal Fill (Right Arrow)");
126 case InsetSpaceParams::UPBRACEFILL:
127 message = _("Horizontal Fill (Up Brace)");
129 case InsetSpaceParams::DOWNBRACEFILL:
130 message = _("Horizontal Fill (Down Brace)");
132 case InsetSpaceParams::CUSTOM:
133 message = support::bformat(_("Horizontal Space (%1$s)"),
134 params_.length.asDocstring());
136 case InsetSpaceParams::CUSTOM_PROTECTED:
137 message = support::bformat(_("Protected Horizontal Space (%1$s)"),
138 params_.length.asDocstring());
145 void InsetSpace::doDispatch(Cursor & cur, FuncRequest & cmd)
147 switch (cmd.action) {
149 case LFUN_INSET_MODIFY:
150 string2params(to_utf8(cmd.argument()), params_);
153 case LFUN_INSET_DIALOG_UPDATE:
154 cur.bv().updateDialog("space", params2string(params()));
158 Inset::doDispatch(cur, cmd);
164 bool InsetSpace::getStatus(Cursor & cur, FuncRequest const & cmd,
165 FuncStatus & status) const
167 switch (cmd.action) {
169 case LFUN_INSET_MODIFY:
170 if (cmd.getArg(0) == "space") {
171 InsetSpaceParams params;
172 string2params(to_utf8(cmd.argument()), params);
173 status.setOnOff(params_.kind == params.kind);
176 case LFUN_INSET_DIALOG_UPDATE:
177 status.setEnabled(true);
180 return Inset::getStatus(cur, cmd, status);
185 bool InsetSpace::showInsetDialog(BufferView * bv) const
187 bv->showDialog("space", params2string(params()),
188 const_cast<InsetSpace *>(this));
194 int const arrow_size = 8;
198 void InsetSpace::metrics(MetricsInfo & mi, Dimension & dim) const
200 if (isStretchableSpace()) {
201 // The metrics for this kinds are calculated externally in
202 // \c TextMetrics::computeRowMetrics. Those are dummy value:
203 dim = Dimension(10, 10, 10);
207 frontend::FontMetrics const & fm = theFontMetrics(mi.base.font);
208 dim.asc = fm.maxAscent();
209 dim.des = fm.maxDescent();
211 switch (params_.kind) {
212 case InsetSpaceParams::THIN:
213 case InsetSpaceParams::NEGTHIN:
214 dim.wid = fm.width(char_type('M')) / 6;
216 case InsetSpaceParams::MEDIUM:
217 case InsetSpaceParams::NEGMEDIUM:
218 dim.wid = fm.width(char_type('M')) / 4;
220 case InsetSpaceParams::THICK:
221 case InsetSpaceParams::NEGTHICK:
222 dim.wid = fm.width(char_type('M')) / 2;
224 case InsetSpaceParams::PROTECTED:
225 case InsetSpaceParams::NORMAL:
226 dim.wid = fm.width(char_type(' '));
228 case InsetSpaceParams::QUAD:
229 dim.wid = fm.width(char_type('M'));
231 case InsetSpaceParams::QQUAD:
232 dim.wid = 2 * fm.width(char_type('M'));
234 case InsetSpaceParams::ENSPACE:
235 case InsetSpaceParams::ENSKIP:
236 dim.wid = int(0.5 * fm.width(char_type('M')));
238 case InsetSpaceParams::CUSTOM:
239 case InsetSpaceParams::CUSTOM_PROTECTED: {
241 params_.length.inPixels(mi.base.textwidth,
242 fm.width(char_type('M')));
243 int const minw = (w < 0) ? 3 * arrow_size : 4;
244 dim.wid = max(minw, abs(w));
247 case InsetSpaceParams::HFILL:
248 case InsetSpaceParams::HFILL_PROTECTED:
249 case InsetSpaceParams::DOTFILL:
250 case InsetSpaceParams::HRULEFILL:
251 case InsetSpaceParams::LEFTARROWFILL:
252 case InsetSpaceParams::RIGHTARROWFILL:
253 case InsetSpaceParams::UPBRACEFILL:
254 case InsetSpaceParams::DOWNBRACEFILL:
258 // Cache the inset dimension.
259 setDimCache(mi, dim);
263 void InsetSpace::draw(PainterInfo & pi, int x, int y) const
265 Dimension const dim = dimension(*pi.base.bv);
267 if (isStretchableSpace() || params_.length.value() < 0) {
268 int const asc = theFontMetrics(pi.base.font).ascent('M');
269 int const desc = theFontMetrics(pi.base.font).descent('M');
270 // Pixel height divisible by 2 for prettier fill graphics:
271 int const oddheight = (asc ^ desc) & 1;
272 int const x0 = x + 1;
273 int const x1 = x + dim.wid - 2;
274 int const y0 = y + desc - 1;
275 int const y1 = y - asc + oddheight - 1;
276 int const y2 = (y0 + y1) / 2;
277 int xoffset = (y0 - y1) / 2;
279 // Two tests for very narrow insets
280 if (xoffset > x1 - x0
281 && (params_.kind == InsetSpaceParams::LEFTARROWFILL
282 || params_.kind == InsetSpaceParams::RIGHTARROWFILL))
284 if (xoffset * 6 > (x1 - x0)
285 && (params_.kind == InsetSpaceParams::UPBRACEFILL
286 || params_.kind == InsetSpaceParams::DOWNBRACEFILL))
287 xoffset = (x1 - x0) / 6;
289 int const x2 = x0 + xoffset;
290 int const x3 = x1 - xoffset;
291 int const xm = (x0 + x1) / 2;
292 int const xml = xm - xoffset;
293 int const xmr = xm + xoffset;
295 if (params_.kind == InsetSpaceParams::HFILL) {
296 pi.pain.line(x0, y1, x0, y0, Color_added_space);
297 pi.pain.line(x0, y2, x1, y2, Color_added_space,
298 frontend::Painter::line_onoffdash);
299 pi.pain.line(x1, y1, x1, y0, Color_added_space);
300 } else if (params_.kind == InsetSpaceParams::HFILL_PROTECTED) {
301 pi.pain.line(x0, y1, x0, y0, Color_latex);
302 pi.pain.line(x0, y2, x1, y2, Color_latex,
303 frontend::Painter::line_onoffdash);
304 pi.pain.line(x1, y1, x1, y0, Color_latex);
305 } else if (params_.kind == InsetSpaceParams::DOTFILL) {
306 pi.pain.line(x0, y1, x0, y0, Color_special);
307 pi.pain.line(x0, y0, x1, y0, Color_special,
308 frontend::Painter::line_onoffdash);
309 pi.pain.line(x1, y1, x1, y0, Color_special);
310 } else if (params_.kind == InsetSpaceParams::HRULEFILL) {
311 pi.pain.line(x0, y1, x0, y0, Color_special);
312 pi.pain.line(x0, y0, x1, y0, Color_special);
313 pi.pain.line(x1, y1, x1, y0, Color_special);
314 } else if (params_.kind == InsetSpaceParams::LEFTARROWFILL) {
315 pi.pain.line(x2, y1 + 1 , x0 + 1, y2, Color_special);
316 pi.pain.line(x0 + 1, y2 + 1 , x2, y0, Color_special);
317 pi.pain.line(x0, y2 , x1, y2, Color_special);
318 } else if (params_.kind == InsetSpaceParams::RIGHTARROWFILL) {
319 pi.pain.line(x3 + 1, y1 + 1 , x1, y2, Color_special);
320 pi.pain.line(x1, y2 + 1 , x3 + 1, y0, Color_special);
321 pi.pain.line(x0, y2 , x1, y2, Color_special);
322 } else if (params_.kind == InsetSpaceParams::UPBRACEFILL) {
323 pi.pain.line(x0 + 1, y1 + 1 , x2, y2, Color_special);
324 pi.pain.line(x2, y2 , xml, y2, Color_special);
325 pi.pain.line(xml + 1, y2 + 1 , xm, y0, Color_special);
326 pi.pain.line(xm + 1, y0 , xmr, y2 + 1, Color_special);
327 pi.pain.line(xmr, y2 , x3, y2, Color_special);
328 pi.pain.line(x3 + 1, y2 , x1, y1 + 1, Color_special);
329 } else if (params_.kind == InsetSpaceParams::DOWNBRACEFILL) {
330 pi.pain.line(x0 + 1, y0 , x2, y2 + 1, Color_special);
331 pi.pain.line(x2, y2 , xml, y2, Color_special);
332 pi.pain.line(xml + 1, y2 , xm, y1 + 1, Color_special);
333 pi.pain.line(xm + 1, y1 + 1 , xmr, y2, Color_special);
334 pi.pain.line(xmr, y2 , x3, y2, Color_special);
335 pi.pain.line(x3 + 1, y2 + 1 , x1, y0, Color_special);
336 } else if (params_.kind == InsetSpaceParams::CUSTOM) {
337 pi.pain.line(x0, y1 + 1 , x2 + 1, y2, Color_special);
338 pi.pain.line(x2 + 1, y2 + 1 , x0, y0, Color_special);
339 pi.pain.line(x1 + 1, y1 + 1 , x3, y2, Color_special);
340 pi.pain.line(x3, y2 + 1 , x1 + 1, y0, Color_special);
341 pi.pain.line(x2, y2 , x3, y2, Color_special);
342 } else if (params_.kind == InsetSpaceParams::CUSTOM_PROTECTED) {
343 pi.pain.line(x0, y1 + 1 , x2 + 1, y2, Color_latex);
344 pi.pain.line(x2 + 1, y2 + 1 , x0, y0, Color_latex);
345 pi.pain.line(x1 + 1, y1 + 1 , x3, y2, Color_latex);
346 pi.pain.line(x3, y2 + 1 , x1 + 1, y0, Color_latex);
347 pi.pain.line(x2, y2 , x3, y2, Color_latex);
352 int const w = dim.wid;
353 int const h = theFontMetrics(pi.base.font).ascent('x');
357 yp[0] = y - max(h / 4, 1);
358 if (params_.kind == InsetSpaceParams::NORMAL ||
359 params_.kind == InsetSpaceParams::PROTECTED) {
360 xp[1] = x; yp[1] = y;
361 xp[2] = x + w; yp[2] = y;
363 xp[1] = x; yp[1] = y + max(h / 4, 1);
364 xp[2] = x + w; yp[2] = y + max(h / 4, 1);
367 yp[3] = y - max(h / 4, 1);
369 if (params_.kind == InsetSpaceParams::PROTECTED ||
370 params_.kind == InsetSpaceParams::ENSPACE ||
371 params_.kind == InsetSpaceParams::NEGTHIN ||
372 params_.kind == InsetSpaceParams::NEGMEDIUM ||
373 params_.kind == InsetSpaceParams::NEGTHICK ||
374 params_.kind == InsetSpaceParams::CUSTOM_PROTECTED)
375 pi.pain.lines(xp, yp, 4, Color_latex);
377 pi.pain.lines(xp, yp, 4, Color_special);
381 void InsetSpaceParams::write(ostream & os) const
385 case InsetSpaceParams::NORMAL:
388 case InsetSpaceParams::PROTECTED:
391 case InsetSpaceParams::THIN:
392 os << "\\thinspace{}";
394 case InsetSpaceParams::MEDIUM:
395 os << "\\medspace{}";
397 case InsetSpaceParams::THICK:
398 os << "\\thickspace{}";
400 case InsetSpaceParams::QUAD:
403 case InsetSpaceParams::QQUAD:
406 case InsetSpaceParams::ENSPACE:
409 case InsetSpaceParams::ENSKIP:
412 case InsetSpaceParams::NEGTHIN:
413 os << "\\negthinspace{}";
415 case InsetSpaceParams::NEGMEDIUM:
416 os << "\\negmedspace{}";
418 case InsetSpaceParams::NEGTHICK:
419 os << "\\negthickspace{}";
421 case InsetSpaceParams::HFILL:
424 case InsetSpaceParams::HFILL_PROTECTED:
425 os << "\\hspace*{\\fill}";
427 case InsetSpaceParams::DOTFILL:
430 case InsetSpaceParams::HRULEFILL:
431 os << "\\hrulefill{}";
433 case InsetSpaceParams::LEFTARROWFILL:
434 os << "\\leftarrowfill{}";
436 case InsetSpaceParams::RIGHTARROWFILL:
437 os << "\\rightarrowfill{}";
439 case InsetSpaceParams::UPBRACEFILL:
440 os << "\\upbracefill{}";
442 case InsetSpaceParams::DOWNBRACEFILL:
443 os << "\\downbracefill{}";
445 case InsetSpaceParams::CUSTOM:
448 case InsetSpaceParams::CUSTOM_PROTECTED:
454 os << "\n\\length " << length.asString();
458 void InsetSpaceParams::read(Lexer & lex)
460 lex.setContext("InsetSpaceParams::read");
464 // The tests for math might be disabled after a file format change
465 if (command == "\\space{}")
466 kind = InsetSpaceParams::NORMAL;
467 else if (command == "~")
468 kind = InsetSpaceParams::PROTECTED;
469 else if (command == "\\thinspace{}")
470 kind = InsetSpaceParams::THIN;
471 else if (math && command == "\\medspace{}")
472 kind = InsetSpaceParams::MEDIUM;
473 else if (math && command == "\\thickspace{}")
474 kind = InsetSpaceParams::THICK;
475 else if (command == "\\quad{}")
476 kind = InsetSpaceParams::QUAD;
477 else if (command == "\\qquad{}")
478 kind = InsetSpaceParams::QQUAD;
479 else if (command == "\\enspace{}")
480 kind = InsetSpaceParams::ENSPACE;
481 else if (command == "\\enskip{}")
482 kind = InsetSpaceParams::ENSKIP;
483 else if (command == "\\negthinspace{}")
484 kind = InsetSpaceParams::NEGTHIN;
485 else if (math && command == "\\negmedspace{}")
486 kind = InsetSpaceParams::NEGMEDIUM;
487 else if (math && command == "\\negthickspace{}")
488 kind = InsetSpaceParams::NEGTHICK;
489 else if (command == "\\hfill{}")
490 kind = InsetSpaceParams::HFILL;
491 else if (command == "\\hspace*{\\fill}")
492 kind = InsetSpaceParams::HFILL_PROTECTED;
493 else if (command == "\\dotfill{}")
494 kind = InsetSpaceParams::DOTFILL;
495 else if (command == "\\hrulefill{}")
496 kind = InsetSpaceParams::HRULEFILL;
497 else if (command == "\\hspace{}")
498 kind = InsetSpaceParams::CUSTOM;
499 else if (command == "\\leftarrowfill{}")
500 kind = InsetSpaceParams::LEFTARROWFILL;
501 else if (command == "\\rightarrowfill{}")
502 kind = InsetSpaceParams::RIGHTARROWFILL;
503 else if (command == "\\upbracefill{}")
504 kind = InsetSpaceParams::UPBRACEFILL;
505 else if (command == "\\downbracefill{}")
506 kind = InsetSpaceParams::DOWNBRACEFILL;
507 else if (command == "\\hspace*{}")
508 kind = InsetSpaceParams::CUSTOM_PROTECTED;
510 lex.printError("InsetSpace: Unknown kind: `$$Token'");
512 if (lex.checkFor("\\length"))
517 void InsetSpace::write(ostream & os) const
524 void InsetSpace::read(Lexer & lex)
527 lex >> "\\end_inset";
531 int InsetSpace::latex(odocstream & os, OutputParams const & runparams) const
533 switch (params_.kind) {
534 case InsetSpaceParams::NORMAL:
535 os << (runparams.free_spacing ? " " : "\\ ");
537 case InsetSpaceParams::PROTECTED:
538 if (runparams.local_font->language()->lang() == "polutonikogreek")
539 // in babel's polutonikogreek, ~ is active
540 os << (runparams.free_spacing ? " " : "\\nobreakspace{}");
542 os << (runparams.free_spacing ? ' ' : '~');
544 case InsetSpaceParams::THIN:
545 os << (runparams.free_spacing ? " " : "\\,");
547 case InsetSpaceParams::MEDIUM:
548 os << (runparams.free_spacing ? " " : "\\:");
550 case InsetSpaceParams::THICK:
551 os << (runparams.free_spacing ? " " : "\\;");
553 case InsetSpaceParams::QUAD:
554 os << (runparams.free_spacing ? " " : "\\quad{}");
556 case InsetSpaceParams::QQUAD:
557 os << (runparams.free_spacing ? " " : "\\qquad{}");
559 case InsetSpaceParams::ENSPACE:
560 os << (runparams.free_spacing ? " " : "\\enspace{}");
562 case InsetSpaceParams::ENSKIP:
563 os << (runparams.free_spacing ? " " : "\\enskip{}");
565 case InsetSpaceParams::NEGTHIN:
566 os << (runparams.free_spacing ? " " : "\\negthinspace{}");
568 case InsetSpaceParams::NEGMEDIUM:
569 os << (runparams.free_spacing ? " " : "\\negmedspace{}");
571 case InsetSpaceParams::NEGTHICK:
572 os << (runparams.free_spacing ? " " : "\\negthickspace{}");
574 case InsetSpaceParams::HFILL:
575 os << (runparams.free_spacing ? " " : "\\hfill{}");
577 case InsetSpaceParams::HFILL_PROTECTED:
578 os << (runparams.free_spacing ? " " : "\\hspace*{\\fill}");
580 case InsetSpaceParams::DOTFILL:
581 os << (runparams.free_spacing ? " " : "\\dotfill{}");
583 case InsetSpaceParams::HRULEFILL:
584 os << (runparams.free_spacing ? " " : "\\hrulefill{}");
586 case InsetSpaceParams::LEFTARROWFILL:
587 os << (runparams.free_spacing ? " " : "\\leftarrowfill{}");
589 case InsetSpaceParams::RIGHTARROWFILL:
590 os << (runparams.free_spacing ? " " : "\\rightarrowfill{}");
592 case InsetSpaceParams::UPBRACEFILL:
593 os << (runparams.free_spacing ? " " : "\\upbracefill{}");
595 case InsetSpaceParams::DOWNBRACEFILL:
596 os << (runparams.free_spacing ? " " : "\\downbracefill{}");
598 case InsetSpaceParams::CUSTOM:
599 if (runparams.free_spacing)
602 os << "\\hspace{" << from_ascii(params_.length.asLatexString()) << "}";
604 case InsetSpaceParams::CUSTOM_PROTECTED:
605 if (runparams.free_spacing)
608 os << "\\hspace*{" << from_ascii(params_.length.asLatexString()) << "}";
615 int InsetSpace::plaintext(odocstream & os, OutputParams const &) const
617 switch (params_.kind) {
618 case InsetSpaceParams::HFILL:
619 case InsetSpaceParams::HFILL_PROTECTED:
622 case InsetSpaceParams::DOTFILL:
625 case InsetSpaceParams::HRULEFILL:
628 case InsetSpaceParams::LEFTARROWFILL:
631 case InsetSpaceParams::RIGHTARROWFILL:
634 case InsetSpaceParams::UPBRACEFILL:
637 case InsetSpaceParams::DOWNBRACEFILL:
647 int InsetSpace::docbook(odocstream & os, OutputParams const &) const
649 switch (params_.kind) {
650 case InsetSpaceParams::NORMAL:
651 case InsetSpaceParams::QUAD:
652 case InsetSpaceParams::QQUAD:
653 case InsetSpaceParams::ENSKIP:
656 case InsetSpaceParams::PROTECTED:
657 case InsetSpaceParams::ENSPACE:
658 case InsetSpaceParams::THIN:
659 case InsetSpaceParams::MEDIUM:
660 case InsetSpaceParams::THICK:
661 case InsetSpaceParams::NEGTHIN:
662 case InsetSpaceParams::NEGMEDIUM:
663 case InsetSpaceParams::NEGTHICK:
666 case InsetSpaceParams::HFILL:
667 case InsetSpaceParams::HFILL_PROTECTED:
669 case InsetSpaceParams::DOTFILL:
672 case InsetSpaceParams::HRULEFILL:
675 case InsetSpaceParams::LEFTARROWFILL:
676 case InsetSpaceParams::RIGHTARROWFILL:
677 case InsetSpaceParams::UPBRACEFILL:
678 case InsetSpaceParams::DOWNBRACEFILL:
679 case InsetSpaceParams::CUSTOM:
680 case InsetSpaceParams::CUSTOM_PROTECTED:
688 docstring InsetSpace::xhtml(odocstream & os, OutputParams const &) const
690 switch (params_.kind) {
691 case InsetSpaceParams::NORMAL:
694 case InsetSpaceParams::ENSKIP:
695 case InsetSpaceParams::ENSPACE:
698 case InsetSpaceParams::QQUAD:
700 case InsetSpaceParams::THICK:
701 case InsetSpaceParams::QUAD:
704 case InsetSpaceParams::THIN:
707 case InsetSpaceParams::PROTECTED:
708 case InsetSpaceParams::MEDIUM:
709 case InsetSpaceParams::NEGTHIN:
710 case InsetSpaceParams::NEGMEDIUM:
711 case InsetSpaceParams::NEGTHICK:
714 case InsetSpaceParams::HFILL:
715 case InsetSpaceParams::HFILL_PROTECTED:
716 case InsetSpaceParams::DOTFILL:
717 case InsetSpaceParams::HRULEFILL:
718 case InsetSpaceParams::LEFTARROWFILL:
719 case InsetSpaceParams::RIGHTARROWFILL:
720 case InsetSpaceParams::UPBRACEFILL:
721 case InsetSpaceParams::DOWNBRACEFILL:
722 // FIXME Can we do anything with those in HTML?
725 case InsetSpaceParams::CUSTOM:
726 case InsetSpaceParams::CUSTOM_PROTECTED:
727 // FIXME Probably we could do some sort of blank span?
734 void InsetSpace::validate(LaTeXFeatures & features) const
736 if (params_.kind == InsetSpaceParams::NEGMEDIUM ||
737 params_.kind == InsetSpaceParams::NEGTHICK)
738 features.require("amsmath");
742 void InsetSpace::tocString(odocstream & os) const
744 plaintext(os, OutputParams(0));
748 bool InsetSpace::isStretchableSpace() const
750 return params_.kind == InsetSpaceParams::HFILL
751 || params_.kind == InsetSpaceParams::HFILL_PROTECTED
752 || params_.kind == InsetSpaceParams::DOTFILL
753 || params_.kind == InsetSpaceParams::HRULEFILL
754 || params_.kind == InsetSpaceParams::LEFTARROWFILL
755 || params_.kind == InsetSpaceParams::RIGHTARROWFILL
756 || params_.kind == InsetSpaceParams::UPBRACEFILL
757 || params_.kind == InsetSpaceParams::DOWNBRACEFILL;
761 docstring InsetSpace::contextMenu(BufferView const &, int, int) const
763 return from_ascii("context-space");
767 void InsetSpace::string2params(string const & in, InsetSpaceParams & params)
769 params = InsetSpaceParams();
773 istringstream data(in);
776 lex.setContext("InsetSpace::string2params");
778 string const name = lex.getString();
779 if (name == "mathspace")
783 LASSERT(name == "space", /**/);
786 // There are cases, such as when we are called via getStatus() from
787 // Dialog::canApply(), where we are just called with "space" rather
788 // than a full "space \type{}\n\\end_inset".
794 string InsetSpace::params2string(InsetSpaceParams const & params)
799 data << "space" << ' ';