Hello,
This is the continuation of my ErrorList work.
This patch creates a error_lists map member inside the Buffer class.
Sorry Lars, I had no choice but to use string for the map key. This is
because the only information that could be passed to the controller is a
string.
With this new architecture, persistent error lists are now possible.
If there's no objection I will commit tomorrow.
Abdel.
Log:
* Buffer
- errorList_, addError(), : deleted
- std::map<std::string, ErrorList> errorLists_ : new member
- errorList(std::string const & type): associated accessors
* buffer_funcs.C
- bufferErrors(Buffer const & buf, TeXErrors const & terr): now needs
a third errorList argument
- bufferErrors(Buffer const & buf, ErrorList const & el): deleted.
* Converter
- convert(): now needs an ErrorList argument instead of filling the
Buffer errorList member directly.
- runLaTeX(): ditto
- scanLog(): ditto
* CutAndPaste.C
- pasteParagraphList(): ditto
- pasteSelection(): ditto
* text.C
- readParagraph(): ditto
- LyXText::read(): ditto
Index: buffer.C
===================================================================
--- buffer.C (revision 14623)
+++ buffer.C (working copy)
@@ -22,6 +22,7 @@
#include "Chktex.h"
#include "debug.h"
#include "encoding.h"
+#include "errorlist.h"
#include "exporter.h"
#include "format.h"
#include "funcrequest.h"
@@ -416,6 +417,8 @@
params().headsep.erase();
params().footskip.erase();
+ ErrorList & errorList = errorLists_["Parse"];
+
while (lex.isOK()) {
lex.next();
string const token = lex.getString();
@@ -445,14 +448,14 @@
"%1$s %2$s\n"),
token,
lex.getString());
- errorList_.push_back(ErrorItem(_("Document
header error"),
+ errorList.push_back(ErrorItem(_("Document
header error"),
s, -1, 0, 0));
}
}
}
if (begin_header_line) {
string const s = _("\\begin_header is missing");
- errorList_.push_back(ErrorItem(_("Document header error"),
+ errorList.push_back(ErrorItem(_("Document header error"),
s, -1, 0, 0));
}
@@ -465,13 +468,14 @@
// Returns false if "\end_document" is not read (Asger)
bool Buffer::readDocument(LyXLex & lex)
{
- errorList_.clear();
+ ErrorList & errorList = errorLists_["Parse"];
+ errorList.clear();
lex.next();
string const token = lex.getString();
if (token != "\\begin_document") {
string const s = _("\\begin_document is missing");
- errorList_.push_back(ErrorItem(_("Document header error"),
+ errorList.push_back(ErrorItem(_("Document header error"),
s, -1, 0, 0));
}
@@ -487,22 +491,12 @@
params().textclass = 0;
}
- bool const res = text().read(*this, lex);
+ bool const res = text().read(*this, lex, errorList);
for_each(text().paragraphs().begin(),
text().paragraphs().end(),
bind(&Paragraph::setInsetOwner, _1, &inset()));
updateBibfilesCache();
- // FIXME: the signal emission below is not needed for now because
- // there is a manual call to "LyXView::showErrorList(_("Parse"))"
- // in BufferView::pimpl::loadLyXFile()
- // Eventually, all manual call to "LyXView::showErrorList()" should
- // be replace with this signal emission.
- //
- // Send the "errors" signal in case of parsing errors
- //if (!errorList_.empty())
- // errors(_("Parse"));
-
return res;
}
@@ -1175,12 +1169,14 @@
Alert::error(_("chktex failure"),
_("Could not run chktex successfully."));
} else if (res > 0) {
- // Insert all errors as errors boxes
- bufferErrors(*this, terr);
+ // Fill-in the error list with the TeX errors
+ bufferErrors(*this, terr, errorLists_["ChkTex"]);
}
busy(false);
+ errors("ChkTeX");
+
return res;
}
@@ -1703,19 +1699,23 @@
}
-ErrorList const & Buffer::getErrorList() const
+ErrorList const & Buffer::errorList(string const type) const
{
- return errorList_;
+ std::map<std::string, ErrorList>::const_iterator I =
errorLists_.find(type);
+ if (I == errorLists_.end())
+ return emptyErrorList_;
+
+ return I->second;
}
-void Buffer::setErrorList(ErrorList const & errorList) const
+ErrorList & Buffer::errorList(string const type)
{
- errorList_ = errorList;
-}
+ std::map<std::string, ErrorList>::iterator I = errorLists_.find(type);
+ if (I == errorLists_.end()) {
+ errorLists_[type] = emptyErrorList_;
+ return errorLists_[type];
+ }
-
-void Buffer::addError(ErrorItem const & errorItem) const
-{
- errorList_.push_back(errorItem);
+ return I->second;
}
Index: buffer.h
===================================================================
--- buffer.h (revision 14623)
+++ buffer.h (working copy)
@@ -357,20 +357,11 @@
/// including preamble
void getSourceCode(std::ostream & os, lyx::pit_type par_begin,
lyx::pit_type par_end, bool full_source);
- /// errorList_ accessor.
- ErrorList const & getErrorList() const;
- /// replace the internal errorList_
- /** FIXME: This method is const for now because the ErrorList GUI
- * showing mechanism is used by other classes in order to show their
- * own processing errors (ex: Converter.C).
- */
- void setErrorList(ErrorList const &) const;
- /// add an error to the errorList_
- /** FIXME: This method is const for now because the ErrorList GUI
- * showing mechanism is used by other classes in order to show their
- * own processing errors (ex: Converter.C).
- */
- void addError(ErrorItem const &) const;
+ /// errorLists_ accessors.
+ //@{
+ ErrorList const & errorList(std::string const type) const;
+ ErrorList & errorList(std::string const type);
+ //@}
private:
/** Inserts a file into a document
@@ -394,12 +385,11 @@
/// documents), needed for appropriate update of natbib labels.
std::vector<std::string> bibfilesCache_;
- /// An error list (replaces the error insets)
- /** FIXME: This member is mutable for now because the ErrorList GUI
- * showing mechanism is used by other classes in order to show their
- * own processing errors (ex: Converter.C).
- */
- mutable ErrorList errorList_;
+ /// Container for all sort of Buffer dependant errors.
+ std::map<std::string, ErrorList> errorLists_;
+
+ /// Empty Error List
+ ErrorList const emptyErrorList_;
};
#endif
Index: buffer_funcs.C
===================================================================
--- buffer_funcs.C (revision 14623)
+++ buffer_funcs.C (working copy)
@@ -212,7 +212,8 @@
}
-void bufferErrors(Buffer const & buf, TeXErrors const & terr)
+void bufferErrors(Buffer const & buf, TeXErrors const & terr,
+ ErrorList & errorList)
{
TeXErrors::Errors::const_iterator cit = terr.begin();
TeXErrors::Errors::const_iterator end = terr.end();
@@ -231,18 +232,12 @@
pos_end);
} while (found && id_start == id_end && pos_start == pos_end);
- buf.addError(ErrorItem(cit->error_desc,
+ errorList.push_back(ErrorItem(cit->error_desc,
cit->error_text, id_start, pos_start, pos_end));
}
}
-void bufferErrors(Buffer const & buf, ErrorList const & el)
-{
- buf.setErrorList(el);
-}
-
-
string const bufferFormat(Buffer const & buffer)
{
if (buffer.isLinuxDoc())
Index: buffer_funcs.h
===================================================================
--- buffer_funcs.h (revision 14623)
+++ buffer_funcs.h (working copy)
@@ -37,11 +37,10 @@
///return the format of the buffer on a string
std::string const bufferFormat(Buffer const & buffer);
-///
-void bufferErrors(Buffer const &, TeXErrors const &);
-///
-void bufferErrors(Buffer const &, ErrorList const &);
+/// Fill in the ErrorList with the TeXErrors
+void bufferErrors(Buffer const &, TeXErrors const &, ErrorList &);
+
/// Count the number of words in the text between these two iterators
int countWords(DocIterator const & from, DocIterator const & to);
Index: BufferView_pimpl.C
===================================================================
--- BufferView_pimpl.C (revision 14623)
+++ BufferView_pimpl.C (working copy)
@@ -28,6 +28,7 @@
#include "CutAndPaste.h"
#include "debug.h"
#include "dispatchresult.h"
+#include "errorlist.h"
#include "factory.h"
#include "FloatList.h"
#include "funcrequest.h"
@@ -198,7 +199,8 @@
}
setBuffer(b);
- owner_->showErrorList(_("Parse"));
+ // Send the "errors" signal in case of parsing errors
+ b->errors("Parse");
// scroll to the position when the file was last closed
if (lyxrc.use_lastfilepos) {
@@ -789,17 +791,18 @@
string res;
Buffer buf("", false);
- // FIXME: is there a need for something like that?
- //buf.errors.connect(boost::bind(&LyXView::showErrorList, owner_, _1));
if (::loadLyXFile(&buf, makeAbsPath(filename))) {
+ ErrorList & el = buffer_->errorList("Parse");
+ // Copy the inserted document error list into the current
buffer one.
+ el = buf.errorList("Parse");
lyx::cap::pasteParagraphList(cursor_, buf.paragraphs(),
- buf.params().textclass);
+ buf.params().textclass, el);
res = _("Document %1$s inserted.");
} else
res = _("Could not insert document %1$s");
owner_->message(bformat(res, disp_fn));
- owner_->showErrorList(_("Document insertion"));
+ buffer_->errors("Parse");
resizeCurrentBuffer();
}
Index: converter.C
===================================================================
--- converter.C (revision 14623)
+++ converter.C (working copy)
@@ -282,7 +282,7 @@
bool Converters::convert(Buffer const * buffer,
string const & from_file, string const & to_file_base,
string const & from_format, string const & to_format,
- string & to_file, bool try_default)
+ string & to_file, ErrorList & errorList, bool
try_default)
{
string const to_ext = formats.extension(to_format);
to_file = changeExtension(to_file_base, to_ext);
@@ -326,6 +326,8 @@
runparams.flavor = getFlavor(edgepath);
string path = onlyPath(from_file);
Path p(path);
+ // empty the error list before any new conversion takes place.
+ errorList.clear();
bool run_latex = false;
string from_base = changeExtension(from_file, "");
@@ -359,7 +361,7 @@
run_latex = true;
string const command = subst(conv.command, token_from,
"");
lyxerr[Debug::FILES] << "Running " << command << endl;
- if (!runLaTeX(*buffer, command, runparams))
+ if (!runLaTeX(*buffer, command, runparams, errorList))
return false;
} else {
if (conv.need_aux && !run_latex
@@ -367,7 +369,7 @@
lyxerr[Debug::FILES]
<< "Running " << latex_command_
<< " to update aux file"<< endl;
- runLaTeX(*buffer, latex_command_, runparams);
+ runLaTeX(*buffer, latex_command_, runparams,
errorList);
}
string const infile2 = (conv.original_dir)
@@ -427,7 +429,7 @@
" < " + quoteName(infile2 + ".out") +
" > " + quoteName(logfile);
one.startscript(Systemcall::Wait, command2);
- if (!scanLog(*buffer, command, logfile))
+ if (!scanLog(*buffer, command, logfile,
errorList))
return false;
}
@@ -516,11 +518,11 @@
bool Converters::convert(Buffer const * buffer,
string const & from_file, string const & to_file_base,
string const & from_format, string const & to_format,
- bool try_default)
+ ErrorList & errorList, bool try_default)
{
string to_file;
return convert(buffer, from_file, to_file_base, from_format, to_format,
- to_file, try_default);
+ to_file, errorList, try_default);
}
@@ -537,7 +539,7 @@
bool Converters::scanLog(Buffer const & buffer, string const & /*command*/,
- string const & filename)
+ string const & filename, ErrorList & errorList)
{
OutputParams runparams;
runparams.flavor = OutputParams::LATEX;
@@ -546,7 +548,7 @@
int const result = latex.scanLogFile(terr);
if (result & LaTeX::ERRORS)
- bufferErrors(buffer, terr);
+ bufferErrors(buffer, terr, errorList);
return true;
}
@@ -569,7 +571,7 @@
bool Converters::runLaTeX(Buffer const & buffer, string const & command,
- OutputParams const & runparams)
+ OutputParams const & runparams, ErrorList & errorList)
{
buffer.busy(true);
buffer.message(_("Running LaTeX..."));
@@ -585,7 +587,7 @@
int const result = latex.run(terr);
if (result & LaTeX::ERRORS)
- bufferErrors(buffer, terr);
+ bufferErrors(buffer, terr, errorList);
// check return value from latex.run().
if ((result & LaTeX::NO_LOGFILE)) {
Index: converter.h
===================================================================
--- converter.h (revision 14623)
+++ converter.h (working copy)
@@ -20,6 +20,7 @@
class Buffer;
+class ErrorList;
class Format;
class Formats;
class OutputParams;
@@ -107,12 +108,13 @@
bool convert(Buffer const * buffer,
std::string const & from_file, std::string const &
to_file_base,
std::string const & from_format, std::string const &
to_format,
- std::string & to_file, bool try_default = false);
+ std::string & to_file, ErrorList & errorList,
+ bool try_default = false);
///
bool convert(Buffer const * buffer,
std::string const & from_file, std::string const &
to_file_base,
std::string const & from_format, std::string const &
to_format,
- bool try_default = false);
+ ErrorList & errorList, bool try_default = false);
///
void update(Formats const & formats);
///
@@ -134,10 +136,10 @@
intToFormat(std::vector<int> const & input);
///
bool scanLog(Buffer const & buffer, std::string const & command,
- std::string const & filename);
+ std::string const & filename, ErrorList & errorList);
///
bool runLaTeX(Buffer const & buffer, std::string const & command,
- OutputParams const &);
+ OutputParams const &, ErrorList & errorList);
///
ConverterList converterlist_;
///
Index: CutAndPaste.C
===================================================================
--- CutAndPaste.C (revision 14623)
+++ CutAndPaste.C (working copy)
@@ -612,7 +612,7 @@
void pasteParagraphList(LCursor & cur, ParagraphList const & parlist,
- textclass_type textclass)
+ textclass_type textclass, ErrorList & errorList)
{
if (cur.inTexted()) {
LyXText * text = cur.text();
@@ -622,15 +622,13 @@
pit_type endpit;
PitPosPair ppp;
- ErrorList el;
boost::tie(ppp, endpit) =
pasteSelectionHelper(cur.buffer(),
text->paragraphs(),
cur.pit(), cur.pos(),
parlist, textclass,
- el);
- bufferErrors(cur.buffer(), el);
+ errorList);
updateLabels(cur.buffer());
cur.clearSelection();
text->setCursor(cur, ppp.first, ppp.second);
@@ -641,15 +639,14 @@
}
-void pasteSelection(LCursor & cur, size_t sel_index)
+void pasteSelection(LCursor & cur, ErrorList & errorList, size_t sel_index)
{
// this does not make sense, if there is nothing to paste
if (!checkPastePossible(sel_index))
return;
pasteParagraphList(cur, theCuts[sel_index].first,
- theCuts[sel_index].second);
- cur.bv().owner()->showErrorList(_("Paste"));
+ theCuts[sel_index].second, errorList);
cur.setSelection();
}
Index: CutAndPaste.h
===================================================================
--- CutAndPaste.h (revision 14623)
+++ CutAndPaste.h (working copy)
@@ -56,11 +56,11 @@
///
void copySelection(LCursor & cur);
///
-void pasteSelection(LCursor & cur, size_t sel_index = 0);
+void pasteSelection(LCursor & cur, ErrorList &, size_t sel_index = 0);
///
void pasteParagraphList(LCursor & cur, ParagraphList const & parlist,
- textclass_type textclass);
+ textclass_type textclass, ErrorList & errorList);
/** Needed to switch between different classes. This works
Index: exporter.C
===================================================================
--- exporter.C (revision 14623)
+++ exporter.C (working copy)
@@ -215,8 +215,13 @@
buffer->makeLaTeXFile(filename, buffer->filePath(), runparams);
}
- if (!converters.convert(buffer, filename, filename,
- backend_format, format, result_file))
+ string const error_type = (format == "program")? "Build" :
bufferFormat(*buffer);
+ bool const success = converters.convert(buffer, filename, filename,
+ backend_format, format, result_file,
+ buffer->errorList(error_type));
+ // Emit the signal to show the error list.
+ buffer->errors(error_type);
+ if (!success)
return false;
if (!put_in_tempdir) {
Index: frontends/controllers/ControlErrorList.C
===================================================================
--- frontends/controllers/ControlErrorList.C (revision 14623)
+++ frontends/controllers/ControlErrorList.C (working copy)
@@ -14,10 +14,15 @@
#include "buffer.h"
#include "BufferView.h"
#include "debug.h"
+#include "gettext.h"
#include "lyxtext.h"
#include "paragraph.h"
#include "pariterator.h"
+#include "support/lstrings.h"
+
+using lyx::support::bformat;
+
using std::endl;
using std::string;
@@ -39,10 +44,13 @@
}
-bool ControlErrorList::initialiseParams(string const & name)
+bool ControlErrorList::initialiseParams(string const & error_type)
{
- errorlist_ = kernel().bufferview()->buffer()->getErrorList();
- name_ = name;
+ Buffer * buf = kernel().bufferview()->buffer();
+ string const title = bformat(_("%1$s Errors (%2$s)"),
+ _(error_type), buf->fileName());
+ errorlist_ = buf->errorList(error_type);
+ name_ = title;
return true;
}
Index: frontends/LyXView.C
===================================================================
--- frontends/LyXView.C (revision 14623)
+++ frontends/LyXView.C (working copy)
@@ -25,6 +25,7 @@
#include "bufferview_funcs.h"
#include "cursor.h"
#include "debug.h"
+#include "errorlist.h"
#include "funcrequest.h"
#include "gettext.h"
#include "intl.h"
@@ -152,6 +153,8 @@
disconnectBuffer();
bool loaded = work_area_->bufferView().loadLyXFile(filename,
tolastfiles);
+ showErrorList("Parse");
+
updateMenubar();
updateToolbars();
updateLayoutChoice();
@@ -170,11 +173,6 @@
if (errorsConnection_.connected())
disconnectBuffer();
- // FIXME: (Abdel 15/07/2006) The connection below is not used for
- // now.
- // Nevertheless, it would be a very good idea to replace all manual
- // calls of showErrorList to a call of the new modified
- // "Buffer::errors" boost signal.
errorsConnection_ =
buf.errors.connect(
boost::bind(&LyXView::showErrorList, this, _1));
@@ -216,13 +214,11 @@
}
-void LyXView::showErrorList(string const & action)
+void LyXView::showErrorList(string const & error_type)
{
- Buffer * b = work_area_->bufferView().buffer();
- if (!b->getErrorList().empty()) {
- string const title = bformat(_("%1$s Errors (%2$s)"),
- action, buffer()->fileName());
- getDialogs().show("errorlist", title);
+ ErrorList & el = buffer()->errorList(error_type);
+ if (!el.empty()) {
+ getDialogs().show("errorlist", error_type);
}
}
Index: importer.C
===================================================================
--- importer.C (revision 14623)
+++ importer.C (working copy)
@@ -39,7 +39,7 @@
bool Importer::Import(LyXView * lv, string const & filename,
- string const & format)
+ string const & format, ErrorList & errorList)
{
string const displaypath = makeDisplayPath(filename);
lv->message(bformat(_("Importing %1$s..."), displaypath));
@@ -53,7 +53,7 @@
it != loaders.end(); ++it) {
if (converters.isReachable(format, *it)) {
if (!converters.convert(0, filename, filename,
- format, *it))
+ format, *it, errorList))
return false;
loader_format = *it;
break;
Index: importer.h
===================================================================
--- importer.h (revision 14623)
+++ importer.h (working copy)
@@ -19,6 +19,7 @@
class LyXView;
+class ErrorList;
class Format;
class Importer {
@@ -26,7 +27,7 @@
///
static
bool Import(LyXView * lv, std::string const & filename,
- std::string const & format);
+ std::string const & format, ErrorList & errorList);
///
static
Index: insets/ExternalSupport.C
===================================================================
--- insets/ExternalSupport.C (revision 14623)
+++ insets/ExternalSupport.C (working copy)
@@ -313,9 +313,12 @@
return; // SUCCESS
string const to_file_base =
support::changeExtension(to_file, string());
+
+ // FIXME (Abdel 12/08/06): Is there a need to show these errors?
+ ErrorList el;
/* bool const success = */
converters.convert(&buffer, temp_file, to_file_base,
- from_format, to_format, true);
+ from_format, to_format, el, true);
// return success
}
Index: insets/insetgraphics.C
===================================================================
--- insets/insetgraphics.C (revision 14623)
+++ insets/insetgraphics.C (working copy)
@@ -720,7 +720,9 @@
<< "\tfile to convert = " << temp_file << '\n'
<< "\t from " << from << " to " << to << '\n';
- if (converters.convert(&buf, temp_file, temp_file, from, to, true)) {
+ // FIXME (Abdel 12/08/06): Is there a need to show these errors?
+ ErrorList el;
+ if (converters.convert(&buf, temp_file, temp_file, from, to, el, true))
{
runparams.exportdata->addExternalFile(tex_format,
to_file, output_to_file);
runparams.exportdata->addExternalFile("dvi",
Index: insets/insettext.C
===================================================================
--- insets/insettext.C (revision 14623)
+++ insets/insettext.C (working copy)
@@ -163,7 +163,8 @@
// delete the initial paragraph
Paragraph oldpar = *paragraphs().begin();
paragraphs().clear();
- bool res = text_.read(buf, lex);
+ ErrorList errorList;
+ bool res = text_.read(buf, lex, errorList);
init();
if (!res) {
Index: lyx_main.C
===================================================================
--- lyx_main.C (revision 14623)
+++ lyx_main.C (working copy)
@@ -280,21 +280,21 @@
last_loaded = b;
} else {
Buffer * buf = bufferlist.newBuffer(s, false);
- if (loadLyXFile(buf, s))
+ if (loadLyXFile(buf, s)) {
last_loaded = buf;
+ ErrorList const & el =
buf->errorList("Parse");
+ if (!el.empty()) {
+ // There should be a way to use
the following but I (abdel) don't know
+ // how to make it compile on
MSVC2005.
+ //for_each(el.begin(),
el.end(), mem_fun_ref(&LyX::printError));
+ for (ErrorList::const_iterator
it = el.begin();
+ it != el.end(); ++it) {
+ printError(*it);
+ }
+ }
+ }
else
bufferlist.release(buf);
-
- ErrorList const & el = buf->getErrorList();
- if (!el.empty()) {
- // There should be a way to use the
following but I (abdel) don't know
- // how to make it compile on MSVC2005.
- //for_each(el.begin(), el.end(),
mem_fun_ref(&LyX::printError));
- for (ErrorList::const_iterator it =
el.begin();
- it != el.end(); ++it) {
- printError(*it);
- }
- }
}
}
Index: lyxfunc.C
===================================================================
--- lyxfunc.C (revision 14623)
+++ lyxfunc.C (working copy)
@@ -837,22 +837,18 @@
case LFUN_BUFFER_UPDATE:
Exporter::Export(owner->buffer(), argument, true);
- owner->showErrorList(bufferFormat(*owner->buffer()));
break;
case LFUN_BUFFER_VIEW:
Exporter::preview(owner->buffer(), argument);
- owner->showErrorList(bufferFormat(*owner->buffer()));
break;
case LFUN_BUILD_PROGRAM:
Exporter::Export(owner->buffer(), "program", true);
- owner->showErrorList(_("Build"));
break;
case LFUN_BUFFER_CHKTEX:
owner->buffer()->runChktex();
- owner->showErrorList(_("ChkTeX"));
break;
case LFUN_BUFFER_EXPORT:
@@ -860,7 +856,6 @@
owner->getDialogs().show("sendto");
else {
Exporter::Export(owner->buffer(), argument,
false);
-
owner->showErrorList(bufferFormat(*owner->buffer()));
}
break;
@@ -892,8 +887,7 @@
break;
} else {
- Exporter::Export(buffer, format_name, true,
- filename);
+ Exporter::Export(buffer, format_name, true,
filename);
}
// Substitute $$FName for filename
@@ -1555,14 +1549,14 @@
recordUndoFullDocument(view());
buffer->params().textclass = new_class;
StableDocIterator backcur(view()->cursor());
- ErrorList el;
+ ErrorList & el = buffer->errorList("Class Switch");
lyx::cap::switchBetweenClasses(
old_class, new_class,
static_cast<InsetText &>(buffer->inset()), el);
view()->setCursor(backcur.asDocIterator(&(buffer->inset())));
- bufferErrors(*buffer, el);
- owner->showErrorList(_("Class switch"));
+
+ buffer->errors("Class Switch");
updateLabels(*buffer);
updateforce = true;
break;
@@ -1889,7 +1883,9 @@
}
}
- Importer::Import(owner, filename, format);
+ ErrorList errorList;
+ Importer::Import(owner, filename, format, errorList);
+ // FIXME (Abdel 12/08/06): Is there a need to display the error list
here?
}
Index: lyxtext.h
===================================================================
--- lyxtext.h (revision 14623)
+++ lyxtext.h (working copy)
@@ -30,6 +30,7 @@
class BufferView;
class CursorSlice;
class Dimension;
+class ErrorList;
class InsetBase;
class InsetBase_code;
class FuncRequest;
@@ -320,7 +321,7 @@
///
void write(Buffer const & buf, std::ostream & os) const;
/// returns whether we've seen our usual 'end' marker
- bool read(Buffer const & buf, LyXLex & lex);
+ bool read(Buffer const & buf, LyXLex & lex, ErrorList & errorList);
///
int ascent() const;
Index: text.C
===================================================================
--- text.C (revision 14623)
+++ text.C (working copy)
@@ -156,7 +156,7 @@
void readParToken(Buffer const & buf, Paragraph & par, LyXLex & lex,
- string const & token, LyXFont & font, Change & change)
+ string const & token, LyXFont & font, Change & change, ErrorList &
errorList)
{
BufferParams const & bp = buf.params();
@@ -180,7 +180,7 @@
bool hasLayout = tclass.hasLayout(layoutname);
if (!hasLayout) {
- buf.addError(ErrorItem(_("Unknown layout"),
+ errorList.push_back(ErrorItem(_("Unknown layout"),
bformat(_("Layout '%1$s' does not exist in textclass
'%2$s'\nTrying to use the default instead.\n"),
layoutname, tclass.name()), par.id(), 0,
par.size()));
layoutname = tclass.defaultLayoutName();
@@ -212,7 +212,7 @@
else {
lex.eatLine();
string line = lex.getString();
- buf.addError(ErrorItem(_("Unknown Inset"), line,
+ errorList.push_back(ErrorItem(_("Unknown Inset"), line,
par.id(), 0, par.size()));
}
} else if (token == "\\family") {
@@ -329,7 +329,7 @@
lyx::time_type ct;
is >> aid >> ct;
if (aid >= bp.author_map.size()) {
- buf.addError(ErrorItem(_("Change tracking error"),
+ errorList.push_back(ErrorItem(_("Change tracking
error"),
bformat(_("Unknown author index for
insertion: %1$d\n"), aid),
par.id(), 0, par.size()));
@@ -343,7 +343,7 @@
lyx::time_type ct;
is >> aid >> ct;
if (aid >= bp.author_map.size()) {
- buf.addError(ErrorItem(_("Change tracking error"),
+ errorList.push_back(ErrorItem(_("Change tracking
error"),
bformat(_("Unknown author index for
deletion: %1$d\n"), aid),
par.id(), 0, par.size()));
@@ -352,14 +352,14 @@
change = Change(Change::DELETED, bp.author_map[aid],
ct);
} else {
lex.eatLine();
- buf.addError(ErrorItem(_("Unknown token"),
+ errorList.push_back(ErrorItem(_("Unknown token"),
bformat(_("Unknown token: %1$s %2$s\n"), token,
lex.getString()),
par.id(), 0, par.size()));
}
}
-void readParagraph(Buffer const & buf, Paragraph & par, LyXLex & lex)
+void readParagraph(Buffer const & buf, Paragraph & par, LyXLex & lex,
ErrorList & errorList)
{
lex.nextToken();
string token = lex.getString();
@@ -368,7 +368,7 @@
while (lex.isOK()) {
- readParToken(buf, par, lex, token, font, change);
+ readParToken(buf, par, lex, token, font, change, errorList);
lex.nextToken();
token = lex.getString();
@@ -2083,7 +2083,7 @@
}
-bool LyXText::read(Buffer const & buf, LyXLex & lex)
+bool LyXText::read(Buffer const & buf, LyXLex & lex, ErrorList & errorList)
{
Paragraph::depth_type depth = 0;
@@ -2122,7 +2122,7 @@
// FIXME: goddamn InsetTabular makes us pass a Buffer
// not BufferParams
- ::readParagraph(buf, pars_.back(), lex);
+ ::readParagraph(buf, pars_.back(), lex, errorList);
} else if (token == "\\begin_deeper") {
++depth;
Index: text3.C
===================================================================
--- text3.C (revision 14623)
+++ text3.C (working copy)
@@ -29,6 +29,7 @@
#include "CutAndPaste.h"
#include "debug.h"
#include "dispatchresult.h"
+#include "errorlist.h"
#include "factory.h"
#include "funcrequest.h"
#include "gettext.h"
@@ -731,7 +732,7 @@
cur.setSelection();
if (content) {
lyx::cap::replaceSelection(cur);
- pasteSelection(cur, 0);
+ pasteSelection(cur, bv->buffer()->errorList("Paste"),
0);
cur.clearSelection();
// restore position
cur.pit() = std::min(cur.lastpit(), spit);
@@ -797,9 +798,12 @@
cur.message(_("Paste"));
lyx::cap::replaceSelection(cur);
if (isStrUnsignedInt(cmd.argument))
- pasteSelection(cur, convert<unsigned
int>(cmd.argument));
+ pasteSelection(cur, bv->buffer()->errorList("Paste"),
+ convert<unsigned int>(cmd.argument));
else
- pasteSelection(cur, 0);
+ pasteSelection(cur, bv->buffer()->errorList("Paste"),
+ 0);
+ bv->buffer()->errors("Paste");
cur.clearSelection(); // bug 393
bv->switchKeyMap();
finishUndo();