More errorlist adjustements.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7209 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Alfredo Braunstein 2003-06-24 20:42:15 +00:00
parent acc1409866
commit 3508b30871
16 changed files with 113 additions and 95 deletions

View File

@ -336,18 +336,6 @@ bool BufferView::insertLyXFile(string const & filen)
}
void BufferView::resetErrorList()
{
pimpl_->errorlist_.clear();
}
void BufferView::setErrorList(ErrorList const & el)
{
pimpl_->errorlist_ = el;
}
void BufferView::showErrorList(string const & action) const
{
if (getErrorList().size()) {
@ -361,6 +349,7 @@ ErrorList const &
BufferView::getErrorList() const
{
return pimpl_->errorlist_;
pimpl_->errorlist_.clear();
}

View File

@ -157,10 +157,6 @@ public:
/// get the stored error list
ErrorList const & getErrorList() const;
/// clears the stored error list
void resetErrorList();
/// stored this error list
void setErrorList(ErrorList const &);
/// show the error list to the user
void showErrorList(string const &) const;
/// set the cursor based on the given TeX source row

View File

@ -167,14 +167,13 @@ bool BufferView::Pimpl::loadLyXFile(string const & filename, bool tolastfiles)
}
Buffer * b = bufferlist.newBuffer(s);
bv_->resetErrorList();
//attach to the error signal in the buffer
b->parseError.connect(boost::bind(&BufferView::Pimpl::addError,
this, _1));
bool loaded = true;
bool loaded = ::loadLyXFile(b, s);
if (! ::loadLyXFile(b, s)) {
if (! loaded) {
bufferlist.release(b);
string text = bformat(_("The document %1$s does "
"not yet exist.\n\n"
@ -187,8 +186,6 @@ bool BufferView::Pimpl::loadLyXFile(string const & filename, bool tolastfiles)
bufferlist.close(buffer_, false);
buffer(newFile(s, string(), true));
}
loaded = false;
}
buffer(b);

View File

@ -1,3 +1,16 @@
2003-06-24 Alfredo Brauntein <abraunst@lyx.org>
* converter.C (scanLog, runLaTeX):
* buffer.C (makeLinuxDocFile, makeDocBookFile, runChkTeX):
move the bv->showErrorList call to the callers
* lyxfunc.C: i.e. here...
* text2.C: and here
* BufferView.[Ch] (setErrorList, resetErrorList): both removed
* exporter.[Ch] (Backends, BufferFormat): the first was moved to anon
namespace, the second to...
* buffer_funcs (BufferFormat, parseErrors): added
* errorlist.C (ErrorList(TeXErrors const &)): removed
2003-06-24 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
* ToolbarBackend.C (getIcon): complain when icon cannot be found

View File

@ -11,6 +11,7 @@
#include <config.h>
#include "buffer.h"
#include "buffer_funcs.h"
#include "bufferlist.h"
#include "LyXAction.h"
#include "lyxrc.h"
@ -1146,8 +1147,6 @@ void Buffer::makeLinuxDocFile(string const & fname, bool nice, bool body_only)
string item_name;
vector<string> environment_stack(5);
users->resetErrorList();
ParagraphList::iterator pit = paragraphs.begin();
ParagraphList::iterator pend = paragraphs.end();
for (; pit != pend; ++pit) {
@ -1276,8 +1275,6 @@ void Buffer::makeLinuxDocFile(string const & fname, bool nice, bool body_only)
// we want this to be true outside previews (for insetexternal)
niceFile = true;
users->showErrorList(_("LinuxDoc"));
}
@ -1594,8 +1591,6 @@ void Buffer::makeDocBookFile(string const & fname, bool nice, bool only_body)
string item_name;
string command_name;
users->resetErrorList();
ParagraphList::iterator par = paragraphs.begin();
ParagraphList::iterator pend = paragraphs.end();
@ -1811,7 +1806,6 @@ void Buffer::makeDocBookFile(string const & fname, bool nice, bool only_body)
// we want this to be true outside previews (for insetexternal)
niceFile = true;
users->showErrorList(_("DocBook"));
}
@ -1937,9 +1931,7 @@ int Buffer::runChktex()
_("Could not run chktex successfully."));
} else if (res > 0) {
// Insert all errors as errors boxes
ErrorList el (*this, terr);
users->setErrorList(el);
users->showErrorList(_("ChkTeX"));
parseErrors(*this, terr);
}
users->owner()->busy(false);

View File

@ -15,9 +15,11 @@
#include "buffer_funcs.h"
#include "bufferlist.h"
#include "buffer.h"
#include "errorlist.h"
#include "gettext.h"
#include "vc-backend.h"
#include "lyxlex.h"
#include "LaTeX.h"
#include "ParagraphList.h"
#include "paragraph.h"
@ -194,3 +196,45 @@ Buffer * newFile(string const & filename, string const & templatename,
return b;
}
void parseErrors(Buffer const & buf, TeXErrors const & terr)
{
TeXErrors::Errors::const_iterator cit = terr.begin();
TeXErrors::Errors::const_iterator end = terr.end();
for (; cit != end; ++cit) {
int par_id = -1;
int posstart = -1;
int const errorrow = cit->error_in_line;
buf.texrow.getIdFromRow(errorrow, par_id, posstart);
int posend = -1;
buf.texrow.getIdFromRow(errorrow + 1, par_id, posend);
buf.parseError(ErrorItem(cit->error_desc,
cit->error_text,
par_id, posstart, posend));
}
}
void parseErrors(Buffer const & buf, ErrorList const & el)
{
ErrorList::const_iterator it = el.begin();
ErrorList::const_iterator end = el.end();
for (; it != end; ++it)
buf.parseError(*it);
}
string const BufferFormat(Buffer const & buffer)
{
if (buffer.isLinuxDoc())
return "linuxdoc";
else if (buffer.isDocBook())
return "docbook";
else if (buffer.isLiterate())
return "literate";
else
return "latex";
}

View File

@ -9,9 +9,14 @@
* Full author contact details are available in file CREDITS
*/
#ifndef BUFFER_FUNCS_H
#define BUFFER_FUNCS_H
#include "LString.h"
class Buffer;
class TeXErrors;
class ErrorList;
/**
* Loads a LyX file \c filename into \c Buffer
@ -24,3 +29,12 @@ bool loadLyXFile(Buffer *, string const & filename);
*/
Buffer * newFile(string const & filename, string const & templatename,
bool isNamed = false);
///return the format of the buffer on a string
string const BufferFormat(Buffer const & buffer);
void parseErrors(Buffer const &, TeXErrors const &);
void parseErrors(Buffer const &, ErrorList const &);
#endif // BUFFER_FUNCS_H

View File

@ -15,6 +15,7 @@
#include "format.h"
#include "lyxrc.h"
#include "buffer.h"
#include "buffer_funcs.h"
#include "bufferview_funcs.h"
#include "errorlist.h"
#include "LaTeX.h"
@ -476,11 +477,8 @@ bool Converters::scanLog(Buffer const * buffer, string const & /*command*/,
TeXErrors terr;
int result = latex.scanLogFile(terr);
if (bv && (result & LaTeX::ERRORS)) {
ErrorList el(*buffer, terr);
bv->setErrorList(el);
bv->showErrorList(_("LaTeX"));
}
if (bv && (result & LaTeX::ERRORS))
parseErrors(*buffer, terr);
return true;
}
@ -507,12 +505,8 @@ bool Converters::runLaTeX(Buffer const * buffer, string const & command,
int result = latex.run(terr,
bv ? &bv->owner()->getLyXFunc() : 0);
if (bv && (result & LaTeX::ERRORS)) {
//show errors
ErrorList el(*buffer, terr);
bv->setErrorList(el);
bv->showErrorList(_("LaTeX"));
}
if (bv && (result & LaTeX::ERRORS))
parseErrors(*buffer, terr);
// check return value from latex.run().
if ((result & LaTeX::NO_LOGFILE)) {

View File

@ -12,7 +12,6 @@
#include "errorlist.h"
#include "buffer.h"
#include "LaTeX.h"
ErrorItem::ErrorItem(string const & error, string const & description,
@ -27,21 +26,3 @@ ErrorItem::ErrorItem()
{}
ErrorList::ErrorList(Buffer const & buf,
TeXErrors const & terr)
{
TeXErrors::Errors::const_iterator cit = terr.begin();
TeXErrors::Errors::const_iterator end = terr.end();
for (; cit != end; ++cit) {
int par_id = -1;
int posstart = -1;
int const errorrow = cit->error_in_line;
buf.texrow.getIdFromRow(errorrow, par_id, posstart);
int posend = -1;
buf.texrow.getIdFromRow(errorrow + 1, par_id, posend);
push_back(ErrorItem(cit->error_desc,
cit->error_text,
par_id, posstart, posend));
}
}

View File

@ -18,7 +18,6 @@
#include <vector>
class Buffer;
class TeXErrors;
/// A class to hold an error item
struct ErrorItem {
@ -36,7 +35,6 @@ class ErrorList : private std::vector<ErrorItem>
{
public:
ErrorList() : std::vector<ErrorItem> () {};
ErrorList(Buffer const & buf, TeXErrors const &);
using std::vector<ErrorItem>::push_back;
using std::vector<ErrorItem>::end;

View File

@ -12,6 +12,7 @@
#include "exporter.h"
#include "buffer.h"
#include "buffer_funcs.h"
#include "lyx_cb.h" //ShowMessage()
#include "support/filetools.h"
#include "lyxrc.h"
@ -26,6 +27,21 @@
using std::vector;
using std::find;
namespace {
vector<string> const Backends(Buffer const * buffer)
{
vector<string> v;
if (buffer->params.getLyXTextClass().isTeXClassAvailable())
v.push_back(BufferFormat(*buffer));
v.push_back("text");
return v;
}
} //namespace anon
bool Exporter::Export(Buffer * buffer, string const & format,
bool put_in_tempdir, string & result_file)
{
@ -142,25 +158,3 @@ Exporter::GetExportableFormats(Buffer const * buffer, bool only_viewable)
return result;
}
string const Exporter::BufferFormat(Buffer const * buffer)
{
if (buffer->isLinuxDoc())
return "linuxdoc";
else if (buffer->isDocBook())
return "docbook";
else if (buffer->isLiterate())
return "literate";
else
return "latex";
}
vector<string> const Exporter::Backends(Buffer const * buffer)
{
vector<string> v;
if (buffer->params.getLyXTextClass().isTeXClassAvailable())
v.push_back(BufferFormat(buffer));
v.push_back("text");
return v;
}

View File

@ -39,11 +39,5 @@ public:
std::vector<Format const *> const
GetExportableFormats(Buffer const * buffer, bool only_viewable);
///
private:
static
string const BufferFormat(Buffer const * buffer);
///
static
std::vector<string> const Backends(Buffer const * buffer);
};
#endif

View File

@ -1,3 +1,8 @@
2003-06-24 Alfredo Braunstein <abraunst@libero.it>
* ControlDocument.C (classApply): removed the call to resetErrorList,
replaced setErrorList by parseErrors
2003-06-21 Alfredo Braunstein <abraunst@libero.it>
* ControlError.[Ch]: removed

View File

@ -19,6 +19,7 @@
#include "lyxfind.h"
#include "buffer.h"
#include "buffer_funcs.h"
#include "errorlist.h"
#include "language.h"
#include "lyx_main.h"
@ -126,8 +127,7 @@ void ControlDocument::classApply()
CutAndPaste::SwitchLayoutsBetweenClasses(old_class, new_class,
lv_.buffer()->paragraphs,
el);
bufferview()->setErrorList(el);
parseErrors(*buffer(), el);
bufferview()->showErrorList(_("Class switch"));
}

View File

@ -1094,25 +1094,31 @@ void LyXFunc::dispatch(FuncRequest const & ev, bool verbose)
case LFUN_UPDATE:
Exporter::Export(owner->buffer(), argument, true);
view()->showErrorList(BufferFormat(*owner->buffer()));
break;
case LFUN_PREVIEW:
Exporter::Preview(owner->buffer(), argument);
view()->showErrorList(BufferFormat(*owner->buffer()));
break;
case LFUN_BUILDPROG:
Exporter::Export(owner->buffer(), "program", true);
view()->showErrorList(_("Build"));
break;
case LFUN_RUNCHKTEX:
owner->buffer()->runChktex();
view()->showErrorList(_("ChkTeX"));
break;
case LFUN_EXPORT:
if (argument == "custom")
owner->getDialogs().showSendto();
else
else {
Exporter::Export(owner->buffer(), argument, false);
view()->showErrorList(BufferFormat(*owner->buffer()));
}
break;
case LFUN_IMPORT:

View File

@ -18,6 +18,7 @@
#include "frontends/LyXView.h"
#include "undo_funcs.h"
#include "buffer.h"
#include "buffer_funcs.h"
#include "bufferparams.h"
#include "errorlist.h"
#include "gettext.h"
@ -1415,7 +1416,7 @@ void LyXText::pasteSelection(size_t sel_index)
cursor.par(), cursor.pos(),
bv()->buffer()->params.textclass,
sel_index, el);
bv()->setErrorList(el);
parseErrors(*bv()->buffer(), el);
bv()->showErrorList(_("Paste"));
redoParagraphs(cursor, endpit);