#include "bufferlist.h"
#include "debug.h"
#include "gettext.h"
+#include "errorlist.h"
#include "iterators.h"
#include "language.h"
#include "lyxcursor.h"
}
-void BufferView::showErrorList()
+void BufferView::resetErrorList()
{
- owner()->getDialogs().show("errorlist");
+ pimpl_->errorlist_.clear();
+}
+
+
+void BufferView::setErrorList(ErrorList const & el)
+{
+ pimpl_->errorlist_ = el;
+}
+
+
+void BufferView::addError(ErrorItem const & ei)
+{
+ pimpl_->errorlist_.push_back(ei);
+
+}
+
+
+void BufferView::showErrorList(string const & action) const
+{
+ if (getErrorList().size()) {
+ string const title = bformat(_("LyX: %1$s errors (%2$s)"), action, buffer()->fileName());
+ owner()->getDialogs().show("errorlist", title);
+ }
+}
+
+
+ErrorList const &
+BufferView::getErrorList() const
+{
+ return pimpl_->errorlist_;
}
class UpdatableInset;
class WordLangTuple;
class Encoding;
+class ErrorList;
+class ErrorItem;
/**
* A buffer view encapsulates a view onto a particular
/// removes all autodeletable insets
bool removeAutoInsets();
+ /// get the stored error list
+ ErrorList const & getErrorList() const;
+ /// clears the stored error list
+ 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();
+ void showErrorList(string const &) const;
/// set the cursor based on the given TeX source row
void setCursorFromRow(int row);
#ifndef BUFFERVIEW_PIMPL_H
#define BUFFERVIEW_PIMPL_H
+#include "errorlist.h"
#include "BufferView.h"
#include "frontends/Timeout.h"
#include "frontends/key_state.h"
/// a function should be executed
bool dispatch(FuncRequest const & ev);
private:
+ /// An error list (replaces the error insets)
+ ErrorList errorlist_;
+
/// track changes for the document
void trackChanges();
+
+2003-05-08 Alfredo Braunstein <abraunst@libero.it>
+
+ * errorlist.[Ch]: added
+ * buffer.C:
+ * BufferView.[Ch]:
+ * BufferView_pimpl.C:
+ * CutAndPaste.[Ch]: get rid of InsetError users, use ErrorList
+ instead
+
2003-05-08 Lars Gullik Bjønnes <larsbj@gullik.net>
* Makefile.am: ensure that lyx is relinked upon changes to the
#include "CutAndPaste.h"
#include "BufferView.h"
#include "buffer.h"
+#include "errorlist.h"
#include "paragraph.h"
#include "ParagraphParameters.h"
#include "lyxtext.h"
pair<PitPosPair, ParagraphList::iterator>
CutAndPaste::pasteSelection(ParagraphList & pars,
ParagraphList::iterator pit, int pos,
- textclass_type tc)
+ textclass_type tc,
+ ErrorList & errorlist)
{
- return pasteSelection(pars, pit, pos, tc, 0);
+ return pasteSelection(pars, pit, pos, tc, 0, errorlist);
}
pair<PitPosPair, ParagraphList::iterator>
CutAndPaste::pasteSelection(ParagraphList & pars,
ParagraphList::iterator pit, int pos,
- textclass_type tc, size_t cut_index)
+ textclass_type tc, size_t cut_index,
+ ErrorList & errorlist)
{
if (!checkPastePossible())
return make_pair(PitPosPair(pit, pos), pit);
// new environment and set also another font if that is required.
// Make sure there is no class difference.
- SwitchLayoutsBetweenClasses(textclass, tc, simple_cut_clone);
+ SwitchLayoutsBetweenClasses(textclass, tc, simple_cut_clone,
+ errorlist);
ParagraphList::iterator tmpbuf = simple_cut_clone.begin();
int depth_delta = pit->params().depth() - tmpbuf->params().depth();
int CutAndPaste::SwitchLayoutsBetweenClasses(textclass_type c1,
textclass_type c2,
- ParagraphList & pars)
+ ParagraphList & pars,
+ ErrorList & errorlist)
{
lyx::Assert(!pars.empty());
"because of class conversion from\n%3$s to %4$s"),
name, par->layout()->name(), tclass1.name(), tclass2.name());
// To warn the user that something had to be done.
- par->insertInset(0, new InsetError(s));
+ errorlist.push_back(ErrorItem("Changed Layout", s,
+ par->id(), 0,
+ par->size()));
}
}
return ret;
class Paragraph;
class BufferParams;
class LyXTextClass;
+class ErrorList;
///
namespace CutAndPaste {
std::pair<PitPosPair, ParagraphList::iterator>
pasteSelection(ParagraphList & pars,
ParagraphList::iterator pit, int pos,
- lyx::textclass_type tc);
+ lyx::textclass_type tc, ErrorList &);
///
std::pair<PitPosPair, ParagraphList::iterator>
pasteSelection(ParagraphList & pars,
ParagraphList::iterator pit, int pos,
lyx::textclass_type tc,
- size_t cuts_index);
+ size_t cuts_indexm, ErrorList &);
///
int nrOfParagraphs();
*/
int SwitchLayoutsBetweenClasses(lyx::textclass_type c1,
lyx::textclass_type c2,
- ParagraphList & par);
+ ParagraphList & par,
+ ErrorList &);
///
bool checkPastePossible();
dimension.h \
encoding.C \
encoding.h \
+ errorlist.C \
+ errorlist.h \
exporter.C \
exporter.h \
gettext.C \
#include "gettext.h"
#include "language.h"
#include "exporter.h"
+#include "errorlist.h"
#include "Lsstream.h"
#include "format.h"
#include "BufferView.h"
string item_name;
vector<string> environment_stack(5);
+ users->resetErrorList();
+
ParagraphList::iterator pit = paragraphs.begin();
ParagraphList::iterator pend = paragraphs.end();
for (; pit != pend; ++pit) {
case LATEX_COMMAND:
if (depth != 0)
- sgmlError(&*pit, 0,
+ sgmlError(pit, 0,
_("Error: Wrong depth for LatexType Command.\n"));
if (!environment_stack[depth].empty()) {
// we want this to be true outside previews (for insetexternal)
niceFile = true;
+
+ users->showErrorList(_("LinuxDoc"));
}
// Print an error message.
-void Buffer::sgmlError(ParagraphList::iterator /*par*/, int /*pos*/,
- string const & /*message*/) const
-{
-#ifdef WITH_WARNINGS
-#warning This is wrong we cannot insert an inset like this!!!
- // I guess this was Jose' so I explain you more or less why this
- // is wrong. This way you insert something in the paragraph and
- // don't tell it to LyXText (row rebreaking and undo handling!!!)
- // I deactivate this code, have a look at BufferView::insertErrors
- // how you should do this correctly! (Jug 20020315)
-#endif
-#if 0
- // insert an error marker in text
- InsetError * new_inset = new InsetError(message);
- par->insertInset(pos, new_inset, LyXFont(LyXFont::ALL_INHERIT,
- params.language));
-#endif
+void Buffer::sgmlError(ParagraphList::iterator pit, int pos,
+ string const & message) const
+{
+ users->addError(ErrorItem(message, string(), pit->id(), pos, pos));
}
string item_name;
string command_name;
+ users->resetErrorList();
+
ParagraphList::iterator par = paragraphs.begin();
ParagraphList::iterator pend = paragraphs.end();
// we want this to be true outside previews (for insetexternal)
niceFile = true;
+ users->showErrorList(_("DocBook"));
}
_("Could not run chktex successfully."));
} else if (res > 0) {
// Insert all errors as errors boxes
- users->showErrorList();
+ ErrorList el (*this, terr);
+ users->setErrorList(el);
+ users->showErrorList(_("ChkTeX"));
}
// if we removed error insets before we ran chktex or if we inserted
--- /dev/null
+/**
+ * \file errorlist.C
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Alfredo Braunstein
+ *
+ * Full author contact details are available in file CREDITS
+ */
+
+#include <config.h>
+
+#include "errorlist.h"
+#include "buffer.h"
+#include "LaTeX.h"
+
+
+ErrorItem::ErrorItem(string const & error, string const & description,
+ int par_id, int pos_start, int pos_end)
+ : error(error), description(description), par_id(par_id),
+ pos_start(pos_start), pos_end(pos_end)
+{}
+
+
+ErrorItem::ErrorItem()
+ : par_id(-1), pos_start(0), pos_end(0)
+{}
+
+
+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));
+ }
+}
--- /dev/null
+// -*- C++ -*-
+
+#ifndef ERRORLIST_H
+#define ERRORLIST_H
+
+/**
+ * \file errorlist.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Alfredo Braunstein
+ *
+ * Full author contact details are available in file CREDITS
+ */
+
+
+#include <vector>
+#include "support/lstrings.h"
+
+class Buffer;
+class TeXErrors;
+
+/// A class to hold an error item
+struct ErrorItem {
+ string error;
+ string description;
+ int par_id;
+ int pos_start;
+ int pos_end;
+ ErrorItem(string const &, string const &,
+ int, int, int);
+ ErrorItem();
+};
+
+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;
+ using std::vector<ErrorItem>::begin;
+ using std::vector<ErrorItem>::operator[];
+ using std::vector<ErrorItem>::size;
+ using std::vector<ErrorItem>::clear;
+ using std::vector<ErrorItem>::empty;
+ using std::vector<ErrorItem>::const_iterator;
+};
+
+
+
+#endif
+2003-05-20 Alfredo Braunstein <abraunst@libero.it>
-2003-05-13 André Pönitz <poenitz@gmx.net>
+ ControlErrorList.[Ch]: small bugs fixed, use ErrorList
+
+2003-05-13 André Pönitz <poenitz@gmx.net>
* ControlForks.[Ch]: use vector<pid_t> instead of strings
#include "lyxfind.h"
#include "buffer.h"
+#include "errorlist.h"
#include "language.h"
#include "lyx_main.h"
#include "lyxtextclass.h"
buffer()->params = *bp_;
lv_.message(_("Converting document to new document class..."));
- int ret = CutAndPaste::SwitchLayoutsBetweenClasses(
- old_class, new_class,
- lv_.buffer()->paragraphs);
- if (!ret)
- return;
+ ErrorList el;
+ CutAndPaste::SwitchLayoutsBetweenClasses(old_class, new_class,
+ lv_.buffer()->paragraphs,
+ el);
- string s;
- if (ret == 1) {
- s = bformat(_("One paragraph could not be converted\n"
- "into the document class %1$s."),
- textclasslist[new_class].name());
- } else {
- s = bformat(_("%1$s paragraphs could not be converted\n"
- "into the document class %2$s."),
- textclasslist[new_class].name());
- }
- Alert::warning(_("Class conversion errors"), s);
+ bufferview()->setErrorList(el);
+ bufferview()->showErrorList(_("Class switch"));
}
#include "ControlErrorList.h"
#include "support/lstrings.h" // tostr
-#include "LaTeX.h"
+#include "errorlist.h"
#include "buffer.h"
#include "BufferView.h"
#include "lyxtext.h"
using std::endl;
-ControlErrorList::ErrorItem::ErrorItem(string const & error,
- string const & description,
- int par_id, int pos_start, int pos_end)
- : error(error), description(description), par_id(par_id),
- pos_start(pos_start), pos_end(pos_end)
-{}
-
-
ControlErrorList::ControlErrorList(Dialog & d)
- : Dialog::Controller(d), current_(0)
+ : Dialog::Controller(d)
{}
void ControlErrorList::clearParams()
-{
- logfilename_.erase();
- clearErrors();
-}
-
-
-std::vector<ControlErrorList::ErrorItem> const &
-ControlErrorList::ErrorList() const
-{
- return ErrorList_;
-}
+{}
-int ControlErrorList::currentItem() const
+ErrorList const &
+ControlErrorList::errorList() const
{
- return current_;
+ return errorlist_;
}
-bool ControlErrorList::initialiseParams(string const &)
+bool ControlErrorList::initialiseParams(string const & name)
{
- logfilename_ = kernel().buffer()->getLogName().second;
- clearErrors();
- fillErrors();
- current_ = 0;
+ errorlist_ = kernel().bufferview()->getErrorList();
+ name_ = name;
return true;
}
-void ControlErrorList::clearErrors()
+string const & ControlErrorList::name()
{
- ErrorList_.clear();
- current_ = 0;
-}
-
-
-void ControlErrorList::fillErrors()
-{
- LaTeX latex("", logfilename_, "");
- TeXErrors terr;
- latex.scanLogFile(terr);
-
- Buffer * const buf = kernel().buffer();
-
- 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);
- ErrorList_.push_back(ErrorItem(cit->error_desc,
- cit->error_text,
- par_id, posstart, posend));
- }
-}
-
-
-string const & ControlErrorList::docName()
-{
- return kernel().buffer()->fileName();
+ return name_;
}
BufferView * const bv = kernel().bufferview();
Buffer * const buf = kernel().buffer();
- current_ = item;
-
- ControlErrorList::ErrorItem const & err = ErrorList_[item];
+ ErrorItem const & err = errorlist_[item];
if (err.par_id == -1)
#ifndef CONTROLERRORLIST_H
#define CONTROLERRORLIST_H
-
+#include "errorlist.h"
#include "Dialog.h"
#include <vector>
class ControlErrorList : public Dialog::Controller {
public:
- /// A class to hold an error item
- struct ErrorItem {
- std::string error;
- std::string description;
- int par_id;
- int pos_start;
- int pos_end;
- ErrorItem(string const &, string const &, int, int, int);
- };
///
ControlErrorList(Dialog & parent);
///
///
virtual void ControlErrorList::dispatchParams() {}
- /// get the current item
- int currentItem() const;
/// goto this error in the parent bv
void goTo(int item);
/// return the parent document name
- string const & docName();
- /// rescan the log file and rebuild the error list
- void fillErrors();
- /// clear everything
- void clearErrors();
+ string const & name();
///
- std::vector<ErrorItem> const & ErrorList() const;
+ ErrorList const & errorList() const;
private:
///
- std::vector<ErrorItem> ErrorList_;
- ///
- string logfilename_;
+ ErrorList errorlist_;
///
- int current_;
+ string name_;
};
#endif // CONTROLERRORLIST_H
+2003-05-20 Alfredo Braunstein <abraunst@libero.it>
+
+ * QErrorList.[Ch]: small bugs fixed.
+
+2003-05-17 Alfredo Braunstein <abraunst@libero.it>
+
+ * QErrorList.C (update_contents): replace TextBrowser::clear() by
+ TextBrowser::setText(QString())
+
2003-05-14 Juergen Spitzmueller <juergen.sp@t-online.de>
* QErrorList.C (select): added a missing toqstr()
#include <config.h>
#include "LyXView.h"
+#include "errorlist.h"
#include "qt_helpers.h"
#include "support/lstrings.h"
#include "debug.h"
typedef QController<ControlErrorList, QView<QErrorListDialog> > base_class;
QErrorList::QErrorList(Dialog & parent)
- : base_class(parent, qt_("LyX: LaTeX error list"))
+ : base_class(parent, "")
{}
void QErrorList::select(int item)
{
controller().goTo(item);
- dialog_->descriptionTB->setText(toqstr(controller().ErrorList()[item].description));
+ dialog_->descriptionTB->setText(toqstr(controller().errorList()[item].description));
}
void QErrorList::update_contents()
{
- string const caption = string(_("LyX: LaTex error List")) + '(' +
- controller().docName() + ')';
-
- dialog_->setCaption(qt_(caption));
+ dialog_->setCaption(toqstr(controller().name()));
dialog_->errorsLB->clear();
- dialog_->descriptionTB->clear();
+ dialog_->descriptionTB->setText(QString());
- std::vector<ControlErrorList::ErrorItem>::const_iterator
- it = controller().ErrorList().begin();
- std::vector<ControlErrorList::ErrorItem>::const_iterator
- end = controller().ErrorList().end();
+ ErrorList::const_iterator it = controller().errorList().begin();
+ ErrorList::const_iterator end = controller().errorList().end();
for(; it != end; ++it) {
- QListBoxItem * error = new QListBoxText(dialog_->errorsLB,
- toqstr(it->error));
+ new QListBoxText(dialog_->errorsLB, toqstr(it->error));
}
- dialog_->errorsLB->setSelected(controller().currentItem(), true);
+ dialog_->errorsLB->setSelected(0, true);
}
virtual void build_dialog();
/// update contents
virtual void update_contents();
- /// run latex
- void runLaTeX();
};
#endif // QERRORLIST_H
{
connect(closePB, SIGNAL(clicked()),
form, SLOT(slotClose()));
+ connect(errorsLB, SIGNAL(returnPressed(QListBoxItem *)),
+ form, SLOT(slotClose()));
}
+2003-05-20 Alfredo Braunstein <abraunst@libero.it>
+
+ * FormErrorList.[Ch]: small bugs fixed
+
2003-05-13 Rob Lahaye <lahaye@snu.ac.kr>
* FormPreferences.C: Change conversions-tooltip.
#include <config.h>
+#include "errorlist.h"
#include "FormErrorList.h"
#include "xformsBC.h"
#include "xforms_helpers.h"
#include "gettext.h"
#include "lyx_forms.h"
-#include <vector>
-
-using std::vector;
-using std::endl;
-
typedef FormController<ControlErrorList, FormView<FD_errorlist> > base_class;
FormErrorList::FormErrorList(Dialog & parent)
- : base_class(parent, _("LaTeX error list"))
+ : base_class(parent, "")
{}
void FormErrorList::build()
{
dialog_.reset(build_errorlist(this));
-
- // Manage the cancel/close button
- bcview().setCancel(dialog_->button_close);
- bcview().addReadOnly(dialog_->browser_errors);
+ setEnabled(dialog_->input_description, false);
}
void FormErrorList::update()
{
+ fl_set_form_title(dialog_->form, controller().name().c_str());
updateContents();
}
ButtonPolicy::SMInput FormErrorList::input(FL_OBJECT * ob, long)
{
- std::vector<ControlErrorList::ErrorItem> const &
- Errors = controller().ErrorList();
-
if (ob == dialog_->browser_errors) {
//xforms return values 1..n
int const choice = int(fl_get_browser(dialog_->browser_errors)) - 1;
- if (0 <= choice && choice < int(Errors.size())) {
- controller().goTo(choice);
- fl_set_input(dialog_->input_description,
- Errors[choice].description.c_str());
- }
+ goTo(choice);
return ButtonPolicy::SMI_VALID;
}
- updateContents();
-
return ButtonPolicy::SMI_VALID;
}
+void FormErrorList::goTo(int where)
+{
+ ErrorList const & errors = controller().errorList();
+
+ if (0 <= where && where < int(errors.size())) {
+ controller().goTo(where);
+ fl_set_input(dialog_->input_description,
+ errors[where].description.c_str());
+ setEnabled(dialog_->input_description, false);
+ }
+}
+
+
void FormErrorList::updateContents()
{
- std::vector<ControlErrorList::ErrorItem> const &
- Errors = controller().ErrorList();
+ fl_clear_browser(dialog_->browser_errors);
- if (Errors.empty()) {
- fl_clear_browser(dialog_->browser_errors);
+ ErrorList const & errors = controller().errorList();
+ if (errors.empty()) {
fl_add_browser_line(dialog_->browser_errors,
_("*** No Lists ***").c_str());
setEnabled(dialog_->browser_errors, false);
return;
}
- unsigned int const topline =
- fl_get_browser_topline(dialog_->browser_errors);
- unsigned int const line = fl_get_browser(dialog_->browser_errors);
-
- fl_clear_browser(dialog_->browser_errors);
setEnabled(dialog_->browser_errors, true);
- std::vector<ControlErrorList::ErrorItem>::const_iterator
- cit = Errors.begin();
- std::vector<ControlErrorList::ErrorItem>::const_iterator
- end = Errors.end();
+ ErrorList::const_iterator cit = errors.begin();
+ ErrorList::const_iterator end = errors.end();
for (; cit != end; ++cit) {
fl_add_browser_line(dialog_->browser_errors,
cit->error.c_str());
}
- fl_set_browser_topline(dialog_->browser_errors, topline);
- fl_select_browser_line(dialog_->browser_errors, line);
+ fl_select_browser_line(dialog_->browser_errors, 1);
+ goTo(1);
}
break;
case LATEX_COMMAND:
- buf->sgmlError(&*pit, 0, _("Error: LatexType Command not allowed here.\n"));
+ buf->sgmlError(pit, 0, _("Error: LatexType Command not allowed here.\n"));
return -1;
break;
#include "undo_funcs.h"
#include "buffer.h"
#include "bufferparams.h"
+#include "errorlist.h"
#include "gettext.h"
#include "BufferView.h"
#include "CutAndPaste.h"
ParagraphList::iterator endpit;
PitPosPair ppp;
+ ErrorList el;
+
boost::tie(ppp, endpit) =
CutAndPaste::pasteSelection(ownerParagraphs(),
cursor.par(), cursor.pos(),
- bv()->buffer()->params.textclass);
+ bv()->buffer()->params.textclass,
+ el);
+ bv()->setErrorList(el);
+ bv()->showErrorList(_("Paste"));
redoParagraphs(cursor, endpit);