}
-AppleSpellChecker::AppleSpellChecker(): d(new Private)
-{
-}
+AppleSpellChecker::AppleSpellChecker()
+ : d(new Private)
+{}
AppleSpellChecker::~AppleSpellChecker()
struct AspellChecker::Private
{
- Private() {}
+ Private()
+ {}
~Private();
/// the location below system/user directory
/// there the rws files lookup will happen
- const string dictDirectory(void) { return "dicts"; }
+ const string dictDirectory(void)
+ {
+ return "dicts";
+ }
/// there the dat+cmap files lookup will happen
- const string dataDirectory(void) { return "data"; }
+ const string dataDirectory(void)
+ {
+ return "data";
+ }
/// os package directory constants
/// macports on Mac OS X or
/// aspell rpms on Linux
- const string osPackageBase(void) {
+ const string osPackageBase(void)
+ {
#ifdef USE_MACOSX_PACKAGING
return "/opt/local";
#else
return "/usr";
#endif
}
- const string osPackageDictDirectory(void) {
+ const string osPackageDictDirectory(void)
+ {
#ifdef USE_MACOSX_PACKAGING
return "/share/aspell";
#else
return "/lib/aspell-0.60";
#endif
}
- const string osPackageDataDirectory(void) { return "/lib/aspell-0.60"; }
+ const string osPackageDataDirectory(void)
+ {
+ return "/lib/aspell-0.60";
+ }
};
}
-AspellChecker::AspellChecker(): d(new Private)
-{
-}
+AspellChecker::AspellChecker()
+ : d(new Private)
+{}
AspellChecker::~AspellChecker()
delete_aspell_string_enumeration(els);
}
+
void AspellChecker::remove(WordLangTuple const & word)
{
d->remove(word);
advanceChangeNumber();
}
+
bool AspellChecker::hasDictionary(Language const * lang) const
{
bool have = false;
return os;
}
+
istream & operator>>(istream & is, Author & a)
{
string s;
}
-bool author_smaller(Author const & lhs, Author const & rhs) {
+bool author_smaller(Author const & lhs, Author const & rhs)
+{
return lhs.bufferId() < rhs.bufferId();
}
AuthorList::AuthorList()
: last_id_(0)
-{
-}
+{}
int AuthorList::record(Author const & a)
}
-void AuthorList::sort() {
+void AuthorList::sort()
+{
std::sort(authors_.begin(), authors_.end(), author_smaller);
}
-ostream & operator<<(ostream & os, AuthorList const & a) {
+ostream & operator<<(ostream & os, AuthorList const & a)
+{
// Copy the authorlist, because we don't want to sort the original
AuthorList sorted = a;
sorted.sort();
return retval;
}
+
// converts a string containing LaTeX commands into unicode
// for display.
docstring convertLaTeXCommands(docstring const & str)
namespace {
- string parseOptions(string const & format, string & optkey,
- string & ifpart, string & elsepart);
-
- // Calls parseOptions to deal with an embedded option, such as:
- // {%number%[[, no.~%number%]]}
- // which must appear at the start of format. ifelsepart gets the
- // whole of the option, and we return what's left after the option.
- // we return format if there is an error.
- string parseEmbeddedOption(string const & format, string & ifelsepart)
- {
- LASSERT(format[0] == '{' && format[1] == '%', return format);
- string optkey;
- string ifpart;
- string elsepart;
- string const rest = parseOptions(format, optkey, ifpart, elsepart);
- if (format == rest) { // parse error
- LYXERR0("ERROR! Couldn't parse `" << format <<"'.");
- return format;
- }
- LASSERT(rest.size() <= format.size(), /* */);
- ifelsepart = format.substr(0, format.size() - rest.size());
- return rest;
+
+string parseOptions(string const & format, string & optkey,
+ string & ifpart, string & elsepart);
+
+// Calls parseOptions to deal with an embedded option, such as:
+// {%number%[[, no.~%number%]]}
+// which must appear at the start of format. ifelsepart gets the
+// whole of the option, and we return what's left after the option.
+// we return format if there is an error.
+string parseEmbeddedOption(string const & format, string & ifelsepart)
+{
+ LASSERT(format[0] == '{' && format[1] == '%', return format);
+ string optkey;
+ string ifpart;
+ string elsepart;
+ string const rest = parseOptions(format, optkey, ifpart, elsepart);
+ if (format == rest) { // parse error
+ LYXERR0("ERROR! Couldn't parse `" << format <<"'.");
+ return format;
}
+ LASSERT(rest.size() <= format.size(), /* */);
+ ifelsepart = format.substr(0, format.size() - rest.size());
+ return rest;
+}
- // Gets a "clause" from a format string, where the clause is
- // delimited by '[[' and ']]'. Returns what is left after the
- // clause is removed, and returns format if there is an error.
- string getClause(string const & format, string & clause)
- {
- string fmt = format;
- // remove '[['
- fmt = fmt.substr(2);
- // we'll remove characters from the front of fmt as we
- // deal with them
- while (!fmt.empty()) {
- if (fmt[0] == ']' && fmt.size() > 1 && fmt[1] == ']') {
- // that's the end
- fmt = fmt.substr(2);
- break;
+// Gets a "clause" from a format string, where the clause is
+// delimited by '[[' and ']]'. Returns what is left after the
+// clause is removed, and returns format if there is an error.
+string getClause(string const & format, string & clause)
+{
+ string fmt = format;
+ // remove '[['
+ fmt = fmt.substr(2);
+ // we'll remove characters from the front of fmt as we
+ // deal with them
+ while (!fmt.empty()) {
+ if (fmt[0] == ']' && fmt.size() > 1 && fmt[1] == ']') {
+ // that's the end
+ fmt = fmt.substr(2);
+ break;
+ }
+ // check for an embedded option
+ if (fmt[0] == '{' && fmt.size() > 1 && fmt[1] == '%') {
+ string part;
+ string const rest = parseEmbeddedOption(fmt, part);
+ if (fmt == rest) {
+ LYXERR0("ERROR! Couldn't parse embedded option in `" << format <<"'.");
+ return format;
}
- // check for an embedded option
- if (fmt[0] == '{' && fmt.size() > 1 && fmt[1] == '%') {
- string part;
- string const rest = parseEmbeddedOption(fmt, part);
- if (fmt == rest) {
- LYXERR0("ERROR! Couldn't parse embedded option in `" << format <<"'.");
- return format;
- }
- clause += part;
- fmt = rest;
- } else { // it's just a normal character
+ clause += part;
+ fmt = rest;
+ } else { // it's just a normal character
clause += fmt[0];
fmt = fmt.substr(1);
- }
}
- return fmt;
}
+ return fmt;
+}
- // parse an options string, which must appear at the start of the
- // format parameter. puts the parsed bits in optkey, ifpart, and
- // elsepart and returns what's left after the option is removed.
- // if there's an error, it returns format itself.
- string parseOptions(string const & format, string & optkey,
- string & ifpart, string & elsepart)
- {
- LASSERT(format[0] == '{' && format[1] == '%', return format);
- // strip '{%'
- string fmt = format.substr(2);
- size_t pos = fmt.find('%'); // end of key
- if (pos == string::npos) {
- LYXERR0("Error parsing `" << format <<"'. Can't find end of key.");
- return format;
- }
- optkey = fmt.substr(0,pos);
- fmt = fmt.substr(pos + 1);
- // [[format]] should be next
- if (fmt[0] != '[' || fmt[1] != '[') {
- LYXERR0("Error parsing `" << format <<"'. Can't find '[[' after key.");
- return format;
- }
+// parse an options string, which must appear at the start of the
+// format parameter. puts the parsed bits in optkey, ifpart, and
+// elsepart and returns what's left after the option is removed.
+// if there's an error, it returns format itself.
+string parseOptions(string const & format, string & optkey,
+ string & ifpart, string & elsepart)
+{
+ LASSERT(format[0] == '{' && format[1] == '%', return format);
+ // strip '{%'
+ string fmt = format.substr(2);
+ size_t pos = fmt.find('%'); // end of key
+ if (pos == string::npos) {
+ LYXERR0("Error parsing `" << format <<"'. Can't find end of key.");
+ return format;
+ }
+ optkey = fmt.substr(0,pos);
+ fmt = fmt.substr(pos + 1);
+ // [[format]] should be next
+ if (fmt[0] != '[' || fmt[1] != '[') {
+ LYXERR0("Error parsing `" << format <<"'. Can't find '[[' after key.");
+ return format;
+ }
- string curfmt = fmt;
- fmt = getClause(curfmt, ifpart);
- if (fmt == curfmt) {
- LYXERR0("Error parsing `" << format <<"'. Couldn't get if clause.");
- return format;
- }
+ string curfmt = fmt;
+ fmt = getClause(curfmt, ifpart);
+ if (fmt == curfmt) {
+ LYXERR0("Error parsing `" << format <<"'. Couldn't get if clause.");
+ return format;
+ }
- if (fmt[0] == '}') // we're done, no else clause
- return fmt.substr(1);
+ if (fmt[0] == '}') // we're done, no else clause
+ return fmt.substr(1);
- // else part should follow
- if (fmt[0] != '[' || fmt[1] != '[') {
- LYXERR0("Error parsing `" << format <<"'. Can't find else clause.");
- return format;
- }
+ // else part should follow
+ if (fmt[0] != '[' || fmt[1] != '[') {
+ LYXERR0("Error parsing `" << format <<"'. Can't find else clause.");
+ return format;
+ }
- curfmt = fmt;
- fmt = getClause(curfmt, elsepart);
- // we should be done
- if (fmt == curfmt || fmt[0] != '}') {
- LYXERR0("Error parsing `" << format <<"'. Can't find end of option.");
- return format;
- }
- return fmt.substr(1);
+ curfmt = fmt;
+ fmt = getClause(curfmt, elsepart);
+ // we should be done
+ if (fmt == curfmt || fmt[0] != '}') {
+ LYXERR0("Error parsing `" << format <<"'. Can't find end of option.");
+ return format;
+ }
+ return fmt.substr(1);
}
+
} // anon namespace
//////////////////////////////////////////////////////////////////////
namespace {
+
// A functor for use with sort, leading to case insensitive sorting
- class compareNoCase: public binary_function<docstring, docstring, bool>
- {
- public:
- bool operator()(docstring const & s1, docstring const & s2) const {
- return compare_no_case(s1, s2) < 0;
- }
- };
+class compareNoCase: public binary_function<docstring, docstring, bool>
+{
+public:
+ bool operator()(docstring const & s1, docstring const & s2) const {
+ return compare_no_case(s1, s2) < 0;
+ }
+};
+
} // namespace anon
namespace {
- // used in xhtml to sort a list of BibTeXInfo objects
- bool lSorter(BibTeXInfo const * lhs, BibTeXInfo const * rhs)
- {
- docstring const lauth = lhs->getAbbreviatedAuthor();
- docstring const rauth = rhs->getAbbreviatedAuthor();
- docstring const lyear = lhs->getYear();
- docstring const ryear = rhs->getYear();
- docstring const ltitl = lhs->operator[]("title");
- docstring const rtitl = rhs->operator[]("title");
- return (lauth < rauth)
- || (lauth == rauth && lyear < ryear)
- || (lauth == rauth && lyear == ryear && ltitl < rtitl);
- }
+
+// used in xhtml to sort a list of BibTeXInfo objects
+bool lSorter(BibTeXInfo const * lhs, BibTeXInfo const * rhs)
+{
+ docstring const lauth = lhs->getAbbreviatedAuthor();
+ docstring const rauth = rhs->getAbbreviatedAuthor();
+ docstring const lyear = lhs->getYear();
+ docstring const ryear = rhs->getYear();
+ docstring const ltitl = lhs->operator[]("title");
+ docstring const rtitl = rhs->operator[]("title");
+ return (lauth < rauth)
+ || (lauth == rauth && lyear < ryear)
+ || (lauth == rauth && lyear == ryear && ltitl < rtitl);
+}
+
}
return start_ == -1 || (start_ <= pos && pos <= end_);
}
+
bool Bidi::same_direction() const
{
return same_direction_;
class BranchNamesEqual : public std::unary_function<Branch, bool>
{
public:
- BranchNamesEqual(docstring const & name) : name_(name) {}
+ BranchNamesEqual(docstring const & name)
+ : name_(name)
+ {}
bool operator()(Branch const & branch) const
{
private:
docstring name_;
};
+
}
/// This is here to force the test to be done whenever parent_buffer
/// is accessed.
- Buffer const * parent() const {
+ Buffer const * parent() const
+ {
// ignore_parent temporarily "orphans" a buffer
// (e.g. if a child is compiled standalone)
if (ignore_parent)
}
///
- void setParent(Buffer const * pb) {
+ void setParent(Buffer const * pb)
+ {
if (parent_buffer == pb)
// nothing to do
return;
/// \p from initial position
/// \p to points to the end position
void updateStatistics(DocIterator & from, DocIterator & to,
- bool skipNoOutput = true);
+ bool skipNoOutput = true);
/// statistics accessor functions
- int wordCount() const { return word_count_; }
- int charCount(bool with_blanks) const {
+ int wordCount() const
+ {
+ return word_count_;
+ }
+ int charCount(bool with_blanks) const
+ {
return char_count_
+ (with_blanks ? blank_count_ : 0);
}
namespace {
+
struct equivalent_to : public binary_function<FileName, FileName, bool>
{
bool operator()(FileName const & x, FileName const & y) const
{ return equivalent(x, y); }
};
+
}
namespace {
-bool formatSorter(Format const * lhs, Format const * rhs) {
+
+bool formatSorter(Format const * lhs, Format const * rhs)
+{
return _(lhs->prettyname()) < _(rhs->prettyname());
}
+
}
return 0;
}
+
/// Note that comparing contents can only be used for InsetCommand
bool findNextInset(DocIterator & dit, vector<InsetCode> const & codes,
docstring const & contents)
namespace {
+
docstring getLaTeXMarkup(docstring const & macro, docstring const & author,
docstring const & chgTime,
OutputParams const & runparams)
return ods.str();
}
+
} //namespace anon
Chktex::Chktex(string const & chktex, string const & f, string const & p)
: cmd(chktex), file(f), path(p)
-{
-}
+{}
int Chktex::run(TeXErrors &terr)
CmdDef::newCmdDefResult CmdDef::newCmdDef(string const & name,
- string const & def)
+ string const & def)
{
string const name2 = trim(name);
return c;
}
+
string const outputLaTeXColor(RGBColor const & color)
{
// this routine returns a LaTeX readable color string in the form
class DocPair {
public:
- DocPair() {}
+ DocPair()
+ {}
DocPair(DocIterator o_, DocIterator n_)
: o(o_), n(n_)
{}
- bool operator!=(DocPair const & rhs) {
+ bool operator!=(DocPair const & rhs)
+ {
// this might not be intuitive but correct for our purpose
return o != rhs.o && n != rhs.n;
}
{}
/// Returns the from pair
- DocPair from() const { return DocPair(o.from, n.from); }
+ DocPair from() const
+ {
+ return DocPair(o.from, n.from);
+ }
/// Returns the to pair
- DocPair to() const { return DocPair(o.to, n.to); }
+ DocPair to() const
+ {
+ return DocPair(o.to, n.to);
+ }
DocRange o;
DocRange n;
template<class T>
class compl_vector {
public:
- compl_vector() {}
+ compl_vector()
+ {}
void reset(T const & def)
{
{}
///
- ~Impl() {}
+ ~Impl()
+ {}
// Algorithm to find the shortest edit string. This algorithm
// only needs a linear amount of memory (linear with the sum
bool abort_;
///
- QString status() {
+ QString status()
+ {
QString status;
status += toqstr("recursion level:") + " " + QString::number(recursion_level_)
+ " " + toqstr("differences:") + " " + QString::number(D_);
}
-static bool equal(DocIterator & o, DocIterator & n) {
+static bool equal(DocIterator & o, DocIterator & n)
+{
// Explicitly check for this, so we won't call
// Paragraph::getChar for the last pos.
bool const o_lastpos = o.pos() == o.lastpos();
class CacheItem {
public:
- CacheItem() {}
+ CacheItem()
+ {}
CacheItem(FileName const & orig_from, string const & to_format,
time_t t, unsigned long c)
: timestamp(t), checksum(c)
<< ' ' << to_format << ' ' << cache_name
<< ' ' << long(timestamp) << ' ' << checksum << '.');
}
- ~CacheItem() {}
+ ~CacheItem()
+ {}
FileName cache_name;
time_t timestamp;
unsigned long checksum;
LASSERT(y < 1000000, /**/);
}
+
// just a helper to be able to set a breakpoint
void lyxbreaker(void const * data, const char * hint, int size)
{
return getout;
}
+
void Counter::set(int v)
{
value_ = v;
}
-
// On the special cases, see http://mathworld.wolfram.com/RomanNumerals.html
// and for a list of roman numerals up to and including 3999, see
// http://www.research.att.com/~njas/sequences/a006968.txt. (Thanks to Joost
for ( ; it != et; it.forwardPos()) {
// avoid invalid nesting when selecting
if (bv.cursorStatus(it) == CUR_INSIDE
- && (!cur.selection() || positionable(it, cur.realAnchor()))) {
- // If this function is ever used again, check whether this
- // is the same as "bv.getPos(it, false)" with boundary = false.
+ && (!cur.selection() || positionable(it, cur.realAnchor()))) {
+ // If this function is ever used again, check
+ // whether this is the same as "bv.getPos(it,
+ // false)" with boundary = false.
Point p = bv.getPos(it);
int xo = p.x_;
int yo = p.y_;
new_cur.boundary(false);
if (!skip_inset &&
text()->checkAndActivateInsetVisual(new_cur, right_pos >= pos(), false)) {
- // we actually move the cursor at the end of this function, for now
- // we just keep track of the new position in new_cur...
+ // we actually move the cursor at the end of this
+ // function, for now we just keep track of the new
+ // position in new_cur...
LYXERR(Debug::RTL, "entering inset at: " << new_cur.pos());
}
return false;
}
- // we actually move the cursor at the end of this function, for now
- // just keep track of the new position in new_cur...
+ // we actually move the cursor at the end of this
+ // function, for now just keep track of the new
+ // position in new_cur...
LYXERR(Debug::RTL, "right edge, moving: " << int(new_cur.pit()) << ","
<< int(new_cur.pos()) << "," << (new_cur.boundary() ? 1 : 0));
// normal movement to the right
else {
new_cur = *this;
- // Recall, if the cursor is at position 'x', that means *before*
- // the character at position 'x'. In RTL, "before" means "to the
- // right of", in LTR, "to the left of". So currently our situation
- // is this: the position to our right is 'right_pos' (i.e., we're
- // currently to the left of 'right_pos'). In order to move to the
- // right, it depends whether or not the character at 'right_pos' is RTL.
+ // Recall, if the cursor is at position 'x', that
+ // means *before* the character at position 'x'. In
+ // RTL, "before" means "to the right of", in LTR, "to
+ // the left of". So currently our situation is this:
+ // the position to our right is 'right_pos' (i.e.,
+ // we're currently to the left of 'right_pos'). In
+ // order to move to the right, it depends whether or
+ // not the character at 'right_pos' is RTL.
new_pos_is_RTL = paragraph().getFontSettings(
buffer()->params(), right_pos).isVisibleRightToLeft();
- // If the character at 'right_pos' *is* LTR, then in order to move to
- // the right of it, we need to be *after* 'right_pos', i.e., move to
- // position 'right_pos' + 1.
+ // If the character at 'right_pos' *is* LTR, then in
+ // order to move to the right of it, we need to be
+ // *after* 'right_pos', i.e., move to position
+ // 'right_pos' + 1.
if (!new_pos_is_RTL) {
new_cur.pos() = right_pos + 1;
// set the boundary to true in two situations:
if (
- // 1. if new_pos is now lastpos, and we're in an RTL paragraph
- // (this means that we're moving right to the end of an LTR chunk
+ // 1. if new_pos is now lastpos, and we're in
+ // an RTL paragraph (this means that we're
+ // moving right to the end of an LTR chunk
// which is at the end of an RTL paragraph);
(new_cur.pos() == lastpos()
&& paragraph().isRTL(buffer()->params()))
- // 2. if the position *after* right_pos is RTL (we want to be
- // *after* right_pos, not before right_pos + 1!)
+ // 2. if the position *after* right_pos is RTL
+ // (we want to be *after* right_pos, not
+ // before right_pos + 1!)
|| paragraph().getFontSettings(buffer()->params(),
new_cur.pos()).isVisibleRightToLeft()
)
else // set the boundary to false
new_cur.boundary(false);
}
- // Otherwise (if the character at position 'right_pos' is RTL), then
- // moving to the right of it is as easy as setting the new position
- // to 'right_pos'.
+ // Otherwise (if the character at position 'right_pos'
+ // is RTL), then moving to the right of it is as easy
+ // as setting the new position to 'right_pos'.
else {
new_cur.pos() = right_pos;
new_cur.boundary(false);
new_cur.boundary(false);
if (!skip_inset &&
text()->checkAndActivateInsetVisual(new_cur, left_pos >= pos(), true)) {
- // we actually move the cursor at the end of this function, for now
- // we just keep track of the new position in new_cur...
+ // we actually move the cursor at the end of this
+ // function, for now we just keep track of the new
+ // position in new_cur...
LYXERR(Debug::RTL, "entering inset at: " << new_cur.pos());
}
return false;
}
- // we actually move the cursor at the end of this function, for now
- // just keep track of the new position in new_cur...
+ // we actually move the cursor at the end of this
+ // function, for now just keep track of the new
+ // position in new_cur...
LYXERR(Debug::RTL, "left edge, moving: " << int(new_cur.pit()) << ","
<< int(new_cur.pos()) << "," << (new_cur.boundary() ? 1 : 0));
// normal movement to the left
else {
new_cur = *this;
- // Recall, if the cursor is at position 'x', that means *before*
- // the character at position 'x'. In RTL, "before" means "to the
- // right of", in LTR, "to the left of". So currently our situation
- // is this: the position to our left is 'left_pos' (i.e., we're
- // currently to the right of 'left_pos'). In order to move to the
- // left, it depends whether or not the character at 'left_pos' is RTL.
+ // Recall, if the cursor is at position 'x', that
+ // means *before* the character at position 'x'. In
+ // RTL, "before" means "to the right of", in LTR, "to
+ // the left of". So currently our situation is this:
+ // the position to our left is 'left_pos' (i.e., we're
+ // currently to the right of 'left_pos'). In order to
+ // move to the left, it depends whether or not the
+ // character at 'left_pos' is RTL.
new_pos_is_RTL = paragraph().getFontSettings(
buffer()->params(), left_pos).isVisibleRightToLeft();
- // If the character at 'left_pos' *is* RTL, then in order to move to
- // the left of it, we need to be *after* 'left_pos', i.e., move to
- // position 'left_pos' + 1.
+ // If the character at 'left_pos' *is* RTL, then in
+ // order to move to the left of it, we need to be
+ // *after* 'left_pos', i.e., move to position
+ // 'left_pos' + 1.
if (new_pos_is_RTL) {
new_cur.pos() = left_pos + 1;
// set the boundary to true in two situations:
if (
- // 1. if new_pos is now lastpos and we're in an LTR paragraph
- // (this means that we're moving left to the end of an RTL chunk
+ // 1. if new_pos is now lastpos and we're in
+ // an LTR paragraph (this means that we're
+ // moving left to the end of an RTL chunk
// which is at the end of an LTR paragraph);
(new_cur.pos() == lastpos()
&& !paragraph().isRTL(buffer()->params()))
- // 2. if the position *after* left_pos is not RTL (we want to be
- // *after* left_pos, not before left_pos + 1!)
+ // 2. if the position *after* left_pos is not
+ // RTL (we want to be *after* left_pos, not
+ // before left_pos + 1!)
|| !paragraph().getFontSettings(buffer()->params(),
new_cur.pos()).isVisibleRightToLeft()
)
else // set the boundary to false
new_cur.boundary(false);
}
- // Otherwise (if the character at position 'left_pos' is LTR), then
- // moving to the left of it is as easy as setting the new position
- // to 'left_pos'.
+ // Otherwise (if the character at position 'left_pos'
+ // is LTR), then moving to the left of it is as easy
+ // as setting the new position to 'left_pos'.
else {
new_cur.pos() = left_pos;
new_cur.boundary(false);
LYXERR(Debug::RTL, "bidi: " << row.pos() << "--" << row.endpos());
- // The cursor is painted *before* the character at pos(), or, if 'boundary'
- // is true, *after* the character at (pos() - 1). So we already have one
- // known position around the cursor:
+ // The cursor is painted *before* the character at pos(), or,
+ // if 'boundary' is true, *after* the character at (pos() -
+ // 1). So we already have one known position around the
+ // cursor:
pos_type const known_pos = boundary() && pos() > 0 ? pos() - 1 : pos();
- // edge case: if we're at the end of the paragraph, things are a little
- // different (because lastpos is a position which does not really "exist"
- // --- there's no character there yet).
+ // edge case: if we're at the end of the paragraph, things are
+ // a little different (because lastpos is a position which
+ // does not really "exist" --- there's no character there
+ // yet).
if (known_pos == lastpos()) {
if (par.isRTL(buf.params())) {
left_pos = -1;
return;
}
- // Whether 'known_pos' is to the left or to the right of the cursor depends
- // on whether it is an RTL or LTR character...
+ // Whether 'known_pos' is to the left or to the right of the
+ // cursor depends on whether it is an RTL or LTR character...
bool const cur_is_RTL =
par.getFontSettings(buf.params(), known_pos).isVisibleRightToLeft();
// ... in the following manner:
- // For an RTL character, "before" means "to the right" and "after" means
- // "to the left"; and for LTR, it's the reverse. So, 'known_pos' is to the
- // right of the cursor if (RTL && boundary) or (!RTL && !boundary):
+ // For an RTL character, "before"
+ // means "to the right" and "after" means "to the left"; and
+ // for LTR, it's the reverse. So, 'known_pos' is to the right
+ // of the cursor if (RTL && boundary) or (!RTL && !boundary):
bool const known_pos_on_right = cur_is_RTL == boundary();
- // So we now know one of the positions surrounding the cursor. Let's
- // determine the other one:
+ // So we now know one of the positions surrounding the cursor.
+ // Let's determine the other one:
if (known_pos_on_right) {
right_pos = known_pos;
// *visual* position of 'left_pos':
pos_type v_left_pos = bidi.log2vis(right_pos) - 1;
- // If the position we just identified as 'left_pos' is a "skipped
- // separator" (a separator which is at the logical end of a row,
- // except for the last row in a paragraph; such separators are not
- // painted, so they "are not really there"; note that in bidi text,
- // such a separator could appear visually in the middle of a row),
- // set 'left_pos' to the *next* position to the left.
+ // If the position we just identified as 'left_pos' is
+ // a "skipped separator" (a separator which is at the
+ // logical end of a row, except for the last row in a
+ // paragraph; such separators are not painted, so they
+ // "are not really there"; note that in bidi text,
+ // such a separator could appear visually in the
+ // middle of a row), set 'left_pos' to the *next*
+ // position to the left.
if (bidi.inRange(v_left_pos)
&& bidi.vis2log(v_left_pos) + 1 == row.endpos()
&& row.endpos() < lastpos()
left_pos = -1;
else
left_pos = bidi.vis2log(v_left_pos);
- // If the position we identified as 'right_pos' is a "skipped
- // separator", set 'right_pos' to the *next* position to the right.
+ // If the position we identified as 'right_pos' is a
+ // "skipped separator", set 'right_pos' to the *next*
+ // position to the right.
if (right_pos + 1 == row.endpos() && row.endpos() < lastpos()
&& par.isSeparator(right_pos)) {
pos_type const v_right_pos = bidi.log2vis(right_pos) + 1;
left_pos = known_pos;
// *visual* position of 'right_pos'
pos_type v_right_pos = bidi.log2vis(left_pos) + 1;
- // If the position we just identified as 'right_pos' is a "skipped
- // separator", set 'right_pos' to the *next* position to the right.
+ // If the position we just identified as 'right_pos'
+ // is a "skipped separator", set 'right_pos' to the
+ // *next* position to the right.
if (bidi.inRange(v_right_pos)
&& bidi.vis2log(v_right_pos) + 1 == row.endpos()
&& row.endpos() < lastpos()
right_pos = -1;
else
right_pos = bidi.vis2log(v_right_pos);
- // If the position we identified as 'left_pos' is a "skipped
- // separator", set 'left_pos' to the *next* position to the left.
+ // If the position we identified as 'left_pos' is a
+ // "skipped separator", set 'left_pos' to the *next*
+ // position to the left.
if (left_pos + 1 == row.endpos() && row.endpos() < lastpos()
&& par.isSeparator(left_pos)) {
pos_type const v_left_pos = bidi.log2vis(left_pos) - 1;
Row const & row = textRow();
bool par_is_LTR = !par.isRTL(buf.params());
- // Inside a table, determining whether to move to the next or previous row
- // should be done based on the table's direction.
+ // Inside a table, determining whether to move to the next or
+ // previous row should be done based on the table's direction.
int s = depth() - 1;
if (s >= 1 && (*this)[s].inset().asInsetTabular()) {
par_is_LTR = !(*this)[s].inset().asInsetTabular()->isRightToLeft(*this);
LYXERR(Debug::RTL, "Inside table! par_is_LTR=" << (par_is_LTR ? 1 : 0));
}
- // if moving left in an LTR paragraph or moving right in an RTL one,
- // move to previous row
+ // if moving left in an LTR paragraph or moving right in an
+ // RTL one, move to previous row
if (par_is_LTR == movingLeft) {
if (row.pos() == 0) { // we're at first row in paragraph
if (pit() == 0) // no previous paragraph! don't move
boundary(false);
}
}
- // if moving left in an RTL paragraph or moving right in an LTR one,
- // move to next row
+ // if moving left in an RTL paragraph or moving right in an
+ // LTR one, move to next row
else {
if (row.endpos() == lastpos()) { // we're at last row in paragraph
if (pit() == lastpit()) // last paragraph! don't move
else {
pos() = bidi.vis2log(row.pos());
- // Moving to the leftmost position in the row, the cursor should
- // normally be placed to the *left* of the leftmost position.
- // A very common exception, though, is if the leftmost character
- // also happens to be the separator at the (logical) end of the row
- // --- in this case, the separator is positioned beyond the left
- // margin, and we don't want to move the cursor there (moving to
- // the left of the separator is equivalent to moving to the next
- // line). So, in this case we actually want to place the cursor
- // to the *right* of the leftmost position (the separator).
- // Another exception is if we're moving to the logically last
- // position in the row, which is *not* a separator: this means
- // that the entire row has no separators (if there were any, the
- // row would have been broken there); and therefore in this case
- // we also move to the *right* of the last position (this indicates
- // to the user that there is no space after this position, and is
- // consistent with the behavior in the middle of a row --- moving
- // right or left moves to the next/previous character; if we were
- // to move to the *left* of this position, that would simulate
- // a separator which is not really there!).
- // Finally, there is an exception to the previous exception: if
- // this non-separator-but-last-position-in-row is an inset, then
- // we *do* want to stay to the left of it anyway: this is the
+ // Moving to the leftmost position in the row,
+ // the cursor should normally be placed to the
+ // *left* of the leftmost position. A very
+ // common exception, though, is if the
+ // leftmost character also happens to be the
+ // separator at the (logical) end of the row
+ // --- in this case, the separator is
+ // positioned beyond the left margin, and we
+ // don't want to move the cursor there (moving
+ // to the left of the separator is equivalent
+ // to moving to the next line). So, in this
+ // case we actually want to place the cursor
+ // to the *right* of the leftmost position
+ // (the separator). Another exception is if
+ // we're moving to the logically last position
+ // in the row, which is *not* a separator:
+ // this means that the entire row has no
+ // separators (if there were any, the row
+ // would have been broken there); and
+ // therefore in this case we also move to the
+ // *right* of the last position (this
+ // indicates to the user that there is no
+ // space after this position, and is
+ // consistent with the behavior in the middle
+ // of a row --- moving right or left moves to
+ // the next/previous character; if we were to
+ // move to the *left* of this position, that
+ // would simulate a separator which is not
+ // really there!). Finally, there is an
+ // exception to the previous exception: if
+ // this non-separator-but-last-position-in-row
+ // is an inset, then we *do* want to stay to
+ // the left of it anyway: this is the
// "boundary" which we simulate at insets.
- // Another exception is when row.endpos() is 0.
+
+ // Another exception is when row.endpos() is
+ // 0.
// do we want to be to the right of pos?
// as explained above, if at last pos in row, stay to the right
else {
pos() = row.endpos() > 0 ? bidi.vis2log(row.endpos() - 1) : 0;
- // Moving to the rightmost position in the row, the cursor should
- // normally be placed to the *right* of the rightmost position.
- // A very common exception, though, is if the rightmost character
- // also happens to be the separator at the (logical) end of the row
- // --- in this case, the separator is positioned beyond the right
- // margin, and we don't want to move the cursor there (moving to
- // the right of the separator is equivalent to moving to the next
- // line). So, in this case we actually want to place the cursor
- // to the *left* of the rightmost position (the separator).
- // Another exception is if we're moving to the logically last
- // position in the row, which is *not* a separator: this means
- // that the entire row has no separators (if there were any, the
- // row would have been broken there); and therefore in this case
- // we also move to the *left* of the last position (this indicates
- // to the user that there is no space after this position, and is
- // consistent with the behavior in the middle of a row --- moving
- // right or left moves to the next/previous character; if we were
- // to move to the *right* of this position, that would simulate
- // a separator which is not really there!).
- // Finally, there is an exception to the previous exception: if
- // this non-separator-but-last-position-in-row is an inset, then
- // we *do* want to stay to the right of it anyway: this is the
- // "boundary" which we simulate at insets.
- // Another exception is when row.endpos() is 0.
+ // Moving to the rightmost position in the
+ // row, the cursor should normally be placed
+ // to the *right* of the rightmost position. A
+ // very common exception, though, is if the
+ // rightmost character also happens to be the
+ // separator at the (logical) end of the row
+ // --- in this case, the separator is
+ // positioned beyond the right margin, and we
+ // don't want to move the cursor there (moving
+ // to the right of the separator is equivalent
+ // to moving to the next line). So, in this
+ // case we actually want to place the cursor
+ // to the *left* of the rightmost position
+ // (the separator). Another exception is if
+ // we're moving to the logically last position
+ // in the row, which is *not* a separator:
+ // this means that the entire row has no
+ // separators (if there were any, the row
+ // would have been broken there); and
+ // therefore in this case we also move to the
+ // *left* of the last position (this indicates
+ // to the user that there is no space after
+ // this position, and is consistent with the
+ // behavior in the middle of a row --- moving
+ // right or left moves to the next/previous
+ // character; if we were to move to the
+ // *right* of this position, that would
+ // simulate a separator which is not really
+ // there!). Finally, there is an exception to
+ // the previous exception: if this
+ // non-separator-but-last-position-in-row is
+ // an inset, then we *do* want to stay to the
+ // right of it anyway: this is the "boundary"
+ // which we simulate at insets. Another
+ // exception is when row.endpos() is 0.
// do we want to be to the left of pos?
// as explained above, if at last pos in row, stay to the left,
return false;
}
+
bool Cursor::upDownInText(bool up, bool & updateNeeded)
{
LASSERT(text(), /**/);
setTargetX(xo);
else if (xo - textTargetOffset() != x_target() &&
depth() == beforeDispatchCursor_.depth()) {
- // In text mode inside the line (not left or right) possibly set a new target_x,
- // but only if we are somewhere else than the previous target-offset.
+ // In text mode inside the line (not left or right)
+ // possibly set a new target_x, but only if we are
+ // somewhere else than the previous target-offset.
- // We want to keep the x-target on subsequent up/down movements
- // that cross beyond the end of short lines. Thus a special
- // handling when the cursor is at the end of line: Use the new
- // x-target only if the old one was before the end of line
- // or the old one was after the beginning of the line
+ // We want to keep the x-target on subsequent up/down
+ // movements that cross beyond the end of short lines.
+ // Thus a special handling when the cursor is at the
+ // end of line: Use the new x-target only if the old
+ // one was before the end of line or the old one was
+ // after the beginning of the line
bool inRTL = isWithinRtlParagraph(*this);
bool left;
bool right;
namespace {
+
docstring parbreak(Cursor const * cur)
{
odocstringstream os;
os << '\n';
return os.str();
}
+
}
Font Cursor::getFont() const
{
- // The logic here should more or less match to the Cursor::setCurrentFont
- // logic, i.e. the cursor height should give a hint what will happen
- // if a character is entered.
+ // The logic here should more or less match to the
+ // Cursor::setCurrentFont logic, i.e. the cursor height should
+ // give a hint what will happen if a character is entered.
// HACK. far from being perfect...
putClipboard(theCuts[0].first, theCuts[0].second, plaintext);
}
+
namespace {
void copySelectionToStack(Cursor const & cur, CutStack & cutstack)
DepList::const_iterator cit = deplist.begin();
DepList::const_iterator end = deplist.end();
for (; cit != end; ++cit) {
- if (cit->second.changed()) return true;
+ if (cit->second.changed())
+ return true;
}
return false;
}
DepList::const_iterator cit = deplist.begin();
DepList::const_iterator end = deplist.end();
for (; cit != end; ++cit) {
- if (suffixIs(cit->first.absFileName(), ext)) {
+ if (suffixIs(cit->first.absFileName(), ext))
return true;
- }
}
return false;
}
: boundary_(false), inset_(0), buffer_(0)
{}
+
// We could be able to get rid of this if only every BufferView were
// associated to a buffer on construction.
DocIterator::DocIterator(Buffer * buf)
struct EnchantChecker::Private
{
- Private() {}
+ Private()
+ {}
~Private();
Spellers::iterator it = spellers_.begin();
Spellers::iterator end = spellers_.end();
- for (; it != end; ++it) {
+ for (; it != end; ++it)
delete it->second.speller;
- }
}
}
-EnchantChecker::EnchantChecker(): d(new Private)
-{
-}
+EnchantChecker::EnchantChecker()
+ : d(new Private)
+{}
EnchantChecker::~EnchantChecker()
Encodings::Encodings()
-{
-}
+{}
void Encodings::read(FileName const & encfile, FileName const & symbolsfile)
*this = sane_font;
}
+
/// Decreases font size_ by one
FontInfo & FontInfo::decSize()
{
namespace {
- void appendSep(string & s1, string const & s2) {
- if (s2.empty())
- return;
- s1 += s1.empty() ? "" : "\n";
- s1 += s2;
- }
+void appendSep(string & s1, string const & s2)
+{
+ if (s2.empty())
+ return;
+ s1 += s1.empty() ? "" : "\n";
+ s1 += s2;
+}
- string makeCSSTag(string const & key, string const & val)
- {
- return key + ": " + val + ";";
- }
+string makeCSSTag(string const & key, string const & val)
+{
+ return key + ": " + val + ";";
+}
- string getFamilyCSS(FontFamily const & f)
- {
- switch (f) {
- case ROMAN_FAMILY:
- return "serif";
- case SANS_FAMILY:
- return "sans-serif";
- case TYPEWRITER_FAMILY:
- return "monospace";
- case SYMBOL_FAMILY:
- case CMR_FAMILY:
- case CMSY_FAMILY:
- case CMM_FAMILY:
- case CMEX_FAMILY:
- case MSA_FAMILY:
- case MSB_FAMILY:
- case EUFRAK_FAMILY:
- case RSFS_FAMILY:
- case WASY_FAMILY:
- case ESINT_FAMILY:
- case INHERIT_FAMILY:
- case IGNORE_FAMILY:
- break;
- }
- return "";
+string getFamilyCSS(FontFamily const & f)
+{
+ switch (f) {
+ case ROMAN_FAMILY:
+ return "serif";
+ case SANS_FAMILY:
+ return "sans-serif";
+ case TYPEWRITER_FAMILY:
+ return "monospace";
+ case SYMBOL_FAMILY:
+ case CMR_FAMILY:
+ case CMSY_FAMILY:
+ case CMM_FAMILY:
+ case CMEX_FAMILY:
+ case MSA_FAMILY:
+ case MSB_FAMILY:
+ case EUFRAK_FAMILY:
+ case RSFS_FAMILY:
+ case WASY_FAMILY:
+ case ESINT_FAMILY:
+ case INHERIT_FAMILY:
+ case IGNORE_FAMILY:
+ break;
}
+ return "";
+}
- string getSeriesCSS(FontSeries const & s)
- {
- switch (s) {
- case MEDIUM_SERIES:
- return "normal";
- case BOLD_SERIES:
- return "bold";
- case INHERIT_SERIES:
- case IGNORE_SERIES:
- break;
- }
- return "";
+string getSeriesCSS(FontSeries const & s)
+{
+ switch (s) {
+ case MEDIUM_SERIES:
+ return "normal";
+ case BOLD_SERIES:
+ return "bold";
+ case INHERIT_SERIES:
+ case IGNORE_SERIES:
+ break;
}
+ return "";
+}
- string getShapeCSS(FontShape const & s)
- {
- string fs = "normal";
- string fv = "normal";
- switch (s) {
- case UP_SHAPE: break;
- case ITALIC_SHAPE: fs = "italic"; break;
- case SLANTED_SHAPE: fs = "oblique"; break;
- case SMALLCAPS_SHAPE: fv = "small-caps"; break;
- case IGNORE_SHAPE:
- case INHERIT_SHAPE:
- fs = ""; fv = ""; break;
- }
- string retval;
- if (!fs.empty())
- appendSep(retval, makeCSSTag("font-style", fs));
- if (!fv.empty())
- appendSep(retval, makeCSSTag("font-variant", fv));
- return retval;
+string getShapeCSS(FontShape const & s)
+{
+ string fs = "normal";
+ string fv = "normal";
+ switch (s) {
+ case UP_SHAPE: break;
+ case ITALIC_SHAPE: fs = "italic"; break;
+ case SLANTED_SHAPE: fs = "oblique"; break;
+ case SMALLCAPS_SHAPE: fv = "small-caps"; break;
+ case IGNORE_SHAPE:
+ case INHERIT_SHAPE:
+ fs = ""; fv = ""; break;
}
+ string retval;
+ if (!fs.empty())
+ appendSep(retval, makeCSSTag("font-style", fs));
+ if (!fv.empty())
+ appendSep(retval, makeCSSTag("font-variant", fv));
+ return retval;
+}
- string getSizeCSS(FontSize const & s)
- {
- switch (s) {
- case FONT_SIZE_TINY:
- return "xx-small";
- case FONT_SIZE_SCRIPT:
- return "x-small";
- case FONT_SIZE_FOOTNOTE:
- case FONT_SIZE_SMALL:
- return "small";
- case FONT_SIZE_NORMAL:
- return "medium";
- case FONT_SIZE_LARGE:
- return "large";
- case FONT_SIZE_LARGER:
- case FONT_SIZE_LARGEST:
- return "x-large";
- case FONT_SIZE_HUGE:
- case FONT_SIZE_HUGER:
- return "xx-large";
- case FONT_SIZE_INCREASE:
- return "larger";
- case FONT_SIZE_DECREASE:
- return "smaller";
- case FONT_SIZE_IGNORE:
- case FONT_SIZE_INHERIT:
- break;
- }
- return "";
+string getSizeCSS(FontSize const & s)
+{
+ switch (s) {
+ case FONT_SIZE_TINY:
+ return "xx-small";
+ case FONT_SIZE_SCRIPT:
+ return "x-small";
+ case FONT_SIZE_FOOTNOTE:
+ case FONT_SIZE_SMALL:
+ return "small";
+ case FONT_SIZE_NORMAL:
+ return "medium";
+ case FONT_SIZE_LARGE:
+ return "large";
+ case FONT_SIZE_LARGER:
+ case FONT_SIZE_LARGEST:
+ return "x-large";
+ case FONT_SIZE_HUGE:
+ case FONT_SIZE_HUGER:
+ return "xx-large";
+ case FONT_SIZE_INCREASE:
+ return "larger";
+ case FONT_SIZE_DECREASE:
+ return "smaller";
+ case FONT_SIZE_IGNORE:
+ case FONT_SIZE_INHERIT:
+ break;
}
+ return "";
+}
} // namespace anonymous
class FormatNamesEqual : public unary_function<Format, bool> {
public:
FormatNamesEqual(string const & name)
- : name_(name) {}
+ : name_(name)
+ {}
bool operator()(Format const & f) const
{
return f.name() == name_;
class FormatExtensionsEqual : public unary_function<Format, bool> {
public:
FormatExtensionsEqual(string const & extension)
- : extension_(extension) {}
+ : extension_(extension)
+ {}
bool operator()(Format const & f) const
{
return f.hasExtension(extension_);
class FormatMimeEqual : public unary_function<Format, bool> {
public:
FormatMimeEqual(string const & mime)
- : mime_(mime) {}
+ : mime_(mime)
+ {}
bool operator()(Format const & f) const
{
// The test for empty mime strings is needed since we allow
class FormatPrettyNameEqual : public unary_function<Format, bool> {
public:
FormatPrettyNameEqual(string const & prettyname)
- : prettyname_(prettyname) {}
+ : prettyname_(prettyname)
+ {}
bool operator()(Format const & f) const
{
return f.prettyname() == prettyname_;
namespace {
+
typedef Translator<OutputParams::FLAVOR, string> FlavorTranslator;
+
FlavorTranslator initFlavorTranslator()
{
FlavorTranslator f(OutputParams::LATEX, "latex");
static FlavorTranslator translator = initFlavorTranslator();
return translator;
}
+
}
FuncStatus::FuncStatus()
: v_(OK)
-{
-}
+{}
void FuncStatus::clear()
return result;
}
+
int HSpace::inPixels(BufferView const & bv) const
{
switch (kind_) {
~Private();
void cleanCache();
- void setUserPath(std::string path);
+ void setUserPath(std::string const & path);
const string dictPath(int selector);
bool haveLanguageFiles(string const & hpath);
bool haveDictionary(Language const * lang, string & hpath);
}
-void HunspellChecker::Private::setUserPath(std::string path)
+void HunspellChecker::Private::setUserPath(std::string const & path)
{
if (user_path_ != lyxrc.hunspelldir_path) {
cleanCache();
bool HunspellChecker::Private::haveDictionary(Language const * lang, string & hpath)
{
- if (hpath.empty()) {
+ if (hpath.empty())
return false;
- }
LYXERR(Debug::FILES, "check hunspell path: " << hpath
<< " for language " << (lang ? lang->lang() : "NULL" ));
}
// another try with code, '_' replaced by '-'
h_path = addName(hpath, subst(lang->code(), '_', '-'));
- if (!haveLanguageFiles(h_path)) {
+ if (!haveLanguageFiles(h_path))
return false;
- }
LYXERR(Debug::FILES, " found " << h_path);
hpath = h_path;
return true;
bool result = false;
setUserPath(lyxrc.hunspelldir_path);
- for ( int p = 0; !result && p < maxLookupSelector(); p++ ) {
+ for (int p = 0; !result && p < maxLookupSelector(); ++p) {
string lpath = dictPath(p);
result = haveDictionary(lang, lpath);
}
{
setUserPath(lyxrc.hunspelldir_path);
Spellers::iterator it = spellers_.find(lang->lang());
- if (it != spellers_.end()) {
+ if (it != spellers_.end())
return it->second;
- }
return addSpeller(lang);
}
Hunspell * HunspellChecker::Private::addSpeller(Language const * lang)
{
Hunspell * h = 0;
- for ( int p = 0; p < maxLookupSelector() && 0 == h; p++ ) {
+ for (int p = 0; p < maxLookupSelector() && 0 == h; ++p) {
string lpath = dictPath(p);
h = addSpeller(lang, lpath);
}
- if (0 != h) {
+ if (h) {
string const encoding = h->get_dic_encoding();
PersonalWordList * pd = new PersonalWordList(lang->lang());
pd->load();
Spellers::const_iterator it = spellers_.begin();
Spellers::const_iterator et = spellers_.end();
- for (; it != et; ++it) {
+ for (; it != et; ++it)
result += it->second != 0;
- }
return result;
}
{
IgnoreList::const_iterator it = ignored_.begin();
for (; it != ignored_.end(); ++it) {
- if ((*it).lang()->code() != wl.lang()->code())
+ if (it->lang()->code() != wl.lang()->code())
continue;
- if ((*it).word() == wl.word())
+ if (it->word() == wl.word())
return true;
}
return false;
}
-HunspellChecker::HunspellChecker(): d(new Private)
-{
-}
+HunspellChecker::HunspellChecker()
+ : d(new Private)
+{}
HunspellChecker::~HunspellChecker()
{
if (!lang)
return false;
- return (d->haveDictionary(lang));
+ return d->haveDictionary(lang);
}
class IndexNamesEqual : public std::unary_function<Index, bool>
{
public:
- IndexNamesEqual(docstring const & name) : name_(name) {}
+ IndexNamesEqual(docstring const & name)
+ : name_(name)
+ {}
bool operator()(Index const & index) const
{
class IndexHasShortcut : public std::unary_function<Index, bool>
{
public:
- IndexHasShortcut(docstring const & shortcut) : shortc_(shortcut) {}
+ IndexHasShortcut(docstring const & shortcut)
+ : shortc_(shortcut)
+ {}
bool operator()(Index const & index) const
{
nomath);
}
+
bool LaTeXFeatures::mustProvide(string const & name) const
{
return isRequired(name) && !isProvided(name);
namespace {
+
docstring const getFloatI18nPreamble(docstring const & type,
docstring const & name, Language const * lang,
Encoding const & enc, bool const polyglossia)
}
-docstring Layout::htmlstyle() const {
+docstring Layout::htmlstyle() const
+{
if (!htmlstyle_.empty() && !htmlforcecss_)
return htmlstyle_;
if (htmldefaultstyle_.empty())
namespace {
- string makeMarginValue(char const * side, double d) {
- ostringstream os;
- os << "margin-" << side << ": " << d << "ex;\n";
- return os.str();
- }
+
+string makeMarginValue(char const * side, double d)
+{
+ ostringstream os;
+ os << "margin-" << side << ": " << d << "ex;\n";
+ return os.str();
+}
+
}
-void Layout::makeDefaultCSS() const {
+void Layout::makeDefaultCSS() const
+{
// this never needs to be redone, since reloading layouts will
// wipe out what we did before.
if (!htmldefaultstyle_.empty())
}
-void LayoutFileList::reset(LayoutFileIndex const & classname) {
+void LayoutFileList::reset(LayoutFileIndex const & classname)
+{
LASSERT(haveClass(classname), /**/);
LayoutFile * tc = classmap_[classname];
LayoutFile * tmpl =
}
+
LayoutFileIndex LayoutFileList::addEmptyClass(string const & textclass)
{
FileName const tempLayout = FileName::tempName("basic_layout");
}
-LayoutFileIndex
- LayoutFileList::addLocalLayout(string const & textclass, string const & path)
+LayoutFileIndex LayoutFileList::addLocalLayout(
+ string const & textclass, string const & path)
{
// FIXME There is a bug here: 4593
//
return textclass;
}
}
- // If .layout is not in local directory, or an invalid layout is found, return null
+ // If .layout is not in local directory, or an invalid layout
+ // is found, return null
return string();
}
} // namespace anon
/// The main application class private implementation.
-struct LyX::Impl
-{
- Impl() : latexfonts_(0), spell_checker_(0), apple_spell_checker_(0), aspell_checker_(0), enchant_checker_(0), hunspell_checker_(0)
- {
- }
+struct LyX::Impl {
+ Impl()
+ : latexfonts_(0), spell_checker_(0), apple_spell_checker_(0), aspell_checker_(0), enchant_checker_(0), hunspell_checker_(0)
+ {}
~Impl()
{
SpellChecker * hunspell_checker_;
};
+
///
frontend::Application * theApp()
{
}
-vector<string> LyXModule::prerequisites() const {
+vector<string> LyXModule::prerequisites() const
+{
#ifdef TEX2LYX
return vector<string>();
#else
}
-bool LyXModule::isAvailable() const {
+bool LyXModule::isAvailable() const
+{
#ifdef TEX2LYX
return true;
#else
// used when sorting the module list.
-class ModuleSorter
-{
+class ModuleSorter {
public:
int operator()(LyXModule const & lm1, LyXModule const & lm2) const
{
return 0;
}
+
LyXModule * ModuleList::operator[](string const & str)
{
LyXModuleList::iterator it = modlist_.begin();
namespace lyx {
namespace {
+
/// Inset identifier (above 0x10ffff, for ucs-4)
char_type const META_INSET = 0x200001;
+
}
class SpellCheckerState {
public:
- SpellCheckerState() {
+ SpellCheckerState()
+ {
needs_refresh_ = true;
current_change_number_ = 0;
}
return empty_;
}
- bool needsRefresh() const {
+ bool needsRefresh() const
+ {
return needs_refresh_;
}
- SpellChecker::ChangeNumber currentChangeNumber() const {
+ SpellChecker::ChangeNumber currentChangeNumber() const
+ {
return current_change_number_;
}
- void refreshRange(pos_type & first, pos_type & last) const {
+ void refreshRange(pos_type & first, pos_type & last) const
+ {
first = refresh_.first;
last = refresh_.last;
}
- void needsRefresh(pos_type pos) {
+ void needsRefresh(pos_type pos)
+ {
if (needs_refresh_ && pos != -1) {
if (pos < refresh_.first)
refresh_.first = pos;
needs_refresh_ = pos != -1;
}
- void needsCompleteRefresh(SpellChecker::ChangeNumber change_number) {
+ void needsCompleteRefresh(SpellChecker::ChangeNumber change_number)
+ {
needs_refresh_ = true;
refresh_.first = 0;
refresh_.last = -1;
current_change_number_ = change_number;
}
-
private:
typedef vector<SpellResultRange> Ranges;
typedef Ranges::const_iterator RangesIterator;
Language * getSpellLanguage(pos_type const from) const;
Language * locateSpellRange(pos_type & from, pos_type & to,
- SkipPositions & skips) const;
+ SkipPositions & skips) const;
- bool hasSpellerChange() const {
+ bool hasSpellerChange() const
+ {
SpellChecker::ChangeNumber speller_change_number = 0;
if (theSpellChecker())
speller_change_number = theSpellChecker()->changeNumber();
speller_state_.setRange(fp, state);
}
- void requestSpellCheck(pos_type pos) {
+ void requestSpellCheck(pos_type pos)
+ {
if (pos == -1)
speller_state_.needsCompleteRefresh(speller_state_.currentChangeNumber());
else
speller_state_.needsRefresh(pos);
}
- void readySpellCheck() {
+ void readySpellCheck()
+ {
speller_state_.needsRefresh(-1);
}
}
// expand at the beginning of a row only if it is the first row of a paragraph
- if (pos == row.pos()) {
+ if (pos == row.pos())
return pos == 0;
- }
// do not expand in some labels
if (par_->layout().margintype != MARGIN_MANUAL && pos < par_->beginOfBody())
LYXERR(Debug::FILES, "count of saved items: " << words_.size());
}
+
bool PersonalWordList::equalwords(docstring const & w1, docstring const & w2) const
{
return w1 == w2;
LyXComm::LyXComm(string const &, Server *, ClientCallbackfct)
{}
+
void LyXComm::openConnection()
{}
void LyXComm::emergencyCleanup()
{}
+
void LyXComm::read_ready()
{}
#else // defined (HAVE_MKFIFO)
-
LyXComm::LyXComm(string const & pip, Server * cli, ClientCallbackfct ccb)
: pipename_(pip), client_(cli), clientcb_(ccb)
{
int status;
// the single = is intended here.
while ((status = ::read(infd_, charbuf, charbuf_size - 1))) {
-
if (status > 0) {
charbuf[status] = '\0'; // turn it into a c string
read_buffer_ += rtrim(charbuf, "\r");
LYXERR(Debug::LYXSERVER, "LyXComm: Sending '" << msg << '\'');
- if (pipename_.empty()) return;
+ if (pipename_.empty())
+ return;
if (!ready_) {
LYXERR0("LyXComm: Pipes are closed. Could not send " << msg);
int compare(char const * a, char const * b, unsigned int len)
{
- using namespace std;
return strncmp(a, b, len);
}
using namespace lyx::support;
-
namespace lyx {
// Address is the unix address for the socket.
namespace lyx {
-
LastFilesSection::LastFilesSection(unsigned int num) :
default_num_last_files(4),
absolute_max_last_files(100)
return res;
}
+
// Returns the current font and depth as a message.
docstring Text::currentState(Cursor const & cur) const
{
namespace {
- LexerKeyword textClassTags[] = {
- { "addtohtmlpreamble", TC_ADDTOHTMLPREAMBLE },
- { "addtohtmlstyles", TC_ADDTOHTMLSTYLES },
- { "addtopreamble", TC_ADDTOPREAMBLE },
- { "citeengine", TC_CITEENGINE },
- { "citeenginetype", TC_CITEENGINETYPE },
- { "citeformat", TC_CITEFORMAT },
- { "classoptions", TC_CLASSOPTIONS },
- { "columns", TC_COLUMNS },
- { "counter", TC_COUNTER },
- { "defaultbiblio", TC_DEFAULTBIBLIO },
- { "defaultfont", TC_DEFAULTFONT },
- { "defaultmodule", TC_DEFAULTMODULE },
- { "defaultstyle", TC_DEFAULTSTYLE },
- { "excludesmodule", TC_EXCLUDESMODULE },
- { "float", TC_FLOAT },
- { "format", TC_FORMAT },
- { "fullauthorlist", TC_FULLAUTHORLIST },
- { "htmlpreamble", TC_HTMLPREAMBLE },
- { "htmlstyles", TC_HTMLSTYLES },
- { "htmltocsection", TC_HTMLTOCSECTION },
- { "ifcounter", TC_IFCOUNTER },
- { "ifstyle", TC_IFSTYLE },
- { "input", TC_INPUT },
- { "insetlayout", TC_INSETLAYOUT },
- { "leftmargin", TC_LEFTMARGIN },
- { "nocounter", TC_NOCOUNTER },
- { "nofloat", TC_NOFLOAT },
- { "nostyle", TC_NOSTYLE },
- { "outputformat", TC_OUTPUTFORMAT },
- { "outputtype", TC_OUTPUTTYPE },
- { "pagestyle", TC_PAGESTYLE },
- { "preamble", TC_PREAMBLE },
- { "provides", TC_PROVIDES },
- { "providesmodule", TC_PROVIDESMODULE },
- { "requires", TC_REQUIRES },
- { "rightmargin", TC_RIGHTMARGIN },
- { "secnumdepth", TC_SECNUMDEPTH },
- { "sides", TC_SIDES },
- { "style", TC_STYLE },
- { "titlelatexname", TC_TITLELATEXNAME },
- { "titlelatextype", TC_TITLELATEXTYPE },
- { "tocdepth", TC_TOCDEPTH }
- };
+LexerKeyword textClassTags[] = {
+ { "addtohtmlpreamble", TC_ADDTOHTMLPREAMBLE },
+ { "addtohtmlstyles", TC_ADDTOHTMLSTYLES },
+ { "addtopreamble", TC_ADDTOPREAMBLE },
+ { "citeengine", TC_CITEENGINE },
+ { "citeenginetype", TC_CITEENGINETYPE },
+ { "citeformat", TC_CITEFORMAT },
+ { "classoptions", TC_CLASSOPTIONS },
+ { "columns", TC_COLUMNS },
+ { "counter", TC_COUNTER },
+ { "defaultbiblio", TC_DEFAULTBIBLIO },
+ { "defaultfont", TC_DEFAULTFONT },
+ { "defaultmodule", TC_DEFAULTMODULE },
+ { "defaultstyle", TC_DEFAULTSTYLE },
+ { "excludesmodule", TC_EXCLUDESMODULE },
+ { "float", TC_FLOAT },
+ { "format", TC_FORMAT },
+ { "fullauthorlist", TC_FULLAUTHORLIST },
+ { "htmlpreamble", TC_HTMLPREAMBLE },
+ { "htmlstyles", TC_HTMLSTYLES },
+ { "htmltocsection", TC_HTMLTOCSECTION },
+ { "ifcounter", TC_IFCOUNTER },
+ { "ifstyle", TC_IFSTYLE },
+ { "input", TC_INPUT },
+ { "insetlayout", TC_INSETLAYOUT },
+ { "leftmargin", TC_LEFTMARGIN },
+ { "nocounter", TC_NOCOUNTER },
+ { "nofloat", TC_NOFLOAT },
+ { "nostyle", TC_NOSTYLE },
+ { "outputformat", TC_OUTPUTFORMAT },
+ { "outputtype", TC_OUTPUTTYPE },
+ { "pagestyle", TC_PAGESTYLE },
+ { "preamble", TC_PREAMBLE },
+ { "provides", TC_PROVIDES },
+ { "providesmodule", TC_PROVIDESMODULE },
+ { "requires", TC_REQUIRES },
+ { "rightmargin", TC_RIGHTMARGIN },
+ { "secnumdepth", TC_SECNUMDEPTH },
+ { "sides", TC_SIDES },
+ { "style", TC_STYLE },
+ { "titlelatexname", TC_TITLELATEXNAME },
+ { "titlelatextype", TC_TITLELATEXTYPE },
+ { "tocdepth", TC_TOCDEPTH }
+};
} //namespace anon
return prerequisites_;
}
+
bool TextClass::hasLayout(docstring const & n) const
{
docstring const name = n.empty() ? defaultLayoutName() : n;
Layout const & DocumentClass::htmlTOCLayout() const
{
- if (html_toc_section_.empty()) {
+ if (html_toc_section_.empty())
html_toc_section_ = getTOCLayout().name();
- }
return operator[](html_toc_section_);
}
break;
}
}
- if (idx.empty()) {
+ if (idx.empty())
return make_pair(string(), string());
- }
for (support::FileNameList::const_iterator it = data_files.begin(); it != data_files.end(); ++it) {
if (contains(it->onlyFileName(), basename)) {
data = it->absFileName();
if (thesaurusAvailable(lang))
return make_pair(string(), string());
- if (!thes_path.empty()) {
+ if (!thes_path.empty())
result = getThesaurus(thes_path, lang);
- }
if (result.first.empty() || result.second.empty()) {
string const sys_path = external_path(addName(lyx::support::package().system_support().absFileName(),dataDirectory())) ;
result = getThesaurus(sys_path, lang);
}
-Thesaurus::Thesaurus() : d(new Thesaurus::Private)
+Thesaurus::Thesaurus()
+ : d(new Thesaurus::Private)
{
}
return true;
}
+
bool VCS::checkparentdirs(FileName const & file, std::string const & pathname)
{
FileName dirname = file.onlyPath();
return result;
}
+
int VSpace::inPixels(BufferView const & bv) const
{
// Height of a normal line in pixels (zoom factor considered)
}
-void WordList::cleanupWordLists() {
+void WordList::cleanupWordLists()
+{
map<Language, WordList *>::const_iterator it = theGlobalWordList.begin();
for (; it != theGlobalWordList.end(); ++it)
delete it->second;
}
inset->setBuffer(*buf);
} else {
- // FIXME This branch should be made to use inset codes as the preceding
- // branch does. Unfortunately, that will take some doing. It requires
- // converting the representation of the insets in LyX files so that they
- // use the inset names listed in Inset.cpp. Then, as above, the inset names
- // can be translated to inset codes using insetCode(). And the insets'
- // write() routines should use insetName() rather than hardcoding it.
+ // FIXME This branch should be made to use inset codes
+ // as the preceding branch does. Unfortunately, that
+ // will take some doing. It requires converting the
+ // representation of the insets in LyX files so that
+ // they use the inset names listed in Inset.cpp. Then,
+ // as above, the inset names can be translated to
+ // inset codes using insetCode(). And the insets'
+ // write() routines should use insetName() rather than
+ // hardcoding it.
if (tmptok == "Quotes") {
inset.reset(new InsetQuotes(buf));
} else if (tmptok == "External") {
N_("Column Width %"), N_("Page Width %"), N_("Line Width %"),
N_("Text Height %"), N_("Page Height %"), "" };
+
Length::UNIT unitFromString(string const & data)
{
int i = 0;
} // namespace anon
+
const char * stringFromUnit(int unit)
{
if (unit < 0 || unit > num_units)
return s;
}
+
/// Wrapper for lyx::regex_replace with simpler interface
bool regex_replace(string const & s, string & t, string const & searchstr,
string const & replacestr)
return rv;
}
+
/** Checks if supplied string segment is well-formed from the standpoint of matching open-closed braces.
**
** Verify that closed braces exactly match open braces. This avoids that, for example,
return true;
}
+
/** The class performing a match between a position in the document and the FindAdvOptions.
**/
class MatchStringAdv {
}
-static docstring stringifySearchBuffer(Buffer & buffer, FindAndReplaceOptions const & opt) {
+static docstring stringifySearchBuffer(Buffer & buffer, FindAndReplaceOptions const & opt)
+{
docstring str;
if (!opt.ignoreformat) {
str = buffer_to_latex(buffer);
/// Return separation pos between the leading material and the rest
-static size_t identifyLeading(string const & s) {
+static size_t identifyLeading(string const & s)
+{
string t = s;
// @TODO Support \item[text]
while (regex_replace(t, t, "^\\\\(emph|textbf|subsubsection|subsection|section|subparagraph|paragraph|part)\\*?\\{", "")
// Remove trailing closure of math, macros and environments, so to catch parts of them.
-static int identifyClosing(string & t) {
+static int identifyClosing(string & t)
+{
int open_braces = 0;
do {
LYXERR(Debug::FIND, "identifyClosing(): t now is '" << t << "'");
/// Finds backwards
-int findBackwardsAdv(DocIterator & cur, MatchStringAdv & match) {
+int findBackwardsAdv(DocIterator & cur, MatchStringAdv & match)
+{
if (! cur)
return 0;
// Backup of original position
/** Check if 'len' letters following cursor are all non-lowercase */
-static bool allNonLowercase(DocIterator const & cur, int len) {
+static bool allNonLowercase(DocIterator const & cur, int len)
+{
pos_type end_pos = cur.pos() + len;
for (pos_type pos = cur.pos(); pos != end_pos; ++pos)
if (isLowerCase(cur.paragraph().getChar(pos)))
/** Check if first letter is upper case and second one is lower case */
-static bool firstUppercase(DocIterator const & cur) {
+static bool firstUppercase(DocIterator const & cur)
+{
char_type ch1, ch2;
if (cur.pos() >= cur.lastpos() - 1) {
LYXERR(Debug::FIND, "No upper-case at cur: " << cur);
**
** \fixme What to do with possible further paragraphs in replace buffer ?
**/
-static void changeFirstCase(Buffer & buffer, TextCase first_case, TextCase others_case) {
+static void changeFirstCase(Buffer & buffer, TextCase first_case, TextCase others_case)
+{
ParagraphList::iterator pit = buffer.paragraphs().begin();
pos_type right = pos_type(1);
pit->changeCase(buffer.params(), pos_type(0), right, first_case);
right = pit->size() + 1;
pit->changeCase(buffer.params(), right, right, others_case);
}
+
} // anon namespace
///
ParagraphList::const_iterator searchParagraph(
ParagraphList::const_iterator p,
- ParagraphList::const_iterator const & pend)
+ ParagraphList::const_iterator const & pend)
{
for (++p; p != pend && p->layout().latextype == LATEX_PARAGRAPH; ++p)
;
ParagraphList::const_iterator searchCommand(
- ParagraphList::const_iterator p,
- ParagraphList::const_iterator const & pend)
+ ParagraphList::const_iterator p,
+ ParagraphList::const_iterator const & pend)
{
Layout const & bstyle = p->layout();
ParagraphList::const_iterator searchEnvironment(
- ParagraphList::const_iterator p,
- ParagraphList::const_iterator const & pend)
+ ParagraphList::const_iterator p,
+ ParagraphList::const_iterator const & pend)
{
Layout const & bstyle = p->layout();
size_t const depth = p->params().depth();
}
-ParagraphList::const_iterator makeParagraph(Buffer const & buf,
- odocstream & os,
- OutputParams const & runparams,
- Text const & text,
- ParagraphList::const_iterator const & pbegin,
- ParagraphList::const_iterator const & pend)
+ParagraphList::const_iterator makeParagraph(
+ Buffer const & buf,
+ odocstream & os,
+ OutputParams const & runparams,
+ Text const & text,
+ ParagraphList::const_iterator const & pbegin,
+ ParagraphList::const_iterator const & pend)
{
ParagraphList const & paragraphs = text.paragraphs();
for (ParagraphList::const_iterator par = pbegin; par != pend; ++par) {
}
-ParagraphList::const_iterator makeEnvironment(Buffer const & buf,
- odocstream & os,
- OutputParams const & runparams,
- Text const & text,
- ParagraphList::const_iterator const & pbegin,
- ParagraphList::const_iterator const & pend)
+ParagraphList::const_iterator makeEnvironment(
+ Buffer const & buf,
+ odocstream & os,
+ OutputParams const & runparams,
+ Text const & text,
+ ParagraphList::const_iterator const & pbegin,
+ ParagraphList::const_iterator const & pend)
{
ParagraphList const & paragraphs = text.paragraphs();
ParagraphList::const_iterator par = pbegin;
}
-ParagraphList::const_iterator makeCommand(Buffer const & buf,
- odocstream & os,
- OutputParams const & runparams,
- Text const & text,
- ParagraphList::const_iterator const & pbegin,
- ParagraphList::const_iterator const & pend)
+ParagraphList::const_iterator makeCommand(
+ Buffer const & buf,
+ odocstream & os,
+ OutputParams const & runparams,
+ Text const & text,
+ ParagraphList::const_iterator const & pbegin,
+ ParagraphList::const_iterator const & pend)
{
ParagraphList const & paragraphs = text.paragraphs();
ParagraphList::const_iterator par = pbegin;
namespace {
enum OpenEncoding {
- none,
- inputenc,
- CJK
+ none,
+ inputenc,
+ CJK
};
static int open_encoding_ = none;
return make_pair(d, docstring(d, ' '));
}
+
void writePlaintextParagraph(Buffer const & buf,
Paragraph const & par,
odocstream & os,
// escape what needs escaping
-docstring htmlize(docstring const & str, XHTMLStream::EscapeSettings e) {
+docstring htmlize(docstring const & str, XHTMLStream::EscapeSettings e)
+{
odocstringstream d;
docstring::const_iterator it = str.begin();
docstring::const_iterator en = str.end();
// escape what needs escaping
-string htmlize(string const & str, XHTMLStream::EscapeSettings e) {
+string htmlize(string const & str, XHTMLStream::EscapeSettings e)
+{
ostringstream d;
string::const_iterator it = str.begin();
string::const_iterator en = str.end();
void makeCommand(Buffer const & buf,
- XHTMLStream & xs,
- OutputParams const & runparams,
- Text const & text,
- ParagraphList::const_iterator const & pbegin)
+ XHTMLStream & xs,
+ OutputParams const & runparams,
+ Text const & text,
+ ParagraphList::const_iterator const & pbegin)
{
Layout const & style = pbegin->layout();
if (!style.counter.empty())
}
-string alignmentToCSS(LyXAlignment align) {
+string alignmentToCSS(LyXAlignment align)
+{
switch (align) {
case LYX_ALIGN_BLOCK:
// we are NOT going to use text-align: justify!!
using frontend::Painter;
using frontend::FontMetrics;
+
RowPainter::RowPainter(PainterInfo & pi,
Text const & text, pit_type pit, Row const & row, Bidi & bidi, int x, int y)
: pi_(pi), text_(text),
pi_.pain.text(int(x), yo_ - maxdesc - labeladdon, str, font);
}
+
/** Check if the current paragraph is the last paragraph in a
proof environment */
static int getEndLabel(pit_type p, Text const & text)