]> git.lyx.org Git - features.git/commitdiff
More errorlist adjustements.
authorAlfredo Braunstein <abraunst@lyx.org>
Tue, 24 Jun 2003 20:42:15 +0000 (20:42 +0000)
committerAlfredo Braunstein <abraunst@lyx.org>
Tue, 24 Jun 2003 20:42:15 +0000 (20:42 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7209 a592a061-630c-0410-9148-cb99ea01b6c8

16 files changed:
src/BufferView.C
src/BufferView.h
src/BufferView_pimpl.C
src/ChangeLog
src/buffer.C
src/buffer_funcs.C
src/buffer_funcs.h
src/converter.C
src/errorlist.C
src/errorlist.h
src/exporter.C
src/exporter.h
src/frontends/controllers/ChangeLog
src/frontends/controllers/ControlDocument.C
src/lyxfunc.C
src/text2.C

index 5b0a7330e7748a99c0eb310966b5b2e9b6f0b084..f5e0dcae38f8600f6625b23eb5df8d479c745256 100644 (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();
 }
 
 
index e2031947ff6eaf5e0fb91f34af87eb5ee9388489..3767c584dc79a0f9dd0db34c6d4764cd1603371e 100644 (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
index a2770b274f54b7582f6b68cead2be0715b01d7b8..13cf1d1b980052dd6efeca5c164f9dd9854681d5 100644 (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);
index 23eea8d8a7fbe1b88b561ee59d471bbc0a0c24ec..5f4a525dd1182a4cc6386a68062b41417b2e36f8 100644 (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
index bacbbe69d7eb30239e0af0fd41a2585bbcbb1eda..658cc859c46c22d4c999a79b182cdb9a1ebbed2f 100644 (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);
index 3590c774fb49f99913d914da90de85f4f64fab55..0eaca7c0dd7070f0834e218c729ca0d29f2f2c62 100644 (file)
 #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";
+}
index dc6a440b76fbaa825f686f30cdb6e062a60de3c3..372d99daea1fdf1fbc0cd029c29f2ef71d1187e0 100644 (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
index cd8a7ae10e673916274bdde8cc0433cb67c18da6..c93b39f3f6a77ccee80a9c08d04eaf86e0161d71 100644 (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)) {
index b9a3c341e5a1ddf124e99cf30bceb8c9b4306947..fd62e75548a815e715e84837b765dc0d04f44c4f 100644 (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));
-       }
-}
index 21a87b08ed14880efb3a09ba67a6e32d5015533d..f2a9b2d46787ac1bd603bb07cf58884884dc92b1 100644 (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;
index c84c7cd49d77d89c7fe0d0d5743f593a5478bacc..49e59e194951a16fd7358f2829e612419475412a 100644 (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"
 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;
-}
index f02e8472a00df54c53e2c2b3677fb38cce803de4..12ccebd4da664501533eade75c31bd6140177c64 100644 (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
index 74c224d6cd3f10cab3b2076fcc52ff32baad0e20..93b3f5fcb33c960209e2206df0de622e82a49389 100644 (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
index e30f5eb2160e1956a98bf9ad94d3ed92e992ad8a..29f11a19dd07e261ca451ecdadcb504fd63bc96d 100644 (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"));
 }
 
index 576d918963acbdcd4b81dca3f74ed21ff9712c61..6799685caf4d0baf867b5a07ab1ba018603de3d8 100644 (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:
index 311f6e345835f2eb3ba915c0cfaf0a72c0ba6772..94ce377a9f581d99c539ee41442d3ddc5b0a8c23 100644 (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);