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 = _("QQuad 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:
147 string2params(to_utf8(cmd.argument()), params_);
150 case LFUN_INSET_DIALOG_UPDATE:
151 cur.bv().updateDialog("space", params2string(params()));
155 Inset::doDispatch(cur, cmd);
161 bool InsetSpace::getStatus(Cursor & cur, FuncRequest const & cmd,
162 FuncStatus & status) const
164 switch (cmd.action) {
166 case LFUN_INSET_MODIFY:
167 if (cmd.getArg(0) == "space") {
168 InsetSpaceParams params;
169 string2params(to_utf8(cmd.argument()), params);
170 status.setOnOff(params_.kind == params.kind);
173 case LFUN_INSET_DIALOG_UPDATE:
174 status.setEnabled(true);
177 return Inset::getStatus(cur, cmd, status);
183 int const arrow_size = 8;
187 void InsetSpace::metrics(MetricsInfo & mi, Dimension & dim) const
189 if (isStretchableSpace()) {
190 // The metrics for this kinds are calculated externally in
191 // \c TextMetrics::computeRowMetrics. Those are dummy value:
192 dim = Dimension(10, 10, 10);
196 frontend::FontMetrics const & fm = theFontMetrics(mi.base.font);
197 dim.asc = fm.maxAscent();
198 dim.des = fm.maxDescent();
200 switch (params_.kind) {
201 case InsetSpaceParams::THIN:
202 case InsetSpaceParams::NEGTHIN:
203 dim.wid = fm.width(char_type('M')) / 6;
205 case InsetSpaceParams::MEDIUM:
206 case InsetSpaceParams::NEGMEDIUM:
207 dim.wid = fm.width(char_type('M')) / 4;
209 case InsetSpaceParams::THICK:
210 case InsetSpaceParams::NEGTHICK:
211 dim.wid = fm.width(char_type('M')) / 2;
213 case InsetSpaceParams::PROTECTED:
214 case InsetSpaceParams::NORMAL:
215 dim.wid = fm.width(char_type(' '));
217 case InsetSpaceParams::QUAD:
218 dim.wid = fm.width(char_type('M'));
220 case InsetSpaceParams::QQUAD:
221 dim.wid = 2 * fm.width(char_type('M'));
223 case InsetSpaceParams::ENSPACE:
224 case InsetSpaceParams::ENSKIP:
225 dim.wid = int(0.5 * fm.width(char_type('M')));
227 case InsetSpaceParams::CUSTOM:
228 case InsetSpaceParams::CUSTOM_PROTECTED: {
230 params_.length.len().inPixels(mi.base.textwidth,
231 fm.width(char_type('M')));
232 int const minw = (w < 0) ? 3 * arrow_size : 4;
233 dim.wid = max(minw, abs(w));
236 case InsetSpaceParams::HFILL:
237 case InsetSpaceParams::HFILL_PROTECTED:
238 case InsetSpaceParams::DOTFILL:
239 case InsetSpaceParams::HRULEFILL:
240 case InsetSpaceParams::LEFTARROWFILL:
241 case InsetSpaceParams::RIGHTARROWFILL:
242 case InsetSpaceParams::UPBRACEFILL:
243 case InsetSpaceParams::DOWNBRACEFILL:
247 // Cache the inset dimension.
248 setDimCache(mi, dim);
252 void InsetSpace::draw(PainterInfo & pi, int x, int y) const
254 Dimension const dim = dimension(*pi.base.bv);
256 if (isStretchableSpace() || params_.length.len().value() < 0) {
257 int const asc = theFontMetrics(pi.base.font).ascent('M');
258 int const desc = theFontMetrics(pi.base.font).descent('M');
259 // Pixel height divisible by 2 for prettier fill graphics:
260 int const oddheight = (asc ^ desc) & 1;
261 int const x0 = x + 1;
262 int const x1 = x + dim.wid - 2;
263 int const y0 = y + desc - 1;
264 int const y1 = y - asc + oddheight - 1;
265 int const y2 = (y0 + y1) / 2;
266 int xoffset = (y0 - y1) / 2;
268 // Two tests for very narrow insets
269 if (xoffset > x1 - x0
270 && (params_.kind == InsetSpaceParams::LEFTARROWFILL
271 || params_.kind == InsetSpaceParams::RIGHTARROWFILL))
273 if (xoffset * 6 > (x1 - x0)
274 && (params_.kind == InsetSpaceParams::UPBRACEFILL
275 || params_.kind == InsetSpaceParams::DOWNBRACEFILL))
276 xoffset = (x1 - x0) / 6;
278 int const x2 = x0 + xoffset;
279 int const x3 = x1 - xoffset;
280 int const xm = (x0 + x1) / 2;
281 int const xml = xm - xoffset;
282 int const xmr = xm + xoffset;
284 if (params_.kind == InsetSpaceParams::HFILL) {
285 pi.pain.line(x0, y1, x0, y0, Color_added_space);
286 pi.pain.line(x0, y2, x1, y2, Color_added_space,
287 frontend::Painter::line_onoffdash);
288 pi.pain.line(x1, y1, x1, y0, Color_added_space);
289 } else if (params_.kind == InsetSpaceParams::HFILL_PROTECTED) {
290 pi.pain.line(x0, y1, x0, y0, Color_latex);
291 pi.pain.line(x0, y2, x1, y2, Color_latex,
292 frontend::Painter::line_onoffdash);
293 pi.pain.line(x1, y1, x1, y0, Color_latex);
294 } else if (params_.kind == InsetSpaceParams::DOTFILL) {
295 pi.pain.line(x0, y1, x0, y0, Color_special);
296 pi.pain.line(x0, y0, x1, y0, Color_special,
297 frontend::Painter::line_onoffdash);
298 pi.pain.line(x1, y1, x1, y0, Color_special);
299 } else if (params_.kind == InsetSpaceParams::HRULEFILL) {
300 pi.pain.line(x0, y1, x0, y0, Color_special);
301 pi.pain.line(x0, y0, x1, y0, Color_special);
302 pi.pain.line(x1, y1, x1, y0, Color_special);
303 } else if (params_.kind == InsetSpaceParams::LEFTARROWFILL) {
304 pi.pain.line(x2, y1 + 1 , x0 + 1, y2, Color_special);
305 pi.pain.line(x0 + 1, y2 + 1 , x2, y0, Color_special);
306 pi.pain.line(x0, y2 , x1, y2, Color_special);
307 } else if (params_.kind == InsetSpaceParams::RIGHTARROWFILL) {
308 pi.pain.line(x3 + 1, y1 + 1 , x1, y2, Color_special);
309 pi.pain.line(x1, y2 + 1 , x3 + 1, y0, Color_special);
310 pi.pain.line(x0, y2 , x1, y2, Color_special);
311 } else if (params_.kind == InsetSpaceParams::UPBRACEFILL) {
312 pi.pain.line(x0 + 1, y1 + 1 , x2, y2, Color_special);
313 pi.pain.line(x2, y2 , xml, y2, Color_special);
314 pi.pain.line(xml + 1, y2 + 1 , xm, y0, Color_special);
315 pi.pain.line(xm + 1, y0 , xmr, y2 + 1, Color_special);
316 pi.pain.line(xmr, y2 , x3, y2, Color_special);
317 pi.pain.line(x3 + 1, y2 , x1, y1 + 1, Color_special);
318 } else if (params_.kind == InsetSpaceParams::DOWNBRACEFILL) {
319 pi.pain.line(x0 + 1, y0 , x2, y2 + 1, Color_special);
320 pi.pain.line(x2, y2 , xml, y2, Color_special);
321 pi.pain.line(xml + 1, y2 , xm, y1 + 1, Color_special);
322 pi.pain.line(xm + 1, y1 + 1 , xmr, y2, Color_special);
323 pi.pain.line(xmr, y2 , x3, y2, Color_special);
324 pi.pain.line(x3 + 1, y2 + 1 , x1, y0, Color_special);
325 } else if (params_.kind == InsetSpaceParams::CUSTOM) {
326 pi.pain.line(x0, y1 + 1 , x2 + 1, y2, Color_special);
327 pi.pain.line(x2 + 1, y2 + 1 , x0, y0, Color_special);
328 pi.pain.line(x1 + 1, y1 + 1 , x3, y2, Color_special);
329 pi.pain.line(x3, y2 + 1 , x1 + 1, y0, Color_special);
330 pi.pain.line(x2, y2 , x3, y2, Color_special);
331 } else if (params_.kind == InsetSpaceParams::CUSTOM_PROTECTED) {
332 pi.pain.line(x0, y1 + 1 , x2 + 1, y2, Color_latex);
333 pi.pain.line(x2 + 1, y2 + 1 , x0, y0, Color_latex);
334 pi.pain.line(x1 + 1, y1 + 1 , x3, y2, Color_latex);
335 pi.pain.line(x3, y2 + 1 , x1 + 1, y0, Color_latex);
336 pi.pain.line(x2, y2 , x3, y2, Color_latex);
341 int const w = dim.wid;
342 int const h = theFontMetrics(pi.base.font).ascent('x');
346 yp[0] = y - max(h / 4, 1);
347 if (params_.kind == InsetSpaceParams::NORMAL ||
348 params_.kind == InsetSpaceParams::PROTECTED) {
349 xp[1] = x; yp[1] = y;
350 xp[2] = x + w; yp[2] = y;
352 xp[1] = x; yp[1] = y + max(h / 4, 1);
353 xp[2] = x + w; yp[2] = y + max(h / 4, 1);
356 yp[3] = y - max(h / 4, 1);
358 if (params_.kind == InsetSpaceParams::PROTECTED ||
359 params_.kind == InsetSpaceParams::ENSPACE ||
360 params_.kind == InsetSpaceParams::NEGTHIN ||
361 params_.kind == InsetSpaceParams::NEGMEDIUM ||
362 params_.kind == InsetSpaceParams::NEGTHICK ||
363 params_.kind == InsetSpaceParams::CUSTOM_PROTECTED)
364 pi.pain.lines(xp, yp, 4, Color_latex);
366 pi.pain.lines(xp, yp, 4, Color_special);
370 void InsetSpaceParams::write(ostream & os) const
374 case InsetSpaceParams::NORMAL:
377 case InsetSpaceParams::PROTECTED:
380 case InsetSpaceParams::THIN:
381 os << "\\thinspace{}";
383 case InsetSpaceParams::MEDIUM:
384 os << "\\medspace{}";
386 case InsetSpaceParams::THICK:
387 os << "\\thickspace{}";
389 case InsetSpaceParams::QUAD:
392 case InsetSpaceParams::QQUAD:
395 case InsetSpaceParams::ENSPACE:
398 case InsetSpaceParams::ENSKIP:
401 case InsetSpaceParams::NEGTHIN:
402 os << "\\negthinspace{}";
404 case InsetSpaceParams::NEGMEDIUM:
405 os << "\\negmedspace{}";
407 case InsetSpaceParams::NEGTHICK:
408 os << "\\negthickspace{}";
410 case InsetSpaceParams::HFILL:
413 case InsetSpaceParams::HFILL_PROTECTED:
414 os << "\\hspace*{\\fill}";
416 case InsetSpaceParams::DOTFILL:
419 case InsetSpaceParams::HRULEFILL:
420 os << "\\hrulefill{}";
422 case InsetSpaceParams::LEFTARROWFILL:
423 os << "\\leftarrowfill{}";
425 case InsetSpaceParams::RIGHTARROWFILL:
426 os << "\\rightarrowfill{}";
428 case InsetSpaceParams::UPBRACEFILL:
429 os << "\\upbracefill{}";
431 case InsetSpaceParams::DOWNBRACEFILL:
432 os << "\\downbracefill{}";
434 case InsetSpaceParams::CUSTOM:
437 case InsetSpaceParams::CUSTOM_PROTECTED:
442 if (!length.len().empty())
443 os << "\n\\length " << length.asString();
447 void InsetSpaceParams::read(Lexer & lex)
449 lex.setContext("InsetSpaceParams::read");
453 // The tests for math might be disabled after a file format change
454 if (command == "\\space{}")
455 kind = InsetSpaceParams::NORMAL;
456 else if (command == "~")
457 kind = InsetSpaceParams::PROTECTED;
458 else if (command == "\\thinspace{}")
459 kind = InsetSpaceParams::THIN;
460 else if (math && command == "\\medspace{}")
461 kind = InsetSpaceParams::MEDIUM;
462 else if (math && command == "\\thickspace{}")
463 kind = InsetSpaceParams::THICK;
464 else if (command == "\\quad{}")
465 kind = InsetSpaceParams::QUAD;
466 else if (command == "\\qquad{}")
467 kind = InsetSpaceParams::QQUAD;
468 else if (command == "\\enspace{}")
469 kind = InsetSpaceParams::ENSPACE;
470 else if (command == "\\enskip{}")
471 kind = InsetSpaceParams::ENSKIP;
472 else if (command == "\\negthinspace{}")
473 kind = InsetSpaceParams::NEGTHIN;
474 else if (math && command == "\\negmedspace{}")
475 kind = InsetSpaceParams::NEGMEDIUM;
476 else if (math && command == "\\negthickspace{}")
477 kind = InsetSpaceParams::NEGTHICK;
478 else if (command == "\\hfill{}")
479 kind = InsetSpaceParams::HFILL;
480 else if (command == "\\hspace*{\\fill}")
481 kind = InsetSpaceParams::HFILL_PROTECTED;
482 else if (command == "\\dotfill{}")
483 kind = InsetSpaceParams::DOTFILL;
484 else if (command == "\\hrulefill{}")
485 kind = InsetSpaceParams::HRULEFILL;
486 else if (command == "\\hspace{}")
487 kind = InsetSpaceParams::CUSTOM;
488 else if (command == "\\leftarrowfill{}")
489 kind = InsetSpaceParams::LEFTARROWFILL;
490 else if (command == "\\rightarrowfill{}")
491 kind = InsetSpaceParams::RIGHTARROWFILL;
492 else if (command == "\\upbracefill{}")
493 kind = InsetSpaceParams::UPBRACEFILL;
494 else if (command == "\\downbracefill{}")
495 kind = InsetSpaceParams::DOWNBRACEFILL;
496 else if (command == "\\hspace*{}")
497 kind = InsetSpaceParams::CUSTOM_PROTECTED;
499 lex.printError("InsetSpace: Unknown kind: `$$Token'");
501 if (lex.checkFor("\\length"))
506 void InsetSpace::write(ostream & os) const
513 void InsetSpace::read(Lexer & lex)
516 lex >> "\\end_inset";
520 int InsetSpace::latex(odocstream & os, OutputParams const & runparams) const
522 switch (params_.kind) {
523 case InsetSpaceParams::NORMAL:
524 os << (runparams.free_spacing ? " " : "\\ ");
526 case InsetSpaceParams::PROTECTED:
527 if (runparams.local_font &&
528 runparams.local_font->language()->lang() == "polutonikogreek")
529 // in babel's polutonikogreek, ~ is active
530 os << (runparams.free_spacing ? " " : "\\nobreakspace{}");
532 os << (runparams.free_spacing ? ' ' : '~');
534 case InsetSpaceParams::THIN:
535 os << (runparams.free_spacing ? " " : "\\,");
537 case InsetSpaceParams::MEDIUM:
538 os << (runparams.free_spacing ? " " : "\\:");
540 case InsetSpaceParams::THICK:
541 os << (runparams.free_spacing ? " " : "\\;");
543 case InsetSpaceParams::QUAD:
544 os << (runparams.free_spacing ? " " : "\\quad{}");
546 case InsetSpaceParams::QQUAD:
547 os << (runparams.free_spacing ? " " : "\\qquad{}");
549 case InsetSpaceParams::ENSPACE:
550 os << (runparams.free_spacing ? " " : "\\enspace{}");
552 case InsetSpaceParams::ENSKIP:
553 os << (runparams.free_spacing ? " " : "\\enskip{}");
555 case InsetSpaceParams::NEGTHIN:
556 os << (runparams.free_spacing ? " " : "\\negthinspace{}");
558 case InsetSpaceParams::NEGMEDIUM:
559 os << (runparams.free_spacing ? " " : "\\negmedspace{}");
561 case InsetSpaceParams::NEGTHICK:
562 os << (runparams.free_spacing ? " " : "\\negthickspace{}");
564 case InsetSpaceParams::HFILL:
565 os << (runparams.free_spacing ? " " : "\\hfill{}");
567 case InsetSpaceParams::HFILL_PROTECTED:
568 os << (runparams.free_spacing ? " " : "\\hspace*{\\fill}");
570 case InsetSpaceParams::DOTFILL:
571 os << (runparams.free_spacing ? " " : "\\dotfill{}");
573 case InsetSpaceParams::HRULEFILL:
574 os << (runparams.free_spacing ? " " : "\\hrulefill{}");
576 case InsetSpaceParams::LEFTARROWFILL:
577 os << (runparams.free_spacing ? " " : "\\leftarrowfill{}");
579 case InsetSpaceParams::RIGHTARROWFILL:
580 os << (runparams.free_spacing ? " " : "\\rightarrowfill{}");
582 case InsetSpaceParams::UPBRACEFILL:
583 os << (runparams.free_spacing ? " " : "\\upbracefill{}");
585 case InsetSpaceParams::DOWNBRACEFILL:
586 os << (runparams.free_spacing ? " " : "\\downbracefill{}");
588 case InsetSpaceParams::CUSTOM:
589 if (runparams.free_spacing)
592 os << "\\hspace{" << from_ascii(params_.length.asLatexString()) << "}";
594 case InsetSpaceParams::CUSTOM_PROTECTED:
595 if (runparams.free_spacing)
598 os << "\\hspace*{" << from_ascii(params_.length.asLatexString()) << "}";
605 int InsetSpace::plaintext(odocstream & os, OutputParams const &) const
607 switch (params_.kind) {
608 case InsetSpaceParams::HFILL:
609 case InsetSpaceParams::HFILL_PROTECTED:
612 case InsetSpaceParams::DOTFILL:
615 case InsetSpaceParams::HRULEFILL:
618 case InsetSpaceParams::LEFTARROWFILL:
621 case InsetSpaceParams::RIGHTARROWFILL:
624 case InsetSpaceParams::UPBRACEFILL:
627 case InsetSpaceParams::DOWNBRACEFILL:
637 int InsetSpace::docbook(odocstream & os, OutputParams const &) const
639 switch (params_.kind) {
640 case InsetSpaceParams::NORMAL:
641 case InsetSpaceParams::QUAD:
642 case InsetSpaceParams::QQUAD:
643 case InsetSpaceParams::ENSKIP:
646 case InsetSpaceParams::PROTECTED:
647 case InsetSpaceParams::ENSPACE:
648 case InsetSpaceParams::THIN:
649 case InsetSpaceParams::MEDIUM:
650 case InsetSpaceParams::THICK:
651 case InsetSpaceParams::NEGTHIN:
652 case InsetSpaceParams::NEGMEDIUM:
653 case InsetSpaceParams::NEGTHICK:
656 case InsetSpaceParams::HFILL:
657 case InsetSpaceParams::HFILL_PROTECTED:
659 case InsetSpaceParams::DOTFILL:
662 case InsetSpaceParams::HRULEFILL:
665 case InsetSpaceParams::LEFTARROWFILL:
666 case InsetSpaceParams::RIGHTARROWFILL:
667 case InsetSpaceParams::UPBRACEFILL:
668 case InsetSpaceParams::DOWNBRACEFILL:
669 case InsetSpaceParams::CUSTOM:
670 case InsetSpaceParams::CUSTOM_PROTECTED:
678 docstring InsetSpace::xhtml(XHTMLStream & xs, OutputParams const &) const
681 switch (params_.kind) {
682 case InsetSpaceParams::NORMAL:
685 case InsetSpaceParams::ENSKIP:
686 case InsetSpaceParams::ENSPACE:
689 case InsetSpaceParams::QQUAD:
691 case InsetSpaceParams::THICK:
692 case InsetSpaceParams::QUAD:
695 case InsetSpaceParams::THIN:
698 case InsetSpaceParams::PROTECTED:
699 case InsetSpaceParams::MEDIUM:
700 case InsetSpaceParams::NEGTHIN:
701 case InsetSpaceParams::NEGMEDIUM:
702 case InsetSpaceParams::NEGTHICK:
705 case InsetSpaceParams::HFILL:
706 case InsetSpaceParams::HFILL_PROTECTED:
707 case InsetSpaceParams::DOTFILL:
708 case InsetSpaceParams::HRULEFILL:
709 case InsetSpaceParams::LEFTARROWFILL:
710 case InsetSpaceParams::RIGHTARROWFILL:
711 case InsetSpaceParams::UPBRACEFILL:
712 case InsetSpaceParams::DOWNBRACEFILL:
714 // Can we do anything with those in HTML?
716 case InsetSpaceParams::CUSTOM:
717 case InsetSpaceParams::CUSTOM_PROTECTED:
719 // Probably we could do some sort of blank span?
722 // don't escape the entities!
723 xs << XHTMLStream::NextRaw() << from_ascii(output);
728 void InsetSpace::validate(LaTeXFeatures & features) const
730 if (params_.kind == InsetSpaceParams::NEGMEDIUM ||
731 params_.kind == InsetSpaceParams::NEGTHICK)
732 features.require("amsmath");
736 void InsetSpace::tocString(odocstream & os) const
738 plaintext(os, OutputParams(0));
742 bool InsetSpace::isStretchableSpace() const
744 return params_.kind == InsetSpaceParams::HFILL
745 || params_.kind == InsetSpaceParams::HFILL_PROTECTED
746 || params_.kind == InsetSpaceParams::DOTFILL
747 || params_.kind == InsetSpaceParams::HRULEFILL
748 || params_.kind == InsetSpaceParams::LEFTARROWFILL
749 || params_.kind == InsetSpaceParams::RIGHTARROWFILL
750 || params_.kind == InsetSpaceParams::UPBRACEFILL
751 || params_.kind == InsetSpaceParams::DOWNBRACEFILL;
755 docstring InsetSpace::contextMenu(BufferView const &, int, int) const
757 return from_ascii("context-space");
761 void InsetSpace::string2params(string const & in, InsetSpaceParams & params)
763 params = InsetSpaceParams();
767 istringstream data(in);
770 lex.setContext("InsetSpace::string2params");
772 string const name = lex.getString();
773 if (name == "mathspace")
777 LASSERT(name == "space", /**/);
780 // There are cases, such as when we are called via getStatus() from
781 // Dialog::canApply(), where we are just called with "space" rather
782 // than a full "space \type{}\n\\end_inset".
788 string InsetSpace::params2string(InsetSpaceParams const & params)
793 data << "space" << ' ';