#include "frontends/screen.h"
#include "insets/insetcommand.h" // ChangeRefs
-#include "insets/inseterror.h"
#include "insets/updatableinset.h"
#include "support/FileInfo.h"
}
-void BufferView::addError(ErrorItem const & ei)
-{
- pimpl_->errorlist_.push_back(ei);
-
-}
-
-
void BufferView::showErrorList(string const & action) const
{
if (getErrorList().size()) {
void resetErrorList();
/// stored this error list
void setErrorList(ErrorList const &);
- /// adds a single error to the list
- void addError(ErrorItem const &);
/// show the error list to the user
void showErrorList(string const &) const;
/// set the cursor based on the given TeX source row
}
+void BufferView::Pimpl::addError(ErrorItem const & ei)
+{
+ errorlist_.push_back(ei);
+
+}
+
bool BufferView::Pimpl::loadLyXFile(string const & filename, bool tolastfiles)
{
}
Buffer * b = bufferlist.newBuffer(s);
- //this is the point to attach to the error signal in the buffer
+ bv_->resetErrorList();
+ //attach to the error signal in the buffer
+ b->parseError.connect(boost::bind(&BufferView::Pimpl::addError,
+ this, _1));
- if (!::loadLyXFile(b, s)) {
+ bool loaded = true;
+
+ if (! ::loadLyXFile(b, s)) {
bufferlist.release(b);
string text = bformat(_("The document %1$s does "
"not yet exist.\n\n"
bufferlist.close(buffer_, false);
buffer(newFile(s, string(), true));
}
- }
+
+ loaded = false;
+ }
buffer(b);
if (tolastfiles)
lastfiles->newFile(b->fileName());
+ if (loaded)
+ bv_->showErrorList(_("Parse"));
+
return true;
}
private:
/// An error list (replaces the error insets)
ErrorList errorlist_;
+ /// add an error to the list
+ void addError(ErrorItem const &);
/// track changes for the document
void trackChanges();
-
+2003-06-21 Alfredo Braunstein <abraunst@libero.it>
+
+ * buffer.[Ch]: added the parseError signal and use it, removed
+ sgmlError
+ * BufferView.[Ch] (addError): moved to ...
+ * BufferView_pimpl.[Ch] (addError, loadLyXFile): ... here. Attach
+ to the Buffer::parseError signal to catch (guess what) parse errors
+ * lyx_main.[Ch] (printError,LyX): added gui-less parsing error feedback
+
2003-06-19 Alfredo Braunstein <abraunst@libero.it>
* bufferlist.[Ch] (loadLyXFile, readFile, newFile): removed the
#include "mathed/formulamacro.h"
#include "mathed/formula.h"
-#include "insets/inseterror.h"
#include "insets/insetbibitem.h"
#include "insets/insetbibtex.h"
#include "insets/insetinclude.h"
unknownClass(unknown);
} else {
++unknown_tokens;
+ string const s = bformat(_("Unknown token: "
+ "%1$s %2$s\n"),
+ token,
+ lex.getString());
+ parseError(ErrorItem(_("Header error"), s,
+ -1, 0, 0));
}
}
}
// Returns false if "\the_end" is not read (Asger)
bool Buffer::readBody(LyXLex & lex, ParagraphList::iterator pit)
{
- int unknown_tokens = 0;
-
Paragraph::depth_type depth = 0;
bool the_end_read = false;
if (paragraphs.empty()) {
- unknown_tokens += readHeader(lex);
-
if (!params.getLyXTextClass().load()) {
string theclass = params.getLyXTextClass().name();
Alert::error(_("Can't load document class"), bformat(
continue;
}
- unknown_tokens += readParagraph(lex, token, paragraphs, pit, depth);
- }
-
-
- if (unknown_tokens > 0) {
- string s;
- if (unknown_tokens == 1) {
- s = bformat(_("Encountered one unknown token when reading "
- "the document %1$s."), fileName());
- } else {
- s = bformat(_("Encountered %1$s unknown tokens when reading "
- "the document %2$s."), tostr(unknown_tokens), fileName());
- }
- Alert::warning(_("Document format failure"), s);
+ readParagraph(lex, token, paragraphs, pit, depth);
}
return the_end_read;
int Buffer::readParagraph(LyXLex & lex, string const & token,
- ParagraphList & pars, ParagraphList::iterator & pit,
- Paragraph::depth_type & depth)
+ ParagraphList & pars, ParagraphList::iterator & pit,
+ Paragraph::depth_type & depth)
{
static Change current_change;
int unknown = 0;
LyXFont f(LyXFont::ALL_INHERIT, params.language);
par.setFont(0, f);
- // FIXME: goddamn InsetTabular makes us pass a Buffer
- // not BufferParams
- unknown += ::readParagraph(*this, par, lex);
-
// insert after
if (pit != pars.end())
++pit;
+
pit = pars.insert(pit, par);
+
+ // FIXME: goddamn InsetTabular makes us pass a Buffer
+ // not BufferParams
+ ::readParagraph(*this, *pit, lex);
+
} else if (token == "\\begin_deeper") {
++depth;
} else if (token == "\\end_deeper") {
case LATEX_COMMAND:
if (depth != 0)
- sgmlError(pit, 0,
- _("Error: Wrong depth for LatexType Command.\n"));
+ parseError(ErrorItem(_("Error:"), _("Wrong depth for LatexType Command.\n"), pit->id(), 0, pit->size()));
if (!environment_stack[depth].empty()) {
sgml::closeTag(ofs, depth, false, environment_stack[depth]);
}
-// Print an error message.
-void Buffer::sgmlError(ParagraphList::iterator pit, int pos,
- string const & message) const
-{
- users->addError(ErrorItem(message, string(), pit->id(), pos, pos));
-}
-
-
void Buffer::makeDocBookFile(string const & fname, bool nice, bool only_body)
{
ofstream ofs(fname.c_str());
case LATEX_COMMAND:
if (depth != 0)
- sgmlError(par, 0,
- _("Error: Wrong depth for LatexType Command.\n"));
+ parseError(ErrorItem(_("Error"), _("Wrong depth for LatexType Command."), par->id(), 0, par->size()));
command_name = style->latexname();
if (res == -1) {
Alert::error(_("chktex failure"),
- _("Could not run chktex successfully."));
+ _("Could not run chktex successfully."));
} else if (res > 0) {
// Insert all errors as errors boxes
ErrorList el (*this, terr);
#include "ParagraphList.h"
#include "author.h"
#include "iterators.h"
+#include "errorlist.h"
#include <boost/scoped_ptr.hpp>
+#include <boost/signals/signal1.hpp>
class BufferView;
class LyXRC;
bool hasParWithID(int id) const;
public:
+ /// This signal is emitted when a parsing error shows up.
+ boost::signal1<void, ErrorItem> parseError;
+
/** Save file.
Takes care of auto-save files and backup file if requested.
Returns \c true if the save is successful, \c false otherwise.
///
void makeDocBookFile(string const & filename,
bool nice, bool only_body = false);
- ///
- void sgmlError(ParagraphList::iterator par, int pos, string const & message) const;
-
/// returns the main language for the buffer (document)
Language const * getLanguage() const;
/// get l10n translated to the buffers language
int par_id;
int pos_start;
int pos_end;
- ErrorItem(string const &, string const &,
- int, int, int);
+ ErrorItem(string const & error, string const & description,
+ int parid, int posstart, int posend);
ErrorItem();
};
+
+2003-06-21 Alfredo Braunstein <abraunst@libero.it>
+
+ * QDocumentDialog.C: header reordering to handle qt/boost "signals"
+ symbol clash
+
2003-06-20 Angus Leeming <leeming@lyx.org>
* QBibtexDialog.C (browsePressed): fix warning of comparison between
#include "QDocumentDialog.h"
#include "Qt2BC.h"
+
#include "language.h"
#include "helper_funcs.h" // getSecond()
#include "insets/insetquotes.h"
#include <vector>
+
using std::vector;
typedef Qt2CB<ControlDocument, Qt2DB<QDocumentDialog> > base_class;
*/
#include <config.h>
+
+#include "buffer.h" //*here* because of braindead qt headers's #define signals
+
#include "qt_helpers.h"
#include "ControlDocument.h"
#include "Spacing.h"
#include "support/lstrings.h"
#include "lyxrc.h"
-#include "buffer.h"
+
#include <qwidgetstack.h>
#include <qlistbox.h>
+2003-06-21 Alfredo Braunstein <abraunst@libero.it>
+
+ * insetinclude.C (docbook): use parseError instead of sgmlError
+
2003-06-19 Alfredo Braunstein <abraunst@libero.it>
* insetinclude.C (loadIfNeeded): call ::loadLyXFile instead
#include "dimension.h"
#include "funcrequest.h"
#include "gettext.h"
+#include "errorlist.h"
#include "intl.h"
#include "LaTeXFeatures.h"
#include "LColor.h"
break;
case LATEX_COMMAND:
- buf->sgmlError(pit, 0, _("Error: LatexType Command not allowed here.\n"));
+ buf->parseError(ErrorItem(_("Error"), _("LatexType Command not allowed here.\n"), pit->id(), 0, pit->size()));
return -1;
break;
#include "frontends/lyx_gui.h"
#include <boost/function.hpp>
+#include <boost/bind.hpp>
+#include <boost/signals/signal1.hpp>
#include <cstdlib>
#include <csignal>
+#include <iostream>
using std::vector;
using std::endl;
vector<string>::iterator end = files.end();
for (; it != end; ++it) {
last_loaded = bufferlist.newBuffer(*it, false);
+ last_loaded->parseError.connect(boost::bind(&LyX::printError, this, _1));
loadLyXFile(last_loaded, *it);
}
}
+void LyX::printError(ErrorItem const & ei)
+{
+ std::cerr << _("LyX: ") << ei.error
+ << ':' << ei.description << std::endl;
+
+}
+
+
void LyX::init(bool gui)
{
signal(SIGHUP, error_handler);
#define LYX_MAIN_H
#include "LString.h"
+#include "errorlist.h"
#include <boost/scoped_ptr.hpp>
#include <boost/utility.hpp>
#include <csignal>
+
class LyXRC;
class LastFiles;
class Buffer;
void readEncodingsFile(string const & name);
/// parsing of non-gui LyX options. Returns true if gui
bool easyParse(int & argc, char * argv[]);
+ /// shows up a parsing error on screen
+ void printError(ErrorItem const &);
/// has this user started lyx for the first time?
bool first_start;
#include "insets/insetlatexaccent.h"
#include "insets/insettabular.h"
#include "insets/insethfill.h"
-#include "insets/inseterror.h"
#include "insets/insetnewline.h"
extern string bibitemWidest(Buffer const *);
lex.eatLine();
string const s = bformat(_("Unknown token: %1$s %2$s\n"),
token, lex.getString());
- // we can do this here this way because we're actually reading
- // the buffer and don't care about LyXText right now.
- par.insertInset(par.size(), new InsetError(s), font);
+
+ buf.parseError(ErrorItem(_("Unknown token"), s,
+ par.id(), 0, par.size()));
return 1;
}
return 0;