mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
various cleanups
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4912 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
0472bb3509
commit
0b95bed295
@ -1,3 +1,27 @@
|
||||
2002-08-09 John Levon <levon@movementarian.org>
|
||||
|
||||
* Makefile.am:
|
||||
* sgml.h:
|
||||
* sgml.C:
|
||||
* buffer.C:
|
||||
* paragraph.h:
|
||||
* paragraph.C: move sgml char escaping out of paragraph
|
||||
|
||||
* paragraph.h:
|
||||
* paragraph.C: remove id setter
|
||||
|
||||
* buffer.C:
|
||||
* paragraph.C:
|
||||
* paragraph_pimpl.C: remove dead tex_code_break_column
|
||||
|
||||
* bufferview_funcs.C: small cleanup
|
||||
|
||||
* lyxfunc.C: remove dead proto
|
||||
|
||||
* lyxtext.h: make some stuff private. Remove some dead stuff.
|
||||
|
||||
* lyxgluelength.C: make as[LyX]String() readable
|
||||
|
||||
2002-08-08 John Levon <levon@movementarian.org>
|
||||
|
||||
* LyXAction.h:
|
||||
|
@ -178,10 +178,12 @@ lyx_SOURCES = \
|
||||
paragraph_pimpl.C \
|
||||
paragraph_pimpl.h \
|
||||
SpellBase.h \
|
||||
ispell.h \
|
||||
ispell.C \
|
||||
pspell.h \
|
||||
ispell.h \
|
||||
pspell.C \
|
||||
pspell.h \
|
||||
sgml.C \
|
||||
sgml.h \
|
||||
tabular.C \
|
||||
tabular.h \
|
||||
tabular-old.C \
|
||||
|
38
src/buffer.C
38
src/buffer.C
@ -44,6 +44,7 @@
|
||||
#include "ParagraphParameters.h"
|
||||
#include "iterators.h"
|
||||
#include "lyxtextclasslist.h"
|
||||
#include "sgml.h"
|
||||
|
||||
#include "mathed/formulamacro.h"
|
||||
#include "mathed/formula.h"
|
||||
@ -106,6 +107,7 @@
|
||||
#include <sys/types.h>
|
||||
#include <utime.h>
|
||||
|
||||
#include <boost/tuple/tuple.hpp>
|
||||
|
||||
#ifdef HAVE_LOCALE
|
||||
#include <locale>
|
||||
@ -137,17 +139,12 @@ using lyx::textclass_type;
|
||||
// all these externs should eventually be removed.
|
||||
extern BufferList bufferlist;
|
||||
|
||||
extern LyXAction lyxaction;
|
||||
|
||||
namespace {
|
||||
|
||||
const int LYX_FORMAT = 220;
|
||||
|
||||
} // namespace anon
|
||||
|
||||
extern int tex_code_break_column;
|
||||
|
||||
|
||||
Buffer::Buffer(string const & file, bool ronly)
|
||||
: paragraph(0), niceFile(true), lyx_clean(true), bak_clean(true),
|
||||
unnamed(false), dep_clean(0), read_only(ronly),
|
||||
@ -2165,8 +2162,6 @@ void Buffer::makeLaTeXFile(ostream & os,
|
||||
{
|
||||
niceFile = nice; // this will be used by Insetincludes.
|
||||
|
||||
tex_code_break_column = lyxrc.ascii_linelen;
|
||||
|
||||
// validate the buffer.
|
||||
lyxerr[Debug::LATEX] << " Validating buffer..." << endl;
|
||||
LaTeXFeatures features(params);
|
||||
@ -2191,9 +2186,7 @@ void Buffer::makeLaTeXFile(ostream & os,
|
||||
// usual is \batchmode and has a
|
||||
// special input@path to allow the including of figures
|
||||
// with either \input or \includegraphics (what figinsets do).
|
||||
// batchmode is not set if there is a tex_code_break_column.
|
||||
// In this case somebody is interested in the generated LaTeX,
|
||||
// so this is OK. input@path is set when the actual parameter
|
||||
// input@path is set when the actual parameter
|
||||
// original_path is set. This is done for usual tex-file, but not
|
||||
// for nice-latex-file. (Matthias 250696)
|
||||
if (!only_body) {
|
||||
@ -2631,12 +2624,6 @@ void Buffer::makeLaTeXFile(ostream & os,
|
||||
// Just to be sure. (Asger)
|
||||
texrow.newline();
|
||||
|
||||
// tex_code_break_column's value is used to decide
|
||||
// if we are in batchmode or not (within mathed_write()
|
||||
// in math_write.C) so we must set it to a non-zero
|
||||
// value when we leave otherwise we save incorrect .lyx files.
|
||||
tex_code_break_column = lyxrc.ascii_linelen;
|
||||
|
||||
lyxerr[Debug::INFO] << "Finished making latex file." << endl;
|
||||
lyxerr[Debug::INFO] << "Row count was " << texrow.rows()-1 << "." << endl;
|
||||
|
||||
@ -3161,10 +3148,10 @@ void Buffer::simpleLinuxDocOnePar(ostream & os,
|
||||
os << c;
|
||||
++char_line_count;
|
||||
} else {
|
||||
string sgml_string;
|
||||
if (par->sgmlConvertChar(c, sgml_string)
|
||||
&& !style->free_spacing && !par->isFreeSpacing())
|
||||
{
|
||||
bool ws;
|
||||
string str;
|
||||
boost::tie(ws, str) = sgml::escapeChar(c);
|
||||
if (ws && !style->free_spacing && !par->isFreeSpacing()) {
|
||||
// in freespacing mode, spaces are
|
||||
// non-breaking characters
|
||||
if (desc_on) {// if char is ' ' then...
|
||||
@ -3178,8 +3165,8 @@ void Buffer::simpleLinuxDocOnePar(ostream & os,
|
||||
os << c;
|
||||
}
|
||||
} else {
|
||||
os << sgml_string;
|
||||
char_line_count += sgml_string.length();
|
||||
os << str;
|
||||
char_line_count += str.length();
|
||||
}
|
||||
}
|
||||
font_old = font;
|
||||
@ -3551,13 +3538,14 @@ void Buffer::simpleDocBookOnePar(ostream & os,
|
||||
}
|
||||
} else {
|
||||
char c = par->getChar(i);
|
||||
string sgml_string;
|
||||
par->sgmlConvertChar(c, sgml_string);
|
||||
bool ws;
|
||||
string str;
|
||||
boost::tie(ws, str) = sgml::escapeChar(c);
|
||||
|
||||
if (style->pass_thru) {
|
||||
os << c;
|
||||
} else if (style->free_spacing || par->isFreeSpacing() || c != ' ') {
|
||||
os << sgml_string;
|
||||
os << str;
|
||||
} else if (desc_on ==1) {
|
||||
++char_line_count;
|
||||
os << "\n</term><listitem><para>";
|
||||
|
@ -210,29 +210,32 @@ string const currentState(BufferView * bv)
|
||||
*/
|
||||
void toggleAndShow(BufferView * bv, LyXFont const & font, bool toggleall)
|
||||
{
|
||||
if (bv->available()) {
|
||||
if (bv->theLockingInset()) {
|
||||
bv->theLockingInset()->setFont(bv, font, toggleall);
|
||||
return;
|
||||
}
|
||||
LyXText * text = bv->getLyXText();
|
||||
if (!text)
|
||||
return;
|
||||
if (!bv->available())
|
||||
return;
|
||||
|
||||
if (bv->theLockingInset()) {
|
||||
bv->theLockingInset()->setFont(bv, font, toggleall);
|
||||
return;
|
||||
}
|
||||
|
||||
LyXText * text = bv->getLyXText();
|
||||
// FIXME: can this happen ??
|
||||
if (!text)
|
||||
return;
|
||||
|
||||
bv->hideCursor();
|
||||
bv->update(text, BufferView::SELECT|BufferView::FITCUR);
|
||||
text->toggleFree(bv, font, toggleall);
|
||||
bv->update(text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
|
||||
bv->hideCursor();
|
||||
bv->update(text, BufferView::SELECT | BufferView::FITCUR);
|
||||
text->toggleFree(bv, font, toggleall);
|
||||
bv->update(text, BufferView::SELECT | BufferView::FITCUR | BufferView::CHANGE);
|
||||
|
||||
if (font.language() != ignore_language ||
|
||||
font.number() != LyXFont::IGNORE) {
|
||||
LyXCursor & cursor = text->cursor;
|
||||
text->computeBidiTables(bv->buffer(), cursor.row());
|
||||
if (cursor.boundary() !=
|
||||
text->isBoundary(bv->buffer(), cursor.par(), cursor.pos(),
|
||||
text->real_current_font))
|
||||
text->setCursor(bv, cursor.par(), cursor.pos(),
|
||||
false, !cursor.boundary());
|
||||
}
|
||||
if (font.language() != ignore_language ||
|
||||
font.number() != LyXFont::IGNORE) {
|
||||
LyXCursor & cursor = text->cursor;
|
||||
text->computeBidiTables(bv->buffer(), cursor.row());
|
||||
if (cursor.boundary() !=
|
||||
text->isBoundary(bv->buffer(), cursor.par(), cursor.pos(),
|
||||
text->real_current_font))
|
||||
text->setCursor(bv, cursor.par(), cursor.pos(),
|
||||
false, !cursor.boundary());
|
||||
}
|
||||
}
|
||||
|
@ -32,8 +32,6 @@
|
||||
|
||||
using std::endl;
|
||||
|
||||
extern LyXRC lyxrc;
|
||||
|
||||
namespace Liason {
|
||||
|
||||
PrinterParams getPrinterParams(Buffer * buffer)
|
||||
|
@ -114,8 +114,6 @@ extern bool selection_possible;
|
||||
|
||||
extern boost::scoped_ptr<kb_keymap> toplevel_keymap;
|
||||
|
||||
extern void show_symbols_form(LyXFunc *);
|
||||
|
||||
// (alkis)
|
||||
extern tex_accent_struct get_accent(kb_action action);
|
||||
|
||||
|
@ -41,52 +41,48 @@ string const LyXGlueLength::asString() const
|
||||
{
|
||||
ostringstream buffer;
|
||||
|
||||
if (!plus_.zero())
|
||||
if (!minus_.zero())
|
||||
if (len_.unit() == plus_.unit() && len_.unit() == minus_.unit())
|
||||
if (plus_.value() == minus_.value())
|
||||
buffer << len_.value() << "+-"
|
||||
<< plus_.value() << unit_name[len_.unit()];
|
||||
else
|
||||
buffer << len_.value()
|
||||
<< '+' << plus_.value()
|
||||
<< '-' << minus_.value()
|
||||
<< unit_name[len_.unit()];
|
||||
else
|
||||
if (plus_.unit() == minus_.unit()
|
||||
&& plus_.value() == minus_.value())
|
||||
buffer << len_.value() << unit_name[len_.unit()]
|
||||
<< "+-" << plus_.value()
|
||||
<< unit_name[plus_.unit()];
|
||||
buffer << len_.value();
|
||||
|
||||
else
|
||||
buffer << len_.value() << unit_name[len_.unit()]
|
||||
<< '+' << plus_.value()
|
||||
<< unit_name[plus_.unit()]
|
||||
<< '-' << minus_.value()
|
||||
<< unit_name[minus_.unit()];
|
||||
else
|
||||
if (len_.unit() == plus_.unit())
|
||||
buffer << len_.value() << '+' << plus_.value()
|
||||
<< unit_name[len_.unit()];
|
||||
else
|
||||
buffer << len_.value() << unit_name[len_.unit()]
|
||||
<< '+' << plus_.value()
|
||||
<< unit_name[plus_.unit()];
|
||||
if (plus_.zero() && minus_.zero()) {
|
||||
buffer << unit_name[len_.unit()];
|
||||
return buffer.str().c_str();
|
||||
}
|
||||
|
||||
// just len and plus
|
||||
if (minus_.zero()) {
|
||||
if (len_.unit() != plus_.unit())
|
||||
buffer << unit_name[len_.unit()];
|
||||
buffer << "+" << plus_.value();
|
||||
buffer << unit_name[plus_.unit()];
|
||||
return buffer.str().c_str();
|
||||
}
|
||||
|
||||
// just len and minus
|
||||
if (plus_.zero()) {
|
||||
if (len_.unit() != minus_.unit())
|
||||
buffer << unit_name[len_.unit()];
|
||||
buffer << "-" << minus_.value();
|
||||
buffer << unit_name[minus_.unit()];
|
||||
return buffer.str().c_str();
|
||||
}
|
||||
|
||||
else
|
||||
if (!minus_.zero())
|
||||
if (len_.unit() == minus_.unit())
|
||||
buffer << len_.value() << '-' << minus_.value()
|
||||
<< unit_name[len_.unit()];
|
||||
|
||||
else
|
||||
buffer << len_.value() << unit_name[len_.unit()]
|
||||
<< '-' << minus_.value()
|
||||
<< unit_name[minus_.unit()];
|
||||
else
|
||||
buffer << len_.value() << unit_name[len_.unit()];
|
||||
// ok, len, plus AND minus
|
||||
|
||||
// len+-
|
||||
if (minus_ == plus_) {
|
||||
if (len_.unit() != minus_.unit())
|
||||
buffer << unit_name[len_.unit()];
|
||||
buffer << "+-" << minus_.value();
|
||||
buffer << unit_name[minus_.unit()];
|
||||
return buffer.str().c_str();
|
||||
}
|
||||
|
||||
// this is so rare a case, why bother minimising units ?
|
||||
|
||||
buffer << unit_name[len_.unit()];
|
||||
buffer << "+" << plus_.value() << unit_name[plus_.unit()];
|
||||
buffer << "-" << minus_.value() << unit_name[minus_.unit()];
|
||||
|
||||
return buffer.str().c_str();
|
||||
}
|
||||
|
||||
@ -95,25 +91,12 @@ string const LyXGlueLength::asLatexString() const
|
||||
{
|
||||
ostringstream buffer;
|
||||
|
||||
buffer << len_.value() << unit_name[len_.unit()];
|
||||
|
||||
if (!plus_.zero())
|
||||
if (!minus_.zero())
|
||||
buffer << len_.value() << unit_name[len_.unit()]
|
||||
<< " plus "
|
||||
<< plus_.value() << unit_name[plus_.unit()]
|
||||
<< " minus "
|
||||
<< minus_.value() << unit_name[minus_.unit()];
|
||||
else
|
||||
buffer << len_.value() << unit_name[len_.unit()]
|
||||
<< " plus "
|
||||
<< plus_.value() << unit_name[plus_.unit()];
|
||||
else
|
||||
if (!minus_.zero())
|
||||
buffer << len_.value() << unit_name[len_.unit()]
|
||||
<< " minus "
|
||||
<< minus_.value() << unit_name[minus_.unit()];
|
||||
else
|
||||
buffer << len_.value() << unit_name[len_.unit()];
|
||||
|
||||
buffer << " plus " << plus_.value() << unit_name[plus_.unit()];
|
||||
if (!minus_.zero())
|
||||
buffer << " minus " << minus_.value() << unit_name[minus_.unit()];
|
||||
return buffer.str().c_str();
|
||||
}
|
||||
|
||||
|
@ -122,9 +122,6 @@ public:
|
||||
///
|
||||
void setLayout(BufferView *, string const & layout);
|
||||
|
||||
/// used in setlayout
|
||||
void makeFontEntriesLayoutSpecific(Buffer const *, Paragraph * par);
|
||||
|
||||
/** increment depth over selection and make a total rebreak of those
|
||||
paragraphs
|
||||
*/
|
||||
@ -166,11 +163,6 @@ public:
|
||||
*/
|
||||
void redoHeightOfParagraph(BufferView *, LyXCursor const & cursor);
|
||||
|
||||
/** forces the redrawing of a paragraph. Needed when manipulating a
|
||||
right address box
|
||||
*/
|
||||
void redoDrawingOfParagraph(BufferView *, LyXCursor const & cursor);
|
||||
|
||||
/** insert a character, moves all the following breaks in the
|
||||
same Paragraph one to the right and make a little rebreak
|
||||
*/
|
||||
@ -321,9 +313,6 @@ public:
|
||||
bool setfont = true,
|
||||
bool boundary = false) const;
|
||||
///
|
||||
float getCursorX(BufferView *, Row *, lyx::pos_type pos,
|
||||
lyx::pos_type last, bool boundary) const;
|
||||
///
|
||||
void setCurrentFont(BufferView *) const;
|
||||
|
||||
///
|
||||
@ -392,11 +381,6 @@ public:
|
||||
/// Change the case of the word at cursor position.
|
||||
void changeCase(BufferView *, TextCase action);
|
||||
///
|
||||
void changeRegionCase(BufferView * bview,
|
||||
LyXCursor const & from,
|
||||
LyXCursor const & to,
|
||||
LyXText::TextCase action);
|
||||
///
|
||||
void transposeChars(BufferView &);
|
||||
|
||||
/** returns a printed row in a pixmap. The y value is needed to
|
||||
@ -464,12 +448,6 @@ public:
|
||||
///
|
||||
void checkParagraph(BufferView *, Paragraph * par, lyx::pos_type pos);
|
||||
///
|
||||
int numberOfCell(Paragraph * par, lyx::pos_type pos) const;
|
||||
///
|
||||
void removeTableRow(LyXCursor & cursor) const;
|
||||
///
|
||||
bool isEmptyTableCell() const;
|
||||
///
|
||||
void toggleAppendix(BufferView *);
|
||||
///
|
||||
int workWidth(BufferView *) const;
|
||||
@ -516,6 +494,22 @@ private:
|
||||
///
|
||||
mutable Row * lastrow;
|
||||
|
||||
///
|
||||
float getCursorX(BufferView *, Row *, lyx::pos_type pos,
|
||||
lyx::pos_type last, bool boundary) const;
|
||||
///
|
||||
void changeRegionCase(BufferView * bview,
|
||||
LyXCursor const & from,
|
||||
LyXCursor const & to,
|
||||
LyXText::TextCase action);
|
||||
/// used in setlayout
|
||||
void makeFontEntriesLayoutSpecific(Buffer const *, Paragraph * par);
|
||||
|
||||
/** forces the redrawing of a paragraph. Needed when manipulating a
|
||||
right address box
|
||||
*/
|
||||
void redoDrawingOfParagraph(BufferView *, LyXCursor const & cursor);
|
||||
|
||||
/** Copybuffer for copy environment type.
|
||||
Asger has learned that this should be a buffer-property instead
|
||||
Lgb has learned that 'char' is a lousy type for non-characters
|
||||
|
@ -54,7 +54,6 @@ using std::reverse;
|
||||
|
||||
using lyx::pos_type;
|
||||
|
||||
int tex_code_break_column = 72; // needs non-zero initialization. set later.
|
||||
// this is a bad idea, but how can Paragraph find its buffer to get
|
||||
// parameters? (JMarc)
|
||||
|
||||
@ -1188,7 +1187,7 @@ Paragraph * Paragraph::TeXOnePar(Buffer const * buf,
|
||||
texrow.newline();
|
||||
}
|
||||
|
||||
if (tex_code_break_column && style->isCommand()) {
|
||||
if (style->isCommand()) {
|
||||
os << '\n';
|
||||
texrow.newline();
|
||||
}
|
||||
@ -1703,70 +1702,6 @@ bool Paragraph::simpleTeXOnePar(Buffer const * buf,
|
||||
}
|
||||
|
||||
|
||||
bool Paragraph::sgmlConvertChar(char c, string & sgml_string)
|
||||
{
|
||||
bool retval = false;
|
||||
switch (c) {
|
||||
case Paragraph::META_HFILL:
|
||||
sgml_string.erase();
|
||||
break;
|
||||
case Paragraph::META_NEWLINE:
|
||||
sgml_string = '\n';
|
||||
break;
|
||||
case '&':
|
||||
sgml_string = "&";
|
||||
break;
|
||||
case '<':
|
||||
sgml_string = "<";
|
||||
break;
|
||||
case '>':
|
||||
sgml_string = ">";
|
||||
break;
|
||||
case '$':
|
||||
sgml_string = "$";
|
||||
break;
|
||||
case '#':
|
||||
sgml_string = "#";
|
||||
break;
|
||||
case '%':
|
||||
sgml_string = "%";
|
||||
break;
|
||||
case '[':
|
||||
sgml_string = "[";
|
||||
break;
|
||||
case ']':
|
||||
sgml_string = "]";
|
||||
break;
|
||||
case '{':
|
||||
sgml_string = "{";
|
||||
break;
|
||||
case '}':
|
||||
sgml_string = "}";
|
||||
break;
|
||||
case '~':
|
||||
sgml_string = "˜";
|
||||
break;
|
||||
case '"':
|
||||
sgml_string = """;
|
||||
break;
|
||||
case '\\':
|
||||
sgml_string = "\";
|
||||
break;
|
||||
case ' ':
|
||||
retval = true;
|
||||
sgml_string = ' ';
|
||||
break;
|
||||
case '\0': // Ignore :-)
|
||||
sgml_string.erase();
|
||||
break;
|
||||
default:
|
||||
sgml_string = c;
|
||||
break;
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
Paragraph * Paragraph::TeXEnvironment(Buffer const * buf,
|
||||
BufferParams const & bparams,
|
||||
ostream & os, TexRow & texrow)
|
||||
@ -2110,12 +2045,6 @@ int Paragraph::id() const
|
||||
}
|
||||
|
||||
|
||||
void Paragraph::id(int id_arg)
|
||||
{
|
||||
pimpl_->id_ = id_arg;
|
||||
}
|
||||
|
||||
|
||||
LyXLayout_ptr const & Paragraph::layout() const
|
||||
{
|
||||
return layout_;
|
||||
|
@ -113,11 +113,9 @@ public:
|
||||
///
|
||||
void validate(LaTeXFeatures &) const;
|
||||
|
||||
///
|
||||
/// return the unique ID of this paragraph
|
||||
int id() const;
|
||||
///
|
||||
void id(int id_arg);
|
||||
///
|
||||
void read();
|
||||
|
||||
///
|
||||
@ -326,8 +324,6 @@ public:
|
||||
///
|
||||
void unsetPExtraType(BufferParams const &);
|
||||
#endif
|
||||
///
|
||||
bool sgmlConvertChar(char c, string & sgml_string);
|
||||
///
|
||||
bool isFreeSpacing() const;
|
||||
|
||||
|
@ -31,9 +31,6 @@ using std::ostream;
|
||||
using std::upper_bound;
|
||||
using std::lower_bound;
|
||||
|
||||
extern int tex_code_break_column;
|
||||
|
||||
|
||||
// Initialize static member.
|
||||
ShareContainer<LyXFont> Paragraph::Pimpl::FontTable::container;
|
||||
// Initialization of the counter for the paragraph id's,
|
||||
@ -249,7 +246,7 @@ void Paragraph::Pimpl::simpleTeXBlanks(ostream & os, TexRow & texrow,
|
||||
LyXLayout const & style)
|
||||
{
|
||||
if (style.pass_thru) return;
|
||||
if (column > tex_code_break_column
|
||||
if (column > lyxrc.ascii_linelen
|
||||
&& i
|
||||
&& getChar(i - 1) != ' '
|
||||
&& (i < size() - 1)
|
||||
@ -263,13 +260,7 @@ void Paragraph::Pimpl::simpleTeXBlanks(ostream & os, TexRow & texrow,
|
||||
|| getChar(i - 1) == '?'
|
||||
|| getChar(i - 1) == ':'
|
||||
|| getChar(i - 1) == '!'))) {
|
||||
if (tex_code_break_column == 0) {
|
||||
// in batchmode we need LaTeX to still
|
||||
// see it as a space not as an extra '\n'
|
||||
os << " %\n";
|
||||
} else {
|
||||
os << '\n';
|
||||
}
|
||||
os << '\n';
|
||||
texrow.newline();
|
||||
texrow.start(owner_, i + 1);
|
||||
column = 0;
|
||||
|
80
src/sgml.C
Normal file
80
src/sgml.C
Normal file
@ -0,0 +1,80 @@
|
||||
/**
|
||||
* \file sgml.C
|
||||
* Copyright 2002 the LyX Team
|
||||
* Read the file COPYING
|
||||
*
|
||||
* \author José Matos
|
||||
* \author John Levon <levon@movementarian.org>
|
||||
*/
|
||||
|
||||
#include "sgml.h"
|
||||
#include "paragraph.h"
|
||||
|
||||
using std::pair;
|
||||
using std::make_pair;
|
||||
|
||||
namespace sgml {
|
||||
|
||||
pair<bool, string> escapeChar(char c)
|
||||
{
|
||||
string str;
|
||||
|
||||
switch (c) {
|
||||
case Paragraph::META_HFILL:
|
||||
break;
|
||||
case Paragraph::META_NEWLINE:
|
||||
str = '\n';
|
||||
break;
|
||||
case ' ':
|
||||
return make_pair(true, string(" "));
|
||||
break;
|
||||
case '\0': // Ignore :-)
|
||||
str.erase();
|
||||
break;
|
||||
case '&':
|
||||
str = "&";
|
||||
break;
|
||||
case '<':
|
||||
str = "<";
|
||||
break;
|
||||
case '>':
|
||||
str = ">";
|
||||
break;
|
||||
case '$':
|
||||
str = "$";
|
||||
break;
|
||||
case '#':
|
||||
str = "#";
|
||||
break;
|
||||
case '%':
|
||||
str = "%";
|
||||
break;
|
||||
case '[':
|
||||
str = "[";
|
||||
break;
|
||||
case ']':
|
||||
str = "]";
|
||||
break;
|
||||
case '{':
|
||||
str = "{";
|
||||
break;
|
||||
case '}':
|
||||
str = "}";
|
||||
break;
|
||||
case '~':
|
||||
str = "˜";
|
||||
break;
|
||||
case '"':
|
||||
str = """;
|
||||
break;
|
||||
case '\\':
|
||||
str = "\";
|
||||
break;
|
||||
default:
|
||||
str = c;
|
||||
break;
|
||||
}
|
||||
return make_pair(false, str);
|
||||
}
|
||||
|
||||
} // namespace sgml
|
30
src/sgml.h
Normal file
30
src/sgml.h
Normal file
@ -0,0 +1,30 @@
|
||||
/**
|
||||
* \file sgml.h
|
||||
* Copyright 2002 the LyX Team
|
||||
* Read the file COPYING
|
||||
*
|
||||
* \author José Matos
|
||||
* \author John Levon <levon@movementarian.org>
|
||||
*/
|
||||
|
||||
#ifndef SGML_H
|
||||
#define SGML_H
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "LString.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace sgml {
|
||||
|
||||
/**
|
||||
* Escape the given character if necessary
|
||||
* to an SGML entity. The bool return is true
|
||||
* if it was a whitespace character.
|
||||
*/
|
||||
std::pair<bool, string> escapeChar(char c);
|
||||
|
||||
}
|
||||
|
||||
#endif // SGML_H
|
Loading…
Reference in New Issue
Block a user