2002-09-25 14:26:13 +00:00
|
|
|
/**
|
2007-04-25 01:24:38 +00:00
|
|
|
* \file InsetSpecialChar.cpp
|
2002-09-25 14:26:13 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
2002-03-21 17:09:55 +00:00
|
|
|
*
|
2002-09-25 14:26:13 +00:00
|
|
|
* \author Asger Alstrup Nielsen
|
|
|
|
* \author Jean-Marc Lasgouttes
|
2008-11-14 15:58:50 +00:00
|
|
|
* \author Lars Gullik Bjønnes
|
2002-03-21 17:09:55 +00:00
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
* Full author contact details are available in file CREDITS.
|
2002-09-25 14:26:13 +00:00
|
|
|
*/
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
2007-04-25 01:24:38 +00:00
|
|
|
#include "InsetSpecialChar.h"
|
2003-05-19 17:03:12 +00:00
|
|
|
|
2007-11-01 22:17:22 +00:00
|
|
|
#include "Dimension.h"
|
2009-01-11 08:31:52 +00:00
|
|
|
#include "Font.h"
|
1999-09-27 18:44:28 +00:00
|
|
|
#include "LaTeXFeatures.h"
|
2007-04-26 11:30:54 +00:00
|
|
|
#include "Lexer.h"
|
2007-04-26 04:41:58 +00:00
|
|
|
#include "MetricsInfo.h"
|
2009-11-25 22:04:41 +00:00
|
|
|
#include "output_xhtml.h"
|
2000-02-17 19:59:08 +00:00
|
|
|
|
2006-10-07 16:15:06 +00:00
|
|
|
#include "frontends/FontMetrics.h"
|
2003-09-05 09:01:27 +00:00
|
|
|
#include "frontends/Painter.h"
|
|
|
|
|
2008-02-18 07:14:42 +00:00
|
|
|
#include "support/debug.h"
|
2007-11-28 22:12:03 +00:00
|
|
|
#include "support/docstream.h"
|
2006-10-21 00:16:43 +00:00
|
|
|
|
2007-12-12 10:16:00 +00:00
|
|
|
using namespace std;
|
2003-10-06 15:43:21 +00:00
|
|
|
|
2007-12-12 10:16:00 +00:00
|
|
|
namespace lyx {
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2003-05-19 17:03:12 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
InsetSpecialChar::InsetSpecialChar(Kind k)
|
2009-11-08 15:53:21 +00:00
|
|
|
: Inset(0), kind_(k)
|
1999-11-22 16:19:48 +00:00
|
|
|
{}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
2001-07-23 09:11:14 +00:00
|
|
|
InsetSpecialChar::Kind InsetSpecialChar::kind() const
|
|
|
|
{
|
|
|
|
return kind_;
|
|
|
|
}
|
|
|
|
|
2003-03-11 15:01:29 +00:00
|
|
|
|
2015-03-13 11:05:15 +00:00
|
|
|
namespace {
|
|
|
|
|
|
|
|
int logoWidth(FontInfo const & font, InsetSpecialChar::Kind kind) {
|
|
|
|
frontend::FontMetrics const & fm = theFontMetrics(font);
|
2015-03-18 10:32:49 +00:00
|
|
|
int const em = fm.width('M');
|
2015-03-13 11:05:15 +00:00
|
|
|
int width = 0;
|
2015-03-15 17:21:01 +00:00
|
|
|
// See drawlogo() below to understand what this does.
|
2015-03-13 11:05:15 +00:00
|
|
|
switch (kind) {
|
|
|
|
case InsetSpecialChar::PHRASE_LYX:
|
2015-03-18 10:32:49 +00:00
|
|
|
width = fm.width(from_ascii("L")) - em / 6
|
|
|
|
+ fm.width(from_ascii("Y")) - em / 8
|
2015-03-13 11:05:15 +00:00
|
|
|
+ fm.width(from_ascii("X"));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case InsetSpecialChar::PHRASE_TEX:
|
2015-03-18 10:32:49 +00:00
|
|
|
width = fm.width(from_ascii("T")) - em / 6
|
|
|
|
+ fm.width(from_ascii("E")) - em / 8
|
2015-03-13 11:05:15 +00:00
|
|
|
+ fm.width(from_ascii("X"));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case InsetSpecialChar::PHRASE_LATEX2E:
|
|
|
|
width = logoWidth(font, InsetSpecialChar::PHRASE_LATEX)
|
2015-03-18 10:32:49 +00:00
|
|
|
+ 3 * em / 20
|
2015-03-13 11:05:15 +00:00
|
|
|
+ fm.width(from_ascii("2") + char_type(0x03b5));
|
|
|
|
break;
|
|
|
|
case InsetSpecialChar::PHRASE_LATEX: {
|
|
|
|
FontInfo smaller = font;
|
|
|
|
smaller.decSize().decSize();
|
2015-03-18 10:32:49 +00:00
|
|
|
width = fm.width(from_ascii("L")) - 9 * em / 25
|
|
|
|
+ theFontMetrics(smaller).width(from_ascii("A")) - 3 * em / 20
|
2015-03-13 11:05:15 +00:00
|
|
|
+ logoWidth(font, InsetSpecialChar::PHRASE_TEX);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
LYXERR0("No information for computing width of logo " << kind);
|
|
|
|
}
|
|
|
|
|
|
|
|
return width;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-09-21 20:39:47 +00:00
|
|
|
void InsetSpecialChar::metrics(MetricsInfo & mi, Dimension & dim) const
|
2000-02-10 17:53:36 +00:00
|
|
|
{
|
2006-10-21 00:16:43 +00:00
|
|
|
frontend::FontMetrics const & fm =
|
2006-10-11 17:24:46 +00:00
|
|
|
theFontMetrics(mi.base.font);
|
2006-10-07 16:15:06 +00:00
|
|
|
dim.asc = fm.maxAscent();
|
|
|
|
dim.des = fm.maxDescent();
|
2015-03-13 11:05:15 +00:00
|
|
|
dim.wid = 0;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2015-03-01 10:16:57 +00:00
|
|
|
docstring s;
|
2001-07-23 09:11:14 +00:00
|
|
|
switch (kind_) {
|
2007-12-06 11:04:56 +00:00
|
|
|
case LIGATURE_BREAK:
|
2015-03-01 10:16:57 +00:00
|
|
|
s = from_ascii("|");
|
2007-12-06 11:04:56 +00:00
|
|
|
break;
|
|
|
|
case END_OF_SENTENCE:
|
2015-03-01 10:16:57 +00:00
|
|
|
s = from_ascii(".");
|
2007-12-06 11:04:56 +00:00
|
|
|
break;
|
|
|
|
case LDOTS:
|
2015-03-01 10:16:57 +00:00
|
|
|
s = from_ascii(". . .");
|
2007-12-06 11:04:56 +00:00
|
|
|
break;
|
|
|
|
case MENU_SEPARATOR:
|
2015-03-01 10:16:57 +00:00
|
|
|
s = from_ascii(" x ");
|
2007-12-06 11:04:56 +00:00
|
|
|
break;
|
|
|
|
case HYPHENATION:
|
2015-03-13 11:05:15 +00:00
|
|
|
dim.wid = fm.width(from_ascii("-"));
|
|
|
|
if (dim.wid > 5)
|
|
|
|
dim.wid -= 2; // to make it look shorter
|
2007-12-06 11:04:56 +00:00
|
|
|
break;
|
|
|
|
case SLASH:
|
2015-03-01 10:16:57 +00:00
|
|
|
s = from_ascii("/");
|
2007-12-06 11:04:56 +00:00
|
|
|
break;
|
|
|
|
case NOBREAKDASH:
|
2015-03-01 10:16:57 +00:00
|
|
|
s = from_ascii("-");
|
|
|
|
break;
|
|
|
|
case PHRASE_LYX:
|
|
|
|
case PHRASE_TEX:
|
|
|
|
case PHRASE_LATEX2E:
|
|
|
|
case PHRASE_LATEX:
|
2015-03-13 11:05:15 +00:00
|
|
|
dim.wid = logoWidth(mi.base.font, kind_);
|
2007-12-06 11:04:56 +00:00
|
|
|
break;
|
2000-02-10 17:53:36 +00:00
|
|
|
}
|
2015-03-13 11:05:15 +00:00
|
|
|
if (dim.wid == 0)
|
|
|
|
dim.wid = fm.width(s);
|
|
|
|
|
2007-09-23 22:39:49 +00:00
|
|
|
setDimCache(mi, dim);
|
2000-02-10 17:53:36 +00:00
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
2015-03-13 11:05:15 +00:00
|
|
|
namespace {
|
|
|
|
|
|
|
|
void drawLogo(PainterInfo & pi, InsetSpecialChar::Kind kind, int & x, int & y) {
|
|
|
|
FontInfo const & font = pi.base.font;
|
|
|
|
// FIXME: this definition of em is bogus, but there is a need
|
|
|
|
// for a big refactoring of the code around this issue anyway.
|
2015-03-18 10:32:49 +00:00
|
|
|
int const em = theFontMetrics(font).width('M');
|
2015-03-13 11:05:15 +00:00
|
|
|
switch (kind) {
|
|
|
|
case InsetSpecialChar::PHRASE_LYX:
|
2015-03-15 17:21:01 +00:00
|
|
|
/** Reference macro:
|
|
|
|
* \providecommand{\LyX}{L\kern-.1667em\lower.25em\hbox{Y}\kern-.125emX\\@};
|
|
|
|
*/
|
2015-03-13 11:05:15 +00:00
|
|
|
x += pi.pain.text(x, y, from_ascii("L"), font);
|
2015-03-18 10:32:49 +00:00
|
|
|
x -= em / 6;
|
|
|
|
x += pi.pain.text(x, y + em / 4, from_ascii("Y"), font);
|
|
|
|
x -= em / 8;
|
2015-03-13 11:05:15 +00:00
|
|
|
x += pi.pain.text(x, y, from_ascii("X"), font);
|
|
|
|
break;
|
|
|
|
|
2015-03-15 17:21:01 +00:00
|
|
|
case InsetSpecialChar::PHRASE_TEX: {
|
|
|
|
/** Reference macro:
|
|
|
|
* \def\TeX{T\kern-.1667em\lower.5ex\hbox{E}\kern-.125emX\@}
|
|
|
|
*/
|
2015-03-18 10:32:49 +00:00
|
|
|
int const ex = theFontMetrics(font).ascent('x');
|
2015-03-13 11:05:15 +00:00
|
|
|
x += pi.pain.text(x, y, from_ascii("T"), font);
|
2015-03-18 10:32:49 +00:00
|
|
|
x -= em / 6;
|
|
|
|
x += pi.pain.text(x, y + ex / 2, from_ascii("E"), font);
|
|
|
|
x -= em / 8;
|
2015-03-13 11:05:15 +00:00
|
|
|
x += pi.pain.text(x, y, from_ascii("X"), font);
|
|
|
|
break;
|
2015-03-15 17:21:01 +00:00
|
|
|
}
|
2015-03-13 11:05:15 +00:00
|
|
|
case InsetSpecialChar::PHRASE_LATEX2E:
|
2015-03-15 17:21:01 +00:00
|
|
|
/** Reference macro:
|
|
|
|
* \DeclareRobustCommand{\LaTeXe}{\mbox{\m@th
|
|
|
|
* \if b\expandafter\@car\f@series\@nil\boldmath\fi
|
|
|
|
* \LaTeX\kern.15em2$_{\textstyle\varepsilon}$}}
|
|
|
|
*/
|
2015-03-13 11:05:15 +00:00
|
|
|
drawLogo(pi, InsetSpecialChar::PHRASE_LATEX, x, y);
|
2015-03-18 10:32:49 +00:00
|
|
|
x += 3 * em / 20;
|
2015-03-13 11:05:15 +00:00
|
|
|
x += pi.pain.text(x, y, from_ascii("2"), font);
|
2015-03-18 10:32:49 +00:00
|
|
|
x += pi.pain.text(x, y + em / 4, char_type(0x03b5), font);
|
2015-03-13 11:05:15 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case InsetSpecialChar::PHRASE_LATEX: {
|
2015-03-15 17:21:01 +00:00
|
|
|
/** Reference macro:
|
|
|
|
* \DeclareRobustCommand{\LaTeX}{L\kern-.36em%
|
|
|
|
* {\sbox\z@ T%
|
|
|
|
* \vbox to\ht\z@{\hbox{\check@mathfonts
|
|
|
|
* \fontsize\sf@size\z@
|
|
|
|
* \math@fontsfalse\selectfont
|
|
|
|
* A}%
|
|
|
|
* \vss}%
|
|
|
|
* }%
|
|
|
|
* \kern-.15em%
|
|
|
|
* \TeX}
|
|
|
|
*/
|
2015-03-13 11:05:15 +00:00
|
|
|
x += pi.pain.text(x, y, from_ascii("L"), font);
|
2015-03-18 10:32:49 +00:00
|
|
|
x -= 9 * em / 25;
|
2015-03-13 11:05:15 +00:00
|
|
|
FontInfo smaller = font;
|
|
|
|
smaller.decSize().decSize();
|
2015-03-18 10:32:49 +00:00
|
|
|
x += pi.pain.text(x, y - em / 5, from_ascii("A"), smaller);
|
|
|
|
x -= 3 * em / 20;
|
2015-03-13 11:05:15 +00:00
|
|
|
drawLogo(pi, InsetSpecialChar::PHRASE_TEX, x, y);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
LYXERR0("No information for drawing logo " << kind);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2003-05-30 06:48:24 +00:00
|
|
|
void InsetSpecialChar::draw(PainterInfo & pi, int x, int y) const
|
2000-02-10 17:53:36 +00:00
|
|
|
{
|
2007-10-28 18:51:54 +00:00
|
|
|
FontInfo font = pi.base.font;
|
2000-06-21 15:07:57 +00:00
|
|
|
|
2001-07-23 09:11:14 +00:00
|
|
|
switch (kind_) {
|
2000-02-10 17:53:36 +00:00
|
|
|
case HYPHENATION:
|
|
|
|
{
|
2007-10-25 12:41:02 +00:00
|
|
|
font.setColor(Color_special);
|
2006-10-21 00:16:43 +00:00
|
|
|
pi.pain.text(x, y, char_type('-'), font);
|
2000-02-10 17:53:36 +00:00
|
|
|
break;
|
|
|
|
}
|
2001-07-20 13:04:36 +00:00
|
|
|
case LIGATURE_BREAK:
|
2001-07-20 09:38:19 +00:00
|
|
|
{
|
2007-10-25 12:41:02 +00:00
|
|
|
font.setColor(Color_special);
|
2006-10-21 00:16:43 +00:00
|
|
|
pi.pain.text(x, y, char_type('|'), font);
|
2001-07-20 09:38:19 +00:00
|
|
|
break;
|
|
|
|
}
|
2000-02-10 17:53:36 +00:00
|
|
|
case END_OF_SENTENCE:
|
|
|
|
{
|
2007-10-25 12:41:02 +00:00
|
|
|
font.setColor(Color_special);
|
2006-10-21 00:16:43 +00:00
|
|
|
pi.pain.text(x, y, char_type('.'), font);
|
2000-02-10 17:53:36 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case LDOTS:
|
|
|
|
{
|
2007-10-25 12:41:02 +00:00
|
|
|
font.setColor(Color_special);
|
2007-05-28 22:27:45 +00:00
|
|
|
string ell = ". . . ";
|
|
|
|
docstring dell(ell.begin(), ell.end());
|
2006-08-13 22:54:59 +00:00
|
|
|
pi.pain.text(x, y, dell, font);
|
2000-02-10 17:53:36 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case MENU_SEPARATOR:
|
|
|
|
{
|
2006-10-21 00:16:43 +00:00
|
|
|
frontend::FontMetrics const & fm =
|
2006-10-11 17:24:46 +00:00
|
|
|
theFontMetrics(font);
|
2006-10-07 16:15:06 +00:00
|
|
|
|
2000-02-10 17:53:36 +00:00
|
|
|
// A triangle the width and height of an 'x'
|
2007-05-28 22:27:45 +00:00
|
|
|
int w = fm.width(char_type('x'));
|
2006-10-21 00:16:43 +00:00
|
|
|
int ox = fm.width(char_type(' ')) + x;
|
|
|
|
int h = fm.ascent(char_type('x'));
|
2000-02-11 16:56:34 +00:00
|
|
|
int xp[4], yp[4];
|
2002-03-21 17:09:55 +00:00
|
|
|
|
2003-05-30 06:48:24 +00:00
|
|
|
xp[0] = ox; yp[0] = y;
|
|
|
|
xp[1] = ox; yp[1] = y - h;
|
|
|
|
xp[2] = ox + w; yp[2] = y - h/2;
|
|
|
|
xp[3] = ox; yp[3] = y;
|
2002-03-21 17:09:55 +00:00
|
|
|
|
2007-10-25 12:41:02 +00:00
|
|
|
pi.pain.lines(xp, yp, 4, Color_special);
|
2000-02-29 02:19:17 +00:00
|
|
|
break;
|
|
|
|
}
|
2007-12-06 11:04:56 +00:00
|
|
|
case SLASH:
|
|
|
|
{
|
|
|
|
font.setColor(Color_special);
|
|
|
|
pi.pain.text(x, y, char_type('/'), font);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case NOBREAKDASH:
|
|
|
|
{
|
|
|
|
font.setColor(Color_latex);
|
|
|
|
pi.pain.text(x, y, char_type('-'), font);
|
|
|
|
break;
|
|
|
|
}
|
2015-03-01 10:16:57 +00:00
|
|
|
case PHRASE_LYX:
|
|
|
|
case PHRASE_TEX:
|
|
|
|
case PHRASE_LATEX2E:
|
|
|
|
case PHRASE_LATEX:
|
2015-03-13 11:05:15 +00:00
|
|
|
drawLogo(pi, kind_, x, y);
|
2015-03-01 10:16:57 +00:00
|
|
|
break;
|
2000-02-10 17:53:36 +00:00
|
|
|
}
|
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
// In lyxf3 this will be just LaTeX
|
2008-02-27 20:43:16 +00:00
|
|
|
void InsetSpecialChar::write(ostream & os) const
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
1999-10-02 16:21:10 +00:00
|
|
|
string command;
|
2001-07-23 09:11:14 +00:00
|
|
|
switch (kind_) {
|
2002-03-21 17:09:55 +00:00
|
|
|
case HYPHENATION:
|
|
|
|
command = "\\-";
|
2001-07-20 09:38:19 +00:00
|
|
|
break;
|
2002-03-21 17:09:55 +00:00
|
|
|
case LIGATURE_BREAK:
|
|
|
|
command = "\\textcompwordmark{}";
|
2001-07-20 09:38:19 +00:00
|
|
|
break;
|
2002-03-21 17:09:55 +00:00
|
|
|
case END_OF_SENTENCE:
|
2001-07-20 09:38:19 +00:00
|
|
|
command = "\\@.";
|
|
|
|
break;
|
|
|
|
case LDOTS:
|
2002-03-21 17:09:55 +00:00
|
|
|
command = "\\ldots{}";
|
2001-07-20 09:38:19 +00:00
|
|
|
break;
|
|
|
|
case MENU_SEPARATOR:
|
2002-03-21 17:09:55 +00:00
|
|
|
command = "\\menuseparator";
|
2001-07-20 09:38:19 +00:00
|
|
|
break;
|
2007-12-06 11:04:56 +00:00
|
|
|
case SLASH:
|
|
|
|
command = "\\slash{}";
|
|
|
|
break;
|
|
|
|
case NOBREAKDASH:
|
|
|
|
command = "\\nobreakdash-";
|
|
|
|
break;
|
2015-03-01 10:16:57 +00:00
|
|
|
case PHRASE_LYX:
|
|
|
|
command = "\\LyX";
|
|
|
|
break;
|
|
|
|
case PHRASE_TEX:
|
|
|
|
command = "\\TeX";
|
|
|
|
break;
|
|
|
|
case PHRASE_LATEX2E:
|
|
|
|
command = "\\LaTeX2e";
|
|
|
|
break;
|
|
|
|
case PHRASE_LATEX:
|
|
|
|
command = "\\LaTeX";
|
|
|
|
break;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
1999-12-07 00:44:53 +00:00
|
|
|
os << "\\SpecialChar " << command << "\n";
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// This function will not be necessary when lyx3
|
2008-02-27 20:43:16 +00:00
|
|
|
void InsetSpecialChar::read(Lexer & lex)
|
2002-03-21 17:09:55 +00:00
|
|
|
{
|
2004-10-05 12:56:22 +00:00
|
|
|
lex.next();
|
2001-08-06 19:13:25 +00:00
|
|
|
string const command = lex.getString();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
1999-11-15 10:58:38 +00:00
|
|
|
if (command == "\\-")
|
2001-07-23 09:11:14 +00:00
|
|
|
kind_ = HYPHENATION;
|
2001-07-20 09:38:19 +00:00
|
|
|
else if (command == "\\textcompwordmark{}")
|
2001-07-23 09:11:14 +00:00
|
|
|
kind_ = LIGATURE_BREAK;
|
1999-11-15 10:58:38 +00:00
|
|
|
else if (command == "\\@.")
|
2001-07-23 09:11:14 +00:00
|
|
|
kind_ = END_OF_SENTENCE;
|
1999-11-15 10:58:38 +00:00
|
|
|
else if (command == "\\ldots{}")
|
2001-07-23 09:11:14 +00:00
|
|
|
kind_ = LDOTS;
|
1999-11-15 10:58:38 +00:00
|
|
|
else if (command == "\\menuseparator")
|
2002-03-21 17:09:55 +00:00
|
|
|
kind_ = MENU_SEPARATOR;
|
2007-12-06 11:04:56 +00:00
|
|
|
else if (command == "\\slash{}")
|
|
|
|
kind_ = SLASH;
|
|
|
|
else if (command == "\\nobreakdash-")
|
|
|
|
kind_ = NOBREAKDASH;
|
2015-03-01 10:16:57 +00:00
|
|
|
else if (command == "\\LyX")
|
|
|
|
kind_ = PHRASE_LYX;
|
|
|
|
else if (command == "\\TeX")
|
|
|
|
kind_ = PHRASE_TEX;
|
|
|
|
else if (command == "\\LaTeX2e")
|
|
|
|
kind_ = PHRASE_LATEX2E;
|
|
|
|
else if (command == "\\LaTeX")
|
|
|
|
kind_ = PHRASE_LATEX;
|
1999-09-27 18:44:28 +00:00
|
|
|
else
|
|
|
|
lex.printError("InsetSpecialChar: Unknown kind: `$$Token'");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-02-10 20:02:48 +00:00
|
|
|
void InsetSpecialChar::latex(otexstream & os,
|
|
|
|
OutputParams const & rp) const
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2001-07-23 09:11:14 +00:00
|
|
|
switch (kind_) {
|
2002-03-21 17:09:55 +00:00
|
|
|
case HYPHENATION:
|
|
|
|
os << "\\-";
|
2001-07-20 09:38:19 +00:00
|
|
|
break;
|
2001-07-20 13:04:36 +00:00
|
|
|
case LIGATURE_BREAK:
|
2001-07-20 09:38:19 +00:00
|
|
|
os << "\\textcompwordmark{}";
|
|
|
|
break;
|
2002-03-21 17:09:55 +00:00
|
|
|
case END_OF_SENTENCE:
|
|
|
|
os << "\\@.";
|
2001-07-20 09:38:19 +00:00
|
|
|
break;
|
2002-03-21 17:09:55 +00:00
|
|
|
case LDOTS:
|
|
|
|
os << "\\ldots{}";
|
2001-07-20 09:38:19 +00:00
|
|
|
break;
|
2002-03-21 17:09:55 +00:00
|
|
|
case MENU_SEPARATOR:
|
2009-01-11 08:31:52 +00:00
|
|
|
if (rp.local_font->isRightToLeft())
|
|
|
|
os << "\\lyxarrow*{}";
|
|
|
|
else
|
|
|
|
os << "\\lyxarrow{}";
|
2001-07-20 09:38:19 +00:00
|
|
|
break;
|
2007-12-06 11:04:56 +00:00
|
|
|
case SLASH:
|
|
|
|
os << "\\slash{}";
|
|
|
|
break;
|
|
|
|
case NOBREAKDASH:
|
2008-10-12 09:54:39 +00:00
|
|
|
if (rp.moving_arg)
|
|
|
|
os << "\\protect";
|
2007-12-06 11:04:56 +00:00
|
|
|
os << "\\nobreakdash-";
|
|
|
|
break;
|
2015-03-01 10:16:57 +00:00
|
|
|
case PHRASE_LYX:
|
|
|
|
if (rp.moving_arg)
|
|
|
|
os << "\\protect";
|
|
|
|
os << "\\LyX{}";
|
|
|
|
break;
|
|
|
|
case PHRASE_TEX:
|
|
|
|
if (rp.moving_arg)
|
|
|
|
os << "\\protect";
|
|
|
|
os << "\\TeX{}";
|
|
|
|
break;
|
|
|
|
case PHRASE_LATEX2E:
|
|
|
|
if (rp.moving_arg)
|
|
|
|
os << "\\protect";
|
2015-03-18 10:32:49 +00:00
|
|
|
os << "\\LaTeXe{}";
|
2015-03-01 10:16:57 +00:00
|
|
|
break;
|
|
|
|
case PHRASE_LATEX:
|
|
|
|
if (rp.moving_arg)
|
|
|
|
os << "\\protect";
|
|
|
|
os << "\\LaTeX{}";
|
|
|
|
break;
|
2000-03-02 02:19:43 +00:00
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
|
2013-03-08 19:52:18 +00:00
|
|
|
int InsetSpecialChar::plaintext(odocstringstream & os,
|
|
|
|
OutputParams const &, size_t) const
|
2000-03-06 02:42:40 +00:00
|
|
|
{
|
2001-07-23 09:11:14 +00:00
|
|
|
switch (kind_) {
|
2001-07-20 09:38:19 +00:00
|
|
|
case HYPHENATION:
|
2007-02-17 11:59:42 +00:00
|
|
|
return 0;
|
2012-01-31 20:49:49 +00:00
|
|
|
case LIGATURE_BREAK:
|
|
|
|
os.put(0x200c);
|
|
|
|
return 1;
|
2002-03-21 17:09:55 +00:00
|
|
|
case END_OF_SENTENCE:
|
2002-11-27 10:30:28 +00:00
|
|
|
os << '.';
|
2007-02-17 11:59:42 +00:00
|
|
|
return 1;
|
2002-03-21 17:09:55 +00:00
|
|
|
case LDOTS:
|
2015-02-01 11:49:41 +00:00
|
|
|
os.put(0x2026);
|
|
|
|
return 1;
|
2002-03-21 17:09:55 +00:00
|
|
|
case MENU_SEPARATOR:
|
|
|
|
os << "->";
|
2007-02-17 11:59:42 +00:00
|
|
|
return 2;
|
2007-12-06 11:04:56 +00:00
|
|
|
case SLASH:
|
|
|
|
os << '/';
|
|
|
|
return 1;
|
|
|
|
case NOBREAKDASH:
|
2012-01-31 20:49:49 +00:00
|
|
|
os.put(0x2011);
|
2007-12-06 11:04:56 +00:00
|
|
|
return 1;
|
2015-03-01 10:16:57 +00:00
|
|
|
case PHRASE_LYX:
|
|
|
|
os << "LyX";
|
|
|
|
return 3;
|
|
|
|
case PHRASE_TEX:
|
|
|
|
os << "TeX";
|
|
|
|
return 3;
|
|
|
|
case PHRASE_LATEX2E:
|
|
|
|
os << "LaTeX2";
|
|
|
|
os.put(0x03b5);
|
|
|
|
return 7;
|
|
|
|
case PHRASE_LATEX:
|
|
|
|
os << "LaTeX";
|
|
|
|
return 5;
|
2000-03-06 02:42:40 +00:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-27 20:43:16 +00:00
|
|
|
int InsetSpecialChar::docbook(odocstream & os, OutputParams const &) const
|
2000-03-06 02:42:40 +00:00
|
|
|
{
|
2001-10-23 09:42:14 +00:00
|
|
|
switch (kind_) {
|
|
|
|
case HYPHENATION:
|
|
|
|
case LIGATURE_BREAK:
|
|
|
|
break;
|
|
|
|
case END_OF_SENTENCE:
|
2002-11-27 10:30:28 +00:00
|
|
|
os << '.';
|
2001-10-23 09:42:14 +00:00
|
|
|
break;
|
|
|
|
case LDOTS:
|
2015-02-01 11:49:41 +00:00
|
|
|
os << "…";
|
2001-10-23 09:42:14 +00:00
|
|
|
break;
|
|
|
|
case MENU_SEPARATOR:
|
|
|
|
os << "&lyxarrow;";
|
|
|
|
break;
|
2007-12-06 11:04:56 +00:00
|
|
|
case SLASH:
|
|
|
|
os << '/';
|
|
|
|
break;
|
|
|
|
case NOBREAKDASH:
|
|
|
|
os << '-';
|
|
|
|
break;
|
2015-03-01 10:16:57 +00:00
|
|
|
case PHRASE_LYX:
|
|
|
|
os << "LyX";
|
|
|
|
break;
|
|
|
|
case PHRASE_TEX:
|
|
|
|
os << "TeX";
|
|
|
|
break;
|
|
|
|
case PHRASE_LATEX2E:
|
|
|
|
os << "LaTeX2";
|
|
|
|
os.put(0x03b5);
|
|
|
|
break;
|
|
|
|
case PHRASE_LATEX:
|
|
|
|
os << "LaTeX";
|
|
|
|
break;
|
2001-10-23 09:42:14 +00:00
|
|
|
}
|
|
|
|
return 0;
|
2000-03-06 02:42:40 +00:00
|
|
|
}
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2009-11-25 22:04:41 +00:00
|
|
|
docstring InsetSpecialChar::xhtml(XHTMLStream & xs, OutputParams const &) const
|
2009-06-05 17:48:14 +00:00
|
|
|
{
|
|
|
|
switch (kind_) {
|
|
|
|
case HYPHENATION:
|
2012-01-31 20:49:49 +00:00
|
|
|
break;
|
2009-06-05 17:48:14 +00:00
|
|
|
case LIGATURE_BREAK:
|
2012-01-31 20:49:49 +00:00
|
|
|
xs << XHTMLStream::ESCAPE_NONE << "‌";
|
2009-06-05 17:48:14 +00:00
|
|
|
break;
|
|
|
|
case END_OF_SENTENCE:
|
2009-11-25 22:04:41 +00:00
|
|
|
xs << '.';
|
2009-06-05 17:48:14 +00:00
|
|
|
break;
|
|
|
|
case LDOTS:
|
2010-11-24 15:27:36 +00:00
|
|
|
xs << XHTMLStream::ESCAPE_NONE << "…";
|
2009-06-05 17:48:14 +00:00
|
|
|
break;
|
|
|
|
case MENU_SEPARATOR:
|
2010-11-24 15:27:36 +00:00
|
|
|
xs << XHTMLStream::ESCAPE_NONE << "⇒";
|
2009-06-05 17:48:14 +00:00
|
|
|
break;
|
|
|
|
case SLASH:
|
2010-11-24 15:27:36 +00:00
|
|
|
xs << XHTMLStream::ESCAPE_NONE << "⁄";
|
2009-06-05 17:48:14 +00:00
|
|
|
break;
|
|
|
|
case NOBREAKDASH:
|
2012-01-31 20:49:49 +00:00
|
|
|
xs << XHTMLStream::ESCAPE_NONE << "‑";
|
2009-06-05 17:48:14 +00:00
|
|
|
break;
|
2015-03-01 10:16:57 +00:00
|
|
|
case PHRASE_LYX:
|
|
|
|
xs << "LyX";
|
|
|
|
break;
|
|
|
|
case PHRASE_TEX:
|
|
|
|
xs << "TeX";
|
|
|
|
break;
|
|
|
|
case PHRASE_LATEX2E:
|
|
|
|
xs << "LaTeX2" << XHTMLStream::ESCAPE_NONE << "ε";
|
|
|
|
break;
|
|
|
|
case PHRASE_LATEX:
|
|
|
|
xs << "LaTeX";
|
|
|
|
break;
|
2009-06-05 17:48:14 +00:00
|
|
|
}
|
2009-06-12 17:23:17 +00:00
|
|
|
return docstring();
|
2009-06-05 17:48:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-15 01:34:04 +00:00
|
|
|
void InsetSpecialChar::toString(odocstream & os) const
|
2005-11-25 14:40:34 +00:00
|
|
|
{
|
2013-01-26 08:53:53 +00:00
|
|
|
switch (kind_) {
|
|
|
|
case LIGATURE_BREAK:
|
|
|
|
// Do not output ZERO WIDTH NON JOINER here
|
|
|
|
// Spell checker would choke on it.
|
|
|
|
return;
|
|
|
|
default:
|
2013-03-08 19:52:18 +00:00
|
|
|
break;
|
2013-01-26 08:53:53 +00:00
|
|
|
}
|
2013-03-08 19:52:18 +00:00
|
|
|
odocstringstream ods;
|
|
|
|
plaintext(ods, OutputParams(0));
|
|
|
|
os << ods.str();
|
2005-11-25 14:40:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-03-29 17:34:36 +00:00
|
|
|
void InsetSpecialChar::forOutliner(docstring & os, size_t) const
|
2010-12-20 21:55:09 +00:00
|
|
|
{
|
|
|
|
odocstringstream ods;
|
|
|
|
plaintext(ods, OutputParams(0));
|
|
|
|
os += ods.str();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
void InsetSpecialChar::validate(LaTeXFeatures & features) const
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2007-08-30 18:03:17 +00:00
|
|
|
if (kind_ == MENU_SEPARATOR)
|
2001-11-19 15:34:11 +00:00
|
|
|
features.require("lyxarrow");
|
2007-12-06 11:04:56 +00:00
|
|
|
if (kind_ == NOBREAKDASH)
|
|
|
|
features.require("amsmath");
|
2015-03-01 10:16:57 +00:00
|
|
|
if (kind_ == PHRASE_LYX)
|
|
|
|
features.require("LyX");
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
2001-11-13 14:47:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
bool InsetSpecialChar::isLetter() const
|
|
|
|
{
|
2011-03-18 09:17:09 +00:00
|
|
|
return kind_ == HYPHENATION || kind_ == LIGATURE_BREAK
|
|
|
|
|| kind_ == NOBREAKDASH;
|
2001-11-13 14:47:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-02-13 10:37:28 +00:00
|
|
|
bool InsetSpecialChar::isLineSeparator() const
|
|
|
|
{
|
2002-03-27 00:05:28 +00:00
|
|
|
#if 0
|
|
|
|
// this would be nice, but it does not work, since
|
|
|
|
// Paragraph::stripLeadingSpaces nukes the characters which
|
|
|
|
// have this property. I leave the code here, since it should
|
|
|
|
// eventually be made to work. (JMarc 20020327)
|
2011-03-18 09:17:09 +00:00
|
|
|
return kind_ == HYPHENATION || kind_ == MENU_SEPARATOR
|
|
|
|
|| kind_ == SLASH;
|
2002-03-27 00:05:28 +00:00
|
|
|
#else
|
|
|
|
return false;
|
|
|
|
#endif
|
2002-02-13 10:37:28 +00:00
|
|
|
}
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
} // namespace lyx
|