2002-03-21 Lars Gullik Bjønnes <larsbj@birdstep.com>
+ * all files: ws cleanup
+
* Makefile.am: remove ld -r stuff
2002-03-21 Juergen Vigna <jug@sad.it>
/* This file is part of
* ======================================================
- *
+ *
* LyX, The Document Processor
- *
+ *
* Copyright 1995 Matthias Ettrich
* Copyright 1995-2001 The LyX Team.
*
class dumpTemplate {
public:
- dumpTemplate(ostream & o)
+ dumpTemplate(ostream & o)
: ost(o) {}
void operator()(ExternalTemplateManager::Templates::value_type const & vt) {
ExternalTemplate const & et = vt.second;
-
+
ost << "Template " << et.lyxName << "\n"
<< "\tGuiName " << et.guiName << "\n"
<< "\tHelpText\n"
<< "\tAutomaticProduction " << et.automaticProduction << "\n";
et.dumpFormats(ost);
ost << "TemplateEnd" << endl;
-
+
}
private:
class dumpFormat {
public:
- dumpFormat(ostream & o)
+ dumpFormat(ostream & o)
: ost(o) {}
void operator()(ExternalTemplate::Formats::value_type const & vt) const{
ExternalTemplate::FormatTemplate const & ft = vt.second;
};
-void ExternalTemplate::dumpFormats(ostream & os) const
+void ExternalTemplate::dumpFormats(ostream & os) const
{
for_each(formats.begin(), formats.end(), dumpFormat(os));
}
-void ExternalTemplateManager::dumpTemplates() const
+void ExternalTemplateManager::dumpTemplates() const
{
for_each(templates.begin(), templates.end(), dumpTemplate(lyxerr));
}
return templates[name];
}
-
-void ExternalTemplateManager::readTemplates(string const & path)
+
+void ExternalTemplateManager::readTemplates(string const & path)
{
Path p(path);
TM_TEMPLATE = 1,
TM_END
};
-
+
keyword_item templatetags[] = {
{ "template", TM_TEMPLATE },
{ "templateend", TM_END }
"No template file" << endl;
return;
}
-
+
while (lex.isOK()) {
switch (lex.lex()) {
case TM_TEMPLATE: {
tmp.readTemplate(lex);
}
break;
-
+
case TM_END:
lex.printError("Warning: End outside Template.");
break;
};
pushpophelper pph(lex, templateoptiontags, TO_END);
-
+
while (lex.isOK()) {
switch (lex.lex()) {
case TO_GUINAME:
lex.next(true);
guiName = lex.getString();
break;
-
+
case TO_HELPTEXT:
helpText = lex.getLongString("HelpTextEnd");
break;
-
+
case TO_FILTER:
lex.next(true);
fileRegExp = lex.getString();
break;
-
+
case TO_VIEWCMD:
lex.next(true);
viewCommand = lex.getString();
break;
-
+
case TO_EDITCMD:
lex.next(true);
editCommand = lex.getString();
break;
-
+
case TO_AUTOMATIC:
lex.next();
automaticProduction = lex.getBool();
break;
-
+
case TO_FORMAT:
lex.next(true);
formats[lex.getString()].readFormat(lex);
break;
-
+
case TO_END:
return;
-
+
default:
lex.printError("ExternalTemplate::readTemplate: "
"Wrong tag: $$Token");
}
-void ExternalTemplate::FormatTemplate::readFormat(LyXLex & lex)
+void ExternalTemplate::FormatTemplate::readFormat(LyXLex & lex)
{
enum FormatTags {
FO_PRODUCT = 1,
FO_PREAMBLE,
FO_END
};
-
+
keyword_item formattags[] = {
{ "formatend", FO_END },
{ "preamble", FO_PREAMBLE },
};
pushpophelper pph(lex, formattags, FO_END);
-
+
while (lex.isOK()) {
switch (lex.lex()) {
case FO_PRODUCT:
lex.next(true);
product = lex.getString();
break;
-
+
case FO_UPDATECMD:
lex.next(true);
updateCommand = lex.getString();
lex.next(true);
updateResult = lex.getString();
break;
-
+
case FO_REQUIREMENT:
lex.next(true);
requirement = lex.getString();
break;
-
+
case FO_PREAMBLE:
preamble = lex.getLongString("preambleend");
break;
-
+
case FO_END:
if (lyxerr.debugging())
lex.printError("FormatEnd");
}
}
}
-
// -*- C++ -*-
/* This file is part of*
- * ======================================================
+ * ======================================================
*
* LyX, The Document Processor
- *
+ *
* Copyright 1995 Matthias Ettrich
* Copyright 1995-2001 The LyX Team.
*
Formats formats;
///
void dumpFormats(std::ostream &) const;
-
+
/// We have to have default commands for safety reasons!
ExternalTemplate();
-
+
};
static ExternalTemplateManager & get();
Templates & getTemplates();
Templates const & getTemplates() const;
- /// return the template by LyX name
+ /// return the template by LyX name
ExternalTemplate const & getTemplateByName(const string & name);
private:
ExternalTemplateManager();
/* This file is part of
- * ======================================================
- *
+ * ======================================================
+ *
* LyX, The Document Processor
- *
+ *
* Copyright 1995 Matthias Ettrich
* Copyright 1995-2001 The LyX Team.
*
#endif
-string const Inset::editMessage() const
+string const Inset::editMessage() const
{
return _("Opened inset");
}
void UpdatableInset::scroll(BufferView * bv, float s) const
{
LyXFont font;
-
+
if (!s) {
scx = 0;
return;
int const workW = bv->workWidth();
int const tmp_top_x = top_x - scx;
-
- if (tmp_top_x > 0 &&
+
+ if (tmp_top_x > 0 &&
(tmp_top_x + width(bv, font)) < workW)
return;
if (s > 0 && top_x > 0)
// int mx_scx=abs((width(bv,font) - bv->workWidth())/2);
//int const save_scx = scx;
-
+
scx = int(s * workW / 2);
// if (!display())
// scx += 20;
if (!scx && (top_x + width(bv, font)) < (bv->workWidth() - 20))
return;
if ((top_x - scx + offset + width(bv, font)) < (bv->workWidth() - 20)) {
- scx = bv->workWidth() - width(bv, font) - top_x + scx - 20;
+ scx = bv->workWidth() - width(bv, font) - top_x + scx - 20;
} else {
scx += offset;
}
/// An updatable inset could handle lyx editing commands
UpdatableInset::RESULT
-UpdatableInset::localDispatch(BufferView * bv,
- kb_action action, string const & arg)
+UpdatableInset::localDispatch(BufferView * bv,
+ kb_action action, string const & arg)
{
if (!arg.empty() && (action==LFUN_SCROLL_INSET)) {
if (arg.find('.') != arg.npos) {
scroll(bv, xx);
}
bv->updateInset(this, false);
-
+
return DISPATCHED;
}
- return UNDISPATCHED;
+ return UNDISPATCHED;
}
bool UpdatableInset::searchForward(BufferView * bv, string const &,
- bool, bool)
+ bool, bool)
{
// we have to unlock ourself in this function by default!
bv->unlockInset(const_cast<UpdatableInset *>(this));
bool UpdatableInset::searchBackward(BufferView * bv, string const &,
- bool, bool)
+ bool, bool)
{
// we have to unlock ourself in this function by default!
bv->unlockInset(const_cast<UpdatableInset *>(this));
// -*- C++ -*-
/* This file is part of
- * ======================================================
- *
+ * ======================================================
+ *
* LyX, The Document Processor
- *
+ *
* Copyright 1995-2001 the LyX Team.
*
* ====================================================== */
///
HIGHLY_EDITABLE
};
-
+
///
Inset();
///
bool free_spc) const = 0;
///
virtual int ascii(Buffer const *,
- std::ostream &, int linelen = 0) const = 0;
+ std::ostream &, int linelen = 0) const = 0;
///
virtual int linuxdoc(Buffer const *, std::ostream &) const = 0;
///
virtual void validate(LaTeXFeatures & features) const;
///
virtual bool deletable() const;
-
+
/// returns LyX code associated with the inset. Used for TOC, ...)
virtual Inset::Code lyxCode() const { return NO_CODE; }
-
+
virtual std::vector<string> const getLabelList() const {
return std::vector<string>();
}
///
virtual Inset * clone(Buffer const &, bool same_ids = false) const = 0;
-
+
/// returns true to override begin and end inset in file
virtual bool directWrite() const;
virtual bool checkInsertChar(LyXFont &);
/// we need this here because collapsed insets are only EDITABLE
virtual void setFont(BufferView *, LyXFont const &,
- bool toggleall = false, bool selectall = false);
+ bool toggleall = false, bool selectall = false);
///
// needed for spellchecking text
///
inline
bool Inset::insetAllowed(Inset * in) const
-{
- return insetAllowed(in->lyxCode());
+{
+ return insetAllowed(in->lyxCode());
}
// Updatable Insets. These insets can be locked and receive
// directly user interaction. Currently used only for mathed.
// Note that all pure methods from Inset class are pure here too.
-// [Alejandro 080596]
+// [Alejandro 080596]
/** Extracted from Matthias notes:
- *
- * An inset can simple call LockInset in it's edit call and *ONLY*
+ *
+ * An inset can simple call LockInset in it's edit call and *ONLY*
* in it's edit call.
*
- * Unlocking is either done by LyX or the inset itself with a
+ * Unlocking is either done by LyX or the inset itself with a
* UnlockInset-call
*
* During the lock, all button and keyboard events will be modified
* and send to the inset through the following inset-features. Note that
* Inset::insetUnlock will be called from inside UnlockInset. It is meant
* to contain the code for restoring the menus and things like this.
- *
+ *
* If a inset wishes any redraw and/or update it just has to call
* updateInset(this).
- *
+ *
* It's is completly irrelevant, where the inset is. UpdateInset will
- * find it in any paragraph in any buffer.
+ * find it in any paragraph in any buffer.
* Of course the_locking_inset and the insets in the current paragraph/buffer
* are checked first, so no performance problem should occur.
*/
/** Dispatch result codes
Now that nested updatable insets are allowed, the local dispatch
becomes a bit complex, just two possible results (boolean)
- are not enough.
-
+ are not enough.
+
DISPATCHED = the inset catched the action
DISPATCHED_NOUPDATE = the inset catched the action and no update
- is needed here to redraw the inset
+ is needed here to redraw the inset
FINISHED = the inset must be unlocked as a result
- of the action
+ of the action
FINISHED_RIGHT = FINISHED, but put the cursor to the RIGHT of
- the inset.
+ the inset.
FINISHED_UP = FINISHED, but put the cursor UP of
- the inset.
+ the inset.
FINISHED_DOWN = FINISHED, but put the cursor DOWN of
- the inset.
+ the inset.
UNDISPATCHED = the action was not catched, it should be
- dispatched by lower level insets
- */
+ dispatched by lower level insets
+ */
enum RESULT {
UNDISPATCHED = 0,
DISPATCHED,
FINISHED_UP,
FINISHED_DOWN
};
-
+
/// To convert old binary dispatch results
RESULT DISPATCH_RESULT(bool b) {
return b ? DISPATCHED : FINISHED;
virtual bool checkInsertChar(LyXFont &);
///
virtual EDITABLE editable() const;
-
+
///
virtual void toggleInsetCursor(BufferView *);
///
// if that one has one!
///
virtual bool insetButtonRelease(BufferView *,
- int x, int y, int button);
+ int x, int y, int button);
///
virtual void insetKeyPress(XKeyEvent * ev);
///
{ return false; }
///
virtual bool unlockInsetInInset(BufferView *, UpdatableInset *,
- bool /*lr*/ = false)
+ bool /*lr*/ = false)
{ return false; }
/// An updatable inset could handle lyx editing commands
virtual RESULT localDispatch(BufferView *, kb_action, string const &);
// needed for search/replace functionality
///
virtual bool searchForward(BufferView *, string const &,
- bool = true, bool = false);
+ bool = true, bool = false);
///
virtual bool searchBackward(BufferView *, string const &,
- bool = true, bool = false);
-
+ bool = true, bool = false);
+
protected:
///
void toggleCursorVisible() const {
*/
inline bool isEditableInset(Inset * i)
{
- return i && i->editable();
+ return i && i->editable();
}
-
+
/**
* returns true if pointer argument is valid
* and points to a highly editable inset
#include "lyxtext.h"
#include "lyxrc.h"
#include "font.h"
-#include "LyXView.h"
+#include "LyXView.h"
#include "lyxtextclasslist.h"
#include "frontends/Dialogs.h"
}
-void InsetBibKey::setCounter(int c)
-{
- counter = c;
+void InsetBibKey::setCounter(int c)
+{
+ counter = c;
}
// I'm sorry but this is still necessary because \bibitem is used also
// as a LyX 2.x command, and lyxlex is not enough smart to understand
-// real LaTeX commands. Yes, that could be fixed, but would be a waste
+// real LaTeX commands. Yes, that could be fixed, but would be a waste
// of time cause LyX3 won't use lyxlex anyway. (ale)
void InsetBibKey::write(Buffer const *, ostream & os) const
{
void InsetBibKey::edit(BufferView * bv, int, int, unsigned int)
-{
+{
bv->owner()->getDialogs()->showBibitem(this);
}
}
}
- if (!buffer->niceFile
+ if (!buffer->niceFile
&& IsFileReadable(MakeAbsPath(style, buffer->filePath()) + ".bst")) {
style = MakeAbsPath(style, buffer->filePath());
}
}
// bibtotoc-Option
- if (!bibtotoc.empty()) {
+ if (!bibtotoc.empty()) {
// maybe a problem when a textclass has no "art" as
// part of its name, because it's than book.
// For the "official" lyx-layouts it's no problem to support
} else {
// article class
- os << "\\addcontentsline{toc}{section}{\\refname}";
+ os << "\\addcontentsline{toc}{section}{\\refname}";
}
}
string db_out;
while (!adb.empty()) {
if (!buffer->niceFile &&
- IsFileReadable(MakeAbsPath(adb, buffer->filePath())+".bib"))
- adb = os::external_path(MakeAbsPath(adb, buffer->filePath()));
+ IsFileReadable(MakeAbsPath(adb, buffer->filePath())+".bib"))
+ adb = os::external_path(MakeAbsPath(adb, buffer->filePath()));
db_out += adb;
db_out += ',';
db_in= split(db_in, adb,',');
// If we didn't find a matching file name just fail silently
if (!file.empty())
vec.push_back(file);
-
+
// Get next file name
- bibfiles = split(bibfiles, tmp, ',');
+ bibfiles = split(bibfiles, tmp, ',');
}
return vec;
}
}
}
- return keys;
+ return keys;
}
{
string contents(getContents());
if (!contains(contents, db)) {
- if (!contents.empty())
+ if (!contents.empty())
contents += ",";
setContents(contents + db);
return true;
setContents(subst(getContents(), tmp, ", "));
} else if (n == 0)
setContents(split(getContents(), bd, ','));
- else
+ else
return false;
}
return true;
// Ha, now we are mainly at 1.2.0 and it is still here (Jug)
// Does look like a hack? It is! (but will change at 0.13)
Paragraph * par = bv->buffer()->paragraph;
-
+
while (par) {
if (par->bibkey) {
int const wx = par->bibkey->width(bv, font);
Paragraph * par = buffer->paragraph;
InsetBibKey * bkey = 0;
LyXFont font;
-
+
while (par) {
if (par->bibkey) {
int const wx =
}
par = par->next();
}
-
+
if (bkey && !bkey->getBibLabel().empty())
return bkey->getBibLabel();
-
+
return "99";
}
// -*- C++ -*-
/* This file is part of*
- * ======================================================
+ * ======================================================
*
* LyX, The Document Processor
- *
+ *
* Copyright 1995 Matthias Ettrich
* Copyright 1995-2001 The LyX Team.
- *
+ *
* ====================================================== */
#ifndef INSET_BIB_H
class Buffer;
/** Used to insert bibitem's information (key and label)
-
+
Must be automatically inserted as the first object in a
- bibliography paragraph.
+ bibliography paragraph.
*/
class InsetBibKey : public InsetCommand {
public:
///
void edit(BufferView * bv, bool front = true);
///
- EDITABLE editable() const { return IS_EDITABLE; }
+ EDITABLE editable() const { return IS_EDITABLE; }
/// A user can't neither insert nor delete this inset
bool deletable() const {
return false;
InsetBibKey * inset;
BufferView * view;
};
-
+
private:
///
int counter;
};
-/** Used to insert BibTeX's information
+/** Used to insert BibTeX's information
*/
class InsetBibtex : public InsetCommand {
public:
void edit(BufferView *, int x, int y, unsigned int button);
///
void edit(BufferView * bv, bool front = true);
- ///
+ ///
int latex(Buffer const *, std::ostream &,
- bool fragile, bool freespace) const;
+ bool fragile, bool freespace) const;
///
std::vector<std::pair<string,string> > const getKeys(Buffer const *) const;
///
///
bool delDatabase(string const &);
///
- bool display() const { return true; }
+ bool display() const { return true; }
///
- struct Holder {
+ struct Holder {
InsetBibtex * inset;
BufferView * view;
};
/* This file is part of
* ======================================================
- *
+ *
* LyX, The Document Processor
- *
+ *
* Copyright 1995 Matthias Ettrich
* Copyright 2000-2001 The LyX Team.
*
int InsetButton::ascent(BufferView * bv, LyXFont const &) const
{
lyx::Assert(bv);
-
+
LyXFont font(LyXFont::ALL_SANE);
font.decSize();
-
+
int width;
int ascent;
int descent;
- string const s = getScreenLabel(bv->buffer());
+ string const s = getScreenLabel(bv->buffer());
- if (editable()) {
+ if (editable()) {
lyxfont::buttonText(s, font, width, ascent, descent);
} else {
lyxfont::rectText(s, font, width, ascent, descent);
int InsetButton::descent(BufferView * bv, LyXFont const &) const
{
lyx::Assert(bv);
-
+
LyXFont font(LyXFont::ALL_SANE);
font.decSize();
-
+
int width;
int ascent;
int descent;
- string const s = getScreenLabel(bv->buffer());
+ string const s = getScreenLabel(bv->buffer());
- if (editable()) {
+ if (editable()) {
lyxfont::buttonText(s, font, width, ascent, descent);
} else {
lyxfont::rectText(s, font, width, ascent, descent);
LyXFont font(LyXFont::ALL_SANE);
font.decSize();
-
+
int width;
int ascent;
int descent;
- string const s = getScreenLabel(bv->buffer());
+ string const s = getScreenLabel(bv->buffer());
- if (editable()) {
+ if (editable()) {
lyxfont::buttonText(s, font, width, ascent, descent);
} else {
lyxfont::rectText(s, font, width, ascent, descent);
int baseline, float & x, bool) const
{
lyx::Assert(bv);
-
+
Painter & pain = bv->painter();
// Draw it as a box with the LaTeX text
LyXFont font(LyXFont::ALL_SANE);
// -*- C++ -*-
/* This file is part of*
- * ======================================================
+ * ======================================================
*
* LyX, The Document Processor
- *
+ *
* Copyright 1995 Matthias Ettrich
* Copyright 2000-2001 The LyX Team.
*
/* This file is part of
* ======================================================
- *
+ *
* LyX, The Document Processor
- *
+ *
* Copyright 2000-2001 The LyX Team.
*
* ======================================================
}
-string const InsetCaption::editMessage() const
+string const InsetCaption::editMessage() const
{
return _("Opened Caption Inset");
}
// Generate the label
string const label = _(fl) + " " + num + ":";
-
+
Painter & pain = bv->painter();
int const w = lyxfont::width(label, f);
pain.text(int(x), baseline, label, f);
// -*- C++ -*-
/* This file is part of
* ======================================================
- *
+ *
* LyX, The Document Processor
*
* Copyright 2000-2001 The LyX Team.
inline
-bool InsetCaption::needFullRow() const
+bool InsetCaption::needFullRow() const
{
return true;
}
inline
-Inset::Code InsetCaption::lyxCode() const
+Inset::Code InsetCaption::lyxCode() const
{
return CAPTION_CODE;
}
/* This file is part of*
- * ======================================================
+ * ======================================================
*
* LyX, The Document Processor
- *
+ *
* Copyright 2000-2001 The LyX Team.
- *
+ *
* ====================================================== */
#include <config.h>
int InsetCitation::ascii(Buffer const *, ostream & os, int) const
{
- os << "[" << getContents() << "]";
- return 0;
+ os << "[" << getContents() << "]";
+ return 0;
}
// Have to overwrite the default InsetCommand method in order to check that
it != getContents().end(); ++it) {
if (*it != ' ') content += *it;
}
-
+
os << "{" << content << "}";
return 0;
// -*- C++ -*-
/* This file is part of*
- * ======================================================
+ * ======================================================
*
* LyX, The Document Processor
- *
+ *
* Copyright 2000-2001 The LyX Team.
- *
+ *
* ====================================================== */
#ifndef INSET_CITE_H
#include "insetcommand.h"
-/** Used to insert citations
+/** Used to insert citations
*/
class InsetCitation : public InsetCommand {
public:
void edit(BufferView * bv, bool front = true);
///
int ascii(Buffer const *, std::ostream &, int linelen) const;
- ///
+ ///
int latex(Buffer const *, std::ostream &, bool, bool) const;
///
void validate(LaTeXFeatures &) const;
/* This file is part of
* ======================================================
- *
+ *
* LyX, The Document Processor
- *
+ *
* Copyright 1998-2001 The LyX Team.
*
* ======================================================
int InsetCollapsable::descent(BufferView * bv, LyXFont const & font) const
{
- if (collapsed_)
+ if (collapsed_)
return descent_collapsed();
return descent_collapsed()
int InsetCollapsable::width(BufferView * bv, LyXFont const & font) const
{
- if (collapsed_)
+ if (collapsed_)
return width_collapsed();
int widthCollapsed = width_collapsed();
}
-void InsetCollapsable::draw(BufferView * bv, LyXFont const & f,
- int baseline, float & x, bool cleared) const
+void InsetCollapsable::draw(BufferView * bv, LyXFont const & f,
+ int baseline, float & x, bool cleared) const
{
if (need_update != NONE) {
const_cast<InsetText *>(&inset)->update(bv, f, true);
x += static_cast<float>(scroll());
if (!cleared && (inset.need_update == InsetText::FULL ||
- inset.need_update == InsetText::INIT ||
- top_x != int(x) ||
- top_baseline != baseline))
+ inset.need_update == InsetText::INIT ||
+ top_x != int(x) ||
+ top_baseline != baseline))
{
// we don't need anymore to clear here we just have to tell
// the underlying LyXText that it should do the RowClear!
top_baseline = baseline;
int const bl = baseline - ascent(bv, f) + ascent_collapsed();
-
+
draw_collapsed(pain, bl, old_x);
- inset.draw(bv, f,
+ inset.draw(bv, f,
bl + descent_collapsed() + inset.ascent(bv, f),
x, cleared);
if (x < (top_x + button_length + TEXT_TO_INSET_OFFSET))
void InsetCollapsable::edit(BufferView * bv, int xp, int yp,
- unsigned int button)
+ unsigned int button)
{
UpdatableInset::edit(bv, xp, yp, button);
void InsetCollapsable::insetButtonPress(BufferView * bv,
- int x, int y, int button)
+ int x, int y, int button)
{
if (!collapsed_ && (y > button_bottom_y)) {
LyXFont font(LyXFont::ALL_SANE);
bool InsetCollapsable::insetButtonRelease(BufferView * bv,
- int x, int y, int button)
+ int x, int y, int button)
{
bool ret = false;
if ((button != 3) && (x >= 0) && (x < button_length) &&
void InsetCollapsable::insetMotionNotify(BufferView * bv,
- int x, int y, int state)
+ int x, int y, int state)
{
if (y > button_bottom_y) {
LyXFont font(LyXFont::ALL_SANE);
int InsetCollapsable::latex(Buffer const * buf, ostream & os,
- bool fragile, bool free_spc) const
+ bool fragile, bool free_spc) const
{
return inset.latex(buf, os, fragile, free_spc);
}
#if 0
int InsetCollapsable::getMaxWidth(BufferView * bv,
- UpdatableInset const * in) const
+ UpdatableInset const * in) const
{
#if 0
int const w = UpdatableInset::getMaxWidth(bv, in);
void InsetCollapsable::update(BufferView * bv, LyXFont const & font,
- bool reinit)
+ bool reinit)
{
if (in_update) {
if (reinit && owner()) {
UpdatableInset::RESULT
InsetCollapsable::localDispatch(BufferView * bv, kb_action action,
- string const & arg)
+ string const & arg)
{
UpdatableInset::RESULT result = inset.localDispatch(bv, action, arg);
if (result >= FINISHED)
bool InsetCollapsable::unlockInsetInInset(BufferView * bv, UpdatableInset * in,
- bool lr)
+ bool lr)
{
if (&inset == in) {
bv->unlockInset(this);
void InsetCollapsable::setFont(BufferView * bv, LyXFont const & font,
- bool toggleall, bool selectall)
+ bool toggleall, bool selectall)
{
inset.setFont(bv, font, toggleall, selectall);
}
return inset.nodraw();
}
-
+
int InsetCollapsable::scroll(bool recursive) const
{
int sx = UpdatableInset::scroll(false);
void InsetCollapsable::open(BufferView * bv)
{
if (!collapsed_) return;
-
+
collapsed_ = false;
bv->updateInset(this, false);
}
{
if (collapsed_)
return;
-
+
collapsed_ = true;
bv->updateInset(const_cast<InsetCollapsable *>(this), false);
}
bool InsetCollapsable::searchForward(BufferView * bv, string const & str,
- bool cs, bool mw)
+ bool cs, bool mw)
{
bool found = inset.searchForward(bv, str, cs, mw);
if (first_after_edit && !found)
bool InsetCollapsable::searchBackward(BufferView * bv, string const & str,
- bool cs, bool mw)
+ bool cs, bool mw)
{
bool found = inset.searchBackward(bv, str, cs, mw);
if (first_after_edit && !found)
// -*- C++ -*-
/* This file is part of
* ======================================================
- *
+ *
* LyX, The Document Processor
*
* Copyright 2000-2001 The LyX Team.
class LyXCursor;
/** A collapsable text inset
-
+
*/
class InsetCollapsable : public UpdatableInset {
public:
///
void draw(BufferView *, const LyXFont &, int , float &, bool) const;
///
- void update(BufferView *, LyXFont const &, bool =false);
+ void update(BufferView *, LyXFont const &, bool =false);
///
void edit(BufferView *, int, int, unsigned int);
///
bool lockInsetInInset(BufferView *, UpdatableInset *);
///
bool unlockInsetInInset(BufferView *, UpdatableInset *,
- bool lr = false);
+ bool lr = false);
///
bool updateInsetInInset(BufferView *, Inset *);
///
void insetKeyPress(XKeyEvent *);
///
UpdatableInset::RESULT localDispatch(BufferView *, kb_action,
- string const &);
+ string const &);
///
int latex(Buffer const *, std::ostream &,
bool fragile, bool free_spc) const;
UpdatableInset * getFirstLockingInsetOfType(Inset::Code);
///
void setFont(BufferView *, LyXFont const &, bool toggleall = false,
- bool selectall = false);
+ bool selectall = false);
///
void setLabel(string const & l) const;
///
}
///
bool searchForward(BufferView * bv, string const & str,
- bool = true, bool = false);
+ bool = true, bool = false);
bool searchBackward(BufferView * bv, string const & str,
- bool = true, bool = false);
+ bool = true, bool = false);
protected:
///
void draw_collapsed(Painter & pain, int , float &) const;
///
int getMaxTextWidth(Painter & pain, UpdatableInset const *) const;
-
+
///
mutable bool collapsed_;
///
/* This file is part of
* ======================================================
- *
+ *
* LyX, The Document Processor
- *
+ *
* Copyright 1995 Matthias Ettrich
* Copyright 1995-2001 The LyX Team.
*
if (cmd.empty()) return;
enum { WS, CMDNAME, OPTION, CONTENT } state = WS;
-
+
// Used to handle things like \command[foo[bar]]{foo{bar}}
int nestdepth = 0;
}
if ((state == OPTION && c == '[') ||
(state == CONTENT && c == '{')) {
- ++nestdepth;
+ ++nestdepth;
}
switch (state) {
case CMDNAME: tcmdname += c; break;
- case OPTION: toptions += c; break;
+ case OPTION: toptions += c; break;
case CONTENT: tcontents += c; break;
case WS:
if (c == '\\') {
// Don't mess with this.
if (!tcmdname.empty()) setCmdName(tcmdname);
if (!toptions.empty()) setOptions(toptions);
- if (!tcontents.empty()) setContents(tcontents);
+ if (!tcontents.empty()) setContents(tcontents);
if (lyxerr.debugging(Debug::PARSER))
lyxerr << "Command <" << cmd
// This function will not be necessary when lyx3
void InsetCommandParams::read(LyXLex & lex)
-{
+{
string token;
if (lex.eatLine()) {
} else {
lex.printError("InsetCommand: Parse error: `$$Token'");
}
-
+
while (lex.isOK()) {
lex.nextToken();
token = lex.getString();
string const InsetCommandParams::getCommand() const
-{
+{
string s;
if (!getCmdName().empty()) s += "\\"+getCmdName();
if (!getOptions().empty()) s += "["+getOptions()+']';
// -*- C++ -*-
/* This file is part of*
- * ======================================================
+ * ======================================================
*
* LyX, The Document Processor
- *
+ *
* Copyright 1995 Matthias Ettrich
* Copyright 1995-2001 The LyX Team.
*
/** Used to insert a LaTeX command automatically
*
* Similar to InsetLaTeX but having control of the basic structure of a
- * LaTeX command: \name[options]{contents}.
+ * LaTeX command: \name[options]{contents}.
*/
class InsetCommandParams {
public:
///
void setFromString(string const &);
private:
- ///
+ ///
string cmdname;
- ///
+ ///
string contents;
- ///
+ ///
string options;
};
{ p_.read(lex); }
/// Can remove one InsetBibKey is modified
void scanCommand(string const & c) { p_.scanCommand(c); };
- ///
+ ///
virtual int latex(Buffer const *, std::ostream &,
bool fragile, bool free_spc) const;
///
virtual int docbook(Buffer const *, std::ostream &) const;
///
Inset::Code lyxCode() const { return Inset::NO_CODE; }
-
+
///
string const getCommand() const { return p_.getCommand(); }
///
/* This file is part of
* ======================================================
- *
+ *
* LyX, The Document Processor
- *
+ *
* Copyright 1995 Matthias Ettrich
* Copyright 1995-2001 The LyX Team.
*
LyXFont efont;
efont.setSize(font.size()).decSize();
efont.setColor(LColor::error);
-
+
// Draw as "Error" in a framed box
x += 1;
pain.fillRectangle(int(x), baseline - ascent(bv, font) + 1,
}
-string const InsetError::editMessage() const
+string const InsetError::editMessage() const
{
return _("Opened error");
}
// -*- C++ -*-
/* This file is part of*
- * ======================================================
+ * ======================================================
*
* LyX, The Document Processor
- *
+ *
* Copyright 1995 Matthias Ettrich
- * Copyright 1995-2001 The LyX Team.
+ * Copyright 1995-2001 The LyX Team.
*
* ====================================================== */
#include <sigc++/signal_system.h>
/** Used for error messages from LaTeX runs.
-
- The edit-operation opens a
- dialog with the text of the error-message. The inset is displayed as
+
+ The edit-operation opens a
+ dialog with the text of the error-message. The inset is displayed as
"Error" in a box, and automatically deleted. */
class InsetError : public Inset {
public:
/* This file is part of
* ======================================================
- *
+ *
* LyX, The Document Processor
- *
+ *
* Copyright 1998 The LyX Team.
*
*======================================================*/
font.setFamily(LyXFont::TYPEWRITER_FAMILY);
font.setColor(LColor::latex);
#endif
-
+
string::const_iterator cit = contents.begin();
string::const_iterator end = contents.end();
pos_type pos = 0;
if (token == "status") {
lex.next();
string const tmp_token = lex.getString();
-
+
if (tmp_token == "Inlined") {
status(0, Inlined);
} else if (tmp_token == "Collapsed") {
// leave this as default!
status(0, Open);
}
-
+
token_found = true;
} else {
lyxerr << "InsetERT::Read: Missing 'status'-tag!"
#ifdef SET_HARD_FONT
#ifndef INHERIT_LANG
LyXFont font(LyXFont::ALL_INHERIT, latex_language);
-#else
+#else
LyXFont font(LyXFont::ALL_INHERIT);
#endif
font.setFamily(LyXFont::TYPEWRITER_FAMILY);
par = par->next();
}
#endif
-
+
if (!token_found) {
if (collapsed_) {
status(0, Collapsed);
}
-void InsetERT::write(Buffer const * buf, ostream & os) const
+void InsetERT::write(Buffer const * buf, ostream & os) const
{
string st;
switch (status_) {
- case Open:
+ case Open:
st = "Open";
break;
case Collapsed:
}
-string const InsetERT::editMessage() const
+string const InsetERT::editMessage() const
{
return _("Opened ERT Inset");
}
// fontchange and this messages is not needed
if (!selectall)
Alert::alert(_("Impossible Operation!"),
- _("Not permitted to change font-types inside ERT-insets!"),
- _("Sorry."));
+ _("Not permitted to change font-types inside ERT-insets!"),
+ _("Sorry."));
}
}
}
-
+
void InsetERT::edit(BufferView * bv, int x, int y, unsigned int button)
{
if (button == 3)
void InsetERT::insetButtonPress(BufferView * bv,
- int x, int y, int button)
+ int x, int y, int button)
{
if (status_ == Inlined) {
inset.insetButtonPress(bv, x, y, button);
showInsetDialog(bv);
return true;
}
-
+
if (status_ != Inlined && (x >= 0) && (x < button_length) &&
(y >= button_top_y) && (y <= button_bottom_y)) {
updateStatus(bv, true);
} else {
LyXFont font(LyXFont::ALL_SANE);
int yy = ascent(bv, font) + y - inset.ascent(bv, font);
-
- // inlined is special - the text appears above
+
+ // inlined is special - the text appears above
// button_bottom_y
if (status_ == Inlined) {
inset.insetButtonRelease(bv, x, yy, button);
void InsetERT::insetMotionNotify(BufferView * bv,
- int x, int y, int state)
+ int x, int y, int state)
{
if (status_ == Inlined) {
inset.insetMotionNotify(bv, x, y, state);
lines += 2;
}
}
-
+
return lines;
}
int InsetERT::ascii(Buffer const *,
- ostream &, int /*linelen*/) const
+ ostream &, int /*linelen*/) const
{
return 0;
}
lines ++;
}
}
-
+
return lines;
}
lines ++;
}
}
-
+
return lines;
}
case LFUN_CUT:
set_latex_font(bv);
break;
-
+
default:
break;
}
#ifdef SET_HARD_FONT
#ifndef INHERIT_LANG
LyXFont f(LyXFont::ALL_INHERIT, latex_language);
-#else
+#else
LyXFont f(LyXFont::ALL_INHERIT);
#endif
font = f;
}
-void InsetERT::draw(BufferView * bv, LyXFont const & f,
- int baseline, float & x, bool cleared) const
+void InsetERT::draw(BufferView * bv, LyXFont const & f,
+ int baseline, float & x, bool cleared) const
{
Painter & pain = bv->painter();
x += static_cast<float>(scroll());
if (!cleared && (inset.need_update == InsetText::FULL ||
- inset.need_update == InsetText::INIT ||
- top_x != int(x) ||
- top_baseline != baseline))
+ inset.need_update == InsetText::INIT ||
+ top_x != int(x) ||
+ top_baseline != baseline))
{
// we don't need anymore to clear here we just have to tell
// the underlying LyXText that it should do the RowClear!
inset.draw(bv, f, baseline, x, cleared);
} else {
draw_collapsed(pain, bl, old_x);
- inset.draw(bv, f,
+ inset.draw(bv, f,
bl + descent_collapsed() + inset.ascent(bv, f),
x, cleared);
}
#ifdef SET_HARD_FONT
#ifndef INHERIT_LANG
LyXFont font(LyXFont::ALL_INHERIT, latex_language);
-#else
+#else
LyXFont font(LyXFont::ALL_INHERIT);
#endif
string const InsetERT::selectNextWordToSpellcheck(BufferView * bv,
- float &) const
+ float &) const
{
bv->unlockInset(const_cast<InsetERT *>(this));
return string();
{
#ifndef INHERIT_LANG
LyXFont f(LyXFont::ALL_INHERIT, latex_language);
-#else
+#else
LyXFont f(LyXFont::ALL_INHERIT);
#endif
font = f;
// -*- C++ -*-
/* This file is part of
* ======================================================
- *
+ *
* LyX, The Document Processor
*
* Copyright 1998 The LyX Team.
#include <sigc++/signal_system.h>
/** A collapsable text inset for LaTeX insertions.
-
+
To write full ert (including styles and other insets) in a given
space.
Note that collapsed_ encompasses both the inline and collapsed button
- versions of this inset.
+ versions of this inset.
*/
class Language;
bool insetAllowed(Inset::Code) const { return false; }
///
void setFont(BufferView *, LyXFont const &,
- bool toggleall = false, bool selectall = false);
+ bool toggleall = false, bool selectall = false);
///
void edit(BufferView *, int, int, unsigned int);
///
bool free_spc) const;
///
int ascii(Buffer const *,
- std::ostream &, int linelen = 0) const;
+ std::ostream &, int linelen = 0) const;
///
int linuxdoc(Buffer const *, std::ostream &) const;
///
void validate(LaTeXFeatures &) const {}
///
UpdatableInset::RESULT localDispatch(BufferView *, kb_action,
- string const &);
+ string const &);
///
bool checkInsertChar(LyXFont &);
///
* ======================================================
*
* LyX, The Document Processor
- *
+ *
* Copyright 1995 Matthias Ettrich
* Copyright 1995-2001 The LyX Team.
*
using std::endl;
-InsetExternal::InsetExternal()
+InsetExternal::InsetExternal()
: view_(0)
{
tempname_ = lyx::tempName(string(), "lyxext");
{
return params_;
}
-
-
+
+
void InsetExternal::setFromParams(Params const & p)
{
params_.filename = p.filename;
params_.parameters = p.parameters;
params_.templ = p.templ;
-}
+}
string const InsetExternal::editMessage() const
} else {
lex.printError("InsetExternal: Parse error: `$$Token'");
}
-
+
while (lex.isOK()) {
lex.nextToken();
token = lex.getString();
<< params_.templ.lyxName << endl;
return 0;
}
-
+
updateExternal(format, buf);
os << doSubstitution(buf, cit->second.product);
return 0; // CHECK (FIXME check what ? - jbl)
if (cit == et.formats.end())
return;
-
+
if (!cit->second.requirement.empty()) {
features.require(cit->second.requirement);
}
result = ReplaceEnvironmentPath(result);
result = subst(result, "$$Tempname", tempname_);
result = subst(result, "$$Sysdir", system_lyxdir);
-
+
// Handle the $$Contents(filename) syntax
if (contains(result, "$$Contents(\"")) {
void InsetExternal::updateExternal() const
{
- updateExternal("LaTeX", view_->buffer());
+ updateExternal("LaTeX", view_->buffer());
}
void InsetExternal::updateExternal(string const & format,
cit->second.updateCommand.empty() ||
!et.automaticProduction)
return;
-
+
if (!cit->second.updateResult.empty()) {
string const resultfile = doSubstitution(buf,
cit->second.updateResult);
if (fi2.exist() && fi.exist() &&
::difftime(fi2.getModificationTime(),
fi.getModificationTime()) >= 0) {
- lyxerr[Debug::FILES] << resultfile
+ lyxerr[Debug::FILES] << resultfile
<< " is up to date" << endl;
return;
}
bool operator!=(InsetExternal::Params const & left,
InsetExternal::Params const & right)
{
- return !(left == right);
+ return !(left == right);
}
-
* ======================================================
*
* LyX, The Document Processor
- *
+ *
* Copyright 1995 Matthias Ettrich
* Copyright 1995-2001 The LyX Team.
*
public:
/// hold parameters settable from the GUI
struct Params {
- Params(string const & f = string(),
- string const & p = string(),
+ Params(string const & f = string(),
+ string const & p = string(),
ExternalTemplate const & t = ExternalTemplate())
: filename(f), parameters(p), templ(t) {}
/// the filename
is in a free-spacing paragraph.
*/
virtual int latex(Buffer const *, std::ostream &, bool fragile,
- bool free_spc) const;
+ bool free_spc) const;
/// write ASCII output to the ostream
virtual int ascii(Buffer const *, std::ostream &, int linelen) const;
/// write LinuxDoc output to the ostream
/// returns LyX code associated with the inset. Used for TOC, ...)
virtual Inset::Code lyxCode() const { return EXTERNAL_CODE; }
-
+
///
virtual Inset * clone(Buffer const &, bool same_id = false) const;
/* This file is part of
* ======================================================
- *
+ *
* LyX, The Document Processor
- *
+ *
* Copyright 1998-2001 The LyX Team.
*
* ====================================================== */
// within - This (optional) argument determines whether floats of this
// class will be numbered within some sectional unit of the
// document. For example, if within is equal to chapter, the
-// floats will be numbered within chapters.
+// floats will be numbered within chapters.
// \floatstyle{style}
// style - plain, boxed, ruled
// \floatname{float}{floatname}
} else {
os << "wide false\n";
}
-
+
InsetCollapsable::write(buf, os);
}
if (contains(placement(), "H")) {
features.require("float");
}
-
+
features.useFloat(floatType_);
InsetCollapsable::validate(features);
}
&& buf_placement != def_placement) {
placement = buf_placement;
}
-
+
os << "\\begin{" << tmptype << "}";
// We only output placement if different from the def_placement.
if (!placement.empty()) {
os << "[" << placement << "]";
}
-
+
os << "%\n";
-
+
int const i = inset.latex(buf, os, fragile, fp);
os << "\\end{" << tmptype << "}%\n";
-
+
return i + 2;
}
bool InsetFloat::showInsetDialog(BufferView * bv) const
{
if (!inset.showInsetDialog(bv)) {
- bv->owner()->getDialogs()->showFloat(const_cast<InsetFloat *>(this));
+ bv->owner()->getDialogs()->showFloat(const_cast<InsetFloat *>(this));
}
return true;
}
-string const & InsetFloat::type() const
+string const & InsetFloat::type() const
{
return floatType_;
}
// -*- C++ -*-
/* This file is part of
* ======================================================
- *
+ *
* LyX, The Document Processor
*
* Copyright 1998 The LyX Team.
class Painter;
/** The float inset
-
+
*/
class InsetFloat : public InsetCollapsable {
public:
{
}
-
+
InsetFloatList::InsetFloatList(string const & type)
: InsetCommand(InsetCommandParams())
{
}
-string const InsetFloatList::getScreenLabel(Buffer const *) const
+string const InsetFloatList::getScreenLabel(Buffer const *) const
{
string const guiName = floatList[getCmdName()]->second.name();
if (!guiName.empty()) {
}
-void InsetFloatList::read(Buffer const *, LyXLex & lex)
+void InsetFloatList::read(Buffer const *, LyXLex & lex)
{
string token;
* ======================================================
*
* LyX, The Document Word Processor
- *
+ *
* Copyright 1995 Matthias Ettrich
* Copyright 1996-2001 The LyX Team.
- *
+ *
* ====================================================== */
#ifndef INSET_FLOATLIST_H
/* This file is part of
* ======================================================
- *
+ *
* LyX, The Document Processor
- *
+ *
* Copyright 1998 The LyX Team.
*
* ======================================================
ostream & os, bool fragile, bool fp) const
{
os << "%\n\\footnote{";
-
+
int const i = inset.latex(buf, os, fragile, fp);
os << "%\n}";
-
+
return i + 2;
}
// -*- C++ -*-
/* This file is part of
* ======================================================
- *
+ *
* LyX, The Document Processor
*
* Copyright 1998 The LyX Team.
#include "insetfootlike.h"
/** The footnote inset
-
+
*/
class InsetFoot : public InsetFootlike {
public:
};
#endif
-
-
-
/* This file is part of
* ======================================================
- *
+ *
* LyX, The Document Processor
- *
+ *
* Copyright 2000-2001 The LyX Team.
*
* ======================================================
}
-void InsetFootlike::write(Buffer const * buf, ostream & os) const
+void InsetFootlike::write(Buffer const * buf, ostream & os) const
{
os << getInsetName() << "\n";
InsetCollapsable::write(buf, os);
// -*- C++ -*-
/* This file is part of
* ======================================================
- *
+ *
* LyX, The Document Processor
*
* Copyright 1998 The LyX Team.
// To have this class is probably a bit overkill... (Lgb)
/** The footnote inset
-
+
*/
class InsetFootlike : public InsetCollapsable {
public:
};
#endif
-
-
-
-
-
/* This file is part of
- * ======================================================
- *
+ * ======================================================
+ *
* LyX, The Document Processor
- *
+ *
* Copyright 1995-2002 the LyX Team.
- *
+ *
* \author Baruch Even
* \author Herbert Voss <voss@lyx.org>
* ====================================================== */
/*
Known BUGS:
-
+
* If the image is from the clipart, and the document is moved to another
directory, the user is screwed. Need a way to handle it.
This amounts to a problem of when to use relative or absolute file paths
We should probably use what the user asks to use... but when he chooses
- by the file dialog we normally get an absolute path and this may not be
+ by the file dialog we normally get an absolute path and this may not be
what the user meant.
Note that browseRelFile in helper_funcs.* provides a file name
which is relative if it is at reference path (here puffer path)
level or below, and an absolute path if the file name is not a
`natural' relative file name. In any case,
- MakeAbsPath(filename, buf->filePath())
+ MakeAbsPath(filename, buf->filePath())
is guaranteed to provide the correct absolute path. This is what is
done know for include insets. Feel free to ask me -- JMarc
14/01/2002
-
+
TODO Before initial production release:
-
+
* What advanced features the users want to do?
Implement them in a non latex dependent way, but a logical way.
LyX should translate it to latex or any other fitting format.
* and when reading one should change the version check and the error message.
* The filename is kept in the lyx file in a relative way, so as to allow
* moving the document file and its images with no problem.
- *
+ *
*
* Conversions:
* Postscript output means EPS figures.
*
* PDF output is best done with PDF figures if it's a direct conversion
* or PNG figures otherwise.
- * Image format
- * from to
- * EPS epstopdf
- * PS ps2pdf
- * JPG/PNG direct
- * PDF direct
- * others PNG
+ * Image format
+ * from to
+ * EPS epstopdf
+ * PS ps2pdf
+ * JPG/PNG direct
+ * PDF direct
+ * others PNG
*/
-#include <config.h>
+#include <config.h>
#ifdef __GNUG__
#pragma implementation
-#endif
+#endif
#include "insets/insetgraphics.h"
#include "insets/insetgraphicsParams.h"
{
return ChangeExtension(filename, string());
}
-
+
} // namespace anon
InsetGraphics::InsetGraphics()
: graphic_label(unique_id()),
cached_status_(grfx::ErrorUnknown), cache_filled_(false), old_asc(0)
-
+
{}
return pixmap != 0;
}
-
+
int InsetGraphics::ascent(BufferView *, LyXFont const &) const
{
old_asc = 50;
int const msg_width = lyxfont::width(msg, msgFont);
font_width = std::max(font_width, msg_width);
}
-
+
return std::max(50, font_width + 15);
}
}
void InsetGraphics::draw(BufferView * bv, LyXFont const & font,
- int baseline, float & x, bool) const
+ int baseline, float & x, bool) const
{
int oasc = old_asc;
grfx::ImageStatus old_status_ = cached_status_;
-
+
int ldescent = descent(bv, font);
int lascent = ascent(bv, font);
int lwidth = width(bv, font);
// This will draw the graphics. If the graphics has not been loaded yet,
// we draw just a rectangle.
Painter & paint = bv->painter();
-
+
if (drawImage()) {
// lyxerr << "IG(" << this << "): " << old_x << endl;
paint.image(old_x + 2, baseline - lascent,
- lwidth - 4, lascent + ldescent,
+ lwidth - 4, lascent + ldescent,
*cached_image_.get());
} else {
paint.rectangle(old_x + 2, baseline - lascent,
- lwidth - 4,
- lascent + ldescent);
+ lwidth - 4,
+ lascent + ldescent);
// Print the file name.
LyXFont msgFont(font);
string const justname = OnlyFilename (params().filename);
if (!justname.empty()) {
msgFont.setSize(LyXFont::SIZE_FOOTNOTE);
- paint.text(old_x + 8,
+ paint.text(old_x + 8,
baseline - lyxfont::maxAscent(msgFont) - 4,
justname, msgFont);
}
if (old_status_ != grfx::ErrorUnknown && old_status_ != cached_status_) {
bv->getLyXText()->status(bv, LyXText::CHANGED_IN_DRAW);
}
-
+
// Reset the cache, ready for the next draw request
cached_status_ = grfx::ErrorUnknown;
cached_image_.reset(0);
lex.next();
string const token = lex.getString();
- lyxerr[Debug::GRAPHICS] << "Token: '" << token << '\''
+ lyxerr[Debug::GRAPHICS] << "Token: '" << token << '\''
<< std::endl;
if (token.empty()) {
}
else {
if (! params_.Read(buf, lex, token))
- lyxerr << "Unknown token, " << token << ", skipping."
+ lyxerr << "Unknown token, " << token << ", skipping."
<< std::endl;
}
}
std::vector<string> const oldUnits =
getVectorFromString("pt,cm,in,p%,c%");
bool finished = false;
- // set the display default
- if (lyxrc.display_graphics == "mono")
+ // set the display default
+ if (lyxrc.display_graphics == "mono")
params_.display = InsetGraphicsParams::MONOCHROME;
- else if (lyxrc.display_graphics == "gray")
+ else if (lyxrc.display_graphics == "gray")
params_.display = InsetGraphicsParams::GRAYSCALE;
- else if (lyxrc.display_graphics == "color")
+ else if (lyxrc.display_graphics == "color")
params_.display = InsetGraphicsParams::COLOR;
else
params_.display = InsetGraphicsParams::NONE;
string const token = lex.getString();
lyxerr[Debug::GRAPHICS] << "Token: " << token << endl;
-
+
if (token.empty())
continue;
else if (token == "\\end_inset") {
} else if (token == "flags") {
if (lex.next())
switch (lex.getInteger()) {
- case 1: params_.display = InsetGraphicsParams::MONOCHROME;
+ case 1: params_.display = InsetGraphicsParams::MONOCHROME;
break;
- case 2: params_.display = InsetGraphicsParams::GRAYSCALE;
+ case 2: params_.display = InsetGraphicsParams::GRAYSCALE;
break;
- case 3: params_.display = InsetGraphicsParams::COLOR;
+ case 3: params_.display = InsetGraphicsParams::COLOR;
break;
}
} else if (token == "subfigure") {
{
// lyxrc.pdf_mode means:
// Are we creating a PDF or a PS file?
- // (Should actually mean, are we using latex or pdflatex).
+ // (Should actually mean, are we using latex or pdflatex).
lyxerr[Debug::GRAPHICS] << "decideOutput: lyxrc.pdf_mode = "
<< lyxrc.pdf_mode << std::endl;
if (lyxrc.pdf_mode) {
bool const zipped = zippedFile(filename_);
if ((zipped && params().noUnzip) || buf->niceFile) {
- lyxerr[Debug::GRAPHICS] << "don't unzip file or export latex"
+ lyxerr[Debug::GRAPHICS] << "don't unzip file or export latex"
<< filename_ << endl;
return filename_;
}
// Return how many newlines we issued.
int const newlines =
int(lyx::count(latex_str.begin(), latex_str.end(),'\n') + 1);
-
+
// lyxerr << "includegraphics: " << newlines << " lines of text"
- // << endl;
+ // << endl;
return newlines;
}
// See also the docbook guide at http://www.docbook.org/
int InsetGraphics::docbook(Buffer const *, ostream & os) const
{
- // In DocBook v5.0, the graphic tag will be eliminated from DocBook, will
- // need to switch to MediaObject. However, for now this is sufficient and
+ // In DocBook v5.0, the graphic tag will be eliminated from DocBook, will
+ // need to switch to MediaObject. However, for now this is sufficient and
// easier to use.
os << "<graphic fileref=\"&" << graphic_label << ";\">";
return 0;
// -*- C++ -*-
/* This file is part of
- * ======================================================
- *
+ * ======================================================
+ *
* LyX, The Document Processor
- *
+ *
* Copyright 1995 Matthias Ettrich
* Copyright 1995-2001 the LyX Team.
*
#ifdef __GNUG__
#pragma interface
-#endif
+#endif
#include "graphics/GraphicsTypes.h"
#include "insets/inset.h"
fragile commands by adding a #\protect# before.
*/
int latex(Buffer const *, std::ostream &,
- bool fragile, bool free_spc) const;
+ bool fragile, bool free_spc) const;
///
int ascii(Buffer const *, std::ostream &, int linelen) const;
///
void readInsetGraphics(Buffer const * buf, LyXLex & lex);
/// Read the FigInset file format
void readFigInset(Buffer const * buf, LyXLex & lex);
-
+
/// Update the inset after parameter change.
void updateInset() const;
/// Get the status message, depends on the image loading status.
mutable int old_asc;
};
-#endif
+#endif
/* This file is part of
* =================================================
- *
+ *
* LyX, The Document Processor
* Copyright 1995 Matthias Ettrich.
* Copyright 1995-2001 The LyX Team.
*
* ================================================= */
-#include <config.h>
+#include <config.h>
#ifdef __GNUG__
#pragma implementation
-#endif
+#endif
#include "insetgraphicsParams.h"
// it is obselete until 1.3
LyXLength convertResizeValue(string const token, LyXLex & lex) {
lex.next();
- string value = lex.getString(); // "width" or "height"
+ string value = lex.getString(); // "width" or "height"
lex.next(); // anyway not interesting
value = lex.getString();
if (token == "default")
size_type = DEFAULT_SIZE; // do nothing
lyxsize_type = DEFAULT_SIZE; // do nothing
keepAspectRatio = false; // only for latex
- rotate = false; // Rotating
+ rotate = false; // Rotating
rotateOrigin = "center"; // Origin
rotateAngle = 0.0; // in degrees
special = string(); // userdefined stuff
}
bool operator==(InsetGraphicsParams const & left,
- InsetGraphicsParams const & right)
+ InsetGraphicsParams const & right)
{
if (left.filename == right.filename &&
- left.bb == right.bb &&
- left.draft == right.draft &&
- left.clip == right.clip &&
- left.display == right.display &&
- left.subcaption == right.subcaption &&
+ left.bb == right.bb &&
+ left.draft == right.draft &&
+ left.clip == right.clip &&
+ left.display == right.display &&
+ left.subcaption == right.subcaption &&
left.noUnzip == right.noUnzip &&
- left.subcaptionText == right.subcaptionText &&
- left.keepAspectRatio == right.keepAspectRatio &&
- left.width == right.width &&
- left.height == right.height &&
- left.scale == right.scale &&
- left.size_type == right.size_type &&
- left.lyxsize_type == right.lyxsize_type &&
- left.lyxwidth == right.lyxwidth &&
- left.lyxheight == right.lyxheight &&
- left.lyxscale == right.lyxscale &&
- left.rotate == right.rotate &&
- left.rotateOrigin == right.rotateOrigin &&
- lyx::float_equal(left.rotateAngle, right.rotateAngle, 0.001 &&
- left.special == right.special)
+ left.subcaptionText == right.subcaptionText &&
+ left.keepAspectRatio == right.keepAspectRatio &&
+ left.width == right.width &&
+ left.height == right.height &&
+ left.scale == right.scale &&
+ left.size_type == right.size_type &&
+ left.lyxsize_type == right.lyxsize_type &&
+ left.lyxwidth == right.lyxwidth &&
+ left.lyxheight == right.lyxheight &&
+ left.lyxscale == right.lyxscale &&
+ left.rotate == right.rotate &&
+ left.rotateOrigin == right.rotateOrigin &&
+ lyx::float_equal(left.rotateAngle, right.rotateAngle, 0.001 &&
+ left.special == right.special)
)
return true;
}
bool operator!=(InsetGraphicsParams const & left,
- InsetGraphicsParams const & right)
+ InsetGraphicsParams const & right)
{
- return !(left == right);
+ return !(left == right);
}
bool InsetGraphicsParams::Read(Buffer const * buf, LyXLex & lex,
- string const& token)
+ string const& token)
{
if (token == "filename") {
lex.next();
// -*- C++ -*-
/* This file is part of
* =================================================
- *
+ *
* LyX, The Document Processor
* Copyright 1995 Matthias Ettrich.
* Copyright 1995-2002 The LyX Team.
#ifdef __GNUG__
#pragma interface
-#endif
+#endif
#include "LString.h"
string rotateOrigin;
/// Rotation angle.
float rotateAngle;
- /// clip image
+ /// clip image
bool clip;
/// draft mode
bool draft;
bool noUnzip;
/// The bounding box with "xLB yLB yRT yRT ", divided by a space!
string bb;
- /// Type of rescaling
+ /// Type of rescaling
sizeType size_type;
/// three possible values for rescaling (latex)
LyXLength width;
///
bool operator!=(InsetGraphicsParams const &, InsetGraphicsParams const &);
-#endif
+#endif
if (cparams == o.cparams && flag == o.flag &&
noload == o.noload && masterFilename_ == o.masterFilename_)
return true;
-
+
return false;
}
// Just to be safe...
string command;
-
+
switch (params_.flag) {
- case INCLUDE:
- command="include";
- break;
- case VERB:
- command="verbatiminput";
- break;
- case INPUT:
- command="input";
- break;
- case VERBAST:
- command="verbatiminput*";
- break;
+ case INCLUDE:
+ command="include";
+ break;
+ case VERB:
+ command="verbatiminput";
+ break;
+ case INPUT:
+ command="input";
+ break;
+ case VERBAST:
+ command="verbatiminput*";
+ break;
}
-
+
params_.cparams.setCmdName(command);
}
void InsetInclude::read(Buffer const *, LyXLex & lex)
{
params_.cparams.read(lex);
-
+
if (params_.cparams.getCmdName() == "include")
params_.flag = INCLUDE;
else if (params_.cparams.getCmdName() == "input")
}
temp += ": ";
-
+
if (params_.cparams.getContents().empty())
temp += "???";
else
return OnlyFilename(ChangeExtension(params_.cparams.getContents(), string()));
}
-
+
string const InsetInclude::getFileName() const
{
return MakeAbsPath(params_.cparams.getContents(),
if (!IsLyXFilename(getFileName()))
return false;
-
+
if (bufferlist.exists(getFileName()))
return true;
-
+
// the readonly flag can/will be wrong, not anymore I think.
FileInfo finfo(getFileName());
if (!finfo.isOK())
return false;
-
+
return bufferlist.readFile(getFileName(), !finfo.writable()) != 0;
}
bool /*fragile*/, bool /*fs*/) const
{
string incfile(params_.cparams.getContents());
-
+
// Do nothing if no file name has been specified
if (incfile.empty())
return 0;
-
+
if (loadIfNeeded()) {
Buffer * tmp = bufferlist.getBuffer(getFileName());
<< "'." << endl;
//return 0;
}
-
+
// write it to a file (so far the complete file)
string writefile = ChangeExtension(getFileName(), ".tex");
writefile = ChangeExtension(writefile, ".tex");
lyxerr[Debug::LATEX] << "incfile:" << incfile << endl;
lyxerr[Debug::LATEX] << "writefile:" << writefile << endl;
-
+
tmp->markDepClean(buffer->tmppath);
-
+
tmp->makeLaTeXFile(writefile,
OnlyPath(getMasterFilename()),
buffer->niceFile, true);
int InsetInclude::linuxdoc(Buffer const * buffer, ostream & os) const
{
string incfile(params_.cparams.getContents());
-
+
// Do nothing if no file name has been specified
if (incfile.empty())
return 0;
-
+
if (loadIfNeeded()) {
Buffer * tmp = bufferlist.getBuffer(getFileName());
lyxerr[Debug::LATEX] << "incfile:" << incfile << endl;
lyxerr[Debug::LATEX] << "writefile:" << writefile << endl;
-
+
tmp->makeLinuxDocFile(writefile, buffer->niceFile, true);
}
<< "]]>";
} else
os << '&' << include_label << ';';
-
+
return 0;
}
// Do nothing if no file name has been specified
if (incfile.empty())
return 0;
-
+
if (loadIfNeeded()) {
Buffer * tmp = bufferlist.getBuffer(getFileName());
lyxerr[Debug::LATEX] << "incfile:" << incfile << endl;
lyxerr[Debug::LATEX] << "writefile:" << writefile << endl;
-
+
tmp->makeDocBookFile(writefile, buffer->niceFile, true);
}
<< "\" format=\"linespecific\">";
} else
os << '&' << include_label << ';';
-
+
return 0;
}
vector<pair<string,string> > const InsetInclude::getKeys() const
{
vector<pair<string,string> > keys;
-
+
if (loadIfNeeded()) {
Buffer * tmp = bufferlist.getBuffer(getFileName());
tmp->setParentName("");
keys = tmp->getBibkeyList();
tmp->setParentName(getMasterFilename());
}
-
+
return keys;
}
* ======================================================
*
* LyX, The Document Processor
- *
+ *
* Copyright 1997 LyX Team (this file was created this year)
*
* ====================================================== */
*/
class InsetInclude: public InsetButton, boost::noncopyable {
public:
- /// the type of inclusion
- enum Flags {
+ /// the type of inclusion
+ enum Flags {
///
INCLUDE = 0,
///
void read(Buffer const *, LyXLex &);
///
int latex(Buffer const *, std::ostream &,
- bool fragile, bool free_spc) const;
+ bool fragile, bool free_spc) const;
///
int ascii(Buffer const *, std::ostream &, int linelen) const;
///
int docbook(Buffer const *, std::ostream &) const;
///
void validate(LaTeXFeatures &) const;
-
- /** Input inserts anything inside a paragraph.
+
+ /** Input inserts anything inside a paragraph.
Display can give some visual feedback
*/
bool display() const;
- /// return the filename stub of the included file
+ /// return the filename stub of the included file
string const getRelFileBaseName() const;
-
+
/// return true if the included file is not loaded
bool isIncludeOnly() const;
/// return true if the file is or got loaded.
bool loadIfNeeded() const;
-
- /// hide a dialog if about
+
+ /// hide a dialog if about
SigC::Signal0<void> hideDialog;
private:
/// get the text displayed on the button
string const getScreenLabel(Buffer const *) const;
/// is this a verbatim include ?
bool isVerbatim() const;
- /// get the filename of the master buffer
- string const getMasterFilename() const;
- /// get the included file name
- string const getFileName() const;
+ /// get the filename of the master buffer
+ string const getMasterFilename() const;
+ /// get the included file name
+ string const getFileName() const;
/// the parameters
Params params_;
- /// holds the entity name that defines the file location (SGML)
+ /// holds the entity name that defines the file location (SGML)
string const include_label;
};
Inset::Code InsetIndex::lyxCode() const
{
- return Inset::INDEX_CODE;
+ return Inset::INDEX_CODE;
}
Inset::Code InsetPrintIndex::lyxCode() const
{
- return Inset::INDEX_PRINT_CODE;
+ return Inset::INDEX_PRINT_CODE;
}
// -*- C++ -*-
/* This file is part of*
- * ======================================================
+ * ======================================================
*
* LyX, The Document Processor
- *
+ *
* Copyright 1995 Matthias Ettrich
* Copyright 1996-2001 the LyX Team.
- *
+ *
* ====================================================== */
#ifndef INSET_INDEX_H
struct LaTeXFeatures;
-/** Used to insert index labels
+/** Used to insert index labels
*/
class InsetIndex : public InsetCommand {
public:
/* This file is part of
* ======================================================
- *
+ *
* LyX, The Document Processor
- *
+ *
* Copyright 1995 Matthias Ettrich
* Copyright 1995-2001 The LyX Team.
*
* ======================================================
*
* LyX, The Document Processor
- *
+ *
* Copyright 1995 Matthias Ettrich
* Copyright 1995-2001 The LyX Team
*
std::vector<string> const getLabelList() const;
///
int latex(Buffer const *, std::ostream &,
- bool fragile, bool free_spc) const;
+ bool fragile, bool free_spc) const;
///
int ascii(Buffer const *, std::ostream &, int linelen) const;
///
/* This file is part of
- * ======================================================
- *
+ * ======================================================
+ *
* LyX, The Document Processor
- *
+ *
* Copyright 1995 Matthias Ettrich
* Copyright 1995-2001 The LyX Team.
*
void InsetLatexAccent::checkContents()
- // check, if we know the modifier and can display it ok on screen
+ // check, if we know the modifier and can display it ok on screen
{
- candisp = false;
+ candisp = false;
if (contents.empty() || contents.length() < 2) {
lyxerr[Debug::KEY] << "Cannot decode: " << contents << endl;
contents = tmp;
}
}
- if (contents[0] != '\\') { // demand that first char is a '\\'
+ if (contents[0] != '\\') { // demand that first char is a '\\'
lyxerr[Debug::KEY] << "Cannot decode: " << contents << endl;
return;
}
lyxerr[Debug::KEY] << "Decode: " << contents << endl;
- remdot = false; plusasc = false; plusdesc = false;
+ remdot = false; plusasc = false; plusdesc = false;
- switch (contents[1]) { // second char should be one of these
+ switch (contents[1]) { // second char should be one of these
case '\'': // acute
- modtype = ACUTE; // acute
- plusasc = true; // at the top of character
- break;
+ modtype = ACUTE; // acute
+ plusasc = true; // at the top of character
+ break;
case '`': // grave
- modtype = GRAVE; // grave
- plusasc = true; // at the top
- break;
+ modtype = GRAVE; // grave
+ plusasc = true; // at the top
+ break;
case '=': // macron
- modtype = MACRON; // macron
- plusasc = true; // at the top
- break;
+ modtype = MACRON; // macron
+ plusasc = true; // at the top
+ break;
case '~': // tilde
- modtype = TILDE; // tilde
- plusasc = true; // at the top
- break;
+ modtype = TILDE; // tilde
+ plusasc = true; // at the top
+ break;
case 'b': // underbar
- modtype = UNDERBAR; // underbar
- plusdesc = true; // at the bottom
- break;
+ modtype = UNDERBAR; // underbar
+ plusdesc = true; // at the bottom
+ break;
case 'c': // cedilla
- modtype = CEDILLA; // cedilla
- plusdesc = true; // at the bottom
- break;
+ modtype = CEDILLA; // cedilla
+ plusdesc = true; // at the bottom
+ break;
case 'd': // underdot
- modtype = UNDERDOT; // underdot
- plusdesc = true; // at the bottom
- break;
+ modtype = UNDERDOT; // underdot
+ plusdesc = true; // at the bottom
+ break;
case 'r': // circle
- modtype = CIRCLE; // circle
- plusasc = true; // at the top
- break;
+ modtype = CIRCLE; // circle
+ plusasc = true; // at the top
+ break;
case 't': // tie
- modtype = TIE; // tie
- plusasc = true; // at the top
- break;
+ modtype = TIE; // tie
+ plusasc = true; // at the top
+ break;
case 'u': // breve
- modtype = BREVE; // breve
- plusasc = true; // at the top
- break;
+ modtype = BREVE; // breve
+ plusasc = true; // at the top
+ break;
case 'v': // caron
- modtype = CARON; // caron
- plusasc = true; // at the top
- break;
+ modtype = CARON; // caron
+ plusasc = true; // at the top
+ break;
case 'q': // special caron
- modtype = SPECIAL_CARON; // special caron
- plusasc = true; // at the top
- break;
+ modtype = SPECIAL_CARON; // special caron
+ plusasc = true; // at the top
+ break;
case 'H': // hungarian umlaut
- modtype = HUNGARIAN_UMLAUT; // hungarian umlaut
- plusasc = true; // at the top
- break;
+ modtype = HUNGARIAN_UMLAUT; // hungarian umlaut
+ plusasc = true; // at the top
+ break;
case '"': // umlaut
- modtype = UMLAUT; // umlaut
- plusasc = true; // at the top
- break;
+ modtype = UMLAUT; // umlaut
+ plusasc = true; // at the top
+ break;
case '.': // dot
- modtype = DOT; // dot
- plusasc = true; // at the top
- break;
+ modtype = DOT; // dot
+ plusasc = true; // at the top
+ break;
case '^': // circumflex
- modtype = CIRCUMFLEX; // circumflex
- plusasc = true; // at the top
- break;
+ modtype = CIRCUMFLEX; // circumflex
+ plusasc = true; // at the top
+ break;
case 'k': // ogonek
modtype = OGONEK; // ogonek
plusdesc = true;
plusasc = true; // at the top (not really needed)
remdot = true;
break;
- case 'l': // lslash
- modtype = lSLASH;
- plusasc = true; // at the top (not really needed)
- break;
- case 'L': // lslash
- modtype = LSLASH;
- plusasc = true; // at the top (not really needed)
- break;
+ case 'l': // lslash
+ modtype = lSLASH;
+ plusasc = true; // at the top (not really needed)
+ break;
+ case 'L': // lslash
+ modtype = LSLASH;
+ plusasc = true; // at the top (not really needed)
+ break;
default:
lyxerr[Debug::KEY] << "Default" << endl;
// unknow accent (or something else)
- return;
- }
+ return;
+ }
// we demand that third char is a '{' (Lgb)
if (contents[2] != '{') return;
}
//ic = (modtype == DOT_LESS_J ? 'j' : 'i');
lyxerr[Debug::KEY] << "Contents: [" << contents << "]"
- << ", ic: " << ic
- << ", top: " << plusasc
- << ", bot: " << plusdesc
- << ", dot: " << remdot
+ << ", ic: " << ic
+ << ", top: " << plusasc
+ << ", bot: " << plusdesc
+ << ", dot: " << remdot
<< ", mod: " << modtype << endl;
// Special case for space
} else if (contents[3] == '}') {
ic = ' ';
} else {
int i = 3;
-
+
// now get the char
ic = contents[3]; // i will always be 3 here
contents= temp;
++i;
remdot = true;
- }
+ }
// demand a '}' at the end
if (contents[++i] != '}' && contents[++i]) return;
-
+
// fine, the char is properly decoded now (hopefully)
lyxerr[Debug::KEY] << "Contents: [" << contents << "]"
<< ", ic: " << ic
- << ", top: " << plusasc
- << ", bot: " << plusdesc
+ << ", top: " << plusasc
+ << ", bot: " << plusdesc
<< ", dot: " << remdot
<< ", mod: " << modtype << endl;
}
- candisp = true;
+ candisp = true;
}
max = lyxfont::ascent('a', font);
else
max = lyxfont::ascent(ic, font);
- if (plusasc)
+ if (plusasc)
max += (lyxfont::maxAscent(font) + 3) / 3;
} else
max = lyxfont::maxAscent(font) + 4;
{
int max;
if (candisp) {
- if (ic == ' ')
+ if (ic == ' ')
max = lyxfont::descent('a', font);
- else
- max = lyxfont::descent(ic, font);
- if (plusdesc)
- max += 3;
+ else
+ max = lyxfont::descent(ic, font);
+ if (plusdesc)
+ max += 3;
} else
max = lyxfont::maxDescent(font) + 4;
return max;
{
if (candisp)
return lyxfont::width(ic, font);
- else
- return lyxfont::width(contents, font) + 4;
+ else
+ return lyxfont::width(contents, font) + 4;
}
bool InsetLatexAccent::displayISO8859_9(BufferView * bv, LyXFont const & font,
- int baseline,
+ int baseline,
float & x) const
{
unsigned char tmpic = ic;
-
+
switch (modtype) {
case CEDILLA:
{
if (ic == 'U') tmpic = 0xdc;
break;
}
- case DOT: if (ic == 'I') tmpic = 0xdd; break;
+ case DOT: if (ic == 'I') tmpic = 0xdd; break;
case DOT_LESS_I: tmpic = 0xfd; break;
default: return false;
}
Painter & pain = bv->painter();
if (lyxrc.font_norm_type == LyXRC::ISO_8859_9)
- if (displayISO8859_9(bv, font0, baseline, x))
+ if (displayISO8859_9(bv, font0, baseline, x))
return;
-
- /* draw it! */
+
+ /* draw it! */
// All the manually drawn accents in this function could use an
// overhaul. Different ways of drawing (what metrics to use)
// should also be considered.
LyXFont font(font0);
if (lyxrc.font_norm_type == LyXRC::ISO_10646_1)
font.setLanguage(english_language);
-
+
if (candisp) {
int asc = ascent(bv, font);
int desc = descent(bv, font);
// now the rest - draw within (x, y, x+wid, y+hg)
switch (modtype) {
case ACUTE: // acute 0xB4
- {
+ {
pain.text(int(x2 - (lyxfont::rbearing(0xB4, font) - lyxfont::lbearing(0xB4, font)) / 2),
baseline - lyxfont::ascent(ic, font) - lyxfont::descent(0xB4, font) - (lyxfont::ascent(0xB4, font) + lyxfont::descent(0xB4, font)) / 2,
char(0xB4), font);
{
pain.text(int(x2 - (lyxfont::rbearing(0xB8, font) - lyxfont::lbearing(0xB8, font)) / 2), baseline,
char(0xB8), font);
-
+
break;
}
case UNDERDOT: // underdot
case CARON: // caron
{
int xp[3], yp[3];
-
+
xp[0] = int(x2 - hg35); yp[0] = int(y + hg35);
xp[1] = int(x2); yp[1] = int(y + hg);
xp[2] = int(x2 + hg35); yp[2] = int(y + hg35);
int xp[3], yp[3];
xp[0] = int(x + wid);
yp[0] = int(y + hg35 + hg);
-
+
xp[1] = int(x + wid + (hg35 / 2.0));
yp[1] = int(y + hg + (hg35 / 2.0));
-
+
xp[2] = int(x + wid + (hg35 / 2.0));
yp[2] = y + int(hg);
// this does probably not look like an ogonek, so
// it should certainly be refined
int xp[4], yp[4];
-
+
xp[0] = int(x2);
yp[0] = y;
-
+
xp[1] = int(x2);
yp[1] = y + int(hg35);
-
+
xp[2] = int(x2 - hg35);
yp[2] = y + int(hg / 2.0);
-
+
xp[3] = int(x2 + hg / 4.0);
yp[3] = y + int(hg);
case LSLASH:
{
int xp[2], yp[2];
-
- xp[0] = int(x);
+
+ xp[0] = int(x);
yp[0] = y + int(3.0 * hg);
-
- xp[1] = int(x + float(wid) * 0.75);
+
+ xp[1] = int(x + float(wid) * 0.75);
yp[1] = y + int(hg);
-
- pain.lines(xp, yp, 2);
- break;
+
+ pain.lines(xp, yp, 2);
+ break;
}
case DOT_LESS_I: // dotless-i
case DOT_LESS_J: // dotless-j
// -*- C++ -*-
/* This file is part of*
- * ======================================================
+ * ======================================================
*
* LyX, The Document Processor
- *
+ *
* Copyright 1995 Matthias Ettrich
*
* ====================================================== */
#include "lyxlex.h"
/** Insertion of accents
-
+
Proper handling of accented characters.
This is class is supposed to handle all LaTeX accents, it
is also possible that the class will change a bit so that
inline bool canDisplay();
// should this inset be handled like a normal charater
bool isChar() const { return true; }
-
+
/// all the accent types
enum ACCENT_TYPES{
///
///
DOT_LESS_I,
///
- DOT_LESS_J, // 18
+ DOT_LESS_J, // 18
///
- lSLASH,
+ lSLASH,
///
- LSLASH
+ LSLASH
};
private:
friend std::ostream & operator<<(std::ostream &, ACCENT_TYPES);
bool candisp;
/// modifier type
ACCENT_TYPES modtype;
-
+
/// remove dot from 'i' and 'j' or transform l, L into lslash, LSLaSH
bool remdot;
/// add something to ascent - accent at the top
/// add something to descent - underlined char
bool plusdesc;
/// international char
- mutable char ic;
+ mutable char ic;
};
/* This file is part of
* ======================================================
- *
+ *
* LyX, The Document Processor
- *
+ *
* Copyright 1998 The LyX Team.
*
* ====================================================== */
ostream & os, bool fragile, bool fp) const
{
os << "\\footnote{%\n";
-
+
int i = inset.latex(buf, os, fragile, fp);
os << "}%\n";
-
+
return i + 2;
}
// -*- C++ -*-
/* This file is part of
* ======================================================
- *
+ *
* LyX, The Document Processor
*
* Copyright 1998 The LyX Team.
#include "insetcollapsable.h"
/** The list inset
-
+
*/
class InsetList : public InsetCollapsable {
public:
/* This file is part of
* ======================================================
- *
+ *
* LyX, The Document Processor
- *
+ *
* Copyright 1998 The LyX Team.
*
* ======================================================
ostream & os, bool fragile, bool fp) const
{
os << "%\n\\marginpar{";
-
+
int const i = inset.latex(buf, os, fragile, fp);
os << "%\n}";
-
+
return i + 2;
}
// -*- C++ -*-
/* This file is part of
* ======================================================
- *
+ *
* LyX, The Document Processor
*
* Copyright 1998 The LyX Team.
#include "insetfootlike.h"
/** The marginal note inset
-
+
*/
class InsetMarginal : public InsetFootlike {
public:
/* This file is part of
* ======================================================
- *
+ *
* LyX, The Document Processor
- *
+ *
* Copyright 1998 The LyX Team.
*
*======================================================*/
// just for experimentation :)
setBackgroundColor(LColor::green);
#endif
-
+
inset.setFrameColor(0, LColor::blue);
setInsetName("Minipage");
}
}
-void InsetMinipage::write(Buffer const * buf, ostream & os) const
+void InsetMinipage::write(Buffer const * buf, ostream & os) const
{
os << getInsetName() << "\n"
<< "position " << pos_ << "\n"
}
os << "\\begin{minipage}[" << s_pos << "]{"
<< width_.asLatexString() << "}%\n";
-
+
int i = inset.latex(buf, os, fragile, fp);
os << "\\end{minipage}%\n";
}
-InsetMinipage::Position InsetMinipage::pos() const
+InsetMinipage::Position InsetMinipage::pos() const
{
return pos_;
}
// -*- C++ -*-
/* This file is part of
* ======================================================
- *
+ *
* LyX, The Document Processor
*
* Copyright 2001 The LyX Team.
#include <sigc++/signal_system.h>
/** The minipage inset
-
+
*/
class InsetMinipage : public InsetCollapsable {
public:
/* This file is part of
* ======================================================
- *
+ *
* LyX, The Document Processor
- *
+ *
* Copyright 1998 The LyX Team.
*
* ======================================================
// This constructor is used for reading old InsetInfo
-InsetNote::InsetNote(Buffer const * buf, string const & contents,
+InsetNote::InsetNote(Buffer const * buf, string const & contents,
bool collapsed)
: InsetCollapsable(buf->params, collapsed)
{
}
-string const InsetNote::editMessage() const
+string const InsetNote::editMessage() const
{
return _("Opened Note Inset");
}
// -*- C++ -*-
/* This file is part of
* ======================================================
- *
+ *
* LyX, The Document Processor
*
* Copyright 2001 The LyX Team.
#include "insetcollapsable.h"
/** The PostIt note inset
-
+
*/
class InsetNote : public InsetCollapsable {
public:
- ///
+ ///
InsetNote(BufferParams const &);
///
InsetNote(InsetNote const &, bool same_id = false);
/* This file is part of*
- * ======================================================
+ * ======================================================
*
* LyX, The Document Processor
- *
+ *
* Copyright 1997-2001 The LyX Team.
- *
+ *
* ====================================================== */
}
-string const InsetParent::getScreenLabel(Buffer const *) const
+string const InsetParent::getScreenLabel(Buffer const *) const
{
return string(_("Parent:")) + getContents();
}
void InsetParent::edit(BufferView * bv, int, int, unsigned int)
-{
+{
bv->owner()->getLyXFunc()->
dispatch(LFUN_CHILDOPEN, getContents());
}
// -*- C++ -*-
/* This file is part of*
- * ======================================================
+ * ======================================================
*
* LyX, The Document Processor
- *
+ *
* Copyright 1997-2001 LyX Team
- *
+ *
* ====================================================== */
#ifndef INSET_PARENT_H
/** Reference to the parent document.
Useful to load a parent document from a child document and to
- share parent's properties between preambleless children.
+ share parent's properties between preambleless children.
*/
class InsetParent : public InsetCommand {
public:
void edit(BufferView *, int, int, unsigned int);
///
void edit(BufferView * bv, bool front = true);
- ///
+ ///
int latex(Buffer const *, std::ostream &,
- bool fragile, bool free_spc) const;
+ bool fragile, bool free_spc) const;
///
void setParent(string fn) { setContents(fn); }
};
/* This file is part of
* ======================================================
- *
+ *
* LyX, The Document Processor
- *
+ *
* Copyright 1995 Matthias Ettrich
* Copyright 1995-2001 The LyX Team.
*
// Index of chars used for the quote. Index is [side, language]
int quote_index[2][6] = {
- { 2, 1, 0, 0, 3, 4 }, // "'',,<>"
+ { 2, 1, 0, 0, 3, 4 }, // "'',,<>"
{ 1, 1, 2, 1, 4, 3 } }; // "`'`'><"
// Corresponding LaTeX code, for double and single quotes.
-char const * const latex_quote_t1[2][5] =
-{ { "\\quotesinglbase{}", "'", "`",
- "\\guilsinglleft{}", "\\guilsinglright{}" },
+char const * const latex_quote_t1[2][5] =
+{ { "\\quotesinglbase{}", "'", "`",
+ "\\guilsinglleft{}", "\\guilsinglright{}" },
{ ",,", "''", "``", "<<", ">>" } };
-char const * const latex_quote_ot1[2][5] =
-{ { "\\quotesinglbase{}", "'", "`",
- "\\guilsinglleft{}", "\\guilsinglright{}" },
+char const * const latex_quote_ot1[2][5] =
+{ { "\\quotesinglbase{}", "'", "`",
+ "\\guilsinglleft{}", "\\guilsinglright{}" },
{ "\\quotedblbase{}", "''", "``",
"\\guillemotleft{}", "\\guillemotright{}" } };
-char const * const latex_quote_babel[2][5] =
+char const * const latex_quote_babel[2][5] =
{ { "\\glq{}", "'", "`", "\\flq{}", "\\frq{}" },
{ "\\glqq{}", "''", "``", "\\flqq{}", "\\frqq{}" } };
InsetQuotes::InsetQuotes(char c, BufferParams const & params)
: language_(params.quotes_language), times_(params.quotes_times)
{
- // Decide whether left or right
+ // Decide whether left or right
switch (c) {
- case ' ': case '(':
+ case ' ': case '(':
case Paragraph::META_HFILL:
- case Paragraph::META_NEWLINE:
- side_ = LeftQ; // left quote
+ case Paragraph::META_NEWLINE:
+ side_ = LeftQ; // left quote
break;
default:
side_ = RightQ; // right quote
}
int i;
-
+
for (i = 0; i < 6; ++i) {
if (str[0] == language_char[i]) {
language_ = quote_language(i);
if (i >= 6) {
lyxerr << "ERROR (InsetQuotes::InsetQuotes):"
" bad language specification." << endl;
- language_ = EnglishQ;
+ language_ = EnglishQ;
}
for (i = 0; i < 2; ++i) {
if (i >= 2) {
lyxerr << "ERROR (InsetQuotes::InsetQuotes):"
" bad side specification." << endl;
- side_ = LeftQ;
+ side_ = LeftQ;
}
for (i = 0; i < 2; ++i) {
if (i >= 2) {
lyxerr << "ERROR (InsetQuotes::InsetQuotes):"
" bad times specification." << endl;
- times_ = DoubleQ;
+ times_ = DoubleQ;
}
}
string const InsetQuotes::dispString(Language const * loclang) const
{
- string disp;
+ string disp;
disp += quote_char[quote_index[side_][language_]];
if (times_ == DoubleQ)
disp += disp;
- if (lyxrc.font_norm_type == LyXRC::ISO_8859_1
- || lyxrc.font_norm_type == LyXRC::ISO_8859_3
- || lyxrc.font_norm_type == LyXRC::ISO_8859_4
- || lyxrc.font_norm_type == LyXRC::ISO_8859_9) {
+ if (lyxrc.font_norm_type == LyXRC::ISO_8859_1
+ || lyxrc.font_norm_type == LyXRC::ISO_8859_3
+ || lyxrc.font_norm_type == LyXRC::ISO_8859_4
+ || lyxrc.font_norm_type == LyXRC::ISO_8859_9) {
if (disp == "'")
disp = "´";
else if (disp == "''")
disp = "´´";
}
- if (lyxrc.font_norm_type == LyXRC::ISO_8859_1
- || lyxrc.font_norm_type == LyXRC::ISO_8859_9
- || lyxrc.font_norm_type == LyXRC::ISO_8859_15) {
+ if (lyxrc.font_norm_type == LyXRC::ISO_8859_1
+ || lyxrc.font_norm_type == LyXRC::ISO_8859_9
+ || lyxrc.font_norm_type == LyXRC::ISO_8859_15) {
if (disp == "<<")
disp = '«';
else if (disp == ">>")
else
disp = " " + disp;
}
-
- return disp;
+
+ return disp;
}
string text;
text += language_char[language_];
text += side_char[side_];
- text += times_char[times_];
+ text += times_char[times_];
os << "Quotes " << text;
}
const int quoteind = quote_index[side_][language_];
string qstr;
-
+
if (language_ == FrenchQ && times_ == DoubleQ
&& curr_lang == "frenchb") {
- if (side_ == LeftQ)
+ if (side_ == LeftQ)
qstr = "\\og "; //the spaces are important here
- else
+ else
qstr = " \\fg{}"; //and here
} else if (language_ == FrenchQ && times_ == DoubleQ
&& curr_lang == "french") {
- if (side_ == LeftQ)
+ if (side_ == LeftQ)
qstr = "<< "; //the spaces are important here
- else
+ else
qstr = " >>"; //and here
} else if (lyxrc.fontenc == "T1") {
qstr = latex_quote_t1[times_][quoteind];
} else if (!use_babel) {
#endif
qstr = latex_quote_ot1[times_][quoteind];
- } else {
+ } else {
qstr = latex_quote_babel[times_][quoteind];
}
}
-void InsetQuotes::validate(LaTeXFeatures & features) const
+void InsetQuotes::validate(LaTeXFeatures & features) const
{
char type = quote_char[quote_index[side_][language_]];
#ifdef DO_USE_DEFAULT_LANGUAGE
- if (features.bufferParams().language->lang() == "default"
+ if (features.bufferParams().language->lang() == "default"
#else
if (!use_babel
#endif
&& lyxrc.fontenc != "T1") {
- if (times_ == SingleQ)
+ if (times_ == SingleQ)
switch (type) {
case ',': features.require("quotesinglbase"); break;
case '<': features.require("guilsinglleft"); break;
case '>': features.require("guilsinglright"); break;
default: break;
}
- else
+ else
switch (type) {
case ',': features.require("quotedblbase"); break;
case '<': features.require("guillemotleft"); break;
* ======================================================
*
* LyX, The Document Processor
- *
+ *
* Copyright 1995 Matthias Ettrich
* Copyright 1995-2001 The LyX Team
*
/** Quotes.
Used for the various quotes. German, English, French, all either
- double or single **/
+ double or single **/
class InsetQuotes : public Inset {
public:
///
///
LeftQ,
///
- RightQ
+ RightQ
};
///
enum quote_times {
///
SingleQ,
///
- DoubleQ
+ DoubleQ
};
-
+
/** The constructor works like this:
\begin{itemize}
- \item fls <- french single quote left
- \item grd <- german double quote right
+ \item fls <- french single quote left
+ \item grd <- german double quote right
\item etc.
\end{itemize}
*/
Inset::Code lyxCode() const;
// should this inset be handled like a normal charater
bool isChar() const { return true; }
-
+
private:
///
quote_language language_;
string const dispString(Language const *) const;
};
#endif
-
{
// Eventually trigger dialog with button 3 not 1
if (button == 3)
- bv->owner()->getLyXFunc()->
+ bv->owner()->getLyXFunc()->
dispatch(LFUN_REF_GOTO, getContents());
else if (button == 1)
bv->owner()->getDialogs()->showRef(this);
* ======================================================
*
* LyX, The Document Processor
- *
+ *
* Copyright 1997 LyX Team (this file was created this year)
- *
+ *
* ====================================================== */
#ifndef INSET_REF_H
struct LaTeXFeatures;
-/** The reference inset
+/** The reference inset
*/
class InsetRef : public InsetCommand {
public:
bool display() const { return false; }
///
int latex(Buffer const *, std::ostream &,
- bool fragile, bool free_spc) const;
+ bool fragile, bool free_spc) const;
///
int ascii(Buffer const *, std::ostream &, int linelen) const;
///
/* This file is part of
* ======================================================
- *
+ *
* LyX, The Document Processor
- *
+ *
* Copyright 2000-2001 The LyX Team.
*
* ======================================================
// -*- C++ -*-
/* This file is part of
* ======================================================
- *
+ *
* LyX, The Document Processor
*
* Copyright 2000-2001 The LyX Team.
/* This file is part of
* ======================================================
- *
+ *
* LyX, The Document Processor
- *
+ *
* Copyright 1997 Asger Alstrup
*
* ====================================================== */
case HYPHENATION:
{
int w = lyxfont::width('-', font);
- if (w > 5)
+ if (w > 5)
w -= 2; // to make it look shorter
return w;
}
{
return lyxfont::width('x', font);
}
-
+
}
return 1; // To shut up gcc
}
int ox = lyxfont::width(' ', font) + int(x);
int h = lyxfont::ascent('x', font);
int xp[4], yp[4];
-
+
xp[0] = ox; yp[0] = baseline;
xp[1] = ox; yp[1] = baseline - h;
xp[2] = ox + w; yp[2] = baseline - h/2;
xp[3] = ox; yp[3] = baseline;
-
+
pain.lines(xp, yp, 4, LColor::special);
x += width(bv, font);
break;
float w = width(bv, font);
int h = lyxfont::ascent('x', font);
int xp[4], yp[4];
-
+
xp[0] = int(x);
yp[0] = baseline - max(h / 4, 1);
xp[3] = int(x + w);
yp[3] = baseline - max(h / 4, 1);
-
+
pain.lines(xp, yp, 4, LColor::special);
x += w;
break;
{
string command;
switch (kind_) {
- case HYPHENATION:
- command = "\\-";
+ case HYPHENATION:
+ command = "\\-";
break;
- case LIGATURE_BREAK:
- command = "\\textcompwordmark{}";
+ case LIGATURE_BREAK:
+ command = "\\textcompwordmark{}";
break;
- case END_OF_SENTENCE:
+ case END_OF_SENTENCE:
command = "\\@.";
break;
case LDOTS:
- command = "\\ldots{}";
+ command = "\\ldots{}";
break;
case MENU_SEPARATOR:
- command = "\\menuseparator";
+ command = "\\menuseparator";
break;
case PROTECTED_SEPARATOR:
//command = "\\protected_separator";
// This function will not be necessary when lyx3
void InsetSpecialChar::read(Buffer const *, LyXLex & lex)
-{
+{
lex.nextToken();
string const command = lex.getString();
else if (command == "\\ldots{}")
kind_ = LDOTS;
else if (command == "\\menuseparator")
- kind_ = MENU_SEPARATOR;
+ kind_ = MENU_SEPARATOR;
else if (command == "\\protected_separator"
|| command == "~")
kind_ = PROTECTED_SEPARATOR;
bool free_space) const
{
switch (kind_) {
- case HYPHENATION:
- os << "\\-";
+ case HYPHENATION:
+ os << "\\-";
break;
case LIGATURE_BREAK:
os << "\\textcompwordmark{}";
break;
- case END_OF_SENTENCE:
- os << "\\@.";
+ case END_OF_SENTENCE:
+ os << "\\@.";
break;
- case LDOTS:
- os << "\\ldots{}";
+ case LDOTS:
+ os << "\\ldots{}";
break;
- case MENU_SEPARATOR:
- os << "\\lyxarrow{}";
+ case MENU_SEPARATOR:
+ os << "\\lyxarrow{}";
break;
- case PROTECTED_SEPARATOR:
- os << (free_space ? " " : "~");
+ case PROTECTED_SEPARATOR:
+ os << (free_space ? " " : "~");
break;
}
return 0;
case HYPHENATION:
case LIGATURE_BREAK:
break;
- case END_OF_SENTENCE:
- os << ".";
+ case END_OF_SENTENCE:
+ os << ".";
break;
- case LDOTS:
- os << "...";
+ case LDOTS:
+ os << "...";
break;
- case MENU_SEPARATOR:
- os << "->";
+ case MENU_SEPARATOR:
+ os << "->";
break;
- case PROTECTED_SEPARATOR:
+ case PROTECTED_SEPARATOR:
os << " ";
break;
}
os << ".";
break;
case LDOTS:
- os << "...";
+ os << "...";
break;
- case MENU_SEPARATOR:
- os << "&lyxarrow;";
+ case MENU_SEPARATOR:
+ os << "&lyxarrow;";
break;
case PROTECTED_SEPARATOR:
os << " ";
os << ".";
break;
case LDOTS:
- os << "...";
+ os << "...";
break;
case MENU_SEPARATOR:
os << "&lyxarrow;";
// -*- C++ -*-
/* This file is part of*
- * ======================================================
+ * ======================================================
*
* LyX, The Document Processor
- *
+ *
* Copyright 1997 Asger Alstrup
*
* ====================================================== */
void write(Buffer const *, std::ostream &) const;
/// Will not be used when lyxf3
void read(Buffer const *, LyXLex & lex);
- ///
+ ///
int latex(Buffer const *, std::ostream &,
bool fragile, bool free_spc) const;
///
int docbook(Buffer const *, std::ostream &) const;
///
virtual Inset * clone(Buffer const &, bool same_id = false) const;
- ///
+ ///
Inset::Code lyxCode() const
{
return Inset::SPECIALCHAR_CODE;
}
/// We don't need \begin_inset and \end_inset
- bool directWrite() const
+ bool directWrite() const
{
return true;
};
///
void validate(LaTeXFeatures &) const;
-
+
// should this inset be handled like a normal charater
bool isChar() const;
/// is this equivalent to a letter?
/* This file is part of
* ======================================================
- *
+ *
* LyX, The Document Processor
*
* Copyright 2001 The LyX Team.
x += static_cast<float>(scroll());
#endif
if (!cleared && ((need_update == INIT) || (need_update == FULL) ||
- (top_x != int(x)) || (top_baseline != baseline)))
+ (top_x != int(x)) || (top_baseline != baseline)))
{
int h = ascent(bv, font) + descent(bv, font);
int const tx = display() || !owner() ? 0 : top_x;
int w = tx ? width(bv, font) : pain.paperWidth();
int ty = baseline - ascent(bv, font);
-
+
if (ty < 0)
ty = 0;
if ((ty + h) > pain.paperHeight())
if (hasSelection()) {
drawCellSelection(pain, nx, baseline, i, j, cell);
}
-
+
tabular->GetCellInset(cell)->draw(bv, font, baseline, cx, cleared);
drawCellLines(pain, nx, baseline, i, cell);
nx += tabular->GetWidthOfColumn(cell);
//
// +--------------------+
// | C | The rectangles are A, B and C
- // | A |------------| B | below, origin top left (tx, ty),
+ // | A |------------| B | below, origin top left (tx, ty),
// | | inset box | | dimensions w(idth), h(eight).
// +---+------------+---+ x grows rightward, y downward
// | D |
#endif
// clear before the inset
int tx, ty, w, h;
- tx = nx + 1;
+ tx = nx + 1;
ty = baseline - tabular->GetAscentOfRow(i) + 1;
w = int(cx - nx - 1);
- h = tabular->GetAscentOfRow(i) +
+ h = tabular->GetAscentOfRow(i) +
tabular->GetDescentOfRow(i) - 1;
pain.fillRectangle(tx, ty, w, h, backgroundColor());
// clear behind the inset
void InsetTabular::drawCellLines(Painter & pain, int x, int baseline,
- int row, int cell) const
+ int row, int cell) const
{
int x2 = x + tabular->GetWidthOfColumn(cell);
bool on_off;
-
+
if (!tabular->TopAlreadyDrawed(cell)) {
on_off = !tabular->TopLine(cell);
pain.line(x, baseline - tabular->GetAscentOfRow(row),
} else {
ce = tabular->right_column_of_cell(sel_cell_end);
}
-
+
int rs = tabular->row_of_cell(sel_cell_start);
int re = tabular->row_of_cell(sel_cell_end);
if (rs > re)
swap(rs, re);
-
+
if ((column >= cs) && (column <= ce) && (row >= rs) && (row <= re)) {
int w = tabular->GetWidthOfColumn(cell);
int h = tabular->GetAscentOfRow(row) + tabular->GetDescentOfRow(row);
void InsetTabular::edit(BufferView * bv, int x, int y, unsigned int button)
{
UpdatableInset::edit(bv, x, y, button);
-
+
if (!bv->lockInset(this)) {
lyxerr[Debug::INSETTEXT] << "InsetTabular::Cannot lock inset" << endl;
return;
void InsetTabular::edit(BufferView * bv, bool front)
{
UpdatableInset::edit(bv, front);
-
+
if (!bv->lockInset(this)) {
lyxerr[Debug::INSETTEXT] << "InsetTabular::Cannot lock inset" << endl;
return;
void InsetTabular::updateLocal(BufferView * bv, UpdateCodes what,
- bool mark_dirty) const
+ bool mark_dirty) const
{
if (what == INIT) {
LyXFont font;
bool InsetTabular::insetButtonRelease(BufferView * bv,
- int x, int y, int button)
+ int x, int y, int button)
{
bool ret = false;
if (the_locking_inset)
button);
return;
}
-
+
hideInsetCursor(bv);
// int const old_cell = actcell;
-
+
setPos(bv, x, y);
if (!hasSelection()) {
setSelection(actcell, actcell);
UpdatableInset::RESULT
InsetTabular::localDispatch(BufferView * bv, kb_action action,
- string const & arg)
+ string const & arg)
{
- // We need to save the value of the_locking_inset as the call to
+ // We need to save the value of the_locking_inset as the call to
// the_locking_inset->LocalDispatch might unlock it.
old_locking_inset = the_locking_inset;
UpdatableInset::RESULT result =
setSelection(start, actcell);
break;
}
-
+
int end = actcell;
// if we are starting a selection, only select
// the current cell at the beginning
setSelection(start, actcell);
break;
}
-
+
int end = actcell;
// if we are starting a selection, only select
// the current cell at the beginning
- if (hasSelection()) {
+ if (hasSelection()) {
moveLeft(bv, false);
end = actcell;
}
case LFUN_NEXTSEL:
case LFUN_WORDLEFT:
case LFUN_WORDLEFTSEL:
- case LFUN_WORDRIGHT:
+ case LFUN_WORDRIGHT:
case LFUN_WORDRIGHTSEL:
case LFUN_DOWN_PARAGRAPH:
case LFUN_DOWN_PARAGRAPHSEL:
case LFUN_END:
case LFUN_ENDSEL:
case LFUN_BEGINNINGBUF:
- case LFUN_BEGINNINGBUFSEL:
+ case LFUN_BEGINNINGBUFSEL:
case LFUN_ENDBUF:
case LFUN_ENDBUFSEL:
break;
break;
// insert file functions
case LFUN_FILE_INSERT_ASCII_PARA:
- case LFUN_FILE_INSERT_ASCII:
+ case LFUN_FILE_INSERT_ASCII:
{
string tmpstr = getContentsOfAsciiFile(bv, arg, false);
if (tmpstr.empty())
if (!copySelection(bv))
break;
setUndo(bv, Undo::DELETE,
- bv->text->cursor.par(),
- bv->text->cursor.par()->next());
+ bv->text->cursor.par(),
+ bv->text->cursor.par()->next());
cutSelection();
updateLocal(bv, INIT, true);
break;
case LFUN_PASTE:
if (hasPasteBuffer()) {
setUndo(bv, Undo::INSERT,
- bv->text->cursor.par(),
- bv->text->cursor.par()->next());
+ bv->text->cursor.par(),
+ bv->text->cursor.par()->next());
pasteSelection(bv);
updateLocal(bv, INIT, true);
break;
int InsetTabular::latex(Buffer const * buf, ostream & os,
- bool fragile, bool fp) const
+ bool fragile, bool fp) const
{
return tabular->latex(buf, os, fragile, fp);
}
{
if (ll > 0)
return tabular->ascii(buf, os, (int)parOwner()->params().depth(),
- false,0);
+ false,0);
return tabular->ascii(buf, os, 0, false,0);
}
bool InsetTabular::calculate_dimensions_of_cells(BufferView * bv,
- LyXFont const & font,
- bool reinit) const
+ LyXFont const & font,
+ bool reinit) const
{
int cell = -1;
int maxAsc = 0;
int maxDesc = 0;
InsetText * inset;
bool changed = false;
-
+
// if we have a locking_inset we should have to check only this cell for
// change so I'll try this to have a boost, but who knows ;)
if ((need_update != INIT) &&
the_locking_inset->toggleInsetCursor(bv);
return;
}
-
+
LyXFont font; // = the_locking_inset->GetFont(par, cursor.pos);
-
+
int const asc = lyxfont::maxAscent(font);
int const desc = lyxfont::maxDescent(font);
-
+
if (isCursorVisible())
bv->hideLockedInsetCursor();
else
return;
if (!isCursorVisible()) {
LyXFont font; // = GetFont(par, cursor.pos);
-
+
int const asc = lyxfont::maxAscent(font);
int const desc = lyxfont::maxDescent(font);
bv->fitLockedInsetCursor(cursor_.x(), cursor_.y(), asc, desc);
return;
}
LyXFont font;
-
+
int const asc = lyxfont::maxAscent(font);
int const desc = lyxfont::maxDescent(font);
bv->fitLockedInsetCursor(cursor_.x(), cursor_.y(), asc, desc);
void InsetTabular::setPos(BufferView * bv, int x, int y) const
{
cursor_.y(0);
-
+
actcell = actrow = actcol = 0;
int ly = tabular->GetDescentOfRow(actrow);
int InsetTabular::getCellXPos(int cell) const
{
int c = cell;
-
+
for (; !tabular->IsFirstCellInRow(c); --c)
;
int lx = tabular->GetWidthOfColumn(cell);
void InsetTabular::setFont(BufferView * bv, LyXFont const & font, bool tall,
- bool selectall)
+ bool selectall)
{
if (selectall) {
setSelection(0, tabular->GetNumberOfCells() - 1);
}
if (hasSelection()) {
setUndo(bv, Undo::EDIT,
- bv->text->cursor.par(),
- bv->text->cursor.par()->next());
+ bv->text->cursor.par(),
+ bv->text->cursor.par()->next());
bool frozen = undo_frozen;
if (!frozen)
freezeUndo();
bool InsetTabular::tabularFeatures(BufferView * bv, string const & what)
{
LyXTabular::Feature action = LyXTabular::LAST_ACTION;
-
+
int i = 0;
for (; tabularFeature[i].action != LyXTabular::LAST_ACTION; ++i) {
string const tmp = tabularFeature[i].feature;
-
+
if (tmp == what.substr(0, tmp.length())) {
//if (!compare(tabularFeatures[i].feature.c_str(), what.c_str(),
//tabularFeatures[i].feature.length())) {
}
static void checkLongtableSpecial(LyXTabular::ltType & ltt,
- string const & special, bool & flag)
+ string const & special, bool & flag)
{
if (special == "dl_above") {
ltt.topDL = flag;
void InsetTabular::tabularFeatures(BufferView * bv,
- LyXTabular::Feature feature,
- string const & value)
+ LyXTabular::Feature feature,
+ string const & value)
{
int sel_col_start;
int sel_col_end;
sel_row_start = sel_row_end = tabular->row_of_cell(actcell);
}
setUndo(bv, Undo::FINISH,
- bv->text->cursor.par(),
- bv->text->cursor.par()->next());
+ bv->text->cursor.par(),
+ bv->text->cursor.par()->next());
int row = tabular->row_of_cell(actcell);
int column = tabular->column_of_cell(actcell);
bool flag = true;
LyXTabular::ltType ltt;
-
+
switch (feature) {
case LyXTabular::SET_PWIDTH:
{
LyXLength const vallen(value);
LyXLength const & tmplen = tabular->GetColumnPWidth(actcell);
-
+
bool const update = (tmplen != vallen);
tabular->SetColumnPWidth(actcell, vallen);
if (update) {
{
LyXLength const vallen(value);
LyXLength const & tmplen = tabular->GetPWidth(actcell);
-
+
bool const update = (tmplen != vallen);
tabular->SetMColumnPWidth(actcell, vallen);
if (update) {
updateLocal(bv, INIT, true);
break;
}
-
+
case LyXTabular::M_TOGGLE_LINE_BOTTOM:
flag = false;
case LyXTabular::TOGGLE_LINE_BOTTOM:
{
- bool lineSet = !tabular->BottomLine(actcell, flag);
+ bool lineSet = !tabular->BottomLine(actcell, flag);
for (int i = sel_row_start; i <= sel_row_end; ++i)
for (int j = sel_col_start; j <= sel_col_end; ++j)
tabular->SetBottomLine(
updateLocal(bv, INIT, true);
break;
}
-
+
case LyXTabular::M_TOGGLE_LINE_LEFT:
flag = false;
case LyXTabular::TOGGLE_LINE_LEFT:
updateLocal(bv, INIT, true);
break;
}
-
+
case LyXTabular::M_TOGGLE_LINE_RIGHT:
flag = false;
case LyXTabular::TOGGLE_LINE_RIGHT:
updateLocal(bv, INIT, true);
break;
}
-
+
case LyXTabular::M_ALIGN_LEFT:
case LyXTabular::M_ALIGN_RIGHT:
case LyXTabular::M_ALIGN_CENTER:
case LyXTabular::MULTICOLUMN:
{
if (sel_row_start != sel_row_end) {
- Alert::alert(_("Impossible Operation!"),
- _("Multicolumns can only be horizontally."),
+ Alert::alert(_("Impossible Operation!"),
+ _("Multicolumns can only be horizontally."),
_("Sorry."));
return;
}
int InsetTabular::getMaxWidthOfCell(BufferView * bv, int cell) const
{
LyXLength const len = tabular->GetPWidth(cell);
-
+
if (len.zero())
return -1;
return len.inPixels(latexTextWidth(bv), bv->text->defaultHeight());
int InsetTabular::getMaxWidth(BufferView * bv,
- UpdatableInset const * inset) const
+ UpdatableInset const * inset) const
{
int cell = tabular->GetCellFromInset(inset, actcell);
<< endl;
return -1;
}
-
+
int w = getMaxWidthOfCell(bv, cell);
if (w > 0) {
// because the inset then subtracts it's top_x and owner->x()
w += (inset->x() - top_x);
}
-
+
return w;
}
LyXText * InsetTabular::getLyXText(BufferView const * bv,
- bool const recursive) const
+ bool const recursive) const
{
if (the_locking_inset)
return the_locking_inset->getLyXText(bv, recursive);
{
int action = LyXTabular::LAST_ACTION;
FuncStatus status;
-
+
int i = 0;
for (; tabularFeature[i].action != LyXTabular::LAST_ACTION; ++i) {
string const tmp = tabularFeature[i].feature;
- if (tmp == what.substr(0, tmp.length())) {
+ if (tmp == what.substr(0, tmp.length())) {
//if (!compare(tabularFeatures[i].feature.c_str(), what.c_str(),
// tabularFeatures[i].feature.length())) {
action = tabularFeature[i].action;
status.clear();
return status.unknown(true);
}
-
+
string const argument = frontStrip(what.substr(tabularFeature[i].feature.length()));
int sel_row_start;
ostringstream sstr;
paste_tabular->ascii(bv->buffer(), sstr,
- (int)parOwner()->params().depth(), true, '\t');
+ (int)parOwner()->params().depth(), true, '\t');
bv->stuffClipboard(sstr.str().c_str());
return true;
}
{
int const start = hasSelection() ? sel_cell_start : actcell;
int const end = hasSelection() ? sel_cell_end : actcell;
-
+
srow = tabular->row_of_cell(start);
erow = tabular->row_of_cell(end);
if (srow > erow) {
bv->unlockInset(const_cast<InsetTabular *>(this));
return string();
}
-
+
// otherwise we have to lock the next inset and ask for it's selecttion
UpdatableInset * inset =
static_cast<UpdatableInset*>(tabular->GetCellInset(++actcell));
bool InsetTabular::searchForward(BufferView * bv, string const & str,
- bool cs, bool mw)
+ bool cs, bool mw)
{
nodraw(true);
if (the_locking_inset) {
bool InsetTabular::searchBackward(BufferView * bv, string const & str,
- bool cs, bool mw)
+ bool cs, bool mw)
{
nodraw(true);
if (the_locking_inset) {
}
bool InsetTabular::insertAsciiString(BufferView * bv, string const & buf,
- bool usePaste)
+ bool usePaste)
{
if (buf.find('\t') == string::npos)
return false;
-
+
int cols = 1;
int rows = 1;
int maxCols = 1;
if (usePaste) {
delete paste_tabular;
paste_tabular = new LyXTabular(bv->buffer()->params,
- this, rows, maxCols);
+ this, rows, maxCols);
loctab = paste_tabular;
cols = 0;
} else {
// check for the last cell if there is no trailing '\n'
if ((cell < cells) && (op < len))
loctab->GetCellInset(cell)->setText(buf.substr(op, len-op));
-
+
return true;
}
// -*- C++ -*-
/* This file is part of
* ======================================================
- *
+ *
* LyX, The Document Processor
*
* Copyright 1995-2001 The LyX Team.
int getActCell() const { return actcell; }
///
void setFont(BufferView *, LyXFont const &, bool toggleall = false,
- bool selectall = false);
+ bool selectall = false);
///
int getMaxWidth(BufferView *, UpdatableInset const *) const;
///
void toggleSelection(BufferView *, bool kill_selection);
///
bool searchForward(BufferView *, string const &,
- bool = true, bool = false);
+ bool = true, bool = false);
bool searchBackward(BufferView *, string const &,
- bool = true, bool = false);
+ bool = true, bool = false);
// this should return true if we have a "normal" cell, otherwise true.
// "normal" means without width set!
bool forceDefaultParagraphs(Inset const * in) const;
-
+
//
// Public structures and variables
///
string selectNextWordInt(BufferView *, float & value) const;
///
bool insertAsciiString(BufferView *, string const & buf, bool usePaste);
-
+
//
// Private structures and variables
///
/* This file is part of
* ======================================================
- *
+ *
* LyX, The Document Processor
*
* Copyright 1998-2001 The LyX Team.
break;
p = p->next();
}
-
+
if (p && t->cursor.pos() <= p->size()) {
sstate.lpar = t->cursor.par();
sstate.pos = t->cursor.pos();
t->selection.mark(sstate.mark_set);
if (sstate.selection) {
t->setCursor(bv, sstate.selstartpar, sstate.selstartpos,
- true, sstate.selstartboundary);
+ true, sstate.selstartboundary);
t->selection.cursor = t->cursor;
t->setCursor(bv, sstate.selendpar, sstate.selendpos,
- true, sstate.selendboundary);
+ true, sstate.selendboundary);
t->setSelection(bv);
t->setCursor(bv, sstate.lpar, sstate.pos);
} else {
{
par = new Paragraph;
par->layout(textclasslist[bp.textclass].defaultLayoutName());
-
+
init();
}
cached_bview = 0;
// NOTE
-
+
while (par) {
Paragraph * tmp = par->next();
delete par;
{
// This is a gross hack...
string old_layout = par->layout();
-
+
while (par) {
Paragraph * tmp = par->next();
delete par;
par = new Paragraph;
par->setInsetOwner(this);
par->layout(old_layout);
-
+
reinitLyXText();
need_update = INIT;
}
string token;
int pos = 0;
Paragraph * return_par = 0;
- Paragraph::depth_type depth = 0;
+ Paragraph::depth_type depth = 0;
LyXFont font(LyXFont::ALL_INHERIT);
clear();
-
+
while (lex.isOK()) {
lex.nextToken();
token = lex.getString();
#endif
break;
}
-
+
if (const_cast<Buffer*>(buf)->
parseSingleLyXformat2Token(lex, par, return_par,
token, pos, depth, font)) {
return_par->setInsetOwner(this);
return_par = return_par->next();
}
-
+
if (token != "\\end_inset") {
lex.printError("Missing \\end_inset at this point. "
"Read: `$$Token'");
}
if (fordraw) {
return max(w - (2 * TEXT_TO_INSET_OFFSET),
- (int)getLyXText(bv)->width);
+ (int)getLyXText(bv)->width);
} else if (w < 0) {
return -1;
}
void InsetText::draw(BufferView * bv, LyXFont const & f,
- int baseline, float & x, bool cleared) const
+ int baseline, float & x, bool cleared) const
{
if (nodraw())
return;
Painter & pain = bv->painter();
-
+
// this is the first thing we have to ask because if the x pos
// changed we have to do a complete rebreak of the text as we
// may have few space to draw in. Well we should check on this too
}
// call these methods so that insetWidth, insetAscent and
- // insetDescent have the right values.
+ // insetDescent have the right values.
width(bv, f);
ascent(bv, f);
descent(bv, f);
top_y = baseline - insetAscent;
if (last_drawn_width != insetWidth) {
- if (!cleared)
+ if (!cleared)
clearInset(bv, baseline, cleared);
need_update |= FULL;
last_drawn_width = insetWidth;
if (!cleared && (need_update == CURSOR)
&& !getLyXText(bv)->selection.set()) {
drawFrame(pain, cleared);
- x += insetWidth;
+ x += insetWidth;
need_update = NONE;
return;
}
y = 0;
while ((row != 0) && (yf < ph)) {
lt->getVisibleRow(bv, y+y_offset, int(x), row,
- y+first, cleared);
+ y+first, cleared);
y += row->height();
yf += row->height();
row = row->next();
} else if (need_update & CLEAR_FRAME) {
clearFrame(pain, cleared);
}
-
+
x += insetWidth - TEXT_TO_INSET_OFFSET;
-
+
if (bv->text->status() == LyXText::CHANGED_IN_DRAW) {
need_update |= FULL;
} else if (need_update != INIT) {
frame_w = insetWidth - TEXT_TO_INSET_OFFSET;
frame_h = insetAscent + insetDescent - TEXT_TO_INSET_OFFSET;
pain.rectangle(frame_x, frame_y, frame_w, frame_h,
- frame_color);
+ frame_color);
frame_is_visible = true;
}
}
if (frame_is_visible) {
if (!cleared) {
pain.rectangle(frame_x, frame_y, frame_w, frame_h,
- backgroundColor());
+ backgroundColor());
}
frame_is_visible = false;
}
{
// this does nothing dangerous so use only a localized buffer
LyXText * llt = getLyXText(bv);
-
+
need_update |= what;
// we have to redraw us full if our LyXText NEEDS_MORE_REFRES or
// if we don't break row so that we only have one row to update!
lt->fullRebreak(bv);
setUpdateStatus(bv, what);
bool flag = (((need_update != CURSOR) && (need_update != NONE)) ||
- (lt->status() != LyXText::UNCHANGED) || lt->selection.set());
+ (lt->status() != LyXText::UNCHANGED) || lt->selection.set());
if (!lt->selection.set())
lt->selection.cursor = lt->cursor;
if (clear)
bv->updateInset(const_cast<InsetText *>(this), mark_dirty);
else
bv->fitCursor();
-
+
if (need_update == CURSOR)
need_update = NONE;
bv->owner()->showState();
void InsetText::edit(BufferView * bv, int x, int y, unsigned int button)
{
UpdatableInset::edit(bv, x, y, button);
-
+
if (!bv->lockInset(this)) {
lyxerr[Debug::INSETS] << "Cannot lock inset" << endl;
return;
}
if (!checkAndActivateInset(bv, x, tmp_y, button))
lt->setCursorFromCoordinates(bv, x - drawTextXOffset,
- y + insetAscent);
+ y + insetAscent);
lt->clearSelection();
finishUndo();
// If the inset is empty set the language of the current font to the
// showInsetCursor(bv);
if (clear)
lt = 0;
-
+
int code = CURSOR;
if (drawFrame_ == LOCKED)
code = CURSOR|DRAW_FRAME;
void InsetText::edit(BufferView * bv, bool front)
{
UpdatableInset::edit(bv, front);
-
+
if (!bv->lockInset(this)) {
lyxerr[Debug::INSETS] << "Cannot lock inset" << endl;
return;
int code;
if (drawFrame_ == LOCKED)
code = CURSOR|CLEAR_FRAME;
- else
+ else
code = CURSOR;
bool clear = false;
if (!lt) {
code = FULL;
} else if (owner()) {
bv->owner()->setLayout(owner()->getLyXText(bv)
- ->cursor.par()->layout());
+ ->cursor.par()->layout());
} else
bv->owner()->setLayout(bv->text->cursor.par()->layout());
// hack for deleteEmptyParMech
bool InsetText::unlockInsetInInset(BufferView * bv, UpdatableInset * inset,
- bool lr)
+ bool lr)
{
if (!the_locking_inset)
return false;
if (the_locking_inset) {
if (the_locking_inset == inset) {
the_locking_inset->insetButtonPress(bv,
- x - inset_x,
- y - inset_y,
- button);
+ x - inset_x,
+ y - inset_y,
+ button);
no_selection = false;
return;
} else if (inset) {
inset_y = cy(bv) + drawTextYOffset;
the_locking_inset = 0;
inset->insetButtonPress(bv, x - inset_x,
- y - inset_y, button);
+ y - inset_y, button);
// inset->edit(bv, x - inset_x, y - inset_y, button);
if (the_locking_inset)
updateLocal(bv, CURSOR, false);
inset_boundary = cboundary(bv);
the_locking_inset = uinset;
uinset->insetButtonPress(bv, x - inset_x, y - inset_y,
- button);
+ button);
uinset->edit(bv, x - inset_x, y - inset_y, 0);
if (the_locking_inset)
updateLocal(bv, CURSOR, false);
}
lt->setCursorFromCoordinates(bv, x - drawTextXOffset,
- y + insetAscent);
+ y + insetAscent);
// set the selection cursor!
lt->selection.cursor = lt->cursor;
lt->cursor.x_fix(lt->cursor.x());
localDispatch(bv, LFUN_PASTE, "");
else
localDispatch(bv, LFUN_PASTESELECTION,
- "paragraph");
+ "paragraph");
}
} else {
getLyXText(bv)->clearSelection();
{
if (the_locking_inset) {
return the_locking_inset->insetButtonRelease(bv,
- x - inset_x, y - inset_y,
- button);
+ x - inset_x, y - inset_y,
+ button);
}
int tmp_x = x - drawTextXOffset;
int tmp_y = y + insetAscent - getLyXText(bv)->first_y;
if (inset) {
if (isHighlyEditableInset(inset)) {
ret = inset->insetButtonRelease(bv, x - inset_x,
- y - inset_y, button);
+ y - inset_y, button);
} else {
inset_x = cx(bv) - top_x + drawTextXOffset;
inset_y = cy(bv) + drawTextYOffset;
ret = inset->insetButtonRelease(bv, x - inset_x,
- y - inset_y, button);
+ y - inset_y, button);
inset->edit(bv, x - inset_x,
- y - inset_y, button);
+ y - inset_y, button);
}
updateLocal(bv, CURSOR_PAR, false);
}
return;
if (the_locking_inset) {
the_locking_inset->insetMotionNotify(bv, x - inset_x,
- y - inset_y,state);
+ y - inset_y,state);
return;
}
bool clear = false;
UpdatableInset::RESULT
InsetText::localDispatch(BufferView * bv,
- kb_action action, string const & arg)
+ kb_action action, string const & arg)
{
bool was_empty = par->size() == 0 && !par->next();
no_selection = false;
* true (on). */
setUndo(bv, Undo::INSERT,
- lt->cursor.par(), lt->cursor.par()->next());
+ lt->cursor.par(), lt->cursor.par()->next());
bv->setState();
if (lyxrc.auto_region_delete) {
if (lt->selection.set()) {
break;
case LFUN_BACKSPACE: {
setUndo(bv, Undo::DELETE,
- lt->cursor.par(), lt->cursor.par()->next());
+ lt->cursor.par(), lt->cursor.par()->next());
if (lt->selection.set())
lt->cutSelection(bv);
else
updflag = true;
}
break;
-
+
case LFUN_DELETE: {
setUndo(bv, Undo::DELETE,
- lt->cursor.par(), lt->cursor.par()->next());
+ lt->cursor.par(), lt->cursor.par()->next());
if (lt->selection.set()) {
lt->cutSelection(bv);
} else {
updflag = true;
}
break;
-
+
case LFUN_CUT: {
setUndo(bv, Undo::DELETE,
- lt->cursor.par(), lt->cursor.par()->next());
+ lt->cursor.par(), lt->cursor.par()->next());
lt->cutSelection(bv);
updwhat = CURSOR_PAR;
updflag = true;
case LFUN_PASTESELECTION:
{
string const clip(bv->getClipboard());
-
+
if (clip.empty())
break;
if (arg == "paragraph") {
}
}
setUndo(bv, Undo::INSERT,
- lt->cursor.par(), lt->cursor.par()->next());
+ lt->cursor.par(), lt->cursor.par()->next());
lt->pasteSelection(bv);
updwhat = CURSOR_PAR;
updflag = true;
break;
}
setUndo(bv, Undo::INSERT,
- lt->cursor.par(), lt->cursor.par()->next());
+ lt->cursor.par(), lt->cursor.par()->next());
lt->insertChar(bv, Paragraph::META_NEWLINE);
updwhat = CURSOR_PAR;
updflag = true;
// do not set layouts on non breakable textinsets
if (autoBreakRows) {
string cur_layout = cpar(bv)->layout();
-
+
// Derive layout number from given argument (string)
- // and current buffer's textclass (number). */
+ // and current buffer's textclass (number). */
textclass_type tclass = bv->buffer()->params.textclass;
string layout = arg;
bool hasLayout = textclasslist[tclass].hasLayout(layout);
string const & obs =
textclasslist[tclass][layout].
obsoleted_by();
- if (!obs.empty())
+ if (!obs.empty())
layout = obs;
}
if (cur_spacing == Spacing::Other) {
cur_value = par->params().spacing().getValue();
}
-
+
istringstream istr(arg.c_str());
string tmp;
istr >> tmp;
}
}
break;
-
+
default:
if (!bv->Dispatch(action, arg))
result = UNDISPATCHED;
{
Paragraph * p = par;
unsigned int lines = 0;
-
+
while (p) {
string const tmp = buf->asciiParagraph(p, linelen, p->previous()==0);
lines += lyx::count(tmp.begin(), tmp.end(), '\n');
vector<string> environment_stack(10);
vector<string> environment_inner(10);
-
+
int const command_depth = 0;
string item_name;
-
+
Paragraph::depth_type depth = 0; // paragraph depth
while (p) {
depth + command_depth,
environment_inner[depth]);
}
-
+
buf->sgmlCloseTag(os, depth + command_depth,
environment_stack[depth]);
-
+
environment_stack[depth].erase();
environment_inner[depth].erase();
- }
+ }
// Write opening SGML tags.
switch (style.latextype) {
environment_inner[depth]);
}
}
-
+
if (style.latextype == LATEX_ENVIRONMENT) {
if (!style.latexparam().empty()) {
if (style.latexparam() == "CDATA")
item_name = "listitem";
buf->sgmlCloseTag(os, command_depth + depth,
item_name);
- if (environment_inner[depth] == "varlistentry")
+ if (environment_inner[depth] == "varlistentry")
buf->sgmlCloseTag(os, depth + command_depth,
environment_inner[depth]);
}
-
+
buf->sgmlCloseTag(os, depth + command_depth,
environment_stack[depth]);
}
}
-
+
return lines;
}
int const asc = lyxfont::maxAscent(font);
int const desc = lyxfont::maxDescent(font);
-
+
if (isCursorVisible())
bv->hideLockedInsetCursor();
else
if (!isCursorVisible()) {
LyXFont const font =
getLyXText(bv)->getFont(bv->buffer(), cpar(bv), cpos(bv));
-
+
int const asc = lyxfont::maxAscent(font);
int const desc = lyxfont::maxDescent(font);
}
LyXFont const font =
getLyXText(bv)->getFont(bv->buffer(), cpar(bv), cpos(bv));
-
+
int const asc = lyxfont::maxAscent(font);
int const desc = lyxfont::maxDescent(font);
UpdatableInset::RESULT
-InsetText::moveRightIntern(BufferView * bv, bool behind,
- bool activate_inset, bool selecting)
+InsetText::moveRightIntern(BufferView * bv, bool behind,
+ bool activate_inset, bool selecting)
{
if (!cpar(bv)->next() && (cpos(bv) >= cpar(bv)->size()))
return FINISHED_RIGHT;
UpdatableInset::RESULT
InsetText::moveLeftIntern(BufferView * bv, bool behind,
- bool activate_inset, bool selecting)
+ bool activate_inset, bool selecting)
{
if (!cpar(bv)->previous() && (cpos(bv) <= 0))
return FINISHED;
}
-vector<string> const InsetText::getLabelList() const
+vector<string> const InsetText::getLabelList() const
{
vector<string> label_list;
void InsetText::setFont(BufferView * bv, LyXFont const & font, bool toggleall,
- bool selectall)
+ bool selectall)
{
if (the_locking_inset) {
the_locking_inset->setFont(bv, font, toggleall, selectall);
int x = llt->cursor.x() + top_x + TEXT_TO_INSET_OFFSET;
if (the_locking_inset) {
LyXFont font = llt->getFont(bv->buffer(), llt->cursor.par(),
- llt->cursor.pos());
+ llt->cursor.pos());
if (font.isVisibleRightToLeft())
x -= the_locking_inset->width(bv, font);
}
LyXText * InsetText::getLyXText(BufferView const * lbv,
- bool const recursive) const
+ bool const recursive) const
{
if (cached_bview == lbv) {
if (recursive && the_locking_inset)
}
// Super UGLY! (Lgb)
BufferView * bv = const_cast<BufferView *>(lbv);
-
+
cached_bview = bv;
Cache::iterator it = cache.find(bv);
restoreLyXTextState(bv, cached_text.get());
cache.insert(make_pair(bv, cached_text));
-
+
if (the_locking_inset && recursive) {
return the_locking_inset->getLyXText(bv);
}
cached_bview = 0;
Cache::iterator it = cache.find(bv);
-
+
if (it == cache.end()) {
return;
}
}
if (!owner()) {
updateLocal(bv, FULL, false);
- // this will scroll the screen such that the cursor becomes visible
+ // this will scroll the screen such that the cursor becomes visible
bv->updateScrollbar();
} else {
need_update |= FULL;
}
if (!owner()) {
updateLocal(bv, FULL, false);
- // this will scroll the screen such that the cursor becomes visible
+ // this will scroll the screen such that the cursor becomes visible
bv->updateScrollbar();
} else {
need_update = FULL;
void InsetText::removeNewlines()
{
bool changed = false;
-
+
for (Paragraph * p = par; p; p = p->next()) {
for (int i = 0; i < p->size(); ++i) {
if (p->getChar(i) == Paragraph::META_NEWLINE) {
int w = insetWidth;
int h = insetAscent + insetDescent;
int ty = baseline - insetAscent;
-
+
if (ty < 0) {
h += ty;
ty = 0;
}
if (y_offset < 0)
y_offset = y;
-
+
if (need_update & SELECTION)
need_update = NONE;
bv->screen()->toggleSelection(lt, bv, kill_selection, y_offset, x);
bool InsetText::searchForward(BufferView * bv, string const & str,
- bool cs, bool mw)
+ bool cs, bool mw)
{
if (the_locking_inset) {
if (the_locking_inset->searchForward(bv, str, cs, mw))
}
bool InsetText::searchBackward(BufferView * bv, string const & str,
- bool cs, bool mw)
+ bool cs, bool mw)
{
if (the_locking_inset)
if (the_locking_inset->searchBackward(bv, str, cs, mw))
void InsetText::appendParagraphs(BufferParams const & bparams,
- Paragraph * newpar)
+ Paragraph * newpar)
{
Paragraph * buf;
Paragraph * tmpbuf = newpar;
Paragraph * lastbuffer = buf = new Paragraph(*tmpbuf, false);
-
+
while (tmpbuf->next()) {
tmpbuf = tmpbuf->next();
lastbuffer->next(new Paragraph(*tmpbuf, false));
{
lastbuffer->insertChar(lastbuffer->size(), ' ');
}
-
+
// make the buf exactly the same layout than our last paragraph
buf->makeSameLayout(lastbuffer);
// -*- C++ -*-
/* This file is part of
* ======================================================
- *
+ *
* LyX, The Document Processor
*
* Copyright 1998 The LyX Team.
/**
A text inset is like a TeX box to write full text
- (including styles and other insets) in a given space.
+ (including styles and other insets) in a given space.
@author: Jürgen Vigna
*/
class InsetText : public UpdatableInset {
///
void setFont(BufferView *, LyXFont const &,
bool toggleall = false,
- bool selectall = false);
+ bool selectall = false);
///
int getMaxWidth(BufferView *, UpdatableInset const *) const;
///
void toggleSelection(BufferView *, bool kill_selection);
///
bool searchForward(BufferView *, string const &,
- bool = true, bool = false);
+ bool = true, bool = false);
///
bool searchBackward(BufferView *, string const &,
- bool = true, bool = false);
+ bool = true, bool = false);
///
bool checkInsertChar(LyXFont &);
///
bool activate_inset = true,
bool selecting = false);
///
- UpdatableInset::RESULT moveLeftIntern(BufferView *, bool behind,
+ UpdatableInset::RESULT moveLeftIntern(BufferView *, bool behind,
bool activate_inset = true,
bool selecting = false);
bool checkAndActivateInset(BufferView * bv, bool behind);
///
bool checkAndActivateInset(BufferView * bv, int x = 0, int y = 0,
- int button = 0);
+ int button = 0);
///
void removeNewlines();
///
void reinitLyXText() const;
///
void collapseParagraphs(BufferParams const & bparams) const;
-
+
/* Private structures and variables */
///
Paragraph * par;
};
///
mutable save_state sstate;
-
+
///
// this is needed globally so we know that we're using it actually and
// so the LyXText-Cache is not erased until used!
/* This file is part of
* ======================================================
- *
+ *
* LyX, The Document Processor
- *
+ *
* Copyright 1998 The LyX Team.
*
* ======================================================
}
-void InsetTheorem::write(Buffer const * buf, ostream & os) const
+void InsetTheorem::write(Buffer const * buf, ostream & os) const
{
os << getInsetName() << "\n";
InsetCollapsable::write(buf, os);
#warning Is this inset used? If YES this is WRONG!!! (Jug)
#endif
InsetTheorem * result = new InsetTheorem;
-
+
result->collapsed_ = collapsed_;
return result;
}
ostream & os, bool fragile, bool fp) const
{
os << "\\begin{theorem}%\n";
-
+
int i = inset.latex(buf, os, fragile, fp);
os << "\\end{theorem}%\n";
-
+
return i + 2;
}
// -*- C++ -*-
/* This file is part of
* ======================================================
- *
+ *
* LyX, The Document Processor
*
* Copyright 1998 The LyX Team.
#include "insetcollapsable.h"
/** The theorem inset
-
+
*/
class InsetTheorem : public InsetCollapsable {
public:
using std::ostream;
-string const InsetTOC::getScreenLabel(Buffer const *) const
+string const InsetTOC::getScreenLabel(Buffer const *) const
{
string const cmdname(getCmdName());
-
+
if (cmdname == "tableofcontents")
return _("Table of Contents");
return _("Unknown toc list");
* ======================================================
*
* LyX, The Document Word Processor
- *
+ *
* Copyright 1995 Matthias Ettrich
* Copyright 1996-2001 The LyX Team.
- *
+ *
* ====================================================== */
#ifndef INSET_TOC_H
string temp;
if (getCmdName() == "url")
temp = _("Url: ");
- else
+ else
temp = _("HtmlUrl: ");
if (!getOptions().empty())
// -*- C++ -*-
/* This file is part of*
- * ======================================================
+ * ======================================================
*
* LyX, The Document Processor
- *
+ *
* Copyright 1997-2001 The LyX Team.
- *
+ *
* ====================================================== */
#ifndef INSET_URL_H
struct LaTeXFeatures;
-/** The url inset
+/** The url inset
*/
class InsetUrl : public InsetCommand {
public:
bool display() const { return false; }
///
int latex(Buffer const *, std::ostream &,
- bool fragile, bool free_spc) const;
+ bool fragile, bool free_spc) const;
///
int ascii(Buffer const *, std::ostream &, int linelen) const;
///
2002-03-21 Lars Gullik Bjønnes <larsbj@birdstep.com>
+ * most files: ws cleanup
+
* Makefile.am: remove ld -r stuff
2002-03-20 Lars Gullik Bjønnes <larsbj@birdstep.com>
///
virtual int sync() { return 0; }
#endif
- ///
+ ///
virtual streamsize xsputn(char_type const *, streamsize n) {
// fakes a purge of the buffer by returning n
return n;
: ostream(new debugbuf(cerr.rdbuf())),
dt(t), nullstream(new nullbuf), internal(0) {}
-
+
/// Constructor, sets the log file to f, and the debug level to t.
DebugStream::DebugStream(char const * f, Debug::type t)
: ostream(new debugbuf(cerr.rdbuf())),
{
/**
I have been running some tests on this to see how much overhead
- this kind of permanent debug code has. My conclusion is: not
- much. In all, but the most time critical code, this will have
+ this kind of permanent debug code has. My conclusion is: not
+ much. In all, but the most time critical code, this will have
close to no impact at all.
-
+
In the tests that I have run the use of
if (debugstream.debugging(DebugStream::INFO))
debugstream << "some debug\n";
- has close to no overhead when the debug level is not
+ has close to no overhead when the debug level is not
DebugStream::INFO.
-
+
The overhead for
debugstream.debug(DebugStream::INFO) << "some debug\n";
is also very small when the debug level is not
DebugStream::INFO. However the overhead for this will increase
if complex debugging information is output.
-
+
The overhead when the debug level is DebugStream::INFO can be
- significant, but since we then are running in debug mode it is
+ significant, but since we then are running in debug mode it is
of no concern.
-
+
Why should we use this instead of the class Error that we already
have? First of all it uses C++ iostream and constructs, secondly
it will be a lot easier to output the debug info that we need
- without a lot of manual conversions, thirdly we can now use
+ without a lot of manual conversions, thirdly we can now use
iomanipulators and the complete iostream formatting functions.
- pluss it will work for all types that have a operator<<
+ pluss it will work for all types that have a operator<<
defined, and can be used in functors that take a ostream & as
parameter. And there should be less need for temporary objects.
And one nice bonus is that we get a log file almost for
free.
-
+
Some of the names are of course open to modifications. I will try
to use the names we already use in LyX.
*/
debugstream.debug(Debug::WARN) << "more debug(WARN)\n";
debugstream.debug(Debug::INFO) << "even more debug(INFO)\n";
debugstream.debug(Debug::CRIT) << "even more debug(CRIT)\n";
- debugstream.addLevel(Debug::type(Debug::CRIT |
+ debugstream.addLevel(Debug::type(Debug::CRIT |
Debug::WARN));
debugstream << "Adding Debug::CRIT and Debug::WARN\n";
debugstream[Debug::WARN] << "more debug(WARN)\n";
// note: the (void*) is needed on g++ 2.7.x since it does not
// support partial specialization. In egcs this should not be
// needed.
- debugstream << "automatic " << &i
+ debugstream << "automatic " << &i
<< ", free store " << p << endl;
delete p;
/*
INFO
Always
- If you want to have debug output from time critical code you should
+ If you want to have debug output from time critical code you should
use this construct:
if (debug.debugging(Debug::INFO)) {
- debug << "...debug output...\n";
+ debug << "...debug output...\n";
}
-
+
To give debug info even if no debug (NONE) is requested:
debug << "... always output ...\n";
public:
/// Constructor, sets the debug level to t.
explicit DebugStream(Debug::type t = Debug::NONE);
-
+
/// Constructor, sets the log file to f, and the debug level to t.
explicit
DebugStream(char const * f, Debug::type t = Debug::NONE);
/// Sets the debugstreams' logfile to f.
void logFile(char const * f);
-
+
/// Returns true if t is part of the current debug level.
bool debugging(Debug::type t = Debug::ANY) const
{
return false;
}
-
+
/** Returns the no-op stream if t is not part of the
current debug level otherwise the real debug stream
is used.
return nullstream;
}
-
+
/** This is an operator to give a more convenient use:
dbgstream[Debug::INFO] << "Info!\n";
*/
};
#endif
-
-
/* This file is part of
* ======================================================
- *
+ *
* LyX, The Document Processor
- *
+ *
* Copyright 1995 Matthias Ettrich
* Copyright 1995-2001 The LyX Team.
*
#undef S_ISNWK
#undef S_ISREG
#undef S_ISSOCK
-#endif
+#endif
#if !defined(S_ISBLK) && defined(S_IFBLK)
#define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
#define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK)
#endif
-// Since major is a function on SVR4, we can't use `ifndef major'.
+// Since major is a function on SVR4, we can't use `ifndef major'.
// might want to put MAJOR_IN_MKDEV for SYSV
#ifdef MAJOR_IN_MKDEV
#include <sys/mkdev.h>
#include <sys/sysmacros.h>
#define HAVE_MAJOR
#endif
-#ifdef major
+#ifdef major
#define HAVE_MAJOR
#endif
FileInfo & FileInfo::newFile(string const & path, bool link)
{
fname = path;
-
+
status = 0;
err = NoErr;
char const * FileInfo::typeIndicator() const
{
lyx::Assert(isOK());
-
+
if (S_ISDIR(buf.st_mode)) return ("/");
#ifdef S_ISLNK
if (S_ISLNK(buf.st_mode)) return ("@");
mode_t FileInfo::getMode() const
{
lyx::Assert(isOK());
-
+
return buf.st_mode;
}
char FileInfo::typeLetter() const
{
lyx::Assert(isOK());
-
+
#ifdef S_ISBLK
if (S_ISBLK(buf.st_mode)) return 'b';
#endif
void FileInfo::setSticky(char * szString) const
{
lyx::Assert(isOK());
-
+
#ifdef S_ISUID
if (buf.st_mode & S_ISUID) {
if (szString[3] != 'x') szString[3] = 'S';
{
// if we don't have a filename we fail
if (fname.empty()) return false;
-
+
if (::access(fname.c_str(), p) == 0)
return true;
else {
// -*- C++ -*-
/* This file is part of
* ======================================================
- *
+ *
* LyX, The Document Processor
- *
+ *
* Copyright 1995 Matthias Ettrich
* Copyright 1995-2001 The LyX Team.
*
public:
///
FileInfo();
-
+
/** Get information about file.
If link is true, the information is about the link itself, not
the file that is obtained by tracing the links. */
/// Query a new file
FileInfo & newFile(string const & path, bool link = false);
-
+
/// Query a new file descriptor
- FileInfo & newFile(int fildes);
-
+ FileInfo & newFile(int fildes);
+
/// Returns a character describing file type (ls -F)
char const * typeIndicator() const;
-
+
/// File protection mode
mode_t getMode() const;
/// Constructs standard mode string (ls style)
void modeString(char * szString) const;
-
+
/// returns a letter describing a file type (ls style)
char typeLetter() const;
-
+
/// builds 'rwx' string describing file access rights
void flagRWX(mode_t i, char * szString) const;
-
+
/// updates mode string to match suid/sgid/sticky bits
void setSticky(char * szString) const;
-
+
///
time_t getModificationTime() const;
-
+
///
time_t getAccessTime() const;
-
+
///
time_t getStatusChangeTime() const;
-
+
/// Total file size in bytes
off_t getSize() const;
-
+
/// Number of hard links
nlink_t getNumberOfLinks() const;
-
+
/// User ID of owner
uid_t getUid() const;
-
+
/// Group ID of owner
gid_t getGid() const;
-
+
/// Is the file information correct? Did the query succeed?
bool isOK() const;
-
+
/// Permission flags
enum perm_test {
/// test for read permission
/* This file is part of
* ======================================================
- *
+ *
* LyX, The Document Processor
- *
+ *
* Copyright 1995 Matthias Ettrich
* Copyright 1995-2001 The LyX Team.
*
// -*- C++ -*-
/* This file is part of
* ======================================================
- *
+ *
* LyX, The Document Processor
- *
+ *
* Copyright 1995 Matthias Ettrich
* Copyright 1995-2001 The LyX Team.
*
#ifndef LISTREAM_H
-#define LISTREAM_H
+#define LISTREAM_H
#ifdef HAVE_ISTREAM
#include <istream>
-#else
+#else
#include <iostream>
#endif
// -*- C++ -*-
/* This file is part of
* ======================================================
- *
+ *
* LyX, The Document Processor
- *
+ *
* Copyright 1995 Matthias Ettrich
* Copyright 1995-2001 The LyX Team.
*
#ifndef LOSTREAM_H
-#define LOSTREAM_H
+#define LOSTREAM_H
#ifdef HAVE_OSTREAM
#include <ostream>
-#else
+#else
#include <iostream>
#endif
struct LRegex::Impl {
///
regex_t * preg;
-
+
///
int error_code;
-
+
///
mutable LRegex::SubMatches matches;
-
+
///
- Impl(string const & regex)
+ Impl(string const & regex)
: preg(new regex_t), error_code(0)
{
error_code = regcomp(preg, regex.c_str(), REG_EXTENDED);
}
-
+
///
~Impl()
{
regfree(preg);
delete preg;
}
-
+
///
bool exact_match(string const & str) const
{
regmatch_t tmp;
if (!regexec(preg, str.c_str(), 1, &tmp, 0)) {
- if (tmp.rm_so == 0 &&
+ if (tmp.rm_so == 0 &&
tmp.rm_eo == static_cast<signed int>(str.length()))
return true;
}
// no match
return false;
}
-
+
///
LRegex::MatchPair const first_match(string const & str) const
{
tmp.rm_eo : string::npos;
return make_pair(first, second - first);
}
-
+
///
string const getError() const
{
delete [] tmp;
return ret;
}
-
+
///
LRegex::SubMatches const & exec(string const & str) const
{
/* This file is part of
* ======================================================
- *
+ *
* LyX, The Document Processor
- *
+ *
* Copyright 1995 Matthias Ettrich
* Copyright 1995-2001 The LyX Team.
*
// -*- C++ -*-
/* This file is part of
* ======================================================
- *
+ *
* LyX, The Document Processor
- *
+ *
* Copyright 1995 Matthias Ettrich
* Copyright 1995-2001 The LyX Team.
*
// Programming Language by Bjarne Stroustrup
#ifndef LSUBSTRING_H
-#define LSUBSTRING_H
+#define LSUBSTRING_H
#ifdef __GNUG__
#pragma interface
/* This file is part of
* ======================================================
- *
+ *
* LyX, The Document Processor
- *
+ *
* Copyright 2000-2001 Jean-Marc Lasgouttes
*
* ======================================================*/
StrPool::~StrPool()
{
- for (Pool::const_iterator cit = pool_.begin();
+ for (Pool::const_iterator cit = pool_.begin();
cit != pool_.end() ; ++cit) {
- delete[] (*cit);
- }
+ delete[] (*cit);
+ }
}
/* One interesting thing here would be to store the strings in a map,
char const * StrPool::add(string const & str)
{
string::size_type s = str.length();
- char * buf = new char [s + 1];
- str.copy(buf, s);
- buf[s] = '\0';
- pool_.push_back(buf);
- return buf;
+ char * buf = new char [s + 1];
+ str.copy(buf, s);
+ buf[s] = '\0';
+ pool_.push_back(buf);
+ return buf;
}
//StrPool strPool;
-
// -*- C++ -*-
/* This file is part of
* ======================================================
- *
+ *
* LyX, The Document Processor
- *
+ *
* Copyright 2000-2001 Jean-Marc Lasgouttes
*
* ======================================================*/
///
class StrPool {
public:
- /// delete all the strings that have been allocated by add()
- ~StrPool();
- /// Make a copy of the string, and remember it in the pool
- char const * add(string const & str);
-
+ /// delete all the strings that have been allocated by add()
+ ~StrPool();
+ /// Make a copy of the string, and remember it in the pool
+ char const * add(string const & str);
+
private:
///
typedef std::vector<char const *> Pool;
///
- Pool pool_;
+ Pool pool_;
};
//extern StrPool strPool;
/*
filetools.C (former paths.C) - part of LyX project
- General path-mangling functions
+ General path-mangling functions
Copyright 1996 Ivan Schreter
Parts Copyright 1996 Dirk Niggemann
- Parts Copyright 1985, 1990, 1993 Free Software Foundation, Inc.
+ Parts Copyright 1985, 1990, 1993 Free Software Foundation, Inc.
Parts Copyright 1996 Asger Alstrup
-
+
See also filetools.h.
lyx-filetool.C : tools functions for file/path handling
#endif
#include <cstdlib>
-#include <cstdio>
+#include <cstdio>
#include <fcntl.h>
#include <cerrno>
#include "debug.h"
{
string name = OnlyFilename(file);
string const path = OnlyPath(file);
-
+
for (string::size_type i = 0; i < name.length(); ++i) {
name[i] &= 0x7f; // set 8th bit to 0
};
string const keep("abcdefghijklmnopqrstuvwxyz"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"@!\"'()*+,-./0123456789:;<=>?[]`|");
-
+
string::size_type pos = 0;
while ((pos = name.find_first_not_of(keep, pos)) != string::npos) {
name[pos++] = '_';
// Is a file read_only?
// return 1 read-write
// 0 read_only
-// -1 error (doesn't exist, no access, anything else)
+// -1 error (doesn't exist, no access, anything else)
int IsFileWriteable (string const & path)
{
FileInfo fi(path);
-
+
if (fi.access(FileInfo::wperm|FileInfo::rperm)) // read-write
return 1;
if (fi.readable()) // read-only
bool IsDirWriteable (string const & path)
{
lyxerr[Debug::FILES] << "IsDirWriteable: " << path << endl;
-
+
string const tmpfl(lyx::tempName(path, "lyxwritetest"));
if (tmpfl.empty())
return false;
-
+
lyx::unlink(tmpfl);
return true;
}
// If path entry begins with $$LyX/, use system_lyxdir
// If path entry begins with $$User/, use user_lyxdir
// Example: "$$User/doc;$$LyX/doc"
-string const FileOpenSearch (string const & path, string const & name,
+string const FileOpenSearch (string const & path, string const & name,
string const & ext)
{
string real_file, path_element;
bool notfound = true;
string tmppath = split(path, path_element, ';');
-
+
while (notfound && !path_element.empty()) {
path_element = os::slashify_path(path_element);
if (!suffixIs(path_element, '/'))
path_element+= '/';
path_element = subst(path_element, "$$LyX", system_lyxdir);
path_element = subst(path_element, "$$User", user_lyxdir);
-
+
real_file = FileSearch(path_element, name, ext);
-
+
if (real_file.empty()) {
do {
tmppath = split(tmppath, path_element, ';');
vector<string> dirlist;
DIR * dirp = ::opendir(dir.c_str());
if (!dirp) {
- lyxerr[Debug::FILES]
+ lyxerr[Debug::FILES]
<< "Directory \"" << dir
<< "\" does not exist to DirList." << endl;
return dirlist;
}
-
+
dirent * dire;
while ((dire = ::readdir(dirp))) {
string const fil = dire->d_name;
vector<string> dirlist;
directory_iterator dit("dir");
while (dit != directory_iterator()) {
- string fil = dit->filename;
+ string fil = dit->filename;
if (prefixIs(fil, extension)) {
- dirlist.push_back(fil);
+ dirlist.push_back(fil);
}
++dit;
}
// Returns the real name of file name in directory path, with optional
-// extension ext.
-string const FileSearch(string const & path, string const & name,
+// extension ext.
+string const FileSearch(string const & path, string const & name,
string const & ext)
{
// if `name' is an absolute path, we ignore the setting of `path'
// search first without extension, then with it.
if (IsFileReadable(fullname))
return fullname;
- else if (ext.empty())
+ else if (ext.empty())
return string();
else { // Is it not more reasonable to use ChangeExtension()? (SMiyata)
fullname += '.';
fullname += ext;
if (IsFileReadable(fullname))
return fullname;
- else
+ else
return string();
}
}
// 1) user_lyxdir
// 2) build_lyxdir (if not empty)
// 3) system_lyxdir
-string const LibFileSearch(string const & dir, string const & name,
+string const LibFileSearch(string const & dir, string const & name,
string const & ext)
{
- string fullname = FileSearch(AddPath(user_lyxdir, dir), name, ext);
+ string fullname = FileSearch(AddPath(user_lyxdir, dir), name, ext);
if (!fullname.empty())
return fullname;
-
- if (!build_lyxdir.empty())
+
+ if (!build_lyxdir.empty())
fullname = FileSearch(AddPath(build_lyxdir, dir), name, ext);
if (!fullname.empty())
return fullname;
-
+
return FileSearch(AddPath(system_lyxdir, dir), name, ext);
}
string const
-i18nLibFileSearch(string const & dir, string const & name,
+i18nLibFileSearch(string const & dir, string const & name,
string const & ext)
{
// this comment is from intl/dcigettext.c. We try to mimick this
- // behaviour here.
+ // behaviour here.
/* The highest priority value is the `LANGUAGE' environment
variable. But we don't use the value if the currently
selected locale is the C locale. This is a GNU extension. */
lang = GetEnv("LANG");
}
}
-
+
lang = token(lang, '_', 0);
-
+
if (lang.empty() || lang == "C")
return LibFileSearch(dir, name, ext);
else {
#if HAVE_PUTENV
// this leaks, but what can we do about it?
- // Is doing a getenv() and a free() of the older value
+ // Is doing a getenv() and a free() of the older value
// a good idea? (JMarc)
// Actually we don't have to leak...calling putenv like this
// should be enough: ... and this is obviously not enough if putenv
// I will enable the above.
//int retval = lyx::putenv(envstr.c_str());
#else
-#ifdef HAVE_SETENV
+#ifdef HAVE_SETENV
string varname;
string const str = envstr.split(varname,'=');
int const retval = ::setenv(varname.c_str(), str.c_str(), true);
int return_value = 0;
while ((de = readdir(dir))) {
string const temp = de->d_name;
- if (temp == "." || temp == "..")
+ if (temp == "." || temp == "..")
continue;
string const unlinkpath = AddName (path, temp);
- lyxerr[Debug::FILES] << "Deleting file: " << unlinkpath
+ lyxerr[Debug::FILES] << "Deleting file: " << unlinkpath
<< endl;
bool deleted = true;
if (fi.isOK() && fi.isDir())
deleted = (DeleteAllFilesInDir(unlinkpath) == 0);
deleted &= (lyx::unlink(unlinkpath) == 0);
- if (!deleted) {
- Alert::err_alert(_("Error! Could not remove file:"),
+ if (!deleted) {
+ Alert::err_alert(_("Error! Could not remove file:"),
unlinkpath);
return_value = -1;
}
- }
+ }
closedir(dir);
return return_value;
}
lyxerr[Debug::FILES]
<< "CreateTmpDir: tempdir=`" << tempdir << "'\n"
<< "CreateTmpDir: mask=`" << mask << "'" << endl;
-
+
string const tmpfl(lyx::tempName(tempdir, mask));
// lyx::tempName actually creates a file to make sure that it
// stays unique. So we have to delete it before we can create
// a dir with the same name. Note also that we are not thread
// safe because of the gap between unlink and mkdir. (Lgb)
lyx::unlink(tmpfl.c_str());
-
+
if (tmpfl.empty() || lyx::mkdir(tmpfl, 0700)) {
Alert::err_alert(_("Error! Couldn't create temporary directory:"),
tempdir);
if (Allfiles && DeleteAllFilesInDir(tmpdir)) {
return -1;
}
- if (lyx::rmdir(tmpdir)) {
- Alert::err_alert(_("Error! Couldn't delete temporary directory:"),
+ if (lyx::rmdir(tmpdir)) {
+ Alert::err_alert(_("Error! Couldn't delete temporary directory:"),
tmpdir);
return -1;
}
- return 0;
+ return 0;
}
} // namespace anon
TempBase = BasePath;
else
TempBase = AddPath(lyx::getcwd(), BasePath);
-
+
// Handle /./ at the end of the path
while (suffixIs(TempBase, "/./"))
TempBase.erase(TempBase.length() - 2);
while (!RTemp.empty()) {
// Split by next /
RTemp = split(RTemp, Temp, '/');
-
+
if (Temp == ".") continue;
if (Temp == "..") {
// Remove one level of TempBase
while (!RTemp.empty()) {
// Split by next /
RTemp = split(RTemp, Temp, '/');
-
+
if (Temp == ".") {
TempBase = "./";
} else if (Temp == "..") {
}
// returns absolute path
- return TempBase;
+ return TempBase;
}
//
// Search ${...} as Variable-Name inside the string and replace it with
// the denoted environmentvariable
-// Allow Variables according to
+// Allow Variables according to
// variable := '$' '{' [A-Za-z_]{[A-Za-z_0-9]*} '}'
//
string const ReplaceEnvironmentPath(string const & path)
{
-//
+//
// CompareChar: Environmentvariables starts with this character
// PathChar: Next path component start with this character
// while CompareChar found do:
// Split String with PathChar
-// Search Environmentvariable
+// Search Environmentvariable
// if found: Replace Strings
//
char const CompareChar = '$';
- char const FirstChar = '{';
- char const EndChar = '}';
- char const UnderscoreChar = '_';
+ char const FirstChar = '{';
+ char const EndChar = '}';
+ char const UnderscoreChar = '_';
string EndString; EndString += EndChar;
string FirstString; FirstString += FirstChar;
string CompareString; CompareString += CompareChar;
string result0 = split(path, result1, CompareChar);
while (!result0.empty()) {
string copy1(result0); // contains String after $
-
+
// Check, if there is an EndChar inside original String.
-
+
if (!regexMatch(copy1, RegExp)) {
// No EndChar inside. So we are finished
result1 += CompareString + result0;
bool result = isalpha(*cp1) || (*cp1 == UnderscoreChar);
++cp1;
while (*cp1 && result) {
- result = isalnum(*cp1) ||
- (*cp1 == UnderscoreChar);
+ result = isalnum(*cp1) ||
+ (*cp1 == UnderscoreChar);
++cp1;
}
result1 += res1;
continue;
}
-
+
string env(GetEnv(res1_contents + 1));
if (!env.empty()) {
// Congratulations. Environmentvariable found
// Next $-Sign?
result0 = split(res0, res1, CompareChar);
result1 += res1;
- }
+ }
return result1;
} // ReplaceEnvironmentPath
}
if (!path2.empty()) {
- string::size_type const p2start = path2.find_first_not_of('/');
+ string::size_type const p2start = path2.find_first_not_of('/');
string::size_type const p2end = path2.find_last_not_of('/');
string const tmp = path2.substr(p2start, p2end - p2start + 1);
buf += tmp + '/';
}
-/*
+/*
Change extension of oldname to extension.
Strips path off if no_path == true.
If no extension on oldname, just appends.
string::size_type last_dot = oldname.rfind('.');
if (last_dot < last_slash && last_slash != string::npos)
last_dot = string::npos;
-
+
string ext;
// Make sure the extension starts with a dot
if (!extension.empty() && extension[0] != '.')
}
// the different filetypes and what they contain in one of the first lines
-// (dots are any characters). (Herbert 20020131)
+// (dots are any characters). (Herbert 20020131)
// AGR Grace...
// BMP BM...
// EPS %!PS-Adobe-3.0 EPSF...
// JPG JFIF
// PDF %PDF-...
// PNG .PNG...
-// PBM P1... or P4 (B/W)
+// PBM P1... or P4 (B/W)
// PGM P2... or P5 (Grayscale)
-// PPM P3... or P6 (color)
+// PPM P3... or P6 (color)
// PS %!PS-Adobe-2.0 or 1.0, no "EPSF"!
// SGI \001\332... (decimal 474)
// TGIF %TGIF...
if (filename.empty() || !IsFileReadable(filename))
// paranoia check
return string();
-
+
ifstream ifs(filename.c_str());
if (!ifs)
// Couldn't open file...
format = "ppm";
}
break;
- }
+ }
if (stamp == "\001\332")
format = "sgi";
else if ((stamp == "II") || (stamp == "MM"))
else if (contains(str,"BITPIX"))
format = "fits";
}
-
+
if (!format.empty()) {
lyxerr[Debug::GRAPHICS]
<< "Recognised Fileformat: " << format << endl;
return format;
- }
-
+ }
+
string const ext(GetExtension(filename));
lyxerr[Debug::GRAPHICS]
<< "filetools(getExtFromContents)\n"
<< "\tCouldn't find a known Type!\n";
if (!ext.empty()) {
lyxerr[Debug::GRAPHICS]
- << "\twill take the file extension -> "
+ << "\twill take the file extension -> "
<< ext << endl;
return ext;
} else {
if (l2 > threshold) {
// Yes, shortend it
prefix += ".../";
-
+
string temp;
-
+
while (relhome.length() > threshold)
relhome = split(relhome, temp, '/');
// (Claus Hentschel) Check if popen was succesful ;-)
if (!inf)
return make_pair(-1, string());
-
+
string ret;
int c = fgetc(inf);
while (c != EOF) {
going to implement this until I see some demand for it.
Lgb
*/
-
+
// If the file can be found directly, we just return a
- // absolute path version of it.
- if (FileInfo(fil).exist())
+ // absolute path version of it.
+ if (FileInfo(fil).exist())
return MakeAbsPath(fil);
- // No we try to find it using kpsewhich.
+ // No we try to find it using kpsewhich.
// It seems from the kpsewhich manual page that it is safe to use
// kpsewhich without --format: "When the --format option is not
// given, the search path used when looking for a file is inferred
cmdret const c = do_popen(kpsecmd);
lyxerr[Debug::LATEX] << "kpse status = " << c.first << "\n"
- << "kpse result = `" << strip(c.second, '\n')
+ << "kpse result = `" << strip(c.second, '\n')
<< "'" << endl;
- if (c.first != -1)
+ if (c.first != -1)
return os::internal_path(strip(strip(c.second, '\n'), '\r'));
else
return string();
}
}
}
-
-
If path entry begins with $$User/, use user_lyxdir.
Example: "$$User/doc;$$LyX/doc".
*/
-string const FileOpenSearch (string const & path, string const & name,
+string const FileOpenSearch (string const & path, string const & name,
string const & ext = string());
/** Returns the real name of file name in directory path, with optional
The file is searched in the given path (unless it is an absolute
file name), first directly, and then with extension .ext (if given).
*/
-string const FileSearch(string const & path, string const & name,
+string const FileSearch(string const & path, string const & name,
string const & ext = string());
/// Returns a vector of all files in directory dir having extension ext.
string const & ext = string());
/** Is directory read only?
- returns
+ returns
true: dir writeable
false: not writeable
*/
\end{enumerate}
The third parameter `ext' is optional.
*/
-string const LibFileSearch(string const & dir, string const & name,
+string const LibFileSearch(string const & dir, string const & name,
string const & ext = string());
/** Same as LibFileSearch(), but tries first to find an
internationalized version of the file by prepending $LANG_ to the
- name
+ name
*/
string const
-i18nLibFileSearch(string const & dir, string const & name,
+i18nLibFileSearch(string const & dir, string const & name,
string const & ext = string());
///
If relpath is absolute, just use that.
If basepath doesn't exist use CWD.
*/
-string const MakeAbsPath(string const & RelPath = string(),
+string const MakeAbsPath(string const & RelPath = string(),
string const & BasePath = string());
/** Creates a nice compact path for displaying. The parameter
glibc returns the needed size.
One problem can be that vsnprintf is not implemented on all archs,
but AFAIK it is part of the new ANSI C standard.
-
+
Lgb
*/
} else {
retval_ = waitForChild();
}
-
+
return retval_;
}
wait = false;
} else if (WIFSIGNALED(status)) {
lyxerr << "LyX: Child didn't catch signal "
- << WTERMSIG(status)
+ << WTERMSIG(status)
<< "and died. Too bad." << endl;
wait = false;
} else if (WIFSTOPPED(status)) {
lyxerr << "LyX: Child (pid: " << pid_
<< ") stopped on signal "
- << WSTOPSIG(status)
+ << WSTOPSIG(status)
<< ". Waiting for child to finish." << endl;
} else {
lyxerr << "LyX: Something rotten happened while "
pid_t Forkedcall::generateChild()
{
const int MAX_ARGV = 255;
- char *syscmd = 0;
+ char *syscmd = 0;
char *argv[MAX_ARGV];
string childcommand(command_); // copy
// reinit
more = !rest.empty();
- if (more)
+ if (more)
rest = split(rest, childcommand, ' ');
}
argv[index] = 0;
///
DontWait
};
-
+
///
Forkedcall();
-
+
/** Start the child process.
*
* The command "what" is passed to fork() for execution.
* Used by the timer.
*/
pid_t pid() const { return pid_; }
-
+
/** Emit the signal.
* Used by the timer.
*/
* \author Asger Alstrup Nielsen
* \author Angus Leeming
*
- * A class for the control of child processes launched using
+ * A class for the control of child processes launched using
* fork() and execvp().
*/
ForkedcallsController::ForkedcallsController()
{
timeout_ = new Timeout(100, Timeout::ONETIME);
-
+
timeout_->timeout
.connect(SigC::slot(this, &ForkedcallsController::timer));
}
bool remove_it = false;
if (waitrpid == -1) {
- lyxerr << "LyX: Error waiting for child: "
+ lyxerr << "LyX: Error waiting for child: "
<< strerror(errno) << endl;
// Child died, so pretend it returned 1
remove_it = true;
} else if (WIFSTOPPED(stat_loc)) {
- lyxerr << "LyX: Child (pid: " << pid
+ lyxerr << "LyX: Child (pid: " << pid
<< ") stopped on signal "
- << WSTOPSIG(stat_loc)
+ << WSTOPSIG(stat_loc)
<< ". Waiting for child to finish." << endl;
} else {
~ForkedcallsController();
/// Get hold of the only controller that can exist inside the process.
- static ForkedcallsController & get();
+ static ForkedcallsController & get();
/// Add a new child process to the list of controlled processes.
void addCall(Forkedcall const & newcall);
/// Signal emitted when the list of current child processes changes.
SigC::Signal0<void> childrenChanged;
-
+
private:
///
ForkedcallsController(ForkedcallsController const &);
/** The timer. Enables us to check the status of the children
* every XX ms and to invoke a callback on completion.
*/
- Timeout * timeout_;
+ Timeout * timeout_;
};
#endif // FORKEDCONTR_H
// Returns current working directory
string const lyx::getcwd()
{
- int n = 256; // Assume path is less than 256 chars
+ int n = 256; // Assume path is less than 256 chars
char * err;
- char * tbuf = new char[n];
-
- // Safe. Hopefully all getcwds behave this way!
- while (((err = l_getcwd(tbuf, n)) == 0) && (errno == ERANGE)) {
+ char * tbuf = new char[n];
+
+ // Safe. Hopefully all getcwds behave this way!
+ while (((err = l_getcwd(tbuf, n)) == 0) && (errno == ERANGE)) {
// Buffer too small, double the buffersize and try again
- delete[] tbuf;
- n = 2 * n;
- tbuf = new char[n];
- }
+ delete[] tbuf;
+ n = 2 * n;
+ tbuf = new char[n];
+ }
string result;
if (err) result = tbuf;
/* This file is part of
- * ======================================================
- *
+ * ======================================================
+ *
* LyX, The Document Processor
- *
+ *
* Copyright 1995 Matthias Ettrich
* Copyright 1995-2001 The LyX Team.
*
bool isStrInt(string const & str)
{
if (str.empty()) return false;
-
+
// Remove leading and trailing white space chars.
string const tmpstr = frontStrip(strip(str, ' '), ' ');
if (tmpstr.empty()) return false;
-
+
string::const_iterator cit = tmpstr.begin();
if ((*cit) == '-') ++cit;
string::const_iterator end = tmpstr.end();
bool isStrUnsignedInt(string const & str)
{
if (str.empty()) return false;
-
+
// Remove leading and trailing white space chars.
string const tmpstr = frontStrip(strip(str, ' '), ' ');
if (tmpstr.empty()) return false;
-
+
string::const_iterator cit = tmpstr.begin();
string::const_iterator end = tmpstr.end();
for (; cit != end; ++cit) {
bool isStrDbl(string const & str)
{
if (str.empty()) return false;
-
+
// Remove leading and trailing white space chars.
string const tmpstr = frontStrip(strip(str, ' '), ' ');
if (tmpstr.empty()) return false;
}
-char lowercase(char c)
-{
- return char(tolower(c));
+char lowercase(char c)
+{
+ return char(tolower(c));
}
-char uppercase(char c)
-{
- return char(toupper(c));
+char uppercase(char c)
+{
+ return char(toupper(c));
}
return tolower(c);
}
};
-
+
struct local_uppercase {
char operator()(char c) const {
return toupper(c);
bool prefixIs(string const & a, char const * pre)
{
lyx::Assert(pre);
-
+
size_t const l = strlen(pre);
string::size_type const alen = a.length();
-
+
if (l > alen || a.empty())
return false;
else {
{
string::size_type const prelen = pre.length();
string::size_type const alen = a.length();
-
+
if (prelen > alen || a.empty())
return false;
else {
bool suffixIs(string const & a, char const * suf)
{
lyx::Assert(suf);
-
+
size_t const suflen = strlen(suf);
string::size_type const alen = a.length();
-
+
if (suflen > alen)
return false;
else {
{
string::size_type const suflen = suf.length();
string::size_type const alen = a.length();
-
+
if (suflen > alen) {
return false;
} else {
bool containsOnly(string const & s, char const * cset)
{
lyx::Assert(cset);
-
+
return s.find_first_not_of(cset) == string::npos;
}
bool containsOnly(char const * s, char const * cset)
{
lyx::Assert(s && cset);
-
+
return string(s).find_first_not_of(cset) == string::npos;
}
bool containsOnly(char const * s, string const & cset)
{
lyx::Assert(s);
-
+
return string(s).find_first_not_of(cset) == string::npos;
}
string const token(string const & a, char delim, int n)
{
if (a.empty()) return string();
-
+
string::size_type k = 0;
string::size_type i = 0;
char const * oldstr, string const & newstr)
{
lyx::Assert(oldstr);
-
+
string lstr(a);
string::size_type i = 0;
string::size_type olen = strlen(oldstr);
string tmp(a);
string::size_type i = tmp.find_last_not_of(c);
if (i == a.length() - 1) return tmp; // no c's at end of a
- if (i != string::npos)
+ if (i != string::npos)
tmp.erase(i + 1, string::npos);
#if !defined(USE_INCLUDED_STRING) && !defined(STD_STRING_IS_GOOD)
/// Needed for broken string::find_last_not_of
string const frontStrip(string const & a, char const * p)
{
lyx::Assert(p);
-
+
if (a.empty() || !*p) return a;
string tmp(a);
string::size_type i = tmp.find_first_not_of(p);
return std::strcmp(a, b);
#else
return strcmp(a, b);
-#endif
+#endif
}
///
return std::strncmp(a, b, len);
#else
return strncmp(a, b, len);
-#endif
+#endif
}
///
///
double strToDbl(string const & str);
-///
+///
char lowercase(char c);
-///
+///
char uppercase(char c);
///
/// convert \a T to string
template<typename T>
inline
-string const tostr(T const & t)
+string const tostr(T const & t)
{
ostringstream ostr;
ostr << t;
typedef string first_argument_type;
typedef string second_argument_type;
typedef bool result_type;
-
+
bool operator()(string const & haystack, string const & needle) const {
return contains(haystack, needle);
}
/** Search a token in this string using the delim.
Doesn't modify the original string. Returns -1 in case of
- failure.
+ failure.
Example:
\code
"a;bc;d".tokenPos(';', "bc") == 1;
/* lxtl.h
* LyX eXternalization Template Library
* This file is part of
- * ======================================================
+ * ======================================================
*
* LyX, The Document Processor
*
typedef GIOP_format<auto_mem_buffer> gui_format;
/* Simplify the use of the XTL. The caller is responsible for creating their
- own memory buffer. The buffer type isn't a template parameter because I
+ own memory buffer. The buffer type isn't a template parameter because I
need/want the forward declared buffer class in some other header files
thereby avoiding an extra file dependency.
ARRae 20000423
template <class InputIter, class OutputIter, class Func>
OutputIter copy_if(InputIter first, InputIter last,
- OutputIter result, Func func)
+ OutputIter result, Func func)
{
for (; first != last; ++first) {
if (func(*first)) {
count (Iterator first, Iterator last, T const & value)
{
#ifdef HAVE_STD_COUNT
- return std::count(first, last, value);
+ return std::count(first, last, value);
#else
- std::iterator_traits<Iterator>::difference_type n = 0;
- while (first != last)
+ std::iterator_traits<Iterator>::difference_type n = 0;
+ while (first != last)
if (*first++ == value) ++n;
return n;
#endif
/** \file lyxfunctional.h
\brief Convenient function objects for use with LyX
-
+
This is currently a small collection of small function objects for use
together with std::algorithms.
**/
template<class R, class C, class A>
class class_fun_t {
public:
- class_fun_t(C & ct, R(C::*p)(A))
+ class_fun_t(C & ct, R(C::*p)(A))
: c(ct), cmf(p) {}
R operator()(A & a) const {
return (c.*cmf)(a);
typedef void difference_type;
typedef void pointer;
typedef void reference;
-
+
back_insert_fun_iterator(Cont & x, MemRet(Type::*p)())
: container(&x), pmf(p) {}
typedef void difference_type;
typedef void pointer;
typedef void reference;
-
+
const_back_insert_fun_iterator(Cont & x, MemRet(Type::*p)() const)
: container(&x), pmf(p) {}
-
+
~const_back_insert_fun_iterator() {}
-
+
const_back_insert_fun_iterator &
operator=(Type const * val) {
container->push_back((val->*pmf)());
return const_compare_memfun_t<R, C, A>(p, a);
}
-
+
// Functors used in the template.
///
// -*- C++ -*-
/* This file is part of
- * ======================================================
- *
+ * ======================================================
+ *
* LyX, The Document Processor
- *
+ *
* Copyright 1995 Matthias Ettrich
* Copyright 1995-2001 The LyX Team.
*
/// generates a checksum
unsigned long sum(string const & file);
/// returns a date string (not used currently)
-char * date();
+char * date();
/// returns the name of the user (not used currently)
string const getUserName();
///
/** Returns true if var is approximately equal to number with allowed error
* of 'error'.
*
- * Reason: A float can be very close to the number, yet still need not be
+ * Reason: A float can be very close to the number, yet still need not be
* exactly equal, you can have exp(-10) which is very close to zero but not
* zero. If you only need an approximate equality (you usually do), use this
* template.
*
* Usage: if (float_equal(var, number, 0.0001)) { }
- *
+ *
* This will check if 'var' is approx. equal to 'number' with error of 1/1000
*/
inline bool float_equal(float var, float number, float error)
#define RE_BACKSLASH_ESCAPE_IN_LISTS (1)
/* If this bit is not set, then + and ? are operators, and \+ and \? are
- literals.
+ literals.
If set, then \+ and \? are operators and + and ? are literals. */
#define RE_BK_PLUS_QM (RE_BACKSLASH_ESCAPE_IN_LISTS << 1)
/* If this bit is set, then ^ and $ are always anchors (outside bracket
expressions, of course).
If this bit is not set, then it depends:
- ^ is an anchor if it is at the beginning of a regular
- expression or after an open-group or an alternation operator;
- $ is an anchor if it is at the end of a regular expression, or
- before a close-group or an alternation operator.
+ ^ is an anchor if it is at the beginning of a regular
+ expression or after an open-group or an alternation operator;
+ $ is an anchor if it is at the end of a regular expression, or
+ before a close-group or an alternation operator.
This bit could be (re)combined with RE_CONTEXT_INDEP_OPS, because
POSIX draft 11.2 says that * etc. in leading positions is undefined.
/* If this bit is set, then special characters are always special
regardless of where they are in the pattern.
If this bit is not set, then special characters are special only in
- some contexts; otherwise they are ordinary. Specifically,
+ some contexts; otherwise they are ordinary. Specifically,
* + ? and intervals are only special when not after the beginning,
open-group, or alternation operator. */
#define RE_CONTEXT_INDEP_OPS (RE_CONTEXT_INDEP_ANCHORS << 1)
#define RE_HAT_LISTS_NOT_NEWLINE (RE_DOT_NOT_NULL << 1)
/* If this bit is set, either \{...\} or {...} defines an
- interval, depending on RE_NO_BK_BRACES.
+ interval, depending on RE_NO_BK_BRACES.
If not set, \{, \}, {, and } are literals. */
#define RE_INTERVALS (RE_HAT_LISTS_NOT_NEWLINE << 1)
If not set, then \<digit> is a back-reference. */
#define RE_NO_BK_REFS (RE_NO_BK_PARENS << 1)
-/* If this bit is set, then | is an alternation operator, and \| is literal.
+/* If this bit is set, then | is an alternation operator, and \| is literal.
If not set, then \| is an alternation operator, and | is literal. */
#define RE_NO_BK_VBAR (RE_NO_BK_REFS << 1)
\f
/* Define combinations of the above bits for the standard possibilities.
(The [[[ comments delimit what gets put into the Texinfo file, so
- don't delete them!) */
+ don't delete them!) */
/* [[[begin syntaxes]]] */
#define RE_SYNTAX_EMACS 0
| RE_NO_BK_VBAR | RE_NO_EMPTY_RANGES \
| RE_UNMATCHED_RIGHT_PAREN_ORD)
-#define RE_SYNTAX_POSIX_AWK \
+#define RE_SYNTAX_POSIX_AWK \
(RE_SYNTAX_POSIX_EXTENDED | RE_BACKSLASH_ESCAPE_IN_LISTS)
#define RE_SYNTAX_GREP \
#ifdef RE_DUP_MAX
#undef RE_DUP_MAX
#endif
-#define RE_DUP_MAX ((1 << 15) - 1)
+#define RE_DUP_MAX ((1 << 15) - 1)
/* POSIX `cflags' bits (i.e., information for `regcomp'). */
/* If this bit is set, then ignore case when matching.
If not set, then case is significant. */
#define REG_ICASE (REG_EXTENDED << 1)
-
+
/* If this bit is set, then anchors do not match at newline
characters in the string.
If not set, then anchors do match at newlines. */
REG_EESCAPE, /* Trailing backslash. */
REG_ESUBREG, /* Invalid back reference. */
REG_EBRACK, /* Unmatched left bracket. */
- REG_EPAREN, /* Parenthesis imbalance. */
+ REG_EPAREN, /* Parenthesis imbalance. */
REG_EBRACE, /* Unmatched \{. */
REG_BADBR, /* Invalid contents of \{\}. */
REG_ERANGE, /* Invalid range end. */
{
/* [[[begin pattern_buffer]]] */
/* Space that holds the compiled pattern. It is declared as
- `unsigned char *' because its elements are
- sometimes used as array indexes. */
+ `unsigned char *' because its elements are
+ sometimes used as array indexes. */
unsigned char *buffer;
/* Number of bytes to which `buffer' points. */
unsigned long allocated;
/* Number of bytes actually used in `buffer'. */
- unsigned long used;
+ unsigned long used;
- /* Syntax setting with which the pattern was compiled. */
+ /* Syntax setting with which the pattern was compiled. */
reg_syntax_t syntax;
- /* Pointer to a fastmap, if any, otherwise zero. re_search uses
- the fastmap, if there is one, to skip over impossible
- starting points for matches. */
+ /* Pointer to a fastmap, if any, otherwise zero. re_search uses
+ the fastmap, if there is one, to skip over impossible
+ starting points for matches. */
char *fastmap;
- /* Either a translate table to apply to all characters before
- comparing them, or zero for no translation. The translation
- is applied to a pattern when it is compiled and to a string
- when it is matched. */
+ /* Either a translate table to apply to all characters before
+ comparing them, or zero for no translation. The translation
+ is applied to a pattern when it is compiled and to a string
+ when it is matched. */
char *translate;
/* Number of subexpressions found by the compiler. */
size_t re_nsub;
- /* Zero if this pattern cannot match the empty string, one else.
- Well, in truth it's used only in `re_search_2', to see
- whether or not we should use the fastmap, so we don't set
- this absolutely perfectly; see `re_compile_fastmap' (the
- `duplicate' case). */
+ /* Zero if this pattern cannot match the empty string, one else.
+ Well, in truth it's used only in `re_search_2', to see
+ whether or not we should use the fastmap, so we don't set
+ this absolutely perfectly; see `re_compile_fastmap' (the
+ `duplicate' case). */
unsigned can_be_null : 1;
- /* If REGS_UNALLOCATED, allocate space in the `regs' structure
- for `max (RE_NREGS, re_nsub + 1)' groups.
- If REGS_REALLOCATE, reallocate space if necessary.
- If REGS_FIXED, use what's there. */
+ /* If REGS_UNALLOCATED, allocate space in the `regs' structure
+ for `max (RE_NREGS, re_nsub + 1)' groups.
+ If REGS_REALLOCATE, reallocate space if necessary.
+ If REGS_FIXED, use what's there. */
#define REGS_UNALLOCATED 0
#define REGS_REALLOCATE 1
#define REGS_FIXED 2
unsigned regs_allocated : 2;
- /* Set to zero when `regex_compile' compiles a pattern; set to one
- by `re_compile_fastmap' if it updates the fastmap. */
+ /* Set to zero when `regex_compile' compiles a pattern; set to one
+ by `re_compile_fastmap' if it updates the fastmap. */
unsigned fastmap_accurate : 1;
- /* If set, `re_match_2' does not return information about
- subexpressions. */
+ /* If set, `re_match_2' does not return information about
+ subexpressions. */
unsigned no_sub : 1;
- /* If set, a beginning-of-line anchor doesn't match at the
- beginning of the string. */
+ /* If set, a beginning-of-line anchor doesn't match at the
+ beginning of the string. */
unsigned not_bol : 1;
- /* Similarly for an end-of-line anchor. */
+ /* Similarly for an end-of-line anchor. */
unsigned not_eol : 1;
- /* If true, an anchor at a newline matches. */
+ /* If true, an anchor at a newline matches. */
unsigned newline_anchor : 1;
/* [[[end pattern_buffer]]] */
BUFFER. Return NULL if successful, and an error string if not. */
extern const char *re_compile_pattern
_RE_ARGS ((const char *pattern, int length,
- struct re_pattern_buffer *buffer));
+ struct re_pattern_buffer *buffer));
/* Compile a fastmap for the compiled pattern in BUFFER; used to
information in REGS (if REGS and BUFFER->no_sub are nonzero). */
extern int re_search
_RE_ARGS ((struct re_pattern_buffer *buffer, const char *string,
- int length, int start, int range, struct re_registers *regs));
+ int length, int start, int range, struct re_registers *regs));
/* Like `re_search', but search in the concatenation of STRING1 and
STRING2. Also, stop searching at index START + STOP. */
extern int re_search_2
_RE_ARGS ((struct re_pattern_buffer *buffer, const char *string1,
- int length1, const char *string2, int length2,
- int start, int range, struct re_registers *regs, int stop));
+ int length1, const char *string2, int length2,
+ int start, int range, struct re_registers *regs, int stop));
/* Like `re_search', but return how many characters in STRING the regexp
in BUFFER matched, starting at position START. */
extern int re_match
_RE_ARGS ((struct re_pattern_buffer *buffer, const char *string,
- int length, int start, struct re_registers *regs));
+ int length, int start, struct re_registers *regs));
/* Relates to `re_match' as `re_search_2' relates to `re_search'. */
-extern int re_match_2
+extern int re_match_2
_RE_ARGS ((struct re_pattern_buffer *buffer, const char *string1,
- int length1, const char *string2, int length2,
- int start, struct re_registers *regs, int stop));
+ int length1, const char *string2, int length2,
+ int start, struct re_registers *regs, int stop));
/* Set REGS to hold NUM_REGS registers, storing them in STARTS and
freeing the old data. */
extern void re_set_registers
_RE_ARGS ((struct re_pattern_buffer *buffer, struct re_registers *regs,
- unsigned num_regs, regoff_t *starts, regoff_t *ends));
+ unsigned num_regs, regoff_t *starts, regoff_t *ends));
/* 4.2 bsd compatibility. */
extern char *re_comp _RE_ARGS ((const char *));
extern int regcomp _RE_ARGS ((regex_t *preg, const char *pattern, int cflags));
extern int regexec
_RE_ARGS ((const regex_t *preg, const char *string, size_t nmatch,
- regmatch_t pmatch[], int eflags));
+ regmatch_t pmatch[], int eflags));
extern size_t regerror
_RE_ARGS ((int errcode, const regex_t *preg, char *errbuf,
- size_t errbuf_size));
+ size_t errbuf_size));
extern void regfree _RE_ARGS ((regex_t *preg));
/* LyX added. */
/* This file is part of
- * ======================================================
- *
+ * ======================================================
+ *
* LyX, The Document Processor
- *
+ *
* Copyright 1995 Matthias Ettrich
* Copyright 1995-2000 The LyX Team.
*
size_t res;
/// Data. At least 1 char for trailing null.
lyxstring::value_type * s;
-
+
///
Srep(lyxstring::size_type nsz, const lyxstring::value_type * p);
///
--ref;
return new Srep(sz, s);
}
-
+
///
void assign(lyxstring::size_type nsz, const lyxstring::value_type * p);
///
sz = 0;
}
}
-
+
void lyxstring::Srep::assign(lyxstring::size_type nsz, const value_type * p)
{
memcpy(tmp + i + n2, &s[i + n], sz - i);
delete[] s;
s = tmp;
- sz += n2;
+ sz += n2;
}
}
///////////////////////////////////////
// The lyxstring Invariant tester
///////////////////////////////////////
-
+
// There are no know bugs in lyxstring now, and it have been
// tested for a long time. so we disable the invariant checker. (Lgb)
#undef ENABLE_ASSERTIONS
/** Testing of the lyxstring invariant
* By creating an object that tests the lyxstring invariant during its
* construction *and* its deconstruction we greatly simplify our code.
- * Calling TestlyxstringInvariant() upon entry to an lyxstring method
+ * Calling TestlyxstringInvariant() upon entry to an lyxstring method
* will test the invariant upon entry to the code. If the Asserts fail
* then we know from the stack trace that the corruption occurred *before*
* entry to this method. We can also be sure it didn't happen in any of
///////////////////////
lyxstring::size_type lyxstring::size() const
-{
+{
return rep->sz;
}
rep = x.rep; // share representation
return *this;
}
-
+
lyxstring & lyxstring::assign(lyxstring const & x, size_type pos, size_type n)
{
return assign(x.substr(pos, n));
}
-
+
lyxstring & lyxstring::assign(value_type const * s, size_type n)
{
}
return *this;
}
-
+
lyxstring & lyxstring::assign(value_type const * s)
{
insert(p - begin(), first, last - first);
}
-
+
////////////////
// Find
////////////////
-
- // All the below find functions should be verified,
- // it is very likely that I have mixed up or interpreted
- // some of the parameters wrong, also some of the funcs can surely
- // be written more effectively.
+
+ // All the below find functions should be verified,
+ // it is very likely that I have mixed up or interpreted
+ // some of the parameters wrong, also some of the funcs can surely
+ // be written more effectively.
lyxstring::size_type lyxstring::find(lyxstring const & a, size_type i) const
{
if (!rep->sz || i >= rep->sz) return npos;
-
+
TestlyxstringInvariant(this);
size_type n = a.length();
{
lyx::Assert(ptr); // OURS!
if (!rep->sz || !*ptr || i >= rep->sz) return npos;
-
+
TestlyxstringInvariant(this);
// What is "n" here? is it the number of value_types to use in ptr
{
lyx::Assert(s); // OURS!
if (!rep->sz || i >= rep->sz) return npos;
-
+
TestlyxstringInvariant(this);
if (!s || !*s) return npos;
TestlyxstringInvariant(this);
- for (size_type t = 0; t + i < rep->sz; ++t) {
- if (rep->s[t + i] == c) return t + i;
+ for (size_type t = 0; t + i < rep->sz; ++t) {
+ if (rep->s[t + i] == c) return t + i;
}
- return npos;
+ return npos;
}
{
TestlyxstringInvariant(this);
- return replace(i - begin(), i2 - i, str);
+ return replace(i - begin(), i2 - i, str);
}
return replace(i - begin(), i2 - i, n, c);
}
-
+
lyxstring & lyxstring::replace(iterator i, iterator i2,
iterator j, iterator j2)
if (!*s) return 1;
// since n > n2, min(n, n2) == 0, c == 0 (stops segfault also)
- // remember that n can very well be a lot larger than rep->sz
- // so we have to ensure that n is no larger than rep->sz
- n = min(n, rep->sz);
+ // remember that n can very well be a lot larger than rep->sz
+ // so we have to ensure that n is no larger than rep->sz
+ n = min(n, rep->sz);
n2 = min(n2, slen);
- if (n == n2)
+ if (n == n2)
return memcmp(&(rep->s[pos]), s, n);
int c = memcmp(&(rep->s[pos]), s, min(n, n2));
if (c)
// -*- C++ -*-
/* This file is part of
* ======================================================
- *
+ *
* LyX, The Document Processor
- *
+ *
* Copyright 1995 Matthias Ettrich
* Copyright 1995-2000 The LyX Team.
*
// right behavior.
#ifndef LYXSTRING_H
-#define LYXSTRING_H
+#define LYXSTRING_H
#ifdef __GNUG__
#pragma interface
#include <cstring> // for size_t
/** A string class for LyX
-
+
This is a permanent String class. It is modeled closely after the C++ STL
string class. In comparison with STL string lyxstring lack support for
reverse iterators and allocators, also char_traits is not used. In most
do things like #lyxstring a= "";#, especially not in constructors.
If you want to use a default empty lyxstring as a parameter, use
-
- #void foo(lyxstring par = lyxstring()); // Correct#
-
+
+ #void foo(lyxstring par = lyxstring()); // Correct#
+
rather than
- #void foo(lyxstring par = ""); // WRONG!#
- #void foo(lyxstring par = 0); // WRONG!#
+ #void foo(lyxstring par = ""); // WRONG!#
+ #void foo(lyxstring par = 0); // WRONG!#
(The last one is only wrong because some compilers can't handle it.)
Correct: & #foo.substring(0, length()-1);# \\
Wrong: & #bar.substring(0, length());#
\end{tabular}
-
+
It is important that you declare lyxstring as const if possible, because
some methods are much more efficient in const versions.
-
+
If you want to check whether a string is empty, do
- #if (foo.empty()) something right#
+ #if (foo.empty()) something right#
rather than something along the lines of
- #if (!foo) completely wrong#
+ #if (!foo) completely wrong#
When you want to copy an lyxstring, just do
-
+
#lyxstring a, b = "String";#
#a = b; // That's it!#
not something like
-
- #lyxstring a, b = "String";#
- #a = b.copy(); // This leaks. // and does not work either. #
-
+
+ #lyxstring a, b = "String";#
+ #a = b.copy(); // This leaks. // and does not work either. #
+
The class automatically handles deep copying when required.
*/
class lyxstring {
public:
/* Typedefs */
-
+
///
typedef char value_type;
constructors as STL, except the one using iterators, one other
difference is that lyxstring, do not allow the optional allocator
parameter. */
-
+
/// "all characters" marker
static const size_type npos;
- /// #lyxstring x;#
+ /// #lyxstring x;#
lyxstring();
-
- /// #lyxstring x(lyxstring ...)#
+
+ /// #lyxstring x(lyxstring ...)#
lyxstring(lyxstring const &, size_type pos = 0, size_type n = npos);
-
+
/// #lyxstring x("abc", 2) -> "ab"#
lyxstring(value_type const *, size_type n);
-
+
// #lyxstring x("abc")#
lyxstring(value_type const *);
-
+
/// lyxstring(5, 'n') -> "nnnnn"
lyxstring(size_type n, value_type c);
///
void reserve(size_type res_arg = 0);
-
+
///
lyxstring & operator=(lyxstring const &);
-
+
///
lyxstring & operator=(value_type const *);
-
+
///
lyxstring & operator=(value_type);
///
lyxstring & assign(lyxstring const &);
-
+
///
lyxstring & assign(lyxstring const &, size_type pos, size_type n);
-
+
///
lyxstring & assign(value_type const * p, size_type n);
-
+
///
lyxstring & assign(value_type const * p);
-
+
///
lyxstring & assign(size_type n, value_type c);
/// unchecked access
const_reference operator[](size_type) const;
-
+
/// unchecked access
reference operator[](size_type);
-
+
/// checked access
const_reference at(size_type) const;
-
+
/// checked access
reference at(size_type);
// add characters after (*this)[length()-1]:
-
+
///
lyxstring & operator+=(lyxstring const &);
-
+
///
lyxstring & operator+=(value_type const *);
-
+
///
lyxstring & operator+=(value_type);
///
lyxstring & insert(size_type pos, lyxstring const &);
-
+
///
lyxstring & insert(size_type pos, lyxstring const &,
size_type pos2, size_type n);
-
+
///
lyxstring & insert(size_type pos, value_type const * p,
size_type n);
}
}
#endif
-
+
///
size_type find(lyxstring const &, size_type i = 0) const;
-
+
///
size_type find(value_type const * p,
size_type i, size_type n) const;
-
+
///
size_type find(value_type const * p, size_type i = 0) const;
-
+
///
size_type find(value_type c, size_type i = 0) const;
///
size_type rfind(lyxstring const &, size_type i = npos) const;
-
+
///
size_type rfind(value_type const * p, size_type i, size_type n) const;
-
+
///
size_type rfind(value_type const * p, size_type i = npos) const;
-
+
///
size_type rfind(value_type c, size_type i = npos) const;
///
size_type find_first_of(lyxstring const &, size_type i = 0) const;
-
+
///
size_type find_first_of(value_type const * p, size_type i,
size_type n) const;
-
+
///
size_type find_first_of(value_type const * p, size_type i = 0) const;
-
+
///
size_type find_first_of(value_type c, size_type i = 0) const;
///
size_type find_last_of(lyxstring const &, size_type i = npos) const;
-
+
///
size_type find_last_of(value_type const * p, size_type i,
size_type n) const;
-
+
///
size_type find_last_of(value_type const * p, size_type i = npos) const;
-
+
///
size_type find_last_of(value_type c, size_type i = npos) const;
///
size_type find_first_not_of(lyxstring const &, size_type i = 0) const;
-
+
///
size_type find_first_not_of(value_type const * p, size_type i,
size_type n) const;
-
+
///
size_type find_first_not_of(value_type const * p,
size_type i = 0) const;
-
+
///
size_type find_first_not_of(value_type c, size_type i = 0) const;
///
size_type find_last_not_of(lyxstring const &,
size_type i = npos) const;
-
+
///
size_type find_last_not_of(value_type const * p, size_type i,
size_type n) const;
-
+
///
size_type find_last_not_of(value_type const * p,
size_type i = npos) const;
-
+
///
size_type find_last_not_of(value_type c, size_type i = npos) const;
///
void swap(lyxstring & str);
-
+
/// Erase n chars from position i.
lyxstring & erase(size_type i = 0, size_type n = npos);
///
iterator erase(iterator first, iterator last);
- ///
+ ///
value_type const * c_str() const;
/* Note that this is STL compilant, so you can not assume
size_type copy(value_type * buf, size_type len,
size_type pos = 0) const;
-
+
///
- int compare(lyxstring const & str) const;
+ int compare(lyxstring const & str) const;
///
int compare(value_type const * p) const;
///
int compare(size_type pos, size_type n, value_type const * p,
size_type n2 = npos) const;
-
-
+
+
///
lyxstring substr(size_type i = 0, size_type n = npos) const;
-
+
private:
// These three operators can be used to discover erronous use of
// ints and strings. However a conforming C++ compiler will flag
int internal_compare(size_type pos, size_type n,
value_type const * s,
size_type slen, size_type n2) const;
-
+
/// Forward declaration of the string representation
struct Srep;
// DEC cxx requires this.
/* This file is part of
* ======================================================
- *
+ *
* LyX, The Document Processor
* Copyright 2001 The LyX Team.
*
{
lyxerr[Debug::FILES] << "lyx::sum() using mmap (lightning fast)"
<< endl;
-
+
int fd = open(file.c_str(), O_RDONLY);
if (!fd)
return 0;
-
+
struct stat info;
fstat(fd, &info);
-
+
void * mm = mmap(0, info.st_size, PROT_READ,
MAP_PRIVATE, fd, 0);
// Some platforms have the wrong type for MAP_FAILED (compaq cxx).
close(fd);
return 0;
}
-
+
char * beg = static_cast<char*>(mm);
char * end = beg + info.st_size;
-
+
boost::crc_32_type crc;
crc.process_block(beg, end);
unsigned long result = crc.checksum();
-
+
munmap(mm, info.st_size);
close(fd);
-
+
return result;
}
#else // No mmap
ifstream ifs(file.c_str());
if (!ifs) return 0;
-
+
istreambuf_iterator<char> beg(ifs);
istreambuf_iterator<char> end;
-
+
return do_crc(beg,end);
}
#else
lyxerr[Debug::FILES]
<< "lyx::sum() using istream_iterator (slow as a snail)"
<< endl;
-
+
ifstream ifs(file.c_str());
if (!ifs) return 0;
-
+
ifs.unsetf(ios::skipws);
istream_iterator<char> beg(ifs);
istream_iterator<char> end;
-
+
return do_crc(beg,end);
}
#endif
/* -*- C++ -*- */
/* This file is part of
- * ======================================================
- *
+ * ======================================================
+ *
* LyX, the High Level Word Processor
- *
+ *
* Copyright 1995 Matthias Ettrich
* Copyright 1995-1998 The LyX Team.
*
- * ======================================================
+ * ======================================================
A few prototypes and definitions needed for Windows NT */
/* Hacks to get LyX running under Win-NT w. Cygnus b19 (steven@cs.uu.nl) */
CMD_EXE
};
- //
+ //
static void init(int * argc, char ** argv[]);
- //
+ //
static string binpath() {return binpath_;}
- //
+ //
static string binname() {return binname_;}
// system_tempdir actually doesn't belong here.
// I put it here only to avoid a global variable.
static void setTmpDir(string p) {tmpdir_ = p;}
- //
+ //
static string getTmpDir() {return tmpdir_;}
- //
+ //
static string current_root();
- //
+ //
static os::shell_type shell() {return _shell;}
// DBCS aware!
static string tmpdir_;
static os::shell_type _shell;
// Used only on OS/2 to determine file system encoding.
- static unsigned long cp_;
+ static unsigned long cp_;
// Never initialize static variables in the header!
// Anyway I bet this class will never be constructed.
/* -*- C++ -*- */
/* This file is part of
-* ======================================================
-*
+* ======================================================
+*
* LyX, The Document Processor
-*
+*
* Copyright 1995 Matthias Ettrich
* Copyright 1995-2001 The LyX Team.
*
-* ======================================================
+* ======================================================
A few prototypes and definitions needed for OS/2 */
#ifndef OS2_DEFINES_H
/* -*- C++ -*- */
/* This file is part of
* ======================================================
-*
+*
* LyX, The Document Processor
-*
+*
* Copyright 1995 Matthias Ettrich
* Copyright 1995-2001 The LyX Team.
*
// The use of Alert::err_alert makes this impossible
// to inline.
//Alert::err_alert(
- // _("Error: Could not change to directory: "),
+ // _("Error: Could not change to directory: "),
// pushedDir_);
}
popped_ = true;
return 0;
}
-
Path(string const & path)
: popped_(false)
{
- if (!path.empty()) {
+ if (!path.empty()) {
pushedDir_ = lyx::getcwd(); // GetCWD();
if (pushedDir_.empty() || lyx::chdir(path)) {
// should throw an exception
// throw DirChangeError();
// The use of Alert::err_alert makes this
// impossible to inline.
- //Alert::err_alert(_("Error: Could not change to directory: "),
+ //Alert::err_alert(_("Error: Could not change to directory: "),
// path);
}
} else {
// 21 May 01 operator= fails if operand transitively owned by *this, as in a
// linked list (report by Ken Johnson, fix by Beman Dawes)
// 21 Jan 01 Suppress some useless warnings with MSVC (David Abrahams)
-// 19 Oct 00 Make shared_ptr ctor from auto_ptr explicit. (Robert Vugts)
+// 19 Oct 00 Make shared_ptr ctor from auto_ptr explicit. (Robert Vugts)
// 24 Jul 00 Change throw() to // never throws. See lib guidelines
// Exception-specification rationale. (Beman Dawes)
// 22 Jun 00 Remove #if continuations to fix GCC 2.95.2 problem (Beman Dawes)
explicit shared_c_ptr(T* p =0) : px(p) {
#ifndef LYX_NO_EXCEPTIONS
try { pn = new long(1); } // fix: prevent leak if new throws
- catch (...) { checked_delete(p); throw; }
+ catch (...) { checked_delete(p); throw; }
#else
pn = new long(1);
assert(pn != 0);
#if !defined(BOOST_NO_MEMBER_TEMPLATES)
template<typename Y>
- shared_c_ptr(const shared_c_ptr<Y>& r) : px(r.px) { // never throws
- ++*(pn = r.pn);
+ shared_c_ptr(const shared_c_ptr<Y>& r) : px(r.px) { // never throws
+ ++*(pn = r.pn);
}
#ifndef BOOST_NO_AUTO_PTR
template<typename Y>
- explicit shared_c_ptr(std::auto_ptr<Y>& r) {
- pn = new long(1); // may throw
- px = r.release(); // fix: moved here to stop leak if new throws
+ explicit shared_c_ptr(std::auto_ptr<Y>& r) {
+ pn = new long(1); // may throw
+ px = r.release(); // fix: moved here to stop leak if new throws
}
-#endif
+#endif
template<typename Y>
- shared_c_ptr& operator=(const shared_c_ptr<Y>& r) {
- share(r.px,r.pn);
- return *this;
+ shared_c_ptr& operator=(const shared_c_ptr<Y>& r) {
+ share(r.px,r.pn);
+ return *this;
}
#ifndef BOOST_NO_AUTO_PTR
template<typename Y>
shared_c_ptr& operator=(std::auto_ptr<Y>& r) {
- // code choice driven by guarantee of "no effect if new throws"
- if (*pn == 1) { checked_delete(px); }
- else { // allocate new reference counter
- long * tmp = new long(1); // may throw
- --*pn; // only decrement once danger of new throwing is past
- pn = tmp;
- } // allocate new reference counter
- px = r.release(); // fix: moved here so doesn't leak if new throws
- return *this;
+ // code choice driven by guarantee of "no effect if new throws"
+ if (*pn == 1) { checked_delete(px); }
+ else { // allocate new reference counter
+ long * tmp = new long(1); // may throw
+ --*pn; // only decrement once danger of new throwing is past
+ pn = tmp;
+ } // allocate new reference counter
+ px = r.release(); // fix: moved here so doesn't leak if new throws
+ return *this;
}
#endif
#else
#ifndef BOOST_NO_AUTO_PTR
- explicit shared_c_ptr(std::auto_ptr<T>& r) {
- pn = new long(1); // may throw
- px = r.release(); // fix: moved here to stop leak if new throws
- }
+ explicit shared_c_ptr(std::auto_ptr<T>& r) {
+ pn = new long(1); // may throw
+ px = r.release(); // fix: moved here to stop leak if new throws
+ }
shared_c_ptr& operator=(std::auto_ptr<T>& r) {
- // code choice driven by guarantee of "no effect if new throws"
- if (*pn == 1) { checked_delete(px); }
- else { // allocate new reference counter
- long * tmp = new long(1); // may throw
- --*pn; // only decrement once danger of new throwing is past
- pn = tmp;
- } // allocate new reference counter
- px = r.release(); // fix: moved here so doesn't leak if new throws
- return *this;
+ // code choice driven by guarantee of "no effect if new throws"
+ if (*pn == 1) { checked_delete(px); }
+ else { // allocate new reference counter
+ long * tmp = new long(1); // may throw
+ --*pn; // only decrement once danger of new throwing is past
+ pn = tmp;
+ } // allocate new reference counter
+ px = r.release(); // fix: moved here so doesn't leak if new throws
+ return *this;
}
#endif
#endif
if (px == p) return; // fix: self-assignment safe
if (--*pn == 0) { checked_delete(px); }
else { // allocate new reference counter
-#ifndef LYX_NO_EXCEPTIONS
- try { pn = new long; } // fix: prevent leak if new throws
- catch (...) {
- ++*pn; // undo effect of --*pn above to meet effects guarantee
- checked_delete(p);
- throw;
- } // catch
+#ifndef LYX_NO_EXCEPTIONS
+ try { pn = new long; } // fix: prevent leak if new throws
+ catch (...) {
+ ++*pn; // undo effect of --*pn above to meet effects guarantee
+ checked_delete(p);
+ throw;
+ } // catch
#else
pn = new long;
assert(pn != 0);
void share(T* rpx, long* rpn) {
if (pn != rpn) { // Q: why not px != rpx? A: fails when both == 0
- ++*rpn; // done before dispose() in case rpn transitively
- // dependent on *this (bug reported by Ken Johnson)
- dispose();
- px = rpx;
- pn = rpn;
+ ++*rpn; // done before dispose() in case rpn transitively
+ // dependent on *this (bug reported by Ken Johnson)
+ dispose();
+ px = rpx;
+ pn = rpn;
}
} // share
}; // shared_ptr
: binary_function<lyx::shared_c_ptr<T>, lyx::shared_c_ptr<T>, bool>
{
bool operator()(const lyx::shared_c_ptr<T>& a,
- const lyx::shared_c_ptr<T>& b) const
+ const lyx::shared_c_ptr<T>& b) const
{ return less<T*>()(a.get(),b.get()); }
};
#endif // ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
#endif // LYX_SMART_PTR_H
-
-
#ifdef __cplusplus
extern "C" {
#endif
-
+
#if defined(HAVE_DECL_SNPRINTF) || defined(HAVE_DECL_VSNPRINTF)
#include <stdio.h>
#endif
#ifdef __cplusplus
} /* end of extern "C" */
#endif
-
+
#endif
streambuf(which), buf(), mode(static_cast<ios::open_mode>(which)),
rpos(0), bufsize(1)
{ }
-
+
explicit stringbuf(const string &s, int which=ios::in|ios::out) :
streambuf(which), buf(s), mode(static_cast<ios::open_mode>(which)),
bufsize(1)
}
rpos = (mode & ios::ate ? s.size() : 0);
}
-
+
string str() const
{
const_cast<stringbuf*>(this)->sync(); // Sigh, really ugly hack
clear();
static_cast<stringbuf*>(_strbuf)->str(s);
}
-
+
stringbuf* rdbuf()
{
return &__my_sb;
{
init (&__my_sb);
}
-
+
stringstreambase(const string& s, int which) :
__my_sb(s, which)
{
init (&__my_sb);
}
};
-
+
class istringstream : public stringstreambase, public istream {
public:
istringstream(int which=ios::in) :
stringstreambase(which)
{ }
-
+
istringstream(const string& s, int which=ios::in) :
stringstreambase(s, which)
{ }
};
-
+
class ostringstream : public stringstreambase, public ostream {
public:
ostringstream(int which=ios::out) :
stringstreambase(which)
{ }
-
+
ostringstream(const string& s, int which=ios::out) :
stringstreambase(s, which)
{ }
};
-
+
class stringstream : public stringstreambase, public iostream {
public:
stringstream(int which=ios::in|ios::out) :
stringstreambase(which)
{ }
-
+
stringstream(const string &s, int which=ios::in|ios::out) :
stringstreambase(s, which)
{ }
if(ch != EOF)
{
string::size_type oldSize = buf.size();
-
+
buf.replace(rpos, string::npos, 1, ch);
if(buf.size() - oldSize != 1)
return EOF;
{
return EOF;
}
-
+
string::size_type n = egptr() - eback();
string::size_type s;
///
DontWait
};
-
+
#if 0
///
Systemcall() {}
/** Generate instance and start child process.
- * The string "what" contains a commandline with arguments separated
+ * The string "what" contains a commandline with arguments separated
* by spaces.
*/
Systemcall(Starttype how, string const & what);
#endif
-
+
/** Start child process.
- * The string "what" contains a commandline with arguments separated
+ * The string "what" contains a commandline with arguments separated
* by spaces.
*/
int startscript(Starttype how, string const & what);
namespace {
inline
-int make_tempfile(char * templ)
+int make_tempfile(char * templ)
{
#ifdef HAVE_MKSTEMP
return ::mkstemp(templ);
char * tmpl = new char[tmpfl.length() + 1]; // + 1 for '\0'
tmpfl.copy(tmpl, string::npos);
tmpl[tmpfl.length()] = '\0'; // terminator
-
+
int const tmpf = make_tempfile(tmpl);
if (tmpf != -1) {
string const t(tmpl);
// -*- C++ -*-
/* This file is part of
* ======================================================
- *
+ *
* LyX, The Document Processor
- *
+ *
* Copyright 1995 Matthias Ettrich
* Copyright 1995-2001 The LyX Team.
*
///
inline
bool IsKommaChar(char c) {
- return (c == ','
+ return (c == ','
|| c == '('
|| c == ')'
|| c == '['
|| c == '#'
|| c == '%'
|| c == '^'
- || c == '/'
+ || c == '/'
|| c == '\\'
|| c == Paragraph::META_NEWLINE
);
}
-/// Word is not IsSeparator or IsKomma or IsHfill or IsFloat or IsInset.
+/// Word is not IsSeparator or IsKomma or IsHfill or IsFloat or IsInset.
inline
bool IsWordChar(unsigned char c) {
return !(IsSeparatorChar(c)
// -*- C++ -*-
/* This file is part of
* =================================================
- *
+ *
* LyX, The Document Processor
* Copyright 1995 Matthias Ettrich.
* Copyright 1995-2001 The LyX Team.
/** This class template is used to translate between two elements, specifically
it was worked out to translate between an enum and strings when reading
the lyx file.
-
+
The two template arguments should be of different types.
*/
template<typename T1, typename T2>
typedef std::pair<T1, T2> MapPair;
///
typedef std::vector<MapPair> Map;
-
+
///
- Translator(T1 const & t1, T2 const & t2)
- : default_t1(t1), default_t2(t2)
+ Translator(T1 const & t1, T2 const & t2)
+ : default_t1(t1), default_t2(t2)
{}
-
+
/// Add a mapping to the translator.
void addPair(T1 const & first, T2 const & second) {
map.push_back(MapPair(first, second));
}
-
+
/// Find the mapping for the first argument
T2 const & find(T1 const & first) const {
lyx::Assert(!map.empty());
-
+
// For explanation see the next find() function.
Map::const_iterator it =
std::find_if(map.begin(), map.end(),
lyx::equal_1st_in_pair<MapPair>(first)
);
-
+
if (it != map.end()) {
return it->second;
} else {
return default_t2;
}
}
-
+
/// Find the mapping for the second argument
T1 const & find(T2 const & second) const {
lyx::Assert(!map.empty());
-
+
// The idea is as follows:
// find_if() will try to compare the data in the vector with
// the value. The vector is made of pairs and the value has
- // the type of the second part of the pair.
+ // the type of the second part of the pair.
// We thus give find_if() an equal_to functor and assign to
// its second post the value we want to compare. We now
// compose the equal_to functor with the select2nd functor
std::find_if(map.begin(), map.end(),
lyx::equal_2nd_in_pair<MapPair>(second)
);
-
+
if (it != map.end())
return it->first;
else {
private:
base_type data_;
};
-
+
#endif
// Revision History
// 21 May 01 checked_delete() and checked_array_delete() added (Beman Dawes,
// suggested by Dave Abrahams, generalizing idea from Vladimir Prus)
-// 21 May 01 made next() and prior() inline (Beman Dawes)
+// 21 May 01 made next() and prior() inline (Beman Dawes)
// 26 Jan 00 protected noncopyable destructor added (Miki Jovanovic)
// 10 Dec 99 next() and prior() templates added (Dave Abrahams)
// 30 Aug 99 moved cast templates to cast.hpp (Beman Dawes)
// 3 Aug 99 cast templates added
-// 20 Jul 99 name changed to utility.hpp
+// 20 Jul 99 name changed to utility.hpp
// 9 Jun 99 protected noncopyable default ctor
// 2 Jun 99 Initial Version. Class noncopyable only contents (Dave Abrahams)
#ifndef LYX_UTILITY_H
#define LYX_UTILITY_H
-#include <boost/config.hpp> // broken compiler workarounds
-#include <boost/static_assert.hpp>
+#include <boost/config.hpp> // broken compiler workarounds
+#include <boost/static_assert.hpp>
//#include <cstddef> // for size_t
//#include <utility> // for std::pair
template< typename T >
inline void checked_delete(T * x)
{
- BOOST_STATIC_ASSERT( sizeof(T) != 0 ); // assert type complete at point
- // of instantiation
- free(x);
+ BOOST_STATIC_ASSERT( sizeof(T) != 0 ); // assert type complete at point
+ // of instantiation
+ free(x);
}
} // namespace boost
#endif // BOOST_UTILITY_HPP
-